WP_Customize_Manager::dismiss_user_auto_draft_changesets() WordPress Method

The WP_Customize_Manager::dismiss_user_auto_draft_changesets() function dismisses any auto-draft changesets for the current user. This is useful for clearing out unnecessary changesets when a user navigates away from the Customizer.

WP_Customize_Manager::dismiss_user_auto_draft_changesets() #

Dismisses all of the current user’s auto-drafts (other than the present one).


Return

(int) The number of auto-drafts that were dismissed.


Top ↑

Source

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

	protected function dismiss_user_auto_draft_changesets() {
		$changeset_autodraft_posts = $this->get_changeset_posts(
			array(
				'post_status'               => 'auto-draft',
				'exclude_restore_dismissed' => true,
				'posts_per_page'            => -1,
			)
		);
		$dismissed                 = 0;
		foreach ( $changeset_autodraft_posts as $autosave_autodraft_post ) {
			if ( $autosave_autodraft_post->ID === $this->changeset_post_id() ) {
				continue;
			}
			if ( update_post_meta( $autosave_autodraft_post->ID, '_customize_restore_dismissed', true ) ) {
				$dismissed++;
			}
		}
		return $dismissed;
	}


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