ACF_Rest_Api::is_password_protected_content_hidden │ private │ ACF 6.8.11

Checks whether a post's field values must stay out of the response because the post is password protected and the caller has neither unlocked it nor can edit it.

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

Хуков нет.

Возвращает

boolean.

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

// private - только в коде основоного (родительского) класса
$result = $this->is_password_protected_content_hidden( $post_id, $request );
$post_id(int) (обязательный)
The post ID.
$request(WP_REST_Request) (обязательный)
The current request.

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

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

Код ACF_Rest_Api::is_password_protected_content_hidden() ACF 6.8.11

private function is_password_protected_content_hidden( $post_id, $request ) {
	$post = get_post( $post_id );

	if ( ! $post instanceof WP_Post || ! post_password_required( $post ) || current_user_can( 'edit_post', $post->ID ) ) {
		return false;
	}

	$password = $request instanceof WP_REST_Request ? $request->get_param( 'password' ) : '';

	return ! is_string( $password ) || '' === $password || ! hash_equals( $post->post_password, $password );
}