Update to Kirki 4.0.22

This commit is contained in:
AlxMedia 2022-03-15 14:29:17 +01:00
parent 2b6ac38550
commit 78edeb1b25
492 changed files with 29668 additions and 39884 deletions

View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 kirki-framework
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,55 @@
# control-dashicons
## Installation
First, install the package using composer:
```bash
composer require kirki-framework/control-dashicons
```
Make sure you include the autoloader:
```php
require_once get_parent_theme_file_path( 'vendor/autoload.php' );
```
To add a control using the customizer API:
```php
/**
* Registers the control and whitelists it for JS templating.
*
* @since 1.0
* @param WP_Customize_Manager $wp_customize The WP_Customize_Manager object.
* @return void
*/
add_action( 'customize_register', function( $wp_customize ) {
$wp_customize->register_control_type( '\Kirki\Control\Dashicons' );
} );
/**
* Add Customizer settings & controls.
*
* @since 1.0
* @param WP_Customize_Manager $wp_customize The WP_Customize_Manager object.
* @return void
*/
add_action( 'customize_register', function( $wp_customize ) {
// Add setting.
$wp_customize->add_setting( 'my_control', [
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'default' => 'menu',
'transport' => 'refresh', // Or postMessage.
'sanitize_callback' => 'sanitize_text_field', // Or a custom sanitization callback.
] );
// Add control.
$wp_customize->add_control( new \Kirki\Control\Dashicons( $wp_customize, 'my_control', [
'label' => esc_html__( 'My Dashicons Control', 'theme_textdomain' ),
'section' => 'my_section',
] ) );
} );
```

View file

@ -0,0 +1,2 @@
.customize-control-kirki-dashicons{position:relative}.customize-control-kirki-dashicons label{display:inline-block;position:relative}.customize-control-kirki-dashicons .icons-wrapper{max-height:300px;overflow-y:scroll}.customize-control-kirki-dashicons .icons-wrapper h4{font-weight:300;margin:.7em 0}.customize-control-kirki-dashicons .icons-wrapper .dashicons{border:1px solid transparent;font-size:25px;height:25px;padding:3px;width:25px}.customize-control-kirki-dashicons .icons-wrapper input{display:none}.customize-control-kirki-dashicons .icons-wrapper input:checked+label .dashicons{border:1px solid #3498db;color:#000}
/*# sourceMappingURL=control.css.map */

View file

@ -0,0 +1,2 @@
wp.customize.controlConstructor["kirki-dashicons"]=wp.customize.kirkiDynamicControl.extend({});
//# sourceMappingURL=control.js.map

View file

@ -0,0 +1,140 @@
<?php
/**
* Customizer Control: dashicons.
*
* @package kirki-framework/control-dashicons
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @since 1.0
*/
namespace Kirki\Control;
use Kirki\URL;
use Kirki\Control\Base;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Dashicons control (modified radio).
*
* @since 1.0
*/
class Dashicons extends Base {
/**
* The control type.
*
* @access public
* @since 1.0
* @var string
*/
public $type = 'kirki-dashicons';
/**
* The version. Used in scripts & styles for cache-busting.
*
* @static
* @access public
* @since 1.0.2
* @var string
*/
public static $control_ver = '1.0';
/**
* Enqueue control related scripts/styles.
*
* @access public
* @since 1.0
* @return void
*/
public function enqueue() {
parent::enqueue();
// Enqueue the script.
wp_enqueue_script( 'kirki-control-dashicons', URL::get_from_path( dirname(dirname( __DIR__ )) . '/dist/control.js' ), [ 'jquery', 'customize-base', 'kirki-control-base' ], self::$control_ver, false );
// Enqueue the style.
wp_enqueue_style( 'kirki-control-dashicons-style', URL::get_from_path( dirname(dirname( __DIR__ )) . '/dist/control.css' ), [ 'dashicons' ], self::$control_ver );
}
/**
* Refresh the parameters passed to the JavaScript via JSON.
*
* @access public
* @since 1.0
* @return void
*/
public function to_json() {
parent::to_json();
$this->json['icons'] = \Kirki\Util\Dashicons::get_icons();
}
/**
* An Underscore (JS) template for this control's content (but not its container).
*
* Class variables for this control class are available in the `data` JS object;
* export custom variables by overriding {@see WP_Customize_Control::to_json()}.
*
* @see WP_Customize_Control::print_template()
*
* @access protected
* @since 1.0
* @return void
*/
protected function content_template() {
?>
<# if ( data.label ) { #><span class="customize-control-title">{{{ data.label }}}</span><# } #>
<# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><# } #>
<div class="icons-wrapper">
<# if ( ! _.isUndefined( data.choices ) && 1 < _.size( data.choices ) ) { #>
<# for ( key in data.choices ) { #>
<input {{{ data.inputAttrs }}} class="dashicons-select" type="radio" value="{{ key }}" name="_customize-dashicons-radio-{{ data.id }}" id="{{ data.id }}{{ key }}" {{{ data.link }}}<# if ( data.value === key ) { #> checked="checked"<# } #>>
<label for="{{ data.id }}{{ key }}"><span class="dashicons dashicons-{{ data.choices[ key ] }}"></span></label>
</input>
<# } #>
<# } else { #>
<#
var dashiconSections = {
'admin-menu': '<?php esc_html_e( 'Admin Menu', 'kirki' ); ?>',
'welcome-screen': '<?php esc_html_e( 'Welcome Screen', 'kirki' ); ?>',
'post-formats': '<?php esc_html_e( 'Post Formats', 'kirki' ); ?>',
'media': '<?php esc_html_e( 'Media', 'kirki' ); ?>',
'image-editing': '<?php esc_html_e( 'Image Editing', 'kirki' ); ?>',
'tinymce': 'TinyMCE',
'posts': '<?php esc_html_e( 'Posts', 'kirki' ); ?>',
'sorting': '<?php esc_html_e( 'Sorting', 'kirki' ); ?>',
'social': '<?php esc_html_e( 'Social', 'kirki' ); ?>',
'wordpress_org': 'WordPress',
'products': '<?php esc_html_e( 'Products', 'kirki' ); ?>',
'taxonomies': '<?php esc_html_e( 'Taxonomies', 'kirki' ); ?>',
'widgets': '<?php esc_html_e( 'Widgets', 'kirki' ); ?>',
'notifications': '<?php esc_html_e( 'Notifications', 'kirki' ); ?>',
'misc': '<?php esc_html_e( 'Miscelaneous', 'kirki' ); ?>'
};
#>
<# _.each( dashiconSections, function( sectionLabel, sectionKey ) { #>
<h4>{{ sectionLabel }}</h4>
<# for ( key in data.icons[ sectionKey ] ) { #>
<input {{{ data.inputAttrs }}}
class="dashicons-select"
type="radio"
value="{{ data.icons[ sectionKey ][ key ] }}"
name="_customize-dashicons-radio-{{ data.id }}"
id="{{ data.id }}{{ data.icons[ sectionKey ][ key ] }}"
{{{ data.link }}}
<# if ( data.value === data.icons[ sectionKey ][ key ] ) { #> checked="checked"<# } #>>
<label for="{{ data.id }}{{ data.icons[ sectionKey ][ key ] }}">
<span class="dashicons dashicons-{{ data.icons[ sectionKey ][ key ] }}"></span>
</label>
</input>
<# } #>
<# }); #>
<# } #>
</div>
<?php
}
}

View file

@ -0,0 +1,84 @@
<?php
/**
* Override field methods
*
* @package kirki-framework/control-dashicons
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @since 1.0
*/
namespace Kirki\Field;
use Kirki\Field;
/**
* Field overrides.
*/
class Dashicons extends Field {
/**
* The field type.
*
* @access public
* @since 1.0
* @var string
*/
public $type = 'kirki-dashicons';
/**
* The control class-name.
*
* @access protected
* @since 0.1
* @var string
*/
protected $control_class = '\Kirki\Control\Dashicons';
/**
* Whether we should register the control class for JS-templating or not.
*
* @access protected
* @since 0.1
* @var bool
*/
protected $control_has_js_template = true;
/**
* Filter arguments before creating the setting.
*
* @access public
* @since 0.1
* @param array $args The field arguments.
* @param WP_Customize_Manager $wp_customize The customizer instance.
* @return array
*/
public function filter_setting_args( $args, $wp_customize ) {
if ( $args['settings'] === $this->args['settings'] ) {
$args = parent::filter_setting_args( $args, $wp_customize );
// Set the sanitize-callback if none is defined.
if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) {
$args['sanitize_callback'] = 'sanitize_text_field';
}
}
return $args;
}
/**
* Filter arguments before creating the control.
*
* @access public
* @since 0.1
* @param array $args The field arguments.
* @param WP_Customize_Manager $wp_customize The customizer instance.
* @return array
*/
public function filter_control_args( $args, $wp_customize ) {
if ( $args['settings'] === $this->args['settings'] ) {
$args = parent::filter_control_args( $args, $wp_customize );
$args['type'] = 'kirki-dashicons';
}
return $args;
}
}

View file

