PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
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
← All changes | admin/formatter/class-term-metabox-formatter.php +12 -144 18.7 → trunk View file →
@@ -4,8 +4,10 @@
4 4 *
5 5 * @package WPSEO\Admin\Formatter
6 6 */
7 7
8 +use Yoast\WP\SEO\Editors\Application\Seo\Term_Seo_Information_Repository;
9 +
8 10 /**
9 11 * This class provides data for the term metabox by return its values for localization.
10 12 */
11 13 class WPSEO_Term_Metabox_Formatter implements WPSEO_Metabox_Formatter_Interface {
@@ -56,12 +58,9 @@
56 58 *
57 59 * @return bool Whether the social templates should be used.
58 60 */
59 61 public function use_social_templates() {
60 - return YoastSEO()->helpers->product->is_premium()
61 - && defined( 'WPSEO_PREMIUM_VERSION' )
62 - && version_compare( WPSEO_PREMIUM_VERSION, '16.5-RC0', '>=' )
63 - && WPSEO_Options::get( 'opengraph', false ) === true;
62 + return WPSEO_Options::get( 'opengraph', false ) === true;
64 63 }
65 64
66 65 /**
67 66 * Returns the translated values.
@@ -73,23 +72,17 @@
73 72
74 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.
75 74 if ( is_object( $this->term ) && property_exists( $this->term, 'taxonomy' ) ) {
76 75 $values = [
77 - 'search_url' => $this->search_url(),
78 - 'post_edit_url' => $this->edit_url(),
79 - 'base_url' => $this->base_url_for_js(),
80 76 'taxonomy' => $this->term->taxonomy,
81 - 'keyword_usage' => $this->get_focus_keyword_usage(),
82 - 'title_template' => $this->get_title_template(),
83 - 'title_template_no_fallback' => $this->get_title_template( false ),
84 - 'metadesc_template' => $this->get_metadesc_template(),
85 - 'first_content_image' => $this->get_image_url(),
86 77 'semrushIntegrationActive' => 0,
87 - 'social_title_template' => $this->get_social_title_template(),
88 - 'social_description_template' => $this->get_social_description_template(),
89 - 'social_image_template' => $this->get_social_image_template(),
90 78 'wincherIntegrationActive' => 0,
79 + 'isInsightsEnabled' => $this->is_insights_enabled(),
91 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 );
92 85 }
93 86
94 87 return $values;
95 88 }
@@ -94,137 +87,12 @@
94 87 return $values;
95 88 }
96 89
97 90 /**
98 - * Gets the image URL for the term's social preview.
91 + * Determines whether the insights feature is enabled for this taxonomy.
99 92 *
100 - * @return string|null The image URL for the social preview.
93 + * @return bool
101 94 */
102 - protected function get_image_url() {
103 - return WPSEO_Image_Utils::get_first_content_image_for_term( $this->term->term_id );
104 - }
105 -
106 - /**
107 - * Returns the url to search for keyword for the taxonomy.
108 - *
109 - * @return string
110 - */
111 - private function search_url() {
112 - return admin_url( 'edit-tags.php?taxonomy=' . $this->term->taxonomy . '&seo_kw_filter={keyword}' );
113 - }
114 -
115 - /**
116 - * Returns the url to edit the taxonomy.
117 - *
118 - * @return string
119 - */
120 - private function edit_url() {
121 - global $wp_version;
122 - $script_filename = version_compare( $wp_version, '4.5', '<' ) ? 'edit-tags' : 'term';
123 - return admin_url( $script_filename . '.php?action=edit&taxonomy=' . $this->term->taxonomy . '&tag_ID={id}' );
124 - }
125 -
126 - /**
127 - * Returns a base URL for use in the JS, takes permalink structure into account.
128 - *
129 - * @return string
130 - */
131 - private function base_url_for_js() {
132 -
133 - $base_url = home_url( '/', null );
134 - if ( ! WPSEO_Options::get( 'stripcategorybase', false ) ) {
135 - $base_url = trailingslashit( $base_url . $this->taxonomy->rewrite['slug'] );
136 - }
137 -
138 - return $base_url;
139 - }
140 -
141 - /**
142 - * Counting the number of given keyword used for other term than given term_id.
143 - *
144 - * @return array
145 - */
146 - private function get_focus_keyword_usage() {
147 - $focuskw = WPSEO_Taxonomy_Meta::get_term_meta( $this->term, $this->term->taxonomy, 'focuskw' );
148 -
149 - return WPSEO_Taxonomy_Meta::get_keyword_usage( $focuskw, $this->term->term_id, $this->term->taxonomy );
150 - }
151 -
152 - /**
153 - * Retrieves the title template.
154 - *
155 - * @param bool $fallback Whether to return the hardcoded fallback if the template value is empty.
156 - *
157 - * @return string The title template.
158 - */
159 - private function get_title_template( $fallback = true ) {
160 - $title = $this->get_template( 'title' );
161 -
162 - if ( $title === '' && $fallback === true ) {
163 - /* translators: %s expands to the variable used for term title. */
164 - $archives = sprintf( __( '%s Archives', 'wordpress-seo' ), '%%term_title%%' );
165 - return $archives . ' %%page%% %%sep%% %%sitename%%';
166 - }
167 -
168 - return $title;
169 - }
170 -
171 - /**
172 - * Retrieves the metadesc template.
173 - *
174 - * @return string The metadesc template.
175 - */
176 - private function get_metadesc_template() {
177 - return $this->get_template( 'metadesc' );
178 - }
179 -
180 - /**
181 - * Retrieves the social title template.
182 - *
183 - * @return string The social title template.
184 - */
185 - private function get_social_title_template() {
186 - if ( $this->use_social_templates ) {
187 - return $this->get_template( 'social-title' );
188 - }
189 -
190 - return '';
191 - }
192 -
193 - /**
194 - * Retrieves the social description template.
195 - *
196 - * @return string The social description template.
197 - */
198 - private function get_social_description_template() {
199 - if ( $this->use_social_templates ) {
200 - return $this->get_template( 'social-description' );
201 - }
202 -
203 - return '';
204 - }
205 -
206 - /**
207 - * Retrieves the social image template.
208 - *
209 - * @return string The social description template.
210 - */
211 - private function get_social_image_template() {
212 - if ( $this->use_social_templates ) {
213 - return $this->get_template( 'social-image-url' );
214 - }
215 -
216 - return '';
217 - }
218 -
219 - /**
220 - * Retrieves a template.
221 - *
222 - * @param string $template_option_name The name of the option in which the template you want to get is saved.
223 - *
224 - * @return string
225 - */
226 - private function get_template( $template_option_name ) {
227 - $needed_option = $template_option_name . '-tax-' . $this->term->taxonomy;
228 - return WPSEO_Options::get( $needed_option, '' );
95 + protected function is_insights_enabled() {
96 + return WPSEO_Options::get( 'enable_metabox_insights', false );
229 97 }
230 98 }