本文整理汇总了PHP中Kirki函数的典型用法代码示例。如果您正苦于以下问题:PHP Kirki函数的具体用法?PHP Kirki怎么用?PHP Kirki使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Kirki函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_kirki
public static function get_kirki()
{
if (null === self::$kirki) {
self::$kirki = Kirki();
}
return self::$kirki;
}
示例2: 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();
}
示例3: 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());
}
示例4: test_custom_css
public function test_custom_css()
{
add_filter('kirki/config', function ($config) {
$config['color_accent'] = '#00bcd4';
$config['color_back'] = '#455a64';
$config['width'] = '20%';
return $config;
});
do_action('customize_controls_print_styles');
$this->assertTrue(false !== strpos(Kirki()->styles['back']->custom_css(), '#00bcd4'));
$this->assertTrue(false !== strpos(Kirki()->styles['back']->custom_css(), '#455a64'));
$this->assertTrue(false !== strpos(Kirki()->styles['back']->custom_css(), '20%'));
}
示例5: test_customize_controls_print_scripts
public function test_customize_controls_print_scripts()
{
add_filter('kirki/config', function () {
return array();
});
$this->expectOutputString('');
print '';
add_filter('kirki/config', function () {
return array('logo_image' => 'http://foo.com/bar.png', 'description' => 'Lorem ipsum dolor sit amet');
});
$script = '$( \'div#customize-info .preview-notice\' ).replaceWith( \'<img src="http://foo.com/bar.png">\' );$( \'div#customize-info .accordion-section-content\' ).replaceWith( \'<div class="accordion-section-content"><div class="theme-description">Lorem ipsum dolor sit amet</div></div>\' );';
$this->expectOutputString('<script>jQuery(document).ready(function($) { "use strict"; ' . $script . '});</script>');
Kirki()->scripts->branding->customize_controls_print_scripts();
}
示例6: test_google_font_enqueued
public function test_google_font_enqueued()
{
$this->add_font_family_field();
$this->add_font_subsets_field();
$this->add_font_weight_field();
set_theme_mod('font_family', 'Open Sans');
set_theme_mod('subsets', 'devangari');
set_theme_mod('font_weight', 100);
Kirki();
$this->go_to(home_url());
do_action('wp_enqueue_scripts');
$styles = $GLOBALS['wp_styles']->registered;
$this->assertTrue(isset($styles['kirki_google_fonts']));
}
示例7: Kirki
function Kirki()
{
// Make sure the class is instanciated
$kirki = Kirki_Toolkit::get_instance();
$kirki->font_registry = new Kirki_Google_Fonts_Registry();
$kirki->api = new Kirki();
$kirki->scripts = new Kirki_Scripts_Registry();
$kirki->styles = array('back' => new Kirki_Styles_Customizer(), 'front' => new Kirki_Styles_Frontend());
/**
* The path of the current Kirki instance
*/
Kirki::$path = dirname(__FILE__);
return $kirki;
}
global $kirki;
$kirki = Kirki();
}
/**
* Apply the filters to the Kirki::$url
*/
if (!function_exists('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']);
}
}
add_action('after_setup_theme', 'kirki_filtered_url');
}
include_once Kirki::$path . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'deprecated.php';
示例8: get_all_fonts
public function get_all_fonts()
{
$fonts = Kirki()->font_registry->get_all_fonts();
$fonts_array = array();
foreach ($fonts as $font => $properties) {
$fonts_array[$font] = $font;
}
return $fonts_array;
}
示例9: get_all_fonts
public function get_all_fonts()
{
$kirki = Kirki();
$fonts = $kirki->font_registry->get_all_fonts();
$fonts_array = array();
foreach ($fonts as $key => $font) {
if (is_array($font)) {
if (isset($font['label'])) {
if (isset($font['stack'])) {
$fonts_array[$font['stack']] = $font['label'];
} else {
$fonts_array[$key] = $font['label'];
}
} else {
$fonts_array[$key] = $key;
}
} else {
$fonts_array[$key] = $font;
}
}
return $fonts_array;
}
示例10: styles
/**
* Get the styles as an array.
*/
public static function styles()
{
$google_fonts_array = Kirki()->font_registry->get_google_fonts();
$backup_fonts = Kirki()->font_registry->get_backup_fonts();
$styles = array();
foreach (self::$output as $output) {
if (!isset($output['element'])) {
continue;
}
/**
* Do we have units?
*/
$units = isset($output['units']) ? $output['units'] : '';
/**
* Do we have a prefix?
*/
$prefix = isset($output['prefix']) ? $output['prefix'] : '';
/**
* Do we have a suffix?
*/
$suffix = isset($output['suffix']) ? $output['suffix'] : '';
/**
* Accept "callback" as short for "sanitize_callback".
*/
if (!isset($output['sanitize_callback']) && isset($output['callback'])) {
$output['sanitize_callback'] = $output['callback'];
}
/**
* Do we have a "media_query" defined?
*/
if (!isset($output['media_query'])) {
$output['media_query'] = 'global';
} else {
$output['media_query'] = esc_attr($output['media_query']);
}
/**
* Do we need to run this through a callback action?
*/
$value = '' != self::$callback ? call_user_func(self::$callback, self::$value) : self::$value;
if (isset($output['sanitize_callback']) && null !== $output['sanitize_callback']) {
$value = call_user_func($output['sanitize_callback'], $value);
}
/**
* Make sure the value is a string before proceeding
* If all is ok, then populate the array.
*/
$element = $output['element'];
/**
* Allow using an array of elements
*/
if (is_array($output['element'])) {
/**
* Make sure our values are unique
*/
$elements = array_unique($element);
/**
* Sort elements alphabetically.
* This way all duplicate items will be merged in the final CSS array.
*/
sort($elements);
/**
* Implode items
*/
$element = implode(',', $elements);
}
if (!is_array($value)) {
if (!isset($output['property'])) {
continue;
}
if ('font-family' == $output['property']) {
// Add backup font
if (Kirki()->font_registry->is_google_font($value)) {
if (isset($google_fonts_array[$value]) && isset($google_fonts_array[$value]['category'])) {
if (isset($backup_fonts[$google_fonts_array[$value]['category']])) {
$value .= ', ' . $backup_fonts[$google_fonts_array[$value]['category']];
}
}
}
}
$styles[$output['media_query']][$element][$output['property']] = $prefix . $value . $units . $suffix;
} else {
/**
* Take care of typography controls output
*/
if ('typography' == self::$field_type) {
if (isset($value['bold']) && $value['bold']) {
$styles[$output['media_query']][$element]['font-weight'] = 'bold';
}
if (isset($value['italic']) && $value['italic']) {
$styles[$output['media_query']][$element]['font-style'] = 'italic';
}
if (isset($value['underline']) && $value['underline']) {
$styles[$output['media_query']][$element]['text-decoration'] = 'underline';
}
if (isset($value['strikethrough']) && $value['strikethrough']) {
$styles[$output['media_query']][$element]['text-decoration'] = 'strikethrough';
}
//.........这里部分代码省略.........
示例11: test_styles_front
function test_styles_front()
{
$this->assertTrue(is_object(Kirki()->styles['front']));
}