mirror of
https://ghproxy.net/https://github.com/AlxMedia/magaziner.git
synced 2025-08-28 09:43:30 +08:00
Update to Kirki 4.0.22
This commit is contained in:
parent
2b6ac38550
commit
78edeb1b25
492 changed files with 29668 additions and 39884 deletions
3
functions/kirki/packages/kirki-framework/control-react-select/dist/control.css
vendored
Normal file
3
functions/kirki/packages/kirki-framework/control-react-select/dist/control.css
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
.customize-control-kirki-react-select input[autocomplete=off]{box-shadow:none}.kirki-react-select__value-container>div:not(.kirki-react-select__single-value):not(.kirki-react-select__multi-value){padding-top:0;padding-bottom:0}.kirki-react-select__control{padding-top:2px;padding-bottom:2px;min-height:26px}.kirki-react-select__value-container .kirki-react-select__input{min-height:24px;height:24px}.kirki-react-select__value-container .kirki-react-select__input input{min-height:24px;height:24px}.kirki-react-select__single-value{display:flex;align-items:center;width:100%}.kirki-react-select__multi-value{align-items:center;position:relative;height:20px}.kirki-react-select__input{display:inline-flex !important;align-items:center;position:relative;left:2px}.kirki-react-select__input input{box-sizing:border-box !important;height:30px}.kirki-react-select__indicators{height:24px !important}.kirki-react-select__indicator{align-items:center;height:24px}.customize-control-kirki-react-select .kirki-react-select__menu{z-index:3}
|
||||
|
||||
/*# sourceMappingURL=control.css.map*/
|
3
functions/kirki/packages/kirki-framework/control-react-select/dist/control.js
vendored
Normal file
3
functions/kirki/packages/kirki-framework/control-react-select/dist/control.js
vendored
Normal file
File diff suppressed because one or more lines are too long
8
functions/kirki/packages/kirki-framework/control-react-select/dist/control.js.LICENSE.txt
vendored
Normal file
8
functions/kirki/packages/kirki-framework/control-react-select/dist/control.js.LICENSE.txt
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
/** @license React v16.13.1
|
||||
* react-is.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
|
@ -0,0 +1,174 @@
|
|||
<?php
|
||||
/**
|
||||
* Customizer Control: kirki-select.
|
||||
*
|
||||
* @package kirki-framework/control-select
|
||||
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Control;
|
||||
|
||||
use Kirki\Control\Base;
|
||||
use Kirki\URL;
|
||||
|
||||
/**
|
||||
* Select control.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class ReactSelect extends Base {
|
||||
|
||||
/**
|
||||
* The control type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-react-select';
|
||||
|
||||
/**
|
||||
* Placeholder text.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string|false
|
||||
*/
|
||||
public $placeholder = false;
|
||||
|
||||
/**
|
||||
* Whether the select should be clearable or not.
|
||||
*
|
||||
* @since 1.0
|
||||
* @var bool
|
||||
*/
|
||||
public $clearable = false;
|
||||
|
||||
/**
|
||||
* Whether this is a multi-select or not.
|
||||
*
|
||||
* *Backwards compatibility note:
|
||||
*
|
||||
* Previously (when Kirki used Select2), $multiple is used to:
|
||||
* - Determine whether the select is multiple or not.
|
||||
* - Determine the maximum number of selection.
|
||||
*
|
||||
* Start from Kirki 4 (when Kirki uses react-select),
|
||||
* $multiple is used to determine whether the select is multiple or not.
|
||||
* The maximum selection number is now set in $max_selection.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var bool
|
||||
*/
|
||||
public $multiple = false;
|
||||
|
||||
/**
|
||||
* The maximum selection length for multiple selection.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.1
|
||||
* @var bool
|
||||
*/
|
||||
public $max_selection_number = 999;
|
||||
|
||||
/**
|
||||
* The version. Used in scripts & styles for cache-busting.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public static $control_ver = '1.1.5';
|
||||
|
||||
/**
|
||||
* 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-select',
|
||||
URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ),
|
||||
[
|
||||
'customize-controls',
|
||||
'customize-base',
|
||||
'wp-element',
|
||||
'wp-compose',
|
||||
'wp-components',
|
||||
'jquery',
|
||||
'wp-i18n',
|
||||
'kirki-control-base',
|
||||
],
|
||||
time(),
|
||||
false
|
||||
);
|
||||
|
||||
// Enqueue the style.
|
||||
wp_enqueue_style( 'kirki-control-select-style', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], self::$control_ver );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URL for the control folder.
|
||||
*
|
||||
* This is a static method because there are more controls in the Kirki framework
|
||||
* that use colorpickers, and they all need to enqueue the same assets.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 1.0.6
|
||||
* @return string
|
||||
*/
|
||||
public static function get_control_path_url() {
|
||||
|
||||
return URL::get_from_path( dirname( __DIR__ ) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the parameters passed to the JavaScript via JSON.
|
||||
*
|
||||
* @see WP_Customize_Control::to_json()
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @return void
|
||||
*/
|
||||
public function to_json() {
|
||||
|
||||
parent::to_json();
|
||||
|
||||
if ( isset( $this->json['label'] ) ) {
|
||||
$this->json['label'] = html_entity_decode( $this->json['label'] );
|
||||
}
|
||||
|
||||
if ( isset( $this->json['description'] ) ) {
|
||||
$this->json['description'] = html_entity_decode( $this->json['description'] );
|
||||
}
|
||||
|
||||
// @link https://react-select.com/props
|
||||
$this->json['isClearable'] = $this->clearable;
|
||||
$this->json['isMulti'] = $this->multiple;
|
||||
$this->json['placeholder'] = ( $this->placeholder ) ? $this->placeholder : esc_html__( 'Select...', 'kirki' );
|
||||
|
||||
// Will be a custom implementation, couldn't find an official prop to set this in react-select.
|
||||
$this->json['maxSelectionNumber'] = $this->max_selection_number;
|
||||
|
||||
$this->json['messages'] = [
|
||||
// translators: %s is the limit of selection number.
|
||||
'maxLimitReached' => sprintf( esc_html__( 'You can only select %s items', 'kirki' ), $this->max_selection_number ),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,201 @@
|
|||
<?php
|
||||
/**
|
||||
* Override field methods
|
||||
*
|
||||
* @package kirki-framework/control-select
|
||||
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Field;
|
||||
|
||||
use Kirki\Field;
|
||||
|
||||
/**
|
||||
* Field overrides.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class ReactSelect extends Field {
|
||||
|
||||
/**
|
||||
* The field type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-select';
|
||||
|
||||
/**
|
||||
* Whether this is a multi-select or not.
|
||||
*
|
||||
* *Backwards compatibility note:
|
||||
*
|
||||
* Previously (when Kirki used Select2), $multiple is used to:
|
||||
* - Determine whether the select is multiple or not.
|
||||
* - Determine the maximum number of selection.
|
||||
*
|
||||
* Start from Kirki 4 (when Kirki uses react-select),
|
||||
* $multiple is used to determine whether the select is multiple or not.
|
||||
* The maximum selection number is now set in $max_selection.
|
||||
*
|
||||
* @since 1.0
|
||||
* @var bool
|
||||
*/
|
||||
protected $multiple = false;
|
||||
|
||||
/**
|
||||
* The maximum selection length for multiple selection.
|
||||
*
|
||||
* @since 1.1
|
||||
* @var bool
|
||||
*/
|
||||
protected $max_selection_number = 999;
|
||||
|
||||
/**
|
||||
* Placeholder text.
|
||||
*
|
||||
* @access protected
|
||||
* @since 1.0
|
||||
* @var string|false
|
||||
*/
|
||||
protected $placeholder = false;
|
||||
|
||||
/**
|
||||
* The control class-name.
|
||||
*
|
||||
* @access protected
|
||||
* @since 0.1
|
||||
* @var string
|
||||
*/
|
||||
protected $control_class = '\Kirki\Control\ReactSelect';
|
||||
|
||||
/**
|
||||
* 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 );
|
||||
|
||||
if ( isset( $args['multiple'] ) ) {
|
||||
$multiple_and_max = self::get_multiple_and_max( $args['multiple'] );
|
||||
$args['multiple'] = $multiple_and_max['multiple'];
|
||||
$args['max_selection_number'] = $multiple_and_max['max_selection_number'];
|
||||
} else {
|
||||
$args['multiple'] = false;
|
||||
}
|
||||
|
||||
// Set the sanitize-callback if none is defined.
|
||||
if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) {
|
||||
$args['sanitize_callback'] = ! $args['multiple'] ? 'sanitize_text_field' : function( $values ) use ( $args ) {
|
||||
$values = (array) $values;
|
||||
$sanitized_values = [];
|
||||
|
||||
// If total selected values > max_selection_number, then we need to remove the excess.
|
||||
if ( count( $values ) > $args['max_selection_number'] ) {
|
||||
for ( $i = 0; $i < $args['max_selection_number']; $i++ ) {
|
||||
$sanitized_values[ $i ] = isset( $values[ $i ] ) ? sanitize_text_field( $values[ $i ] ) : '';
|
||||
}
|
||||
} else {
|
||||
foreach ( $values as $index => $subvalue ) {
|
||||
$sanitized_values[ $index ] = sanitize_text_field( $subvalue );
|
||||
}
|
||||
}
|
||||
|
||||
return $sanitized_values;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
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 );
|
||||
|
||||
if ( isset( $args['multiple'] ) ) {
|
||||
$multiple_and_max = self::get_multiple_and_max( $args['multiple'] );
|
||||
$args['multiple'] = $multiple_and_max['multiple'];
|
||||
$args['max_selection_number'] = $multiple_and_max['max_selection_number'];
|
||||
}
|
||||
|
||||
$args['type'] = 'kirki-react-select';
|
||||
}
|
||||
|
||||
return $args;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of "multiple" and "max_selection_number"
|
||||
* from the provided $multiple parameter.
|
||||
*
|
||||
* @since 1.1
|
||||
*
|
||||
* @param bool|int $multiple The provided $multiple value.
|
||||
* @return array
|
||||
*/
|
||||
public static function get_multiple_and_max( $multiple ) {
|
||||
|
||||
$max_selection_number = 999;
|
||||
|
||||
if ( is_numeric( $multiple ) ) {
|
||||
$multiple = (int) $multiple;
|
||||
|
||||
/**
|
||||
* Treat -1 as unlimited just like in WordPress's get_posts (well, in this Kirki case, it's 999 :).
|
||||
* Also treat 0 as "unlimited" because 1 it self will disable the multiple selection.
|
||||
*/
|
||||
if ( 0 >= $multiple ) {
|
||||
$max_selection_number = 999;
|
||||
$multiple = true;
|
||||
} else {
|
||||
// If $multiple is > 1.
|
||||
if ( 1 < $multiple ) {
|
||||
$max_selection_number = $multiple;
|
||||
$multiple = true;
|
||||
} else {
|
||||
// Here $multiple === 1, that means, it's single mode select.
|
||||
$multiple = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'multiple' => $multiple,
|
||||
'max_selection_number' => $max_selection_number,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue