PluginProbe
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO / 2.10.0
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO v2.10.0
2.10.0 2.9.0 2.8.0 2.7.0 2.6.0 2.5.0 2.4.0 2.3.0 2.2.0 2.1.1 2.1.0 2.0.2 2.0.1 2.0.0 1.32.0 1.31.0 1.30.0 1.29.0 1.28.0 1.27.0 1.26.0 1.25.0 trunk 1.0.0 1.0.1 All 51 releases
← All changes | includes/admin/importers/class-import-controller.php +92 -1 2.9.0 → 2.10.0 View file →
@@ -60,9 +60,17 @@
60 60 * the frontend workflow (useImportWorkflow.js EXPORT_TYPES) can send —
61 61 * 404_logs was missing, so Rank Math's 404 Monitor could never be
62 62 * exported or migrated through REST.
63 63 */
64 - private const ALLOWED_TYPES = ['postmeta', 'termmeta', 'usermeta', 'redirections', '404_logs', 'settings'];
64 + private const ALLOWED_TYPES = [
65 + 'postmeta',
66 + 'termmeta',
67 + 'usermeta',
68 + 'redirections',
69 + '404_logs',
70 + 'settings',
71 + Block_Converter::TYPE,
72 + ];
65 73
66 74 /**
67 75 * Types the export and migrate endpoints accept.
68 76 *
@@ -150,8 +158,41 @@
150 158 ],
151 159 ],
152 160 ]);
153 161
162 + // Undo for the Rank Math FAQ/HowTo block conversion on sites with
163 + // revisions disabled, where Block_Converter kept the original content
164 + // in post meta. With revisions on, the post's revision history is the
165 + // undo and this route has nothing to restore.
166 + register_rest_route($this->namespace, '/' . $this->rest_base . '/content-blocks/restore', [
167 + [
168 + 'methods' => \WP_REST_Server::CREATABLE,
169 + 'callback' => [$this, 'restore_content_blocks'],
170 + 'permission_callback' => [$this, 'check_permissions'],
171 + 'args' => [
172 + 'post_id' => [
173 + 'type' => 'integer',
174 + 'default' => 0,
175 + 'minimum' => 0,
176 + 'sanitize_callback' => 'absint',
177 + 'description' => __('Restore one post. Omit to restore every post with a backup, one page at a time.', 'thinkrank'),
178 + ],
179 + 'after' => [
180 + 'type' => 'integer',
181 + 'default' => 0,
182 + 'minimum' => 0,
183 + 'sanitize_callback' => 'absint',
184 + 'description' => __('Paging cursor: pass the previous response\'s next_after.', 'thinkrank'),
185 + ],
186 + 'force' => [
187 + 'type' => 'boolean',
188 + 'default' => false,
189 + 'description' => __('Restore posts that were edited after the conversion, discarding those edits.', 'thinkrank'),
190 + ],
191 + ],
192 + ],
193 + ]);
194 +
154 195 register_rest_route($this->namespace, '/' . $this->rest_base . '/snapshot', [
155 196 [
156 197 'methods' => \WP_REST_Server::DELETABLE,
157 198 'callback' => [$this, 'delete_snapshot'],
@@ -458,8 +499,58 @@
458 499 'status' => 'complete',
459 500 'message' => sprintf('Deleted %d source data entries for %s', $deleted, $plugin),
460 501 'deleted' => $deleted,
461 502 ], 200);
503 + }
504 +
505 + /**
506 + * POST /import/content-blocks/restore: put converted posts back.
507 + *
508 + * Restores the pre-conversion `post_content` Block_Converter kept for posts
509 + * converted while revisions were disabled. A post edited since is reported
510 + * under `modified` and left alone unless `force` is set.
511 + *
512 + * Without `post_id` it works through one page of posts per call; while
513 + * `next_after` is non-null, call again with `after` set to it.
514 + *
515 + * @since 2.10.0
516 + *
517 + * @param \WP_REST_Request $request Request object
518 + * @return \WP_REST_Response
519 + */
520 + public function restore_content_blocks(\WP_REST_Request $request): \WP_REST_Response {
521 + $post_id = (int) $request->get_param('post_id');
522 + $force = (bool) $request->get_param('force');
523 + $limit = Block_Converter::chunk_size();
524 +
525 + $ids = $post_id > 0
526 + ? [$post_id]
527 + : Block_Converter::get_backup_post_ids((int) $request->get_param('after'), $limit);
528 +
529 + $report = [
530 + 'restored' => [],
531 + 'modified' => [],
532 + 'no_backup' => [],
533 + 'errors' => [],
534 + 'next_after' => null,
535 + ];
536 +
537 + foreach ($ids as $id) {
538 + $result = Block_Converter::restore_post($id, $force);
539 +
540 + if ('error' === $result['status']) {
541 + $report['errors'][] = ['post_id' => $id, 'message' => $result['message']];
542 + continue;
543 + }
544 +
545 + $report[$result['status']][] = $id;
546 + }
547 +
548 + if ($post_id < 1 && count($ids) === $limit) {
549 + $report['next_after'] = (int) end($ids);
550 + }
551 +
552 + return new \WP_REST_Response($report, 200);
462 553 }
463 554
464 555 /**
465 556 * DELETE /import/snapshot — Delete snapshot data from wp_options