如果没有可用的子主题,我会使用自定义插件进行一些小的更改。以下用于隐藏更新通知等的代码始终运行良好。然而,如果我从PHP 7.0切换到7.1,就会破坏网站。即使在没有激活其他插件和最新的2017主题的情况下,我的测试安装也是如此。我想不出这个问题。有什么想法吗?非常感谢。
function remove_core_updates() {
global $wp_version;return(object) array(\'last_checked\'=> time(),\'version_checked\'=> $wp_version,);
}
function nstrm_remove_admin_submenus() {
remove_submenu_page( \'options-general.php\', \'mainwp_child_tab\' );
}
function hide_plugins($plugins) {
if(is_plugin_active(\'mainwp-child/mainwp-child.php\')) {
unset( $plugins[\'mainwp-child/mainwp-child.php\'] );
}
return $plugins;
}
function updates() {
$current_user = wp_get_current_user();
if (\'user-x\' != $current_user->user_login) {
add_filter(\'pre_site_transient_update_core\', \'remove_core_updates\');
add_filter(\'pre_site_transient_update_plugins\', \'remove_core_updates\');
add_filter(\'pre_site_transient_update_themes\', \'remove_core_updates\');
add_filter( \'all_plugins\', \'hide_plugins\');
add_action( \'admin_menu\', \'nstrm_remove_admin_submenus\', 999 );
}
}
function master() {
updates();
remove_core_updates();
hide_plugins();
nstrm_remove_admin_submenus();
}
add_action( \'init\', \'master\' );
WP错误日志是这样说的:
PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function hide_plugins(), 0 passed in /www/htdocs/w0131417/wp-content/plugins/myplugins2.php on line 74 and exactly 1 expected in /www/htdocs/w0131417/wp-content/plugins/myplugins2.php:55
Stack trace:
#0 /www/htdocs/w0131417/wp-content/plugins/myplugins2.php(74): hide_plugins()
#1 /www/htdocs/w0131417/wp-includes/class-wp-hook.php(286): master(\'\')
#2 /www/htdocs/w0131417/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)
#3 /www/htdocs/w0131417/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
#4 /www/htdocs/w0131417/wp-settings.php(450): do_action(\'init\')
#5 /www/htdocs/w0131417/wp-config.php(61): require_once(\'/www/htdocs/w01...\')
#6 /www/htdocs/w0131417/wp-load.php(37): require_once(\'/www/htdocs/w01...\')
#7 /www/htdocs/w0131417/wp-blog-header.php(13): require_once(\'/www/htdocs/w01...\')
#8 /www/htdocs/w0131417/index.php(17): require(\'/www/htdocs/w01...\')
#9 {main}
thrown in /www/htdocs/w0131417/wp-content/plugins/myplugins2.php on line 55