PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.5
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.5
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
← All changes | src/integrations/third-party/web-stories.php +35 -1 18.2 → 28.5 View file →
@@ -2,12 +2,14 @@
2 2
3 3 namespace Yoast\WP\SEO\Integrations\Third_Party;
4 4
5 5 use Yoast\WP\SEO\Conditionals\Web_Stories_Conditional;
6 +use Yoast\WP\SEO\Context\Meta_Tags_Context;
6 7 use Yoast\WP\SEO\Integrations\Front_End_Integration;
7 8 use Yoast\WP\SEO\Integrations\Integration_Interface;
8 9 use Yoast\WP\SEO\Models\Indexable;
9 10 use Yoast\WP\SEO\Presentations\Indexable_Presentation;
11 +use Yoast\WP\SEO\Presenters\Title_Presenter;
10 12
11 13 /**
12 14 * Web Stories integration.
13 15 */
@@ -45,9 +47,14 @@
45 47 *
46 48 * @return void
47 49 */
48 50 public function register_hooks() {
49 - \add_action( 'web_stories_enable_metadata', '__return_false' );
51 + // Disable default title and meta description output in the Web Stories plugin,
52 + // and force-add title & meta description presenter, regardless of theme support.
53 + \add_filter( 'web_stories_enable_document_title', '__return_false' );
54 + \add_filter( 'web_stories_enable_metadata', '__return_false' );
55 + \add_filter( 'wpseo_frontend_presenters', [ $this, 'filter_frontend_presenters' ], 10, 2 );
56 +
50 57 \add_action( 'web_stories_enable_schemaorg_metadata', '__return_false' );
51 58 \add_action( 'web_stories_enable_open_graph_metadata', '__return_false' );
52 59 \add_action( 'web_stories_enable_twitter_metadata', '__return_false' );
53 60
@@ -53,8 +60,35 @@
53 60
54 61 \add_action( 'web_stories_story_head', [ $this, 'web_stories_story_head' ], 1 );
55 62 \add_filter( 'wpseo_schema_article_type', [ $this, 'filter_schema_article_type' ], 10, 2 );
56 63 \add_filter( 'wpseo_metadesc', [ $this, 'filter_meta_description' ], 10, 2 );
64 + }
65 +
66 + /**
67 + * Filter 'wpseo_frontend_presenters' - Allow filtering the presenter instances in or out of the request.
68 + *
69 + * @param array $presenters The presenters.
70 + * @param Meta_Tags_Context $context The meta tags context for the current page.
71 + * @return array Filtered presenters.
72 + */
73 + public function filter_frontend_presenters( $presenters, $context ) {
74 + if ( $context->indexable->object_sub_type !== 'web-story' ) {
75 + return $presenters;
76 + }
77 +
78 + $has_title_presenter = false;
79 +
80 + foreach ( $presenters as $presenter ) {
81 + if ( $presenter instanceof Title_Presenter ) {
82 + $has_title_presenter = true;
83 + }
84 + }
85 +
86 + if ( ! $has_title_presenter ) {
87 + $presenters[] = new Title_Presenter();
88 + }
89 +
90 + return $presenters;
57 91 }
58 92
59 93 /**
60 94 * Hooks into web story <head> generation to modify output.