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/import/plugins/class-import-aioseo-v4.php +18 -16 18.6 → trunk View file →
@@ -61,11 +61,11 @@
61 61
62 62 /**
63 63 * Mapping between the AiOSEO replace vars and the Yoast replace vars.
64 64 *
65 + * @see https://yoast.com/help/list-available-snippet-variables-yoast-seo/
66 + *
65 67 * @var array
66 - *
67 - * @see https://yoast.com/help/list-available-snippet-variables-yoast-seo/
68 68 */
69 69 protected $replace_vars = [
70 70 // They key is the AiOSEO replace var, the value is the Yoast replace var (see class-wpseo-replace-vars).
71 71 '#author_first_name' => '%%author_first_name%%',
@@ -106,15 +106,15 @@
106 106 // At this point we're already looping through all the $clone_keys (this happens in meta_keys_clone() in the abstract class).
107 107 // Now, we'll also loop through the replace_vars array, which holds the mappings between the AiOSEO variables and the Yoast variables.
108 108 // We'll replace all the AiOSEO variables in the temporary table with their Yoast equivalents.
109 109 foreach ( $this->replace_vars as $aioseo_variable => $yoast_variable ) {
110 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: We need this query and this is done at many other places as well, for example class-import-rankmath.
110 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: We need this query and this is done at many other places as well, for example class-import-rankmath.
111 111 $wpdb->query(
112 112 $wpdb->prepare(
113 113 'UPDATE tmp_meta_table SET meta_value = REPLACE( meta_value, %s, %s )',
114 114 $aioseo_variable,
115 - $yoast_variable
116 - )
115 + $yoast_variable,
116 + ),
117 117 );
118 118 }
119 119
120 120 // The AiOSEO custom fields take the form of `#custom_field-myfield`.
@@ -145,12 +145,12 @@
145 145 $unique_custom_fields_or_taxonomies = [];
146 146
147 147 foreach ( $meta_values as $meta_value ) {
148 148 // Find all custom field replace vars, store them in `$matches`.
149 - \preg_match_all(
149 + preg_match_all(
150 150 "/#$aioseo_prefix-([\w-]+)/",
151 151 $meta_value,
152 - $matches
152 + $matches,
153 153 );
154 154
155 155 /*
156 156 * `$matches[1]` contain the captured matches of the
@@ -158,13 +158,13 @@
158 158 */
159 159 $custom_fields_or_taxonomies = $matches[1];
160 160
161 161 foreach ( $custom_fields_or_taxonomies as $custom_field_or_taxonomy ) {
162 - $unique_custom_fields_or_taxonomies[ \trim( $custom_field_or_taxonomy ) ] = 1;
162 + $unique_custom_fields_or_taxonomies[ trim( $custom_field_or_taxonomy ) ] = 1;
163 163 }
164 164 }
165 165
166 - return \array_keys( $unique_custom_fields_or_taxonomies );
166 + return array_keys( $unique_custom_fields_or_taxonomies );
167 167 }
168 168
169 169 /**
170 170 * Replaces every AIOSEO custom field/taxonomy/etc. replace var with the Yoast version.
@@ -175,8 +175,10 @@
175 175 * @param wpdb $wpdb The WordPress database object.
176 176 * @param string $aioseo_prefix The AiOSEO prefix to use
177 177 * (e.g. `custom-field` for custom fields or `tax_name` for custom taxonomies).
178 178 * @param string $yoast_prefix The Yoast prefix to use (e.g. `cf` for custom fields).
179 + *
180 + * @return void
179 181 */
180 182 protected function replace_custom_field_or_taxonomy_replace_vars( $unique_custom_fields_or_taxonomies, $wpdb, $aioseo_prefix, $yoast_prefix ) {
181 183 foreach ( $unique_custom_fields_or_taxonomies as $unique_custom_field_or_taxonomy ) {
182 184 $aioseo_variable = "#{$aioseo_prefix}-{$unique_custom_field_or_taxonomy}";
@@ -181,20 +183,20 @@
181 183 foreach ( $unique_custom_fields_or_taxonomies as $unique_custom_field_or_taxonomy ) {
182 184 $aioseo_variable = "#{$aioseo_prefix}-{$unique_custom_field_or_taxonomy}";
183 185 $yoast_variable = "%%{$yoast_prefix}_{$unique_custom_field_or_taxonomy}%%";
184 186
185 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
187 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
186 188 $wpdb->query(
187 189 $wpdb->prepare(
188 190 'UPDATE tmp_meta_table SET meta_value = REPLACE( meta_value, %s, %s )',
189 191 $aioseo_variable,
190 - $yoast_variable
191 - )
192 + $yoast_variable,
193 + ),
192 194 );
193 195 }
194 196 }
195 197
196 - // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
198 + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
197 199
198 200 /**
199 201 * Retrieve all the meta values from the temporary meta table that contain
200 202 * at least one AiOSEO custom field replace var.
@@ -208,14 +210,14 @@
208 210 protected function get_meta_values_with_custom_field_or_taxonomy( $wpdb, $aioseo_prefix ) {
209 211 return $wpdb->get_col(
210 212 $wpdb->prepare(
211 213 'SELECT meta_value FROM tmp_meta_table WHERE meta_value LIKE %s',
212 - "%#$aioseo_prefix-%"
213 - )
214 + "%#$aioseo_prefix-%",
215 + ),
214 216 );
215 217 }
216 218
217 - // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
219 + // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
218 220
219 221 /**
220 222 * Detects whether there is AIOSEO data to import by looking whether the AIOSEO data have been cleaned up.
221 223 *