← All changes
|
includes/admin/importers/class-import-detector.php
+50
-1
2.8.0
→
2.10.0
View file →
| @@ -166,10 +166,18 @@ | ||
| 166 | 166 | // Only surface source plugins that are currently installed AND active. |
| 167 | 167 | // Migrating from a plugin the user no longer runs isn't actionable, so |
| 168 | 168 | // leftover data from a deactivated/uninstalled plugin is intentionally |
| 169 | 169 | // excluded from the migration screen. |
| 170 | + // | |
| 171 | + // The one exception is Rank Math's FAQ / HowTo blocks. Those live in | |
| 172 | + // post_content, and deactivating Rank Math is precisely what breaks | |
| 173 | + // them: the blocks turn into "unsupported block" in the editor and lose | |
| 174 | + // their schema on the front end. Hiding the only screen that can repair | |
| 175 | + // them, at the exact moment they need repairing, left users with no way | |
| 176 | + // out at all (#777) — so an inactive Rank Math stays listed whenever | |
| 177 | + // convertible blocks remain, carrying that type and nothing else. | |
| 170 | 178 | if (!$this->is_source_active($config['plugin_files'] ?? [])) { |
| 171 | - return null; | |
| 179 | + return $this->detect_orphaned_blocks($slug, $config); | |
| 172 | 180 | } |
| 173 | 181 | |
| 174 | 182 | $counts = []; |
| 175 | 183 | $total = 0; |
| @@ -214,8 +222,18 @@ | ||
| 214 | 222 | // when the exporter supports it (Rank Math Pro's redirects + 404 |
| 215 | 223 | // Monitor and Yoast Premium's redirects were never offered). |
| 216 | 224 | $counts = array_merge($counts, $this->detect_redirect_data($slug)); |
| 217 | 225 | |
| 226 | + // FAQ / HowTo blocks, offered while Rank Math is still active too, so | |
| 227 | + // the wizard converts them on the way out rather than leaving the user | |
| 228 | + // to discover the breakage after deactivation. | |
| 229 | + if ('rankmath' === $slug) { | |
| 230 | + $block_count = Block_Converter::count_posts(); | |
| 231 | + if ($block_count > 0) { | |
| 232 | + $counts[Block_Converter::TYPE] = $block_count; | |
| 233 | + } | |
| 234 | + } | |
| 235 | + | |
| 218 | 236 | // Check for settings |
| 219 | 237 | $has_settings = false; |
| 220 | 238 | foreach ($config['option_keys'] as $option_key) { |
| 221 | 239 | if (get_option($option_key, null) !== null) { |
| @@ -241,8 +259,39 @@ | ||
| 241 | 259 | 'plugin' => $slug, |
| 242 | 260 | 'plugin_name' => $config['name'], |
| 243 | 261 | 'counts' => $counts, |
| 244 | 262 | 'total' => $total, |
| 263 | + ]; | |
| 264 | + } | |
| 265 | + | |
| 266 | + /** | |
| 267 | + * Detection result for a deactivated source that has left convertible | |
| 268 | + * content blocks behind, or null when there is nothing to repair. | |
| 269 | + * | |
| 270 | + * Only the block type is reported. The plugin's postmeta and settings are | |
| 271 | + * deliberately still withheld: migrating those from a plugin the site no | |
| 272 | + * longer runs is the case the active-only rule exists to prevent, and it is | |
| 273 | + * not what broke. | |
| 274 | + * | |
| 275 | + * @param string $slug Plugin slug. | |
| 276 | + * @param array $config Plugin configuration. | |
| 277 | + * @return array|null | |
| 278 | + */ | |
| 279 | + private function detect_orphaned_blocks(string $slug, array $config): ?array { | |
| 280 | + if ('rankmath' !== $slug) { | |
| 281 | + return null; | |
| 282 | + } | |
| 283 | + | |
| 284 | + $count = Block_Converter::count_posts(); | |
| 285 | + if ($count < 1) { | |
| 286 | + return null; | |
| 287 | + } | |
| 288 | + | |
| 289 | + return [ | |
| 290 | + 'plugin' => $slug, | |
| 291 | + 'plugin_name' => $config['name'], | |
| 292 | + 'counts' => [Block_Converter::TYPE => $count], | |
| 293 | + 'total' => $count, | |
| 245 | 294 | ]; |
| 246 | 295 | } |
| 247 | 296 | |
| 248 | 297 | /** |