acf_form_widget::acf_validate_save_postpublicACF 5.4.0

This function will loop over $_POST data and validate

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

Хуков нет.

Возвращает

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

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

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

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

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

Код acf_form_widget::acf_validate_save_post() ACF 6.4.2

public function acf_validate_save_post() {
	// phpcs:disable WordPress.Security.NonceVerification.Missing -- Verified elsewhere.
	// bail early if not widget
	if ( ! isset( $_POST['_acf_widget_id'] ) ) {
		return;
	}

	// vars
	$id     = sanitize_text_field( wp_unslash( $_POST['_acf_widget_id'] ) );
	$number = acf_maybe_get_POST( '_acf_widget_number' );
	$prefix = acf_maybe_get_POST( '_acf_widget_prefix' );
	$values = ! empty( $_POST[ $id ][ $number ]['acf'] ) ? acf_sanitize_request_args( $_POST[ $id ][ $number ]['acf'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash -- unslash not required.

	// validate
	acf_validate_values( $values, $prefix );
	// phpcs:enable WordPress.Security.NonceVerification.Missing
}