PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
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 / domain / markdown / sections / title.php

title.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI trunk, at src/llms-txt/domain/markdown/sections/title.php

79 lines 1.5 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.MaxExceeded
4 namespace Yoast\WP\SEO\Llms_Txt\Domain\Markdown\Sections;
5
6 use Yoast\WP\SEO\Llms_Txt\Application\Markdown_Escaper;
7
8 /**
9 * Represents the title section.
10 */
11 class Title implements Section_Interface {
12
13 /**
14 * The site title.
15 *
16 * @var string
17 */
18 private $site_title;
19
20 /**
21 * The site tagline.
22 *
23 * @var string
24 */
25 private $site_tagline;
26
27 /**
28 * Class constructor.
29 *
30 * @param string $site_title The site title.
31 * @param string $site_tagline The site tagline.
32 */
33 public function __construct(
34 string $site_title,
35 string $site_tagline
36 ) {
37 $this->site_title = $site_title;
38 $this->site_tagline = $site_tagline;
39 }
40
41 /**
42 * Returns the prefix of the section.
43 *
44 * @return string
45 */
46 public function get_prefix(): string {
47 return '# ';
48 }
49
50 /**
51 * Renders the title section.
52 *
53 * @return string
54 */
55 public function render(): string {
56 if ( $this->site_tagline === '' ) {
57 return $this->site_title;
58 }
59
60 if ( $this->site_title === '' ) {
61 return $this->site_tagline;
62 }
63
64 return "$this->site_title: $this->site_tagline";
65 }
66
67 /**
68 * Escapes the markdown content.
69 *
70 * @param Markdown_Escaper $markdown_escaper The markdown escaper.
71 *
72 * @return void
73 */
74 public function escape_markdown( Markdown_Escaper $markdown_escaper ): void {
75 $this->site_title = $markdown_escaper->escape_markdown_content( $this->site_title );
76 $this->site_tagline = $markdown_escaper->escape_markdown_content( $this->site_tagline );
77 }
78 }
79