| 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 |
|