File "acf-hook-functions.php"
Full path: /home/kosmetik/public_html/wp-content/plugins/advanced-custom-fields/includes/acf-hook-functions.php
File
size: 2.45 B
MIME-type: text/x-php
Charset: utf-8
Download Open Edit Advanced Editor Back
<?php
acf_register_store('hook-variations');
function acf_add_filter_variations($filter = '', $variations = array(), $index = 0)
{
acf_get_store('hook-variations')->set($filter, array('type' => 'filter', 'variations' => $variations, 'index' => $index));
add_filter($filter, '_acf_apply_hook_variations', 10, 10);
}
function acf_add_action_variations($action = '', $variations = array(), $index = 0)
{
acf_get_store('hook-variations')->set($action, array('type' => 'action', 'variations' => $variations, 'index' => $index));
add_action($action, '_acf_apply_hook_variations', 10, 10);
}
function _acf_apply_hook_variations()
{
$filter = current_filter();
$args = func_get_args();
$variations = acf_get_store('hook-variations')->get($filter);
extract($variations);
$field = $args[$index];
foreach ($variations as $variation) {
if (isset($field["_{$variation}"])) {
$value = $field["_{$variation}"];
} elseif (isset($field[$variation])) {
$value = $field[$variation];
} else {
continue;
}
if ($type === 'filter') {
$args[0] = apply_filters_ref_array("{$filter}/{$variation}={$value}", $args);
} else {
do_action_ref_array("{$filter}/{$variation}={$value}", $args);
}
}
return $args[0];
}
acf_register_store('deprecated-hooks');
function acf_add_deprecated_filter($deprecated, $version, $replacement)
{
acf_get_store('deprecated-hooks')->append(array('type' => 'filter', 'deprecated' => $deprecated, 'replacement' => $replacement, 'version' => $version));
add_filter($replacement, '_acf_apply_deprecated_hook', 10, 10);
}
function acf_add_deprecated_action($deprecated, $version, $replacement)
{
acf_get_store('deprecated-hooks')->append(array('type' => 'action', 'deprecated' => $deprecated, 'replacement' => $replacement, 'version' => $version));
add_filter($replacement, '_acf_apply_deprecated_hook', 10, 10);
}
function _acf_apply_deprecated_hook()
{
$hook = current_filter();
$args = func_get_args();
$items = acf_get_store('deprecated-hooks')->query(array('replacement' => $hook));
foreach ($items as $item) {
extract($item);
if (has_filter($deprecated)) {
if ($type === 'filter') {
$args[0] = apply_filters_ref_array($deprecated, $args);
} else {
do_action_ref_array($deprecated, $args);
}
}
}
return $args[0];
}