ACF_Admin_Internal_Post_Type::verify_save_postpublicACF 6.1

Ran during the save_post to verify that the post should be saved.

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

Хуков нет.

Возвращает

true|false.

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

$ACF_Admin_Internal_Post_Type = new ACF_Admin_Internal_Post_Type();
$ACF_Admin_Internal_Post_Type->verify_save_post( $post_id, $post );
$post_id(int) (обязательный)
The ID of the post being saved.
$post(WP_Post) (обязательный)
The post object.

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

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

Код ACF_Admin_Internal_Post_Type::verify_save_post() ACF 6.4.2

public function verify_save_post( $post_id, $post ) {
	// Do not save if this is an auto save routine.
	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
		return false;
	}

	// Bail early if not an ACF internal post type.
	if ( $post->post_type !== $this->post_type ) {
		return false;
	}

	// Only save once! WordPress saves a revision as well.
	if ( wp_is_post_revision( $post_id ) ) {
		return false;
	}

	// Verify nonce.
	$nonce_name = str_replace(
		array( 'acf-', '-' ),
		array( '', '_' ),
		$this->post_type
	);

	if ( ! acf_verify_nonce( $nonce_name ) ) {
		return false;
	}

	// Bail early if request came from an unauthorised user.
	if ( ! current_user_can( acf_get_setting( 'capability' ) ) ) {
		return false;
	}

	return true;
}