WP_Customize_Manager::check_changeset_lock_with_heartbeat() WordPress Method

The WP_Customize_Manager::check_changeset_lock_with_heartbeat() method is used to check if a changeset lock is still valid. If the lock has expired, the changeset will be unlocked and a notice will be displayed to the user.

WP_Customize_Manager::check_changeset_lock_with_heartbeat( array $response, array $data, string $screen_id ) #

Checks locked changeset with heartbeat API.


Parameters

$response

(array)(Required)The Heartbeat response.

$data

(array)(Required)The $_POST data sent.

$screen_id

(string)(Required)The screen id.


Top ↑

Return

(array) The Heartbeat response.


Top ↑

Source

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

	public function check_changeset_lock_with_heartbeat( $response, $data, $screen_id ) {
		if ( isset( $data['changeset_uuid'] ) ) {
			$changeset_post_id = $this->find_changeset_post_id( $data['changeset_uuid'] );
		} else {
			$changeset_post_id = $this->changeset_post_id();
		}

		if (
			array_key_exists( 'check_changeset_lock', $data )
			&& 'customize' === $screen_id
			&& $changeset_post_id
			&& current_user_can( get_post_type_object( 'customize_changeset' )->cap->edit_post, $changeset_post_id )
		) {
			$lock_user_id = wp_check_post_lock( $changeset_post_id );

			if ( $lock_user_id ) {
				$response['customize_changeset_lock_user'] = $this->get_lock_user_data( $lock_user_id );
			} else {

				// Refreshing time will ensure that the user is sitting on customizer and has not closed the customizer tab.
				$this->refresh_changeset_lock( $changeset_post_id );
			}
		}

		return $response;
	}


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