Exemplo n.º 1
0
        return shortcode_atts(self::_get_settings_defaults(), $settings);
    }
    public static function register_setting()
    {
        register_setting(EASYAZON_SETTINGS_PAGE, EASYAZON_SETTINGS_NAME, array(__CLASS__, 'sanitize_settings'));
    }
    public static function sanitize_settings($settings)
    {
        $settings = is_array($settings) ? $settings : array();
        $settings_defaults = self::_get_settings_defaults();
        wp_cache_delete(EASYAZON_SETTINGS_NAME);
        $settings = apply_filters('easyazon_sanitize_settings', $settings, $settings, $settings_defaults);
        return shortcode_atts($settings_defaults, $settings);
    }
    private static function _get_settings()
    {
        $settings = wp_cache_get(EASYAZON_SETTINGS_NAME);
        if (!is_array($settings)) {
            $settings = apply_filters('easyazon_pre_get_settings', get_option(EASYAZON_SETTINGS_NAME, self::_get_settings_defaults()));
            wp_cache_set(EASYAZON_SETTINGS_NAME, $settings, null, EASYAZON_CACHE_PERIOD);
        }
        return $settings;
    }
    private static function _get_settings_defaults()
    {
        return apply_filters('easyazon_pre_get_settings_defaults', array());
    }
}
require_once 'lib/settings-functions.php';
EasyAzon_Components_Settings::init();
function easyazon_get_setting($setting_name, $default = false)
{
    return apply_filters(__FUNCTION__ . '_' . $setting_name, apply_filters(__FUNCTION__, EasyAzon_Components_Settings::get_setting($setting_name, $default), $setting_name, $default), $default);
}