当前位置: 首页>>代码示例>>PHP>>正文


PHP of_get_default_values函数代码示例

本文整理汇总了PHP中of_get_default_values函数的典型用法代码示例。如果您正苦于以下问题:PHP of_get_default_values函数的具体用法?PHP of_get_default_values怎么用?PHP of_get_default_values使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了of_get_default_values函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: populate_defaults

 public function populate_defaults()
 {
     include_once ABSPATH . 'wp-admin/includes/screen.php';
     include_once dirname(dirname(__DIR__)) . '/options.php';
     // Suppress notices resulting from call to of_get_default_values.
     // We're not testing the options framework here.
     $this->options = array_merge($this->options, @of_get_default_values());
 }
开发者ID:NathanLawrence,项目名称:Largo,代码行数:8,代码来源:mock-options-framework.php

示例2: optionsframework_validate

/**
 * 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.', 'options_framework_theme'), 'updated fade');
        return of_get_default_values();
    }
    /*
     * 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
     */
    $clean = array();
    $options =& _optionsframework_options();
    foreach ($options as $option) {
        if (!isset($option['id'])) {
            continue;
        }
        if (!isset($option['type'])) {
            continue;
        }
        $id = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($option['id']));
        // Set checkbox to false if it wasn't sent in the $_POST
        if ('checkbox' == $option['type'] && !isset($input[$id])) {
            $input[$id] = false;
        }
        // Set each item in the multicheck to false if it wasn't sent in the $_POST
        if ('multicheck' == $option['type'] && !isset($input[$id])) {
            foreach ($option['options'] as $key => $value) {
                $input[$id][$key] = false;
            }
        }
        // For a value to be submitted to database it must pass through a sanitization filter
        if (has_filter('of_sanitize_' . $option['type'])) {
            $clean[$id] = apply_filters('of_sanitize_' . $option['type'], $input[$id], $option);
        }
    }
    // Hook to run after validation
    do_action('optionsframework_after_validate', $clean);
    return $clean;
}
开发者ID:selectSIFISO,项目名称:.comsite,代码行数:56,代码来源:options-framework.php

示例3: optionsframework_validate

/** 
 * Validate Options.
 *
 * This runs after the submit/reset button has been clicked and
 * validates the inputs.
 *
 * @uses $_POST['reset']
 * @uses $_POST['update']
 */
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.', 'optionsframework'), 'updated fade');
        return of_get_default_values();
    }
    /*
     * Udpdate Settings.
     */
    if (isset($_POST['update'])) {
        $clean = array();
        $options = optionsframework_options();
        foreach ($options as $option) {
            if (!isset($option['id'])) {
                continue;
            }
            if (!isset($option['type'])) {
                continue;
            }
            $id = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($option['id']));
            // Set checkbox to false if it wasn't sent in the $_POST
            if ('checkbox' == $option['type'] && !isset($input[$id])) {
                $input[$id] = '0';
            }
            // Set each item in the multicheck to false if it wasn't sent in the $_POST
            if ('multicheck' == $option['type'] && !isset($input[$id])) {
                foreach ($option['options'] as $key => $value) {
                    $input[$id][$key] = '0';
                }
            }
            // For a value to be submitted to database it must pass through a sanitization filter
            if (has_filter('of_sanitize_' . $option['type'])) {
                $clean[$id] = apply_filters('of_sanitize_' . $option['type'], $input[$id], $option);
            }
        }
        add_settings_error('options-framework', 'save_options', __('Options saved.', 'optionsframework'), 'updated fade');
        return $clean;
    }
    /*
     * Request Not Recognized.
     */
    return of_get_default_values();
}
开发者ID:eduarhp,项目名称:NuFronteer,代码行数:59,代码来源:options-framework.php

示例4: largo_set_new_option_defaults

/**
 * Save default values for any newly introduced options to the database
 *
 * Note: this must be called before any other update function calls `of_set_option`,
 * as `of_set_uption` defaults all values to null.
 *
 * @since 0.5.1
 */
function largo_set_new_option_defaults()
{
    // Gets the unique id, returning a default if it isn't defined
    $config = get_option('optionsframework');
    if (isset($config['id'])) {
        $options = get_option($config['id']);
        // a list of saved options
        $defaults = of_get_default_values();
        // the list of default values.
        $options = wp_parse_args($options, $defaults);
        // merge 'em.
        update_option($config['id'], $options);
    }
}
开发者ID:uniteddiversity,项目名称:Largo,代码行数:22,代码来源:update.php

