acf_validation::acf_validate_save_postpublicACF 5.4.0

Loops over $_POST data and validates ACF values.

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

Хуков нет.

Возвращает

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

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

$acf_validation = new acf_validation();
$acf_validation->acf_validate_save_post();

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

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

Код acf_validation::acf_validate_save_post() ACF 6.4.2

public function acf_validate_save_post() {
	// phpcs:disable WordPress.Security.NonceVerification.Missing -- Verified elsewhere.
	$post_type = acf_request_arg( 'post_type', false );
	$screen    = acf_request_arg( '_acf_screen', false );

	if ( in_array( $screen, array( 'post_type', 'taxonomy', 'ui_options_page' ), true ) && in_array( $post_type, array( 'acf-post-type', 'acf-taxonomy', 'acf-ui-options-page' ), true ) ) {
		acf_validate_internal_post_type_values( $post_type );
	} elseif ( acf_request_arg( 'acf_ui_options_page' ) ) {
		acf_validate_internal_post_type_values( 'acf-ui-options-page' );
	} else {
		// Bail early if no matching $_POST.
		if ( empty( $_POST['acf'] ) ) {
			return;
		}

		acf_validate_values( $_POST['acf'], 'acf' ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
	}
	// phpcs:enable WordPress.Security.NonceVerification.Missing
}