Updated Kirki from 3.0.34.1 to 3.0.35.3

This commit is contained in:
LebCit
2019-04-30 02:23:07 +03:00
parent e4771048aa
commit 14d3666080
113 changed files with 978 additions and 783 deletions
+2
View File
@@ -93,6 +93,8 @@ class Kirki_Autoload {
$path = dirname( __FILE__ ) . '/modules/';
$path .= strtolower( str_replace( '_', '-', str_replace( 'Kirki_Modules_', '', $class_name ) ) ) . '/';
$paths[] = $path . $filename;
} elseif ( 'Kirki_Fonts' === $class_name ) {
$paths[] = dirname( __FILE__ ) . '/modules/webfonts/class-kirki-fonts.php';
}
if ( isset( $name_parts[0] ) ) {
@@ -48,7 +48,6 @@ class Kirki_Controls {
* @since 3.0.17
*/
public function __construct() {
if ( ! $this->views_path ) {
$this->views_path = wp_normalize_path( dirname( KIRKI_PLUGIN_FILE ) . '/controls/views/' );
}
+18 -45
View File
@@ -861,8 +861,6 @@ kirki = jQuery.extend( kirki, {
// Make sure value is properly formatted.
value = ( 'array' === saveAs && _.isString( value ) ) ? { url: value } : value;
control.container.find( '.kirki-controls-loading-spinner' ).hide();
// Tweaks for save_as = id.
if ( ( 'id' === saveAs || 'ID' === saveAs ) && '' !== value ) {
wp.media.attachment( value ).fetch().then( function() {
@@ -1400,8 +1398,8 @@ kirki = jQuery.extend( kirki, {
numericValue,
unit;
// Early exit if value is undefined.
if ( 'undefined' === typeof value ) {
// Early exit if value is not a string or a number.
if ( 'string' !== typeof value || 'number' !== typeof value ) {
return true;
}
@@ -1812,8 +1810,6 @@ wp.customize.controlConstructor['kirki-date'] = wp.customize.kirkiDynamicControl
dateFormat: 'yy-mm-dd'
} );
control.container.find( '.kirki-controls-loading-spinner' ).hide();
// Save the changes
this.container.on( 'change keyup paste', 'input.datepicker', function() {
control.setting.set( jQuery( this ).val() );
@@ -2246,8 +2242,6 @@ wp.customize.controlConstructor.repeater = wp.customize.Control.extend( {
// The current value set in Control Class (set in Kirki_Customize_Repeater_Control::to_json() function)
var settingValue = this.params.value;
control.container.find( '.kirki-controls-loading-spinner' ).hide();
// The hidden field that keeps the data saved (though we never update it)
this.settingField = this.container.find( '[data-customize-setting-link]' ).first();
@@ -3086,7 +3080,6 @@ wp.customize.controlConstructor['kirki-slider'] = wp.customize.kirkiDynamicContr
} );
}
} );
/* global kirkiControlLoader */
wp.customize.controlConstructor['kirki-sortable'] = wp.customize.Control.extend( {
// When we're finished loading continue processing
@@ -3096,31 +3089,12 @@ wp.customize.controlConstructor['kirki-sortable'] = wp.customize.Control.extend(
var control = this;
// Init the control.
if ( ! _.isUndefined( window.kirkiControlLoader ) && _.isFunction( kirkiControlLoader ) ) {
kirkiControlLoader( control );
} else {
control.initKirkiControl();
}
},
initKirkiControl: function() {
'use strict';
var control = this;
control.container.find( '.kirki-controls-loading-spinner' ).hide();
// Set the sortable container.
control.sortableContainer = control.container.find( 'ul.sortable' ).first();
// Init sortable.
control.sortableContainer.sortable( {
jQuery( control.container.find( 'ul.sortable' ).first() ).sortable( {
// Update value when we stop sorting.
stop: function() {
control.updateValue();
update: function() {
control.setting.set( control.getNewVal() );
}
} ).disableSelection().find( 'li' ).each( function() {
@@ -3131,26 +3105,25 @@ wp.customize.controlConstructor['kirki-sortable'] = wp.customize.Control.extend(
} ).click( function() {
// Update value on click.
control.updateValue();
control.setting.set( control.getNewVal() );
} );
},
/**
* Updates the sorting list
* Getss thhe new vvalue.
*
* @since 3.0.35
* @returns {Array}
*/
updateValue: function() {
'use strict';
var control = this,
newValue = [];
this.sortableContainer.find( 'li' ).each( function() {
if ( ! jQuery( this ).is( '.invisible' ) ) {
newValue.push( jQuery( this ).data( 'value' ) );
getNewVal: function() {
var items = jQuery( this.container.find( 'li' ) ),
newVal = [];
_.each ( items, function( item ) {
if ( ! jQuery( item ).hasClass( 'invisible' ) ) {
newVal.push( jQuery( item ).data( 'value' ) );
}
} );
control.setting.set( newValue );
return newVal;
}
} );
wp.customize.controlConstructor['kirki-switch'] = wp.customize.kirkiDynamicControl.extend( {
@@ -3478,7 +3451,7 @@ wp.customize.controlConstructor['kirki-typography'] = wp.customize.kirkiDynamicC
} else {
fontWeight = ( ! _.isString( value.variant ) ) ? '400' : value.variant.match( /\d/g );
fontWeight = ( ! _.isObject( fontWeight ) ) ? '400' : fontWeight.join( '' );
fontStyle = ( -1 !== value.variant.indexOf( 'italic' ) ) ? 'italic' : 'normal';
fontStyle = ( value.variant && -1 !== value.variant.indexOf( 'italic' ) ) ? 'italic' : 'normal';
}
control.saveValue( 'font-weight', fontWeight );
File diff suppressed because one or more lines are too long
@@ -45,78 +45,78 @@ class Kirki_Control_Background extends Kirki_Control_Base {
<!-- background-color -->
<div class="background-color">
<h4><?php esc_attr_e( 'Background Color', 'kirki' ); ?></h4>
<h4><?php esc_html_e( 'Background Color', 'kirki' ); ?></h4>
<input type="text" data-default-color="{{ data.default['background-color'] }}" data-alpha="true" value="{{ data.value['background-color'] }}" class="kirki-color-control"/>
</div>
<!-- background-image -->
<div class="background-image">
<h4><?php esc_attr_e( 'Background Image', 'kirki' ); ?></h4>
<h4><?php esc_html_e( 'Background Image', 'kirki' ); ?></h4>
<div class="attachment-media-view background-image-upload">
<# if ( data.value['background-image'] ) { #>
<div class="thumbnail thumbnail-image"><img src="{{ data.value['background-image'] }}"/></div>
<# } else { #>
<div class="placeholder"><?php esc_attr_e( 'No File Selected', 'kirki' ); ?></div>
<div class="placeholder"><?php esc_html_e( 'No File Selected', 'kirki' ); ?></div>
<# } #>
<div class="actions">
<button class="button background-image-upload-remove-button<# if ( ! data.value['background-image'] ) { #> hidden <# } #>"><?php esc_attr_e( 'Remove', 'kirki' ); ?></button>
<button type="button" class="button background-image-upload-button"><?php esc_attr_e( 'Select File', 'kirki' ); ?></button>
<button class="button background-image-upload-remove-button<# if ( ! data.value['background-image'] ) { #> hidden <# } #>"><?php esc_html_e( 'Remove', 'kirki' ); ?></button>
<button type="button" class="button background-image-upload-button"><?php esc_html_e( 'Select File', 'kirki' ); ?></button>
</div>
</div>
</div>
<!-- background-repeat -->
<div class="background-repeat">
<h4><?php esc_attr_e( 'Background Repeat', 'kirki' ); ?></h4>
<h4><?php esc_html_e( 'Background Repeat', 'kirki' ); ?></h4>
<select {{{ data.inputAttrs }}}>
<option value="no-repeat"<# if ( 'no-repeat' === data.value['background-repeat'] ) { #> selected <# } #>><?php esc_attr_e( 'No Repeat', 'kirki' ); ?></option>
<option value="repeat"<# if ( 'repeat' === data.value['background-repeat'] ) { #> selected <# } #>><?php esc_attr_e( 'Repeat All', 'kirki' ); ?></option>
<option value="repeat-x"<# if ( 'repeat-x' === data.value['background-repeat'] ) { #> selected <# } #>><?php esc_attr_e( 'Repeat Horizontally', 'kirki' ); ?></option>
<option value="repeat-y"<# if ( 'repeat-y' === data.value['background-repeat'] ) { #> selected <# } #>><?php esc_attr_e( 'Repeat Vertically', 'kirki' ); ?></option>
<option value="no-repeat"<# if ( 'no-repeat' === data.value['background-repeat'] ) { #> selected <# } #>><?php esc_html_e( 'No Repeat', 'kirki' ); ?></option>
<option value="repeat"<# if ( 'repeat' === data.value['background-repeat'] ) { #> selected <# } #>><?php esc_html_e( 'Repeat All', 'kirki' ); ?></option>
<option value="repeat-x"<# if ( 'repeat-x' === data.value['background-repeat'] ) { #> selected <# } #>><?php esc_html_e( 'Repeat Horizontally', 'kirki' ); ?></option>
<option value="repeat-y"<# if ( 'repeat-y' === data.value['background-repeat'] ) { #> selected <# } #>><?php esc_html_e( 'Repeat Vertically', 'kirki' ); ?></option>
</select>
</div>
<!-- background-position -->
<div class="background-position">
<h4><?php esc_attr_e( 'Background Position', 'kirki' ); ?></h4>
<h4><?php esc_html_e( 'Background Position', 'kirki' ); ?></h4>
<select {{{ data.inputAttrs }}}>
<option value="left top"<# if ( 'left top' === data.value['background-position'] ) { #> selected <# } #>><?php esc_attr_e( 'Left Top', 'kirki' ); ?></option>
<option value="left center"<# if ( 'left center' === data.value['background-position'] ) { #> selected <# } #>><?php esc_attr_e( 'Left Center', 'kirki' ); ?></option>
<option value="left bottom"<# if ( 'left bottom' === data.value['background-position'] ) { #> selected <# } #>><?php esc_attr_e( 'Left Bottom', 'kirki' ); ?></option>
<option value="right top"<# if ( 'right top' === data.value['background-position'] ) { #> selected <# } #>><?php esc_attr_e( 'Right Top', 'kirki' ); ?></option>
<option value="right center"<# if ( 'right center' === data.value['background-position'] ) { #> selected <# } #>><?php esc_attr_e( 'Right Center', 'kirki' ); ?></option>
<option value="right bottom"<# if ( 'right bottom' === data.value['background-position'] ) { #> selected <# } #>><?php esc_attr_e( 'Right Bottom', 'kirki' ); ?></option>
<option value="center top"<# if ( 'center top' === data.value['background-position'] ) { #> selected <# } #>><?php esc_attr_e( 'Center Top', 'kirki' ); ?></option>
<option value="center center"<# if ( 'center center' === data.value['background-position'] ) { #> selected <# } #>><?php esc_attr_e( 'Center Center', 'kirki' ); ?></option>
<option value="center bottom"<# if ( 'center bottom' === data.value['background-position'] ) { #> selected <# } #>><?php esc_attr_e( 'Center Bottom', 'kirki' ); ?></option>
<option value="left top"<# if ( 'left top' === data.value['background-position'] ) { #> selected <# } #>><?php esc_html_e( 'Left Top', 'kirki' ); ?></option>
<option value="left center"<# if ( 'left center' === data.value['background-position'] ) { #> selected <# } #>><?php esc_html_e( 'Left Center', 'kirki' ); ?></option>
<option value="left bottom"<# if ( 'left bottom' === data.value['background-position'] ) { #> selected <# } #>><?php esc_html_e( 'Left Bottom', 'kirki' ); ?></option>
<option value="right top"<# if ( 'right top' === data.value['background-position'] ) { #> selected <# } #>><?php esc_html_e( 'Right Top', 'kirki' ); ?></option>
<option value="right center"<# if ( 'right center' === data.value['background-position'] ) { #> selected <# } #>><?php esc_html_e( 'Right Center', 'kirki' ); ?></option>
<option value="right bottom"<# if ( 'right bottom' === data.value['background-position'] ) { #> selected <# } #>><?php esc_html_e( 'Right Bottom', 'kirki' ); ?></option>
<option value="center top"<# if ( 'center top' === data.value['background-position'] ) { #> selected <# } #>><?php esc_html_e( 'Center Top', 'kirki' ); ?></option>
<option value="center center"<# if ( 'center center' === data.value['background-position'] ) { #> selected <# } #>><?php esc_html_e( 'Center Center', 'kirki' ); ?></option>
<option value="center bottom"<# if ( 'center bottom' === data.value['background-position'] ) { #> selected <# } #>><?php esc_html_e( 'Center Bottom', 'kirki' ); ?></option>
</select>
</div>
<!-- background-size -->
<div class="background-size">
<h4><?php esc_attr_e( 'Background Size', 'kirki' ); ?></h4>
<h4><?php esc_html_e( 'Background Size', 'kirki' ); ?></h4>
<div class="buttonset">
<input {{{ data.inputAttrs }}} class="switch-input screen-reader-text" type="radio" value="cover" name="_customize-bg-{{{ data.id }}}-size" id="{{ data.id }}cover" <# if ( 'cover' === data.value['background-size'] ) { #> checked="checked" <# } #>>
<label class="switch-label switch-label-<# if ( 'cover' === data.value['background-size'] ) { #>on <# } else { #>off<# } #>" for="{{ data.id }}cover"><?php esc_attr_e( 'Cover', 'kirki' ); ?></label>
<label class="switch-label switch-label-<# if ( 'cover' === data.value['background-size'] ) { #>on <# } else { #>off<# } #>" for="{{ data.id }}cover"><?php esc_html_e( 'Cover', 'kirki' ); ?></label>
</input>
<input {{{ data.inputAttrs }}} class="switch-input screen-reader-text" type="radio" value="contain" name="_customize-bg-{{{ data.id }}}-size" id="{{ data.id }}contain" <# if ( 'contain' === data.value['background-size'] ) { #> checked="checked" <# } #>>
<label class="switch-label switch-label-<# if ( 'contain' === data.value['background-size'] ) { #>on <# } else { #>off<# } #>" for="{{ data.id }}contain"><?php esc_attr_e( 'Contain', 'kirki' ); ?></label>
<label class="switch-label switch-label-<# if ( 'contain' === data.value['background-size'] ) { #>on <# } else { #>off<# } #>" for="{{ data.id }}contain"><?php esc_html_e( 'Contain', 'kirki' ); ?></label>
</input>
<input {{{ data.inputAttrs }}} class="switch-input screen-reader-text" type="radio" value="auto" name="_customize-bg-{{{ data.id }}}-size" id="{{ data.id }}auto" <# if ( 'auto' === data.value['background-size'] ) { #> checked="checked" <# } #>>
<label class="switch-label switch-label-<# if ( 'auto' === data.value['background-size'] ) { #>on <# } else { #>off<# } #>" for="{{ data.id }}auto"><?php esc_attr_e( 'Auto', 'kirki' ); ?></label>
<label class="switch-label switch-label-<# if ( 'auto' === data.value['background-size'] ) { #>on <# } else { #>off<# } #>" for="{{ data.id }}auto"><?php esc_html_e( 'Auto', 'kirki' ); ?></label>
</input>
</div>
</div>
<!-- background-attachment -->
<div class="background-attachment">
<h4><?php esc_attr_e( 'Background Attachment', 'kirki' ); ?></h4>
<h4><?php esc_html_e( 'Background Attachment', 'kirki' ); ?></h4>
<div class="buttonset">
<input {{{ data.inputAttrs }}} class="switch-input screen-reader-text" type="radio" value="scroll" name="_customize-bg-{{{ data.id }}}-attachment" id="{{ data.id }}scroll" <# if ( 'scroll' === data.value['background-attachment'] ) { #> checked="checked" <# } #>>
<label class="switch-label switch-label-<# if ( 'scroll' === data.value['background-attachment'] ) { #>on <# } else { #>off<# } #>" for="{{ data.id }}scroll"><?php esc_attr_e( 'Scroll', 'kirki' ); ?></label>
<label class="switch-label switch-label-<# if ( 'scroll' === data.value['background-attachment'] ) { #>on <# } else { #>off<# } #>" for="{{ data.id }}scroll"><?php esc_html_e( 'Scroll', 'kirki' ); ?></label>
</input>
<input {{{ data.inputAttrs }}} class="switch-input screen-reader-text" type="radio" value="fixed" name="_customize-bg-{{{ data.id }}}-attachment" id="{{ data.id }}fixed" <# if ( 'fixed' === data.value['background-attachment'] ) { #> checked="checked" <# } #>>
<label class="switch-label switch-label-<# if ( 'fixed' === data.value['background-attachment'] ) { #>on <# } else { #>off<# } #>" for="{{ data.id }}fixed"><?php esc_attr_e( 'Fixed', 'kirki' ); ?></label>
<label class="switch-label switch-label-<# if ( 'fixed' === data.value['background-attachment'] ) { #>on <# } else { #>off<# } #>" for="{{ data.id }}fixed"><?php esc_html_e( 'Fixed', 'kirki' ); ?></label>
</input>
</div>
</div>
@@ -129,18 +129,19 @@ class Kirki_Control_Base extends WP_Customize_Control {
'kirkiL10n',
array(
'isScriptDebug' => ( defined( 'SCRIPT_DEBUG' ) && true === SCRIPT_DEBUG ),
'noFileSelected' => esc_attr__( 'No File Selected', 'kirki' ),
'remove' => esc_attr__( 'Remove', 'kirki' ),
'default' => esc_attr__( 'Default', 'kirki' ),
'selectFile' => esc_attr__( 'Select File', 'kirki' ),
'standardFonts' => esc_attr__( 'Standard Fonts', 'kirki' ),
'googleFonts' => esc_attr__( 'Google Fonts', 'kirki' ),
'defaultCSSValues' => esc_attr__( 'CSS Defaults', 'kirki' ),
'defaultBrowserFamily' => esc_attr__( 'Default Browser Font-Family', 'kirki' ),
'noFileSelected' => esc_html__( 'No File Selected', 'kirki' ),
'remove' => esc_html__( 'Remove', 'kirki' ),
'default' => esc_html__( 'Default', 'kirki' ),
'selectFile' => esc_html__( 'Select File', 'kirki' ),
'standardFonts' => esc_html__( 'Standard Fonts', 'kirki' ),
'googleFonts' => esc_html__( 'Google Fonts', 'kirki' ),
'defaultCSSValues' => esc_html__( 'CSS Defaults', 'kirki' ),
'defaultBrowserFamily' => esc_html__( 'Default Browser Font-Family', 'kirki' ),
)
);
$suffix = str_replace( '.min', '', $suffix );
// Enqueue the style.
wp_enqueue_style(
'kirki-styles',
@@ -156,42 +157,58 @@ class Kirki_Control_Base extends WP_Customize_Control {
* @see WP_Customize_Control::to_json()
*/
public function to_json() {
// Get the basics from the parent class.
parent::to_json();
// Default value.
$this->json['default'] = $this->setting->default;
if ( isset( $this->default ) ) {
$this->json['default'] = $this->default;
}
// Required.
$this->json['required'] = $this->required;
// Output.
$this->json['output'] = $this->output;
// Value.
$this->json['value'] = $this->value();
// Choices.
$this->json['choices'] = $this->choices;
// The link.
$this->json['link'] = $this->get_link();
// The ID.
$this->json['id'] = $this->id;
// Translation strings.
$this->json['l10n'] = $this->l10n();
// The ajaxurl in case we need it.
$this->json['ajaxurl'] = admin_url( 'admin-ajax.php' );
// Input attributes.
$this->json['inputAttrs'] = '';
foreach ( $this->input_attrs as $attr => $value ) {
$this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" ';
}
// The kirki-config.
$this->json['kirkiConfig'] = $this->kirki_config;
// The option-type.
$this->json['kirkiOptionType'] = $this->option_type;
// The option-name.
$this->json['kirkiOptionName'] = $this->option_name;
// The preset.
$this->json['preset'] = $this->preset;
// The CSS-Variables.
$this->json['css-var'] = $this->css_vars;
}
@@ -36,7 +36,7 @@ if ( ! class_exists( 'WP_Customize_Code_Editor_Control' ) ) {
protected function content_template() {
?>
<div class="notice notice-error" data-type="error"><div class="notification-message">
<?php esc_attr_e( 'Please update your WordPress installation to a version newer than 4.9 to access the code control.', 'kirki' ); ?>
<?php esc_html_e( 'Please update your WordPress installation to a version newer than 4.9 to access the code control.', 'kirki' ); ?>
</div></div>
<?php
}
@@ -46,5 +46,29 @@ if ( ! class_exists( 'WP_Customize_Code_Editor_Control' ) ) {
/**
* Adds a "code" control, alias of the WP_Customize_Code_Editor_Control class.
*/
class Kirki_Control_Code extends WP_Customize_Code_Editor_Control {}
class Kirki_Control_Code extends WP_Customize_Code_Editor_Control {
/**
* Whitelisting the "required" argument.
*
* @since 3.0.17
* @access public
* @var array
*/
public $required = array();
/**
* Refresh the parameters passed to the JavaScript via JSON.
*
* @see WP_Customize_Control::to_json()
*/
public function to_json() {
// Get the basics from the parent class.
parent::to_json();
// Required.
$this->json['required'] = $this->required;
}
}
}
@@ -57,6 +57,5 @@ class Kirki_Control_Custom extends Kirki_Control_Base {
{{{ data.value }}}
</label>
<?php
}
}
@@ -34,7 +34,6 @@ class Kirki_Control_Dashicons extends Kirki_Control_Base {
*/
public function to_json() {
parent::to_json();
$this->json['icons'] = Kirki_Helper::get_dashicons();
}
@@ -34,10 +34,9 @@ class Kirki_Control_Dimension extends Kirki_Control_Base {
*/
public function enqueue() {
parent::enqueue();
wp_localize_script(
'kirki-script', 'dimensionkirkiL10n', array(
'invalid-value' => esc_attr__( 'Invalid Value', 'kirki' ),
'invalid-value' => esc_html__( 'Invalid Value', 'kirki' ),
)
);
}
@@ -58,7 +58,6 @@ class Kirki_Control_Dimensions extends Kirki_Control_Base {
* @access public
*/
public function enqueue() {
wp_enqueue_style( 'kirki-styles', trailingslashit( Kirki::$url ) . 'controls/css/styles.css', array(), KIRKI_VERSION );
wp_localize_script( 'kirki-script', 'dimensionskirkiL10n', $this->l10n() );
}
@@ -112,31 +111,31 @@ class Kirki_Control_Dimensions extends Kirki_Control_Base {
*/
protected function l10n() {
return array(
'left-top' => esc_attr__( 'Left Top', 'kirki' ),
'left-center' => esc_attr__( 'Left Center', 'kirki' ),
'left-bottom' => esc_attr__( 'Left Bottom', 'kirki' ),
'right-top' => esc_attr__( 'Right Top', 'kirki' ),
'right-center' => esc_attr__( 'Right Center', 'kirki' ),
'right-bottom' => esc_attr__( 'Right Bottom', 'kirki' ),
'center-top' => esc_attr__( 'Center Top', 'kirki' ),
'center-center' => esc_attr__( 'Center Center', 'kirki' ),
'center-bottom' => esc_attr__( 'Center Bottom', 'kirki' ),
'font-size' => esc_attr__( 'Font Size', 'kirki' ),
'font-weight' => esc_attr__( 'Font Weight', 'kirki' ),
'line-height' => esc_attr__( 'Line Height', 'kirki' ),
'font-style' => esc_attr__( 'Font Style', 'kirki' ),
'letter-spacing' => esc_attr__( 'Letter Spacing', 'kirki' ),
'word-spacing' => esc_attr__( 'Word Spacing', 'kirki' ),
'top' => esc_attr__( 'Top', 'kirki' ),
'bottom' => esc_attr__( 'Bottom', 'kirki' ),
'left' => esc_attr__( 'Left', 'kirki' ),
'right' => esc_attr__( 'Right', 'kirki' ),
'center' => esc_attr__( 'Center', 'kirki' ),
'size' => esc_attr__( 'Size', 'kirki' ),
'spacing' => esc_attr__( 'Spacing', 'kirki' ),
'width' => esc_attr__( 'Width', 'kirki' ),
'height' => esc_attr__( 'Height', 'kirki' ),
'invalid-value' => esc_attr__( 'Invalid Value', 'kirki' ),
'left-top' => esc_html__( 'Left Top', 'kirki' ),
'left-center' => esc_html__( 'Left Center', 'kirki' ),
'left-bottom' => esc_html__( 'Left Bottom', 'kirki' ),
'right-top' => esc_html__( 'Right Top', 'kirki' ),
'right-center' => esc_html__( 'Right Center', 'kirki' ),
'right-bottom' => esc_html__( 'Right Bottom', 'kirki' ),
'center-top' => esc_html__( 'Center Top', 'kirki' ),
'center-center' => esc_html__( 'Center Center', 'kirki' ),
'center-bottom' => esc_html__( 'Center Bottom', 'kirki' ),
'font-size' => esc_html__( 'Font Size', 'kirki' ),
'font-weight' => esc_html__( 'Font Weight', 'kirki' ),
'line-height' => esc_html__( 'Line Height', 'kirki' ),
'font-style' => esc_html__( 'Font Style', 'kirki' ),
'letter-spacing' => esc_html__( 'Letter Spacing', 'kirki' ),
'word-spacing' => esc_html__( 'Word Spacing', 'kirki' ),
'top' => esc_html__( 'Top', 'kirki' ),
'bottom' => esc_html__( 'Bottom', 'kirki' ),
'left' => esc_html__( 'Left', 'kirki' ),
'right' => esc_html__( 'Right', 'kirki' ),
'center' => esc_html__( 'Center', 'kirki' ),
'size' => esc_html__( 'Size', 'kirki' ),
'spacing' => esc_html__( 'Spacing', 'kirki' ),
'width' => esc_html__( 'Width', 'kirki' ),
'height' => esc_html__( 'Height', 'kirki' ),
'invalid-value' => esc_html__( 'Invalid Value', 'kirki' ),
);
}
}
@@ -42,7 +42,6 @@ class Kirki_Control_Multicolor extends Kirki_Control_Base {
*/
public function to_json() {
parent::to_json();
$this->json['alpha'] = (bool) $this->alpha;
}
@@ -34,7 +34,6 @@ class Kirki_Control_Radio_Image extends Kirki_Control_Base {
*/
public function to_json() {
parent::to_json();
foreach ( $this->input_attrs as $attr => $value ) {
if ( 'style' !== $attr ) {
$this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" ';
@@ -69,7 +69,6 @@ class Kirki_Control_Repeater extends Kirki_Control_Base {
* @param array $args {@see WP_Customize_Control::__construct}.
*/
public function __construct( $manager, $id, $args = array() ) {
parent::__construct( $manager, $id, $args );
// Set up defaults for row labels.
@@ -84,7 +83,7 @@ class Kirki_Control_Repeater extends Kirki_Control_Base {
if ( empty( $this->button_label ) ) {
/* translators: %s represents the label of the row. */
$this->button_label = sprintf( esc_attr__( 'Add new %s', 'kirki' ), $this->row_label['value'] );
$this->button_label = sprintf( esc_html__( 'Add new %s', 'kirki' ), $this->row_label['value'] );
}
if ( empty( $args['fields'] ) || ! is_array( $args['fields'] ) ) {
@@ -109,21 +108,24 @@ class Kirki_Control_Repeater extends Kirki_Control_Base {
case 'image':
case 'cropped_image':
case 'upload':
// We add it to the list of fields that need some extra filtering/processing.
$media_fields_to_filter[ $key ] = true;
break;
case 'dropdown-pages':
// If the field is a dropdown-pages field then add it to args.
$dropdown = wp_dropdown_pages(
array(
'name' => '',
'echo' => 0,
'show_option_none' => esc_attr__( 'Select a Page', 'kirki' ),
'show_option_none' => esc_html__( 'Select a Page', 'kirki' ),
'option_none_value' => '0',
'selected' => '',
)
);
// Hackily add in the data link parameter.
$dropdown = str_replace( '<select', '<select data-field="' . esc_attr( $args['fields'][ $key ]['id'] ) . '"' . $this->get_link(), $dropdown ); // phpcs:ignore Generic.Formatting.MultipleStatementAlignment.NotSameWarning
$args['fields'][ $key ]['dropdown'] = $dropdown;
@@ -224,7 +226,7 @@ class Kirki_Control_Repeater extends Kirki_Control_Base {
<?php if ( isset( $this->choices['limit'] ) ) : ?>
<?php /* translators: %s represents the number of rows we're limiting the repeater to allow. */ ?>
<p class="limit"><?php printf( esc_attr__( 'Limit: %s rows', 'kirki' ), esc_html( $this->choices['limit'] ) ); ?></p>
<p class="limit"><?php printf( esc_html__( 'Limit: %s rows', 'kirki' ), esc_html( $this->choices['limit'] ) ); ?></p>
<?php endif; ?>
<button class="button-secondary repeater-add"><?php echo esc_html( $this->button_label ); ?></button>
@@ -378,17 +380,17 @@ class Kirki_Control_Repeater extends Kirki_Control_Base {
<# var defaultImageURL = ( field.default.url ) ? field.default.url : field.default; #>
<img src="{{{ defaultImageURL }}}">
<# } else { #>
<?php esc_attr_e( 'No Image Selected', 'kirki' ); ?>
<?php esc_html_e( 'No Image Selected', 'kirki' ); ?>
<# } #>
</figure>
<div class="actions">
<button type="button" class="button remove-button<# if ( ! field.default ) { #> hidden<# } #>"><?php esc_attr_e( 'Remove', 'kirki' ); ?></button>
<button type="button" class="button remove-button<# if ( ! field.default ) { #> hidden<# } #>"><?php esc_html_e( 'Remove', 'kirki' ); ?></button>
<button type="button" class="button upload-button" data-label=" <?php esc_attr_e( 'Add Image', 'kirki' ); ?>" data-alt-label="<?php echo esc_attr_e( 'Change Image', 'kirki' ); ?>" >
<# if ( field.default ) { #>
<?php esc_attr_e( 'Change Image', 'kirki' ); ?>
<?php esc_html_e( 'Change Image', 'kirki' ); ?>
<# } else { #>
<?php esc_attr_e( 'Add Image', 'kirki' ); ?>
<?php esc_html_e( 'Add Image', 'kirki' ); ?>
<# } #>
</button>
<# if ( field.default.id ) { #>
@@ -410,7 +412,7 @@ class Kirki_Control_Repeater extends Kirki_Control_Base {
<# var defaultFilename = ( field.default.filename ) ? field.default.filename : field.default; #>
<span class="file"><span class="dashicons dashicons-media-default"></span> {{ defaultFilename }}</span>
<# } else { #>
<?php esc_attr_e( 'No File Selected', 'kirki' ); ?>
<?php esc_html_e( 'No File Selected', 'kirki' ); ?>
<# } #>
</figure>
@@ -418,9 +420,9 @@ class Kirki_Control_Repeater extends Kirki_Control_Base {
<button type="button" class="button remove-button<# if ( ! field.default ) { #> hidden<# } #>"></button>
<button type="button" class="button upload-button" data-label="<?php esc_attr_e( 'Add File', 'kirki' ); ?>" data-alt-label="<?php esc_attr_e( 'Change File', 'kirki' ); ?>">
<# if ( field.default ) { #>
<?php esc_attr_e( 'Change File', 'kirki' ); ?>
<?php esc_html_e( 'Change File', 'kirki' ); ?>
<# } else { #>
<?php esc_attr_e( 'Add File', 'kirki' ); ?>
<?php esc_html_e( 'Add File', 'kirki' ); ?>
<# } #>
</button>
<# if ( field.default.id ) { #>
@@ -440,7 +442,7 @@ class Kirki_Control_Repeater extends Kirki_Control_Base {
</div>
<# }); #>
<button type="button" class="button-link repeater-row-remove"><?php esc_attr_e( 'Remove', 'kirki' ); ?></button>
<button type="button" class="button-link repeater-row-remove"><?php esc_html_e( 'Remove', 'kirki' ); ?></button>
</div>
</li>
</script>
@@ -466,12 +468,12 @@ class Kirki_Control_Repeater extends Kirki_Control_Base {
// Validating row label type.
if ( isset( $args['row_label']['value'] ) && ! empty( $args['row_label']['value'] ) ) {
$this->row_label['value'] = esc_attr( $args['row_label']['value'] );
$this->row_label['value'] = esc_html( $args['row_label']['value'] );
}
// Validating row label field.
if ( isset( $args['row_label']['field'] ) && ! empty( $args['row_label']['field'] ) && isset( $args['fields'][ esc_attr( $args['row_label']['field'] ) ] ) ) {
$this->row_label['field'] = esc_attr( $args['row_label']['field'] );
if ( isset( $args['row_label']['field'] ) && ! empty( $args['row_label']['field'] ) && isset( $args['fields'][ sanitize_key( $args['row_label']['field'] ) ] ) ) {
$this->row_label['field'] = esc_html( $args['row_label']['field'] );
} else {
// If from field is not set correctly, making sure standard is set as the type.
$this->row_label['type'] = 'text';
@@ -52,7 +52,6 @@ class Kirki_Control_Select extends Kirki_Control_Base {
*/
public function to_json() {
parent::to_json();
$this->json['multiple'] = $this->multiple;
$this->json['placeholder'] = $this->placeholder;
}
@@ -36,7 +36,6 @@ class Kirki_Control_Slider extends Kirki_Control_Base {
*/
public function to_json() {
parent::to_json();
$this->json['choices'] = wp_parse_args(
$this->json['choices'], array(
'min' => '0',
@@ -64,7 +63,7 @@ class Kirki_Control_Slider extends Kirki_Control_Base {
<# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><# } #>
<div class="wrapper">
<input {{{ data.inputAttrs }}} type="range" min="{{ data.choices['min'] }}" max="{{ data.choices['max'] }}" step="{{ data.choices['step'] }}" value="{{ data.value }}" {{{ data.link }}} />
<span class="slider-reset dashicons dashicons-image-rotate"><span class="screen-reader-text"><?php esc_attr_e( 'Reset', 'kirki' ); ?></span></span>
<span class="slider-reset dashicons dashicons-image-rotate"><span class="screen-reader-text"><?php esc_html_e( 'Reset', 'kirki' ); ?></span></span>
<span class="value">
<input {{{ data.inputAttrs }}} type="text"/>
<span class="suffix">{{ data.choices['suffix'] }}</span>
@@ -66,7 +66,6 @@ class Kirki_Control_Sortable extends Kirki_Control_Base {
<# }); #>
</ul>
</label>
<?php
}
}
@@ -49,11 +49,11 @@ class Kirki_Control_Switch extends Kirki_Control_Base {
<input class="screen-reader-text" {{{ data.inputAttrs }}} name="switch_{{ data.id }}" id="switch_{{ data.id }}" type="checkbox" value="{{ data.value }}" {{{ data.link }}}<# if ( '1' == data.value ) { #> checked<# } #> />
<label class="switch-label" for="switch_{{ data.id }}">
<span class="switch-on">
<# data.choices.on = data.choices.on || '<?php esc_attr_e( 'On', 'kirki' ); ?>' #>
<# data.choices.on = data.choices.on || '<?php esc_html_e( 'On', 'kirki' ); ?>' #>
{{ data.choices.on }}
</span>
<span class="switch-off">
<# data.choices.off = data.choices.off || '<?php esc_attr_e( 'Off', 'kirki' ); ?>' #>
<# data.choices.off = data.choices.off || '<?php esc_html_e( 'Off', 'kirki' ); ?>' #>
{{ data.choices.off }}
</span>
</label>
@@ -40,10 +40,12 @@ class Kirki_Control_Typography extends Kirki_Control_Base {
if ( ! in_array( $key, array( 'variant', 'font-weight', 'font-style' ), true ) && ! isset( $this->json['default'][ $key ] ) ) {
unset( $this->json['value'][ $key ] );
}
// Fix for https://wordpress.org/support/topic/white-font-after-updateing-to-3-0-16.
if ( ! isset( $this->json['default'][ $key ] ) ) {
unset( $this->json['value'][ $key ] );
}
// Fix for https://github.com/aristath/kirki/issues/1405.
if ( isset( $this->json['default'][ $key ] ) && false === $this->json['default'][ $key ] ) {
unset( $this->json['value'][ $key ] );
@@ -77,18 +79,18 @@ class Kirki_Control_Typography extends Kirki_Control_Base {
<# data.value['font-family'] = data.value['font-family'] || data['default']['font-family']; #>
<# if ( data.choices['fonts'] ) { data.fonts = data.choices['fonts']; } #>
<div class="font-family">
<h5><?php esc_attr_e( 'Font Family', 'kirki' ); ?></h5>
<h5><?php esc_html_e( 'Font Family', 'kirki' ); ?></h5>
<select {{{ data.inputAttrs }}} id="kirki-typography-font-family-{{{ data.id }}}" placeholder="<?php esc_attr_e( 'Select Font Family', 'kirki' ); ?>"></select>
</div>
<# if ( ! _.isUndefined( data.choices['font-backup'] ) && true === data.choices['font-backup'] ) { #>
<div class="font-backup hide-on-standard-fonts kirki-font-backup-wrapper">
<h5><?php esc_attr_e( 'Backup Font', 'kirki' ); ?></h5>
<h5><?php esc_html_e( 'Backup Font', 'kirki' ); ?></h5>
<select {{{ data.inputAttrs }}} id="kirki-typography-font-backup-{{{ data.id }}}" placeholder="<?php esc_attr_e( 'Select Font Family', 'kirki' ); ?>"></select>
</div>
<# } #>
<# if ( true === data.show_variants || false !== data.default.variant ) { #>
<div class="variant kirki-variant-wrapper">
<h5><?php esc_attr_e( 'Variant', 'kirki' ); ?></h5>
<h5><?php esc_html_e( 'Variant', 'kirki' ); ?></h5>
<select {{{ data.inputAttrs }}} class="variant" id="kirki-typography-variant-{{{ data.id }}}"></select>
</div>
<# } #>
@@ -103,7 +105,7 @@ class Kirki_Control_Typography extends Kirki_Control_Base {
<# if ( ! _.isUndefined( data.default['font-size'] ) ) { #>
<# data.value['font-size'] = data.value['font-size'] || data['default']['font-size']; #>
<div class="font-size">
<h5><?php esc_attr_e( 'Font Size', 'kirki' ); ?></h5>
<h5><?php esc_html_e( 'Font Size', 'kirki' ); ?></h5>
<input {{{ data.inputAttrs }}} type="text" value="{{ data.value['font-size'] }}"/>
</div>
<# } #>
@@ -111,7 +113,7 @@ class Kirki_Control_Typography extends Kirki_Control_Base {
<# if ( ! _.isUndefined( data.default['line-height'] ) ) { #>
<# data.value['line-height'] = data.value['line-height'] || data['default']['line-height']; #>
<div class="line-height">
<h5><?php esc_attr_e( 'Line Height', 'kirki' ); ?></h5>
<h5><?php esc_html_e( 'Line Height', 'kirki' ); ?></h5>
<input {{{ data.inputAttrs }}} type="text" value="{{ data.value['line-height'] }}"/>
</div>
<# } #>
@@ -119,7 +121,7 @@ class Kirki_Control_Typography extends Kirki_Control_Base {
<# if ( ! _.isUndefined( data.default['letter-spacing'] ) ) { #>
<# data.value['letter-spacing'] = data.value['letter-spacing'] || data['default']['letter-spacing']; #>
<div class="letter-spacing">
<h5><?php esc_attr_e( 'Letter Spacing', 'kirki' ); ?></h5>
<h5><?php esc_html_e( 'Letter Spacing', 'kirki' ); ?></h5>
<input {{{ data.inputAttrs }}} type="text" value="{{ data.value['letter-spacing'] }}"/>
</div>
<# } #>
@@ -127,7 +129,7 @@ class Kirki_Control_Typography extends Kirki_Control_Base {
<# if ( ! _.isUndefined( data.default['word-spacing'] ) ) { #>
<# data.value['word-spacing'] = data.value['word-spacing'] || data['default']['word-spacing']; #>
<div class="word-spacing">
<h5><?php esc_attr_e( 'Word Spacing', 'kirki' ); ?></h5>
<h5><?php esc_html_e( 'Word Spacing', 'kirki' ); ?></h5>
<input {{{ data.inputAttrs }}} type="text" value="{{ data.value['word-spacing'] }}"/>
</div>
<# } #>
@@ -135,36 +137,36 @@ class Kirki_Control_Typography extends Kirki_Control_Base {
<# if ( ! _.isUndefined( data.default['text-align'] ) ) { #>
<# data.value['text-align'] = data.value['text-align'] || data['default']['text-align']; #>
<div class="text-align">
<h5><?php esc_attr_e( 'Text Align', 'kirki' ); ?></h5>
<h5><?php esc_html_e( 'Text Align', 'kirki' ); ?></h5>
<div class="text-align-choices">
<input {{{ data.inputAttrs }}} type="radio" value="inherit" name="_customize-typography-text-align-radio-{{ data.id }}" id="{{ data.id }}-text-align-inherit" <# if ( data.value['text-align'] === 'inherit' ) { #> checked="checked"<# } #>>
<label for="{{ data.id }}-text-align-inherit">
<span class="dashicons dashicons-editor-removeformatting"></span>
<span class="screen-reader-text"><?php esc_attr_e( 'Inherit', 'kirki' ); ?></span>
<span class="screen-reader-text"><?php esc_html_e( 'Inherit', 'kirki' ); ?></span>
</label>
</input>
<input {{{ data.inputAttrs }}} type="radio" value="left" name="_customize-typography-text-align-radio-{{ data.id }}" id="{{ data.id }}-text-align-left" <# if ( data.value['text-align'] === 'left' ) { #> checked="checked"<# } #>>
<label for="{{ data.id }}-text-align-left">
<span class="dashicons dashicons-editor-alignleft"></span>
<span class="screen-reader-text"><?php esc_attr_e( 'Left', 'kirki' ); ?></span>
<span class="screen-reader-text"><?php esc_html_e( 'Left', 'kirki' ); ?></span>
</label>
</input>
<input {{{ data.inputAttrs }}} type="radio" value="center" name="_customize-typography-text-align-radio-{{ data.id }}" id="{{ data.id }}-text-align-center" <# if ( data.value['text-align'] === 'center' ) { #> checked="checked"<# } #>>
<label for="{{ data.id }}-text-align-center">
<span class="dashicons dashicons-editor-aligncenter"></span>
<span class="screen-reader-text"><?php esc_attr_e( 'Center', 'kirki' ); ?></span>
<span class="screen-reader-text"><?php esc_html_e( 'Center', 'kirki' ); ?></span>
</label>
</input>
<input {{{ data.inputAttrs }}} type="radio" value="right" name="_customize-typography-text-align-radio-{{ data.id }}" id="{{ data.id }}-text-align-right" <# if ( data.value['text-align'] === 'right' ) { #> checked="checked"<# } #>>
<label for="{{ data.id }}-text-align-right">
<span class="dashicons dashicons-editor-alignright"></span>
<span class="screen-reader-text"><?php esc_attr_e( 'Right', 'kirki' ); ?></span>
<span class="screen-reader-text"><?php esc_html_e( 'Right', 'kirki' ); ?></span>
</label>
</input>
<input {{{ data.inputAttrs }}} type="radio" value="justify" name="_customize-typography-text-align-radio-{{ data.id }}" id="{{ data.id }}-text-align-justify" <# if ( data.value['text-align'] === 'justify' ) { #> checked="checked"<# } #>>
<label for="{{ data.id }}-text-align-justify">
<span class="dashicons dashicons-editor-justify"></span>
<span class="screen-reader-text"><?php esc_attr_e( 'Justify', 'kirki' ); ?></span>
<span class="screen-reader-text"><?php esc_html_e( 'Justify', 'kirki' ); ?></span>
</label>
</input>
</div>
@@ -174,15 +176,15 @@ class Kirki_Control_Typography extends Kirki_Control_Base {
<# if ( ! _.isUndefined( data.default['text-transform'] ) ) { #>
<# data.value['text-transform'] = data.value['text-transform'] || data['default']['text-transform']; #>
<div class="text-transform">
<h5><?php esc_attr_e( 'Text Transform', 'kirki' ); ?></h5>
<h5><?php esc_html_e( 'Text Transform', 'kirki' ); ?></h5>
<select {{{ data.inputAttrs }}} id="kirki-typography-text-transform-{{{ data.id }}}">
<option value=""<# if ( '' === data.value['text-transform'] ) { #>selected<# } #>></option>
<option value="none"<# if ( 'none' === data.value['text-transform'] ) { #>selected<# } #>><?php esc_attr_e( 'None', 'kirki' ); ?></option>
<option value="capitalize"<# if ( 'capitalize' === data.value['text-transform'] ) { #>selected<# } #>><?php esc_attr_e( 'Capitalize', 'kirki' ); ?></option>
<option value="uppercase"<# if ( 'uppercase' === data.value['text-transform'] ) { #>selected<# } #>><?php esc_attr_e( 'Uppercase', 'kirki' ); ?></option>
<option value="lowercase"<# if ( 'lowercase' === data.value['text-transform'] ) { #>selected<# } #>><?php esc_attr_e( 'Lowercase', 'kirki' ); ?></option>
<option value="initial"<# if ( 'initial' === data.value['text-transform'] ) { #>selected<# } #>><?php esc_attr_e( 'Initial', 'kirki' ); ?></option>
<option value="inherit"<# if ( 'inherit' === data.value['text-transform'] ) { #>selected<# } #>><?php esc_attr_e( 'Inherit', 'kirki' ); ?></option>
<option value="none"<# if ( 'none' === data.value['text-transform'] ) { #>selected<# } #>><?php esc_html_e( 'None', 'kirki' ); ?></option>
<option value="capitalize"<# if ( 'capitalize' === data.value['text-transform'] ) { #>selected<# } #>><?php esc_html_e( 'Capitalize', 'kirki' ); ?></option>
<option value="uppercase"<# if ( 'uppercase' === data.value['text-transform'] ) { #>selected<# } #>><?php esc_html_e( 'Uppercase', 'kirki' ); ?></option>
<option value="lowercase"<# if ( 'lowercase' === data.value['text-transform'] ) { #>selected<# } #>><?php esc_html_e( 'Lowercase', 'kirki' ); ?></option>
<option value="initial"<# if ( 'initial' === data.value['text-transform'] ) { #>selected<# } #>><?php esc_html_e( 'Initial', 'kirki' ); ?></option>
<option value="inherit"<# if ( 'inherit' === data.value['text-transform'] ) { #>selected<# } #>><?php esc_html_e( 'Inherit', 'kirki' ); ?></option>
</select>
</div>
<# } #>
@@ -190,15 +192,15 @@ class Kirki_Control_Typography extends Kirki_Control_Base {
<# if ( ! _.isUndefined( data.default['text-decoration'] ) ) { #>
<# data.value['text-decoration'] = data.value['text-decoration'] || data['default']['text-decoration']; #>
<div class="text-decoration">
<h5><?php esc_attr_e( 'Text Decoration', 'kirki' ); ?></h5>
<h5><?php esc_html_e( 'Text Decoration', 'kirki' ); ?></h5>
<select {{{ data.inputAttrs }}} id="kirki-typography-text-decoration-{{{ data.id }}}">
<option value=""<# if ( '' === data.value['text-decoration'] ) { #>selected<# } #>></option>
<option value="none"<# if ( 'none' === data.value['text-decoration'] ) { #>selected<# } #>><?php esc_attr_e( 'None', 'kirki' ); ?></option>
<option value="underline"<# if ( 'underline' === data.value['text-decoration'] ) { #>selected<# } #>><?php esc_attr_e( 'Underline', 'kirki' ); ?></option>
<option value="overline"<# if ( 'overline' === data.value['text-decoration'] ) { #>selected<# } #>><?php esc_attr_e( 'Overline', 'kirki' ); ?></option>
<option value="line-through"<# if ( 'line-through' === data.value['text-decoration'] ) { #>selected<# } #>><?php esc_attr_e( 'Line-Through', 'kirki' ); ?></option>
<option value="initial"<# if ( 'initial' === data.value['text-decoration'] ) { #>selected<# } #>><?php esc_attr_e( 'Initial', 'kirki' ); ?></option>
<option value="inherit"<# if ( 'inherit' === data.value['text-decoration'] ) { #>selected<# } #>><?php esc_attr_e( 'Inherit', 'kirki' ); ?></option>
<option value="none"<# if ( 'none' === data.value['text-decoration'] ) { #>selected<# } #>><?php esc_html_e( 'None', 'kirki' ); ?></option>
<option value="underline"<# if ( 'underline' === data.value['text-decoration'] ) { #>selected<# } #>><?php esc_html_e( 'Underline', 'kirki' ); ?></option>
<option value="overline"<# if ( 'overline' === data.value['text-decoration'] ) { #>selected<# } #>><?php esc_html_e( 'Overline', 'kirki' ); ?></option>
<option value="line-through"<# if ( 'line-through' === data.value['text-decoration'] ) { #>selected<# } #>><?php esc_html_e( 'Line-Through', 'kirki' ); ?></option>
<option value="initial"<# if ( 'initial' === data.value['text-decoration'] ) { #>selected<# } #>><?php esc_html_e( 'Initial', 'kirki' ); ?></option>
<option value="inherit"<# if ( 'inherit' === data.value['text-decoration'] ) { #>selected<# } #>><?php esc_html_e( 'Inherit', 'kirki' ); ?></option>
</select>
</div>
<# } #>
@@ -206,7 +208,7 @@ class Kirki_Control_Typography extends Kirki_Control_Base {
<# if ( ! _.isUndefined( data.default['margin-top'] ) ) { #>
<# data.value['margin-top'] = data.value['margin-top'] || data['default']['margin-top']; #>
<div class="margin-top">
<h5><?php esc_attr_e( 'Margin Top', 'kirki' ); ?></h5>
<h5><?php esc_html_e( 'Margin Top', 'kirki' ); ?></h5>
<input {{{ data.inputAttrs }}} type="text" value="{{ data.value['margin-top'] }}"/>
</div>
<# } #>
@@ -214,7 +216,7 @@ class Kirki_Control_Typography extends Kirki_Control_Base {
<# if ( ! _.isUndefined( data.default['margin-bottom'] ) ) { #>
<# data.value['margin-bottom'] = data.value['margin-bottom'] || data['default']['margin-bottom']; #>
<div class="margin-bottom">
<h5><?php esc_attr_e( 'Margin Bottom', 'kirki' ); ?></h5>
<h5><?php esc_html_e( 'Margin Bottom', 'kirki' ); ?></h5>
<input {{{ data.inputAttrs }}} type="text" value="{{ data.value['margin-bottom'] }}"/>
</div>
<# } #>
@@ -222,7 +224,7 @@ class Kirki_Control_Typography extends Kirki_Control_Base {
<# if ( ! _.isUndefined( data.default['color'] ) && false !== data.default['color'] ) { #>
<# data.value['color'] = data.value['color'] || data['default']['color']; #>
<div class="color">
<h5><?php esc_attr_e( 'Color', 'kirki' ); ?></h5>
<h5><?php esc_html_e( 'Color', 'kirki' ); ?></h5>
<input {{{ data.inputAttrs }}} type="text" data-palette="{{ data.palette }}" data-default-color="{{ data.default['color'] }}" value="{{ data.value['color'] }}" class="kirki-color-control"/>
</div>
<# } #>
@@ -241,7 +243,6 @@ class Kirki_Control_Typography extends Kirki_Control_Base {
* @return array
*/
protected function format_variants_array( $variants ) {
$all_variants = Kirki_Fonts::get_all_variants();
$final_variants = array();
foreach ( $variants as $variant ) {
@@ -43,12 +43,7 @@ class Kirki_Settings_Repeater_Setting extends WP_Customize_Setting {
* @return mixed The value.
*/
public function value() {
$value = parent::value();
if ( ! is_array( $value ) ) {
$value = array();
}
return $value;
return (array) parent::value();
}
/**
@@ -59,26 +54,26 @@ class Kirki_Settings_Repeater_Setting extends WP_Customize_Setting {
* @return array
*/
public function sanitize_repeater_setting( $value ) {
if ( ! is_array( $value ) ) {
$value = json_decode( urldecode( $value ) );
}
$sanitized = ( empty( $value ) || ! is_array( $value ) ) ? array() : $value;
if ( empty( $value ) || ! is_array( $value ) ) {
$value = array();
}
// Make sure that every row is an array, not an object.
foreach ( $sanitized as $key => $_value ) {
$sanitized[ $key ] = (array) $_value;
if ( empty( $_value ) ) {
unset( $sanitized[ $key ] );
foreach ( $value as $key => $val ) {
$value[ $key ] = (array) $val;
if ( empty( $val ) ) {
unset( $value[ $key ] );
}
}
// Reindex array.
if ( is_array( $sanitized ) ) {
$sanitized = array_values( $sanitized );
if ( is_array( $value ) ) {
$value = array_values( $value );
}
return $sanitized;
return $value;
}
}
+7 -7
View File
@@ -31,13 +31,13 @@ if ( _.isObject( data.value ) && ! _.isUndefined( data.value.url ) ) {
data.choices.labels = _.isObject( data.choices.labels ) ? data.choices.labels : {};
data.choices.labels = _.defaults( data.choices.labels, {
select: '<?php esc_attr_e( 'Select image', 'kirki' ); ?>',
change: '<?php esc_attr_e( 'Change image', 'kirki' ); ?>',
'default': '<?php esc_attr_e( 'Default', 'kirki' ); ?>',
remove: '<?php esc_attr_e( 'Remove', 'kirki' ); ?>',
placeholder: '<?php esc_attr_e( 'No image selected', 'kirki' ); ?>',
frame_title: '<?php esc_attr_e( 'Select image', 'kirki' ); ?>',
frame_button: '<?php esc_attr_e( 'Choose image', 'kirki' ); ?>',
select: '<?php esc_html_e( 'Select image', 'kirki' ); ?>',
change: '<?php esc_html_e( 'Change image', 'kirki' ); ?>',
'default': '<?php esc_html_e( 'Default', 'kirki' ); ?>',
remove: '<?php esc_html_e( 'Remove', 'kirki' ); ?>',
placeholder: '<?php esc_html_e( 'No image selected', 'kirki' ); ?>',
frame_title: '<?php esc_html_e( 'Select image', 'kirki' ); ?>',
frame_button: '<?php esc_html_e( 'Choose image', 'kirki' ); ?>',
} );
#>
+3 -5
View File
@@ -139,15 +139,14 @@ final class Kirki_Config {
* @return Kirki_Config
*/
public static function get_instance( $id = 'global', $args = array() ) {
$id = trim( esc_attr( $id ) );
$id = ( '' === $id ) ? 'global' : $id;
if ( empty( $id ) ) {
$id = 'global';
}
$id_md5 = md5( $id );
if ( ! isset( self::$instances[ $id_md5 ] ) ) {
self::$instances[ $id_md5 ] = new self( $id, $args );
}
return self::$instances[ $id_md5 ];
}
/**
@@ -173,7 +172,6 @@ final class Kirki_Config {
* @return array
*/
public function get_config() {
return $this->config_final;
}
}
+3 -2
View File
@@ -48,6 +48,7 @@ class Kirki_Control {
// Set the control types.
$this->set_control_types();
// Add the control.
$this->add_control( $args );
@@ -65,12 +66,12 @@ class Kirki_Control {
// Set a default class name.
$class_name = 'WP_Customize_Control';
// Get the classname from the array of control classnames.
if ( array_key_exists( $args['type'], self::$control_types ) ) {
$class_name = self::$control_types[ $args['type'] ];
}
return $class_name;
}
/**
@@ -83,6 +84,7 @@ class Kirki_Control {
// Get the name of the class we're going to use.
$class_name = $this->get_control_class_name( $args );
// Add the control.
$this->wp_customize->add_control( new $class_name( $this->wp_customize, $args['settings'], $args ) );
@@ -107,7 +109,6 @@ class Kirki_Control {
// Make sure the defined classes actually exist.
foreach ( self::$control_types as $key => $classname ) {
if ( ! class_exists( $classname ) ) {
unset( self::$control_types[ $key ] );
}
+15 -83
View File
@@ -245,7 +245,7 @@ class Kirki_Field {
if ( isset( $args['setting'] ) && ! empty( $args['setting'] ) && ( ! isset( $args['settings'] ) || empty( $args['settings'] ) ) ) {
/* translators: %s represents the field ID where the error occurs. */
_doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Typo found in field %s - setting instead of settings.', 'kirki' ), esc_attr( $args['settings'] ) ), '3.0.10' );
_doing_it_wrong( __METHOD__, sprintf( esc_html__( 'Typo found in field %s - setting instead of settings.', 'kirki' ), esc_html( $args['settings'] ) ), '3.0.10' );
$args['settings'] = $args['setting'];
unset( $args['setting'] );
}
@@ -254,17 +254,17 @@ class Kirki_Field {
// assume that the provided argument is $args and set $config_id = 'global'.
if ( is_array( $config_id ) && empty( $args ) ) {
/* translators: %1$s represents the field ID where the error occurs. %2$s is the URL in the documentation site. */
_doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Config not defined for field %1$s - See %2$s for details on how to properly add fields.', 'kirki' ), esc_attr( $args['settings'] ), 'https://aristath.github.io/kirki/docs/getting-started/fields.html' ), '3.0.10' );
_doing_it_wrong( __METHOD__, sprintf( esc_html__( 'Config not defined for field %1$s - See %2$s for details on how to properly add fields.', 'kirki' ), esc_html( $args['settings'] ), 'https://aristath.github.io/kirki/docs/getting-started/fields.html' ), '3.0.10' );
$args = $config_id;
$config_id = 'global';
}
$args['kirki_config'] = $config_id;
$this->kirki_config = trim( esc_attr( $config_id ) );
$this->kirki_config = $config_id;
if ( '' === $config_id ) {
/* translators: %1$s represents the field ID where the error occurs. %2$s is the URL in the documentation site. */
_doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Config not defined for field %1$s - See %2$s for details on how to properly add fields.', 'kirki' ), esc_attr( $args['settings'] ), 'https://aristath.github.io/kirki/docs/getting-started/fields.html' ), '3.0.10' );
_doing_it_wrong( __METHOD__, sprintf( esc_html__( 'Config not defined for field %1$s - See %2$s for details on how to properly add fields.', 'kirki' ), esc_html( $args['settings'] ), 'https://aristath.github.io/kirki/docs/getting-started/fields.html' ), '3.0.10' );
$this->kirki_config = 'global';
}
@@ -306,7 +306,6 @@ class Kirki_Field {
$properties = get_class_vars( __CLASS__ );
// Some things must run before the others.
$this->set_option_name();
$this->set_option_type();
$this->set_settings();
@@ -332,62 +331,13 @@ class Kirki_Field {
}
/**
* Escape $kirki_config.
*
* @access protected
*/
protected function set_kirki_config() {
$this->kirki_config = esc_attr( $this->kirki_config );
}
/**
* Escape $option_name.
*
* @access protected
*/
protected function set_option_name() {
$this->option_name = esc_attr( $this->option_name );
}
/**
* Escape the $section.
*
* @access protected
*/
protected function set_section() {
$this->section = sanitize_key( $this->section );
}
/**
* Escape the $section.
*
* @access protected
*/
protected function set_input_attrs() {
if ( ! is_array( $this->input_attrs ) ) {
$this->input_attrs = array();
}
}
/**
* Checks the capability chosen is valid.
* If not, then falls back to 'edit_theme_options'
*
* @access protected
*/
protected function set_capability() {
// Early exit if we're using 'edit_theme_options'.
if ( 'edit_theme_options' === $this->capability ) {
return;
}
// Escape & trim the capability.
$this->capability = trim( esc_attr( $this->capability ) );
$this->input_attrs = (array) $this->input_attrs;
}
/**
@@ -401,10 +351,11 @@ class Kirki_Field {
if ( 'options' === $this->option_type ) {
$this->option_type = 'option';
}
// Take care of common typos.
if ( 'theme_mods' === $this->option_type ) {
/* translators: %1$s represents the field ID where the error occurs. */
_doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Typo found in field %s - "theme_mods" vs "theme_mod"', 'kirki' ), esc_attr( $this->settings ) ), '3.0.10' );
_doing_it_wrong( __METHOD__, sprintf( esc_html( 'Typo found in field %s - "theme_mods" vs "theme_mod"', 'kirki' ), esc_html( $this->settings ) ), '3.0.10' );
$this->option_type = 'theme_mod';
}
}
@@ -415,14 +366,13 @@ class Kirki_Field {
* @access protected
*/
protected function set_partial_refresh() {
if ( ! is_array( $this->partial_refresh ) ) {
$this->partial_refresh = array();
}
foreach ( $this->partial_refresh as $id => $args ) {
if ( ! is_array( $args ) || ! isset( $args['selector'] ) || ! isset( $args['render_callback'] ) || ! is_callable( $args['render_callback'] ) ) {
/* translators: %1$s represents the field ID where the error occurs. */
_doing_it_wrong( __METHOD__, sprintf( esc_attr__( '"partial_refresh" invalid entry in field %s', 'kirki' ), esc_attr( $this->settings ) ), '3.0.10' );
_doing_it_wrong( __METHOD__, sprintf( esc_html__( '"partial_refresh" invalid entry in field %s', 'kirki' ), esc_html( $this->settings ) ), '3.0.10' );
unset( $this->partial_refresh[ $id ] );
continue;
}
@@ -452,6 +402,7 @@ class Kirki_Field {
$settings = array();
foreach ( $this->settings as $setting_key => $setting_value ) {
$settings[ $setting_key ] = $setting_value;
// If we're using serialized options then we need to spice this up.
if ( 'option' === $this->option_type && '' !== $this->option_name && ( false === strpos( $setting_key, '[' ) ) ) {
$settings[ $setting_key ] = "{$this->option_name}[{$setting_value}]";
@@ -471,7 +422,6 @@ class Kirki_Field {
* @access protected
*/
protected function set_active_callback() {
if ( is_array( $this->active_callback ) ) {
if ( ! is_callable( $this->active_callback ) ) {
@@ -495,23 +445,13 @@ class Kirki_Field {
if ( '__return_true' === $this->active_callback ) {
return;
}
// Make sure the function is callable, otherwise fallback to __return_true.
if ( ! is_callable( $this->active_callback ) ) {
$this->active_callback = '__return_true';
}
}
/**
* Sets the control type.
*
* @access protected
*/
protected function set_type() {
// Escape the control type (it doesn't hurt to be sure).
$this->type = esc_attr( $this->type );
}
/**
* Sets the $id.
* Setting the ID should happen after the 'settings' sanitization.
@@ -521,7 +461,6 @@ class Kirki_Field {
* @access protected
*/
protected function set_id() {
$this->id = sanitize_key( str_replace( '[', '-', str_replace( ']', '', $this->settings ) ) );
}
@@ -531,7 +470,6 @@ class Kirki_Field {
* @access protected
*/
protected function set_choices() {
if ( ! is_array( $this->choices ) ) {
$this->choices = array();
}
@@ -543,9 +481,7 @@ class Kirki_Field {
* @access protected
*/
protected function set_disable_output() {
$this->disable_output = (bool) $this->disable_output;
}
/**
@@ -554,25 +490,26 @@ class Kirki_Field {
* @access protected
*/
protected function set_output() {
if ( empty( $this->output ) ) {
return;
}
if ( ! is_array( $this->output ) ) {
/* translators: The field ID where the error occurs. */
_doing_it_wrong( __METHOD__, sprintf( esc_attr__( '"output" invalid format in field %s. The "output" argument should be defined as an array of arrays.', 'kirki' ), esc_attr( $this->settings ) ), '3.0.10' );
_doing_it_wrong( __METHOD__, sprintf( esc_html__( '"output" invalid format in field %s. The "output" argument should be defined as an array of arrays.', 'kirki' ), esc_html( $this->settings ) ), '3.0.10' );
$this->output = array(
array(
'element' => $this->output,
),
);
}
// Convert to array of arrays if needed.
if ( isset( $this->output['element'] ) ) {
/* translators: The field ID where the error occurs. */
_doing_it_wrong( __METHOD__, sprintf( esc_attr__( '"output" invalid format in field %s. The "output" argument should be defined as an array of arrays.', 'kirki' ), esc_attr( $this->settings ) ), '3.0.10' );
_doing_it_wrong( __METHOD__, sprintf( esc_html__( '"output" invalid format in field %s. The "output" argument should be defined as an array of arrays.', 'kirki' ), esc_html( $this->settings ) ), '3.0.10' );
$this->output = array( $this->output );
}
foreach ( $this->output as $key => $output ) {
if ( empty( $output ) || ! isset( $output['element'] ) ) {
unset( $this->output[ $key ] );
@@ -581,6 +518,7 @@ class Kirki_Field {
if ( ! isset( $output['sanitize_callback'] ) && isset( $output['callback'] ) ) {
$this->output[ $key ]['sanitize_callback'] = $output['callback'];
}
// Convert element arrays to strings.
if ( isset( $output['element'] ) && is_array( $output['element'] ) ) {
$this->output[ $key ]['element'] = array_unique( $this->output[ $key ]['element'] );
@@ -605,7 +543,6 @@ class Kirki_Field {
* @access protected
*/
protected function set_js_vars() {
if ( ! is_array( $this->js_vars ) ) {
$this->js_vars = array();
}
@@ -654,7 +591,6 @@ class Kirki_Field {
}
$this->js_vars = $js_vars;
$this->transport = 'postMessage';
}
}
@@ -664,7 +600,6 @@ class Kirki_Field {
* @access protected
*/
protected function set_variables() {
if ( ! is_array( $this->variables ) ) {
$variable = ( is_string( $this->variables ) && ! empty( $this->variables ) ) ? $this->variables : false;
$this->variables = array();
@@ -680,7 +615,6 @@ class Kirki_Field {
* @access protected
*/
protected function set_transport() {
if ( 'postmessage' === trim( strtolower( $this->transport ) ) ) {
$this->transport = 'postMessage';
}
@@ -692,7 +626,6 @@ class Kirki_Field {
* @access protected
*/
protected function set_required() {
if ( ! is_array( $this->required ) ) {
$this->required = array();
}
@@ -704,7 +637,6 @@ class Kirki_Field {
* @access protected
*/
protected function set_priority() {
$this->priority = absint( $this->priority );
}
+1 -14
View File
@@ -60,6 +60,7 @@ class Kirki_Helper {
*/
public static function recurse( $array, $array1 ) {
foreach ( $array1 as $key => $value ) {
// Create new key in $array, if it is empty or not an array.
if ( ! isset( $array[ $key ] ) || ( isset( $array[ $key ] ) && ! is_array( $array[ $key ] ) ) ) {
$array[ $key ] = array();
@@ -161,7 +162,6 @@ class Kirki_Helper {
* @return array
*/
public static function get_image_from_url( $url ) {
$image_id = self::get_image_id( $url );
$image = wp_get_attachment_image_src( $image_id, 'full' );
@@ -171,7 +171,6 @@ class Kirki_Helper {
'height' => $image[2],
'thumbnail' => $image[3],
);
}
/**
@@ -183,7 +182,6 @@ class Kirki_Helper {
* @return array
*/
public static function get_posts( $args ) {
if ( is_string( $args ) ) {
$args = add_query_arg(
array(
@@ -206,7 +204,6 @@ class Kirki_Helper {
wp_reset_postdata();
return $items;
}
/**
@@ -217,7 +214,6 @@ class Kirki_Helper {
* @return array
*/
public static function get_taxonomies() {
$items = array();
// Get the taxonomies.
@@ -235,7 +231,6 @@ class Kirki_Helper {
}
return $items;
}
/**
@@ -246,7 +241,6 @@ class Kirki_Helper {
* @return array
*/
public static function get_post_types() {
$items = array();
// Get the post types.
@@ -262,7 +256,6 @@ class Kirki_Helper {
}
return $items;
}
/**
@@ -274,7 +267,6 @@ class Kirki_Helper {
* @return array
*/
public static function get_terms( $taxonomies ) {
$items = array();
// Get the post types.
@@ -286,7 +278,6 @@ class Kirki_Helper {
}
return $items;
}
/**
@@ -298,7 +289,6 @@ class Kirki_Helper {
* @return array
*/
public static function get_material_design_colors( $context = 'primary' ) {
$colors = array(
'primary' => array( '#FFFFFF', '#000000', '#F44336', '#E91E63', '#9C27B0', '#673AB7', '#3F51B5', '#2196F3', '#03A9F4', '#00BCD4', '#009688', '#4CAF50', '#8BC34A', '#CDDC39', '#FFEB3B', '#FFC107', '#FF9800', '#FF5722', '#795548', '#9E9E9E', '#607D8B' ),
'red' => array( '#FFEBEE', '#FFCDD2', '#EF9A9A', '#E57373', '#EF5350', '#F44336', '#E53935', '#D32F2F', '#C62828', '#B71C1C', '#FF8A80', '#FF5252', '#FF1744', '#D50000' ),
@@ -323,7 +313,6 @@ class Kirki_Helper {
);
switch ( $context ) {
case '50':
case '100':
case '200':
@@ -387,7 +376,6 @@ class Kirki_Helper {
* @return array
*/
public static function get_dashicons() {
return array(
'admin-menu' => array( 'menu', 'admin-site', 'dashboard', 'admin-post', 'admin-media', 'admin-links', 'admin-page', 'admin-comments', 'admin-appearance', 'admin-plugins', 'admin-users', 'admin-tools', 'admin-settings', 'admin-network', 'admin-home', 'admin-generic', 'admin-collapse', 'filter', 'admin-customizer', 'admin-multisite' ),
'welcome-screen' => array( 'welcome-write-blog', 'welcome-add-page', 'welcome-view-site', 'welcome-widgets-menus', 'welcome-comments', 'welcome-learn-more' ),
@@ -405,7 +393,6 @@ class Kirki_Helper {
'notifications' => array( 'yes', 'no', 'no-alt', 'plus', 'plus-alt', 'minus', 'dismiss', 'marker', 'star-filled', 'star-half', 'star-empty', 'flag', 'warning' ),
'misc' => array( 'location', 'location-alt', 'vault', 'shield', 'shield-alt', 'sos', 'search', 'slides', 'analytics', 'chart-pie', 'chart-bar', 'chart-line', 'chart-area', 'groups', 'businessman', 'id', 'id-alt', 'products', 'awards', 'forms', 'testimonial', 'portfolio', 'book', 'book-alt', 'download', 'upload', 'backup', 'clock', 'lightbulb', 'microphone', 'desktop', 'tablet', 'smartphone', 'phone', 'index-card', 'carrot', 'building', 'store', 'album', 'palmtree', 'tickets-alt', 'money', 'smiley', 'thumbs-up', 'thumbs-down', 'layout' ),
);
}
/**
+2 -9
View File
@@ -28,7 +28,6 @@ class Kirki_Init {
* The class constructor.
*/
public function __construct() {
self::set_url();
add_action( 'after_setup_theme', array( $this, 'set_url' ) );
add_action( 'wp_loaded', array( $this, 'add_to_customizer' ), 1 );
@@ -49,7 +48,6 @@ class Kirki_Init {
* @access public
*/
public static function set_url() {
if ( Kirki_Util::is_plugin() ) {
return;
}
@@ -79,7 +77,6 @@ class Kirki_Init {
* @return array
*/
public function default_control_types( $control_types = array() ) {
$this->control_types = array(
'checkbox' => 'Kirki_Control_Checkbox',
'kirki-background' => 'Kirki_Control_Background',
@@ -115,7 +112,6 @@ class Kirki_Init {
'upload' => 'Kirki_Control_Upload',
);
return array_merge( $this->control_types, $control_types );
}
/**
@@ -216,7 +212,6 @@ class Kirki_Init {
* @var object The WordPress Customizer object.
*/
public function add_fields() {
global $wp_customize;
foreach ( Kirki::$fields as $args ) {
@@ -243,7 +238,6 @@ class Kirki_Init {
* @since 2.0.0
*/
private function fields_from_filters() {
$fields = apply_filters( 'kirki_controls', array() );
$fields = apply_filters( 'kirki_fields', $fields );
@@ -264,7 +258,6 @@ class Kirki_Init {
* @return bool
*/
public static function is_plugin() {
// Return result using the Kirki_Util class.
return Kirki_Util::is_plugin();
}
@@ -278,9 +271,9 @@ class Kirki_Init {
* @return array Formatted as array( 'variable-name' => value ).
*/
public static function get_variables() {
// Log error for developers.
_doing_it_wrong( __METHOD__, esc_attr__( 'We detected you\'re using Kirki_Init::get_variables(). Please use Kirki_Util::get_variables() instead.', 'kirki' ), '3.0.10' );
// Return result using the Kirki_Util class.
_doing_it_wrong( __METHOD__, esc_html__( 'We detected you\'re using Kirki_Init::get_variables(). Please use Kirki_Util::get_variables() instead.', 'kirki' ), '3.0.10' );
return Kirki_Util::get_variables();
}
-11
View File
@@ -48,7 +48,6 @@ class Kirki_L10n {
// If we got this far, then Kirki is embedded in a plugin.
// We want the theme's textdomain to handle translations.
add_filter( 'override_load_textdomain', array( $this, 'override_load_textdomain' ), 5, 3 );
}
/**
@@ -57,12 +56,10 @@ class Kirki_L10n {
* @access public
*/
public function load_textdomain() {
if ( null !== $this->get_path() ) {
load_textdomain( $this->textdomain, $this->get_path() );
}
load_plugin_textdomain( $this->textdomain, false, Kirki::$path . '/languages' );
}
/**
@@ -84,9 +81,7 @@ class Kirki_L10n {
$found_path = $path;
}
}
return $found_path;
}
/**
@@ -96,12 +91,10 @@ class Kirki_L10n {
* @return array
*/
protected function get_paths() {
return array(
WP_LANG_DIR . '/' . $this->textdomain . '-' . get_locale() . '.mo',
Kirki::$path . '/languages/' . $this->textdomain . '-' . get_locale() . '.mo',
);
}
/**
@@ -115,7 +108,6 @@ class Kirki_L10n {
* @return bool
*/
public function override_load_textdomain( $override, $domain, $mofile ) {
global $l10n;
if ( isset( $l10n[ $this->get_theme_textdomain() ] ) ) {
$l10n['kirki'] = $l10n[ $this->get_theme_textdomain() ]; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited
@@ -126,7 +118,6 @@ class Kirki_L10n {
return true;
}
return $override;
}
/**
@@ -137,7 +128,6 @@ class Kirki_L10n {
* @return string
*/
private function get_theme_textdomain() {
if ( '' === $this->theme_textdomain ) {
// Get the textdomain.
@@ -150,6 +140,5 @@ class Kirki_L10n {
}
}
return $this->theme_textdomain;
}
}
+11 -18
View File
@@ -42,20 +42,19 @@ class Kirki_Modules {
* @since 3.0.0
*/
public function __construct() {
$this->default_modules();
$this->init();
add_action( 'after_setup_theme', array( $this, 'setup_default_modules' ), 10 );
add_action( 'after_setup_theme', array( $this, 'init' ), 11 );
}
/**
* Set the default modules and apply the 'kirki_modules' filter.
* In v3.0.35 this method was renamed from default_modules to setup_default_modules,
* and its visibility changed from private to public to fix https://github.com/aristath/kirki/issues/2023
*
* @access private
* @access public
* @since 3.0.0
*/
private function default_modules() {
public function setup_default_modules() {
self::$modules = apply_filters(
'kirki_modules', array(
'css' => 'Kirki_Modules_CSS',
@@ -72,19 +71,20 @@ class Kirki_Modules {
'webfonts' => 'Kirki_Modules_Webfonts',
'webfont-loader' => 'Kirki_Modules_Webfont_Loader',
'preset' => 'Kirki_Modules_Preset',
'gutenberg' => 'Kirki_Modules_Gutenberg',
)
);
}
/**
* Instantiates the modules.
* In v3.0.35 the visibility for this method was changed
* from private to public to fix https://github.com/aristath/kirki/issues/2023
*
* @access private
* @access public
* @since 3.0.0
*/
private function init() {
public function init() {
foreach ( self::$modules as $key => $module_class ) {
if ( class_exists( $module_class ) ) {
// Use this syntax instead of $module_class::get_instance()
@@ -103,11 +103,9 @@ class Kirki_Modules {
* @since 3.0.0
*/
public static function add_module( $module ) {
if ( ! in_array( $module, self::$modules, true ) ) {
self::$modules[] = $module;
}
}
/**
@@ -119,7 +117,6 @@ class Kirki_Modules {
* @since 3.0.0
*/
public static function remove_module( $module ) {
$key = array_search( $module, self::$modules, true );
if ( false !== $key ) {
unset( self::$modules[ $key ] );
@@ -135,9 +132,7 @@ class Kirki_Modules {
* @return array
*/
public static function get_modules() {
return self::$modules;
}
/**
@@ -149,8 +144,6 @@ class Kirki_Modules {
* @return array
*/
public static function get_active_modules() {
return self::$active_modules;
}
}
+1 -4
View File
@@ -32,10 +32,8 @@ class Kirki_Panel {
* @param array $args The panel arguments.
*/
public function __construct( $args ) {
$this->panel_types = apply_filters( 'kirki_panel_types', $this->panel_types );
$this->add_panel( $args );
}
/**
@@ -51,7 +49,6 @@ class Kirki_Panel {
}
$panel_classname = $this->panel_types[ $args['type'] ];
$wp_customize->add_panel( new $panel_classname( $wp_customize, sanitize_key( $args['id'] ), $args ) );
$wp_customize->add_panel( new $panel_classname( $wp_customize, $args['id'], $args ) );
}
}
@@ -70,6 +70,7 @@ class Kirki_Sanitize_Values {
* @return int|string Page ID if the page is published; otherwise, the setting default.
*/
public static function dropdown_pages( $page_id, $setting ) {
// Ensure $input is an absolute integer.
$page_id = absint( $page_id );
@@ -170,16 +171,20 @@ class Kirki_Sanitize_Values {
* @return string
*/
public static function color( $value ) {
// If the value is empty, then return empty.
if ( '' === $value ) {
return '';
}
// If transparent, then return 'transparent'.
if ( is_string( $value ) && 'transparent' === trim( $value ) ) {
return 'transparent';
}
// Instantiate the object.
$color = ariColor::newColor( $value );
// Return a CSS value, using the auto-detected mode.
return $color->toCSS( $color->mode );
}
+1 -5
View File
@@ -30,10 +30,8 @@ class Kirki_Section {
* @param array $args The section parameters.
*/
public function __construct( $args ) {
$this->section_types = apply_filters( 'kirki_section_types', $this->section_types );
$this->add_section( $args );
}
/**
@@ -43,7 +41,6 @@ class Kirki_Section {
* @param array $args The section parameters.
*/
public function add_section( $args ) {
global $wp_customize;
// The default class to be used when creating a section.
@@ -58,7 +55,6 @@ class Kirki_Section {
}
// Add the section.
$wp_customize->add_section( new $section_classname( $wp_customize, sanitize_key( $args['id'] ), $args ) );
$wp_customize->add_section( new $section_classname( $wp_customize, $args['id'], $args ) );
}
}
+3 -4
View File
@@ -33,16 +33,15 @@ class Kirki_Sections {
* @return void
*/
public function outer_sections_css() {
echo '<style>';
$css = '';
if ( ! empty( Kirki::$sections ) ) {
foreach ( Kirki::$sections as $section_args ) {
if ( isset( $section_args['id'] ) && isset( $section_args['type'] ) && 'outer' === $section_args['type'] || 'kirki-outer' === $section_args['type'] ) {
$css .= '#customize-theme-controls li#accordion-section-' . $section_args['id'] . '{display:list-item!important;}';
echo '#customize-theme-controls li#accordion-section-' . esc_html( $section_args['id'] ) . '{display:list-item!important;}';
}
}
}
if ( ! empty( $css ) ) {
echo '<style>' . esc_attr( $css ) . '</style>';
}
echo '</style>';
}
}
@@ -49,6 +49,7 @@ class Kirki_Settings {
// Set the setting_types.
$this->set_setting_types();
// Add the settings.
$this->add_settings( $args );
+3 -8
View File
@@ -22,7 +22,6 @@ class Kirki_Util {
* @access public
*/
public function __construct() {
add_filter( 'http_request_args', array( $this, 'http_request' ), 10, 2 );
}
@@ -35,7 +34,6 @@ class Kirki_Util {
* @return bool
*/
public static function is_plugin() {
$is_plugin = false;
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
@@ -90,18 +88,15 @@ class Kirki_Util {
// Is the variable ['name'] defined? If yes, then we can proceed.
if ( isset( $field_variable['name'] ) ) {
// Sanitize the variable name.
$variable_name = esc_attr( $field_variable['name'] );
// Do we have a callback function defined? If not then set $variable_callback to false.
$variable_callback = ( isset( $field_variable['callback'] ) && is_callable( $field_variable['callback'] ) ) ? $field_variable['callback'] : false;
// If we have a variable_callback defined then get the value of the option
// and run it through the callback function.
// If no callback is defined (false) then just get the value.
$variables[ $variable_name ] = Kirki_Values::get_value( $field['settings'] );
$variables[ $field_variable['name'] ] = Kirki_Values::get_value( $field['settings'] );
if ( $variable_callback ) {
$variables[ $variable_name ] = call_user_func( $field_variable['callback'], Kirki_Values::get_value( $field['settings'] ) );
$variables[ $field_variable['name'] ] = call_user_func( $field_variable['callback'], Kirki_Values::get_value( $field['settings'] ) );
}
}
}
@@ -110,7 +105,6 @@ class Kirki_Util {
// Pass the variables through a filter ('kirki_variable') and return the array of variables.
return apply_filters( 'kirki_variable', $variables );
}
/**
@@ -123,6 +117,7 @@ class Kirki_Util {
* @return array
*/
public function http_request( $request = array(), $url = '' ) {
// Early exit if installed as a plugin or not a request to wordpress.org,
// or finally if we don't have everything we need.
if (
-4
View File
@@ -25,7 +25,6 @@ class Kirki_Values {
* @since 3.0.10
*/
public function __construct() {
add_filter( 'kirki_values_get_value', array( $this, 'typography_field_tweaks' ), 10, 2 );
}
@@ -39,7 +38,6 @@ class Kirki_Values {
* @return array
*/
public function typography_field_tweaks( $value, $field_id ) {
if ( isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ $field_id ]['type'] ) ) {
if ( 'kirki-typography' === Kirki::$fields[ $field_id ]['type'] ) {
@@ -149,8 +147,6 @@ class Kirki_Values {
$value = get_option( $field['settings'], $field['default'] );
}
}
return $value;
}
}
+29 -23
View File
@@ -128,7 +128,6 @@ class Kirki extends Kirki_Init {
* @return mixed The saved value of the field.
*/
public static function get_option( $config_id = '', $field_id = '' ) {
return Kirki_Values::get_value( $config_id, $field_id );
}
@@ -141,7 +140,6 @@ class Kirki extends Kirki_Init {
* @param array $args The configuration options.
*/
public static function add_config( $config_id, $args = array() ) {
$config = Kirki_Config::get_instance( $config_id, $args );
$config_args = $config->get_config();
self::$config[ $config_args['id'] ] = $config_args;
@@ -156,14 +154,20 @@ class Kirki extends Kirki_Init {
* @param array $args The panel arguments.
*/
public static function add_panel( $id = '', $args = array() ) {
$args['id'] = esc_attr( $id );
$args['description'] = ( isset( $args['description'] ) ) ? $args['description'] : '';
$args['priority'] = ( isset( $args['priority'] ) ) ? absint( $args['priority'] ) : 10;
$args['type'] = ( isset( $args['type'] ) ) ? $args['type'] : 'default';
$args['type'] = 'kirki-' . $args['type'];
self::$panels[ $args['id'] ] = $args;
$args['id'] = $id;
if ( ! isset( $args['description'] ) ) {
$args['description'] = '';
}
if ( ! isset( $args['priority'] ) ) {
$args['priority'] = 10;
}
if ( ! isset( $args['type'] ) ) {
$args['type'] = 'default';
}
if ( false === strpos( $args['type'], 'kirki-' ) ) {
$args['type'] = 'kirki-' . $args['type'];
}
self::$panels[ $id ] = $args;
}
/**
@@ -189,15 +193,21 @@ class Kirki extends Kirki_Init {
* @param array $args The section arguments.
*/
public static function add_section( $id, $args ) {
$args['id'] = $id;
if ( ! isset( $args['description'] ) ) {
$args['description'] = '';
}
if ( ! isset( $args['priority'] ) ) {
$args['priority'] = 10;
}
if ( ! isset( $args['type'] ) ) {
$args['type'] = 'default';
}
if ( false === strpos( $args['type'], 'kirki-' ) ) {
$args['type'] = 'kirki-' . $args['type'];
}
$args['id'] = esc_attr( $id );
$args['panel'] = ( isset( $args['panel'] ) ) ? esc_attr( $args['panel'] ) : '';
$args['description'] = ( isset( $args['description'] ) ) ? $args['description'] : '';
$args['priority'] = ( isset( $args['priority'] ) ) ? absint( $args['priority'] ) : 10;
$args['type'] = ( isset( $args['type'] ) ) ? $args['type'] : 'default';
$args['type'] = 'kirki-' . $args['type'];
self::$sections[ $args['id'] ] = $args;
self::$sections[ $id ] = $args;
}
/**
@@ -223,9 +233,8 @@ class Kirki extends Kirki_Init {
* @param array $args The field arguments.
*/
public static function add_field( $config_id, $args ) {
if ( doing_action( 'customize_register' ) ) {
_doing_it_wrong( __METHOD__, esc_attr__( 'Kirki fields should not be added on customize_register. Please add them directly, or on init.', 'kirki' ), '3.0.10' );
_doing_it_wrong( __METHOD__, esc_html__( 'Kirki fields should not be added on customize_register. Please add them directly, or on init.', 'kirki' ), '3.0.10' );
}
// Early exit if 'type' is not defined.
@@ -251,9 +260,7 @@ class Kirki extends Kirki_Init {
return;
}
}
new Kirki_Field( $config_id, $args );
}
/**
@@ -281,7 +288,6 @@ class Kirki extends Kirki_Init {
* @return string
*/
public static function get_config_param( $id, $param ) {
if ( ! isset( self::$config[ $id ] ) || ! isset( self::$config[ $id ][ $param ] ) ) {
return '';
}
+1 -1
View File
@@ -16,7 +16,7 @@ if ( ! function_exists( 'kirki_get_option' ) ) {
* @return mixed
*/
function kirki_get_option( $option = '' ) {
_deprecated_function( __FUNCTION__, '1.0.0', sprintf( esc_attr__( '%1$s or %2$s', 'kirki' ), 'get_theme_mod', 'get_option' ) );
_deprecated_function( __FUNCTION__, '1.0.0', sprintf( esc_html__( '%1$s or %2$s', 'kirki' ), 'get_theme_mod', 'get_option' ) );
return Kirki::get_option( '', $option );
}
}
@@ -20,9 +20,7 @@ class Kirki_Field_Background extends Kirki_Field {
* @access protected
*/
protected function set_type() {
$this->type = 'kirki-background';
}
/**
@@ -38,7 +36,6 @@ class Kirki_Field_Background extends Kirki_Field {
return;
}
$this->sanitize_callback = array( $this, 'sanitize' );
}
/**
@@ -49,17 +46,16 @@ class Kirki_Field_Background extends Kirki_Field {
* @return array
*/
public function sanitize( $value ) {
if ( ! is_array( $value ) ) {
return array();
}
return array(
'background-color' => ( isset( $value['background-color'] ) ) ? esc_attr( $value['background-color'] ) : '',
'background-color' => ( isset( $value['background-color'] ) ) ? sanitize_text_field( $value['background-color'] ) : '',
'background-image' => ( isset( $value['background-image'] ) ) ? esc_url_raw( $value['background-image'] ) : '',
'background-repeat' => ( isset( $value['background-repeat'] ) ) ? esc_attr( $value['background-repeat'] ) : '',
'background-position' => ( isset( $value['background-position'] ) ) ? esc_attr( $value['background-position'] ) : '',
'background-size' => ( isset( $value['background-size'] ) ) ? esc_attr( $value['background-size'] ) : '',
'background-attachment' => ( isset( $value['background-attachment'] ) ) ? esc_attr( $value['background-attachment'] ) : '',
'background-repeat' => ( isset( $value['background-repeat'] ) ) ? sanitize_text_field( $value['background-repeat'] ) : '',
'background-position' => ( isset( $value['background-position'] ) ) ? sanitize_text_field( $value['background-position'] ) : '',
'background-size' => ( isset( $value['background-size'] ) ) ? sanitize_text_field( $value['background-size'] ) : '',
'background-attachment' => ( isset( $value['background-attachment'] ) ) ? sanitize_text_field( $value['background-attachment'] ) : '',
);
}
@@ -116,7 +112,6 @@ class Kirki_Field_Background extends Kirki_Field {
}
$this->js_vars = $js_vars;
$this->transport = 'postMessage';
}
}
}
@@ -20,9 +20,7 @@ class Kirki_Field_Checkbox extends Kirki_Field {
* @access protected
*/
protected function set_type() {
$this->type = 'checkbox';
}
/**
@@ -31,11 +29,9 @@ class Kirki_Field_Checkbox extends Kirki_Field {
* @access protected
*/
protected function set_sanitize_callback() {
if ( ! $this->sanitize_callback ) {
$this->sanitize_callback = array( $this, 'sanitize' );
}
}
/**
@@ -46,13 +42,7 @@ class Kirki_Field_Checkbox extends Kirki_Field {
* @return bool
*/
public function sanitize( $value = null ) {
if ( '0' === $value || 'false' === $value ) {
return false;
}
return (bool) $value;
return ( '0' === $value || 'false' === $value ) ? false : (bool) $value;
}
/**
@@ -61,8 +51,6 @@ class Kirki_Field_Checkbox extends Kirki_Field {
* @access protected
*/
protected function set_default() {
$this->default = (bool) ( 1 === $this->default || '1' === $this->default || true === $this->default || 'true' === $this->default || 'on' === $this->default );
}
}
@@ -114,6 +114,5 @@ class Kirki_Field_Code extends Kirki_Field {
// It is the responsibility of the theme/plugin that registers this field
// to properly apply any necessary filtering.
$this->sanitize_callback = array( 'Kirki_Sanitize_Values', 'unfiltered' );
}
}
@@ -20,11 +20,9 @@ class Kirki_Field_Color_Alpha extends Kirki_Field_Color {
* @access protected
*/
protected function set_choices() {
if ( ! is_array( $this->choices ) ) {
$this->choices = array();
}
$this->choices['alpha'] = true;
}
}
@@ -20,8 +20,6 @@ class Kirki_Field_Color_Palette extends Kirki_Field {
* @access protected
*/
protected function set_type() {
$this->type = 'kirki-color-palette';
}
}
@@ -36,9 +36,7 @@ class Kirki_Field_Color extends Kirki_Field {
* @access protected
*/
protected function set_type() {
$this->type = 'kirki-color';
}
/**
@@ -47,12 +45,11 @@ class Kirki_Field_Color extends Kirki_Field {
* @access protected
*/
protected function set_choices() {
if ( ! is_array( $this->choices ) ) {
$this->choices = array();
}
if ( true === $this->alpha ) {
_doing_it_wrong( 'Kirki::add_field', esc_attr__( 'Do not use "alpha" as an argument in color controls. Use "choices[alpha]" instead.', 'kirki' ), '3.0.10' );
_doing_it_wrong( 'Kirki::add_field', esc_html__( 'Do not use "alpha" as an argument in color controls. Use "choices[alpha]" instead.', 'kirki' ), '3.0.10' );
$this->choices['alpha'] = true;
}
if ( ! isset( $this->choices['alpha'] ) || true !== $this->choices['alpha'] ) {
@@ -84,6 +81,5 @@ class Kirki_Field_Color extends Kirki_Field {
return;
}
$this->sanitize_callback = array( 'Kirki_Sanitize_Values', 'color' );
}
}
@@ -20,9 +20,7 @@ class Kirki_Field_Custom extends Kirki_Field {
* @access protected
*/
protected function set_type() {
$this->type = 'kirki-custom';
}
/**
@@ -37,9 +35,9 @@ class Kirki_Field_Custom extends Kirki_Field {
if ( ! empty( $this->sanitize_callback ) ) {
return;
}
// Custom fields don't actually save any value.
// just use __return_true.
$this->sanitize_callback = '__return_true';
}
}
@@ -20,9 +20,7 @@ class Kirki_Field_Dashicons extends Kirki_Field {
* @access protected
*/
protected function set_type() {
$this->type = 'kirki-dashicons';
}
/**
@@ -37,6 +35,6 @@ class Kirki_Field_Dashicons extends Kirki_Field {
if ( ! empty( $this->sanitize_callback ) ) {
return;
}
$this->sanitize_callback = 'esc_attr';
$this->sanitize_callback = 'sanitize_text_field';
}
}
@@ -20,9 +20,7 @@ class Kirki_Field_Date extends Kirki_Field {
* @access protected
*/
protected function set_type() {
$this->type = 'kirki-date';
}
/**
@@ -37,7 +35,6 @@ class Kirki_Field_Date extends Kirki_Field {
if ( ! empty( $this->sanitize_callback ) ) {
return;
}
$this->sanitize_callback = 'esc_textarea';
$this->sanitize_callback = 'sanitize_text_field';
}
}
@@ -20,9 +20,7 @@ class Kirki_Field_Dimension extends Kirki_Field {
* @access protected
*/
protected function set_type() {
$this->type = 'kirki-dimension';
}
/**
@@ -20,9 +20,7 @@ class Kirki_Field_Dimensions extends Kirki_Field {
* @access protected
*/
protected function set_type() {
$this->type = 'kirki-dimensions';
}
/**
@@ -38,7 +36,6 @@ class Kirki_Field_Dimensions extends Kirki_Field {
return;
}
$this->sanitize_callback = array( $this, 'sanitize' );
}
/**
@@ -55,7 +52,6 @@ class Kirki_Field_Dimensions extends Kirki_Field {
$value[ $key ] = sanitize_text_field( $sub_value );
}
return $value;
}
/**
@@ -65,7 +61,6 @@ class Kirki_Field_Dimensions extends Kirki_Field {
* @access protected
*/
protected function set_choices() {
$this->choices['controls'] = array();
if ( is_array( $this->default ) ) {
foreach ( $this->default as $key => $value ) {
@@ -26,6 +26,7 @@ class Kirki_Field_Editor extends Kirki_Field {
$this->type = 'kirki-editor';
return;
}
// Fallback for older WordPress versions.
$this->type = 'kirki-generic';
if ( ! is_array( $this->choices ) ) {
@@ -33,7 +34,6 @@ class Kirki_Field_Editor extends Kirki_Field {
}
$this->choices['element'] = 'textarea';
$this->choices['rows'] = '5';
}
/**
@@ -49,6 +49,5 @@ class Kirki_Field_Editor extends Kirki_Field {
return;
}
$this->sanitize_callback = 'wp_kses_post';
}
}
@@ -20,9 +20,7 @@ class Kirki_Field_FontAwesome extends Kirki_Field {
* @access protected
*/
protected function set_type() {
$this->type = 'kirki-fontawesome';
}
/**
@@ -37,7 +35,6 @@ class Kirki_Field_FontAwesome extends Kirki_Field {
if ( ! empty( $this->sanitize_callback ) ) {
return;
}
$this->sanitize_callback = 'esc_attr';
$this->sanitize_callback = 'sanitize_text_field';
}
}
+7 -12
View File
@@ -30,9 +30,7 @@ class Kirki_Field_Image extends Kirki_Field {
* @access protected
*/
protected function set_type() {
$this->type = 'kirki-image';
}
/**
@@ -46,13 +44,13 @@ class Kirki_Field_Image extends Kirki_Field {
$this->button_labels = wp_parse_args(
$this->button_labels,
array(
'select' => esc_attr__( 'Select image', 'kirki' ),
'change' => esc_attr__( 'Change image', 'kirki' ),
'default' => esc_attr__( 'Default', 'kirki' ),
'remove' => esc_attr__( 'Remove', 'kirki' ),
'placeholder' => esc_attr__( 'No image selected', 'kirki' ),
'frame_title' => esc_attr__( 'Select image', 'kirki' ),
'frame_button' => esc_attr__( 'Choose image', 'kirki' ),
'select' => esc_html__( 'Select image', 'kirki' ),
'change' => esc_html__( 'Change image', 'kirki' ),
'default' => esc_html__( 'Default', 'kirki' ),
'remove' => esc_html__( 'Remove', 'kirki' ),
'placeholder' => esc_html__( 'No image selected', 'kirki' ),
'frame_title' => esc_html__( 'Select image', 'kirki' ),
'frame_button' => esc_html__( 'Choose image', 'kirki' ),
)
);
}
@@ -64,7 +62,6 @@ class Kirki_Field_Image extends Kirki_Field {
* @access protected
*/
protected function set_choices() {
if ( ! is_array( $this->choices ) ) {
$this->choices = (array) $this->choices;
}
@@ -91,7 +88,6 @@ class Kirki_Field_Image extends Kirki_Field {
return;
}
$this->sanitize_callback = array( $this, 'sanitize' );
}
/**
@@ -100,7 +96,6 @@ class Kirki_Field_Image extends Kirki_Field {
* @param string|array $value The control's value.
*/
public function sanitize( $value ) {
if ( isset( $this->choices['save_as'] ) && 'array' === $this->choices['save_as'] ) {
return array(
'id' => ( isset( $value['id'] ) && '' !== $value['id'] ) ? (int) $value['id'] : '',
@@ -20,9 +20,7 @@ class Kirki_Field_Kirki_Generic extends Kirki_Field {
* @access protected
*/
protected function set_type() {
$this->type = 'kirki-generic';
}
@@ -32,14 +30,12 @@ class Kirki_Field_Kirki_Generic extends Kirki_Field {
* @access protected
*/
protected function set_choices() {
if ( ! is_array( $this->choices ) ) {
$this->choices = array();
}
if ( ! isset( $this->choices['element'] ) ) {
$this->choices['element'] = 'input';
}
}
/**
@@ -55,6 +51,5 @@ class Kirki_Field_Kirki_Generic extends Kirki_Field {
return;
}
$this->sanitize_callback = 'wp_kses_post';
}
}
@@ -20,9 +20,7 @@ class Kirki_Field_Multicheck extends Kirki_Field {
* @access protected
*/
protected function set_type() {
$this->type = 'kirki-multicheck';
}
/**
@@ -38,7 +36,6 @@ class Kirki_Field_Multicheck extends Kirki_Field {
return;
}
$this->sanitize_callback = array( $this, 'sanitize' );
}
/**
@@ -47,9 +44,7 @@ class Kirki_Field_Multicheck extends Kirki_Field {
* @param string|array $value The control's value.
*/
public function sanitize( $value ) {
$value = ( ! is_array( $value ) ) ? explode( ',', $value ) : $value;
return ( ! empty( $value ) ) ? array_map( 'sanitize_text_field', $value ) : array();
}
}
@@ -62,8 +62,6 @@ class Kirki_Field_Multicolor extends Kirki_Field {
* @return array The value.
*/
public function sanitize( $value ) {
return $value;
}
}
@@ -31,9 +31,7 @@ class Kirki_Field_Number extends Kirki_Field {
* @access protected
*/
protected function set_sanitize_callback() {
$this->sanitize_callback = array( $this, 'sanitize' );
}
/**
@@ -42,7 +40,6 @@ class Kirki_Field_Number extends Kirki_Field {
* @access protected
*/
protected function set_choices() {
$this->choices = wp_parse_args(
$this->choices,
array(
@@ -65,7 +62,6 @@ class Kirki_Field_Number extends Kirki_Field {
* @return bool
*/
public function sanitize( $value = 0 ) {
$this->set_choices();
$value = filter_var( $value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION );
@@ -20,8 +20,6 @@ class Kirki_Field_Palette extends Kirki_Field_Radio {
* @access protected
*/
protected function set_type() {
$this->type = 'kirki-palette';
}
}
@@ -20,9 +20,7 @@ class Kirki_Field_Preset extends Kirki_Field_Select {
* @access protected
*/
protected function set_type() {
$this->type = 'kirki-select';
}
/**
@@ -20,8 +20,6 @@ class Kirki_Field_Radio_Buttonset extends Kirki_Field_Radio {
* @access protected
*/
protected function set_type() {
$this->type = 'kirki-radio-buttonset';
}
}
@@ -20,8 +20,6 @@ class Kirki_Field_Radio_Image extends Kirki_Field_Radio {
* @access protected
*/
protected function set_type() {
$this->type = 'kirki-radio-image';
}
}
@@ -28,16 +28,15 @@ class Kirki_Field_Radio extends Kirki_Field {
* @access protected
*/
protected function set_type() {
$this->type = 'kirki-radio';
// Tweaks for backwards-compatibility:
// Prior to version 0.8 radio-buttonset & radio-image were part of the radio control.
if ( in_array( $this->mode, array( 'buttonset', 'image' ), true ) ) {
/* translators: %1$s represents the field ID where the error occurs. %2%s is buttonset/image. */
_doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Error in field %1$s. The "mode" argument has been deprecated since Kirki v0.8. Use the "radio-%2$s" type instead.', 'kirki' ), esc_attr( $this->settings ), esc_attr( $this->mode ) ), '3.0.10' );
_doing_it_wrong( __METHOD__, sprintf( esc_html__( 'Error in field %1$s. The "mode" argument has been deprecated since Kirki v0.8. Use the "radio-%2$s" type instead.', 'kirki' ), esc_html( $this->settings ), esc_html( $this->mode ) ), '3.0.10' );
$this->type = 'radio-' . $this->mode;
}
}
/**
@@ -52,7 +51,6 @@ class Kirki_Field_Radio extends Kirki_Field {
if ( ! empty( $this->sanitize_callback ) ) {
return;
}
$this->sanitize_callback = 'esc_attr';
$this->sanitize_callback = 'sanitize_text_field';
}
}
@@ -29,9 +29,7 @@ class Kirki_Field_Repeater extends Kirki_Field {
* @access protected
*/
protected function set_type() {
$this->type = 'repeater';
}
/**
@@ -44,7 +42,6 @@ class Kirki_Field_Repeater extends Kirki_Field {
// Force using refresh mode.
// Currently the repeater control does not support postMessage.
$this->transport = 'refresh';
}
@@ -89,13 +86,16 @@ class Kirki_Field_Repeater extends Kirki_Field {
$value[ $row_id ] = array();
continue;
}
// Start parsing sub-fields in rows.
foreach ( $row_value as $subfield_id => $subfield_value ) {
// Make sure this is a valid subfield.
// If it's not, then unset it.
if ( ! isset( $this->fields[ $subfield_id ] ) ) {
unset( $value[ $row_id ][ $subfield_id ] );
}
// Get the subfield-type.
if ( ! isset( $this->fields[ $subfield_id ]['type'] ) ) {
continue;
@@ -104,9 +104,7 @@ class Kirki_Field_Repeater extends Kirki_Field {
// Allow using a sanitize-callback on a per-field basis.
if ( isset( $this->fields[ $subfield_id ]['sanitize_callback'] ) ) {
$subfield_value = call_user_func( $this->fields[ $subfield_id ]['sanitize_callback'], $subfield_value );
} else {
switch ( $subfield_type ) {
@@ -121,9 +119,8 @@ class Kirki_Field_Repeater extends Kirki_Field {
$subfield_value = (int) $subfield_value;
break;
case 'color':
// Instantiate the object.
$color_obj = ariColor::newColor( $subfield_value );
$$subfield_value = $color_obj->toCSS( $color_obj->mode );
$color_obj = ariColor::newColor( $subfield_value );
$subfield_value = $color_obj->toCSS( $color_obj->mode );
break;
case 'text':
$subfield_value = sanitize_text_field( $subfield_value );
@@ -136,7 +133,7 @@ class Kirki_Field_Repeater extends Kirki_Field {
$subfield_value = filter_var( $subfield_value, FILTER_SANITIZE_EMAIL );
break;
case 'tel':
$subfield_value = esc_attr( $subfield_value );
$subfield_value = sanitize_text_field( $subfield_value );
break;
case 'checkbox':
$subfield_value = (bool) $subfield_value;
@@ -150,16 +147,16 @@ class Kirki_Field_Repeater extends Kirki_Field {
if ( 1 < $multiple ) {
$subfield_value = (array) $subfield_value;
foreach ( $subfield_value as $sub_subfield_key => $sub_subfield_value ) {
$subfield_value[ $sub_subfield_key ] = esc_attr( $sub_subfield_value );
$subfield_value[ $sub_subfield_key ] = sanitize_text_field( $sub_subfield_value );
}
} else {
$subfield_value = esc_attr( $subfield_value );
$subfield_value = sanitize_text_field( $subfield_value );
}
}
break;
case 'radio':
case 'radio-image':
$subfield_value = esc_attr( $subfield_value );
$subfield_value = sanitize_text_field( $subfield_value );
break;
case 'textarea':
$subfield_value = html_entity_decode( wp_kses_post( $subfield_value ) );
@@ -169,7 +166,6 @@ class Kirki_Field_Repeater extends Kirki_Field {
$value[ $row_id ][ $subfield_id ] = $subfield_value;
}
}
return $value;
}
}
@@ -40,9 +40,7 @@ class Kirki_Field_Select extends Kirki_Field {
* @access protected
*/
protected function set_type() {
$this->type = 'kirki-select';
}
/**
@@ -54,16 +52,6 @@ class Kirki_Field_Select extends Kirki_Field {
$this->multiple = absint( $this->multiple );
}
/**
* The placeholder text.
*
* @access protected
* @since 3.0.21
*/
protected function set_placeholder() {
$this->placeholder = esc_attr( $this->placeholder );
}
/**
* Sets the $sanitize_callback
*
@@ -77,7 +65,6 @@ class Kirki_Field_Select extends Kirki_Field {
return;
}
$this->sanitize_callback = array( $this, 'sanitize' );
}
/**
@@ -89,18 +76,16 @@ class Kirki_Field_Select extends Kirki_Field {
* @return string|array
*/
public function sanitize( $value ) {
if ( is_array( $value ) ) {
foreach ( $value as $key => $subvalue ) {
if ( '' !== $subvalue || isset( $this->choices[''] ) ) {
$key = sanitize_key( $key );
$value[ $key ] = esc_attr( $subvalue );
$value[ $key ] = sanitize_text_field( $subvalue );
}
}
return $value;
}
return esc_attr( $value );
return sanitize_text_field( $value );
}
/**
@@ -110,7 +95,6 @@ class Kirki_Field_Select extends Kirki_Field {
* @since 3.0.0
*/
protected function set_default() {
if ( 1 < $this->multiple && ! is_array( $this->default ) ) {
$this->default = array( $this->default );
}
@@ -22,8 +22,6 @@ class Kirki_Field_Select2_Multiple extends Kirki_Field_Select {
* @access protected
*/
protected function set_multiple() {
$this->multiple = 999;
}
}
@@ -20,8 +20,6 @@ class Kirki_Field_Slider extends Kirki_Field_Number {
* @access protected
*/
protected function set_type() {
$this->type = 'kirki-slider';
}
}
@@ -20,9 +20,7 @@ class Kirki_Field_Sortable extends Kirki_Field {
* @access protected
*/
protected function set_type() {
$this->type = 'kirki-sortable';
}
/**
@@ -31,9 +29,7 @@ class Kirki_Field_Sortable extends Kirki_Field {
* @access protected
*/
protected function set_sanitize_callback() {
$this->sanitize_callback = array( $this, 'sanitize' );
}
/**
@@ -44,19 +40,17 @@ class Kirki_Field_Sortable extends Kirki_Field {
* @return array
*/
public function sanitize( $value = array() ) {
if ( is_string( $value ) || is_numeric( $value ) ) {
return array(
esc_attr( $value ),
sanitize_text_field( $value ),
);
}
$sanitized_value = array();
foreach ( $value as $sub_value ) {
if ( isset( $this->choices[ $sub_value ] ) ) {
$sanitized_value[] = esc_attr( $sub_value );
$sanitized_value[] = sanitize_text_field( $sub_value );
}
}
return $sanitized_value;
}
}
@@ -21,7 +21,6 @@ class Kirki_Field_Spacing extends Kirki_Field_Dimensions {
* @access protected
*/
protected function set_choices() {
$default_args = array(
'controls' => array(
'top' => ( isset( $this->default['top'] ) ),
@@ -30,14 +29,13 @@ class Kirki_Field_Spacing extends Kirki_Field_Dimensions {
'right' => ( isset( $this->default['top'] ) ),
),
'labels' => array(
'top' => esc_attr__( 'Top', 'kirki' ),
'bottom' => esc_attr__( 'Bottom', 'kirki' ),
'left' => esc_attr__( 'Left', 'kirki' ),
'right' => esc_attr__( 'Right', 'kirki' ),
'top' => esc_html__( 'Top', 'kirki' ),
'bottom' => esc_html__( 'Bottom', 'kirki' ),
'left' => esc_html__( 'Left', 'kirki' ),
'right' => esc_html__( 'Right', 'kirki' ),
),
);
$this->choices = wp_parse_args( $this->choices, $default_args );
}
}
@@ -20,9 +20,7 @@ class Kirki_Field_Switch extends Kirki_Field_Checkbox {
* @access protected
*/
protected function set_type() {
$this->type = 'kirki-switch';
}
/**
@@ -31,7 +29,6 @@ class Kirki_Field_Switch extends Kirki_Field_Checkbox {
* @access protected
*/
protected function set_choices() {
if ( ! is_array( $this->choices ) ) {
$this->choices = array();
}
@@ -39,8 +36,8 @@ class Kirki_Field_Switch extends Kirki_Field_Checkbox {
$this->choices = wp_parse_args(
$this->choices,
array(
'on' => esc_attr__( 'On', 'kirki' ),
'off' => esc_attr__( 'Off', 'kirki' ),
'on' => esc_html__( 'On', 'kirki' ),
'off' => esc_html__( 'Off', 'kirki' ),
'round' => false,
)
);
@@ -20,13 +20,11 @@ class Kirki_Field_Text extends Kirki_Field_Kirki_Generic {
* @access protected
*/
protected function set_choices() {
if ( ! is_array( $this->choices ) ) {
$this->choices = array();
}
$this->choices['element'] = 'input';
$this->choices['type'] = 'text';
}
/**
@@ -41,7 +39,6 @@ class Kirki_Field_Text extends Kirki_Field_Kirki_Generic {
if ( ! empty( $this->sanitize_callback ) ) {
return;
}
$this->sanitize_callback = 'esc_textarea';
$this->sanitize_callback = 'sanitize_textarea_field';
}
}
@@ -20,7 +20,6 @@ class Kirki_Field_Textarea extends Kirki_Field_Kirki_Generic {
* @access protected
*/
protected function set_choices() {
$this->choices = array(
'element' => 'textarea',
'rows' => 5,
@@ -20,8 +20,6 @@ class Kirki_Field_Toggle extends Kirki_Field_Checkbox {
* @access protected
*/
protected function set_type() {
$this->type = 'kirki-toggle';
}
}
@@ -20,9 +20,7 @@ class Kirki_Field_Typography extends Kirki_Field {
* @access protected
*/
protected function set_type() {
$this->type = 'kirki-typography';
}
/**
@@ -72,7 +70,6 @@ class Kirki_Field_Typography extends Kirki_Field {
return;
}
$this->sanitize_callback = array( __CLASS__, 'sanitize' );
}
/**
@@ -81,7 +78,6 @@ class Kirki_Field_Typography extends Kirki_Field {
* @access protected
*/
protected function set_js_vars() {
if ( ! is_array( $this->js_vars ) ) {
$this->js_vars = array();
}
@@ -124,9 +120,7 @@ class Kirki_Field_Typography extends Kirki_Field {
}
$this->js_vars = $js_vars;
$this->transport = 'postMessage';
}
}
/**
@@ -138,7 +132,6 @@ class Kirki_Field_Typography extends Kirki_Field {
* @return array
*/
public static function sanitize( $value ) {
if ( ! is_array( $value ) ) {
return array();
}
@@ -146,7 +139,7 @@ class Kirki_Field_Typography extends Kirki_Field {
foreach ( $value as $key => $val ) {
switch ( $key ) {
case 'font-family':
$value['font-family'] = esc_attr( $val );
$value['font-family'] = sanitize_text_field( $val );
break;
case 'font-weight':
if ( isset( $value['variant'] ) ) {
@@ -158,11 +151,14 @@ class Kirki_Field_Typography extends Kirki_Field {
}
break;
case 'variant':
// Use 'regular' instead of 400 for font-variant.
$value['variant'] = ( 400 === $val || '400' === $val ) ? 'regular' : $val;
// Get font-weight from variant.
$value['font-weight'] = filter_var( $value['variant'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION );
$value['font-weight'] = ( 'regular' === $value['variant'] || 'italic' === $value['variant'] ) ? 400 : absint( $value['font-weight'] );
// Get font-style from variant.
if ( ! isset( $value['font-style'] ) ) {
$value['font-style'] = ( false === strpos( $value['variant'], 'italic' ) ) ? 'normal' : 'italic';
@@ -205,7 +201,6 @@ class Kirki_Field_Typography extends Kirki_Field {
* @since 3.0.0
*/
protected function set_choices() {
if ( ! is_array( $this->choices ) ) {
$this->choices = array();
}
@@ -20,9 +20,7 @@ class Kirki_Field_Upload extends Kirki_Field {
* @access protected
*/
protected function set_type() {
$this->type = 'upload';
}
/**
@@ -38,6 +36,5 @@ class Kirki_Field_Upload extends Kirki_Field {
return;
}
$this->sanitize_callback = 'esc_url_raw';
}
}
@@ -20,13 +20,11 @@ class Kirki_Field_URL extends Kirki_Field_Kirki_Generic {
* @access protected
*/
protected function set_choices() {
if ( ! is_array( $this->choices ) ) {
$this->choices = array();
}
$this->choices['element'] = 'input';
$this->choices['type'] = 'text';
}
/**
@@ -42,6 +40,5 @@ class Kirki_Field_URL extends Kirki_Field_Kirki_Generic {
return;
}
$this->sanitize_callback = 'esc_url_raw';
}
}
+1 -1
View File
@@ -5,7 +5,7 @@
* Description: The ultimate WordPress Customizer Toolkit
* Author: Aristeides Stathopoulos
* Author URI: http://aristath.github.io
* Version: 3.0.34.1
* Version: 3.0.35.3
* Text Domain: kirki
*
* GitHub Plugin URI: aristath/kirki
@@ -36,6 +36,15 @@ class Kirki_Modules_CSS_Vars {
*/
private $fields = array();
/**
* CSS-variables array [var=>val].
*
* @access private
* @since 3.0.35
* @var array
*/
private $vars = array();
/**
* Constructor
*
@@ -43,7 +52,9 @@ class Kirki_Modules_CSS_Vars {
* @since 3.0.28
*/
protected function __construct() {
add_action( 'wp_head', array( $this, 'the_style' ), 0 );
add_action( 'init', array( $this, 'populate_vars' ) );
add_action( 'wp_head', array( $this, 'the_style' ), 999 );
add_action( 'admin_head', array( $this, 'the_style' ), 999 );
add_action( 'customize_preview_init', array( $this, 'postmessage' ) );
}
@@ -64,17 +75,16 @@ class Kirki_Modules_CSS_Vars {
}
/**
* Add styles in <head>.
* Populates the $vars property of this object.
*
* @access public
* @since 3.0.28
* @since 3.0.35
* @return void
*/
public function the_style() {
public function populate_vars() {
// Get an array of all fields.
$fields = Kirki::$fields;
echo '<style id="kirki-css-vars">';
echo ':root{';
foreach ( $fields as $id => $args ) {
if ( ! isset( $args['css_vars'] ) || empty( $args['css_vars'] ) ) {
continue;
@@ -82,16 +92,46 @@ class Kirki_Modules_CSS_Vars {
$val = Kirki_Values::get_value( $args['kirki_config'], $id );
foreach ( $args['css_vars'] as $css_var ) {
if ( isset( $css_var[2] ) && is_array( $val ) && isset( $val[ $css_var[2] ] ) ) {
echo esc_attr( $css_var[0] ) . ':' . esc_attr( str_replace( '$', $val[ $css_var[2] ], $css_var[1] ) ) . ';';
$this->vars[ $css_var[0] ] = str_replace( '$', $val[ $css_var[2] ], $css_var[1] );
} else {
echo esc_attr( $css_var[0] ) . ':' . esc_attr( str_replace( '$', $val, $css_var[1] ) ) . ';';
$this->vars[ $css_var[0] ] = str_replace( '$', $val, $css_var[1] );
}
}
}
}
/**
* Add styles in <head>.
*
* @access public
* @since 3.0.28
* @return void
*/
public function the_style() {
if ( empty( $this->vars ) ) {
return;
}
echo '<style id="kirki-css-vars">';
echo ':root{';
foreach ( $this->vars as $var => $val ) {
echo esc_html( $var ) . ':' . esc_html( $val ) . ';';
}
echo '}';
echo '</style>';
}
/**
* Get an array of all the variables.
*
* @access public
* @since 3.0.35
* @return array
*/
public function get_vars() {
return $this->vars;
}
/**
* Enqueues the script that handles postMessage
* and adds variables to it using the wp_localize_script function.
+22 -1
View File
@@ -54,7 +54,28 @@ jQuery( document ).ready( function() {
styles[ cssVar[0] ] = cssVar[1].replace( '$', newVal );
}
} );
jQuery( '#kirki-css-vars' ).html( kirkiCssVars.buildStyle( styles ) ) ;
jQuery( '#kirki-css-vars' ).html( kirkiCssVars.buildStyle( styles ) );
} );
} );
} );
} );
wp.customize.bind( 'preview-ready', function() {
wp.customize.preview.bind( 'active', function() {
_.each( kirkiCssVarFields, function( field ) {
wp.customize( field.settings, function( value ) {
var styles = kirkiCssVars.getStyles(),
newVal = window.parent.wp.customize( value.id ).get();
_.each( field.css_vars, function( cssVar ) {
if ( 'object' === typeof newVal ) {
if ( cssVar[2] && newVal[ cssVar[2] ] ) {
styles[ cssVar[0] ] = cssVar[1].replace( '$', newVal[ cssVar[2] ] );
}
} else {
styles[ cssVar[0] ] = cssVar[1].replace( '$', newVal );
}
} );
jQuery( '#kirki-css-vars' ).html( kirkiCssVars.buildStyle( styles ) );
} );
} );
} );
@@ -33,6 +33,7 @@ class Kirki_CSS_To_File {
// If the file doesn't exist, create it.
if ( ! file_exists( $this->get_path( 'file' ) ) ) {
// If the file-write fails, fallback to inline
// and cache the failure so we don't try again immediately.
$this->write_file();
@@ -49,10 +50,8 @@ class Kirki_CSS_To_File {
* @return string|array
*/
protected function get_path( $context = '' ) {
$upload_dir = wp_upload_dir();
$paths = array(
$paths = array(
'file' => wp_normalize_path( $upload_dir['basedir'] . '/kirki-css/styles.css' ),
'folder' => wp_normalize_path( $upload_dir['basedir'] . '/kirki-css' ),
);
@@ -64,7 +63,6 @@ class Kirki_CSS_To_File {
return $paths['folder'];
}
return $paths;
}
/**
@@ -75,10 +73,8 @@ class Kirki_CSS_To_File {
* @return string
*/
public function get_url() {
$upload_dir = wp_upload_dir();
return esc_url_raw( $upload_dir['baseurl'] . '/kirki-css/styles.css' );
}
/**
@@ -90,7 +86,6 @@ class Kirki_CSS_To_File {
* @return integer|false
*/
public function get_timestamp() {
if ( file_exists( $this->get_path( 'file' ) ) ) {
return filemtime( $this->get_path( 'file' ) );
}
@@ -105,7 +100,6 @@ class Kirki_CSS_To_File {
* @return bool
*/
public function write_file() {
$css = array();
$configs = Kirki::$config;
foreach ( $configs as $config_id => $args ) {
@@ -126,7 +120,6 @@ class Kirki_CSS_To_File {
set_transient( 'kirki_css_write_to_file_failed', true, HOUR_IN_SECONDS );
}
return $write_file;
}
/**
@@ -145,7 +138,6 @@ class Kirki_CSS_To_File {
require_once wp_normalize_path( ABSPATH . '/wp-admin/includes/file.php' );
WP_Filesystem();
}
return $wp_filesystem;
}
}
@@ -178,7 +178,6 @@ final class Kirki_Modules_CSS_Generator {
}
$obj = new $classname( $field['kirki_config'], self::$output, self::$value, $field );
return $obj->get_styles();
}
/**
@@ -232,7 +231,6 @@ final class Kirki_Modules_CSS_Generator {
* @return array
*/
public static function add_prefixes( $css ) {
if ( is_array( $css ) ) {
foreach ( $css as $media_query => $elements ) {
foreach ( $elements as $element => $style_array ) {
@@ -74,7 +74,6 @@ class Kirki_Modules_CSS {
* @access protected
*/
protected function __construct() {
$class_files = array(
'Kirki_CSS_To_File' => '/class-kirki-css-to-file.php',
'Kirki_Modules_CSS_Generator' => '/class-kirki-modules-css-generator.php',
@@ -95,9 +94,7 @@ class Kirki_Modules_CSS {
include_once wp_normalize_path( dirname( __FILE__ ) . $file );
}
}
add_action( 'init', array( $this, 'init' ) );
}
/**
@@ -122,11 +119,10 @@ class Kirki_Modules_CSS {
* @access public
*/
public function init() {
global $wp_customize;
Kirki_Modules_Webfonts::get_instance();
global $wp_customize;
$config = apply_filters( 'kirki_config', array() );
$priority = 999;
if ( isset( $config['styles_priority'] ) ) {
@@ -140,8 +136,10 @@ class Kirki_Modules_CSS {
$method = apply_filters( 'kirki_dynamic_css_method', 'inline' );
if ( $wp_customize ) {
// If we're in the customizer, load inline no matter what.
add_action( 'wp_enqueue_scripts', array( $this, 'inline_dynamic_css' ), $priority );
add_action( 'enqueue_block_editor_assets', array( $this, 'inline_dynamic_css' ), $priority );
// If we're using file method, on save write the new styles.
if ( 'file' === $method ) {
@@ -152,10 +150,13 @@ class Kirki_Modules_CSS {
}
if ( 'file' === $method ) {
// Attempt to write the CSS to file.
$this->css_to_file = new Kirki_CSS_To_File();
// If we succesd, load this file.
$failed = get_transient( 'kirki_css_write_to_file_failed' );
// If writing CSS to file hasn't failed, just enqueue this file.
if ( ! $failed ) {
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_compiled_file' ), $priority );
@@ -174,6 +175,9 @@ class Kirki_Modules_CSS {
// If we got this far then add styles inline.
add_action( 'wp_enqueue_scripts', array( $this, 'inline_dynamic_css' ), $priority );
// Admin styles, adds Gutenberg compatibility.
add_action( 'admin_enqueue_scripts', array( $this, 'inline_dynamic_css' ), $priority );
}
/**
@@ -183,9 +187,7 @@ class Kirki_Modules_CSS {
* @since 3.0.0
*/
public function enqueue_compiled_file() {
wp_enqueue_style( 'kirki-styles', $this->css_to_file->get_url(), array(), $this->css_to_file->get_timestamp() );
}
/**
* Adds inline styles.
@@ -267,6 +269,7 @@ class Kirki_Modules_CSS {
}
if ( true === apply_filters( "kirki_{$config_id}_css_skip_hidden", true ) ) {
// Only continue if field dependencies are met.
if ( ! empty( $field['required'] ) ) {
$valid = true;
@@ -316,4 +319,16 @@ class Kirki_Modules_CSS {
public static function add_fontawesome_script() {
self::$enqueue_fa = true;
}
/**
* Check if FontAwesome should be loaded.
*
* @static
* @since 3.0.35
* @access public
* @return void
*/
public static function get_enqueue_fa() {
return self::$enqueue_fa;
}
}
@@ -64,7 +64,6 @@ class Kirki_Output {
* @param array $field The field.
*/
public function __construct( $config_id, $output, $value, $field ) {
$this->config_id = $config_id;
$this->value = $value;
$this->output = $output;
@@ -82,7 +81,6 @@ class Kirki_Output {
* @return string|array
*/
protected function apply_sanitize_callback( $output, $value ) {
if ( isset( $output['sanitize_callback'] ) && null !== $output['sanitize_callback'] ) {
// If the sanitize_callback is invalid, return the value.
@@ -91,9 +89,7 @@ class Kirki_Output {
}
return call_user_func( $output['sanitize_callback'], $this->value );
}
return $value;
}
/**
@@ -104,7 +100,6 @@ class Kirki_Output {
* @return string|array
*/
protected function apply_value_pattern( $output, $value ) {
if ( isset( $output['value_pattern'] ) && ! empty( $output['value_pattern'] ) && is_string( $output['value_pattern'] ) ) {
if ( ! is_array( $value ) ) {
$value = str_replace( '$', $value, $output['value_pattern'] );
@@ -244,6 +239,18 @@ class Kirki_Output {
}
$value = $this->process_value( $value, $output );
if ( is_admin() && ! is_customize_preview() ) {
// Check if this is an admin style.
if ( ! isset( $output['context'] ) || ! in_array( 'editor', $output['context'] ) ) {
continue;
}
} elseif ( isset( $output['context'] ) && ! in_array( 'front', $output['context'] ) ) {
// Check if this is a frontend style.
continue;
}
$this->process_output( $output, $value );
}
}
@@ -22,7 +22,6 @@ class Kirki_Output_Field_Background extends Kirki_Output {
* @param array $value The field's value.
*/
protected function process_output( $output, $value ) {
$output = wp_parse_args(
$output,
array(
@@ -22,7 +22,6 @@ class Kirki_Output_Field_Dimensions extends Kirki_Output {
* @param array $value The field's value.
*/
protected function process_output( $output, $value ) {
$output = wp_parse_args(
$output, array(
'element' => '',
@@ -22,7 +22,6 @@ class Kirki_Output_Field_Image extends Kirki_Output {
* @param array $value The field's value.
*/
protected function process_output( $output, $value ) {
if ( ! isset( $output['element'] ) || ! isset( $output['property'] ) ) {
return;
}
@@ -22,7 +22,6 @@ class Kirki_Output_Field_Multicolor extends Kirki_Output {
* @param array $value The field's value.
*/
protected function process_output( $output, $value ) {
foreach ( $value as $key => $sub_value ) {
// If "element" is not defined, there's no reason to continue.
@@ -22,7 +22,6 @@ class Kirki_Output_Field_Typography extends Kirki_Output {
* @param array $value The field's value.
*/
protected function process_output( $output, $value ) {
$output['media_query'] = ( isset( $output['media_query'] ) ) ? $output['media_query'] : 'global';
$output['element'] = ( isset( $output['element'] ) ) ? $output['element'] : 'body';
$output['prefix'] = ( isset( $output['prefix'] ) ) ? $output['prefix'] : '';
@@ -20,16 +20,13 @@ class Kirki_Output_Property_Background_Image extends Kirki_Output_Property {
* @access protected
*/
protected function process_value() {
if ( is_array( $this->value ) && isset( $this->value['url'] ) ) {
$this->value = $this->value['url'];
}
if ( false === strpos( $this->value, 'gradient' ) && false === strpos( $this->value, 'url(' ) ) {
if ( empty( $this->value ) ) {
return;
}
if ( preg_match( '/^\d+$/', $this->value ) ) {
$this->value = 'url("' . set_url_scheme( wp_get_attachment_url( $this->value ) ) . '")';
} else {
@@ -20,7 +20,6 @@ class Kirki_Output_Property_Background_Position extends Kirki_Output_Property {
* @access protected
*/
protected function process_value() {
$this->value = trim( $this->value );
// If you use calc() there, I suppose you know what you're doing.
@@ -20,7 +20,6 @@ class Kirki_Output_Property_Font_Family extends Kirki_Output_Property {
* @access protected
*/
protected function process_value() {
$google_fonts_array = Kirki_Fonts::get_google_fonts();
$backup_fonts = Kirki_Fonts::get_backup_fonts();
@@ -38,12 +38,16 @@ class Kirki_Modules_Custom_Sections {
* @since 3.0.0
*/
protected function __construct() {
// Register the new section types.
add_filter( 'kirki_section_types', array( $this, 'set_section_types' ) );
// Register the new panel types.
add_filter( 'kirki_panel_types', array( $this, 'set_panel_types' ) );
// Include the section-type files.
add_action( 'customize_register', array( $this, 'include_sections_and_panels' ) );
// Enqueue styles & scripts.
add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_scrips' ), 999 );
}
@@ -73,14 +77,12 @@ class Kirki_Modules_Custom_Sections {
* @return array
*/
public function set_section_types( $section_types ) {
$new_types = array(
'kirki-default' => 'Kirki_Sections_Default_Section',
'kirki-expanded' => 'Kirki_Sections_Expanded_Section',
'kirki-nested' => 'Kirki_Sections_Nested_Section',
);
return array_merge( $section_types, $new_types );
}
/**
@@ -92,12 +94,10 @@ class Kirki_Modules_Custom_Sections {
* @return array
*/
public function set_panel_types( $panel_types ) {
$new_types = array(
'kirki-nested' => 'Kirki_Panels_Nested_Panel',
);
return array_merge( $panel_types, $new_types );
}
/**
@@ -143,7 +143,6 @@ class Kirki_Modules_Custom_Sections {
}
}
}
}
/**
@@ -153,10 +152,7 @@ class Kirki_Modules_Custom_Sections {
* @since 3.0.0
*/
public function enqueue_scrips() {
wp_enqueue_style( 'kirki-custom-sections', trailingslashit( Kirki::$url ) . 'modules/custom-sections/sections.css', array(), KIRKI_VERSION );
wp_enqueue_script( 'kirki-custom-sections', trailingslashit( Kirki::$url ) . 'modules/custom-sections/sections.js', array( 'jquery', 'customize-base', 'customize-controls' ), KIRKI_VERSION, false );
}
}
@@ -40,7 +40,6 @@ class Kirki_Panels_Nested_Panel extends WP_Customize_Panel {
* @return array The array to be exported to the client as JSON.
*/
public function json() {
$array = wp_array_slice_assoc(
(array) $this, array(
'id',
@@ -21,5 +21,4 @@ class Kirki_Sections_Expanded_Section extends WP_Customize_Section {
* @var string
*/
public $type = 'kirki-expanded';
}
@@ -40,7 +40,6 @@ class Kirki_Sections_Nested_Section extends WP_Customize_Section {
* @return array The array to be exported to the client as JSON.
*/
public function json() {
$array = wp_array_slice_assoc(
(array) $this, array(
'id',
@@ -58,10 +57,10 @@ class Kirki_Sections_Nested_Section extends WP_Customize_Section {
$array['active'] = $this->active();
$array['instanceNumber'] = $this->instance_number;
$array['customizeAction'] = esc_attr__( 'Customizing', 'kirki' );
$array['customizeAction'] = esc_html__( 'Customizing', 'kirki' );
if ( $this->panel ) {
/* translators: The title. */
$array['customizeAction'] = sprintf( esc_attr__( 'Customizing &#9656; %s', 'kirki' ), esc_html( $this->manager->get_panel( $this->panel )->title ) );
$array['customizeAction'] = sprintf( esc_html__( 'Customizing &#9656; %s', 'kirki' ), esc_html( $this->manager->get_panel( $this->panel )->title ) );
}
return $array;
}
@@ -67,7 +67,6 @@ class Kirki_Modules_Customizer_Branding {
* @since 3.0.0
*/
public function customize_controls_print_scripts() {
$config = apply_filters( 'kirki_config', array() );
$vars = array(
'logoImage' => '',
@@ -64,7 +64,6 @@ class Kirki_Modules_Customizer_Styling {
* @access public
*/
public function custom_css() {
$config = apply_filters( 'kirki_config', array() );
if ( ! isset( $config['color_accent'] ) && ! isset( $config['color_back'] ) ) {
return;
@@ -117,9 +116,9 @@ class Kirki_Modules_Customizer_Styling {
#customize-control-changeset_preview_link input,
#customize-control-changeset_scheduled_date,
.wp-core-ui .wp-full-overlay .collapse-sidebar {
background: <?php echo esc_attr( $back ); ?>;
background-color: <?php echo esc_attr( $back ); ?>;
color: <?php echo esc_attr( $text_on_back ); ?>;
background: <?php echo esc_html( $back ); ?>;
background-color: <?php echo esc_html( $back ); ?>;
color: <?php echo esc_html( $text_on_back ); ?>;
}
<?php if ( $back ) : ?>
@@ -136,8 +135,8 @@ class Kirki_Modules_Customizer_Styling {
#customize-sidebar-outer-content {
border-left-color: <?php echo esc_attr( $border_on_back ); ?>;
border-right-color: <?php echo esc_attr( $border_on_back ); ?>;
border-left-color: <?php echo esc_html( $border_on_back ); ?>;
border-right-color: <?php echo esc_html( $border_on_back ); ?>;
}
#customize-controls .customize-info .panel-title,
@@ -145,70 +144,70 @@ class Kirki_Modules_Customizer_Styling {
#customize-controls .customize-pane-child h3.customize-section-title,
.customize-control,
#customize-controls .description {
color: <?php echo esc_attr( $text_on_back ); ?>;
color: <?php echo esc_html( $text_on_back ); ?>;
}
#customize-controls .customize-info,
#customize-header-actions,
.customize-section-title {
border-bottom-color: <?php echo esc_attr( $border_on_back ); ?>;
border-bottom-color: <?php echo esc_html( $border_on_back ); ?>;
}
.wp-full-overlay-sidebar .wp-full-overlay-header,
.customize-controls-close,
.expanded .wp-full-overlay-footer {
color: <?php echo esc_attr( $text_on_back ); ?>;
background-color: <?php echo esc_attr( $back_on_back ); ?>;
border-color: <?php echo esc_attr( $border_on_back ); ?>;
color: <?php echo esc_html( $text_on_back ); ?>;
background-color: <?php echo esc_html( $back_on_back ); ?>;
border-color: <?php echo esc_html( $border_on_back ); ?>;
}
.accordion-section,
#customize-theme-controls .customize-pane-child.accordion-section-content {
background: <?php echo esc_attr( $back_on_back ); ?>;
background: <?php echo esc_html( $back_on_back ); ?>;
}
#accordion-section-themes+.control-section,
#customize-theme-controls .control-section:last-of-type.open,
#customize-theme-controls .control-section:last-of-type > .accordion-section-title,
#customize-theme-controls .control-section.open {
border-bottom-color: <?php echo esc_attr( $border_on_back ); ?>;
border-top-color: <?php echo esc_attr( $border_on_back ); ?>;
border-bottom-color: <?php echo esc_html( $border_on_back ); ?>;
border-top-color: <?php echo esc_html( $border_on_back ); ?>;
}
#customize-theme-controls .accordion-section-title {
border-bottom-color: <?php echo esc_attr( $border_on_back ); ?>;
border-left-color: <?php echo esc_attr( $border_on_back ); ?>;
border-bottom-color: <?php echo esc_html( $border_on_back ); ?>;
border-left-color: <?php echo esc_html( $border_on_back ); ?>;
}
#customize-theme-controls .control-section-themes .accordion-section-title,
#customize-theme-controls .control-section-themes .accordion-section-title:hover {
border-bottom-color: <?php echo esc_attr( $border_on_back ); ?>;
border-top-color: <?php echo esc_attr( $border_on_back ); ?>;
border-bottom-color: <?php echo esc_attr( $border_on_back ); ?>;
border-bottom-color: <?php echo esc_html( $border_on_back ); ?>;
border-top-color: <?php echo esc_html( $border_on_back ); ?>;
border-bottom-color: <?php echo esc_html( $border_on_back ); ?>;
}
#customize-theme-controls .accordion-section-title:after {
color: <?php echo esc_attr( $arrows_on_back ); ?>;
color: <?php echo esc_html( $arrows_on_back ); ?>;
}
.wp-core-ui .button,
.wp-core-ui .button-secondary {
background-color: <?php echo esc_attr( $back ); ?>;
border-color: <?php echo esc_attr( $border_on_back ); ?>;
box-shadow: 0 1px 0 <?php echo esc_attr( $border_on_back ); ?>;
-webkit-box-shadow: 0 1px 0 <?php echo esc_attr( $border_on_back ); ?>;
text-shadow: 0 -1px 1px <?php echo esc_attr( $border_on_back ); ?>, 1px 0 1px <?php echo esc_attr( $border_on_back ); ?>, 0 1px 1px <?php echo esc_attr( $border_on_back ); ?>, -1px 0 1px <?php echo esc_attr( $border_on_back ); ?>;
color: <?php echo esc_attr( $text_on_back ); ?>;
background-color: <?php echo esc_html( $back ); ?>;
border-color: <?php echo esc_html( $border_on_back ); ?>;
box-shadow: 0 1px 0 <?php echo esc_html( $border_on_back ); ?>;
-webkit-box-shadow: 0 1px 0 <?php echo esc_html( $border_on_back ); ?>;
text-shadow: 0 -1px 1px <?php echo esc_html( $border_on_back ); ?>, 1px 0 1px <?php echo esc_html( $border_on_back ); ?>, 0 1px 1px <?php echo esc_html( $border_on_back ); ?>, -1px 0 1px <?php echo esc_html( $border_on_back ); ?>;
color: <?php echo esc_html( $text_on_back ); ?>;
}
@media screen and (max-width: 640px) {
.customize-controls-preview-toggle{
background-color: <?php echo esc_attr( $back ); ?>;
border-color: <?php echo esc_attr( $border_on_back ); ?>;
box-shadow:0 1px 0 <?php echo esc_attr( $border_on_back ); ?>;
-webkit-box-shadow:0 1px 0 <?php echo esc_attr( $border_on_back ); ?>;
text-shadow:0 -1px 1px <?php echo esc_attr( $border_on_back ); ?>, 1px 0 1px <?php echo esc_attr( $border_on_back ); ?>, 0 1px 1px <?php echo esc_attr( $border_on_back ); ?>, -1px 0 1px <?php echo esc_attr( $border_on_back ); ?>;
color: <?php echo esc_attr( $text_on_back ); ?>;
background-color: <?php echo esc_html( $back ); ?>;
border-color: <?php echo esc_html( $border_on_back ); ?>;
box-shadow:0 1px 0 <?php echo esc_html( $border_on_back ); ?>;
-webkit-box-shadow:0 1px 0 <?php echo esc_html( $border_on_back ); ?>;
text-shadow:0 -1px 1px <?php echo esc_html( $border_on_back ); ?>, 1px 0 1px <?php echo esc_html( $border_on_back ); ?>, 0 1px 1px <?php echo esc_html( $border_on_back ); ?>, -1px 0 1px <?php echo esc_html( $border_on_back ); ?>;
color: <?php echo esc_html( $text_on_back ); ?>;
}
}
@@ -222,12 +221,12 @@ class Kirki_Modules_Customizer_Styling {
.wp-core-ui .button-secondary:hover,
.customize-panel-back,
.customize-section-back {
background-color: <?php echo esc_attr( $back_on_back ); ?>;
border-color: <?php echo esc_attr( $border_on_back ); ?>;
box-shadow: 0 1px 0 <?php echo esc_attr( $border_on_back ); ?>;
-webkit-box-shadow: 0 1px 0 <?php echo esc_attr( $border_on_back ); ?>;
text-shadow: 0 -1px 1px <?php echo esc_attr( $border_on_back ); ?>, 1px 0 1px <?php echo esc_attr( $border_on_back ); ?>, 0 1px 1px <?php echo esc_attr( $border_on_back ); ?>, -1px 0 1px <?php echo esc_attr( $border_on_back ); ?>;
color: <?php echo esc_attr( $text_on_back ); ?>;
background-color: <?php echo esc_html( $back_on_back ); ?>;
border-color: <?php echo esc_html( $border_on_back ); ?>;
box-shadow: 0 1px 0 <?php echo esc_html( $border_on_back ); ?>;
-webkit-box-shadow: 0 1px 0 <?php echo esc_html( $border_on_back ); ?>;
text-shadow: 0 -1px 1px <?php echo esc_html( $border_on_back ); ?>, 1px 0 1px <?php echo esc_html( $border_on_back ); ?>, 0 1px 1px <?php echo esc_html( $border_on_back ); ?>, -1px 0 1px <?php echo esc_html( $border_on_back ); ?>;
color: <?php echo esc_html( $text_on_back ); ?>;
}
@media screen and (max-width: 640px) {
@@ -235,42 +234,42 @@ class Kirki_Modules_Customizer_Styling {
.customize-controls-preview-toggle.hover,
.customize-controls-preview-toggle:focus,
.customize-controls-preview-toggle:hover {
background-color: <?php echo esc_attr( $back_on_back ); ?>;
border-color: <?php echo esc_attr( $border_on_back ); ?>;
box-shadow: 0 1px 0 <?php echo esc_attr( $border_on_back ); ?>;
-webkit-box-shadow: 0 1px 0 <?php echo esc_attr( $border_on_back ); ?>;
text-shadow: 0 -1px 1px <?php echo esc_attr( $border_on_back ); ?>, 1px 0 1px <?php echo esc_attr( $border_on_back ); ?>, 0 1px 1px <?php echo esc_attr( $border_on_back ); ?>, -1px 0 1px <?php echo esc_attr( $border_on_back ); ?>;
color:<?php echo esc_attr( $text_on_back ); ?>;
background-color: <?php echo esc_html( $back_on_back ); ?>;
border-color: <?php echo esc_html( $border_on_back ); ?>;
box-shadow: 0 1px 0 <?php echo esc_html( $border_on_back ); ?>;
-webkit-box-shadow: 0 1px 0 <?php echo esc_html( $border_on_back ); ?>;
text-shadow: 0 -1px 1px <?php echo esc_html( $border_on_back ); ?>, 1px 0 1px <?php echo esc_html( $border_on_back ); ?>, 0 1px 1px <?php echo esc_html( $border_on_back ); ?>, -1px 0 1px <?php echo esc_html( $border_on_back ); ?>;
color:<?php echo esc_html( $text_on_back ); ?>;
}
}
.customize-control-kirki-background .background-attachment .buttonset .switch-label,
.customize-control-kirki-background .background-size .buttonset .switch-label,
.customize-control-kirki-radio-buttonset .buttonset .switch-label {
color: <?php echo esc_attr( $text_on_back ); ?>;
color: <?php echo esc_html( $text_on_back ); ?>;
}
.wp-color-result {
border-color: <?php echo esc_attr( $border_on_back ); ?>;
-webkit-box-shadow: 0 1px 0 <?php echo esc_attr( $border_on_back ); ?>;
box-shadow: 0 1px 0 <?php echo esc_attr( $border_on_back ); ?>;
border-color: <?php echo esc_html( $border_on_back ); ?>;
-webkit-box-shadow: 0 1px 0 <?php echo esc_html( $border_on_back ); ?>;
box-shadow: 0 1px 0 <?php echo esc_html( $border_on_back ); ?>;
}
.wp-color-result:focus,
.wp-color-result:hover {
border-color: <?php echo esc_attr( $border_on_back ); ?>;
background: <?php echo esc_attr( $back_on_back ); ?>;
border-color: <?php echo esc_html( $border_on_back ); ?>;
background: <?php echo esc_html( $back_on_back ); ?>;
}
.wp-color-result:after {
border-color: <?php echo esc_attr( $border_on_back ); ?>;
background: <?php echo esc_attr( $back ); ?>;
color: <?php echo esc_attr( $text_on_back ); ?>;
border-color: <?php echo esc_html( $border_on_back ); ?>;
background: <?php echo esc_html( $back ); ?>;
color: <?php echo esc_html( $text_on_back ); ?>;
}
.wp-color-result:focus:after,
.wp-color-result:hover:after {
color: <?php echo esc_attr( $text_on_back ); ?>;
color: <?php echo esc_html( $text_on_back ); ?>;
}
.customize-control input[type=tel],
@@ -285,29 +284,29 @@ class Kirki_Modules_Customizer_Styling {
.customize-control select,
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
background: <?php echo esc_attr( $back ); ?>;
border-color: <?php echo esc_attr( $border_on_back ); ?>;
color: <?php echo esc_attr( $text_on_back ); ?>;
background: <?php echo esc_html( $back ); ?>;
border-color: <?php echo esc_html( $border_on_back ); ?>;
color: <?php echo esc_html( $text_on_back ); ?>;
}
.customize-control-kirki-slider input[type=range]::-webkit-slider-thumb {
background-color:<?php echo esc_attr( $accent ); ?>;
background-color:<?php echo esc_html( $accent ); ?>;
}
.customize-control-kirki-slider input[type=range]::-moz-range-thumb {
background-color: <?php echo esc_attr( $accent ); ?>;
background-color: <?php echo esc_html( $accent ); ?>;
}
.customize-control-kirki-slider input[type=range]::-ms-thumb {
background-color: <?php echo esc_attr( $accent ); ?>;
background-color: <?php echo esc_html( $accent ); ?>;
}
.customize-control-kirki-slider input[type=range] {
background: <?php echo esc_attr( $border_on_back ); ?>;
background: <?php echo esc_html( $border_on_back ); ?>;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
color:<?php echo esc_attr( $text_on_back ); ?>;
color:<?php echo esc_html( $text_on_back ); ?>;
}
.wp-full-overlay-footer .devices {
@@ -318,7 +317,7 @@ class Kirki_Modules_Customizer_Styling {
}
.kirki-reset-section .dashicons {
color: <?php echo esc_attr( $back_on_back ); ?>;
color: <?php echo esc_html( $back_on_back ); ?>;
}
#customize-controls .control-section .accordion-section-title:focus,
@@ -329,72 +328,72 @@ class Kirki_Modules_Customizer_Styling {
.customize-panel-back:hover,
.customize-section-back:focus,
.customize-section-back:hover {
background: <?php echo esc_attr( $hover_on_back ); ?>;
color: <?php echo esc_attr( $accent ); ?>;
border-left-color: <?php echo esc_attr( $accent ); ?>;
background: <?php echo esc_html( $hover_on_back ); ?>;
color: <?php echo esc_html( $accent ); ?>;
border-left-color: <?php echo esc_html( $accent ); ?>;
}
.customize-controls-close:hover {
background-color: <?php echo esc_attr( $back ); ?>;
color: <?php echo esc_attr( $accent ); ?>;
border-color: <?php echo esc_attr( $accent ); ?>;
background-color: <?php echo esc_html( $back ); ?>;
color: <?php echo esc_html( $accent ); ?>;
border-color: <?php echo esc_html( $accent ); ?>;
}
#customize-theme-controls .control-section .accordion-section-title:focus:after,
#customize-theme-controls .control-section .accordion-section-title:hover:after,
#customize-theme-controls .control-section.open .accordion-section-title:after,
#customize-theme-controls .control-section:hover>.accordion-section-title:after {
color: <?php echo esc_attr( $accent ); ?>;
color: <?php echo esc_html( $accent ); ?>;
}
.wp-core-ui .button.button-primary {
background-color: <?php echo esc_attr( $accent ); ?>;
border-color: <?php echo esc_attr( $border_on_accent ); ?>;
box-shadow: 0 1px 0 <?php echo esc_attr( $border_on_accent ); ?>;
-webkit-box-shadow: 0 1px 0 <?php echo esc_attr( $border_on_accent ); ?>;
text-shadow: 0 -1px 1px <?php echo esc_attr( $border_on_accent ); ?>, 1px 0 1px <?php echo esc_attr( $border_on_accent ); ?>, 0 1px 1px <?php echo esc_attr( $border_on_accent ); ?>, -1px 0 1px <?php echo esc_attr( $border_on_accent ); ?>;
color: <?php echo esc_attr( $text_on_accent ); ?>;
background-color: <?php echo esc_html( $accent ); ?>;
border-color: <?php echo esc_html( $border_on_accent ); ?>;
box-shadow: 0 1px 0 <?php echo esc_html( $border_on_accent ); ?>;
-webkit-box-shadow: 0 1px 0 <?php echo esc_html( $border_on_accent ); ?>;
text-shadow: 0 -1px 1px <?php echo esc_html( $border_on_accent ); ?>, 1px 0 1px <?php echo esc_html( $border_on_accent ); ?>, 0 1px 1px <?php echo esc_html( $border_on_accent ); ?>, -1px 0 1px <?php echo esc_html( $border_on_accent ); ?>;
color: <?php echo esc_html( $text_on_accent ); ?>;
}
.wp-core-ui .button.button-primary.focus,
.wp-core-ui .button.button-primary.hover,
.wp-core-ui .button.button-primary:focus,
.wp-core-ui .button.button-primary:hover {
background-color: <?php echo esc_attr( $accent ); ?>;
border-color: <?php echo esc_attr( $border_on_accent ); ?>;
box-shadow: 0 1px 0 <?php echo esc_attr( $border_on_accent ); ?>;
-webkit-box-shadow: 0 1px 0 <?php echo esc_attr( $border_on_accent ); ?>;
text-shadow: 0 -1px 1px <?php echo esc_attr( $border_on_accent ); ?>, 1px 0 1px <?php echo esc_attr( $border_on_accent ); ?>, 0 1px 1px <?php echo esc_attr( $border_on_accent ); ?>, -1px 0 1px <?php echo esc_attr( $border_on_accent ); ?>;
color: <?php echo esc_attr( $text_on_accent ); ?>;
background-color: <?php echo esc_html( $accent ); ?>;
border-color: <?php echo esc_html( $border_on_accent ); ?>;
box-shadow: 0 1px 0 <?php echo esc_html( $border_on_accent ); ?>;
-webkit-box-shadow: 0 1px 0 <?php echo esc_html( $border_on_accent ); ?>;
text-shadow: 0 -1px 1px <?php echo esc_html( $border_on_accent ); ?>, 1px 0 1px <?php echo esc_html( $border_on_accent ); ?>, 0 1px 1px <?php echo esc_html( $border_on_accent ); ?>, -1px 0 1px <?php echo esc_html( $border_on_accent ); ?>;
color: <?php echo esc_html( $text_on_accent ); ?>;
}
.wp-core-ui .button.button-primary-disabled,
.wp-core-ui .button.button-primary.disabled,
.wp-core-ui .button.button-primary:disabled,
.wp-core-ui .button.button-primary[disabled] {
background-color: <?php echo esc_attr( $accent_disabled ); ?> !important;
border-color: <?php echo esc_attr( $border_on_accent_disabled ); ?> !important;
box-shadow: 0 1px 0 <?php echo esc_attr( $border_on_accent_disabled ); ?> !important;
-webkit-box-shadow: 0 1px 0 <?php echo esc_attr( $border_on_accent_disabled ); ?> !important;
text-shadow: 0 -1px 1px <?php echo esc_attr( $border_on_accent_disabled ); ?>, 1px 0 1px <?php echo esc_attr( $border_on_accent_disabled ); ?>, 0 1px 1px <?php echo esc_attr( $border_on_accent_disabled ); ?>, -1px 0 1px <?php echo esc_attr( $border_on_accent_disabled ); ?> !important;
color: <?php echo esc_attr( $text_on_accent_disabled ); ?> !important;
background-color: <?php echo esc_html( $accent_disabled ); ?> !important;
border-color: <?php echo esc_html( $border_on_accent_disabled ); ?> !important;
box-shadow: 0 1px 0 <?php echo esc_html( $border_on_accent_disabled ); ?> !important;
-webkit-box-shadow: 0 1px 0 <?php echo esc_html( $border_on_accent_disabled ); ?> !important;
text-shadow: 0 -1px 1px <?php echo esc_html( $border_on_accent_disabled ); ?>, 1px 0 1px <?php echo esc_html( $border_on_accent_disabled ); ?>, 0 1px 1px <?php echo esc_html( $border_on_accent_disabled ); ?>, -1px 0 1px <?php echo esc_html( $border_on_accent_disabled ); ?> !important;
color: <?php echo esc_html( $text_on_accent_disabled ); ?> !important;
}
input[type=checkbox]:checked:before {
color: <?php echo esc_attr( $accent ); ?>;
color: <?php echo esc_html( $accent ); ?>;
}
.select2-container--default .select2-results__option--highlighted[aria-selected] {
background-color: <?php echo esc_attr( $accent ); ?>;
color: <?php echo esc_attr( $text_on_accent ); ?>;
background-color: <?php echo esc_html( $accent ); ?>;
color: <?php echo esc_html( $text_on_accent ); ?>;
}
.customize-control-kirki-radio-buttonset .buttonset .switch-input:checked + .switch-label,
.customize-control-kirki-background .background-attachment .buttonset .switch-input:checked + .switch-label,
.customize-control-kirki-background .background-size .buttonset .switch-input:checked + .switch-label {
background-color: <?php echo esc_attr( $accent ); ?>;
border-color: <?php echo esc_attr( $border_on_accent ); ?>;
color: <?php echo esc_attr( $text_on_accent ); ?>;
background-color: <?php echo esc_html( $accent ); ?>;
border-color: <?php echo esc_html( $border_on_accent ); ?>;
color: <?php echo esc_html( $text_on_accent ); ?>;
}
.notice,
@@ -405,16 +404,16 @@ class Kirki_Modules_Customizer_Styling {
<?php if ( isset( $config['width'] ) ) : ?>
.wp-full-overlay-sidebar {
width: <?php echo esc_attr( $config['width'] ); ?>;
width: <?php echo esc_html( $config['width'] ); ?>;
}
.expanded .wp-full-overlay-footer {
width: <?php echo esc_attr( $config['width'] ); ?>;
width: <?php echo esc_html( $config['width'] ); ?>;
}
.wp-full-overlay.expanded {
margin-left: <?php echo esc_attr( $config['width'] ); ?>;
margin-left: <?php echo esc_html( $config['width'] ); ?>;
}
.wp-full-overlay.collapsed .wp-full-overlay-sidebar {
margin-left: -<?php echo esc_attr( $config['width'] ); ?>;
margin-left: -<?php echo esc_html( $config['width'] ); ?>;
}
<?php endif; ?>
</style>
@@ -65,7 +65,6 @@ class Kirki_Modules_Field_Dependencies {
* @return void
*/
public function field_dependencies() {
wp_enqueue_script( 'kirki_field_dependencies', trailingslashit( Kirki::$url ) . 'modules/field-dependencies/field-dependencies.js', array( 'jquery', 'customize-base', 'customize-controls' ), KIRKI_VERSION, true );
}
}
@@ -0,0 +1,355 @@
<?php
/**
* Gutenberg integration for Kirki.
*
* This class contains methods for integrating Kirki with
* the new WordPress core editor, Gutenberg. It provides
* fonts and styles to be output by the theme.
*
* @package Kirki
* @category Core
* @author Tim Elsass
* @copyright Copyright (c) 2017, Aristeides Stathopoulos
* @license https://opensource.org/licenses/MIT
* @since 3.0.35
*/
/**
* Wrapper class for static methods.
*
* @since 3.0.35
*/
class Kirki_Modules_Gutenberg {
/**
* The object instance.
*
* @static
* @access private
* @since 3.0.35
* @var object
*/
private static $instance;
/**
* Configuration reference.
*
* @access public
* @since 3.0.35
* @var object $configs
*/
private $configs;
/**
* Whether feature is enabled.
*
* @access public
* @since 3.0.35
* @var bool $enabled
*/
public $enabled;
/**
* CSS Module reference.
*
* @access public
* @since 3.0.35
* @var object $modules_css
*/
private $modules_css;
/**
* Webfonts Module reference.
*
* @access public
* @since 3.0.35
* @var object $modules_webfonts
*/
private $modules_webfonts;
/**
* Google Fonts reference.
*
* @access public
* @since 3.0.35
* @var object $google_fonts
*/
private $google_fonts;
/**
* Webfonts Loader Module reference.
*
* @access public
* @since 3.0.35
* @var object $modules_webfonts
*/
private $modules_webfont_loader;
/**
* Constructor.
*
* @access protected
* @since 3.0.0
*/
protected function __construct() {
add_action( 'admin_init', array( $this, 'init' ) );
}
/**
* Initialize Module.
*
* Sets class properties and add necessary hooks.
*
* @since 3.0.35
*/
public function init() {
$this->set_configs();
$this->set_enabled();
$this->set_modules_css();
$this->set_google_fonts();
$this->set_modules_webfonts();
$this->set_modules_webfont_loader();
$this->add_hooks();
}
/**
* Gets an instance of this object.
* Prevents duplicate instances which avoid artefacts and improves performance.
*
* @static
* @access public
* @since 3.0.0
* @return object
*/
public static function get_instance() {
if ( ! self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Add hooks for Gutenberg editor integration.
*
* @access protected
* @since 3.0.35
*/
protected function add_hooks() {
if ( ! $this->is_disabled() ) {
add_action( 'after_setup_theme', array( $this, 'add_theme_support' ), 999 );
add_action( 'enqueue_block_editor_assets', array( $this, 'load_fonts' ) );
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_fontawesome' ) );
add_filter( 'block_editor_settings', array( $this, 'enqueue' ) );
}
}
/**
* Add theme support for editor styles.
*
* This checks if theme has declared editor-styles support
* already, and if not present, declares it. Hooked late.
*
* @access public
* @since 3.0.35
*/
public function add_theme_support() {
if ( true !== get_theme_support( 'editor-styles' ) ) {
add_theme_support( 'editor-styles' );
}
}
/**
* Enqueue styles to Gutenberg Editor.
*
* @access public
* @since 3.0.35
*/
public function enqueue( $settings ) {
$styles = $this->get_styles();
if ( ! empty( $styles ) ) {
$settings['styles'][] = array( 'css' => $styles );
}
return $settings;
}
/**
* Gets the styles to add to Gutenberg Editor.
*
* @access public
* @since 3.0.35
*
* @return string $styles String containing inline styles to add to Gutenberg.
*/
public function get_styles() {
$styles = null;
foreach ( $this->configs as $config_id => $args ) {
if ( true === $this->is_disabled( $args ) ) {
continue;
}
$modules_css = $this->modules_css;
$styles = $modules_css::loop_controls( $config_id );
$styles = apply_filters( "kirki_gutenberg_{$config_id}_dynamic_css", $styles );
if ( empty( $styles ) ) {
continue;
}
}
return $styles;
}
/**
* Helper method to check if feature is disabled.
*
* Feature can be disabled by KIRKI_NO_OUTPUT constant,
* gutenbeg_support argument, and disabled output argument.
*
* @access public
* @since 3.0.35
*
* @return bool $disabled Is gutenberg integration feature disabled?
*/
private function is_disabled( $args = array() ) {
if ( defined( 'KIRKI_NO_OUTPUT' ) && true === KIRKI_NO_OUTPUT ) {
return true;
}
if ( ! empty( $args ) ) {
if ( isset( $args['disable_output'] ) && true === $args['disable_output'] ) {
return true;
}
if ( ! isset( $args['gutenberg_support'] ) || true !== $args['gutenberg_support'] ) {
return true;
}
}
return false;
}
/**
* Load Fonts in Gutenberg Editor.
*
* @access public
* @since 3.0.35
*/
public function load_fonts() {
$modules_webfonts = $this->modules_webfonts;
$google_fonts = $this->google_fonts;
foreach ( $this->configs as $config_id => $args ) {
if ( $this->is_disabled( $args ) ) {
continue;
}
$this->modules_webfont_loader->set_load( true );
$this->modules_webfont_loader->enqueue_scripts();
$async = new Kirki_Modules_Webfonts_Async(
$config_id,
$modules_webfonts::get_instance(),
$google_fonts::get_instance()
);
$async->webfont_loader();
$async->webfont_loader_script();
$local_fonts = new Kirki_Modules_Webfonts_Local(
$modules_webfonts::get_instance(),
$google_fonts::get_instance()
);
$local_fonts->add_styles();
return;
}
}
/**
* Enqueue fontawesome in Gutenberg Editor.
*
* @access public
* @since 3.0.35
*/
public function enqueue_fontawesome() {
foreach ( $this->configs as $config_id => $args ) {
if ( $this->is_disabled( $args ) ) {
continue;
}
$modules_css = $this->modules_css;
if ( $modules_css::get_enqueue_fa() && apply_filters( 'kirki_load_fontawesome', true ) ) {
wp_enqueue_script( 'kirki-fontawesome-font', 'https://use.fontawesome.com/30858dc40a.js', array(), '4.0.7', true );
}
return;
}
}
/**
* Set class property for $configs.
*
* @access private
* @since 3.0.35
*/
private function set_configs() {
return $this->configs = Kirki::$config;
}
/**
* Set class property for $enabled.
*
* @access private
* @since 3.0.35
*/
private function set_enabled() {
$this->enabled = ! $this->is_disabled();
}
/**
* Set class property for $modules_css.
*
* @access private
* @since 3.0.35
*/
private function set_modules_css() {
$this->modules_css = Kirki_Modules_CSS::get_instance();
}
/**
* Set class property for $google_fonts.
*
* @access private
* @since 3.0.35
*/
private function set_google_fonts() {
$this->google_fonts = Kirki_Fonts_Google::get_instance();
}
/**
* Set class property for $modules_webfonts.
*
* @access private
* @since 3.0.35
*/
private function set_modules_webfonts() {
$this->modules_webfonts = Kirki_Modules_Webfonts::get_instance();
}
/**
* Set class property for $modules_webfont_loader.
*
* @access private
* @since 3.0.35
*/
private function set_modules_webfont_loader() {
$this->modules_webfont_loader = Kirki_Modules_Webfont_Loader::get_instance();
}
}
@@ -74,16 +74,13 @@ class Kirki_Modules_Icons {
* @param string $context Lowercase 'section' or 'panel'.
*/
public function add_icon( $id, $icon, $context = 'section' ) {
self::$icons[ $context ][ $id ] = trim( $icon );
}
/**
* Format the script in a way that will be compatible with WordPress.
*/
public function customize_controls_enqueue_scripts() {
$sections = Kirki::$sections;
$panels = Kirki::$panels;
@@ -103,6 +100,5 @@ class Kirki_Modules_Icons {
wp_enqueue_script( 'kirki_panel_and_section_icons', trailingslashit( Kirki::$url ) . 'modules/icons/icons.js', array( 'jquery', 'customize-base', 'customize-controls' ), KIRKI_VERSION, true );
wp_localize_script( 'kirki_panel_and_section_icons', 'kirkiIcons', self::$icons );
}
}
@@ -56,7 +56,6 @@ class Kirki_Modules_Loading {
* @since 3.0.0
*/
public function init() {
global $wp_customize;
if ( ! $wp_customize ) {
return;
@@ -70,7 +69,6 @@ class Kirki_Modules_Loading {
add_action( 'wp_footer', array( $this, 'add_loader_to_footer' ) );
add_action( 'wp_head', array( $this, 'add_loader_styles_to_header' ), 99 );
$this->remove_default_loading_styles();
}
/**
@@ -43,7 +43,6 @@ class Kirki_Modules_Post_Meta {
* @since 3.1.0
*/
protected function __construct() {
add_action( 'customize_preview_init', array( $this, 'customize_preview_init' ) );
add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_control_scripts' ) );
}
@@ -55,7 +54,6 @@ class Kirki_Modules_Post_Meta {
* @since 3.1.0
*/
public function enqueue_control_scripts() {
wp_enqueue_script( 'kirki_post_meta_previewed_controls', trailingslashit( Kirki::$url ) . 'modules/post-meta/customize-controls.js', array( 'jquery', 'customize-controls' ), KIRKI_VERSION, true );
}
@@ -66,7 +64,6 @@ class Kirki_Modules_Post_Meta {
* @since 3.1.0
*/
public function customize_preview_init() {
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_preview_scripts' ) );
}
@@ -77,7 +74,6 @@ class Kirki_Modules_Post_Meta {
* @since 3.1.0
*/
public function enqueue_preview_scripts() {
wp_enqueue_script( 'kirki_post_meta_previewed_preview', trailingslashit( Kirki::$url ) . 'modules/post-meta/customize-preview.js', array( 'jquery', 'customize-preview' ), KIRKI_VERSION, true );
$wp_scripts = wp_scripts();
@@ -19,6 +19,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* Adds styles to the customizer.
*/
class Kirki_Modules_PostMessage {
/**
* The object instance.
*
@@ -70,7 +71,6 @@ class Kirki_Modules_PostMessage {
* The rest is handled via JS.
*/
public function postmessage() {
wp_enqueue_script( 'kirki_auto_postmessage', trailingslashit( Kirki::$url ) . 'modules/postmessage/postmessage.js', array( 'jquery', 'customize-preview' ), KIRKI_VERSION, true );
$fields = Kirki::$fields;
foreach ( $fields as $field ) {
@@ -80,7 +80,6 @@ class Kirki_Modules_PostMessage {
}
$this->script = apply_filters( 'kirki_postmessage_script', $this->script );
wp_add_inline_script( 'kirki_auto_postmessage', $this->script, 'after' );
}
/**
@@ -91,7 +90,6 @@ class Kirki_Modules_PostMessage {
* @param array $args The arguments.
*/
protected function script( $args ) {
$script = 'wp.customize(\'' . $args['settings'] . '\',function(value){value.bind(function(newval){';
$add_css = false;
@@ -115,6 +113,7 @@ class Kirki_Modules_PostMessage {
$field = array(
'scripts' => array(),
);
// Loop through the js_vars and generate the script.
foreach ( $args['js_vars'] as $key => $js_var ) {
@@ -127,10 +126,12 @@ class Kirki_Modules_PostMessage {
}
}
if ( isset( $js_var['element'] ) ) {
// Array to string.
if ( is_array( $js_var['element'] ) ) {
$js_var['element'] = implode( ',', $js_var['element'] );
}
// Replace single quotes with double quotes to avoid issues with the compiled JS.
$js_var['element'] = str_replace( '\'', '"', $js_var['element'] );
}
@@ -173,7 +174,6 @@ class Kirki_Modules_PostMessage {
* @param array $args The arguments for this js_var.
*/
protected function script_html_var( $args ) {
$script = ( isset( $args['choice'] ) ) ? "newval=newval['{$args['choice']}'];" : '';
// Apply the value_pattern.
@@ -243,7 +243,6 @@ class Kirki_Modules_PostMessage {
* @param array $args The arguments for this js_var.
*/
protected function script_var_array( $args ) {
$script = ( 0 === $args['index_key'] ) ? 'css=\'\';' : '';
$property_script = '';
@@ -280,9 +279,11 @@ class Kirki_Modules_PostMessage {
// Mostly used for padding, margin & position properties.
$direction_script = 'if(_.contains([\'top\',\'bottom\',\'left\',\'right\'],subKey)){';
$direction_script .= 'css+=\'' . $args['element'] . '{' . $args['property'] . '-\'+subKey+\':\'+subValue+\'' . $args['units'] . $args['suffix'] . ';}\';}';
// Allows us to apply this just for a specific choice in the array of the values.
if ( '' !== $choice ) {
$choice_is_direction = ( false !== strpos( $choice, 'top' ) || false !== strpos( $choice, 'bottom' ) || false !== strpos( $choice, 'left' ) || false !== strpos( $choice, 'right' ) );
// The script.
$script .= 'if(\'' . $choice . '\'===subKey){';
$script .= ( $choice_is_direction ) ? $direction_script . 'else{' : '';
@@ -315,7 +316,6 @@ class Kirki_Modules_PostMessage {
* @param array $field The field arguments.
*/
protected function script_var_typography( $args, $field ) {
$args = $this->get_args( $args );
$script = '';
@@ -323,7 +323,7 @@ class Kirki_Modules_PostMessage {
// Load the font using WenFontloader.
// This is a bit ugly because wp_add_inline_script doesn't allow adding <script> directly.
$webfont_loader = 'sc=\'a\';jQuery(\'head\').append(sc.replace(\'a\',\'<\')+\'script>if(!_.isUndefined(WebFont)&&fontFamily){WebFont.load({google:{families:["\'+fontFamily.replace( /\"/g, \'&quot;\' )+\':\'+variant+\'cyrillic,cyrillic-ext,devanagari,greek,greek-ext,khmer,latin,latin-ext,vietnamese,hebrew,arabic,bengali,gujarati,tamil,telugu,thai"]}});}\'+sc.replace(\'a\',\'<\')+\'/script>\');';
$webfont_loader = 'sc=\'a\';jQuery(\'head\').append(sc.replace(\'a\',\'<\')+\'script>if(!_.isUndefined(WebFont)&&fontFamily){WebFont.load({google:{families:["\'+fontFamily.replace( /\"/g, \'&quot;\' )+\':\'+variant+\':cyrillic,cyrillic-ext,devanagari,greek,greek-ext,khmer,latin,latin-ext,vietnamese,hebrew,arabic,bengali,gujarati,tamil,telugu,thai"]}});}\'+sc.replace(\'a\',\'<\')+\'/script>\');';
// Add the css.
$css_build_array = array(
@@ -405,9 +405,7 @@ class Kirki_Modules_PostMessage {
* @return string
*/
private function before_script( $args ) {
$script = '';
if ( isset( $args['type'] ) ) {
switch ( $args['type'] ) {
case 'kirki-typography':
@@ -455,7 +453,6 @@ class Kirki_Modules_PostMessage {
$args['js_callback'][1] = '';
}
return $args;
}
/**
@@ -497,7 +494,6 @@ class Kirki_Modules_PostMessage {
* @return string|array A callable function or method.
*/
protected function get_callback( $args ) {
switch ( $args['type'] ) {
case 'kirki-background':
case 'kirki-dimensions':

Some files were not shown because too many files have changed in this diff Show More