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


PHP Kirki::config方法代码示例

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


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

示例1: custom_css

 /**
  * Add custom CSS rules to the head, applying our custom styles
  */
 function custom_css()
 {
     $color = $this->get_admin_colors();
     $config = Kirki::config();
     $color_font = false;
     $color_accent = $config->get('color_accent', $color['icon_colors']['focus']);
     $color_back = $config->get('color_back', '#ffffff');
     $color_font = 170 > Kirki_Color::get_brightness($color_back) ? '#f2f2f2' : '#222';
     $styles = '<style>';
     // Background styles
     $styles .= '#customize-controls .wp-full-overlay-sidebar-content{background-color:' . $color_back . ';}';
     $styles .= '#customize-theme-controls .accordion-section-title, #customize-info .accordion-section-title,#customize-info .accordion-section-title:hover,#customize-info.open .accordion-section-title{background-color:' . $color_back . ';color:' . $color_font . ';}';
     $styles .= '#customize-theme-controls .control-section .accordion-section-title:hover,#customize-theme-controls .control-section .accordion-section-title:focus,.control-section.control-panel>.accordion-section-title:after{background-color:' . Kirki_Color::adjust_brightness($color_back, -10) . ';color:' . $color_font . ';}';
     $styles .= '#customize-theme-controls .control-section.control-panel>h3.accordion-section-title:focus:after, #customize-theme-controls .control-section.control-panel>h3.accordion-section-title:hover:after{background-color:' . Kirki_Color::adjust_brightness($color_back, -20) . ';color:' . $color_font . ';}';
     $styles .= '#customize-theme-controls .control-section.open .accordion-section-title{background-color:' . $color_accent . ' !important;color:' . $color_font . ' !important;}';
     // Tooltip styles
     // $styles .= 'li.customize-control a.button.tooltip.hint--left {color:' . $color_accent . ';}';
     // Image-Radio styles
     $styles .= '.customize-control-radio-image .image.ui-buttonset label.ui-state-active {border-color:' . $color_accent . ';}';
     // Buttonset-Radio styles
     $styles .= '.customize-control-radio-buttonset label.ui-state-active{background-color:' . $color_accent . ';color:' . $color_font . ';}';
     // Slider Controls
     $styles .= '.customize-control-slider .ui-slider .ui-slider-handle{background-color:' . $color_accent . ';border-color:' . $color_accent . ';}';
     // Switch Controls
     $styles .= '.customize-control-switch .Switch .On, .customize-control-toggle .Switch .On{color:' . $color_accent . ';}';
     // Toggle Controls
     $styles .= '.customize-control-switch .Switch.Round.On, .customize-control-toggle .Switch.Round.On{background-color:' . Kirki_Color::adjust_brightness($color_accent, -10) . ';}';
     // Sortable Controls
     $styles .= '.customize-control-sortable ul.ui-sortable li .dashicons.visibility{color:' . $color_accent . ';}';
     // Palette Controls
     $styles .= '.customize-control-palette label.ui-state-active.ui-button.ui-widget span.ui-button-text {border-color:' . $color_accent . ';}';
     $styles .= '</style>';
     echo $styles;
 }
开发者ID:rsantellan,项目名称:wordpress-ecommerce,代码行数:37,代码来源:class-kirki-styles-customizer.php

示例2: kirki_sanitize_choice

/**
 * Sanitize a value from a list of allowed values.
 *
 * @since 0.5
 *
 * @param  mixed    $input      The value to sanitize.
 * @param  mixed    $setting    The setting for which the sanitizing is occurring.
 */
function kirki_sanitize_choice($input, $setting)
{
    global $wp_customize;
    $config = Kirki::config()->get_all();
    if ('' != $config['option_name']) {
        return sanitize_key($input);
    }
    $field = $wp_customize->get_control($setting->id);
    return array_key_exists($input, $field->choices) ? $input : $setting->default;
}
开发者ID:rsantellan,项目名称:wordpress-ecommerce,代码行数:18,代码来源:sanitize.php

