@@ -26,704 +26,704 @@ |
||
26 | 26 | class Registry |
27 | 27 | { |
28 | 28 | |
29 | - const ASSET_TYPE_CSS = 'css'; |
|
30 | - const ASSET_TYPE_JS = 'js'; |
|
31 | - const ASSET_NAMESPACE_CORE = 'core'; |
|
32 | - const FILE_NAME_BUILD_MANIFEST = 'build-manifest.json'; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var EE_Template_Config $template_config |
|
36 | - */ |
|
37 | - protected $template_config; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var EE_Currency_Config $currency_config |
|
41 | - */ |
|
42 | - protected $currency_config; |
|
43 | - |
|
44 | - /** |
|
45 | - * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script. |
|
46 | - * |
|
47 | - * @var array |
|
48 | - */ |
|
49 | - protected $jsdata = array(); |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * This keeps track of all scripts with registered data. It is used to prevent duplicate data objects setup in the |
|
54 | - * page source. |
|
55 | - * @var array |
|
56 | - */ |
|
57 | - protected $script_handles_with_data = array(); |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * @var DomainInterface |
|
62 | - */ |
|
63 | - protected $domain; |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * @var I18nRegistry |
|
68 | - */ |
|
69 | - private $i18n_registry; |
|
70 | - |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * Holds the manifest data obtained from registered manifest files. |
|
75 | - * Manifests are maps of asset chunk name to actual built asset file names. |
|
76 | - * Shape of this array is: |
|
77 | - * |
|
78 | - * array( |
|
79 | - * 'some_namespace_slug' => array( |
|
80 | - * 'some_chunk_name' => array( |
|
81 | - * 'js' => 'filename.js' |
|
82 | - * 'css' => 'filename.js' |
|
83 | - * ), |
|
84 | - * 'url_base' => 'https://baseurl.com/to/assets |
|
85 | - * ) |
|
86 | - * ) |
|
87 | - * |
|
88 | - * @var array |
|
89 | - */ |
|
90 | - private $manifest_data = array(); |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * Registry constructor. |
|
95 | - * Hooking into WP actions for script registry. |
|
96 | - * |
|
97 | - * @param EE_Template_Config $template_config |
|
98 | - * @param EE_Currency_Config $currency_config |
|
99 | - * @param I18nRegistry $i18n_registry |
|
100 | - * @param DomainInterface $domain |
|
101 | - * @throws InvalidArgumentException |
|
102 | - * @throws InvalidFilePathException |
|
103 | - */ |
|
104 | - public function __construct( |
|
105 | - EE_Template_Config $template_config, |
|
106 | - EE_Currency_Config $currency_config, |
|
107 | - I18nRegistry $i18n_registry, |
|
108 | - DomainInterface $domain |
|
109 | - ) { |
|
110 | - $this->template_config = $template_config; |
|
111 | - $this->currency_config = $currency_config; |
|
112 | - $this->domain = $domain; |
|
113 | - $this->i18n_registry = $i18n_registry; |
|
114 | - $this->registerManifestFile( |
|
115 | - self::ASSET_NAMESPACE_CORE, |
|
116 | - $this->domain->distributionAssetsUrl(), |
|
117 | - $this->domain->distributionAssetsPath() . self::FILE_NAME_BUILD_MANIFEST |
|
118 | - ); |
|
119 | - add_action('wp_enqueue_scripts', array($this, 'scripts'), 1); |
|
120 | - add_action('admin_enqueue_scripts', array($this, 'scripts'), 1); |
|
121 | - add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 2); |
|
122 | - add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 2); |
|
123 | - add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1); |
|
124 | - add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1); |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * For classes that have Registry as a dependency, this provides a handy way to register script handles for i18n |
|
130 | - * translation handling. |
|
131 | - * |
|
132 | - * @return I18nRegistry |
|
133 | - */ |
|
134 | - public function getI18nRegistry() |
|
135 | - { |
|
136 | - return $this->i18n_registry; |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * Callback for the WP script actions. |
|
141 | - * Used to register globally accessible core scripts. |
|
142 | - * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency. |
|
143 | - * |
|
144 | - */ |
|
145 | - public function scripts() |
|
146 | - { |
|
147 | - global $wp_version; |
|
148 | - wp_register_script( |
|
149 | - 'ee-manifest', |
|
150 | - $this->getJsUrl(self::ASSET_NAMESPACE_CORE, 'manifest'), |
|
151 | - array(), |
|
152 | - null, |
|
153 | - true |
|
154 | - ); |
|
155 | - wp_register_script( |
|
156 | - 'eejs-core', |
|
157 | - $this->getJsUrl(self::ASSET_NAMESPACE_CORE, 'eejs'), |
|
158 | - array('ee-manifest'), |
|
159 | - null, |
|
160 | - true |
|
161 | - ); |
|
162 | - wp_register_script( |
|
163 | - 'ee-vendor-react', |
|
164 | - $this->getJsUrl(self::ASSET_NAMESPACE_CORE, 'reactVendor'), |
|
165 | - array('eejs-core'), |
|
166 | - null, |
|
167 | - true |
|
168 | - ); |
|
169 | - //only run this if WordPress 4.4.0 > is in use. |
|
170 | - if (version_compare($wp_version, '4.4.0', '>')) { |
|
171 | - //js.api |
|
172 | - wp_register_script( |
|
173 | - 'eejs-api', |
|
174 | - EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
175 | - array('underscore', 'eejs-core'), |
|
176 | - EVENT_ESPRESSO_VERSION, |
|
177 | - true |
|
178 | - ); |
|
179 | - $this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest'); |
|
180 | - $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/')); |
|
181 | - } |
|
182 | - if (! is_admin()) { |
|
183 | - $this->loadCoreCss(); |
|
184 | - } |
|
185 | - $this->registerTranslationsForHandles(array('eejs-core')); |
|
186 | - $this->loadCoreJs(); |
|
187 | - $this->loadJqueryValidate(); |
|
188 | - $this->loadAccountingJs(); |
|
189 | - $this->loadQtipJs(); |
|
190 | - $this->registerAdminAssets(); |
|
191 | - } |
|
192 | - |
|
193 | - |
|
194 | - |
|
195 | - /** |
|
196 | - * Call back for the script print in frontend and backend. |
|
197 | - * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point. |
|
198 | - * |
|
199 | - * @since 4.9.31.rc.015 |
|
200 | - */ |
|
201 | - public function enqueueData() |
|
202 | - { |
|
203 | - $this->removeAlreadyRegisteredDataForScriptHandles(); |
|
204 | - wp_add_inline_script( |
|
205 | - 'eejs-core', |
|
206 | - 'var eejsdata=' . wp_json_encode(array('data' => $this->jsdata)), |
|
207 | - 'before' |
|
208 | - ); |
|
209 | - wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
|
210 | - $this->localizeAccountingJs(); |
|
211 | - $this->addRegisteredScriptHandlesWithData('eejs-core'); |
|
212 | - $this->addRegisteredScriptHandlesWithData('espresso_core'); |
|
213 | - } |
|
214 | - |
|
215 | - |
|
216 | - |
|
217 | - /** |
|
218 | - * Used to add data to eejs.data object. |
|
219 | - * Note: Overriding existing data is not allowed. |
|
220 | - * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript. |
|
221 | - * If the data you add is something like this: |
|
222 | - * $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) ); |
|
223 | - * It will be exposed in the page source as: |
|
224 | - * eejs.data.my_plugin_data.foo == gar |
|
225 | - * |
|
226 | - * @param string $key Key used to access your data |
|
227 | - * @param string|array $value Value to attach to key |
|
228 | - * @throws InvalidArgumentException |
|
229 | - */ |
|
230 | - public function addData($key, $value) |
|
231 | - { |
|
232 | - if ($this->verifyDataNotExisting($key)) { |
|
233 | - $this->jsdata[$key] = $value; |
|
234 | - } |
|
235 | - } |
|
236 | - |
|
237 | - |
|
238 | - |
|
239 | - /** |
|
240 | - * Similar to addData except this allows for users to push values to an existing key where the values on key are |
|
241 | - * elements in an array. |
|
242 | - * When you use this method, the value you include will be appended to the end of an array on $key. |
|
243 | - * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript |
|
244 | - * object like this, eejs.data.test = [ my_data, |
|
245 | - * ] |
|
246 | - * If there has already been a scalar value attached to the data object given key, then |
|
247 | - * this will throw an exception. |
|
248 | - * |
|
249 | - * @param string $key Key to attach data to. |
|
250 | - * @param string|array $value Value being registered. |
|
251 | - * @throws InvalidArgumentException |
|
252 | - */ |
|
253 | - public function pushData($key, $value) |
|
254 | - { |
|
255 | - if (isset($this->jsdata[$key]) |
|
256 | - && ! is_array($this->jsdata[$key]) |
|
257 | - ) { |
|
258 | - throw new invalidArgumentException( |
|
259 | - sprintf( |
|
260 | - __( |
|
261 | - 'The value for %1$s is already set and it is not an array. The %2$s method can only be used to |
|
29 | + const ASSET_TYPE_CSS = 'css'; |
|
30 | + const ASSET_TYPE_JS = 'js'; |
|
31 | + const ASSET_NAMESPACE_CORE = 'core'; |
|
32 | + const FILE_NAME_BUILD_MANIFEST = 'build-manifest.json'; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var EE_Template_Config $template_config |
|
36 | + */ |
|
37 | + protected $template_config; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var EE_Currency_Config $currency_config |
|
41 | + */ |
|
42 | + protected $currency_config; |
|
43 | + |
|
44 | + /** |
|
45 | + * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script. |
|
46 | + * |
|
47 | + * @var array |
|
48 | + */ |
|
49 | + protected $jsdata = array(); |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * This keeps track of all scripts with registered data. It is used to prevent duplicate data objects setup in the |
|
54 | + * page source. |
|
55 | + * @var array |
|
56 | + */ |
|
57 | + protected $script_handles_with_data = array(); |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * @var DomainInterface |
|
62 | + */ |
|
63 | + protected $domain; |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * @var I18nRegistry |
|
68 | + */ |
|
69 | + private $i18n_registry; |
|
70 | + |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * Holds the manifest data obtained from registered manifest files. |
|
75 | + * Manifests are maps of asset chunk name to actual built asset file names. |
|
76 | + * Shape of this array is: |
|
77 | + * |
|
78 | + * array( |
|
79 | + * 'some_namespace_slug' => array( |
|
80 | + * 'some_chunk_name' => array( |
|
81 | + * 'js' => 'filename.js' |
|
82 | + * 'css' => 'filename.js' |
|
83 | + * ), |
|
84 | + * 'url_base' => 'https://baseurl.com/to/assets |
|
85 | + * ) |
|
86 | + * ) |
|
87 | + * |
|
88 | + * @var array |
|
89 | + */ |
|
90 | + private $manifest_data = array(); |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * Registry constructor. |
|
95 | + * Hooking into WP actions for script registry. |
|
96 | + * |
|
97 | + * @param EE_Template_Config $template_config |
|
98 | + * @param EE_Currency_Config $currency_config |
|
99 | + * @param I18nRegistry $i18n_registry |
|
100 | + * @param DomainInterface $domain |
|
101 | + * @throws InvalidArgumentException |
|
102 | + * @throws InvalidFilePathException |
|
103 | + */ |
|
104 | + public function __construct( |
|
105 | + EE_Template_Config $template_config, |
|
106 | + EE_Currency_Config $currency_config, |
|
107 | + I18nRegistry $i18n_registry, |
|
108 | + DomainInterface $domain |
|
109 | + ) { |
|
110 | + $this->template_config = $template_config; |
|
111 | + $this->currency_config = $currency_config; |
|
112 | + $this->domain = $domain; |
|
113 | + $this->i18n_registry = $i18n_registry; |
|
114 | + $this->registerManifestFile( |
|
115 | + self::ASSET_NAMESPACE_CORE, |
|
116 | + $this->domain->distributionAssetsUrl(), |
|
117 | + $this->domain->distributionAssetsPath() . self::FILE_NAME_BUILD_MANIFEST |
|
118 | + ); |
|
119 | + add_action('wp_enqueue_scripts', array($this, 'scripts'), 1); |
|
120 | + add_action('admin_enqueue_scripts', array($this, 'scripts'), 1); |
|
121 | + add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 2); |
|
122 | + add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 2); |
|
123 | + add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1); |
|
124 | + add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1); |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * For classes that have Registry as a dependency, this provides a handy way to register script handles for i18n |
|
130 | + * translation handling. |
|
131 | + * |
|
132 | + * @return I18nRegistry |
|
133 | + */ |
|
134 | + public function getI18nRegistry() |
|
135 | + { |
|
136 | + return $this->i18n_registry; |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * Callback for the WP script actions. |
|
141 | + * Used to register globally accessible core scripts. |
|
142 | + * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency. |
|
143 | + * |
|
144 | + */ |
|
145 | + public function scripts() |
|
146 | + { |
|
147 | + global $wp_version; |
|
148 | + wp_register_script( |
|
149 | + 'ee-manifest', |
|
150 | + $this->getJsUrl(self::ASSET_NAMESPACE_CORE, 'manifest'), |
|
151 | + array(), |
|
152 | + null, |
|
153 | + true |
|
154 | + ); |
|
155 | + wp_register_script( |
|
156 | + 'eejs-core', |
|
157 | + $this->getJsUrl(self::ASSET_NAMESPACE_CORE, 'eejs'), |
|
158 | + array('ee-manifest'), |
|
159 | + null, |
|
160 | + true |
|
161 | + ); |
|
162 | + wp_register_script( |
|
163 | + 'ee-vendor-react', |
|
164 | + $this->getJsUrl(self::ASSET_NAMESPACE_CORE, 'reactVendor'), |
|
165 | + array('eejs-core'), |
|
166 | + null, |
|
167 | + true |
|
168 | + ); |
|
169 | + //only run this if WordPress 4.4.0 > is in use. |
|
170 | + if (version_compare($wp_version, '4.4.0', '>')) { |
|
171 | + //js.api |
|
172 | + wp_register_script( |
|
173 | + 'eejs-api', |
|
174 | + EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
175 | + array('underscore', 'eejs-core'), |
|
176 | + EVENT_ESPRESSO_VERSION, |
|
177 | + true |
|
178 | + ); |
|
179 | + $this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest'); |
|
180 | + $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/')); |
|
181 | + } |
|
182 | + if (! is_admin()) { |
|
183 | + $this->loadCoreCss(); |
|
184 | + } |
|
185 | + $this->registerTranslationsForHandles(array('eejs-core')); |
|
186 | + $this->loadCoreJs(); |
|
187 | + $this->loadJqueryValidate(); |
|
188 | + $this->loadAccountingJs(); |
|
189 | + $this->loadQtipJs(); |
|
190 | + $this->registerAdminAssets(); |
|
191 | + } |
|
192 | + |
|
193 | + |
|
194 | + |
|
195 | + /** |
|
196 | + * Call back for the script print in frontend and backend. |
|
197 | + * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point. |
|
198 | + * |
|
199 | + * @since 4.9.31.rc.015 |
|
200 | + */ |
|
201 | + public function enqueueData() |
|
202 | + { |
|
203 | + $this->removeAlreadyRegisteredDataForScriptHandles(); |
|
204 | + wp_add_inline_script( |
|
205 | + 'eejs-core', |
|
206 | + 'var eejsdata=' . wp_json_encode(array('data' => $this->jsdata)), |
|
207 | + 'before' |
|
208 | + ); |
|
209 | + wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
|
210 | + $this->localizeAccountingJs(); |
|
211 | + $this->addRegisteredScriptHandlesWithData('eejs-core'); |
|
212 | + $this->addRegisteredScriptHandlesWithData('espresso_core'); |
|
213 | + } |
|
214 | + |
|
215 | + |
|
216 | + |
|
217 | + /** |
|
218 | + * Used to add data to eejs.data object. |
|
219 | + * Note: Overriding existing data is not allowed. |
|
220 | + * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript. |
|
221 | + * If the data you add is something like this: |
|
222 | + * $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) ); |
|
223 | + * It will be exposed in the page source as: |
|
224 | + * eejs.data.my_plugin_data.foo == gar |
|
225 | + * |
|
226 | + * @param string $key Key used to access your data |
|
227 | + * @param string|array $value Value to attach to key |
|
228 | + * @throws InvalidArgumentException |
|
229 | + */ |
|
230 | + public function addData($key, $value) |
|
231 | + { |
|
232 | + if ($this->verifyDataNotExisting($key)) { |
|
233 | + $this->jsdata[$key] = $value; |
|
234 | + } |
|
235 | + } |
|
236 | + |
|
237 | + |
|
238 | + |
|
239 | + /** |
|
240 | + * Similar to addData except this allows for users to push values to an existing key where the values on key are |
|
241 | + * elements in an array. |
|
242 | + * When you use this method, the value you include will be appended to the end of an array on $key. |
|
243 | + * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript |
|
244 | + * object like this, eejs.data.test = [ my_data, |
|
245 | + * ] |
|
246 | + * If there has already been a scalar value attached to the data object given key, then |
|
247 | + * this will throw an exception. |
|
248 | + * |
|
249 | + * @param string $key Key to attach data to. |
|
250 | + * @param string|array $value Value being registered. |
|
251 | + * @throws InvalidArgumentException |
|
252 | + */ |
|
253 | + public function pushData($key, $value) |
|
254 | + { |
|
255 | + if (isset($this->jsdata[$key]) |
|
256 | + && ! is_array($this->jsdata[$key]) |
|
257 | + ) { |
|
258 | + throw new invalidArgumentException( |
|
259 | + sprintf( |
|
260 | + __( |
|
261 | + 'The value for %1$s is already set and it is not an array. The %2$s method can only be used to |
|
262 | 262 | push values to this data element when it is an array.', |
263 | - 'event_espresso' |
|
264 | - ), |
|
265 | - $key, |
|
266 | - __METHOD__ |
|
267 | - ) |
|
268 | - ); |
|
269 | - } |
|
270 | - $this->jsdata[$key][] = $value; |
|
271 | - } |
|
272 | - |
|
273 | - |
|
274 | - |
|
275 | - /** |
|
276 | - * Used to set content used by javascript for a template. |
|
277 | - * Note: Overrides of existing registered templates are not allowed. |
|
278 | - * |
|
279 | - * @param string $template_reference |
|
280 | - * @param string $template_content |
|
281 | - * @throws InvalidArgumentException |
|
282 | - */ |
|
283 | - public function addTemplate($template_reference, $template_content) |
|
284 | - { |
|
285 | - if (! isset($this->jsdata['templates'])) { |
|
286 | - $this->jsdata['templates'] = array(); |
|
287 | - } |
|
288 | - //no overrides allowed. |
|
289 | - if (isset($this->jsdata['templates'][$template_reference])) { |
|
290 | - throw new invalidArgumentException( |
|
291 | - sprintf( |
|
292 | - __( |
|
293 | - 'The %1$s key already exists for the templates array in the js data array. No overrides are allowed.', |
|
294 | - 'event_espresso' |
|
295 | - ), |
|
296 | - $template_reference |
|
297 | - ) |
|
298 | - ); |
|
299 | - } |
|
300 | - $this->jsdata['templates'][$template_reference] = $template_content; |
|
301 | - } |
|
302 | - |
|
303 | - |
|
304 | - |
|
305 | - /** |
|
306 | - * Retrieve the template content already registered for the given reference. |
|
307 | - * |
|
308 | - * @param string $template_reference |
|
309 | - * @return string |
|
310 | - */ |
|
311 | - public function getTemplate($template_reference) |
|
312 | - { |
|
313 | - return isset($this->jsdata['templates'][$template_reference]) |
|
314 | - ? $this->jsdata['templates'][$template_reference] |
|
315 | - : ''; |
|
316 | - } |
|
317 | - |
|
318 | - |
|
319 | - |
|
320 | - /** |
|
321 | - * Retrieve registered data. |
|
322 | - * |
|
323 | - * @param string $key Name of key to attach data to. |
|
324 | - * @return mixed If there is no for the given key, then false is returned. |
|
325 | - */ |
|
326 | - public function getData($key) |
|
327 | - { |
|
328 | - return isset($this->jsdata[$key]) |
|
329 | - ? $this->jsdata[$key] |
|
330 | - : false; |
|
331 | - } |
|
332 | - |
|
333 | - |
|
334 | - /** |
|
335 | - * Get the actual asset path for asset manifests. |
|
336 | - * If there is no asset path found for the given $chunk_name, then the $chunk_name is returned. |
|
337 | - * @param string $namespace The namespace associated with the manifest file hosting the map of chunk_name to actual |
|
338 | - * asset file location. |
|
339 | - * @param string $chunk_name |
|
340 | - * @param string $asset_type |
|
341 | - * @return string |
|
342 | - * @since 4.9.59.p |
|
343 | - */ |
|
344 | - public function getAssetUrl($namespace, $chunk_name, $asset_type) |
|
345 | - { |
|
346 | - $url = isset( |
|
347 | - $this->manifest_data[$namespace][$chunk_name][$asset_type], |
|
348 | - $this->manifest_data[$namespace]['url_base'] |
|
349 | - ) |
|
350 | - ? $this->manifest_data[$namespace]['url_base'] |
|
351 | - . $this->manifest_data[$namespace][$chunk_name][$asset_type] |
|
352 | - : $chunk_name; |
|
353 | - return apply_filters( |
|
354 | - 'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl', |
|
355 | - $url, |
|
356 | - $namespace, |
|
357 | - $chunk_name, |
|
358 | - $asset_type |
|
359 | - ); |
|
360 | - } |
|
361 | - |
|
362 | - |
|
363 | - |
|
364 | - /** |
|
365 | - * Return the url to a js file for the given namespace and chunk name. |
|
366 | - * |
|
367 | - * @param string $namespace |
|
368 | - * @param string $chunk_name |
|
369 | - * @return string |
|
370 | - */ |
|
371 | - public function getJsUrl($namespace, $chunk_name) |
|
372 | - { |
|
373 | - return $this->getAssetUrl($namespace, $chunk_name, self::ASSET_TYPE_JS); |
|
374 | - } |
|
375 | - |
|
376 | - |
|
377 | - /** |
|
378 | - * Return the url to a css file for the given namespace and chunk name. |
|
379 | - * |
|
380 | - * @param string $namespace |
|
381 | - * @param string $chunk_name |
|
382 | - * @return string |
|
383 | - */ |
|
384 | - public function getCssUrl($namespace, $chunk_name) |
|
385 | - { |
|
386 | - return $this->getAssetUrl($namespace, $chunk_name, self::ASSET_TYPE_CSS); |
|
387 | - } |
|
388 | - |
|
389 | - |
|
390 | - /** |
|
391 | - * Used to register a js/css manifest file with the registered_manifest_files property. |
|
392 | - * |
|
393 | - * @param string $namespace Provided to associate the manifest file with a specific namespace. |
|
394 | - * @param string $url_base The url base for the manifest file location. |
|
395 | - * @param string $manifest_file The absolute path to the manifest file. |
|
396 | - * @throws InvalidArgumentException |
|
397 | - * @throws InvalidFilePathException |
|
398 | - * @since 4.9.59.p |
|
399 | - */ |
|
400 | - public function registerManifestFile($namespace, $url_base, $manifest_file) |
|
401 | - { |
|
402 | - if (isset($this->manifest_data[$namespace])) { |
|
403 | - throw new InvalidArgumentException( |
|
404 | - sprintf( |
|
405 | - esc_html__( |
|
406 | - 'The namespace for this manifest file has already been registered, choose a namespace other than %s', |
|
407 | - 'event_espresso' |
|
408 | - ), |
|
409 | - $namespace |
|
410 | - ) |
|
411 | - ); |
|
412 | - } |
|
413 | - if (filter_var($url_base, FILTER_VALIDATE_URL) === false) { |
|
414 | - if (is_admin()) { |
|
415 | - EE_Error::add_error( |
|
416 | - sprintf( |
|
417 | - esc_html__( |
|
418 | - 'The url given for %1$s assets is invalid. The url provided was: "%2$s". This usually happens when another plugin or theme on a site is using the "%3$s" filter or has an invalid url set for the "%4$s" constant', |
|
419 | - 'event_espresso' |
|
420 | - ), |
|
421 | - 'Event Espresso', |
|
422 | - $url_base, |
|
423 | - 'plugins_url', |
|
424 | - 'WP_PLUGIN_URL' |
|
425 | - ), |
|
426 | - __FILE__, |
|
427 | - __FUNCTION__, |
|
428 | - __LINE__ |
|
429 | - ); |
|
430 | - } |
|
431 | - return; |
|
432 | - } |
|
433 | - $this->manifest_data[$namespace] = $this->decodeManifestFile($manifest_file); |
|
434 | - if (! isset($this->manifest_data[$namespace]['url_base'])) { |
|
435 | - $this->manifest_data[$namespace]['url_base'] = trailingslashit($url_base); |
|
436 | - } |
|
437 | - } |
|
438 | - |
|
439 | - |
|
440 | - |
|
441 | - /** |
|
442 | - * Decodes json from the provided manifest file. |
|
443 | - * |
|
444 | - * @since 4.9.59.p |
|
445 | - * @param string $manifest_file Path to manifest file. |
|
446 | - * @return array |
|
447 | - * @throws InvalidFilePathException |
|
448 | - */ |
|
449 | - private function decodeManifestFile($manifest_file) |
|
450 | - { |
|
451 | - if (! file_exists($manifest_file)) { |
|
452 | - throw new InvalidFilePathException($manifest_file); |
|
453 | - } |
|
454 | - return json_decode(file_get_contents($manifest_file), true); |
|
455 | - } |
|
456 | - |
|
457 | - |
|
458 | - |
|
459 | - /** |
|
460 | - * Verifies whether the given data exists already on the jsdata array. |
|
461 | - * Overriding data is not allowed. |
|
462 | - * |
|
463 | - * @param string $key Index for data. |
|
464 | - * @return bool If valid then return true. |
|
465 | - * @throws InvalidArgumentException if data already exists. |
|
466 | - */ |
|
467 | - protected function verifyDataNotExisting($key) |
|
468 | - { |
|
469 | - if (isset($this->jsdata[$key])) { |
|
470 | - if (is_array($this->jsdata[$key])) { |
|
471 | - throw new InvalidArgumentException( |
|
472 | - sprintf( |
|
473 | - __( |
|
474 | - 'The value for %1$s already exists in the Registry::eejs object. |
|
263 | + 'event_espresso' |
|
264 | + ), |
|
265 | + $key, |
|
266 | + __METHOD__ |
|
267 | + ) |
|
268 | + ); |
|
269 | + } |
|
270 | + $this->jsdata[$key][] = $value; |
|
271 | + } |
|
272 | + |
|
273 | + |
|
274 | + |
|
275 | + /** |
|
276 | + * Used to set content used by javascript for a template. |
|
277 | + * Note: Overrides of existing registered templates are not allowed. |
|
278 | + * |
|
279 | + * @param string $template_reference |
|
280 | + * @param string $template_content |
|
281 | + * @throws InvalidArgumentException |
|
282 | + */ |
|
283 | + public function addTemplate($template_reference, $template_content) |
|
284 | + { |
|
285 | + if (! isset($this->jsdata['templates'])) { |
|
286 | + $this->jsdata['templates'] = array(); |
|
287 | + } |
|
288 | + //no overrides allowed. |
|
289 | + if (isset($this->jsdata['templates'][$template_reference])) { |
|
290 | + throw new invalidArgumentException( |
|
291 | + sprintf( |
|
292 | + __( |
|
293 | + 'The %1$s key already exists for the templates array in the js data array. No overrides are allowed.', |
|
294 | + 'event_espresso' |
|
295 | + ), |
|
296 | + $template_reference |
|
297 | + ) |
|
298 | + ); |
|
299 | + } |
|
300 | + $this->jsdata['templates'][$template_reference] = $template_content; |
|
301 | + } |
|
302 | + |
|
303 | + |
|
304 | + |
|
305 | + /** |
|
306 | + * Retrieve the template content already registered for the given reference. |
|
307 | + * |
|
308 | + * @param string $template_reference |
|
309 | + * @return string |
|
310 | + */ |
|
311 | + public function getTemplate($template_reference) |
|
312 | + { |
|
313 | + return isset($this->jsdata['templates'][$template_reference]) |
|
314 | + ? $this->jsdata['templates'][$template_reference] |
|
315 | + : ''; |
|
316 | + } |
|
317 | + |
|
318 | + |
|
319 | + |
|
320 | + /** |
|
321 | + * Retrieve registered data. |
|
322 | + * |
|
323 | + * @param string $key Name of key to attach data to. |
|
324 | + * @return mixed If there is no for the given key, then false is returned. |
|
325 | + */ |
|
326 | + public function getData($key) |
|
327 | + { |
|
328 | + return isset($this->jsdata[$key]) |
|
329 | + ? $this->jsdata[$key] |
|
330 | + : false; |
|
331 | + } |
|
332 | + |
|
333 | + |
|
334 | + /** |
|
335 | + * Get the actual asset path for asset manifests. |
|
336 | + * If there is no asset path found for the given $chunk_name, then the $chunk_name is returned. |
|
337 | + * @param string $namespace The namespace associated with the manifest file hosting the map of chunk_name to actual |
|
338 | + * asset file location. |
|
339 | + * @param string $chunk_name |
|
340 | + * @param string $asset_type |
|
341 | + * @return string |
|
342 | + * @since 4.9.59.p |
|
343 | + */ |
|
344 | + public function getAssetUrl($namespace, $chunk_name, $asset_type) |
|
345 | + { |
|
346 | + $url = isset( |
|
347 | + $this->manifest_data[$namespace][$chunk_name][$asset_type], |
|
348 | + $this->manifest_data[$namespace]['url_base'] |
|
349 | + ) |
|
350 | + ? $this->manifest_data[$namespace]['url_base'] |
|
351 | + . $this->manifest_data[$namespace][$chunk_name][$asset_type] |
|
352 | + : $chunk_name; |
|
353 | + return apply_filters( |
|
354 | + 'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl', |
|
355 | + $url, |
|
356 | + $namespace, |
|
357 | + $chunk_name, |
|
358 | + $asset_type |
|
359 | + ); |
|
360 | + } |
|
361 | + |
|
362 | + |
|
363 | + |
|
364 | + /** |
|
365 | + * Return the url to a js file for the given namespace and chunk name. |
|
366 | + * |
|
367 | + * @param string $namespace |
|
368 | + * @param string $chunk_name |
|
369 | + * @return string |
|
370 | + */ |
|
371 | + public function getJsUrl($namespace, $chunk_name) |
|
372 | + { |
|
373 | + return $this->getAssetUrl($namespace, $chunk_name, self::ASSET_TYPE_JS); |
|
374 | + } |
|
375 | + |
|
376 | + |
|
377 | + /** |
|
378 | + * Return the url to a css file for the given namespace and chunk name. |
|
379 | + * |
|
380 | + * @param string $namespace |
|
381 | + * @param string $chunk_name |
|
382 | + * @return string |
|
383 | + */ |
|
384 | + public function getCssUrl($namespace, $chunk_name) |
|
385 | + { |
|
386 | + return $this->getAssetUrl($namespace, $chunk_name, self::ASSET_TYPE_CSS); |
|
387 | + } |
|
388 | + |
|
389 | + |
|
390 | + /** |
|
391 | + * Used to register a js/css manifest file with the registered_manifest_files property. |
|
392 | + * |
|
393 | + * @param string $namespace Provided to associate the manifest file with a specific namespace. |
|
394 | + * @param string $url_base The url base for the manifest file location. |
|
395 | + * @param string $manifest_file The absolute path to the manifest file. |
|
396 | + * @throws InvalidArgumentException |
|
397 | + * @throws InvalidFilePathException |
|
398 | + * @since 4.9.59.p |
|
399 | + */ |
|
400 | + public function registerManifestFile($namespace, $url_base, $manifest_file) |
|
401 | + { |
|
402 | + if (isset($this->manifest_data[$namespace])) { |
|
403 | + throw new InvalidArgumentException( |
|
404 | + sprintf( |
|
405 | + esc_html__( |
|
406 | + 'The namespace for this manifest file has already been registered, choose a namespace other than %s', |
|
407 | + 'event_espresso' |
|
408 | + ), |
|
409 | + $namespace |
|
410 | + ) |
|
411 | + ); |
|
412 | + } |
|
413 | + if (filter_var($url_base, FILTER_VALIDATE_URL) === false) { |
|
414 | + if (is_admin()) { |
|
415 | + EE_Error::add_error( |
|
416 | + sprintf( |
|
417 | + esc_html__( |
|
418 | + 'The url given for %1$s assets is invalid. The url provided was: "%2$s". This usually happens when another plugin or theme on a site is using the "%3$s" filter or has an invalid url set for the "%4$s" constant', |
|
419 | + 'event_espresso' |
|
420 | + ), |
|
421 | + 'Event Espresso', |
|
422 | + $url_base, |
|
423 | + 'plugins_url', |
|
424 | + 'WP_PLUGIN_URL' |
|
425 | + ), |
|
426 | + __FILE__, |
|
427 | + __FUNCTION__, |
|
428 | + __LINE__ |
|
429 | + ); |
|
430 | + } |
|
431 | + return; |
|
432 | + } |
|
433 | + $this->manifest_data[$namespace] = $this->decodeManifestFile($manifest_file); |
|
434 | + if (! isset($this->manifest_data[$namespace]['url_base'])) { |
|
435 | + $this->manifest_data[$namespace]['url_base'] = trailingslashit($url_base); |
|
436 | + } |
|
437 | + } |
|
438 | + |
|
439 | + |
|
440 | + |
|
441 | + /** |
|
442 | + * Decodes json from the provided manifest file. |
|
443 | + * |
|
444 | + * @since 4.9.59.p |
|
445 | + * @param string $manifest_file Path to manifest file. |
|
446 | + * @return array |
|
447 | + * @throws InvalidFilePathException |
|
448 | + */ |
|
449 | + private function decodeManifestFile($manifest_file) |
|
450 | + { |
|
451 | + if (! file_exists($manifest_file)) { |
|
452 | + throw new InvalidFilePathException($manifest_file); |
|
453 | + } |
|
454 | + return json_decode(file_get_contents($manifest_file), true); |
|
455 | + } |
|
456 | + |
|
457 | + |
|
458 | + |
|
459 | + /** |
|
460 | + * Verifies whether the given data exists already on the jsdata array. |
|
461 | + * Overriding data is not allowed. |
|
462 | + * |
|
463 | + * @param string $key Index for data. |
|
464 | + * @return bool If valid then return true. |
|
465 | + * @throws InvalidArgumentException if data already exists. |
|
466 | + */ |
|
467 | + protected function verifyDataNotExisting($key) |
|
468 | + { |
|
469 | + if (isset($this->jsdata[$key])) { |
|
470 | + if (is_array($this->jsdata[$key])) { |
|
471 | + throw new InvalidArgumentException( |
|
472 | + sprintf( |
|
473 | + __( |
|
474 | + 'The value for %1$s already exists in the Registry::eejs object. |
|
475 | 475 | Overrides are not allowed. Since the value of this data is an array, you may want to use the |
476 | 476 | %2$s method to push your value to the array.', |
477 | - 'event_espresso' |
|
478 | - ), |
|
479 | - $key, |
|
480 | - 'pushData()' |
|
481 | - ) |
|
482 | - ); |
|
483 | - } |
|
484 | - throw new InvalidArgumentException( |
|
485 | - sprintf( |
|
486 | - __( |
|
487 | - 'The value for %1$s already exists in the Registry::eejs object. Overrides are not |
|
477 | + 'event_espresso' |
|
478 | + ), |
|
479 | + $key, |
|
480 | + 'pushData()' |
|
481 | + ) |
|
482 | + ); |
|
483 | + } |
|
484 | + throw new InvalidArgumentException( |
|
485 | + sprintf( |
|
486 | + __( |
|
487 | + 'The value for %1$s already exists in the Registry::eejs object. Overrides are not |
|
488 | 488 | allowed. Consider attaching your value to a different key', |
489 | - 'event_espresso' |
|
490 | - ), |
|
491 | - $key |
|
492 | - ) |
|
493 | - ); |
|
494 | - } |
|
495 | - return true; |
|
496 | - } |
|
497 | - |
|
498 | - |
|
499 | - |
|
500 | - /** |
|
501 | - * registers core default stylesheets |
|
502 | - */ |
|
503 | - private function loadCoreCss() |
|
504 | - { |
|
505 | - if ($this->template_config->enable_default_style) { |
|
506 | - $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
507 | - ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
508 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css'; |
|
509 | - wp_register_style( |
|
510 | - 'espresso_default', |
|
511 | - $default_stylesheet_path, |
|
512 | - array('dashicons'), |
|
513 | - EVENT_ESPRESSO_VERSION |
|
514 | - ); |
|
515 | - //Load custom style sheet if available |
|
516 | - if ($this->template_config->custom_style_sheet !== null) { |
|
517 | - wp_register_style( |
|
518 | - 'espresso_custom_css', |
|
519 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
520 | - array('espresso_default'), |
|
521 | - EVENT_ESPRESSO_VERSION |
|
522 | - ); |
|
523 | - } |
|
524 | - } |
|
525 | - } |
|
526 | - |
|
527 | - |
|
528 | - |
|
529 | - /** |
|
530 | - * registers core default javascript |
|
531 | - */ |
|
532 | - private function loadCoreJs() |
|
533 | - { |
|
534 | - // load core js |
|
535 | - wp_register_script( |
|
536 | - 'espresso_core', |
|
537 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
538 | - array('jquery'), |
|
539 | - EVENT_ESPRESSO_VERSION, |
|
540 | - true |
|
541 | - ); |
|
542 | - } |
|
543 | - |
|
544 | - |
|
545 | - |
|
546 | - /** |
|
547 | - * registers jQuery Validate for form validation |
|
548 | - */ |
|
549 | - private function loadJqueryValidate() |
|
550 | - { |
|
551 | - // register jQuery Validate and additional methods |
|
552 | - wp_register_script( |
|
553 | - 'jquery-validate', |
|
554 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
555 | - array('jquery'), |
|
556 | - '1.15.0', |
|
557 | - true |
|
558 | - ); |
|
559 | - wp_register_script( |
|
560 | - 'jquery-validate-extra-methods', |
|
561 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
562 | - array('jquery', 'jquery-validate'), |
|
563 | - '1.15.0', |
|
564 | - true |
|
565 | - ); |
|
566 | - } |
|
567 | - |
|
568 | - |
|
569 | - |
|
570 | - /** |
|
571 | - * registers accounting.js for performing client-side calculations |
|
572 | - */ |
|
573 | - private function loadAccountingJs() |
|
574 | - { |
|
575 | - //accounting.js library |
|
576 | - // @link http://josscrowcroft.github.io/accounting.js/ |
|
577 | - wp_register_script( |
|
578 | - 'ee-accounting-core', |
|
579 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
580 | - array('underscore'), |
|
581 | - '0.3.2', |
|
582 | - true |
|
583 | - ); |
|
584 | - wp_register_script( |
|
585 | - 'ee-accounting', |
|
586 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
587 | - array('ee-accounting-core'), |
|
588 | - EVENT_ESPRESSO_VERSION, |
|
589 | - true |
|
590 | - ); |
|
591 | - } |
|
592 | - |
|
593 | - |
|
594 | - |
|
595 | - /** |
|
596 | - * registers accounting.js for performing client-side calculations |
|
597 | - */ |
|
598 | - private function localizeAccountingJs() |
|
599 | - { |
|
600 | - wp_localize_script( |
|
601 | - 'ee-accounting', |
|
602 | - 'EE_ACCOUNTING_CFG', |
|
603 | - array( |
|
604 | - 'currency' => array( |
|
605 | - 'symbol' => $this->currency_config->sign, |
|
606 | - 'format' => array( |
|
607 | - 'pos' => $this->currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
608 | - 'neg' => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
609 | - 'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s', |
|
610 | - ), |
|
611 | - 'decimal' => $this->currency_config->dec_mrk, |
|
612 | - 'thousand' => $this->currency_config->thsnds, |
|
613 | - 'precision' => $this->currency_config->dec_plc, |
|
614 | - ), |
|
615 | - 'number' => array( |
|
616 | - 'precision' => $this->currency_config->dec_plc, |
|
617 | - 'thousand' => $this->currency_config->thsnds, |
|
618 | - 'decimal' => $this->currency_config->dec_mrk, |
|
619 | - ), |
|
620 | - ) |
|
621 | - ); |
|
622 | - $this->addRegisteredScriptHandlesWithData('ee-accounting'); |
|
623 | - } |
|
624 | - |
|
625 | - |
|
626 | - |
|
627 | - /** |
|
628 | - * registers assets for cleaning your ears |
|
629 | - */ |
|
630 | - private function loadQtipJs() |
|
631 | - { |
|
632 | - // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
633 | - // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
634 | - if (apply_filters('FHEE_load_qtip', false)) { |
|
635 | - EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
636 | - } |
|
637 | - } |
|
638 | - |
|
639 | - |
|
640 | - /** |
|
641 | - * This is used to set registered script handles that have data. |
|
642 | - * @param string $script_handle |
|
643 | - */ |
|
644 | - private function addRegisteredScriptHandlesWithData($script_handle) |
|
645 | - { |
|
646 | - $this->script_handles_with_data[$script_handle] = $script_handle; |
|
647 | - } |
|
648 | - |
|
649 | - |
|
650 | - /**i |
|
489 | + 'event_espresso' |
|
490 | + ), |
|
491 | + $key |
|
492 | + ) |
|
493 | + ); |
|
494 | + } |
|
495 | + return true; |
|
496 | + } |
|
497 | + |
|
498 | + |
|
499 | + |
|
500 | + /** |
|
501 | + * registers core default stylesheets |
|
502 | + */ |
|
503 | + private function loadCoreCss() |
|
504 | + { |
|
505 | + if ($this->template_config->enable_default_style) { |
|
506 | + $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
507 | + ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
508 | + : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css'; |
|
509 | + wp_register_style( |
|
510 | + 'espresso_default', |
|
511 | + $default_stylesheet_path, |
|
512 | + array('dashicons'), |
|
513 | + EVENT_ESPRESSO_VERSION |
|
514 | + ); |
|
515 | + //Load custom style sheet if available |
|
516 | + if ($this->template_config->custom_style_sheet !== null) { |
|
517 | + wp_register_style( |
|
518 | + 'espresso_custom_css', |
|
519 | + EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
520 | + array('espresso_default'), |
|
521 | + EVENT_ESPRESSO_VERSION |
|
522 | + ); |
|
523 | + } |
|
524 | + } |
|
525 | + } |
|
526 | + |
|
527 | + |
|
528 | + |
|
529 | + /** |
|
530 | + * registers core default javascript |
|
531 | + */ |
|
532 | + private function loadCoreJs() |
|
533 | + { |
|
534 | + // load core js |
|
535 | + wp_register_script( |
|
536 | + 'espresso_core', |
|
537 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
538 | + array('jquery'), |
|
539 | + EVENT_ESPRESSO_VERSION, |
|
540 | + true |
|
541 | + ); |
|
542 | + } |
|
543 | + |
|
544 | + |
|
545 | + |
|
546 | + /** |
|
547 | + * registers jQuery Validate for form validation |
|
548 | + */ |
|
549 | + private function loadJqueryValidate() |
|
550 | + { |
|
551 | + // register jQuery Validate and additional methods |
|
552 | + wp_register_script( |
|
553 | + 'jquery-validate', |
|
554 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
555 | + array('jquery'), |
|
556 | + '1.15.0', |
|
557 | + true |
|
558 | + ); |
|
559 | + wp_register_script( |
|
560 | + 'jquery-validate-extra-methods', |
|
561 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
562 | + array('jquery', 'jquery-validate'), |
|
563 | + '1.15.0', |
|
564 | + true |
|
565 | + ); |
|
566 | + } |
|
567 | + |
|
568 | + |
|
569 | + |
|
570 | + /** |
|
571 | + * registers accounting.js for performing client-side calculations |
|
572 | + */ |
|
573 | + private function loadAccountingJs() |
|
574 | + { |
|
575 | + //accounting.js library |
|
576 | + // @link http://josscrowcroft.github.io/accounting.js/ |
|
577 | + wp_register_script( |
|
578 | + 'ee-accounting-core', |
|
579 | + EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
580 | + array('underscore'), |
|
581 | + '0.3.2', |
|
582 | + true |
|
583 | + ); |
|
584 | + wp_register_script( |
|
585 | + 'ee-accounting', |
|
586 | + EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
587 | + array('ee-accounting-core'), |
|
588 | + EVENT_ESPRESSO_VERSION, |
|
589 | + true |
|
590 | + ); |
|
591 | + } |
|
592 | + |
|
593 | + |
|
594 | + |
|
595 | + /** |
|
596 | + * registers accounting.js for performing client-side calculations |
|
597 | + */ |
|
598 | + private function localizeAccountingJs() |
|
599 | + { |
|
600 | + wp_localize_script( |
|
601 | + 'ee-accounting', |
|
602 | + 'EE_ACCOUNTING_CFG', |
|
603 | + array( |
|
604 | + 'currency' => array( |
|
605 | + 'symbol' => $this->currency_config->sign, |
|
606 | + 'format' => array( |
|
607 | + 'pos' => $this->currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
608 | + 'neg' => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
609 | + 'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s', |
|
610 | + ), |
|
611 | + 'decimal' => $this->currency_config->dec_mrk, |
|
612 | + 'thousand' => $this->currency_config->thsnds, |
|
613 | + 'precision' => $this->currency_config->dec_plc, |
|
614 | + ), |
|
615 | + 'number' => array( |
|
616 | + 'precision' => $this->currency_config->dec_plc, |
|
617 | + 'thousand' => $this->currency_config->thsnds, |
|
618 | + 'decimal' => $this->currency_config->dec_mrk, |
|
619 | + ), |
|
620 | + ) |
|
621 | + ); |
|
622 | + $this->addRegisteredScriptHandlesWithData('ee-accounting'); |
|
623 | + } |
|
624 | + |
|
625 | + |
|
626 | + |
|
627 | + /** |
|
628 | + * registers assets for cleaning your ears |
|
629 | + */ |
|
630 | + private function loadQtipJs() |
|
631 | + { |
|
632 | + // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
633 | + // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
634 | + if (apply_filters('FHEE_load_qtip', false)) { |
|
635 | + EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
636 | + } |
|
637 | + } |
|
638 | + |
|
639 | + |
|
640 | + /** |
|
641 | + * This is used to set registered script handles that have data. |
|
642 | + * @param string $script_handle |
|
643 | + */ |
|
644 | + private function addRegisteredScriptHandlesWithData($script_handle) |
|
645 | + { |
|
646 | + $this->script_handles_with_data[$script_handle] = $script_handle; |
|
647 | + } |
|
648 | + |
|
649 | + |
|
650 | + /**i |
|
651 | 651 | * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the |
652 | 652 | * Dependency stored in WP_Scripts if its set. |
653 | 653 | */ |
654 | - private function removeAlreadyRegisteredDataForScriptHandles() |
|
655 | - { |
|
656 | - if (empty($this->script_handles_with_data)) { |
|
657 | - return; |
|
658 | - } |
|
659 | - foreach ($this->script_handles_with_data as $script_handle) { |
|
660 | - $this->removeAlreadyRegisteredDataForScriptHandle($script_handle); |
|
661 | - } |
|
662 | - } |
|
663 | - |
|
664 | - |
|
665 | - /** |
|
666 | - * Removes any data dependency registered in WP_Scripts if its set. |
|
667 | - * @param string $script_handle |
|
668 | - */ |
|
669 | - private function removeAlreadyRegisteredDataForScriptHandle($script_handle) |
|
670 | - { |
|
671 | - if (isset($this->script_handles_with_data[$script_handle])) { |
|
672 | - global $wp_scripts; |
|
673 | - $unset_handle = false; |
|
674 | - if ($wp_scripts->get_data($script_handle, 'data')) { |
|
675 | - unset($wp_scripts->registered[$script_handle]->extra['data']); |
|
676 | - $unset_handle = true; |
|
677 | - } |
|
678 | - //deal with inline_scripts |
|
679 | - if ($wp_scripts->get_data($script_handle, 'before')) { |
|
680 | - unset($wp_scripts->registered[$script_handle]->extra['before']); |
|
681 | - $unset_handle = true; |
|
682 | - } |
|
683 | - if ($wp_scripts->get_data($script_handle, 'after')) { |
|
684 | - unset($wp_scripts->registered[$script_handle]->extra['after']); |
|
685 | - } |
|
686 | - if ($unset_handle) { |
|
687 | - unset($this->script_handles_with_data[$script_handle]); |
|
688 | - } |
|
689 | - } |
|
690 | - } |
|
691 | - |
|
692 | - |
|
693 | - /** |
|
694 | - * Registers assets that are used in the WordPress admin. |
|
695 | - */ |
|
696 | - private function registerAdminAssets() |
|
697 | - { |
|
698 | - wp_register_script( |
|
699 | - 'ee-wp-plugins-page', |
|
700 | - $this->getJsUrl(self::ASSET_NAMESPACE_CORE, 'wp-plugins-page'), |
|
701 | - array( |
|
702 | - 'jquery', |
|
703 | - 'ee-vendor-react' |
|
704 | - ), |
|
705 | - null, |
|
706 | - true |
|
707 | - ); |
|
708 | - wp_register_style( |
|
709 | - 'ee-wp-plugins-page', |
|
710 | - $this->getCssUrl(self::ASSET_NAMESPACE_CORE, 'wp-plugins-page'), |
|
711 | - array(), |
|
712 | - null |
|
713 | - ); |
|
714 | - $this->registerTranslationsForHandles(array('ee-wp-plugins-page')); |
|
715 | - } |
|
716 | - |
|
717 | - |
|
718 | - /** |
|
719 | - * All handles that are registered via the registry that might have translations have their translations registered |
|
720 | - * |
|
721 | - * @param array $handles_to_register |
|
722 | - */ |
|
723 | - private function registerTranslationsForHandles(array $handles_to_register) |
|
724 | - { |
|
725 | - foreach($handles_to_register as $handle) { |
|
726 | - $this->i18n_registry->registerScriptI18n($handle); |
|
727 | - } |
|
728 | - } |
|
654 | + private function removeAlreadyRegisteredDataForScriptHandles() |
|
655 | + { |
|
656 | + if (empty($this->script_handles_with_data)) { |
|
657 | + return; |
|
658 | + } |
|
659 | + foreach ($this->script_handles_with_data as $script_handle) { |
|
660 | + $this->removeAlreadyRegisteredDataForScriptHandle($script_handle); |
|
661 | + } |
|
662 | + } |
|
663 | + |
|
664 | + |
|
665 | + /** |
|
666 | + * Removes any data dependency registered in WP_Scripts if its set. |
|
667 | + * @param string $script_handle |
|
668 | + */ |
|
669 | + private function removeAlreadyRegisteredDataForScriptHandle($script_handle) |
|
670 | + { |
|
671 | + if (isset($this->script_handles_with_data[$script_handle])) { |
|
672 | + global $wp_scripts; |
|
673 | + $unset_handle = false; |
|
674 | + if ($wp_scripts->get_data($script_handle, 'data')) { |
|
675 | + unset($wp_scripts->registered[$script_handle]->extra['data']); |
|
676 | + $unset_handle = true; |
|
677 | + } |
|
678 | + //deal with inline_scripts |
|
679 | + if ($wp_scripts->get_data($script_handle, 'before')) { |
|
680 | + unset($wp_scripts->registered[$script_handle]->extra['before']); |
|
681 | + $unset_handle = true; |
|
682 | + } |
|
683 | + if ($wp_scripts->get_data($script_handle, 'after')) { |
|
684 | + unset($wp_scripts->registered[$script_handle]->extra['after']); |
|
685 | + } |
|
686 | + if ($unset_handle) { |
|
687 | + unset($this->script_handles_with_data[$script_handle]); |
|
688 | + } |
|
689 | + } |
|
690 | + } |
|
691 | + |
|
692 | + |
|
693 | + /** |
|
694 | + * Registers assets that are used in the WordPress admin. |
|
695 | + */ |
|
696 | + private function registerAdminAssets() |
|
697 | + { |
|
698 | + wp_register_script( |
|
699 | + 'ee-wp-plugins-page', |
|
700 | + $this->getJsUrl(self::ASSET_NAMESPACE_CORE, 'wp-plugins-page'), |
|
701 | + array( |
|
702 | + 'jquery', |
|
703 | + 'ee-vendor-react' |
|
704 | + ), |
|
705 | + null, |
|
706 | + true |
|
707 | + ); |
|
708 | + wp_register_style( |
|
709 | + 'ee-wp-plugins-page', |
|
710 | + $this->getCssUrl(self::ASSET_NAMESPACE_CORE, 'wp-plugins-page'), |
|
711 | + array(), |
|
712 | + null |
|
713 | + ); |
|
714 | + $this->registerTranslationsForHandles(array('ee-wp-plugins-page')); |
|
715 | + } |
|
716 | + |
|
717 | + |
|
718 | + /** |
|
719 | + * All handles that are registered via the registry that might have translations have their translations registered |
|
720 | + * |
|
721 | + * @param array $handles_to_register |
|
722 | + */ |
|
723 | + private function registerTranslationsForHandles(array $handles_to_register) |
|
724 | + { |
|
725 | + foreach($handles_to_register as $handle) { |
|
726 | + $this->i18n_registry->registerScriptI18n($handle); |
|
727 | + } |
|
728 | + } |
|
729 | 729 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $this->registerManifestFile( |
115 | 115 | self::ASSET_NAMESPACE_CORE, |
116 | 116 | $this->domain->distributionAssetsUrl(), |
117 | - $this->domain->distributionAssetsPath() . self::FILE_NAME_BUILD_MANIFEST |
|
117 | + $this->domain->distributionAssetsPath().self::FILE_NAME_BUILD_MANIFEST |
|
118 | 118 | ); |
119 | 119 | add_action('wp_enqueue_scripts', array($this, 'scripts'), 1); |
120 | 120 | add_action('admin_enqueue_scripts', array($this, 'scripts'), 1); |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | //js.api |
172 | 172 | wp_register_script( |
173 | 173 | 'eejs-api', |
174 | - EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
174 | + EE_LIBRARIES_URL.'rest_api/assets/js/eejs-api.min.js', |
|
175 | 175 | array('underscore', 'eejs-core'), |
176 | 176 | EVENT_ESPRESSO_VERSION, |
177 | 177 | true |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | $this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest'); |
180 | 180 | $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/')); |
181 | 181 | } |
182 | - if (! is_admin()) { |
|
182 | + if ( ! is_admin()) { |
|
183 | 183 | $this->loadCoreCss(); |
184 | 184 | } |
185 | 185 | $this->registerTranslationsForHandles(array('eejs-core')); |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | $this->removeAlreadyRegisteredDataForScriptHandles(); |
204 | 204 | wp_add_inline_script( |
205 | 205 | 'eejs-core', |
206 | - 'var eejsdata=' . wp_json_encode(array('data' => $this->jsdata)), |
|
206 | + 'var eejsdata='.wp_json_encode(array('data' => $this->jsdata)), |
|
207 | 207 | 'before' |
208 | 208 | ); |
209 | 209 | wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | */ |
283 | 283 | public function addTemplate($template_reference, $template_content) |
284 | 284 | { |
285 | - if (! isset($this->jsdata['templates'])) { |
|
285 | + if ( ! isset($this->jsdata['templates'])) { |
|
286 | 286 | $this->jsdata['templates'] = array(); |
287 | 287 | } |
288 | 288 | //no overrides allowed. |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | return; |
432 | 432 | } |
433 | 433 | $this->manifest_data[$namespace] = $this->decodeManifestFile($manifest_file); |
434 | - if (! isset($this->manifest_data[$namespace]['url_base'])) { |
|
434 | + if ( ! isset($this->manifest_data[$namespace]['url_base'])) { |
|
435 | 435 | $this->manifest_data[$namespace]['url_base'] = trailingslashit($url_base); |
436 | 436 | } |
437 | 437 | } |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | */ |
449 | 449 | private function decodeManifestFile($manifest_file) |
450 | 450 | { |
451 | - if (! file_exists($manifest_file)) { |
|
451 | + if ( ! file_exists($manifest_file)) { |
|
452 | 452 | throw new InvalidFilePathException($manifest_file); |
453 | 453 | } |
454 | 454 | return json_decode(file_get_contents($manifest_file), true); |
@@ -503,9 +503,9 @@ discard block |
||
503 | 503 | private function loadCoreCss() |
504 | 504 | { |
505 | 505 | if ($this->template_config->enable_default_style) { |
506 | - $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
506 | + $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css') |
|
507 | 507 | ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
508 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css'; |
|
508 | + : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css'; |
|
509 | 509 | wp_register_style( |
510 | 510 | 'espresso_default', |
511 | 511 | $default_stylesheet_path, |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | if ($this->template_config->custom_style_sheet !== null) { |
517 | 517 | wp_register_style( |
518 | 518 | 'espresso_custom_css', |
519 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
519 | + EVENT_ESPRESSO_UPLOAD_URL.'css/'.$this->template_config->custom_style_sheet, |
|
520 | 520 | array('espresso_default'), |
521 | 521 | EVENT_ESPRESSO_VERSION |
522 | 522 | ); |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | // load core js |
535 | 535 | wp_register_script( |
536 | 536 | 'espresso_core', |
537 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
537 | + EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', |
|
538 | 538 | array('jquery'), |
539 | 539 | EVENT_ESPRESSO_VERSION, |
540 | 540 | true |
@@ -551,14 +551,14 @@ discard block |
||
551 | 551 | // register jQuery Validate and additional methods |
552 | 552 | wp_register_script( |
553 | 553 | 'jquery-validate', |
554 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
554 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', |
|
555 | 555 | array('jquery'), |
556 | 556 | '1.15.0', |
557 | 557 | true |
558 | 558 | ); |
559 | 559 | wp_register_script( |
560 | 560 | 'jquery-validate-extra-methods', |
561 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
561 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js', |
|
562 | 562 | array('jquery', 'jquery-validate'), |
563 | 563 | '1.15.0', |
564 | 564 | true |
@@ -576,14 +576,14 @@ discard block |
||
576 | 576 | // @link http://josscrowcroft.github.io/accounting.js/ |
577 | 577 | wp_register_script( |
578 | 578 | 'ee-accounting-core', |
579 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
579 | + EE_THIRD_PARTY_URL.'accounting/accounting.js', |
|
580 | 580 | array('underscore'), |
581 | 581 | '0.3.2', |
582 | 582 | true |
583 | 583 | ); |
584 | 584 | wp_register_script( |
585 | 585 | 'ee-accounting', |
586 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
586 | + EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', |
|
587 | 587 | array('ee-accounting-core'), |
588 | 588 | EVENT_ESPRESSO_VERSION, |
589 | 589 | true |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | */ |
723 | 723 | private function registerTranslationsForHandles(array $handles_to_register) |
724 | 724 | { |
725 | - foreach($handles_to_register as $handle) { |
|
725 | + foreach ($handles_to_register as $handle) { |
|
726 | 726 | $this->i18n_registry->registerScriptI18n($handle); |
727 | 727 | } |
728 | 728 | } |
@@ -16,55 +16,55 @@ |
||
16 | 16 | interface DomainInterface extends InterminableInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @return string |
|
21 | - * @throws DomainException |
|
22 | - */ |
|
23 | - public function pluginFile(); |
|
19 | + /** |
|
20 | + * @return string |
|
21 | + * @throws DomainException |
|
22 | + */ |
|
23 | + public function pluginFile(); |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * @return string |
|
28 | - * @throws DomainException |
|
29 | - */ |
|
30 | - public function pluginBasename(); |
|
26 | + /** |
|
27 | + * @return string |
|
28 | + * @throws DomainException |
|
29 | + */ |
|
30 | + public function pluginBasename(); |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @return string |
|
35 | - */ |
|
36 | - public function pluginPath(); |
|
33 | + /** |
|
34 | + * @return string |
|
35 | + */ |
|
36 | + public function pluginPath(); |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * @return string |
|
41 | - * @throws DomainException |
|
42 | - */ |
|
43 | - public function pluginUrl(); |
|
39 | + /** |
|
40 | + * @return string |
|
41 | + * @throws DomainException |
|
42 | + */ |
|
43 | + public function pluginUrl(); |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * @return string |
|
48 | - * @throws DomainException |
|
49 | - */ |
|
50 | - public function version(); |
|
46 | + /** |
|
47 | + * @return string |
|
48 | + * @throws DomainException |
|
49 | + */ |
|
50 | + public function version(); |
|
51 | 51 | |
52 | 52 | |
53 | - /** |
|
54 | - * @return string |
|
55 | - */ |
|
56 | - public function distributionAssetsPath(); |
|
53 | + /** |
|
54 | + * @return string |
|
55 | + */ |
|
56 | + public function distributionAssetsPath(); |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * @return string |
|
61 | - */ |
|
62 | - public function distributionAssetsUrl(); |
|
59 | + /** |
|
60 | + * @return string |
|
61 | + */ |
|
62 | + public function distributionAssetsUrl(); |
|
63 | 63 | |
64 | 64 | |
65 | - /** |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function assetNamespace(); |
|
65 | + /** |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function assetNamespace(); |
|
69 | 69 | |
70 | 70 | } |
@@ -20,157 +20,157 @@ |
||
20 | 20 | abstract class DomainBase implements DomainInterface |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * Equivalent to `__FILE__` for main plugin file. |
|
25 | - * |
|
26 | - * @var FilePath |
|
27 | - */ |
|
28 | - private $plugin_file; |
|
29 | - |
|
30 | - /** |
|
31 | - * String indicating version for plugin |
|
32 | - * |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - private $version; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var string $plugin_basename |
|
39 | - */ |
|
40 | - private $plugin_basename; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var string $plugin_path |
|
44 | - */ |
|
45 | - private $plugin_path; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var string $plugin_url |
|
49 | - */ |
|
50 | - private $plugin_url; |
|
51 | - |
|
52 | - /** |
|
53 | - * @var string $asset_namespace |
|
54 | - */ |
|
55 | - private $asset_namespace; |
|
56 | - |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * Initializes internal properties. |
|
61 | - * |
|
62 | - * @param FilePath $plugin_file |
|
63 | - * @param Version $version |
|
64 | - */ |
|
65 | - public function __construct(FilePath $plugin_file, Version $version) |
|
66 | - { |
|
67 | - $this->plugin_file = $plugin_file; |
|
68 | - $this->version = $version; |
|
69 | - $this->plugin_basename = plugin_basename($this->pluginFile()); |
|
70 | - $this->plugin_path = plugin_dir_path($this->pluginFile()); |
|
71 | - $this->plugin_url = plugin_dir_url($this->pluginFile()); |
|
72 | - $this->setAssetNamespace(); |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * @return string |
|
78 | - */ |
|
79 | - public function pluginFile() |
|
80 | - { |
|
81 | - return (string) $this->plugin_file; |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * @return string |
|
88 | - */ |
|
89 | - public function pluginBasename() |
|
90 | - { |
|
91 | - return $this->plugin_basename; |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * @return string |
|
98 | - */ |
|
99 | - public function pluginPath() |
|
100 | - { |
|
101 | - return $this->plugin_path; |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - |
|
106 | - /** |
|
107 | - * @return string |
|
108 | - */ |
|
109 | - public function pluginUrl() |
|
110 | - { |
|
111 | - return $this->plugin_url; |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * @return string |
|
118 | - */ |
|
119 | - public function version() |
|
120 | - { |
|
121 | - return (string) $this->version; |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * @return Version |
|
128 | - */ |
|
129 | - public function versionValueObject() |
|
130 | - { |
|
131 | - return $this->version; |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * @return string |
|
137 | - */ |
|
138 | - public function distributionAssetsPath() |
|
139 | - { |
|
140 | - return $this->pluginPath() . 'assets/dist/'; |
|
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * @return string |
|
146 | - */ |
|
147 | - public function distributionAssetsUrl() |
|
148 | - { |
|
149 | - return $this->pluginUrl() . 'assets/dist/'; |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * @return string |
|
155 | - */ |
|
156 | - public function assetNamespace() |
|
157 | - { |
|
158 | - return $this->asset_namespace; |
|
159 | - } |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * @return void |
|
164 | - */ |
|
165 | - private function setAssetNamespace() |
|
166 | - { |
|
167 | - $asset_namespace = explode('/', $this->plugin_basename); |
|
168 | - $asset_namespace = reset($asset_namespace); |
|
169 | - $asset_namespace = $asset_namespace === 'event-espresso-core' |
|
170 | - ? Registry::ASSET_NAMESPACE_CORE |
|
171 | - : $asset_namespace; |
|
172 | - $this->asset_namespace = $asset_namespace; |
|
173 | - } |
|
23 | + /** |
|
24 | + * Equivalent to `__FILE__` for main plugin file. |
|
25 | + * |
|
26 | + * @var FilePath |
|
27 | + */ |
|
28 | + private $plugin_file; |
|
29 | + |
|
30 | + /** |
|
31 | + * String indicating version for plugin |
|
32 | + * |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + private $version; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var string $plugin_basename |
|
39 | + */ |
|
40 | + private $plugin_basename; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var string $plugin_path |
|
44 | + */ |
|
45 | + private $plugin_path; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var string $plugin_url |
|
49 | + */ |
|
50 | + private $plugin_url; |
|
51 | + |
|
52 | + /** |
|
53 | + * @var string $asset_namespace |
|
54 | + */ |
|
55 | + private $asset_namespace; |
|
56 | + |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * Initializes internal properties. |
|
61 | + * |
|
62 | + * @param FilePath $plugin_file |
|
63 | + * @param Version $version |
|
64 | + */ |
|
65 | + public function __construct(FilePath $plugin_file, Version $version) |
|
66 | + { |
|
67 | + $this->plugin_file = $plugin_file; |
|
68 | + $this->version = $version; |
|
69 | + $this->plugin_basename = plugin_basename($this->pluginFile()); |
|
70 | + $this->plugin_path = plugin_dir_path($this->pluginFile()); |
|
71 | + $this->plugin_url = plugin_dir_url($this->pluginFile()); |
|
72 | + $this->setAssetNamespace(); |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * @return string |
|
78 | + */ |
|
79 | + public function pluginFile() |
|
80 | + { |
|
81 | + return (string) $this->plugin_file; |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * @return string |
|
88 | + */ |
|
89 | + public function pluginBasename() |
|
90 | + { |
|
91 | + return $this->plugin_basename; |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * @return string |
|
98 | + */ |
|
99 | + public function pluginPath() |
|
100 | + { |
|
101 | + return $this->plugin_path; |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + |
|
106 | + /** |
|
107 | + * @return string |
|
108 | + */ |
|
109 | + public function pluginUrl() |
|
110 | + { |
|
111 | + return $this->plugin_url; |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * @return string |
|
118 | + */ |
|
119 | + public function version() |
|
120 | + { |
|
121 | + return (string) $this->version; |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * @return Version |
|
128 | + */ |
|
129 | + public function versionValueObject() |
|
130 | + { |
|
131 | + return $this->version; |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * @return string |
|
137 | + */ |
|
138 | + public function distributionAssetsPath() |
|
139 | + { |
|
140 | + return $this->pluginPath() . 'assets/dist/'; |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * @return string |
|
146 | + */ |
|
147 | + public function distributionAssetsUrl() |
|
148 | + { |
|
149 | + return $this->pluginUrl() . 'assets/dist/'; |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * @return string |
|
155 | + */ |
|
156 | + public function assetNamespace() |
|
157 | + { |
|
158 | + return $this->asset_namespace; |
|
159 | + } |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * @return void |
|
164 | + */ |
|
165 | + private function setAssetNamespace() |
|
166 | + { |
|
167 | + $asset_namespace = explode('/', $this->plugin_basename); |
|
168 | + $asset_namespace = reset($asset_namespace); |
|
169 | + $asset_namespace = $asset_namespace === 'event-espresso-core' |
|
170 | + ? Registry::ASSET_NAMESPACE_CORE |
|
171 | + : $asset_namespace; |
|
172 | + $this->asset_namespace = $asset_namespace; |
|
173 | + } |
|
174 | 174 | |
175 | 175 | |
176 | 176 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public function distributionAssetsPath() |
139 | 139 | { |
140 | - return $this->pluginPath() . 'assets/dist/'; |
|
140 | + return $this->pluginPath().'assets/dist/'; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function distributionAssetsUrl() |
148 | 148 | { |
149 | - return $this->pluginUrl() . 'assets/dist/'; |
|
149 | + return $this->pluginUrl().'assets/dist/'; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | */ |
165 | 165 | private function setAssetNamespace() |
166 | 166 | { |
167 | - $asset_namespace = explode('/', $this->plugin_basename); |
|
167 | + $asset_namespace = explode('/', $this->plugin_basename); |
|
168 | 168 | $asset_namespace = reset($asset_namespace); |
169 | 169 | $asset_namespace = $asset_namespace === 'event-espresso-core' |
170 | 170 | ? Registry::ASSET_NAMESPACE_CORE |
@@ -26,68 +26,68 @@ |
||
26 | 26 | interface BlockInterface |
27 | 27 | { |
28 | 28 | |
29 | - /** |
|
30 | - * Perform any early setup required by the block |
|
31 | - * including setting the block type and supported post types |
|
32 | - * |
|
33 | - * @return void |
|
34 | - */ |
|
35 | - public function initialize(); |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * @return string |
|
40 | - */ |
|
41 | - public function blockType(); |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * AssetRegister that this editor block uses for asset registration |
|
46 | - * |
|
47 | - * @return AssetRegisterInterface |
|
48 | - */ |
|
49 | - public function assetRegister(); |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * Registers the Editor Block with WP core; |
|
54 | - * Returns the registered block type on success, or false on failure. |
|
55 | - * |
|
56 | - * @return WP_Block_Type|false |
|
57 | - */ |
|
58 | - public function registerBlock(); |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * Un-registers the Editor Block with WP core; |
|
63 | - * Returns the registered block type on success, or false on failure. |
|
64 | - * |
|
65 | - * @return WP_Block_Type|false |
|
66 | - */ |
|
67 | - public function unRegisterBlock(); |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * returns true if the block type applies for the supplied post type |
|
72 | - * and should be added to that post type's editor |
|
73 | - * |
|
74 | - * @param string $post_type |
|
75 | - * @return boolean |
|
76 | - */ |
|
77 | - public function appliesToPostType($post_type); |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * @return array |
|
82 | - */ |
|
83 | - public function getEditorContainer(); |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * returns the rendered HTML for the block |
|
88 | - * |
|
89 | - * @param array $attributes |
|
90 | - * @return string |
|
91 | - */ |
|
92 | - public function renderBlock(array $attributes = array()); |
|
29 | + /** |
|
30 | + * Perform any early setup required by the block |
|
31 | + * including setting the block type and supported post types |
|
32 | + * |
|
33 | + * @return void |
|
34 | + */ |
|
35 | + public function initialize(); |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * @return string |
|
40 | + */ |
|
41 | + public function blockType(); |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * AssetRegister that this editor block uses for asset registration |
|
46 | + * |
|
47 | + * @return AssetRegisterInterface |
|
48 | + */ |
|
49 | + public function assetRegister(); |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * Registers the Editor Block with WP core; |
|
54 | + * Returns the registered block type on success, or false on failure. |
|
55 | + * |
|
56 | + * @return WP_Block_Type|false |
|
57 | + */ |
|
58 | + public function registerBlock(); |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * Un-registers the Editor Block with WP core; |
|
63 | + * Returns the registered block type on success, or false on failure. |
|
64 | + * |
|
65 | + * @return WP_Block_Type|false |
|
66 | + */ |
|
67 | + public function unRegisterBlock(); |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * returns true if the block type applies for the supplied post type |
|
72 | + * and should be added to that post type's editor |
|
73 | + * |
|
74 | + * @param string $post_type |
|
75 | + * @return boolean |
|
76 | + */ |
|
77 | + public function appliesToPostType($post_type); |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * @return array |
|
82 | + */ |
|
83 | + public function getEditorContainer(); |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * returns the rendered HTML for the block |
|
88 | + * |
|
89 | + * @param array $attributes |
|
90 | + * @return string |
|
91 | + */ |
|
92 | + public function renderBlock(array $attributes = array()); |
|
93 | 93 | } |
@@ -20,55 +20,55 @@ |
||
20 | 20 | class BlockCollection extends Collection |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * Collection constructor |
|
25 | - * |
|
26 | - * @throws InvalidInterfaceException |
|
27 | - */ |
|
28 | - public function __construct() |
|
29 | - { |
|
30 | - parent::__construct('EventEspresso\core\domain\entities\editor\BlockInterface'); |
|
31 | - } |
|
23 | + /** |
|
24 | + * Collection constructor |
|
25 | + * |
|
26 | + * @throws InvalidInterfaceException |
|
27 | + */ |
|
28 | + public function __construct() |
|
29 | + { |
|
30 | + parent::__construct('EventEspresso\core\domain\entities\editor\BlockInterface'); |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * unRegisterBlock |
|
36 | - * finds block in the Collection based on the identifier that was set using addObject() |
|
37 | - * and calls unRegisterBlock() on it. Returns block if successful and false if block was not found. |
|
38 | - * PLZ NOTE: the pointer is reset to the beginning of the collection afterwards |
|
39 | - * |
|
40 | - * @param mixed $identifier |
|
41 | - * @return boolean |
|
42 | - */ |
|
43 | - public function unRegisterBlock($identifier) |
|
44 | - { |
|
45 | - $this->rewind(); |
|
46 | - while ($this->valid()) { |
|
47 | - if ($identifier === $this->getInfo()) { |
|
48 | - $object = $this->current(); |
|
49 | - $this->rewind(); |
|
50 | - return $object->unRegisterBlock(); |
|
51 | - } |
|
52 | - $this->next(); |
|
53 | - } |
|
54 | - return false; |
|
55 | - } |
|
34 | + /** |
|
35 | + * unRegisterBlock |
|
36 | + * finds block in the Collection based on the identifier that was set using addObject() |
|
37 | + * and calls unRegisterBlock() on it. Returns block if successful and false if block was not found. |
|
38 | + * PLZ NOTE: the pointer is reset to the beginning of the collection afterwards |
|
39 | + * |
|
40 | + * @param mixed $identifier |
|
41 | + * @return boolean |
|
42 | + */ |
|
43 | + public function unRegisterBlock($identifier) |
|
44 | + { |
|
45 | + $this->rewind(); |
|
46 | + while ($this->valid()) { |
|
47 | + if ($identifier === $this->getInfo()) { |
|
48 | + $object = $this->current(); |
|
49 | + $this->rewind(); |
|
50 | + return $object->unRegisterBlock(); |
|
51 | + } |
|
52 | + $this->next(); |
|
53 | + } |
|
54 | + return false; |
|
55 | + } |
|
56 | 56 | |
57 | 57 | |
58 | - /** |
|
59 | - * unRegisterAllBlocks |
|
60 | - * calls unRegisterBlock() on all blocks in Collection. |
|
61 | - * PLZ NOTE: the pointer is reset to the beginning of the collection afterwards |
|
62 | - * |
|
63 | - * @return void |
|
64 | - */ |
|
65 | - public function unRegisterAllBlocks() |
|
66 | - { |
|
67 | - $this->rewind(); |
|
68 | - while ($this->valid()) { |
|
69 | - $this->current()->unRegisterBlock(); |
|
70 | - $this->next(); |
|
71 | - } |
|
72 | - $this->rewind(); |
|
73 | - } |
|
58 | + /** |
|
59 | + * unRegisterAllBlocks |
|
60 | + * calls unRegisterBlock() on all blocks in Collection. |
|
61 | + * PLZ NOTE: the pointer is reset to the beginning of the collection afterwards |
|
62 | + * |
|
63 | + * @return void |
|
64 | + */ |
|
65 | + public function unRegisterAllBlocks() |
|
66 | + { |
|
67 | + $this->rewind(); |
|
68 | + while ($this->valid()) { |
|
69 | + $this->current()->unRegisterBlock(); |
|
70 | + $this->next(); |
|
71 | + } |
|
72 | + $this->rewind(); |
|
73 | + } |
|
74 | 74 | } |
@@ -22,78 +22,78 @@ |
||
22 | 22 | abstract class BlockManager |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * @var CollectionInterface|BlockInterface[] $blocks |
|
27 | - */ |
|
28 | - protected $blocks; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var RequestInterface $request |
|
32 | - */ |
|
33 | - protected $request; |
|
34 | - |
|
35 | - /** |
|
36 | - * the post type that the current request applies to |
|
37 | - * |
|
38 | - * @var string $request_post_type |
|
39 | - */ |
|
40 | - protected $request_post_type; |
|
41 | - |
|
42 | - /** |
|
43 | - * value of the 'page' $_GET param |
|
44 | - * |
|
45 | - * @var string $page |
|
46 | - */ |
|
47 | - protected $page; |
|
48 | - |
|
49 | - /** |
|
50 | - * value of the 'action' $_GET param |
|
51 | - * |
|
52 | - * @var string $action |
|
53 | - */ |
|
54 | - protected $action; |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * BlockManager constructor. |
|
59 | - * |
|
60 | - * @param BlockCollection $blocks |
|
61 | - * @param RequestInterface $request |
|
62 | - */ |
|
63 | - public function __construct( |
|
64 | - BlockCollection $blocks, |
|
65 | - RequestInterface $request |
|
66 | - ) { |
|
67 | - $this->blocks = $blocks; |
|
68 | - $this->request = $request; |
|
69 | - $this->request_post_type = $this->request->getRequestParam('post_type', ''); |
|
70 | - $this->page = $this->request->getRequestParam('page', ''); |
|
71 | - $this->action = $this->request->getRequestParam('action', ''); |
|
72 | - add_action($this->init_hook(), array($this, 'initialize')); |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * Returns the name of a hookpoint to be used to call initialize() |
|
78 | - * |
|
79 | - * @return string |
|
80 | - */ |
|
81 | - abstract public function init_hook(); |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * Perform any early setup required for block editors to functions |
|
86 | - * |
|
87 | - * @return void |
|
88 | - */ |
|
89 | - abstract public function initialize(); |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * @return string |
|
94 | - */ |
|
95 | - public function currentRequestPostType() |
|
96 | - { |
|
97 | - return $this->request_post_type; |
|
98 | - } |
|
25 | + /** |
|
26 | + * @var CollectionInterface|BlockInterface[] $blocks |
|
27 | + */ |
|
28 | + protected $blocks; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var RequestInterface $request |
|
32 | + */ |
|
33 | + protected $request; |
|
34 | + |
|
35 | + /** |
|
36 | + * the post type that the current request applies to |
|
37 | + * |
|
38 | + * @var string $request_post_type |
|
39 | + */ |
|
40 | + protected $request_post_type; |
|
41 | + |
|
42 | + /** |
|
43 | + * value of the 'page' $_GET param |
|
44 | + * |
|
45 | + * @var string $page |
|
46 | + */ |
|
47 | + protected $page; |
|
48 | + |
|
49 | + /** |
|
50 | + * value of the 'action' $_GET param |
|
51 | + * |
|
52 | + * @var string $action |
|
53 | + */ |
|
54 | + protected $action; |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * BlockManager constructor. |
|
59 | + * |
|
60 | + * @param BlockCollection $blocks |
|
61 | + * @param RequestInterface $request |
|
62 | + */ |
|
63 | + public function __construct( |
|
64 | + BlockCollection $blocks, |
|
65 | + RequestInterface $request |
|
66 | + ) { |
|
67 | + $this->blocks = $blocks; |
|
68 | + $this->request = $request; |
|
69 | + $this->request_post_type = $this->request->getRequestParam('post_type', ''); |
|
70 | + $this->page = $this->request->getRequestParam('page', ''); |
|
71 | + $this->action = $this->request->getRequestParam('action', ''); |
|
72 | + add_action($this->init_hook(), array($this, 'initialize')); |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * Returns the name of a hookpoint to be used to call initialize() |
|
78 | + * |
|
79 | + * @return string |
|
80 | + */ |
|
81 | + abstract public function init_hook(); |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * Perform any early setup required for block editors to functions |
|
86 | + * |
|
87 | + * @return void |
|
88 | + */ |
|
89 | + abstract public function initialize(); |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * @return string |
|
94 | + */ |
|
95 | + public function currentRequestPostType() |
|
96 | + { |
|
97 | + return $this->request_post_type; |
|
98 | + } |
|
99 | 99 | } |
@@ -163,10 +163,10 @@ |
||
163 | 163 | foreach ($this->blocks as $block) { |
164 | 164 | // perform any setup required for the block |
165 | 165 | $block_type = $block->registerBlock(); |
166 | - if (! $block_type instanceof WP_Block_Type) { |
|
166 | + if ( ! $block_type instanceof WP_Block_Type) { |
|
167 | 167 | throw new InvalidEntityException($block_type, 'WP_Block_Type'); |
168 | 168 | } |
169 | - if (! $this->asset_register_collection->has($block->assetRegister())) { |
|
169 | + if ( ! $this->asset_register_collection->has($block->assetRegister())) { |
|
170 | 170 | $this->asset_register_collection->add($block->assetRegister()); |
171 | 171 | } |
172 | 172 | do_action( |
@@ -40,158 +40,158 @@ |
||
40 | 40 | class BlockRegistrationManager extends BlockManager |
41 | 41 | { |
42 | 42 | |
43 | - /** |
|
44 | - * @var AssetRegisterCollection $asset_register_collection |
|
45 | - */ |
|
46 | - protected $asset_register_collection; |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * BlockRegistrationManager constructor. |
|
51 | - * |
|
52 | - * @param AssetRegisterCollection $asset_register_collection |
|
53 | - * @param BlockCollection $blocks |
|
54 | - * @param RequestInterface $request |
|
55 | - */ |
|
56 | - public function __construct( |
|
57 | - AssetRegisterCollection $asset_register_collection, |
|
58 | - BlockCollection $blocks, |
|
59 | - RequestInterface $request |
|
60 | - ) { |
|
61 | - $this->asset_register_collection = $asset_register_collection; |
|
62 | - parent::__construct($blocks, $request); |
|
63 | - } |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * Returns the name of a hookpoint to be used to call initialize() |
|
68 | - * |
|
69 | - * @return string |
|
70 | - */ |
|
71 | - public function init_hook() |
|
72 | - { |
|
73 | - return 'AHEE__EE_System__set_hooks_for_core'; |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * Perform any early setup required for block editors to functions |
|
79 | - * |
|
80 | - * @return void |
|
81 | - * @throws Exception |
|
82 | - */ |
|
83 | - public function initialize() |
|
84 | - { |
|
85 | - $this->loadBlocks(); |
|
86 | - add_action('AHEE__EE_System__initialize', array($this, 'registerBlocks')); |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - /** |
|
91 | - * @return CollectionInterface|BlockInterface[] |
|
92 | - * @throws ReflectionException |
|
93 | - * @throws InvalidArgumentException |
|
94 | - * @throws EE_Error |
|
95 | - * @throws InvalidClassException |
|
96 | - * @throws InvalidDataTypeException |
|
97 | - * @throws InvalidEntityException |
|
98 | - * @throws InvalidFilePathException |
|
99 | - * @throws InvalidIdentifierException |
|
100 | - * @throws InvalidInterfaceException |
|
101 | - */ |
|
102 | - protected function populateBlockCollection() |
|
103 | - { |
|
104 | - $loader = new CollectionLoader( |
|
105 | - new CollectionDetails( |
|
106 | - // collection name |
|
107 | - 'shortcodes', |
|
108 | - // collection interface |
|
109 | - 'EventEspresso\core\domain\entities\editor\BlockInterface', |
|
110 | - // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
111 | - apply_filters( |
|
112 | - 'FHEE__EventEspresso_core_services_editor_BlockManager__populateBlockCollection__collection_FQCNs', |
|
113 | - array( |
|
114 | - // 'EventEspresso\core\domain\entities\editor\blocks\common', |
|
115 | - // 'EventEspresso\core\domain\entities\editor\blocks\editor', |
|
116 | - // 'EventEspresso\core\domain\entities\editor\blocks\widgets', |
|
117 | - ) |
|
118 | - ), |
|
119 | - // filepaths to classes to add |
|
120 | - array(), |
|
121 | - // file mask to use if parsing folder for files to add |
|
122 | - '', |
|
123 | - // what to use as identifier for collection entities |
|
124 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
125 | - CollectionDetails::ID_CLASS_NAME |
|
126 | - ), |
|
127 | - $this->blocks |
|
128 | - ); |
|
129 | - return $loader->getCollection(); |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * populates the BlockCollection and calls initialize() on all installed blocks |
|
135 | - * |
|
136 | - * @return void |
|
137 | - * @throws Exception |
|
138 | - */ |
|
139 | - public function loadBlocks() |
|
140 | - { |
|
141 | - try { |
|
142 | - $this->populateBlockCollection(); |
|
143 | - // cycle thru block loaders and initialize each loader |
|
144 | - foreach ($this->blocks as $block) { |
|
145 | - $block->initialize(); |
|
146 | - } |
|
147 | - } catch (Exception $exception) { |
|
148 | - new ExceptionStackTraceDisplay($exception); |
|
149 | - } |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * calls registerBlock() and load assets for all installed blocks |
|
155 | - * |
|
156 | - * @return void |
|
157 | - * @throws Exception |
|
158 | - */ |
|
159 | - public function registerBlocks() |
|
160 | - { |
|
161 | - try { |
|
162 | - // cycle thru block loader folders |
|
163 | - foreach ($this->blocks as $block) { |
|
164 | - // perform any setup required for the block |
|
165 | - $block_type = $block->registerBlock(); |
|
166 | - if (! $block_type instanceof WP_Block_Type) { |
|
167 | - throw new InvalidEntityException($block_type, 'WP_Block_Type'); |
|
168 | - } |
|
169 | - if (! $this->asset_register_collection->has($block->assetRegister())) { |
|
170 | - $this->asset_register_collection->add($block->assetRegister()); |
|
171 | - } |
|
172 | - do_action( |
|
173 | - 'FHEE__EventEspresso_core_services_editor_BlockManager__registerBlocks__block_type_registered', |
|
174 | - $block, |
|
175 | - $block_type |
|
176 | - ); |
|
177 | - } |
|
178 | - if ($this->asset_register_collection->hasObjects()) { |
|
179 | - $this->asset_register_collection->registerManifestFile(); |
|
180 | - // register primary assets |
|
181 | - add_action('enqueue_block_assets', array($this, 'registerAssets')); |
|
182 | - } |
|
183 | - } catch (Exception $exception) { |
|
184 | - new ExceptionStackTraceDisplay($exception); |
|
185 | - } |
|
186 | - } |
|
187 | - |
|
188 | - |
|
189 | - /** |
|
190 | - * Registers assets for all classes in the AssetRegisterCollection |
|
191 | - */ |
|
192 | - public function registerAssets() |
|
193 | - { |
|
194 | - $this->asset_register_collection->registerScripts(); |
|
195 | - $this->asset_register_collection->registerStyles(); |
|
196 | - } |
|
43 | + /** |
|
44 | + * @var AssetRegisterCollection $asset_register_collection |
|
45 | + */ |
|
46 | + protected $asset_register_collection; |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * BlockRegistrationManager constructor. |
|
51 | + * |
|
52 | + * @param AssetRegisterCollection $asset_register_collection |
|
53 | + * @param BlockCollection $blocks |
|
54 | + * @param RequestInterface $request |
|
55 | + */ |
|
56 | + public function __construct( |
|
57 | + AssetRegisterCollection $asset_register_collection, |
|
58 | + BlockCollection $blocks, |
|
59 | + RequestInterface $request |
|
60 | + ) { |
|
61 | + $this->asset_register_collection = $asset_register_collection; |
|
62 | + parent::__construct($blocks, $request); |
|
63 | + } |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * Returns the name of a hookpoint to be used to call initialize() |
|
68 | + * |
|
69 | + * @return string |
|
70 | + */ |
|
71 | + public function init_hook() |
|
72 | + { |
|
73 | + return 'AHEE__EE_System__set_hooks_for_core'; |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * Perform any early setup required for block editors to functions |
|
79 | + * |
|
80 | + * @return void |
|
81 | + * @throws Exception |
|
82 | + */ |
|
83 | + public function initialize() |
|
84 | + { |
|
85 | + $this->loadBlocks(); |
|
86 | + add_action('AHEE__EE_System__initialize', array($this, 'registerBlocks')); |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + /** |
|
91 | + * @return CollectionInterface|BlockInterface[] |
|
92 | + * @throws ReflectionException |
|
93 | + * @throws InvalidArgumentException |
|
94 | + * @throws EE_Error |
|
95 | + * @throws InvalidClassException |
|
96 | + * @throws InvalidDataTypeException |
|
97 | + * @throws InvalidEntityException |
|
98 | + * @throws InvalidFilePathException |
|
99 | + * @throws InvalidIdentifierException |
|
100 | + * @throws InvalidInterfaceException |
|
101 | + */ |
|
102 | + protected function populateBlockCollection() |
|
103 | + { |
|
104 | + $loader = new CollectionLoader( |
|
105 | + new CollectionDetails( |
|
106 | + // collection name |
|
107 | + 'shortcodes', |
|
108 | + // collection interface |
|
109 | + 'EventEspresso\core\domain\entities\editor\BlockInterface', |
|
110 | + // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
111 | + apply_filters( |
|
112 | + 'FHEE__EventEspresso_core_services_editor_BlockManager__populateBlockCollection__collection_FQCNs', |
|
113 | + array( |
|
114 | + // 'EventEspresso\core\domain\entities\editor\blocks\common', |
|
115 | + // 'EventEspresso\core\domain\entities\editor\blocks\editor', |
|
116 | + // 'EventEspresso\core\domain\entities\editor\blocks\widgets', |
|
117 | + ) |
|
118 | + ), |
|
119 | + // filepaths to classes to add |
|
120 | + array(), |
|
121 | + // file mask to use if parsing folder for files to add |
|
122 | + '', |
|
123 | + // what to use as identifier for collection entities |
|
124 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
125 | + CollectionDetails::ID_CLASS_NAME |
|
126 | + ), |
|
127 | + $this->blocks |
|
128 | + ); |
|
129 | + return $loader->getCollection(); |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * populates the BlockCollection and calls initialize() on all installed blocks |
|
135 | + * |
|
136 | + * @return void |
|
137 | + * @throws Exception |
|
138 | + */ |
|
139 | + public function loadBlocks() |
|
140 | + { |
|
141 | + try { |
|
142 | + $this->populateBlockCollection(); |
|
143 | + // cycle thru block loaders and initialize each loader |
|
144 | + foreach ($this->blocks as $block) { |
|
145 | + $block->initialize(); |
|
146 | + } |
|
147 | + } catch (Exception $exception) { |
|
148 | + new ExceptionStackTraceDisplay($exception); |
|
149 | + } |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * calls registerBlock() and load assets for all installed blocks |
|
155 | + * |
|
156 | + * @return void |
|
157 | + * @throws Exception |
|
158 | + */ |
|
159 | + public function registerBlocks() |
|
160 | + { |
|
161 | + try { |
|
162 | + // cycle thru block loader folders |
|
163 | + foreach ($this->blocks as $block) { |
|
164 | + // perform any setup required for the block |
|
165 | + $block_type = $block->registerBlock(); |
|
166 | + if (! $block_type instanceof WP_Block_Type) { |
|
167 | + throw new InvalidEntityException($block_type, 'WP_Block_Type'); |
|
168 | + } |
|
169 | + if (! $this->asset_register_collection->has($block->assetRegister())) { |
|
170 | + $this->asset_register_collection->add($block->assetRegister()); |
|
171 | + } |
|
172 | + do_action( |
|
173 | + 'FHEE__EventEspresso_core_services_editor_BlockManager__registerBlocks__block_type_registered', |
|
174 | + $block, |
|
175 | + $block_type |
|
176 | + ); |
|
177 | + } |
|
178 | + if ($this->asset_register_collection->hasObjects()) { |
|
179 | + $this->asset_register_collection->registerManifestFile(); |
|
180 | + // register primary assets |
|
181 | + add_action('enqueue_block_assets', array($this, 'registerAssets')); |
|
182 | + } |
|
183 | + } catch (Exception $exception) { |
|
184 | + new ExceptionStackTraceDisplay($exception); |
|
185 | + } |
|
186 | + } |
|
187 | + |
|
188 | + |
|
189 | + /** |
|
190 | + * Registers assets for all classes in the AssetRegisterCollection |
|
191 | + */ |
|
192 | + public function registerAssets() |
|
193 | + { |
|
194 | + $this->asset_register_collection->registerScripts(); |
|
195 | + $this->asset_register_collection->registerStyles(); |
|
196 | + } |
|
197 | 197 | } |
@@ -22,198 +22,198 @@ |
||
22 | 22 | abstract class BlockAssetRegister implements AssetRegisterInterface |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * @var DomainInterface $domain |
|
27 | - */ |
|
28 | - private $domain; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var Registry $registry |
|
32 | - */ |
|
33 | - private $registry; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var string $script_handle |
|
37 | - */ |
|
38 | - private $script_handle; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var array $script_dependencies |
|
42 | - */ |
|
43 | - private $script_dependencies; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var string $style_handle |
|
47 | - */ |
|
48 | - private $style_handle; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var array $style_dependencies |
|
52 | - */ |
|
53 | - private $style_dependencies; |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * BlockAssetRegister constructor. |
|
58 | - * |
|
59 | - * @param string $script_handle |
|
60 | - * @param array $script_dependencies |
|
61 | - * @param string $style_handle |
|
62 | - * @param array $style_dependencies |
|
63 | - * @param DomainInterface $domain |
|
64 | - * @param Registry $registry |
|
65 | - * @throws InvalidDataTypeException |
|
66 | - */ |
|
67 | - public function __construct( |
|
68 | - $script_handle, |
|
69 | - array $script_dependencies, |
|
70 | - $style_handle, |
|
71 | - array $style_dependencies, |
|
72 | - DomainInterface $domain, |
|
73 | - Registry $registry |
|
74 | - ) { |
|
75 | - $this->setScriptHandle($script_handle); |
|
76 | - $this->setScriptDependencies($script_dependencies); |
|
77 | - $this->setStyleHandle($style_handle); |
|
78 | - $this->setStyleDependencies($style_dependencies); |
|
79 | - $this->domain = $domain; |
|
80 | - $this->registry = $registry; |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * @return string |
|
86 | - */ |
|
87 | - public function scriptHandle() |
|
88 | - { |
|
89 | - return $this->script_handle; |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * @param string $script_handle |
|
95 | - * @throws InvalidDataTypeException |
|
96 | - */ |
|
97 | - private function setScriptHandle($script_handle) |
|
98 | - { |
|
99 | - if (! is_string($script_handle)) { |
|
100 | - throw new InvalidDataTypeException('$script_handle', $script_handle, 'string'); |
|
101 | - } |
|
102 | - $this->script_handle = $script_handle; |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - /** |
|
107 | - * @return string |
|
108 | - */ |
|
109 | - public function styleHandle() |
|
110 | - { |
|
111 | - return $this->style_handle; |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * @param string $style_handle |
|
117 | - * @throws InvalidDataTypeException |
|
118 | - */ |
|
119 | - private function setStyleHandle($style_handle) |
|
120 | - { |
|
121 | - if (! is_string($style_handle)) { |
|
122 | - throw new InvalidDataTypeException('$style_handle', $style_handle, 'string'); |
|
123 | - } |
|
124 | - $this->style_handle = $style_handle; |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * @return array |
|
130 | - */ |
|
131 | - private function scriptDependencies() |
|
132 | - { |
|
133 | - return $this->script_dependencies; |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - /** |
|
138 | - * @param array $script_dependencies |
|
139 | - */ |
|
140 | - private function setScriptDependencies(array $script_dependencies) |
|
141 | - { |
|
142 | - $this->script_dependencies = $script_dependencies + array( |
|
143 | - 'eejs-core', |
|
144 | - 'wp-blocks', // Provides useful functions and components for extending the editor |
|
145 | - 'wp-i18n', // Provides localization functions |
|
146 | - 'wp-element', // Provides React.Component |
|
147 | - 'wp-components' // Provides many prebuilt components and controls |
|
148 | - ); |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * @return array |
|
154 | - */ |
|
155 | - private function styleDependencies() |
|
156 | - { |
|
157 | - return $this->style_dependencies; |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * @param array $style_dependencies |
|
163 | - */ |
|
164 | - private function setStyleDependencies(array $style_dependencies) |
|
165 | - { |
|
166 | - $this->style_dependencies = $style_dependencies; |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - /** |
|
171 | - * @return void |
|
172 | - * @throws \EventEspresso\core\exceptions\InvalidFilePathException |
|
173 | - * @throws \InvalidArgumentException |
|
174 | - */ |
|
175 | - public function registerManifestFile() |
|
176 | - { |
|
177 | - if($this->domain->assetNamespace() !== Registry::ASSET_NAMESPACE_CORE) { |
|
178 | - $this->registry->registerManifestFile( |
|
179 | - $this->domain->assetNamespace(), |
|
180 | - $this->domain->distributionAssetsUrl(), |
|
181 | - $this->domain->distributionAssetsPath() . Registry::FILE_NAME_BUILD_MANIFEST |
|
182 | - ); |
|
183 | - } |
|
184 | - } |
|
185 | - |
|
186 | - |
|
187 | - /** |
|
188 | - * @return void |
|
189 | - */ |
|
190 | - public function registerScripts() |
|
191 | - { |
|
192 | - wp_register_script( |
|
193 | - $this->scriptHandle(), |
|
194 | - $this->registry->getJsUrl( |
|
195 | - $this->domain->assetNamespace(), |
|
196 | - $this->scriptHandle() |
|
197 | - ), |
|
198 | - $this->scriptDependencies(), |
|
199 | - null, |
|
200 | - true |
|
201 | - ); |
|
202 | - } |
|
203 | - |
|
204 | - |
|
205 | - /** |
|
206 | - * @return void |
|
207 | - */ |
|
208 | - public function registerStyles() |
|
209 | - { |
|
210 | - wp_register_style( |
|
211 | - $this->styleHandle(), |
|
212 | - $this->registry->getCssUrl( |
|
213 | - $this->domain->assetNamespace(), |
|
214 | - $this->styleHandle() |
|
215 | - ), |
|
216 | - $this->styleDependencies() |
|
217 | - ); |
|
218 | - } |
|
25 | + /** |
|
26 | + * @var DomainInterface $domain |
|
27 | + */ |
|
28 | + private $domain; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var Registry $registry |
|
32 | + */ |
|
33 | + private $registry; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var string $script_handle |
|
37 | + */ |
|
38 | + private $script_handle; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var array $script_dependencies |
|
42 | + */ |
|
43 | + private $script_dependencies; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var string $style_handle |
|
47 | + */ |
|
48 | + private $style_handle; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var array $style_dependencies |
|
52 | + */ |
|
53 | + private $style_dependencies; |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * BlockAssetRegister constructor. |
|
58 | + * |
|
59 | + * @param string $script_handle |
|
60 | + * @param array $script_dependencies |
|
61 | + * @param string $style_handle |
|
62 | + * @param array $style_dependencies |
|
63 | + * @param DomainInterface $domain |
|
64 | + * @param Registry $registry |
|
65 | + * @throws InvalidDataTypeException |
|
66 | + */ |
|
67 | + public function __construct( |
|
68 | + $script_handle, |
|
69 | + array $script_dependencies, |
|
70 | + $style_handle, |
|
71 | + array $style_dependencies, |
|
72 | + DomainInterface $domain, |
|
73 | + Registry $registry |
|
74 | + ) { |
|
75 | + $this->setScriptHandle($script_handle); |
|
76 | + $this->setScriptDependencies($script_dependencies); |
|
77 | + $this->setStyleHandle($style_handle); |
|
78 | + $this->setStyleDependencies($style_dependencies); |
|
79 | + $this->domain = $domain; |
|
80 | + $this->registry = $registry; |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * @return string |
|
86 | + */ |
|
87 | + public function scriptHandle() |
|
88 | + { |
|
89 | + return $this->script_handle; |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * @param string $script_handle |
|
95 | + * @throws InvalidDataTypeException |
|
96 | + */ |
|
97 | + private function setScriptHandle($script_handle) |
|
98 | + { |
|
99 | + if (! is_string($script_handle)) { |
|
100 | + throw new InvalidDataTypeException('$script_handle', $script_handle, 'string'); |
|
101 | + } |
|
102 | + $this->script_handle = $script_handle; |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + /** |
|
107 | + * @return string |
|
108 | + */ |
|
109 | + public function styleHandle() |
|
110 | + { |
|
111 | + return $this->style_handle; |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * @param string $style_handle |
|
117 | + * @throws InvalidDataTypeException |
|
118 | + */ |
|
119 | + private function setStyleHandle($style_handle) |
|
120 | + { |
|
121 | + if (! is_string($style_handle)) { |
|
122 | + throw new InvalidDataTypeException('$style_handle', $style_handle, 'string'); |
|
123 | + } |
|
124 | + $this->style_handle = $style_handle; |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * @return array |
|
130 | + */ |
|
131 | + private function scriptDependencies() |
|
132 | + { |
|
133 | + return $this->script_dependencies; |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + /** |
|
138 | + * @param array $script_dependencies |
|
139 | + */ |
|
140 | + private function setScriptDependencies(array $script_dependencies) |
|
141 | + { |
|
142 | + $this->script_dependencies = $script_dependencies + array( |
|
143 | + 'eejs-core', |
|
144 | + 'wp-blocks', // Provides useful functions and components for extending the editor |
|
145 | + 'wp-i18n', // Provides localization functions |
|
146 | + 'wp-element', // Provides React.Component |
|
147 | + 'wp-components' // Provides many prebuilt components and controls |
|
148 | + ); |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * @return array |
|
154 | + */ |
|
155 | + private function styleDependencies() |
|
156 | + { |
|
157 | + return $this->style_dependencies; |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * @param array $style_dependencies |
|
163 | + */ |
|
164 | + private function setStyleDependencies(array $style_dependencies) |
|
165 | + { |
|
166 | + $this->style_dependencies = $style_dependencies; |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + /** |
|
171 | + * @return void |
|
172 | + * @throws \EventEspresso\core\exceptions\InvalidFilePathException |
|
173 | + * @throws \InvalidArgumentException |
|
174 | + */ |
|
175 | + public function registerManifestFile() |
|
176 | + { |
|
177 | + if($this->domain->assetNamespace() !== Registry::ASSET_NAMESPACE_CORE) { |
|
178 | + $this->registry->registerManifestFile( |
|
179 | + $this->domain->assetNamespace(), |
|
180 | + $this->domain->distributionAssetsUrl(), |
|
181 | + $this->domain->distributionAssetsPath() . Registry::FILE_NAME_BUILD_MANIFEST |
|
182 | + ); |
|
183 | + } |
|
184 | + } |
|
185 | + |
|
186 | + |
|
187 | + /** |
|
188 | + * @return void |
|
189 | + */ |
|
190 | + public function registerScripts() |
|
191 | + { |
|
192 | + wp_register_script( |
|
193 | + $this->scriptHandle(), |
|
194 | + $this->registry->getJsUrl( |
|
195 | + $this->domain->assetNamespace(), |
|
196 | + $this->scriptHandle() |
|
197 | + ), |
|
198 | + $this->scriptDependencies(), |
|
199 | + null, |
|
200 | + true |
|
201 | + ); |
|
202 | + } |
|
203 | + |
|
204 | + |
|
205 | + /** |
|
206 | + * @return void |
|
207 | + */ |
|
208 | + public function registerStyles() |
|
209 | + { |
|
210 | + wp_register_style( |
|
211 | + $this->styleHandle(), |
|
212 | + $this->registry->getCssUrl( |
|
213 | + $this->domain->assetNamespace(), |
|
214 | + $this->styleHandle() |
|
215 | + ), |
|
216 | + $this->styleDependencies() |
|
217 | + ); |
|
218 | + } |
|
219 | 219 | } |
220 | 220 | \ No newline at end of file |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | */ |
97 | 97 | private function setScriptHandle($script_handle) |
98 | 98 | { |
99 | - if (! is_string($script_handle)) { |
|
99 | + if ( ! is_string($script_handle)) { |
|
100 | 100 | throw new InvalidDataTypeException('$script_handle', $script_handle, 'string'); |
101 | 101 | } |
102 | 102 | $this->script_handle = $script_handle; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | private function setStyleHandle($style_handle) |
120 | 120 | { |
121 | - if (! is_string($style_handle)) { |
|
121 | + if ( ! is_string($style_handle)) { |
|
122 | 122 | throw new InvalidDataTypeException('$style_handle', $style_handle, 'string'); |
123 | 123 | } |
124 | 124 | $this->style_handle = $style_handle; |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | { |
142 | 142 | $this->script_dependencies = $script_dependencies + array( |
143 | 143 | 'eejs-core', |
144 | - 'wp-blocks', // Provides useful functions and components for extending the editor |
|
145 | - 'wp-i18n', // Provides localization functions |
|
146 | - 'wp-element', // Provides React.Component |
|
144 | + 'wp-blocks', // Provides useful functions and components for extending the editor |
|
145 | + 'wp-i18n', // Provides localization functions |
|
146 | + 'wp-element', // Provides React.Component |
|
147 | 147 | 'wp-components' // Provides many prebuilt components and controls |
148 | 148 | ); |
149 | 149 | } |
@@ -174,11 +174,11 @@ discard block |
||
174 | 174 | */ |
175 | 175 | public function registerManifestFile() |
176 | 176 | { |
177 | - if($this->domain->assetNamespace() !== Registry::ASSET_NAMESPACE_CORE) { |
|
177 | + if ($this->domain->assetNamespace() !== Registry::ASSET_NAMESPACE_CORE) { |
|
178 | 178 | $this->registry->registerManifestFile( |
179 | 179 | $this->domain->assetNamespace(), |
180 | 180 | $this->domain->distributionAssetsUrl(), |
181 | - $this->domain->distributionAssetsPath() . Registry::FILE_NAME_BUILD_MANIFEST |
|
181 | + $this->domain->distributionAssetsPath().Registry::FILE_NAME_BUILD_MANIFEST |
|
182 | 182 | ); |
183 | 183 | } |
184 | 184 | } |
@@ -16,28 +16,28 @@ |
||
16 | 16 | */ |
17 | 17 | interface AssetRegisterInterface |
18 | 18 | { |
19 | - /** |
|
20 | - * @return void |
|
21 | - */ |
|
22 | - public function registerManifestFile(); |
|
23 | - |
|
24 | - /** |
|
25 | - * @return void |
|
26 | - */ |
|
27 | - public function registerScripts(); |
|
28 | - |
|
29 | - /** |
|
30 | - * @return void |
|
31 | - */ |
|
32 | - public function registerStyles(); |
|
33 | - |
|
34 | - /** |
|
35 | - * @return string |
|
36 | - */ |
|
37 | - public function scriptHandle(); |
|
38 | - |
|
39 | - /** |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - public function styleHandle(); |
|
19 | + /** |
|
20 | + * @return void |
|
21 | + */ |
|
22 | + public function registerManifestFile(); |
|
23 | + |
|
24 | + /** |
|
25 | + * @return void |
|
26 | + */ |
|
27 | + public function registerScripts(); |
|
28 | + |
|
29 | + /** |
|
30 | + * @return void |
|
31 | + */ |
|
32 | + public function registerStyles(); |
|
33 | + |
|
34 | + /** |
|
35 | + * @return string |
|
36 | + */ |
|
37 | + public function scriptHandle(); |
|
38 | + |
|
39 | + /** |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + public function styleHandle(); |
|
43 | 43 | } |
44 | 44 | \ No newline at end of file |