views
1 week ago
Assets.php
1 week ago
OptInOptOut.php
1 week ago
OptInPage.php
1 week ago
OptOut.php
1 week ago
PluginActionLinks.php
1 week ago
Shop.php
1 week ago
Tracker.php
1 week ago
Assets.php
42 lines
| 1 | <?php |
| 2 | |
| 3 | namespace FSVendor\WPDesk\Tracker; |
| 4 | |
| 5 | use FSVendor\WPDesk\PluginBuilder\Plugin\Hookable; |
| 6 | /** |
| 7 | * Can enqueue assets. |
| 8 | */ |
| 9 | class Assets implements Hookable |
| 10 | { |
| 11 | /** |
| 12 | * @var string |
| 13 | */ |
| 14 | private $script_version = '1'; |
| 15 | /** |
| 16 | * @var string |
| 17 | */ |
| 18 | private $plugin_slug; |
| 19 | /** |
| 20 | * @param string $plugin_slug |
| 21 | */ |
| 22 | public function __construct($plugin_slug) |
| 23 | { |
| 24 | $this->plugin_slug = $plugin_slug; |
| 25 | } |
| 26 | public function hooks() |
| 27 | { |
| 28 | add_action('admin_enqueue_scripts', [$this, 'admin_enqueue_scripts']); |
| 29 | } |
| 30 | public function admin_enqueue_scripts() |
| 31 | { |
| 32 | $screen = get_current_screen(); |
| 33 | if ($screen->id === 'admin_page_wpdesk_tracker_' . $this->plugin_slug) { |
| 34 | $handle = 'wpdesk-helper-tracker_' . $this->plugin_slug; |
| 35 | wp_register_style($handle, plugin_dir_url(__FILE__) . '../assets/css/tracker.css', [], $this->script_version); |
| 36 | wp_register_script($handle, plugin_dir_url(__FILE__) . '../assets/js/admin.js', [], $this->script_version); |
| 37 | wp_enqueue_style($handle); |
| 38 | wp_enqueue_script($handle); |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 |