本文整理汇总了PHP中Kirki类的典型用法代码示例。如果您正苦于以下问题:PHP Kirki类的具体用法?PHP Kirki怎么用?PHP Kirki使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Kirki类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: google_link
function google_link()
{
$fields = Kirki::fields()->get_all();
// Early exit if no fields are found.
if (!$fields || empty($fields)) {
return;
}
// Get an array of all the google fonts
$google_fonts = Kirki::fonts()->get_google_fonts();
$fonts = array();
foreach ($fields as $field) {
if (isset($field['output'])) {
// Check if this is a font-family control
$is_font_family = isset($field['output']['property']) && 'font-family' == $field['output']['property'] ? true : false;
// Check if this is a font-weight control
$is_font_weight = isset($field['output']['property']) && 'font-weight' == $field['output']['property'] ? true : false;
// Check if this is a font subset control
$is_font_subset = isset($field['output']['property']) && 'font-subset' == $field['output']['property'] ? true : false;
if ($is_font_family || $is_font_weight || $is_font_subset) {
// The value of this control
$value = kirki_get_option($field['settings_raw']);
if ($is_font_family) {
$fonts[]['font-family'] = $value;
} else {
if ($is_font_weight) {
$fonts[]['font-weight'] = $value;
} else {
if ($is_font_subset) {
$fonts[]['subsets'] = $value;
}
}
}
}
}
}
foreach ($fonts as $font) {
if (isset($font['font-family'])) {
$font_families = !isset($font_families) ? array() : $font_families;
$font_families[] = $font['font-family'];
if (Kirki::fonts()->is_google_font($font['font-family'])) {
$has_google_font = true;
}
}
if (isset($font['font-weight'])) {
$font_weights = !isset($font_weights) ? array() : $font_weights;
$font_weights[] = $font['font-weight'];
}
if (isset($font['subsets'])) {
$font_subsets = !isset($font_subsets) ? array() : $font_subsets;
$font_subsets[] = $font['subsets'];
}
}
$font_families = !isset($font_families) || empty($font_families) ? false : $font_families;
$font_weights = !isset($font_weights) || empty($font_weights) ? '400' : $font_weights;
$font_subsets = !isset($font_subsets) || empty($font_subsets) ? 'all' : $font_subsets;
if (!isset($has_google_font) || !$has_google_font) {
$font_families = false;
}
return $font_families ? Kirki::fonts()->get_google_font_uri($font_families, $font_weights, $font_subsets) : false;
}
开发者ID:rsantellan,项目名称:wordpress-ecommerce,代码行数:60,代码来源:class-kirki-scripts-frontend-google-fonts.php
示例2: get_instance
/**
* Access the single instance of this class
* @return Kirki
*/
public static function get_instance()
{
if (self::$instance == null) {
self::$instance = new Kirki();
}
return self::$instance;
}
示例3: css
/**
* The class constructor.
*
* @var string the setting ID.
* @var string theme_mod / option
* @var array an array of arrays of the output arguments.
* @var mixed a callable function.
*/
public static function css($field)
{
/**
* Make sure the field is sanitized before proceeding any further.
*/
$field = Kirki_Field::sanitize_field($field);
/**
* Get the config ID used in the Kirki class.
*/
$config_id = Kirki::get_config_id($field);
/**
* Set class vars
*/
self::$settings = $field['settings'];
self::$output = $field['output'];
self::$callback = $field['sanitize_callback'];
/**
* Get the value of this field
*/
if ('option' == Kirki::$config[$config_id]['option_type'] && '' != Kirki::$config[$config_id]['option_name']) {
self::$value = Kirki::get_option($config_id, str_replace(array(']', Kirki::$config[$config_id]['option_name'] . '['), '', $field['settings']));
} else {
self::$value = Kirki::get_option($config_id, $field['settings']);
}
/**
* Returns the styles
*/
if (!is_array(self::$value)) {
return self::styles();
}
}
示例4: test_customize_controls_print_scripts
public function test_customize_controls_print_scripts()
{
Kirki::add_field('', array('settings' => 'foo', 'type' => 'text', 'section' => 'bar', 'help' => 'Lorem Ipsum'));
$script = '$( "<a href=\'#\' class=\'tooltip hint--left\' data-hint=\'Lorem Ipsum\'><span class=\'dashicons dashicons-info\'></span></a>" ).prependTo( "#customize-control-foo" );';
$this->expectOutputString('<script>jQuery(document).ready(function($) { "use strict"; ' . $script . '});</script>');
Kirki()->scripts->tooltips->customize_controls_print_footer_scripts();
}
示例5: tm_polygon_body_classes
/**
* Adds custom classes to the array of body classes.
* ================================================
*
* @param array $classes Classes for the body element.
*
* @return array
*/
function tm_polygon_body_classes($classes)
{
// Adds a class of group-blog to blogs with more than 1 published author.
if (is_multi_author()) {
$classes[] = 'group-blog';
}
global $tm_polygon_custom_class;
if ($tm_polygon_custom_class) {
$classes[] = $tm_polygon_custom_class;
}
if (Kirki::get_option('tm-polygon', 'site_general_boxed') == 1) {
$classes[] = 'boxed';
}
$classes[] = Kirki::get_option('tm-polygon', 'header_type');
global $tm_polygon_page_layout_private;
if ($tm_polygon_page_layout_private != 'default' && class_exists('cmb2_bootstrap_205')) {
$tm_polygon_layout = get_post_meta(get_the_ID(), "tm_polygon_page_layout_private", true);
} else {
$tm_polygon_layout = Kirki::get_option('tm-polygon', 'page_layout');
}
$classes[] = $tm_polygon_layout;
if (defined('TM_CORE_VERSION')) {
$classes[] = 'core_' . str_replace(".", "", TM_CORE_VERSION);
}
return $classes;
}
示例6: 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;
}
示例7: wp_footer
public function wp_footer()
{
global $wp_customize;
// Early exit if we're not in the customizer
if (!isset($wp_customize)) {
return;
}
// Get an array of all the fields
$fields = Kirki::fields()->get_all();
$script = '';
// Parse the fields and create the script.
foreach ($fields as $field) {
if (isset($field['transport']) && !is_null($field['js_vars']) && 'postMessage' == $field['transport']) {
foreach ($field['js_vars'] as $js_vars) {
$script .= 'wp.customize( \'' . $field['settings'] . '\', function( value ) {';
$script .= 'value.bind( function( newval ) {';
if ('html' == $js_vars['function']) {
$script .= '$( \'' . esc_js($js_vars["element"]) . '\' ).html( newval );';
} elseif ('css' == $js_vars['function']) {
$script .= '$(\'' . esc_js($js_vars["element"]) . '\').css(\'' . esc_js($js_vars["property"]) . '\', newval );';
}
$script .= '}); });';
}
}
}
if ('' != $script) {
echo Kirki_Scripts_Registry::prepare($script);
}
}
开发者ID:rsantellan,项目名称:wordpress-ecommerce,代码行数:29,代码来源:class-kirki-scripts-customizer-postmessage.php
示例8: kirki_filtered_url
function kirki_filtered_url()
{
$config = apply_filters('kirki/config', array());
if (isset($config['url_path'])) {
Kirki::$url = esc_url_raw($config['url_path']);
}
}
示例9: test_add_section
public function test_add_section()
{
Kirki::add_section('test_empty', array());
Kirki::add_section('test', array('priority' => 4, 'title' => 'Title', 'description' => 'My Description', 'panel' => 'my_panel'));
$this->assertEquals(array('id' => 'test_empty', 'description' => '', 'priority' => 10, 'active_callback' => '__return_true', 'panel' => ''), Kirki::$sections['test_empty']);
$this->assertEquals(array('id' => 'test', 'title' => 'Title', 'description' => 'My Description', 'priority' => '4', 'active_callback' => '__return_true', 'panel' => 'my_panel'), Kirki::$sections['test']);
$this->assertEquals(2, count(Kirki::$sections));
}
示例10: test_config
public function test_config()
{
Kirki::add_config('test_empty', array());
Kirki::add_config('test', array('capability' => 'manage_network_options', 'option_type' => 'option', 'option_name' => 'my_option_name', 'compiler' => array(), 'disable_output' => true, 'postMessage' => 'auto'));
$this->assertEquals(array('capability' => 'edit_theme_options', 'option_type' => 'theme_mod', 'option_name' => '', 'compiler' => array(), 'disable_output' => false, 'postMessage' => ''), Kirki::$config['global']);
$this->assertEquals(array('capability' => 'edit_theme_options', 'option_type' => 'theme_mod', 'option_name' => '', 'compiler' => array(), 'disable_output' => false, 'postMessage' => ''), Kirki::$config['test_empty']);
$this->assertEquals(array('capability' => 'manage_network_options', 'option_type' => 'option', 'option_name' => 'my_option_name', 'compiler' => array(), 'disable_output' => true, 'postMessage' => 'auto'), Kirki::$config['test']);
$this->assertEquals(3, count(Kirki::$config));
}
示例11: fields_from_filters
/**
* Process fields added using the 'kirki/fields' and 'kirki/controls' filter.
* These filters are no longer used, this is simply for backwards-compatibility
*/
public function fields_from_filters()
{
$fields = apply_filters('kirki/controls', array());
$fields = apply_filters('kirki/fields', $fields);
if (!empty($fields)) {
foreach ($fields as $field) {
Kirki::add_field('global', $field);
}
}
}
示例12: 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
示例13: build
/**
* Build the customizer fields.
* Parses all fields and creates the setting & control for each of them.
*/
public function build($wp_customize)
{
include_once KIRKI_PATH . '/includes/class-kirki-control.php';
include_once KIRKI_PATH . '/includes/class-kirki-controls.php';
$fields = Kirki::fields()->get_all();
// Early exit if controls are not set or if they're empty
if (empty($fields)) {
return;
}
foreach ($fields as $field) {
$this->build_field($wp_customize, $field);
}
}
示例14: test_generate_script
public function test_generate_script()
{
$js_vars = array('element' => 'body', 'function' => 'css', 'property' => 'color');
Kirki::add_field('', array('settings' => 'foo', 'type' => 'text', 'transport' => 'postMessage', 'js_vars' => $js_vars));
set_theme_mod('foo', '#333');
$wp_customize = $this->init_customizer();
$this->assertEquals('wp.customize( \'foo\', function( value ) {value.bind( function( newval ) {$(\'body\').css(\'color\', newval );}); });', Kirki()->scripts->postmessage->generate_script());
$js_vars = array('element' => 'body', 'function' => 'html');
Kirki::add_field('', array('settings' => 'foo', 'type' => 'text', 'transport' => 'postMessage', 'js_vars' => $js_vars));
set_theme_mod('foo', 'this is a string');
$wp_customize = $this->init_customizer();
$this->assertEquals('wp.customize( \'foo\', function( value ) {value.bind( function( newval ) {$(\'body\').html( newval );}); });', Kirki()->scripts->postmessage->generate_script());
}
示例15: 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);
}
}