| 1 |
<?php |
| 2 |
/** |
| 3 |
* Selection Lite |
| 4 |
* Carefully selected Elementor addons bundle, for building the most awesome websites |
| 5 |
* |
| 6 |
* @encoding UTF-8 |
| 7 |
* @version 1.12 |
| 8 |
* @copyright (C) 2018-2024 Merkulove ( https://merkulov.design/ ). All rights reserved. |
| 9 |
* @license GPLv3 |
| 10 |
* @contributors merkulove, vladcherviakov, phoenixmkua, podolianochka, viktorialev01 |
| 11 |
* @support help@merkulov.design |
| 12 |
**/ |
| 13 |
|
| 14 |
namespace Merkulove\SelectionLite\Unity; |
| 15 |
|
| 16 |
/** Exit if accessed directly. */ |
| 17 |
if ( ! defined( 'ABSPATH' ) ) { |
| 18 |
header( 'Status: 403 Forbidden' ); |
| 19 |
header( 'HTTP/1.1 403 Forbidden' ); |
| 20 |
exit; |
| 21 |
} |
| 22 |
|
| 23 |
/** |
| 24 |
* Class adds admin js scripts. |
| 25 |
* |
| 26 |
* @since 1.0 |
| 27 |
* |
| 28 |
**/ |
| 29 |
final class AdminScripts { |
| 30 |
|
| 31 |
/** |
| 32 |
* The one true AdminScripts. |
| 33 |
* |
| 34 |
* @var AdminScripts |
| 35 |
**/ |
| 36 |
private static $instance; |
| 37 |
|
| 38 |
/** |
| 39 |
* Sets up a new AdminScripts instance. |
| 40 |
* |
| 41 |
* @access public |
| 42 |
**/ |
| 43 |
private function __construct() { |
| 44 |
|
| 45 |
add_action( 'admin_enqueue_scripts', [ $this, 'admin_scripts' ] ); |
| 46 |
|
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* Add JavaScrips for admin area. |
| 51 |
* |
| 52 |
* @return void |
| 53 |
**/ |
| 54 |
public function admin_scripts() { |
| 55 |
|
| 56 |
/** Add scripts on plugin setting page. */ |
| 57 |
$this->settings_scripts(); |
| 58 |
|
| 59 |
} |
| 60 |
|
| 61 |
/** |
| 62 |
* Scripts for plugin setting page. |
| 63 |
* |
| 64 |
* @return void |
| 65 |
**/ |
| 66 |
private function settings_scripts() { |
| 67 |
|
| 68 |
/** Add styles only on setting page */ |
| 69 |
$screen = get_current_screen(); |
| 70 |
if ( null === $screen ) { return; } |
| 71 |
|
| 72 |
/** Add styles only on plugin settings page */ |
| 73 |
if ( ! in_array( $screen->base, Plugin::get_menu_bases(), true ) ) { return; } |
| 74 |
|
| 75 |
wp_enqueue_script( 'mdp-selection-lite-ui', Plugin::get_url() . 'src/Merkulove/Unity/assets/js/merkulov-ui' . Plugin::get_suffix() . '.js', [], Plugin::get_version(), true ); |
| 76 |
wp_enqueue_script( 'mdp-selection-lite-admin', Plugin::get_url() . 'js/admin' . Plugin::get_suffix() . '.js', [ 'jquery' ], Plugin::get_version(), true ); |
| 77 |
|
| 78 |
} |
| 79 |
|
| 80 |
/** |
| 81 |
* Main AdminScripts Instance. |
| 82 |
* Insures that only one instance of AdminScripts exists in memory at any one time. |
| 83 |
* |
| 84 |
* @static |
| 85 |
* @return AdminScripts |
| 86 |
**/ |
| 87 |
public static function get_instance() { |
| 88 |
|
| 89 |
/** @noinspection SelfClassReferencingInspection */ |
| 90 |
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AdminScripts ) ) { |
| 91 |
|
| 92 |
self::$instance = new AdminScripts; |
| 93 |
|
| 94 |
} |
| 95 |
|
| 96 |
return self::$instance; |
| 97 |
|
| 98 |
} |
| 99 |
|
| 100 |
} |
| 101 |
|