PluginProbe ʕ •ᴥ•ʔ
Kirki – Freeform Page Builder, Website Builder & Customizer / 6.0.13
Kirki – Freeform Page Builder, Website Builder & Customizer v6.0.13
6.1.1 6.1.0 6.0.14 6.0.13 6.0.12 6.0.11 6.0.10 6.0.9 6.0.8 6.0.7 6.0.6 6.0.5 6.0.4 6.0.3 6.0.2 6.0.1 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.19 4.0.20 4.0.21 4.0.22 4.0.23 4.0.24 4.1 4.2.0 5.0.0 5.1.0 5.1.1 5.2.0 5.2.1 5.2.2 5.2.3 6.0.0 trunk 3.0.40 3.0.41 3.0.42 3.0.43 3.0.44 3.0.45 3.1.0 3.1.1 3.1.2
kirki / customizer / class-customizer.php
kirki / customizer Last commit date
lib 2 months ago packages 2 weeks ago bootstrap.php 2 months ago class-customizer.php 2 months ago
class-customizer.php
104 lines
1 <?php
2 /**
3 * The Kirki Customizer class.
4 *
5 * @package kirki
6 * @since 5.0.0
7 */
8
9 namespace Kirki;
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 use Kirki\L10n;
16 use Kirki\Compatibility\Modules;
17 use Kirki\Compatibility\Framework;
18 use Kirki\Compatibility\Kirki;
19
20 if (!class_exists(__NAMESPACE__ . '\\Customizer', false)) {
21 /**
22 * The Customizer class.
23 */
24 class Customizer
25 {
26 /**
27 * Init the customizer.
28 *
29 * @return void
30 */
31 public static function init()
32 {
33 require_once __DIR__ . '/lib/class-aricolor.php';
34 require_once __DIR__ . '/lib/class-kirki-color.php';
35 require_once dirname(__DIR__) . '/vendor/autoload.php';
36 require_once __DIR__ . '/bootstrap.php';
37
38 if (!defined('KIRKI_PLUGIN_DIR')) {
39 define('KIRKI_PLUGIN_DIR', dirname(__DIR__));
40 }
41
42 if (!defined('KIRKI_PLUGIN_URL')) {
43 define('KIRKI_PLUGIN_URL', URL::get_from_path(dirname(__DIR__)));
44 }
45
46 // Start Kirki.
47 global $kirki;
48 $kirki = Framework::get_instance();
49
50 // Instantiate the modules.
51 $kirki->modules = new Modules();
52
53 // Instantiate classes.
54 new Kirki();
55 new L10n('kirki', dirname(__DIR__) . '/languages');
56
57 // Add an empty config for global fields.
58 Kirki::add_config('');
59
60 // Load custom config if exists.
61 $custom_config_path = dirname(__DIR__) . '/custom-config.php';
62 if (file_exists($custom_config_path)) {
63 require_once $custom_config_path;
64 }
65 // Load packages.
66 require_once __DIR__ . '/packages/index.php';
67
68 // Handle tests.
69 if (defined('KIRKI_TEST') && true === constant('KIRKI_TEST') && file_exists(__DIR__ . '/example.php')) {
70 include_once __DIR__ . '/example.php';
71 }
72
73 // Enqueue common assets.
74 add_action('customize_controls_enqueue_scripts', [__CLASS__, 'enqueue_assets'], 5);
75 add_action('customize_preview_init', [__CLASS__, 'enqueue_assets'], 5);
76 }
77
78 /**
79 * Enqueue common assets.
80 *
81 * @param array $deps The script dependencies.
82 * @return void
83 */
84 public static function enqueue_assets($deps = [])
85 {
86 // Preview frame is NOT admin, Pane frame IS admin.
87 $is_preview_frame = is_customize_preview() && !is_admin();
88
89 if (empty($deps)) {
90 $deps = ['jquery', 'wp-element'];
91 if ($is_preview_frame) {
92 $deps[] = 'customize-preview';
93 } else {
94 $deps[] = 'customize-controls';
95 }
96 }
97
98 $file = $is_preview_frame ? 'preview' : 'controls';
99
100 wp_enqueue_style('kirki-customizer', URL::get_from_path(dirname(__DIR__) . "/assets/customizer/{$file}.min.css"), [], KIRKI_VERSION);
101 wp_enqueue_script('kirki-customizer', URL::get_from_path(dirname(__DIR__) . "/assets/customizer/{$file}.min.js"), $deps, KIRKI_VERSION, true);
102 }
103 }
104 }