WPSEO_Addon_Manager::get_slug_by_plugin_file()protectedYoast 1.0

Retrieves the addon slug by given plugin file path.

Метод класса: WPSEO_Addon_Manager{}

Хуков нет.

Возвращает

Строку. The slug when found or empty string when not.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_slug_by_plugin_file( $plugin_file );
$plugin_file(строка) (обязательный)
The file path to the plugin.

Код WPSEO_Addon_Manager::get_slug_by_plugin_file() Yoast 22.4

protected function get_slug_by_plugin_file( $plugin_file ) {
	$addons = self::$addons;

	// Yoast SEO Free isn't an addon, but we needed it in Premium to fetch translations.
	if ( YoastSEO()->helpers->product->is_premium() ) {
		$addons['wp-seo.php'] = self::FREE_SLUG;
	}

	foreach ( $addons as $addon => $addon_slug ) {
		if ( strpos( $plugin_file, $addon ) !== false ) {
			return $addon_slug;
		}
	}

	return '';
}