mirror of
https://ghproxy.net/https://github.com/AlxMedia/curver.git
synced 2025-08-28 11:50:25 +08:00
Update to Kirki 4.0.22
This commit is contained in:
parent
4ff905c2c6
commit
a02e711106
493 changed files with 29670 additions and 39886 deletions
7
functions/kirki/packages/autoload.php
Normal file
7
functions/kirki/packages/autoload.php
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
// autoload.php @generated by Composer
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitc56aa391ac498061f8d648878e0e6144::getLoader();
|
572
functions/kirki/packages/composer/ClassLoader.php
Normal file
572
functions/kirki/packages/composer/ClassLoader.php
Normal file
|
@ -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;
|
||||
}
|
350
functions/kirki/packages/composer/InstalledVersions.php
Normal file
350
functions/kirki/packages/composer/InstalledVersions.php
Normal file
|
@ -0,0 +1,350 @@
|
|||
<?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`
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
21
functions/kirki/packages/composer/LICENSE
Normal file
21
functions/kirki/packages/composer/LICENSE
Normal file
|
@ -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.
|
||||
|
10
functions/kirki/packages/composer/autoload_classmap.php
Normal file
10
functions/kirki/packages/composer/autoload_classmap.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
// autoload_classmap.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
||||
);
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
// autoload_namespaces.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
);
|
19
functions/kirki/packages/composer/autoload_psr4.php
Normal file
19
functions/kirki/packages/composer/autoload_psr4.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
// autoload_psr4.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$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'),
|
||||
'Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\' => array($vendorDir . '/dealerdirect/phpcodesniffer-composer-installer/src'),
|
||||
'Composer\\Installers\\' => array($vendorDir . '/composer/installers/src/Composer/Installers'),
|
||||
);
|
61
functions/kirki/packages/composer/autoload_real.php
Normal file
61
functions/kirki/packages/composer/autoload_real.php
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?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(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitc56aa391ac498061f8d648878e0e6144', 'loadClassLoader'));
|
||||
|
||||
$includePaths = require __DIR__ . '/include_paths.php';
|
||||
$includePaths[] = get_include_path();
|
||||
set_include_path(implode(PATH_SEPARATOR, $includePaths));
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitc56aa391ac498061f8d648878e0e6144::getInitializer($loader));
|
||||
} else {
|
||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->set($namespace, $path);
|
||||
}
|
||||
|
||||
$map = require __DIR__ . '/autoload_psr4.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->setPsr4($namespace, $path);
|
||||
}
|
||||
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
$loader->addClassMap($classMap);
|
||||
}
|
||||
}
|
||||
|
||||
$loader->register(true);
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
150
functions/kirki/packages/composer/autoload_static.php
Normal file
150
functions/kirki/packages/composer/autoload_static.php
Normal file
|
@ -0,0 +1,150 @@
|
|||
<?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,
|
||||
),
|
||||
'D' =>
|
||||
array (
|
||||
'Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\' => 55,
|
||||
),
|
||||
'C' =>
|
||||
array (
|
||||
'Composer\\Installers\\' => 20,
|
||||
),
|
||||
);
|
||||
|
||||
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',
|
||||
),
|
||||
'Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/dealerdirect/phpcodesniffer-composer-installer/src',
|
||||
),
|
||||
'Composer\\Installers\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers',
|
||||
),
|
||||
);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
11
functions/kirki/packages/composer/include_paths.php
Normal file
11
functions/kirki/packages/composer/include_paths.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
// include_paths.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
$baseDir . '/',
|
||||
$baseDir . '/core',
|
||||
);
|
511
functions/kirki/packages/composer/installed.php
Normal file
511
functions/kirki/packages/composer/installed.php
Normal file
|
@ -0,0 +1,511 @@
|
|||
<?php return array(
|
||||
'root' => array(
|
||||
'pretty_version' => 'dev-master',
|
||||
'version' => 'dev-master',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'reference' => 'f44123472688894cb60ad0552857a3aadc4a6ee4',
|
||||
'name' => 'kirki-framework/kirki',
|
||||
'dev' => true,
|
||||
),
|
||||
'versions' => array(
|
||||
'composer/installers' => array(
|
||||
'pretty_version' => 'v2.0.1',
|
||||
'version' => '2.0.1.0',
|
||||
'type' => 'composer-plugin',
|
||||
'install_path' => __DIR__ . '/./installers',
|
||||
'aliases' => array(),
|
||||
'reference' => 'a241e78aaeb09781f5f5b92ac01ffd13ab43e5e8',
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'dealerdirect/phpcodesniffer-composer-installer' => array(
|
||||
'pretty_version' => 'v0.7.2',
|
||||
'version' => '0.7.2.0',
|
||||
'type' => 'composer-plugin',
|
||||
'install_path' => __DIR__ . '/../dealerdirect/phpcodesniffer-composer-installer',
|
||||
'aliases' => array(),
|
||||
'reference' => '1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db',
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'kirki-framework/compatibility' => array(
|
||||
'pretty_version' => 'v1.0.9',
|
||||
'version' => '1.0.9.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/compatibility',
|
||||
'aliases' => array(),
|
||||
'reference' => '1169e68f1232dfc7d659c981d440d81e8253a810',
|
||||
'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.1',
|
||||
'version' => '1.0.1.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/control-code',
|
||||
'aliases' => array(),
|
||||
'reference' => '29909ae3f62210b9b5937c798086ce8495e77d72',
|
||||
'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.14',
|
||||
'version' => '1.0.14.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/control-react-colorful',
|
||||
'aliases' => array(),
|
||||
'reference' => 'bcfe71b736f4b43c00b0292e9260c78815808364',
|
||||
'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' => 'v1.0.3',
|
||||
'version' => '1.0.3.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/control-repeater',
|
||||
'aliases' => array(),
|
||||
'reference' => 'b24e7ae8641867616cc12038eda0a6e990399bbd',
|
||||
'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' => 'dev-master',
|
||||
'version' => 'dev-master',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'reference' => 'f44123472688894cb60ad0552857a3aadc4a6ee4',
|
||||
'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.10',
|
||||
'version' => '1.0.10.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/module-css',
|
||||
'aliases' => array(),
|
||||
'reference' => '93b97d0e6b09fe4953c69a8ba9bc06884af91b27',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kirki-framework/module-editor-styles' => array(
|
||||
'pretty_version' => 'v1.0.1',
|
||||
'version' => '1.0.1.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/module-editor-styles',
|
||||
'aliases' => array(),
|
||||
'reference' => 'd30622f500cfcc4e0145790d4aeca541d6c73319',
|
||||
'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' => 'v1.0.6',
|
||||
'version' => '1.0.6.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/module-postmessage',
|
||||
'aliases' => array(),
|
||||
'reference' => 'd543c8d34e7d6fc8c2ce4805d8fc940070a54691',
|
||||
'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.4',
|
||||
'version' => '1.0.4.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../kirki-framework/module-webfonts',
|
||||
'aliases' => array(),
|
||||
'reference' => 'ec12372bb67230ab5558a6b3d8b7f98300d2e2a6',
|
||||
'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,
|
||||
),
|
||||
'phpcompatibility/php-compatibility' => array(
|
||||
'pretty_version' => '9.3.5',
|
||||
'version' => '9.3.5.0',
|
||||
'type' => 'phpcodesniffer-standard',
|
||||
'install_path' => __DIR__ . '/../phpcompatibility/php-compatibility',
|
||||
'aliases' => array(),
|
||||
'reference' => '9fb324479acf6f39452e0655d2429cc0d3914243',
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'phpcompatibility/phpcompatibility-paragonie' => array(
|
||||
'pretty_version' => '1.3.1',
|
||||
'version' => '1.3.1.0',
|
||||
'type' => 'phpcodesniffer-standard',
|
||||
'install_path' => __DIR__ . '/../phpcompatibility/phpcompatibility-paragonie',
|
||||
'aliases' => array(),
|
||||
'reference' => 'ddabec839cc003651f2ce695c938686d1086cf43',
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'phpcompatibility/phpcompatibility-wp' => array(
|
||||
'pretty_version' => '2.1.3',
|
||||
'version' => '2.1.3.0',
|
||||
'type' => 'phpcodesniffer-standard',
|
||||
'install_path' => __DIR__ . '/../phpcompatibility/phpcompatibility-wp',
|
||||
'aliases' => array(),
|
||||
'reference' => 'd55de55f88697b9cdb94bccf04f14eb3b11cf308',
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'squizlabs/php_codesniffer' => array(
|
||||
'pretty_version' => '3.6.2',
|
||||
'version' => '3.6.2.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../squizlabs/php_codesniffer',
|
||||
'aliases' => array(),
|
||||
'reference' => '5e4e71592f69da17871dba6e80dd51bce74a351a',
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'wp-coding-standards/wpcs' => array(
|
||||
'pretty_version' => '2.3.0',
|
||||
'version' => '2.3.0.0',
|
||||
'type' => 'phpcodesniffer-standard',
|
||||
'install_path' => __DIR__ . '/../wp-coding-standards/wpcs',
|
||||
'aliases' => array(),
|
||||
'reference' => '7da1894633f168fe244afc6de00d141f27517b62',
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'wptrt/wpthemereview' => array(
|
||||
'pretty_version' => 'dev-develop',
|
||||
'version' => 'dev-develop',
|
||||
'type' => 'phpcodesniffer-standard',
|
||||
'install_path' => __DIR__ . '/../wptrt/wpthemereview',
|
||||
'aliases' => array(
|
||||
0 => '9999999-dev',
|
||||
),
|
||||
'reference' => '15684d0852fe90d807c2ae7746dea1302b74b4bd',
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
),
|
||||
);
|
26
functions/kirki/packages/composer/platform_check.php
Normal file
26
functions/kirki/packages/composer/platform_check.php
Normal file
|
@ -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,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 ( '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,56 @@
|
|||
<?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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
/******/ });
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -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.
|
2
functions/kirki/packages/kirki-framework/control-base/dist/control.css
vendored
Normal file
2
functions/kirki/packages/kirki-framework/control-base/dist/control.css
vendored
Normal file
|
@ -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 */
|
2
functions/kirki/packages/kirki-framework/control-base/dist/control.js
vendored
Normal file
2
functions/kirki/packages/kirki-framework/control-base/dist/control.js
vendored
Normal file
|
@ -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));
|
2
functions/kirki/packages/kirki-framework/control-checkbox/dist/control.css
vendored
Normal file
2
functions/kirki/packages/kirki-framework/control-checkbox/dist/control.css
vendored
Normal file
|
@ -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 */
|
2
functions/kirki/packages/kirki-framework/control-checkbox/dist/control.js
vendored
Normal file
2
functions/kirki/packages/kirki-framework/control-checkbox/dist/control.js
vendored
Normal file
|
@ -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,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,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 = '\WP_Customize_Code_Editor_Control';
|
||||
|
||||
/**
|
||||
* 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)
|
2
functions/kirki/packages/kirki-framework/control-color-palette/dist/control.css
vendored
Normal file
2
functions/kirki/packages/kirki-framework/control-color-palette/dist/control.css
vendored
Normal file
|
@ -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 */
|
2
functions/kirki/packages/kirki-framework/control-color-palette/dist/control.js
vendored
Normal file
2
functions/kirki/packages/kirki-framework/control-color-palette/dist/control.js
vendored
Normal file
|
@ -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,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,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.
|
|
@ -0,0 +1,55 @@
|
|||
# control-dashicons
|
||||
|
||||
## Installation
|
||||
|
||||
First, install the package using composer:
|
||||
|
||||
```bash
|
||||
composer require kirki-framework/control-dashicons
|
||||
```
|
||||
|
||||
Make sure you include the autoloader:
|
||||
```php
|
||||
require_once get_parent_theme_file_path( 'vendor/autoload.php' );
|
||||
```
|
||||
|
||||
To add a control using the customizer API:
|
||||
|
||||
```php
|
||||
|
||||
/**
|
||||
* Registers the control and whitelists it for JS templating.
|
||||
*
|
||||
* @since 1.0
|
||||
* @param WP_Customize_Manager $wp_customize The WP_Customize_Manager object.
|
||||
* @return void
|
||||
*/
|
||||
add_action( 'customize_register', function( $wp_customize ) {
|
||||
$wp_customize->register_control_type( '\Kirki\Control\Dashicons' );
|
||||
} );
|
||||
|
||||
/**
|
||||
* Add Customizer settings & controls.
|
||||
*
|
||||
* @since 1.0
|
||||
* @param WP_Customize_Manager $wp_customize The WP_Customize_Manager object.
|
||||
* @return void
|
||||
*/
|
||||
add_action( 'customize_register', function( $wp_customize ) {
|
||||
|
||||
// Add setting.
|
||||
$wp_customize->add_setting( 'my_control', [
|
||||
'type' => 'theme_mod',
|
||||
'capability' => 'edit_theme_options',
|
||||
'default' => 'menu',
|
||||
'transport' => 'refresh', // Or postMessage.
|
||||
'sanitize_callback' => 'sanitize_text_field', // Or a custom sanitization callback.
|
||||
] );
|
||||
|
||||
// Add control.
|
||||
$wp_customize->add_control( new \Kirki\Control\Dashicons( $wp_customize, 'my_control', [
|
||||
'label' => esc_html__( 'My Dashicons Control', 'theme_textdomain' ),
|
||||
'section' => 'my_section',
|
||||
] ) );
|
||||
} );
|
||||
```
|
2
functions/kirki/packages/kirki-framework/control-dashicons/dist/control.css
vendored
Normal file
2
functions/kirki/packages/kirki-framework/control-dashicons/dist/control.css
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
.customize-control-kirki-dashicons{position:relative}.customize-control-kirki-dashicons label{display:inline-block;position:relative}.customize-control-kirki-dashicons .icons-wrapper{max-height:300px;overflow-y:scroll}.customize-control-kirki-dashicons .icons-wrapper h4{font-weight:300;margin:.7em 0}.customize-control-kirki-dashicons .icons-wrapper .dashicons{border:1px solid transparent;font-size:25px;height:25px;padding:3px;width:25px}.customize-control-kirki-dashicons .icons-wrapper input{display:none}.customize-control-kirki-dashicons .icons-wrapper input:checked+label .dashicons{border:1px solid #3498db;color:#000}
|
||||
/*# sourceMappingURL=control.css.map */
|
2
functions/kirki/packages/kirki-framework/control-dashicons/dist/control.js
vendored
Normal file
2
functions/kirki/packages/kirki-framework/control-dashicons/dist/control.js
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
wp.customize.controlConstructor["kirki-dashicons"]=wp.customize.kirkiDynamicControl.extend({});
|
||||
//# sourceMappingURL=control.js.map
|
|
@ -0,0 +1,140 @@
|
|||
<?php
|
||||
/**
|
||||
* Customizer Control: dashicons.
|
||||
*
|
||||
* @package kirki-framework/control-dashicons
|
||||
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Control;
|
||||
|
||||
use Kirki\URL;
|
||||
use Kirki\Control\Base;
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dashicons control (modified radio).
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class Dashicons extends Base {
|
||||
|
||||
/**
|
||||
* The control type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-dashicons';
|
||||
|
||||
/**
|
||||
* The version. Used in scripts & styles for cache-busting.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 1.0.2
|
||||
* @var string
|
||||
*/
|
||||
public static $control_ver = '1.0';
|
||||
|
||||
/**
|
||||
* Enqueue control related scripts/styles.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue() {
|
||||
parent::enqueue();
|
||||
|
||||
// Enqueue the script.
|
||||
wp_enqueue_script( 'kirki-control-dashicons', URL::get_from_path( dirname(dirname( __DIR__ )) . '/dist/control.js' ), [ 'jquery', 'customize-base', 'kirki-control-base' ], self::$control_ver, false );
|
||||
|
||||
// Enqueue the style.
|
||||
wp_enqueue_style( 'kirki-control-dashicons-style', URL::get_from_path( dirname(dirname( __DIR__ )) . '/dist/control.css' ), [ 'dashicons' ], self::$control_ver );
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the parameters passed to the JavaScript via JSON.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @return void
|
||||
*/
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
$this->json['icons'] = \Kirki\Util\Dashicons::get_icons();
|
||||
}
|
||||
|
||||
/**
|
||||
* An Underscore (JS) template for this control's content (but not its container).
|
||||
*
|
||||
* Class variables for this control class are available in the `data` JS object;
|
||||
* export custom variables by overriding {@see WP_Customize_Control::to_json()}.
|
||||
*
|
||||
* @see WP_Customize_Control::print_template()
|
||||
*
|
||||
* @access protected
|
||||
* @since 1.0
|
||||
* @return void
|
||||
*/
|
||||
protected function content_template() {
|
||||
?>
|
||||
<# if ( data.label ) { #><span class="customize-control-title">{{{ data.label }}}</span><# } #>
|
||||
<# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><# } #>
|
||||
<div class="icons-wrapper">
|
||||
<# if ( ! _.isUndefined( data.choices ) && 1 < _.size( data.choices ) ) { #>
|
||||
<# for ( key in data.choices ) { #>
|
||||
<input {{{ data.inputAttrs }}} class="dashicons-select" type="radio" value="{{ key }}" name="_customize-dashicons-radio-{{ data.id }}" id="{{ data.id }}{{ key }}" {{{ data.link }}}<# if ( data.value === key ) { #> checked="checked"<# } #>>
|
||||
<label for="{{ data.id }}{{ key }}"><span class="dashicons dashicons-{{ data.choices[ key ] }}"></span></label>
|
||||
</input>
|
||||
<# } #>
|
||||
<# } else { #>
|
||||
<#
|
||||
var dashiconSections = {
|
||||
'admin-menu': '<?php esc_html_e( 'Admin Menu', 'kirki' ); ?>',
|
||||
'welcome-screen': '<?php esc_html_e( 'Welcome Screen', 'kirki' ); ?>',
|
||||
'post-formats': '<?php esc_html_e( 'Post Formats', 'kirki' ); ?>',
|
||||
'media': '<?php esc_html_e( 'Media', 'kirki' ); ?>',
|
||||
'image-editing': '<?php esc_html_e( 'Image Editing', 'kirki' ); ?>',
|
||||
'tinymce': 'TinyMCE',
|
||||
'posts': '<?php esc_html_e( 'Posts', 'kirki' ); ?>',
|
||||
'sorting': '<?php esc_html_e( 'Sorting', 'kirki' ); ?>',
|
||||
'social': '<?php esc_html_e( 'Social', 'kirki' ); ?>',
|
||||
'wordpress_org': 'WordPress',
|
||||
'products': '<?php esc_html_e( 'Products', 'kirki' ); ?>',
|
||||
'taxonomies': '<?php esc_html_e( 'Taxonomies', 'kirki' ); ?>',
|
||||
'widgets': '<?php esc_html_e( 'Widgets', 'kirki' ); ?>',
|
||||
'notifications': '<?php esc_html_e( 'Notifications', 'kirki' ); ?>',
|
||||
'misc': '<?php esc_html_e( 'Miscelaneous', 'kirki' ); ?>'
|
||||
};
|
||||
#>
|
||||
<# _.each( dashiconSections, function( sectionLabel, sectionKey ) { #>
|
||||
<h4>{{ sectionLabel }}</h4>
|
||||
<# for ( key in data.icons[ sectionKey ] ) { #>
|
||||
<input {{{ data.inputAttrs }}}
|
||||
class="dashicons-select"
|
||||
type="radio"
|
||||
value="{{ data.icons[ sectionKey ][ key ] }}"
|
||||
name="_customize-dashicons-radio-{{ data.id }}"
|
||||
id="{{ data.id }}{{ data.icons[ sectionKey ][ key ] }}"
|
||||
{{{ data.link }}}
|
||||
<# if ( data.value === data.icons[ sectionKey ][ key ] ) { #> checked="checked"<# } #>>
|
||||
<label for="{{ data.id }}{{ data.icons[ sectionKey ][ key ] }}">
|
||||
<span class="dashicons dashicons-{{ data.icons[ sectionKey ][ key ] }}"></span>
|
||||
</label>
|
||||
</input>
|
||||
<# } #>
|
||||
<# }); #>
|
||||
<# } #>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
/**
|
||||
* Override field methods
|
||||
*
|
||||
* @package kirki-framework/control-dashicons
|
||||
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Field;
|
||||
|
||||
use Kirki\Field;
|
||||
|
||||
/**
|
||||
* Field overrides.
|
||||
*/
|
||||
class Dashicons extends Field {
|
||||
|
||||
/**
|
||||
* The field type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-dashicons';
|
||||
|
||||
/**
|
||||
* The control class-name.
|
||||
*
|
||||
* @access protected
|
||||
* @since 0.1
|
||||
* @var string
|
||||
*/
|
||||
protected $control_class = '\Kirki\Control\Dashicons';
|
||||
|
||||
/**
|
||||
* Whether we should register the control class for JS-templating or not.
|
||||
*
|
||||
* @access protected
|
||||
* @since 0.1
|
||||
* @var bool
|
||||
*/
|
||||
protected $control_has_js_template = true;
|
||||
|
||||
/**
|
||||
* Filter arguments before creating the setting.
|
||||
*
|
||||
* @access public
|
||||
* @since 0.1
|
||||
* @param array $args The field arguments.
|
||||
* @param WP_Customize_Manager $wp_customize The customizer instance.
|
||||
* @return array
|
||||
*/
|
||||
public function filter_setting_args( $args, $wp_customize ) {
|
||||
if ( $args['settings'] === $this->args['settings'] ) {
|
||||
$args = parent::filter_setting_args( $args, $wp_customize );
|
||||
|
||||
// Set the sanitize-callback if none is defined.
|
||||
if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) {
|
||||
$args['sanitize_callback'] = 'sanitize_text_field';
|
||||
}
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter arguments before creating the control.
|
||||
*
|
||||
* @access public
|
||||
* @since 0.1
|
||||
* @param array $args The field arguments.
|
||||
* @param WP_Customize_Manager $wp_customize The customizer instance.
|
||||
* @return array
|
||||
*/
|
||||
public function filter_control_args( $args, $wp_customize ) {
|
||||
if ( $args['settings'] === $this->args['settings'] ) {
|
||||
$args = parent::filter_control_args( $args, $wp_customize );
|
||||
$args['type'] = 'kirki-dashicons';
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
/**
|
||||
* Helper methods for dashicons.
|
||||
*
|
||||
* @package kirki-framework/control-dashicons
|
||||
* @category Core
|
||||
* @author Ari Stathopoulos (@aristath)
|
||||
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Util;
|
||||
|
||||
/**
|
||||
* A simple object containing static methods.
|
||||
*/
|
||||
class Dashicons {
|
||||
|
||||
/**
|
||||
* Get an array of all available dashicons.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @return array
|
||||
*/
|
||||
public static function get_icons() {
|
||||
return [
|
||||
'admin-menu' => [ 'menu', 'menu-alt', 'menu-alt2', 'menu-alt3', 'admin-site', 'admin-site-alt', 'admin-site-alt2', 'admin-site-alt3', 'dashboard', 'admin-post', 'admin-media', 'admin-links', 'admin-page', 'admin-comments', 'admin-appearance', 'admin-plugins', 'plugins-checked', 'admin-users', 'admin-tools', 'admin-settings', 'admin-network', 'admin-home', 'admin-generic', 'admin-collapse', 'filter', 'admin-customizer', 'admin-multisite' ],
|
||||
'welcome-screen' => [ 'welcome-write-blog', 'welcome-add-page', 'welcome-view-site', 'welcome-widgets-menus', 'welcome-comments', 'welcome-learn-more' ],
|
||||
'post-formats' => [ 'format-aside', 'format-image', 'format-gallery', 'format-video', 'format-status', 'format-quote', 'format-chat', 'format-audio', 'camera', 'camera-alt', 'images-alt', 'images-alt2', 'video-alt', 'video-alt2', 'video-alt3' ],
|
||||
'media' => [ 'media-archive', 'media-audio', 'media-code', 'media-default', 'media-document', 'media-interactive', 'media-spreadsheet', 'media-text', 'media-video', 'playlist-audio', 'playlist-video', 'controls-play', 'controls-pause', 'controls-forward', 'controls-skipforward', 'controls-back', 'controls-skipback', 'controls-repeat', 'controls-volumeon', 'controls-volumeoff' ],
|
||||
'image-editing' => [ 'image-crop', 'image-rotate', 'image-rotate-left', 'image-rotate-right', 'image-flip-vertical', 'image-flip-horizontal', 'image-filter', 'undo', 'redo' ],
|
||||
'tinymce' => [ 'editor-bold', 'editor-italic', 'editor-ul', 'editor-ol', 'editor-ol-rtl', 'editor-quote', 'editor-alignleft', 'editor-aligncenter', 'editor-alignright', 'editor-insertmore', 'editor-spellcheck', 'editor-expand', 'editor-contract', 'editor-kitchensink', 'editor-underline', 'editor-justify', 'editor-textcolor', 'editor-paste-word', 'editor-paste-text', 'editor-removeformatting', 'editor-video', 'editor-customchar', 'editor-outdent', 'editor-indent', 'editor-help', 'editor-strikethrough', 'editor-unlink', 'editor-rtl', 'editor-ltr', 'editor-break', 'editor-code', 'editor-paragraph', 'editor-table' ],
|
||||
'posts' => [ 'align-left', 'align-right', 'align-center', 'align-none', 'lock', 'unlock', 'calendar', 'calendar-alt', 'visibility', 'hidden', 'post-status', 'edit', 'trash', 'sticky' ],
|
||||
'sorting' => [ 'external', 'arrow-up', 'arrow-down', 'arrow-right', 'arrow-left', 'arrow-up-alt', 'arrow-down-alt', 'arrow-right-alt', 'arrow-left-alt', 'arrow-up-alt2', 'arrow-down-alt2', 'arrow-right-alt2', 'arrow-left-alt2', 'sort', 'leftright', 'randomize', 'list-view', 'exerpt-view', 'grid-view', 'move' ],
|
||||
'social' => [ 'share', 'share-alt', 'share-alt2', 'twitter', 'rss', 'email', 'email-alt', 'email-alt2', 'facebook', 'facebook-alt', 'googleplus', 'networking', 'instagram' ],
|
||||
'wordpress_org' => [ 'hammer', 'art', 'migrate', 'performance', 'universal-access', 'universal-access-alt', 'tickets', 'nametag', 'clipboard', 'heart', 'megaphone', 'schedule', 'tide', 'rest-api', 'code-standards' ],
|
||||
'products' => [ 'wordpress', 'wordpress-alt', 'pressthis', 'update', 'update-alt', 'screenoptions', 'info', 'cart', 'feedback', 'cloud', 'translation' ],
|
||||
'taxonomies' => [ 'tag', 'category' ],
|
||||
'widgets' => [ 'archive', 'tagcloud', 'text' ],
|
||||
'notifications' => [ 'yes', 'yes-alt', 'no', 'no-alt', 'plus', 'plus-alt', 'minus', 'dismiss', 'marker', 'star-filled', 'star-half', 'star-empty', 'flag', 'warning' ],
|
||||
'misc' => [ 'location', 'location-alt', 'vault', 'shield', 'shield-alt', 'sos', 'search', 'slides', 'text-page', 'analytics', 'chart-pie', 'chart-bar', 'chart-line', 'chart-area', 'groups', 'businessman', 'businesswoman', 'businessperson', 'id', 'id-alt', 'products', 'awards', 'forms', 'testimonial', 'portfolio', 'book', 'book-alt', 'download', 'upload', 'backup', 'clock', 'lightbulb', 'microphone', 'desktop', 'tablet', 'smartphone', 'phone', 'index-card', 'carrot', 'building', 'store', 'album', 'palmtree', 'tickets-alt', 'money', 'smiley', 'thumbs-up', 'thumbs-down', 'layout', 'paperclip' ],
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
import "./control.scss";
|
||||
|
||||
wp.customize.controlConstructor['kirki-dashicons'] = wp.customize.kirkiDynamicControl.extend( {} );
|
|
@ -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-date
|
||||
|
||||
## Installation
|
||||
|
||||
First, install the package using composer:
|
||||
|
||||
```bash
|
||||
composer require kirki-framework/control-date
|
||||
```
|
||||
|
||||
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\Date' );
|
||||
} );
|
||||
|
||||
/**
|
||||
* 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' => '',
|
||||
'transport' => 'refresh', // Or postMessage.
|
||||
'sanitize_callback' => 'sanitize_text_field', // Or a custom sanitization callback.
|
||||
] );
|
||||
|
||||
// Add control.
|
||||
$wp_customize->add_control( new \Kirki\Control\Date( $wp_customize, 'my_control', [
|
||||
'label' => esc_html__( 'My Control', 'theme_textdomain' ),
|
||||
'section' => 'my_section',
|
||||
] ) );
|
||||
} );
|
||||
```
|
2
functions/kirki/packages/kirki-framework/control-date/dist/control.css
vendored
Normal file
2
functions/kirki/packages/kirki-framework/control-date/dist/control.css
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
.kirki-datepicker-popup{background-color:#fff;border:1px solid #ddd;border-radius:6px;box-shadow:0 12px 15px 0 rgba(0,0,0,.09);margin-top:15px;max-width:275px;overflow:hidden;padding-bottom:10px;z-index:500001!important}.kirki-datepicker-popup .ui-datepicker-header{background-color:#eee;padding:10px}.kirki-datepicker-popup .ui-datepicker-header .ui-datepicker-next,.kirki-datepicker-popup .ui-datepicker-header .ui-datepicker-prev{align-items:center;border-radius:50%;cursor:pointer;display:flex;height:30px;justify-content:center;overflow:hidden;position:absolute;transition:all .2s;width:30px}.kirki-datepicker-popup .ui-datepicker-header .ui-datepicker-next:active,.kirki-datepicker-popup .ui-datepicker-header .ui-datepicker-next:focus,.kirki-datepicker-popup .ui-datepicker-header .ui-datepicker-next:hover,.kirki-datepicker-popup .ui-datepicker-header .ui-datepicker-prev:active,.kirki-datepicker-popup .ui-datepicker-header .ui-datepicker-prev:focus,.kirki-datepicker-popup .ui-datepicker-header .ui-datepicker-prev:hover{background-color:#2271b1;color:#fff}.kirki-datepicker-popup .ui-datepicker-header .ui-datepicker-next:after,.kirki-datepicker-popup .ui-datepicker-header .ui-datepicker-next:before,.kirki-datepicker-popup .ui-datepicker-header .ui-datepicker-prev:after,.kirki-datepicker-popup .ui-datepicker-header .ui-datepicker-prev:before{font-family:dashicons}.kirki-datepicker-popup .ui-datepicker-header .ui-datepicker-next .ui-icon,.kirki-datepicker-popup .ui-datepicker-header .ui-datepicker-prev .ui-icon{display:none}.kirki-datepicker-popup .ui-datepicker-header .ui-datepicker-prev{left:10px}.kirki-datepicker-popup .ui-datepicker-header .ui-datepicker-prev:before{content:"\f341"}.kirki-datepicker-popup .ui-datepicker-header .ui-datepicker-next{right:10px}.kirki-datepicker-popup .ui-datepicker-header .ui-datepicker-next:after{content:"\f345"}.kirki-datepicker-popup .ui-datepicker-header .ui-datepicker-title{align-items:center;display:flex;font-size:16px;height:30px;justify-content:center;text-align:center;width:100%}.kirki-datepicker-popup .ui-datepicker-calendar{border-collapse:collapse;padding-bottom:20px;width:100%}.kirki-datepicker-popup .ui-datepicker-calendar thead{background-color:#ddd;padding-left:5px;padding-right:5px}.kirki-datepicker-popup .ui-datepicker-calendar thead th{font-size:13px;font-weight:600;padding-bottom:5px;padding-top:5px;text-align:center}.kirki-datepicker-popup .ui-datepicker-calendar tbody{padding:5px}.kirki-datepicker-popup .ui-datepicker-calendar tbody td{padding:2px;text-align:center}.kirki-datepicker-popup .ui-datepicker-calendar tbody a{color:#333;text-decoration:none}.kirki-datepicker-popup .ui-datepicker-calendar tbody .ui-datepicker-today .ui-state-default{background-color:#eee}.kirki-datepicker-popup .ui-datepicker-calendar tbody .ui-datepicker-today .ui-state-active,.kirki-datepicker-popup .ui-datepicker-calendar tbody .ui-datepicker-today .ui-state-active:active,.kirki-datepicker-popup .ui-datepicker-calendar tbody .ui-datepicker-today .ui-state-active:focus,.kirki-datepicker-popup .ui-datepicker-calendar tbody .ui-datepicker-today .ui-state-active:hover{background-color:#2271b1}.kirki-datepicker-popup .ui-datepicker-calendar tbody .ui-state-default{align-items:center;border-radius:50%;display:inline-flex;height:30px;justify-content:center;width:30px}.kirki-datepicker-popup .ui-datepicker-calendar tbody .ui-state-default:active,.kirki-datepicker-popup .ui-datepicker-calendar tbody .ui-state-default:hover{background-color:#eee}.kirki-datepicker-popup .ui-datepicker-calendar tbody .ui-state-active,.kirki-datepicker-popup .ui-datepicker-calendar tbody .ui-state-default:focus{background-color:#2271b1;color:#fff}.kirki-datepicker-popup .ui-datepicker-calendar tbody .ui-state-active:active,.kirki-datepicker-popup .ui-datepicker-calendar tbody .ui-state-active:focus,.kirki-datepicker-popup .ui-datepicker-calendar tbody .ui-state-active:hover{background-color:#2271b1}
|
||||
/*# sourceMappingURL=control.css.map */
|
2
functions/kirki/packages/kirki-framework/control-date/dist/control.js
vendored
Normal file
2
functions/kirki/packages/kirki-framework/control-date/dist/control.js
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
wp.customize.controlConstructor["kirki-date"]=wp.customize.kirkiDynamicControl.extend({handleWidth:function(e){document.querySelector("#kirki-style-datepicker").innerHTML=".kirki-datepicker-popup {width: "+e.clientWidth.toString()+"px;}"},initKirkiControl:function(e){var t;t=(e=e||this).selector+" input.datepicker";var i=document.querySelector("#kirki-style-datepicker");i||((i=document.createElement("style")).id="kirki-style-datepicker",document.head.appendChild(i)),jQuery(t).datepicker({dateFormat:"yy-mm-dd",duration:200,beforeShow:function(t,i){i.dpDiv[0].classList.add("kirki-datepicker-popup"),e.handleWidth(t)}}),this.container.on("change keyup paste","input.datepicker",(function(){e.setting.set(jQuery(this).val())}))}});
|
||||
//# sourceMappingURL=control.js.map
|
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
/**
|
||||
* Customizer Control: kirki-date.
|
||||
*
|
||||
* @package kirki-framework/control-date
|
||||
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Control;
|
||||
|
||||
use Kirki\URL;
|
||||
use Kirki\Control\Base;
|
||||
|
||||
/**
|
||||
* A simple date control, using jQuery UI.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class Date extends Base {
|
||||
|
||||
/**
|
||||
* The control type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-date';
|
||||
|
||||
/**
|
||||
* The version. Used in scripts & styles for cache-busting.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public static $control_ver = '1.0';
|
||||
|
||||
/**
|
||||
* Enqueue control related scripts/styles.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue() {
|
||||
parent::enqueue();
|
||||
|
||||
// Enqueue the script.
|
||||
wp_enqueue_script( 'kirki-control-date', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [ 'jquery', 'customize-base', 'kirki-control-base', 'jquery-ui-datepicker' ], self::$control_ver, false );
|
||||
|
||||
// Enqueue the style.
|
||||
wp_enqueue_style( 'kirki-control-date-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() {
|
||||
?>
|
||||
<label>
|
||||
<# if ( data.label ) { #><span class="customize-control-title">{{{ data.label }}}</span><# } #>
|
||||
<# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><# } #>
|
||||
<div class="customize-control-content">
|
||||
<input {{{ data.inputAttrs }}} class="datepicker" type="text" id="{{ data.id }}" value="{{ data.value }}" {{{ data.link }}} />
|
||||
</div>
|
||||
</label>
|
||||
<?php
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
/**
|
||||
* Override field methods
|
||||
*
|
||||
* @package kirki-framework/control-date
|
||||
* @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 Date extends Field {
|
||||
|
||||
/**
|
||||
* The field type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-date';
|
||||
|
||||
/**
|
||||
* The control class-name.
|
||||
*
|
||||
* @access protected
|
||||
* @since 0.1
|
||||
* @var string
|
||||
*/
|
||||
protected $control_class = '\Kirki\Control\Date';
|
||||
|
||||
/**
|
||||
* Whether we should register the control class for JS-templating or not.
|
||||
*
|
||||
* @access protected
|
||||
* @since 0.1
|
||||
* @var bool
|
||||
*/
|
||||
protected $control_has_js_template = true;
|
||||
|
||||
/**
|
||||
* Filter arguments before creating the setting.
|
||||
*
|
||||
* @access public
|
||||
* @since 0.1
|
||||
* @param array $args The field arguments.
|
||||
* @param WP_Customize_Manager $wp_customize The customizer instance.
|
||||
* @return array
|
||||
*/
|
||||
public function filter_setting_args( $args, $wp_customize ) {
|
||||
if ( $args['settings'] === $this->args['settings'] ) {
|
||||
$args = parent::filter_setting_args( $args, $wp_customize );
|
||||
|
||||
// Set the sanitize-callback if none is defined.
|
||||
if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) {
|
||||
$args['sanitize_callback'] = 'sanitize_text_field';
|
||||
}
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter arguments before creating the control.
|
||||
*
|
||||
* @access public
|
||||
* @since 0.1
|
||||
* @param array $args The field arguments.
|
||||
* @param WP_Customize_Manager $wp_customize The customizer instance.
|
||||
* @return array
|
||||
*/
|
||||
public function filter_control_args( $args, $wp_customize ) {
|
||||
if ( $args['settings'] === $this->args['settings'] ) {
|
||||
$args = parent::filter_control_args( $args, $wp_customize );
|
||||
$args['type'] = 'kirki-date';
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
import "./control.scss";
|
||||
|
||||
wp.customize.controlConstructor['kirki-date'] = wp.customize.kirkiDynamicControl.extend({
|
||||
|
||||
handleWidth: (input) => {
|
||||
var styleTag = document.querySelector('#kirki-style-datepicker');
|
||||
styleTag.innerHTML = '.kirki-datepicker-popup {width: ' + input.clientWidth.toString() + 'px;}';
|
||||
},
|
||||
|
||||
initKirkiControl: function (control) {
|
||||
var selector;
|
||||
|
||||
control = control || this;
|
||||
selector = control.selector + ' input.datepicker';
|
||||
|
||||
var styleTag = document.querySelector('#kirki-style-datepicker');
|
||||
|
||||
if (!styleTag) {
|
||||
styleTag = document.createElement('style');
|
||||
styleTag.id = 'kirki-style-datepicker';
|
||||
document.head.appendChild(styleTag);
|
||||
}
|
||||
|
||||
// Init the datepicker.
|
||||
jQuery(selector).datepicker({
|
||||
dateFormat: 'yy-mm-dd',
|
||||
duration: 200,
|
||||
beforeShow: function (input, inst) {
|
||||
inst.dpDiv[0].classList.add('kirki-datepicker-popup');
|
||||
control.handleWidth(input);
|
||||
}
|
||||
});
|
||||
|
||||
// Save the changes
|
||||
this.container.on('change keyup paste', 'input.datepicker', function () {
|
||||
control.setting.set(jQuery(this).val());
|
||||
});
|
||||
}
|
||||
});
|
|
@ -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-dimension
|
||||
|
||||
## Installation
|
||||
|
||||
First, install the package using composer:
|
||||
|
||||
```bash
|
||||
composer require kirki-framework/control-dimension
|
||||
```
|
||||
|
||||
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\Dimension' );
|
||||
} );
|
||||
|
||||
/**
|
||||
* 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' => '10px',
|
||||
'transport' => 'refresh', // Or postMessage.
|
||||
'sanitize_callback' => 'sanitize_text_field', // Or a custom sanitization callback.
|
||||
] );
|
||||
|
||||
// Add control.
|
||||
$wp_customize->add_control( new \Kirki\Control\Dimension( $wp_customize, 'my_control', [
|
||||
'label' => esc_html__( 'My Control', 'theme_textdomain' ),
|
||||
'section' => 'my_section',
|
||||
] ) );
|
||||
} );
|
||||
```
|
2
functions/kirki/packages/kirki-framework/control-dimension/dist/control.css
vendored
Normal file
2
functions/kirki/packages/kirki-framework/control-dimension/dist/control.css
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
.customize-control-kirki-dimension .has-label-bottom .kirki-control-label{color:#333;font-size:11px;font-weight:500;margin-top:3px;text-align:center}.customize-control-kirki-dimension .has-label-bottom .kirki-control-input{background-color:#f7f7f7}.customize-control-kirki-dimension .has-label-bottom .kirki-control-input:focus{background-color:#fff}
|
||||
/*# sourceMappingURL=control.css.map */
|
2
functions/kirki/packages/kirki-framework/control-dimension/dist/control.js
vendored
Normal file
2
functions/kirki/packages/kirki-framework/control-dimension/dist/control.js
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
wp.customize.controlConstructor["kirki-dimension"]=wp.customize.kirkiDynamicControl.extend({initKirkiControl:function(i){var n;(i=i||this).kirkiNotifications(),i.container.on("change keyup paste","input",(function(){n=jQuery(this).val(),i.setting.set(n)}))},kirkiNotifications:function(){var i=this,n=void 0!==i.params.choices&&void 0!==i.params.choices.accept_unitless&&!0===i.params.choices.accept_unitless;wp.customize(i.id,(function(t){t.bind((function(e){var a="long_title";!1!==i.validateCssValue(e)||n&&!isNaN(e)?t.notifications.remove(a):t.notifications.add(a,new wp.customize.Notification(a,{type:"warning",message:dimensionkirkiL10n["invalid-value"]}))}))}))},validateCssValue:function(i){var n,t,e,a=this,o=!0;return!i||""===i||0===i||"0"===i||"auto"===i||"inherit"===i||"initial"===i||0<=i.indexOf("calc(")&&0<=i.indexOf(")")||(n=parseFloat(i),!(t=i.replace(n,""))||(2<=(e=i.split(" ")).length?(e.forEach((function(i){i&&!a.validateCssValue(i)&&(o=!1)})),o):!isNaN(n)&&-1!==["fr","rem","em","ex","%","px","cm","mm","in","pt","pc","ch","vh","vw","vmin","vmax"].indexOf(t)))}});
|
||||
//# sourceMappingURL=control.js.map
|
|
@ -0,0 +1,159 @@
|
|||
<?php
|
||||
/**
|
||||
* Customizer Control: dimension
|
||||
*
|
||||
* @package kirki-framework/control-dimension
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* A text control with validation for CSS units.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class Dimension extends Base {
|
||||
|
||||
/**
|
||||
* The control type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-dimension';
|
||||
|
||||
/**
|
||||
* The version. Used in scripts & styles for cache-busting.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public static $control_ver = '1.0';
|
||||
|
||||
/**
|
||||
* Enqueue control related scripts/styles.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue() {
|
||||
parent::enqueue();
|
||||
|
||||
// Enqueue the script.
|
||||
wp_enqueue_script( 'kirki-control-dimension', 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-dimension-style', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], self::$control_ver );
|
||||
|
||||
wp_localize_script(
|
||||
'kirki-control-dimension',
|
||||
'dimensionkirkiL10n',
|
||||
[
|
||||
'invalid-value' => esc_html__( 'Invalid Value', 'kirki' ),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URL for the control folder.
|
||||
*
|
||||
* This is a static method because there are more controls in the Kirki framework
|
||||
* that use colorpickers, and they all need to enqueue the same assets.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @return string
|
||||
*/
|
||||
public static function get_control_path_url() {
|
||||
return URL::get_from_path( dirname( __DIR__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
$input_class = 'kirki-control-input';
|
||||
|
||||
if ( isset( $this->input_attrs['class'] ) ) {
|
||||
$input_class .= ' ' . $this->input_attrs['class'];
|
||||
unset( $this->input_attrs['class'] );
|
||||
}
|
||||
|
||||
// Get the basics from the parent class.
|
||||
parent::to_json();
|
||||
|
||||
// Input class name.
|
||||
$this->json['inputClass'] = $input_class;
|
||||
|
||||
// Label position.
|
||||
$this->json['labelPosition'] = 'top';
|
||||
|
||||
if ( isset( $this->choices['label_position'] ) && 'bottom' === $this->choices['label_position'] ) {
|
||||
$this->json['labelPosition'] = 'bottom';
|
||||
}
|
||||
|
||||
// Input id.
|
||||
$this->json['inputId'] = '_customize-input-' . $this->id;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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-control-form <# if ('bottom' === data.labelPosition) { #>has-label-bottom<# } #>">
|
||||
<# if ( 'top' === data.labelPosition ) { #>
|
||||
<label class="kirki-control-label" for="{{ data.inputId }}">
|
||||
<# if ( data.label ) { #><span class="customize-control-title">{{{ data.label }}}</span><# } #>
|
||||
<# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><# } #>
|
||||
</label>
|
||||
<# } #>
|
||||
|
||||
<div class="kirki-input-control">
|
||||
<# var val = ( data.value && _.isString( data.value ) ) ? data.value.replace( '%%', '%' ) : ''; #>
|
||||
<input id="{{ data.inputId }}" {{{ data.inputAttrs }}} type="text" value="{{ val }}" class="{{ data.inputClass }}" />
|
||||
</div>
|
||||
|
||||
<# if ( 'bottom' === data.labelPosition ) { #>
|
||||
<label class="kirki-control-label" for="{{ data.inputId }}">
|
||||
<# if ( data.label ) { #>{{{ data.label }}} <# } #>
|
||||
</label>
|
||||
<# } #>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
/**
|
||||
* Override field methods
|
||||
*
|
||||
* @package Kirki
|
||||
* @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 Dimension extends Field {
|
||||
|
||||
/**
|
||||
* The field type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-dimension';
|
||||
|
||||
/**
|
||||
* The control class-name.
|
||||
*
|
||||
* @access protected
|
||||
* @since 0.1
|
||||
* @var string
|
||||
*/
|
||||
protected $control_class = '\Kirki\Control\Dimension';
|
||||
|
||||
/**
|
||||
* Whether we should register the control class for JS-templating or not.
|
||||
*
|
||||
* @access protected
|
||||
* @since 0.1
|
||||
* @var bool
|
||||
*/
|
||||
protected $control_has_js_template = true;
|
||||
|
||||
/**
|
||||
* Filter arguments before creating the setting.
|
||||
*
|
||||
* @access public
|
||||
* @since 0.1
|
||||
* @param array $args The field arguments.
|
||||
* @param WP_Customize_Manager $wp_customize The customizer instance.
|
||||
* @return array
|
||||
*/
|
||||
public function filter_setting_args( $args, $wp_customize ) {
|
||||
if ( $args['settings'] === $this->args['settings'] ) {
|
||||
$args = parent::filter_setting_args( $args, $wp_customize );
|
||||
|
||||
// Set the sanitize-callback if none is defined.
|
||||
if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) {
|
||||
$args['sanitize_callback'] = 'sanitize_text_field';
|
||||
}
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter arguments before creating the control.
|
||||
*
|
||||
* @access public
|
||||
* @since 0.1
|
||||
* @param array $args The field arguments.
|
||||
* @param WP_Customize_Manager $wp_customize The customizer instance.
|
||||
* @return array
|
||||
*/
|
||||
public function filter_control_args( $args, $wp_customize ) {
|
||||
if ( $args['settings'] === $this->args['settings'] ) {
|
||||
$args = parent::filter_control_args( $args, $wp_customize );
|
||||
$args['type'] = 'kirki-dimension';
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
import "./control.scss";
|
||||
|
||||
/* global dimensionkirkiL10n */
|
||||
wp.customize.controlConstructor['kirki-dimension'] = wp.customize.kirkiDynamicControl.extend( {
|
||||
|
||||
initKirkiControl: function( control ) {
|
||||
var value;
|
||||
control = control || this;
|
||||
|
||||
// Notifications.
|
||||
control.kirkiNotifications();
|
||||
|
||||
// Save the value
|
||||
control.container.on( 'change keyup paste', 'input', function() {
|
||||
value = jQuery( this ).val();
|
||||
control.setting.set( value );
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Handles notifications.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
kirkiNotifications: function() {
|
||||
|
||||
var control = this,
|
||||
acceptUnitless = ( 'undefined' !== typeof control.params.choices && 'undefined' !== typeof control.params.choices.accept_unitless && true === control.params.choices.accept_unitless );
|
||||
|
||||
wp.customize( control.id, function( setting ) {
|
||||
setting.bind( function( value ) {
|
||||
var code = 'long_title';
|
||||
|
||||
if ( false === control.validateCssValue( value ) && ( ! acceptUnitless || isNaN( value ) ) ) {
|
||||
setting.notifications.add( code, new wp.customize.Notification( code, {
|
||||
type: 'warning',
|
||||
message: dimensionkirkiL10n['invalid-value']
|
||||
} ) );
|
||||
} else {
|
||||
setting.notifications.remove( code );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
},
|
||||
|
||||
validateCssValue: function( value ) {
|
||||
|
||||
var control = this,
|
||||
validUnits = [ 'fr', 'rem', 'em', 'ex', '%', 'px', 'cm', 'mm', 'in', 'pt', 'pc', 'ch', 'vh', 'vw', 'vmin', 'vmax' ],
|
||||
numericValue,
|
||||
unit,
|
||||
multiples,
|
||||
multiplesValid = true;
|
||||
|
||||
// Whitelist values.
|
||||
if ( ! value || '' === value || 0 === value || '0' === value || 'auto' === value || 'inherit' === value || 'initial' === value ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Skip checking if calc().
|
||||
if ( 0 <= value.indexOf( 'calc(' ) && 0 <= value.indexOf( ')' ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get the numeric value.
|
||||
numericValue = parseFloat( value );
|
||||
|
||||
// Get the unit
|
||||
unit = value.replace( numericValue, '' );
|
||||
|
||||
// Allow unitless.
|
||||
if ( ! unit ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for multiple values.
|
||||
multiples = value.split( ' ' );
|
||||
if ( 2 <= multiples.length ) {
|
||||
multiples.forEach( function( item ) {
|
||||
if ( item && ! control.validateCssValue( item ) ) {
|
||||
multiplesValid = false;
|
||||
}
|
||||
});
|
||||
|
||||
return multiplesValid;
|
||||
}
|
||||
|
||||
// Check the validity of the numeric value and units.
|
||||
return ( ! isNaN( numericValue ) && -1 !== validUnits.indexOf( unit ) );
|
||||
}
|
||||
} );
|
|
@ -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,54 @@
|
|||
# control-editor
|
||||
|
||||
## Installation
|
||||
|
||||
First, install the package using composer:
|
||||
|
||||
```bash
|
||||
composer require kirki-framework/control-editor
|
||||
```
|
||||
|
||||
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\Editor' );
|
||||
} );
|
||||
|
||||
/**
|
||||
* 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' => '',
|
||||
'transport' => 'refresh', // Or postMessage.
|
||||
'sanitize_callback' => 'wp_kses_post', // Or a custom sanitization callback.
|
||||
] );
|
||||
|
||||
// Add control.
|
||||
$wp_customize->add_control( new \Kirki\Control\Editor( $wp_customize, 'my_control', [
|
||||
'label' => esc_html__( 'My Control', 'theme_textdomain' ),
|
||||
'section' => 'my_section',
|
||||
] ) );
|
||||
} );
|
||||
```
|
2
functions/kirki/packages/kirki-framework/control-editor/dist/control.css
vendored
Normal file
2
functions/kirki/packages/kirki-framework/control-editor/dist/control.css
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
.customize-control-kirki-editor textarea{width:100%}
|
||||
/*# sourceMappingURL=control.css.map */
|
2
functions/kirki/packages/kirki-framework/control-editor/dist/control.js
vendored
Normal file
2
functions/kirki/packages/kirki-framework/control-editor/dist/control.js
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
wp.customize.controlConstructor["kirki-editor"]=wp.customize.kirkiDynamicControl.extend({initKirkiControl:function(i){var t,e,n,o;t=(i=i||this).container.find("textarea"),n="kirki-editor-"+i.id.replace("[","").replace("]",""),o={tinymce:{wpautop:!0},quicktags:!0,mediaButtons:!0},wp.editor&&wp.editor.initialize&&wp.editor.initialize(n,jQuery.extend({},o,i.params.choices)),(e=tinyMCE.get(n))&&e.onChange.add((function(n){var o;n.save(),o=e.getContent(),t.val(o).trigger("change"),wp.customize.instance(i.id).set(o)}))}});
|
||||
//# sourceMappingURL=control.js.map
|
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
/**
|
||||
* Customizer Control: editor.
|
||||
*
|
||||
* Creates a TinyMCE textarea.
|
||||
*
|
||||
* @package kirki-framework/control-editor
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* A TinyMCE control.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class Editor extends Base {
|
||||
|
||||
/**
|
||||
* The control type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-editor';
|
||||
|
||||
/**
|
||||
* The version. Used in scripts & styles for cache-busting.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public static $control_ver = '1.0';
|
||||
|
||||
/**
|
||||
* Args to pass to TinyMCE.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var bool
|
||||
*/
|
||||
public $choices = [];
|
||||
|
||||
/**
|
||||
* Enqueue control related scripts/styles.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue() {
|
||||
parent::enqueue();
|
||||
|
||||
// Enqueue the script.
|
||||
wp_enqueue_script( 'kirki-control-editor', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [ 'jquery', 'customize-base', 'kirki-control-base' ], self::$control_ver, false );
|
||||
|
||||
// Enqueue the style.
|
||||
wp_enqueue_style( 'kirki-control-editor-style', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], self::$control_ver );
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the parameters passed to the JavaScript via JSON.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @return void
|
||||
*/
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
$this->json['choices'] = $this->choices;
|
||||
}
|
||||
|
||||
/**
|
||||
* An Underscore (JS) template for this control's content (but not its container).
|
||||
*
|
||||
* Class variables for this control class are available in the `data` JS object;
|
||||
* export custom variables by overriding {@see WP_Customize_Control::to_json()}.
|
||||
*
|
||||
* The actual editor is added from the \Kirki\Field\Editor class.
|
||||
* All this template contains is a button that triggers the global editor on/off
|
||||
* and a hidden textarea element that is used to mirror save the options.
|
||||
*
|
||||
* @see WP_Customize_Control::print_template()
|
||||
*
|
||||
* @access protected
|
||||
* @since 1.0
|
||||
* @return void
|
||||
*/
|
||||
protected function content_template() {
|
||||
?>
|
||||
<label>
|
||||
<# if ( data.label ) { #><span class="customize-control-title">{{{ data.label }}}</span><# } #>
|
||||
<# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><# } #>
|
||||
</label>
|
||||
<textarea id="kirki-editor-{{{ data.id.replace( '[', '' ).replace( ']', '' ) }}}" {{{ data.inputAttrs }}} {{{ data.link }}}>{{ data.value }}</textarea>
|
||||
<?php
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
/**
|
||||
* Override field methods
|
||||
*
|
||||
* @package kirki-framework/control-editor
|
||||
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
namespace Kirki\Field;
|
||||
|
||||
use Kirki\Field;
|
||||
|
||||
/**
|
||||
* Field overrides.
|
||||
*/
|
||||
class Editor extends Field {
|
||||
|
||||
/**
|
||||
* The field type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'kirki-editor';
|
||||
|
||||
/**
|
||||
* The control class-name.
|
||||
*
|
||||
* @access protected
|
||||
* @since 0.1
|
||||
* @var string
|
||||
*/
|
||||
protected $control_class = '\Kirki\Control\Editor';
|
||||
|
||||
/**
|
||||
* Whether we should register the control class for JS-templating or not.
|
||||
*
|
||||
* @access protected
|
||||
* @since 0.1
|
||||
* @var bool
|
||||
*/
|
||||
protected $control_has_js_template = true;
|
||||
|
||||
/**
|
||||
* Filter arguments before creating the setting.
|
||||
*
|
||||
* @access public
|
||||
* @since 0.1
|
||||
* @param array $args The field arguments.
|
||||
* @param WP_Customize_Manager $wp_customize The customizer instance.
|
||||
* @return array
|
||||
*/
|
||||
public function filter_setting_args( $args, $wp_customize ) {
|
||||
if ( $args['settings'] === $this->args['settings'] ) {
|
||||
$args = parent::filter_setting_args( $args, $wp_customize );
|
||||
|
||||
// Set the sanitize-callback if none is defined.
|
||||
if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) {
|
||||
$args['sanitize_callback'] = 'wp_kses_post';
|
||||
}
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter arguments before creating the control.
|
||||
*
|
||||
* @access public
|
||||
* @since 0.1
|
||||
* @param array $args The field arguments.
|
||||
* @param WP_Customize_Manager $wp_customize The customizer instance.
|
||||
* @return array
|
||||
*/
|
||||
public function filter_control_args( $args, $wp_customize ) {
|
||||
if ( $args['settings'] === $this->args['settings'] ) {
|
||||
$args = parent::filter_control_args( $args, $wp_customize );
|
||||
$args['type'] = 'kirki-editor';
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
import "./control.scss";
|
||||
|
||||
/* global tinyMCE */
|
||||
wp.customize.controlConstructor[ 'kirki-editor' ] = wp.customize.kirkiDynamicControl.extend( {
|
||||
initKirkiControl: function( control ) {
|
||||
var element, editor, id, defaultParams;
|
||||
control = control || this;
|
||||
element = control.container.find( 'textarea' );
|
||||
id = 'kirki-editor-' + control.id.replace( '[', '' ).replace( ']', '' );
|
||||
|
||||
defaultParams = {
|
||||
tinymce: {
|
||||
wpautop: true
|
||||
},
|
||||
quicktags: true,
|
||||
mediaButtons: true
|
||||
};
|
||||
|
||||
// Overwrite the default paramaters if choices is defined.
|
||||
if ( wp.editor && wp.editor.initialize ) {
|
||||
wp.editor.initialize( id, jQuery.extend( {}, defaultParams, control.params.choices ) );
|
||||
}
|
||||
|
||||
editor = tinyMCE.get( id );
|
||||
|
||||
if ( editor ) {
|
||||
editor.onChange.add( function( ed ) {
|
||||
var content;
|
||||
|
||||
ed.save();
|
||||
content = editor.getContent();
|
||||
element.val( content ).trigger( 'change' );
|
||||
wp.customize.instance( control.id ).set( content );
|
||||
} );
|
||||
}
|
||||
}
|
||||
} );
|
|
@ -0,0 +1,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,61 @@
|
|||
# control-fontawesome
|
||||
|
||||
## Installation
|
||||
|
||||
First, install the package using composer:
|
||||
|
||||
```bash
|
||||
composer require kirki-framework/control-generic
|
||||
```
|
||||
|
||||
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\Generic' );
|
||||
} );
|
||||
|
||||
/**
|
||||
* 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' => '',
|
||||
'transport' => 'refresh', // Or postMessage.
|
||||
'sanitize_callback' => 'sanitize_text_field', // Or a custom sanitization callback.
|
||||
] );
|
||||
|
||||
// Add control.
|
||||
$wp_customize->add_control( new \Kirki\Control\Generic( $wp_customize, 'my_control', [
|
||||
'label' => esc_html__( 'My Control', 'theme_textdomain' ),
|
||||
'section' => 'my_section',
|
||||
'choices' => [
|
||||
'element' => 'input',
|
||||
'type' => 'password',
|
||||
'style' => 'background-color:black;color:red;',
|
||||
'data-foo' => 'bar',
|
||||
],
|
||||
] ) );
|
||||
} );
|
||||
```
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue