Exciting News! Flipper Code is now WePlugins! Same commitment to excellence, brand new identity.

How to use plugin_install_description filter in WordPress

Sandeep Kumar Mishra
Sandeep Kumar Mishra
November 7, 2022
5 minutes read

Let’s talk about the plugin_install_description filter. This hook is super useful when you want to tweak the plugin card description on the Add Plugins screen. You can use it to customize how plugin descriptions appear to your users.

Before diving in, you need to register the hook using add_filter. This can be done in your theme’s functions.php file or, even better, in a custom WordPress plugin. At WePlugins, we always recommend creating a custom plugin to avoid issues when updating your theme.

We’ve got a function called modify_plugin_install_description_defaults which takes two parameters. This function is registered using add_filter. The first parameter is the hook name plugin_install_description. The second is the function name modify_plugin_install_description_defaults. The third parameter is the priority of the hook, and the last parameter is the number of arguments.

Sometimes, you might need to remove a registered hook, and for that, you can use remove_filter.

Parameters

Below are the two parameters required to use this hook:

  • $description: (string) Plugin card description.
  • $plugin: (array) An array of plugin data. See plugins_api() for the list of possible values.

Live Example

Here’s a basic example of how you can use this hook:

Example 1: Modifying Plugin Description

In this example, we’ll modify the plugin description.

	function weplugins_modify_plugin_install_description_defaults($description, $plugin) { 
		// Update the $description variable as needed.
		return $description; 
	}
	// Add the filter
	add_filter("plugin_install_description", "weplugins_modify_plugin_install_description_defaults", 10, 2);
	

Example 2: Conditional Modification

Here, we’ll conditionally modify the plugin description based on specific criteria:

	function weplugins_modify_plugin_install_description_conditionally($description, $plugin) {
		if ($plugin['slug'] == 'specific-plugin') {
			$description .= ' - This is a special plugin!';
		}
		return $description;
	}
	add_filter("plugin_install_description", "weplugins_modify_plugin_install_description_conditionally", 10, 2);
	

Example 3: Removing the Hook

To remove a hook callback, use the example below:

	remove_filter("plugin_install_description", "weplugins_modify_plugin_install_description_defaults", 10, 2);
	

Make sure to provide the same callback function name, priority, and number of arguments while removing the hook callback.

Access Premium WordPress Plugins

Contact Us

If you need any customization or run into trouble using this hook, feel free to reach out to us. Our team at WePlugins would be happy to assist you. Contact Us

Sandeep Kumar Mishra

Sandeep Kumar Mishra

Sandeep Kumar Mishra writes about WordPress and Artificial Intelligence, offering tips and guides to help you master your website and stay updated with the latest tech trends.

Explore the latest in WordPress

Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.