@@ -16,26 +16,26 @@ |
||
16 | 16 | class InvalidCollectionIdentifierException extends OutOfBoundsException |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * InvalidCollectionIdentifierException constructor. |
|
21 | - * |
|
22 | - * @param $identifier |
|
23 | - * @param string $message |
|
24 | - * @param int $code |
|
25 | - * @param Exception|null $previous |
|
26 | - */ |
|
27 | - public function __construct($identifier, $message = '', $code = 0, Exception $previous = null) |
|
28 | - { |
|
29 | - if (empty($message)) { |
|
30 | - $message = sprintf( |
|
31 | - __( |
|
32 | - 'The supplied identifier "%1$s" does not exist within this collection. |
|
19 | + /** |
|
20 | + * InvalidCollectionIdentifierException constructor. |
|
21 | + * |
|
22 | + * @param $identifier |
|
23 | + * @param string $message |
|
24 | + * @param int $code |
|
25 | + * @param Exception|null $previous |
|
26 | + */ |
|
27 | + public function __construct($identifier, $message = '', $code = 0, Exception $previous = null) |
|
28 | + { |
|
29 | + if (empty($message)) { |
|
30 | + $message = sprintf( |
|
31 | + __( |
|
32 | + 'The supplied identifier "%1$s" does not exist within this collection. |
|
33 | 33 | You may need to delay adding this asset until the required dependency has been added.', |
34 | - 'event_espresso' |
|
35 | - ), |
|
36 | - $identifier |
|
37 | - ); |
|
38 | - } |
|
39 | - parent::__construct($message, $code, $previous); |
|
40 | - } |
|
34 | + 'event_espresso' |
|
35 | + ), |
|
36 | + $identifier |
|
37 | + ); |
|
38 | + } |
|
39 | + parent::__construct($message, $code, $previous); |
|
40 | + } |
|
41 | 41 | } |
@@ -16,25 +16,25 @@ |
||
16 | 16 | class DuplicateCollectionIdentifierException extends OutOfRangeException |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * DuplicateCollectionIdentifierException constructor. |
|
21 | - * |
|
22 | - * @param $identifier |
|
23 | - * @param string $message |
|
24 | - * @param int $code |
|
25 | - * @param Exception|null $previous |
|
26 | - */ |
|
27 | - public function __construct($identifier, $message = '', $code = 0, Exception $previous = null) |
|
28 | - { |
|
29 | - if (empty($message)) { |
|
30 | - $message = sprintf( |
|
31 | - __( |
|
32 | - 'The supplied identifier "%1$s" already exists within this collection.', |
|
33 | - 'event_espresso' |
|
34 | - ), |
|
35 | - $identifier |
|
36 | - ); |
|
37 | - } |
|
38 | - parent::__construct($message, $code, $previous); |
|
39 | - } |
|
19 | + /** |
|
20 | + * DuplicateCollectionIdentifierException constructor. |
|
21 | + * |
|
22 | + * @param $identifier |
|
23 | + * @param string $message |
|
24 | + * @param int $code |
|
25 | + * @param Exception|null $previous |
|
26 | + */ |
|
27 | + public function __construct($identifier, $message = '', $code = 0, Exception $previous = null) |
|
28 | + { |
|
29 | + if (empty($message)) { |
|
30 | + $message = sprintf( |
|
31 | + __( |
|
32 | + 'The supplied identifier "%1$s" already exists within this collection.', |
|
33 | + 'event_espresso' |
|
34 | + ), |
|
35 | + $identifier |
|
36 | + ); |
|
37 | + } |
|
38 | + parent::__construct($message, $code, $previous); |
|
39 | + } |
|
40 | 40 | } |
@@ -21,86 +21,86 @@ |
||
21 | 21 | { |
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * AssetCollection constructor |
|
26 | - * |
|
27 | - * @throws InvalidInterfaceException |
|
28 | - */ |
|
29 | - public function __construct() |
|
30 | - { |
|
31 | - parent::__construct('EventEspresso\core\domain\values\assets\Asset'); |
|
32 | - } |
|
24 | + /** |
|
25 | + * AssetCollection constructor |
|
26 | + * |
|
27 | + * @throws InvalidInterfaceException |
|
28 | + */ |
|
29 | + public function __construct() |
|
30 | + { |
|
31 | + parent::__construct('EventEspresso\core\domain\values\assets\Asset'); |
|
32 | + } |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * @return StylesheetAsset[] |
|
37 | - * @since $VID:$ |
|
38 | - */ |
|
39 | - public function getStylesheetAssets() |
|
40 | - { |
|
41 | - return $this->getAssetsOfType(Asset::TYPE_CSS); |
|
42 | - } |
|
35 | + /** |
|
36 | + * @return StylesheetAsset[] |
|
37 | + * @since $VID:$ |
|
38 | + */ |
|
39 | + public function getStylesheetAssets() |
|
40 | + { |
|
41 | + return $this->getAssetsOfType(Asset::TYPE_CSS); |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * @return JavascriptAsset[] |
|
47 | - * @since $VID:$ |
|
48 | - */ |
|
49 | - public function getJavascriptAssets() |
|
50 | - { |
|
51 | - return $this->getAssetsOfType(Asset::TYPE_JS); |
|
52 | - } |
|
45 | + /** |
|
46 | + * @return JavascriptAsset[] |
|
47 | + * @since $VID:$ |
|
48 | + */ |
|
49 | + public function getJavascriptAssets() |
|
50 | + { |
|
51 | + return $this->getAssetsOfType(Asset::TYPE_JS); |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * @return ManifestFile[] |
|
57 | - * @since $VID:$ |
|
58 | - */ |
|
59 | - public function getManifestFiles() |
|
60 | - { |
|
61 | - return $this->getAssetsOfType(Asset::TYPE_MANIFEST); |
|
62 | - } |
|
55 | + /** |
|
56 | + * @return ManifestFile[] |
|
57 | + * @since $VID:$ |
|
58 | + */ |
|
59 | + public function getManifestFiles() |
|
60 | + { |
|
61 | + return $this->getAssetsOfType(Asset::TYPE_MANIFEST); |
|
62 | + } |
|
63 | 63 | |
64 | 64 | |
65 | - /** |
|
66 | - * @param $type |
|
67 | - * @return array |
|
68 | - * @since $VID:$ |
|
69 | - */ |
|
70 | - protected function getAssetsOfType($type) |
|
71 | - { |
|
72 | - $files = array(); |
|
73 | - $this->rewind(); |
|
74 | - while ($this->valid()) { |
|
75 | - /** @var \EventEspresso\core\domain\values\assets\Asset $asset */ |
|
76 | - $asset = $this->current(); |
|
77 | - if ($asset->type() === $type) { |
|
78 | - $files[ $asset->handle() ] = $asset; |
|
79 | - } |
|
80 | - $this->next(); |
|
81 | - } |
|
82 | - $this->rewind(); |
|
83 | - return $files; |
|
84 | - } |
|
65 | + /** |
|
66 | + * @param $type |
|
67 | + * @return array |
|
68 | + * @since $VID:$ |
|
69 | + */ |
|
70 | + protected function getAssetsOfType($type) |
|
71 | + { |
|
72 | + $files = array(); |
|
73 | + $this->rewind(); |
|
74 | + while ($this->valid()) { |
|
75 | + /** @var \EventEspresso\core\domain\values\assets\Asset $asset */ |
|
76 | + $asset = $this->current(); |
|
77 | + if ($asset->type() === $type) { |
|
78 | + $files[ $asset->handle() ] = $asset; |
|
79 | + } |
|
80 | + $this->next(); |
|
81 | + } |
|
82 | + $this->rewind(); |
|
83 | + return $files; |
|
84 | + } |
|
85 | 85 | |
86 | 86 | |
87 | - /** |
|
88 | - * @return JavascriptAsset[] |
|
89 | - * @since $VID:$ |
|
90 | - */ |
|
91 | - public function getJavascriptAssetsWithData() |
|
92 | - { |
|
93 | - $files = array(); |
|
94 | - $this->rewind(); |
|
95 | - while ($this->valid()) { |
|
96 | - /** @var \EventEspresso\core\domain\values\assets\JavascriptAsset $asset */ |
|
97 | - $asset = $this->current(); |
|
98 | - if ($asset->type() === Asset::TYPE_JS && $asset->hasLocalizedData()) { |
|
99 | - $files[ $asset->handle() ] = $asset; |
|
100 | - } |
|
101 | - $this->next(); |
|
102 | - } |
|
103 | - $this->rewind(); |
|
104 | - return $files; |
|
105 | - } |
|
87 | + /** |
|
88 | + * @return JavascriptAsset[] |
|
89 | + * @since $VID:$ |
|
90 | + */ |
|
91 | + public function getJavascriptAssetsWithData() |
|
92 | + { |
|
93 | + $files = array(); |
|
94 | + $this->rewind(); |
|
95 | + while ($this->valid()) { |
|
96 | + /** @var \EventEspresso\core\domain\values\assets\JavascriptAsset $asset */ |
|
97 | + $asset = $this->current(); |
|
98 | + if ($asset->type() === Asset::TYPE_JS && $asset->hasLocalizedData()) { |
|
99 | + $files[ $asset->handle() ] = $asset; |
|
100 | + } |
|
101 | + $this->next(); |
|
102 | + } |
|
103 | + $this->rewind(); |
|
104 | + return $files; |
|
105 | + } |
|
106 | 106 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | /** @var \EventEspresso\core\domain\values\assets\Asset $asset */ |
76 | 76 | $asset = $this->current(); |
77 | 77 | if ($asset->type() === $type) { |
78 | - $files[ $asset->handle() ] = $asset; |
|
78 | + $files[$asset->handle()] = $asset; |
|
79 | 79 | } |
80 | 80 | $this->next(); |
81 | 81 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | /** @var \EventEspresso\core\domain\values\assets\JavascriptAsset $asset */ |
97 | 97 | $asset = $this->current(); |
98 | 98 | if ($asset->type() === Asset::TYPE_JS && $asset->hasLocalizedData()) { |
99 | - $files[ $asset->handle() ] = $asset; |
|
99 | + $files[$asset->handle()] = $asset; |
|
100 | 100 | } |
101 | 101 | $this->next(); |
102 | 102 | } |
@@ -16,28 +16,28 @@ |
||
16 | 16 | class InvalidIdentifierException extends InvalidArgumentException |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * InvalidIdentifierException constructor. |
|
21 | - * |
|
22 | - * @param string $actual the identifier that was supplied |
|
23 | - * @param string $expected example of an acceptable identifier |
|
24 | - * @param string $message |
|
25 | - * @param int $code |
|
26 | - * @param Exception $previous |
|
27 | - */ |
|
28 | - public function __construct($actual, $expected, $message = '', $code = 0, Exception $previous = null) |
|
29 | - { |
|
30 | - if (empty($message)) { |
|
31 | - $message = sprintf( |
|
32 | - __( |
|
33 | - 'The supplied identifier "%1$s" is invalid. A value like "%2$s" was expected.', |
|
34 | - 'event_espresso' |
|
35 | - ), |
|
36 | - $actual, |
|
37 | - $expected |
|
38 | - ); |
|
39 | - } |
|
40 | - parent::__construct($message, $code, $previous); |
|
41 | - } |
|
19 | + /** |
|
20 | + * InvalidIdentifierException constructor. |
|
21 | + * |
|
22 | + * @param string $actual the identifier that was supplied |
|
23 | + * @param string $expected example of an acceptable identifier |
|
24 | + * @param string $message |
|
25 | + * @param int $code |
|
26 | + * @param Exception $previous |
|
27 | + */ |
|
28 | + public function __construct($actual, $expected, $message = '', $code = 0, Exception $previous = null) |
|
29 | + { |
|
30 | + if (empty($message)) { |
|
31 | + $message = sprintf( |
|
32 | + __( |
|
33 | + 'The supplied identifier "%1$s" is invalid. A value like "%2$s" was expected.', |
|
34 | + 'event_espresso' |
|
35 | + ), |
|
36 | + $actual, |
|
37 | + $expected |
|
38 | + ); |
|
39 | + } |
|
40 | + parent::__construct($message, $code, $previous); |
|
41 | + } |
|
42 | 42 | } |
43 | 43 | // Location: core/exceptions/InvalidIdentifierException.php |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | //js.api |
176 | 176 | $this->addJavascript( |
177 | 177 | CoreAssetManager::JS_HANDLE_EE_JS_API, |
178 | - EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
178 | + EE_LIBRARIES_URL.'rest_api/assets/js/eejs-api.min.js', |
|
179 | 179 | array( |
180 | 180 | CoreAssetManager::JS_HANDLE_UNDERSCORE, |
181 | 181 | CoreAssetManager::JS_HANDLE_EE_JS_CORE |
@@ -187,11 +187,11 @@ discard block |
||
187 | 187 | |
188 | 188 | $this->addJavascript( |
189 | 189 | CoreAssetManager::JS_HANDLE_EE_CORE, |
190 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
190 | + EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', |
|
191 | 191 | array(CoreAssetManager::JS_HANDLE_JQUERY) |
192 | 192 | ) |
193 | 193 | ->setLocalizationCallback( |
194 | - function () { |
|
194 | + function() { |
|
195 | 195 | wp_localize_script( |
196 | 196 | CoreAssetManager::JS_HANDLE_EE_CORE, |
197 | 197 | CoreAssetManager::JS_HANDLE_EE_I18N, |
@@ -213,16 +213,16 @@ discard block |
||
213 | 213 | if ($this->template_config->enable_default_style && ! is_admin()) { |
214 | 214 | $this->addStylesheet( |
215 | 215 | CoreAssetManager::CSS_HANDLE_EE_DEFAULT, |
216 | - is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
216 | + is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css') |
|
217 | 217 | ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
218 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
218 | + : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', |
|
219 | 219 | array('dashicons') |
220 | 220 | ); |
221 | 221 | //Load custom style sheet if available |
222 | 222 | if ($this->template_config->custom_style_sheet !== null) { |
223 | 223 | $this->addStylesheet( |
224 | 224 | CoreAssetManager::CSS_HANDLE_EE_CUSTOM, |
225 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
225 | + EVENT_ESPRESSO_UPLOAD_URL.'css/'.$this->template_config->custom_style_sheet, |
|
226 | 226 | array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT) |
227 | 227 | ); |
228 | 228 | } |
@@ -242,14 +242,14 @@ discard block |
||
242 | 242 | { |
243 | 243 | $this->addJavascript( |
244 | 244 | CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
245 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
245 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', |
|
246 | 246 | array(CoreAssetManager::JS_HANDLE_JQUERY) |
247 | 247 | ) |
248 | 248 | ->setVersion('1.15.0'); |
249 | 249 | |
250 | 250 | $this->addJavascript( |
251 | 251 | CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
252 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
252 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js', |
|
253 | 253 | array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
254 | 254 | ) |
255 | 255 | ->setVersion('1.15.0'); |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | // @link http://josscrowcroft.github.io/accounting.js/ |
271 | 271 | $this->addJavascript( |
272 | 272 | CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
273 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
273 | + EE_THIRD_PARTY_URL.'accounting/accounting.js', |
|
274 | 274 | array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
275 | 275 | ) |
276 | 276 | ->setVersion('0.3.2'); |
@@ -278,11 +278,11 @@ discard block |
||
278 | 278 | $currency_config = $this->currency_config; |
279 | 279 | $this->addJavascript( |
280 | 280 | CoreAssetManager::JS_HANDLE_EE_ACCOUNTING, |
281 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
281 | + EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', |
|
282 | 282 | array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
283 | 283 | ) |
284 | 284 | ->setLocalizationCallback( |
285 | - function () use ($currency_config) { |
|
285 | + function() use ($currency_config) { |
|
286 | 286 | wp_localize_script( |
287 | 287 | CoreAssetManager::JS_HANDLE_EE_ACCOUNTING, |
288 | 288 | 'EE_ACCOUNTING_CFG', |
@@ -28,336 +28,336 @@ |
||
28 | 28 | class CoreAssetManager extends AssetManager |
29 | 29 | { |
30 | 30 | |
31 | - // WordPress core / Third party JS asset handles |
|
32 | - const JS_HANDLE_JQUERY = 'jquery'; |
|
33 | - |
|
34 | - const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate'; |
|
35 | - |
|
36 | - const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods'; |
|
37 | - |
|
38 | - const JS_HANDLE_UNDERSCORE = 'underscore'; |
|
39 | - |
|
40 | - const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core'; |
|
41 | - |
|
42 | - // EE JS assets handles |
|
43 | - const JS_HANDLE_EE_MANIFEST = 'ee-manifest'; |
|
44 | - |
|
45 | - const JS_HANDLE_EE_JS_CORE = 'eejs-core'; |
|
46 | - |
|
47 | - const JS_HANDLE_EE_VENDOR_REACT = 'ee-vendor-react'; |
|
48 | - |
|
49 | - const JS_HANDLE_EE_JS_API = 'eejs-api'; |
|
50 | - |
|
51 | - const JS_HANDLE_EE_CORE = 'espresso_core'; |
|
52 | - |
|
53 | - const JS_HANDLE_EE_I18N = 'eei18n'; |
|
54 | - |
|
55 | - const JS_HANDLE_EE_ACCOUNTING = 'ee-accounting'; |
|
56 | - |
|
57 | - const JS_HANDLE_EE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page'; |
|
58 | - |
|
59 | - // EE CSS assets handles |
|
60 | - const CSS_HANDLE_EE_DEFAULT = 'espresso_default'; |
|
61 | - |
|
62 | - const CSS_HANDLE_EE_CUSTOM = 'espresso_custom_css'; |
|
63 | - |
|
64 | - /** |
|
65 | - * @var EE_Currency_Config $currency_config |
|
66 | - */ |
|
67 | - protected $currency_config; |
|
68 | - |
|
69 | - /** |
|
70 | - * @var EE_Template_Config $template_config |
|
71 | - */ |
|
72 | - protected $template_config; |
|
73 | - |
|
74 | - |
|
75 | - /** |
|
76 | - * CoreAssetRegister constructor. |
|
77 | - * |
|
78 | - * @param AssetCollection $assets |
|
79 | - * @param EE_Currency_Config $currency_config |
|
80 | - * @param EE_Template_Config $template_config |
|
81 | - * @param DomainInterface $domain |
|
82 | - * @param Registry $registry |
|
83 | - */ |
|
84 | - public function __construct( |
|
85 | - AssetCollection $assets, |
|
86 | - EE_Currency_Config $currency_config, |
|
87 | - EE_Template_Config $template_config, |
|
88 | - DomainInterface $domain, |
|
89 | - Registry $registry |
|
90 | - ) { |
|
91 | - $this->currency_config = $currency_config; |
|
92 | - $this->template_config = $template_config; |
|
93 | - parent::__construct($domain, $assets, $registry); |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * @since $VID:$ |
|
99 | - * @throws DuplicateCollectionIdentifierException |
|
100 | - * @throws InvalidArgumentException |
|
101 | - * @throws InvalidDataTypeException |
|
102 | - * @throws InvalidEntityException |
|
103 | - */ |
|
104 | - public function addAssets() |
|
105 | - { |
|
106 | - $this->addJavascriptFiles(); |
|
107 | - $this->addStylesheetFiles(); |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - /** |
|
112 | - * @since $VID:$ |
|
113 | - * @throws DuplicateCollectionIdentifierException |
|
114 | - * @throws InvalidArgumentException |
|
115 | - * @throws InvalidDataTypeException |
|
116 | - * @throws InvalidEntityException |
|
117 | - */ |
|
118 | - public function addJavascriptFiles() |
|
119 | - { |
|
120 | - $this->loadCoreJs(); |
|
121 | - $this->loadJqueryValidate(); |
|
122 | - $this->loadAccountingJs(); |
|
123 | - add_action( |
|
124 | - 'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script', |
|
125 | - array($this, 'loadQtipJs') |
|
126 | - ); |
|
127 | - $this->registerAdminAssets(); |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * @since $VID:$ |
|
133 | - * @throws DuplicateCollectionIdentifierException |
|
134 | - * @throws InvalidDataTypeException |
|
135 | - * @throws InvalidEntityException |
|
136 | - */ |
|
137 | - public function addStylesheetFiles() |
|
138 | - { |
|
139 | - $this->loadCoreCss(); |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * core default javascript |
|
145 | - * |
|
146 | - * @since $VID:$ |
|
147 | - * @throws DuplicateCollectionIdentifierException |
|
148 | - * @throws InvalidArgumentException |
|
149 | - * @throws InvalidDataTypeException |
|
150 | - * @throws InvalidEntityException |
|
151 | - */ |
|
152 | - private function loadCoreJs() |
|
153 | - { |
|
154 | - $this->addJavascript( |
|
155 | - CoreAssetManager::JS_HANDLE_EE_MANIFEST, |
|
156 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest') |
|
157 | - ); |
|
158 | - |
|
159 | - $this->addJavascript( |
|
160 | - CoreAssetManager::JS_HANDLE_EE_JS_CORE, |
|
161 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'), |
|
162 | - array(CoreAssetManager::JS_HANDLE_EE_MANIFEST) |
|
163 | - ) |
|
164 | - ->setRequiresTranslation() |
|
165 | - ->setHasLocalizedData(); |
|
166 | - |
|
167 | - $this->addJavascript( |
|
168 | - CoreAssetManager::JS_HANDLE_EE_VENDOR_REACT, |
|
169 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'reactVendor'), |
|
170 | - array(CoreAssetManager::JS_HANDLE_EE_JS_CORE) |
|
171 | - ); |
|
172 | - |
|
173 | - global $wp_version; |
|
174 | - if (version_compare($wp_version, '4.4.0', '>')) { |
|
175 | - //js.api |
|
176 | - $this->addJavascript( |
|
177 | - CoreAssetManager::JS_HANDLE_EE_JS_API, |
|
178 | - EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
179 | - array( |
|
180 | - CoreAssetManager::JS_HANDLE_UNDERSCORE, |
|
181 | - CoreAssetManager::JS_HANDLE_EE_JS_CORE |
|
182 | - ) |
|
183 | - ); |
|
184 | - $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest')); |
|
185 | - $this->registry->addData( |
|
186 | - 'paths', |
|
187 | - array( |
|
188 | - 'rest_route' => rest_url('ee/v4.8.36/'), |
|
189 | - 'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(), |
|
190 | - ) |
|
191 | - ); |
|
192 | - } |
|
193 | - |
|
194 | - $this->addJavascript( |
|
195 | - CoreAssetManager::JS_HANDLE_EE_CORE, |
|
196 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
197 | - array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
198 | - ) |
|
199 | - ->setLocalizationCallback( |
|
200 | - function () { |
|
201 | - wp_localize_script( |
|
202 | - CoreAssetManager::JS_HANDLE_EE_CORE, |
|
203 | - CoreAssetManager::JS_HANDLE_EE_I18N, |
|
204 | - EE_Registry::$i18n_js_strings |
|
205 | - ); |
|
206 | - } |
|
207 | - ); |
|
208 | - } |
|
209 | - |
|
210 | - |
|
211 | - /** |
|
212 | - * @since $VID:$ |
|
213 | - * @throws DuplicateCollectionIdentifierException |
|
214 | - * @throws InvalidDataTypeException |
|
215 | - * @throws InvalidEntityException |
|
216 | - */ |
|
217 | - private function loadCoreCss() |
|
218 | - { |
|
219 | - if ($this->template_config->enable_default_style && ! is_admin()) { |
|
220 | - $this->addStylesheet( |
|
221 | - CoreAssetManager::CSS_HANDLE_EE_DEFAULT, |
|
222 | - is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
223 | - ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
224 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
225 | - array('dashicons') |
|
226 | - ); |
|
227 | - //Load custom style sheet if available |
|
228 | - if ($this->template_config->custom_style_sheet !== null) { |
|
229 | - $this->addStylesheet( |
|
230 | - CoreAssetManager::CSS_HANDLE_EE_CUSTOM, |
|
231 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
232 | - array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT) |
|
233 | - ); |
|
234 | - } |
|
235 | - } |
|
236 | - } |
|
237 | - |
|
238 | - |
|
239 | - /** |
|
240 | - * jQuery Validate for form validation |
|
241 | - * |
|
242 | - * @since $VID:$ |
|
243 | - * @throws DuplicateCollectionIdentifierException |
|
244 | - * @throws InvalidDataTypeException |
|
245 | - * @throws InvalidEntityException |
|
246 | - */ |
|
247 | - private function loadJqueryValidate() |
|
248 | - { |
|
249 | - $this->addJavascript( |
|
250 | - CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
|
251 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
252 | - array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
253 | - ) |
|
254 | - ->setVersion('1.15.0'); |
|
255 | - |
|
256 | - $this->addJavascript( |
|
257 | - CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
|
258 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
259 | - array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
|
260 | - ) |
|
261 | - ->setVersion('1.15.0'); |
|
262 | - } |
|
263 | - |
|
264 | - |
|
265 | - /** |
|
266 | - * accounting.js for performing client-side calculations |
|
267 | - * |
|
268 | - * @since $VID:$ |
|
269 | - * @throws DuplicateCollectionIdentifierException |
|
270 | - * @throws InvalidDataTypeException |
|
271 | - * @throws InvalidEntityException |
|
272 | - */ |
|
273 | - private function loadAccountingJs() |
|
274 | - { |
|
275 | - //accounting.js library |
|
276 | - // @link http://josscrowcroft.github.io/accounting.js/ |
|
277 | - $this->addJavascript( |
|
278 | - CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
|
279 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
280 | - array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
|
281 | - ) |
|
282 | - ->setVersion('0.3.2'); |
|
283 | - |
|
284 | - $currency_config = $this->currency_config; |
|
285 | - $this->addJavascript( |
|
286 | - CoreAssetManager::JS_HANDLE_EE_ACCOUNTING, |
|
287 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
288 | - array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
|
289 | - ) |
|
290 | - ->setLocalizationCallback( |
|
291 | - function () use ($currency_config) { |
|
292 | - wp_localize_script( |
|
293 | - CoreAssetManager::JS_HANDLE_EE_ACCOUNTING, |
|
294 | - 'EE_ACCOUNTING_CFG', |
|
295 | - array( |
|
296 | - 'currency' => array( |
|
297 | - 'symbol' => $currency_config->sign, |
|
298 | - 'format' => array( |
|
299 | - 'pos' => $currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
300 | - 'neg' => $currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
301 | - 'zero' => $currency_config->sign_b4 ? '%s--' : '--%s', |
|
302 | - ), |
|
303 | - 'decimal' => $currency_config->dec_mrk, |
|
304 | - 'thousand' => $currency_config->thsnds, |
|
305 | - 'precision' => $currency_config->dec_plc, |
|
306 | - ), |
|
307 | - 'number' => array( |
|
308 | - 'precision' => $currency_config->dec_plc, |
|
309 | - 'thousand' => $currency_config->thsnds, |
|
310 | - 'decimal' => $currency_config->dec_mrk, |
|
311 | - ), |
|
312 | - ) |
|
313 | - ); |
|
314 | - } |
|
315 | - ) |
|
316 | - ->setVersion(); |
|
317 | - } |
|
318 | - |
|
319 | - |
|
320 | - /** |
|
321 | - * registers assets for cleaning your ears |
|
322 | - * |
|
323 | - * @param JavascriptAsset $script |
|
324 | - */ |
|
325 | - public function loadQtipJs(JavascriptAsset $script) |
|
326 | - { |
|
327 | - // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
328 | - // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
329 | - if ( |
|
330 | - $script->handle() === CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE |
|
331 | - && apply_filters('FHEE_load_qtip', false) |
|
332 | - ) { |
|
333 | - EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
334 | - } |
|
335 | - } |
|
336 | - |
|
337 | - |
|
338 | - /** |
|
339 | - * assets that are used in the WordPress admin |
|
340 | - * |
|
341 | - * @since $VID:$ |
|
342 | - * @throws DuplicateCollectionIdentifierException |
|
343 | - * @throws InvalidDataTypeException |
|
344 | - * @throws InvalidEntityException |
|
345 | - */ |
|
346 | - private function registerAdminAssets() |
|
347 | - { |
|
348 | - $this->addJavascript( |
|
349 | - CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE, |
|
350 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'), |
|
351 | - array( |
|
352 | - CoreAssetManager::JS_HANDLE_JQUERY, |
|
353 | - CoreAssetManager::JS_HANDLE_EE_VENDOR_REACT, |
|
354 | - ) |
|
355 | - ) |
|
356 | - ->setRequiresTranslation(); |
|
357 | - |
|
358 | - $this->addStylesheet( |
|
359 | - CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE, |
|
360 | - $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page') |
|
361 | - ); |
|
362 | - } |
|
31 | + // WordPress core / Third party JS asset handles |
|
32 | + const JS_HANDLE_JQUERY = 'jquery'; |
|
33 | + |
|
34 | + const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate'; |
|
35 | + |
|
36 | + const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods'; |
|
37 | + |
|
38 | + const JS_HANDLE_UNDERSCORE = 'underscore'; |
|
39 | + |
|
40 | + const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core'; |
|
41 | + |
|
42 | + // EE JS assets handles |
|
43 | + const JS_HANDLE_EE_MANIFEST = 'ee-manifest'; |
|
44 | + |
|
45 | + const JS_HANDLE_EE_JS_CORE = 'eejs-core'; |
|
46 | + |
|
47 | + const JS_HANDLE_EE_VENDOR_REACT = 'ee-vendor-react'; |
|
48 | + |
|
49 | + const JS_HANDLE_EE_JS_API = 'eejs-api'; |
|
50 | + |
|
51 | + const JS_HANDLE_EE_CORE = 'espresso_core'; |
|
52 | + |
|
53 | + const JS_HANDLE_EE_I18N = 'eei18n'; |
|
54 | + |
|
55 | + const JS_HANDLE_EE_ACCOUNTING = 'ee-accounting'; |
|
56 | + |
|
57 | + const JS_HANDLE_EE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page'; |
|
58 | + |
|
59 | + // EE CSS assets handles |
|
60 | + const CSS_HANDLE_EE_DEFAULT = 'espresso_default'; |
|
61 | + |
|
62 | + const CSS_HANDLE_EE_CUSTOM = 'espresso_custom_css'; |
|
63 | + |
|
64 | + /** |
|
65 | + * @var EE_Currency_Config $currency_config |
|
66 | + */ |
|
67 | + protected $currency_config; |
|
68 | + |
|
69 | + /** |
|
70 | + * @var EE_Template_Config $template_config |
|
71 | + */ |
|
72 | + protected $template_config; |
|
73 | + |
|
74 | + |
|
75 | + /** |
|
76 | + * CoreAssetRegister constructor. |
|
77 | + * |
|
78 | + * @param AssetCollection $assets |
|
79 | + * @param EE_Currency_Config $currency_config |
|
80 | + * @param EE_Template_Config $template_config |
|
81 | + * @param DomainInterface $domain |
|
82 | + * @param Registry $registry |
|
83 | + */ |
|
84 | + public function __construct( |
|
85 | + AssetCollection $assets, |
|
86 | + EE_Currency_Config $currency_config, |
|
87 | + EE_Template_Config $template_config, |
|
88 | + DomainInterface $domain, |
|
89 | + Registry $registry |
|
90 | + ) { |
|
91 | + $this->currency_config = $currency_config; |
|
92 | + $this->template_config = $template_config; |
|
93 | + parent::__construct($domain, $assets, $registry); |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * @since $VID:$ |
|
99 | + * @throws DuplicateCollectionIdentifierException |
|
100 | + * @throws InvalidArgumentException |
|
101 | + * @throws InvalidDataTypeException |
|
102 | + * @throws InvalidEntityException |
|
103 | + */ |
|
104 | + public function addAssets() |
|
105 | + { |
|
106 | + $this->addJavascriptFiles(); |
|
107 | + $this->addStylesheetFiles(); |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + /** |
|
112 | + * @since $VID:$ |
|
113 | + * @throws DuplicateCollectionIdentifierException |
|
114 | + * @throws InvalidArgumentException |
|
115 | + * @throws InvalidDataTypeException |
|
116 | + * @throws InvalidEntityException |
|
117 | + */ |
|
118 | + public function addJavascriptFiles() |
|
119 | + { |
|
120 | + $this->loadCoreJs(); |
|
121 | + $this->loadJqueryValidate(); |
|
122 | + $this->loadAccountingJs(); |
|
123 | + add_action( |
|
124 | + 'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script', |
|
125 | + array($this, 'loadQtipJs') |
|
126 | + ); |
|
127 | + $this->registerAdminAssets(); |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * @since $VID:$ |
|
133 | + * @throws DuplicateCollectionIdentifierException |
|
134 | + * @throws InvalidDataTypeException |
|
135 | + * @throws InvalidEntityException |
|
136 | + */ |
|
137 | + public function addStylesheetFiles() |
|
138 | + { |
|
139 | + $this->loadCoreCss(); |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * core default javascript |
|
145 | + * |
|
146 | + * @since $VID:$ |
|
147 | + * @throws DuplicateCollectionIdentifierException |
|
148 | + * @throws InvalidArgumentException |
|
149 | + * @throws InvalidDataTypeException |
|
150 | + * @throws InvalidEntityException |
|
151 | + */ |
|
152 | + private function loadCoreJs() |
|
153 | + { |
|
154 | + $this->addJavascript( |
|
155 | + CoreAssetManager::JS_HANDLE_EE_MANIFEST, |
|
156 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest') |
|
157 | + ); |
|
158 | + |
|
159 | + $this->addJavascript( |
|
160 | + CoreAssetManager::JS_HANDLE_EE_JS_CORE, |
|
161 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'), |
|
162 | + array(CoreAssetManager::JS_HANDLE_EE_MANIFEST) |
|
163 | + ) |
|
164 | + ->setRequiresTranslation() |
|
165 | + ->setHasLocalizedData(); |
|
166 | + |
|
167 | + $this->addJavascript( |
|
168 | + CoreAssetManager::JS_HANDLE_EE_VENDOR_REACT, |
|
169 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'reactVendor'), |
|
170 | + array(CoreAssetManager::JS_HANDLE_EE_JS_CORE) |
|
171 | + ); |
|
172 | + |
|
173 | + global $wp_version; |
|
174 | + if (version_compare($wp_version, '4.4.0', '>')) { |
|
175 | + //js.api |
|
176 | + $this->addJavascript( |
|
177 | + CoreAssetManager::JS_HANDLE_EE_JS_API, |
|
178 | + EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
179 | + array( |
|
180 | + CoreAssetManager::JS_HANDLE_UNDERSCORE, |
|
181 | + CoreAssetManager::JS_HANDLE_EE_JS_CORE |
|
182 | + ) |
|
183 | + ); |
|
184 | + $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest')); |
|
185 | + $this->registry->addData( |
|
186 | + 'paths', |
|
187 | + array( |
|
188 | + 'rest_route' => rest_url('ee/v4.8.36/'), |
|
189 | + 'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(), |
|
190 | + ) |
|
191 | + ); |
|
192 | + } |
|
193 | + |
|
194 | + $this->addJavascript( |
|
195 | + CoreAssetManager::JS_HANDLE_EE_CORE, |
|
196 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
197 | + array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
198 | + ) |
|
199 | + ->setLocalizationCallback( |
|
200 | + function () { |
|
201 | + wp_localize_script( |
|
202 | + CoreAssetManager::JS_HANDLE_EE_CORE, |
|
203 | + CoreAssetManager::JS_HANDLE_EE_I18N, |
|
204 | + EE_Registry::$i18n_js_strings |
|
205 | + ); |
|
206 | + } |
|
207 | + ); |
|
208 | + } |
|
209 | + |
|
210 | + |
|
211 | + /** |
|
212 | + * @since $VID:$ |
|
213 | + * @throws DuplicateCollectionIdentifierException |
|
214 | + * @throws InvalidDataTypeException |
|
215 | + * @throws InvalidEntityException |
|
216 | + */ |
|
217 | + private function loadCoreCss() |
|
218 | + { |
|
219 | + if ($this->template_config->enable_default_style && ! is_admin()) { |
|
220 | + $this->addStylesheet( |
|
221 | + CoreAssetManager::CSS_HANDLE_EE_DEFAULT, |
|
222 | + is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
223 | + ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
224 | + : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
225 | + array('dashicons') |
|
226 | + ); |
|
227 | + //Load custom style sheet if available |
|
228 | + if ($this->template_config->custom_style_sheet !== null) { |
|
229 | + $this->addStylesheet( |
|
230 | + CoreAssetManager::CSS_HANDLE_EE_CUSTOM, |
|
231 | + EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
232 | + array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT) |
|
233 | + ); |
|
234 | + } |
|
235 | + } |
|
236 | + } |
|
237 | + |
|
238 | + |
|
239 | + /** |
|
240 | + * jQuery Validate for form validation |
|
241 | + * |
|
242 | + * @since $VID:$ |
|
243 | + * @throws DuplicateCollectionIdentifierException |
|
244 | + * @throws InvalidDataTypeException |
|
245 | + * @throws InvalidEntityException |
|
246 | + */ |
|
247 | + private function loadJqueryValidate() |
|
248 | + { |
|
249 | + $this->addJavascript( |
|
250 | + CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
|
251 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
252 | + array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
253 | + ) |
|
254 | + ->setVersion('1.15.0'); |
|
255 | + |
|
256 | + $this->addJavascript( |
|
257 | + CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
|
258 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
259 | + array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
|
260 | + ) |
|
261 | + ->setVersion('1.15.0'); |
|
262 | + } |
|
263 | + |
|
264 | + |
|
265 | + /** |
|
266 | + * accounting.js for performing client-side calculations |
|
267 | + * |
|
268 | + * @since $VID:$ |
|
269 | + * @throws DuplicateCollectionIdentifierException |
|
270 | + * @throws InvalidDataTypeException |
|
271 | + * @throws InvalidEntityException |
|
272 | + */ |
|
273 | + private function loadAccountingJs() |
|
274 | + { |
|
275 | + //accounting.js library |
|
276 | + // @link http://josscrowcroft.github.io/accounting.js/ |
|
277 | + $this->addJavascript( |
|
278 | + CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
|
279 | + EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
280 | + array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
|
281 | + ) |
|
282 | + ->setVersion('0.3.2'); |
|
283 | + |
|
284 | + $currency_config = $this->currency_config; |
|
285 | + $this->addJavascript( |
|
286 | + CoreAssetManager::JS_HANDLE_EE_ACCOUNTING, |
|
287 | + EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
288 | + array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
|
289 | + ) |
|
290 | + ->setLocalizationCallback( |
|
291 | + function () use ($currency_config) { |
|
292 | + wp_localize_script( |
|
293 | + CoreAssetManager::JS_HANDLE_EE_ACCOUNTING, |
|
294 | + 'EE_ACCOUNTING_CFG', |
|
295 | + array( |
|
296 | + 'currency' => array( |
|
297 | + 'symbol' => $currency_config->sign, |
|
298 | + 'format' => array( |
|
299 | + 'pos' => $currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
300 | + 'neg' => $currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
301 | + 'zero' => $currency_config->sign_b4 ? '%s--' : '--%s', |
|
302 | + ), |
|
303 | + 'decimal' => $currency_config->dec_mrk, |
|
304 | + 'thousand' => $currency_config->thsnds, |
|
305 | + 'precision' => $currency_config->dec_plc, |
|
306 | + ), |
|
307 | + 'number' => array( |
|
308 | + 'precision' => $currency_config->dec_plc, |
|
309 | + 'thousand' => $currency_config->thsnds, |
|
310 | + 'decimal' => $currency_config->dec_mrk, |
|
311 | + ), |
|
312 | + ) |
|
313 | + ); |
|
314 | + } |
|
315 | + ) |
|
316 | + ->setVersion(); |
|
317 | + } |
|
318 | + |
|
319 | + |
|
320 | + /** |
|
321 | + * registers assets for cleaning your ears |
|
322 | + * |
|
323 | + * @param JavascriptAsset $script |
|
324 | + */ |
|
325 | + public function loadQtipJs(JavascriptAsset $script) |
|
326 | + { |
|
327 | + // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
328 | + // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
329 | + if ( |
|
330 | + $script->handle() === CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE |
|
331 | + && apply_filters('FHEE_load_qtip', false) |
|
332 | + ) { |
|
333 | + EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
334 | + } |
|
335 | + } |
|
336 | + |
|
337 | + |
|
338 | + /** |
|
339 | + * assets that are used in the WordPress admin |
|
340 | + * |
|
341 | + * @since $VID:$ |
|
342 | + * @throws DuplicateCollectionIdentifierException |
|
343 | + * @throws InvalidDataTypeException |
|
344 | + * @throws InvalidEntityException |
|
345 | + */ |
|
346 | + private function registerAdminAssets() |
|
347 | + { |
|
348 | + $this->addJavascript( |
|
349 | + CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE, |
|
350 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'), |
|
351 | + array( |
|
352 | + CoreAssetManager::JS_HANDLE_JQUERY, |
|
353 | + CoreAssetManager::JS_HANDLE_EE_VENDOR_REACT, |
|
354 | + ) |
|
355 | + ) |
|
356 | + ->setRequiresTranslation(); |
|
357 | + |
|
358 | + $this->addStylesheet( |
|
359 | + CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE, |
|
360 | + $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page') |
|
361 | + ); |
|
362 | + } |
|
363 | 363 | } |
@@ -16,26 +16,26 @@ |
||
16 | 16 | class ManifestFile extends Asset |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * Asset constructor. |
|
21 | - * |
|
22 | - * @param DomainInterface $domain |
|
23 | - * @throws InvalidDataTypeException |
|
24 | - */ |
|
25 | - public function __construct(DomainInterface $domain) |
|
26 | - { |
|
27 | - parent::__construct(Asset::TYPE_MANIFEST, $domain->assetNamespace(), $domain); |
|
28 | - } |
|
29 | - |
|
30 | - |
|
31 | - public function urlBase() |
|
32 | - { |
|
33 | - return $this->domain->distributionAssetsUrl(); |
|
34 | - } |
|
35 | - |
|
36 | - |
|
37 | - public function filepath() |
|
38 | - { |
|
39 | - return $this->domain->distributionAssetsPath(); |
|
40 | - } |
|
19 | + /** |
|
20 | + * Asset constructor. |
|
21 | + * |
|
22 | + * @param DomainInterface $domain |
|
23 | + * @throws InvalidDataTypeException |
|
24 | + */ |
|
25 | + public function __construct(DomainInterface $domain) |
|
26 | + { |
|
27 | + parent::__construct(Asset::TYPE_MANIFEST, $domain->assetNamespace(), $domain); |
|
28 | + } |
|
29 | + |
|
30 | + |
|
31 | + public function urlBase() |
|
32 | + { |
|
33 | + return $this->domain->distributionAssetsUrl(); |
|
34 | + } |
|
35 | + |
|
36 | + |
|
37 | + public function filepath() |
|
38 | + { |
|
39 | + return $this->domain->distributionAssetsPath(); |
|
40 | + } |
|
41 | 41 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | private function setType($type) |
84 | 84 | { |
85 | - if (! in_array($type, $this->validAssetTypes(), true)) { |
|
85 | + if ( ! in_array($type, $this->validAssetTypes(), true)) { |
|
86 | 86 | throw new InvalidDataTypeException( |
87 | 87 | 'Asset::$type', |
88 | 88 | $type, |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | private function setHandle($handle) |
101 | 101 | { |
102 | - if (! is_string($handle)) { |
|
102 | + if ( ! is_string($handle)) { |
|
103 | 103 | throw new InvalidDataTypeException( |
104 | 104 | '$handle', |
105 | 105 | $handle, |
@@ -16,154 +16,154 @@ |
||
16 | 16 | abstract class Asset |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * indicates the file extension for a build distribution CSS file |
|
21 | - */ |
|
22 | - const FILE_EXTENSION_DISTRIBUTION_CSS = '.dist.css'; |
|
23 | - |
|
24 | - /** |
|
25 | - * indicates the file extension for a build distribution JS file |
|
26 | - */ |
|
27 | - const FILE_EXTENSION_DISTRIBUTION_JS = '.dist.js'; |
|
28 | - |
|
29 | - /** |
|
30 | - * indicates a Cascading Style Sheet asset |
|
31 | - */ |
|
32 | - const TYPE_CSS = 'css'; |
|
33 | - |
|
34 | - /** |
|
35 | - * indicates a Javascript asset |
|
36 | - */ |
|
37 | - const TYPE_JS = 'js'; |
|
38 | - |
|
39 | - /** |
|
40 | - * indicates a Javascript manifest file |
|
41 | - */ |
|
42 | - const TYPE_MANIFEST = 'manifest'; |
|
43 | - |
|
44 | - /** |
|
45 | - * @var DomainInterface $domain |
|
46 | - */ |
|
47 | - protected $domain; |
|
48 | - |
|
49 | - /** |
|
50 | - * @var string $type |
|
51 | - */ |
|
52 | - private $type; |
|
53 | - |
|
54 | - /** |
|
55 | - * @var string $handle |
|
56 | - */ |
|
57 | - private $handle; |
|
58 | - |
|
59 | - /** |
|
60 | - * @var bool $registered |
|
61 | - */ |
|
62 | - private $registered = false; |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * Asset constructor. |
|
67 | - * |
|
68 | - * @param $type |
|
69 | - * @param string $handle |
|
70 | - * @param DomainInterface $domain |
|
71 | - * @throws InvalidDataTypeException |
|
72 | - */ |
|
73 | - public function __construct($type, $handle, DomainInterface $domain) |
|
74 | - { |
|
75 | - $this->domain = $domain; |
|
76 | - $this->setType($type); |
|
77 | - $this->setHandle($handle); |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * @return array |
|
83 | - */ |
|
84 | - public function validAssetTypes() |
|
85 | - { |
|
86 | - return array( |
|
87 | - Asset::TYPE_CSS, |
|
88 | - Asset::TYPE_JS, |
|
89 | - Asset::TYPE_MANIFEST, |
|
90 | - ); |
|
91 | - } |
|
92 | - |
|
93 | - |
|
94 | - /** |
|
95 | - * @param string $type |
|
96 | - * @throws InvalidDataTypeException |
|
97 | - */ |
|
98 | - private function setType($type) |
|
99 | - { |
|
100 | - if (! in_array($type, $this->validAssetTypes(), true)) { |
|
101 | - throw new InvalidDataTypeException( |
|
102 | - 'Asset::$type', |
|
103 | - $type, |
|
104 | - 'one of the TYPE_* class constants on \EventEspresso\core\domain\values\Asset is required' |
|
105 | - ); |
|
106 | - } |
|
107 | - $this->type = $type; |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - /** |
|
112 | - * @param string $handle |
|
113 | - * @throws InvalidDataTypeException |
|
114 | - */ |
|
115 | - private function setHandle($handle) |
|
116 | - { |
|
117 | - if (! is_string($handle)) { |
|
118 | - throw new InvalidDataTypeException( |
|
119 | - '$handle', |
|
120 | - $handle, |
|
121 | - 'string' |
|
122 | - ); |
|
123 | - } |
|
124 | - $this->handle = $handle; |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * @return string |
|
130 | - */ |
|
131 | - public function assetNamespace() |
|
132 | - { |
|
133 | - return $this->domain->assetNamespace(); |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - /** |
|
138 | - * @return string |
|
139 | - */ |
|
140 | - public function type() |
|
141 | - { |
|
142 | - return $this->type; |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * @return string |
|
148 | - */ |
|
149 | - public function handle() |
|
150 | - { |
|
151 | - return $this->handle; |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * @return bool |
|
156 | - */ |
|
157 | - public function isRegistered() |
|
158 | - { |
|
159 | - return $this->registered; |
|
160 | - } |
|
161 | - |
|
162 | - /** |
|
163 | - * @param bool $registered |
|
164 | - */ |
|
165 | - public function setRegistered($registered = true) |
|
166 | - { |
|
167 | - $this->registered = filter_var($registered, FILTER_VALIDATE_BOOLEAN); |
|
168 | - } |
|
19 | + /** |
|
20 | + * indicates the file extension for a build distribution CSS file |
|
21 | + */ |
|
22 | + const FILE_EXTENSION_DISTRIBUTION_CSS = '.dist.css'; |
|
23 | + |
|
24 | + /** |
|
25 | + * indicates the file extension for a build distribution JS file |
|
26 | + */ |
|
27 | + const FILE_EXTENSION_DISTRIBUTION_JS = '.dist.js'; |
|
28 | + |
|
29 | + /** |
|
30 | + * indicates a Cascading Style Sheet asset |
|
31 | + */ |
|
32 | + const TYPE_CSS = 'css'; |
|
33 | + |
|
34 | + /** |
|
35 | + * indicates a Javascript asset |
|
36 | + */ |
|
37 | + const TYPE_JS = 'js'; |
|
38 | + |
|
39 | + /** |
|
40 | + * indicates a Javascript manifest file |
|
41 | + */ |
|
42 | + const TYPE_MANIFEST = 'manifest'; |
|
43 | + |
|
44 | + /** |
|
45 | + * @var DomainInterface $domain |
|
46 | + */ |
|
47 | + protected $domain; |
|
48 | + |
|
49 | + /** |
|
50 | + * @var string $type |
|
51 | + */ |
|
52 | + private $type; |
|
53 | + |
|
54 | + /** |
|
55 | + * @var string $handle |
|
56 | + */ |
|
57 | + private $handle; |
|
58 | + |
|
59 | + /** |
|
60 | + * @var bool $registered |
|
61 | + */ |
|
62 | + private $registered = false; |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * Asset constructor. |
|
67 | + * |
|
68 | + * @param $type |
|
69 | + * @param string $handle |
|
70 | + * @param DomainInterface $domain |
|
71 | + * @throws InvalidDataTypeException |
|
72 | + */ |
|
73 | + public function __construct($type, $handle, DomainInterface $domain) |
|
74 | + { |
|
75 | + $this->domain = $domain; |
|
76 | + $this->setType($type); |
|
77 | + $this->setHandle($handle); |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * @return array |
|
83 | + */ |
|
84 | + public function validAssetTypes() |
|
85 | + { |
|
86 | + return array( |
|
87 | + Asset::TYPE_CSS, |
|
88 | + Asset::TYPE_JS, |
|
89 | + Asset::TYPE_MANIFEST, |
|
90 | + ); |
|
91 | + } |
|
92 | + |
|
93 | + |
|
94 | + /** |
|
95 | + * @param string $type |
|
96 | + * @throws InvalidDataTypeException |
|
97 | + */ |
|
98 | + private function setType($type) |
|
99 | + { |
|
100 | + if (! in_array($type, $this->validAssetTypes(), true)) { |
|
101 | + throw new InvalidDataTypeException( |
|
102 | + 'Asset::$type', |
|
103 | + $type, |
|
104 | + 'one of the TYPE_* class constants on \EventEspresso\core\domain\values\Asset is required' |
|
105 | + ); |
|
106 | + } |
|
107 | + $this->type = $type; |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + /** |
|
112 | + * @param string $handle |
|
113 | + * @throws InvalidDataTypeException |
|
114 | + */ |
|
115 | + private function setHandle($handle) |
|
116 | + { |
|
117 | + if (! is_string($handle)) { |
|
118 | + throw new InvalidDataTypeException( |
|
119 | + '$handle', |
|
120 | + $handle, |
|
121 | + 'string' |
|
122 | + ); |
|
123 | + } |
|
124 | + $this->handle = $handle; |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * @return string |
|
130 | + */ |
|
131 | + public function assetNamespace() |
|
132 | + { |
|
133 | + return $this->domain->assetNamespace(); |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + /** |
|
138 | + * @return string |
|
139 | + */ |
|
140 | + public function type() |
|
141 | + { |
|
142 | + return $this->type; |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * @return string |
|
148 | + */ |
|
149 | + public function handle() |
|
150 | + { |
|
151 | + return $this->handle; |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * @return bool |
|
156 | + */ |
|
157 | + public function isRegistered() |
|
158 | + { |
|
159 | + return $this->registered; |
|
160 | + } |
|
161 | + |
|
162 | + /** |
|
163 | + * @param bool $registered |
|
164 | + */ |
|
165 | + public function setRegistered($registered = true) |
|
166 | + { |
|
167 | + $this->registered = filter_var($registered, FILTER_VALIDATE_BOOLEAN); |
|
168 | + } |
|
169 | 169 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | private function setSource($source) |
95 | 95 | { |
96 | - if (! is_string($source)) { |
|
96 | + if ( ! is_string($source)) { |
|
97 | 97 | throw new InvalidDataTypeException( |
98 | 98 | '$source', |
99 | 99 | $source, |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function setVersion($version = EVENT_ESPRESSO_VERSION) |
128 | 128 | { |
129 | - if (! is_string($version)) { |
|
129 | + if ( ! is_string($version)) { |
|
130 | 130 | throw new InvalidDataTypeException( |
131 | 131 | '$version', |
132 | 132 | $version, |
@@ -16,136 +16,136 @@ |
||
16 | 16 | abstract class BrowserAsset extends Asset |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var string $source |
|
21 | - */ |
|
22 | - private $source; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var array $dependencies |
|
26 | - */ |
|
27 | - private $dependencies; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var string $version |
|
31 | - */ |
|
32 | - private $version; |
|
33 | - |
|
34 | - |
|
35 | - /** |
|
36 | - * Asset constructor. |
|
37 | - * |
|
38 | - * @param string $type |
|
39 | - * @param string $handle |
|
40 | - * @param string $source |
|
41 | - * @param array $dependencies |
|
42 | - * @param DomainInterface $domain |
|
43 | - * @throws InvalidDataTypeException |
|
44 | - */ |
|
45 | - public function __construct($type, $handle, $source, array $dependencies, DomainInterface $domain) |
|
46 | - { |
|
47 | - parent::__construct($type, $handle, $domain); |
|
48 | - $this->setSource($source); |
|
49 | - $this->setDependencies($dependencies); |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * @since $VID:$ |
|
55 | - */ |
|
56 | - abstract public function enqueueAsset(); |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * @return array |
|
61 | - */ |
|
62 | - public function dependencies() |
|
63 | - { |
|
64 | - return $this->dependencies; |
|
65 | - } |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * @param array $dependencies |
|
70 | - */ |
|
71 | - private function setDependencies(array $dependencies) |
|
72 | - { |
|
73 | - $this->dependencies = $dependencies; |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * @since $VID:$ |
|
79 | - * @return bool |
|
80 | - */ |
|
81 | - public function hasDependencies() |
|
82 | - { |
|
83 | - return count($this->dependencies) > 0; |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * @return string |
|
89 | - */ |
|
90 | - public function source() |
|
91 | - { |
|
92 | - return $this->source; |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * @param string $source |
|
98 | - * @throws InvalidDataTypeException |
|
99 | - */ |
|
100 | - private function setSource($source) |
|
101 | - { |
|
102 | - if (! is_string($source)) { |
|
103 | - throw new InvalidDataTypeException( |
|
104 | - '$source', |
|
105 | - $source, |
|
106 | - 'string' |
|
107 | - ); |
|
108 | - } |
|
109 | - $this->source = $source; |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * @return string |
|
115 | - * @throws InvalidDataTypeException |
|
116 | - */ |
|
117 | - public function version() |
|
118 | - { |
|
119 | - // if version is NOT set and this asset was NOT built for distribution, |
|
120 | - // then set the version equal to the EE core plugin version |
|
121 | - if ( |
|
122 | - $this->version === null |
|
123 | - && ( |
|
124 | - substr($this->source, -8) !== Asset::FILE_EXTENSION_DISTRIBUTION_JS |
|
125 | - || substr($this->source, -9) !== Asset::FILE_EXTENSION_DISTRIBUTION_CSS |
|
126 | - ) |
|
127 | - ) { |
|
128 | - $this->setVersion(); |
|
129 | - } |
|
130 | - return $this->version; |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * @param string $version |
|
136 | - * @return BrowserAsset |
|
137 | - * @throws InvalidDataTypeException |
|
138 | - */ |
|
139 | - public function setVersion($version = EVENT_ESPRESSO_VERSION) |
|
140 | - { |
|
141 | - if (! is_string($version)) { |
|
142 | - throw new InvalidDataTypeException( |
|
143 | - '$version', |
|
144 | - $version, |
|
145 | - 'string' |
|
146 | - ); |
|
147 | - } |
|
148 | - $this->version = $version; |
|
149 | - return $this; |
|
150 | - } |
|
19 | + /** |
|
20 | + * @var string $source |
|
21 | + */ |
|
22 | + private $source; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var array $dependencies |
|
26 | + */ |
|
27 | + private $dependencies; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var string $version |
|
31 | + */ |
|
32 | + private $version; |
|
33 | + |
|
34 | + |
|
35 | + /** |
|
36 | + * Asset constructor. |
|
37 | + * |
|
38 | + * @param string $type |
|
39 | + * @param string $handle |
|
40 | + * @param string $source |
|
41 | + * @param array $dependencies |
|
42 | + * @param DomainInterface $domain |
|
43 | + * @throws InvalidDataTypeException |
|
44 | + */ |
|
45 | + public function __construct($type, $handle, $source, array $dependencies, DomainInterface $domain) |
|
46 | + { |
|
47 | + parent::__construct($type, $handle, $domain); |
|
48 | + $this->setSource($source); |
|
49 | + $this->setDependencies($dependencies); |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * @since $VID:$ |
|
55 | + */ |
|
56 | + abstract public function enqueueAsset(); |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * @return array |
|
61 | + */ |
|
62 | + public function dependencies() |
|
63 | + { |
|
64 | + return $this->dependencies; |
|
65 | + } |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * @param array $dependencies |
|
70 | + */ |
|
71 | + private function setDependencies(array $dependencies) |
|
72 | + { |
|
73 | + $this->dependencies = $dependencies; |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * @since $VID:$ |
|
79 | + * @return bool |
|
80 | + */ |
|
81 | + public function hasDependencies() |
|
82 | + { |
|
83 | + return count($this->dependencies) > 0; |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * @return string |
|
89 | + */ |
|
90 | + public function source() |
|
91 | + { |
|
92 | + return $this->source; |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * @param string $source |
|
98 | + * @throws InvalidDataTypeException |
|
99 | + */ |
|
100 | + private function setSource($source) |
|
101 | + { |
|
102 | + if (! is_string($source)) { |
|
103 | + throw new InvalidDataTypeException( |
|
104 | + '$source', |
|
105 | + $source, |
|
106 | + 'string' |
|
107 | + ); |
|
108 | + } |
|
109 | + $this->source = $source; |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * @return string |
|
115 | + * @throws InvalidDataTypeException |
|
116 | + */ |
|
117 | + public function version() |
|
118 | + { |
|
119 | + // if version is NOT set and this asset was NOT built for distribution, |
|
120 | + // then set the version equal to the EE core plugin version |
|
121 | + if ( |
|
122 | + $this->version === null |
|
123 | + && ( |
|
124 | + substr($this->source, -8) !== Asset::FILE_EXTENSION_DISTRIBUTION_JS |
|
125 | + || substr($this->source, -9) !== Asset::FILE_EXTENSION_DISTRIBUTION_CSS |
|
126 | + ) |
|
127 | + ) { |
|
128 | + $this->setVersion(); |
|
129 | + } |
|
130 | + return $this->version; |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * @param string $version |
|
136 | + * @return BrowserAsset |
|
137 | + * @throws InvalidDataTypeException |
|
138 | + */ |
|
139 | + public function setVersion($version = EVENT_ESPRESSO_VERSION) |
|
140 | + { |
|
141 | + if (! is_string($version)) { |
|
142 | + throw new InvalidDataTypeException( |
|
143 | + '$version', |
|
144 | + $version, |
|
145 | + 'string' |
|
146 | + ); |
|
147 | + } |
|
148 | + $this->version = $version; |
|
149 | + return $this; |
|
150 | + } |
|
151 | 151 | } |
@@ -54,7 +54,7 @@ |
||
54 | 54 | */ |
55 | 55 | private function setMedia($media) |
56 | 56 | { |
57 | - if (! is_string($media)) { |
|
57 | + if ( ! is_string($media)) { |
|
58 | 58 | throw new InvalidDataTypeException( |
59 | 59 | '$media', |
60 | 60 | $media, |
@@ -16,60 +16,60 @@ |
||
16 | 16 | class StylesheetAsset extends BrowserAsset |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var string $media |
|
21 | - */ |
|
22 | - private $media; |
|
19 | + /** |
|
20 | + * @var string $media |
|
21 | + */ |
|
22 | + private $media; |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * CssFile constructor. |
|
27 | - * |
|
28 | - * @param $handle |
|
29 | - * @param string $source |
|
30 | - * @param array $dependencies |
|
31 | - * @param DomainInterface $domain |
|
32 | - * @param $media |
|
33 | - * @throws InvalidDataTypeException |
|
34 | - */ |
|
35 | - public function __construct($handle, $source, array $dependencies, DomainInterface $domain, $media = 'all') |
|
36 | - { |
|
37 | - parent::__construct(Asset::TYPE_CSS, $handle, $source, $dependencies, $domain); |
|
38 | - $this->setMedia($media); |
|
39 | - } |
|
25 | + /** |
|
26 | + * CssFile constructor. |
|
27 | + * |
|
28 | + * @param $handle |
|
29 | + * @param string $source |
|
30 | + * @param array $dependencies |
|
31 | + * @param DomainInterface $domain |
|
32 | + * @param $media |
|
33 | + * @throws InvalidDataTypeException |
|
34 | + */ |
|
35 | + public function __construct($handle, $source, array $dependencies, DomainInterface $domain, $media = 'all') |
|
36 | + { |
|
37 | + parent::__construct(Asset::TYPE_CSS, $handle, $source, $dependencies, $domain); |
|
38 | + $this->setMedia($media); |
|
39 | + } |
|
40 | 40 | |
41 | 41 | |
42 | - /** |
|
43 | - * @return string |
|
44 | - */ |
|
45 | - public function media() |
|
46 | - { |
|
47 | - return $this->media; |
|
48 | - } |
|
42 | + /** |
|
43 | + * @return string |
|
44 | + */ |
|
45 | + public function media() |
|
46 | + { |
|
47 | + return $this->media; |
|
48 | + } |
|
49 | 49 | |
50 | 50 | |
51 | - /** |
|
52 | - * @param string $media |
|
53 | - * @throws InvalidDataTypeException |
|
54 | - */ |
|
55 | - private function setMedia($media) |
|
56 | - { |
|
57 | - if (! is_string($media)) { |
|
58 | - throw new InvalidDataTypeException( |
|
59 | - '$media', |
|
60 | - $media, |
|
61 | - 'string' |
|
62 | - ); |
|
63 | - } |
|
64 | - $this->media = $media; |
|
65 | - } |
|
51 | + /** |
|
52 | + * @param string $media |
|
53 | + * @throws InvalidDataTypeException |
|
54 | + */ |
|
55 | + private function setMedia($media) |
|
56 | + { |
|
57 | + if (! is_string($media)) { |
|
58 | + throw new InvalidDataTypeException( |
|
59 | + '$media', |
|
60 | + $media, |
|
61 | + 'string' |
|
62 | + ); |
|
63 | + } |
|
64 | + $this->media = $media; |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * @since $VID:$ |
|
70 | - */ |
|
71 | - public function enqueueAsset() |
|
72 | - { |
|
73 | - wp_enqueue_style($this->handle()); |
|
74 | - } |
|
68 | + /** |
|
69 | + * @since $VID:$ |
|
70 | + */ |
|
71 | + public function enqueueAsset() |
|
72 | + { |
|
73 | + wp_enqueue_style($this->handle()); |
|
74 | + } |
|
75 | 75 | } |