How do I hide the plugin meta line on the plugin page.

I need some help removing or hiding the meta line for the individual plugins on the plugin page. This is the line for each plugin that displays the version number, author and link to the plugin's website.

This to get control over the plugin page on multisite subsites. I'm using Supporter to offer plugins to my users, but I want to clean up what is displayed to them. In a perfect world, the option employed would still display the meta line on the main site, but not on any of the subsites.

Here's a screenshot of the plugin page of our testing subsite. As you can imagine, it would look much better without the meta line:

  • Saunt Valerian
    • The Bug Hunter

    That's the trouble, I've already investigated the Multisite Plugin Manager and found that it wasn't compatible with Supporter (and I am using Supporter). But since MPM was developed by Aaron, I thought I'd ask here for details on how to hide.

    Though I am going to dig into the code of MPM (but I'm not a coder so I'll probably break something) and see if I can extract the snippet that hides the meta line and then place it in as a mu-plugin. Doing it that way is probably a bad idea though.....

  • Saunt Valerian
    • The Bug Hunter

    Right, I pulled this out of Aaron's MPM plugin and threw it all by itself into a mu-plugin (hide-plugin-meta-line.php). Didn't seem to have any effect at all... any thoughts? Maybe it doesn't work with WP 3.1.2?

    <?php
    
    //removes the meta information for normal admins
    	function remove_plugin_meta($plugin_meta, $plugin_file) {
    	  if ( is_super_admin() ) {
    			return $plugin_meta;
    		} else {
        	remove_all_actions("after_plugin_row_$plugin_file");
    		  return array();
    		}
    	}
    
      function remove_plugin_update_row() {
    	  if ( !is_super_admin() ) {
        	remove_all_actions('after_plugin_row');
    		}
    	}
    ?>
  • DavidM
    • DEV MAN’s Mascot

    Hi Saunt,

    I believe you'll only need the following 2 other lines added to that to complete the plugin and actually, mu-plugins really would be the perfect place to put the file, I think.

    add_filter( 'plugin_row_meta' , array( &$this, 'remove_plugin_meta' ), 10, 2 );
    add_action( 'admin_init', array( &$this, 'remove_plugin_update_row' ) );

    Cheers,
    David

  • Saunt Valerian
    • The Bug Hunter

    That blew everything up, maybe I put it in wrong:

    Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'Array' was given in /home/teatrade/public_html/wp-includes/plugin.php on line 166

    Warning: implode() [function.implode]: Invalid arguments passed in /home/teatrade/public_html/wp-admin/includes/class-wp-plugins-list-table.php on line 436

    Here's what I have now

    <?php
    //removes the meta information for normal admins
    	function remove_plugin_meta($plugin_meta, $plugin_file) {
    	  if ( is_super_admin() ) {
    			return $plugin_meta;
    		} else {
        	remove_all_actions("after_plugin_row_$plugin_file");
    		  return array();
    		}
    	}
    
      function remove_plugin_update_row() {
    	  if ( !is_super_admin() ) {
        	remove_all_actions('after_plugin_row');
    		}
    	}
    
    add_filter( 'plugin_row_meta' , array( &$this, 'remove_plugin_meta' ), 10, 2 );
    add_action( 'admin_init', array( &$this, 'remove_plugin_update_row' ) );
    ?>
  • Mason
    • DEV MAN’s Sidekick

    Hiya,

    Actually, the code David provided is correct. Dropping this into a file in mu-plugins will work:

    <?php
    add_filter( 'plugin_row_meta' , array( &$this, 'remove_plugin_meta' ), 10, 2 );
    add_action( 'admin_init', array( &$this, 'remove_plugin_update_row' ) );
    ?>

    Can you verify that you used exactly that? Also, what version of WordPress are you running?

    Thanks!

  • Saunt Valerian
    • The Bug Hunter

    Mason,

    I put in just the code that you provided directly above in to a mu-plugin and received these errors. The first one was displayed in the header, and the other two were displayed in repeatedly in place of the plugin meta line:

    Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'Array' was given in /home/teatrade/public_html/wp-includes/plugin.php on line 395

    Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'Array' was given in /home/teatrade/public_html/wp-includes/plugin.php on line 166

    Warning: implode() [function.implode]: Invalid arguments passed in /home/teatrade/public_html/wp-admin/includes/class-wp-plugins-list-table.php on line 436

    I'm running WP 3.1.3

  • Mason
    • DEV MAN’s Sidekick

    Hiya Saunt,

    Can you try loading a fresh copy of your wp-includes folder via ftp? Just download a new copy from WordPress, delete the old wp-includes directory and upload a new one.

    You definitely shouldn't be getting this error if everything's running alright. I just ran the code to be sure on a dev install (which is 3.2 but I don't believe that'll make a difference for this).

  • Saunt Valerian
    • The Bug Hunter

    Maybe it is a server thing. I added this as a mu-plugin to my multisite test install (it's a fresh installation of 3.2) and I received the same set of errors.

    Appears in the header:
    Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'Array' was given in /home/teatrade/public_html/testbase/wp-includes/plugin.php on line 405

    Appears on the plugin page for each plugin:
    Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'Array' was given in /home/teatrade/public_html/testbase/wp-includes/plugin.php on line 170

    Warning: implode() [function.implode]: Invalid arguments passed in /home/teatrade/public_html/testbase/wp-admin/includes/class-wp-plugins-list-table.php on line 440

  • Mason
    • DEV MAN’s Sidekick

    Hiya,

    So it works for you but you have PHP warnings? Or it doesn't work at all.

    If it's working, can we also verify whether you have WPDEBUG defined as true in your wp-config? Still trying to come up with why this is happening on your install, but not on ours.

    Thanks!

  • Saunt Valerian
    • The Bug Hunter

    I suppose that you could technically say that it is working since the meta lines are gone, but they are replaced with those warnings. I do have debug set to false.

    I did it on the test install since I thought it might be a plugin conflict, but I turned all the plugins off (including buddypress) and I still received the error/warnings.

  • Mason
    • DEV MAN’s Sidekick

    Ah, sorry, we need to pull out the function's namespace as it's no longer associated with any plugin.

    Give this a shot:

    <?php
    function remove_plugin_meta($plugin_meta, $plugin_file) {
    	remove_all_actions("after_plugin_row_$plugin_file");
    	  return array();
    }
    
      function remove_plugin_update_row() {
        	remove_all_actions('after_plugin_row');
    }
    
    	add_filter( 'plugin_row_meta' , 'remove_plugin_meta', 10, 2 );
    	add_action( 'admin_init', 'remove_plugin_update_row', 1 );
    ?>

    Thanks!

  • Saunt Valerian
    • The Bug Hunter

    @mason - that work beautifully, but it doesn't isolate the main blog/network control area. Having the meta line visible on the main blog or network area plugin pages is useful since the meta has useful information for the admin (ability to check changelogs, updating).

    Of course, Aaron had to spoil all the hard work you did on this, by chiming in that he wrote it into Supporter! :wink:

    I'm going to upgrade my supporter when it comes out of Beta, thank you for all of this!

  • Mason
    • DEV MAN’s Sidekick

    Hiya Saunt Valerian,

    No worries. FYI, the following will show the plugin meta to super admins only:

    <?php
    
    function remove_plugin_meta($plugin_meta, $plugin_file) {
      if ( is_super_admin() ) {
    		return $plugin_meta;
    	} else {
    	remove_all_actions("after_plugin_row_$plugin_file");
    	  return array();
    	}
    }
    
    function remove_plugin_update_row() {
      if ( !is_super_admin() ) {
    	remove_all_actions('after_plugin_row');
    	}
    }
    
    	add_filter( 'plugin_row_meta' , 'remove_plugin_meta', 10, 2 );
    	add_action( 'admin_init', 'remove_plugin_update_row' );
    
    ?>

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.