/** * An Underscore (JS) template for rendering this section. * * Class variables for this section class are available in the `data` JS object; * export custom variables by overriding WP_Customize_Section::json(). * * @access protected */ protected function render_template() { $l10n = Kirki_l10n::get_strings(); ?> <li id="accordion-section-{{ data.id }}" class="accordion-section control-section control-section-{{ data.type }}"> <h3 class="accordion-section-title" tabindex="0"> {{ data.title }} <span class="screen-reader-text">{{ window.kirki.l10n.global['open-section'] }}</span> </h3> <ul class="accordion-section-content"> <li class="customize-section-description-container"> <div class="customize-section-title"> <button class="customize-section-back" tabindex="-1"> <span class="screen-reader-text">{{ window.kirki.l10n.global.back }}</span> </button> <h3> <span class="customize-action"> {{{ data.customizeAction }}} </span> {{ data.title }} <a href="#" class="kirki-reset-section" data-reset-section-id="{{ data.id }}"> {{{ window.kirki.l10n.global['reset-with-icon'] }}} </a> </h3> </div> <# if ( data.description ) { #> <div class="description customize-section-description"> {{{ data.description }}} </div> <# } #> </li> </ul> </li> <?php }
/** * Sets the $choices * * @access protected */ protected function set_choices() { // Get l10n strings. $l10n = Kirki_l10n::get_strings($this->kirki_config); // Make sure we have some defaults in case none are defined. $defaults = array('language' => 'css', 'theme' => 'kirki-dark', 'label' => $l10n['open-editor']); $this->choices = wp_parse_args($this->choices, $defaults); // Make sure the choices are defined and set as an array. if (!is_array($this->choices)) { $this->choices = array(); } // An array of valid languages. $valid_languages = array('coffescript', 'css', 'haml', 'htmlembedded', 'htmlmixed', 'javascript', 'markdown', 'php', 'sass', 'smarty', 'sql', 'stylus', 'textile', 'twig', 'xml', 'yaml'); // Make sure the defined language exists. // If not, fallback to CSS. if (!in_array($this->choices['language'], $valid_languages, true)) { $this->choices['language'] = 'css'; } // Hack for 'html' mode. if ('html' === $this->choices['language']) { $this->choices['language'] = 'htmlmixed'; } // Set the theme. if (in_array($this->choices['theme'], array('kirki-dark', 'kirki-light'), true)) { return; } if (in_array($this->choices['theme'], array('light', 'dark'), true)) { $this->choices['theme'] = 'kirki-' . $this->choices['theme']; return; } $this->choices['theme'] = $defaults['theme']; }
/** * Refresh the parameters passed to the JavaScript via JSON. * * @access public */ public function to_json() { parent::to_json(); $l10n = Kirki_l10n::get_strings($this->kirki_config); $dropdown = wp_dropdown_pages(array('name' => '_customize-dropdown-pages-' . esc_attr($this->id), 'echo' => 0, 'show_option_none' => esc_attr($l10n['select-page']), 'option_none_value' => '0', 'selected' => esc_attr($this->value()))); // Hackily add in the data link parameter. $dropdown = str_replace('<select', '<select ' . $this->get_link(), $dropdown); $this->json['dropdown'] = $dropdown; }
/** * L10n helper for controls. */ public function customize_controls_l10n() { // Register the l10n script. wp_register_script('kirki-l10n', trailingslashit(Kirki::$url) . 'assets/js/l10n.js'); // Add localization strings. // We'll do this on a per-config basis so that the filters are properly applied. $configs = Kirki::$config; $l10n = array(); foreach ($configs as $id => $args) { $l10n[$id] = Kirki_l10n::get_strings($id); } wp_localize_script('kirki-l10n', 'kirkiL10n', $l10n); wp_enqueue_script('kirki-l10n'); }
/** * Sets the control choices. * * @access protected */ protected function set_choices() { if (!is_array($this->choices)) { $this->choices = array(); } $l10n = Kirki_l10n::get_strings($this->kirki_config); if (!isset($this->choices['on'])) { $this->choices['on'] = $l10n['on']; } if (!isset($this->choices['off'])) { $this->choices['off'] = $l10n['off']; } if (!isset($this->choices['round'])) { $this->choices['round'] = false; } }
/** * Constructor. * * Supplied `$args` override class property defaults. * * If `$args['settings']` is not defined, use the $id as the setting ID. * * @since 2.3.5 * @param WP_Customize_Manager $manager Customizer bootstrap instance. * @param string $id Control ID. * @param array $args { * Optional. Arguments to override class property defaults. * * @type int $instance_number Order in which this instance was created in relation * to other instances. * @type WP_Customize_Manager $manager Customizer bootstrap instance. * @type string $id Control ID. * @type array $settings All settings tied to the control. If undefined, `$id` will * be used. * @type string $setting The primary setting for the control (if there is one). * Default 'default'. * @type int $priority Order priority to load the control. Default 10. * @type string $section Section the control belongs to. Default empty. * @type string $label Label for the control. Default empty. * @type string $description Description for the control. Default empty. * @type array $choices List of choices for 'radio' or 'select' type controls, where * values are the keys, and labels are the values. * Default empty array. * @type array $input_attrs List of custom input attributes for control output, where * attribute names are the keys and values are the values. Not * used for 'checkbox', 'radio', 'select', 'textarea', or * 'dropdown-pages' control types. Default empty array. * @type array $json Deprecated. Use WP_Customize_Control::json() instead. * @type string $type Control type. Core controls include 'text', 'checkbox', * 'textarea', 'radio', 'select', and 'dropdown-pages'. Additional * input types such as 'email', 'url', 'number', 'hidden', and * 'date' are supported implicitly. Default 'text'. * } */ public function __construct($manager, $id, $args = array()) { // Call the constructor from the parent class. parent::__construct($manager, $id, $args); // Add translation strings. $this->l10n = Kirki_l10n::get_strings($this->kirki_config); }
/** * The background choices. * * @return array<string,array> */ public static function background_choices() { $i18n = Kirki_l10n::get_strings(); return array('repeat' => array('no-repeat' => $i18n['no-repeat'], 'repeat' => $i18n['repeat-all'], 'repeat-x' => $i18n['repeat-x'], 'repeat-y' => $i18n['repeat-y'], 'inherit' => $i18n['inherit']), 'size' => array('inherit' => $i18n['inherit'], 'cover' => $i18n['cover'], 'contain' => $i18n['contain']), 'attach' => array('inherit' => $i18n['inherit'], 'fixed' => $i18n['fixed'], 'scroll' => $i18n['scroll']), 'position' => array('left-top' => $i18n['left-top'], 'left-center' => $i18n['left-center'], 'left-bottom' => $i18n['left-bottom'], 'right-top' => $i18n['right-top'], 'right-center' => $i18n['right-center'], 'right-bottom' => $i18n['right-bottom'], 'center-top' => $i18n['center-top'], 'center-center' => $i18n['center-center'], 'center-bottom' => $i18n['center-bottom'])); }
/** * Returns an array of all available variants. * * @static * @access public * @return array */ public static function get_all_variants() { $i18n = Kirki_l10n::get_strings(); return array('100' => $i18n['ultra-light'], '100italic' => $i18n['ultra-light-italic'], '200' => $i18n['light'], '200italic' => $i18n['light-italic'], '300' => $i18n['book'], '300italic' => $i18n['book-italic'], 'regular' => $i18n['regular'], 'italic' => $i18n['italic'], '500' => $i18n['medium'], '500italic' => $i18n['medium-italic'], '600' => $i18n['semi-bold'], '600italic' => $i18n['semi-bold-italic'], '700' => $i18n['bold'], '700italic' => $i18n['bold-italic'], '800' => $i18n['extra-bold'], '800italic' => $i18n['extra-bold-italic'], '900' => $i18n['ultra-bold'], '900italic' => $i18n['ultra-bold-italic']); }