WordPress.org

Make WordPress Core

Changeset 37405


Ignore:
Timestamp:
05/10/2016 06:40:48 AM (4 years ago)
Author:
westonruter
Message:

Customize: Ensure that wp_setup_nav_menu_item filter applies consistently on nav_menu_item setting values.

The filter was being applied in WP_Customize_Nav_Menu_Item_Setting::value() but not in WP_Customize_Nav_Menu_Item_Setting::value_as_wp_post_nav_menu_item().

Props celloexpressions, westonruter.
Fixes #35203.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php

    r36709 r37405  
    571571        $post->description = apply_filters( 'nav_menu_description', wp_trim_words( $post->description, 200 ) );
    572572
     573        /** This filter is documented in wp-includes/nav-menu.php */
     574        $post = apply_filters( 'wp_setup_nav_menu_item', $post );
     575
    573576        return $post;
    574577    }
  • trunk/tests/phpunit/tests/customize/nav-menu-item-setting.php

    r36610 r37405  
    767767            'menu_item_parent' => 0,
    768768            'position'         => 2,
    769             'type'             => 'post_type',
     769            'type'             => 'custom_type',
    770770            'title'            => 'Hello \o/ o\'o World',
    771771            'url'              => '',
     
    783783
    784784        $setting->preview();
     785
    785786        $nav_menu_item = $setting->value_as_wp_post_nav_menu_item();
     787        $this->assertEquals( 'Custom Link', $nav_menu_item->type_label );
     788        add_filter( 'wp_setup_nav_menu_item', array( $this, 'filter_type_label' ) );
     789        $nav_menu_item = $setting->value_as_wp_post_nav_menu_item();
     790        $this->assertEquals( 'Custom Label', $nav_menu_item->type_label );
    786791
    787792        $this->assertObjectNotHasAttribute( 'nav_menu_term_id', $nav_menu_item );
Note: See TracChangeset for help on using the changeset viewer.