示例3: customize_controls_enqueue_scripts

 /**
  * Enqueue the scripts required.
  */
 public function customize_controls_enqueue_scripts()
 {
     $config = Kirki::config()->get_all();
     $kirki_url = '' != $config['url_path'] ? $config['url_path'] : KIRKI_URL;
     wp_enqueue_script('kirki_customizer_js', trailingslashit($kirki_url) . 'assets/js/customizer.js', array('jquery', 'customize-controls'));
     wp_enqueue_script('serialize-js', trailingslashit($kirki_url) . 'assets/js/serialize.js');
     wp_enqueue_script('jquery-stepper-min-js', trailingslashit($kirki_url) . 'assets/js/jquery.fs.stepper.min.js', array('jquery'));
     wp_enqueue_script('jquery-ui-core');
     wp_enqueue_script('jquery-ui-tooltip');
     wp_enqueue_script('jquery-stepper-min-js');
 }
开发者ID:rsantellan,项目名称:wordpress-ecommerce,代码行数:14,代码来源:class-kirki-scripts-customizer-default-scripts.php

示例4: frontend_styles

 /**
  * Add a dummy, empty stylesheet if no stylesheet_id has been defined and we need one.
  */
 public function frontend_styles()
 {
     // Early exit if we're not using output
     if (!$this->uses_output()) {
         return;
     }
     $config = Kirki::config()->get_all();
     $kirki_stylesheet = Kirki::config()->getOrThrow('stylesheet_id');
     $root_url = '' != $config['url_path'] ? Kirki::config()->getOrThrow('url_path') : KIRKI_URL;
     if ('kirki-styles' == $kirki_stylesheet) {
         wp_enqueue_style('kirki-styles', trailingslashit($root_url) . 'assets/css/kirki-styles.css', NULL, NULL);
     }
 }
开发者ID:rsantellan,项目名称:wordpress-ecommerce,代码行数:16,代码来源:class-kirki-styles-frontend.php

示例5: customize_controls_print_scripts

 /**
  * If we've specified an image to be used as logo,
  * replace the default theme description with a div that will include our logo.
  */
 public function customize_controls_print_scripts()
 {
     $options = Kirki::config()->get_all();
     $script = '';
     if ('' != $options['logo_image'] || '' != $options['description']) {
         if ('' != $options['logo_image']) {
             $script .= '$( \'div#customize-info .preview-notice\' ).replaceWith( \'<img src="' . $options['logo_image'] . '">\' );';
         }
         if ('' != $options['description']) {
             $script .= '$( \'div#customize-info .accordion-section-content\' ).replaceWith( \'<div class="accordion-section-content"><div class="theme-description">' . $options['description'] . '</div></div>\' );';
         }
     }
     if ('' != $script) {
         echo Kirki_Scripts_Registry::prepare($script);
     }
 }
开发者ID:rsantellan,项目名称:wordpress-ecommerce,代码行数:20,代码来源:class-kirki-scripts-customizer-branding.php

示例6: kirki_get_option

/**
 * Get the value of a field.
 */
function kirki_get_option($option = '')
{
    // Make sure the class is instanciated
    Kirki::get_instance();
    // Get the array of all the fields.
    $fields = Kirki::fields()->get_all();
    // Get the config.
    $config = Kirki::config()->get_all();
    /**
     * If no setting has been defined then return all.
     */
    if ('' == $option) {
        if ('option' == $config['options_type']) {
            $values = array();
            foreach ($fields as $field) {
                $values[] = get_option($field['settings'], $field['default']);
            }
        } else {
            $values = get_theme_mods();
        }
        return $values;
    }
    // If a value has been defined then we proceed.
    // Early exit if this option does not exist
    if (!isset($fields[$option])) {
        return;
    }
    $option_name = $fields[$option]['settings'];
    $default = $fields[$option]['default'];
    if ('option' == $config['options_type']) {
        $value = get_option($option_name, $default);
    } else {
        $value = get_theme_mod($option_name, $default);
    }
    return $value;
}
开发者ID:IlhamFS,项目名称:wordpress,代码行数:39,代码来源:helpers.php

