WP_Customize_Manager::handle_override_changeset_lock_request() WordPress Method

The WP_Customize_Manager::handle_override_changeset_lock_request() method is used to override a changeset lock request. This can be useful if you want to take over a changeset that is locked by another user, or if you want to lock a changeset yourself to prevent other users from modifying it.

WP_Customize_Manager::handle_override_changeset_lock_request() #

Removes changeset lock when take over request is sent via Ajax.


Source

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

	public function handle_override_changeset_lock_request() {
		if ( ! $this->is_preview() ) {
			wp_send_json_error( 'not_preview', 400 );
		}

		if ( ! check_ajax_referer( 'customize_override_changeset_lock', 'nonce', false ) ) {
			wp_send_json_error(
				array(
					'code'    => 'invalid_nonce',
					'message' => __( 'Security check failed.' ),
				)
			);
		}

		$changeset_post_id = $this->changeset_post_id();

		if ( empty( $changeset_post_id ) ) {
			wp_send_json_error(
				array(
					'code'    => 'no_changeset_found_to_take_over',
					'message' => __( 'No changeset found to take over' ),
				)
			);
		}

		if ( ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->edit_post, $changeset_post_id ) ) {
			wp_send_json_error(
				array(
					'code'    => 'cannot_remove_changeset_lock',
					'message' => __( 'Sorry, you are not allowed to take over.' ),
				)
			);
		}

		$this->set_changeset_lock( $changeset_post_id, true );

		wp_send_json_success( 'changeset_taken_over' );
	}


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