wp_map_nav_menu_locations example

// Attempt to re-map the nav menu location assignments when previewing a theme switch.         $mapped_nav_menu_locations = array();
        if ( ! $this->manager->is_theme_active() ) {
            $theme_mods = get_option( 'theme_mods_' . $this->manager->get_stylesheet(), array() );

            // If there is no data from a previous activation, start fresh.             if ( empty( $theme_mods['nav_menu_locations'] ) ) {
                $theme_mods['nav_menu_locations'] = array();
            }

            $mapped_nav_menu_locations = wp_map_nav_menu_locations( $theme_mods['nav_menu_locations']$this->original_nav_menu_locations );
        }

        foreach ( $locations as $location => $description ) {
            $setting_id = "nav_menu_locations[{$location}]";

            $setting = $this->manager->get_setting( $setting_id );
            if ( $setting ) {
                $setting->transport = 'postMessage';
                remove_filter( "customize_sanitize_{$setting_id}", 'absint' );
                add_filter( "customize_sanitize_{$setting_id}", array( $this, 'intval_base10' ) );
            } else {
                


/** * Handles menu config after theme change. * * @access private * @since 4.9.0 */
function _wp_menus_changed() {
    $old_nav_menu_locations    = get_option( 'theme_switch_menu_locations', array() );
    $new_nav_menu_locations    = get_nav_menu_locations();
    $mapped_nav_menu_locations = wp_map_nav_menu_locations( $new_nav_menu_locations$old_nav_menu_locations );

    set_theme_mod( 'nav_menu_locations', $mapped_nav_menu_locations );
    delete_option( 'theme_switch_menu_locations' );
}

/** * Maps nav menu locations according to assignments in previously active theme. * * @since 4.9.0 * * @param array $new_nav_menu_locations New nav menu locations assignments. * @param array $old_nav_menu_locations Old nav menu locations assignments. * @return array Nav menus mapped to new nav menu locations. */
Home | Imprint | This part of the site doesn't use cookies.