PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 27.5
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v27.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
wordpress-seo / src / llms-txt / infrastructure / markdown-services / description-adapter.php

description-adapter.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 27.5, at src/llms-txt/infrastructure/markdown-services/description-adapter.php

49 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong
4 namespace Yoast\WP\SEO\Llms_Txt\Infrastructure\Markdown_Services;
5
6 use Yoast\WP\SEO\Llms_Txt\Domain\Markdown\Sections\Description;
7 use Yoast\WP\SEO\Surfaces\Meta_Surface;
8
9 /**
10 * The adapter of the description.
11 */
12 class Description_Adapter {
13
14 /**
15 * Holds the meta helper surface.
16 *
17 * @var Meta_Surface
18 */
19 private $meta;
20
21 /**
22 * Class constructor.
23 *
24 * @param Meta_Surface $meta The meta surface.
25 */
26 public function __construct(
27 Meta_Surface $meta
28 ) {
29 $this->meta = $meta;
30 }
31
32 /**
33 * Gets the description.
34 *
35 * @return Description The description.
36 */
37 public function get_description(): Description {
38 $meta_description = $this->meta->for_home_page()->meta_description;
39
40 // In a lot of cases, the homepage's meta description falls back to the site's tagline.
41 // But that is already used for the title section, so let's try to not have duplicate content.
42 if ( $meta_description === \get_bloginfo( 'description' ) ) {
43 return new Description( '' );
44 }
45
46 return new Description( $meta_description );
47 }
48 }
49