| 1 |
<?php |
| 2 |
|
| 3 |
//phpcs:disable Yoast.NamingConventions.NamespaceName.MaxExceeded |
| 4 |
namespace Yoast\WP\SEO\Editors\Framework\Seo\Terms; |
| 5 |
|
| 6 |
use WP_Term; |
| 7 |
use WPSEO_Options; |
| 8 |
use Yoast\WP\SEO\Editors\Domain\Seo\Seo_Plugin_Data_Interface; |
| 9 |
|
| 10 |
/** |
| 11 |
* Abstract class for all term data providers. |
| 12 |
*/ |
| 13 |
abstract class Abstract_Term_Seo_Data_Provider { |
| 14 |
|
| 15 |
/** |
| 16 |
* The term the metabox formatter is for. |
| 17 |
* |
| 18 |
* @var WP_Term |
| 19 |
*/ |
| 20 |
protected $term; |
| 21 |
|
| 22 |
/** |
| 23 |
* The term. |
| 24 |
* |
| 25 |
* @param WP_Term $term The term. |
| 26 |
* |
| 27 |
* @return void |
| 28 |
*/ |
| 29 |
public function set_term( WP_Term $term ): void { |
| 30 |
$this->term = $term; |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Retrieves a template. |
| 35 |
* |
| 36 |
* @param string $template_option_name The name of the option in which the template you want to get is saved. |
| 37 |
* |
| 38 |
* @return string |
| 39 |
*/ |
| 40 |
protected function get_template( string $template_option_name ): string { |
| 41 |
$needed_option = $template_option_name . '-tax-' . $this->term->taxonomy; |
| 42 |
return WPSEO_Options::get( $needed_option, '' ); |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* Method to return the compiled SEO data. |
| 47 |
* |
| 48 |
* @return Seo_Plugin_Data_Interface The specific seo data. |
| 49 |
*/ |
| 50 |
abstract public function get_data(): Seo_Plugin_Data_Interface; |
| 51 |
} |
| 52 |
|