Provider
Class Provider
Source
File: src/Events/Integrations/Plugins/WordPress_SEO/Provider.php
class Provider extends Integration_Abstract {
use Plugin_Integration;
/**
* @inheritDoc
*/
public static function get_slug(): string {
return 'wordpress-seo';
}
/**
* @inheritDoc
*/
public function load_conditionals(): bool {
return function_exists( 'YoastSEO' )
&& defined( 'WPSEO_VERSION' )
&& version_compare( WPSEO_VERSION, '19.0', '>=' );
}
/**
* @inheritDoc
*/
protected function load(): void {
add_filter( 'wpseo_schema_graph_pieces', [ $this, 'add_graph_pieces' ], 11, 2 );
add_action( 'init', [ $this, 'remove_yoast_legacy_integration' ], 20 );
}
/**
* Prevent the old Yoast plugin integration with TEC from loading.
*
* @since 6.0.4
*
* @return void
*/
public function remove_yoast_legacy_integration(): void {
$tec_integration = YoastSEO()->classes->get( 'Yoast\\WP\\SEO\\Integrations\\Third_Party\\The_Events_Calendar' );
if ( ! empty( $tec_integration ) ) {
remove_filter( 'wpseo_schema_graph_pieces', [ $tec_integration, 'add_graph_pieces' ], 11 );
}
}
/**
* Adds the events graph pieces to the schema collector.
*
* @param array $pieces The current graph pieces.
* @param string $context The current context.
*
* @return array Extended graph pieces.
*/
public function add_graph_pieces( $pieces, $context ) {
if ( is_admin() ) {
return $pieces;
}
if ( \WPSEO_Options::get( 'opengraph' ) !== true ) {
return $pieces;
}
$pieces[] = new Events_Schema( $context );
return $pieces;
}
}
Changelog
| Version | Description |
|---|---|
| 6.0.4 | Introduced. |
Methods
- add_graph_pieces — Adds the events graph pieces to the schema collector.
- get_slug
- load_conditionals
- remove_yoast_legacy_integration — Prevent the old Yoast plugin integration with TEC from loading.
- version_compare — Checks the version of Yoast SEO against a given Version.