示例7: sanitize_settings

 /**
  * Sanitizes the setting name
  *
  * @param array the field definition
  * @return string.
  */
 public function sanitize_settings($field)
 {
     $config = Kirki::config()->get_all();
     // Pass this throught the sanitize_settings_raw method first.
     $field['settings'] = $this->sanitize_settings_raw($field);
     // Checking and sanitization of config values is handled by the Config class.
     // If the value of 'option_name' is not empty, then we're also using options instead of theme_mods.
     if ('' != $config['option_name']) {
         $field['settings'] = $config['option_name'] . '[' . $field['settings'] . ']';
     }
     return $field['settings'];
 }
开发者ID:rsantellan,项目名称:wordpress-ecommerce,代码行数:18,代码来源:class-kirki-fields.php

示例8: test_get_option

 public function test_get_option()
 {
     Kirki::$config = null;
     Kirki::$fields = null;
     $this->add_config();
     $this->add_field();
     $this->assertEquals('some-default-value', Kirki::get_option('my_config_theme_mods', 'my_setting_theme_mods'));
     $this->assertEquals('some-default-value', Kirki::get_option('my_config_options', 'my_setting_options'));
     $this->assertEquals('some-default-value', Kirki::get_option('my_config_options_serialized', 'my_option[my_setting_options_serialized]'));
     Kirki::$config = null;
     Kirki::$fields = null;
     $this->add_config();
     $this->add_background_fields();
     $this->assertEquals(array('color' => '#333333', 'image' => 'http://foo.com/bar.png', 'repeat' => 'no-repeat', 'size' => 'cover', 'attach' => 'scroll', 'position' => 'center-bottom', 'opacity' => '.6'), Kirki::get_option('my_config_theme_mods', 'my_settings_test_background_theme_mod'));
     $this->assertEquals(array('color' => '#333333', 'image' => 'http://foo.com/bar.png', 'repeat' => 'no-repeat', 'size' => 'cover', 'attach' => 'scroll', 'position' => 'center-bottom', 'opacity' => '.6'), Kirki::get_option('my_config_options', 'my_settings_test_background_options'));
     $this->assertEquals(array('color' => '#333333', 'image' => 'http://foo.com/bar.png', 'repeat' => 'no-repeat', 'size' => 'cover', 'attach' => 'scroll', 'position' => 'center-bottom', 'opacity' => '.6'), Kirki::get_option('my_config_options_serialized', 'my_option[my_settings_test_background_options_serialized]'));
     Kirki::$config = null;
     Kirki::$fields = null;
     $this->add_config();
     $this->add_background_fields();
     set_theme_mod('my_settings_test_background_theme_mod_color', '#000000');
     $this->assertEquals(array('color' => '#000000', 'image' => 'http://foo.com/bar.png', 'repeat' => 'no-repeat', 'size' => 'cover', 'attach' => 'scroll', 'position' => 'center-bottom', 'opacity' => '.6'), Kirki::get_option('my_config_theme_mods', 'my_settings_test_background_theme_mod'));
     update_option('my_settings_test_background_options_color', '#222222');
     $this->assertEquals(array('color' => '#222222', 'image' => 'http://foo.com/bar.png', 'repeat' => 'no-repeat', 'size' => 'cover', 'attach' => 'scroll', 'position' => 'center-bottom', 'opacity' => '.6'), Kirki::get_option('my_config_options', 'my_settings_test_background_options'));
     update_option('my_option', array('my_settings_test_background_options_serialized_color' => '#444444'));
     $this->assertEquals(array('color' => '#444444', 'image' => 'http://foo.com/bar.png', 'repeat' => 'no-repeat', 'size' => 'cover', 'attach' => 'scroll', 'position' => 'center-bottom', 'opacity' => '.6'), Kirki::get_option('my_config_options_serialized', 'my_option[my_settings_test_background_options_serialized]'));
 }
开发者ID:1bigidea,项目名称:kirki,代码行数:27,代码来源:test-kirki.php

示例9: kirki_get_option

/**
 * Get the value of a field.
 */
