If there's no child theme available, I use a custom plugin for some minor changes. The following code for hiding update notifications etc. has always worked perfectly. However, if I switch from PHP 7.0 to 7.1 it breaks the site. This is true even in my test installation with no other plugins activated and the latest Twenty17 theme. I can't figure out the problem. Any ideas? Thank you!

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() {
add_action( 'init', 'master' );

This is what the WP error log says:

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
  • You must be getting an error somewhere. What does it say? Check the error log if it doesn't appear on screen. May 25 '18 at 11:43
  • In your context have the var $plugins no handover. The hook init haven't any parameter and is not clear how to set the var $plugins. In php7 need the parameter in the function a default value there you can set in the function or you add them on the call of the function.
    – bueltge
    May 25 '18 at 13:10

I changed the master function to:

function master() {

Now it works. Is this the right way to to it?

  • You could removw the $plugins argument from your function as well inside the master function, hide_plugins() as you are not using it at all. Php7 is more strict, you could also pass anything and it would work
    – funkysoul
    May 27 '18 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.