deprecated
1 month ago
Aliases.php
2 months ago
Config.php
5 months ago
Control.php
5 months ago
Deprecated.php
5 months ago
Field.php
2 months ago
Framework.php
5 months ago
Init.php
2 months ago
Kirki.php
2 months ago
Modules.php
2 months ago
Pro_Namespace_Compatibility.php
5 months ago
Sanitize_Values.php
5 months ago
Scripts.php
2 months ago
Settings.php
5 months ago
Values.php
5 months ago
Scripts.php
61 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Registers scripts for WordPress Compatibility with versions prior to WP5.0 |
| 4 | * |
| 5 | * @package Kirki |
| 6 | * @category Core |
| 7 | * @author Themeum |
| 8 | * @copyright Copyright (c) 2023, Themeum |
| 9 | * @license https://opensource.org/licenses/MIT |
| 10 | * @since 0.1 |
| 11 | */ |
| 12 | |
| 13 | namespace Kirki\Compatibility; |
| 14 | |
| 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | exit; |
| 17 | } |
| 18 | |
| 19 | use Kirki\URL; |
| 20 | |
| 21 | /** |
| 22 | * Adds scripts for backwards-compatibility |
| 23 | * |
| 24 | * @since 0.1 |
| 25 | */ |
| 26 | class Scripts { |
| 27 | |
| 28 | /** |
| 29 | * Constructor. |
| 30 | * |
| 31 | * @access public |
| 32 | * @since 0.1 |
| 33 | */ |
| 34 | public function __construct() { |
| 35 | global $wp_version; |
| 36 | |
| 37 | /** |
| 38 | * Check if the WordPress version is lower than 5.0 |
| 39 | * If lower then we need to enqueue the backported scripts. |
| 40 | */ |
| 41 | if ( version_compare( $GLOBALS['wp_version'], '5.0', '<' ) ) { |
| 42 | add_action( 'admin_register_scripts', [ $this, 'register_scripts' ] ); |
| 43 | add_action( 'customize_controls_enqueue_scripts', [ $this, 'register_scripts' ] ); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Enqueue missing WP scripts. |
| 49 | * |
| 50 | * @access public |
| 51 | * @since 0.1 |
| 52 | * @return void |
| 53 | */ |
| 54 | public function register_scripts() { |
| 55 | $folder_url = trailingslashit( URL::get_from_path( __DIR__ ) ); |
| 56 | wp_register_script( 'wp-polyfill', $folder_url . 'scripts/wp-polyfill.js', [], '7.0.0', false ); |
| 57 | wp_register_script( 'wp-hooks', $folder_url . 'scripts/hooks.js', [ 'wp-polyfill' ], '2.2.0', false ); |
| 58 | wp_register_script( 'wp-i18n', $folder_url . 'scripts/i18n.js', [ 'wp-polyfill' ], '3.3.0', false ); |
| 59 | } |
| 60 | |
| 61 | } |