WP_Customize_Manager::get_changeset_posts()protectedWP 4.9.0

Gets changeset posts.

Method of the class: WP_Customize_Manager{}

No Hooks.

Return

WP_Post[]. Auto-draft changesets.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_changeset_posts( $args );
$args(array)

Args to pass into get_posts() query changesets.

Default: array()

  • posts_per_page(int)
    Number of posts to return.
    Default: -1 (all posts)

  • author(int)
    Post author.
    Default: current user

  • post_status(string)
    Status of changeset.
    Default: 'auto-draft'

  • exclude_restore_dismissed(true|false)
    Whether to exclude changeset auto-drafts that have been dismissed.
    Default: true

Changelog

Since 4.9.0 Introduced.

WP_Customize_Manager::get_changeset_posts() code WP 6.6.2

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 );
}