Create New Item
×
Item Type
File
Folder
Item Name
×
Search file in folder and subfolders...
File Manager
/
wp-content
/
plugins
/
advanced-custom-fields
/
includes
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php if (!defined('ABSPATH')) { exit; } if (!class_exists('ACF_Local_Meta')) { class ACF_Local_Meta { var $meta = array(); var $post_id = 0; function __construct() { add_filter('acf/pre_load_post_id', array($this, 'pre_load_post_id'), 1, 2); add_filter('acf/pre_load_meta', array($this, 'pre_load_meta'), 1, 2); add_filter('acf/pre_load_metadata', array($this, 'pre_load_metadata'), 1, 4); } function add($meta = array(), $post_id = 0, $is_main = false) { if ($this->is_request($meta)) { $meta = $this->capture($meta, $post_id); } $this->meta[$post_id] = $meta; if ($is_main) { $this->post_id = $post_id; } return $meta; } function is_request($meta = array()) { return acf_is_field_key(key($meta)); } function capture($values = array(), $post_id = 0) { $this->meta[$post_id] = array(); add_filter('acf/pre_update_metadata', array($this, 'capture_update_metadata'), 1, 5); if ($values) { acf_update_values($values, $post_id); } remove_filter('acf/pre_update_metadata', array($this, 'capture_update_metadata'), 1, 5); return $this->meta[$post_id]; } function capture_update_metadata($null, $post_id, $name, $value, $hidden) { $name = ($hidden ? '_' : '') . $name; $this->meta[$post_id][$name] = $value; return true; } function remove($post_id = 0) { unset($this->meta[$post_id]); if ($post_id === $this->post_id) { $this->post_id = 0; } } function pre_load_meta($null, $post_id) { if (isset($this->meta[$post_id])) { return $this->meta[$post_id]; } return $null; } function pre_load_metadata($null, $post_id, $name, $hidden) { $name = ($hidden ? '_' : '') . $name; if (isset($this->meta[$post_id])) { if (isset($this->meta[$post_id][$name])) { return $this->meta[$post_id][$name]; } return '__return_null'; } return $null; } function pre_load_post_id($null, $post_id) { if (!$post_id && $this->post_id) { return $this->post_id; } return $null; } } } function acf_setup_meta($meta = array(), $post_id = 0, $is_main = false) { return acf_get_instance('ACF_Local_Meta')->add($meta, $post_id, $is_main); } function acf_reset_meta($post_id = 0) { return acf_get_instance('ACF_Local_Meta')->remove($post_id); }