WP_Customize_Manager::find_changeset_post_id() WordPress Method

The WP_Customize_Manager::find_changeset_post_id() method is used to find the post ID for a changeset. A changeset is a special post type that is used to store changes to the WordPress Customizer. This method is used to find the post ID for a changeset so that the changeset can be updated.

WP_Customize_Manager::find_changeset_post_id( string $uuid ) #

Finds the changeset post ID for a given changeset UUID.


Parameters

$uuid

(string)(Required)Changeset UUID.


Top ↑

Return

(int|null) Returns post ID on success and null on failure.


Top ↑

Source

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

	public function find_changeset_post_id( $uuid ) {
		$cache_group       = 'customize_changeset_post';
		$changeset_post_id = wp_cache_get( $uuid, $cache_group );
		if ( $changeset_post_id && 'customize_changeset' === get_post_type( $changeset_post_id ) ) {
			return $changeset_post_id;
		}

		$changeset_post_query = new WP_Query(
			array(
				'post_type'              => 'customize_changeset',
				'post_status'            => get_post_stati(),
				'name'                   => $uuid,
				'posts_per_page'         => 1,
				'no_found_rows'          => true,
				'cache_results'          => true,
				'update_post_meta_cache' => false,
				'update_post_term_cache' => false,
				'lazy_load_term_meta'    => false,
			)
		);
		if ( ! empty( $changeset_post_query->posts ) ) {
			// Note: 'fields'=>'ids' is not being used in order to cache the post object as it will be needed.
			$changeset_post_id = $changeset_post_query->posts[0]->ID;
			wp_cache_set( $uuid, $changeset_post_id, $cache_group );
			return $changeset_post_id;
		}

		return null;
	}


Top ↑

Changelog

Changelog
VersionDescription
4.7.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