File "acf-helper-functions.php"

Full path: /home/kosmetik/public_html/wp-content/plugins/advanced-custom-fields/includes/acf-helper-functions.php
File size: 3.57 B
MIME-type: text/x-php
Charset: utf-8

Download   Open   Edit   Advanced Editor   Back

<?php

function acf_is_empty($var)
{
    return !$var && !is_numeric($var);
}
function acf_not_empty($var)
{
    return $var || is_numeric($var);
}
function acf_uniqid($prefix = 'acf')
{
    global $acf_uniqid;
    if (!isset($acf_uniqid)) {
        $acf_uniqid = 1;
    }
    return $prefix . '-' . $acf_uniqid++;
}
function acf_merge_attributes($array1, $array2)
{
    $array3 = array_merge($array1, $array2);
    foreach (array('class', 'style') as $key) {
        if (isset($array1[$key]) && isset($array2[$key])) {
            $array3[$key] = trim($array1[$key]) . ' ' . trim($array2[$key]);
        }
    }
    return $array3;
}
function acf_cache_key($key = '')
{
    return apply_filters('acf/get_cache_key', $key, $key);
}
function acf_request_args($args = array())
{
    foreach ($args as $k => $v) {
        $args[$k] = isset($_REQUEST[$k]) ? $_REQUEST[$k] : $args[$k];
    }
    return $args;
}
function acf_request_arg($name = '', $default = null)
{
    return isset($_REQUEST[$name]) ? $_REQUEST[$name] : $default;
}
acf_register_store('filters');
function acf_enable_filter($name = '')
{
    acf_get_store('filters')->set($name, true);
}
function acf_disable_filter($name = '')
{
    acf_get_store('filters')->set($name, false);
}
function acf_is_filter_enabled($name = '')
{
    return acf_get_store('filters')->get($name);
}
function acf_get_filters()
{
    return acf_get_store('filters')->get();
}
function acf_set_filters($filters = array())
{
    acf_get_store('filters')->set($filters);
}
function acf_disable_filters()
{
    $prev_state = acf_get_filters();
    acf_set_filters(array_map('__return_false', $prev_state));
    return $prev_state;
}
function acf_enable_filters($filters = array())
{
    $prev_state = acf_get_filters();
    if ($filters) {
        acf_set_filters($filters);
    } else {
        acf_set_filters(array_map('__return_true', $prev_state));
    }
    return $prev_state;
}
function acf_idval($value)
{
    if (is_numeric($value)) {
        return (int) $value;
    } elseif (is_array($value)) {
        return (int) isset($value['ID']) ? $value['ID'] : 0;
    } elseif (is_object($value)) {
        return (int) isset($value->ID) ? $value->ID : 0;
    }
    return 0;
}
function acf_maybe_idval($value)
{
    if ($id = acf_idval($value)) {
        return $id;
    }
    return $value;
}
function acf_numval($value)
{
    return intval($value) == floatval($value) ? intval($value) : floatval($value);
}
function acf_idify($str = '')
{
    return str_replace(array('][', '[', ']'), array('-', '-', ''), strtolower($str));
}
function acf_slugify($str = '', $glue = '-')
{
    return str_replace(array('_', '-', '/', ' '), $glue, strtolower($str));
}
function acf_punctify($str = '')
{
    if (substr(trim(strip_tags($str)), -1) !== '.') {
        return trim($str) . '.';
    }
    return trim($str);
}
function acf_did($name)
{
    if (acf_get_data("acf_did_{$name}")) {
        return true;
    } else {
        acf_set_data("acf_did_{$name}", true);
        return false;
    }
}
function acf_strlen($str)
{
    return mb_strlen(str_replace("\r\n", "\n", wp_specialchars_decode(wp_unslash($str))));
}
function acf_with_default($value, $default_value)
{
    return $value ? $value : $default_value;
}
function acf_doing_action($action)
{
    global $wp_filter;
    if (isset($wp_filter[$action])) {
        return $wp_filter[$action]->current_priority();
    }
    return false;
}
function acf_get_current_url()
{
    if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) {
        return (is_ssl() ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    }
    return '';
}