Exemplo n.º 1
0
/**
 * PageLines Option
 *
 * Uses controls to find and retrieve the appropriate option value
 *
 * @package PageLines DMS
 *
 * @since   ...
 *
 * @link    http://www.pagelines.com/wiki/Ploption
 *
 * @param   'key' the id of the option
 * @param   array $args
 *
 * @uses    is_pagelines_special
 * @uses    plspecial
 * @uses    plmeta
 * @uses    pldefault
 * @uses    get_ploption
 * @uses    plnewkey
 *
 * @return  bool|mixed
 */
function ploption($key, $args = array())
{
    _pl_deprecated_function(__FUNCTION__, '1.1', 'pl_setting()');
    $d = array('subkey' => null, 'post_id' => null, 'setting' => null, 'clone_id' => null, 'type' => '', 'translate' => false, 'key' => $key);
    $o = wp_parse_args($args, $d);
    if (has_filter("ploption_{$key}")) {
        return apply_filters("ploption_{$key}", $key, $o);
    }
    if (class_exists('PageLinesTemplateHandler') && pl_setting($key, $o)) {
        return pagelines_magic_parse(pl_setting($key, $o), $o);
    } elseif (is_pagelines_special($o) && plspecial($key, $o)) {
        return pagelines_magic_parse(plspecial($key, $o), $o);
    } elseif (isset($o['post_id']) && plmeta($key, $args)) {
        return pagelines_magic_parse(plmeta($key, $o), $o);
    } elseif (pldefault($key, $o)) {
        return pldefault($key, $o);
    } elseif (get_ploption($key, $o)) {
        return pagelines_magic_parse(get_ploption($key, $o), $o);
    } elseif (get_ploption($key, $o) === null) {
        if ($newkey = plnewkey($key)) {
            return $newkey;
        } else {
            return false;
        }
    }
}
Exemplo n.º 2
0
/**
 * Grab from global defaults panel
 *
 * @param 'key' the id of the option
 *
 **/
function pldefault($key, $args = array(), $mode = '')
{
    global $pagelines_special_meta;
    $sp = $pagelines_special_meta;
    $slug = 'default';
    $reverse_key = $key . '_reverse';
    $default_value = isset($sp[$slug]) && is_array($sp[$slug]) && isset($sp[$slug][$key]) ? $sp[$slug][$key] : false;
    // check if on default option is reversed by meta
    $reverse_value = $mode != 'val' && (plmeta($reverse_key, $args) || plspecial($reverse_key, $args)) ? true : false;
    if (!$reverse_value) {
        return $default_value;
    } else {
        return false;
    }
}