Я создаю супер базовый одностраничный шаблон WordPress со всеми плагинами, отключенными с помощью нескольких фильтров.
Я получаю сообщение об ошибке, когда пытаюсь загрузить страницу, потому что в файле functions.php он извлекает несколько функций для набора потенциально загружаемых плагинов, выполненных предыдущим разработчиком. Поскольку они отключены, обработка останавливается с фатальной ошибкой.
Вместо того, чтобы заменять каждое место проверкой function_exists, можно ли пропустить загрузку файла functions.php, если он находится в единственном шаблоне страницы, который я использую?

Быстрое решение - переименовать / сделать резервную копию предыдущего файла functions.php разработчиков, а затем создать новый пустой файл functions.php. Например, используя терминал оболочки bash:
mv /wp-content/themes/your-theme-here/functions.php /wp-content/themes/your-theme-here/functions.php.bkup
touch /wp-content/themes/your-theme-here/functions.php
mv - это команда перемещения / переименования, первый аргумент - это файл, который нужно переместить (переименовать), второй - куда его переместить (переименовать).
touch - предоставляет способ создания нового файла.
Затем вы можете заполнить этот новый файл functions.php любыми функциями, которые еще требуются вашему проекту.
Сложность в том, что wp-settings.php всегда загружает файл function.php шаблона.
Однако, поскольку файл functions.php загружается почти в самом конце обработки WordPress, я думаю, вы можете использовать действие setup_theme, чтобы взять на себя обработку WordPress и выполнить оставшуюся часть обработки WordPress как wp-blog-header. php, кроме пропуска загрузки functions.php.
add_action( 'setup_theme', function() {
if ( $use_my_singlular_page_template ) {
// Define the template related constants.
wp_templating_constants( );
// Load the default text localization domain.
load_default_textdomain();
$locale = get_locale();
$locale_file = WP_LANG_DIR . "/$locale.php";
if ( ( 0 === validate_file( $locale ) ) && is_readable( $locale_file ) )
require( $locale_file );
unset( $locale_file );
/**
* WordPress Locale object for loading locale domain date and various strings.
* @global WP_Locale $wp_locale
* @since 2.1.0
*/
$GLOBALS['wp_locale'] = new WP_Locale();
/**
* WordPress Locale Switcher object for switching locales.
*
* @since 4.7.0
*
* @global WP_Locale_Switcher $wp_locale_switcher WordPress locale switcher object.
*/
$GLOBALS['wp_locale_switcher'] = new WP_Locale_Switcher();
$GLOBALS['wp_locale_switcher']->init();
/*
* don't load theme's function.php
// Load the functions for the active theme, for both parent and child theme if applicable.
if ( ! wp_installing() || 'wp-activate.php' === $pagenow ) {
if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists( STYLESHEETPATH . '/functions.php' ) )
include( STYLESHEETPATH . '/functions.php' );
if ( file_exists( TEMPLATEPATH . '/functions.php' ) )
include( TEMPLATEPATH . '/functions.php' );
}
*/
/**
* Fires after the theme is loaded.
*
* @since 3.0.0
*/
do_action( 'after_setup_theme' );
// Set up current user.
$GLOBALS['wp']->init();
/**
* Fires after WordPress has finished loading but before any headers are sent.
*
* Most of WP is loaded at this stage, and the user is authenticated. WP continues
* to load on the {@see 'init'} hook that follows (e.g. widgets), and many plugins instantiate
* themselves on it for all sorts of reasons (e.g. they need a user, a taxonomy, etc.).
*
* If you wish to plug an action once WP is loaded, use the {@see 'wp_loaded'} hook below.
*
* @since 1.5.0
*/
do_action( 'init' );
// Check site status
if ( is_multisite() ) {
if ( true !== ( $file = ms_site_check() ) ) {
require( $file );
die();
}
unset($file);
}
/**
* This hook is fired once WP, all plugins, and the theme are fully loaded and instantiated.
*
* Ajax requests should use wp-admin/admin-ajax.php. admin-ajax.php can handle requests for
* users not logged in.
*
* @link https://codex.wordpress.org/AJAX_in_Plugins
*
* @since 3.0.0
*/
do_action( 'wp_loaded' );
// do the remaining parts of wp-blog-header.php
// Set up the WordPress query.
wp();
// Load the theme template.
require_once( ABSPATH . WPINC . '/template-loader.php' );
// everything is done; must not return!
exit();
}
} );
Это отвечает на мой вопрос, но не решает мою проблему. Удалив functions.php, я отключил пользовательский тип сообщения, который вызвал другие проблемы. В итоге мне пришлось разрешить нескольким плагинам использовать несколько строк remove_action, чтобы удалить то, что добавлял плагин. В общем, теперь он работает так, как ожидалось, даже если он не совсем идеален. Спасибо!