WP_Customize_Manager::get_changeset_posts() WordPress Method

The WP_Customize_Manager::get_changeset_posts() function retrieves all of the posts that have been saved as part of a changeset. This function is useful for displaying a list of all the posts that have been customized, as well as for finding out which posts have not been saved as part of a changeset.

WP_Customize_Manager::get_changeset_posts( array $args = array() ) #

Gets changeset posts.


Parameters

$args

(array)(Optional)Args to pass into get_posts() to query changesets.

  • 'posts_per_page'
    (int) Number of posts to return. Defaults to -1 (all posts).
  • 'author'
    (int) Post author. Defaults to current user.
  • 'post_status'
    (string) Status of changeset. Defaults to 'auto-draft'.
  • 'exclude_restore_dismissed'
    (bool) Whether to exclude changeset auto-drafts that have been dismissed. Defaults to true.

Default value: array()


Top ↑

Return

(WP_Post[]) Auto-draft changesets.


Top ↑

Source

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

	protected function get_changeset_posts( $args = array() ) {
		$default_args = array(
			'exclude_restore_dismissed' => true,
			'posts_per_page'            => -1,
			'post_type'                 => 'customize_changeset',
			'post_status'               => 'auto-draft',
			'order'                     => 'DESC',
			'orderby'                   => 'date',
			'no_found_rows'             => true,
			'cache_results'             => true,
			'update_post_meta_cache'    => false,
			'update_post_term_cache'    => false,
			'lazy_load_term_meta'       => false,
		);
		if ( get_current_user_id() ) {
			$default_args['author'] = get_current_user_id();
		}
		$args = array_merge( $default_args, $args );

		if ( ! empty( $args['exclude_restore_dismissed'] ) ) {
			unset( $args['exclude_restore_dismissed'] );
			$args['meta_query'] = array(
				array(
					'key'     => '_customize_restore_dismissed',
					'compare' => 'NOT EXISTS',
				),
			);
		}

		return get_posts( $args );
	}


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