2019-02-10 20:21:07 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Automatic field-dependencies scripts calculation for Kirki controls.
|
|
|
|
*
|
|
|
|
* @package Kirki
|
|
|
|
* @category Modules
|
2019-02-17 14:28:35 +01:00
|
|
|
* @author Ari Stathopoulos (@aristath)
|
|
|
|
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
|
2020-02-25 18:04:54 +01:00
|
|
|
* @license https://opensource.org/licenses/MIT
|
2019-02-10 20:21:07 +01:00
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Exit if accessed directly.
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds styles to the customizer.
|
|
|
|
*/
|
|
|
|
class Kirki_Modules_Field_Dependencies {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The object instance.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
* @access private
|
|
|
|
* @since 3.0.0
|
|
|
|
* @var object
|
|
|
|
*/
|
|
|
|
private static $instance;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*
|
|
|
|
* @access protected
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
|
|
|
protected function __construct() {
|
|
|
|
add_action( 'customize_controls_enqueue_scripts', array( $this, 'field_dependencies' ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets an instance of this object.
|
|
|
|
* Prevents duplicate instances which avoid artefacts and improves performance.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
* @access public
|
|
|
|
* @since 3.0.0
|
|
|
|
* @return object
|
|
|
|
*/
|
|
|
|
public static function get_instance() {
|
|
|
|
if ( ! self::$instance ) {
|
|
|
|
self::$instance = new self();
|
|
|
|
}
|
|
|
|
return self::$instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enqueues the field-dependencies script
|
|
|
|
* and adds variables to it using the wp_localize_script function.
|
|
|
|
* The rest is handled via JS.
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function field_dependencies() {
|
|
|
|
wp_enqueue_script( 'kirki_field_dependencies', trailingslashit( Kirki::$url ) . 'modules/field-dependencies/field-dependencies.js', array( 'jquery', 'customize-base', 'customize-controls' ), KIRKI_VERSION, true );
|
|
|
|
}
|
|
|
|
}
|