← All changes
|
includes/admin/importers/class-rankmath-exporter.php
+45
-1
2.2.0
→
2.10.0
View file →
| @@ -182,8 +182,17 @@ | ||
| 182 | 182 | if ($log_count > 0) { |
| 183 | 183 | $types['404_logs'] = $log_count; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | + // FAQ / HowTo blocks live in post_content, not in any meta table, so | |
| 187 | + // they are invisible to every count above. Without this type they were | |
| 188 | + // never migrated at all and simply broke when Rank Math went away | |
| 189 | + // (#777). | |
| 190 | + $block_count = Block_Converter::count_posts(); | |
| 191 | + if ($block_count > 0) { | |
| 192 | + $types[Block_Converter::TYPE] = $block_count; | |
| 193 | + } | |
| 194 | + | |
| 186 | 195 | foreach ($this->option_keys as $key) { |
| 187 | 196 | if (get_option($key, null) !== null) { |
| 188 | 197 | $types['settings'] = 1; |
| 189 | 198 | break; |
| @@ -750,8 +759,40 @@ | ||
| 750 | 759 | |
| 751 | 760 | /** |
| 752 | 761 | * {@inheritDoc} |
| 753 | 762 | * |
| 763 | + * `content_blocks` records carry post ids only. The blocks themselves stay | |
| 764 | + * in `post_content` and are rewritten in place at migrate time — copying | |
| 765 | + * the content into the snapshot would mean holding a second copy of every | |
| 766 | + * FAQ page in `wp_options`, which is where snapshots live. | |
| 767 | + */ | |
| 768 | + protected function export_custom_type_page(string $type, int $page): array { | |
| 769 | + if (Block_Converter::TYPE !== $type) { | |
| 770 | + return parent::export_custom_type_page($type, $page); | |
| 771 | + } | |
| 772 | + | |
| 773 | + $post_ids = Block_Converter::get_post_ids($page, $this->chunk_size); | |
| 774 | + | |
| 775 | + // export_chunk() decides whether another page follows from the number | |
| 776 | + // of rows the query returned, so report it even when nothing is emitted. | |
| 777 | + $this->last_page_row_count = count($post_ids); | |
| 778 | + | |
| 779 | + $records = []; | |
| 780 | + foreach ($post_ids as $post_id) { | |
| 781 | + $records[] = [ | |
| 782 | + 'object_id' => $post_id, | |
| 783 | + 'object_type' => 'post', | |
| 784 | + 'source_plugin' => $this->plugin_slug, | |
| 785 | + 'data' => ['post_id' => $post_id], | |
| 786 | + ]; | |
| 787 | + } | |
| 788 | + | |
| 789 | + return $records; | |
| 790 | + } | |
| 791 | + | |
| 792 | + /** | |
| 793 | + * {@inheritDoc} | |
| 794 | + * | |
| 754 | 795 | * Rank Math's 404 monitor keeps one row per URI in `rank_math_404_logs`, |
| 755 | 796 | * which lines up with ThinkRank Pro's `thinkrank_404_logs`. |
| 756 | 797 | */ |
| 757 | 798 | protected function export_404_logs_page(int $page): array { |
| @@ -1002,9 +1043,12 @@ | ||
| 1002 | 1043 | if ($post_id) { |
| 1003 | 1044 | $post = get_post($post_id); |
| 1004 | 1045 | if ($post) { |
| 1005 | 1046 | $replacements['%title%'] = $post->post_title; |
| 1006 | - $replacements['%excerpt%'] = wp_trim_words($post->post_excerpt ?: wp_trim_words(wp_strip_all_tags($post->post_content), 55), 55); | |
| 1047 | + $replacements['%excerpt%'] = \ThinkRank\Core\Seo_Text::trim_words( | |
| 1048 | + $post->post_excerpt ?: \ThinkRank\Core\Seo_Text::trim_words(wp_strip_all_tags($post->post_content), 55), | |
| 1049 | + 55 | |
| 1050 | + ); | |
| 1007 | 1051 | $replacements['%date%'] = get_the_date('', $post); |
| 1008 | 1052 | $replacements['%modified%'] = get_the_modified_date('', $post); |
| 1009 | 1053 | $replacements['%id%'] = (string) $post_id; |
| 1010 | 1054 | $replacements['%name%'] = get_the_author_meta('display_name', (int) $post->post_author); |