mirror of
https://ghproxy.net/https://github.com/AlxMedia/curver.git
synced 2025-08-28 09:25:45 +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-editor/LICENSE
Normal file
21
functions/kirki/kirki-packages/control-editor/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-editor/dist/control.css
vendored
Normal file
2
functions/kirki/kirki-packages/control-editor/dist/control.css
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
.customize-control-kirki-editor textarea{width:100%}
|
||||
/*# sourceMappingURL=control.css.map */
|
1
functions/kirki/kirki-packages/control-editor/dist/control.css.map
vendored
Normal file
1
functions/kirki/kirki-packages/control-editor/dist/control.css.map
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"mappings":"AACE,yCACE,UCAJ","sources":["src/control.scss","%3Cinput%20css%20nydtJI%3E"],"sourcesContent":[".customize-control-kirki-editor {\n textarea {\n width: 100%;\n }\n}\n",".customize-control-kirki-editor textarea {\n width: 100%;\n}\n/*# sourceMappingURL=control.css.map */\n"],"names":[],"version":3,"file":"control.css.map"}
|
2
functions/kirki/kirki-packages/control-editor/dist/control.js
vendored
Normal file
2
functions/kirki/kirki-packages/control-editor/dist/control.js
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
wp.customize.controlConstructor["kirki-editor"]=wp.customize.kirkiDynamicControl.extend({initKirkiControl:function(i){var t,e,n,o;t=(i=i||this).container.find("textarea"),n="kirki-editor-"+i.id.replace("[","").replace("]",""),o={tinymce:{wpautop:!0},quicktags:!0,mediaButtons:!0},wp.editor&&wp.editor.initialize&&wp.editor.initialize(n,jQuery.extend({},o,i.params.choices)),(e=tinyMCE.get(n))&&e.onChange.add((function(n){var o;n.save(),o=e.getContent(),t.val(o).trigger("change"),wp.customize.instance(i.id).set(o)}))}});
|
||||
//# sourceMappingURL=control.js.map
|
1
functions/kirki/kirki-packages/control-editor/dist/control.js.map
vendored
Normal file
1
functions/kirki/kirki-packages/control-editor/dist/control.js.map
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"mappings":"AAGAA,GAAGC,UAAUC,mBAAkB,gBAAqBF,GAAGC,UAAUE,oBAAoBC,OAAM,CAC1FC,iBAAgB,SAAYC,GAC3B,IAAIC,EAASC,EAAQC,EAAIC,EAEzBH,GADAD,EAAUA,GAAOK,MACCC,UAAUC,KAAI,YAChCJ,EAAE,gBAA0BH,EAAQG,GAAGK,QAAO,IAAK,IAAOA,QAAO,IAAK,IAEtEJ,EAAa,CACZK,QAAO,CACNC,SAAS,GAEVC,WAAW,EACXC,cAAc,GAIVlB,GAAGQ,QAAUR,GAAGQ,OAAOW,YAC3BnB,GAAGQ,OAAOW,WAAYV,EAAIW,OAAOhB,OAAM,GAAMM,EAAeJ,EAAQe,OAAOC,WAG5Ed,EAASe,QAAQC,IAAKf,KAGrBD,EAAOiB,SAASC,KAAG,SAAYC,GAC9B,IAAIC,EAEJD,EAAGE,OACHD,EAAUpB,EAAOsB,aACjBvB,EAAQwB,IAAKH,GAAUI,QAAO,UAC9BhC,GAAGC,UAAUgC,SAAU3B,EAAQG,IAAKyB,IAAKN","sources":["src/control.js"],"sourcesContent":["import \"./control.scss\";\n\n/* global tinyMCE */\nwp.customize.controlConstructor[ 'kirki-editor' ] = wp.customize.kirkiDynamicControl.extend( {\n\tinitKirkiControl: function( control ) {\n\t\tvar element, editor, id, defaultParams;\n\t\tcontrol = control || this;\n\t\telement = control.container.find( 'textarea' );\n\t\tid = 'kirki-editor-' + control.id.replace( '[', '' ).replace( ']', '' );\n\n\t\tdefaultParams = {\n\t\t\ttinymce: {\n\t\t\t\twpautop: true\n\t\t\t},\n\t\t\tquicktags: true,\n\t\t\tmediaButtons: true\n\t\t};\n\n\t\t// Overwrite the default paramaters if choices is defined.\n\t\tif ( wp.editor && wp.editor.initialize ) {\n\t\t\twp.editor.initialize( id, jQuery.extend( {}, defaultParams, control.params.choices ) );\n\t\t}\n\n\t\teditor = tinyMCE.get( id );\n\n\t\tif ( editor ) {\n\t\t\teditor.onChange.add( function( ed ) {\n\t\t\t\tvar content;\n\n\t\t\t\ted.save();\n\t\t\t\tcontent = editor.getContent();\n\t\t\t\telement.val( content ).trigger( 'change' );\n\t\t\t\twp.customize.instance( control.id ).set( content );\n\t\t\t} );\n\t\t}\n\t}\n} );\n"],"names":["wp","customize","controlConstructor","kirkiDynamicControl","extend","initKirkiControl","control","element","editor","id","defaultParams","this","container","find","replace","tinymce","wpautop","quicktags","mediaButtons","initialize","jQuery","params","choices","tinyMCE","get","onChange","add","ed","content","save","getContent","val","trigger","instance","set"],"version":3,"file":"control.js.map"}
|
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
/**
|
||||
* Customizer Control: editor.
|
||||
*
|
||||
* Creates a TinyMCE textarea.
|
||||
*
|
||||
* @package kirki-framework/control-editor
|
||||
* @copyright Copyright (c) 2023, Themeum
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Control;
|
||||
|
||||
use Kirki\Control\Base;
|
||||
use Kirki\URL;
|
||||
|
||||
/**
|
||||
* A TinyMCE control.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class Editor extends Base {
|
||||
|
||||
/**
|
||||
* The control type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-editor';
|
||||
|
||||
/**
|
||||
* The version. Used in scripts & styles for cache-busting.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public static $control_ver = '1.0';
|
||||
|
||||
/**
|
||||
* Args to pass to TinyMCE.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var bool
|
||||
*/
|
||||
public $choices = [];
|
||||
|
||||
/**
|
||||
* 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-editor', 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-editor-style', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], self::$control_ver );
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the parameters passed to the JavaScript via JSON.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @return void
|
||||
*/
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
$this->json['choices'] = $this->choices;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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()}.
|
||||
*
|
||||
* The actual editor is added from the \Kirki\Field\Editor class.
|
||||
* All this template contains is a button that triggers the global editor on/off
|
||||
* and a hidden textarea element that is used to mirror save the options.
|
||||
*
|
||||
* @see WP_Customize_Control::print_template()
|
||||
*
|
||||
* @access protected
|
||||
* @since 1.0
|
||||
* @return void
|
||||
*/
|
||||
protected function content_template() {
|
||||
?>
|
||||
<label>
|
||||
<# if ( data.label ) { #><span class="customize-control-title">{{{ data.label }}}</span><# } #>
|
||||
<# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><# } #>
|
||||
</label>
|
||||
<textarea id="kirki-editor-{{{ data.id.replace( '[', '' ).replace( ']', '' ) }}}" {{{ data.inputAttrs }}} {{{ data.link }}}>{{ data.value }}</textarea>
|
||||
<?php
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
/**
|
||||
* Override field methods
|
||||
*
|
||||
* @package kirki-framework/control-editor
|
||||
* @copyright Copyright (c) 2023, Themeum
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Field;
|
||||
|
||||
use Kirki\Field;
|
||||
|
||||
/**
|
||||
* Field overrides.
|
||||
*/
|
||||
class Editor extends Field {
|
||||
|
||||
/**
|
||||
* The field type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-editor';
|
||||
|
||||
/**
|
||||
* The control class-name.
|
||||
*
|
||||
* @access protected
|
||||
* @since 0.1
|
||||
* @var string
|
||||
*/
|
||||
protected $control_class = '\Kirki\Control\Editor';
|
||||
|
||||
/**
|
||||
* 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'] = 'wp_kses_post';
|
||||
}
|
||||
}
|
||||
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-editor';
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
}
|
37
functions/kirki/kirki-packages/control-editor/src/control.js
Normal file
37
functions/kirki/kirki-packages/control-editor/src/control.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
import "./control.scss";
|
||||
|
||||
/* global tinyMCE */
|
||||
wp.customize.controlConstructor[ 'kirki-editor' ] = wp.customize.kirkiDynamicControl.extend( {
|
||||
initKirkiControl: function( control ) {
|
||||
var element, editor, id, defaultParams;
|
||||
control = control || this;
|
||||
element = control.container.find( 'textarea' );
|
||||
id = 'kirki-editor-' + control.id.replace( '[', '' ).replace( ']', '' );
|
||||
|
||||
defaultParams = {
|
||||
tinymce: {
|
||||
wpautop: true
|
||||
},
|
||||
quicktags: true,
|
||||
mediaButtons: true
|
||||
};
|
||||
|
||||
// Overwrite the default paramaters if choices is defined.
|
||||
if ( wp.editor && wp.editor.initialize ) {
|
||||
wp.editor.initialize( id, jQuery.extend( {}, defaultParams, control.params.choices ) );
|
||||
}
|
||||
|
||||
editor = tinyMCE.get( id );
|
||||
|
||||
if ( editor ) {
|
||||
editor.onChange.add( function( ed ) {
|
||||
var content;
|
||||
|
||||
ed.save();
|
||||
content = editor.getContent();
|
||||
element.val( content ).trigger( 'change' );
|
||||
wp.customize.instance( control.id ).set( content );
|
||||
} );
|
||||
}
|
||||
}
|
||||
} );
|
|
@ -0,0 +1,5 @@
|
|||
.customize-control-kirki-editor {
|
||||
textarea {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue