PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 27.8
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v27.8
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 / editors / framework / seo / terms / title-data-provider.php

title-data-provider.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 27.8, at src/editors/framework/seo/terms/title-data-provider.php

43 lines 1.3 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\Editors\Framework\Seo\Terms;
5
6 use Yoast\WP\SEO\Editors\Domain\Seo\Seo_Plugin_Data_Interface;
7 use Yoast\WP\SEO\Editors\Domain\Seo\Title;
8 use Yoast\WP\SEO\Editors\Framework\Seo\Title_Data_Provider_Interface;
9
10 /**
11 * Describes if the title SEO data.
12 */
13 class Title_Data_Provider extends Abstract_Term_Seo_Data_Provider implements Title_Data_Provider_Interface {
14
15 /**
16 * Retrieves the title template.
17 *
18 * @param bool $fallback Whether to return the hardcoded fallback if the template value is empty.
19 *
20 * @return string The title template.
21 */
22 public function get_title_template( bool $fallback = true ): string {
23 $title = $this->get_template( 'title' );
24
25 if ( $title === '' && $fallback === true ) {
26 /* translators: %s expands to the variable used for term title. */
27 $archives = \sprintf( \__( '%s Archives', 'wordpress-seo' ), '%%term_title%%' );
28 return $archives . ' %%page%% %%sep%% %%sitename%%';
29 }
30
31 return $title;
32 }
33
34 /**
35 * Method to return the Title domain object with SEO data.
36 *
37 * @return Seo_Plugin_Data_Interface The specific seo data.
38 */
39 public function get_data(): Seo_Plugin_Data_Interface {
40 return new Title( $this->get_title_template(), $this->get_title_template( false ) );
41 }
42 }
43