display name and version constant. * * @since 1.0.0 * * @var array */ const KNOWN = array( 'yoast' => array( 'name' => 'Yoast SEO', 'constant' => 'WPSEO_VERSION', ), 'rank_math' => array( 'name' => 'Rank Math SEO', 'constant' => 'RANK_MATH_VERSION', ), 'aioseo' => array( 'name' => 'All in One SEO', 'constant' => 'AIOSEO_VERSION', ), 'seopress' => array( 'name' => 'SEOPress', 'constant' => 'SEOPRESS_VERSION', ), ); /** * Callable that tells whether a constant is defined. Replaceable for tests. * * @since 1.0.0 * * @var callable */ private $is_defined; /** * Constructor. * * @since 1.0.0 * * @param callable|null $is_defined Optional replacement for `defined()`. */ public function __construct( ?callable $is_defined = null ) { $this->is_defined = null !== $is_defined ? $is_defined : 'defined'; } /** * The conflicting plugins that are active. * * @since 1.0.0 * * @return array Plugin id => display name. */ public function detect(): array { $found = array(); foreach ( self::KNOWN as $id => $plugin ) { if ( call_user_func( $this->is_defined, $plugin['constant'] ) ) { $found[ $id ] = $plugin['name']; } } /** * Filters the detected conflicting SEO plugins. * * @since 1.0.0 * * @param array $found Plugin id => display name. */ return apply_filters( 'elevenrank_detected_seo_plugins', $found ); } }