add_config() public static méthode

Sets the configuration options.
public static add_config ( string $config_id, array $args = [] )
$config_id string The configuration ID.
$args array The configuration options.
 public function test_field()
 {
     Kirki::add_config('test', array('capability' => 'manage_network_options', 'option_type' => 'option', 'option_name' => 'my_option_name', 'compiler' => array(), 'disable_output' => true, 'postMessage' => 'auto'));
     Kirki::add_field('global', array('settings' => 'my_setting_global', 'label' => __('My custom control', 'translation_domain'), 'section' => 'my_section', 'type' => 'text', 'priority' => 10, 'default' => 'some-default-value'));
     Kirki::add_field('test', array('settings' => 'my_setting_test', 'label' => __('My custom control', 'translation_domain'), 'section' => 'my_section', 'type' => 'text', 'priority' => 10, 'default' => 'some-default-value'));
     $this->assertEquals(array('settings' => 'my_setting_global', 'label' => 'My custom control', 'section' => 'my_section', 'type' => 'kirki-generic', 'priority' => 10, 'default' => 'some-default-value', 'kirki_config' => 'global', 'option_name' => '', 'option_type' => 'theme_mod', 'capability' => 'edit_theme_options', 'disable_output' => false, 'tooltip' => '', 'active_callback' => '__return_true', 'choices' => array(), 'output' => array(), 'variables' => null, 'id' => 'my_setting_global', 'sanitize_callback' => 'wp_kses_post', 'choices' => array('element' => 'input', 'type' => 'text')), Kirki::$fields['my_setting_global']);
     $this->assertEquals(array('settings' => 'my_option_name[my_setting_test]', 'label' => 'My custom control', 'section' => 'my_section', 'type' => 'kirki-generic', 'priority' => 10, 'default' => 'some-default-value', 'kirki_config' => 'test', 'option_name' => 'my_option_name', 'option_type' => 'option', 'capability' => 'manage_network_options', 'disable_output' => true, 'tooltip' => '', 'active_callback' => '__return_true', 'choices' => array(), 'output' => array(), 'variables' => null, 'id' => 'my_option_name-my_setting_test', 'sanitize_callback' => 'wp_kses_post', 'choices' => array('element' => 'input', 'type' => 'text')), Kirki::$fields['my_option_name[my_setting_test]']);
 }
 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));
 }
Exemple #3
0
<?php

/* Load Kirki customizer framework */
include_once dirname(__FILE__) . '/options/kirki.php';
/* Early exit if Kirki is not installed */
if (!class_exists('Kirki')) {
    return;
}
/* Register Kirki config */
Kirki::add_config('shamrock_settings', array('capability' => 'edit_theme_options', 'option_type' => 'theme_mod'));
/* Header options */
Kirki::add_section('shamrock_header', array('priority' => 101, 'title' => __('Header', 'shamrock'), 'description' => __('These are setting for your website header/navigation area', 'shamrock')));
Kirki::add_field('shamrock_settings', array('type' => 'image', 'setting' => 'logo', 'label' => __('Logo', 'shamrock'), 'description' => __('Upload your logo', 'shamrock'), 'section' => 'shamrock_header', 'default' => ''));
Kirki::add_field('shamrock_settings', array('type' => 'checkbox', 'setting' => 'site_description', 'label' => __('Display site description', 'shamrock'), 'section' => 'shamrock_header', 'default' => 1));
Kirki::add_field('shamrock_settings', array('type' => 'checkbox', 'setting' => 'nav_social', 'label' => __('Include social icons in navigation', 'shamrock'), 'section' => 'shamrock_header', 'default' => 1));
Kirki::add_field('shamrock_settings', array('type' => 'checkbox', 'setting' => 'nav_search', 'label' => __('Include search in navigation', 'shamrock'), 'section' => 'shamrock_header', 'default' => 1));
/* General blog options */
Kirki::add_section('shamrock_blog', array('priority' => 101, 'title' => __('Blog', 'shamrock'), 'description' => __('These are general blog settings for your archive pages', 'shamrock')));
Kirki::add_field('shamrock_settings', array('type' => 'checkbox', 'setting' => 'rtl', 'label' => __('RTL mode', 'shamrock'), 'section' => 'shamrock_blog', 'default' => false));
Kirki::add_field('shamrock_settings', array('type' => 'radio', 'setting' => 'blog_layout', 'label' => __('Blog layout', 'shamrock'), 'section' => 'shamrock_blog', 'default' => 'sidebar', 'choices' => array('sidebar' => __('With Sidebar', 'shamrock'), 'classic' => __('Full Width (no sidebar)', 'shamrock'))));
Kirki::add_field('shamrock_settings', array('type' => 'checkbox', 'setting' => 'show_fimg', 'label' => __('Display featured image', 'shamrock'), 'section' => 'shamrock_blog', 'default' => 1));
Kirki::add_field('shamrock_settings', array('type' => 'image', 'setting' => 'default_fimg', 'label' => __('Deafult featured image', 'shamrock'), 'description' => __('Upload an image to display it for posts which don\'t have featured image set', 'shamrock'), 'section' => 'shamrock_blog', 'default' => '', 'required' => array(array('setting' => 'show_fimg', 'operator' => '==', 'value' => 1))));
Kirki::add_field('shamrock_settings', array('type' => 'checkbox', 'setting' => 'show_cat', 'label' => __('Display category', 'shamrock'), 'section' => 'shamrock_blog', 'default' => 1));
Kirki::add_field('shamrock_settings', array('type' => 'multicheck', 'setting' => 'meta', 'label' => __('Display post meta data', 'shamrock'), 'section' => 'shamrock_blog', 'default' => array('date', 'author', 'rtime', 'comments'), 'choices' => array('date' => __('Date', 'shamrock'), 'author' => __('Author', 'shamrock'), 'rtime' => __('Reading time', 'shamrock'), 'comments' => __('Comments', 'shamrock'))));
Kirki::add_field('shamrock_settings', array('type' => 'radio', 'setting' => 'content_type', 'label' => __('Content limit type', 'shamrock'), 'section' => 'shamrock_blog', 'default' => 'excerpt', 'choices' => array('content' => __('Manual (using &lt;!--more--&gt; tag)', 'shamrock'), 'excerpt' => __('Automatic (excerpt)', 'shamrock'))));
Kirki::add_field('shamrock_settings', array('type' => 'text', 'setting' => 'excerpt_length', 'label' => __('Excerpt length', 'shamrock'), 'description' => __('Specify your excerpt length (number of characters)', 'shamrock'), 'section' => 'shamrock_blog', 'default' => 230, 'required' => array(array('setting' => 'content_type', 'operator' => '==', 'value' => 'excerpt'))));
Kirki::add_field('shamrock_settings', array('type' => 'text', 'setting' => 'excerpt_more', 'label' => __('Excerpt "more" string', 'shamrock'), 'description' => __('Specify more string to append after excerpts', 'shamrock'), 'section' => 'shamrock_blog', 'default' => '...', 'required' => array(array('setting' => 'content_type', 'operator' => '==', 'value' => 'excerpt'))));
Kirki::add_field('shamrock_settings', array('type' => 'radio', 'setting' => 'pagination', 'label' => __('Pagination', 'shamrock'), 'section' => 'shamrock_blog', 'default' => 'numeric', 'choices' => array('numeric' => __('Numeric', 'shamrock'), 'classic' => __('Classic (prev/next)', 'shamrock'))));
/* Single post options */
Kirki::add_section('shamrock_single', array('priority' => 101, 'title' => __('Single Post', 'shamrock'), 'description' => __('These are settings which are applied to your single post template', 'shamrock')));
Kirki::add_field('shamrock_settings', array('type' => 'radio', 'setting' => 'single_layout', 'label' => __('Single posts layout', 'shamrock'), 'section' => 'shamrock_single', 'default' => 'sidebar', 'choices' => array('sidebar' => __('With Sidebar', 'shamrock'), 'classic' => __('Full Width (no sidebar)', 'shamrock'))));
Exemple #4
0
function gannet_kirki_init()
{
    Kirki::add_config('gannet_config', array('capability' => 'edit_theme_options', 'option_type' => 'theme_mod'));
    /**
     * Header Panel
     * - Header Image
     * - Header Logo
     */
    /**
     * Header Text or Logo
     */
    Kirki::add_field('gannet_config', array('type' => 'radio-buttonset', 'settings' => 'header_brand', 'label' => __('Show Header Text or Logo', 'gannet'), 'description' => __('Enable search functionality', 'gannet'), 'section' => 'title_tagline', 'priority' => 10, 'default' => 'text', 'choices' => array('text' => __('Header Text', 'gannet'), 'logo' => __('Logo', 'gannet'))));
    /**
     * Site Title Color
     */
    Kirki::add_field('gannet_config', array('type' => 'color', 'label' => __('Site Title Color', 'gannet'), 'settings' => 'site_title_color', 'section' => 'title_tagline', 'default' => '#292929', 'priority' => 10, 'required' => array(array('setting' => 'header_brand', 'operator' => '==', 'value' => 'text')), 'output' => array(array('element' => '.site-title a', 'property' => 'color')), 'transport' => 'postMessage', 'js_vars' => array(array('element' => '.site-title a', 'function' => 'css', 'property' => 'color'))));
    /**
     * Site Tagline Color
     */
    Kirki::add_field('gannet_config', array('type' => 'color', 'label' => __('Site Tagline Color', 'gannet'), 'settings' => 'site_tagline_color', 'section' => 'title_tagline', 'default' => '#7cccf9', 'priority' => 10, 'required' => array(array('setting' => 'header_brand', 'operator' => '==', 'value' => 'text')), 'output' => array(array('element' => '.site-description', 'property' => 'color')), 'transport' => 'postMessage', 'js_vars' => array(array('element' => '.site-description', 'function' => 'css', 'property' => 'color'))));
    Kirki::add_field('gannet_config', array('type' => 'select', 'settings' => 'site_title_font_family', 'label' => __('Site title Font Family', 'gannet'), 'section' => 'title_tagline', 'default' => 'Roboto Condensed', 'priority' => 20, 'choices' => Kirki_Fonts::get_font_choices(), 'required' => array(array('setting' => 'header_brand', 'operator' => '==', 'value' => 'text')), 'output' => array(array('element' => '.site-branding .site-title a', 'property' => 'font-family')), 'transport' => 'postMessage', 'js_vars' => array(array('element' => '.site-branding .site-title a', 'function' => 'css', 'property' => 'font-family'))));
    Kirki::add_field('gannet_config', array('type' => 'select', 'settings' => 'site_description_font_family', 'label' => __('Site Description Font Family', 'gannet'), 'section' => 'title_tagline', 'default' => 'Droid Serif', 'priority' => 20, 'choices' => Kirki_Fonts::get_font_choices(), 'required' => array(array('setting' => 'header_brand', 'operator' => '==', 'value' => 'text')), 'output' => array(array('element' => '.site-branding .site-description', 'property' => 'font-family')), 'transport' => 'postMessage', 'js_vars' => array(array('element' => '.site-branding .site-description', 'function' => 'css', 'property' => 'font-family'))));
    Kirki::add_field('gannet_config', array('settings' => 'logo', 'label' => __('Upload Your Logo', 'gannet'), 'description' => __('We recommend a maximum logo size of 260 x 80 pixels', 'gannet'), 'section' => 'title_tagline', 'priority' => 20, 'type' => 'upload', 'required' => array(array('setting' => 'header_brand', 'operator' => '==', 'value' => 'logo'))));
    Kirki::add_field('gannet_config', array('settings' => 'logo_retina', 'label' => __('Upload Your Retina Logo', 'gannet'), 'description' => __('The retina logo must be double the main logo resolution, so at our recommendation it would be 520 x 160 pixels', 'gannet'), 'section' => 'title_tagline', 'priority' => 20, 'type' => 'upload', 'required' => array(array('setting' => 'header_brand', 'operator' => '==', 'value' => 'logo'))));
    /**
     * Colors Panel
     * - Skin (Premium)
     * - Palettes (premium)
     * - Background Color
     * - Primary Color
     * - Secondary Color
     * - Headings Text Color
     * - Body Text Color
     */
    Kirki::add_field('gannet_config', array('type' => 'custom', 'label' => __('Skin', 'gannet'), 'description' => __('Choose between light or dark skins.', 'gannet'), 'settings' => 'skin_upsell', 'section' => 'colors', 'default' => gannet_upsell(__('This feature is only available in the premium version', 'gannet'))));
    Kirki::add_field('gannet_config', array('type' => 'custom', 'label' => __('Palettes', 'gannet'), 'description' => __('Choose between a set of carefully crafted pallettes.', 'gannet'), 'settings' => 'palettes_upsell', 'section' => 'colors', 'default' => gannet_upsell(__('This feature is only available in the premium version', 'gannet'))));
    /**
     * Background Color
     */
    Kirki::add_field('gannet_config', array('type' => 'color', 'label' => __('Background Color', 'gannet'), 'description' => __('Choose a background accent color.', 'gannet'), 'settings' => 'background_color', 'section' => 'colors', 'default' => '#f9f9f9', 'transport' => 'postMessage', 'js_vars' => array(array('element' => 'body', 'function' => 'css', 'property' => 'background-color'))));
    /**
     * Primary Color
     */
    Kirki::add_field('gannet_config', array('type' => 'color', 'label' => __('Primary Color', 'gannet'), 'description' => __('Choose a primary accent color.', 'gannet'), 'settings' => 'primary_color', 'section' => 'colors', 'default' => '#7bcaf7', 'transport' => 'postMessage', 'js_vars' => array(array('element' => 'a, .site-branding .site-description', 'function' => 'css', 'property' => 'color'))));
    /**
     * Secondary Color
     */
    Kirki::add_field('gannet_config', array('type' => 'color', 'label' => __('Secondary Color', 'gannet'), 'description' => __('Choose a secondary accent color.', 'gannet'), 'settings' => 'secondary_color', 'section' => 'colors', 'default' => '#f0b86f'));
    Kirki::add_field('gannet_config', array('type' => 'color', 'label' => __('Heading Text Color', 'gannet'), 'description' => __('Choose a heading (h1 - h6) color.', 'gannet'), 'settings' => 'heading_text_color', 'section' => 'colors', 'default' => '#292929', 'js_vars' => array(array('element' => 'h1, h2, h3, h4, h5, h6', 'function' => 'css', 'property' => 'color'))));
    Kirki::add_field('gannet_config', array('type' => 'color', 'label' => __('Body Text Color', 'gannet'), 'description' => __('Choose a body text color.', 'gannet'), 'settings' => 'body_text_color', 'section' => 'colors', 'default' => '#292929', 'js_vars' => array(array('element' => 'body', 'function' => 'css', 'property' => 'color'))));
    /**
     * Layout Section
     */
    Kirki::add_section('layout', array('priority' => 90, 'title' => __('Layout & Design', 'gannet')));
    Kirki::add_field('gannet_config', array('type' => 'custom', 'label' => __('Site Layout', 'gannet'), 'settings' => 'site_layout_upsell', 'section' => 'layout', 'default' => gannet_upsell(__('This feature is only available in the premium version', 'gannet'))));
    Kirki::add_field('gannet_config', array('type' => 'custom', 'label' => __('Header Layout', 'gannet'), 'settings' => 'header_layout_upsell', 'section' => 'layout', 'default' => gannet_upsell(__('This feature is only available in the premium version', 'gannet'))));
    Kirki::add_field('gannet_config', array('type' => 'switch', 'settings' => 'show_search', 'label' => __('Show Search', 'gannet'), 'description' => __('Enable search functionality', 'gannet'), 'help' => __('Displays/removes search icon in navigation and footer.', 'gannet'), 'section' => 'layout', 'priority' => 20, 'default' => '1', 'choices' => array('on' => __('On', 'gannet'), 'off' => __('Off', 'gannet'))));
    /**
     * Typography
     */
    Kirki::add_panel('typography_panel', array('priority' => 90, 'title' => __('Typography', 'gannet')));
    /**
     * Heading Type
     */
    Kirki::add_section('heading_type', array('title' => __('Headings', 'gannet'), 'panel' => 'typography_panel'));
    Kirki::add_field('gannet_config', array('type' => 'select', 'settings' => 'heading_type_font_family', 'label' => __('Font Family', 'gannet'), 'section' => 'heading_type', 'default' => 'Open Sans', 'priority' => 20, 'choices' => Kirki_Fonts::get_font_choices(), 'output' => array(array('element' => 'h1, h2, h3, h4, h5, h6', 'property' => 'font-family')), 'transport' => 'postMessage', 'js_vars' => array(array('element' => 'h1, h2, h3, h4, h5, h6', 'function' => 'css', 'property' => 'font-family'))));
    Kirki::add_field('gannet_config', array('type' => 'slider', 'settings' => 'heading_type_font_weight', 'label' => __('Font Weight', 'gannet'), 'section' => 'heading_type', 'default' => 600, 'priority' => 24, 'choices' => array('min' => 100, 'max' => 900, 'step' => 100), 'transport' => 'postMessage', 'js_vars' => array(array('element' => 'h1, h2, h3, h4, h5, h6', 'function' => 'css', 'property' => 'font-weight'))));
    /**
     * H1 Font Size
     */
    Kirki::add_field('gannet_config', array('type' => 'slider', 'settings' => 'heading_type_h1_font_size', 'label' => __('H1 Font Size', 'gannet'), 'section' => 'heading_type', 'default' => 40, 'priority' => 25, 'choices' => array('min' => 22, 'max' => 60, 'step' => 1), 'transport' => 'postMessage', 'js_vars' => array(array('element' => 'h1', 'function' => 'css', 'property' => 'font-size', 'units' => 'px'))));
    /**
     * H2 Font Size
     */
    Kirki::add_field('gannet_config', array('type' => 'slider', 'settings' => 'heading_type_h2_font_size', 'label' => __('H2 Font Size', 'gannet'), 'section' => 'heading_type', 'default' => 34, 'priority' => 25, 'choices' => array('min' => 20, 'max' => 50, 'step' => 1), 'transport' => 'postMessage', 'js_vars' => array(array('element' => 'h2', 'function' => 'css', 'property' => 'font-size', 'units' => 'px'))));
    /**
     * H3 Font Size
     */
    Kirki::add_field('gannet_config', array('type' => 'slider', 'settings' => 'heading_type_h3_font_size', 'label' => __('H3 Font Size', 'gannet'), 'section' => 'heading_type', 'default' => 24, 'priority' => 25, 'choices' => array('min' => 26, 'max' => 48, 'step' => 1), 'transport' => 'postMessage', 'js_vars' => array(array('element' => 'h3', 'function' => 'css', 'property' => 'font-size', 'units' => 'px'))));
    /**
     * H4 Font Size
     */
    Kirki::add_field('gannet_config', array('type' => 'slider', 'settings' => 'heading_type_h4_font_size', 'label' => __('H4 Font Size', 'gannet'), 'section' => 'heading_type', 'default' => 22, 'priority' => 25, 'choices' => array('min' => 16, 'max' => 40, 'step' => 1), 'transport' => 'postMessage', 'js_vars' => array(array('element' => 'h4', 'function' => 'css', 'property' => 'font-size', 'units' => 'px'))));
    /**
     * H5 Font Size
     */
    Kirki::add_field('gannet_config', array('type' => 'slider', 'settings' => 'heading_type_h5_font_size', 'label' => __('H5 Font Size', 'gannet'), 'section' => 'heading_type', 'default' => 20, 'priority' => 25, 'choices' => array('min' => 14, 'max' => 40, 'step' => 1), 'transport' => 'postMessage', 'js_vars' => array(array('element' => 'h5', 'function' => 'css', 'property' => 'font-size', 'units' => 'px'))));
    /**
     * H6 Font Size
     */
    Kirki::add_field('gannet_config', array('type' => 'slider', 'settings' => 'heading_type_h6_font_size', 'label' => __('H6 Font Size', 'gannet'), 'section' => 'heading_type', 'default' => 18, 'priority' => 25, 'choices' => array('min' => 12, 'max' => 30, 'step' => 1), 'transport' => 'postMessage', 'js_vars' => array(array('element' => 'h6', 'function' => 'css', 'property' => 'font-size', 'units' => 'px'))));
    /**
     * Base Typography
     */
    Kirki::add_section('base_type', array('title' => __('Base', 'gannet'), 'panel' => 'typography_panel'));
    Kirki::add_field('gannet_config', array('type' => 'select', 'settings' => 'base_type_font_family', 'label' => __('Font Family', 'gannet'), 'section' => 'base_type', 'default' => 'Open Sans', 'priority' => 20, 'choices' => Kirki_Fonts::get_font_choices(), 'transport' => 'postMessage', 'output' => array(array('element' => 'body', 'property' => 'font-family')), 'js_vars' => array(array('element' => 'body', 'function' => 'css', 'property' => 'font-family'))));
    Kirki::add_field('gannet_config', array('type' => 'slider', 'settings' => 'base_type_font_weight', 'label' => __('Font Weight', 'gannet'), 'section' => 'base_type', 'default' => 300, 'priority' => 24, 'choices' => array('min' => 100, 'max' => 900, 'step' => 100), 'transport' => 'postMessage', 'js_vars' => array(array('element' => 'body', 'function' => 'css', 'property' => 'font-weight'))));
    /**
     * Base Font Size
     */
    Kirki::add_field('gannet_config', array('type' => 'slider', 'settings' => 'base_type_font_size', 'label' => __('Base Font Size', 'gannet'), 'section' => 'base_type', 'default' => 14, 'priority' => 25, 'choices' => array('min' => 12, 'max' => 30, 'step' => 1), 'output' => array(array('element' => 'body', 'property' => 'font-size', 'units' => 'px')), 'transport' => 'postMessage', 'js_vars' => array(array('element' => 'body', 'function' => 'css', 'property' => 'font-size', 'units' => 'px'))));
}
Exemple #5
0
 */
