Make WordPress Core


Ignore:
Timestamp:
08/12/2015 02:06:21 PM (9 years ago)
Author:
boonebgorges
Message:

When splitting a shared 'nav_menu' term, ensure that nav items and theme locations are retained.

Props boonebgorges, dd32.
Fixes #33187.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/taxonomy.php

    r33238 r33611  
    43974397
    43984398/**
     4399 * If the term being split is a nav_menu, change associations.
     4400 *
     4401 * @ignore
     4402 * @since 4.3.0
     4403 *
     4404 * @global wpdb $wpdb
     4405 *
     4406 * @param int    $term_id          ID of the formerly shared term.
     4407 * @param int    $new_term_id      ID of the new term created for the $term_taxonomy_id.
     4408 * @param int    $term_taxonomy_id ID for the term_taxonomy row affected by the split.
     4409 * @param string $taxonomy         Taxonomy for the split term.
     4410 */
     4411function _wp_check_split_nav_menu_terms( $term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) {
     4412    if ( 'nav_menu' !== $taxonomy ) {
     4413        return;
     4414    }
     4415
     4416    // Update menu locations.
     4417    $locations = get_nav_menu_locations();
     4418    foreach ( $locations as $location => $menu_id ) {
     4419        if ( $term_id == $menu_id ) {
     4420            $locations[ $location ] = $new_term_id;
     4421        }
     4422    }
     4423    set_theme_mod( 'nav_menu_locations', $locations );
     4424}
     4425
     4426/**
    43994427 * Get data about terms that previously shared a single term_id, but have since been split.
    44004428 *
Note: See TracChangeset for help on using the changeset viewer.