WC_WCCOM_Site_Installer::get_wporg_plugin_main_file
Get WP.org plugin's main file.
Method of the class: WC_WCCOM_Site_Installer{}
No Hooks.
Returns
true|false|String.
Usage
$result = WC_WCCOM_Site_Installer::get_wporg_plugin_main_file( $dir );
- $dir(string) (required)
- Directory name of the plugin.
Changelog
| Since 3.7.0 | Introduced. |
WC_WCCOM_Site_Installer::get_wporg_plugin_main_file() WC WCCOM Site Installer::get wporg plugin main file code WC 10.5.0
public static function get_wporg_plugin_main_file( $dir ) {
// Ensure that exact dir name is used.
$dir = trailingslashit( $dir );
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$plugins = get_plugins();
foreach ( $plugins as $path => $plugin ) {
if ( 0 === strpos( $path, $dir ) ) {
return $path;
}
}
return false;
}