function kirki_numeric_fields($fields)
{
    // step = 10
    $fields[] = array('type' => 'slider', 'settings' => 'slider_demo', 'label' => __('This is the label', 'kirki'), 'description' => __('This is the control description', 'kirki'), 'help' => __('This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki'), 'section' => 'numeric', 'default' => 20, 'priority' => 10, 'choices' => array('min' => -100, 'max' => 100, 'step' => 10));
    // step = 0.01
    $fields[] = array('type' => 'slider', 'settings' => 'slider_demo_2', 'label' => __('This is the label', 'kirki'), 'description' => __('This is the control description', 'kirki'), 'help' => __('This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki'), 'section' => 'numeric', 'default' => 1.58, 'priority' => 20, 'choices' => array('min' => 0, 'max' => 5, 'step' => 0.01));
    $fields[] = array('type' => 'number', 'settings' => 'number_demo', 'label' => __('This is the label', 'kirki'), 'description' => __('This is the control description', 'kirki'), 'help' => __('This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki'), 'section' => 'numeric', 'default' => '42', 'priority' => 10);
    return $fields;
}
add_filter('kirki/fields', 'kirki_numeric_fields');
/**
 * Create a config instance that will be used by fields added via the static methods.
 * For this example we'll be defining our options to be serialized in the db, under the 'kirki_demo' option.
 */
Kirki::add_config('kirki_demo', array('options_type' => 'option', 'option_name' => 'kirki_demo'));
/**
 * Create Custom field using the Kirki API static functions
 */
Kirki::add_field('kirki_demo', array('type' => 'custom', 'settings' => 'custom_demo', 'label' => __('This is the label', 'kirki'), 'description' => __('This is the control description', 'kirki'), 'help' => __('This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki'), 'section' => 'custom_section', 'default' => '<div style="padding: 30px;background-color: #333; color: #fff; border-radius: 50px;">You can enter custom markup in this control and use it however you want</div>', 'priority' => 10));
/**
 * Create Color fields using the Kirki API static functions
 */
Kirki::add_field('kirki_demo', array('type' => 'color', 'settings' => 'color_demo', 'label' => __('Color Control', 'kirki'), 'description' => __('This is the control description', 'kirki'), 'help' => __('This is some extra help. You can use this to add some additional instructions for users.', 'kirki'), 'section' => 'color_section', 'default' => '#0088cc', 'priority' => 10, 'output' => array(array('element' => 'a, a:visited', 'property' => 'color', 'units' => ' !important'), array('element' => '#content', 'property' => 'border-color')), 'transport' => 'postMessage', 'js_vars' => array(array('element' => 'a, a:visited', 'function' => 'css', 'property' => 'color'), array('element' => '#content', 'function' => 'css', 'property' => 'background-color'))));
Kirki::add_field('kirki_demo', array('type' => 'color-alpha', 'settings' => 'color_alpha_demo', 'label' => __('Color-Alpha Control', 'kirki'), 'description' => __('This is the control description', 'kirki'), 'help' => __('This is some extra help. You can use this to add some additional instructions for users.', 'kirki'), 'section' => 'color_section', 'default' => '#0088cc', 'priority' => 10, 'output' => array(array('element' => 'a, a:visited', 'property' => 'color', 'units' => ' !important'), array('element' => '#content', 'property' => 'border-color')), 'transport' => 'postMessage', 'js_vars' => array(array('element' => 'a, a:visited', 'function' => 'css', 'property' => 'color'), array('element' => '#content', 'function' => 'css', 'property' => 'background-color'))));
/**
 * Create Boolean fields using the Kirki API static functions
 */
// Checkbox
Kirki::add_field('kirki_demo', array('type' => 'checkbox', 'settings' => 'checkbox_demo_0', 'label' => __('This is the label', 'kirki'), 'description' => __('This is the control description', 'kirki'), 'help' => __('This is some extra help. You can use this to add some additional instructions for users.', 'kirki'), 'section' => 'boolean_controls', 'default' => 1, 'priority' => 10));
// Switch
function kirki_hooks_init()
{
    Kirki::add_config('my_kirki_repeater', array('capability' => 'edit_theme_options', 'option_type' => 'option', 'option_name' => 'my_kirki_repeater'));
    Kirki::add_section('my_kirki_repeater_section', array('title' => __('Kirki Repeater', 'kirki'), 'description' => __('Add custom CSS here', 'kirki'), 'panel' => '', 'priority' => 1, 'capability' => 'edit_theme_options', 'theme_supports' => ''));
}
Exemple #7
0
<?php

function my_theme_kirki_textdomain()
{
    $config['i18n']['add-new'] = esc_attr__('Tilføj', 'fagy');
    return $config;
}
if (class_exists('Kirki')) {
    add_filter('kirki/config', 'my_theme_kirki_textdomain');
    // Config for kirki
    Kirki::add_config('faaborg_gym', array('capability' => 'edit_theme_options', 'option_type' => 'theme_mod'));
    // Topbar
    require 'topbar.php';
    // Hero banner
    require 'hero-banner.php';
    // Footer
    require 'footer.php';
    // Facebook
    require 'facebook.php';
}
Exemple #8
0
 public function add_config()
 {
     Kirki::add_config('my_config', array('option_type' => 'option', 'option_name' => 'my_option', 'capability' => 'edit_posts'));
     Kirki::add_config('my_config2', array('option_type' => 'theme_mod', 'capability' => 'edit_posts'));
     Kirki::add_config('my_config3', array('option_type' => 'option', 'capability' => 'edit_posts'));
 }
Exemple #9
0
    define('WEFOSTER_CUSTOMIZER_URL', get_template_directory_uri());
}
// Our Mobile Devices Class that helps with loading responsive template parts and assets.
// We include this class because wp_is_mobile is unreliable in some cases.
if (!function_exists('wff_notphone') && !defined('WP_CLI')) {
    require_once WEFOSTER_THEME_DIR . '/lib/vendor/Mobile-Detect/wp-mobile-detect.php';
}
/**
 * Set up Kirki
 *
 * @since 1.0.0
 *
 */
if (!defined('WEFOSTER_PLUS_PLUGIN_DIR')) {
    require WEFOSTER_CUSTOMIZER_DIR . '/lib/vendor/kirki/kirki.php';
    Kirki::add_config('wefoster_plus', array('capability' => 'edit_theme_options', 'option_type' => 'theme_mod'));
}
/**
 * $content_width is a global variable used by WordPress for max image upload sizes
 * and media embeds (in pixels).
 * @since 1.0.0
 *
 * Example: If the content area is 640px wide, set $content_width = 620; so images and videos will not overflow.
 * Default: 1140px is the default Bootstrap container width.
 */
if (!isset($content_width)) {
    $content_width = 1140;
}
/**
 * Load our Files
 *
Exemple #10
0
 public function add_config()
 {
     Kirki::add_config('my_config_theme_mods', array('option_type' => 'theme_mod', 'capability' => 'edit_posts'));
     Kirki::add_config('my_config_options', array('option_type' => 'option', 'capability' => 'edit_posts'));
     Kirki::add_config('my_config_options_serialized', array('option_type' => 'option', 'option_name' => 'my_option', 'capability' => 'edit_posts'));
 }
<?php

/* ------------------------------------------------------------------------- *
 *  This file contains the options for the theme.
/* ------------------------------------------------------------------------- */
// Integrating Kirki with our theme
include_once get_template_directory() . '/kirki/kirki.php';
// Adding the configuration
Kirki::add_config('mc', array('capability' => 'edit_theme_options', 'option_type' => 'option', 'option_name' => 'mc'));
// Adding the Product Slider panel
Kirki::add_panel('product_slider', array('priority' => 10, 'title' => __('Product Slider', 'magnificient'), 'description' => __('A slider to show the products', 'magnificient')));
// Adding the Product Description panel
Kirki::add_panel('product_description', array('priority' => 10, 'title' => __('Product Description', 'magnificient'), 'description' => __('Panels to show description of the products', 'magnificient')));
// Adding the Product Details panel
Kirki::add_panel('product_details', array('priority' => 10, 'title' => __('Product Details', 'magnificient'), 'description' => __('Panels to show details of the products', 'magnificient')));
// Adding the Team Showcase panel
Kirki::add_panel('team_showcase', array('priority' => 10, 'title' => __('Team Showcase', 'magnificient'), 'description' => __('A section to show your team', 'magnificient')));
// Adding the Frontpage Separate Page Content panel
Kirki::add_panel('front_page_separate_page_content', array('priority' => 10, 'title' => __('Frontpage Separate Page Content', 'magnificient'), 'description' => __('A section to fetch content from another page', 'magnificient')));
// Adding the Product Slider for Homepage section
Kirki::add_section('product_slider_for_homepage', array('title' => __('Product Slider for Homepage', 'magnificient'), 'description' => __('This slider will be shown on the front page of your website', 'magnificient'), 'panel' => 'product_slider', 'priority' => 160, 'capability' => 'edit_theme_options', 'theme_supports' => ''));
// Adding the Product Images for Homepage section
Kirki::add_section('product_images_for_homepage', array('title' => __('Product Images for Homepage', 'magnificient'), 'description' => __('These images will be shown on the product description panels on the  front page of your website', 'magnificient'), 'panel' => 'product_description', 'priority' => 160, 'capability' => 'edit_theme_options', 'theme_supports' => ''));
// Adding the Product Description for Homepage section
Kirki::add_section('product_description_for_homepage', array('title' => __('Product Description for Homepage', 'magnificient'), 'description' => __('These panels will be shown on the front page of your website', 'magnificient'), 'panel' => 'product_description', 'priority' => 160, 'capability' => 'edit_theme_options', 'theme_supports' => ''));
// Adding the Product Details for Homepage section
Kirki::add_section('product_details_for_homepage', array('title' => __('Product Details for Homepage', 'magnificient'), 'description' => __('This will show the details on the front page of your website', 'magnificient'), 'panel' => 'product_details', 'priority' => 160, 'capability' => 'edit_theme_options', 'theme_supports' => ''));
// Adding the Team Showcase for Homepage section
Kirki::add_section('team_showcase_for_homepage', array('title' => __('Team Showcase for Homepage', 'magnificient'), 'description' => __('This will show the team members on the front page of your website', 'magnificient'), 'panel' => 'team_showcase', 'priority' => 160, 'capability' => 'edit_theme_options', 'theme_supports' => ''));
// Adding the Frontpage Separate Page Content for Homepage section
Kirki::add_section('front_page_separate_page_content_for_homepage', array('title' => __('Frontpage Separate Page Content for Homepage', 'magnificient'), 'description' => __('This will show the separate page content on the front page of your website', 'magnificient'), 'panel' => 'front_page_separate_page_content', 'priority' => 160, 'capability' => 'edit_theme_options', 'theme_supports' => ''));
Exemple #12
0
// Early exit if Kirki is not installed
if (!class_exists('Kirki')) {
    return;
}
/**
 * Create panels using the Kirki API.
 */
Kirki::add_section('site_general', array('priority' => 10, 'title' => __('General', 'beagency'), 'description' => __('You may need to refresh the page to see the changes.', 'beagency')));
Kirki::add_section('site_homepage', array('priority' => 20, 'title' => __('Homepage', 'beagency'), 'description' => __('Here you can customize your homepage.', 'beagency'), 'active_callback' => 'is_front_page'));
Kirki::add_section('site_404_page', array('priority' => 30, 'title' => __('404 Page', 'beagency'), 'description' => __('Here you can customize your 404 Page.', 'beagency'), 'active_callback' => 'is_404'));
Kirki::add_section('site_footer', array('priority' => 120, 'title' => __('Site Footer', 'beagency'), 'description' => __('Here you can customize the footer on your site.', 'beagency')));
Kirki::add_section('upgrade_theme', array('priority' => 130, 'title' => __('Upgrade', 'beagency')));
/**
 * Create a config instance that will be used by fields added via the static methods.
 */
Kirki::add_config('beagency_kirki', array('option_type' => 'theme_mod'));
/**
 * Create fields using the Kirki API static functions.
 */
Kirki::add_field('beagency_kirki', array('type' => 'text', 'settings' => 'general_site_title', 'label' => __('Site Title', 'beagency'), 'section' => 'site_general', 'default' => get_bloginfo('name'), 'priority' => 10, 'transport' => 'postMessage', 'js_vars' => array(array('element' => '.site-title a', 'function' => 'html', 'property' => 'text'))));
Kirki::add_field('beagency_kirki', array('type' => 'dropdown-pages', 'settings' => 'general_front_page', 'label' => __('Front Page', 'beagency'), 'help' => __('Create a blank page with Home Page template and set it as Front Page.', 'beagency'), 'section' => 'site_general', 'default' => get_option('page_on_front'), 'priority' => 20));
Kirki::add_field('beagency_kirki', array('type' => 'dropdown-pages', 'settings' => 'general_posts_page', 'label' => __('Posts Page', 'beagency'), 'help' => __('Create a blank page and set it as Posts Page.', 'beagency'), 'section' => 'site_general', 'default' => get_option('page_for_posts'), 'priority' => 30));
Kirki::add_field('beagency_kirki', array('type' => 'checkbox', 'settings' => 'general_sticky_menu', 'label' => __('Enable Sticky Menu?', 'beagency'), 'help' => __('If enable, the menu will be accessible from anywhere without having to scroll.', 'beagency'), 'section' => 'site_general', 'default' => '1', 'priority' => 40));
Kirki::add_field('beagency_kirki', array('type' => 'checkbox', 'settings' => 'general_go_to_top', 'label' => __('Enable Go to Top Button?', 'beagency'), 'section' => 'site_general', 'default' => '1', 'priority' => 50));
Kirki::add_field('beagency_kirki', array('type' => 'checkbox', 'settings' => 'homepage_heading', 'label' => __('Enable Heading Block?', 'beagency'), 'section' => 'site_homepage', 'default' => '1', 'priority' => 10));
Kirki::add_field('beagency_kirki', array('type' => 'textarea', 'settings' => 'homepage_heading_h1', 'label' => __('Heading', 'beagency'), 'help' => __('If you want to color the word, just wrap it with \\"span\\" tag.', 'beagency'), 'section' => 'site_homepage', 'default' => 'Hello, We are <span>BeTheme</span>. We <span><i class="fa fa-heart-o"></i></span> WordPress!', 'priority' => 20, 'required' => array(array('setting' => 'homepage_heading', 'operator' => '==', 'value' => 1))));
Kirki::add_field('beagency_kirki', array('type' => 'textarea', 'settings' => 'homepage_heading_span', 'label' => __('Content', 'beagency'), 'section' => 'site_homepage', 'default' => 'We handcraft well-thought-out WordPress themes built on solid coding and elegant design.', 'priority' => 30, 'required' => array(array('setting' => 'homepage_heading', 'operator' => '==', 'value' => 1))));
Kirki::add_field('beagency_kirki', array('type' => 'checkbox', 'settings' => 'homepage_image', 'label' => __('Enable Header Image?', 'beagency'), 'section' => 'site_homepage', 'default' => '0', 'priority' => 40));
Kirki::add_field('beagency_kirki', array('type' => 'image', 'settings' => 'homepage_image_url', 'label' => __('Current Header Image', 'beagency'), 'section' => 'site_homepage', 'default' => '', 'priority' => 50, 'required' => array(array('setting' => 'homepage_image', 'operator' => '==', 'value' => 1))));
Kirki::add_field('beagency_kirki', array('type' => 'text', 'settings' => 'homepage_portfolio_title', 'label' => __('Portfolio Block Title', 'beagency'), 'help' => __('If you want to color the word, just wrap it with \\"span\\" tag.', 'beagency'), 'section' => 'site_homepage', 'default' => 'Our <span>Latest</span> Works', 'priority' => 60));
Kirki::add_field('beagency_kirki', array('type' => 'checkbox', 'settings' => 'homepage_blog', 'label' => __('Enable Blog Block?', 'beagency'), 'section' => 'site_homepage', 'default' => '1', 'priority' => 70));
<?php

