]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/customize/class-wp-customize-nav-menu-item-setting.php
Wordpress 4.6
[autoinstalls/wordpress.git] / wp-includes / customize / class-wp-customize-nav-menu-item-setting.php
index 073423ecbe72ae37608835399764119530fb0ee9..c71ab09754def899deaf72901bb29f5c60c0e5de 100644 (file)
@@ -67,10 +67,11 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
         * Default transport.
         *
         * @since 4.3.0
         * Default transport.
         *
         * @since 4.3.0
+        * @since 4.5.0 Default changed to 'refresh'
         * @access public
         * @var string
         */
         * @access public
         * @var string
         */
-       public $transport = 'postMessage';
+       public $transport = 'refresh';
 
        /**
         * The post ID represented by this setting instance. This is the db_id.
 
        /**
         * The post ID represented by this setting instance. This is the db_id.
@@ -131,6 +132,8 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
        /**
         * Status for calling the update method, used in customize_save_response filter.
         *
        /**
         * Status for calling the update method, used in customize_save_response filter.
         *
+        * See {@see 'customize_save_response'}.
+        *
         * When status is inserted, the placeholder post ID is stored in $previous_post_id.
         * When status is error, the error is stored in $update_error.
         *
         * When status is inserted, the placeholder post ID is stored in $previous_post_id.
         * When status is error, the error is stored in $update_error.
         *
@@ -403,7 +406,7 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
        }
 
        /**
        }
 
        /**
-        * Filter the wp_get_nav_menu_items() result to supply the previewed menu items.
+        * Filters the wp_get_nav_menu_items() result to supply the previewed menu items.
         *
         * @since 4.3.0
         * @access public
         *
         * @since 4.3.0
         * @access public
@@ -494,7 +497,7 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
                // @todo We should probably re-apply some constraints imposed by $args.
                unset( $args['include'] );
 
                // @todo We should probably re-apply some constraints imposed by $args.
                unset( $args['include'] );
 
-               // Remove invalid items only in frontend.
+               // Remove invalid items only in front end.
                if ( ! is_admin() ) {
                        $items = array_filter( $items, '_is_valid_nav_menu_item' );
                }
                if ( ! is_admin() ) {
                        $items = array_filter( $items, '_is_valid_nav_menu_item' );
                }
@@ -569,6 +572,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->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;
        }
 
                return $post;
        }
 
@@ -638,9 +644,9 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
                $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['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['title'] = wp_unslash( apply_filters( 'title_save_pre', wp_slash( $menu_item_value['title'] ) ) );
+               $menu_item_value['attr_title'] = wp_unslash( apply_filters( 'excerpt_save_pre', wp_slash( $menu_item_value['attr_title'] ) ) );
+               $menu_item_value['description'] = wp_unslash( apply_filters( 'content_save_pre', wp_slash( $menu_item_value['description'] ) ) );
 
                $menu_item_value['url'] = esc_url_raw( $menu_item_value['url'] );
                if ( 'publish' !== $menu_item_value['status'] ) {
 
                $menu_item_value['url'] = esc_url_raw( $menu_item_value['url'] );
                if ( 'publish' !== $menu_item_value['status'] ) {
@@ -654,11 +660,11 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
        }
 
        /**
        }
 
        /**
-        * Create/update the nav_menu_item post for this setting.
+        * Creates/updates the nav_menu_item post for this setting.
         *
         * Any created menu items will have their assigned post IDs exported to the client
         *
         * Any created menu items will have their assigned post IDs exported to the client
-        * via the customize_save_response filter. Likewise, any errors will be exported
-        * to the client via the customize_save_response() filter.
+        * via the {@see 'customize_save_response'} filter. Likewise, any errors will be
+        * exported to the client via the customize_save_response() filter.
         *
         * To delete a menu, the client can send false as the value.
         *
         *
         * To delete a menu, the client can send false as the value.
         *
@@ -775,7 +781,7 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
                        $r = wp_update_nav_menu_item(
                                $value['nav_menu_term_id'],
                                $is_placeholder ? 0 : $this->post_id,
                        $r = wp_update_nav_menu_item(
                                $value['nav_menu_term_id'],
                                $is_placeholder ? 0 : $this->post_id,
-                               $menu_item_data
+                               wp_slash( $menu_item_data )
                        );
 
                        if ( is_wp_error( $r ) ) {
                        );
 
                        if ( is_wp_error( $r ) ) {