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 / admin / formatter / class-term-metabox-formatter.php

class-term-metabox-formatter.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 27.8, at admin/formatter/class-term-metabox-formatter.php

99 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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