ACF_Local_Meta::addpublicACF 5.8.0

add

Adds postmeta to storage. Accepts data in either raw or request format.

Method of the class: ACF_Local_Meta{}

No Hooks.

Returns

Array.

Usage

$ACF_Local_Meta = new ACF_Local_Meta();
$ACF_Local_Meta->add( $meta, $post_id, $is_main );
$meta(array)
An array of metdata to store.
Default: array()
$post_id(mixed)
The post_id for this data.
$is_main(true|false)
Makes this postmeta visible to get_field() without a $post_id value.
Default: false

Changelog

Since 5.8.0 Introduced.

ACF_Local_Meta::add() code ACF 6.0.4

function add( $meta = array(), $post_id = 0, $is_main = false ) {

	// Capture meta if supplied meta is from a REQUEST.
	if ( $this->is_request( $meta ) ) {
		$meta = $this->capture( $meta, $post_id );
	}

	// Add to storage.
	$this->meta[ $post_id ] = $meta;

	// Set $post_id reference when is the "main" postmeta.
	if ( $is_main ) {
		$this->post_id = $post_id;
	}

	// Return meta.
	return $meta;
}