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/presentations/indexable-presentation.php +59 -77 18.228.5 View file →
@@ -22,36 +22,41 @@
22 22 * Class Indexable_Presentation.
23 23 *
24 24 * Presentation object for indexables.
25 25 *
26 - * @property string $title
27 - * @property string $meta_description
28 - * @property array $robots
29 - * @property string $canonical
30 - * @property string $rel_next
31 - * @property string $rel_prev
32 - * @property string $open_graph_type
33 - * @property string $open_graph_title
34 - * @property string $open_graph_description
35 - * @property array $open_graph_images
36 - * @property string $open_graph_url
37 - * @property string $open_graph_site_name
38 - * @property string $open_graph_article_publisher
39 - * @property string $open_graph_article_author
40 - * @property string $open_graph_article_published_time
41 - * @property string $open_graph_article_modified_time
42 - * @property string $open_graph_locale
43 - * @property string $open_graph_fb_app_id
44 - * @property array $schema
45 - * @property string $twitter_card
46 - * @property string $twitter_title
47 - * @property string $twitter_description
48 - * @property string $twitter_image
49 - * @property string $twitter_creator
50 - * @property string $twitter_site
51 - * @property array $source
52 - * @property array $breadcrumbs
53 - * @property int $estimated_reading_time_minutes
26 + * @property string $title
27 + * @property string $meta_description
28 + * @property array $robots
29 + * @property string $canonical
30 + * @property string $rel_next
31 + * @property string $rel_prev
32 + * @property string $open_graph_type
33 + * @property string $open_graph_title
34 + * @property string $open_graph_description
35 + * @property array $open_graph_images
36 + * @property int $open_graph_image_id
37 + * @property string $open_graph_image
38 + * @property string $open_graph_url
39 + * @property string $open_graph_site_name
40 + * @property string $open_graph_article_publisher
41 + * @property string $open_graph_article_author
42 + * @property string $open_graph_article_published_time
43 + * @property string $open_graph_article_modified_time
44 + * @property string $open_graph_locale
45 + * @property string $open_graph_fb_app_id
46 + * @property string $permalink
47 + * @property array $schema
48 + * @property string $twitter_card
49 + * @property string $twitter_title
50 + * @property string $twitter_description
51 + * @property string $twitter_image
52 + * @property string $twitter_creator
53 + * @property string $twitter_site
54 + * @property object|array $source
55 + * @property array $breadcrumbs
56 + * @property int $estimated_reading_time_minutes
57 + * @property array $googlebot
58 + * @property array $bingbot
54 59 */
55 60 class Indexable_Presentation extends Abstract_Presentation {
56 61
57 62 /**
@@ -168,8 +173,10 @@
168 173 * @param Open_Graph_Locale_Generator $open_graph_locale_generator The Open Graph locale generator.
169 174 * @param Open_Graph_Image_Generator $open_graph_image_generator The Open Graph image generator.
170 175 * @param Twitter_Image_Generator $twitter_image_generator The Twitter image generator.
171 176 * @param Breadcrumbs_Generator $breadcrumbs_generator The breadcrumbs generator.
177 + *
178 + * @return void
172 179 */
173 180 public function set_generators(
174 181 Schema_Generator $schema_generator,
175 182 Open_Graph_Locale_Generator $open_graph_locale_generator,
@@ -196,8 +203,10 @@
196 203 * @param User_Helper $user The user helper.
197 204 * @param Indexable_Helper $indexable The indexable helper.
198 205 * @param Permalink_Helper $permalink The permalink helper.
199 206 * @param Values_Helper $values The values helper.
207 + *
208 + * @return void
200 209 */
201 210 public function set_helpers(
202 211 Image_Helper $image,
203 212 Options_Helper $options,
@@ -222,13 +231,22 @@
222 231 * Gets the permalink from the indexable or generates it if dynamic permalinks are enabled.
223 232 *
224 233 * @return string The permalink.
225 234 */
226 - public function get_permalink() {
235 + public function generate_permalink() {
227 236 if ( $this->indexable_helper->dynamic_permalinks_enabled() ) {
228 237 return $this->permalink_helper->get_permalink_for_indexable( $this->model );
229 238 }
230 239
240 + if ( \is_date() ) {
241 + return $this->current_page->get_date_archive_permalink();
242 + }
243 +
244 + if ( \is_attachment() ) {
245 + global $wp;
246 + return \trailingslashit( \home_url( $wp->request ) );
247 + }
248 +
231 249 return $this->model->permalink;
232 250 }
233 251
234 252 /**
@@ -305,10 +323,9 @@
305 323
306 324 /**
307 325 * Filter: 'wpseo_robots' - Allows filtering of the meta robots output of Yoast SEO.
308 326 *
309 - * @api string $robots The meta robots directives to be echoed.
310 - *
327 + * @param string $robots The meta robots directives to be echoed.
311 328 * @param Indexable_Presentation $presentation The presentation of an indexable.
312 329 */
313 330 $robots_filtered = \apply_filters( 'wpseo_robots', $robots_string, $this );
314 331
@@ -335,8 +352,15 @@
335 352
336 353 $robots = $robots_new;
337 354 }
338 355
356 + if ( \is_bool( $robots_filtered ) && ( $robots_filtered === false ) ) {
357 + return [
358 + 'index' => 'noindex',
359 + 'follow' => 'nofollow',
360 + ];
361 + }
362 +
339 363 if ( ! $robots_filtered ) {
340 364 return [];
341 365 }
342 366
@@ -342,10 +366,9 @@
342 366
343 367 /**
344 368 * Filter: 'wpseo_robots_array' - Allows filtering of the meta robots output array of Yoast SEO.
345 369 *
346 - * @api array $robots The meta robots directives to be used.
347 - *
370 + * @param array $robots The meta robots directives to be used.
348 371 * @param Indexable_Presentation $presentation The presentation of an indexable.
349 372 */
350 373 return \apply_filters( 'wpseo_robots_array', \array_filter( $robots ), $this );
351 374 }
@@ -350,36 +373,8 @@
350 373 return \apply_filters( 'wpseo_robots_array', \array_filter( $robots ), $this );
351 374 }
352 375
353 376 /**
354 - * Generates the robots value for the googlebot tag.
355 - *
356 - * @deprecated 14.9 Values merged into the robots meta tag.
357 - * @codeCoverageIgnore
358 - *
359 - * @return array The robots value with opt-in snippets.
360 - */
361 - public function generate_googlebot() {
362 - \_deprecated_function( __METHOD__, 'WPSEO 14.9' );
363 -
364 - return [];
365 - }
366 -
367 - /**
368 - * Generates the value for the bingbot tag.
369 - *
370 - * @deprecated 14.9 Values merged into the robots meta tag.
371 - * @codeCoverageIgnore
372 - *
373 - * @return array The robots value with opt-in snippets.
374 - */
375 - public function generate_bingbot() {
376 - \_deprecated_function( __METHOD__, 'WPSEO 14.9' );
377 -
378 - return [];
379 - }
380 -
381 - /**
382 377 * Generates the canonical.
383 378 *
384 379 * @return string The canonical.
385 380 */
@@ -387,11 +382,10 @@
387 382 if ( $this->model->canonical ) {
388 383 return $this->model->canonical;
389 384 }
390 385
391 - $permalink = $this->get_permalink();
392 - if ( $permalink ) {
393 - return $permalink;
386 + if ( $this->permalink ) {
387 + return $this->permalink;
394 388 }
395 389
396 390 return '';
397 391 }
@@ -515,9 +509,9 @@
515 509 if ( $this->model->canonical ) {
516 510 return $this->model->canonical;
517 511 }
518 512
519 - return $this->get_permalink();
513 + return $this->permalink;
520 514 }
521 515
522 516 /**
523 517 * Generates the open graph article publisher.
@@ -561,20 +555,8 @@
561 555 * @return string The open graph locale.
562 556 */
563 557 public function generate_open_graph_locale() {
564 558 return $this->open_graph_locale_generator->generate( $this->context );
565 - }
566 -
567 - /**
568 - * Generates the open graph Facebook app ID.
569 - *
570 - * @deprecated 15.5
571 - * @codeCoverageIgnore
572 - *
573 - * @return string The open graph Facebook app ID.
574 - */
575 - public function generate_open_graph_fb_app_id() {
576 - return $this->options->get( 'fbadminapp', '' );
577 559 }
578 560
579 561 /**
580 562 * Generates the open graph site name.