관리-도구
편집 파일: Radio_Buttonset.php
<?php /** * Customizer Control: radio-buttonset. * * @package kirki-framework/control-radio * @copyright Copyright (c) 2023, Themeum * @license https://opensource.org/licenses/MIT * @since 1.0 */ namespace Kirki\Control; use Kirki\Control\Base; use Kirki\Control\Radio; use Kirki\URL; /** * Radio Buttonset control (modified radio) * * @since 1.0 */ class Radio_Buttonset extends Base { /** * The control type. * * @access public * @since 1.0 * @var string */ public $type = 'kirki-radio-buttonset'; /** * Enqueue control related scripts/styles. * * @access public * @since 1.0 * @return void */ public function enqueue() { parent::enqueue(); // Enqueue the script. wp_enqueue_script( 'kirki-control-radio', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [ 'jquery', 'customize-base', 'kirki-control-base' ], Radio::$control_ver, false ); // Enqueue the style. wp_enqueue_style( 'kirki-control-radio-style', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], Radio::$control_ver ); } /** * An Underscore (JS) template for this control's content (but not its container). * * Class variables for this control class are available in the `data` JS object; * export custom variables by overriding {@see WP_Customize_Control::to_json()}. * * @see WP_Customize_Control::print_template() * * @access protected * @since 1.0 * @return void */ protected function content_template() { ?> <# if ( data.label ) { #><span class="customize-control-title">{{{ data.label }}}</span><# } #> <# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><# } #> <div id="input_{{ data.id }}" class="buttonset"> <# for ( key in data.choices ) { #> <input {{{ data.inputAttrs }}} class="switch-input screen-reader-text" type="radio" value="{{ key }}" name="_customize-radio-{{{ data.id }}}" id="{{ data.id }}{{ key }}" {{{ data.link }}}<# if ( key === data.value ) { #> checked="checked" <# } #>> <label class="switch-label switch-label-<# if ( key === data.value ) { #>on <# } else { #>off<# } #>" for="{{ data.id }}{{ key }}">{{{ data.choices[ key ] }}}</label> </input> <# } #> </div> <?php } }