acf_restrict_save_input() │ ACF 6.8.11

Restricts $_POST['acf'] and $_FILES['acf'] to the top-level keys a save may accept for an object, in place.

Call after verifying the nonce and before acf_validate_save_post(), so dropped keys can't cause validation errors. Also records the render IDs that basic uploader nonces are verified against.

Хуков нет.

Возвращает

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

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

acf_restrict_save_input( $args );
$args(массив) (обязательный)
See acf_filter_save_values().

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

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

Код acf_restrict_save_input() ACF 6.8.11

function acf_restrict_save_input( array $args ) {
	// phpcs:disable WordPress.Security.NonceVerification.Missing -- Verified by the caller.
	$values = isset( $_POST['acf'] ) && is_array( $_POST['acf'] ) ? $_POST['acf'] : array(); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash -- Only keys are read here.
	$keys   = array_keys( $values );

	if ( isset( $_FILES['acf']['name'] ) && is_array( $_FILES['acf']['name'] ) ) {
		$keys = array_merge( $keys, array_keys( $_FILES['acf']['name'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Only keys are read here.
	}

	$allowed = _acf_get_allowed_save_keys( $keys, $args );

	if ( isset( $_POST['acf'] ) ) {
		$_POST['acf'] = array_intersect_key( $values, array_flip( $allowed ) );
	}
	// phpcs:enable WordPress.Security.NonceVerification.Missing

	acf_restrict_uploaded_field_keys( $allowed );
	acf_set_upload_render_ids( $args['render_ids'] ?? array() );
}