diff --git a/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php b/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php index 463da87afe..2fa0b5c0d2 100644 --- a/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php +++ b/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php @@ -572,6 +572,12 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting { } } + /** This filter is documented in wp-includes/nav-menu.php */ + $post->attr_title = apply_filters( 'nav_menu_attr_title', $post->attr_title ); + + /** This filter is documented in wp-includes/nav-menu.php */ + $post->description = apply_filters( 'nav_menu_description', wp_trim_words( $post->description, 200 ) ); + return $post; } @@ -619,7 +625,7 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting { ); $menu_item_value = array_merge( $default, $menu_item_value ); $menu_item_value = wp_array_slice_assoc( $menu_item_value, array_keys( $default ) ); - $menu_item_value['position'] = max( 0, intval( $menu_item_value['position'] ) ); + $menu_item_value['position'] = intval( $menu_item_value['position'] ); foreach ( array( 'object_id', 'menu_item_parent', 'nav_menu_term_id' ) as $key ) { // Note we need to allow negative-integer IDs for previewed objects not inserted yet. @@ -638,14 +644,16 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting { $menu_item_value[ $key ] = implode( ' ', array_map( 'sanitize_html_class', $value ) ); } - foreach ( array( 'title', 'attr_title', 'description', 'original_title' ) as $key ) { - // @todo Should esc_attr() the attr_title as well? - $menu_item_value[ $key ] = sanitize_text_field( $menu_item_value[ $key ] ); - } + $menu_item_value['original_title'] = sanitize_text_field( $menu_item_value['original_title'] ); + + // Apply the same filters as when calling wp_insert_post(). + $menu_item_value['title'] = apply_filters( 'title_save_pre', $menu_item_value['title'] ); + $menu_item_value['attr_title'] = apply_filters( 'excerpt_save_pre', $menu_item_value['attr_title'] ); + $menu_item_value['description'] = apply_filters( 'content_save_pre', $menu_item_value['description'] ); $menu_item_value['url'] = esc_url_raw( $menu_item_value['url'] ); - if ( ! get_post_status_object( $menu_item_value['status'] ) ) { - $menu_item_value['status'] = 'publish'; + if ( 'publish' !== $menu_item_value['status'] ) { + $menu_item_value['status'] = 'draft'; } $menu_item_value['_invalid'] = (bool) $menu_item_value['_invalid']; diff --git a/wp-includes/version.php b/wp-includes/version.php index 3585f5513f..e6aa1c3a24 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-beta3-35579'; +$wp_version = '4.4-beta3-35580'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.