flexible-shipping
/
vendor_prefixed
/
wpdesk
/
wp-pointer
/
src
/
WPDesk
/
Pointer
/
PointersScripts.php
views
2 weeks ago
PointerConditions.php
2 weeks ago
PointerMessage.php
2 weeks ago
PointerPosition.php
2 weeks ago
PointersScripts.php
2 weeks ago
PointersScripts.php
52 lines
| 1 | <?php |
| 2 | |
| 3 | namespace FSVendor\WPDesk\Pointer; |
| 4 | |
| 5 | use FSVendor\WPDesk\PluginBuilder\Plugin\Hookable; |
| 6 | /** |
| 7 | * Pointers handler. |
| 8 | * |
| 9 | * @package WPDesk\Pointer |
| 10 | */ |
| 11 | class PointersScripts implements Hookable |
| 12 | { |
| 13 | /** |
| 14 | * @var array |
| 15 | */ |
| 16 | private $enqueueOnScreens = array(); |
| 17 | /** |
| 18 | * PointersScripts constructor. |
| 19 | * |
| 20 | * @param null|string|array $enqueueOnScreens Empty for all screens. |
| 21 | */ |
| 22 | public function __construct($enqueueOnScreens = array()) |
| 23 | { |
| 24 | if (null === $enqueueOnScreens) { |
| 25 | $enqueueOnScreens = array(); |
| 26 | } |
| 27 | if (!is_array($enqueueOnScreens)) { |
| 28 | $enqueueOnScreens = array($enqueueOnScreens); |
| 29 | } |
| 30 | $this->enqueueOnScreens = $enqueueOnScreens; |
| 31 | } |
| 32 | /** |
| 33 | * Hooks. |
| 34 | */ |
| 35 | public function hooks() |
| 36 | { |
| 37 | add_action('admin_enqueue_scripts', array($this, 'enqueueScripts')); |
| 38 | } |
| 39 | /** |
| 40 | * Enqueue scripts. |
| 41 | * |
| 42 | * @param string $hook |
| 43 | */ |
| 44 | public function enqueueScripts($hook) |
| 45 | { |
| 46 | if (count($this->enqueueOnScreens) === 0 || in_array($hook, $this->enqueueOnScreens, \true)) { |
| 47 | wp_enqueue_style('wp-pointer'); |
| 48 | wp_enqueue_script('wp-pointer'); |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 |