function kirki_get_option($option = '')
{
    // Make sure the class is instanciated
    Kirki::get_instance();
    // Get the array of all the fields.
    $fields = Kirki::fields()->get_all();
    // Get the config.
    $config = Kirki::config()->get_all();
    // If we're using options instead of theme_mods,
    // then first we'll have to get the array of all options.
    if ('option' == $config['options_type']) {
        $values = array();
        if ('' == $config['option_name']) {
            // No option name is defined.
            // Each options is saved separately in the db, so we'll manually build the array here.
            foreach ($fields as $field) {
                $values[$field['settings']] = get_option($field['settings'], $field['default']);
            }
        } else {
            // An option_name has been defined so our options are all saved in an array there.
            $values = get_option($config['option_name']);
            foreach ($fields as $field) {
                if (!isset($values[$field['settings_raw']])) {
                    $values[$field['settings_raw']] = maybe_unserialize($field['default']);
                }
            }
        }
    }
    if ('' == $option) {
        // No option has been defined so we'll get all options and return an array
        // If we're using options then we already have the $values set above.
        // All we need here is a fallback for theme_mods
        if ('option' != $config['options_type']) {
            // We're using theme_mods
            $values = get_theme_mods();
        }
        // Early exit and return the array of all values
        return $values;
    }
    // If a value has been defined then we proceed.
    // Early exit if this option does not exist
    $field_id = 'option' == $config['options_type'] && '' != $config['option_name'] ? $config['option_name'] . '[' . $option . ']' : $option;
    if (!isset($fields[$field_id])) {
        return;
    }
    if ('option' == $config['options_type']) {
        // We're using options instead of theme_mods.
        // We already have the array of values set from above so we'll use that.
        $value = isset($values[$option]) ? $values[$option] : $fields[$option]['default'];
    } else {
        // We're using theme_mods
        $value = get_theme_mod($option, $fields[$option]['default']);
    }
    // Combine background options to a single array
    if ('background' == $fields[$field_id]['type']) {
        if ('option' == $config['options_type']) {
            $value = array('background-color' => isset($values[$option . '_color']) ? $values[$option . '_color'] : null, 'background-repeat' => isset($values[$option . '_repeat']) ? $values[$option . '_repeat'] : null, 'background-attachment' => isset($values[$option . '_attach']) ? $values[$option . '_attach'] : null, 'background-image' => isset($values[$option . '_image']) ? $values[$option . '_image'] : null, 'background-position' => isset($values[$option . '_position']) ? $values[$option . '_position'] : null, 'background-clip' => isset($values[$option . '_clip']) ? $values[$option . '_clip'] : null, 'background-size' => isset($values[$option . '_size']) ? $values[$option . '_size'] : null);
        } else {
            $value = array('background-color' => isset($fields[$field_id]['default']['color']) ? get_theme_mod($option . '_color', $fields[$field_id]['default']['color']) : null, 'background-repeat' => isset($fields[$field_id]['default']['repeat']) ? get_theme_mod($option . '_repeat', $fields[$field_id]['default']['repeat']) : null, 'background-attachment' => isset($fields[$field_id]['default']['attach']) ? get_theme_mod($option . '_attach', $fields[$field_id]['default']['attach']) : null, 'background-image' => isset($fields[$field_id]['default']['image']) ? get_theme_mod($option . '_image', $fields[$field_id]['default']['image']) : null, 'background-position' => isset($fields[$field_id]['default']['position']) ? get_theme_mod($option . '_position', $fields[$field_id]['default']['position']) : null, 'background-clip' => isset($fields[$field_id]['default']['clip']) ? get_theme_mod($option . '_clip', $fields[$field_id]['default']['clip']) : null, 'background-size' => isset($fields[$field_id]['default']['size']) ? get_theme_mod($option . '_size', $fields[$field_id]['default']['size']) : null);
        }
    }
    // Return the single value.
    // Pass it through maybe_unserialize so we're sure we get a proper value.
    return maybe_unserialize($value);
}
开发者ID:rsantellan,项目名称:wordpress-ecommerce,代码行数:68,代码来源:helpers.php

