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. git-svn-id: https://develop.svn.wordpress.org/trunk@37405 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
41cfd4d826
commit
8359290d8f
@ -570,6 +570,9 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
|
||||
/** This filter is documented in wp-includes/nav-menu.php */
|
||||
$post->description = apply_filters( 'nav_menu_description', wp_trim_words( $post->description, 200 ) );
|
||||
|
||||
/** This filter is documented in wp-includes/nav-menu.php */
|
||||
$post = apply_filters( 'wp_setup_nav_menu_item', $post );
|
||||
|
||||
return $post;
|
||||
}
|
||||
|
||||
|
@ -766,7 +766,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
'object' => 'post',
|
||||
'menu_item_parent' => 0,
|
||||
'position' => 2,
|
||||
'type' => 'post_type',
|
||||
'type' => 'custom_type',
|
||||
'title' => 'Hello \o/ o\'o World',
|
||||
'url' => '',
|
||||
'target' => '',
|
||||
@ -782,7 +782,12 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
$this->wp_customize->set_post_value( $setting->id, $post_value );
|
||||
|
||||
$setting->preview();
|
||||
|
||||
$nav_menu_item = $setting->value_as_wp_post_nav_menu_item();
|
||||
$this->assertEquals( 'Custom Link', $nav_menu_item->type_label );
|
||||
add_filter( 'wp_setup_nav_menu_item', array( $this, 'filter_type_label' ) );
|
||||
$nav_menu_item = $setting->value_as_wp_post_nav_menu_item();
|
||||
$this->assertEquals( 'Custom Label', $nav_menu_item->type_label );
|
||||
|
||||
$this->assertObjectNotHasAttribute( 'nav_menu_term_id', $nav_menu_item );
|
||||
$this->assertObjectNotHasAttribute( 'status', $nav_menu_item );
|
||||
|
Loading…
Reference in New Issue
Block a user