wp/wp-includes/class-wp-customize-manager.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
  1229 					$settings = get_option( "widget_{$id_base}", array() );
  1229 					$settings = get_option( "widget_{$id_base}", array() );
  1230 					if ( $settings instanceof ArrayObject || $settings instanceof ArrayIterator ) {
  1230 					if ( $settings instanceof ArrayObject || $settings instanceof ArrayIterator ) {
  1231 						$settings = $settings->getArrayCopy();
  1231 						$settings = $settings->getArrayCopy();
  1232 					}
  1232 					}
  1233 
  1233 
       
  1234 					unset( $settings['_multiwidget'] );
       
  1235 
  1234 					// Find the max widget number for this type.
  1236 					// Find the max widget number for this type.
  1235 					$widget_numbers = array_keys( $settings );
  1237 					$widget_numbers = array_keys( $settings );
  1236 					if ( count( $widget_numbers ) > 0 ) {
  1238 					if ( count( $widget_numbers ) > 0 ) {
  1237 						$widget_numbers[]               = 1;
  1239 						$widget_numbers[]               = 1;
  1238 						$max_widget_numbers[ $id_base ] = max( ...$widget_numbers );
  1240 						$max_widget_numbers[ $id_base ] = max( ...$widget_numbers );
  1459 					! in_array( $setting_id, $reused_nav_menu_setting_ids, true )
  1461 					! in_array( $setting_id, $reused_nav_menu_setting_ids, true )
  1460 					&&
  1462 					&&
  1461 					preg_match( '#^nav_menu\[(?P<nav_menu_id>-?\d+)\]$#', $setting_id, $matches )
  1463 					preg_match( '#^nav_menu\[(?P<nav_menu_id>-?\d+)\]$#', $setting_id, $matches )
  1462 				);
  1464 				);
  1463 				if ( $can_reuse ) {
  1465 				if ( $can_reuse ) {
  1464 					$nav_menu_term_id              = intval( $matches['nav_menu_id'] );
  1466 					$nav_menu_term_id              = (int) $matches['nav_menu_id'];
  1465 					$nav_menu_setting_id           = $setting_id;
  1467 					$nav_menu_setting_id           = $setting_id;
  1466 					$reused_nav_menu_setting_ids[] = $setting_id;
  1468 					$reused_nav_menu_setting_ids[] = $setting_id;
  1467 					break;
  1469 					break;
  1468 				}
  1470 				}
  1469 			}
  1471 			}
  1896 		 */
  1898 		 */
  1897 		if ( ! headers_sent() ) {
  1899 		if ( ! headers_sent() ) {
  1898 			nocache_headers();
  1900 			nocache_headers();
  1899 			header( 'X-Robots: noindex, nofollow, noarchive' );
  1901 			header( 'X-Robots: noindex, nofollow, noarchive' );
  1900 		}
  1902 		}
  1901 		add_action( 'wp_head', 'wp_no_robots' );
  1903 		add_filter( 'wp_robots', 'wp_robots_no_robots' );
  1902 		add_filter( 'wp_headers', array( $this, 'filter_iframe_security_headers' ) );
  1904 		add_filter( 'wp_headers', array( $this, 'filter_iframe_security_headers' ) );
  1903 
  1905 
  1904 		/*
  1906 		/*
  1905 		 * If preview is being served inside the customizer preview iframe, and
  1907 		 * If preview is being served inside the customizer preview iframe, and
  1906 		 * if the user doesn't have customize capability, then it is assumed
  1908 		 * if the user doesn't have customize capability, then it is assumed
  1939 		 */
  1941 		 */
  1940 		do_action( 'customize_preview_init', $this );
  1942 		do_action( 'customize_preview_init', $this );
  1941 	}
  1943 	}
  1942 
  1944 
  1943 	/**
  1945 	/**
  1944 	 * Filter the X-Frame-Options and Content-Security-Policy headers to ensure frontend can load in customizer.
  1946 	 * Filters the X-Frame-Options and Content-Security-Policy headers to ensure frontend can load in customizer.
  1945 	 *
  1947 	 *
  1946 	 * @since 4.7.0
  1948 	 * @since 4.7.0
  1947 	 *
  1949 	 *
  1948 	 * @param array $headers Headers.
  1950 	 * @param array $headers Headers.
  1949 	 * @return array Headers.
  1951 	 * @return array Headers.
  2393 	public function prepare_setting_validity_for_js( $validity ) {
  2395 	public function prepare_setting_validity_for_js( $validity ) {
  2394 		if ( is_wp_error( $validity ) ) {
  2396 		if ( is_wp_error( $validity ) ) {
  2395 			$notification = array();
  2397 			$notification = array();
  2396 			foreach ( $validity->errors as $error_code => $error_messages ) {
  2398 			foreach ( $validity->errors as $error_code => $error_messages ) {
  2397 				$notification[ $error_code ] = array(
  2399 				$notification[ $error_code ] = array(
  2398 					'message' => join( ' ', $error_messages ),
  2400 					'message' => implode( ' ', $error_messages ),
  2399 					'data'    => $validity->get_error_data( $error_code ),
  2401 					'data'    => $validity->get_error_data( $error_code ),
  2400 				);
  2402 				);
  2401 			}
  2403 			}
  2402 			return $notification;
  2404 			return $notification;
  2403 		} else {
  2405 		} else {
  3101 		do_action( 'save_post', $post->ID, $post, true );
  3103 		do_action( 'save_post', $post->ID, $post, true );
  3102 
  3104 
  3103 		/** This action is documented in wp-includes/post.php */
  3105 		/** This action is documented in wp-includes/post.php */
  3104 		do_action( 'wp_insert_post', $post->ID, $post, true );
  3106 		do_action( 'wp_insert_post', $post->ID, $post, true );
  3105 
  3107 
       
  3108 		wp_after_insert_post( get_post( $post_id ), true, $post );
       
  3109 
  3106 		wp_trash_post_comments( $post_id );
  3110 		wp_trash_post_comments( $post_id );
  3107 
  3111 
  3108 		/** This action is documented in wp-includes/post.php */
  3112 		/** This action is documented in wp-includes/post.php */
  3109 		do_action( 'trashed_post', $post_id );
  3113 		do_action( 'trashed_post', $post_id );
  3110 
  3114 
  3264 		}
  3268 		}
  3265 		$lock = get_post_meta( $changeset_post_id, '_edit_lock', true );
  3269 		$lock = get_post_meta( $changeset_post_id, '_edit_lock', true );
  3266 		$lock = explode( ':', $lock );
  3270 		$lock = explode( ':', $lock );
  3267 
  3271 
  3268 		if ( $lock && ! empty( $lock[1] ) ) {
  3272 		if ( $lock && ! empty( $lock[1] ) ) {
  3269 			$user_id         = intval( $lock[1] );
  3273 			$user_id         = (int) $lock[1];
  3270 			$current_user_id = get_current_user_id();
  3274 			$current_user_id = get_current_user_id();
  3271 			if ( $user_id === $current_user_id ) {
  3275 			if ( $user_id === $current_user_id ) {
  3272 				$lock = sprintf( '%s:%s', time(), $user_id );
  3276 				$lock = sprintf( '%s:%s', time(), $user_id );
  3273 				update_post_meta( $changeset_post_id, '_edit_lock', $lock );
  3277 				update_post_meta( $changeset_post_id, '_edit_lock', $lock );
  3274 			}
  3278 			}
  3275 		}
  3279 		}
  3276 	}
  3280 	}
  3277 
  3281 
  3278 	/**
  3282 	/**
  3279 	 * Filter heartbeat settings for the Customizer.
  3283 	 * Filters heartbeat settings for the Customizer.
  3280 	 *
  3284 	 *
  3281 	 * @since 4.9.0
  3285 	 * @since 4.9.0
  3282 	 * @param array $settings Current settings to filter.
  3286 	 * @param array $settings Current settings to filter.
  3283 	 * @return array Heartbeat settings.
  3287 	 * @return array Heartbeat settings.
  3284 	 */
  3288 	 */
  3901 	 * @param string $id Panel ID to remove.
  3905 	 * @param string $id Panel ID to remove.
  3902 	 */
  3906 	 */
  3903 	public function remove_panel( $id ) {
  3907 	public function remove_panel( $id ) {
  3904 		// Removing core components this way is _doing_it_wrong().
  3908 		// Removing core components this way is _doing_it_wrong().
  3905 		if ( in_array( $id, $this->components, true ) ) {
  3909 		if ( in_array( $id, $this->components, true ) ) {
  3906 			$message = sprintf(
  3910 			_doing_it_wrong(
  3907 				/* translators: 1: Panel ID, 2: Link to 'customize_loaded_components' filter reference. */
  3911 				__METHOD__,
  3908 				__( 'Removing %1$s manually will cause PHP warnings. Use the %2$s filter instead.' ),
       
  3909 				$id,
       
  3910 				sprintf(
  3912 				sprintf(
  3911 					'<a href="%1$s">%2$s</a>',
  3913 					/* translators: 1: Panel ID, 2: Link to 'customize_loaded_components' filter reference. */
  3912 					esc_url( 'https://developer.wordpress.org/reference/hooks/customize_loaded_components/' ),
  3914 					__( 'Removing %1$s manually will cause PHP warnings. Use the %2$s filter instead.' ),
  3913 					'<code>customize_loaded_components</code>'
  3915 					$id,
  3914 				)
  3916 					sprintf(
       
  3917 						'<a href="%1$s">%2$s</a>',
       
  3918 						esc_url( 'https://developer.wordpress.org/reference/hooks/customize_loaded_components/' ),
       
  3919 						'<code>customize_loaded_components</code>'
       
  3920 					)
       
  3921 				),
       
  3922 				'4.5.0'
  3915 			);
  3923 			);
  3916 
       
  3917 			_doing_it_wrong( __METHOD__, $message, '4.5.0' );
       
  3918 		}
  3924 		}
  3919 		unset( $this->panels[ $id ] );
  3925 		unset( $this->panels[ $id ] );
  3920 	}
  3926 	}
  3921 
  3927 
  3922 	/**
  3928 	/**
  4271 		</script>
  4277 		</script>
  4272 
  4278 
  4273 		<script type="text/html" id="tmpl-customize-changeset-locked-notification">
  4279 		<script type="text/html" id="tmpl-customize-changeset-locked-notification">
  4274 			<li class="notice notice-{{ data.type || 'info' }} {{ data.containerClasses || '' }}" data-code="{{ data.code }}" data-type="{{ data.type }}">
  4280 			<li class="notice notice-{{ data.type || 'info' }} {{ data.containerClasses || '' }}" data-code="{{ data.code }}" data-type="{{ data.type }}">
  4275 				<div class="notification-message customize-changeset-locked-message">
  4281 				<div class="notification-message customize-changeset-locked-message">
  4276 					<img class="customize-changeset-locked-avatar" src="{{ data.lockUser.avatar }}" alt="{{ data.lockUser.name }}">
  4282 					<img class="customize-changeset-locked-avatar" src="{{ data.lockUser.avatar }}" alt="{{ data.lockUser.name }}" />
  4277 					<p class="currently-editing">
  4283 					<p class="currently-editing">
  4278 						<# if ( data.message ) { #>
  4284 						<# if ( data.message ) { #>
  4279 							{{{ data.message }}}
  4285 							{{{ data.message }}}
  4280 						<# } else if ( data.allowOverride ) { #>
  4286 						<# } else if ( data.allowOverride ) { #>
  4281 							<?php
  4287 							<?php