WC_WCCOM_Site_Installer::get_wporg_plugin_main_file()public staticWC 3.7.0

Get WP.org plugin's main file.

Method of the class: WC_WCCOM_Site_Installer{}

No Hooks.

Return

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() code WC 9.4.2

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;
}