| 1 |
<?php |
| 2 |
/** |
| 3 |
* WPSEO plugin file. |
| 4 |
* |
| 5 |
* @package WPSEO\Admin\Formatter |
| 6 |
*/ |
| 7 |
|
| 8 |
use Yoast\WP\SEO\Editors\Application\Seo\Term_Seo_Information_Repository; |
| 9 |
|
| 10 |
/** |
| 11 |
* This class provides data for the term metabox by return its values for localization. |
| 12 |
*/ |
| 13 |
class WPSEO_Term_Metabox_Formatter implements WPSEO_Metabox_Formatter_Interface { |
| 14 |
|
| 15 |
/** |
| 16 |
* The term the metabox formatter is for. |
| 17 |
* |
| 18 |
* @var WP_Term|stdClass |
| 19 |
*/ |
| 20 |
private $term; |
| 21 |
|
| 22 |
/** |
| 23 |
* The term's taxonomy. |
| 24 |
* |
| 25 |
* @var stdClass |
| 26 |
*/ |
| 27 |
private $taxonomy; |
| 28 |
|
| 29 |
/** |
| 30 |
* Whether we must return social templates values. |
| 31 |
* |
| 32 |
* @var bool |
| 33 |
*/ |
| 34 |
private $use_social_templates = false; |
| 35 |
|
| 36 |
/** |
| 37 |
* Array with the WPSEO_Titles options. |
| 38 |
* |
| 39 |
* @var array |
| 40 |
*/ |
| 41 |
protected $options; |
| 42 |
|
| 43 |
/** |
| 44 |
* WPSEO_Taxonomy_Scraper constructor. |
| 45 |
* |
| 46 |
* @param stdClass $taxonomy Taxonomy. |
| 47 |
* @param WP_Term|stdClass $term Term. |
| 48 |
*/ |
| 49 |
public function __construct( $taxonomy, $term ) { |
| 50 |
$this->taxonomy = $taxonomy; |
| 51 |
$this->term = $term; |
| 52 |
|
| 53 |
$this->use_social_templates = $this->use_social_templates(); |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* Determines whether the social templates should be used. |
| 58 |
* |
| 59 |
* @return bool Whether the social templates should be used. |
| 60 |
*/ |
| 61 |
public function use_social_templates() { |
| 62 |
return WPSEO_Options::get( 'opengraph', false ) === true; |
| 63 |
} |
| 64 |
|
| 65 |
/** |
| 66 |
* Returns the translated values. |
| 67 |
* |
| 68 |
* @return array |
| 69 |
*/ |
| 70 |
public function get_values() { |
| 71 |
$values = []; |
| 72 |
|
| 73 |
// Todo: a column needs to be added on the termpages to add a filter for the keyword, so this can be used in the focus keyphrase doubles. |
| 74 |
if ( is_object( $this->term ) && property_exists( $this->term, 'taxonomy' ) ) { |
| 75 |
$values = [ |
| 76 |
'taxonomy' => $this->term->taxonomy, |
| 77 |
'semrushIntegrationActive' => 0, |
| 78 |
'wincherIntegrationActive' => 0, |
| 79 |
'isInsightsEnabled' => $this->is_insights_enabled(), |
| 80 |
]; |
| 81 |
|
| 82 |
$repo = YoastSEO()->classes->get( Term_Seo_Information_Repository::class ); |
| 83 |
$repo->set_term( $this->term ); |
| 84 |
$values = ( $repo->get_seo_data() + $values ); |
| 85 |
} |
| 86 |
|
| 87 |
return $values; |
| 88 |
} |
| 89 |
|
| 90 |
/** |
| 91 |
* Determines whether the insights feature is enabled for this taxonomy. |
| 92 |
* |
| 93 |
* @return bool |
| 94 |
*/ |
| 95 |
protected function is_insights_enabled() { |
| 96 |
return WPSEO_Options::get( 'enable_metabox_insights', false ); |
| 97 |
} |
| 98 |
} |
| 99 |
|