Using WordPress ‘plugin_install_description’ PHP filter

The plugin_install_description WordPress PHP filter modifies the plugin card description on the Add Plugins screen.

Usage

add_filter('plugin_install_description', 'modify_plugin_description', 10, 2);
function modify_plugin_description($description, $plugin) {
  // your custom code here
  return $description;
}

Parameters

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

More information

See WordPress Developer Resources: plugin_install_description

Examples

Shorten plugin descriptions

Shorten the plugin descriptions to 100 characters.

add_filter('plugin_install_description', 'shorten_plugin_description', 10, 2);
function shorten_plugin_description($description, $plugin) {
  return substr($description, 0, 100) . '...';
}

Add a prefix to plugin descriptions

Add a custom prefix to all plugin descriptions.

add_filter('plugin_install_description', 'add_prefix_to_plugin_description', 10, 2);
function add_prefix_to_plugin_description($description, $plugin) {
  return 'Custom Prefix: ' . $description;
}

Highlight specific keywords in plugin descriptions

Highlight the keywords “WordPress” and “plugin” in plugin descriptions.

add_filter('plugin_install_description', 'highlight_keywords_in_plugin_description', 10, 2);
function highlight_keywords_in_plugin_description($description, $plugin) {
  $keywords = ['WordPress', 'plugin'];
  foreach ($keywords as $keyword) {
    $description = str_replace($keyword, '<strong>' . $keyword . '</strong>', $description);
  }
  return $description;
}

Remove specific keywords from plugin descriptions

Remove the keywords “WordPress” and “plugin” from plugin descriptions.

add_filter('plugin_install_description', 'remove_keywords_from_plugin_description', 10, 2);
function remove_keywords_from_plugin_description($description, $plugin) {
  $keywords = ['WordPress', 'plugin'];
  return str_replace($keywords, '', $description);
}

Append the plugin author to the description

Add the plugin author’s name to the description.

add_filter('plugin_install_description', 'add_author_to_plugin_description', 10, 2);
function add_author_to_plugin_description($description, $plugin) {
  $author = $plugin['author'];
  return $description . ' (Author: ' . $author . ')';
}