@ -0,0 +1,47 @@
<?php
/**
* Helper methods for dashicons.
*
* @package kirki-framework/control-dashicons
* @category Core
* @author Ari Stathopoulos (@aristath)
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @since 1.0
*/
namespace Kirki\Util;
/**
* A simple object containing static methods.
*/
class Dashicons {
/**
* Get an array of all available dashicons.
*
* @static
* @access public
* @since 1.0
* @return array
*/
public static function get_icons() {
return [
'admin-menu' => [ 'menu', 'menu-alt', 'menu-alt2', 'menu-alt3', 'admin-site', 'admin-site-alt', 'admin-site-alt2', 'admin-site-alt3', 'dashboard', 'admin-post', 'admin-media', 'admin-links', 'admin-page', 'admin-comments', 'admin-appearance', 'admin-plugins', 'plugins-checked', 'admin-users', 'admin-tools', 'admin-settings', 'admin-network', 'admin-home', 'admin-generic', 'admin-collapse', 'filter', 'admin-customizer', 'admin-multisite' ],
'welcome-screen' => [ 'welcome-write-blog', 'welcome-add-page', 'welcome-view-site', 'welcome-widgets-menus', 'welcome-comments', 'welcome-learn-more' ],
'post-formats' => [ 'format-aside', 'format-image', 'format-gallery', 'format-video', 'format-status', 'format-quote', 'format-chat', 'format-audio', 'camera', 'camera-alt', 'images-alt', 'images-alt2', 'video-alt', 'video-alt2', 'video-alt3' ],
'media' => [ 'media-archive', 'media-audio', 'media-code', 'media-default', 'media-document', 'media-interactive', 'media-spreadsheet', 'media-text', 'media-video', 'playlist-audio', 'playlist-video', 'controls-play', 'controls-pause', 'controls-forward', 'controls-skipforward', 'controls-back', 'controls-skipback', 'controls-repeat', 'controls-volumeon', 'controls-volumeoff' ],
'image-editing' => [ 'image-crop', 'image-rotate', 'image-rotate-left', 'image-rotate-right', 'image-flip-vertical', 'image-flip-horizontal', 'image-filter', 'undo', 'redo' ],
'tinymce' => [ 'editor-bold', 'editor-italic', 'editor-ul', 'editor-ol', 'editor-ol-rtl', 'editor-quote', 'editor-alignleft', 'editor-aligncenter', 'editor-alignright', 'editor-insertmore', 'editor-spellcheck', 'editor-expand', 'editor-contract', 'editor-kitchensink', 'editor-underline', 'editor-justify', 'editor-textcolor', 'editor-paste-word', 'editor-paste-text', 'editor-removeformatting', 'editor-video', 'editor-customchar', 'editor-outdent', 'editor-indent', 'editor-help', 'editor-strikethrough', 'editor-unlink', 'editor-rtl', 'editor-ltr', 'editor-break', 'editor-code', 'editor-paragraph', 'editor-table' ],
'posts' => [ 'align-left', 'align-right', 'align-center', 'align-none', 'lock', 'unlock', 'calendar', 'calendar-alt', 'visibility', 'hidden', 'post-status', 'edit', 'trash', 'sticky' ],
'sorting' => [ 'external', 'arrow-up', 'arrow-down', 'arrow-right', 'arrow-left', 'arrow-up-alt', 'arrow-down-alt', 'arrow-right-alt', 'arrow-left-alt', 'arrow-up-alt2', 'arrow-down-alt2', 'arrow-right-alt2', 'arrow-left-alt2', 'sort', 'leftright', 'randomize', 'list-view', 'exerpt-view', 'grid-view', 'move' ],
'social' => [ 'share', 'share-alt', 'share-alt2', 'twitter', 'rss', 'email', 'email-alt', 'email-alt2', 'facebook', 'facebook-alt', 'googleplus', 'networking', 'instagram' ],
'wordpress_org' => [ 'hammer', 'art', 'migrate', 'performance', 'universal-access', 'universal-access-alt', 'tickets', 'nametag', 'clipboard', 'heart', 'megaphone', 'schedule', 'tide', 'rest-api', 'code-standards' ],
'products' => [ 'wordpress', 'wordpress-alt', 'pressthis', 'update', 'update-alt', 'screenoptions', 'info', 'cart', 'feedback', 'cloud', 'translation' ],
'taxonomies' => [ 'tag', 'category' ],
'widgets' => [ 'archive', 'tagcloud', 'text' ],
'notifications' => [ 'yes', 'yes-alt', 'no', 'no-alt', 'plus', 'plus-alt', 'minus', 'dismiss', 'marker', 'star-filled', 'star-half', 'star-empty', 'flag', 'warning' ],
'misc' => [ 'location', 'location-alt', 'vault', 'shield', 'shield-alt', 'sos', 'search', 'slides', 'text-page', 'analytics', 'chart-pie', 'chart-bar', 'chart-line', 'chart-area', 'groups', 'businessman', 'businesswoman', 'businessperson', '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', 'paperclip' ],
];
}
}

View file

@ -0,0 +1,3 @@
import "./control.scss";
wp.customize.controlConstructor['kirki-dashicons'] = wp.customize.kirkiDynamicControl.extend( {} );