wp/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
   181 			$this->populate_value();
   181 			$this->populate_value();
   182 			foreach ( array_diff( array_keys( $this->default ), array_keys( $this->value ) ) as $missing ) {
   182 			foreach ( array_diff( array_keys( $this->default ), array_keys( $this->value ) ) as $missing ) {
   183 				throw new Exception( "Supplied nav_menu_item value missing property: $missing" );
   183 				throw new Exception( "Supplied nav_menu_item value missing property: $missing" );
   184 			}
   184 			}
   185 		}
   185 		}
   186 
       
   187 	}
   186 	}
   188 
   187 
   189 	/**
   188 	/**
   190 	 * Clear the cached value when this nav menu item is updated.
   189 	 * Clear the cached value when this nav menu item is updated.
   191 	 *
   190 	 *
   226 		} elseif ( isset( $this->value ) ) {
   225 		} elseif ( isset( $this->value ) ) {
   227 			$value = $this->value;
   226 			$value = $this->value;
   228 		} else {
   227 		} else {
   229 			$value = false;
   228 			$value = false;
   230 
   229 
   231 			// Note that a ID of less than one indicates a nav_menu not yet inserted.
   230 			// Note that an ID of less than one indicates a nav_menu not yet inserted.
   232 			if ( $this->post_id > 0 ) {
   231 			if ( $this->post_id > 0 ) {
   233 				$post = get_post( $this->post_id );
   232 				$post = get_post( $this->post_id );
   234 				if ( $post && self::POST_TYPE === $post->post_type ) {
   233 				if ( $post && self::POST_TYPE === $post->post_type ) {
   235 					$is_title_empty = empty( $post->post_title );
   234 					$is_title_empty = empty( $post->post_title );
   236 					$value          = (array) wp_setup_nav_menu_item( $post );
   235 					$value          = (array) wp_setup_nav_menu_item( $post );
   724 
   723 
   725 		/** This filter is documented in wp-includes/post.php */
   724 		/** This filter is documented in wp-includes/post.php */
   726 		$menu_item_value['description'] = wp_unslash( apply_filters( 'content_save_pre', wp_slash( $menu_item_value['description'] ) ) );
   725 		$menu_item_value['description'] = wp_unslash( apply_filters( 'content_save_pre', wp_slash( $menu_item_value['description'] ) ) );
   727 
   726 
   728 		if ( '' !== $menu_item_value['url'] ) {
   727 		if ( '' !== $menu_item_value['url'] ) {
   729 			$menu_item_value['url'] = esc_url_raw( $menu_item_value['url'] );
   728 			$menu_item_value['url'] = sanitize_url( $menu_item_value['url'] );
   730 			if ( '' === $menu_item_value['url'] ) {
   729 			if ( '' === $menu_item_value['url'] ) {
   731 				return new WP_Error( 'invalid_url', __( 'Invalid URL.' ) ); // Fail sanitization if URL is invalid.
   730 				return new WP_Error( 'invalid_url', __( 'Invalid URL.' ) ); // Fail sanitization if URL is invalid.
   732 			}
   731 			}
   733 		}
   732 		}
   734 		if ( 'publish' !== $menu_item_value['status'] ) {
   733 		if ( 'publish' !== $menu_item_value['status'] ) {
   876 				} else {
   875 				} else {
   877 					$this->update_status = 'updated';
   876 					$this->update_status = 'updated';
   878 				}
   877 				}
   879 			}
   878 			}
   880 		}
   879 		}
   881 
       
   882 	}
   880 	}
   883 
   881 
   884 	/**
   882 	/**
   885 	 * Export data for the JS client.
   883 	 * Export data for the JS client.
   886 	 *
   884 	 *