mirror of
https://ghproxy.net/https://github.com/AlxMedia/curver.git
synced 2025-08-28 11:50:25 +08:00
Update to Kirki 4.2.0
This commit is contained in:
parent
cbfd4f27e4
commit
77ecd4ca69
440 changed files with 6230 additions and 5211 deletions
21
functions/kirki/kirki-packages/control-multicheck/LICENSE
Normal file
21
functions/kirki/kirki-packages/control-multicheck/LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2019 kirki-framework
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
2
functions/kirki/kirki-packages/control-multicheck/dist/control.css
vendored
Normal file
2
functions/kirki/kirki-packages/control-multicheck/dist/control.css
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
|
||||
/*# sourceMappingURL=control.css.map */
|
1
functions/kirki/kirki-packages/control-multicheck/dist/control.css.map
vendored
Normal file
1
functions/kirki/kirki-packages/control-multicheck/dist/control.css.map
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"mappings":"","sources":[],"sourcesContent":[],"names":[],"version":3,"file":"control.css.map"}
|
2
functions/kirki/kirki-packages/control-multicheck/dist/control.js
vendored
Normal file
2
functions/kirki/kirki-packages/control-multicheck/dist/control.js
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
wp.customize.controlConstructor["kirki-multicheck"]=wp.customize.kirkiDynamicControl.extend({initKirkiControl:function(n){(n=n||this).container.on("change","input",(function(){var i=[],e=0;jQuery.each(n.params.choices,(function(t){n.container.find('input[value="'+t+'"]').is(":checked")?(n.container.find('input[value="'+t+'"]').parent().addClass("checked"),i[e]=t,e++):n.container.find('input[value="'+t+'"]').parent().removeClass("checked")})),n.setting.set(i)}))}});
|
||||
//# sourceMappingURL=control.js.map
|
1
functions/kirki/kirki-packages/control-multicheck/dist/control.js.map
vendored
Normal file
1
functions/kirki/kirki-packages/control-multicheck/dist/control.js.map
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"mappings":"AAEAA,GAAGC,UAAUC,mBAAkB,oBAAuBF,GAAGC,UAAUE,oBAAoBC,OAAM,CAE5FC,iBAAgB,SAAYC,IAC3BA,EAAUA,GAAOC,MAGTC,UAAUC,GAAE,SAAU,SAAS,WACtC,IAAIC,EAAK,GACRC,EAAI,EAGLC,OAAOC,KAAMP,EAAQQ,OAAOC,SAAO,SAAYC,GACzCV,EAAQE,UAAUS,KAAI,gBAAoBD,EAAG,MAAUE,GAAE,aAC7DZ,EAAQE,UAAUS,KAAI,gBAAoBD,EAAG,MAAUG,SAASC,SAAQ,WACxEV,EAAOC,GAAMK,EACbL,KAEAL,EAAQE,UAAUS,KAAI,gBAAoBD,EAAG,MAAUG,SAASE,YAAW,cAK7Ef,EAAQgB,QAAQC,IAAKb","sources":["src/control.js"],"sourcesContent":["import \"./control.scss\";\n\nwp.customize.controlConstructor['kirki-multicheck'] = wp.customize.kirkiDynamicControl.extend( {\n\n\tinitKirkiControl: function( control ) {\n\t\tcontrol = control || this;\n\n\t\t// Save the value\n\t\tcontrol.container.on( 'change', 'input', function() {\n\t\t\tvar value = [],\n\t\t\t\ti = 0;\n\n\t\t\t// Build the value as an object using the sub-values from individual checkboxes.\n\t\t\tjQuery.each( control.params.choices, function( key ) {\n\t\t\t\tif ( control.container.find( 'input[value=\"' + key + '\"]' ).is( ':checked' ) ) {\n\t\t\t\t\tcontrol.container.find( 'input[value=\"' + key + '\"]' ).parent().addClass( 'checked' );\n\t\t\t\t\tvalue[ i ] = key;\n\t\t\t\t\ti++;\n\t\t\t\t} else {\n\t\t\t\t\tcontrol.container.find( 'input[value=\"' + key + '\"]' ).parent().removeClass( 'checked' );\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\t// Update the value in the customizer.\n\t\t\tcontrol.setting.set( value );\n\t\t} );\n\t}\n} );\n"],"names":["wp","customize","controlConstructor","kirkiDynamicControl","extend","initKirkiControl","control","this","container","on","value","i","jQuery","each","params","choices","key","find","is","parent","addClass","removeClass","setting","set"],"version":3,"file":"control.js.map"}
|
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
/**
|
||||
* Customizer Control: multicheck.
|
||||
*
|
||||
* Multiple checkbox customize control class.
|
||||
* Props @ Justin Tadlock: http://justintadlock.com/archives/2015/05/26/multiple-checkbox-customizer-control
|
||||
*
|
||||
* @package kirki-framework/control-multicheck
|
||||
* @copyright Copyright (c) 2023, Themeum
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Control;
|
||||
|
||||
use Kirki\Control\Base;
|
||||
use Kirki\URL;
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a multicheck control.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class Multicheck extends Base {
|
||||
|
||||
/**
|
||||
* The control type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-multicheck';
|
||||
|
||||
/**
|
||||
* The version. Used in scripts & styles for cache-busting.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public static $control_ver = '1.0';
|
||||
|
||||
/**
|
||||
* 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-multicheck', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [ 'jquery', 'customize-base', 'kirki-control-base' ], self::$control_ver, false );
|
||||
|
||||
// Enqueue the style.
|
||||
wp_enqueue_style( 'kirki-control-multicheck-style', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], self::$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.choices ) { return; } #>
|
||||
|
||||
<# if ( data.label ) { #><span class="customize-control-title">{{{ data.label }}}</span><# } #>
|
||||
<# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><# } #>
|
||||
|
||||
<ul>
|
||||
<# for ( key in data.choices ) { #>
|
||||
<li><label<# if ( _.contains( data.value, key ) ) { #> class="checked"<# } #>><input {{{ data.inputAttrs }}} type="checkbox" value="{{ key }}"<# if ( _.contains( data.value, key ) ) { #> checked<# } #> />{{ data.choices[ key ] }}</label></li>
|
||||
<# } #>
|
||||
</ul>
|
||||
<?php
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
/**
|
||||
* Override field methods
|
||||
*
|
||||
* @package kirki-framework/control-multicheck
|
||||
* @copyright Copyright (c) 2023, Themeum
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Field;
|
||||
|
||||
use Kirki\Field;
|
||||
|
||||
/**
|
||||
* Field overrides.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class Multicheck extends Field {
|
||||
|
||||
/**
|
||||
* The field type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-multicheck';
|
||||
|
||||
/**
|
||||
* The control class-name.
|
||||
*
|
||||
* @access protected
|
||||
* @since 0.1
|
||||
* @var string
|
||||
*/
|
||||
protected $control_class = '\Kirki\Control\Multicheck';
|
||||
|
||||
/**
|
||||
* Whether we should register the control class for JS-templating or not.
|
||||
*
|
||||
* @access protected
|
||||
* @since 0.1
|
||||
* @var bool
|
||||
*/
|
||||
protected $control_has_js_template = true;
|
||||
|
||||
/**
|
||||
* Filter arguments before creating the setting.
|
||||
*
|
||||
* @access public
|
||||
* @since 0.1
|
||||
* @param array $args The field arguments.
|
||||
* @param WP_Customize_Manager $wp_customize The customizer instance.
|
||||
* @return array
|
||||
*/
|
||||
public function filter_setting_args( $args, $wp_customize ) {
|
||||
if ( $args['settings'] === $this->args['settings'] ) {
|
||||
$args = parent::filter_setting_args( $args, $wp_customize );
|
||||
|
||||
// Set the sanitize-callback if none is defined.
|
||||
if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) {
|
||||
$args['sanitize_callback'] = [ __CLASS__, 'sanitize' ];
|
||||
}
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter arguments before creating the control.
|
||||
*
|
||||
* @access public
|
||||
* @since 0.1
|
||||
* @param array $args The field arguments.
|
||||
* @param WP_Customize_Manager $wp_customize The customizer instance.
|
||||
* @return array
|
||||
*/
|
||||
public function filter_control_args( $args, $wp_customize ) {
|
||||
if ( $args['settings'] === $this->args['settings'] ) {
|
||||
$args = parent::filter_control_args( $args, $wp_customize );
|
||||
$args['type'] = 'kirki-multicheck';
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* The sanitize method that will be used as a falback
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @param string|array $value The control's value.
|
||||
* @return array
|
||||
*/
|
||||
public static function sanitize( $value ) {
|
||||
$value = ( ! is_array( $value ) ) ? explode( ',', $value ) : $value;
|
||||
return ( ! empty( $value ) ) ? array_map( 'sanitize_text_field', $value ) : [];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
import "./control.scss";
|
||||
|
||||
wp.customize.controlConstructor['kirki-multicheck'] = wp.customize.kirkiDynamicControl.extend( {
|
||||
|
||||
initKirkiControl: function( control ) {
|
||||
control = control || this;
|
||||
|
||||
// Save the value
|
||||
control.container.on( 'change', 'input', function() {
|
||||
var value = [],
|
||||
i = 0;
|
||||
|
||||
// Build the value as an object using the sub-values from individual checkboxes.
|
||||
jQuery.each( control.params.choices, function( key ) {
|
||||
if ( control.container.find( 'input[value="' + key + '"]' ).is( ':checked' ) ) {
|
||||
control.container.find( 'input[value="' + key + '"]' ).parent().addClass( 'checked' );
|
||||
value[ i ] = key;
|
||||
i++;
|
||||
} else {
|
||||
control.container.find( 'input[value="' + key + '"]' ).parent().removeClass( 'checked' );
|
||||
}
|
||||
} );
|
||||
|
||||
// Update the value in the customizer.
|
||||
control.setting.set( value );
|
||||
} );
|
||||
}
|
||||
} );
|
Loading…
Add table
Add a link
Reference in a new issue