if (class_exists('Kirki')) {
    Kirki::add_config('smamo_conf', array('capability' => 'edit_theme_options', 'option_type' => 'theme_mod'));
    Kirki::add_config('smamo_business_info', array('capability' => 'edit_theme_options', 'option_type' => 'theme_mod'));
    require 'kirki/info.php';
}
 /**
  * Test sanitize_config_id
  */
 public function test_sanitize_config_id()
 {
     // Define invalid config IDs. should return 'global'.
     $this->assertEquals('global', Kirki_Field::sanitize_config_id('foo', array('kirki_config' => 'bar')));
     $this->assertEquals('global', Kirki_Field::sanitize_config_id(array()));
     Kirki::add_config('foo');
     Kirki::add_config('bar');
     $this->assertEquals('bar', Kirki_Field::sanitize_config_id('foo', array('kirki_config' => 'bar')));
     $this->assertEquals('foo', Kirki_Field::sanitize_config_id('foo', array()));
     $this->assertEquals('global', Kirki_Field::sanitize_config_id('', array()));
     $this->assertEquals('global', Kirki_Field::sanitize_config_id());
 }
Exemple #15
0
<?php

Kirki::add_config('smamo_conf', array('capability' => 'edit_theme_options', 'option_type' => 'theme_mod'));
Kirki::add_config('smamo_business_info', array('capability' => 'edit_theme_options', 'option_type' => 'theme_mod'));
Kirki::add_config('smamo_logo', array('capability' => 'edit_theme_options', 'option_type' => 'theme_mod'));
Kirki::add_config('smamo_front_video', array('capability' => 'edit_theme_options', 'option_type' => 'theme_mod'));
require 'kirki/info.php';
require 'kirki/logo.php';
require 'kirki/video.php';
Exemple #16
0
/**
 * Setting Customizer
 * ==================
 */
function infinity_customizer_sections($wp_customize)
{
    $wp_customize->get_section('io_section')->priority = '40';
}
if (function_exists('register_section_for_io_section')) {
    add_action('customize_register', 'infinity_customizer_sections');
}
/**
 * General setups
 * ==============
 */
Kirki::add_config('infinity', array('option_type' => 'theme_mod', 'capability' => 'edit_theme_options'));
$priority = 1;
// Add panels
Kirki::add_panel('site', array('priority' => $priority++, 'title' => __('Site', 'infinity'), 'description' => __('My Description', 'infinity')));
Kirki::add_panel('top', array('priority' => $priority++, 'title' => __('Top Area', 'infinity'), 'description' => __('My Description', 'infinity')));
Kirki::add_panel('header', array('priority' => $priority++, 'title' => __('Header', 'infinity'), 'description' => __('My Description', 'infinity')));
Kirki::add_panel('nav', array('priority' => $priority++, 'title' => __('Navigation', 'infinity'), 'description' => __('My Description', 'infinity')));
Kirki::add_panel('button', array('priority' => $priority++, 'title' => __('Button', 'infinity'), 'description' => __('My Description', 'infinity')));
Kirki::add_panel('footer', array('priority' => $priority++, 'title' => __('Footer', 'infinity'), 'description' => __('My Description', 'infinity')));
Kirki::add_panel('copyright', array('priority' => $priority++, 'title' => __('Copyright', 'infinity'), 'description' => __('My Description', 'infinity')));
Kirki::add_panel('page', array('priority' => $priority++, 'title' => __('Page', 'infinity'), 'description' => __('My Description', 'infinity')));
Kirki::add_panel('post', array('priority' => $priority++, 'title' => __('Post', 'infinity'), 'description' => __('My Description', 'infinity')));
Kirki::add_panel('woo', array('priority' => $priority++, 'title' => __('Woocommerce', 'infinity'), 'description' => __('My Description', 'infinity')));
Kirki::add_panel('custom', array('priority' => $priority++, 'title' => __('Custom code', 'infinity'), 'description' => __('My Description', 'infinity')));
$priority = 1;
// Add sections for site panel
Exemple #17
0
 public static function setArgs($opt_name = '', $args = array())
 {
     Kirki::add_config($opt_name, array('option_type' => 'option', 'option_name' => $args['opt_name']));
 }
 /**
  * Config main kirki settings
  *
  * @throws Exception
  * @access private
  */
 private function config()
 {
     if (!isset(static::$id) || is_null(static::$id)) {
         throw new Exception(Translate::translate(__CLASS__ . '::id is required and can not be empty!'));
     }
     if (!isset($this->capability) || is_null($this->capability)) {
         throw new Exception(Translate::translate(__CLASS__ . '::capability is required and can not be empty!'));
     }
     if (!isset($this->option_key_name) || is_null($this->option_key_name)) {
         throw new Exception(Translate::translate(__CLASS__ . '::option_key_name is required and can not be empty!'));
     }
     \Kirki::add_config(static::$id, array('capability' => $this->capability, 'option_type' => $this->option_type, 'option_name' => $this->option_key_name));
 }
Exemple #19
0
 */
function kirki_numeric_fields($fields)
{
    // step = 10
    $fields[] = array('type' => 'slider', 'settings' => 'slider_demo', 'label' => __('This is the label', 'kirki'), 'description' => __('This is the control description', 'kirki'), 'help' => __('This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki'), 'section' => 'numeric', 'default' => 20, 'priority' => 10, 'choices' => array('min' => -100, 'max' => 100, 'step' => 10));
    // step = 0.01
    $fields[] = array('type' => 'slider', 'settings' => 'slider_demo_2', 'label' => __('This is the label', 'kirki'), 'description' => __('This is the control description', 'kirki'), 'help' => __('This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki'), 'section' => 'numeric', 'default' => 1.58, 'priority' => 20, 'choices' => array('min' => 0, 'max' => 5, 'step' => 0.01));
    $fields[] = array('type' => 'number', 'settings' => 'number_demo', 'label' => __('This is the label', 'kirki'), 'description' => __('This is the control description', 'kirki'), 'help' => __('This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki'), 'section' => 'numeric', 'default' => '42', 'priority' => 10);
    return $fields;
}
add_filter('kirki/fields', 'kirki_numeric_fields');
/**
 * Create a config instance that will be used by fields added via the static methods.
 * For this example we'll be defining our options to be serialized in the db, under the 'kirki_demo' option.
 */
Kirki::add_config('kirki_demo', array('option_type' => 'theme_mod'));
/**
 * Create Custom field using the Kirki API static functions
 */
Kirki::add_field('kirki_demo', array('type' => 'custom', 'settings' => 'custom_demo', 'label' => __('This is the label', 'kirki'), 'description' => __('This is the control description', 'kirki'), 'help' => __('This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki'), 'section' => 'custom_section', 'default' => '<div style="padding: 30px;background-color: #333; color: #fff; border-radius: 50px;">You can enter custom markup in this control and use it however you want</div>', 'priority' => 10));
/**
 * Create Color fields using the Kirki API static functions
 */
Kirki::add_field('kirki_demo', array('type' => 'color', 'settings' => 'color_demo', 'label' => __('Color Control', 'kirki'), 'description' => __('This is the control description', 'kirki'), 'help' => __('This is some extra help. You can use this to add some additional instructions for users.', 'kirki'), 'section' => 'color_section', 'default' => '#0088cc', 'priority' => 10, 'output' => array(array('element' => 'a, a:visited', 'property' => 'color', 'units' => ' !important'), array('element' => '#content', 'property' => 'border-color')), 'transport' => 'postMessage', 'js_vars' => array(array('element' => 'a, a:visited', 'function' => 'css', 'property' => 'color'), array('element' => '#content', 'function' => 'css', 'property' => 'background-color'))));
Kirki::add_field('kirki_demo', array('type' => 'color-alpha', 'settings' => 'color_alpha_demo', 'label' => __('Color-Alpha Control', 'kirki'), 'description' => __('This is the control description', 'kirki'), 'help' => __('This is some extra help. You can use this to add some additional instructions for users.', 'kirki'), 'section' => 'color_section', 'default' => '#0088cc', 'priority' => 10, 'output' => array(array('element' => 'a, a:visited', 'property' => 'color', 'units' => ' !important'), array('element' => '#content', 'property' => 'border-color')), 'transport' => 'postMessage', 'js_vars' => array(array('element' => 'a, a:visited', 'function' => 'css', 'property' => 'color'), array('element' => '#content', 'function' => 'css', 'property' => 'background-color'))));
/**
 * Create Boolean fields using the Kirki API static functions
 */
// Checkbox
Kirki::add_field('kirki_demo', array('type' => 'checkbox', 'settings' => 'checkbox_demo_0', 'label' => __('This is the label', 'kirki'), 'description' => __('This is the control description', 'kirki'), 'help' => __('This is some extra help. You can use this to add some additional instructions for users.', 'kirki'), 'section' => 'boolean_controls', 'default' => 1, 'priority' => 10));
// Switch
Exemple #20
0
<?php

Kirki::add_config('dreamville_config', array('option_type' => 'theme_mod', 'capability' => 'edit_theme_options'));
Exemple #21
0
     * @since 0.8.0
     */
    function kirki_load_textdomain()
    {
        $textdomain = 'kirki';
        // Look for WP_LANG_DIR/{$domain}-{$locale}.mo
        if (file_exists(WP_LANG_DIR . '/' . $textdomain . '-' . get_locale() . '.mo')) {
            $file = WP_LANG_DIR . '/' . $textdomain . '-' . get_locale() . '.mo';
        }
        // Look for Kirki::$path/languages/{$domain}-{$locale}.mo
        if (!isset($file) && file_exists(Kirki::$path . DIRECTORY_SEPARATOR . 'languages' . DIRECTORY_SEPARATOR . $textdomain . '-' . get_locale() . '.mo')) {
            $file = Kirki::$path . DIRECTORY_SEPARATOR . 'languages' . DIRECTORY_SEPARATOR . $textdomain . '-' . get_locale() . '.mo';
        }
        if (isset($file)) {
            load_textdomain($textdomain, $file);
        }
        load_plugin_textdomain($textdomain, false, Kirki::$path . DIRECTORY_SEPARATOR . 'languages');
    }
    add_action('plugins_loaded', 'kirki_load_textdomain');
}
// Add an empty config for global fields
Kirki::add_config('');
/**
 * To enable the demo theme, just add this line to your wp-config.php file:
 * define( 'KIRKI_CONFIG', true );
 * Once you add that line, you'll see a new theme in your dashboard called "Kirki Demo".
 * Activate that theme to test all controls.
 */
if (defined('KIRKI_DEMO') && KIRKI_DEMO && file_exists(dirname(__FILE__) . '/demo-theme/style.css')) {
    register_theme_directory(dirname(__FILE__));
}
Exemple #22
0
<?php

Kirki::add_config('smamo_conf', array('capability' => 'edit_theme_options', 'option_type' => 'theme_mod'));
Kirki::add_config('smamo_business_info', array('capability' => 'edit_theme_options', 'option_type' => 'theme_mod'));
Kirki::add_config('mailchimp', array('capability' => 'edit_theme_options', 'option_type' => 'theme_mod'));
require 'kirki/logos.php';
require 'kirki/info.php';
require 'kirki/mailchimp.php';
Exemple #23
0
  * Add sections
  */
 Kirki::add_section('checkbox', array('title' => esc_attr__('Checkbox Controls', 'kirki-demo'), 'priority' => 1, 'capability' => 'edit_theme_options'));
 Kirki::add_section('text', array('title' => esc_attr__('Text Controls', 'kirki-demo'), 'priority' => 2, 'capability' => 'edit_theme_options'));
 Kirki::add_section('color', array('title' => esc_attr__('Color & Color-Alpha Controls', 'kirki-demo'), 'priority' => 3, 'capability' => 'edit_theme_options'));
 Kirki::add_section('numeric', array('title' => esc_attr__('Numeric Controls', 'kirki-demo'), 'priority' => 4, 'capability' => 'edit_theme_options'));
 Kirki::add_section('radio', array('title' => esc_attr__('Radio Controls', 'kirki-demo'), 'priority' => 5, 'capability' => 'edit_theme_options'));
 Kirki::add_section('select', array('title' => esc_attr__('Select Controls', 'kirki-demo'), 'priority' => 6, 'capability' => 'edit_theme_options'));
 Kirki::add_section('composite', array('title' => esc_attr__('Composite Controls', 'kirki-demo'), 'priority' => 7, 'capability' => 'edit_theme_options'));
 Kirki::add_section('custom', array('title' => esc_attr__('Custom Control', 'kirki-demo'), 'priority' => 4, 'capability' => 'edit_theme_options'));
 /**
  * Add the configuration.
  * This way all the fields using the 'kirki_demo' ID
  * will inherit these options
  */
 Kirki::add_config('kirki_demo', array('capability' => 'edit_theme_options', 'option_type' => 'theme_mod'));
 /**
  * Add fields
  */
 Kirki::add_field('kirki_demo', array('type' => 'checkbox', 'settings' => 'checkbox_demo', 'label' => esc_attr__('Checkbox demo', 'kirki'), 'description' => esc_attr__('This is a simple checkbox', 'kirki-demo'), 'help' => esc_attr__('This is a tooltip', 'kirki-demo'), 'section' => 'checkbox', 'default' => true, 'priority' => 10));
 Kirki::add_field('kirki_demo', array('type' => 'switch', 'settings' => 'switch_demo', 'label' => esc_attr__('Switch demo', 'kirki'), 'description' => esc_attr__('This is a switch control. Internally it is a checkbox and you can also change the ON/OFF labels.', 'kirki-demo'), 'help' => esc_attr__('This is a tooltip', 'kirki-demo'), 'section' => 'checkbox', 'default' => true, 'priority' => 10, 'required' => array(array('setting' => 'checkbox_demo', 'operator' => '==', 'value' => true))));
 Kirki::add_field('kirki_demo', array('type' => 'toggle', 'settings' => 'toggle_demo', 'label' => esc_attr__('Toggle demo', 'kirki'), 'description' => esc_attr__('This is a toggle. it is basically identical to a switch, the only difference is that it does not have any labels and to save space it is inline with the label. Internally this is a checkbox.', 'kirki-demo'), 'help' => esc_attr__('This is a tooltip', 'kirki-demo'), 'section' => 'checkbox', 'default' => true, 'priority' => 10));
 Kirki::add_field('kirki_demo', array('type' => 'text', 'settings' => 'text_demo', 'label' => esc_attr__('Text Control', 'kirki-demo'), 'help' => esc_attr__('This is a tooltip', 'kirki-demo'), 'default' => esc_attr__('This text is entered in the "text" control.', 'kirki-demo'), 'section' => 'text', 'default' => '', 'priority' => 10));
 Kirki::add_field('kirki_demo', array('type' => 'textarea', 'settings' => 'textarea_demo', 'label' => esc_attr__('Textarea Control', 'kirki-demo'), 'help' => esc_attr__('This is a tooltip', 'kirki-demo'), 'default' => esc_attr__('This text is entered in the "textarea" control.', 'kirki-demo'), 'section' => 'text', 'default' => '', 'priority' => 10));
 Kirki::add_field('kirki_demo', array('type' => 'editor', 'settings' => 'editor_demo', 'label' => esc_attr__('Editor Control', 'kirki-demo'), 'help' => esc_attr__('This is a tooltip', 'kirki-demo'), 'section' => 'text', 'default' => esc_attr__('This text is entered in the "editor" control.', 'kirki-demo'), 'priority' => 10));
 Kirki::add_field('kirki_demo', array('type' => 'code', 'settings' => 'code_demo', 'label' => esc_attr__('Code Control', 'kirki'), 'help' => esc_attr__('This is a tooltip', 'kirki-demo'), 'description' => esc_attr__('This is a simple code control. You can define the language you want as well as the theme. In this demo we are using a CSS editor with the monokai theme.', 'kirki-demo'), 'section' => 'text', 'default' => 'body { background: #fff; }', 'priority' => 10, 'choices' => array('language' => 'css', 'theme' => 'monokai', 'height' => 250)));
 Kirki::add_field('kirki_demo', array('type' => 'color', 'settings' => 'color_demo', 'label' => esc_attr__('Color Control', 'kirki'), 'description' => esc_attr__('This uses the default WordPress-core color control.', 'kirki-demo'), 'help' => esc_attr__('This is a tooltip', 'kirki-demo'), 'section' => 'color', 'default' => '#81d742', 'priority' => 10, 'output' => array(array('element' => '.demo.color p', 'property' => 'color')), 'transport' => 'postMessage', 'js_vars' => array(array('element' => '.demo.color p', 'function' => 'css', 'property' => 'color'))));
 Kirki::add_field('kirki_demo', array('type' => 'color-alpha', 'settings' => 'color_alpha_demo', 'label' => esc_attr__('Color-Alpha Control', 'kirki'), 'description' => esc_attr__('Similar to the default Color control but with a teist: This one allows you to also select an opacity for the color and saves the value as HEX or RGBA depending on the alpha channel\'s value.', 'kirki-demo'), 'help' => esc_attr__('This is a tooltip', 'kirki-demo'), 'section' => 'color', 'default' => '#333333', 'priority' => 10, 'output' => array(array('element' => '.demo.color', 'property' => 'background-color')), 'transport' => 'postMessage', 'js_vars' => array(array('element' => '.demo.color', 'function' => 'css', 'property' => 'background-color'))));
 Kirki::add_field('kirki_demo', array('type' => 'custom', 'settings' => 'custom_demo', 'label' => esc_attr__('Custom Control', 'kirki-demo'), 'description' => esc_attr__('This is the control description', 'kirki-demo'), 'help' => esc_attr__('This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki-demo'), 'section' => 'custom', 'default' => '<div style="padding: 30px;background-color: #333; color: #fff; border-radius: 50px;">You can enter custom markup in this control and use it however you want</div>', 'priority' => 10));
 Kirki::add_field('kirki_demo', array('type' => 'dimension', 'settings' => 'dimension_demo', 'label' => esc_attr__('Dimension Control', 'kirki'), 'description' => esc_attr__('In this example we are changing the width of the body', 'kirki-demo'), 'help' => esc_attr__('This is a tooltip', 'kirki-demo'), 'section' => 'composite', 'default' => '980px', 'priority' => 10, 'output' => array(array('element' => 'body', 'property' => 'width')), 'transport' => 'postMessage', 'js_vars' => array(array('element' => 'body', 'property' => 'width', 'function' => 'css'))));
 Kirki::add_field('kirki_demo', array('type' => 'multicheck', 'settings' => 'multicheck_demo', 'label' => esc_attr__('Multicheck control', 'kirki-demo'), 'description' => esc_attr__('You can define choices for this control and it will save the selected values as an array.', 'kirki-demo'), 'help' => esc_attr__('This is a tooltip', 'kirki-demo'), 'section' => 'checkbox', 'default' => array('option-1', 'option-3'), 'priority' => 10, 'choices' => array('option-1' => esc_attr__('Option 1', 'kirki-demo'), 'option-2' => esc_attr__('Option 2', 'kirki-demo'), 'option-3' => esc_attr__('Option 3', 'kirki-demo'), 'option-4' => esc_attr__('Option 4', 'kirki-demo'), 'option-5' => esc_attr__('Option 5', 'kirki-demo'))));
Exemple #24
0
 /**
  * Set up the Kirki Customizer
  */
 public function setupKirkiCustomizer()
 {
     \Kirki::add_config($this->textdomain, array('capability' => 'edit_theme_options', 'option_type' => 'option'));
     add_filter('kirki/config', function ($config) {
         $config['styles_priority'] = 100000;
         return $config;
     });
     add_filter('kirki/control_types', function ($controls) {
         $controls['media'] = '\\WP_Customize_Media_Control';
         $controls['cropped_image'] = '\\WP_Customize_Cropped_Image_Control';
         return $controls;
     });
     $panels = $this->setting('customizer/panels', []);
     if (count($panels) > 0) {
         foreach ($panels as $key => $data) {
             \Kirki::add_panel($key, $data);
         }
     }
     $sections = $this->setting('customizer/sections', []);
     if (count($sections) > 0) {
         foreach ($sections as $key => $data) {
             \Kirki::add_section($key, $data);
         }
     }
     $settings = $this->setting('customizer/settings', []);
     if (count($settings) > 0) {
         foreach ($settings as $setting => $data) {
             $control = null;
             if (isset($data['control'])) {
                 $control = $data['control'];
                 unset($data['control']);
             }
             if ($control) {
                 $data = array_merge($data, $control);
             }
             $data['settings'] = $setting;
             \Kirki::add_field($this->textdomain, $data);
         }
     }
 }