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,131 @@
<?php
/**
* Try to automatically generate the script necessary for adding icons to panels & section
*
* @package Kirki
* @category Core
* @author Ari Stathopoulos (@aristath)
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @since 3.0.0
*/
namespace Kirki\Module;
use Kirki\URL;
/**
* Adds scripts for icons in sections & panels.
*/
class Section_Icons {
/**
* An array of panels and sections with icons.
*
* @static
* @access private
* @var array
*/
private static $icons = [];
/**
* An array of panels.
*
* @access private
* @since 1.0
* @var array
*/
private $panels = [];
/**
* An array of sections.
*
* @access private
* @since 1.0
* @var array
*/
private $sections = [];
/**
* The class constructor.
*
* @access public
*/
public function __construct() {
add_action( 'customize_controls_enqueue_scripts', [ $this, 'customize_controls_enqueue_scripts' ], 99 );
add_action( 'kirki_panel_added', [ $this, 'panel_added' ], 10, 2 );
add_action( 'kirki_section_added', [ $this, 'section_added' ], 10, 2 );
}
/**
* Adds icon for a section/panel.
*
* @access public
* @since 3.0.0
* @param string $id The panel or section ID.
* @param string $icon The icon to add.
* @param string $context Lowercase 'section' or 'panel'.
*/
public function add_icon( $id, $icon, $context = 'section' ) {
self::$icons[ $context ][ $id ] = trim( $icon );
}
/**
* Hooks in kirki_panel_added to populate $this->panels.
*
* @access public
* @since 1.0
* @param string $id The panel ID.
* @param array $args The panel arguments.
*/
public function panel_added( $id, $args ) {
if ( isset( $args['icon'] ) ) {
$args['id'] = $id;
$this->panels[] = $args;
}
}
/**
* Hooks in kirki_section_added to populate $this->sections.
*
* @access public
* @since 1.0
* @param string $id The section ID.
* @param array $args The section arguments.
*/
public function section_added( $id, $args ) {
if ( isset( $args['icon'] ) ) {
$args['id'] = $id;
$this->sections[] = $args;
}
}
/**
* Format the script in a way that will be compatible with WordPress.
*/
public function customize_controls_enqueue_scripts() {
// Parse panels and find ones with icons.
foreach ( $this->panels as $panel ) {
$this->add_icon( $panel['id'], $panel['icon'], 'panel' );
}
// Parse sections and find ones with icons.
foreach ( $this->sections as $section ) {
$this->add_icon( $section['id'], $section['icon'], 'section' );
}
wp_enqueue_script( 'kirki_panel_and_section_icons', URL::get_from_path( __DIR__ . '/icons.js' ), [ 'jquery', 'customize-base', 'customize-controls' ], '1.0', true );
wp_localize_script( 'kirki_panel_and_section_icons', 'kirkiIcons', self::$icons );
}
}

View file

@ -0,0 +1,30 @@
/* global kirkiIcons */
jQuery( document ).ready( function() {
'use strict';
if ( ! _.isUndefined( kirkiIcons.section ) ) {
// Parse sections and add icons.
_.each( kirkiIcons.section, function( icon, sectionID ) {
// Add icons in list.
jQuery( '#accordion-section-' + sectionID + ' > h3' ).addClass( 'dashicons-before ' + icon );
// Add icons on titles when a section is open.
jQuery( '#sub-accordion-section-' + sectionID + ' .customize-section-title > h3' ).append( '<span class="dashicons ' + icon + '" style="float:left;padding-right:.1em;padding-top:2px;"></span>' );
} );
}
if ( ! _.isUndefined( kirkiIcons.panel ) ) {
_.each( kirkiIcons.panel, function( icon, panelID ) {
// Add icons in lists & headers.
jQuery( '#accordion-panel-' + panelID + ' > h3, #sub-accordion-panel-' + panelID + ' .panel-title' ).addClass( 'dashicons-before ' + icon );
} );
}
} );