acf_save_post()ACF 5.0.0

acf_save_post

Saves the $_POST data.

Хуки из функции

Возвращает

true|false. True if save was successful.

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

acf_save_post( $post_id, $values );
$post_id(int|строка)
The post id.
$values(массив)
An array of values to override $_POST.
По умолчанию: null

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

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

Код acf_save_post() ACF 6.0.4

function acf_save_post( $post_id = 0, $values = null ) {

	// phpcs:disable WordPress.Security.NonceVerification.Missing -- Verified elsewhere.
	// Override $_POST data with $values.
	if ( $values !== null ) {
		$_POST['acf'] = $values;
	}

	// Bail early if no data to save.
	if ( empty( $_POST['acf'] ) ) {
		return false;
	}

	// Set form data (useful in various filters/actions).
	acf_set_form_data( 'post_id', $post_id );

	// Filter $_POST data for users without the 'unfiltered_html' capability.
	if ( ! acf_allow_unfiltered_html() ) {
		$_POST['acf'] = wp_kses_post_deep( $_POST['acf'] );
	}
	// phpcs:enable WordPress.Security.NonceVerification.Missing

	// Do generic action.
	do_action( 'acf/save_post', $post_id );

	// Return true.
	return true;
}