本文整理汇总了PHP中Kirki类的典型用法代码示例。如果您正苦于以下问题:PHP Kirki类的具体用法?PHP Kirki怎么用?PHP Kirki使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Kirki类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:IlhamFS,项目名称:wordpress,代码行数:11,代码来源:Kirki.php
示例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();
}
}
开发者ID:nikoz84,项目名称:kirki,代码行数:39,代码来源:class-kirki-output.php
示例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();
}
开发者ID:yarwalker,项目名称:ecobyt,代码行数:7,代码来源:test-kirki-scripts-customizer-tooltips.php
示例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;
}
开发者ID:novichkovv,项目名称:prlab,代码行数:34,代码来源:extras.php
示例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;
}
开发者ID:rsantellan,项目名称:wordpress-ecommerce,代码行数:37,代码来源:class-kirki-styles-customizer.php
示例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']);
}
}
开发者ID:TheSkin,项目名称:skin-toolkit-plugin,代码行数:7,代码来源:kirki.php
示例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));
}
开发者ID:quintenm,项目名称:maresthema-2016,代码行数:8,代码来源:test-kirki-add_section.php
示例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));
}
开发者ID:quintenm,项目名称:maresthema-2016,代码行数:9,代码来源:test-kirki-add_config.php
示例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);
}
}
}
开发者ID:1bigidea,项目名称:kirki,代码行数:14,代码来源:class-kirki-fields-filter.php
示例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);
}
}
开发者ID:rsantellan,项目名称:wordpress-ecommerce,代码行数:17,代码来源:class-kirki-builder.php
示例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());
}
开发者ID:silversite,项目名称:silverwp,代码行数:13,代码来源:test-kirki-scripts-customizer-postmessage.php
示例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);
}
}
开发者ID:rsantellan,项目名称:wordpress-ecommerce,代码行数:20,代码来源:class-kirki-scripts-customizer-branding.php
示例16: tm_polygon_js_custom_code
function tm_polygon_js_custom_code()
{
?>
<?php
if (Kirki::get_option('tm-polygon', 'custom_js_enable') == 1) {
?>
<?php
echo html_entity_decode(Kirki::get_option('tm-polygon', 'custom_js'));
?>
<?php
}
?>
<?php
if (Kirki::get_option('tm-polygon', 'nav_sticky_enable') == 1 && has_nav_menu('primary')) {
?>
<?php
if (Kirki::get_option('tm-polygon', 'header_type') == 'header02' || Kirki::get_option('tm-polygon', 'header_type') == 'header04') {
?>
<script>
jQuery(document).ready(function ($) {
$(".sticky-menu").headroom(
{
offset: $(".site-top").innerHeight(),
}
);
});
</script>
<?php
} else {
?>
<script>
jQuery(document).ready(function ($) {
$(".sticky-menu").headroom(
{
offset: 0
}
);
});
</script>
<?php
}
?>
<?php
}
}
开发者ID:novichkovv,项目名称:prlab,代码行数:45,代码来源:custom-js.php
示例17: infinity_js_custom_code
function infinity_js_custom_code()
{
?>
<?php
if (Kirki::get_option('infinity', 'custom_js_enable') == 1) {
?>
<?php
echo html_entity_decode(Kirki::get_option('infinity', 'custom_js'));
?>
<?php
}
?>
<?php
if (Kirki::get_option('infinity', 'nav_sticky_enable') == 1 && has_nav_menu('primary')) {
?>
<?php
if (Kirki::get_option('infinity', 'header_type') == 'header03' || Kirki::get_option('infinity', 'header_type') == 'header04') {
?>
<script>
jQuery(document).ready(function ($) {
$(".header").headroom(
{
offset: 52
}
);
});
</script>
<?php
} else {
?>
<script>
jQuery(document).ready(function ($) {
$("#site-navigation").headroom(
{
offset: 160
}
);
});
</script>
<?php
}
?>
<?php
}
}
开发者ID:Neminath,项目名称:lastmile,代码行数:45,代码来源:custom-js.php
示例18: add_fields_via_api
/**
* Add fields using the Kirki API
*/
public function add_fields_via_api()
{
$args = $this->field;
$args['section'] = sanitize_key($this->field['type']);
$args['capability'] = 'read';
$args['settings'] = sanitize_key($this->field['type']) . '_demo_3';
$args['label'] = sprintf(__('%s theme_mod via API', 'kirki'), $args['type']);
$args['option_type'] = 'theme_mod';
Kirki::add_field('', $args);
$args['settings'] = sanitize_key($this->field['type']) . '_demo_4';
$args['label'] = sprintf(__('%s single option via API', 'kirki'), $args['type']);
$args['option_type'] = 'option';
Kirki::add_field('', $args);
$args['settings'] = sanitize_key($this->field['type']) . '_demo_5';
$args['option_type'] = 'option';
$args['label'] = sprintf(__('%s serialized option via API', 'kirki'), $args['type']);
$args['option_name'] = 'kirki_test';
Kirki::add_field('', $args);
}
开发者ID:yarwalker,项目名称:ecobyt,代码行数:22,代码来源:kirki-user-tests.php
示例19: customize_controls_print_footer_scripts
/**
* Add the script to the footer
*/
function customize_controls_print_footer_scripts()
{
$fields = Kirki::fields()->get_all();
$scripts = array();
foreach ($fields as $field) {
if ('number' == $field['type']) {
$scripts[] = '$( "#customize-control-' . $field['settings'] . ' input[type=\'number\']").stepper();';
}
}
// No need to echo anything if the script is empty
if (empty($scripts)) {
return;
}
// Make sure we don't add any duplicates
$scripts = array_unique($scripts);
// Convert array to string
$script = implode('', $scripts);
echo Kirki_Scripts_Registry::prepare($script);
}
开发者ID:rsantellan,项目名称:wordpress-ecommerce,代码行数:22,代码来源:class-kirki-scripts-customizer-stepper.php
示例20: test
public function test()
{
$this->assertEquals(kirki_get_option(), Kirki::get_option());
$this->assertEquals(kirki_sanitize_hex('#ffffff'), Kirki_Color::sanitize_hex('#ffffff'));
$this->assertEquals(kirki_get_rgb('#ffffff'), Kirki_Color::get_rgb('#ffffff'));
$this->assertEquals(kirki_get_rgba('#ffffff'), Kirki_Color::get_rgba('#ffffff'));
$this->assertEquals(kirki_get_brightness('#ffffff'), Kirki_Color::get_brightness('#ffffff'));
$font_registry = Kirki_Toolkit::fonts();
$this->assertEquals(Kirki_Fonts::get_all_fonts(), $font_registry->get_all_fonts());
$this->assertEquals(Kirki_Fonts::get_font_choices(), $font_registry->get_font_choices());
$this->assertEquals(Kirki_Fonts::is_google_font('foo'), $font_registry->is_google_font('foo'));
$this->assertEquals(Kirki_Fonts::get_google_font_uri(array('foo')), $font_registry->get_google_font_uri(array('foo')));
$this->assertEquals(Kirki_Fonts::get_google_font_subsets(), $font_registry->get_google_font_subsets());
$this->assertEquals(Kirki_Fonts::choose_google_font_variants('Roboto'), $font_registry->choose_google_font_variants('Roboto'));
$this->assertEquals(Kirki_Fonts::get_standard_fonts(), $font_registry->get_standard_fonts());
$this->assertEquals(Kirki_Fonts::get_font_stack('foo'), $font_registry->get_font_stack('foo'));
$this->assertEquals(Kirki_Fonts::sanitize_font_choice('foo'), $font_registry->sanitize_font_choice('foo'));
$this->assertEquals(Kirki_Fonts::get_google_fonts(), $font_registry->get_google_fonts());
}
开发者ID:quintenm,项目名称:maresthema-2016,代码行数:19,代码来源:test-deprecated.php
注:本文中的Kirki类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论