示例10: customize_controls_print_footer_scripts

 /**
  * Add the required script.
  */
 function customize_controls_print_footer_scripts()
 {
     // Get an array of all our fields
     $fields = Kirki::fields()->get_all();
     // Get the config options
     $config = Kirki::config()->get_all();
     // Early exit if no controls are defined
     if (empty($fields)) {
         return;
     }
     $script = '';
     foreach ($fields as $field) {
         $required = isset($field['required']) ? $field['required'] : false;
         if ($required) {
             $show = false;
             foreach ($required as $dependency) {
                 // Find the type of the dependency control
                 if ('option' == $config['options_type'] && '' != $config['option_name']) {
                     $dependency['setting'] = $config['option_name'] . '[' . $dependency['setting'] . ']';
                 }
                 $type = $fields[$dependency['setting']]['type'];
                 // If "operator" is not set then set it to "=="
                 if (!isset($dependency['operator'])) {
                     $dependency['operator'] = '==';
                 }
                 $dependency['operator'] = esc_js($dependency['operator']);
                 // Set the control type
                 $type = 'dropdown-pages' == $type ? 'select' : $type;
                 $type = 'radio-image' == $type ? 'radio' : $type;
                 $type = 'radio-buttonset' == $type ? 'radio' : $type;
                 $type = 'toggle' == $type ? 'checkbox' : $type;
                 $type = 'switch' == $type ? 'checkbox' : $type;
                 // Set the controller used in the script
                 $controller = '#customize-control-' . $fields[$dependency['setting']]['id'] . ' input';
                 $common_controller = '';
                 // Se the controller for select-type controls
                 if ('select' == $type) {
                     $controller = '#customize-control-' . $fields[$dependency['setting']]['id'] . ' select';
                 } elseif ('radio' == $type) {
                     $controller = '#customize-control-' . $fields[$dependency['setting']]['id'] . ' input[value="' . $dependency['value'] . '"]';
                     $common_controller = '#customize-control-' . $fields[$dependency['setting']]['id'] . ' input';
                 }
                 // The target element
                 $target = '#customize-control-' . $field['id'];
                 // if this is a background control then make sure we target all sub-controls
                 if ('background' == $field['type']) {
                     $target = '#customize-control-' . $control['settings'] . '_color, ';
                     $target .= '#customize-control-' . $control['settings'] . '_image, ';
                     $target .= '#customize-control-' . $control['settings'] . '_repeat, ';
                     $target .= '#customize-control-' . $control['settings'] . '_size, ';
                     $target .= '#customize-control-' . $control['settings'] . '_position, ';
                     $target .= '#customize-control-' . $control['settings'] . '_attach';
                 }
                 // If no operator has been defined, fallback to '=='
                 if (!isset($dependency['operator'])) {
                     $dependency['operator'] = '==';
                 }
                 $action_1 = '.show()';
                 $action_2 = '.hide()';
                 // Allow checking both checked and unchecked checkboxes
                 if ('checkbox' == $type) {
                     if (0 == $dependency['value'] && '==' == $dependency['operator']) {
                         $action_1 = '.hide()';
                         $action_2 = '.show()';
                         $show = true;
                     }
                     if (1 == $dependency['value'] && '!=' == $dependency['operator']) {
                         $action_1 = '.hide()';
                         $action_2 = '.show()';
                     }
                 }
                 // Get the initial status
                 $value = kirki_get_option($dependency['setting']);
                 switch ($dependency['operator']) {
                     case '==':
                         $show = $dependency['value'] == $value ? true : $show;
                         break;
                     case '!=':
                         $show = $dependency['value'] != $value ? true : $show;
                         break;
                     case '>=':
                         $show = $dependency['value'] >= $value ? true : $show;
                         break;
                     case '<=':
                         $show = $dependency['value'] <= $value ? true : $show;
                         break;
                     case '>':
                         $show = $dependency['value'] > $value ? true : $show;
                         break;
                     case '<':
                         $show = $dependency['value'] < $value ? true : $show;
                         break;
                     default:
                         $show = $dependency['value'] == $value ? true : $show;
                 }
                 // if initial status is hidden then hide the control
                 if (false == $show) {
//.........这里部分代码省略.........
开发者ID:rsantellan,项目名称:wordpress-ecommerce,代码行数:101,代码来源:class-kirki-scripts-customizer-required.php


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