monsterinsights_get_plugin_basename_from_slug

Retrieve the plugin basename from the plugin slug.

Description

(string) monsterinsights_get_plugin_basename_from_slug( (string) $slug ); 

Returns (string)

The plugin basename if found, else the plugin slug.

Parameters (1)

0. $slug (string)
The plugin slug.

Usage

  1. if ( !function_exists( 'monsterinsights_get_plugin_basename_from_slug' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-analytics-for-wordpress-by-monsterinsights/includes/admin/pages/addons.php'; 
  3.  
  4. // The plugin slug. 
  5. $slug = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = monsterinsights_get_plugin_basename_from_slug($slug); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/admin/pages/addons.php  
  1. function monsterinsights_get_plugin_basename_from_slug( $slug ) { 
  2. $keys = array_keys( get_plugins() ); 
  3.  
  4. foreach ( $keys as $key ) { 
  5. if ( preg_match( '|^' . $slug . '|', $key ) ) { 
  6. return $key; 
  7.  
  8. return $slug; 
  9.