first commit
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 Ari Stathopoulos (@aristath)
|
||||
|
||||
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.
|
||||
|
After Width: | Height: | Size: 786 B |
|
After Width: | Height: | Size: 866 B |
|
After Width: | Height: | Size: 869 B |
|
After Width: | Height: | Size: 929 B |
|
After Width: | Height: | Size: 932 B |
|
After Width: | Height: | Size: 935 B |
|
After Width: | Height: | Size: 306 B |
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="71.497665"
|
||||
height="23.886881"
|
||||
version="1.1"
|
||||
xml:space="preserve"
|
||||
style="clip-rule:evenodd;fill-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1"
|
||||
id="svg2"
|
||||
inkscape:version="0.91 r13725"
|
||||
sodipodi:docname="kirki-bottom.svg"><metadata
|
||||
id="metadata56"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs54" /><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1871"
|
||||
inkscape:window-height="1056"
|
||||
id="namedview52"
|
||||
showgrid="false"
|
||||
fit-margin-top="0"
|
||||
fit-margin-left="0"
|
||||
fit-margin-right="0"
|
||||
fit-margin-bottom="0"
|
||||
inkscape:zoom="4.6669048"
|
||||
inkscape:cx="-1.0852472"
|
||||
inkscape:cy="-7.0625365"
|
||||
inkscape:window-x="49"
|
||||
inkscape:window-y="24"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg2" /><g
|
||||
id="g4242"
|
||||
transform="translate(-3.71284,-0.18012)"
|
||||
inkscape:export-xdpi="94"
|
||||
inkscape:export-ydpi="94"><path
|
||||
inkscape:export-ydpi="94.19397"
|
||||
inkscape:export-xdpi="94.19397"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path46"
|
||||
style="fill:none;stroke:#000000;stroke-width:0.2;stroke-miterlimit:1;stroke-dasharray:none"
|
||||
d="m 10.4064,22.5387 -0.3276,0 0,1.4283 -1.65866,0 -0.31673,-2.9188 C 5.488,18.886 3.81284,15.6275 3.81284,12.0084 c 0,-2.71119 0.9401,-5.22001 2.5246,-7.23473 L 6.0704,2.31269 l 2.90602,0 C 10.8759,1.02464 13.1284,0.28012 15.5411,0.28012 c 2.4127,0 4.6652,0.74452 6.5647,2.03257 l 2.8545,0 -0.2609,2.40411 c 1.6102,2.01928 2.57,4.55213 2.57,7.2916 0,3.6568 -1.7103,6.9454 -4.3471,9.0859 l -0.3117,2.8727 -1.6586,0 0,-1.4283 -0.2761,0 c -1.5432,0.7637 -3.2923,1.1979 -5.1348,1.1979 -1.8425,0 -3.5916,-0.4342 -5.1347,-1.1979 z" /><g
|
||||
inkscape:export-ydpi="94.19397"
|
||||
inkscape:export-xdpi="94.19397"
|
||||
style="stroke-width:0.2;stroke-miterlimit:1;stroke-dasharray:none"
|
||||
id="g48"><path
|
||||
d="m 15.4462,11.8498 c 3.4224,0 6.1968,2.104 6.1968,4.6994 0,2.5955 -2.7744,4.6995 -6.1968,4.6995 -3.4224,0 -6.19678,-2.104 -6.19678,-4.6995 0,-2.5954 2.77438,-4.6994 6.19678,-4.6994 z m -1.9811,2.9947 c 0.5725,0 1.0366,0.8148 1.0366,1.8199 0,1.0051 -0.4641,1.8199 -1.0366,1.8199 -0.5725,0 -1.0366,-0.8148 -1.0366,-1.8199 0,-1.0051 0.4641,-1.8199 1.0366,-1.8199 z m 4.0544,0 c 0.5726,0 1.0367,0.8148 1.0367,1.8199 0,1.0051 -0.4641,1.8199 -1.0367,1.8199 -0.5725,0 -1.0366,-0.8148 -1.0366,-1.8199 0,-1.0051 0.4641,-1.8199 1.0366,-1.8199 z"
|
||||
style="fill:none;stroke:#000000;stroke-width:0.2;stroke-miterlimit:1;stroke-dasharray:none"
|
||||
id="path50"
|
||||
inkscape:connector-curvature="0" /></g></g><g
|
||||
id="g20"
|
||||
style="fill:#000000;fill-opacity:0.20408164"
|
||||
inkscape:export-xdpi="94.19397"
|
||||
inkscape:export-ydpi="94.19397"
|
||||
transform="matrix(0.34650485,0,0,0.34650485,30.267064,8.7780735)"><text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-variant:normal;font-weight:300;font-stretch:normal;font-size:40px;line-height:125%;font-family:Roboto;-inkscape-font-specification:'Roboto Light';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:0.20408164;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
x="-7.2853427"
|
||||
y="42.141983"
|
||||
id="text4234"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan4236"
|
||||
x="-7.2853427"
|
||||
y="42.141983">toolkit</tspan></text>
|
||||
</g><text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:15.76700211px;line-height:125%;font-family:'Roboto Slab';-inkscape-font-specification:'Roboto Slab Bold';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:0.10204079;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
x="27.568701"
|
||||
y="11.573637"
|
||||
id="text4238"
|
||||
sodipodi:linespacing="125%"
|
||||
inkscape:export-xdpi="94"
|
||||
inkscape:export-ydpi="94"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan4240"
|
||||
x="27.568701"
|
||||
y="11.573637">KIRKI</tspan></text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.8 KiB |
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"name": "kirki-framework/kirki",
|
||||
"type": "library",
|
||||
"version": "4.0.24",
|
||||
"keywords": ["WordPress", "Customizer"],
|
||||
"description": "Extending the WordPress customizer",
|
||||
"homepage": "https://kirki.org",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kirki Framework",
|
||||
"email": "connect@mapsteps.com"
|
||||
}
|
||||
],
|
||||
"config": {
|
||||
"vendor-dir": "packages",
|
||||
"allow-plugins": {
|
||||
"composer/installers": true,
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||
}
|
||||
},
|
||||
"include-path": [".", "core"],
|
||||
"require": {
|
||||
"php": ">=7.0",
|
||||
"kirki-framework/util": "*",
|
||||
"kirki-framework/l10n": "*",
|
||||
"kirki-framework/field": "*",
|
||||
"kirki-framework/url-getter": "*",
|
||||
"kirki-framework/control-base": "*",
|
||||
"kirki-framework/control-checkbox": "*",
|
||||
"kirki-framework/control-code": "*",
|
||||
"kirki-framework/control-cropped-image": "*",
|
||||
"kirki-framework/control-custom": "*",
|
||||
"kirki-framework/control-dashicons": "*",
|
||||
"kirki-framework/control-date": "*",
|
||||
"kirki-framework/control-dimension": "*",
|
||||
"kirki-framework/control-editor": "*",
|
||||
"kirki-framework/control-generic": "*",
|
||||
"kirki-framework/control-image": "*",
|
||||
"kirki-framework/control-multicheck": "*",
|
||||
"kirki-framework/control-palette": "*",
|
||||
"kirki-framework/control-radio": "*",
|
||||
"kirki-framework/control-repeater": "*",
|
||||
"kirki-framework/control-select": "*",
|
||||
"kirki-framework/control-react-select": "*",
|
||||
"kirki-framework/control-slider": "*",
|
||||
"kirki-framework/control-sortable": "*",
|
||||
"kirki-framework/control-upload": "*",
|
||||
"kirki-framework/field-dimensions": "*",
|
||||
"kirki-framework/field-fontawesome": "*",
|
||||
"kirki-framework/field-typography": "*",
|
||||
"kirki-framework/module-css": "*",
|
||||
"kirki-framework/module-editor-styles": "*",
|
||||
"kirki-framework/module-field-dependencies": "*",
|
||||
"kirki-framework/module-postmessage": "*",
|
||||
"kirki-framework/module-preset": "*",
|
||||
"kirki-framework/module-selective-refresh": "*",
|
||||
"kirki-framework/module-tooltips": "*",
|
||||
"kirki-framework/module-webfonts": "*",
|
||||
"kirki-framework/compatibility": "*",
|
||||
"kirki-framework/data-option": "*",
|
||||
"kirki-framework/module-panels": "*",
|
||||
"kirki-framework/module-sections": "*",
|
||||
"kirki-framework/module-section-icons": "*",
|
||||
"kirki-framework/control-react-colorful": "*",
|
||||
"kirki-framework/control-color": "*",
|
||||
"kirki-framework/control-color-palette": "*",
|
||||
"kirki-framework/field-background": "*",
|
||||
"kirki-framework/field-multicolor": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* Bootstrap the plugin.
|
||||
*
|
||||
* @since 4.0
|
||||
* @package kirki
|
||||
*/
|
||||
|
||||
/**
|
||||
* Instantiate oblects.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
new \Kirki\Compatibility\Aliases();
|
||||
new \Kirki\Compatibility\Scripts();
|
||||
new \Kirki\Compatibility\Deprecated();
|
||||
new \Kirki\Data\Option();
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: Kirki Customizer Framework
|
||||
* Plugin URI: https://kirki.org
|
||||
* Description: The Ultimate WordPress Customizer Framework
|
||||
* Author: David Vongries
|
||||
* Author URI: https://davidvongries.com/
|
||||
* Version: 4.0.24
|
||||
* Text Domain: kirki
|
||||
* Requires at least: 5.2
|
||||
* Requires PHP: 7.0
|
||||
*
|
||||
* @package Kirki
|
||||
* @category Core
|
||||
* @author Ari Stathopoulos (@aristath)
|
||||
* @copyright Copyright (c) 2021, David Vongries
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
use Kirki\L10n;
|
||||
use Kirki\Compatibility\Modules;
|
||||
use Kirki\Compatibility\Framework;
|
||||
use Kirki\Compatibility\Kirki;
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// No need to proceed if Kirki already exists.
|
||||
if ( class_exists( 'Kirki' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! defined( 'KIRKI_PLUGIN_FILE' ) ) {
|
||||
define( 'KIRKI_PLUGIN_FILE', __FILE__ );
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/lib/class-aricolor.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude
|
||||
require_once __DIR__ . '/lib/class-kirki-color.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude
|
||||
require_once __DIR__ . '/packages/autoload.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude
|
||||
require_once __DIR__ . '/inc/bootstrap.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude
|
||||
|
||||
// Define the KIRKI_VERSION constant.
|
||||
if ( ! defined( 'KIRKI_VERSION' ) ) {
|
||||
define( 'KIRKI_VERSION', '4.0.24' );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'Kirki' ) ) {
|
||||
/**
|
||||
* Returns an instance of the Kirki object.
|
||||
*/
|
||||
function kirki() {
|
||||
$kirki = Framework::get_instance();
|
||||
return $kirki;
|
||||
}
|
||||
}
|
||||
|
||||
// Start Kirki.
|
||||
global $kirki;
|
||||
$kirki = kirki();
|
||||
|
||||
// Instantiate the modules.
|
||||
$kirki->modules = new Modules();
|
||||
|
||||
// Instantiate classes.
|
||||
new Kirki();
|
||||
new L10n( 'kirki', __DIR__ . '/languages' );
|
||||
|
||||
// ? Bagus: Do we really need to-reinclude this file? It was included above.
|
||||
// Include the ariColor library.
|
||||
require_once wp_normalize_path( dirname( __FILE__ ) . '/lib/class-aricolor.php' ); // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude
|
||||
|
||||
// Add an empty config for global fields.
|
||||
Kirki::add_config( '' ); // ? Bagus: what is this for? Adding empty config.
|
||||
|
||||
// ? Bagus: Do we really need this line? custom-config.php here is supposed to inside this plugin. Or is this just in case we need it in the future?
|
||||
$custom_config_path = dirname( __FILE__ ) . '/custom-config.php';
|
||||
$custom_config_path = wp_normalize_path( $custom_config_path );
|
||||
if ( file_exists( $custom_config_path ) ) {
|
||||
require_once $custom_config_path; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude
|
||||
}
|
||||
|
||||
// Add upgrade notifications.
|
||||
require_once wp_normalize_path( dirname( __FILE__ ) . '/upgrade-notifications.php' ); // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude
|
||||
|
||||
/**
|
||||
* To enable tests, add this line to your wp-config.php file (or anywhere alse):
|
||||
* define( 'KIRKI_TEST', true );
|
||||
*
|
||||
* Please note that the example.php file is not included in the wordpress.org distribution
|
||||
* and will only be included in dev versions of the plugin in the github repository.
|
||||
*/
|
||||
if ( defined( 'KIRKI_TEST' ) && true === KIRKI_TEST && file_exists( dirname( __FILE__ ) . '/example.php' ) ) {
|
||||
include_once dirname( __FILE__ ) . '/example.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude
|
||||
}
|
||||
@@ -0,0 +1,982 @@
|
||||
<?php
|
||||
// phpcs:ignoreFile
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'ariColor' ) ) {
|
||||
/**
|
||||
* The color calculations class.
|
||||
*/
|
||||
class ariColor {
|
||||
|
||||
/**
|
||||
* An array of our instances.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @var array
|
||||
*/
|
||||
public static $instances = array();
|
||||
|
||||
/**
|
||||
* The color initially set.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @var mixed
|
||||
*/
|
||||
public $color;
|
||||
|
||||
/**
|
||||
* A fallback color in case of failure.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @var mixed
|
||||
*/
|
||||
public $fallback = '#ffffff';
|
||||
|
||||
/**
|
||||
* Fallback object from the fallback color.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @var object
|
||||
*/
|
||||
public $fallback_obj;
|
||||
|
||||
/**
|
||||
* The mode we're using for this color.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @var string
|
||||
*/
|
||||
public $mode = 'hex';
|
||||
|
||||
/**
|
||||
* An array containing all word-colors (white/blue/red etc)
|
||||
* and their corresponding HEX codes.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @var array
|
||||
*/
|
||||
public $word_colors = array();
|
||||
|
||||
/**
|
||||
* The hex code of the color.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @var string
|
||||
*/
|
||||
public $hex;
|
||||
|
||||
/**
|
||||
* Red value.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @var int
|
||||
*/
|
||||
public $red = 0;
|
||||
|
||||
/**
|
||||
* Green value.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @var int
|
||||
*/
|
||||
public $green = 0;
|
||||
|
||||
/**
|
||||
* Blue value.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @var int
|
||||
*/
|
||||
public $blue = 0;
|
||||
|
||||
/**
|
||||
* Alpha value (min:0, max: 1)
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @var float
|
||||
*/
|
||||
public $alpha = 1;
|
||||
|
||||
/**
|
||||
* Hue value.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @var float
|
||||
*/
|
||||
public $hue;
|
||||
|
||||
/**
|
||||
* Saturation value.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @var float
|
||||
*/
|
||||
public $saturation;
|
||||
|
||||
/**
|
||||
* Lightness value.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @var float
|
||||
*/
|
||||
public $lightness;
|
||||
|
||||
/**
|
||||
* Chroma value.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @var float
|
||||
*/
|
||||
public $chroma;
|
||||
|
||||
/**
|
||||
* An array containing brightnesses.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @var array
|
||||
*/
|
||||
public $brightness = array();
|
||||
|
||||
/**
|
||||
* Luminance value.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @var float
|
||||
*/
|
||||
public $luminance;
|
||||
|
||||
/**
|
||||
* The class constructor.
|
||||
*
|
||||
* @access protected
|
||||
* @since 1.0.0
|
||||
* @param string|array $color The color.
|
||||
* @param string $mode The color mode. Leave empty to auto-detect.
|
||||
*/
|
||||
protected function __construct( $color = '', $mode = 'auto' ) {
|
||||
$this->color = $color;
|
||||
|
||||
if ( is_array( $color ) && isset( $color['fallback'] ) ) {
|
||||
$this->fallback = $color['fallback'];
|
||||
$this->fallback_obj = self::newColor( $this->fallback );
|
||||
}
|
||||
|
||||
if ( ! method_exists( $this, 'from_' . $mode ) ) {
|
||||
$mode = $this->get_mode( $color );
|
||||
}
|
||||
|
||||
$this->mode = $mode;
|
||||
|
||||
if ( ! $mode ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->mode = $mode;
|
||||
$method = 'from_' . $mode;
|
||||
// Call the from_{$color_mode} method.
|
||||
$this->$method();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an instance for this color.
|
||||
* We use a separate instance per color
|
||||
* because there's no need to create a completely new instance each time we call this class.
|
||||
* Instead using instances helps us improve performance & footprint.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @param string|array $color The color.
|
||||
* @param string $mode Mode to be used.
|
||||
* @return ariColor (object)
|
||||
*/
|
||||
public static function newColor( $color, $mode = 'auto' ) {
|
||||
|
||||
// Get an md5 for this color.
|
||||
$color_md5 = ( is_array( $color ) ) ? md5( wp_json_encode( $color ) . $mode ) : md5( $color . $mode );
|
||||
// Set the instance if it does not already exist.
|
||||
if ( ! isset( self::$instances[ $color_md5 ] ) ) {
|
||||
self::$instances[ $color_md5 ] = new self( $color, $mode );
|
||||
}
|
||||
return self::$instances[ $color_md5 ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias of the newColor method.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 1.1
|
||||
* @param string|array $color The color.
|
||||
* @param string $mode Mode to be used.
|
||||
* @return ariColor (object)
|
||||
*/
|
||||
public static function new_color( $color, $mode = 'auto' ) {
|
||||
return self::newColor( $color, $mode );
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows us to get a new instance by modifying a property of the existing one.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @param string $property Can be one of the following:
|
||||
* red,
|
||||
* green,
|
||||
* blue,
|
||||
* alpha,
|
||||
* hue,
|
||||
* saturation,
|
||||
* lightness,
|
||||
* brightness.
|
||||
* @param int|float|string $value The new value.
|
||||
* @return ariColor|null
|
||||
*/
|
||||
public function getNew( $property = '', $value = '' ) {
|
||||
|
||||
if ( in_array( $property, array( 'red', 'green', 'blue', 'alpha' ), true ) ) {
|
||||
// Check if we're changing any of the rgba values.
|
||||
$value = max( 0, min( 255, $value ) );
|
||||
if ( 'red' === $property ) {
|
||||
return self::new_color( 'rgba(' . $value . ',' . $this->green . ',' . $this->blue . ',' . $this->alpha . ')', 'rgba' );
|
||||
} elseif ( 'green' === $property ) {
|
||||
return self::new_color( 'rgba(' . $this->red . ',' . $value . ',' . $this->blue . ',' . $this->alpha . ')', 'rgba' );
|
||||
} elseif ( 'blue' === $property ) {
|
||||
return self::new_color( 'rgba(' . $this->red . ',' . $this->green . ',' . $value . ',' . $this->alpha . ')', 'rgba' );
|
||||
} elseif ( 'alpha' === $property ) {
|
||||
return self::new_color( 'rgba(' . $this->red . ',' . $this->green . ',' . $this->blue . ',' . $value . ')', 'rgba' );
|
||||
}
|
||||
} elseif ( in_array( $property, array( 'hue', 'saturation', 'lightness' ), true ) ) {
|
||||
// Check if we're changing any of the hsl values.
|
||||
$value = ( 'hue' === $property ) ? max( 0, min( 360, $value ) ) : max( 0, min( 100, $value ) );
|
||||
|
||||
if ( 'hue' === $property ) {
|
||||
return self::new_color( 'hsla(' . $value . ',' . $this->saturation . '%,' . $this->lightness . '%,' . $this->alpha . ')', 'hsla' );
|
||||
} elseif ( 'saturation' === $property ) {
|
||||
return self::new_color( 'hsla(' . $this->hue . ',' . $value . '%,' . $this->lightness . '%,' . $this->alpha . ')', 'hsla' );
|
||||
} elseif ( 'lightness' === $property ) {
|
||||
return self::new_color( 'hsla(' . $this->hue . ',' . $this->saturation . '%,' . $value . '%,' . $this->alpha . ')', 'hsla' );
|
||||
}
|
||||
} elseif ( 'brightness' === $property ) {
|
||||
// Check if we're changing the brightness.
|
||||
if ( $value < $this->brightness['total'] ) {
|
||||
$red = max( 0, min( 255, $this->red - ( $this->brightness['total'] - $value ) ) );
|
||||
$green = max( 0, min( 255, $this->green - ( $this->brightness['total'] - $value ) ) );
|
||||
$blue = max( 0, min( 255, $this->blue - ( $this->brightness['total'] - $value ) ) );
|
||||
} elseif ( $value > $this->brightness['total'] ) {
|
||||
$red = max( 0, min( 255, $this->red + ( $value - $this->brightness['total'] ) ) );
|
||||
$green = max( 0, min( 255, $this->green + ( $value - $this->brightness['total'] ) ) );
|
||||
$blue = max( 0, min( 255, $this->blue + ( $value - $this->brightness['total'] ) ) );
|
||||
} else {
|
||||
// If it's not smaller and it's not greater, then it's equal.
|
||||
return $this;
|
||||
}
|
||||
return self::new_color( 'rgba(' . $red . ',' . $green . ',' . $blue . ',' . $this->alpha . ')', 'rgba' );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allias for the getNew method.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.1.0
|
||||
* @param string $property Can be one of the following:
|
||||
* red,
|
||||
* green,
|
||||
* blue,
|
||||
* alpha,
|
||||
* hue,
|
||||
* saturation,
|
||||
* lightness,
|
||||
* brightness.
|
||||
* @param int|float|string $value The new value.
|
||||
* @return ariColor|null
|
||||
*/
|
||||
public function get_new( $property = '', $value = '' ) {
|
||||
return $this->getNew( $property, $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Figure out what mode we're using.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @param string|array $color The color we're querying.
|
||||
* @return string
|
||||
*/
|
||||
public function get_mode( $color ) {
|
||||
|
||||
// Check if value is an array.
|
||||
if ( is_array( $color ) ) {
|
||||
// Does the array have an 'rgba' key?
|
||||
if ( isset( $color['rgba'] ) ) {
|
||||
$this->color = $color['rgba'];
|
||||
return 'rgba';
|
||||
} elseif ( isset( $color['color'] ) ) {
|
||||
// Does the array have a 'color' key?
|
||||
$this->color = $color['color'];
|
||||
if ( is_string( $color['color'] ) && false !== strpos( $color['color'], 'rgba' ) ) {
|
||||
return 'rgba';
|
||||
}
|
||||
return 'hex';
|
||||
}
|
||||
// Is this a simple array with 4 items?
|
||||
if ( 4 === count( $color ) && isset( $color[0] ) && isset( $color[1] ) && isset( $color[2] ) && isset( $color[3] ) ) {
|
||||
$this->color = 'rgba(' . intval( $color[0] ) . ',' . intval( $color[1] ) . ',' . intval( $color[2] ) . ',' . intval( $color[3] ) . ')';
|
||||
return 'rgba';
|
||||
} elseif ( 3 === count( $color ) && isset( $color[0] ) && isset( $color[1] ) && isset( $color[2] ) ) {
|
||||
// Is this a simple array with 3 items?
|
||||
$this->color = 'rgba(' . intval( $color[0] ) . ',' . intval( $color[1] ) . ',' . intval( $color[2] ) . ',1)';
|
||||
return 'rgba';
|
||||
}
|
||||
|
||||
// Check for other keys in the array and get values from there.
|
||||
$finders_keepers = array(
|
||||
'r' => 'red',
|
||||
'g' => 'green',
|
||||
'b' => 'blue',
|
||||
'a' => 'alpha',
|
||||
'red' => 'red',
|
||||
'green' => 'green',
|
||||
'blue' => 'blue',
|
||||
'alpha' => 'alpha',
|
||||
'opacity' => 'alpha',
|
||||
);
|
||||
$found = false;
|
||||
foreach ( $finders_keepers as $finder => $keeper ) {
|
||||
if ( isset( $color[ $finder ] ) ) {
|
||||
$found = true;
|
||||
$this->$keeper = $color[ $finder ];
|
||||
}
|
||||
}
|
||||
|
||||
// We failed, use fallback.
|
||||
if ( ! $found ) {
|
||||
$this->from_fallback();
|
||||
return $this->mode;
|
||||
}
|
||||
|
||||
// We did not fail, so use rgba values recovered above.
|
||||
$this->color = 'rgba(' . $this->red . ',' . $this->green . ',' . $this->blue . ',' . $this->alpha . ')';
|
||||
return 'rgba';
|
||||
}
|
||||
|
||||
// If a string and 3 or 6 characters long, add # since it's a hex.
|
||||
if ( 3 === strlen( $this->color ) || 6 === strlen( $this->color ) && false === strpos( $this->color, '#' ) ) {
|
||||
$this->color = '#' . $this->color;
|
||||
$color = $this->color;
|
||||
}
|
||||
|
||||
// If we got this far, it's not an array.
|
||||
// Check for key identifiers in the value.
|
||||
$finders_keepers = array(
|
||||
'#' => 'hex',
|
||||
'rgba' => 'rgba',
|
||||
'rgb' => 'rgb',
|
||||
'hsla' => 'hsla',
|
||||
'hsl' => 'hsl',
|
||||
);
|
||||
foreach ( $finders_keepers as $finder => $keeper ) {
|
||||
if ( false !== strrpos( $color, $finder ) ) {
|
||||
|
||||
// Make sure hex colors have 6 digits and not more.
|
||||
if ( '#' === $finder && 7 < strlen( $color ) ) {
|
||||
$this->color = substr( $color, 0, 7 );
|
||||
}
|
||||
|
||||
return $keeper;
|
||||
}
|
||||
}
|
||||
// Perhaps we're using a word like "orange"?
|
||||
$wordcolors = $this->get_word_colors();
|
||||
if ( is_string( $color ) && array_key_exists( $color, $wordcolors ) ) {
|
||||
$this->color = '#' . $wordcolors[ $color ];
|
||||
return 'hex';
|
||||
}
|
||||
// Fallback to hex.
|
||||
|
||||
$this->color = $this->fallback;
|
||||
return 'hex';
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts with a HEX color and calculates all other properties.
|
||||
*
|
||||
* @access protected
|
||||
* @since 1.0.0
|
||||
* @return null
|
||||
*/
|
||||
protected function from_hex() {
|
||||
|
||||
if ( ! function_exists( 'sanitize_hex_color' ) ) {
|
||||
require_once wp_normalize_path( ABSPATH . WPINC . '/class-wp-customize-manager.php' );
|
||||
}
|
||||
// Is this perhaps a word-color?
|
||||
$word_colors = $this->get_word_colors();
|
||||
if ( array_key_exists( $this->color, $word_colors ) ) {
|
||||
$this->color = '#' . $word_colors[ $this->color ];
|
||||
}
|
||||
// Sanitize color.
|
||||
$this->hex = sanitize_hex_color( maybe_hash_hex_color( $this->color ) );
|
||||
$hex = ltrim( $this->hex, '#' );
|
||||
|
||||
// Fallback if needed.
|
||||
if ( ! $hex || 3 > strlen( $hex ) ) {
|
||||
$this->from_fallback();
|
||||
return;
|
||||
}
|
||||
// Make sure we have 6 digits for the below calculations.
|
||||
if ( 3 === strlen( $hex ) ) {
|
||||
$hex = ltrim( $this->hex, '#' );
|
||||
$hex = substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) . substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) . substr( $hex, 2, 1 ) . substr( $hex, 2, 1 );
|
||||
}
|
||||
|
||||
// Set red, green, blue.
|
||||
$this->red = hexdec( substr( $hex, 0, 2 ) );
|
||||
$this->green = hexdec( substr( $hex, 2, 2 ) );
|
||||
$this->blue = hexdec( substr( $hex, 4, 2 ) );
|
||||
$this->alpha = 1;
|
||||
// Set other color properties.
|
||||
$this->set_brightness();
|
||||
$this->set_hsl();
|
||||
$this->set_luminance();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts with an RGB color and calculates all other properties.
|
||||
*
|
||||
* @access protected
|
||||
* @since 1.0.0
|
||||
* @return null
|
||||
*/
|
||||
protected function from_rgb() {
|
||||
$value = explode( ',', str_replace( array( ' ', 'rgb', '(', ')' ), '', $this->color ) );
|
||||
// Set red, green, blue.
|
||||
$this->red = ( isset( $value[0] ) ) ? intval( $value[0] ) : 255;
|
||||
$this->green = ( isset( $value[1] ) ) ? intval( $value[1] ) : 255;
|
||||
$this->blue = ( isset( $value[2] ) ) ? intval( $value[2] ) : 255;
|
||||
$this->alpha = 1;
|
||||
// Set the hex.
|
||||
$this->hex = $this->rgb_to_hex( $this->red, $this->green, $this->blue );
|
||||
// Set other color properties.
|
||||
$this->set_brightness();
|
||||
$this->set_hsl();
|
||||
$this->set_luminance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts with an RGBA color and calculates all other properties.
|
||||
*
|
||||
* @access protected
|
||||
* @since 1.0.0
|
||||
* @return null
|
||||
*/
|
||||
protected function from_rgba() {
|
||||
// Set r, g, b, a properties.
|
||||
$value = explode( ',', str_replace( array( ' ', 'rgba', '(', ')' ), '', $this->color ) );
|
||||
$this->red = ( isset( $value[0] ) ) ? intval( $value[0] ) : 255;
|
||||
$this->green = ( isset( $value[1] ) ) ? intval( $value[1] ) : 255;
|
||||
$this->blue = ( isset( $value[2] ) ) ? intval( $value[2] ) : 255;
|
||||
$this->alpha = ( isset( $value[3] ) ) ? filter_var( $value[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : 1;
|
||||
// Limit values in the range of 0 - 255.
|
||||
$this->red = max( 0, min( 255, $this->red ) );
|
||||
$this->green = max( 0, min( 255, $this->green ) );
|
||||
$this->blue = max( 0, min( 255, $this->blue ) );
|
||||
// Limit values 0 - 1.
|
||||
$this->alpha = max( 0, min( 1, $this->alpha ) );
|
||||
// Set hex.
|
||||
$this->hex = $this->rgb_to_hex( $this->red, $this->green, $this->blue );
|
||||
// Set other color properties.
|
||||
$this->set_brightness();
|
||||
$this->set_hsl();
|
||||
$this->set_luminance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts with an HSL color and calculates all other properties.
|
||||
*
|
||||
* @access protected
|
||||
* @since 1.0.0
|
||||
* @return null
|
||||
*/
|
||||
protected function from_hsl() {
|
||||
$value = explode( ',', str_replace( array( ' ', 'hsl', '(', ')', '%' ), '', $this->color ) );
|
||||
$this->hue = $value[0];
|
||||
$this->saturation = $value[1];
|
||||
$this->lightness = $value[2];
|
||||
$this->from_hsl_array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts with an HSLA color and calculates all other properties.
|
||||
*
|
||||
* @access protected
|
||||
* @since 1.0.0
|
||||
* @return null
|
||||
*/
|
||||
protected function from_hsla() {
|
||||
$value = explode( ',', str_replace( array( ' ', 'hsla', '(', ')', '%' ), '', $this->color ) );
|
||||
$this->hue = $value[0];
|
||||
$this->saturation = $value[1];
|
||||
$this->lightness = $value[2];
|
||||
$this->alpha = $value[3];
|
||||
$this->from_hsl_array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the HEX value of a color given values for $red, $green, $blue.
|
||||
*
|
||||
* @access protected
|
||||
* @since 1.0.0
|
||||
* @param int|string $red The red value of this color.
|
||||
* @param int|string $green The green value of this color.
|
||||
* @param int|string $blue The blue value of this color.
|
||||
* @return string
|
||||
*/
|
||||
protected function rgb_to_hex( $red, $green, $blue ) {
|
||||
// Get hex values properly formatted.
|
||||
$hex_red = $this->dexhex_double_digit( $red );
|
||||
$hex_green = $this->dexhex_double_digit( $green );
|
||||
$hex_blue = $this->dexhex_double_digit( $blue );
|
||||
return '#' . $hex_red . $hex_green . $hex_blue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a decimal value to hex and make sure it's 2 characters.
|
||||
*
|
||||
* @access protected
|
||||
* @since 1.0.0
|
||||
* @param int|string $value The value to convert.
|
||||
* @return string
|
||||
*/
|
||||
protected function dexhex_double_digit( $value ) {
|
||||
$value = dechex( $value );
|
||||
if ( 1 === strlen( $value ) ) {
|
||||
$value = '0' . $value;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the red, green, blue values of an HSL color.
|
||||
*
|
||||
* @access protected
|
||||
* @since 1.0.0
|
||||
* @see https://gist.github.com/brandonheyer/5254516
|
||||
*/
|
||||
protected function from_hsl_array() {
|
||||
$h = $this->hue / 360;
|
||||
$s = $this->saturation / 100;
|
||||
$l = $this->lightness / 100;
|
||||
|
||||
$r = $l;
|
||||
$g = $l;
|
||||
$b = $l;
|
||||
$v = ( $l <= 0.5 ) ? ( $l * ( 1.0 + $s ) ) : ( $l + $s - $l * $s );
|
||||
if ( $v > 0 ) {
|
||||
$m = $l + $l - $v;
|
||||
$sv = ( $v - $m ) / $v;
|
||||
$h *= 6.0;
|
||||
$sextant = floor( $h );
|
||||
$fract = $h - $sextant;
|
||||
$vsf = $v * $sv * $fract;
|
||||
$mid1 = $m + $vsf;
|
||||
$mid2 = $v - $vsf;
|
||||
switch ( $sextant ) {
|
||||
case 0:
|
||||
$r = $v;
|
||||
$g = $mid1;
|
||||
$b = $m;
|
||||
break;
|
||||
case 1:
|
||||
$r = $mid2;
|
||||
$g = $v;
|
||||
$b = $m;
|
||||
break;
|
||||
case 2:
|
||||
$r = $m;
|
||||
$g = $v;
|
||||
$b = $mid1;
|
||||
break;
|
||||
case 3:
|
||||
$r = $m;
|
||||
$g = $mid2;
|
||||
$b = $v;
|
||||
break;
|
||||
case 4:
|
||||
$r = $mid1;
|
||||
$g = $m;
|
||||
$b = $v;
|
||||
break;
|
||||
case 5:
|
||||
$r = $v;
|
||||
$g = $m;
|
||||
$b = $mid2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->red = round( $r * 255, 0 );
|
||||
$this->green = round( $g * 255, 0 );
|
||||
$this->blue = round( $b * 255, 0 );
|
||||
|
||||
$this->hex = $this->rgb_to_hex( $this->red, $this->green, $this->blue );
|
||||
$this->set_luminance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a CSS-formatted value for colors.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @param string $mode The mode we're using.
|
||||
* @return string
|
||||
*/
|
||||
public function toCSS( $mode = 'hex' ) {
|
||||
|
||||
$value = '';
|
||||
|
||||
switch ( $mode ) {
|
||||
case 'hex':
|
||||
$value = strtolower( $this->hex );
|
||||
break;
|
||||
case 'rgba':
|
||||
$value = 'rgba(' . $this->red . ',' . $this->green . ',' . $this->blue . ',' . $this->alpha . ')';
|
||||
break;
|
||||
case 'rgb':
|
||||
$value = 'rgb(' . $this->red . ',' . $this->green . ',' . $this->blue . ')';
|
||||
break;
|
||||
case 'hsl':
|
||||
$value = 'hsl(' . $this->hue . ',' . round( $this->saturation ) . '%,' . round( $this->lightness ) . '%)';
|
||||
break;
|
||||
case 'hsla':
|
||||
$value = 'hsla(' . $this->hue . ',' . round( $this->saturation ) . '%,' . round( $this->lightness ) . '%,' . $this->alpha . ')';
|
||||
break;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for the toCSS method.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.1
|
||||
* @param string $mode The mode we're using.
|
||||
* @return string
|
||||
*/
|
||||
public function to_css( $mode = 'hex' ) {
|
||||
return $this->toCSS( $mode );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the HSL values of a color based on the values of red, green, blue.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function set_hsl() {
|
||||
$red = $this->red / 255;
|
||||
$green = $this->green / 255;
|
||||
$blue = $this->blue / 255;
|
||||
|
||||
$max = max( $red, $green, $blue );
|
||||
$min = min( $red, $green, $blue );
|
||||
|
||||
$lightness = ( $max + $min ) / 2;
|
||||
$difference = $max - $min;
|
||||
|
||||
if ( ! $difference ) {
|
||||
$hue = $saturation = 0; // Achromatic.
|
||||
} else {
|
||||
$saturation = $difference / ( 1 - abs( 2 * $lightness - 1 ) );
|
||||
switch ( $max ) {
|
||||
case $red:
|
||||
$hue = 60 * fmod( ( ( $green - $blue ) / $difference ), 6 );
|
||||
if ( $blue > $green ) {
|
||||
$hue += 360;
|
||||
}
|
||||
break;
|
||||
case $green:
|
||||
$hue = 60 * ( ( $blue - $red ) / $difference + 2 );
|
||||
break;
|
||||
case $blue:
|
||||
$hue = 60 * ( ( $red - $green ) / $difference + 4 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->hue = round( $hue );
|
||||
$this->saturation = round( $saturation * 100 );
|
||||
$this->lightness = round( $lightness * 100 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the brightness of a color based on the values of red, green, blue.
|
||||
*
|
||||
* @access protected
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function set_brightness() {
|
||||
$this->brightness = array(
|
||||
'red' => round( $this->red * .299 ),
|
||||
'green' => round( $this->green * .587 ),
|
||||
'blue' => round( $this->blue * .114 ),
|
||||
'total' => intval( ( $this->red * .299 ) + ( $this->green * .587 ) + ( $this->blue * .114 ) ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the luminance of a color (range:0-255) based on the values of red, green, blue.
|
||||
*
|
||||
* @access protected
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function set_luminance() {
|
||||
$lum = ( 0.2126 * $this->red ) + ( 0.7152 * $this->green ) + ( 0.0722 * $this->blue );
|
||||
$this->luminance = round( $lum );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of all the wordcolors.
|
||||
*
|
||||
* @access protected
|
||||
* @since 1.0.0
|
||||
* @return array
|
||||
*/
|
||||
protected function get_word_colors() {
|
||||
return array(
|
||||
'aliceblue' => 'F0F8FF',
|
||||
'antiquewhite' => 'FAEBD7',
|
||||
'aqua' => '00FFFF',
|
||||
'aquamarine' => '7FFFD4',
|
||||
'azure' => 'F0FFFF',
|
||||
'beige' => 'F5F5DC',
|
||||
'bisque' => 'FFE4C4',
|
||||
'black' => '000000',
|
||||
'blanchedalmond' => 'FFEBCD',
|
||||
'blue' => '0000FF',
|
||||
'blueviolet' => '8A2BE2',
|
||||
'brown' => 'A52A2A',
|
||||
'burlywood' => 'DEB887',
|
||||
'cadetblue' => '5F9EA0',
|
||||
'chartreuse' => '7FFF00',
|
||||
'chocolate' => 'D2691E',
|
||||
'coral' => 'FF7F50',
|
||||
'cornflowerblue' => '6495ED',
|
||||
'cornsilk' => 'FFF8DC',
|
||||
'crimson' => 'DC143C',
|
||||
'cyan' => '00FFFF',
|
||||
'darkblue' => '00008B',
|
||||
'darkcyan' => '008B8B',
|
||||
'darkgoldenrod' => 'B8860B',
|
||||
'darkgray' => 'A9A9A9',
|
||||
'darkgreen' => '006400',
|
||||
'darkgrey' => 'A9A9A9',
|
||||
'darkkhaki' => 'BDB76B',
|
||||
'darkmagenta' => '8B008B',
|
||||
'darkolivegreen' => '556B2F',
|
||||
'darkorange' => 'FF8C00',
|
||||
'darkorchid' => '9932CC',
|
||||
'darkred' => '8B0000',
|
||||
'darksalmon' => 'E9967A',
|
||||
'darkseagreen' => '8FBC8F',
|
||||
'darkslateblue' => '483D8B',
|
||||
'darkslategray' => '2F4F4F',
|
||||
'darkslategrey' => '2F4F4F',
|
||||
'darkturquoise' => '00CED1',
|
||||
'darkviolet' => '9400D3',
|
||||
'deeppink' => 'FF1493',
|
||||
'deepskyblue' => '00BFFF',
|
||||
'dimgray' => '696969',
|
||||
'dimgrey' => '696969',
|
||||
'dodgerblue' => '1E90FF',
|
||||
'firebrick' => 'B22222',
|
||||
'floralwhite' => 'FFFAF0',
|
||||
'forestgreen' => '228B22',
|
||||
'fuchsia' => 'FF00FF',
|
||||
'gainsboro' => 'DCDCDC',
|
||||
'ghostwhite' => 'F8F8FF',
|
||||
'gold' => 'FFD700',
|
||||
'goldenrod' => 'DAA520',
|
||||
'gray' => '808080',
|
||||
'green' => '008000',
|
||||
'greenyellow' => 'ADFF2F',
|
||||
'grey' => '808080',
|
||||
'honeydew' => 'F0FFF0',
|
||||
'hotpink' => 'FF69B4',
|
||||
'indianred' => 'CD5C5C',
|
||||
'indigo' => '4B0082',
|
||||
'ivory' => 'FFFFF0',
|
||||
'khaki' => 'F0E68C',
|
||||
'lavender' => 'E6E6FA',
|
||||
'lavenderblush' => 'FFF0F5',
|
||||
'lawngreen' => '7CFC00',
|
||||
'lemonchiffon' => 'FFFACD',
|
||||
'lightblue' => 'ADD8E6',
|
||||
'lightcoral' => 'F08080',
|
||||
'lightcyan' => 'E0FFFF',
|
||||
'lightgoldenrodyellow' => 'FAFAD2',
|
||||
'lightgray' => 'D3D3D3',
|
||||
'lightgreen' => '90EE90',
|
||||
'lightgrey' => 'D3D3D3',
|
||||
'lightpink' => 'FFB6C1',
|
||||
'lightsalmon' => 'FFA07A',
|
||||
'lightseagreen' => '20B2AA',
|
||||
'lightskyblue' => '87CEFA',
|
||||
'lightslategray' => '778899',
|
||||
'lightslategrey' => '778899',
|
||||
'lightsteelblue' => 'B0C4DE',
|
||||
'lightyellow' => 'FFFFE0',
|
||||
'lime' => '00FF00',
|
||||
'limegreen' => '32CD32',
|
||||
'linen' => 'FAF0E6',
|
||||
'magenta' => 'FF00FF',
|
||||
'maroon' => '800000',
|
||||
'mediumaquamarine' => '66CDAA',
|
||||
'mediumblue' => '0000CD',
|
||||
'mediumorchid' => 'BA55D3',
|
||||
'mediumpurple' => '9370D0',
|
||||
'mediumseagreen' => '3CB371',
|
||||
'mediumslateblue' => '7B68EE',
|
||||
'mediumspringgreen' => '00FA9A',
|
||||
'mediumturquoise' => '48D1CC',
|
||||
'mediumvioletred' => 'C71585',
|
||||
'midnightblue' => '191970',
|
||||
'mintcream' => 'F5FFFA',
|
||||
'mistyrose' => 'FFE4E1',
|
||||
'moccasin' => 'FFE4B5',
|
||||
'navajowhite' => 'FFDEAD',
|
||||
'navy' => '000080',
|
||||
'oldlace' => 'FDF5E6',
|
||||
'olive' => '808000',
|
||||
'olivedrab' => '6B8E23',
|
||||
'orange' => 'FFA500',
|
||||
'orangered' => 'FF4500',
|
||||
'orchid' => 'DA70D6',
|
||||
'palegoldenrod' => 'EEE8AA',
|
||||
'palegreen' => '98FB98',
|
||||
'paleturquoise' => 'AFEEEE',
|
||||
'palevioletred' => 'DB7093',
|
||||
'papayawhip' => 'FFEFD5',
|
||||
'peachpuff' => 'FFDAB9',
|
||||
'peru' => 'CD853F',
|
||||
'pink' => 'FFC0CB',
|
||||
'plum' => 'DDA0DD',
|
||||
'powderblue' => 'B0E0E6',
|
||||
'purple' => '800080',
|
||||
'red' => 'FF0000',
|
||||
'rosybrown' => 'BC8F8F',
|
||||
'royalblue' => '4169E1',
|
||||
'saddlebrown' => '8B4513',
|
||||
'salmon' => 'FA8072',
|
||||
'sandybrown' => 'F4A460',
|
||||
'seagreen' => '2E8B57',
|
||||
'seashell' => 'FFF5EE',
|
||||
'sienna' => 'A0522D',
|
||||
'silver' => 'C0C0C0',
|
||||
'skyblue' => '87CEEB',
|
||||
'slateblue' => '6A5ACD',
|
||||
'slategray' => '708090',
|
||||
'slategrey' => '708090',
|
||||
'snow' => 'FFFAFA',
|
||||
'springgreen' => '00FF7F',
|
||||
'steelblue' => '4682B4',
|
||||
'tan' => 'D2B48C',
|
||||
'teal' => '008080',
|
||||
'thistle' => 'D8BFD8',
|
||||
'tomato' => 'FF6347',
|
||||
'turquoise' => '40E0D0',
|
||||
'violet' => 'EE82EE',
|
||||
'wheat' => 'F5DEB3',
|
||||
'white' => 'FFFFFF',
|
||||
'whitesmoke' => 'F5F5F5',
|
||||
'yellow' => 'FFFF00',
|
||||
'yellowgreen' => '9ACD32',
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Use fallback object.
|
||||
*
|
||||
* @access protected
|
||||
* @since 1.2.0
|
||||
*/
|
||||
protected function from_fallback() {
|
||||
$this->color = $this->fallback;
|
||||
|
||||
if ( ! $this->fallback_obj ) {
|
||||
$this->fallback_obj = self::newColor( $this->fallback );
|
||||
}
|
||||
$this->color = $this->fallback_obj->color;
|
||||
$this->mode = $this->fallback_obj->mode;
|
||||
$this->red = $this->fallback_obj->red;
|
||||
$this->green = $this->fallback_obj->green;
|
||||
$this->blue = $this->fallback_obj->blue;
|
||||
$this->alpha = $this->fallback_obj->alpha;
|
||||
$this->hue = $this->fallback_obj->hue;
|
||||
$this->saturation = $this->fallback_obj->saturation;
|
||||
$this->lightness = $this->fallback_obj->lightness;
|
||||
$this->luminance = $this->fallback_obj->luminance;
|
||||
$this->hex = $this->fallback_obj->hex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle non-existing public methods.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.1.0
|
||||
* @param string $name The method name.
|
||||
* @param mixed $arguments The method arguments.
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call( $name, $arguments ) {
|
||||
if ( method_exists( $this, $name ) ) {
|
||||
call_user_func( array( $this, $name ), $arguments );
|
||||
} else {
|
||||
return $arguments;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle non-existing public static methods.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 1.1.0
|
||||
* @param string $name The method name.
|
||||
* @param mixed $arguments The method arguments.
|
||||
* @return mixed
|
||||
*/
|
||||
public static function __callStatic( $name, $arguments ) {
|
||||
if ( method_exists( __CLASS__, $name ) ) {
|
||||
call_user_func( array( __CLASS__, $name ), $arguments );
|
||||
} else {
|
||||
return $arguments;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,342 @@
|
||||
<?php
|
||||
/**
|
||||
* Color Calculations class for Kirki
|
||||
* Initially built for the Shoestrap-3 theme and then tweaked for Kirki.
|
||||
*
|
||||
* @package Kirki
|
||||
* @category Core
|
||||
* @author Ari Stathopoulos (@aristath)
|
||||
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
// phpcs:ignoreFile
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper class for color manipulation.
|
||||
*/
|
||||
final class Kirki_Color extends ariColor {
|
||||
|
||||
/**
|
||||
* A proxy for the sanitize_color method.
|
||||
*
|
||||
* @param string|array $color The color.
|
||||
* @param bool $hash Whether we want to include a hash (#) at the beginning or not.
|
||||
* @return string The sanitized hex color.
|
||||
*/
|
||||
public static function sanitize_hex( $color = '#FFFFFF', $hash = true ) {
|
||||
if ( ! $hash ) {
|
||||
return ltrim( self::sanitize_color( $color, 'hex' ), '#' );
|
||||
}
|
||||
return self::sanitize_color( $color, 'hex' );
|
||||
}
|
||||
|
||||
/**
|
||||
* A proxy the sanitize_color method.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $color The color.
|
||||
* @return string
|
||||
*/
|
||||
public static function sanitize_rgba( $color ) {
|
||||
return self::sanitize_color( $color, 'rgba' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize colors.
|
||||
* Determine if the current value is a hex or an rgba color and call the appropriate method.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 0.8.5
|
||||
* @param string|array $color The color.
|
||||
* @param string $mode The mode to be used.
|
||||
* @return string
|
||||
*/
|
||||
public static function sanitize_color( $color = '', $mode = 'auto' ) {
|
||||
if ( is_string( $color ) && 'transparent' == trim( $color ) ) {
|
||||
return 'transparent';
|
||||
}
|
||||
$obj = ariColor::newColor( $color );
|
||||
if ( 'auto' == $mode ) {
|
||||
$mode = $obj->mode;
|
||||
}
|
||||
return $obj->toCSS( $mode );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rgb value of a color.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $color The color.
|
||||
* @param boolean $implode Whether we want to implode the values or not.
|
||||
* @return array|string
|
||||
*/
|
||||
public static function get_rgb( $color, $implode = false ) {
|
||||
$obj = ariColor::newColor( $color );
|
||||
if ( $implode ) {
|
||||
return $obj->toCSS( 'rgb' );
|
||||
}
|
||||
return array( $obj->red, $obj->green, $obj->blue );
|
||||
}
|
||||
|
||||
/**
|
||||
* A proxy for the sanitize_color method.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string|array $color The color to convert.
|
||||
* @return string The hex value of the color.
|
||||
*/
|
||||
public static function rgba2hex( $color ) {
|
||||
return self::sanitize_color( $color, 'hex' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the alpha channel from an rgba color.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $color The rgba color formatted like rgba(r,g,b,a).
|
||||
* @return int|float The alpha value of the color.
|
||||
*/
|
||||
public static function get_alpha_from_rgba( $color ) {
|
||||
$obj = ariColor::newColor( $color );
|
||||
return $obj->alpha;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rgba value of the $color.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $color The hex value of a color.
|
||||
* @param int|float $alpha Opacity level (0-1).
|
||||
* @return string
|
||||
*/
|
||||
public static function get_rgba( $color = '#fff', $alpha = 1 ) {
|
||||
$obj = ariColor::newColor( $color );
|
||||
if ( 1 == $alpha ) {
|
||||
return $obj->toCSS( 'rgba' );
|
||||
}
|
||||
// Make sure that opacity is properly formatted.
|
||||
// Converts 1-100 values to 0-1.
|
||||
if ( $alpha > 1 || $alpha < -1 ) {
|
||||
// Divide by 100.
|
||||
$alpha /= 100;
|
||||
}
|
||||
// Get absolute value.
|
||||
$alpha = abs( $alpha );
|
||||
// Max 1.
|
||||
if ( 1 < $alpha ) {
|
||||
$alpha = 1;
|
||||
}
|
||||
$new_obj = $obj->getNew( 'alpha', $alpha );
|
||||
return $new_obj->toCSS( 'rgba' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Strips the alpha value from an RGBA color string.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $color The RGBA color string.
|
||||
* @return string The corresponding RGB string.
|
||||
*/
|
||||
public static function rgba_to_rgb( $color ) {
|
||||
$obj = ariColor::newColor( $color );
|
||||
return $obj->toCSS( 'rgb' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the brightness of the $hex color.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $hex The hex value of a color.
|
||||
* @return int Value between 0 and 255.
|
||||
*/
|
||||
public static function get_brightness( $hex ) {
|
||||
$hex = self::sanitize_hex( $hex, false );
|
||||
|
||||
// Returns brightness value from 0 to 255.
|
||||
return intval( ( ( hexdec( substr( $hex, 0, 2 ) ) * 299 ) + ( hexdec( substr( $hex, 2, 2 ) ) * 587 ) + ( hexdec( substr( $hex, 4, 2 ) ) * 114 ) ) / 1000 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts brightness of the $hex color.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $hex The hex value of a color.
|
||||
* @param integer $steps Should be between -255 and 255. Negative = darker, positive = lighter.
|
||||
* @return string Returns hex color.
|
||||
*/
|
||||
public static function adjust_brightness( $hex, $steps ) {
|
||||
$hex = self::sanitize_hex( $hex, false );
|
||||
$steps = max( -255, min( 255, $steps ) );
|
||||
|
||||
// Adjust number of steps and keep it inside 0 to 255.
|
||||
$red = max( 0, min( 255, hexdec( substr( $hex, 0, 2 ) ) + $steps ) );
|
||||
$green = max( 0, min( 255, hexdec( substr( $hex, 2, 2 ) ) + $steps ) );
|
||||
$blue = max( 0, min( 255, hexdec( substr( $hex, 4, 2 ) ) + $steps ) );
|
||||
|
||||
$red_hex = str_pad( dechex( $red ), 2, '0', STR_PAD_LEFT );
|
||||
$green_hex = str_pad( dechex( $green ), 2, '0', STR_PAD_LEFT );
|
||||
$blue_hex = str_pad( dechex( $blue ), 2, '0', STR_PAD_LEFT );
|
||||
return self::sanitize_hex( $red_hex . $green_hex . $blue_hex );
|
||||
}
|
||||
|
||||
/**
|
||||
* Mixes 2 hex colors.
|
||||
* The "percentage" variable is the percent of the first color.
|
||||
* to be used it the mix. default is 50 (equal mix).
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string|false $hex1 Color.
|
||||
* @param string|false $hex2 Color.
|
||||
* @param int $percentage A value between 0 and 100.
|
||||
* @return string Returns hex color.
|
||||
*/
|
||||
public static function mix_colors( $hex1, $hex2, $percentage ) {
|
||||
$hex1 = self::sanitize_hex( $hex1, false );
|
||||
$hex2 = self::sanitize_hex( $hex2, false );
|
||||
$red = ( $percentage * hexdec( substr( $hex1, 0, 2 ) ) + ( 100 - $percentage ) * hexdec( substr( $hex2, 0, 2 ) ) ) / 100;
|
||||
$green = ( $percentage * hexdec( substr( $hex1, 2, 2 ) ) + ( 100 - $percentage ) * hexdec( substr( $hex2, 2, 2 ) ) ) / 100;
|
||||
$blue = ( $percentage * hexdec( substr( $hex1, 4, 2 ) ) + ( 100 - $percentage ) * hexdec( substr( $hex2, 4, 2 ) ) ) / 100;
|
||||
$red_hex = str_pad( dechex( $red ), 2, '0', STR_PAD_LEFT );
|
||||
$green_hex = str_pad( dechex( $green ), 2, '0', STR_PAD_LEFT );
|
||||
$blue_hex = str_pad( dechex( $blue ), 2, '0', STR_PAD_LEFT );
|
||||
return self::sanitize_hex( $red_hex . $green_hex . $blue_hex );
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert hex color to hsv.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $hex The hex value of color 1.
|
||||
* @return array Returns array( 'h', 's', 'v' ).
|
||||
*/
|
||||
public static function hex_to_hsv( $hex ) {
|
||||
$rgb = (array) (array) self::get_rgb( self::sanitize_hex( $hex, false ) );
|
||||
return self::rgb_to_hsv( $rgb );
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert hex color to hsv.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $color The rgb color to convert array( 'r', 'g', 'b' ).
|
||||
* @return array Returns array( 'h', 's', 'v' ).
|
||||
*/
|
||||
public static function rgb_to_hsv( $color = array() ) {
|
||||
$var_r = ( $color[0] / 255 );
|
||||
$var_g = ( $color[1] / 255 );
|
||||
$var_b = ( $color[2] / 255 );
|
||||
$var_min = min( $var_r, $var_g, $var_b );
|
||||
$var_max = max( $var_r, $var_g, $var_b );
|
||||
$del_max = $var_max - $var_min;
|
||||
$h = 0;
|
||||
$s = 0;
|
||||
$v = $var_max;
|
||||
if ( 0 != $del_max ) {
|
||||
$s = $del_max / $var_max;
|
||||
$del_r = ( ( ( $var_max - $var_r ) / 6 ) + ( $del_max / 2 ) ) / $del_max;
|
||||
$del_g = ( ( ( $var_max - $var_g ) / 6 ) + ( $del_max / 2 ) ) / $del_max;
|
||||
$del_b = ( ( ( $var_max - $var_b ) / 6 ) + ( $del_max / 2 ) ) / $del_max;
|
||||
if ( $var_r == $var_max ) {
|
||||
$h = $del_b - $del_g;
|
||||
} elseif ( $var_g == $var_max ) {
|
||||
$h = ( 1 / 3 ) + $del_r - $del_b;
|
||||
} elseif ( $var_b == $var_max ) {
|
||||
$h = ( 2 / 3 ) + $del_g - $del_r;
|
||||
}
|
||||
if ( $h < 0 ) {
|
||||
$h++;
|
||||
}
|
||||
if ( $h > 1 ) {
|
||||
$h--;
|
||||
}
|
||||
}
|
||||
return array(
|
||||
'h' => round( $h, 2 ),
|
||||
's' => round( $s, 2 ),
|
||||
'v' => round( $v, 2 ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a very simple algorithm that works by summing up the differences between the three color components red, green and blue.
|
||||
* A value higher than 500 is recommended for good readability.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $color_1 The 1st color.
|
||||
* @param string $color_2 The 2nd color.
|
||||
* @return string
|
||||
*/
|
||||
public static function color_difference( $color_1 = '#ffffff', $color_2 = '#000000' ) {
|
||||
$color_1 = self::sanitize_hex( $color_1, false );
|
||||
$color_2 = self::sanitize_hex( $color_2, false );
|
||||
$color_1_rgb = self::get_rgb( $color_1 );
|
||||
$color_2_rgb = self::get_rgb( $color_2 );
|
||||
$r_diff = max( $color_1_rgb[0], $color_2_rgb[0] ) - min( $color_1_rgb[0], $color_2_rgb[0] );
|
||||
$g_diff = max( $color_1_rgb[1], $color_2_rgb[1] ) - min( $color_1_rgb[1], $color_2_rgb[1] );
|
||||
$b_diff = max( $color_1_rgb[2], $color_2_rgb[2] ) - min( $color_1_rgb[2], $color_2_rgb[2] );
|
||||
$color_diff = $r_diff + $g_diff + $b_diff;
|
||||
return $color_diff;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function tries to compare the brightness of the colors.
|
||||
* A return value of more than 125 is recommended.
|
||||
* Combining it with the color_difference function above might make sense.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $color_1 The 1st color.
|
||||
* @param string $color_2 The 2nd color.
|
||||
* @return string
|
||||
*/
|
||||
public static function brightness_difference( $color_1 = '#ffffff', $color_2 = '#000000' ) {
|
||||
$color_1 = self::sanitize_hex( $color_1, false );
|
||||
$color_2 = self::sanitize_hex( $color_2, false );
|
||||
$color_1_rgb = self::get_rgb( $color_1 );
|
||||
$color_2_rgb = self::get_rgb( $color_2 );
|
||||
$br_1 = ( 299 * $color_1_rgb[0] + 587 * $color_1_rgb[1] + 114 * $color_1_rgb[2] ) / 1000;
|
||||
$br_2 = ( 299 * $color_2_rgb[0] + 587 * $color_2_rgb[1] + 114 * $color_2_rgb[2] ) / 1000;
|
||||
return intval( abs( $br_1 - $br_2 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses the luminosity to calculate the difference between the given colors.
|
||||
* The returned value should be bigger than 5 for best readability.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $color_1 The 1st color.
|
||||
* @param string $color_2 The 2nd color.
|
||||
* @return string
|
||||
*/
|
||||
public static function lumosity_difference( $color_1 = '#ffffff', $color_2 = '#000000' ) {
|
||||
$color_1 = self::sanitize_hex( $color_1, false );
|
||||
$color_2 = self::sanitize_hex( $color_2, false );
|
||||
$color_1_rgb = self::get_rgb( $color_1 );
|
||||
$color_2_rgb = self::get_rgb( $color_2 );
|
||||
$l1 = 0.2126 * pow( $color_1_rgb[0] / 255, 2.2 ) + 0.7152 * pow( $color_1_rgb[1] / 255, 2.2 ) + 0.0722 * pow( $color_1_rgb[2] / 255, 2.2 );
|
||||
$l2 = 0.2126 * pow( $color_2_rgb[0] / 255, 2.2 ) + 0.7152 * pow( $color_2_rgb[1] / 255, 2.2 ) + 0.0722 * pow( $color_2_rgb[2] / 255, 2.2 );
|
||||
$lum_diff = ( $l1 > $l2 ) ? ( $l1 + 0.05 ) / ( $l2 + 0.05 ) : ( $l2 + 0.05 ) / ( $l1 + 0.05 );
|
||||
return round( $lum_diff, 2 );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
// autoload.php @generated by Composer
|
||||
|
||||
if (PHP_VERSION_ID < 50600) {
|
||||
echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitc56aa391ac498061f8d648878e0e6144::getLoader();
|
||||
@@ -0,0 +1,572 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
/**
|
||||
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
|
||||
*
|
||||
* $loader = new \Composer\Autoload\ClassLoader();
|
||||
*
|
||||
* // register classes with namespaces
|
||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->add('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* // activate the autoloader
|
||||
* $loader->register();
|
||||
*
|
||||
* // to enable searching the include path (eg. for PEAR packages)
|
||||
* $loader->setUseIncludePath(true);
|
||||
*
|
||||
* In this example, if you try to use a class in the Symfony\Component
|
||||
* namespace or one of its children (Symfony\Component\Console for instance),
|
||||
* the autoloader will first look for the class under the component/
|
||||
* directory, and it will then fallback to the framework/ directory if not
|
||||
* found before giving up.
|
||||
*
|
||||
* This class is loosely based on the Symfony UniversalClassLoader.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @see https://www.php-fig.org/psr/psr-0/
|
||||
* @see https://www.php-fig.org/psr/psr-4/
|
||||
*/
|
||||
class ClassLoader
|
||||
{
|
||||
/** @var ?string */
|
||||
private $vendorDir;
|
||||
|
||||
// PSR-4
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<string, int>>
|
||||
*/
|
||||
private $prefixLengthsPsr4 = array();
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<int, string>>
|
||||
*/
|
||||
private $prefixDirsPsr4 = array();
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, string>
|
||||
*/
|
||||
private $fallbackDirsPsr4 = array();
|
||||
|
||||
// PSR-0
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<string, string[]>>
|
||||
*/
|
||||
private $prefixesPsr0 = array();
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, string>
|
||||
*/
|
||||
private $fallbackDirsPsr0 = array();
|
||||
|
||||
/** @var bool */
|
||||
private $useIncludePath = false;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
* @psalm-var array<string, string>
|
||||
*/
|
||||
private $classMap = array();
|
||||
|
||||
/** @var bool */
|
||||
private $classMapAuthoritative = false;
|
||||
|
||||
/**
|
||||
* @var bool[]
|
||||
* @psalm-var array<string, bool>
|
||||
*/
|
||||
private $missingClasses = array();
|
||||
|
||||
/** @var ?string */
|
||||
private $apcuPrefix;
|
||||
|
||||
/**
|
||||
* @var self[]
|
||||
*/
|
||||
private static $registeredLoaders = array();
|
||||
|
||||
/**
|
||||
* @param ?string $vendorDir
|
||||
*/
|
||||
public function __construct($vendorDir = null)
|
||||
{
|
||||
$this->vendorDir = $vendorDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getPrefixes()
|
||||
{
|
||||
if (!empty($this->prefixesPsr0)) {
|
||||
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return array<string, array<int, string>>
|
||||
*/
|
||||
public function getPrefixesPsr4()
|
||||
{
|
||||
return $this->prefixDirsPsr4;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return array<string, string>
|
||||
*/
|
||||
public function getFallbackDirs()
|
||||
{
|
||||
return $this->fallbackDirsPsr0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return array<string, string>
|
||||
*/
|
||||
public function getFallbackDirsPsr4()
|
||||
{
|
||||
return $this->fallbackDirsPsr4;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[] Array of classname => path
|
||||
* @psalm-return array<string, string>
|
||||
*/
|
||||
public function getClassMap()
|
||||
{
|
||||
return $this->classMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $classMap Class to filename map
|
||||
* @psalm-param array<string, string> $classMap
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addClassMap(array $classMap)
|
||||
{
|
||||
if ($this->classMap) {
|
||||
$this->classMap = array_merge($this->classMap, $classMap);
|
||||
} else {
|
||||
$this->classMap = $classMap;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-0 directories for a given prefix, either
|
||||
* appending or prepending to the ones previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param string[]|string $paths The PSR-0 root directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add($prefix, $paths, $prepend = false)
|
||||
{
|
||||
if (!$prefix) {
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr0
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
$this->fallbackDirsPsr0,
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$first = $prefix[0];
|
||||
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
||||
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
||||
|
||||
return;
|
||||
}
|
||||
if ($prepend) {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixesPsr0[$first][$prefix]
|
||||
);
|
||||
} else {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
$this->prefixesPsr0[$first][$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-4 directories for a given namespace, either
|
||||
* appending or prepending to the ones previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param string[]|string $paths The PSR-4 base directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addPsr4($prefix, $paths, $prepend = false)
|
||||
{
|
||||
if (!$prefix) {
|
||||
// Register directories for the root namespace.
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr4
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
$this->fallbackDirsPsr4,
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
||||
// Register directories for a new namespace.
|
||||
$length = strlen($prefix);
|
||||
if ('\\' !== $prefix[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
} elseif ($prepend) {
|
||||
// Prepend directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixDirsPsr4[$prefix]
|
||||
);
|
||||
} else {
|
||||
// Append directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
$this->prefixDirsPsr4[$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-0 directories for a given prefix,
|
||||
* replacing any others previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param string[]|string $paths The PSR-0 base directories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirsPsr0 = (array) $paths;
|
||||
} else {
|
||||
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-4 directories for a given namespace,
|
||||
* replacing any others previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param string[]|string $paths The PSR-4 base directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setPsr4($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirsPsr4 = (array) $paths;
|
||||
} else {
|
||||
$length = strlen($prefix);
|
||||
if ('\\' !== $prefix[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns on searching the include path for class files.
|
||||
*
|
||||
* @param bool $useIncludePath
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUseIncludePath($useIncludePath)
|
||||
{
|
||||
$this->useIncludePath = $useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to check if the autoloader uses the include path to check
|
||||
* for classes.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getUseIncludePath()
|
||||
{
|
||||
return $this->useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns off searching the prefix and fallback directories for classes
|
||||
* that have not been registered with the class map.
|
||||
*
|
||||
* @param bool $classMapAuthoritative
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setClassMapAuthoritative($classMapAuthoritative)
|
||||
{
|
||||
$this->classMapAuthoritative = $classMapAuthoritative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should class lookup fail if not found in the current class map?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isClassMapAuthoritative()
|
||||
{
|
||||
return $this->classMapAuthoritative;
|
||||
}
|
||||
|
||||
/**
|
||||
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
||||
*
|
||||
* @param string|null $apcuPrefix
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setApcuPrefix($apcuPrefix)
|
||||
{
|
||||
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The APCu prefix in use, or null if APCu caching is not enabled.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getApcuPrefix()
|
||||
{
|
||||
return $this->apcuPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
|
||||
if (null === $this->vendorDir) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($prepend) {
|
||||
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
|
||||
} else {
|
||||
unset(self::$registeredLoaders[$this->vendorDir]);
|
||||
self::$registeredLoaders[$this->vendorDir] = $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this instance as an autoloader.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
|
||||
if (null !== $this->vendorDir) {
|
||||
unset(self::$registeredLoaders[$this->vendorDir]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
* @return true|null True if loaded, null otherwise
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->findFile($class)) {
|
||||
includeFile($file);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the path to the file where the class is defined.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return string|false The path if found, false otherwise
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
// class map lookup
|
||||
if (isset($this->classMap[$class])) {
|
||||
return $this->classMap[$class];
|
||||
}
|
||||
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
|
||||
return false;
|
||||
}
|
||||
if (null !== $this->apcuPrefix) {
|
||||
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
|
||||
if ($hit) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
$file = $this->findFileWithExtension($class, '.php');
|
||||
|
||||
// Search for Hack files if we are running on HHVM
|
||||
if (false === $file && defined('HHVM_VERSION')) {
|
||||
$file = $this->findFileWithExtension($class, '.hh');
|
||||
}
|
||||
|
||||
if (null !== $this->apcuPrefix) {
|
||||
apcu_add($this->apcuPrefix.$class, $file);
|
||||
}
|
||||
|
||||
if (false === $file) {
|
||||
// Remember that this class does not exist.
|
||||
$this->missingClasses[$class] = true;
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently registered loaders indexed by their corresponding vendor directories.
|
||||
*
|
||||
* @return self[]
|
||||
*/
|
||||
public static function getRegisteredLoaders()
|
||||
{
|
||||
return self::$registeredLoaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
* @param string $ext
|
||||
* @return string|false
|
||||
*/
|
||||
private function findFileWithExtension($class, $ext)
|
||||
{
|
||||
// PSR-4 lookup
|
||||
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
||||
|
||||
$first = $class[0];
|
||||
if (isset($this->prefixLengthsPsr4[$first])) {
|
||||
$subPath = $class;
|
||||
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
||||
$subPath = substr($subPath, 0, $lastPos);
|
||||
$search = $subPath . '\\';
|
||||
if (isset($this->prefixDirsPsr4[$search])) {
|
||||
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
|
||||
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
||||
if (file_exists($file = $dir . $pathEnd)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-4 fallback dirs
|
||||
foreach ($this->fallbackDirsPsr4 as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 lookup
|
||||
if (false !== $pos = strrpos($class, '\\')) {
|
||||
// namespaced class name
|
||||
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
||||
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
||||
} else {
|
||||
// PEAR-like class name
|
||||
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
||||
}
|
||||
|
||||
if (isset($this->prefixesPsr0[$first])) {
|
||||
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
||||
if (0 === strpos($class, $prefix)) {
|
||||
foreach ($dirs as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 fallback dirs
|
||||
foreach ($this->fallbackDirsPsr0 as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 include paths.
|
||||
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope isolated include.
|
||||
*
|
||||
* Prevents access to $this/self from included files.
|
||||
*
|
||||
* @param string $file
|
||||
* @return void
|
||||
* @private
|
||||
*/
|
||||
function includeFile($file)
|
||||
{
|
||||
include $file;
|
||||
}
|
||||
@@ -0,0 +1,352 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer;
|
||||
|
||||
use Composer\Autoload\ClassLoader;
|
||||
use Composer\Semver\VersionParser;
|
||||
|
||||
/**
|
||||
* This class is copied in every Composer installed project and available to all
|
||||
*
|
||||
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
|
||||
*
|
||||
* To require its presence, you can require `composer-runtime-api ^2.0`
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class InstalledVersions
|
||||
{
|
||||
/**
|
||||
* @var mixed[]|null
|
||||
* @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}|array{}|null
|
||||
*/
|
||||
private static $installed;
|
||||
|
||||
/**
|
||||
* @var bool|null
|
||||
*/
|
||||
private static $canGetVendors;
|
||||
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
|
||||
*/
|
||||
private static $installedByVendor = array();
|
||||
|
||||
/**
|
||||
* Returns a list of all package names which are present, either by being installed, replaced or provided
|
||||
*
|
||||
* @return string[]
|
||||
* @psalm-return list<string>
|
||||
*/
|
||||
public static function getInstalledPackages()
|
||||
{
|
||||
$packages = array();
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
$packages[] = array_keys($installed['versions']);
|
||||
}
|
||||
|
||||
if (1 === \count($packages)) {
|
||||
return $packages[0];
|
||||
}
|
||||
|
||||
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all package names with a specific type e.g. 'library'
|
||||
*
|
||||
* @param string $type
|
||||
* @return string[]
|
||||
* @psalm-return list<string>
|
||||
*/
|
||||
public static function getInstalledPackagesByType($type)
|
||||
{
|
||||
$packagesByType = array();
|
||||
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
foreach ($installed['versions'] as $name => $package) {
|
||||
if (isset($package['type']) && $package['type'] === $type) {
|
||||
$packagesByType[] = $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $packagesByType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given package is installed
|
||||
*
|
||||
* This also returns true if the package name is provided or replaced by another package
|
||||
*
|
||||
* @param string $packageName
|
||||
* @param bool $includeDevRequirements
|
||||
* @return bool
|
||||
*/
|
||||
public static function isInstalled($packageName, $includeDevRequirements = true)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (isset($installed['versions'][$packageName])) {
|
||||
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given package satisfies a version constraint
|
||||
*
|
||||
* e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
|
||||
*
|
||||
* Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
|
||||
*
|
||||
* @param VersionParser $parser Install composer/semver to have access to this class and functionality
|
||||
* @param string $packageName
|
||||
* @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
|
||||
* @return bool
|
||||
*/
|
||||
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
||||
{
|
||||
$constraint = $parser->parseConstraints($constraint);
|
||||
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
||||
|
||||
return $provided->matches($constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a version constraint representing all the range(s) which are installed for a given package
|
||||
*
|
||||
* It is easier to use this via isInstalled() with the $constraint argument if you need to check
|
||||
* whether a given version of a package is installed, and not just whether it exists
|
||||
*
|
||||
* @param string $packageName
|
||||
* @return string Version constraint usable with composer/semver
|
||||
*/
|
||||
public static function getVersionRanges($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ranges = array();
|
||||
if (isset($installed['versions'][$packageName]['pretty_version'])) {
|
||||
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
|
||||
}
|
||||
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
|
||||
}
|
||||
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
|
||||
}
|
||||
if (array_key_exists('provided', $installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
|
||||
}
|
||||
|
||||
return implode(' || ', $ranges);
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
||||
*/
|
||||
public static function getVersion($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($installed['versions'][$packageName]['version'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $installed['versions'][$packageName]['version'];
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
||||
*/
|
||||
public static function getPrettyVersion($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($installed['versions'][$packageName]['pretty_version'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $installed['versions'][$packageName]['pretty_version'];
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
|
||||
*/
|
||||
public static function getReference($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($installed['versions'][$packageName]['reference'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $installed['versions'][$packageName]['reference'];
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
|
||||
*/
|
||||
public static function getInstallPath($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}
|
||||
*/
|
||||
public static function getRootPackage()
|
||||
{
|
||||
$installed = self::getInstalled();
|
||||
|
||||
return $installed[0]['root'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raw installed.php data for custom implementations
|
||||
*
|
||||
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
|
||||
* @return array[]
|
||||
* @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}
|
||||
*/
|
||||
public static function getRawData()
|
||||
{
|
||||
@trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
|
||||
|
||||
if (null === self::$installed) {
|
||||
// only require the installed.php file if this file is loaded from its dumped location,
|
||||
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
||||
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||
self::$installed = include __DIR__ . '/installed.php';
|
||||
} else {
|
||||
self::$installed = array();
|
||||
}
|
||||
}
|
||||
|
||||
return self::$installed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raw data of all installed.php which are currently loaded for custom implementations
|
||||
*
|
||||
* @return array[]
|
||||
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
|
||||
*/
|
||||
public static function getAllRawData()
|
||||
{
|
||||
return self::getInstalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets you reload the static array from another file
|
||||
*
|
||||
* This is only useful for complex integrations in which a project needs to use
|
||||
* this class but then also needs to execute another project's autoloader in process,
|
||||
* and wants to ensure both projects have access to their version of installed.php.
|
||||
*
|
||||
* A typical case would be PHPUnit, where it would need to make sure it reads all
|
||||
* the data it needs from this class, then call reload() with
|
||||
* `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
|
||||
* the project in which it runs can then also use this class safely, without
|
||||
* interference between PHPUnit's dependencies and the project's dependencies.
|
||||
*
|
||||
* @param array[] $data A vendor/composer/installed.php data set
|
||||
* @return void
|
||||
*
|
||||
* @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} $data
|
||||
*/
|
||||
public static function reload($data)
|
||||
{
|
||||
self::$installed = $data;
|
||||
self::$installedByVendor = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
|
||||
*/
|
||||
private static function getInstalled()
|
||||
{
|
||||
if (null === self::$canGetVendors) {
|
||||
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
|
||||
}
|
||||
|
||||
$installed = array();
|
||||
|
||||
if (self::$canGetVendors) {
|
||||
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
|
||||
if (isset(self::$installedByVendor[$vendorDir])) {
|
||||
$installed[] = self::$installedByVendor[$vendorDir];
|
||||
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
||||
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
|
||||
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
|
||||
self::$installed = $installed[count($installed) - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (null === self::$installed) {
|
||||
// only require the installed.php file if this file is loaded from its dumped location,
|
||||
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
||||
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||
self::$installed = require __DIR__ . '/installed.php';
|
||||
} else {
|
||||
self::$installed = array();
|
||||
}
|
||||
}
|
||||
$installed[] = self::$installed;
|
||||
|
||||
return $installed;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
Copyright (c) Nils Adermann, Jordi Boggiano
|
||||
|
||||
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.
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
// autoload_classmap.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
||||
);
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
// autoload_namespaces.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
);
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
// autoload_psr4.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Kirki\\Util\\' => array($vendorDir . '/kirki-framework/control-dashicons/src/Util', $vendorDir . '/kirki-framework/util/src'),
|
||||
'Kirki\\Settings\\' => array($vendorDir . '/kirki-framework/control-repeater/src/Settings'),
|
||||
'Kirki\\Module\\' => array($vendorDir . '/kirki-framework/module-css/src', $vendorDir . '/kirki-framework/module-editor-styles/src', $vendorDir . '/kirki-framework/module-field-dependencies/src', $vendorDir . '/kirki-framework/module-postmessage/src', $vendorDir . '/kirki-framework/module-preset/src', $vendorDir . '/kirki-framework/module-section-icons/src', $vendorDir . '/kirki-framework/module-selective-refresh/src', $vendorDir . '/kirki-framework/module-tooltips/src', $vendorDir . '/kirki-framework/module-webfonts/src'),
|
||||
'Kirki\\Field\\' => array($vendorDir . '/kirki-framework/control-checkbox/src/Field', $vendorDir . '/kirki-framework/control-code/src/Field', $vendorDir . '/kirki-framework/control-color/src/Field', $vendorDir . '/kirki-framework/control-color-palette/src/Field', $vendorDir . '/kirki-framework/control-custom/src/Field', $vendorDir . '/kirki-framework/control-dashicons/src/Field', $vendorDir . '/kirki-framework/control-date/src/Field', $vendorDir . '/kirki-framework/control-dimension/src/Field', $vendorDir . '/kirki-framework/control-editor/src/Field', $vendorDir . '/kirki-framework/control-generic/src/Field', $vendorDir . '/kirki-framework/control-image/src/Field', $vendorDir . '/kirki-framework/control-multicheck/src/Field', $vendorDir . '/kirki-framework/control-palette/src/Field', $vendorDir . '/kirki-framework/control-radio/src/Field', $vendorDir . '/kirki-framework/control-react-colorful/src/Field', $vendorDir . '/kirki-framework/control-react-select/src/Field', $vendorDir . '/kirki-framework/control-repeater/src/Field', $vendorDir . '/kirki-framework/control-select/src/Field', $vendorDir . '/kirki-framework/control-slider/src/Field', $vendorDir . '/kirki-framework/control-sortable/src/Field', $vendorDir . '/kirki-framework/control-upload/src/Field', $vendorDir . '/kirki-framework/field-background/src', $vendorDir . '/kirki-framework/field-dimensions/src', $vendorDir . '/kirki-framework/field-fontawesome/src/Field', $vendorDir . '/kirki-framework/field-multicolor/src/Field', $vendorDir . '/kirki-framework/field-typography/src/Field'),
|
||||
'Kirki\\Data\\' => array($vendorDir . '/kirki-framework/data-option/src'),
|
||||
'Kirki\\Control\\' => array($vendorDir . '/kirki-framework/control-base/src/Control', $vendorDir . '/kirki-framework/control-checkbox/src/Control', $vendorDir . '/kirki-framework/control-code/src/Control', $vendorDir . '/kirki-framework/control-color/src/Control', $vendorDir . '/kirki-framework/control-color-palette/src/Control', $vendorDir . '/kirki-framework/control-cropped-image/src', $vendorDir . '/kirki-framework/control-custom/src/Control', $vendorDir . '/kirki-framework/control-dashicons/src/Control', $vendorDir . '/kirki-framework/control-date/src/Control', $vendorDir . '/kirki-framework/control-dimension/src/Control', $vendorDir . '/kirki-framework/control-editor/src/Control', $vendorDir . '/kirki-framework/control-generic/src/Control', $vendorDir . '/kirki-framework/control-image/src/Control', $vendorDir . '/kirki-framework/control-multicheck/src/Control', $vendorDir . '/kirki-framework/control-palette/src/Control', $vendorDir . '/kirki-framework/control-radio/src/Control', $vendorDir . '/kirki-framework/control-react-colorful/src/Control', $vendorDir . '/kirki-framework/control-react-select/src/Control', $vendorDir . '/kirki-framework/control-repeater/src/Control', $vendorDir . '/kirki-framework/control-select/src/Control', $vendorDir . '/kirki-framework/control-slider/src/Control', $vendorDir . '/kirki-framework/control-sortable/src/Control', $vendorDir . '/kirki-framework/control-upload/src/Control', $vendorDir . '/kirki-framework/field-multicolor/src/Control', $vendorDir . '/kirki-framework/field-typography/src/Control'),
|
||||
'Kirki\\Compatibility\\' => array($vendorDir . '/kirki-framework/compatibility/src'),
|
||||
'Kirki\\' => array($vendorDir . '/kirki-framework/field/src', $vendorDir . '/kirki-framework/googlefonts/src', $vendorDir . '/kirki-framework/l10n/src', $vendorDir . '/kirki-framework/module-panels/src', $vendorDir . '/kirki-framework/module-sections/src', $vendorDir . '/kirki-framework/url-getter/src'),
|
||||
);
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInitc56aa391ac498061f8d648878e0e6144
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
public static function loadClassLoader($class)
|
||||
{
|
||||
if ('Composer\Autoload\ClassLoader' === $class) {
|
||||
require __DIR__ . '/ClassLoader.php';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Composer\Autoload\ClassLoader
|
||||
*/
|
||||
public static function getLoader()
|
||||
{
|
||||
if (null !== self::$loader) {
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
require __DIR__ . '/platform_check.php';
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitc56aa391ac498061f8d648878e0e6144', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitc56aa391ac498061f8d648878e0e6144', 'loadClassLoader'));
|
||||
|
||||
$includePaths = require __DIR__ . '/include_paths.php';
|
||||
$includePaths[] = get_include_path();
|
||||
set_include_path(implode(PATH_SEPARATOR, $includePaths));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitc56aa391ac498061f8d648878e0e6144::getInitializer($loader));
|
||||
|
||||
$loader->register(true);
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
// autoload_static.php @generated by Composer
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInitc56aa391ac498061f8d648878e0e6144
|
||||
{
|
||||
public static $prefixLengthsPsr4 = array (
|
||||
'K' =>
|
||||
array (
|
||||
'Kirki\\Util\\' => 11,
|
||||
'Kirki\\Settings\\' => 15,
|
||||
'Kirki\\Module\\' => 13,
|
||||
'Kirki\\Field\\' => 12,
|
||||
'Kirki\\Data\\' => 11,
|
||||
'Kirki\\Control\\' => 14,
|
||||
'Kirki\\Compatibility\\' => 20,
|
||||
'Kirki\\' => 6,
|
||||
),
|
||||
);
|
||||
|
||||
public static $prefixDirsPsr4 = array (
|
||||
'Kirki\\Util\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/kirki-framework/control-dashicons/src/Util',
|
||||
1 => __DIR__ . '/..' . '/kirki-framework/util/src',
|
||||
),
|
||||
'Kirki\\Settings\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/kirki-framework/control-repeater/src/Settings',
|
||||
),
|
||||
'Kirki\\Module\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/kirki-framework/module-css/src',
|
||||
1 => __DIR__ . '/..' . '/kirki-framework/module-editor-styles/src',
|
||||
2 => __DIR__ . '/..' . '/kirki-framework/module-field-dependencies/src',
|
||||
3 => __DIR__ . '/..' . '/kirki-framework/module-postmessage/src',
|
||||
4 => __DIR__ . '/..' . '/kirki-framework/module-preset/src',
|
||||
5 => __DIR__ . '/..' . '/kirki-framework/module-section-icons/src',
|
||||
6 => __DIR__ . '/..' . '/kirki-framework/module-selective-refresh/src',
|
||||
7 => __DIR__ . '/..' . '/kirki-framework/module-tooltips/src',
|
||||
8 => __DIR__ . '/..' . '/kirki-framework/module-webfonts/src',
|
||||
),
|
||||
'Kirki\\Field\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/kirki-framework/control-checkbox/src/Field',
|
||||
1 => __DIR__ . '/..' . '/kirki-framework/control-code/src/Field',
|
||||
2 => __DIR__ . '/..' . '/kirki-framework/control-color/src/Field',
|
||||
3 => __DIR__ . '/..' . '/kirki-framework/control-color-palette/src/Field',
|
||||
4 => __DIR__ . '/..' . '/kirki-framework/control-custom/src/Field',
|
||||
5 => __DIR__ . '/..' . '/kirki-framework/control-dashicons/src/Field',
|
||||
6 => __DIR__ . '/..' . '/kirki-framework/control-date/src/Field',
|
||||
7 => __DIR__ . '/..' . '/kirki-framework/control-dimension/src/Field',
|
||||
8 => __DIR__ . '/..' . '/kirki-framework/control-editor/src/Field',
|
||||
9 => __DIR__ . '/..' . '/kirki-framework/control-generic/src/Field',
|
||||
10 => __DIR__ . '/..' . '/kirki-framework/control-image/src/Field',
|
||||
11 => __DIR__ . '/..' . '/kirki-framework/control-multicheck/src/Field',
|
||||
12 => __DIR__ . '/..' . '/kirki-framework/control-palette/src/Field',
|
||||
13 => __DIR__ . '/..' . '/kirki-framework/control-radio/src/Field',
|
||||
14 => __DIR__ . '/..' . '/kirki-framework/control-react-colorful/src/Field',
|
||||
15 => __DIR__ . '/..' . '/kirki-framework/control-react-select/src/Field',
|
||||
16 => __DIR__ . '/..' . '/kirki-framework/control-repeater/src/Field',
|
||||
17 => __DIR__ . '/..' . '/kirki-framework/control-select/src/Field',
|
||||
18 => __DIR__ . '/..' . '/kirki-framework/control-slider/src/Field',
|
||||
19 => __DIR__ . '/..' . '/kirki-framework/control-sortable/src/Field',
|
||||
20 => __DIR__ . '/..' . '/kirki-framework/control-upload/src/Field',
|
||||
21 => __DIR__ . '/..' . '/kirki-framework/field-background/src',
|
||||
22 => __DIR__ . '/..' . '/kirki-framework/field-dimensions/src',
|
||||
23 => __DIR__ . '/..' . '/kirki-framework/field-fontawesome/src/Field',
|
||||
24 => __DIR__ . '/..' . '/kirki-framework/field-multicolor/src/Field',
|
||||
25 => __DIR__ . '/..' . '/kirki-framework/field-typography/src/Field',
|
||||
),
|
||||
'Kirki\\Data\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/kirki-framework/data-option/src',
|
||||
),
|
||||
'Kirki\\Control\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/kirki-framework/control-base/src/Control',
|
||||
1 => __DIR__ . '/..' . '/kirki-framework/control-checkbox/src/Control',
|
||||
2 => __DIR__ . '/..' . '/kirki-framework/control-code/src/Control',
|
||||
3 => __DIR__ . '/..' . '/kirki-framework/control-color/src/Control',
|
||||
4 => __DIR__ . '/..' . '/kirki-framework/control-color-palette/src/Control',
|
||||
5 => __DIR__ . '/..' . '/kirki-framework/control-cropped-image/src',
|
||||
6 => __DIR__ . '/..' . '/kirki-framework/control-custom/src/Control',
|
||||
7 => __DIR__ . '/..' . '/kirki-framework/control-dashicons/src/Control',
|
||||
8 => __DIR__ . '/..' . '/kirki-framework/control-date/src/Control',
|
||||
9 => __DIR__ . '/..' . '/kirki-framework/control-dimension/src/Control',
|
||||
10 => __DIR__ . '/..' . '/kirki-framework/control-editor/src/Control',
|
||||
11 => __DIR__ . '/..' . '/kirki-framework/control-generic/src/Control',
|
||||
12 => __DIR__ . '/..' . '/kirki-framework/control-image/src/Control',
|
||||
13 => __DIR__ . '/..' . '/kirki-framework/control-multicheck/src/Control',
|
||||
14 => __DIR__ . '/..' . '/kirki-framework/control-palette/src/Control',
|
||||
15 => __DIR__ . '/..' . '/kirki-framework/control-radio/src/Control',
|
||||
16 => __DIR__ . '/..' . '/kirki-framework/control-react-colorful/src/Control',
|
||||
17 => __DIR__ . '/..' . '/kirki-framework/control-react-select/src/Control',
|
||||
18 => __DIR__ . '/..' . '/kirki-framework/control-repeater/src/Control',
|
||||
19 => __DIR__ . '/..' . '/kirki-framework/control-select/src/Control',
|
||||
20 => __DIR__ . '/..' . '/kirki-framework/control-slider/src/Control',
|
||||
21 => __DIR__ . '/..' . '/kirki-framework/control-sortable/src/Control',
|
||||
22 => __DIR__ . '/..' . '/kirki-framework/control-upload/src/Control',
|
||||
23 => __DIR__ . '/..' . '/kirki-framework/field-multicolor/src/Control',
|
||||
24 => __DIR__ . '/..' . '/kirki-framework/field-typography/src/Control',
|
||||
),
|
||||
'Kirki\\Compatibility\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/kirki-framework/compatibility/src',
|
||||
),
|
||||
'Kirki\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/kirki-framework/field/src',
|
||||
1 => __DIR__ . '/..' . '/kirki-framework/googlefonts/src',
|
||||
2 => __DIR__ . '/..' . '/kirki-framework/l10n/src',
|
||||
3 => __DIR__ . '/..' . '/kirki-framework/module-panels/src',
|
||||
4 => __DIR__ . '/..' . '/kirki-framework/module-sections/src',
|
||||
5 => __DIR__ . '/..' . '/kirki-framework/url-getter/src',
|
||||
),
|
||||
);
|
||||
|
||||
public static $classMap = array (
|
||||
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
||||
);
|
||||
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitc56aa391ac498061f8d648878e0e6144::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitc56aa391ac498061f8d648878e0e6144::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitc56aa391ac498061f8d648878e0e6144::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
// include_paths.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
$baseDir . '/',
|
||||
$baseDir . '/core',
|
||||
);
|
||||
@@ -0,0 +1,437 @@
|
||||
<?php return array(
|
||||
'root' => array(
|
||||
'pretty_version' => '4.0.24',
|
||||
'version' => '4.0.24.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'reference' => NULL,
|
||||
'name' => 'kirki-framework/kirki',
|
||||
'dev' => true,
|
||||
),
|
||||
'versions' => array(
|
||||
'kirki-framework/compatibility' => array(
|
||||
'pretty_version' => 'v1.0.11',
|
||||
'version' => '1.0.11.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/compatibility',
|
||||
'aliases' => array(),
|
||||
'reference' => '551fdc67b39e7345fc49a785b2cdd0c2a9f0bc3e',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/control-base' => array(
|
||||
'pretty_version' => 'v1.0.4',
|
||||
'version' => '1.0.4.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/control-base',
|
||||
'aliases' => array(),
|
||||
'reference' => '0abf9e81f21e5256be879240cca98778e99851eb',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/control-checkbox' => array(
|
||||
'pretty_version' => 'v1.0.6',
|
||||
'version' => '1.0.6.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/control-checkbox',
|
||||
'aliases' => array(),
|
||||
'reference' => '1f581fd75cf9cae20788decbe56d5ef48d3b7bf8',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/control-code' => array(
|
||||
'pretty_version' => 'v1.0.2',
|
||||
'version' => '1.0.2.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/control-code',
|
||||
'aliases' => array(),
|
||||
'reference' => '88e7b01127fc7039e2c1fc6761184b0332f9a0c3',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/control-color' => array(
|
||||
'pretty_version' => 'v1.0.1',
|
||||
'version' => '1.0.1.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/control-color',
|
||||
'aliases' => array(),
|
||||
'reference' => '5820fa89e0e8dc69dd4864575074552434193e11',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/control-color-palette' => array(
|
||||
'pretty_version' => 'v1.0.3',
|
||||
'version' => '1.0.3.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/control-color-palette',
|
||||
'aliases' => array(),
|
||||
'reference' => '32715837449e9a6666253b28b538bd69d6718c67',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/control-cropped-image' => array(
|
||||
'pretty_version' => 'v1.0.1',
|
||||
'version' => '1.0.1.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/control-cropped-image',
|
||||
'aliases' => array(),
|
||||
'reference' => '549e7ddfe1a9fe2305fe6c1bc6cc80489d647452',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/control-custom' => array(
|
||||
'pretty_version' => 'v1.0.1',
|
||||
'version' => '1.0.1.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/control-custom',
|
||||
'aliases' => array(),
|
||||
'reference' => '103f4f813f1919c23ec41e81c81cfbf83ab0e78f',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/control-dashicons' => array(
|
||||
'pretty_version' => 'v1.0.1',
|
||||
'version' => '1.0.1.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/control-dashicons',
|
||||
'aliases' => array(),
|
||||
'reference' => '90210466bd4a53b6ab4468330064eabeaf242fd9',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/control-date' => array(
|
||||
'pretty_version' => 'v1.0.1',
|
||||
'version' => '1.0.1.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/control-date',
|
||||
'aliases' => array(),
|
||||
'reference' => '71e7fb60b5789d77579b12b202e5487cd2bd5dc2',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/control-dimension' => array(
|
||||
'pretty_version' => 'v1.0.2',
|
||||
'version' => '1.0.2.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/control-dimension',
|
||||
'aliases' => array(),
|
||||
'reference' => '7a64c587fd57fb5bdbeceb393b621457c4d9f515',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/control-editor' => array(
|
||||
'pretty_version' => 'v1.0.1',
|
||||
'version' => '1.0.1.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/control-editor',
|
||||
'aliases' => array(),
|
||||
'reference' => '5e27c3cc7b10eb317321790a5d8ddf57304cf2a2',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/control-generic' => array(
|
||||
'pretty_version' => 'v1.0.2',
|
||||
'version' => '1.0.2.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/control-generic',
|
||||
'aliases' => array(),
|
||||
'reference' => '5f87bb740ba92717b6b10b862e571919003906c4',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/control-image' => array(
|
||||
'pretty_version' => 'v1.0.2',
|
||||
'version' => '1.0.2.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/control-image',
|
||||
'aliases' => array(),
|
||||
'reference' => '32e2a2aff8a7e5d6ff9dfe530563a4381dc82e61',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/control-multicheck' => array(
|
||||
'pretty_version' => 'v1.0.2',
|
||||
'version' => '1.0.2.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/control-multicheck',
|
||||
'aliases' => array(),
|
||||
'reference' => '90098008c1988e7cd2b84c75ece68bbcd3bbeb70',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/control-palette' => array(
|
||||
'pretty_version' => 'v0.1.1',
|
||||
'version' => '0.1.1.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/control-palette',
|
||||
'aliases' => array(),
|
||||
'reference' => 'aca16701c2aaddab0cef3e429cdb753845e03ae0',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/control-radio' => array(
|
||||
'pretty_version' => 'v1.0.2',
|
||||
'version' => '1.0.2.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/control-radio',
|
||||
'aliases' => array(),
|
||||
'reference' => '1e47f185f8d95005c83e0ffbf3ff09faecea8eac',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/control-react-colorful' => array(
|
||||
'pretty_version' => 'v1.0.17',
|
||||
'version' => '1.0.17.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/control-react-colorful',
|
||||
'aliases' => array(),
|
||||
'reference' => '79258cdbcdd4ee8582560edc4a09c8ba45eaf219',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/control-react-select' => array(
|
||||
'pretty_version' => 'v1.1.5',
|
||||
'version' => '1.1.5.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/control-react-select',
|
||||
'aliases' => array(),
|
||||
'reference' => '4c156e42a36f74ff5b9b1e2797b1742845de9e47',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/control-repeater' => array(
|
||||
'pretty_version' => '1.0.5',
|
||||
'version' => '1.0.5.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/control-repeater',
|
||||
'aliases' => array(),
|
||||
'reference' => '5375e65054b7a73da4e735fa7bee831c7f6c1cfc',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/control-select' => array(
|
||||
'pretty_version' => 'v1.0.1',
|
||||
'version' => '1.0.1.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/control-select',
|
||||
'aliases' => array(),
|
||||
'reference' => '01abe2cbce62b7a566c890697a32506b94910156',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/control-slider' => array(
|
||||
'pretty_version' => 'v1.0.5',
|
||||
'version' => '1.0.5.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/control-slider',
|
||||
'aliases' => array(),
|
||||
'reference' => '40ce473123f0cb12da745467d69210cff3ffecf5',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/control-sortable' => array(
|
||||
'pretty_version' => 'v1.0.1',
|
||||
'version' => '1.0.1.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/control-sortable',
|
||||
'aliases' => array(),
|
||||
'reference' => 'ea4659bb2118c57ec6e24cd2ab06f36a3a528d26',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/control-upload' => array(
|
||||
'pretty_version' => 'v1.0.3',
|
||||
'version' => '1.0.3.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/control-upload',
|
||||
'aliases' => array(),
|
||||
'reference' => '13ea09c9330c6eb1d4452d5948866f226b0f8a0f',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/data-option' => array(
|
||||
'pretty_version' => 'v1.0.3',
|
||||
'version' => '1.0.3.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/data-option',
|
||||
'aliases' => array(),
|
||||
'reference' => '9a54f5c553e2f1e84f4ff620e271bfc16ee49ced',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/field' => array(
|
||||
'pretty_version' => 'v1.0.10',
|
||||
'version' => '1.0.10.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/field',
|
||||
'aliases' => array(),
|
||||
'reference' => '97f5bf659cc68d46e2bce62489acf2d2142b36e7',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/field-background' => array(
|
||||
'pretty_version' => 'v1.0.1',
|
||||
'version' => '1.0.1.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/field-background',
|
||||
'aliases' => array(),
|
||||
'reference' => '875b5e42c3de8a77d0a15c7dd55c8467cbf18373',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/field-dimensions' => array(
|
||||
'pretty_version' => 'v1.0.3',
|
||||
'version' => '1.0.3.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/field-dimensions',
|
||||
'aliases' => array(),
|
||||
'reference' => 'ac147cc95fb706664953471ef8f14cfb04f197fc',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/field-fontawesome' => array(
|
||||
'pretty_version' => 'v1.0.1',
|
||||
'version' => '1.0.1.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/field-fontawesome',
|
||||
'aliases' => array(),
|
||||
'reference' => '64d8954039eef1ff03429cdd13c81e4e6b278321',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/field-multicolor' => array(
|
||||
'pretty_version' => 'v1.0.3',
|
||||
'version' => '1.0.3.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/field-multicolor',
|
||||
'aliases' => array(),
|
||||
'reference' => '3e0df3f5548fb89b38cb144bc87992936ed7b536',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/field-typography' => array(
|
||||
'pretty_version' => 'v1.0.6',
|
||||
'version' => '1.0.6.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/field-typography',
|
||||
'aliases' => array(),
|
||||
'reference' => '2d96fc2d65325ce8474d55e083db742cf437c0dd',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/googlefonts' => array(
|
||||
'pretty_version' => '1.0.4',
|
||||
'version' => '1.0.4.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/googlefonts',
|
||||
'aliases' => array(),
|
||||
'reference' => '3fa0b6b5aacda3213ca7ccedcba3e6906aecb409',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/kirki' => array(
|
||||
'pretty_version' => '4.0.24',
|
||||
'version' => '4.0.24.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'reference' => NULL,
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/l10n' => array(
|
||||
'pretty_version' => 'v1.0.2',
|
||||
'version' => '1.0.2.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/l10n',
|
||||
'aliases' => array(),
|
||||
'reference' => '5a40875434ca075a09c81952547e3ccc7eeef704',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/module-css' => array(
|
||||
'pretty_version' => 'v1.0.11',
|
||||
'version' => '1.0.11.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/module-css',
|
||||
'aliases' => array(),
|
||||
'reference' => 'b53cff693b489cc7e4991ef725a66ddafa8aa84b',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/module-editor-styles' => array(
|
||||
'pretty_version' => 'v1.0.2',
|
||||
'version' => '1.0.2.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/module-editor-styles',
|
||||
'aliases' => array(),
|
||||
'reference' => 'a86f8b66fa0a442ce092c122b997c8d5f8d20951',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/module-field-dependencies' => array(
|
||||
'pretty_version' => 'v1.0.6',
|
||||
'version' => '1.0.6.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/module-field-dependencies',
|
||||
'aliases' => array(),
|
||||
'reference' => '5bf94bdce480d8405136cd5f0013ef42a775f167',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/module-panels' => array(
|
||||
'pretty_version' => 'v1.0.1',
|
||||
'version' => '1.0.1.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/module-panels',
|
||||
'aliases' => array(),
|
||||
'reference' => '1599dd344c15c49a837b5fdbddb1e37544bef979',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/module-postmessage' => array(
|
||||
'pretty_version' => '1.0.7',
|
||||
'version' => '1.0.7.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/module-postmessage',
|
||||
'aliases' => array(),
|
||||
'reference' => '9b2b419027f3b95a2546041a83fc5607492f35a5',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/module-preset' => array(
|
||||
'pretty_version' => 'v1.0.3',
|
||||
'version' => '1.0.3.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/module-preset',
|
||||
'aliases' => array(),
|
||||
'reference' => 'b4862fbeb9e441ed4ccd15f29a1d17d6f300f6a9',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/module-section-icons' => array(
|
||||
'pretty_version' => 'v0.1.0',
|
||||
'version' => '0.1.0.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/module-section-icons',
|
||||
'aliases' => array(),
|
||||
'reference' => '0e77b904692772974e5e291143f45056a5ab3665',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/module-sections' => array(
|
||||
'pretty_version' => 'v1.0.4',
|
||||
'version' => '1.0.4.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/module-sections',
|
||||
'aliases' => array(),
|
||||
'reference' => 'ee8c9120ddd7fe63e1ca39db93714b9b4e5d477c',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/module-selective-refresh' => array(
|
||||
'pretty_version' => 'v1.0.3',
|
||||
'version' => '1.0.3.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/module-selective-refresh',
|
||||
'aliases' => array(),
|
||||
'reference' => 'bfeb430cb7eff60f5ba79e0785cf413905202c42',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/module-tooltips' => array(
|
||||
'pretty_version' => 'v1.0.10',
|
||||
'version' => '1.0.10.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/module-tooltips',
|
||||
'aliases' => array(),
|
||||
'reference' => '5b4715bd236a4239356e408068bffc2f300f3cdf',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/module-webfonts' => array(
|
||||
'pretty_version' => 'v1.0.5',
|
||||
'version' => '1.0.5.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/module-webfonts',
|
||||
'aliases' => array(),
|
||||
'reference' => '6be8c298abc29bccc227e1b1dbcb029e6a072659',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/url-getter' => array(
|
||||
'pretty_version' => 'v1.0.5',
|
||||
'version' => '1.0.5.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/url-getter',
|
||||
'aliases' => array(),
|
||||
'reference' => 'cfe7ea5b51c5e9b5e7d706ed56694f54a972fae2',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/util' => array(
|
||||
'pretty_version' => 'v1.0.2',
|
||||
'version' => '1.0.2.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/util',
|
||||
'aliases' => array(),
|
||||
'reference' => 'fa3deaafe48055b56aedf80501817e3d9e83211c',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
// platform_check.php @generated by Composer
|
||||
|
||||
$issues = array();
|
||||
|
||||
if (!(PHP_VERSION_ID >= 70000)) {
|
||||
$issues[] = 'Your Composer dependencies require a PHP version ">= 7.0.0". You are running ' . PHP_VERSION . '.';
|
||||
}
|
||||
|
||||
if ($issues) {
|
||||
if (!headers_sent()) {
|
||||
header('HTTP/1.1 500 Internal Server Error');
|
||||
}
|
||||
if (!ini_get('display_errors')) {
|
||||
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
||||
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
|
||||
} elseif (!headers_sent()) {
|
||||
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
|
||||
}
|
||||
}
|
||||
trigger_error(
|
||||
'Composer detected issues in your platform: ' . implode(' ', $issues),
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
@@ -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.
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "kirki-framework/compatibility",
|
||||
"type": "library",
|
||||
"description": "Compatibility package for themes using the Kirki v3.x API.",
|
||||
"keywords": ["wordpress","customizer","framework"],
|
||||
"homepage": "https://kirki.org",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kirki Framework",
|
||||
"email": "connect@mapsteps.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.0"
|
||||
},
|
||||
"autoload" : {
|
||||
"psr-4" : {
|
||||
"Kirki\\Compatibility\\" : "src/"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
/**
|
||||
* Adds class aliases for backwards compatibility.
|
||||
*
|
||||
* @package Kirki
|
||||
* @category Core
|
||||
* @author Ari Stathopoulos (@aristath)
|
||||
* @copyright Copyright (c) 2020, David Vongries
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 0.1
|
||||
*/
|
||||
|
||||
namespace Kirki\Compatibility;
|
||||
|
||||
/**
|
||||
* Adds class aliases for backwards compatibility.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
class Aliases {
|
||||
|
||||
/**
|
||||
* An array of class aliases.
|
||||
*
|
||||
* @access private
|
||||
* @since 0.1
|
||||
* @var array
|
||||
*/
|
||||
private $aliases = [
|
||||
'generic' => [
|
||||
[ 'Kirki\Compatibility\Kirki', 'Kirki' ],
|
||||
[ 'Kirki\Compatibility\Config', 'Kirki_Config' ],
|
||||
[ 'Kirki\Compatibility\Control', 'Kirki_Control' ],
|
||||
[ 'Kirki\Compatibility\Field', 'Kirki_Field' ],
|
||||
[ 'Kirki\Util\Helper', 'Kirki_Helper' ],
|
||||
[ 'Kirki\Compatibility\Init', 'Kirki_Init' ],
|
||||
[ 'Kirki\L10n', 'Kirki_L10n' ],
|
||||
[ 'Kirki\Compatibility\Modules', 'Kirki_Modules' ],
|
||||
[ 'Kirki\Compatibility\Sanitize_Values', 'Kirki_Sanitize_Values' ],
|
||||
[ 'Kirki\Compatibility\Section', 'Kirki_Section' ],
|
||||
[ 'Kirki\Compatibility\Values', 'Kirki_Values' ],
|
||||
[ 'Kirki\Util\Util', 'Kirki_Util' ],
|
||||
[ 'Kirki\Compatibility\Framework', 'Kirki_Toolkit' ],
|
||||
[ 'Kirki\Module\CSS', 'Kirki_Modules_CSS' ],
|
||||
[ 'Kirki\Module\CSS\Output', 'Kirki_Output' ],
|
||||
[ 'Kirki\Module\CSS\Generator', 'Kirki_Modules_CSS_Generator' ],
|
||||
[ 'Kirki\Module\CSS\Property', 'Kirki_Output_Property' ],
|
||||
[ 'Kirki\Module\CSS\Property\Font_Family', 'Kirki_Output_Property_Font_Family' ],
|
||||
[ 'Kirki\Module\Preset', 'Kirki_Modules_Preset' ],
|
||||
[ 'Kirki\Module\Tooltips', 'Kirki_Modules_Tooltips' ],
|
||||
[ 'Kirki\Module\Webfonts', 'Kirki_Modules_Webfonts' ],
|
||||
[ 'Kirki\Module\Webfonts\Google', 'Kirki_Fonts_Google' ],
|
||||
[ 'Kirki\Module\Webfonts\Fonts', 'Kirki_Fonts' ],
|
||||
[ 'Kirki\Module\Webfonts\Embed', 'Kirki_Modules_Webfonts_Embed' ],
|
||||
[ 'Kirki\Module\Webfonts\Async', 'Kirki_Modules_Webfonts_Async' ],
|
||||
[ 'Kirki\Module\Field_Dependencies', 'Kirki_Modules_Field_Dependencies' ],
|
||||
[ 'Kirki\Module\Editor_Styles', 'Kirki_Modules_Gutenberg' ],
|
||||
[ 'Kirki\Module\Selective_Refresh', 'Kirki_Modules_Selective_Refresh' ],
|
||||
[ 'Kirki\Module\Postmessage', 'Kirki_Modules_Postmessage' ],
|
||||
[ 'Kirki\Field\Background', 'Kirki_Field_Background' ],
|
||||
[ 'Kirki\Field\CSS\Background', 'Kirki_Output_Field_Background' ],
|
||||
[ 'Kirki\Field\Checkbox', 'Kirki_Field_Checkbox' ],
|
||||
[ 'Kirki\Field\Checkbox_Switch', 'Kirki_Field_Switch' ],
|
||||
[ 'Kirki\Field\Checkbox_Switch', 'Kirki\Field\Switch' ], // Preventing typo.
|
||||
[ 'Kirki\Field\Checkbox_Toggle', 'Kirki_Field_Toggle' ],
|
||||
[ 'Kirki\Field\Checkbox_Toggle', 'Kirki\Field\Toggle' ], // Preventing typo.
|
||||
[ 'Kirki\Field\Code', 'Kirki_Field_Code' ],
|
||||
[ 'Kirki\Field\Color', 'Kirki_Field_Color' ],
|
||||
[ 'Kirki\Field\Color', 'Kirki_Field_Color_Alpha' ],
|
||||
[ 'Kirki\Field\Color_Palette', 'Kirki_Field_Color_Palette' ],
|
||||
[ 'Kirki\Field\Custom', 'Kirki_Field_Custom' ],
|
||||
[ 'Kirki\Field\Dashicons', 'Kirki_Field_Dashicons' ],
|
||||
[ 'Kirki\Field\Date', 'Kirki_Field_Date' ],
|
||||
[ 'Kirki\Field\Dimension', 'Kirki_Field_Dimension' ],
|
||||
[ 'Kirki\Field\Dimensions', 'Kirki_Field_Dimensions' ],
|
||||
[ 'Kirki\Field\CSS\Dimensions', 'Kirki_Output_Field_Dimensions' ],
|
||||
[ 'Kirki\Field\Dimensions', 'Kirki_Field_Spacing' ],
|
||||
[ 'Kirki\Field\Dimensions', 'Kirki\Field\Spacing' ],
|
||||
[ 'Kirki\Field\Editor', 'Kirki_Field_Editor' ],
|
||||
[ 'Kirki\Field\FontAwesome', 'Kirki_Field_FontAwesome' ],
|
||||
[ 'Kirki\Field\Generic', 'Kirki_Field_Kirki_Generic' ],
|
||||
[ 'Kirki\Field\Generic', 'Kirki_Field_Generic' ],
|
||||
[ 'Kirki\Field\Text', 'Kirki_Field_Text' ],
|
||||
[ 'Kirki\Field\Textarea', 'Kirki_Field_Textarea' ],
|
||||
[ 'Kirki\Field\URL', 'Kirki_Field_URL' ],
|
||||
[ 'Kirki\Field\URL', 'Kirki_Field_Link' ],
|
||||
[ 'Kirki\Field\URL', 'Kirki\Field\Link' ],
|
||||
[ 'Kirki\Field\Image', 'Kirki_Field_Image' ],
|
||||
[ 'Kirki\Field\CSS\Image', 'Kirki_Output_Field_Image' ],
|
||||
[ 'Kirki\Field\Multicheck', 'Kirki_Field_Multicheck' ],
|
||||
[ 'Kirki\Field\Multicolor', 'Kirki_Field_Multicolor' ],
|
||||
[ 'Kirki\Field\CSS\Multicolor', 'Kirki_Output_Field_Multicolor' ],
|
||||
[ 'Kirki\Field\Number', 'Kirki_Field_Number' ],
|
||||
[ 'Kirki\Field\Palette', 'Kirki_Field_Palette' ],
|
||||
[ 'Kirki\Field\Repeater', 'Kirki_Field_Repeater' ],
|
||||
[ 'Kirki\Field\Dropdown_Pages', 'Kirki_Field_Dropdown_Pages' ],
|
||||
[ 'Kirki\Field\Preset', 'Kirki_Field_Preset' ],
|
||||
[ 'Kirki\Field\Select', 'Kirki_Field_Select' ],
|
||||
[ 'Kirki\Field\Slider', 'Kirki_Field_Slider' ],
|
||||
[ 'Kirki\Field\Sortable', 'Kirki_Field_Sortable' ],
|
||||
[ 'Kirki\Field\Typography', 'Kirki_Field_Typography' ],
|
||||
[ 'Kirki\Field\CSS\Typography', 'Kirki_Output_Field_Typography' ],
|
||||
[ 'Kirki\Field\Upload', 'Kirki_Field_Upload' ],
|
||||
],
|
||||
'customizer' => [
|
||||
[ 'Kirki\Control\Base', 'Kirki_Control_Base' ],
|
||||
[ 'Kirki\Control\Base', 'Kirki_Customize_Control' ],
|
||||
[ 'Kirki\Control\Checkbox', 'Kirki_Control_Checkbox' ],
|
||||
[ 'Kirki\Control\Checkbox_Switch', 'Kirki_Control_Switch' ],
|
||||
[ 'Kirki\Control\Checkbox_Toggle', 'Kirki_Control_Toggle' ],
|
||||
[ 'WP_Customize_Code_Editor_Control', 'Kirki_Control_Code' ],
|
||||
[ 'Kirki\Control\Color', 'Kirki_Control_Color' ],
|
||||
[ 'Kirki\Control\Color_Palette', 'Kirki_Control_Color_Palette' ],
|
||||
[ 'WP_Customize_Cropped_Image_Control', 'Kirki_Control_Cropped_Image' ],
|
||||
[ 'Kirki\Control\Custom', 'Kirki_Control_Custom' ],
|
||||
[ 'Kirki\Control\Dashicons', 'Kirki_Control_Dashicons' ],
|
||||
[ 'Kirki\Control\Date', 'Kirki_Control_Date' ],
|
||||
[ 'Kirki\Control\Dimension', 'Kirki_Control_Dimension' ],
|
||||
[ 'Kirki\Control\Editor', 'Kirki_Control_Editor' ],
|
||||
[ 'Kirki\Control\Generic', 'Kirki_Control_Generic' ],
|
||||
[ 'Kirki\Control\Image', 'Kirki_Control_Image' ],
|
||||
[ 'Kirki\Control\Multicheck', 'Kirki_Control_Multicheck' ],
|
||||
[ 'Kirki\Control\Generic', 'Kirki_Control_Number' ],
|
||||
[ 'Kirki\Control\Palette', 'Kirki_Control_Palette' ],
|
||||
[ 'Kirki\Control\Radio', 'Kirki_Control_Radio' ],
|
||||
[ 'Kirki\Control\Radio_Buttonset', 'Kirki_Control_Radio_Buttonset' ],
|
||||
[ 'Kirki\Control\Radio_Image', 'Kirki_Control_Radio_Image' ],
|
||||
[ 'Kirki\Control\Radio_Image', 'Kirki_Controls_Radio_Image_Control' ],
|
||||
[ 'Kirki\Control\Repeater', 'Kirki_Control_Repeater' ],
|
||||
[ 'Kirki\Control\Select', 'Kirki_Control_Select' ],
|
||||
[ 'Kirki\Control\Slider', 'Kirki_Control_Slider' ],
|
||||
[ 'Kirki\Control\Sortable', 'Kirki_Control_Sortable' ],
|
||||
[ 'Kirki\Control\Upload', 'Kirki_Control_Upload' ],
|
||||
[ 'Kirki\Settings\Repeater', 'Kirki\Settings\Repeater_Setting' ],
|
||||
[ 'Kirki\Settings\Repeater', 'Kirki_Settings_Repeater_Setting' ],
|
||||
[ 'WP_Customize_Section', 'Kirki_Sections_Default_Section' ],
|
||||
[ 'Kirki\Section_Types\Expanded', 'Kirki_Sections_Expanded_Section' ],
|
||||
[ 'Kirki\Section_Types\Nested', 'Kirki_Sections_Nested_Section' ],
|
||||
[ 'Kirki\Section_Types\Link', 'Kirki_Sections_Link_Section' ],
|
||||
[ 'Kirki\Panel_Types\Nested', 'Kirki_Panels_Nested_Panel' ],
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @access public
|
||||
* @since 0.1
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->add_aliases();
|
||||
add_action( 'customize_register', [ $this, 'add_customizer_aliases' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds object aliases.
|
||||
*
|
||||
* @access public
|
||||
* @since 0.1
|
||||
* @return void
|
||||
*/
|
||||
public function add_aliases() {
|
||||
foreach ( $this->aliases['generic'] as $item ) {
|
||||
if ( class_exists( $item[0] ) ) {
|
||||
class_alias( $item[0], $item[1] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds object aliases for classes that get instantiated on customize_register.
|
||||
*
|
||||
* @access public
|
||||
* @since 0.1
|
||||
* @return void
|
||||
*/
|
||||
public function add_customizer_aliases() {
|
||||
foreach ( $this->aliases['customizer'] as $item ) {
|
||||
if ( class_exists( $item[0] ) ) {
|
||||
class_alias( $item[0], $item[1] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
/**
|
||||
* Processes configurations.
|
||||
*
|
||||
* @package Kirki
|
||||
* @category Compatibility
|
||||
* @author Ari Stathopoulos (@aristath)
|
||||
* @copyright Copyright (c) 2020, David Vongries
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Kirki\Compatibility;
|
||||
|
||||
/**
|
||||
* The Config object
|
||||
*/
|
||||
final class Config {
|
||||
|
||||
/**
|
||||
* Each instance is stored separately in this array.
|
||||
*
|
||||
* @static
|
||||
* @access private
|
||||
* @var array
|
||||
*/
|
||||
private static $instances = [];
|
||||
|
||||
/**
|
||||
* The finalized configuration array.
|
||||
*
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
protected $config_final = [];
|
||||
|
||||
/**
|
||||
* The configuration ID.
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $id = 'global';
|
||||
|
||||
/**
|
||||
* Capability (fields will inherit this).
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $capability = 'edit_theme_options';
|
||||
|
||||
/**
|
||||
* The data-type we'll be using.
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $option_type = 'theme_mod';
|
||||
|
||||
/**
|
||||
* If we're using serialized options, then this is the global option name.
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $option_name = '';
|
||||
|
||||
/**
|
||||
* The compiler.
|
||||
*
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
protected $compiler = [];
|
||||
|
||||
/**
|
||||
* Set to true if you want to completely disable any Kirki-generated CSS.
|
||||
*
|
||||
* @access protected
|
||||
* @var bool
|
||||
*/
|
||||
protected $disable_output = false;
|
||||
|
||||
/**
|
||||
* The class constructor.
|
||||
* Use the get_instance() static method to get the instance you need.
|
||||
*
|
||||
* @access private
|
||||
* @param string $config_id @see Kirki\Compatibility\Config::get_instance().
|
||||
* @param array $args @see Kirki\Compatibility\Config::get_instance().
|
||||
*/
|
||||
private function __construct( $config_id = 'global', $args = [] ) {
|
||||
|
||||
// Get defaults from the class.
|
||||
$defaults = get_class_vars( __CLASS__ );
|
||||
// Skip what we don't need in this context.
|
||||
unset( $defaults['config_final'] );
|
||||
unset( $defaults['instances'] );
|
||||
// Apply any kirki_config global filters.
|
||||
$defaults = apply_filters( 'kirki_config', $defaults );
|
||||
// Merge our args with the defaults.
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
||||
// Modify default values with the defined ones.
|
||||
foreach ( $args as $key => $value ) {
|
||||
// Is this property whitelisted?
|
||||
if ( property_exists( $this, $key ) ) {
|
||||
$args[ $key ] = $value;
|
||||
}
|
||||
}
|
||||
$this->id = $config_id;
|
||||
|
||||
$this->config_final = wp_parse_args(
|
||||
[
|
||||
'id' => $config_id,
|
||||
],
|
||||
$args
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to get an instance of your config.
|
||||
* Each config has its own instance of this object.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $id Config ID.
|
||||
* @param array $args {
|
||||
* Optional. Arguments to override config defaults.
|
||||
*
|
||||
* @type string $capability @see https://codex.wordpress.org/Roles_and_Capabilities
|
||||
* @type string $option_type theme_mod or option.
|
||||
* @type string $option_name If we want to used serialized options,
|
||||
* this is where we'll be adding the option name.
|
||||
* All fields using this config will be items in that array.
|
||||
* @type array $compiler Not yet fully implemented
|
||||
* @type bool $disable_output If set to true, no CSS will be generated
|
||||
* from fields using this configuration.
|
||||
* }
|
||||
*
|
||||
* @return Kirki\Compatibility\Config
|
||||
*/
|
||||
public static function get_instance( $id = 'global', $args = [] ) {
|
||||
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 ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the IDs of all current configs.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 3.0.22
|
||||
* @return array
|
||||
*/
|
||||
public static function get_config_ids() {
|
||||
$configs = [];
|
||||
foreach ( self::$instances as $instance ) {
|
||||
$configs[] = $instance->id;
|
||||
}
|
||||
return array_unique( $configs );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the $config_final property
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function get_config() {
|
||||
return $this->config_final;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/**
|
||||
* Controls handler
|
||||
*
|
||||
* @package Kirki
|
||||
* @category Core
|
||||
* @author Ari Stathopoulos (@aristath)
|
||||
* @copyright Copyright (c) 2020, David Vongries
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Kirki\Compatibility;
|
||||
|
||||
/**
|
||||
* Our main Kirki\Control object
|
||||
*/
|
||||
class Control {
|
||||
|
||||
/**
|
||||
* The $wp_customize WordPress global.
|
||||
*
|
||||
* @access protected
|
||||
* @var WP_Customize_Manager
|
||||
*/
|
||||
protected $wp_customize;
|
||||
|
||||
/**
|
||||
* An array of all available control types.
|
||||
*
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
protected static $control_types = [];
|
||||
|
||||
/**
|
||||
* The class constructor.
|
||||
* Creates the actual controls in the customizer.
|
||||
*
|
||||
* @access public
|
||||
* @param array $args The field definition as sanitized in Kirki\Field.
|
||||
*/
|
||||
public function __construct( $args ) {
|
||||
|
||||
// Set the $wp_customize property.
|
||||
global $wp_customize;
|
||||
if ( ! $wp_customize ) {
|
||||
return;
|
||||
}
|
||||
$this->wp_customize = $wp_customize;
|
||||
|
||||
// Set the control types.
|
||||
$this->set_control_types();
|
||||
|
||||
// Add the control.
|
||||
$this->add_control( $args );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class name of the class needed to create tis control.
|
||||
*
|
||||
* @access private
|
||||
* @param array $args The field definition as sanitized in Kirki\Field.
|
||||
*
|
||||
* @return string the name of the class that will be used to create this control.
|
||||
*/
|
||||
final function get_control_class_name( $args ) {
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the control.
|
||||
*
|
||||
* @access protected
|
||||
* @param array $args The field definition as sanitized in Kirki\Field.
|
||||
*/
|
||||
final protected function add_control( $args ) {
|
||||
|
||||
// Get the name of the class we're going to use.
|
||||
$class_name = $this->get_control_class_name( $args );
|
||||
|
||||
/**
|
||||
* Allow filtering the arguments.
|
||||
*
|
||||
* @since 0.1
|
||||
* @param array $args The arguments.
|
||||
* @param WP_Customize_Manager $wp_customize The customizer instance.
|
||||
* @return array Return the arguments.
|
||||
*/
|
||||
$args = apply_filters( 'kirki_field_add_control_args', $args, $this->wp_customize );
|
||||
|
||||
// Add the control.
|
||||
$this->wp_customize->add_control( new $class_name( $this->wp_customize, $args['settings'], $args ) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the $control_types property.
|
||||
* Makes sure the kirki_control_types filter is applied
|
||||
* and that the defined classes actually exist.
|
||||
* If a defined class does not exist, it is removed.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
final function set_control_types() {
|
||||
|
||||
// Early exit if this has already run.
|
||||
if ( ! empty( self::$control_types ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
self::$control_types = apply_filters( 'kirki_control_types', [] );
|
||||
|
||||
// Make sure the defined classes actually exist.
|
||||
foreach ( self::$control_types as $key => $classname ) {
|
||||
if ( ! class_exists( $classname ) ) {
|
||||
unset( self::$control_types[ $key ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Backwards-compatibility for Kirki filters.
|
||||
*
|
||||
* @package Kirki
|
||||
* @category Core
|
||||
* @author Ari Stathopoulos (@aristath)
|
||||
* @copyright Copyright (c) 2020, David Vongries
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Compatibility;
|
||||
|
||||
/**
|
||||
* Please do not use this class directly.
|
||||
* You should instead extend it per-field-type.
|
||||
*/
|
||||
class Deprecated {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
*/
|
||||
public function __construct() {
|
||||
require_once __DIR__ . '/deprecated/classes.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude
|
||||
require_once __DIR__ . '/deprecated/functions.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude
|
||||
require_once __DIR__ . '/deprecated/filters.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,677 @@
|
||||
<?php
|
||||
/**
|
||||
* Creates and validates field parameters.
|
||||
*
|
||||
* @package Kirki
|
||||
* @category Core
|
||||
* @author Ari Stathopoulos (@aristath)
|
||||
* @copyright Copyright (c) 2020, David Vongries
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Compatibility;
|
||||
|
||||
use Kirki\Compatibility\Kirki;
|
||||
|
||||
/**
|
||||
* Please do not use this class directly.
|
||||
* You should instead extend it per-field-type.
|
||||
*/
|
||||
class Field {
|
||||
|
||||
/**
|
||||
* An array of the field arguments.
|
||||
*
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
protected $args = [];
|
||||
|
||||
/**
|
||||
* The ID of the kirki_config we're using.
|
||||
*
|
||||
* @see Kirki\Compatibility\Config
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $kirki_config = 'global';
|
||||
|
||||
/**
|
||||
* The capability required so that users can edit this field.
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $capability = 'edit_theme_options';
|
||||
|
||||
/**
|
||||
* If we're using options instead of theme_mods
|
||||
* and we want them serialized, this is the option that
|
||||
* will saved in the db.
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $option_name = '';
|
||||
|
||||
/**
|
||||
* Custom input attributes (defined as an array).
|
||||
*
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
protected $input_attrs = [];
|
||||
|
||||
/**
|
||||
* Preset choices.
|
||||
*
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
protected $preset = [];
|
||||
|
||||
/**
|
||||
* CSS Variables.
|
||||
*
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
protected $css_vars = [];
|
||||
|
||||
/**
|
||||
* Use "theme_mod" or "option".
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $option_type = 'theme_mod';
|
||||
|
||||
/**
|
||||
* The name of this setting (id for the db).
|
||||
*
|
||||
* @access protected
|
||||
* @var string|array
|
||||
*/
|
||||
protected $settings = '';
|
||||
|
||||
/**
|
||||
* Set to true if you want to disable all CSS output for this field.
|
||||
*
|
||||
* @access protected
|
||||
* @var bool
|
||||
*/
|
||||
protected $disable_output = false;
|
||||
|
||||
/**
|
||||
* The field type.
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $type = 'kirki-generic';
|
||||
|
||||
/**
|
||||
* Some fields require options to be set.
|
||||
* We're whitelisting the property here
|
||||
* and suggest you validate this in a child class.
|
||||
*
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
protected $choices = [];
|
||||
|
||||
/**
|
||||
* Assign this field to a section.
|
||||
* Fields not assigned to a section will not be displayed in the customizer.
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $section = '';
|
||||
|
||||
/**
|
||||
* The default value for this field.
|
||||
*
|
||||
* @access protected
|
||||
* @var string|array|bool
|
||||
*/
|
||||
protected $default = '';
|
||||
|
||||
/**
|
||||
* Priority determines the position of a control inside a section.
|
||||
* Lower priority numbers move the control to the top.
|
||||
*
|
||||
* @access protected
|
||||
* @var int
|
||||
*/
|
||||
protected $priority = 10;
|
||||
|
||||
/**
|
||||
* Unique ID for this field.
|
||||
* This is auto-calculated from the $settings argument.
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $id = '';
|
||||
|
||||
/**
|
||||
* Use if you want to automatically generate CSS from this field's value.
|
||||
*
|
||||
* @see https://kirki.org/docs/arguments/output
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
protected $output = [];
|
||||
|
||||
/**
|
||||
* Use to automatically generate postMessage scripts.
|
||||
* Not necessary to use if you use 'transport' => 'auto'
|
||||
* and have already set an array for the 'output' argument.
|
||||
*
|
||||
* @see https://kirki.org/docs/arguments/js_vars
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
protected $js_vars = [];
|
||||
|
||||
/**
|
||||
* If you want to use a CSS compiler, then use this to set the variable names.
|
||||
*
|
||||
* @see https://kirki.org/docs/arguments/variables
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
protected $variables = [];
|
||||
|
||||
/**
|
||||
* Text that will be used in a tooltip to provide extra info for this field.
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $tooltip = '';
|
||||
|
||||
/**
|
||||
* A custom callback to determine if the field should be visible or not.
|
||||
*
|
||||
* @access protected
|
||||
* @var string|array
|
||||
*/
|
||||
protected $active_callback = '__return_true';
|
||||
|
||||
/**
|
||||
* A custom sanitize callback that will be used to properly save the values.
|
||||
*
|
||||
* @access protected
|
||||
* @var string|array
|
||||
*/
|
||||
protected $sanitize_callback = '';
|
||||
|
||||
/**
|
||||
* Use 'refresh', 'postMessage' or 'auto'.
|
||||
* 'auto' will automatically geberate any 'js_vars' from the 'output' argument.
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $transport = 'refresh';
|
||||
|
||||
/**
|
||||
* Define dependencies to show/hide this field based on the values of other fields.
|
||||
*
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
protected $required = [];
|
||||
|
||||
/**
|
||||
* Partial Refreshes array.
|
||||
*
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
protected $partial_refresh = [];
|
||||
|
||||
/**
|
||||
* The class constructor.
|
||||
* Parses and sanitizes all field arguments.
|
||||
* Then it adds the field to Kirki::$fields.
|
||||
*
|
||||
* @access public
|
||||
* @param string $config_id The ID of the config we want to use.
|
||||
* Defaults to "global".
|
||||
* Configs are handled by the Kirki\Compatibility\Config class.
|
||||
* @param array $args The arguments of the field.
|
||||
*/
|
||||
public function __construct( $config_id = 'global', $args = [] ) {
|
||||
|
||||
/**
|
||||
* In case the user only provides 1 argument,
|
||||
* assume that the provided argument is $args and set $config_id = 'global'.
|
||||
*/
|
||||
if ( is_array( $config_id ) && empty( $args ) ) {
|
||||
$args = $config_id;
|
||||
$config_id = isset( $args['kirki_config'] ) ? $args['kirki_config'] : 'global';
|
||||
}
|
||||
|
||||
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_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'] );
|
||||
}
|
||||
|
||||
$args['kirki_config'] = $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_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';
|
||||
}
|
||||
|
||||
// Get defaults from the class.
|
||||
$defaults = get_class_vars( __CLASS__ );
|
||||
|
||||
// Get the config arguments, and merge them with the defaults.
|
||||
$config_defaults = ( isset( Kirki::$config['global'] ) ) ? Kirki::$config['global'] : [];
|
||||
|
||||
if ( 'global' !== $this->kirki_config && isset( Kirki::$config[ $this->kirki_config ] ) ) {
|
||||
$config_defaults = Kirki::$config[ $this->kirki_config ];
|
||||
}
|
||||
|
||||
$config_defaults = ( is_array( $config_defaults ) ) ? $config_defaults : [];
|
||||
|
||||
foreach ( $config_defaults as $key => $value ) {
|
||||
if ( isset( $defaults[ $key ] ) && ! empty( $value ) && $value !== $defaults[ $key ] ) {
|
||||
$defaults[ $key ] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// Merge our args with the defaults.
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
||||
// Set the class properties using the parsed args.
|
||||
foreach ( $args as $key => $value ) {
|
||||
$this->$key = $value;
|
||||
}
|
||||
|
||||
$this->args = $args;
|
||||
|
||||
$this->set_field();
|
||||
|
||||
// Instantiate the \Kirki\Field to apply hooks.
|
||||
new \Kirki\Field\None( $this->args );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the field arguments
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function set_field() {
|
||||
|
||||
$properties = get_class_vars( __CLASS__ );
|
||||
|
||||
// Some things must run before the others.
|
||||
$this->set_option_type();
|
||||
$this->set_settings();
|
||||
|
||||
// Sanitize the properties, skipping the ones that have already run above.
|
||||
foreach ( array_keys( $properties ) as $property ) {
|
||||
if ( in_array( $property, [ 'option_name', 'option_type', 'settings' ], true ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( method_exists( $this, 'set_' . $property ) ) {
|
||||
$method_name = 'set_' . $property;
|
||||
$this->$method_name();
|
||||
}
|
||||
}
|
||||
|
||||
// Get all arguments with their values.
|
||||
$args = get_object_vars( $this );
|
||||
|
||||
foreach ( array_keys( $args ) as $key ) {
|
||||
$args[ $key ] = $this->$key;
|
||||
}
|
||||
|
||||
// Add the field to the static $fields variable properly indexed.
|
||||
Kirki::$fields[ $this->settings ] = $args;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape the $section.
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function set_input_attrs() {
|
||||
$this->input_attrs = (array) $this->input_attrs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure we're using the correct option_type
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function set_option_type() {
|
||||
|
||||
// Take care of common typos.
|
||||
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_html( 'Typo found in field %s - "theme_mods" vs "theme_mod"', 'kirki' ), esc_html( $this->settings ) ), '3.0.10' );
|
||||
$this->option_type = 'theme_mod';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifications for partial refreshes.
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function set_partial_refresh() {
|
||||
if ( ! is_array( $this->partial_refresh ) ) {
|
||||
$this->partial_refresh = [];
|
||||
}
|
||||
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_html__( '"partial_refresh" invalid entry in field %s', 'kirki' ), esc_html( $this->settings ) ), '3.0.10' );
|
||||
unset( $this->partial_refresh[ $id ] );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ( ! empty( $this->partial_refresh ) ) {
|
||||
$this->transport = 'postMessage';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the settings.
|
||||
* If we're using serialized options it makes sure that settings are properly formatted.
|
||||
* We'll also be escaping all setting names here for consistency.
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function set_settings() {
|
||||
|
||||
// If settings is not an array, temporarily convert it to an array.
|
||||
// This is just to allow us to process everything the same way and avoid code duplication.
|
||||
// if settings is not an array then it will not be set as an array in the end.
|
||||
if ( ! is_array( $this->settings ) ) {
|
||||
$this->settings = [
|
||||
'kirki_placeholder_setting' => $this->settings,
|
||||
];
|
||||
}
|
||||
$settings = [];
|
||||
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}]";
|
||||
}
|
||||
}
|
||||
$this->settings = $settings;
|
||||
if ( isset( $this->settings['kirki_placeholder_setting'] ) ) {
|
||||
$this->settings = $this->settings['kirki_placeholder_setting'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the active_callback
|
||||
* If we're using the $required argument,
|
||||
* Then this is where the switch is made to our evaluation method.
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function set_active_callback() {
|
||||
|
||||
if ( is_array( $this->active_callback ) ) {
|
||||
|
||||
if ( ! is_callable( $this->active_callback ) ) {
|
||||
|
||||
// Bugfix for https://github.com/aristath/kirki/issues/1961.
|
||||
foreach ( $this->active_callback as $key => $val ) {
|
||||
if ( is_callable( $val ) ) {
|
||||
unset( $this->active_callback[ $key ] );
|
||||
}
|
||||
}
|
||||
if ( isset( $this->active_callback[0] ) ) {
|
||||
$this->required = $this->active_callback;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $this->required ) ) {
|
||||
$this->active_callback = '__return_true';
|
||||
return;
|
||||
}
|
||||
// No need to proceed any further if we're using the default value.
|
||||
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 $id.
|
||||
* Setting the ID should happen after the 'settings' sanitization.
|
||||
* This way we can also properly handle cases where the option_type is set to 'option'
|
||||
* and we're using an array instead of individual options.
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function set_id() {
|
||||
$this->id = sanitize_key( str_replace( '[', '-', str_replace( ']', '', $this->settings ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the $choices.
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function set_choices() {
|
||||
if ( ! is_array( $this->choices ) ) {
|
||||
$this->choices = [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes the $disable_output.
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function set_disable_output() {
|
||||
$this->disable_output = (bool) $this->disable_output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the $sanitize_callback
|
||||
*
|
||||
* @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_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 = [
|
||||
[
|
||||
'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_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 = [ $this->output ];
|
||||
}
|
||||
|
||||
foreach ( $this->output as $key => $output ) {
|
||||
if ( empty( $output ) || ! isset( $output['element'] ) ) {
|
||||
unset( $this->output[ $key ] );
|
||||
continue;
|
||||
}
|
||||
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'] );
|
||||
sort( $this->output[ $key ]['element'] );
|
||||
|
||||
// Trim each element in the array.
|
||||
foreach ( $this->output[ $key ]['element'] as $index => $element ) {
|
||||
$this->output[ $key ]['element'][ $index ] = trim( $element );
|
||||
}
|
||||
$this->output[ $key ]['element'] = implode( ',', $this->output[ $key ]['element'] );
|
||||
}
|
||||
|
||||
// Fix for https://github.com/aristath/kirki/issues/1659#issuecomment-346229751.
|
||||
$this->output[ $key ]['element'] = str_replace( [ "\t", "\n", "\r", "\0", "\x0B" ], ' ', $this->output[ $key ]['element'] );
|
||||
$this->output[ $key ]['element'] = trim( preg_replace( '/\s+/', ' ', $this->output[ $key ]['element'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the $js_vars
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function set_js_vars() {
|
||||
if ( ! is_array( $this->js_vars ) ) {
|
||||
$this->js_vars = [];
|
||||
}
|
||||
|
||||
// Check if transport is set to auto.
|
||||
// If not, then skip the auto-calculations and exit early.
|
||||
if ( 'auto' !== $this->transport ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set transport to refresh initially.
|
||||
// Serves as a fallback in case we failt to auto-calculate js_vars.
|
||||
$this->transport = 'refresh';
|
||||
|
||||
$js_vars = [];
|
||||
|
||||
// Try to auto-generate js_vars.
|
||||
// First we need to check if js_vars are empty, and that output is not empty.
|
||||
if ( empty( $this->js_vars ) && ! empty( $this->output ) ) {
|
||||
|
||||
// Start going through each item in the $output array.
|
||||
foreach ( $this->output as $output ) {
|
||||
$output['function'] = ( isset( $output['function'] ) ) ? $output['function'] : 'style';
|
||||
|
||||
// If 'element' is not defined, skip this.
|
||||
if ( ! isset( $output['element'] ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( is_array( $output['element'] ) ) {
|
||||
$output['element'] = implode( ',', $output['element'] );
|
||||
}
|
||||
|
||||
// If there's a sanitize_callback defined skip this, unless we also have a js_callback defined.
|
||||
if ( isset( $output['sanitize_callback'] ) && ! empty( $output['sanitize_callback'] ) && ! isset( $output['js_callback'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If we got this far, it's safe to add this.
|
||||
$js_vars[] = $output;
|
||||
}
|
||||
|
||||
// Did we manage to get all the items from 'output'?
|
||||
// If not, then we're missing something so don't add this.
|
||||
if ( count( $js_vars ) !== count( $this->output ) ) {
|
||||
return;
|
||||
}
|
||||
$this->js_vars = $js_vars;
|
||||
$this->transport = 'postMessage';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the $variables
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function set_variables() {
|
||||
if ( ! is_array( $this->variables ) ) {
|
||||
$variable = ( is_string( $this->variables ) && ! empty( $this->variables ) ) ? $this->variables : false;
|
||||
$this->variables = [];
|
||||
if ( $variable && empty( $this->variables ) ) {
|
||||
$this->variables[0]['name'] = $variable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the $transport
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function set_transport() {
|
||||
if ( 'postmessage' === trim( strtolower( $this->transport ) ) ) {
|
||||
$this->transport = 'postMessage';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the $required
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function set_required() {
|
||||
if ( ! is_array( $this->required ) ) {
|
||||
$this->required = [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the $priority
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function set_priority() {
|
||||
$this->priority = absint( $this->priority );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the $css_vars
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function set_css_vars() {
|
||||
if ( is_string( $this->css_vars ) ) {
|
||||
$this->css_vars = [ $this->css_vars ];
|
||||
}
|
||||
if ( isset( $this->css_vars[0] ) && is_string( $this->css_vars[0] ) ) {
|
||||
$this->css_vars = [ $this->css_vars ];
|
||||
}
|
||||
foreach ( $this->css_vars as $key => $val ) {
|
||||
if ( ! isset( $val[1] ) ) {
|
||||
$this->css_vars[ $key ][1] = '$';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* The main Kirki object
|
||||
*
|
||||
* @package Kirki
|
||||
* @category Core
|
||||
* @author Ari Stathopoulos (@aristath)
|
||||
* @copyright Copyright (c) 2020, David Vongries
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Compatibility;
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Singleton class
|
||||
*/
|
||||
final class Framework {
|
||||
|
||||
/**
|
||||
* Holds the one, true instance of this object.
|
||||
*
|
||||
* @static
|
||||
* @access protected
|
||||
* @var object
|
||||
*/
|
||||
protected static $instance = null;
|
||||
|
||||
/**
|
||||
* Access the single instance of this class.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @return Kirki\Compatibility\Framework
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,310 @@
|
||||
<?php
|
||||
/**
|
||||
* Initializes Kirki
|
||||
*
|
||||
* @package Kirki
|
||||
* @category Core
|
||||
* @author Ari Stathopoulos (@aristath)
|
||||
* @copyright Copyright (c) 2020, David Vongries
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Compatibility;
|
||||
|
||||
/**
|
||||
* Initialize Kirki
|
||||
*/
|
||||
class Init {
|
||||
|
||||
/**
|
||||
* Control types.
|
||||
*
|
||||
* @access private
|
||||
* @since 3.0.0
|
||||
* @var array
|
||||
*/
|
||||
private $control_types = [];
|
||||
|
||||
/**
|
||||
* Should we show a nag for the deprecated fontawesome field?
|
||||
*
|
||||
* @static
|
||||
* @access private
|
||||
* @since 3.0.42
|
||||
* @var bool
|
||||
*/
|
||||
private static $show_fa_nag = false;
|
||||
|
||||
/**
|
||||
* The class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'wp_loaded', [ $this, 'add_to_customizer' ], 1 );
|
||||
add_filter( 'kirki_control_types', [ $this, 'default_control_types' ] );
|
||||
|
||||
add_action( 'customize_register', [ $this, 'remove_controls' ], 99999 );
|
||||
|
||||
add_action( 'admin_notices', [ $this, 'admin_notices' ] );
|
||||
add_action( 'admin_init', [ $this, 'dismiss_nag' ] );
|
||||
|
||||
// ? Bagus: is this necessary? The Values class doesn't have constructor, so this does nothing.
|
||||
new Values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the default Kirki control types.
|
||||
*
|
||||
* @access public
|
||||
* @since 3.0.0
|
||||
* @param array $control_types The control types array.
|
||||
* @return array
|
||||
*/
|
||||
public function default_control_types( $control_types = [] ) {
|
||||
$this->control_types = [
|
||||
'kirki-composite' => '\Kirki\Control\Composite',
|
||||
'checkbox' => '\Kirki\Control\Checkbox',
|
||||
'kirki-color' => '\Kirki\Control\ReactColorful',
|
||||
'kirki-color-palette' => '\Kirki\Control\Color_Palette',
|
||||
'kirki-custom' => '\Kirki\Control\Custom',
|
||||
'kirki-date' => '\Kirki\Control\Date',
|
||||
'kirki-dashicons' => '\Kirki\Control\Dashicons',
|
||||
'kirki-dimension' => '\Kirki\Control\Dimension',
|
||||
'kirki-dimensions' => '\Kirki\Control\Dimensions',
|
||||
'kirki-editor' => '\Kirki\Control\Editor',
|
||||
'kirki-image' => '\Kirki\Control\Image',
|
||||
'kirki-multicolor' => '\Kirki\Control\Multicolor',
|
||||
'kirki-multicheck' => '\Kirki\Control\Multicheck',
|
||||
'kirki-number' => '\Kirki\Control\Number',
|
||||
'kirki-radio' => '\Kirki\Control\Radio',
|
||||
'kirki-radio-buttonset' => '\Kirki\Control\Radio_Buttonset',
|
||||
'kirki-radio-image' => '\Kirki\Control\Radio_Image',
|
||||
'repeater' => '\Kirki\Control\Repeater',
|
||||
'kirki-select' => '\Kirki\Control\Select',
|
||||
'kirki-slider' => '\Kirki\Control\Slider',
|
||||
'kirki-sortable' => '\Kirki\Control\Sortable',
|
||||
'kirki-spacing' => '\Kirki\Control\Dimensions',
|
||||
'kirki-switch' => '\Kirki\Control\Checkbox_Switch',
|
||||
'kirki-generic' => '\Kirki\Control\Generic',
|
||||
'kirki-toggle' => '\Kirki\Control\Checkbox_Toggle',
|
||||
'image' => '\Kirki\Control\Image',
|
||||
'cropped_image' => '\Kirki\Control\Cropped_Image',
|
||||
'upload' => '\Kirki\Control\Upload',
|
||||
];
|
||||
return array_merge( $this->control_types, $control_types );
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function that adds the fields to the customizer.
|
||||
*/
|
||||
public function add_to_customizer() {
|
||||
$this->fields_from_filters();
|
||||
add_action( 'customize_register', [ $this, 'register_control_types' ] );
|
||||
add_action( 'customize_register', [ $this, 'add_fields' ], 99 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register control types
|
||||
*/
|
||||
public function register_control_types() {
|
||||
global $wp_customize;
|
||||
|
||||
$this->control_types = $this->default_control_types();
|
||||
if ( ! class_exists( 'WP_Customize_Code_Editor_Control' ) ) {
|
||||
unset( $this->control_types['code_editor'] );
|
||||
}
|
||||
foreach ( $this->control_types as $key => $classname ) {
|
||||
if ( ! class_exists( $classname ) ) {
|
||||
unset( $this->control_types[ $key ] );
|
||||
}
|
||||
}
|
||||
|
||||
$skip_control_types = apply_filters(
|
||||
'kirki_control_types_exclude',
|
||||
[
|
||||
'\Kirki\Control\Repeater',
|
||||
'\WP_Customize_Control',
|
||||
]
|
||||
);
|
||||
|
||||
foreach ( $this->control_types as $control_type ) {
|
||||
if ( ! in_array( $control_type, $skip_control_types, true ) && class_exists( $control_type ) ) {
|
||||
$wp_customize->register_control_type( $control_type );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the settings and controls from the $fields array and register them.
|
||||
*
|
||||
* @var object The WordPress Customizer object.
|
||||
*/
|
||||
public function add_fields() {
|
||||
global $wp_customize;
|
||||
|
||||
foreach ( Kirki::$fields as $args ) {
|
||||
|
||||
// Create the settings.
|
||||
new \Kirki\Compatibility\Settings( $args );
|
||||
|
||||
// Check if we're on the customizer.
|
||||
// If we are, then we will create the controls, add the scripts needed for the customizer
|
||||
// and any other tweaks that this field may require.
|
||||
if ( $wp_customize ) {
|
||||
|
||||
// Create the control.
|
||||
new Control( $args );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process fields added using the 'kirki_fields' and 'kirki_controls' filter.
|
||||
* These filters are no longer used, this is simply for backwards-compatibility.
|
||||
*
|
||||
* @access private
|
||||
* @since 2.0.0
|
||||
*/
|
||||
private function fields_from_filters() {
|
||||
$fields = apply_filters( 'kirki_controls', [] );
|
||||
$fields = apply_filters( 'kirki_fields', $fields );
|
||||
|
||||
if ( ! empty( $fields ) ) {
|
||||
foreach ( $fields as $field ) {
|
||||
$field['kirki_config'] = 'global';
|
||||
Kirki::add_field( 'global', $field );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for the is_plugin static method in the Kirki\Util\Util class.
|
||||
* This is here for backwards-compatibility purposes.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 3.0.0
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_plugin() {
|
||||
return Util::is_plugin();
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for the get_variables static method in the Kirki\Util\Util class.
|
||||
* This is here for backwards-compatibility purposes.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 2.0.0
|
||||
* @return array Formatted as array( 'variable-name' => value ).
|
||||
*/
|
||||
public static function get_variables() {
|
||||
|
||||
// Log error for developers.
|
||||
_doing_it_wrong( __METHOD__, esc_html__( 'We detected you\'re using Kirki\Compatibility\Init::get_variables(). Please use \Kirki\Util\Util::get_variables() instead.', 'kirki' ), '3.0.10' );
|
||||
|
||||
// ! This will be failed, because Util class is under Kirki\Util namespace.
|
||||
return Util::get_variables();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove controls.
|
||||
*
|
||||
* @since 3.0.17
|
||||
* @param object $wp_customize The customizer object.
|
||||
* @return void
|
||||
*/
|
||||
public function remove_controls( $wp_customize ) {
|
||||
foreach ( Kirki::$controls_to_remove as $control ) {
|
||||
$wp_customize->remove_control( $control );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows an admin notice.
|
||||
*
|
||||
* @access public
|
||||
* @since 3.0.42
|
||||
* @return void
|
||||
*/
|
||||
public function admin_notices() {
|
||||
|
||||
// No need for a nag if we don't need to recommend installing the FA plugin.
|
||||
if ( ! self::$show_fa_nag ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// No need for a nag if FA plugin is already installed.
|
||||
if ( defined( 'FONTAWESOME_DIR_PATH' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// No need for a nag if current user can't install plugins.
|
||||
if ( ! current_user_can( 'install_plugins' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// No need for a nag if user has dismissed it.
|
||||
$dismissed = get_user_meta( get_current_user_id(), 'kirki_fa_nag_dismissed', true );
|
||||
if ( true === $dismissed || 1 === $dismissed || '1' === $dismissed ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<div class="notice notice-info is-dismissible">
|
||||
<p>
|
||||
<?php esc_html_e( 'Your theme uses a Font Awesome field for icons. To avoid issues with missing icons on your frontend we recommend you install the official Font Awesome plugin.', 'kirki' ); ?>
|
||||
</p>
|
||||
<p>
|
||||
<a class="button button-primary" href="<?php echo esc_url( admin_url( 'plugin-install.php?tab=plugin-information&plugin=font-awesome&TB_iframe=true&width=600&height=550' ) ); ?>"><?php esc_html_e( 'Install Plugin', 'kirki' ); ?></a>
|
||||
<a class="button button-secondary" href="<?php echo esc_url( wp_nonce_url( admin_url( '?dismiss-nag=font-awesome-kirki' ), 'kirki-dismiss-nag', 'nonce' ) ); ?>"><?php esc_html_e( 'Don\'t show this again', 'kirki' ); ?></a>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Dismisses the nag.
|
||||
*
|
||||
* @access public
|
||||
* @since 3.0.42
|
||||
* @return void
|
||||
*/
|
||||
public function dismiss_nag() {
|
||||
if ( isset( $_GET['nonce'] ) && wp_verify_nonce( $_GET['nonce'], 'kirki-dismiss-nag' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
|
||||
if ( get_current_user_id() && isset( $_GET['dismiss-nag'] ) && 'font-awesome-kirki' === $_GET['dismiss-nag'] ) {
|
||||
update_user_meta( get_current_user_id(), 'kirki_fa_nag_dismissed', true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles showing a nag if the theme is using the deprecated fontawesome field
|
||||
*
|
||||
* @static
|
||||
* @access protected
|
||||
* @since 3.0.42
|
||||
* @param array $args The field arguments.
|
||||
* @return void
|
||||
*/
|
||||
protected static function maybe_show_fontawesome_nag( $args ) {
|
||||
|
||||
// If we already know we want it, skip check.
|
||||
if ( self::$show_fa_nag ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the field is fontawesome.
|
||||
if ( isset( $args['type'] ) && in_array( $args['type'], [ 'fontawesome', 'kirki-fontawesome' ], true ) ) {
|
||||
|
||||
// Skip check if theme has disabled FA enqueueing via a filter.
|
||||
if ( ! apply_filters( 'kirki_load_fontawesome', true ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we got this far, we need to show the nag.
|
||||
self::$show_fa_nag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,304 @@
|
||||
<?php
|
||||
/**
|
||||
* The Kirki API class.
|
||||
* Takes care of adding panels, sections & fields to the customizer.
|
||||
* For documentation please see https://github.com/aristath/kirki/wiki
|
||||
*
|
||||
* @package Kirki
|
||||
* @category Core
|
||||
* @author Ari Stathopoulos (@aristath)
|
||||
* @copyright Copyright (c) 2020, David Vongries
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Compatibility;
|
||||
|
||||
// ? Bagus: do we really need these? They are already under the same namespace as Kirki class (this file).
|
||||
use Kirki\Compatibility\Config;
|
||||
use Kirki\Compatibility\Field;
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* This class acts as an interface.
|
||||
* Developers may use this object to add configurations, fields, panels and sections.
|
||||
* You can also access all available configurations, fields, panels and sections
|
||||
* by accessing the object's static properties.
|
||||
*/
|
||||
class Kirki extends Init {
|
||||
|
||||
/**
|
||||
* URL to the Kirki folder.
|
||||
*
|
||||
* @deprecated This is no longer used. Only kept here for backwards compatibility to avoid fatal errors.
|
||||
* @static
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public static $url;
|
||||
|
||||
/**
|
||||
* An array containing all configurations.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @var array
|
||||
*/
|
||||
public static $config = [];
|
||||
|
||||
/**
|
||||
* An array containing all fields for compatibility purpose.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @var array
|
||||
*/
|
||||
public static $fields = [];
|
||||
|
||||
/**
|
||||
* An array containing all fields.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @var array
|
||||
*/
|
||||
public static $all_fields = [];
|
||||
|
||||
/**
|
||||
* An array containing all controls to be removed.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 3.0.17
|
||||
* @var array
|
||||
*/
|
||||
public static $controls_to_remove = [];
|
||||
|
||||
/**
|
||||
* Modules object.
|
||||
*
|
||||
* @access public
|
||||
* @since 3.0.0
|
||||
* @var object
|
||||
*/
|
||||
public $modules;
|
||||
|
||||
/**
|
||||
* Get the value of an option from the db.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $config_id The ID of the configuration corresponding to this field.
|
||||
* @param string $field_id The field_id (defined as 'settings' in the field arguments).
|
||||
* @return mixed The saved value of the field.
|
||||
*/
|
||||
public static function get_option( $config_id = '', $field_id = '' ) {
|
||||
|
||||
return Values::get_value( $config_id, $field_id );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the configuration options.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $config_id The configuration ID.
|
||||
* @param array $args The configuration options.
|
||||
*/
|
||||
public static function add_config( $config_id, $args = [] ) {
|
||||
|
||||
$config = Config::get_instance( $config_id, $args );
|
||||
$config_args = $config->get_config();
|
||||
|
||||
self::$config[ $config_args['id'] ] = $config_args;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new panel.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $id The ID for this panel.
|
||||
* @param array $args The panel arguments.
|
||||
*/
|
||||
public static function add_panel( $id = '', $args = [] ) {
|
||||
|
||||
new \Kirki\Panel( $id, $args );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a panel.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 3.0.17
|
||||
* @param string $id The ID for this panel.
|
||||
*/
|
||||
public static function remove_panel( $id = '' ) {
|
||||
|
||||
$panel = new \Kirki\Panel( $id );
|
||||
$panel->remove();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new section.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $id The ID for this section.
|
||||
* @param array $args The section arguments.
|
||||
*/
|
||||
public static function add_section( $id, $args ) {
|
||||
|
||||
new \Kirki\Section( $id, $args );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a section.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 3.0.17
|
||||
* @param string $id The ID for this section.
|
||||
*/
|
||||
public static function remove_section( $id = '' ) {
|
||||
|
||||
$section = new \Kirki\Section( $id, $args );
|
||||
$section->remove();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new field.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $config_id The configuration ID for this field.
|
||||
* @param array $args The field arguments.
|
||||
*/
|
||||
public static function add_field( $config_id, $args = [] ) {
|
||||
|
||||
if ( doing_action( 'customize_register' ) ) {
|
||||
_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' );
|
||||
}
|
||||
|
||||
parent::maybe_show_fontawesome_nag( $args );
|
||||
|
||||
// Early exit if 'type' is not defined.
|
||||
if ( ! isset( $args['type'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$args = self::migrate_css_vars( $args );
|
||||
|
||||
$str = str_replace( [ '-', '_' ], ' ', $args['type'] );
|
||||
$classname = '\Kirki\Field\\' . str_replace( ' ', '_', ucwords( $str ) );
|
||||
|
||||
$config = Config::get_instance( $config_id )->get_config();
|
||||
$args['kirki_config'] = isset( $args['kirki_config'] ) ? $args['kirki_config'] : $config_id;
|
||||
|
||||
unset( $config['id'] );
|
||||
|
||||
$args = wp_parse_args( $args, $config );
|
||||
|
||||
if ( class_exists( $classname ) ) {
|
||||
unset( $args['type'] );
|
||||
new $classname( $args );
|
||||
return;
|
||||
}
|
||||
|
||||
new Field( $config_id, $args );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a control.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 3.0.17
|
||||
* @param string $id The field ID.
|
||||
*/
|
||||
public static function remove_control( $id ) {
|
||||
|
||||
if ( ! in_array( $id, self::$controls_to_remove, true ) ) {
|
||||
self::$controls_to_remove[] = $id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a parameter for a config-id.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 3.0.10
|
||||
* @param string $id The config-ID.
|
||||
* @param string $param The parameter we want.
|
||||
* @return string
|
||||
*/
|
||||
public static function get_config_param( $id, $param ) {
|
||||
|
||||
if ( ! isset( self::$config[ $id ] ) || ! isset( self::$config[ $id ][ $param ] ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return self::$config[ $id ][ $param ];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate css-variables to output argument.
|
||||
*
|
||||
* This only exists for backwards-compatibility with the deprecated css-vars argument.
|
||||
*
|
||||
* @static
|
||||
* @since 4.0
|
||||
* @param array $args The field arguments.
|
||||
* @return array
|
||||
*/
|
||||
private static function migrate_css_vars( $args ) {
|
||||
|
||||
// Convert css_vars to output args.
|
||||
if ( isset( $args['css_vars'] ) ) {
|
||||
|
||||
if ( isset( $args['transport'] ) && 'postMessage' === $args['transport'] ) {
|
||||
$args['transport'] = 'auto';
|
||||
}
|
||||
|
||||
// Convert to properly-formatted arrays.
|
||||
$args['css_vars'] = (array) $args['css_vars'];
|
||||
|
||||
if ( isset( $args['css_vars'][0] ) && is_string( $args['css_vars'][0] ) ) {
|
||||
$args['css_vars'] = [ $args['css_vars'] ];
|
||||
}
|
||||
|
||||
foreach ( $args['css_vars'] as $css_var ) {
|
||||
$output = [
|
||||
'element' => ':root',
|
||||
'property' => $css_var[0],
|
||||
];
|
||||
if ( isset( $css_var[1] ) ) {
|
||||
$output['value_pattern'] = $css_var[1];
|
||||
}
|
||||
if ( isset( $css_var[2] ) ) {
|
||||
$output['choice'] = $css_var[2];
|
||||
}
|
||||
$args['output'][] = $output;
|
||||
}
|
||||
}
|
||||
|
||||
return $args;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
/**
|
||||
* Handles modules loading.
|
||||
*
|
||||
* @package Kirki
|
||||
* @category Modules
|
||||
* @author Ari Stathopoulos (@aristath)
|
||||
* @copyright Copyright (c) 2020, David Vongries
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 3.0.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Compatibility;
|
||||
|
||||
/**
|
||||
* The Modules class.
|
||||
*/
|
||||
class Modules {
|
||||
|
||||
/**
|
||||
* An array of available modules.
|
||||
*
|
||||
* @static
|
||||
* @access private
|
||||
* @since 3.0.0
|
||||
* @var array
|
||||
*/
|
||||
private static $modules = [];
|
||||
|
||||
/**
|
||||
* An array of active modules (objects).
|
||||
*
|
||||
* @static
|
||||
* @access private
|
||||
* @since 3.0.0
|
||||
* @var array
|
||||
*/
|
||||
private static $active_modules = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @access public
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
add_action( 'after_setup_theme', [ $this, 'setup_default_modules' ], 10 );
|
||||
add_action( 'after_setup_theme', [ $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 public
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function setup_default_modules() {
|
||||
|
||||
self::$modules = apply_filters(
|
||||
'kirki_modules',
|
||||
[
|
||||
'css' => '\Kirki\Module\CSS',
|
||||
'tooltips' => '\Kirki\Module\Tooltips',
|
||||
'postMessage' => '\Kirki\Module\Postmessage',
|
||||
'selective-refresh' => '\Kirki\Module\Selective_Refresh',
|
||||
'field-dependencies' => '\Kirki\Module\Field_Dependencies',
|
||||
'webfonts' => '\Kirki\Module\Webfonts',
|
||||
'preset' => '\Kirki\Module\Preset',
|
||||
'gutenberg' => '\Kirki\Module\Editor_Styles',
|
||||
'section-icons' => '\Kirki\Module\Section_Icons',
|
||||
]
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 public
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function init() {
|
||||
|
||||
foreach ( self::$modules as $module_class ) {
|
||||
if ( class_exists( $module_class ) ) {
|
||||
new $module_class();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a module.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $module The classname of the module to add.
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public static function add_module( $module ) {
|
||||
|
||||
if ( ! in_array( $module, self::$modules, true ) ) {
|
||||
self::$modules[] = $module;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a module.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $module The classname of the module to add.
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public static function remove_module( $module ) {
|
||||
|
||||
$key = array_search( $module, self::$modules, true );
|
||||
|
||||
if ( false !== $key ) {
|
||||
unset( self::$modules[ $key ] );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the modules array.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 3.0.0
|
||||
* @return array
|
||||
*/
|
||||
public static function get_modules() {
|
||||
|
||||
return self::$modules;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array of active modules (objects).
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 3.0.0
|
||||
* @return array
|
||||
*/
|
||||
public static function get_active_modules() {
|
||||
|
||||
return self::$active_modules;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
/**
|
||||
* Additional sanitization methods for controls.
|
||||
* These are used in the field's 'sanitize_callback' argument.
|
||||
*
|
||||
* @package Kirki
|
||||
* @category Core
|
||||
* @author Ari Stathopoulos (@aristath)
|
||||
* @copyright Copyright (c) 2020, David Vongries
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Compatibility;
|
||||
|
||||
use Kirki\Field\Checkbox;
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple wrapper class for static methods.
|
||||
*/
|
||||
class Sanitize_Values {
|
||||
|
||||
/**
|
||||
* Checkbox sanitization callback.
|
||||
*
|
||||
* Sanitization callback for 'checkbox' type controls.
|
||||
* This callback sanitizes `$value` as a boolean value, either TRUE or FALSE.
|
||||
*
|
||||
* Deprecated. Use \Kirki\Field\Checkbox::sanitize() instead.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @see \Kirki\Field\Checkbox::sanitize()
|
||||
* @param bool|string $value Whether the checkbox is checked.
|
||||
* @return bool Whether the checkbox is checked.
|
||||
*/
|
||||
public static function checkbox( $value ) {
|
||||
$obj = new Checkbox();
|
||||
|
||||
// ! This sanitize function doesn't exist. A method exists check should be used before actually calling it.
|
||||
return (bool) $obj->sanitize( $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize number options.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 0.5
|
||||
* @param int|float|double|string $value The value to be sanitized.
|
||||
* @return integer|double|string
|
||||
*/
|
||||
public static function number( $value ) {
|
||||
return ( is_numeric( $value ) ) ? $value : intval( $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop-down Pages sanitization callback.
|
||||
*
|
||||
* - Sanitization: dropdown-pages
|
||||
* - Control: dropdown-pages
|
||||
*
|
||||
* Sanitization callback for 'dropdown-pages' type controls. This callback sanitizes `$page_id`
|
||||
* as an absolute integer, and then validates that $input is the ID of a published page.
|
||||
*
|
||||
* @see absint() https://developer.wordpress.org/reference/functions/absint/
|
||||
* @see get_post_status() https://developer.wordpress.org/reference/functions/get_post_status/
|
||||
*
|
||||
* @param int $page_id Page ID.
|
||||
* @param WP_Customize_Setting $setting Setting instance.
|
||||
* @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 );
|
||||
|
||||
// If $page_id is an ID of a published page, return it; otherwise, return the default.
|
||||
return ( 'publish' === get_post_status( $page_id ) ? $page_id : $setting->default );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitizes css dimensions.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 2.2.0
|
||||
* @param string $value The value to be sanitized.
|
||||
* @return string
|
||||
*/
|
||||
public static function css_dimension( $value ) {
|
||||
|
||||
// Trim it.
|
||||
$value = trim( $value );
|
||||
|
||||
// If the value is round, then return 50%.
|
||||
if ( 'round' === $value ) {
|
||||
$value = '50%';
|
||||
}
|
||||
|
||||
// If the value is empty, return empty.
|
||||
if ( '' === $value ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// If auto, inherit or initial, return the value.
|
||||
if ( 'auto' === $value || 'initial' === $value || 'inherit' === $value || 'normal' === $value ) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
// Return empty if there are no numbers in the value.
|
||||
if ( ! preg_match( '#[0-9]#', $value ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// If we're using calc() then return the value.
|
||||
if ( false !== strpos( $value, 'calc(' ) ) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
// The raw value without the units.
|
||||
$raw_value = self::filter_number( $value );
|
||||
$unit_used = '';
|
||||
|
||||
// An array of all valid CSS units. Their order was carefully chosen for this evaluation, don't mix it up!!!
|
||||
$units = [ 'fr', 'rem', 'em', 'ex', '%', 'px', 'cm', 'mm', 'in', 'pt', 'pc', 'ch', 'vh', 'vw', 'vmin', 'vmax' ];
|
||||
foreach ( $units as $unit ) {
|
||||
if ( false !== strpos( $value, $unit ) ) {
|
||||
$unit_used = $unit;
|
||||
}
|
||||
}
|
||||
|
||||
// Hack for rem values.
|
||||
if ( 'em' === $unit_used && false !== strpos( $value, 'rem' ) ) {
|
||||
$unit_used = 'rem';
|
||||
}
|
||||
|
||||
return $raw_value . $unit_used;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters numeric values.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $value The value to be sanitized.
|
||||
* @return int|float
|
||||
*/
|
||||
public static function filter_number( $value ) {
|
||||
return filter_var( $value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize RGBA colors
|
||||
*
|
||||
* @static
|
||||
* @since 0.8.5
|
||||
* @param string $value The value to be sanitized.
|
||||
* @return string
|
||||
*/
|
||||
public static function rgba( $value ) {
|
||||
$color = \ariColor::newColor( $value );
|
||||
return $color->toCSS( 'rgba' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize colors.
|
||||
*
|
||||
* @static
|
||||
* @since 0.8.5
|
||||
* @param string $value The value to be sanitized.
|
||||
* @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 );
|
||||
}
|
||||
|
||||
/**
|
||||
* DOES NOT SANITIZE ANYTHING.
|
||||
*
|
||||
* @static
|
||||
* @since 0.5
|
||||
* @param int|string|array $value The value to be sanitized.
|
||||
* @return int|string|array
|
||||
*/
|
||||
public static function unfiltered( $value ) {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* Registers scripts for WordPress Compatibility with versions prior to WP5.0
|
||||
*
|
||||
* @package Kirki
|
||||
* @category Core
|
||||
* @author Ari Stathopoulos (@aristath)
|
||||
* @copyright Copyright (c) 2020, David Vongries
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 0.1
|
||||
*/
|
||||
|
||||
namespace Kirki\Compatibility;
|
||||
|
||||
use Kirki\URL;
|
||||
|
||||
/**
|
||||
* Adds scripts for backwards-compatibility
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
class Scripts {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @access public
|
||||
* @since 0.1
|
||||
*/
|
||||
public function __construct() {
|
||||
global $wp_version;
|
||||
|
||||
/**
|
||||
* Check if the WordPress version is lower than 5.0
|
||||
* If lower then we need to enqueue the backported scripts.
|
||||
*/
|
||||
if ( version_compare( $GLOBALS['wp_version'], '5.0', '<' ) ) {
|
||||
add_action( 'wp_enqueue_scripts', [ $this, 'register_scripts' ] );
|
||||
add_action( 'admin_register_scripts', [ $this, 'register_scripts' ] );
|
||||
add_action( 'customize_controls_enqueue_scripts', [ $this, 'register_scripts' ] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue missing WP scripts.
|
||||
*
|
||||
* @access public
|
||||
* @since 0.1
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
$folder_url = trailingslashit( URL::get_from_path( __DIR__ ) );
|
||||
wp_register_script( 'wp-polyfill', $folder_url . 'scripts/wp-polyfill.js', [], '7.0.0', false );
|
||||
wp_register_script( 'wp-hooks', $folder_url . 'scripts/hooks.js', [ 'wp-polyfill' ], '2.2.0', false );
|
||||
wp_register_script( 'wp-i18n', $folder_url . 'scripts/i18n.js', [ 'wp-polyfill' ], '3.3.0', false );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
/**
|
||||
* Handles sections created via the Kirki API.
|
||||
*
|
||||
* @package Kirki
|
||||
* @category Core
|
||||
* @author Ari Stathopoulos (@aristath)
|
||||
* @copyright Copyright (c) 2020, David Vongries
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Compatibility;
|
||||
|
||||
/**
|
||||
* Each setting is a separate instance
|
||||
*/
|
||||
class Settings {
|
||||
|
||||
/**
|
||||
* The global $wp_customize object.
|
||||
*
|
||||
* @access protected
|
||||
* @var WP_Customize_Manager
|
||||
*/
|
||||
protected $wp_customize;
|
||||
|
||||
/**
|
||||
* The setting-stypes we're using.
|
||||
*
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
protected $setting_types = [];
|
||||
|
||||
/**
|
||||
* Creates a new Settings object.
|
||||
* Class constructor.
|
||||
*
|
||||
* @access public
|
||||
* @param array $args The field definition as sanitized in Kirki\Compatibility\Field.
|
||||
*/
|
||||
public function __construct( $args = [] ) {
|
||||
|
||||
// Set the $wp_customize property.
|
||||
global $wp_customize;
|
||||
if ( ! $wp_customize ) {
|
||||
return;
|
||||
}
|
||||
$this->wp_customize = $wp_customize;
|
||||
|
||||
// Set the setting_types.
|
||||
$this->set_setting_types();
|
||||
|
||||
// Add the settings.
|
||||
$this->add_settings( $args );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the settings for this field.
|
||||
* If settings are defined as an array, then it goes through them
|
||||
* and calls the add_setting method.
|
||||
* If not an array, then it just calls add_setting
|
||||
*
|
||||
* @access private
|
||||
* @param array $args The field definition as sanitized in Kirki\Compatibility\Field.
|
||||
*/
|
||||
final function add_settings( $args = [] ) {
|
||||
|
||||
// Get the classname we'll be using to create our setting(s).
|
||||
$classname = false;
|
||||
if ( isset( $args['option_type'] ) && array_key_exists( $args['option_type'], $this->setting_types ) ) {
|
||||
$classname = $this->setting_types[ $args['option_type'] ];
|
||||
}
|
||||
if ( ! isset( $args['type'] ) || ! array_key_exists( $args['type'], $this->setting_types ) ) {
|
||||
$args['type'] = 'default';
|
||||
}
|
||||
$classname = ! $classname ? $this->setting_types[ $args['type'] ] : $classname;
|
||||
|
||||
// If settings are defined as an array, then we need to go through them
|
||||
// and call add_setting for each one of them separately.
|
||||
if ( isset( $args['settings'] ) && is_array( $args['settings'] ) ) {
|
||||
|
||||
// Make sure defaults have been defined.
|
||||
if ( ! isset( $args['default'] ) || ! is_array( $args['default'] ) ) {
|
||||
$args['default'] = [];
|
||||
}
|
||||
foreach ( $args['settings'] as $key => $value ) {
|
||||
// ? Bagus: this $defaults var is not defined anywhere inside this function, so is this a mistake?
|
||||
$default = ( isset( $defaults[ $key ] ) ) ? $defaults[ $key ] : '';
|
||||
$this->add_setting( $classname, $value, $default, $args['option_type'], $args['capability'], $args['transport'], $args['sanitize_callback'] );
|
||||
}
|
||||
}
|
||||
$this->add_setting( $classname, $args['settings'], $args['default'], $args['option_type'], $args['capability'], $args['transport'], $args['sanitize_callback'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* This is where we're finally adding the setting to the Customizer.
|
||||
*
|
||||
* @access private
|
||||
* @param string $classname The name of the class that will be used to create this setting.
|
||||
* We're getting this from $this->setting_types.
|
||||
* @param string $setting The setting-name.
|
||||
* If settings is an array, then this method is called per-setting.
|
||||
* @param string|array $default Default value for this setting.
|
||||
* @param string $type The data type we're using. Valid options: theme_mod|option.
|
||||
* @param string $capability @see https://codex.wordpress.org/Roles_and_Capabilities.
|
||||
* @param string $transport Use refresh|postMessage.
|
||||
* @param string|array $sanitize_callback A callable sanitization function or method.
|
||||
*/
|
||||
final function add_setting( $classname, $setting, $default, $type, $capability, $transport, $sanitize_callback ) {
|
||||
|
||||
$this->wp_customize->add_setting(
|
||||
new $classname(
|
||||
$this->wp_customize,
|
||||
$setting,
|
||||
[
|
||||
'default' => $default,
|
||||
'type' => $type,
|
||||
'capability' => $capability,
|
||||
'transport' => $transport,
|
||||
'sanitize_callback' => $sanitize_callback,
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the $this->setting_types property.
|
||||
* Makes sure the kirki_setting_types filter is applied
|
||||
* and that the defined classes actually exist.
|
||||
* If a defined class does not exist, it is removed.
|
||||
*/
|
||||
final function set_setting_types() {
|
||||
|
||||
// Apply the kirki_setting_types filter.
|
||||
$this->setting_types = apply_filters(
|
||||
'kirki_setting_types',
|
||||
[
|
||||
'default' => 'WP_Customize_Setting',
|
||||
'repeater' => '\Kirki_Settings_Repeater_Setting',
|
||||
'user_meta' => '\Kirki\Util\Setting\User_Meta',
|
||||
'site_option' => '\Kirki\Util\Setting\Site_Option',
|
||||
]
|
||||
);
|
||||
|
||||
// Make sure the defined classes actually exist.
|
||||
foreach ( $this->setting_types as $key => $classname ) {
|
||||
|
||||
if ( ! class_exists( $classname ) ) {
|
||||
unset( $this->setting_types[ $key ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/**
|
||||
* Helpers to get the values of a field.
|
||||
*
|
||||
* ! WARNING: PLEASE DO NOT USE THESE.
|
||||
* we only have these for backwards-compatibility purposes.
|
||||
* please use get_option() & get_theme_mod() instead.
|
||||
*
|
||||
* @package Kirki
|
||||
* @category Core
|
||||
* @author Ari Stathopoulos (@aristath)
|
||||
* @copyright Copyright (c) 2020, David Vongries
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Compatibility;
|
||||
|
||||
/**
|
||||
* Wrapper class for static methods.
|
||||
*/
|
||||
class Values {
|
||||
|
||||
/**
|
||||
* Get the value of a field.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $config_id The configuration ID. @see Kirki\Compatibility\Config.
|
||||
* @param string $field_id The field ID.
|
||||
* @return string|array
|
||||
*/
|
||||
public static function get_value( $config_id = '', $field_id = '' ) {
|
||||
|
||||
// Make sure value is defined.
|
||||
$value = '';
|
||||
|
||||
// This allows us to skip the $config_id argument.
|
||||
// If we skip adding a $config_id, use the 'global' configuration.
|
||||
if ( ( '' === $field_id ) && '' !== $config_id ) {
|
||||
$field_id = $config_id;
|
||||
$config_id = 'global';
|
||||
}
|
||||
|
||||
// If $config_id is empty, set it to 'global'.
|
||||
$config_id = ( '' === $config_id ) ? 'global' : $config_id;
|
||||
|
||||
// Fallback to 'global' if $config_id is not found.
|
||||
if ( ! isset( Kirki::$config[ $config_id ] ) ) {
|
||||
$config_id = 'global';
|
||||
}
|
||||
|
||||
if ( 'theme_mod' === Kirki::$config[ $config_id ]['option_type'] ) {
|
||||
|
||||
// We're using theme_mods so just get the value using get_theme_mod.
|
||||
$default_value = null;
|
||||
|
||||
if ( isset( Kirki::$all_fields[ $field_id ] ) && isset( Kirki::$all_fields[ $field_id ]['default'] ) ) {
|
||||
$default_value = Kirki::$all_fields[ $field_id ]['default'];
|
||||
}
|
||||
|
||||
$value = get_theme_mod( $field_id, $default_value );
|
||||
|
||||
return apply_filters( 'kirki_values_get_value', $value, $field_id );
|
||||
}
|
||||
|
||||
if ( 'option' === Kirki::$config[ $config_id ]['option_type'] ) {
|
||||
|
||||
// We're using options.
|
||||
if ( '' !== Kirki::$config[ $config_id ]['option_name'] ) {
|
||||
// Options are serialized as a single option in the db.
|
||||
// We'll have to get the option and then get the item from the array.
|
||||
$options = get_option( Kirki::$config[ $config_id ]['option_name'] );
|
||||
|
||||
if ( ! isset( Kirki::$all_fields[ $field_id ] ) && isset( Kirki::$all_fields[ Kirki::$config[ $config_id ]['option_name'] . '[' . $field_id . ']' ] ) ) {
|
||||
$field_id = Kirki::$config[ $config_id ]['option_name'] . '[' . $field_id . ']';
|
||||
}
|
||||
|
||||
$setting_modified = str_replace( ']', '', str_replace( Kirki::$config[ $config_id ]['option_name'] . '[', '', $field_id ) );
|
||||
|
||||
$default_value = ( isset( Kirki::$all_fields[ $field_id ] ) && isset( Kirki::$all_fields[ $field_id ]['default'] ) ) ? Kirki::$all_fields[ $field_id ]['default'] : '';
|
||||
$value = ( isset( $options[ $setting_modified ] ) ) ? $options[ $setting_modified ] : $default_value;
|
||||
$value = maybe_unserialize( $value );
|
||||
|
||||
return apply_filters( 'kirki_values_get_value', $value, $field_id );
|
||||
}
|
||||
|
||||
// Each option separately saved in the db.
|
||||
$value = get_option( $field_id, Kirki::$all_fields[ $field_id ]['default'] );
|
||||
|
||||
return apply_filters( 'kirki_values_get_value', $value, $field_id );
|
||||
|
||||
}
|
||||
|
||||
return apply_filters( 'kirki_values_get_value', $value, $field_id );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value or fallsback to default.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param array $field The field aruments.
|
||||
* @return string|array
|
||||
*/
|
||||
public static function get_sanitized_field_value( $field ) {
|
||||
$value = $field['default'];
|
||||
if ( ! isset( $field['option_type'] ) || 'theme_mod' === $field['option_type'] ) {
|
||||
$value = get_theme_mod( $field['settings'], $field['default'] );
|
||||
} elseif ( isset( $field['option_type'] ) && 'option' === $field['option_type'] ) {
|
||||
if ( isset( $field['option_name'] ) && '' !== $field['option_name'] ) {
|
||||
$all_values = get_option( $field['option_name'], [] );
|
||||
$sub_setting_id = str_replace( [ ']', $field['option_name'] . '[' ], '', $field['settings'] );
|
||||
if ( isset( $all_values[ $sub_setting_id ] ) ) {
|
||||
$value = $all_values[ $sub_setting_id ];
|
||||
}
|
||||
} else {
|
||||
$value = get_option( $field['settings'], $field['default'] );
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
// phpcs:ignoreFile
|
||||
|
||||
if ( ! class_exists( 'Kirki_Active_Callback' ) ) {
|
||||
// Removed in https://github.com/aristath/kirki/pull/1682/files
|
||||
class Kirki_Active_Callback {
|
||||
public static function evaluate() {
|
||||
_deprecated_function( __METHOD__, '3.0.17', null );
|
||||
return true;
|
||||
}
|
||||
private static function evaluate_requirement() {
|
||||
_deprecated_function( __METHOD__, '3.0.17', null );
|
||||
return true;
|
||||
}
|
||||
public static function compare( $value1, $value2, $operator ) {
|
||||
_deprecated_function( __METHOD__, '3.0.17', 'Kirki_Helper::compare_values' );
|
||||
return Kirki_Helper::compare_values( $value1, $value2, $operator );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated in v3.0.36
|
||||
*
|
||||
* Keeping it here in case a theme or plugin was using one of its public methods.
|
||||
* This is just to avoid fatal errors, it does not do anything.
|
||||
*/
|
||||
if ( ! class_exists( 'Kirki_CSS_To_File' ) ) {
|
||||
class Kirki_CSS_To_File {
|
||||
public function __construct() {}
|
||||
public function get_url() {}
|
||||
public function get_timestamp() {}
|
||||
public function write_file() {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
// phpcs:ignoreFile
|
||||
|
||||
add_filter( 'kirki_config', function( $args ) {
|
||||
return apply_filters( 'kirki/config', $args );
|
||||
}, 99 );
|
||||
|
||||
add_filter( 'kirki_control_types', function( $args ) {
|
||||
return apply_filters( 'kirki/control_types', $args );
|
||||
}, 99 );
|
||||
|
||||
add_filter( 'kirki_section_types', function( $args ) {
|
||||
return apply_filters( 'kirki/section_types', $args );
|
||||
}, 99 );
|
||||
|
||||
add_filter( 'kirki_section_types_exclude', function( $args ) {
|
||||
return apply_filters( 'kirki/section_types/exclude', $args );
|
||||
}, 99 );
|
||||
|
||||
add_filter( 'kirki_control_types_exclude', function( $args ) {
|
||||
return apply_filters( 'kirki/control_types/exclude', $args );
|
||||
}, 99 );
|
||||
|
||||
add_filter( 'kirki_controls', function( $args ) {
|
||||
return apply_filters( 'kirki/controls', $args );
|
||||
}, 99 );
|
||||
|
||||
add_filter( 'kirki_fields', function( $args ) {
|
||||
return apply_filters( 'kirki/fields', $args );
|
||||
}, 99 );
|
||||
|
||||
add_filter( 'kirki_modules', function( $args ) {
|
||||
return apply_filters( 'kirki/modules', $args );
|
||||
}, 99 );
|
||||
|
||||
add_filter( 'kirki_panel_types', function( $args ) {
|
||||
return apply_filters( 'kirki/panel_types', $args );
|
||||
}, 99 );
|
||||
|
||||
add_filter( 'kirki_setting_types', function( $args ) {
|
||||
return apply_filters( 'kirki/setting_types', $args );
|
||||
}, 99 );
|
||||
|
||||
add_filter( 'kirki_variable', function( $args ) {
|
||||
return apply_filters( 'kirki/variable', $args );
|
||||
}, 99 );
|
||||
|
||||
add_filter( 'kirki_values_get_value', function( $arg1, $arg2 ) {
|
||||
return apply_filters( 'kirki/values/get_value', $arg1, $arg2 );
|
||||
}, 99, 2 );
|
||||
|
||||
add_action( 'init', function() {
|
||||
$config_ids = \Kirki\Compatibility\Config::get_config_ids();
|
||||
global $kirki_deprecated_filters_iteration;
|
||||
foreach ( $config_ids as $config_id ) {
|
||||
foreach( array(
|
||||
'/dynamic_css',
|
||||
'/output/control-classnames',
|
||||
'/css/skip_hidden',
|
||||
'/styles',
|
||||
'/output/property-classnames',
|
||||
'/webfonts/skip_hidden',
|
||||
) as $filter_suffix ) {
|
||||
$kirki_deprecated_filters_iteration = array( $config_id, $filter_suffix );
|
||||
add_filter( "kirki_{$config_id}_{$filter_suffix}", function( $args ) {
|
||||
global $kirki_deprecated_filters_iteration;
|
||||
$kirki_deprecated_filters_iteration[1] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[1] );
|
||||
return apply_filters( "kirki/{$kirki_deprecated_filters_iteration[0]}/{$kirki_deprecated_filters_iteration[1]}", $args );
|
||||
}, 99 );
|
||||
if ( false !== strpos( $kirki_deprecated_filters_iteration[1], '-' ) ) {
|
||||
$kirki_deprecated_filters_iteration[1] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[1] );
|
||||
add_filter( "kirki_{$config_id}_{$filter_suffix}", function( $args ) {
|
||||
global $kirki_deprecated_filters_iteration;
|
||||
$kirki_deprecated_filters_iteration[1] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[1] );
|
||||
return apply_filters( "kirki/{$kirki_deprecated_filters_iteration[0]}/{$kirki_deprecated_filters_iteration[1]}", $args );
|
||||
}, 99 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 99 );
|
||||
|
||||
add_filter( 'kirki_enqueue_google_fonts', function( $args ) {
|
||||
return apply_filters( 'kirki/enqueue_google_fonts', $args );
|
||||
}, 99 );
|
||||
|
||||
add_filter( 'kirki_styles_array', function( $args ) {
|
||||
return apply_filters( 'kirki/styles_array', $args );
|
||||
}, 99 );
|
||||
|
||||
add_filter( 'kirki_dynamic_css_method', function( $args ) {
|
||||
return apply_filters( 'kirki/dynamic_css/method', $args );
|
||||
}, 99 );
|
||||
|
||||
add_filter( 'kirki_postmessage_script', function( $args ) {
|
||||
return apply_filters( 'kirki/postmessage/script', $args );
|
||||
}, 99 );
|
||||
|
||||
add_filter( 'kirki_fonts_all', function( $args ) {
|
||||
return apply_filters( 'kirki/fonts/all', $args );
|
||||
}, 99 );
|
||||
|
||||
add_filter( 'kirki_fonts_standard_fonts', function( $args ) {
|
||||
return apply_filters( 'kirki/fonts/standard_fonts', $args );
|
||||
}, 99 );
|
||||
|
||||
add_filter( 'kirki_fonts_google_fonts', function( $args ) {
|
||||
return apply_filters( 'kirki/fonts/google_fonts', $args );
|
||||
}, 99 );
|
||||
|
||||
add_filter( 'kirki_googlefonts_load_method', function( $args ) {
|
||||
return apply_filters( 'kirki/googlefonts_load_method', $args );
|
||||
}, 99 );
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
// phpcs:ignoreFile
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'kirki_get_option' ) ) {
|
||||
/**
|
||||
* Get the value of a field.
|
||||
* This is a deprecated function that we used when there was no API.
|
||||
* Please use get_theme_mod() or get_option() instead.
|
||||
* @see https://developer.wordpress.org/reference/functions/get_theme_mod/
|
||||
* @see https://developer.wordpress.org/reference/functions/get_option/
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function kirki_get_option( $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 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'kirki_sanitize_hex' ) ) {
|
||||
function kirki_sanitize_hex( $color ) {
|
||||
_deprecated_function( __FUNCTION__, '1.0.0', 'ariColor::newColor( $color )->toCSS( \'hex\' )' );
|
||||
return Kirki_Color::sanitize_hex( $color );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'kirki_get_rgb' ) ) {
|
||||
function kirki_get_rgb( $hex, $implode = false ) {
|
||||
_deprecated_function( __FUNCTION__, '1.0.0', 'ariColor::newColor( $color )->toCSS( \'rgb\' )' );
|
||||
return Kirki_Color::get_rgb( $hex, $implode );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'kirki_get_rgba' ) ) {
|
||||
function kirki_get_rgba( $hex = '#fff', $opacity = 100 ) {
|
||||
_deprecated_function( __FUNCTION__, '1.0.0', 'ariColor::newColor( $color )->toCSS( \'rgba\' )' );
|
||||
return Kirki_Color::get_rgba( $hex, $opacity );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'kirki_get_brightness' ) ) {
|
||||
function kirki_get_brightness( $hex ) {
|
||||
_deprecated_function( __FUNCTION__, '1.0.0', 'ariColor::newColor( $color )->lightness' );
|
||||
return Kirki_Color::get_brightness( $hex );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'Kirki' ) ) {
|
||||
function Kirki() {
|
||||
return \Kirki\Compatibility\Framework::get_instance();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,623 @@
|
||||
this["wp"] = this["wp"] || {}; this["wp"]["hooks"] =
|
||||
/******/ (function(modules) { // webpackBootstrap
|
||||
/******/ // The module cache
|
||||
/******/ var installedModules = {};
|
||||
/******/
|
||||
/******/ // The require function
|
||||
/******/ function __webpack_require__(moduleId) {
|
||||
/******/
|
||||
/******/ // Check if module is in cache
|
||||
/******/ if(installedModules[moduleId]) {
|
||||
/******/ return installedModules[moduleId].exports;
|
||||
/******/ }
|
||||
/******/ // Create a new module (and put it into the cache)
|
||||
/******/ var module = installedModules[moduleId] = {
|
||||
/******/ i: moduleId,
|
||||
/******/ l: false,
|
||||
/******/ exports: {}
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Execute the module function
|
||||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||||
/******/
|
||||
/******/ // Flag the module as loaded
|
||||
/******/ module.l = true;
|
||||
/******/
|
||||
/******/ // Return the exports of the module
|
||||
/******/ return module.exports;
|
||||
/******/ }
|
||||
/******/
|
||||
/******/
|
||||
/******/ // expose the modules object (__webpack_modules__)
|
||||
/******/ __webpack_require__.m = modules;
|
||||
/******/
|
||||
/******/ // expose the module cache
|
||||
/******/ __webpack_require__.c = installedModules;
|
||||
/******/
|
||||
/******/ // define getter function for harmony exports
|
||||
/******/ __webpack_require__.d = function(exports, name, getter) {
|
||||
/******/ if(!__webpack_require__.o(exports, name)) {
|
||||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
||||
/******/ }
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = function(exports) {
|
||||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
/******/ }
|
||||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // create a fake namespace object
|
||||
/******/ // mode & 1: value is a module id, require it
|
||||
/******/ // mode & 2: merge all properties of value into the ns
|
||||
/******/ // mode & 4: return value when already ns object
|
||||
/******/ // mode & 8|1: behave like require
|
||||
/******/ __webpack_require__.t = function(value, mode) {
|
||||
/******/ if(mode & 1) value = __webpack_require__(value);
|
||||
/******/ if(mode & 8) return value;
|
||||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
||||
/******/ var ns = Object.create(null);
|
||||
/******/ __webpack_require__.r(ns);
|
||||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
||||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
||||
/******/ return ns;
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = function(module) {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ function getDefault() { return module['default']; } :
|
||||
/******/ function getModuleExports() { return module; };
|
||||
/******/ __webpack_require__.d(getter, 'a', getter);
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Object.prototype.hasOwnProperty.call
|
||||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
||||
/******/
|
||||
/******/ // __webpack_public_path__
|
||||
/******/ __webpack_require__.p = "";
|
||||
/******/
|
||||
/******/
|
||||
/******/ // Load entry module and return exports
|
||||
/******/ return __webpack_require__(__webpack_require__.s = 366);
|
||||
/******/ })
|
||||
/************************************************************************/
|
||||
/******/ ({
|
||||
|
||||
/***/ 366:
|
||||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/validateNamespace.js
|
||||
/**
|
||||
* Validate a namespace string.
|
||||
*
|
||||
* @param {string} namespace The namespace to validate - should take the form
|
||||
* `vendor/plugin/function`.
|
||||
*
|
||||
* @return {boolean} Whether the namespace is valid.
|
||||
*/
|
||||
function validateNamespace(namespace) {
|
||||
if ('string' !== typeof namespace || '' === namespace) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('The namespace must be a non-empty string.');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(namespace)) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('The namespace can only contain numbers, letters, dashes, periods, underscores and slashes.');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* harmony default export */ var build_module_validateNamespace = (validateNamespace);
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/validateHookName.js
|
||||
/**
|
||||
* Validate a hookName string.
|
||||
*
|
||||
* @param {string} hookName The hook name to validate. Should be a non empty string containing
|
||||
* only numbers, letters, dashes, periods and underscores. Also,
|
||||
* the hook name cannot begin with `__`.
|
||||
*
|
||||
* @return {boolean} Whether the hook name is valid.
|
||||
*/
|
||||
function validateHookName(hookName) {
|
||||
if ('string' !== typeof hookName || '' === hookName) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('The hook name must be a non-empty string.');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (/^__/.test(hookName)) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('The hook name cannot begin with `__`.');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(hookName)) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('The hook name can only contain numbers, letters, dashes, periods and underscores.');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* harmony default export */ var build_module_validateHookName = (validateHookName);
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createAddHook.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns a function which, when invoked, will add a hook.
|
||||
*
|
||||
* @param {Object} hooks Stored hooks, keyed by hook name.
|
||||
*
|
||||
* @return {Function} Function that adds a new hook.
|
||||
*/
|
||||
|
||||
function createAddHook(hooks) {
|
||||
/**
|
||||
* Adds the hook to the appropriate hooks container.
|
||||
*
|
||||
* @param {string} hookName Name of hook to add
|
||||
* @param {string} namespace The unique namespace identifying the callback in the form `vendor/plugin/function`.
|
||||
* @param {Function} callback Function to call when the hook is run
|
||||
* @param {?number} priority Priority of this hook (default=10)
|
||||
*/
|
||||
return function addHook(hookName, namespace, callback) {
|
||||
var priority = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 10;
|
||||
|
||||
if (!build_module_validateHookName(hookName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!build_module_validateNamespace(namespace)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ('function' !== typeof callback) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('The hook callback must be a function.');
|
||||
return;
|
||||
} // Validate numeric priority
|
||||
|
||||
|
||||
if ('number' !== typeof priority) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('If specified, the hook priority must be a number.');
|
||||
return;
|
||||
}
|
||||
|
||||
var handler = {
|
||||
callback: callback,
|
||||
priority: priority,
|
||||
namespace: namespace
|
||||
};
|
||||
|
||||
if (hooks[hookName]) {
|
||||
// Find the correct insert index of the new hook.
|
||||
var handlers = hooks[hookName].handlers;
|
||||
var i;
|
||||
|
||||
for (i = handlers.length; i > 0; i--) {
|
||||
if (priority >= handlers[i - 1].priority) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i === handlers.length) {
|
||||
// If append, operate via direct assignment.
|
||||
handlers[i] = handler;
|
||||
} else {
|
||||
// Otherwise, insert before index via splice.
|
||||
handlers.splice(i, 0, handler);
|
||||
} // We may also be currently executing this hook. If the callback
|
||||
// we're adding would come after the current callback, there's no
|
||||
// problem; otherwise we need to increase the execution index of
|
||||
// any other runs by 1 to account for the added element.
|
||||
|
||||
|
||||
(hooks.__current || []).forEach(function (hookInfo) {
|
||||
if (hookInfo.name === hookName && hookInfo.currentIndex >= i) {
|
||||
hookInfo.currentIndex++;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// This is the first hook of its type.
|
||||
hooks[hookName] = {
|
||||
handlers: [handler],
|
||||
runs: 0
|
||||
};
|
||||
}
|
||||
|
||||
if (hookName !== 'hookAdded') {
|
||||
doAction('hookAdded', hookName, namespace, callback, priority);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/* harmony default export */ var build_module_createAddHook = (createAddHook);
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createRemoveHook.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns a function which, when invoked, will remove a specified hook or all
|
||||
* hooks by the given name.
|
||||
*
|
||||
* @param {Object} hooks Stored hooks, keyed by hook name.
|
||||
* @param {boolean} removeAll Whether to remove all callbacks for a hookName, without regard to namespace. Used to create `removeAll*` functions.
|
||||
*
|
||||
* @return {Function} Function that removes hooks.
|
||||
*/
|
||||
|
||||
function createRemoveHook(hooks, removeAll) {
|
||||
/**
|
||||
* Removes the specified callback (or all callbacks) from the hook with a
|
||||
* given hookName and namespace.
|
||||
*
|
||||
* @param {string} hookName The name of the hook to modify.
|
||||
* @param {string} namespace The unique namespace identifying the callback in the form `vendor/plugin/function`.
|
||||
*
|
||||
* @return {number} The number of callbacks removed.
|
||||
*/
|
||||
return function removeHook(hookName, namespace) {
|
||||
if (!build_module_validateHookName(hookName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!removeAll && !build_module_validateNamespace(namespace)) {
|
||||
return;
|
||||
} // Bail if no hooks exist by this name
|
||||
|
||||
|
||||
if (!hooks[hookName]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var handlersRemoved = 0;
|
||||
|
||||
if (removeAll) {
|
||||
handlersRemoved = hooks[hookName].handlers.length;
|
||||
hooks[hookName] = {
|
||||
runs: hooks[hookName].runs,
|
||||
handlers: []
|
||||
};
|
||||
} else {
|
||||
// Try to find the specified callback to remove.
|
||||
var handlers = hooks[hookName].handlers;
|
||||
|
||||
var _loop = function _loop(i) {
|
||||
if (handlers[i].namespace === namespace) {
|
||||
handlers.splice(i, 1);
|
||||
handlersRemoved++; // This callback may also be part of a hook that is
|
||||
// currently executing. If the callback we're removing
|
||||
// comes after the current callback, there's no problem;
|
||||
// otherwise we need to decrease the execution index of any
|
||||
// other runs by 1 to account for the removed element.
|
||||
|
||||
(hooks.__current || []).forEach(function (hookInfo) {
|
||||
if (hookInfo.name === hookName && hookInfo.currentIndex >= i) {
|
||||
hookInfo.currentIndex--;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
for (var i = handlers.length - 1; i >= 0; i--) {
|
||||
_loop(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (hookName !== 'hookRemoved') {
|
||||
doAction('hookRemoved', hookName, namespace);
|
||||
}
|
||||
|
||||
return handlersRemoved;
|
||||
};
|
||||
}
|
||||
|
||||
/* harmony default export */ var build_module_createRemoveHook = (createRemoveHook);
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createHasHook.js
|
||||
/**
|
||||
* Returns a function which, when invoked, will return whether any handlers are
|
||||
* attached to a particular hook.
|
||||
*
|
||||
* @param {Object} hooks Stored hooks, keyed by hook name.
|
||||
*
|
||||
* @return {Function} Function that returns whether any handlers are
|
||||
* attached to a particular hook.
|
||||
*/
|
||||
function createHasHook(hooks) {
|
||||
/**
|
||||
* Returns how many handlers are attached for the given hook.
|
||||
*
|
||||
* @param {string} hookName The name of the hook to check for.
|
||||
*
|
||||
* @return {boolean} Whether there are handlers that are attached to the given hook.
|
||||
*/
|
||||
return function hasHook(hookName) {
|
||||
return hookName in hooks;
|
||||
};
|
||||
}
|
||||
|
||||
/* harmony default export */ var build_module_createHasHook = (createHasHook);
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createRunHook.js
|
||||
/**
|
||||
* Returns a function which, when invoked, will execute all callbacks
|
||||
* registered to a hook of the specified type, optionally returning the final
|
||||
* value of the call chain.
|
||||
*
|
||||
* @param {Object} hooks Stored hooks, keyed by hook name.
|
||||
* @param {?boolean} returnFirstArg Whether each hook callback is expected to
|
||||
* return its first argument.
|
||||
*
|
||||
* @return {Function} Function that runs hook callbacks.
|
||||
*/
|
||||
function createRunHook(hooks, returnFirstArg) {
|
||||
/**
|
||||
* Runs all callbacks for the specified hook.
|
||||
*
|
||||
* @param {string} hookName The name of the hook to run.
|
||||
* @param {...*} args Arguments to pass to the hook callbacks.
|
||||
*
|
||||
* @return {*} Return value of runner, if applicable.
|
||||
*/
|
||||
return function runHooks(hookName) {
|
||||
if (!hooks[hookName]) {
|
||||
hooks[hookName] = {
|
||||
handlers: [],
|
||||
runs: 0
|
||||
};
|
||||
}
|
||||
|
||||
hooks[hookName].runs++;
|
||||
var handlers = hooks[hookName].handlers;
|
||||
|
||||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
args[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
if (!handlers || !handlers.length) {
|
||||
return returnFirstArg ? args[0] : undefined;
|
||||
}
|
||||
|
||||
var hookInfo = {
|
||||
name: hookName,
|
||||
currentIndex: 0
|
||||
};
|
||||
|
||||
hooks.__current.push(hookInfo);
|
||||
|
||||
while (hookInfo.currentIndex < handlers.length) {
|
||||
var handler = handlers[hookInfo.currentIndex];
|
||||
var result = handler.callback.apply(null, args);
|
||||
|
||||
if (returnFirstArg) {
|
||||
args[0] = result;
|
||||
}
|
||||
|
||||
hookInfo.currentIndex++;
|
||||
}
|
||||
|
||||
hooks.__current.pop();
|
||||
|
||||
if (returnFirstArg) {
|
||||
return args[0];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/* harmony default export */ var build_module_createRunHook = (createRunHook);
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createCurrentHook.js
|
||||
/**
|
||||
* Returns a function which, when invoked, will return the name of the
|
||||
* currently running hook, or `null` if no hook of the given type is currently
|
||||
* running.
|
||||
*
|
||||
* @param {Object} hooks Stored hooks, keyed by hook name.
|
||||
*
|
||||
* @return {Function} Function that returns the current hook.
|
||||
*/
|
||||
function createCurrentHook(hooks) {
|
||||
/**
|
||||
* Returns the name of the currently running hook, or `null` if no hook of
|
||||
* the given type is currently running.
|
||||
*
|
||||
* @return {?string} The name of the currently running hook, or
|
||||
* `null` if no hook is currently running.
|
||||
*/
|
||||
return function currentHook() {
|
||||
if (!hooks.__current || !hooks.__current.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return hooks.__current[hooks.__current.length - 1].name;
|
||||
};
|
||||
}
|
||||
|
||||
/* harmony default export */ var build_module_createCurrentHook = (createCurrentHook);
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createDoingHook.js
|
||||
/**
|
||||
* Returns a function which, when invoked, will return whether a hook is
|
||||
* currently being executed.
|
||||
*
|
||||
* @param {Object} hooks Stored hooks, keyed by hook name.
|
||||
*
|
||||
* @return {Function} Function that returns whether a hook is currently
|
||||
* being executed.
|
||||
*/
|
||||
function createDoingHook(hooks) {
|
||||
/**
|
||||
* Returns whether a hook is currently being executed.
|
||||
*
|
||||
* @param {?string} hookName The name of the hook to check for. If
|
||||
* omitted, will check for any hook being executed.
|
||||
*
|
||||
* @return {boolean} Whether the hook is being executed.
|
||||
*/
|
||||
return function doingHook(hookName) {
|
||||
// If the hookName was not passed, check for any current hook.
|
||||
if ('undefined' === typeof hookName) {
|
||||
return 'undefined' !== typeof hooks.__current[0];
|
||||
} // Return the __current hook.
|
||||
|
||||
|
||||
return hooks.__current[0] ? hookName === hooks.__current[0].name : false;
|
||||
};
|
||||
}
|
||||
|
||||
/* harmony default export */ var build_module_createDoingHook = (createDoingHook);
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createDidHook.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns a function which, when invoked, will return the number of times a
|
||||
* hook has been called.
|
||||
*
|
||||
* @param {Object} hooks Stored hooks, keyed by hook name.
|
||||
*
|
||||
* @return {Function} Function that returns a hook's call count.
|
||||
*/
|
||||
|
||||
function createDidHook(hooks) {
|
||||
/**
|
||||
* Returns the number of times an action has been fired.
|
||||
*
|
||||
* @param {string} hookName The hook name to check.
|
||||
*
|
||||
* @return {number} The number of times the hook has run.
|
||||
*/
|
||||
return function didHook(hookName) {
|
||||
if (!build_module_validateHookName(hookName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return hooks[hookName] && hooks[hookName].runs ? hooks[hookName].runs : 0;
|
||||
};
|
||||
}
|
||||
|
||||
/* harmony default export */ var build_module_createDidHook = (createDidHook);
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createHooks.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns an instance of the hooks object.
|
||||
*
|
||||
* @return {Object} Object that contains all hooks.
|
||||
*/
|
||||
|
||||
function createHooks() {
|
||||
var actions = Object.create(null);
|
||||
var filters = Object.create(null);
|
||||
actions.__current = [];
|
||||
filters.__current = [];
|
||||
return {
|
||||
addAction: build_module_createAddHook(actions),
|
||||
addFilter: build_module_createAddHook(filters),
|
||||
removeAction: build_module_createRemoveHook(actions),
|
||||
removeFilter: build_module_createRemoveHook(filters),
|
||||
hasAction: build_module_createHasHook(actions),
|
||||
hasFilter: build_module_createHasHook(filters),
|
||||
removeAllActions: build_module_createRemoveHook(actions, true),
|
||||
removeAllFilters: build_module_createRemoveHook(filters, true),
|
||||
doAction: build_module_createRunHook(actions),
|
||||
applyFilters: build_module_createRunHook(filters, true),
|
||||
currentAction: build_module_createCurrentHook(actions),
|
||||
currentFilter: build_module_createCurrentHook(filters),
|
||||
doingAction: build_module_createDoingHook(actions),
|
||||
doingFilter: build_module_createDoingHook(filters),
|
||||
didAction: build_module_createDidHook(actions),
|
||||
didFilter: build_module_createDidHook(filters),
|
||||
actions: actions,
|
||||
filters: filters
|
||||
};
|
||||
}
|
||||
|
||||
/* harmony default export */ var build_module_createHooks = (createHooks);
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/index.js
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addAction", function() { return addAction; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addFilter", function() { return addFilter; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeAction", function() { return removeAction; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeFilter", function() { return removeFilter; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasAction", function() { return hasAction; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasFilter", function() { return hasFilter; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeAllActions", function() { return removeAllActions; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeAllFilters", function() { return removeAllFilters; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doAction", function() { return doAction; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "applyFilters", function() { return applyFilters; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "currentAction", function() { return currentAction; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "currentFilter", function() { return currentFilter; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doingAction", function() { return doingAction; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doingFilter", function() { return doingFilter; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "didAction", function() { return didAction; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "didFilter", function() { return didFilter; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "actions", function() { return build_module_actions; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "filters", function() { return build_module_filters; });
|
||||
/* concated harmony reexport createHooks */__webpack_require__.d(__webpack_exports__, "createHooks", function() { return build_module_createHooks; });
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
var _createHooks = build_module_createHooks(),
|
||||
addAction = _createHooks.addAction,
|
||||
addFilter = _createHooks.addFilter,
|
||||
removeAction = _createHooks.removeAction,
|
||||
removeFilter = _createHooks.removeFilter,
|
||||
hasAction = _createHooks.hasAction,
|
||||
hasFilter = _createHooks.hasFilter,
|
||||
removeAllActions = _createHooks.removeAllActions,
|
||||
removeAllFilters = _createHooks.removeAllFilters,
|
||||
doAction = _createHooks.doAction,
|
||||
applyFilters = _createHooks.applyFilters,
|
||||
currentAction = _createHooks.currentAction,
|
||||
currentFilter = _createHooks.currentFilter,
|
||||
doingAction = _createHooks.doingAction,
|
||||
doingFilter = _createHooks.doingFilter,
|
||||
didAction = _createHooks.didAction,
|
||||
didFilter = _createHooks.didFilter,
|
||||
build_module_actions = _createHooks.actions,
|
||||
build_module_filters = _createHooks.filters;
|
||||
|
||||
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
/******/ });
|
||||
@@ -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.
|
||||
@@ -0,0 +1,5 @@
|
||||
# control-base
|
||||
|
||||
This package serves as a base for other controls.
|
||||
|
||||
By itself the `\Kirki\Control\Base` doesn't do anything. It is simply an object that all other Kirki controls should extend to avoid code duplication.
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "kirki-framework/control-base",
|
||||
"type": "library",
|
||||
"description": "The base class for other Kirki's controls.",
|
||||
"keywords": [
|
||||
"wordpress",
|
||||
"customizer",
|
||||
"framework"
|
||||
],
|
||||
"homepage": "https://kirki.org",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kirki Framework",
|
||||
"email": "connect@mapsteps.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.0",
|
||||
"kirki-framework/url-getter": "*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Kirki\\Control\\": "src/Control"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
@media screen and (min-width:1667px){.rtl .wp-full-overlay.expanded{margin-left:0;margin-right:300px}.wp-full-overlay.expanded{margin-left:300px}}#customize-theme-controls .customize-pane-child.open{overflow:visible}.wp-full-overlay-sidebar{width:300px}.expanded .wp-full-overlay-footer{max-width:299px}.kirki-w100{width:100%}.kirki-w50{width:50%}.kirki-w45{width:45%}.kirki-w40{width:40%}.kirki-w33{width:33.3333%}.kirki-w30{width:30%}.kirki-w25{width:25%}.kirki-w20{width:20%}.kirki-w15{width:15%}.kirki-w10{width:10%}.kirki-w5{width:5%}.control-section-kirki-default,.control-section-kirki-outer{min-height:100%}.customize-control-has-small-gap{margin-bottom:9px}.customize-control-is-gapless{margin-bottom:0}.customize-control-kirki-hidden-field{height:0;margin-bottom:0}.customize-control-kirki,.customize-control-kirki *{box-sizing:border-box}.customize-control-kirki.kirki-group-item{clear:none}.kirki-group-item{clear:none;float:left;padding-left:3px;padding-right:3px}.kirki-group-item.kirki-group-start{padding-left:0;padding-right:3px}.kirki-group-item.kirki-group-break,.kirki-group-item.kirki-group-end{padding-left:3px;padding-right:0}.kirki-group-item.kirki-group-end:after{clear:both;content:"";display:block;height:0;width:100%}.customize-control-kirki{position:relative}.customize-control-kirki .kirki-control-label,.customize-control-kirki label.customize-control-title{display:block}.customize-control-kirki .kirki-control-form{position:relative}.customize-control-kirki .kirki-control-form textarea{display:block;width:100%}
|
||||
/*# sourceMappingURL=control.css.map */
|
||||
@@ -0,0 +1 @@
|
||||
{"mappings":"AACE,qCACE,+BAEE,aAAA,CADA,kBCCJ,CCDA,0BACE,iBDMF,CALF,CCGA,qDACE,gBDKF,CCFA,yBACE,WDKF,CCFA,kCACE,eDKF,CCFA,YACE,UDKF,CCFA,WACE,SDKF,CCFA,WACE,SDKF,CCFA,WACE,SDKF,CCFA,WACE,cDKF,CCFA,WACE,SDKF,CCFA,WACE,SDKF,CCFA,WACE,SDKF,CCFA,WACE,SDKF,CCFA,WACE,SDKF,CCFA,UACE,QDKF,CCFA,4DAEE,eDKF,CCFA,iCACE,iBDKF,CCFA,8BACE,eDKF,CCFA,sCAEE,QAAA,CADA,eDMF,CCFA,oDAEE,qBDKF,CCFA,0CACE,UDKF,CCFA,kBAEE,UAAA,CADA,UAAA,CAEA,gBAAA,CACA,iBDKF,CCHE,oCACE,cAAA,CACA,iBDKJ,CCFE,sEAEE,gBAAA,CACA,eDGJ,CCCI,wCAKE,UAAA,CAJA,UAAA,CACA,aAAA,CAEA,QAAA,CADA,UDGN,CCIA,yBACE,iBDDF,CCGE,qGAEE,aDDJ,CCIE,6CACE,iBDFJ,CCII,sDACE,aAAA,CACA,UDFN","sources":["src/rtl.scss","%3Cinput%20css%20N7IR_2%3E","src/control.scss"],"sourcesContent":[".rtl {\n @media screen and (min-width: 1667px) {\n .wp-full-overlay.expanded {\n margin-right: 300px;\n margin-left: 0;\n }\n }\n}\n","@media screen and (min-width: 1667px) {\n .rtl .wp-full-overlay.expanded {\n margin-right: 300px;\n margin-left: 0;\n }\n}\n\n@media screen and (min-width: 1667px) {\n .wp-full-overlay.expanded {\n margin-left: 300px;\n }\n}\n#customize-theme-controls .customize-pane-child.open {\n overflow: visible;\n}\n\n.wp-full-overlay-sidebar {\n width: 300px;\n}\n\n.expanded .wp-full-overlay-footer {\n max-width: 299px;\n}\n\n.kirki-w100 {\n width: 100%;\n}\n\n.kirki-w50 {\n width: 50%;\n}\n\n.kirki-w45 {\n width: 45%;\n}\n\n.kirki-w40 {\n width: 40%;\n}\n\n.kirki-w33 {\n width: 33.3333%;\n}\n\n.kirki-w30 {\n width: 30%;\n}\n\n.kirki-w25 {\n width: 25%;\n}\n\n.kirki-w20 {\n width: 20%;\n}\n\n.kirki-w15 {\n width: 15%;\n}\n\n.kirki-w10 {\n width: 10%;\n}\n\n.kirki-w5 {\n width: 5%;\n}\n\n.control-section-kirki-default,\n.control-section-kirki-outer {\n min-height: 100%;\n}\n\n.customize-control-has-small-gap {\n margin-bottom: 9px;\n}\n\n.customize-control-is-gapless {\n margin-bottom: 0;\n}\n\n.customize-control-kirki-hidden-field {\n margin-bottom: 0;\n height: 0;\n}\n\n.customize-control-kirki,\n.customize-control-kirki * {\n box-sizing: border-box;\n}\n\n.customize-control-kirki.kirki-group-item {\n clear: none;\n}\n\n.kirki-group-item {\n float: left;\n clear: none;\n padding-left: 3px;\n padding-right: 3px;\n}\n.kirki-group-item.kirki-group-start {\n padding-left: 0;\n padding-right: 3px;\n}\n.kirki-group-item.kirki-group-break, .kirki-group-item.kirki-group-end {\n padding-left: 3px;\n padding-right: 0;\n}\n.kirki-group-item.kirki-group-end::after {\n content: \"\";\n display: block;\n width: 100%;\n height: 0;\n clear: both;\n}\n\n.customize-control-kirki {\n position: relative;\n}\n.customize-control-kirki .kirki-control-label,\n.customize-control-kirki label.customize-control-title {\n display: block;\n}\n.customize-control-kirki .kirki-control-form {\n position: relative;\n}\n.customize-control-kirki .kirki-control-form textarea {\n display: block;\n width: 100%;\n}\n/*# sourceMappingURL=control.css.map */\n","@import \"rtl.scss\";\n\n@media screen and (min-width: 1667px) {\n .wp-full-overlay.expanded {\n margin-left: 300px;\n }\n}\n\n#customize-theme-controls .customize-pane-child.open {\n overflow: visible;\n}\n\n.wp-full-overlay-sidebar {\n width: 300px;\n}\n\n.expanded .wp-full-overlay-footer {\n max-width: 299px;\n}\n\n.kirki-w100 {\n width: 100%;\n}\n\n.kirki-w50 {\n width: 50%;\n}\n\n.kirki-w45 {\n width: 45%;\n}\n\n.kirki-w40 {\n width: 40%;\n}\n\n.kirki-w33 {\n width: 33.3333%;\n}\n\n.kirki-w30 {\n width: 30%;\n}\n\n.kirki-w25 {\n width: 25%;\n}\n\n.kirki-w20 {\n width: 20%;\n}\n\n.kirki-w15 {\n width: 15%;\n}\n\n.kirki-w10 {\n width: 10%;\n}\n\n.kirki-w5 {\n width: 5%;\n}\n\n.control-section-kirki-default,\n.control-section-kirki-outer {\n min-height: 100%;\n}\n\n.customize-control-has-small-gap {\n margin-bottom: 9px;\n}\n\n.customize-control-is-gapless {\n margin-bottom: 0;\n}\n\n.customize-control-kirki-hidden-field {\n margin-bottom: 0;\n height: 0;\n}\n\n.customize-control-kirki,\n.customize-control-kirki * {\n box-sizing: border-box;\n}\n\n.customize-control-kirki.kirki-group-item {\n clear: none; // Override WordPress.\n}\n\n.kirki-group-item {\n float: left;\n clear: none;\n padding-left: 3px;\n padding-right: 3px;\n\n &.kirki-group-start {\n padding-left: 0;\n padding-right: 3px;\n }\n\n &.kirki-group-break,\n &.kirki-group-end {\n padding-left: 3px;\n padding-right: 0;\n }\n\n &.kirki-group-end {\n &::after {\n content: \"\";\n display: block;\n width: 100%;\n height: 0;\n clear: both;\n }\n }\n}\n\n.customize-control-kirki {\n position: relative;\n\n .kirki-control-label,\n label.customize-control-title {\n display: block;\n }\n\n .kirki-control-form {\n position: relative;\n\n textarea {\n display: block;\n width: 100%;\n }\n }\n}\n"],"names":[],"version":3,"file":"control.css.map"}
|
||||
@@ -0,0 +1,2 @@
|
||||
!function(){var t;wp.customize.kirkiDynamicControl=wp.customize.Control.extend({initialize:function(t,e){var i,n=this,o=e||{};if(o.params=o.params||{},o.params.type||(o.params.type="kirki-generic"),o.content){var r=o.content.split('class="');r=r[1].split('"'),i=r[0]}else i="customize-control customize-control-"+o.params.type;!o.params.wrapper_attrs&&o.params.wrapper_atts&&(o.params.wrapper_attrs=o.params.wrapper_atts),o.params.content=jQuery("<li></li>"),o.params.content.attr("id","customize-control-"+t.replace(/]/g,"").replace(/\[/g,"-")),o.params.content.attr("class",i),_.each(o.params.wrapper_attrs,(function(t,e){"class"===e&&(t=t.replace("{default_class}",i)),o.params.content.attr(e,t)})),n.propertyElements=[],wp.customize.Control.prototype.initialize.call(n,t,o),wp.hooks.doAction("kirki.dynamicControl.init.after",t,n,o)},_setUpSettingRootLinks:function(){var t=this;t.container.find("[data-customize-setting-link]").each((function(){var e=jQuery(this);wp.customize(e.data("customizeSettingLink"),(function(i){var n=new wp.customize.Element(e);t.elements.push(n),n.sync(i),n.set(i())}))}))},_setUpSettingPropertyLinks:function(){var t=this;t.setting&&t.container.find("[data-customize-setting-property-link]").each((function(){var e,i=jQuery(this),n=i.data("customizeSettingPropertyLink");e=new wp.customize.Element(i),t.propertyElements.push(e),e.set(t.setting()[n]),e.bind((function(e){var i=t.setting();e!==i[n]&&((i=_.clone(i))[n]=e,t.setting.set(i))})),t.setting.bind((function(t){t[n]!==e.get()&&e.set(t[n])}))}))},ready:function(){var t=this;t._setUpSettingRootLinks(),t._setUpSettingPropertyLinks(),wp.customize.Control.prototype.ready.call(t),t.deferred.embedded.done((function(){t.initKirkiControl(),wp.hooks.doAction("kirki.dynamicControl.ready.deferred.embedded.done",t)})),wp.hooks.doAction("kirki.dynamicControl.ready.after",t)},embed:function(){var t=this,e=t.section();e&&(wp.customize.section(e,(function(e){"kirki-expanded"===e.params.type||e.expanded()||wp.customize.settings.autofocus.control===t.id?t.actuallyEmbed():e.expanded.bind((function(e){e&&t.actuallyEmbed()}))})),wp.hooks.doAction("kirki.dynamicControl.embed.after",t))},actuallyEmbed:function(){var t=this;"resolved"!==t.deferred.embedded.state()&&(t.renderContent(),t.deferred.embedded.resolve(),wp.hooks.doAction("kirki.dynamicControl.actuallyEmbed.after",t))},focus:function(t){var e=this;e.actuallyEmbed(),wp.customize.Control.prototype.focus.call(e,t),wp.hooks.doAction("kirki.dynamicControl.focus.after",e)},initKirkiControl:function(t){t=t||this,wp.hooks.doAction("kirki.dynamicControl.initKirkiControl",this),t.container.on("change keyup paste click","input",(function(){t.setting.set(jQuery(this).val())}))}}),(t=wp.customize).Value.prototype.set=function(e){var i,n,o=this._value;return e=this._setter.apply(this,arguments),null===(e=this.validate(e))||_.isEqual(o,e)||(this.id&&t.control(this.id)&&t.control(this.id).params&&t.control(this.id).params.parent_setting&&(i=t.control(this.id).params.parent_setting,(n={})[this.id.replace(i+"[","").replace("]","")]=e,t.control(i).setting.set(jQuery.extend({},t.control(i).setting._value,n))),this._value=e,this._dirty=!0,this.callbacks.fireWith(this,[e,o])),this},t.Value.prototype.get=function(){var e;return this.id&&t.control(this.id)&&t.control(this.id).params&&t.control(this.id).params.parent_setting?(e=t.control(this.id).params.parent_setting,t.control(e).setting.get()[this.id.replace(e+"[","").replace("]","")]):this._value}}();
|
||||
//# sourceMappingURL=control.js.map
|
||||
@@ -0,0 +1,347 @@
|
||||
<?php
|
||||
/**
|
||||
* Customizer Controls Base.
|
||||
*
|
||||
* Extend this in other controls.
|
||||
*
|
||||
* @package kirki-framework/control-base
|
||||
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Control;
|
||||
|
||||
use Kirki\URL;
|
||||
|
||||
/**
|
||||
* A base for controls.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class Base extends \WP_Customize_Control {
|
||||
|
||||
/**
|
||||
* Used to automatically generate all CSS output.
|
||||
*
|
||||
* Whitelisting property for use in Kirki modules.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var array
|
||||
*/
|
||||
public $output = [];
|
||||
|
||||
/**
|
||||
* Data type
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $option_type = 'theme_mod';
|
||||
|
||||
/**
|
||||
* Option name (if using options).
|
||||
*
|
||||
* Whitelisting property for use in Kirki modules.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $option_name = false;
|
||||
|
||||
/**
|
||||
* The kirki_config we're using for this control
|
||||
*
|
||||
* Whitelisting property for use in Kirki modules.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $kirki_config = 'global';
|
||||
|
||||
/**
|
||||
* Whitelisting the "preset" argument for use in Kirki modules.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var array
|
||||
*/
|
||||
public $preset = [];
|
||||
|
||||
/**
|
||||
* Whitelisting the "css_vars" argument for use in Kirki modules.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $css_vars = '';
|
||||
|
||||
/**
|
||||
* The version. Used in scripts & styles for cache-busting.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public static $control_ver = '1.0.4';
|
||||
|
||||
/**
|
||||
* Parent setting.
|
||||
*
|
||||
* Used for composite controls to denote the setting that should be saved.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.1
|
||||
* @var string
|
||||
*/
|
||||
public $parent_setting;
|
||||
|
||||
/**
|
||||
* Wrapper attributes.
|
||||
*
|
||||
* The value of this property will be rendered to the wrapper element.
|
||||
* Can be 'class', 'id', 'data-*', and other attributes.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.1
|
||||
* @var array
|
||||
*/
|
||||
public $wrapper_attrs = [];
|
||||
|
||||
/**
|
||||
* Backwards compatibility support for `$wrapper_attrs`.
|
||||
*
|
||||
* Kirki v3 already has this `$wrapper_atts` property.
|
||||
* It was not published in the documentation, and more for internal use.
|
||||
*
|
||||
* The `WP_Customize_Control` is using `input_attrs` not `input_atts` (see, attrs vs atts).
|
||||
* So Kirki uses `$wrapper_attrs` for consistency and keep the old `$wrapper_atts` backwards compatibility.
|
||||
*
|
||||
* This property could be removed in the future.
|
||||
* Please use `$wrapper_attrs` instead.
|
||||
*
|
||||
* @since 1.1
|
||||
* @deprecated 1.0.1 This variable could be removed in the future. Please use `$wrapper_attrs` instead.
|
||||
* @var array
|
||||
*/
|
||||
public $wrapper_atts = [];
|
||||
|
||||
/**
|
||||
* Wrapper options.
|
||||
*
|
||||
* This won't be rendered automatically to the wrapper element.
|
||||
* The purpose is to allow us to have custom options so we can manage it when needed.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.1
|
||||
* @var array
|
||||
*/
|
||||
public $wrapper_opts = [];
|
||||
|
||||
/**
|
||||
* Extra script dependencies.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @return array
|
||||
*/
|
||||
public function kirki_script_dependencies() {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue control related scripts/styles.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue() {
|
||||
|
||||
// Enqueue the styles.
|
||||
wp_enqueue_style( 'kirki-control-base', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], self::$control_ver );
|
||||
|
||||
// Enqueue the scripts.
|
||||
wp_enqueue_script( 'kirki-control-base', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [ 'customize-controls' ], self::$control_ver, false );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the control wrapper and calls $this->render_content() for the internals.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
protected function render() {
|
||||
|
||||
$id = 'customize-control-' . str_replace( [ '[', ']' ], [ '-', '' ], $this->id );
|
||||
$class = 'customize-control customize-control-kirki customize-control-' . $this->type;
|
||||
$gap = isset( $this->wrapper_opts['gap'] ) ? $this->wrapper_opts['gap'] : 'default';
|
||||
$tag = isset( $this->wrapper_opts['tag'] ) ? $this->wrapper_opts['tag'] : 'li';
|
||||
|
||||
switch ( $gap ) {
|
||||
case 'small':
|
||||
$class .= ' customize-control-has-small-gap';
|
||||
break;
|
||||
|
||||
case 'none':
|
||||
$class .= ' customize-control-is-gapless';
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if ( empty( $this->wrapper_attrs ) && ! empty( $this->wrapper_atts ) ) {
|
||||
$this->wrapper_attrs = $this->wrapper_atts;
|
||||
}
|
||||
|
||||
if ( isset( $this->wrapper_attrs['id'] ) ) {
|
||||
$id = $this->wrapper_attrs['id'];
|
||||
}
|
||||
|
||||
if ( ! isset( $this->wrapper_attrs['data-kirki-setting'] ) ) {
|
||||
$this->wrapper_attrs['data-kirki-setting'] = $this->id;
|
||||
}
|
||||
|
||||
if ( ! isset( $this->wrapper_attrs['data-kirki-setting-link'] ) ) {
|
||||
if ( isset( $this->settings['default'] ) ) {
|
||||
$this->wrapper_attrs['data-kirki-setting-link'] = $this->settings['default']->id;
|
||||
}
|
||||
}
|
||||
|
||||
$data_attrs = '';
|
||||
|
||||
foreach ( $this->wrapper_attrs as $attr_key => $attr_value ) {
|
||||
if ( 0 === strpos( $attr_key, 'data-' ) ) {
|
||||
$data_attrs .= ' ' . esc_attr( $attr_key ) . '="' . esc_attr( $attr_value ) . '"';
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $this->wrapper_attrs['class'] ) ) {
|
||||
$class = str_ireplace( '{default_class}', $class, $this->wrapper_attrs['class'] );
|
||||
}
|
||||
|
||||
// ! Consider to esc $data_attrs.
|
||||
// ? What function we can use to escape string like data-xx="yy"?
|
||||
printf( '<' . esc_attr( $tag ) . ' id="%s" class="%s"%s>', esc_attr( $id ), esc_attr( $class ), $data_attrs );
|
||||
$this->render_content();
|
||||
echo '</' . esc_attr( $tag ) . '>';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the parameters passed to the JavaScript via JSON.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @see WP_Customize_Control::to_json()
|
||||
* @return void
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
// 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'] = '';
|
||||
|
||||
if ( is_array( $this->input_attrs ) ) {
|
||||
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;
|
||||
|
||||
// Parent setting.
|
||||
$this->json['parent_setting'] = $this->parent_setting;
|
||||
|
||||
// Wrapper Attributes.
|
||||
$this->json['wrapper_attrs'] = $this->wrapper_attrs;
|
||||
$this->json['wrapper_atts'] = $this->wrapper_attrs; // For backward compatibility - Could be removed in the future.
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the control's content.
|
||||
*
|
||||
* Allows the content to be overridden without having to rewrite the wrapper in `$this::render()`.
|
||||
* Control content can alternately be rendered in JS. See WP_Customize_Control::print_template().
|
||||
*
|
||||
* @access protected
|
||||
* @since 1.0
|
||||
* @return void
|
||||
*/
|
||||
protected function render_content() {}
|
||||
|
||||
/**
|
||||
* 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()}.
|
||||
*
|
||||
* @access protected
|
||||
* @since 1.0
|
||||
* @see WP_Customize_Control::print_template()
|
||||
* @return void
|
||||
*/
|
||||
protected function content_template() {}
|
||||
|
||||
/**
|
||||
* Returns an array of translation strings.
|
||||
*
|
||||
* @access protected
|
||||
* @since 3.0.0
|
||||
* @return array
|
||||
*/
|
||||
protected function l10n() {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
import "./control.scss";
|
||||
import "./dynamic-control";
|
||||
@@ -0,0 +1,289 @@
|
||||
/**
|
||||
* The majority of the code in this file
|
||||
* is derived from the wp-customize-posts plugin
|
||||
* and the work of @westonruter to whom I am very grateful.
|
||||
*
|
||||
* @see https://github.com/xwp/wp-customize-posts
|
||||
*/
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* A dynamic color-alpha control.
|
||||
*
|
||||
* @class
|
||||
* @augments wp.customize.Control
|
||||
* @augments wp.customize.Class
|
||||
*/
|
||||
wp.customize.kirkiDynamicControl = wp.customize.Control.extend({
|
||||
|
||||
initialize: function (id, options) {
|
||||
let control = this;
|
||||
let args = options || {};
|
||||
|
||||
args.params = args.params || {};
|
||||
|
||||
if (!args.params.type) {
|
||||
args.params.type = 'kirki-generic';
|
||||
}
|
||||
|
||||
let className;
|
||||
|
||||
if (args.content) {
|
||||
let splits = args.content.split('class="');
|
||||
splits = splits[1].split('"');
|
||||
className = splits[0];
|
||||
} else {
|
||||
className = 'customize-control customize-control-' + args.params.type;
|
||||
}
|
||||
|
||||
if (!args.params.wrapper_attrs && args.params.wrapper_atts) {
|
||||
args.params.wrapper_attrs = args.params.wrapper_atts;
|
||||
}
|
||||
|
||||
// Hijack the container to add wrapper_attrs.
|
||||
args.params.content = jQuery("<li></li>");
|
||||
args.params.content.attr('id', 'customize-control-' + id.replace(/]/g, '').replace(/\[/g, '-'));
|
||||
args.params.content.attr('class', className);
|
||||
|
||||
_.each(args.params.wrapper_attrs, function (val, key) {
|
||||
if ('class' === key) {
|
||||
val = val.replace('{default_class}', className);
|
||||
}
|
||||
|
||||
args.params.content.attr(key, val);
|
||||
});
|
||||
|
||||
control.propertyElements = [];
|
||||
wp.customize.Control.prototype.initialize.call(control, id, args);
|
||||
wp.hooks.doAction('kirki.dynamicControl.init.after', id, control, args);
|
||||
},
|
||||
|
||||
/**
|
||||
* Add bidirectional data binding links between inputs and the setting(s).
|
||||
*
|
||||
* This is copied from wp.customize.Control.prototype.initialize(). It
|
||||
* should be changed in Core to be applied once the control is embedded.
|
||||
*
|
||||
* @private
|
||||
* @returns {void}
|
||||
*/
|
||||
_setUpSettingRootLinks: function () {
|
||||
var control = this,
|
||||
nodes = control.container.find('[data-customize-setting-link]');
|
||||
|
||||
nodes.each(function () {
|
||||
var node = jQuery(this);
|
||||
|
||||
wp.customize(node.data('customizeSettingLink'), function (setting) {
|
||||
var element = new wp.customize.Element(node);
|
||||
control.elements.push(element);
|
||||
element.sync(setting);
|
||||
element.set(setting());
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Add bidirectional data binding links between inputs and the setting properties.
|
||||
*
|
||||
* @private
|
||||
* @returns {void}
|
||||
*/
|
||||
_setUpSettingPropertyLinks: function () {
|
||||
var control = this,
|
||||
nodes;
|
||||
|
||||
if (!control.setting) {
|
||||
return;
|
||||
}
|
||||
|
||||
nodes = control.container.find('[data-customize-setting-property-link]');
|
||||
|
||||
nodes.each(function () {
|
||||
var node = jQuery(this),
|
||||
element,
|
||||
propertyName = node.data('customizeSettingPropertyLink');
|
||||
|
||||
element = new wp.customize.Element(node);
|
||||
control.propertyElements.push(element);
|
||||
element.set(control.setting()[propertyName]);
|
||||
|
||||
element.bind(function (newPropertyValue) {
|
||||
var newSetting = control.setting();
|
||||
if (newPropertyValue === newSetting[propertyName]) {
|
||||
return;
|
||||
}
|
||||
newSetting = _.clone(newSetting);
|
||||
newSetting[propertyName] = newPropertyValue;
|
||||
control.setting.set(newSetting);
|
||||
});
|
||||
control.setting.bind(function (newValue) {
|
||||
if (newValue[propertyName] !== element.get()) {
|
||||
element.set(newValue[propertyName]);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
ready: function () {
|
||||
var control = this;
|
||||
|
||||
control._setUpSettingRootLinks();
|
||||
control._setUpSettingPropertyLinks();
|
||||
|
||||
wp.customize.Control.prototype.ready.call(control);
|
||||
|
||||
control.deferred.embedded.done(function () {
|
||||
control.initKirkiControl();
|
||||
wp.hooks.doAction('kirki.dynamicControl.ready.deferred.embedded.done', control);
|
||||
});
|
||||
wp.hooks.doAction('kirki.dynamicControl.ready.after', control);
|
||||
},
|
||||
|
||||
/**
|
||||
* Embed the control in the document.
|
||||
*
|
||||
* Override the embed() method to do nothing,
|
||||
* so that the control isn't embedded on load,
|
||||
* unless the containing section is already expanded.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
embed: function () {
|
||||
var control = this,
|
||||
sectionId = control.section();
|
||||
|
||||
if (!sectionId) {
|
||||
return;
|
||||
}
|
||||
|
||||
wp.customize.section(sectionId, function (section) {
|
||||
if ('kirki-expanded' === section.params.type || section.expanded() || wp.customize.settings.autofocus.control === control.id) {
|
||||
control.actuallyEmbed();
|
||||
} else {
|
||||
section.expanded.bind(function (expanded) {
|
||||
if (expanded) {
|
||||
control.actuallyEmbed();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
wp.hooks.doAction('kirki.dynamicControl.embed.after', control);
|
||||
},
|
||||
|
||||
/**
|
||||
* Deferred embedding of control when actually
|
||||
*
|
||||
* This function is called in Section.onChangeExpanded() so the control
|
||||
* will only get embedded when the Section is first expanded.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
actuallyEmbed: function () {
|
||||
var control = this;
|
||||
if ('resolved' === control.deferred.embedded.state()) {
|
||||
return;
|
||||
}
|
||||
control.renderContent();
|
||||
control.deferred.embedded.resolve(); // This triggers control.ready().
|
||||
wp.hooks.doAction('kirki.dynamicControl.actuallyEmbed.after', control);
|
||||
},
|
||||
|
||||
/**
|
||||
* This is not working with autofocus.
|
||||
*
|
||||
* @param {object} [args] Args.
|
||||
* @returns {void}
|
||||
*/
|
||||
focus: function (args) {
|
||||
var control = this;
|
||||
control.actuallyEmbed();
|
||||
wp.customize.Control.prototype.focus.call(control, args);
|
||||
wp.hooks.doAction('kirki.dynamicControl.focus.after', control);
|
||||
},
|
||||
|
||||
/**
|
||||
* Additional actions that run on ready.
|
||||
*
|
||||
* @param {object} control - The control object. If undefined fallsback to the this.
|
||||
* @returns {void}
|
||||
*/
|
||||
initKirkiControl: function (control) {
|
||||
control = control || this;
|
||||
wp.hooks.doAction('kirki.dynamicControl.initKirkiControl', this);
|
||||
|
||||
// Save the value
|
||||
control.container.on('change keyup paste click', 'input', function () {
|
||||
control.setting.set(jQuery(this).val());
|
||||
});
|
||||
}
|
||||
});
|
||||
}());
|
||||
|
||||
(function (api) {
|
||||
|
||||
/**
|
||||
* Set the value and trigger all bound callbacks.
|
||||
*
|
||||
* @since 1.0
|
||||
* @param {object} to - New value.
|
||||
* @returns {Object} - this
|
||||
*/
|
||||
api.Value.prototype.set = function (to) {
|
||||
var from = this._value,
|
||||
parentSetting,
|
||||
newVal;
|
||||
|
||||
to = this._setter.apply(this, arguments);
|
||||
to = this.validate(to);
|
||||
|
||||
// Bail if the sanitized value is null or unchanged.
|
||||
if (null === to || _.isEqual(from, to)) {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start Kirki mod.
|
||||
*/
|
||||
if (this.id && api.control(this.id) && api.control(this.id).params && api.control(this.id).params.parent_setting) {
|
||||
parentSetting = api.control(this.id).params.parent_setting;
|
||||
newVal = {};
|
||||
newVal[this.id.replace(parentSetting + '[', '').replace(']', '')] = to;
|
||||
api.control(parentSetting).setting.set(jQuery.extend({}, api.control(parentSetting).setting._value, newVal));
|
||||
}
|
||||
|
||||
/**
|
||||
* End Kirki mod.
|
||||
*/
|
||||
|
||||
this._value = to;
|
||||
this._dirty = true;
|
||||
|
||||
this.callbacks.fireWith(this, [to, from]);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the value.
|
||||
*
|
||||
* @returns {mixed} - Returns the value.
|
||||
*/
|
||||
api.Value.prototype.get = function () {
|
||||
|
||||
// Start Kirki mod.
|
||||
var parentSetting;
|
||||
if (this.id && api.control(this.id) && api.control(this.id).params && api.control(this.id).params.parent_setting) {
|
||||
parentSetting = api.control(this.id).params.parent_setting;
|
||||
return api.control(parentSetting).setting.get()[this.id.replace(parentSetting + '[', '').replace(']', '')];
|
||||
}
|
||||
// End Kirki mod.
|
||||
|
||||
return this._value;
|
||||
};
|
||||
}(wp.customize));
|
||||
@@ -0,0 +1,2 @@
|
||||
.customize-control-kirki-toggle .kirki-toggle{align-items:flex-start;display:flex;justify-content:space-between}.customize-control-kirki-toggle .kirki-toggle .kirki-control-label{width:80%}.customize-control-kirki-toggle .kirki-toggle .kirki-control-form{text-align:right;width:20%}.customize-control-kirki-toggle .kirki-toggle .kirki-toggle-switch-label{width:100%}.customize-control-kirki-toggle .kirki-toggle .kirki-toggle-switch-label:before{right:0}.customize-control-kirki-toggle .kirki-toggle .kirki-toggle-switch-label:after{right:18px}.customize-control-kirki-switch .kirki-switch .kirki-toggle-switch-label{padding:10px 0 12px 44px;text-align:left}.customize-control-kirki-switch .kirki-switch .kirki-toggle-switch-label:after,.customize-control-kirki-switch .kirki-switch .kirki-toggle-switch-label:before{left:0}.customize-control-kirki-switch .kirki-switch .toggle-off,.customize-control-kirki-switch .kirki-switch .toggle-on{bottom:-2px;padding-left:5px;position:relative}.customize-control-kirki-switch .kirki-switch .toggle-on{color:#0073aa;display:none}.customize-control-kirki-switch .kirki-switch .toggle-off{color:#82878c;display:inline-block}.kirki-toggle-switch-label{cursor:pointer;display:inline-block;position:relative}.kirki-toggle-switch-label:after,.kirki-toggle-switch-label:before{box-sizing:border-box;content:"";margin:0;outline:0;position:absolute;top:50%;transform:translate3d(0,-50%,0);transition:all .35s cubic-bezier(0,.95,.38,.98),background-color .15s ease}.kirki-toggle-switch-label:before{background-color:#b4b9be;border:1px solid #b4b9be;border-radius:8px;height:14px;width:37px}.kirki-toggle-switch-label:after{background-color:#999;border:1px solid rgba(0,0,0,.1);border-radius:50%;height:22px;width:22px}.kirki-toggle-switch-input{opacity:0}.kirki-toggle-switch-input:checked+.kirki-toggle-switch-label:after{background-color:#0073aa;transform:translate3d(100%,-50%,0)}.kirki-toggle-switch-input:checked+.kirki-toggle-switch-label .toggle-on{display:inline-block}.kirki-toggle-switch-input:checked+.kirki-toggle-switch-label .toggle-off{display:none}
|
||||
/*# sourceMappingURL=control.css.map */
|
||||
@@ -0,0 +1,2 @@
|
||||
!function(){var i={initKirkiControl:function(i){(i=i||this).container.on("change","input",(function(){i.setting.set(jQuery(this).is(":checked"))}))}};wp.customize.controlConstructor["kirki-checkbox"]=wp.customize.kirkiDynamicControl.extend(i),wp.customize.controlConstructor["kirki-switch"]=wp.customize.kirkiDynamicControl.extend(i),wp.customize.controlConstructor["kirki-toggle"]=wp.customize.kirkiDynamicControl.extend(i)}();
|
||||
//# sourceMappingURL=control.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"mappings":"YAEA,IAAIA,EAAsB,CAEzBC,iBAAkB,SAAUC,IAC3BA,EAAUA,GAAWC,MACbC,UAAUC,GAAI,SAAU,SAAS,WACxCH,EAAQI,QAAQC,IAAKC,OAAQL,MAAOM,GAAI,kBAK3CC,GAAGC,UAAUC,mBAAmB,kBAAoBF,GAAGC,UAAUE,oBAAoBC,OAAQd,GAC7FU,GAAGC,UAAUC,mBAAmB,gBAAoBF,GAAGC,UAAUE,oBAAoBC,OAAQd,GAC7FU,GAAGC,UAAUC,mBAAmB,gBAAoBF,GAAGC,UAAUE,oBAAoBC,OAAQd","sources":["src/control.js"],"sourcesContent":["import \"./control.scss\";\n\nvar kirkiCheckboxScript = {\n\n\tinitKirkiControl: function( control ) {\n\t\tcontrol = control || this;\n\t\tcontrol.container.on( 'change', 'input', function() {\n\t\t\tcontrol.setting.set( jQuery( this ).is( ':checked' ) );\n\t\t} );\n\t}\n};\n\nwp.customize.controlConstructor['kirki-checkbox'] = wp.customize.kirkiDynamicControl.extend( kirkiCheckboxScript );\nwp.customize.controlConstructor['kirki-switch'] = wp.customize.kirkiDynamicControl.extend( kirkiCheckboxScript );\nwp.customize.controlConstructor['kirki-toggle'] = wp.customize.kirkiDynamicControl.extend( kirkiCheckboxScript );\n"],"names":["$1abc80d3e2df1201$var$kirkiCheckboxScript","initKirkiControl","control","this","container","on","setting","set","jQuery","is","wp","customize","controlConstructor","kirkiDynamicControl","extend"],"version":3,"file":"control.js.map"}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/**
|
||||
* Customizer Control: checkbox.
|
||||
*
|
||||
* Creates a new custom control.
|
||||
* Custom controls contains all background-related options.
|
||||
*
|
||||
* @package kirki-framework/control-checkbox
|
||||
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Control;
|
||||
|
||||
use Kirki\Control\Base;
|
||||
use Kirki\URL;
|
||||
|
||||
/**
|
||||
* Adds a checkbox control.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class Checkbox extends Base {
|
||||
|
||||
/**
|
||||
* The control type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-checkbox';
|
||||
|
||||
/**
|
||||
* The control version.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public static $control_ver = '1.0.3';
|
||||
|
||||
/**
|
||||
* 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-checkbox', 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-checkbox-style', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], self::$control_ver );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
?>
|
||||
<input
|
||||
id="_customize-input-{{ data.id }}"
|
||||
type="checkbox"
|
||||
value="{{ data.value }}"
|
||||
{{{ data.link }}}
|
||||
<# if ( data.description ) { #>aria-describedby="_customize-description-{{ data.id }}"<# } #>
|
||||
<# if ( data.value ) { #>checked="checked"<# } #>
|
||||
/>
|
||||
<label for="_customize-input-{{ data.id }}">{{{ data.label }}}</label>
|
||||
<# if ( data.description ) { #>
|
||||
<span id="_customize-description-{{ data.id }}" class="description customize-control-description">{{{ data.description }}}</span>
|
||||
<# } #>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
/**
|
||||
* Customizer Control: switch.
|
||||
*
|
||||
* @package kirki-framework/checkbox
|
||||
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Control;
|
||||
|
||||
use Kirki\Control\Base;
|
||||
use Kirki\URL;
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch control (modified checkbox).
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class Checkbox_Switch extends Base {
|
||||
|
||||
/**
|
||||
* The control type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-switch';
|
||||
|
||||
/**
|
||||
* The control version.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public static $control_ver = '1.0.3';
|
||||
|
||||
/**
|
||||
* 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-checkbox', 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-checkbox-style', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], self::$control_ver );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the parameters passed to the JavaScript via JSON.
|
||||
*
|
||||
* @since 3.4.0
|
||||
*/
|
||||
public function to_json() {
|
||||
|
||||
// Get the basics from the parent class.
|
||||
parent::to_json();
|
||||
|
||||
$this->json['checkboxType'] = str_ireplace( 'kirki-', '', $this->type );
|
||||
|
||||
$this->json['defaultChoices'] = [
|
||||
'on' => __( 'On', 'kirki' ),
|
||||
'off' => __( 'Off', 'kirki' ),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
?>
|
||||
|
||||
<div class="kirki-{{ data.checkboxType }}-control kirki-{{ data.checkboxType }}">
|
||||
<# if ( data.label || data.description ) { #>
|
||||
<div class="kirki-control-label">
|
||||
<# if ( data.label ) { #>
|
||||
<label class="customize-control-title" for="kirki_{{ data.checkboxType }}_{{ data.id }}">
|
||||
{{{ data.label }}}
|
||||
</label>
|
||||
<# } #>
|
||||
|
||||
<# if ( data.description ) { #>
|
||||
<span class="description customize-control-description">{{{ data.description }}}</span>
|
||||
<# } #>
|
||||
</div>
|
||||
<# } #>
|
||||
|
||||
<div class="kirki-control-form">
|
||||
<input class="screen-reader-text kirki-toggle-switch-input" {{{ data.inputAttrs }}} name="kirki_{{ data.checkboxType }}_{{ data.id }}" id="kirki_{{ data.checkboxType }}_{{ data.id }}" type="checkbox" value="{{ data.value }}" {{{ data.link }}}<# if ( '1' == data.value ) { #> checked<# } #> />
|
||||
<label class="kirki-toggle-switch-label" for="kirki_{{ data.checkboxType }}_{{ data.id }}">
|
||||
<# if ('switch' === data.checkboxType) { #>
|
||||
<span class="toggle-on">
|
||||
<# data.choices.on = data.choices.on || data.defaultChoices.on #>
|
||||
{{ data.choices.on }}
|
||||
</span>
|
||||
<span class="toggle-off">
|
||||
<# data.choices.off = data.choices.off || data.defaultChoices.off #>
|
||||
{{ data.choices.off }}
|
||||
</span>
|
||||
<# } #>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Customizer Control: toggle.
|
||||
*
|
||||
* @package kirki-framework/checkbox
|
||||
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Control;
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch control (modified checkbox).
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class Checkbox_Toggle extends Checkbox_Switch {
|
||||
|
||||
/**
|
||||
* The control type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-toggle';
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
/**
|
||||
* Override field methods
|
||||
*
|
||||
* @package kirki-framework/checkbox
|
||||
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Field;
|
||||
|
||||
use Kirki\Field;
|
||||
|
||||
/**
|
||||
* Field overrides.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class Checkbox extends Field {
|
||||
|
||||
/**
|
||||
* The field type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-checkbox';
|
||||
|
||||
/**
|
||||
* The control class-name.
|
||||
*
|
||||
* @access protected
|
||||
* @since 0.1
|
||||
* @var string
|
||||
*/
|
||||
protected $control_class = '\Kirki\Control\Checkbox';
|
||||
|
||||
/**
|
||||
* 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'] = function( $value ) {
|
||||
return ( '0' === $value || 'false' === $value ) ? false : (bool) $value;
|
||||
};
|
||||
}
|
||||
|
||||
$args['default'] = isset( $args['default'] ) ? $args['default'] : false;
|
||||
|
||||
// Make sure the default is formatted as boolean.
|
||||
$args['default'] = (bool) ( 1 === $args['default'] || '1' === $args['default'] || true === $args['default'] || 'true' === $args['default'] || 'on' === $args['default'] );
|
||||
}
|
||||
|
||||
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-checkbox';
|
||||
}
|
||||
|
||||
return $args;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Override field methods
|
||||
*
|
||||
* @package kirki-framework/checkbox
|
||||
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Field;
|
||||
|
||||
/**
|
||||
* Field overrides.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class Checkbox_Switch extends Checkbox {
|
||||
|
||||
/**
|
||||
* The field type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-switch';
|
||||
|
||||
/**
|
||||
* The control class-name.
|
||||
*
|
||||
* @access protected
|
||||
* @since 0.1
|
||||
* @var string
|
||||
*/
|
||||
protected $control_class = '\Kirki\Control\Checkbox_Switch';
|
||||
|
||||
/**
|
||||
* 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-switch';
|
||||
}
|
||||
|
||||
return $args;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* Override field methods
|
||||
*
|
||||
* @package kirki-framework/checkbox
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Field;
|
||||
|
||||
/**
|
||||
* Field overrides.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class Checkbox_Toggle extends Checkbox {
|
||||
|
||||
/**
|
||||
* The field type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-toggle';
|
||||
|
||||
/**
|
||||
* The control class-name.
|
||||
*
|
||||
* @access protected
|
||||
* @since 0.1
|
||||
* @var string
|
||||
*/
|
||||
protected $control_class = '\Kirki\Control\Checkbox_Toggle';
|
||||
|
||||
/**
|
||||
* 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-toggle';
|
||||
}
|
||||
|
||||
return $args;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
@@ -0,0 +1,14 @@
|
||||
# control-code
|
||||
|
||||
## Installation
|
||||
|
||||
First, install the package using composer:
|
||||
|
||||
```bash
|
||||
composer require kirki-framework/control-code
|
||||
```
|
||||
|
||||
Make sure you include the autoloader:
|
||||
```php
|
||||
require_once get_parent_theme_file_path( 'vendor/autoload.php' );
|
||||
```
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "kirki-framework/control-code",
|
||||
"type": "library",
|
||||
"description": "Code control for the Kirki Customizer framework.",
|
||||
"keywords": [
|
||||
"wordpress",
|
||||
"customizer",
|
||||
"framework"
|
||||
],
|
||||
"homepage": "https://kirki.org",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kirki Framework",
|
||||
"email": "connect@mapsteps.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.0",
|
||||
"kirki-framework/field": "*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Kirki\\Control\\": "src/Control",
|
||||
"Kirki\\Field\\": "src/Field"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/**
|
||||
* The code editor control.
|
||||
*
|
||||
* Creates a code editor control.
|
||||
*
|
||||
* @package kirki-framework/control-code
|
||||
* @license MIT (https://oss.ninja/mit?organization=Kirki%20Framework)
|
||||
* @since 1.0.2
|
||||
*/
|
||||
|
||||
namespace Kirki\Control;
|
||||
|
||||
use Kirki\Control\Base;
|
||||
|
||||
/**
|
||||
* Slider control.
|
||||
*
|
||||
* @since 1.0.2
|
||||
*/
|
||||
class Code extends Base {
|
||||
|
||||
/**
|
||||
* The control version.
|
||||
*
|
||||
* @since 1.0.2
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public static $control_ver = '1.0.2';
|
||||
|
||||
/**
|
||||
* Customize control type.
|
||||
*
|
||||
* @since 1.0.2
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'code_editor';
|
||||
|
||||
/**
|
||||
* Type of code that is being edited.
|
||||
*
|
||||
* @since 1.0.2
|
||||
* @var string
|
||||
*/
|
||||
public $code_type = '';
|
||||
|
||||
/**
|
||||
* Code editor settings.
|
||||
*
|
||||
* @see wp_enqueue_code_editor()
|
||||
* @since 1.0.2
|
||||
* @var array|false
|
||||
*/
|
||||
public $editor_settings = array();
|
||||
|
||||
/**
|
||||
* Enqueue control related scripts/styles.
|
||||
*
|
||||
* @since 1.0.2
|
||||
*/
|
||||
public function enqueue() {
|
||||
$this->editor_settings = wp_enqueue_code_editor(
|
||||
array_merge(
|
||||
array(
|
||||
'type' => $this->code_type,
|
||||
'codemirror' => array(
|
||||
'indentUnit' => 2,
|
||||
'tabSize' => 2,
|
||||
),
|
||||
),
|
||||
$this->editor_settings
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the parameters passed to the JavaScript via JSON.
|
||||
*
|
||||
* @since 1.0.2
|
||||
*
|
||||
* @see WP_Customize_Control::json()
|
||||
*
|
||||
* @return array Array of parameters passed to the JavaScript.
|
||||
*/
|
||||
public function json() {
|
||||
$json = parent::json();
|
||||
$json['editor_settings'] = $this->editor_settings;
|
||||
$json['input_attrs'] = $this->input_attrs;
|
||||
return $json;
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't render the control content from PHP, as it's rendered via JS on load.
|
||||
*
|
||||
* @since 1.0.2
|
||||
*/
|
||||
public function render_content() {}
|
||||
|
||||
/**
|
||||
* Render a JS template for control display.
|
||||
*
|
||||
* @since 1.0.2
|
||||
*/
|
||||
public function content_template() {
|
||||
?>
|
||||
<# var elementIdPrefix = 'el' + String( Math.random() ); #>
|
||||
<# if ( data.label ) { #>
|
||||
<label for="{{ elementIdPrefix }}_editor" class="customize-control-title">
|
||||
{{ data.label }}
|
||||
</label>
|
||||
<# } #>
|
||||
<# if ( data.description ) { #>
|
||||
<span class="description customize-control-description">{{{ data.description }}}</span>
|
||||
<# } #>
|
||||
<div class="customize-control-notifications-container"></div>
|
||||
<textarea id="{{ elementIdPrefix }}_editor"
|
||||
<# _.each( _.extend( { 'class': 'code' }, data.input_attrs ), function( value, key ) { #>
|
||||
{{{ key }}}="{{ value }}"
|
||||
<# }); #>
|
||||
></textarea>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
/**
|
||||
* Override field methods
|
||||
*
|
||||
* @package kirki-framework/control-code
|
||||
* @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 Code extends Field {
|
||||
|
||||
/**
|
||||
* The field type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-code';
|
||||
|
||||
/**
|
||||
* The control class-name.
|
||||
*
|
||||
* @access protected
|
||||
* @since 0.1
|
||||
* @var string
|
||||
*/
|
||||
protected $control_class = '\Kirki\Control\Code';
|
||||
|
||||
/**
|
||||
* 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'] = function( $value ) {
|
||||
/**
|
||||
* Code fields should not be filtered by default.
|
||||
* Their values usually contain CSS/JS and it it the responsibility
|
||||
* of the theme/plugin that registers this field
|
||||
* to properly apply any necessary sanitization.
|
||||
*/
|
||||
return $value;
|
||||
};
|
||||
}
|
||||
}
|
||||
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'] = 'code_editor';
|
||||
|
||||
$args['input_attrs'] = [
|
||||
'aria-describedby' => 'kirki-code editor-keyboard-trap-help-1 editor-keyboard-trap-help-2 editor-keyboard-trap-help-3 editor-keyboard-trap-help-4',
|
||||
];
|
||||
if ( ! isset( $args['choices']['language'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$language = $args['choices']['language'];
|
||||
switch ( $language ) {
|
||||
case 'json':
|
||||
case 'xml':
|
||||
$language = 'application/' . $language;
|
||||
break;
|
||||
case 'http':
|
||||
$language = 'message/' . $language;
|
||||
break;
|
||||
case 'js':
|
||||
case 'javascript':
|
||||
$language = 'text/javascript';
|
||||
break;
|
||||
case 'txt':
|
||||
$language = 'text/plain';
|
||||
break;
|
||||
case 'css':
|
||||
case 'jsx':
|
||||
case 'html':
|
||||
$language = 'text/' . $language;
|
||||
break;
|
||||
default:
|
||||
$language = ( 'js' === $language ) ? 'javascript' : $language;
|
||||
$language = ( 'htm' === $language ) ? 'html' : $language;
|
||||
$language = ( 'yml' === $language ) ? 'yaml' : $language;
|
||||
$language = 'text/x-' . $language;
|
||||
break;
|
||||
}
|
||||
if ( ! isset( $args['editor_settings'] ) ) {
|
||||
$args['editor_settings'] = [];
|
||||
}
|
||||
if ( ! isset( $args['editor_settings']['codemirror'] ) ) {
|
||||
$args['editor_settings']['codemirror'] = [];
|
||||
}
|
||||
if ( ! isset( $args['editor_settings']['codemirror']['mode'] ) ) {
|
||||
$args['editor_settings']['codemirror']['mode'] = $language;
|
||||
}
|
||||
|
||||
if ( 'text/x-scss' === $args['editor_settings']['codemirror']['mode'] ) {
|
||||
$args['editor_settings']['codemirror'] = array_merge(
|
||||
$args['editor_settings']['codemirror'],
|
||||
[
|
||||
'lint' => false,
|
||||
'autoCloseBrackets' => true,
|
||||
'matchBrackets' => true,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"presets": [
|
||||
[
|
||||
"@babel/preset-react",
|
||||
{
|
||||
"runtime": "classic"
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
# Kirki Color Palette Control
|
||||
A `control-color-palette` package for Kirki Customizer Framework.
|
||||
|
||||
## Table of Contents
|
||||
- [Kirki Color Palette Control](#kirki-color-palette-control)
|
||||
- [Table of Contents](#table-of-contents)
|
||||
- [Installation](#installation)
|
||||
- [Usage](#usage)
|
||||
- [Using Kirki API](#using-kirki-api)
|
||||
- [Using WordPress Customizer API](#using-wordpress-customizer-api)
|
||||
- [License](#license)
|
||||
|
||||
## Installation
|
||||
First, install the package using composer:
|
||||
|
||||
```bash
|
||||
composer require kirki-framework/control-color-palette
|
||||
```
|
||||
|
||||
Then make sure you have included the autoloader:
|
||||
|
||||
```php
|
||||
require_once "your/path/to/vendor/autoload.php";
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
This control can be consumed using Kirki API or using WordPress Customizer API.
|
||||
|
||||
### Using Kirki API
|
||||
|
||||
```php
|
||||
new \Kirki\Field\Color_Palette(
|
||||
[
|
||||
'settings' => 'your_control_setting_id',
|
||||
'label' => esc_html__( 'Your Control Label', 'your-text-domain' ),
|
||||
'description' => esc_html__( 'Your control description.', 'your-text-domain' ),
|
||||
'section' => 'your_section_id',
|
||||
'default' => 5,
|
||||
'choices' => [
|
||||
'colors' => [ '#000000', '#222222', '#444444', '#666666', '#888888', '#aaaaaa', '#cccccc', '#eeeeee', '#ffffff' ],
|
||||
'shape' => 'round', // Optional, default is 'square'.
|
||||
'size' => 20, // Optional, default is 28.
|
||||
],
|
||||
]
|
||||
);
|
||||
```
|
||||
|
||||
### Using WordPress Customizer API
|
||||
|
||||
```php
|
||||
/**
|
||||
* Register customizer settings and controls.
|
||||
*
|
||||
* @param \WP_Customize_Manager $wp_customize The Customizer object.
|
||||
*/
|
||||
function your_customize_register_function( $wp_customize ) {
|
||||
|
||||
// Add setting.
|
||||
$wp_customize->add_setting(
|
||||
'your_control_setting_id',
|
||||
[
|
||||
'type' => 'theme_mod', // Or 'option'.
|
||||
'capability' => 'edit_theme_options',
|
||||
'default' => 5,
|
||||
'transport' => 'postMessage', // Or 'refresh'.
|
||||
'sanitize' => 'intval', // Or 'absint' or other int sanitization.
|
||||
]
|
||||
);
|
||||
|
||||
// Add control.
|
||||
$wp_customize->add_control(
|
||||
new \Kirki\Control\Color_Palette(
|
||||
$wp_customize,
|
||||
'your_control_setting_id',
|
||||
[
|
||||
'label' => esc_html__( 'Your Control Label', 'your-text-domain' ),
|
||||
'description' => esc_html__( 'Your control description.', 'your-text-domain' ),
|
||||
'section' => 'your_section_id',
|
||||
'choices' => [
|
||||
'colors' => [ '#000000', '#222222', '#444444', '#666666', '#888888', '#aaaaaa', '#cccccc', '#eeeeee', '#ffffff' ],
|
||||
'shape' => 'round', // Optional, default is 'square'.
|
||||
'size' => 20, // Optional, default is 28.
|
||||
],
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
// Add more settings...
|
||||
|
||||
// Add more controls...
|
||||
|
||||
}
|
||||
add_action( 'customize_register', 'your_customize_register_function' );
|
||||
```
|
||||
|
||||
## License
|
||||
[MIT License](https://oss.ninja/mit?organization=Kirki%20Framework)
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "kirki-framework/control-color-palette",
|
||||
"description": "Color palette control for the Kirki Customizer Framework",
|
||||
"type": "library",
|
||||
"license": "MIT",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Kirki\\Control\\": "src/Control",
|
||||
"Kirki\\Field\\": "src/Field"
|
||||
}
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kirki Framework",
|
||||
"email": "connect@mapsteps.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.0",
|
||||
"kirki-framework/control-base": "*"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
.customize-control-kirki-color-palette,.customize-control-kirki-color-palette *{box-sizing:border-box}.customize-control-kirki-color-palette .kirki-control-label{display:block;position:relative}.customize-control-kirki-color-palette .kirki-control-form{margin-bottom:6px;position:relative}.customize-control-kirki-color-palette .kirki-control-form:hover .kirki-control-reset{opacity:1}.customize-control-kirki-color-palette .kirki-control-reset{align-items:center;background-color:transparent;border-radius:50%;border-width:0;color:#50575e;cursor:pointer;display:flex;height:20px;justify-content:center;opacity:0;padding:0;position:absolute;right:0;top:0;transition:all .3s;width:20px;z-index:3}.customize-control-kirki-color-palette .kirki-control-reset:focus{opacity:1}.customize-control-kirki-color-palette .kirki-control-reset:hover i{color:red;transform:rotate(-45deg)}.customize-control-kirki-color-palette .kirki-control-reset i{font-size:12px;height:auto;transform:rotate(45deg);transition:transform .3s;width:auto}.customize-control-kirki-color-palette .kirki-colors{align-items:center;display:flex;flex-wrap:wrap;list-style:none;margin:0;padding:0;width:100%}.customize-control-kirki-color-palette .kirki-colors.kirki-round-colors .kirki-color div{border-radius:50%}.customize-control-kirki-color-palette .kirki-color{display:block;margin:0 11px 11px 0;padding:0;position:relative}.customize-control-kirki-color-palette .kirki-color:last-child{padding-right:0}.customize-control-kirki-color-palette .kirki-color>div{align-items:center;border:1px solid #dedede;border-radius:4px;cursor:pointer;display:flex;height:100%;justify-content:center;position:absolute;transform:scale(1);transition:transform .2s;width:100%}.customize-control-kirki-color-palette .kirki-color>div:hover{transform:scale(1.2)}.customize-control-kirki-color-palette .kirki-color.is-selected>div{border-color:#2271b1;border-width:4px}
|
||||
/*# sourceMappingURL=control.css.map */
|
||||
@@ -0,0 +1,2 @@
|
||||
(()=>{var t={};t=React;var e=e=>{const{control:o,customizerSetting:n,choices:i}=e,[a,c]=t.useState(e.value);o.updateComponentState=t=>{c(t)};const r=t=>{n.set(t.target.title)},s=i.size+2;return React.createElement("div",{className:"kirki-control-form",tabIndex:"1"},React.createElement("label",{className:"kirki-control-label"},React.createElement("span",{className:"customize-control-title"},e.label),React.createElement("span",{className:"customize-control-description description",dangerouslySetInnerHTML:{__html:e.description}})),React.createElement("div",{className:"customize-control-notifications-container",ref:e.setNotificationContainer}),React.createElement("button",{type:"button",className:"kirki-control-reset",onClick:()=>{""!==e.default&&void 0!==e.default?n.set(e.default):n.set(e.value)}},React.createElement("i",{className:"dashicons dashicons-image-rotate"})),React.createElement("ul",{className:"kirki-colors kirki-"+i.shape+"-colors"},i.colors.map(((t,e)=>{const o=t===a?"kirki-color is-selected":"kirki-color";return React.createElement("li",{key:e.toString(),className:o,style:{width:s+"px",height:s+"px"}},React.createElement("div",{title:t,style:{backgroundColor:t},onClick:r}))}))))};function o(){return o=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t},o.apply(this,arguments)}var n=wp.customize.Control.extend({initialize:function(t,e){const o=this;o.setNotificationContainer=o.setNotificationContainer.bind(o),wp.customize.Control.prototype.initialize.call(o,t,e),wp.customize.control.bind("removed",(function t(e){o===e&&(o.destroy(),o.container.remove(),wp.customize.control.unbind("removed",t))}))},setNotificationContainer:function(t){this.notifications.container=jQuery(t),this.notifications.render()},renderContent:function(){const t=this;ReactDOM.render(React.createElement(e,o({},t.params,{control:t,customizerSetting:t.setting,setNotificationContainer:t.setNotificationCotainer,value:t.params.value})),t.container[0]),!1!==t.params.choices.allowCollapse&&t.container.addClass("allowCollapse")},ready:function(){const t=this;t.setting.bind((e=>{t.updateComponentState(e)}))},updateComponentState:t=>{},destroy:function(){ReactDOM.unmountComponentAtNode(this.container[0]),wp.customize.Control.prototype.destroy&&wp.customize.Control.prototype.destroy.call(this)}});wp.customize.controlConstructor["kirki-color-palette"]=n})();
|
||||
//# sourceMappingURL=control.js.map
|
||||
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
/**
|
||||
* The slider control.
|
||||
*
|
||||
* Creates a slider control.
|
||||
*
|
||||
* @package kirki-framework/control-slider
|
||||
* @license MIT (https://oss.ninja/mit?organization=Kirki%20Framework)
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Control;
|
||||
|
||||
use Kirki\Control\Base;
|
||||
use Kirki\URL;
|
||||
|
||||
/**
|
||||
* Color Palette control.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class Color_Palette extends Base {
|
||||
|
||||
/**
|
||||
* The control type.
|
||||
*
|
||||
* @since 1.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-color-palette';
|
||||
|
||||
/**
|
||||
* The control version.
|
||||
*
|
||||
* @since 1.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public static $control_ver = '1.0';
|
||||
|
||||
/**
|
||||
* Enqueue control related styles/scripts.
|
||||
*
|
||||
* @since 1.0
|
||||
* @access public
|
||||
*/
|
||||
public function enqueue() {
|
||||
|
||||
parent::enqueue();
|
||||
|
||||
// Enqueue the style.
|
||||
wp_enqueue_style( 'kirki-color-palette-control', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], self::$control_ver );
|
||||
|
||||
// Enqueue the script.
|
||||
wp_enqueue_script( 'kirki-color-palette-control', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [ 'jquery', 'customize-controls', 'customize-base', 'react-dom' ], self::$control_ver, false );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the parameters passed to the JavaScript via JSON.
|
||||
*
|
||||
* @see WP_Customize_Control::to_json()
|
||||
*
|
||||
* @since 1.0
|
||||
* @access public
|
||||
*/
|
||||
public function to_json() {
|
||||
|
||||
parent::to_json();
|
||||
|
||||
if ( isset( $this->json['label'] ) ) {
|
||||
$this->json['label'] = html_entity_decode( $this->json['label'] );
|
||||
}
|
||||
|
||||
if ( isset( $this->json['description'] ) ) {
|
||||
$this->json['description'] = html_entity_decode( $this->json['description'] );
|
||||
}
|
||||
|
||||
$this->json['value'] = strtolower( $this->json['value'] );
|
||||
|
||||
$choices = $this->json['choices'];
|
||||
|
||||
$this->json['choices'] = wp_parse_args(
|
||||
$choices,
|
||||
[
|
||||
'shape' => 'square',
|
||||
'size' => 28,
|
||||
'colors' => [],
|
||||
]
|
||||
);
|
||||
|
||||
$this->json['choices']['colors'] = array_map( 'strtolower', $this->json['choices']['colors'] );
|
||||
|
||||
if ( isset( $choices['style'] ) && ! empty( $choices['style'] ) ) {
|
||||
if ( ! isset( $choices['shape'] ) || empty( $choices['shape'] ) ) {
|
||||
$this->json['choices']['shape'] = $choices['style'];
|
||||
}
|
||||
|
||||
unset( $this->json['choices']['style'] );
|
||||
}
|
||||
|
||||
if ( ! is_numeric( $this->json['choices']['size'] ) ) {
|
||||
$this->json['choices']['size'] = 28;
|
||||
}
|
||||
|
||||
$this->json['choices']['shape'] = 'circle' === $this->json['choices']['shape'] ? 'round' : $this->json['choices']['shape'];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 WP_Customize_Control::to_json().
|
||||
*
|
||||
* @see WP_Customize_Control::print_template()
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
protected function content_template() {}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
/**
|
||||
* Override field methods.
|
||||
*
|
||||
* @package kirki-framework/control-slider
|
||||
* @license MIT (https://oss.ninja/mit?organization=Kirki%20Framework)
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Field;
|
||||
|
||||
use Kirki\Field;
|
||||
|
||||
/**
|
||||
* Field overrides.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class Color_Palette extends Field {
|
||||
|
||||
/**
|
||||
* The field type.
|
||||
*
|
||||
* @since 1.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-color-palette';
|
||||
|
||||
/**
|
||||
* The control class-name.
|
||||
*
|
||||
* @since 1.0
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $control_class = '\Kirki\Control\Color_Palette';
|
||||
|
||||
/**
|
||||
* Whether we should register the control class for JS-templating or not.
|
||||
*
|
||||
* @since 1.0
|
||||
* @access protected
|
||||
* @var bool
|
||||
*/
|
||||
protected $control_has_js_template = true;
|
||||
|
||||
/**
|
||||
* Filter arguments before creating the setting.
|
||||
*
|
||||
* @param array $args The field arguments.
|
||||
* @param \WP_Customize_Manager $wp_customize The customizer instance.
|
||||
*
|
||||
* @return array $args The maybe-filtered arguments.
|
||||
*/
|
||||
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'] = [ __CLASS__, 'sanitize' ];
|
||||
}
|
||||
}
|
||||
|
||||
return $args;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter arguments before creating the control.
|
||||
*
|
||||
* @param array $args The field arguments.
|
||||
* @param \WP_Customize_Manager $wp_customize The customizer instance.
|
||||
*
|
||||
* @return array $args The maybe-filtered arguments.
|
||||
*/
|
||||
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-color-palette';
|
||||
}
|
||||
|
||||
return $args;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize colors.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 1.0.2
|
||||
* @param string $value The color.
|
||||
* @return string
|
||||
*/
|
||||
public static function sanitize( $value ) {
|
||||
|
||||
/**
|
||||
* This pattern will check and match 3/6/8-character hex, rgb, rgba, hsl, hsla, hsv, and hsva colors.
|
||||
*
|
||||
* RGB regex:
|
||||
* @link https://stackoverflow.com/questions/9585973/javascript-regular-expression-for-rgb-values#answer-9586045
|
||||
*
|
||||
* For testing it, you can use these links:
|
||||
*
|
||||
* @link https://regex101.com/
|
||||
* @link https://regexr.com/
|
||||
* @link https://www.regextester.com/
|
||||
*
|
||||
* How to test it?
|
||||
*
|
||||
* Paste the following code to the test field (of course without the asterisks and spaces in front of them):
|
||||
* rgba(255, 255, 0, 0.9)
|
||||
* rgb(255, 255, 0)
|
||||
* #ff0
|
||||
* #ffff00
|
||||
* hsl(150, 25%, 25%)
|
||||
* hsla(250, 25%, 25%, 0.7)
|
||||
* hsv(125, 15%, 30%)
|
||||
* hsva(125, 15%, 30%, 0.5)
|
||||
*
|
||||
* And then paste the regex `$pattern` below (without the single quote's start and end) to the regular expression box.
|
||||
* Set the flag to use "global" and "multiline".
|
||||
*/
|
||||
$pattern = '/^(\#[\da-f]{3}|\#[\da-f]{6}|\#[\da-f]{8}|rgba\(((\d{1,2}|1\d\d|2([0-4]\d|5[0-5]))\s*,\s*){2}((\d{1,2}|1\d\d|2([0-4]\d|5[0-5]))\s*)(,\s*(0\.\d+|1))\)|rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)|hsla\(\s*((\d{1,2}|[1-2]\d{2}|3([0-5]\d|60)))\s*,\s*((\d{1,2}|100)\s*%)\s*,\s*((\d{1,2}|100)\s*%)(,\s*(0\.\d+|1))\)|hsl\(\s*((\d{1,2}|[1-2]\d{2}|3([0-5]\d|60)))\s*,\s*((\d{1,2}|100)\s*%)\s*,\s*((\d{1,2}|100)\s*%)\)|hsva\(\s*((\d{1,2}|[1-2]\d{2}|3([0-5]\d|60)))\s*,\s*((\d{1,2}|100)\s*%)\s*,\s*((\d{1,2}|100)\s*%)(,\s*(0\.\d+|1))\)|hsv\(\s*((\d{1,2}|[1-2]\d{2}|3([0-5]\d|60)))\s*,\s*((\d{1,2}|100)\s*%)\s*,\s*((\d{1,2}|100)\s*%)\))$/';
|
||||
|
||||
\preg_match( $pattern, $value, $matches );
|
||||
|
||||
// Return the 1st match found.
|
||||
if ( isset( $matches[0] ) ) {
|
||||
if ( is_string( $matches[0] ) ) {
|
||||
return $matches[0];
|
||||
}
|
||||
|
||||
if ( is_array( $matches[0] ) && isset( $matches[0][0] ) ) {
|
||||
return $matches[0][0];
|
||||
}
|
||||
}
|
||||
|
||||
// If no match was found, return an empty string.
|
||||
return '';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
import KirkiColorPaletteForm from './KirkiColorPaletteForm';
|
||||
|
||||
/**
|
||||
* KirkiColorPaletteControl.
|
||||
*
|
||||
* Global objects brought:
|
||||
* - wp
|
||||
* - jQuery
|
||||
* - React
|
||||
* - ReactDOM
|
||||
*
|
||||
* @class
|
||||
* @augments wp.customize.Control
|
||||
* @augments wp.customize.Class
|
||||
*/
|
||||
const KirkiColorPaletteControl = wp.customize.Control.extend({
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*
|
||||
* @param {string} id - Control ID.
|
||||
* @param {object} params - Control params.
|
||||
*/
|
||||
initialize: function (id, params) {
|
||||
const control = this;
|
||||
|
||||
// Bind functions to this control context for passing as React props.
|
||||
control.setNotificationContainer = control.setNotificationContainer.bind(control);
|
||||
|
||||
wp.customize.Control.prototype.initialize.call(control, id, params);
|
||||
|
||||
// The following should be eliminated with <https://core.trac.wordpress.org/ticket/31334>.
|
||||
function onRemoved(removedControl) {
|
||||
if (control === removedControl) {
|
||||
control.destroy();
|
||||
control.container.remove();
|
||||
wp.customize.control.unbind('removed', onRemoved);
|
||||
}
|
||||
}
|
||||
wp.customize.control.bind('removed', onRemoved);
|
||||
},
|
||||
|
||||
/**
|
||||
* Set notification container and render.
|
||||
*
|
||||
* This is called when the React component is mounted.
|
||||
*
|
||||
* @param {Element} element - Notification container.
|
||||
* @returns {void}
|
||||
*/
|
||||
setNotificationContainer: function setNotificationContainer(element) {
|
||||
const control = this;
|
||||
|
||||
control.notifications.container = jQuery(element);
|
||||
control.notifications.render();
|
||||
},
|
||||
|
||||
/**
|
||||
* Render the control into the DOM.
|
||||
*
|
||||
* This is called from the Control#embed() method in the parent class.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
renderContent: function renderContent() {
|
||||
const control = this;
|
||||
|
||||
ReactDOM.render(
|
||||
<KirkiColorPaletteForm
|
||||
{...control.params}
|
||||
control={control}
|
||||
customizerSetting={control.setting}
|
||||
setNotificationContainer={control.setNotificationCotainer}
|
||||
value={control.params.value}
|
||||
/>,
|
||||
control.container[0]
|
||||
);
|
||||
|
||||
if (false !== control.params.choices.allowCollapse) {
|
||||
control.container.addClass('allowCollapse');
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* After control has been first rendered, start re-rendering when setting changes.
|
||||
*
|
||||
* React is able to be used here instead of the wp.customize.Element abstraction.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
ready: function ready() {
|
||||
const control = this;
|
||||
|
||||
/**
|
||||
* Update component value's state when customizer setting's value is changed.
|
||||
*/
|
||||
control.setting.bind((val) => {
|
||||
control.updateComponentState(val);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* This method will be overriden by the rendered component.
|
||||
*/
|
||||
updateComponentState: (val) => { },
|
||||
|
||||
/**
|
||||
* Handle removal/de-registration of the control.
|
||||
*
|
||||
* This is essentially the inverse of the Control#embed() method.
|
||||
*
|
||||
* @link https://core.trac.wordpress.org/ticket/31334
|
||||
* @returns {void}
|
||||
*/
|
||||
destroy: function destroy() {
|
||||
const control = this;
|
||||
|
||||
// Garbage collection: undo mounting that was done in the embed/renderContent method.
|
||||
ReactDOM.unmountComponentAtNode(control.container[0]);
|
||||
|
||||
// Call destroy method in parent if it exists (as of #31334).
|
||||
if (wp.customize.Control.prototype.destroy) {
|
||||
wp.customize.Control.prototype.destroy.call(control);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export default KirkiColorPaletteControl;
|
||||
@@ -0,0 +1,78 @@
|
||||
import { useState } from "react";
|
||||
|
||||
const KirkiColorPaletteForm = (props) => {
|
||||
const { control, customizerSetting, choices } = props;
|
||||
|
||||
const [selectedItem, setSelectedItem] = useState(props.value);
|
||||
|
||||
control.updateComponentState = (val) => {
|
||||
setSelectedItem(val);
|
||||
};
|
||||
|
||||
const handleSelect = (e) => {
|
||||
customizerSetting.set(e.target.title);
|
||||
};
|
||||
|
||||
const handleReset = () => {
|
||||
if ("" !== props.default && "undefined" !== typeof props.default) {
|
||||
customizerSetting.set(props.default);
|
||||
} else {
|
||||
customizerSetting.set(props.value);
|
||||
}
|
||||
};
|
||||
|
||||
const size = choices.size + 2; // 2 here is 1px border on each side.
|
||||
|
||||
return (
|
||||
<div className="kirki-control-form" tabIndex="1">
|
||||
<label className="kirki-control-label">
|
||||
<span className="customize-control-title">{props.label}</span>
|
||||
<span
|
||||
className="customize-control-description description"
|
||||
dangerouslySetInnerHTML={{ __html: props.description }}
|
||||
/>
|
||||
</label>
|
||||
|
||||
<div
|
||||
className="customize-control-notifications-container"
|
||||
ref={props.setNotificationContainer}
|
||||
></div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
className="kirki-control-reset"
|
||||
onClick={handleReset}
|
||||
>
|
||||
<i className="dashicons dashicons-image-rotate"></i>
|
||||
</button>
|
||||
|
||||
<ul className={"kirki-colors kirki-" + choices.shape + "-colors"}>
|
||||
{choices.colors.map((color, index) => {
|
||||
const itemClassName =
|
||||
color === selectedItem ? "kirki-color is-selected" : "kirki-color";
|
||||
|
||||
return (
|
||||
<li
|
||||
key={index.toString()}
|
||||
className={itemClassName}
|
||||
style={{
|
||||
width: size + "px",
|
||||
height: size + "px",
|
||||
}}
|
||||
>
|
||||
<div
|
||||
title={color}
|
||||
style={{
|
||||
backgroundColor: color,
|
||||
}}
|
||||
onClick={handleSelect}
|
||||
></div>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default KirkiColorPaletteForm;
|
||||
@@ -0,0 +1,6 @@
|
||||
import "./control.scss";
|
||||
import KirkiColorPaletteControl from './KirkiColorPaletteControl';
|
||||
|
||||
|
||||
// Register control type with Customizer.
|
||||
wp.customize.controlConstructor['kirki-color-palette'] = KirkiColorPaletteControl;
|
||||
@@ -0,0 +1,41 @@
|
||||
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
||||
|
||||
module.exports = {
|
||||
externals: {
|
||||
"jquery": "jQuery",
|
||||
"react": "React",
|
||||
"react-dom": "ReactDOM"
|
||||
},
|
||||
plugins: [
|
||||
new MiniCssExtractPlugin({
|
||||
filename: "./control.css"
|
||||
})
|
||||
],
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.(js|jsx)$/,
|
||||
exclude: /node_modules/,
|
||||
use: {
|
||||
loader: "babel-loader"
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /\.s[ac]ss$/i,
|
||||
use: [
|
||||
// Extracts CSS into separate files
|
||||
MiniCssExtractPlugin.loader,
|
||||
// Translates CSS into CommonJS
|
||||
"css-loader",
|
||||
// Compiles Sass to CSS
|
||||
"sass-loader",
|
||||
],
|
||||
}
|
||||
]
|
||||
},
|
||||
entry: "./src/control.js",
|
||||
output: {
|
||||
filename: "control.js",
|
||||
},
|
||||
devtool: "source-map"
|
||||
};
|
||||
@@ -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.
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* Object used by the Kirki framework to instantiate the control.
|
||||
*
|
||||
* This is a man-in-the-middle class, nothing but a proxy to set sanitization
|
||||
* callbacks and any usother properties we may need.
|
||||
*
|
||||
* @package kirki-framework/control-color
|
||||
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Field;
|
||||
|
||||
use Kirki\Field;
|
||||
|
||||
/**
|
||||
* Field overrides.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class Color extends ReactColorful {}
|
||||
@@ -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.
|
||||
@@ -0,0 +1 @@
|
||||
# control-cropped-image
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "kirki-framework/control-cropped-image",
|
||||
"type": "library",
|
||||
"description": "Cropped-Image control for the Kirki Customizer framework.",
|
||||
"keywords": [
|
||||
"wordpress",
|
||||
"customizer",
|
||||
"framework"
|
||||
],
|
||||
"homepage": "https://kirki.org",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kirki Framework",
|
||||
"email": "connect@mapsteps.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Kirki\\Control\\": "src/"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Customizer Control: cropped-image.
|
||||
*
|
||||
* @package kirki-framework/control-cropped-image
|
||||
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Control;
|
||||
|
||||
/**
|
||||
* Adds the image control.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class Cropped_Image extends \WP_Customize_Cropped_Image_Control {
|
||||
|
||||
/**
|
||||
* The field type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-cropped-image';
|
||||
}
|
||||
@@ -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.
|
||||
@@ -0,0 +1,55 @@
|
||||
# control-custom
|
||||
|
||||
## Installation
|
||||
|
||||
First, install the package using composer:
|
||||
|
||||
```bash
|
||||
composer require kirki-framework/control-custom
|
||||
```
|
||||
|
||||
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\Custom' );
|
||||
} );
|
||||
|
||||
/**
|
||||
* 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' => '<div style="padding:12px;background-color:#000;color>' . esc_html__( 'content', 'theme_textdomain' ) . '</div>',
|
||||
'transport' => 'refresh',
|
||||
'sanitize_callback' => '__return_null',
|
||||
] );
|
||||
|
||||
// Add control.
|
||||
$wp_customize->add_control( new \Kirki\Control\Custom( $wp_customize, 'my_control', [
|
||||
'label' => esc_html__( 'My Custom Control', 'theme_textdomain' ),
|
||||
'section' => 'colors',
|
||||
] ) );
|
||||
} );
|
||||
```
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "kirki-framework/control-custom",
|
||||
"type": "library",
|
||||
"description": "Custom control for the Kirki Customizer framework.",
|
||||
"keywords": ["wordpress","customizer","framework"],
|
||||
"homepage": "https://kirki.org",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kirki Framework",
|
||||
"email": "connect@mapsteps.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.0",
|
||||
"kirki-framework/control-base": "*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Kirki\\Control\\": "src/Control",
|
||||
"Kirki\\Field\\": "src/Field"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* Customizer Control: custom.
|
||||
*
|
||||
* Creates a new custom control.
|
||||
* Custom controls accept raw HTML/JS.
|
||||
*
|
||||
* @package kirki-framework/control-custom
|
||||
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Control;
|
||||
|
||||
use Kirki\Control\Base;
|
||||
|
||||
/**
|
||||
* The "custom" control allows you to add any raw HTML.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class Custom extends Base {
|
||||
|
||||
/**
|
||||
* The control type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-custom';
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
?>
|
||||
<label>
|
||||
<# if ( data.label ) { #><span class="customize-control-title">{{{ data.label }}}</span><# } #>
|
||||
<# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><# } #>
|
||||
<?php
|
||||
/**
|
||||
* The value is defined by the developer in the field configuration as 'default'.
|
||||
* There is no user input on this field, it's a raw HTML/JS field and we do not sanitize it.
|
||||
* Do not be alarmed, this is not a security issue.
|
||||
* In order for someone to be able to change this they would have to have access to your filesystem.
|
||||
* If that happens, they can change whatever they want anyways. This field is not a concern.
|
||||
*/
|
||||
?>
|
||||
{{{ data.value }}}
|
||||
</label>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* Override field methods when used with the Kirki API.
|
||||
*
|
||||
* @package kirki-framework/control-custom
|
||||
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Field;
|
||||
|
||||
use Kirki\Field;
|
||||
|
||||
/**
|
||||
* Field overrides.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class Custom extends Field {
|
||||
|
||||
/**
|
||||
* The field type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-custom';
|
||||
|
||||
/**
|
||||
* The control class-name.
|
||||
*
|
||||
* @access protected
|
||||
* @since 0.1
|
||||
* @var string
|
||||
*/
|
||||
protected $control_class = '\Kirki\Control\Custom';
|
||||
|
||||
/**
|
||||
* Whether we should register the control class for JS-templating or not.
|
||||
*
|
||||
* @access protected
|
||||
* @since 0.1
|
||||
* @var bool
|
||||
*/
|
||||
protected $control_has_js_template = true;
|
||||
|
||||
/**
|
||||
* Filter arguments before creating the setting.
|
||||
*
|
||||
* @access public
|
||||
* @since 0.1
|
||||
* @param array $args The field arguments.
|
||||
* @param WP_Customize_Manager $wp_customize The customizer instance.
|
||||
* @return array
|
||||
*/
|
||||
public function filter_setting_args( $args, $wp_customize ) {
|
||||
if ( $args['settings'] === $this->args['settings'] ) {
|
||||
$args = parent::filter_setting_args( $args, $wp_customize );
|
||||
if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) {
|
||||
$args['sanitize_callback'] = '__return_null';
|
||||
}
|
||||
}
|
||||
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-custom';
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||