wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
block_core_navigation_get_classic_menu_fallback is deprecated since version 6.3.0!
Alternative: WP_Navigation_Fallback::get_classic_menu_fallback
Alternative: WP_Navigation_Fallback::get_classic_menu_fallback
block_core_navigation_get_classic_menu_fallback › WordPress Function
Seit6.2.0
Veraltet6.3.0
› block_core_navigation_get_classic_menu_fallback ( Keine Parameter )
Gibt zurück: |
|
Definiert in: |
|
Codex: |
Get the classic navigation menu to use as a fallback.
Quellcode
function block_core_navigation_get_classic_menu_fallback() { _deprecated_function( __FUNCTION__, '6.3.0', 'WP_Navigation_Fallback::get_classic_menu_fallback' ); $classic_nav_menus = wp_get_nav_menus(); // If menus exist. if ( $classic_nav_menus && ! is_wp_error( $classic_nav_menus ) ) { // Handles simple use case where user has a classic menu and switches to a block theme. // Returns the menu assigned to location `primary`. $locations = get_nav_menu_locations(); if ( isset( $locations['primary'] ) ) { $primary_menu = wp_get_nav_menu_object( $locations['primary'] ); if ( $primary_menu ) { return $primary_menu; } } // Returns a menu if `primary` is its slug. foreach ( $classic_nav_menus as $classic_nav_menu ) { if ( 'primary' === $classic_nav_menu->slug ) { return $classic_nav_menu; } } // Otherwise return the most recently created classic menu. usort( $classic_nav_menus, static function ( $a, $b ) { return $b->term_id - $a->term_id; } ); return $classic_nav_menus[0]; } }