Return the details for a single plugin based on the extension data from an error.
Parameters
$extensionarrayrequired- The extension that caused the error.
slugstringThe extension slug. The directory of the plugin or theme.typestringThe extension type. Either'plugin'or'theme'.
Source
private function get_plugin( $extension ) {
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$plugins = get_plugins();
// Assume plugin main file name first since it is a common convention.
if ( isset( $plugins[ "{$extension['slug']}/{$extension['slug']}.php" ] ) ) {
return $plugins[ "{$extension['slug']}/{$extension['slug']}.php" ];
} else {
foreach ( $plugins as $file => $plugin_data ) {
if ( str_starts_with( $file, "{$extension['slug']}/" ) || $file === $extension['slug'] ) {
return $plugin_data;
}
}
}
return false;
}
Changelog
| Version | Description |
|---|---|
| 5.3.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.