compatibility
1 month ago
controls
2 months ago
fields
2 months ago
modules
2 months ago
utils
3 weeks ago
autoload.php
5 months ago
index.php
5 months ago
index.php
80 lines
| 1 | <?php |
| 2 | defined( 'ABSPATH' ) || exit; |
| 3 | |
| 4 | if ( ! function_exists( 'kirki_init_controls' ) ) { |
| 5 | |
| 6 | /** |
| 7 | * Init Kirki controls. |
| 8 | */ |
| 9 | function kirki_init_controls() { |
| 10 | |
| 11 | $autoload_path = __DIR__ . '/autoload.php'; |
| 12 | |
| 13 | if ( file_exists( $autoload_path ) ) { |
| 14 | require_once $autoload_path; |
| 15 | } |
| 16 | |
| 17 | // Load Pro namespace compatibility for backward compatibility. |
| 18 | $compatibility_path = __DIR__ . '/compatibility/src/Pro_Namespace_Compatibility.php'; |
| 19 | if ( file_exists( $compatibility_path ) ) { |
| 20 | require_once $compatibility_path; |
| 21 | } |
| 22 | |
| 23 | $packages = array( |
| 24 | __DIR__ . '/controls/headline-divider', |
| 25 | __DIR__ . '/controls/input-slider', |
| 26 | __DIR__ . '/controls/margin-padding', |
| 27 | __DIR__ . '/controls/responsive', |
| 28 | __DIR__ . '/controls/tabs', |
| 29 | ); |
| 30 | |
| 31 | foreach ( $packages as $package ) { |
| 32 | $package_name = basename( $package ); |
| 33 | $init_class_name = str_ireplace( '-', ' ', $package_name ); |
| 34 | $init_class_name = ucwords( $init_class_name ); |
| 35 | $init_class_name = str_ireplace( ' ', '', $init_class_name ); |
| 36 | $init_class_name = '\\Kirki\\' . $init_class_name . '\\Init'; |
| 37 | |
| 38 | $init_file_path = $package . '/' . basename( $package ) . '.php'; |
| 39 | |
| 40 | if ( file_exists( $init_file_path ) ) { |
| 41 | include_once $init_file_path; |
| 42 | } |
| 43 | |
| 44 | if ( class_exists( $init_class_name ) ) { |
| 45 | new $init_class_name(); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | if ( ! function_exists( 'kirki_load_controls' ) ) { |
| 53 | |
| 54 | /** |
| 55 | * Load Kirki controls. |
| 56 | */ |
| 57 | function kirki_load_controls() { |
| 58 | |
| 59 | // Stop, if Kirki is not installed. |
| 60 | if ( ! defined( 'KIRKI_VERSION' ) ) { |
| 61 | return; |
| 62 | } |
| 63 | |
| 64 | // Stop, if Kirki controls are already loaded. |
| 65 | if ( defined( 'KIRKI_CONTROLS_VERSION' ) ) { |
| 66 | return; |
| 67 | } |
| 68 | |
| 69 | $plugin_file = defined( 'KIRKI_PLUGIN_FILE' ) ? KIRKI_PLUGIN_FILE : __FILE__; |
| 70 | define( 'KIRKI_CONTROLS_VERSION', KIRKI_VERSION ); |
| 71 | define( 'KIRKI_CONTROLS_PLUGIN_FILE', $plugin_file ); |
| 72 | |
| 73 | kirki_init_controls(); |
| 74 | |
| 75 | } |
| 76 | |
| 77 | add_action( 'plugins_loaded', 'kirki_load_controls' ); |
| 78 | |
| 79 | } |
| 80 |