WP_Customize_Manager::refresh_changeset_lock()publicWP 4.9.0

Refreshes changeset lock with the current time if current user edited the changeset before.

Метод класса: WP_Customize_Manager{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$WP_Customize_Manager = new WP_Customize_Manager();
$WP_Customize_Manager->refresh_changeset_lock( $changeset_post_id );
$changeset_post_id(int) (обязательный)
Changeset post ID.

Список изменений

С версии 4.9.0 Введена.

Код WP_Customize_Manager::refresh_changeset_lock() WP 6.5.2

public function refresh_changeset_lock( $changeset_post_id ) {
	if ( ! $changeset_post_id ) {
		return;
	}

	$lock = get_post_meta( $changeset_post_id, '_edit_lock', true );
	$lock = explode( ':', $lock );

	if ( $lock && ! empty( $lock[1] ) ) {
		$user_id         = (int) $lock[1];
		$current_user_id = get_current_user_id();
		if ( $user_id === $current_user_id ) {
			$lock = sprintf( '%s:%s', time(), $user_id );
			update_post_meta( $changeset_post_id, '_edit_lock', $lock );
		}
	}
}