コード例 #1
0
ファイル: options-presets.php プロジェクト: mnjit/aa-global
<?php

/**
 * Skins options.
 */
// File Security Check
if (!defined('ABSPATH')) {
    exit;
}
// page
$options[] = array("name" => _x('Skins', 'theme-options', LANGUAGE_ZONE), "type" => "heading");
$options[] = array("name" => _x('Select a skin', 'theme-options', LANGUAGE_ZONE), "type" => "block_begin");
$options[] = array("name" => '', "desc" => '', "id" => "of-preset", "std" => 'blue', "type" => "images", "options" => optionsframework_get_presets_list());
$options[] = array("type" => "block_end");
コード例 #2
0
function optionsframework_presets_data($id)
{
    static $presets = null;
    if (null === $presets) {
        $presets = array();
        foreach (optionsframework_get_presets_list() as $fname => $thumb) {
            $file = OPTIONS_FRAMEWORK_PRESETS_DIR . $fname . '.php';
            if (is_readable($file)) {
                include_once $file;
            }
        }
    }
    if (isset($presets[$id])) {
        return $presets[$id];
    }
    return array();
}
コード例 #3
0
ファイル: options-framework.php プロジェクト: scottnkerr/eeco
/**
 * Validate Options.
 *
 * This runs after the submit/reset button has been clicked and
 * validates the inputs.
 *
 * @uses $_POST['reset'] to restore default options
 */
function optionsframework_validate($input)
{
    /*
     * Restore Defaults.
     *
     * In the event that the user clicked the "Restore Defaults"
     * button, the options defined in the theme's options.php
     * file will be added to the option for the active theme.
     */
    if (isset($_POST['reset'])) {
        add_settings_error('options-framework', 'restore_defaults', __('Default options restored.', LANGUAGE_ZONE), 'updated fade');
        $current = null;
        if (isset($_POST['_wp_http_referer'])) {
            $arr = array();
            wp_parse_str($_POST['_wp_http_referer'], $arr);
            $current = current($arr);
        }
        return of_get_default_values($current);
    }
    /*
     * Update Settings
     *
     * This used to check for $_POST['update'], but has been updated
     * to be compatible with the theme customizer introduced in WordPress 3.4
     */
    // Get all defined options
    $options_orig =& _optionsframework_options();
    // Get all saved options
    $known_options = get_option('optionsframework', array());
    $saved_options = get_option($known_options['id'], array());
    $clean = array();
    $preserve = apply_filters('optionsframework_validate_preserve_fields', array());
    $presets_list = optionsframework_get_presets_list();
    // If there are preset option on this page - use this options instead saved
    if (isset($input['preset']) && in_array($input['preset'], array_keys($presets_list))) {
        // Get preset options
        $preset_options = optionsframework_presets_data($input['preset']);
        // Ignore preserved options
        foreach ($preserve as $option) {
            if (isset($preset_options[$option])) {
                unset($preset_options[$option]);
            }
        }
        if (!isset($preset_options['preset'])) {
            $preset_options['preset'] = $input['preset'];
        }
        // Use all options for sanitazing
        $options = $options_orig;
        // Merge options, use preset options
        $saved_options = $used_options = array_merge((array) $saved_options, $preset_options);
        $is_preset = true;
        // If regular page
    } else {
        // Get kurrent preset options
        $preset_options = optionsframework_presets_data($saved_options['preset']);
        // Options only for current page
        $options = array_filter($options_orig, 'optionsframework_options_for_page_filter');
        // Defune options data with which we will work
        $used_options = $input;
        $is_preset = false;
    }
    // Sanitize options
    foreach ($options as $option) {
        if (!isset($option['id'])) {
            continue;
        }
        if (!isset($option['type'])) {
            continue;
        }
        $id = preg_replace('/(\\W!-)/', '', strtolower($option['id']));
        // Set checkbox to false if it wasn't sent in the $_POST
        if ('checkbox' == $option['type'] && !isset($used_options[$id])) {
            $used_options[$id] = false;
        }
        // Set each item in the multicheck to false if it wasn't sent in the $_POST
        if ('multicheck' == $option['type'] && !isset($used_options[$id])) {
            foreach ($option['options'] as $key => $value) {
                $used_options[$id][$key] = false;
            }
        }
        // Use preset value instead native std
        if (isset($preset_options[$id])) {
            $option['std'] = $preset_options[$id];
        }
        if ($is_preset) {
            if ('upload' == $option['type'] && isset($used_options[$id]) && is_array($used_options[$id])) {
                $used_options[$id] = array_reverse($used_options[$id]);
            }
        }
        // For a value to be submitted to database it must pass through a sanitization filter
        if (!empty($option['sanitize']) && has_filter('of_sanitize_' . $option['sanitize'])) {
            $clean[$id] = apply_filters('of_sanitize_' . $option['sanitize'], $used_options[$id], $option);
        } elseif (has_filter('of_sanitize_' . $option['type'])) {
            $clean[$id] = apply_filters('of_sanitize_' . $option['type'], $used_options[$id], $option);
        }
    }
    // Merge current options and saved ones
    $clean = array_merge($saved_options, $clean);
    // Hook to run after validation
    do_action('optionsframework_after_validate', $clean, $input);
    return $clean;
}
コード例 #4
0
<?php

/**
 * Skins.
 *
 * @package the7
 * @since 1.0.0
 */
if (!defined('ABSPATH')) {
    exit;
    // Exit if accessed directly
}
$options[] = array('desc' => sprintf(_x("<strong>Attention!</strong> Changing skin will overwrite most of your settings.\nYou may want to use <a href='%s'>Export/Import Options</a> interface to backup your current theme options.", 'theme-options', 'the7mk2'), admin_url('admin.php?page=of-importexport-menu')), 'type' => 'info');
$options[] = array('name' => _x('Skins', 'theme-options', 'the7mk2'), 'type' => 'heading');
$options[] = array('name' => _x('Skins', 'theme-options', 'the7mk2'), 'type' => 'block');
$options['preset'] = array('id' => 'preset', 'std' => 'none', 'type' => 'images', 'options' => optionsframework_get_presets_list());
コード例 #5
0
ファイル: options-functions.php プロジェクト: mnjit/aa-global
function optionsframework_presets_data($id)
{
    static $presets = array();
    if (empty($presets)) {
        foreach (optionsframework_get_presets_list() as $fname => $thumb) {
            $file = dirname(__FILE__) . '/presets/' . $fname . '.php';
            if (is_readable($file)) {
                include $file;
            }
        }
    }
    if (isset($presets[$id])) {
        return $presets[$id];
    }
    return array();
}
コード例 #6
0
function optionsframework_presets_data($id)
{
    $preset = array();
    $registered_presets = optionsframework_get_presets_list();
    if (array_key_exists($id, $registered_presets)) {
        $preset = apply_filters('presscore_options_return_preset', array(), $id);
        if ($preset) {
            return $preset;
        }
        include OPTIONS_FRAMEWORK_PRESETS_DIR . $id . '.php';
        if (isset($presets[$id])) {
            $preset = $presets[$id];
        }
    }
    return $preset;
}