PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.5
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.5
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 | src/integrations/admin/import-integration.php +52 -1 18.428.5 View file →
@@ -77,8 +77,10 @@
77 77 }
78 78
79 79 /**
80 80 * Enqueues the Import script.
81 + *
82 + * @return void
81 83 */
82 84 public function enqueue_import_script() {
83 85 \wp_enqueue_style( 'dashicons' );
84 86 $this->asset_manager->enqueue_script( 'import' );
@@ -96,8 +98,9 @@
96 98 'note' => \esc_html__( 'Note: ', 'wordpress-seo' ),
97 99 'cleanup_after_import_msg' => \esc_html__( 'After you\'ve imported data from another SEO plugin, please make sure to clean up all the original data from that plugin. (step 5)', 'wordpress-seo' ),
98 100 'select_placeholder' => \esc_html__( 'Select SEO plugin', 'wordpress-seo' ),
99 101 'no_data_msg' => \esc_html__( 'No data found from other SEO plugins.', 'wordpress-seo' ),
102 + 'validation_failure' => $this->get_validation_failure_alert(),
100 103 'import_failure' => $this->get_import_failure_alert( true ),
101 104 'cleanup_failure' => $this->get_import_failure_alert( false ),
102 105 'spinner' => \admin_url( 'images/loading.gif' ),
103 106 'replacing_texts' => [
@@ -146,9 +149,11 @@
146 149 protected function get_importing_endpoints() {
147 150 $available_actions = $this->importable_detector->detect_importers();
148 151 $importing_endpoints = [];
149 152
150 - foreach ( $available_actions as $plugin => $types ) {
153 + $available_sorted_actions = $this->sort_actions( $available_actions );
154 +
155 + foreach ( $available_sorted_actions as $plugin => $types ) {
151 156 foreach ( $types as $type ) {
152 157 $importing_endpoints[ $plugin ][] = $this->importing_route->get_endpoint( $plugin, $type );
153 158 }
154 159 }
@@ -156,8 +161,34 @@
156 161 return $importing_endpoints;
157 162 }
158 163
159 164 /**
165 + * Sorts the array of importing actions, by moving any validating actions to the start for every plugin.
166 + *
167 + * @param array $available_actions The array of actions that we want to sort.
168 + *
169 + * @return array The sorted array of actions.
170 + */
171 + protected function sort_actions( $available_actions ) {
172 + $first_action = 'validate_data';
173 + $available_sorted_actions = [];
174 +
175 + foreach ( $available_actions as $plugin => $plugin_available_actions ) {
176 +
177 + $validate_action_position = \array_search( $first_action, $plugin_available_actions, true );
178 +
179 + if ( ! empty( $validate_action_position ) ) {
180 + unset( $plugin_available_actions[ $validate_action_position ] );
181 + \array_unshift( $plugin_available_actions, $first_action );
182 + }
183 +
184 + $available_sorted_actions[ $plugin ] = $plugin_available_actions;
185 + }
186 +
187 + return $available_sorted_actions;
188 + }
189 +
190 + /**
160 191 * Retrieves a list of the importing endpoints to use.
161 192 *
162 193 * @return array The endpoints.
163 194 */
@@ -171,8 +202,28 @@
171 202 }
172 203 }
173 204
174 205 return $importing_endpoints;
206 + }
207 +
208 + /**
209 + * Gets the validation failure alert using the Alert_Presenter.
210 + *
211 + * @return string The validation failure alert.
212 + */
213 + protected function get_validation_failure_alert() {
214 + $content = \esc_html__( 'The AIOSEO import was cancelled because some AIOSEO data is missing. Please try and take the following steps to fix this:', 'wordpress-seo' );
215 + $content .= '<br/>';
216 + $content .= '<ol><li>';
217 + $content .= \esc_html__( 'If you have never saved any AIOSEO \'Search Appearance\' settings, please do that first and run the import again.', 'wordpress-seo' );
218 + $content .= '</li>';
219 + $content .= '<li>';
220 + $content .= \esc_html__( 'If you already have saved AIOSEO \'Search Appearance\' settings and the issue persists, please contact our support team so we can take a closer look.', 'wordpress-seo' );
221 + $content .= '</li></ol>';
222 +
223 + $validation_failure_alert = new Alert_Presenter( $content, 'error' );
224 +
225 + return $validation_failure_alert->present();
175 226 }
176 227
177 228 /**
178 229 * Gets the import failure alert using the Alert_Presenter.