| 1 |
<?php |
| 2 |
|
| 3 |
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure. |
| 4 |
namespace Yoast\WP\SEO\Plugins_Tab\Domain; |
| 5 |
|
| 6 |
/** |
| 7 |
* Detects whether a plugin is a Yoast plugin by checking its author information. |
| 8 |
*/ |
| 9 |
class Plugin_Detector { |
| 10 |
|
| 11 |
/** |
| 12 |
* The string to look for in the plugin's AuthorName field. |
| 13 |
* |
| 14 |
* @var string |
| 15 |
*/ |
| 16 |
public const AUTHOR_IDENTIFIER = 'Team Yoast'; |
| 17 |
|
| 18 |
/** |
| 19 |
* The minimum number of Yoast plugins required to show the tab. |
| 20 |
* |
| 21 |
* @var int |
| 22 |
*/ |
| 23 |
public const MINIMUM_FOR_TAB = 2; |
| 24 |
|
| 25 |
/** |
| 26 |
* Checks whether a plugin is a Yoast plugin based on its author data. |
| 27 |
* |
| 28 |
* @param array<string, string> $plugin_data The plugin data array. |
| 29 |
* |
| 30 |
* @return bool Whether the plugin is a Yoast plugin. |
| 31 |
*/ |
| 32 |
public function is_yoast_plugin( array $plugin_data ): bool { |
| 33 |
if ( ! isset( $plugin_data['AuthorName'] ) || ! \is_string( $plugin_data['AuthorName'] ) ) { |
| 34 |
return false; |
| 35 |
} |
| 36 |
|
| 37 |
return \str_contains( $plugin_data['AuthorName'], self::AUTHOR_IDENTIFIER ); |
| 38 |
} |
| 39 |
} |
| 40 |
|