File "acf-value-functions.php"
Full path: /home/kosmetik/public_html/wp-content/plugins/advanced-custom-fields/includes/acf-value-functions.php
File
size: 3.37 B
MIME-type: text/x-php
Charset: utf-8
Download Open Edit Advanced Editor Back
<?php
acf_register_store('values')->prop('multisite', true);
function acf_get_reference($field_name, $post_id)
{
$reference = apply_filters('acf/pre_load_reference', null, $field_name, $post_id);
if ($reference !== null) {
return $reference;
}
$reference = acf_get_metadata($post_id, $field_name, true);
return apply_filters('acf/load_reference', $reference, $field_name, $post_id);
}
function acf_get_value($post_id, $field)
{
$value = apply_filters('acf/pre_load_value', null, $post_id, $field);
if ($value !== null) {
return $value;
}
$field_name = $field['name'];
$store = acf_get_store('values');
if ($store->has("{$post_id}:{$field_name}")) {
return $store->get("{$post_id}:{$field_name}");
}
$value = acf_get_metadata($post_id, $field_name);
if ($value === null && isset($field['default_value'])) {
$value = $field['default_value'];
}
$value = apply_filters('acf/load_value', $value, $post_id, $field);
$store->set("{$post_id}:{$field_name}", $value);
return $value;
}
acf_add_filter_variations('acf/load_value', array('type', 'name', 'key'), 2);
function acf_format_value($value, $post_id, $field)
{
$check = apply_filters('acf/pre_format_value', null, $value, $post_id, $field);
if ($check !== null) {
return $check;
}
$field_name = $field['name'];
$store = acf_get_store('values');
if ($store->has("{$post_id}:{$field_name}:formatted")) {
return $store->get("{$post_id}:{$field_name}:formatted");
}
$value = apply_filters('acf/format_value', $value, $post_id, $field);
$store->set("{$post_id}:{$field_name}:formatted", $value);
return $value;
}
acf_add_filter_variations('acf/format_value', array('type', 'name', 'key'), 2);
function acf_update_value($value, $post_id, $field)
{
$check = apply_filters('acf/pre_update_value', null, $value, $post_id, $field);
if ($check !== null) {
return $check;
}
$value = apply_filters('acf/update_value', $value, $post_id, $field, $value);
if ($value === null) {
return acf_delete_value($post_id, $field);
}
$return = acf_update_metadata($post_id, $field['name'], $value);
acf_update_metadata($post_id, $field['name'], $field['key'], true);
acf_flush_value_cache($post_id, $field['name']);
return $return;
}
acf_add_filter_variations('acf/update_value', array('type', 'name', 'key'), 2);
function acf_update_values($values, $post_id)
{
foreach ($values as $key => $value) {
$field = acf_get_field($key);
if ($field) {
acf_update_value($value, $post_id, $field);
}
}
}
function acf_flush_value_cache($post_id = 0, $field_name = '')
{
acf_get_store('values')->remove("{$post_id}:{$field_name}")->remove("{$post_id}:{$field_name}:formatted");
}
function acf_delete_value($post_id, $field)
{
do_action('acf/delete_value', $post_id, $field['name'], $field);
$return = acf_delete_metadata($post_id, $field['name']);
acf_delete_metadata($post_id, $field['name'], true);
acf_flush_value_cache($post_id, $field['name']);
return $return;
}
acf_add_filter_variations('acf/delete_value', array('type', 'name', 'key'), 2);
function acf_preview_value($value, $post_id, $field)
{
return apply_filters('acf/preview_value', $value, $post_id, $field);
}
acf_add_filter_variations('acf/preview_value', array('type', 'name', 'key'), 2);