PluginProbe
UpStream: a Project Management Plugin for WordPress / trunk
UpStream: a Project Management Plugin for WordPress vtrunk
trunk 1.39.0 1.39.1 1.39.2 1.39.3 2.0.7 2.1.0
upstream / vendor / alledia / wordpress-plugin-framework / src / library / Module / Assets.php

Assets.php in UpStream: a Project Management Plugin for WordPress trunk, at vendor/alledia/wordpress-plugin-framework/src/library/Module/Assets.php

148 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Allex\Module;
4
5 use Allex\Container;
6
7 class Assets extends Abstract_Module
8 {
9 /**
10 * @var string
11 */
12 protected $assets_base_url;
13
14 /**
15 * @var string
16 */
17 protected $version;
18
19 /**
20 * Assets constructor.
21 *
22 * @param Container $container
23 */
24 public function __construct(Container $container)
25 {
26 parent::__construct($container);
27
28 $this->assets_base_url = $this->container['ASSETS_BASE_URL'];
29 $this->version = $this->container['VERSION'];
30 }
31
32 /**
33 * Initialize the module loading the hooks.
34 */
35 public function init()
36 {
37 $this->init_hooks();
38 }
39
40 /**
41 * Initialize the hooks.
42 */
43 protected function init_hooks()
44 {
45 add_action('admin_enqueue_scripts', [$this, 'admin_enqueue_styles']);
46 add_action('admin_enqueue_scripts', [$this, 'admin_enqueue_scripts']);
47 }
48
49 /**
50 * Enqueue styles for the admin UI.
51 */
52 public function admin_enqueue_styles()
53 {
54 wp_enqueue_style(
55 'allex',
56 $this->assets_base_url . '/css/allex-admin.css',
57 ['allex-font-awesome', 'allex-grid'],
58 $this->version
59 );
60
61 wp_enqueue_style(
62 'allex-grid',
63 $this->assets_base_url . '/css/allex-grid.min.css',
64 [],
65 $this->version
66 );
67
68 wp_enqueue_style(
69 'allex-font-awesome',
70 $this->assets_base_url . '/lib/font-awesome-v5.2.0/css/all.min.css',
71 [],
72 $this->version
73 );
74 }
75
76 /**
77 * Enqueue scripts for the admin UI.
78 */
79 public function admin_enqueue_scripts()
80 {
81 global $wp_scripts;
82
83 if (!isset($wp_scripts->queue['react'])) {
84 wp_enqueue_script(
85 'react',
86 "{$this->assets_base_url}/lib/react.min.js",
87 [],
88 $this->version
89 );
90 wp_enqueue_script(
91 'react-dom',
92 "{$this->assets_base_url}/lib/react-dom.min.js",
93 ['react'],
94 $this->version
95 );
96 }
97
98 wp_enqueue_script(
99 'allex-admin-addons',
100 "{$this->assets_base_url}/js/admin-addons.min.js",
101 ['jquery', 'react', 'react-dom'],
102 $this->version
103 );
104
105 wp_enqueue_script(
106 'allex',
107 $this->assets_base_url . '/js/allex-admin.js',
108 ['jquery', 'react'],
109 $this->version
110 );
111
112 wp_localize_script(
113 'allex-admin-addons',
114 'allexContext',
115 [
116 'labels' => [
117 'installed' => __('Installed Extensions', 'allex'),
118 'browse_more' => __('Browse More Extensions', 'allex'),
119 'enter_license_key' => __('Enter your license key', 'allex'),
120 'activate' => __('Activate', 'allex'),
121 'license_key' => __('License Key', 'allex'),
122 'change' => __('Change', 'allex'),
123 'get_plugins' => __('Get Pro Add-ons!', 'allex'),
124 'please_wait' => __('Please, wait...', 'allex'),
125 'empty_license' => __('Please, enter a license key.', 'allex'),
126 'contact_support' => __(
127 'If the error persists, please contact the support team.',
128 'allex'
129 ),
130 'all_plugins_installed' => __(
131 'Awesome, it seems like you have all the add-ons installed. Thank you for supporting us.',
132 'allex'
133 ),
134 'license_status_invalid' => __('Invalid license', 'allex'),
135 'license_status_valid' => __('Activated', 'allex'),
136 'license_status_missing' => __('This license key was not found.', 'allex'),
137 'license_status_disabled' => __('This license key is disabled.', 'allex'),
138 'license_status_expired' => __('This license key has expired.', 'allex'),
139 'license_status_no_activations_left' => __(
140 'This license key has no activations left. Please, consider upgrading your plan.',
141 'allex'
142 ),
143 ],
144 ]
145 );
146 }
147 }
148