PluginProbe
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) / 2.1.3
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) v2.1.3
2.1.3 2.1.2 2.1.1 2.1.0 2.0.4 2.0.3 2.0.2 2.0.1 2.0.0 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 trunk 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 All 57 releases
← All changes | src/Admin/Rest/AbstractRestController.php +59 -0 2.1.22.1.3 View file →
@@ -280,8 +280,25 @@
280 280 return $out;
281 281 }
282 282
283 283 /**
284 + * Navigation sources that are stored as posts rather than `nav_menu` terms.
285 + *
286 + * Keyed by post type, valued by the short source label shown after the menu
287 + * name in the picker. `kadence_navigation` is only registered when Kadence
288 + * Blocks is active, which is why every caller checks post_type_exists()
289 + * before querying — the list itself is deliberately static so it costs
290 + * nothing to ask for.
291 + */
292 + protected static function darkify_block_menu_sources()
293 + {
294 + return [
295 + 'wp_navigation' => \__('Block menu', 'darkify'),
296 + 'kadence_navigation' => \__('Kadence', 'darkify'),
297 + ];
298 + }
299 +
300 + /**
284 301 * The read-only shortcode templates for the `switcher_shortcode` /
285 302 * `switcher_shortcode_v2` fields, byte-for-byte as the old framework's field
286 303 * renderers printed them.
287 304 */
@@ -350,8 +367,50 @@
350 367 case 'menu':
351 368 case 'menus': {
352 369 foreach (\wp_get_nav_menus() as $menu) {
353 370 $out[(string) $menu->term_id] = $menu->name;
371 + }
372 +
373 + /*
374 + * Block-theme and Kadence navigations are POSTS, not `nav_menu`
375 + * terms, so wp_get_nav_menus() above cannot see them. On a block
376 + * theme — or any site whose menus were built with Kadence
377 + * Navigation — this field came back completely empty even though
378 + * the site had menus, because there were no classic menus left to
379 + * list.
380 + *
381 + * Their ids are POST ids and would collide with the term ids
382 + * above (post 5 and term 5 are different menus), so they are
383 + * namespaced `<post_type>:<id>`. Bare numeric keys stay reserved
384 + * for classic menus, which is what keeps every already-saved
385 + * `switch_in_menu_location` resolving to exactly the menu it
386 + * always did.
387 + */
388 + foreach (self::darkify_block_menu_sources() as $post_type => $label) {
389 + if (! \post_type_exists($post_type)) {
390 + continue;
391 + }
392 +
393 + $navs = \get_posts([
394 + 'post_type' => $post_type,
395 + 'post_status' => 'publish',
396 + 'numberposts' => -1,
397 + 'orderby' => 'title',
398 + 'order' => 'ASC',
399 + 'suppress_filters' => false,
400 + ]);
401 +
402 + foreach (\is_array($navs) ? $navs : [] as $nav) {
403 + $title = ($nav->post_title !== '')
404 + ? $nav->post_title
405 + /* translators: %d: navigation menu post ID. */
406 + : \sprintf(\__('(no title) #%d', 'darkify'), $nav->ID);
407 +
408 + // The source is shown because a site can legitimately
409 + // have a classic menu, a block menu and a Kadence menu
410 + // all called "Primary Menu".
411 + $out[$post_type . ':' . $nav->ID] = $title . ' — ' . $label;
412 + }
354 413 }
355 414 break;
356 415 }
357 416 }