Hide Perks from Plugins Page

Experimental Snippet 🧪

So you’ve installed dozens of perks, each one more useful than the last, but you find that you’d rather not see them all listed individually on your Plugins page. No problem! This snippet will hide perks from your Plugins page.

Note: Perks will still show up on your Updates page.

Code

Filename: gp-hide-perks-from-plugins-page.php

<?php
/**
 * Gravity Perks // Hide Perks from Plugins Page
 * https://gravitywiz.com/documentation/
 *
 * Experimental Snippet 🧪
 *
 * So you've installed dozens of perks, each one more useful than the last, but you find that you'd rather not see them all
 * listed individually on your Plugins page. No problem! This snippet will hide perks from your Plugins page.
 *
 * Note: Perks will still show up on your Updates page.
 */
add_filter( 'all_plugins', function( $plugins ) {

	if ( ! is_callable( 'get_current_screen' ) || get_current_screen()->id !== 'plugins' ) {
		return $plugins;
	}

	$filtered_plugins = array();

	foreach ( $plugins as $slug => $plugin ) {
		if ( ! wp_validate_boolean( rgar( $plugin, 'Perk' ) ) ) {
			$filtered_plugins[ $slug ] = $plugin;
		}
	}

	return $filtered_plugins;
} );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.