acf_form_attachment::save_attachmentpublicACF 5.0.0

save_attachment

description

Method of the class: acf_form_attachment{}

No Hooks.

Returns

$post_id. (int)

Usage

$acf_form_attachment = new acf_form_attachment();
$acf_form_attachment->save_attachment( $post, $attachment );
$post(required)
.
$attachment(required)
.

Changelog

Since 5.0.0 Introduced.

acf_form_attachment::save_attachment() code ACF 6.0.4

function save_attachment( $post, $attachment ) {

	// bail early if not valid nonce
	if ( ! acf_verify_nonce( 'attachment' ) ) {
		return $post;
	}

	// bypass validation for ajax
	if ( acf_is_ajax( 'save-attachment-compat' ) ) {
		acf_save_post( $post['ID'] );

		// validate and save
	} elseif ( acf_validate_save_post( true ) ) {
		acf_save_post( $post['ID'] );
	}

	// return
	return $post;
}