WP_Customize_Manager::establish_loaded_changeset() WordPress Method

The establish_loaded_changeset() method is used to load a changeset if one exists in the current request. This is done by checking for the presence of a changeset UUID in the $_REQUEST superglobal, and if one is found, verifying that the current user can edit the changeset. If everything checks out, the changeset data is loaded into the $this->changeset property.

WP_Customize_Manager::establish_loaded_changeset() #

Establishes the loaded changeset.


Description

This method runs right at after_setup_theme and applies the ‘customize_changeset_branching’ filter to determine whether concurrent changesets are allowed. Then if the Customizer is not initialized with a changeset_uuid param, this method will determine which UUID should be used. If changeset branching is disabled, then the most saved changeset will be loaded by default. Otherwise, if there are no existing saved changesets or if changeset branching is enabled, then a new UUID will be generated.


Top ↑

Source

File: wp-includes/class-wp-customize-manager.php

	public function establish_loaded_changeset() {
		global $pagenow;

		if ( empty( $this->_changeset_uuid ) ) {
			$changeset_uuid = null;

			if ( ! $this->branching() && $this->is_theme_active() ) {
				$unpublished_changeset_posts = $this->get_changeset_posts(
					array(
						'post_status'               => array_diff( get_post_stati(), array( 'auto-draft', 'publish', 'trash', 'inherit', 'private' ) ),
						'exclude_restore_dismissed' => false,
						'author'                    => 'any',
						'posts_per_page'            => 1,
						'order'                     => 'DESC',
						'orderby'                   => 'date',
					)
				);
				$unpublished_changeset_post  = array_shift( $unpublished_changeset_posts );
				if ( ! empty( $unpublished_changeset_post ) && wp_is_uuid( $unpublished_changeset_post->post_name ) ) {
					$changeset_uuid = $unpublished_changeset_post->post_name;
				}
			}

			// If no changeset UUID has been set yet, then generate a new one.
			if ( empty( $changeset_uuid ) ) {
				$changeset_uuid = wp_generate_uuid4();
			}

			$this->_changeset_uuid = $changeset_uuid;
		}

		if ( is_admin() && 'customize.php' === $pagenow ) {
			$this->set_changeset_lock( $this->changeset_post_id() );
		}
	}


Top ↑

Changelog

Changelog
VersionDescription
4.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More