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


PHP WP_Customize_Control::get_setting方法代码示例

本文整理汇总了PHP中WP_Customize_Control::get_setting方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Customize_Control::get_setting方法的具体用法?PHP WP_Customize_Control::get_setting怎么用?PHP WP_Customize_Control::get_setting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WP_Customize_Control的用法示例。


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

示例1: ya_customize_register

/**
 * Adds sections to the customizer
 * @param WP_Customize_Control $wp_customize
 */
function ya_customize_register($wp_customize)
{
    $priority = 200;
    $sections = array();
    $ya_options = ya_options();
    $i = 0;
    foreach ($ya_options->sections as $section) {
        if (isset($section['fields']) && is_array($section['fields'])) {
            foreach ($section['fields'] as $field) {
                $customize = $field['id'] . '_customize_allow';
                if ($ya_options->get($customize)) {
                    if (isset($field['options'])) {
                        $field['choices'] = $field['options'];
                    }
                    if ($field['type'] == 'upload') {
                        $field['type'] = 'image';
                    }
                    if ($field['type'] == 'radio_img') {
                        $field['type'] = 'select';
                        $field['choices'] = array();
                        foreach ($field['options'] as $key => $choices) {
                            $field['choices'][$key] = $choices['title'];
                        }
                    }
                    $field['label'] = $field['title'];
                    $field['section'] = sanitize_title($section['title']);
                    $field['settings'] = $ya_options->args['opt_name'] . '[' . $field['id'] . ']';
                    $field['priority'] = $priority++;
                    $sections[$i]['fields'][] = $field;
                }
            }
            if (isset($sections[$i]['fields'])) {
                $sections[$i]['title'] = $section['title'];
                $sections[$i]['priority'] = $priority++;
                $sections[$i]['capability'] = 'edit_theme_options';
                $i++;
            }
        }
    }
    foreach ($sections as $section) {
        // Add Section
        $wp_customize->add_section(sanitize_title($section['title']), $section);
        foreach ($section['fields'] as $field) {
            //Add Setting
            $wp_customize->add_setting($ya_options->args['opt_name'] . '[' . $field['id'] . ']', array('default' => $ya_options->get($field['id']), 'type' => 'option', 'transport' => 'postMessage', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'customize_option'));
            // Add Control
            switch ($field['type']) {
                case 'color':
                    $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, $field['id'], $field));
                    break;
                case 'image':
                    $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, $field['id'], $field));
                    break;
                case 'textarea':
                    $wp_customize->add_control(new WP_Customize_Textarea_Control($wp_customize, $field['id'], $field));
                    break;
                default:
                    $wp_customize->add_control($field['id'], $field);
            }
            //$wp_customize->get_setting($ya_options->args['opt_name'].'['.$field['id'].']')->transport = 'postMessage';
        }
    }
    $wp_customize->get_setting('blogname')->transport = 'postMessage';
    $wp_customize->get_setting('blogdescription')->transport = 'postMessage';
}
开发者ID:junibrosas,项目名称:shoppingyourway,代码行数:69,代码来源:customizer.php


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