示例5: optionsframework_validate

/**
 * 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);
//.........这里部分代码省略.........
开发者ID:scottnkerr,项目名称:eeco,代码行数:101,代码来源:options-framework.php

示例6: largo_set_new_option_defaults

/**
 * Save default values for any newly introduced options to the database
 *
 * Note: this must be called before any other update function calls `of_set_option`,
 * as `of_set_uption` defaults all values to null.
 *
 * @since 0.5.1
 */
function largo_set_new_option_defaults()
{
    // Gets the unique id, returning a default if it isn't defined
    $config = get_option('optionsframework');
    if (isset($config['id'])) {
        $defaults = of_get_default_values();
        // the list of default values.
        $previous_options = largo_retrieve_previous_options();
        $options = wp_parse_args($previous_options, $defaults);
        update_option($config['id'], $options);
    }
}
开发者ID:NathanLawrence,项目名称:Largo,代码行数:20,代码来源:update.php

示例7: optionsframework_validate

/** 
 * Validate Options.
 *
 * This runs after the submit/reset button has been clicked and
 * validates the inputs.
 *
 * @uses $_POST['reset']
 * @uses $_POST['update']
 */
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', _x('Default options restored.', 'optionsframework', 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);
    }
    /*
     * Udpdate Settings.
     */
    $clean = array();
    $options_orig = optionsframework_options();
    $options = array_filter($options_orig, 'optionsframework_options_for_page_filter');
    foreach ($options as $option) {
        if (!isset($option['id'])) {
            continue;
        }
        if (!isset($option['type'])) {
            continue;
        }
        $sanitize = isset($option['sanitize']) ? $option['sanitize'] : true;
        $id = preg_replace('/(\\W!-)/', '', strtolower($option['id']));
        // Set checkbox to false if it wasn't sent in the $_POST
        if ('checkbox' == $option['type'] && !isset($input[$id])) {
            $input[$id] = '0';
        }
        // Set each item in the multicheck to false if it wasn't sent in the $_POST
        if ('multicheck' == $option['type'] && !isset($input[$id])) {
            foreach ($option['options'] as $key => $value) {
                $input[$id][$key] = '0';
            }
        }
        if (!isset($input[$id])) {
            continue;
        }
        // For a value to be submitted to database it must pass through a sanitization filter
        if (!has_filter('of_sanitize_' . $option['type'])) {
            continue;
        }
        if ($sanitize) {
            $clean[$id] = apply_filters('of_sanitize_' . $option['type'], $input[$id], $option);
        } else {
            $clean[$id] = $input[$id];
        }
    }
    unset($option);
    $known_options = get_option('optionsframework', array());
    $saved_options = get_option($known_options['id'], array());
    if (isset($clean['of-preset'])) {
        $preserve = array('of_generatortest2', 'social_icons', 'branding-header_logo', 'branding-retina_header_logo', 'branding-header_mobile_logo', 'branding-retina_header_mobile_logo', 'branding-footer_logo', 'branding-retina_footer_logo', 'branding-favicon', "branding-copyrights", 'branding-dt_credits', 'misc-static_css', 'misc-rollover_blur', 'misc-show_header_contacts', 'misc-contact_address', 'misc-contact_phone', 'misc-contact_email', 'misc-contact_skype', 'misc-contact_work_hours', 'misc-show_next_prev_post', 'misc-show_next_prev_portfolio', 'misc-show_top_line', 'misc-show_search_top', 'misc-show_author_details', 'misc-analitics_code', 'menu-parent_menu_clickable', 'social-like_post', 'social-like_portfolio', 'social-like_catalog', 'social-like_gallery', 'social-like_photo', 'social-like_video', 'social-like_button_google_plus', 'social-like_button_twitter', 'social-like_button_faceboock');
        $preset_options = optionsframework_presets_data($clean['of-preset']);
        foreach ($preserve as $pres) {
            if (isset($preset_options[$pres])) {
                unset($preset_options[$pres]);
            }
        }
        $saved_options = array_merge((array) $saved_options, $preset_options);
    }
    $clean = array_merge($saved_options, $clean);
    add_settings_error('options-framework', 'save_options', _x('Options saved.', 'optionsframework', LANGUAGE_ZONE), 'updated fade');
    return $clean;
}
开发者ID:mnjit,项目名称:aa-global,代码行数:83,代码来源:options-framework.php


注:本文中的of_get_default_values函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。