@@ -23,284 +23,284 @@ |
||
23 | 23 | abstract class AssetManager implements AssetManagerInterface |
24 | 24 | { |
25 | 25 | |
26 | - /** |
|
27 | - * @var AssetCollection $assets |
|
28 | - */ |
|
29 | - protected $assets; |
|
26 | + /** |
|
27 | + * @var AssetCollection $assets |
|
28 | + */ |
|
29 | + protected $assets; |
|
30 | 30 | |
31 | - /** |
|
32 | - * @var DomainInterface |
|
33 | - */ |
|
34 | - protected $domain; |
|
31 | + /** |
|
32 | + * @var DomainInterface |
|
33 | + */ |
|
34 | + protected $domain; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @var Registry $registry |
|
38 | - */ |
|
39 | - protected $registry; |
|
36 | + /** |
|
37 | + * @var Registry $registry |
|
38 | + */ |
|
39 | + protected $registry; |
|
40 | 40 | |
41 | 41 | |
42 | - /** |
|
43 | - * AssetRegister constructor. |
|
44 | - * |
|
45 | - * @param DomainInterface $domain |
|
46 | - * @param AssetCollection $assets |
|
47 | - * @param Registry $registry |
|
48 | - */ |
|
49 | - public function __construct(DomainInterface $domain, AssetCollection $assets, Registry $registry) |
|
50 | - { |
|
51 | - $this->domain = $domain; |
|
52 | - $this->assets = $assets; |
|
53 | - $this->registry = $registry; |
|
54 | - add_action('wp_enqueue_scripts', array($this, 'addManifestFile'), 0); |
|
55 | - add_action('admin_enqueue_scripts', array($this, 'addManifestFile'), 0); |
|
56 | - add_action('wp_enqueue_scripts', array($this, 'addAssets'), 2); |
|
57 | - add_action('admin_enqueue_scripts', array($this, 'addAssets'), 2); |
|
58 | - } |
|
42 | + /** |
|
43 | + * AssetRegister constructor. |
|
44 | + * |
|
45 | + * @param DomainInterface $domain |
|
46 | + * @param AssetCollection $assets |
|
47 | + * @param Registry $registry |
|
48 | + */ |
|
49 | + public function __construct(DomainInterface $domain, AssetCollection $assets, Registry $registry) |
|
50 | + { |
|
51 | + $this->domain = $domain; |
|
52 | + $this->assets = $assets; |
|
53 | + $this->registry = $registry; |
|
54 | + add_action('wp_enqueue_scripts', array($this, 'addManifestFile'), 0); |
|
55 | + add_action('admin_enqueue_scripts', array($this, 'addManifestFile'), 0); |
|
56 | + add_action('wp_enqueue_scripts', array($this, 'addAssets'), 2); |
|
57 | + add_action('admin_enqueue_scripts', array($this, 'addAssets'), 2); |
|
58 | + } |
|
59 | 59 | |
60 | 60 | |
61 | - /** |
|
62 | - * @since 4.9.71.p |
|
63 | - * @return string |
|
64 | - */ |
|
65 | - public function assetNamespace() |
|
66 | - { |
|
67 | - return $this->domain->assetNamespace(); |
|
68 | - } |
|
61 | + /** |
|
62 | + * @since 4.9.71.p |
|
63 | + * @return string |
|
64 | + */ |
|
65 | + public function assetNamespace() |
|
66 | + { |
|
67 | + return $this->domain->assetNamespace(); |
|
68 | + } |
|
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * @return void |
|
73 | - * @throws DuplicateCollectionIdentifierException |
|
74 | - * @throws InvalidDataTypeException |
|
75 | - * @throws InvalidEntityException |
|
76 | - * @since 4.9.62.p |
|
77 | - */ |
|
78 | - public function addManifestFile() |
|
79 | - { |
|
80 | - // if a manifest file has already been added for this domain, then just return |
|
81 | - if ($this->assets->has($this->domain->assetNamespace())) { |
|
82 | - return; |
|
83 | - } |
|
84 | - $asset = new ManifestFile($this->domain); |
|
85 | - $this->assets->add($asset, $this->domain->assetNamespace()); |
|
86 | - } |
|
71 | + /** |
|
72 | + * @return void |
|
73 | + * @throws DuplicateCollectionIdentifierException |
|
74 | + * @throws InvalidDataTypeException |
|
75 | + * @throws InvalidEntityException |
|
76 | + * @since 4.9.62.p |
|
77 | + */ |
|
78 | + public function addManifestFile() |
|
79 | + { |
|
80 | + // if a manifest file has already been added for this domain, then just return |
|
81 | + if ($this->assets->has($this->domain->assetNamespace())) { |
|
82 | + return; |
|
83 | + } |
|
84 | + $asset = new ManifestFile($this->domain); |
|
85 | + $this->assets->add($asset, $this->domain->assetNamespace()); |
|
86 | + } |
|
87 | 87 | |
88 | 88 | |
89 | - /** |
|
90 | - * @return ManifestFile[] |
|
91 | - * @since 4.9.62.p |
|
92 | - */ |
|
93 | - public function getManifestFile() |
|
94 | - { |
|
95 | - return $this->assets->getManifestFiles(); |
|
96 | - } |
|
89 | + /** |
|
90 | + * @return ManifestFile[] |
|
91 | + * @since 4.9.62.p |
|
92 | + */ |
|
93 | + public function getManifestFile() |
|
94 | + { |
|
95 | + return $this->assets->getManifestFiles(); |
|
96 | + } |
|
97 | 97 | |
98 | 98 | |
99 | - /** |
|
100 | - * @param string $handle |
|
101 | - * @param string $source |
|
102 | - * @param array $dependencies |
|
103 | - * @param bool $load_in_footer |
|
104 | - * @param string $version |
|
105 | - * @return JavascriptAsset |
|
106 | - * @throws DuplicateCollectionIdentifierException |
|
107 | - * @throws InvalidDataTypeException |
|
108 | - * @throws InvalidEntityException |
|
109 | - * @throws DomainException |
|
110 | - * @since 4.9.62.p |
|
111 | - */ |
|
112 | - public function addJavascript( |
|
113 | - $handle, |
|
114 | - $source, |
|
115 | - array $dependencies = array(), |
|
116 | - $load_in_footer = true, |
|
117 | - $version = '' |
|
118 | - ) { |
|
119 | - $asset = new JavascriptAsset( |
|
120 | - $handle, |
|
121 | - $source, |
|
122 | - array_unique($dependencies), |
|
123 | - $load_in_footer, |
|
124 | - $this->domain, |
|
125 | - $version |
|
126 | - ); |
|
127 | - $this->assets->add($asset, $handle); |
|
128 | - return $asset; |
|
129 | - } |
|
99 | + /** |
|
100 | + * @param string $handle |
|
101 | + * @param string $source |
|
102 | + * @param array $dependencies |
|
103 | + * @param bool $load_in_footer |
|
104 | + * @param string $version |
|
105 | + * @return JavascriptAsset |
|
106 | + * @throws DuplicateCollectionIdentifierException |
|
107 | + * @throws InvalidDataTypeException |
|
108 | + * @throws InvalidEntityException |
|
109 | + * @throws DomainException |
|
110 | + * @since 4.9.62.p |
|
111 | + */ |
|
112 | + public function addJavascript( |
|
113 | + $handle, |
|
114 | + $source, |
|
115 | + array $dependencies = array(), |
|
116 | + $load_in_footer = true, |
|
117 | + $version = '' |
|
118 | + ) { |
|
119 | + $asset = new JavascriptAsset( |
|
120 | + $handle, |
|
121 | + $source, |
|
122 | + array_unique($dependencies), |
|
123 | + $load_in_footer, |
|
124 | + $this->domain, |
|
125 | + $version |
|
126 | + ); |
|
127 | + $this->assets->add($asset, $handle); |
|
128 | + return $asset; |
|
129 | + } |
|
130 | 130 | |
131 | 131 | |
132 | - /** |
|
133 | - * Used to register a javascript asset where everything is dynamically derived from the given handle. |
|
134 | - * |
|
135 | - * @param string $handle |
|
136 | - * @param string|array $extra_dependencies |
|
137 | - * @return JavascriptAsset |
|
138 | - * @throws DuplicateCollectionIdentifierException |
|
139 | - * @throws InvalidDataTypeException |
|
140 | - * @throws InvalidEntityException |
|
141 | - * @throws DomainException |
|
142 | - */ |
|
143 | - public function addJs($handle, $extra_dependencies = []) |
|
144 | - { |
|
145 | - $details = $this->getAssetDetails( |
|
146 | - Asset::TYPE_JS, |
|
147 | - $handle, |
|
148 | - $extra_dependencies |
|
149 | - ); |
|
150 | - return $this->addJavascript( |
|
151 | - $handle, |
|
152 | - $this->registry->getJsUrl($this->domain->assetNamespace(), $handle), |
|
153 | - $details['dependencies'], |
|
154 | - true, |
|
155 | - $details['version'] |
|
156 | - ); |
|
157 | - } |
|
132 | + /** |
|
133 | + * Used to register a javascript asset where everything is dynamically derived from the given handle. |
|
134 | + * |
|
135 | + * @param string $handle |
|
136 | + * @param string|array $extra_dependencies |
|
137 | + * @return JavascriptAsset |
|
138 | + * @throws DuplicateCollectionIdentifierException |
|
139 | + * @throws InvalidDataTypeException |
|
140 | + * @throws InvalidEntityException |
|
141 | + * @throws DomainException |
|
142 | + */ |
|
143 | + public function addJs($handle, $extra_dependencies = []) |
|
144 | + { |
|
145 | + $details = $this->getAssetDetails( |
|
146 | + Asset::TYPE_JS, |
|
147 | + $handle, |
|
148 | + $extra_dependencies |
|
149 | + ); |
|
150 | + return $this->addJavascript( |
|
151 | + $handle, |
|
152 | + $this->registry->getJsUrl($this->domain->assetNamespace(), $handle), |
|
153 | + $details['dependencies'], |
|
154 | + true, |
|
155 | + $details['version'] |
|
156 | + ); |
|
157 | + } |
|
158 | 158 | |
159 | 159 | |
160 | - /** |
|
161 | - * @param string $handle |
|
162 | - * @param array $dependencies |
|
163 | - * @param bool $load_in_footer |
|
164 | - * @param string $version |
|
165 | - * @return JavascriptAsset |
|
166 | - * @throws DomainException |
|
167 | - * @throws DuplicateCollectionIdentifierException |
|
168 | - * @throws InvalidDataTypeException |
|
169 | - * @throws InvalidEntityException |
|
170 | - * @since 4.9.71.p |
|
171 | - */ |
|
172 | - public function addVendorJavascript( |
|
173 | - $handle, |
|
174 | - array $dependencies = array(), |
|
175 | - $load_in_footer = true, |
|
176 | - $version = '' |
|
177 | - ) { |
|
178 | - $dev_suffix = wp_scripts_get_suffix('dev'); |
|
179 | - $vendor_path = $this->domain->pluginUrl() . 'assets/vendor/'; |
|
180 | - return $this->addJavascript( |
|
181 | - $handle, |
|
182 | - "{$vendor_path}{$handle}{$dev_suffix}". Asset::EXT_JS, |
|
183 | - $dependencies, |
|
184 | - $load_in_footer, |
|
185 | - $version |
|
186 | - ); |
|
187 | - } |
|
160 | + /** |
|
161 | + * @param string $handle |
|
162 | + * @param array $dependencies |
|
163 | + * @param bool $load_in_footer |
|
164 | + * @param string $version |
|
165 | + * @return JavascriptAsset |
|
166 | + * @throws DomainException |
|
167 | + * @throws DuplicateCollectionIdentifierException |
|
168 | + * @throws InvalidDataTypeException |
|
169 | + * @throws InvalidEntityException |
|
170 | + * @since 4.9.71.p |
|
171 | + */ |
|
172 | + public function addVendorJavascript( |
|
173 | + $handle, |
|
174 | + array $dependencies = array(), |
|
175 | + $load_in_footer = true, |
|
176 | + $version = '' |
|
177 | + ) { |
|
178 | + $dev_suffix = wp_scripts_get_suffix('dev'); |
|
179 | + $vendor_path = $this->domain->pluginUrl() . 'assets/vendor/'; |
|
180 | + return $this->addJavascript( |
|
181 | + $handle, |
|
182 | + "{$vendor_path}{$handle}{$dev_suffix}". Asset::EXT_JS, |
|
183 | + $dependencies, |
|
184 | + $load_in_footer, |
|
185 | + $version |
|
186 | + ); |
|
187 | + } |
|
188 | 188 | |
189 | 189 | |
190 | - /** |
|
191 | - * @param string $handle |
|
192 | - * @param string $source |
|
193 | - * @param array $dependencies |
|
194 | - * @param string $media |
|
195 | - * @param string $version |
|
196 | - * @return StylesheetAsset |
|
197 | - * @throws DomainException |
|
198 | - * @throws DuplicateCollectionIdentifierException |
|
199 | - * @throws InvalidDataTypeException |
|
200 | - * @throws InvalidEntityException |
|
201 | - * @since 4.9.62.p |
|
202 | - */ |
|
203 | - public function addStylesheet( |
|
204 | - $handle, |
|
205 | - $source, |
|
206 | - array $dependencies = array(), |
|
207 | - $media = 'all', |
|
208 | - $version = '' |
|
209 | - ) { |
|
210 | - $asset = new StylesheetAsset( |
|
211 | - $handle, |
|
212 | - $source, |
|
213 | - array_unique($dependencies), |
|
214 | - $this->domain, |
|
215 | - $media, |
|
216 | - $version |
|
217 | - ); |
|
218 | - $this->assets->add($asset, $handle); |
|
219 | - return $asset; |
|
220 | - } |
|
190 | + /** |
|
191 | + * @param string $handle |
|
192 | + * @param string $source |
|
193 | + * @param array $dependencies |
|
194 | + * @param string $media |
|
195 | + * @param string $version |
|
196 | + * @return StylesheetAsset |
|
197 | + * @throws DomainException |
|
198 | + * @throws DuplicateCollectionIdentifierException |
|
199 | + * @throws InvalidDataTypeException |
|
200 | + * @throws InvalidEntityException |
|
201 | + * @since 4.9.62.p |
|
202 | + */ |
|
203 | + public function addStylesheet( |
|
204 | + $handle, |
|
205 | + $source, |
|
206 | + array $dependencies = array(), |
|
207 | + $media = 'all', |
|
208 | + $version = '' |
|
209 | + ) { |
|
210 | + $asset = new StylesheetAsset( |
|
211 | + $handle, |
|
212 | + $source, |
|
213 | + array_unique($dependencies), |
|
214 | + $this->domain, |
|
215 | + $media, |
|
216 | + $version |
|
217 | + ); |
|
218 | + $this->assets->add($asset, $handle); |
|
219 | + return $asset; |
|
220 | + } |
|
221 | 221 | |
222 | 222 | |
223 | - /** |
|
224 | - * Used to register a css asset where everything is dynamically derived from the given handle. |
|
225 | - * |
|
226 | - * @param string $handle |
|
227 | - * @param string|array $extra_dependencies |
|
228 | - * @return StylesheetAsset |
|
229 | - * @throws DuplicateCollectionIdentifierException |
|
230 | - * @throws InvalidDataTypeException |
|
231 | - * @throws InvalidEntityException |
|
232 | - * @throws DomainException |
|
233 | - */ |
|
234 | - public function addCss($handle, $extra_dependencies = []) |
|
235 | - { |
|
236 | - $details = $this->getAssetDetails( |
|
237 | - Asset::TYPE_CSS, |
|
238 | - $handle, |
|
239 | - $extra_dependencies |
|
240 | - ); |
|
241 | - return $this->addStylesheet( |
|
242 | - $handle, |
|
243 | - $this->registry->getCssUrl($this->domain->assetNamespace(), $handle), |
|
244 | - $details['dependencies'], |
|
245 | - 'all', |
|
246 | - $details['version'] |
|
247 | - ); |
|
248 | - } |
|
223 | + /** |
|
224 | + * Used to register a css asset where everything is dynamically derived from the given handle. |
|
225 | + * |
|
226 | + * @param string $handle |
|
227 | + * @param string|array $extra_dependencies |
|
228 | + * @return StylesheetAsset |
|
229 | + * @throws DuplicateCollectionIdentifierException |
|
230 | + * @throws InvalidDataTypeException |
|
231 | + * @throws InvalidEntityException |
|
232 | + * @throws DomainException |
|
233 | + */ |
|
234 | + public function addCss($handle, $extra_dependencies = []) |
|
235 | + { |
|
236 | + $details = $this->getAssetDetails( |
|
237 | + Asset::TYPE_CSS, |
|
238 | + $handle, |
|
239 | + $extra_dependencies |
|
240 | + ); |
|
241 | + return $this->addStylesheet( |
|
242 | + $handle, |
|
243 | + $this->registry->getCssUrl($this->domain->assetNamespace(), $handle), |
|
244 | + $details['dependencies'], |
|
245 | + 'all', |
|
246 | + $details['version'] |
|
247 | + ); |
|
248 | + } |
|
249 | 249 | |
250 | 250 | |
251 | - /** |
|
252 | - * @param string $handle |
|
253 | - * @return bool |
|
254 | - * @since 4.9.62.p |
|
255 | - */ |
|
256 | - public function enqueueAsset($handle) |
|
257 | - { |
|
258 | - if ($this->assets->has($handle)) { |
|
259 | - $asset = $this->assets->get($handle); |
|
260 | - if ($asset->isRegistered()) { |
|
261 | - $asset->enqueueAsset(); |
|
262 | - return true; |
|
263 | - } |
|
264 | - } |
|
265 | - return false; |
|
266 | - } |
|
251 | + /** |
|
252 | + * @param string $handle |
|
253 | + * @return bool |
|
254 | + * @since 4.9.62.p |
|
255 | + */ |
|
256 | + public function enqueueAsset($handle) |
|
257 | + { |
|
258 | + if ($this->assets->has($handle)) { |
|
259 | + $asset = $this->assets->get($handle); |
|
260 | + if ($asset->isRegistered()) { |
|
261 | + $asset->enqueueAsset(); |
|
262 | + return true; |
|
263 | + } |
|
264 | + } |
|
265 | + return false; |
|
266 | + } |
|
267 | 267 | |
268 | 268 | |
269 | - /** |
|
270 | - * @param string $asset_type |
|
271 | - * @param string $handle |
|
272 | - * @param array $extra_dependencies |
|
273 | - * @return array |
|
274 | - * @since 4.10.2.p |
|
275 | - */ |
|
276 | - private function getAssetDetails($asset_type, $handle, $extra_dependencies = []) |
|
277 | - { |
|
278 | - $getAssetDetails = ''; |
|
279 | - switch ($asset_type) { |
|
280 | - case Asset::TYPE_JS : |
|
281 | - $getAssetDetails = 'getJsAssetDetails'; |
|
282 | - break; |
|
283 | - case Asset::TYPE_CSS : |
|
284 | - $getAssetDetails = 'getCssAssetDetails'; |
|
285 | - break; |
|
286 | - } |
|
287 | - if ($getAssetDetails === '') { |
|
288 | - return ['dependencies' => [], 'version' => '']; |
|
289 | - } |
|
290 | - $details = $this->registry->$getAssetDetails( |
|
291 | - $this->domain->assetNamespace(), |
|
292 | - $handle |
|
293 | - ); |
|
294 | - $details['dependencies'] = isset($details['dependencies']) |
|
295 | - ? $details['dependencies'] |
|
296 | - : []; |
|
297 | - $details['version'] = isset($details['version']) |
|
298 | - ? $details['version'] |
|
299 | - : ''; |
|
300 | - $details['dependencies'] = ! empty($extra_dependencies) |
|
301 | - ? array_merge($details['dependencies'], (array) $extra_dependencies) |
|
302 | - : $details['dependencies']; |
|
303 | - return $details; |
|
269 | + /** |
|
270 | + * @param string $asset_type |
|
271 | + * @param string $handle |
|
272 | + * @param array $extra_dependencies |
|
273 | + * @return array |
|
274 | + * @since 4.10.2.p |
|
275 | + */ |
|
276 | + private function getAssetDetails($asset_type, $handle, $extra_dependencies = []) |
|
277 | + { |
|
278 | + $getAssetDetails = ''; |
|
279 | + switch ($asset_type) { |
|
280 | + case Asset::TYPE_JS : |
|
281 | + $getAssetDetails = 'getJsAssetDetails'; |
|
282 | + break; |
|
283 | + case Asset::TYPE_CSS : |
|
284 | + $getAssetDetails = 'getCssAssetDetails'; |
|
285 | + break; |
|
286 | + } |
|
287 | + if ($getAssetDetails === '') { |
|
288 | + return ['dependencies' => [], 'version' => '']; |
|
289 | + } |
|
290 | + $details = $this->registry->$getAssetDetails( |
|
291 | + $this->domain->assetNamespace(), |
|
292 | + $handle |
|
293 | + ); |
|
294 | + $details['dependencies'] = isset($details['dependencies']) |
|
295 | + ? $details['dependencies'] |
|
296 | + : []; |
|
297 | + $details['version'] = isset($details['version']) |
|
298 | + ? $details['version'] |
|
299 | + : ''; |
|
300 | + $details['dependencies'] = ! empty($extra_dependencies) |
|
301 | + ? array_merge($details['dependencies'], (array) $extra_dependencies) |
|
302 | + : $details['dependencies']; |
|
303 | + return $details; |
|
304 | 304 | |
305 | - } |
|
305 | + } |
|
306 | 306 | } |
@@ -176,10 +176,10 @@ |
||
176 | 176 | $version = '' |
177 | 177 | ) { |
178 | 178 | $dev_suffix = wp_scripts_get_suffix('dev'); |
179 | - $vendor_path = $this->domain->pluginUrl() . 'assets/vendor/'; |
|
179 | + $vendor_path = $this->domain->pluginUrl().'assets/vendor/'; |
|
180 | 180 | return $this->addJavascript( |
181 | 181 | $handle, |
182 | - "{$vendor_path}{$handle}{$dev_suffix}". Asset::EXT_JS, |
|
182 | + "{$vendor_path}{$handle}{$dev_suffix}".Asset::EXT_JS, |
|
183 | 183 | $dependencies, |
184 | 184 | $load_in_footer, |
185 | 185 | $version |
@@ -31,392 +31,392 @@ |
||
31 | 31 | class PersistentAdminNoticeManager |
32 | 32 | { |
33 | 33 | |
34 | - const WP_OPTION_KEY = 'ee_pers_admin_notices'; |
|
35 | - |
|
36 | - /** |
|
37 | - * @var Collection|PersistentAdminNotice[] $notice_collection |
|
38 | - */ |
|
39 | - private $notice_collection; |
|
40 | - |
|
41 | - /** |
|
42 | - * if AJAX is not enabled, then the return URL will be used for redirecting back to the admin page where the |
|
43 | - * persistent admin notice was displayed, and ultimately dismissed from. |
|
44 | - * |
|
45 | - * @var string $return_url |
|
46 | - */ |
|
47 | - private $return_url; |
|
48 | - |
|
49 | - /** |
|
50 | - * @var CapabilitiesChecker $capabilities_checker |
|
51 | - */ |
|
52 | - private $capabilities_checker; |
|
53 | - |
|
54 | - /** |
|
55 | - * @var RequestInterface $request |
|
56 | - */ |
|
57 | - private $request; |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * PersistentAdminNoticeManager constructor |
|
62 | - * |
|
63 | - * @param CapabilitiesChecker $capabilities_checker |
|
64 | - * @param RequestInterface $request |
|
65 | - * @param string $return_url where to redirect to after dismissing notices |
|
66 | - * @throws InvalidDataTypeException |
|
67 | - */ |
|
68 | - public function __construct( |
|
69 | - CapabilitiesChecker $capabilities_checker, |
|
70 | - RequestInterface $request, |
|
71 | - $return_url = '' |
|
72 | - ) { |
|
73 | - $this->setReturnUrl($return_url); |
|
74 | - $this->capabilities_checker = $capabilities_checker; |
|
75 | - $this->request = $request; |
|
76 | - // setup up notices at priority 9 because `EE_Admin::display_admin_notices()` runs at priority 10, |
|
77 | - // and we want to retrieve and generate any nag notices at the last possible moment |
|
78 | - add_action('admin_notices', array($this, 'displayNotices'), 9); |
|
79 | - add_action('network_admin_notices', array($this, 'displayNotices'), 9); |
|
80 | - add_action('wp_ajax_dismiss_ee_nag_notice', array($this, 'dismissNotice')); |
|
81 | - add_action('shutdown', array($this, 'registerAndSaveNotices'), 998); |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * @param string $return_url |
|
87 | - * @throws InvalidDataTypeException |
|
88 | - */ |
|
89 | - public function setReturnUrl($return_url) |
|
90 | - { |
|
91 | - if (! is_string($return_url)) { |
|
92 | - throw new InvalidDataTypeException('$return_url', $return_url, 'string'); |
|
93 | - } |
|
94 | - $this->return_url = $return_url; |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * @return Collection |
|
100 | - * @throws InvalidEntityException |
|
101 | - * @throws InvalidInterfaceException |
|
102 | - * @throws InvalidDataTypeException |
|
103 | - * @throws DomainException |
|
104 | - * @throws DuplicateCollectionIdentifierException |
|
105 | - */ |
|
106 | - protected function getPersistentAdminNoticeCollection() |
|
107 | - { |
|
108 | - if (! $this->notice_collection instanceof Collection) { |
|
109 | - $this->notice_collection = new Collection( |
|
110 | - 'EventEspresso\core\domain\entities\notifications\PersistentAdminNotice' |
|
111 | - ); |
|
112 | - $this->retrieveStoredNotices(); |
|
113 | - $this->registerNotices(); |
|
114 | - } |
|
115 | - return $this->notice_collection; |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * generates PersistentAdminNotice objects for all non-dismissed notices saved to the db |
|
121 | - * |
|
122 | - * @return void |
|
123 | - * @throws InvalidEntityException |
|
124 | - * @throws DomainException |
|
125 | - * @throws InvalidDataTypeException |
|
126 | - * @throws DuplicateCollectionIdentifierException |
|
127 | - */ |
|
128 | - protected function retrieveStoredNotices() |
|
129 | - { |
|
130 | - $persistent_admin_notices = get_option(PersistentAdminNoticeManager::WP_OPTION_KEY, array()); |
|
131 | - if (! empty($persistent_admin_notices)) { |
|
132 | - foreach ($persistent_admin_notices as $name => $details) { |
|
133 | - if (is_array($details)) { |
|
134 | - if ( |
|
135 | - ! isset( |
|
136 | - $details['message'], |
|
137 | - $details['capability'], |
|
138 | - $details['cap_context'], |
|
139 | - $details['dismissed'] |
|
140 | - ) |
|
141 | - ) { |
|
142 | - throw new DomainException( |
|
143 | - sprintf( |
|
144 | - esc_html__( |
|
145 | - 'The "%1$s" PersistentAdminNotice could not be retrieved from the database.', |
|
146 | - 'event_espresso' |
|
147 | - ), |
|
148 | - $name |
|
149 | - ) |
|
150 | - ); |
|
151 | - } |
|
152 | - // new format for nag notices |
|
153 | - $this->notice_collection->add( |
|
154 | - new PersistentAdminNotice( |
|
155 | - $name, |
|
156 | - $details['message'], |
|
157 | - false, |
|
158 | - $details['capability'], |
|
159 | - $details['cap_context'], |
|
160 | - $details['dismissed'] |
|
161 | - ), |
|
162 | - sanitize_key($name) |
|
163 | - ); |
|
164 | - } else { |
|
165 | - try { |
|
166 | - // old nag notices, that we want to convert to the new format |
|
167 | - $this->notice_collection->add( |
|
168 | - new PersistentAdminNotice( |
|
169 | - $name, |
|
170 | - (string) $details, |
|
171 | - false, |
|
172 | - '', |
|
173 | - '', |
|
174 | - empty($details) |
|
175 | - ), |
|
176 | - sanitize_key($name) |
|
177 | - ); |
|
178 | - } catch (Exception $e) { |
|
179 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
180 | - } |
|
181 | - } |
|
182 | - // each notice will self register when the action hook in registerNotices is triggered |
|
183 | - } |
|
184 | - } |
|
185 | - } |
|
186 | - |
|
187 | - |
|
188 | - /** |
|
189 | - * exposes the Persistent Admin Notice Collection via an action |
|
190 | - * so that PersistentAdminNotice objects can be added and/or removed |
|
191 | - * without compromising the actual collection like a filter would |
|
192 | - */ |
|
193 | - protected function registerNotices() |
|
194 | - { |
|
195 | - do_action( |
|
196 | - 'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices', |
|
197 | - $this->notice_collection |
|
198 | - ); |
|
199 | - } |
|
200 | - |
|
201 | - |
|
202 | - /** |
|
203 | - * @throws DomainException |
|
204 | - * @throws InvalidClassException |
|
205 | - * @throws InvalidDataTypeException |
|
206 | - * @throws InvalidInterfaceException |
|
207 | - * @throws InvalidEntityException |
|
208 | - * @throws DuplicateCollectionIdentifierException |
|
209 | - */ |
|
210 | - public function displayNotices() |
|
211 | - { |
|
212 | - $this->notice_collection = $this->getPersistentAdminNoticeCollection(); |
|
213 | - if ($this->notice_collection->hasObjects()) { |
|
214 | - $enqueue_assets = false; |
|
215 | - // and display notices |
|
216 | - foreach ($this->notice_collection as $persistent_admin_notice) { |
|
217 | - /** @var PersistentAdminNotice $persistent_admin_notice */ |
|
218 | - // don't display notices that have already been dismissed |
|
219 | - if ($persistent_admin_notice->getDismissed()) { |
|
220 | - continue; |
|
221 | - } |
|
222 | - try { |
|
223 | - $this->capabilities_checker->processCapCheck( |
|
224 | - $persistent_admin_notice->getCapCheck() |
|
225 | - ); |
|
226 | - } catch (InsufficientPermissionsException $e) { |
|
227 | - // user does not have required cap, so skip to next notice |
|
228 | - // and just eat the exception - nom nom nom nom |
|
229 | - continue; |
|
230 | - } |
|
231 | - if ($persistent_admin_notice->getMessage() === '') { |
|
232 | - continue; |
|
233 | - } |
|
234 | - $this->displayPersistentAdminNotice($persistent_admin_notice); |
|
235 | - $enqueue_assets = true; |
|
236 | - } |
|
237 | - if ($enqueue_assets) { |
|
238 | - $this->enqueueAssets(); |
|
239 | - } |
|
240 | - } |
|
241 | - } |
|
242 | - |
|
243 | - |
|
244 | - /** |
|
245 | - * does what it's named |
|
246 | - * |
|
247 | - * @return void |
|
248 | - */ |
|
249 | - public function enqueueAssets() |
|
250 | - { |
|
251 | - wp_register_script( |
|
252 | - 'espresso_core', |
|
253 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
254 | - array('jquery'), |
|
255 | - EVENT_ESPRESSO_VERSION, |
|
256 | - true |
|
257 | - ); |
|
258 | - wp_register_script( |
|
259 | - 'ee_error_js', |
|
260 | - EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', |
|
261 | - array('espresso_core'), |
|
262 | - EVENT_ESPRESSO_VERSION, |
|
263 | - true |
|
264 | - ); |
|
265 | - wp_localize_script( |
|
266 | - 'ee_error_js', |
|
267 | - 'ee_dismiss', |
|
268 | - array( |
|
269 | - 'return_url' => urlencode($this->return_url), |
|
270 | - 'ajax_url' => WP_AJAX_URL, |
|
271 | - 'unknown_error' => wp_strip_all_tags( |
|
272 | - __( |
|
273 | - 'An unknown error has occurred on the server while attempting to dismiss this notice.', |
|
274 | - 'event_espresso' |
|
275 | - ) |
|
276 | - ), |
|
277 | - ) |
|
278 | - ); |
|
279 | - wp_enqueue_script('ee_error_js'); |
|
280 | - } |
|
281 | - |
|
282 | - |
|
283 | - /** |
|
284 | - * displayPersistentAdminNoticeHtml |
|
285 | - * |
|
286 | - * @param PersistentAdminNotice $persistent_admin_notice |
|
287 | - */ |
|
288 | - protected function displayPersistentAdminNotice(PersistentAdminNotice $persistent_admin_notice) |
|
289 | - { |
|
290 | - // used in template |
|
291 | - $persistent_admin_notice_name = $persistent_admin_notice->getName(); |
|
292 | - $persistent_admin_notice_message = $persistent_admin_notice->getMessage(); |
|
293 | - require EE_TEMPLATES . '/notifications/persistent_admin_notice.template.php'; |
|
294 | - } |
|
295 | - |
|
296 | - |
|
297 | - /** |
|
298 | - * dismissNotice |
|
299 | - * |
|
300 | - * @param string $pan_name the name, or key of the Persistent Admin Notice to be dismissed |
|
301 | - * @param bool $purge if true, then delete it from the db |
|
302 | - * @param bool $return forget all of this AJAX or redirect nonsense, and just return |
|
303 | - * @return void |
|
304 | - * @throws InvalidEntityException |
|
305 | - * @throws InvalidInterfaceException |
|
306 | - * @throws InvalidDataTypeException |
|
307 | - * @throws DomainException |
|
308 | - * @throws InvalidArgumentException |
|
309 | - * @throws InvalidArgumentException |
|
310 | - * @throws InvalidArgumentException |
|
311 | - * @throws InvalidArgumentException |
|
312 | - * @throws DuplicateCollectionIdentifierException |
|
313 | - */ |
|
314 | - public function dismissNotice($pan_name = '', $purge = false, $return = false) |
|
315 | - { |
|
316 | - $pan_name = $this->request->getRequestParam('ee_nag_notice', $pan_name); |
|
317 | - $this->notice_collection = $this->getPersistentAdminNoticeCollection(); |
|
318 | - if (! empty($pan_name) && $this->notice_collection->has($pan_name)) { |
|
319 | - /** @var PersistentAdminNotice $persistent_admin_notice */ |
|
320 | - $persistent_admin_notice = $this->notice_collection->get($pan_name); |
|
321 | - $persistent_admin_notice->setDismissed(true); |
|
322 | - $persistent_admin_notice->setPurge($purge); |
|
323 | - $this->saveNotices(); |
|
324 | - } |
|
325 | - if ($return) { |
|
326 | - return; |
|
327 | - } |
|
328 | - if ($this->request->isAjax()) { |
|
329 | - // grab any notices and concatenate into string |
|
330 | - echo wp_json_encode( |
|
331 | - array( |
|
332 | - 'errors' => implode('<br />', EE_Error::get_notices(false)), |
|
333 | - ) |
|
334 | - ); |
|
335 | - exit(); |
|
336 | - } |
|
337 | - // save errors to a transient to be displayed on next request (after redirect) |
|
338 | - EE_Error::get_notices(false, true); |
|
339 | - wp_safe_redirect( |
|
340 | - urldecode( |
|
341 | - $this->request->getRequestParam('return_url', '') |
|
342 | - ) |
|
343 | - ); |
|
344 | - } |
|
345 | - |
|
346 | - |
|
347 | - /** |
|
348 | - * saveNotices |
|
349 | - * |
|
350 | - * @throws DomainException |
|
351 | - * @throws InvalidDataTypeException |
|
352 | - * @throws InvalidInterfaceException |
|
353 | - * @throws InvalidEntityException |
|
354 | - * @throws DuplicateCollectionIdentifierException |
|
355 | - */ |
|
356 | - public function saveNotices() |
|
357 | - { |
|
358 | - $this->notice_collection = $this->getPersistentAdminNoticeCollection(); |
|
359 | - if ($this->notice_collection->hasObjects()) { |
|
360 | - $persistent_admin_notices = get_option(PersistentAdminNoticeManager::WP_OPTION_KEY, array()); |
|
361 | - // maybe initialize persistent_admin_notices |
|
362 | - if (empty($persistent_admin_notices)) { |
|
363 | - add_option(PersistentAdminNoticeManager::WP_OPTION_KEY, array(), '', 'no'); |
|
364 | - } |
|
365 | - foreach ($this->notice_collection as $persistent_admin_notice) { |
|
366 | - // are we deleting this notice ? |
|
367 | - if ($persistent_admin_notice->getPurge()) { |
|
368 | - unset($persistent_admin_notices[ $persistent_admin_notice->getName() ]); |
|
369 | - } else { |
|
370 | - /** @var PersistentAdminNotice $persistent_admin_notice */ |
|
371 | - $persistent_admin_notices[ $persistent_admin_notice->getName() ] = array( |
|
372 | - 'message' => $persistent_admin_notice->getMessage(), |
|
373 | - 'capability' => $persistent_admin_notice->getCapability(), |
|
374 | - 'cap_context' => $persistent_admin_notice->getCapContext(), |
|
375 | - 'dismissed' => $persistent_admin_notice->getDismissed(), |
|
376 | - ); |
|
377 | - } |
|
378 | - } |
|
379 | - update_option(PersistentAdminNoticeManager::WP_OPTION_KEY, $persistent_admin_notices); |
|
380 | - } |
|
381 | - } |
|
382 | - |
|
383 | - |
|
384 | - /** |
|
385 | - * @throws DomainException |
|
386 | - * @throws InvalidDataTypeException |
|
387 | - * @throws InvalidEntityException |
|
388 | - * @throws InvalidInterfaceException |
|
389 | - * @throws DuplicateCollectionIdentifierException |
|
390 | - */ |
|
391 | - public function registerAndSaveNotices() |
|
392 | - { |
|
393 | - $this->getPersistentAdminNoticeCollection(); |
|
394 | - $this->registerNotices(); |
|
395 | - $this->saveNotices(); |
|
396 | - add_filter( |
|
397 | - 'PersistentAdminNoticeManager__registerAndSaveNotices__complete', |
|
398 | - '__return_true' |
|
399 | - ); |
|
400 | - } |
|
401 | - |
|
402 | - |
|
403 | - /** |
|
404 | - * @throws DomainException |
|
405 | - * @throws InvalidDataTypeException |
|
406 | - * @throws InvalidEntityException |
|
407 | - * @throws InvalidInterfaceException |
|
408 | - * @throws InvalidArgumentException |
|
409 | - * @throws DuplicateCollectionIdentifierException |
|
410 | - */ |
|
411 | - public static function loadRegisterAndSaveNotices() |
|
412 | - { |
|
413 | - /** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */ |
|
414 | - $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared( |
|
415 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
416 | - ); |
|
417 | - // if shutdown has already run, then call registerAndSaveNotices() manually |
|
418 | - if (did_action('shutdown')) { |
|
419 | - $persistent_admin_notice_manager->registerAndSaveNotices(); |
|
420 | - } |
|
421 | - } |
|
34 | + const WP_OPTION_KEY = 'ee_pers_admin_notices'; |
|
35 | + |
|
36 | + /** |
|
37 | + * @var Collection|PersistentAdminNotice[] $notice_collection |
|
38 | + */ |
|
39 | + private $notice_collection; |
|
40 | + |
|
41 | + /** |
|
42 | + * if AJAX is not enabled, then the return URL will be used for redirecting back to the admin page where the |
|
43 | + * persistent admin notice was displayed, and ultimately dismissed from. |
|
44 | + * |
|
45 | + * @var string $return_url |
|
46 | + */ |
|
47 | + private $return_url; |
|
48 | + |
|
49 | + /** |
|
50 | + * @var CapabilitiesChecker $capabilities_checker |
|
51 | + */ |
|
52 | + private $capabilities_checker; |
|
53 | + |
|
54 | + /** |
|
55 | + * @var RequestInterface $request |
|
56 | + */ |
|
57 | + private $request; |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * PersistentAdminNoticeManager constructor |
|
62 | + * |
|
63 | + * @param CapabilitiesChecker $capabilities_checker |
|
64 | + * @param RequestInterface $request |
|
65 | + * @param string $return_url where to redirect to after dismissing notices |
|
66 | + * @throws InvalidDataTypeException |
|
67 | + */ |
|
68 | + public function __construct( |
|
69 | + CapabilitiesChecker $capabilities_checker, |
|
70 | + RequestInterface $request, |
|
71 | + $return_url = '' |
|
72 | + ) { |
|
73 | + $this->setReturnUrl($return_url); |
|
74 | + $this->capabilities_checker = $capabilities_checker; |
|
75 | + $this->request = $request; |
|
76 | + // setup up notices at priority 9 because `EE_Admin::display_admin_notices()` runs at priority 10, |
|
77 | + // and we want to retrieve and generate any nag notices at the last possible moment |
|
78 | + add_action('admin_notices', array($this, 'displayNotices'), 9); |
|
79 | + add_action('network_admin_notices', array($this, 'displayNotices'), 9); |
|
80 | + add_action('wp_ajax_dismiss_ee_nag_notice', array($this, 'dismissNotice')); |
|
81 | + add_action('shutdown', array($this, 'registerAndSaveNotices'), 998); |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * @param string $return_url |
|
87 | + * @throws InvalidDataTypeException |
|
88 | + */ |
|
89 | + public function setReturnUrl($return_url) |
|
90 | + { |
|
91 | + if (! is_string($return_url)) { |
|
92 | + throw new InvalidDataTypeException('$return_url', $return_url, 'string'); |
|
93 | + } |
|
94 | + $this->return_url = $return_url; |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * @return Collection |
|
100 | + * @throws InvalidEntityException |
|
101 | + * @throws InvalidInterfaceException |
|
102 | + * @throws InvalidDataTypeException |
|
103 | + * @throws DomainException |
|
104 | + * @throws DuplicateCollectionIdentifierException |
|
105 | + */ |
|
106 | + protected function getPersistentAdminNoticeCollection() |
|
107 | + { |
|
108 | + if (! $this->notice_collection instanceof Collection) { |
|
109 | + $this->notice_collection = new Collection( |
|
110 | + 'EventEspresso\core\domain\entities\notifications\PersistentAdminNotice' |
|
111 | + ); |
|
112 | + $this->retrieveStoredNotices(); |
|
113 | + $this->registerNotices(); |
|
114 | + } |
|
115 | + return $this->notice_collection; |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * generates PersistentAdminNotice objects for all non-dismissed notices saved to the db |
|
121 | + * |
|
122 | + * @return void |
|
123 | + * @throws InvalidEntityException |
|
124 | + * @throws DomainException |
|
125 | + * @throws InvalidDataTypeException |
|
126 | + * @throws DuplicateCollectionIdentifierException |
|
127 | + */ |
|
128 | + protected function retrieveStoredNotices() |
|
129 | + { |
|
130 | + $persistent_admin_notices = get_option(PersistentAdminNoticeManager::WP_OPTION_KEY, array()); |
|
131 | + if (! empty($persistent_admin_notices)) { |
|
132 | + foreach ($persistent_admin_notices as $name => $details) { |
|
133 | + if (is_array($details)) { |
|
134 | + if ( |
|
135 | + ! isset( |
|
136 | + $details['message'], |
|
137 | + $details['capability'], |
|
138 | + $details['cap_context'], |
|
139 | + $details['dismissed'] |
|
140 | + ) |
|
141 | + ) { |
|
142 | + throw new DomainException( |
|
143 | + sprintf( |
|
144 | + esc_html__( |
|
145 | + 'The "%1$s" PersistentAdminNotice could not be retrieved from the database.', |
|
146 | + 'event_espresso' |
|
147 | + ), |
|
148 | + $name |
|
149 | + ) |
|
150 | + ); |
|
151 | + } |
|
152 | + // new format for nag notices |
|
153 | + $this->notice_collection->add( |
|
154 | + new PersistentAdminNotice( |
|
155 | + $name, |
|
156 | + $details['message'], |
|
157 | + false, |
|
158 | + $details['capability'], |
|
159 | + $details['cap_context'], |
|
160 | + $details['dismissed'] |
|
161 | + ), |
|
162 | + sanitize_key($name) |
|
163 | + ); |
|
164 | + } else { |
|
165 | + try { |
|
166 | + // old nag notices, that we want to convert to the new format |
|
167 | + $this->notice_collection->add( |
|
168 | + new PersistentAdminNotice( |
|
169 | + $name, |
|
170 | + (string) $details, |
|
171 | + false, |
|
172 | + '', |
|
173 | + '', |
|
174 | + empty($details) |
|
175 | + ), |
|
176 | + sanitize_key($name) |
|
177 | + ); |
|
178 | + } catch (Exception $e) { |
|
179 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
180 | + } |
|
181 | + } |
|
182 | + // each notice will self register when the action hook in registerNotices is triggered |
|
183 | + } |
|
184 | + } |
|
185 | + } |
|
186 | + |
|
187 | + |
|
188 | + /** |
|
189 | + * exposes the Persistent Admin Notice Collection via an action |
|
190 | + * so that PersistentAdminNotice objects can be added and/or removed |
|
191 | + * without compromising the actual collection like a filter would |
|
192 | + */ |
|
193 | + protected function registerNotices() |
|
194 | + { |
|
195 | + do_action( |
|
196 | + 'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices', |
|
197 | + $this->notice_collection |
|
198 | + ); |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | + /** |
|
203 | + * @throws DomainException |
|
204 | + * @throws InvalidClassException |
|
205 | + * @throws InvalidDataTypeException |
|
206 | + * @throws InvalidInterfaceException |
|
207 | + * @throws InvalidEntityException |
|
208 | + * @throws DuplicateCollectionIdentifierException |
|
209 | + */ |
|
210 | + public function displayNotices() |
|
211 | + { |
|
212 | + $this->notice_collection = $this->getPersistentAdminNoticeCollection(); |
|
213 | + if ($this->notice_collection->hasObjects()) { |
|
214 | + $enqueue_assets = false; |
|
215 | + // and display notices |
|
216 | + foreach ($this->notice_collection as $persistent_admin_notice) { |
|
217 | + /** @var PersistentAdminNotice $persistent_admin_notice */ |
|
218 | + // don't display notices that have already been dismissed |
|
219 | + if ($persistent_admin_notice->getDismissed()) { |
|
220 | + continue; |
|
221 | + } |
|
222 | + try { |
|
223 | + $this->capabilities_checker->processCapCheck( |
|
224 | + $persistent_admin_notice->getCapCheck() |
|
225 | + ); |
|
226 | + } catch (InsufficientPermissionsException $e) { |
|
227 | + // user does not have required cap, so skip to next notice |
|
228 | + // and just eat the exception - nom nom nom nom |
|
229 | + continue; |
|
230 | + } |
|
231 | + if ($persistent_admin_notice->getMessage() === '') { |
|
232 | + continue; |
|
233 | + } |
|
234 | + $this->displayPersistentAdminNotice($persistent_admin_notice); |
|
235 | + $enqueue_assets = true; |
|
236 | + } |
|
237 | + if ($enqueue_assets) { |
|
238 | + $this->enqueueAssets(); |
|
239 | + } |
|
240 | + } |
|
241 | + } |
|
242 | + |
|
243 | + |
|
244 | + /** |
|
245 | + * does what it's named |
|
246 | + * |
|
247 | + * @return void |
|
248 | + */ |
|
249 | + public function enqueueAssets() |
|
250 | + { |
|
251 | + wp_register_script( |
|
252 | + 'espresso_core', |
|
253 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
254 | + array('jquery'), |
|
255 | + EVENT_ESPRESSO_VERSION, |
|
256 | + true |
|
257 | + ); |
|
258 | + wp_register_script( |
|
259 | + 'ee_error_js', |
|
260 | + EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', |
|
261 | + array('espresso_core'), |
|
262 | + EVENT_ESPRESSO_VERSION, |
|
263 | + true |
|
264 | + ); |
|
265 | + wp_localize_script( |
|
266 | + 'ee_error_js', |
|
267 | + 'ee_dismiss', |
|
268 | + array( |
|
269 | + 'return_url' => urlencode($this->return_url), |
|
270 | + 'ajax_url' => WP_AJAX_URL, |
|
271 | + 'unknown_error' => wp_strip_all_tags( |
|
272 | + __( |
|
273 | + 'An unknown error has occurred on the server while attempting to dismiss this notice.', |
|
274 | + 'event_espresso' |
|
275 | + ) |
|
276 | + ), |
|
277 | + ) |
|
278 | + ); |
|
279 | + wp_enqueue_script('ee_error_js'); |
|
280 | + } |
|
281 | + |
|
282 | + |
|
283 | + /** |
|
284 | + * displayPersistentAdminNoticeHtml |
|
285 | + * |
|
286 | + * @param PersistentAdminNotice $persistent_admin_notice |
|
287 | + */ |
|
288 | + protected function displayPersistentAdminNotice(PersistentAdminNotice $persistent_admin_notice) |
|
289 | + { |
|
290 | + // used in template |
|
291 | + $persistent_admin_notice_name = $persistent_admin_notice->getName(); |
|
292 | + $persistent_admin_notice_message = $persistent_admin_notice->getMessage(); |
|
293 | + require EE_TEMPLATES . '/notifications/persistent_admin_notice.template.php'; |
|
294 | + } |
|
295 | + |
|
296 | + |
|
297 | + /** |
|
298 | + * dismissNotice |
|
299 | + * |
|
300 | + * @param string $pan_name the name, or key of the Persistent Admin Notice to be dismissed |
|
301 | + * @param bool $purge if true, then delete it from the db |
|
302 | + * @param bool $return forget all of this AJAX or redirect nonsense, and just return |
|
303 | + * @return void |
|
304 | + * @throws InvalidEntityException |
|
305 | + * @throws InvalidInterfaceException |
|
306 | + * @throws InvalidDataTypeException |
|
307 | + * @throws DomainException |
|
308 | + * @throws InvalidArgumentException |
|
309 | + * @throws InvalidArgumentException |
|
310 | + * @throws InvalidArgumentException |
|
311 | + * @throws InvalidArgumentException |
|
312 | + * @throws DuplicateCollectionIdentifierException |
|
313 | + */ |
|
314 | + public function dismissNotice($pan_name = '', $purge = false, $return = false) |
|
315 | + { |
|
316 | + $pan_name = $this->request->getRequestParam('ee_nag_notice', $pan_name); |
|
317 | + $this->notice_collection = $this->getPersistentAdminNoticeCollection(); |
|
318 | + if (! empty($pan_name) && $this->notice_collection->has($pan_name)) { |
|
319 | + /** @var PersistentAdminNotice $persistent_admin_notice */ |
|
320 | + $persistent_admin_notice = $this->notice_collection->get($pan_name); |
|
321 | + $persistent_admin_notice->setDismissed(true); |
|
322 | + $persistent_admin_notice->setPurge($purge); |
|
323 | + $this->saveNotices(); |
|
324 | + } |
|
325 | + if ($return) { |
|
326 | + return; |
|
327 | + } |
|
328 | + if ($this->request->isAjax()) { |
|
329 | + // grab any notices and concatenate into string |
|
330 | + echo wp_json_encode( |
|
331 | + array( |
|
332 | + 'errors' => implode('<br />', EE_Error::get_notices(false)), |
|
333 | + ) |
|
334 | + ); |
|
335 | + exit(); |
|
336 | + } |
|
337 | + // save errors to a transient to be displayed on next request (after redirect) |
|
338 | + EE_Error::get_notices(false, true); |
|
339 | + wp_safe_redirect( |
|
340 | + urldecode( |
|
341 | + $this->request->getRequestParam('return_url', '') |
|
342 | + ) |
|
343 | + ); |
|
344 | + } |
|
345 | + |
|
346 | + |
|
347 | + /** |
|
348 | + * saveNotices |
|
349 | + * |
|
350 | + * @throws DomainException |
|
351 | + * @throws InvalidDataTypeException |
|
352 | + * @throws InvalidInterfaceException |
|
353 | + * @throws InvalidEntityException |
|
354 | + * @throws DuplicateCollectionIdentifierException |
|
355 | + */ |
|
356 | + public function saveNotices() |
|
357 | + { |
|
358 | + $this->notice_collection = $this->getPersistentAdminNoticeCollection(); |
|
359 | + if ($this->notice_collection->hasObjects()) { |
|
360 | + $persistent_admin_notices = get_option(PersistentAdminNoticeManager::WP_OPTION_KEY, array()); |
|
361 | + // maybe initialize persistent_admin_notices |
|
362 | + if (empty($persistent_admin_notices)) { |
|
363 | + add_option(PersistentAdminNoticeManager::WP_OPTION_KEY, array(), '', 'no'); |
|
364 | + } |
|
365 | + foreach ($this->notice_collection as $persistent_admin_notice) { |
|
366 | + // are we deleting this notice ? |
|
367 | + if ($persistent_admin_notice->getPurge()) { |
|
368 | + unset($persistent_admin_notices[ $persistent_admin_notice->getName() ]); |
|
369 | + } else { |
|
370 | + /** @var PersistentAdminNotice $persistent_admin_notice */ |
|
371 | + $persistent_admin_notices[ $persistent_admin_notice->getName() ] = array( |
|
372 | + 'message' => $persistent_admin_notice->getMessage(), |
|
373 | + 'capability' => $persistent_admin_notice->getCapability(), |
|
374 | + 'cap_context' => $persistent_admin_notice->getCapContext(), |
|
375 | + 'dismissed' => $persistent_admin_notice->getDismissed(), |
|
376 | + ); |
|
377 | + } |
|
378 | + } |
|
379 | + update_option(PersistentAdminNoticeManager::WP_OPTION_KEY, $persistent_admin_notices); |
|
380 | + } |
|
381 | + } |
|
382 | + |
|
383 | + |
|
384 | + /** |
|
385 | + * @throws DomainException |
|
386 | + * @throws InvalidDataTypeException |
|
387 | + * @throws InvalidEntityException |
|
388 | + * @throws InvalidInterfaceException |
|
389 | + * @throws DuplicateCollectionIdentifierException |
|
390 | + */ |
|
391 | + public function registerAndSaveNotices() |
|
392 | + { |
|
393 | + $this->getPersistentAdminNoticeCollection(); |
|
394 | + $this->registerNotices(); |
|
395 | + $this->saveNotices(); |
|
396 | + add_filter( |
|
397 | + 'PersistentAdminNoticeManager__registerAndSaveNotices__complete', |
|
398 | + '__return_true' |
|
399 | + ); |
|
400 | + } |
|
401 | + |
|
402 | + |
|
403 | + /** |
|
404 | + * @throws DomainException |
|
405 | + * @throws InvalidDataTypeException |
|
406 | + * @throws InvalidEntityException |
|
407 | + * @throws InvalidInterfaceException |
|
408 | + * @throws InvalidArgumentException |
|
409 | + * @throws DuplicateCollectionIdentifierException |
|
410 | + */ |
|
411 | + public static function loadRegisterAndSaveNotices() |
|
412 | + { |
|
413 | + /** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */ |
|
414 | + $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared( |
|
415 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
416 | + ); |
|
417 | + // if shutdown has already run, then call registerAndSaveNotices() manually |
|
418 | + if (did_action('shutdown')) { |
|
419 | + $persistent_admin_notice_manager->registerAndSaveNotices(); |
|
420 | + } |
|
421 | + } |
|
422 | 422 | } |
@@ -15,183 +15,183 @@ |
||
15 | 15 | */ |
16 | 16 | abstract class Asset |
17 | 17 | { |
18 | - /** |
|
19 | - * indicates the file extension for a CSS file |
|
20 | - */ |
|
21 | - const EXT_CSS = '.css'; |
|
22 | - |
|
23 | - /** |
|
24 | - * indicates the file extension for a JS file |
|
25 | - */ |
|
26 | - const EXT_JS = '.js'; |
|
27 | - |
|
28 | - /** |
|
29 | - * indicates the file extension for a JS file |
|
30 | - */ |
|
31 | - const EXT_PHP = '.php'; |
|
32 | - |
|
33 | - /** |
|
34 | - * indicates the file extension for a build distribution CSS file |
|
35 | - */ |
|
36 | - const FILE_EXTENSION_DISTRIBUTION_CSS = '.dist.css'; |
|
37 | - |
|
38 | - /** |
|
39 | - * indicates the file extension for a build distribution JS file |
|
40 | - */ |
|
41 | - const FILE_EXTENSION_DISTRIBUTION_JS = '.dist.js'; |
|
42 | - |
|
43 | - /** |
|
44 | - * Indicates the file extension for a build distribution dependencies json file. |
|
45 | - */ |
|
46 | - const FILE_EXTENSION_DISTRIBUTION_DEPS = '.dist.deps.php'; |
|
47 | - |
|
48 | - /** |
|
49 | - * indicates a Cascading Style Sheet asset |
|
50 | - */ |
|
51 | - const TYPE_CSS = 'css'; |
|
52 | - |
|
53 | - /** |
|
54 | - * indicates a Javascript asset |
|
55 | - */ |
|
56 | - const TYPE_JS = 'js'; |
|
57 | - |
|
58 | - /** |
|
59 | - * indicates a JSON asset |
|
60 | - */ |
|
61 | - CONST TYPE_JSON = 'json'; |
|
62 | - /** |
|
63 | - * indicates a PHP asset |
|
64 | - */ |
|
65 | - CONST TYPE_PHP = 'php'; |
|
66 | - |
|
67 | - /** |
|
68 | - * indicates a Javascript manifest file |
|
69 | - */ |
|
70 | - const TYPE_MANIFEST = 'manifest'; |
|
71 | - |
|
72 | - /** |
|
73 | - * @var DomainInterface $domain |
|
74 | - */ |
|
75 | - protected $domain; |
|
76 | - |
|
77 | - /** |
|
78 | - * @var string $type |
|
79 | - */ |
|
80 | - private $type; |
|
81 | - |
|
82 | - /** |
|
83 | - * @var string $handle |
|
84 | - */ |
|
85 | - private $handle; |
|
86 | - |
|
87 | - /** |
|
88 | - * @var bool $registered |
|
89 | - */ |
|
90 | - private $registered = false; |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * Asset constructor. |
|
95 | - * |
|
96 | - * @param $type |
|
97 | - * @param string $handle |
|
98 | - * @param DomainInterface $domain |
|
99 | - * @throws InvalidDataTypeException |
|
100 | - */ |
|
101 | - public function __construct($type, $handle, DomainInterface $domain) |
|
102 | - { |
|
103 | - $this->domain = $domain; |
|
104 | - $this->setType($type); |
|
105 | - $this->setHandle($handle); |
|
106 | - } |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * @return array |
|
111 | - */ |
|
112 | - public function validAssetTypes() |
|
113 | - { |
|
114 | - return array( |
|
115 | - Asset::TYPE_CSS, |
|
116 | - Asset::TYPE_JS, |
|
117 | - Asset::TYPE_MANIFEST, |
|
118 | - ); |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * @param string $type |
|
124 | - * @throws InvalidDataTypeException |
|
125 | - */ |
|
126 | - private function setType($type) |
|
127 | - { |
|
128 | - if (! in_array($type, $this->validAssetTypes(), true)) { |
|
129 | - throw new InvalidDataTypeException( |
|
130 | - 'Asset::$type', |
|
131 | - $type, |
|
132 | - 'one of the TYPE_* class constants on \EventEspresso\core\domain\values\Asset is required' |
|
133 | - ); |
|
134 | - } |
|
135 | - $this->type = $type; |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * @param string $handle |
|
141 | - * @throws InvalidDataTypeException |
|
142 | - */ |
|
143 | - private function setHandle($handle) |
|
144 | - { |
|
145 | - if (! is_string($handle)) { |
|
146 | - throw new InvalidDataTypeException( |
|
147 | - '$handle', |
|
148 | - $handle, |
|
149 | - 'string' |
|
150 | - ); |
|
151 | - } |
|
152 | - $this->handle = $handle; |
|
153 | - } |
|
154 | - |
|
155 | - |
|
156 | - /** |
|
157 | - * @return string |
|
158 | - */ |
|
159 | - public function assetNamespace() |
|
160 | - { |
|
161 | - return $this->domain->assetNamespace(); |
|
162 | - } |
|
163 | - |
|
164 | - |
|
165 | - /** |
|
166 | - * @return string |
|
167 | - */ |
|
168 | - public function type() |
|
169 | - { |
|
170 | - return $this->type; |
|
171 | - } |
|
172 | - |
|
173 | - |
|
174 | - /** |
|
175 | - * @return string |
|
176 | - */ |
|
177 | - public function handle() |
|
178 | - { |
|
179 | - return $this->handle; |
|
180 | - } |
|
181 | - |
|
182 | - /** |
|
183 | - * @return bool |
|
184 | - */ |
|
185 | - public function isRegistered() |
|
186 | - { |
|
187 | - return $this->registered; |
|
188 | - } |
|
189 | - |
|
190 | - /** |
|
191 | - * @param bool $registered |
|
192 | - */ |
|
193 | - public function setRegistered($registered = true) |
|
194 | - { |
|
195 | - $this->registered = filter_var($registered, FILTER_VALIDATE_BOOLEAN); |
|
196 | - } |
|
18 | + /** |
|
19 | + * indicates the file extension for a CSS file |
|
20 | + */ |
|
21 | + const EXT_CSS = '.css'; |
|
22 | + |
|
23 | + /** |
|
24 | + * indicates the file extension for a JS file |
|
25 | + */ |
|
26 | + const EXT_JS = '.js'; |
|
27 | + |
|
28 | + /** |
|
29 | + * indicates the file extension for a JS file |
|
30 | + */ |
|
31 | + const EXT_PHP = '.php'; |
|
32 | + |
|
33 | + /** |
|
34 | + * indicates the file extension for a build distribution CSS file |
|
35 | + */ |
|
36 | + const FILE_EXTENSION_DISTRIBUTION_CSS = '.dist.css'; |
|
37 | + |
|
38 | + /** |
|
39 | + * indicates the file extension for a build distribution JS file |
|
40 | + */ |
|
41 | + const FILE_EXTENSION_DISTRIBUTION_JS = '.dist.js'; |
|
42 | + |
|
43 | + /** |
|
44 | + * Indicates the file extension for a build distribution dependencies json file. |
|
45 | + */ |
|
46 | + const FILE_EXTENSION_DISTRIBUTION_DEPS = '.dist.deps.php'; |
|
47 | + |
|
48 | + /** |
|
49 | + * indicates a Cascading Style Sheet asset |
|
50 | + */ |
|
51 | + const TYPE_CSS = 'css'; |
|
52 | + |
|
53 | + /** |
|
54 | + * indicates a Javascript asset |
|
55 | + */ |
|
56 | + const TYPE_JS = 'js'; |
|
57 | + |
|
58 | + /** |
|
59 | + * indicates a JSON asset |
|
60 | + */ |
|
61 | + CONST TYPE_JSON = 'json'; |
|
62 | + /** |
|
63 | + * indicates a PHP asset |
|
64 | + */ |
|
65 | + CONST TYPE_PHP = 'php'; |
|
66 | + |
|
67 | + /** |
|
68 | + * indicates a Javascript manifest file |
|
69 | + */ |
|
70 | + const TYPE_MANIFEST = 'manifest'; |
|
71 | + |
|
72 | + /** |
|
73 | + * @var DomainInterface $domain |
|
74 | + */ |
|
75 | + protected $domain; |
|
76 | + |
|
77 | + /** |
|
78 | + * @var string $type |
|
79 | + */ |
|
80 | + private $type; |
|
81 | + |
|
82 | + /** |
|
83 | + * @var string $handle |
|
84 | + */ |
|
85 | + private $handle; |
|
86 | + |
|
87 | + /** |
|
88 | + * @var bool $registered |
|
89 | + */ |
|
90 | + private $registered = false; |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * Asset constructor. |
|
95 | + * |
|
96 | + * @param $type |
|
97 | + * @param string $handle |
|
98 | + * @param DomainInterface $domain |
|
99 | + * @throws InvalidDataTypeException |
|
100 | + */ |
|
101 | + public function __construct($type, $handle, DomainInterface $domain) |
|
102 | + { |
|
103 | + $this->domain = $domain; |
|
104 | + $this->setType($type); |
|
105 | + $this->setHandle($handle); |
|
106 | + } |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * @return array |
|
111 | + */ |
|
112 | + public function validAssetTypes() |
|
113 | + { |
|
114 | + return array( |
|
115 | + Asset::TYPE_CSS, |
|
116 | + Asset::TYPE_JS, |
|
117 | + Asset::TYPE_MANIFEST, |
|
118 | + ); |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * @param string $type |
|
124 | + * @throws InvalidDataTypeException |
|
125 | + */ |
|
126 | + private function setType($type) |
|
127 | + { |
|
128 | + if (! in_array($type, $this->validAssetTypes(), true)) { |
|
129 | + throw new InvalidDataTypeException( |
|
130 | + 'Asset::$type', |
|
131 | + $type, |
|
132 | + 'one of the TYPE_* class constants on \EventEspresso\core\domain\values\Asset is required' |
|
133 | + ); |
|
134 | + } |
|
135 | + $this->type = $type; |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * @param string $handle |
|
141 | + * @throws InvalidDataTypeException |
|
142 | + */ |
|
143 | + private function setHandle($handle) |
|
144 | + { |
|
145 | + if (! is_string($handle)) { |
|
146 | + throw new InvalidDataTypeException( |
|
147 | + '$handle', |
|
148 | + $handle, |
|
149 | + 'string' |
|
150 | + ); |
|
151 | + } |
|
152 | + $this->handle = $handle; |
|
153 | + } |
|
154 | + |
|
155 | + |
|
156 | + /** |
|
157 | + * @return string |
|
158 | + */ |
|
159 | + public function assetNamespace() |
|
160 | + { |
|
161 | + return $this->domain->assetNamespace(); |
|
162 | + } |
|
163 | + |
|
164 | + |
|
165 | + /** |
|
166 | + * @return string |
|
167 | + */ |
|
168 | + public function type() |
|
169 | + { |
|
170 | + return $this->type; |
|
171 | + } |
|
172 | + |
|
173 | + |
|
174 | + /** |
|
175 | + * @return string |
|
176 | + */ |
|
177 | + public function handle() |
|
178 | + { |
|
179 | + return $this->handle; |
|
180 | + } |
|
181 | + |
|
182 | + /** |
|
183 | + * @return bool |
|
184 | + */ |
|
185 | + public function isRegistered() |
|
186 | + { |
|
187 | + return $this->registered; |
|
188 | + } |
|
189 | + |
|
190 | + /** |
|
191 | + * @param bool $registered |
|
192 | + */ |
|
193 | + public function setRegistered($registered = true) |
|
194 | + { |
|
195 | + $this->registered = filter_var($registered, FILTER_VALIDATE_BOOLEAN); |
|
196 | + } |
|
197 | 197 | } |
@@ -20,1173 +20,1173 @@ |
||
20 | 20 | class EE_Dependency_Map |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * This means that the requested class dependency is not present in the dependency map |
|
25 | - */ |
|
26 | - const not_registered = 0; |
|
27 | - |
|
28 | - /** |
|
29 | - * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
30 | - */ |
|
31 | - const load_new_object = 1; |
|
32 | - |
|
33 | - /** |
|
34 | - * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
35 | - * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
36 | - */ |
|
37 | - const load_from_cache = 2; |
|
38 | - |
|
39 | - /** |
|
40 | - * When registering a dependency, |
|
41 | - * this indicates to keep any existing dependencies that already exist, |
|
42 | - * and simply discard any new dependencies declared in the incoming data |
|
43 | - */ |
|
44 | - const KEEP_EXISTING_DEPENDENCIES = 0; |
|
45 | - |
|
46 | - /** |
|
47 | - * When registering a dependency, |
|
48 | - * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
49 | - */ |
|
50 | - const OVERWRITE_DEPENDENCIES = 1; |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * @type EE_Dependency_Map $_instance |
|
55 | - */ |
|
56 | - protected static $_instance; |
|
57 | - |
|
58 | - /** |
|
59 | - * @var ClassInterfaceCache $class_cache |
|
60 | - */ |
|
61 | - private $class_cache; |
|
62 | - |
|
63 | - /** |
|
64 | - * @type RequestInterface $request |
|
65 | - */ |
|
66 | - protected $request; |
|
67 | - |
|
68 | - /** |
|
69 | - * @type LegacyRequestInterface $legacy_request |
|
70 | - */ |
|
71 | - protected $legacy_request; |
|
72 | - |
|
73 | - /** |
|
74 | - * @type ResponseInterface $response |
|
75 | - */ |
|
76 | - protected $response; |
|
77 | - |
|
78 | - /** |
|
79 | - * @type LoaderInterface $loader |
|
80 | - */ |
|
81 | - protected $loader; |
|
82 | - |
|
83 | - /** |
|
84 | - * @type array $_dependency_map |
|
85 | - */ |
|
86 | - protected $_dependency_map = []; |
|
87 | - |
|
88 | - /** |
|
89 | - * @type array $_class_loaders |
|
90 | - */ |
|
91 | - protected $_class_loaders = []; |
|
92 | - |
|
93 | - |
|
94 | - /** |
|
95 | - * EE_Dependency_Map constructor. |
|
96 | - * |
|
97 | - * @param ClassInterfaceCache $class_cache |
|
98 | - */ |
|
99 | - protected function __construct(ClassInterfaceCache $class_cache) |
|
100 | - { |
|
101 | - $this->class_cache = $class_cache; |
|
102 | - do_action('EE_Dependency_Map____construct', $this); |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - /** |
|
107 | - * @return void |
|
108 | - */ |
|
109 | - public function initialize() |
|
110 | - { |
|
111 | - $this->_register_core_dependencies(); |
|
112 | - $this->_register_core_class_loaders(); |
|
113 | - $this->_register_core_aliases(); |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * @singleton method used to instantiate class object |
|
119 | - * @param ClassInterfaceCache|null $class_cache |
|
120 | - * @return EE_Dependency_Map |
|
121 | - */ |
|
122 | - public static function instance(ClassInterfaceCache $class_cache = null) |
|
123 | - { |
|
124 | - // check if class object is instantiated, and instantiated properly |
|
125 | - if ( |
|
126 | - ! self::$_instance instanceof EE_Dependency_Map |
|
127 | - && $class_cache instanceof ClassInterfaceCache |
|
128 | - ) { |
|
129 | - self::$_instance = new EE_Dependency_Map($class_cache); |
|
130 | - } |
|
131 | - return self::$_instance; |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * @param RequestInterface $request |
|
137 | - */ |
|
138 | - public function setRequest(RequestInterface $request) |
|
139 | - { |
|
140 | - $this->request = $request; |
|
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * @param LegacyRequestInterface $legacy_request |
|
146 | - */ |
|
147 | - public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
148 | - { |
|
149 | - $this->legacy_request = $legacy_request; |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * @param ResponseInterface $response |
|
155 | - */ |
|
156 | - public function setResponse(ResponseInterface $response) |
|
157 | - { |
|
158 | - $this->response = $response; |
|
159 | - } |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * @param LoaderInterface $loader |
|
164 | - */ |
|
165 | - public function setLoader(LoaderInterface $loader) |
|
166 | - { |
|
167 | - $this->loader = $loader; |
|
168 | - } |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * @param string $class |
|
173 | - * @param array $dependencies |
|
174 | - * @param int $overwrite |
|
175 | - * @return bool |
|
176 | - */ |
|
177 | - public static function register_dependencies( |
|
178 | - $class, |
|
179 | - array $dependencies, |
|
180 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
181 | - ) { |
|
182 | - return self::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * Assigns an array of class names and corresponding load sources (new or cached) |
|
188 | - * to the class specified by the first parameter. |
|
189 | - * IMPORTANT !!! |
|
190 | - * The order of elements in the incoming $dependencies array MUST match |
|
191 | - * the order of the constructor parameters for the class in question. |
|
192 | - * This is especially important when overriding any existing dependencies that are registered. |
|
193 | - * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
194 | - * |
|
195 | - * @param string $class |
|
196 | - * @param array $dependencies |
|
197 | - * @param int $overwrite |
|
198 | - * @return bool |
|
199 | - */ |
|
200 | - public function registerDependencies( |
|
201 | - $class, |
|
202 | - array $dependencies, |
|
203 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
204 | - ) { |
|
205 | - $class = trim($class, '\\'); |
|
206 | - $registered = false; |
|
207 | - if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
208 | - self::$_instance->_dependency_map[ $class ] = []; |
|
209 | - } |
|
210 | - // we need to make sure that any aliases used when registering a dependency |
|
211 | - // get resolved to the correct class name |
|
212 | - foreach ($dependencies as $dependency => $load_source) { |
|
213 | - $alias = self::$_instance->getFqnForAlias($dependency); |
|
214 | - if ( |
|
215 | - $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
216 | - || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
217 | - ) { |
|
218 | - unset($dependencies[ $dependency ]); |
|
219 | - $dependencies[ $alias ] = $load_source; |
|
220 | - $registered = true; |
|
221 | - } |
|
222 | - } |
|
223 | - // now add our two lists of dependencies together. |
|
224 | - // using Union (+=) favours the arrays in precedence from left to right, |
|
225 | - // so $dependencies is NOT overwritten because it is listed first |
|
226 | - // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
227 | - // Union is way faster than array_merge() but should be used with caution... |
|
228 | - // especially with numerically indexed arrays |
|
229 | - $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
230 | - // now we need to ensure that the resulting dependencies |
|
231 | - // array only has the entries that are required for the class |
|
232 | - // so first count how many dependencies were originally registered for the class |
|
233 | - $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
234 | - // if that count is non-zero (meaning dependencies were already registered) |
|
235 | - self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
236 | - // then truncate the final array to match that count |
|
237 | - ? array_slice($dependencies, 0, $dependency_count) |
|
238 | - // otherwise just take the incoming array because nothing previously existed |
|
239 | - : $dependencies; |
|
240 | - return $registered; |
|
241 | - } |
|
242 | - |
|
243 | - |
|
244 | - /** |
|
245 | - * @param string $class_name |
|
246 | - * @param string $loader |
|
247 | - * @param bool $overwrite |
|
248 | - * @return bool |
|
249 | - * @throws DomainException |
|
250 | - */ |
|
251 | - public static function register_class_loader($class_name, $loader = 'load_core', $overwrite = false) |
|
252 | - { |
|
253 | - if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
254 | - throw new DomainException( |
|
255 | - esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
256 | - ); |
|
257 | - } |
|
258 | - // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
259 | - if ( |
|
260 | - ! is_callable($loader) |
|
261 | - && ( |
|
262 | - strpos($loader, 'load_') !== 0 |
|
263 | - || ! method_exists('EE_Registry', $loader) |
|
264 | - ) |
|
265 | - ) { |
|
266 | - throw new DomainException( |
|
267 | - sprintf( |
|
268 | - esc_html__( |
|
269 | - '"%1$s" is not a valid loader method on EE_Registry.', |
|
270 | - 'event_espresso' |
|
271 | - ), |
|
272 | - $loader |
|
273 | - ) |
|
274 | - ); |
|
275 | - } |
|
276 | - $class_name = self::$_instance->getFqnForAlias($class_name); |
|
277 | - if ($overwrite || ! isset(self::$_instance->_class_loaders[ $class_name ])) { |
|
278 | - self::$_instance->_class_loaders[ $class_name ] = $loader; |
|
279 | - return true; |
|
280 | - } |
|
281 | - return false; |
|
282 | - } |
|
283 | - |
|
284 | - |
|
285 | - /** |
|
286 | - * @return array |
|
287 | - */ |
|
288 | - public function dependency_map() |
|
289 | - { |
|
290 | - return $this->_dependency_map; |
|
291 | - } |
|
292 | - |
|
293 | - |
|
294 | - /** |
|
295 | - * returns TRUE if dependency map contains a listing for the provided class name |
|
296 | - * |
|
297 | - * @param string $class_name |
|
298 | - * @return boolean |
|
299 | - */ |
|
300 | - public function has($class_name = '') |
|
301 | - { |
|
302 | - // all legacy models have the same dependencies |
|
303 | - if (strpos($class_name, 'EEM_') === 0) { |
|
304 | - $class_name = 'LEGACY_MODELS'; |
|
305 | - } |
|
306 | - return isset($this->_dependency_map[ $class_name ]); |
|
307 | - } |
|
308 | - |
|
309 | - |
|
310 | - /** |
|
311 | - * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
312 | - * |
|
313 | - * @param string $class_name |
|
314 | - * @param string $dependency |
|
315 | - * @return bool |
|
316 | - */ |
|
317 | - public function has_dependency_for_class($class_name = '', $dependency = '') |
|
318 | - { |
|
319 | - // all legacy models have the same dependencies |
|
320 | - if (strpos($class_name, 'EEM_') === 0) { |
|
321 | - $class_name = 'LEGACY_MODELS'; |
|
322 | - } |
|
323 | - $dependency = $this->getFqnForAlias($dependency, $class_name); |
|
324 | - return isset($this->_dependency_map[ $class_name ][ $dependency ]); |
|
325 | - } |
|
326 | - |
|
327 | - |
|
328 | - /** |
|
329 | - * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
330 | - * |
|
331 | - * @param string $class_name |
|
332 | - * @param string $dependency |
|
333 | - * @return int |
|
334 | - */ |
|
335 | - public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
336 | - { |
|
337 | - // all legacy models have the same dependencies |
|
338 | - if (strpos($class_name, 'EEM_') === 0) { |
|
339 | - $class_name = 'LEGACY_MODELS'; |
|
340 | - } |
|
341 | - $dependency = $this->getFqnForAlias($dependency); |
|
342 | - return $this->has_dependency_for_class($class_name, $dependency) |
|
343 | - ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
344 | - : EE_Dependency_Map::not_registered; |
|
345 | - } |
|
346 | - |
|
347 | - |
|
348 | - /** |
|
349 | - * @param string $class_name |
|
350 | - * @return string | Closure |
|
351 | - */ |
|
352 | - public function class_loader($class_name) |
|
353 | - { |
|
354 | - // all legacy models use load_model() |
|
355 | - if (strpos($class_name, 'EEM_') === 0) { |
|
356 | - return 'load_model'; |
|
357 | - } |
|
358 | - // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc |
|
359 | - // perform strpos() first to avoid loading regex every time we load a class |
|
360 | - if ( |
|
361 | - strpos($class_name, 'EE_CPT_') === 0 |
|
362 | - && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name) |
|
363 | - ) { |
|
364 | - return 'load_core'; |
|
365 | - } |
|
366 | - $class_name = $this->getFqnForAlias($class_name); |
|
367 | - return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : ''; |
|
368 | - } |
|
369 | - |
|
370 | - |
|
371 | - /** |
|
372 | - * @return array |
|
373 | - */ |
|
374 | - public function class_loaders() |
|
375 | - { |
|
376 | - return $this->_class_loaders; |
|
377 | - } |
|
378 | - |
|
379 | - |
|
380 | - /** |
|
381 | - * adds an alias for a classname |
|
382 | - * |
|
383 | - * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
384 | - * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
385 | - * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
386 | - */ |
|
387 | - public function add_alias($fqcn, $alias, $for_class = '') |
|
388 | - { |
|
389 | - $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
390 | - } |
|
391 | - |
|
392 | - |
|
393 | - /** |
|
394 | - * Returns TRUE if the provided fully qualified name IS an alias |
|
395 | - * WHY? |
|
396 | - * Because if a class is type hinting for a concretion, |
|
397 | - * then why would we need to find another class to supply it? |
|
398 | - * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
399 | - * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
400 | - * Don't go looking for some substitute. |
|
401 | - * Whereas if a class is type hinting for an interface... |
|
402 | - * then we need to find an actual class to use. |
|
403 | - * So the interface IS the alias for some other FQN, |
|
404 | - * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
405 | - * represents some other class. |
|
406 | - * |
|
407 | - * @param string $fqn |
|
408 | - * @param string $for_class |
|
409 | - * @return bool |
|
410 | - */ |
|
411 | - public function isAlias($fqn = '', $for_class = '') |
|
412 | - { |
|
413 | - return $this->class_cache->isAlias($fqn, $for_class); |
|
414 | - } |
|
415 | - |
|
416 | - |
|
417 | - /** |
|
418 | - * Returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
419 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
420 | - * for example: |
|
421 | - * if the following two entries were added to the _aliases array: |
|
422 | - * array( |
|
423 | - * 'interface_alias' => 'some\namespace\interface' |
|
424 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
425 | - * ) |
|
426 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
427 | - * to load an instance of 'some\namespace\classname' |
|
428 | - * |
|
429 | - * @param string $alias |
|
430 | - * @param string $for_class |
|
431 | - * @return string |
|
432 | - */ |
|
433 | - public function getFqnForAlias($alias = '', $for_class = '') |
|
434 | - { |
|
435 | - return $this->class_cache->getFqnForAlias($alias, $for_class); |
|
436 | - } |
|
437 | - |
|
438 | - |
|
439 | - /** |
|
440 | - * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
441 | - * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
442 | - * This is done by using the following class constants: |
|
443 | - * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
444 | - * EE_Dependency_Map::load_new_object - generates a new object every time |
|
445 | - */ |
|
446 | - protected function _register_core_dependencies() |
|
447 | - { |
|
448 | - $this->_dependency_map = [ |
|
449 | - 'EE_Admin' => [ |
|
450 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
451 | - ], |
|
452 | - 'EE_Request_Handler' => [ |
|
453 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
454 | - 'EventEspresso\core\services\request\Response' => EE_Dependency_Map::load_from_cache, |
|
455 | - ], |
|
456 | - 'EE_System' => [ |
|
457 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
458 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
459 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
460 | - 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
461 | - ], |
|
462 | - 'EE_Session' => [ |
|
463 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
464 | - 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
465 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
466 | - 'EventEspresso\core\services\session\SessionStartHandler' => EE_Dependency_Map::load_from_cache, |
|
467 | - 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
468 | - ], |
|
469 | - 'EE_Cart' => [ |
|
470 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
471 | - ], |
|
472 | - 'EE_Front_Controller' => [ |
|
473 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
474 | - 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
475 | - 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
476 | - ], |
|
477 | - 'EE_Messenger_Collection_Loader' => [ |
|
478 | - 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
479 | - ], |
|
480 | - 'EE_Message_Type_Collection_Loader' => [ |
|
481 | - 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
482 | - ], |
|
483 | - 'EE_Message_Resource_Manager' => [ |
|
484 | - 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
485 | - 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
486 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
487 | - ], |
|
488 | - 'EE_Message_Factory' => [ |
|
489 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
490 | - ], |
|
491 | - 'EE_messages' => [ |
|
492 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
493 | - ], |
|
494 | - 'EE_Messages_Generator' => [ |
|
495 | - 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
496 | - 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
497 | - 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
498 | - 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
499 | - ], |
|
500 | - 'EE_Messages_Processor' => [ |
|
501 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
502 | - ], |
|
503 | - 'EE_Messages_Queue' => [ |
|
504 | - 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
505 | - ], |
|
506 | - 'EE_Messages_Template_Defaults' => [ |
|
507 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
508 | - 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
509 | - ], |
|
510 | - 'EE_Message_To_Generate_From_Request' => [ |
|
511 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
512 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
513 | - ], |
|
514 | - 'EventEspresso\core\services\commands\CommandBus' => [ |
|
515 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
516 | - ], |
|
517 | - 'EventEspresso\services\commands\CommandHandler' => [ |
|
518 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
519 | - 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
520 | - ], |
|
521 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => [ |
|
522 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
523 | - ], |
|
524 | - 'EventEspresso\core\services\commands\CompositeCommandHandler' => [ |
|
525 | - 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
526 | - 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
527 | - ], |
|
528 | - 'EventEspresso\core\services\commands\CommandFactory' => [ |
|
529 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
530 | - ], |
|
531 | - 'EventEspresso\core\services\commands\middleware\CapChecker' => [ |
|
532 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
533 | - ], |
|
534 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => [ |
|
535 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
536 | - ], |
|
537 | - 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => [ |
|
538 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
539 | - ], |
|
540 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => [ |
|
541 | - 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
542 | - ], |
|
543 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => [ |
|
544 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
545 | - ], |
|
546 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => [ |
|
547 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
548 | - ], |
|
549 | - 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => [ |
|
550 | - 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
551 | - ], |
|
552 | - 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => [ |
|
553 | - 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
554 | - ], |
|
555 | - 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => [ |
|
556 | - 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
557 | - ], |
|
558 | - 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => [ |
|
559 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
560 | - ], |
|
561 | - 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => [ |
|
562 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
563 | - ], |
|
564 | - 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => [ |
|
565 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
566 | - ], |
|
567 | - 'EventEspresso\core\services\database\TableManager' => [ |
|
568 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
569 | - ], |
|
570 | - 'EE_Data_Migration_Class_Base' => [ |
|
571 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
572 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
573 | - ], |
|
574 | - 'EE_DMS_Core_4_1_0' => [ |
|
575 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
576 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
577 | - ], |
|
578 | - 'EE_DMS_Core_4_2_0' => [ |
|
579 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
580 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
581 | - ], |
|
582 | - 'EE_DMS_Core_4_3_0' => [ |
|
583 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
584 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
585 | - ], |
|
586 | - 'EE_DMS_Core_4_4_0' => [ |
|
587 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
588 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
589 | - ], |
|
590 | - 'EE_DMS_Core_4_5_0' => [ |
|
591 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
592 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
593 | - ], |
|
594 | - 'EE_DMS_Core_4_6_0' => [ |
|
595 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
596 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
597 | - ], |
|
598 | - 'EE_DMS_Core_4_7_0' => [ |
|
599 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
600 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
601 | - ], |
|
602 | - 'EE_DMS_Core_4_8_0' => [ |
|
603 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
604 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
605 | - ], |
|
606 | - 'EE_DMS_Core_4_9_0' => [ |
|
607 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
608 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
609 | - ], |
|
610 | - 'EE_DMS_Core_4_10_0' => [ |
|
611 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
612 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
613 | - 'EE_DMS_Core_4_9_0' => EE_Dependency_Map::load_from_cache, |
|
614 | - ], |
|
615 | - 'EventEspresso\core\services\assets\I18nRegistry' => [ |
|
616 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
617 | - ], |
|
618 | - 'EventEspresso\core\services\assets\Registry' => [ |
|
619 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
620 | - 'EventEspresso\core\services\assets\I18nRegistry' => EE_Dependency_Map::load_from_cache, |
|
621 | - ], |
|
622 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => [ |
|
623 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
624 | - ], |
|
625 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => [ |
|
626 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
627 | - ], |
|
628 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => [ |
|
629 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
630 | - ], |
|
631 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => [ |
|
632 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
633 | - ], |
|
634 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => [ |
|
635 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
636 | - ], |
|
637 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => [ |
|
638 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
639 | - ], |
|
640 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => [ |
|
641 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
642 | - ], |
|
643 | - 'EventEspresso\core\services\cache\BasicCacheManager' => [ |
|
644 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
645 | - ], |
|
646 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => [ |
|
647 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
648 | - ], |
|
649 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => [ |
|
650 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
651 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
652 | - ], |
|
653 | - 'EventEspresso\core\domain\values\EmailAddress' => [ |
|
654 | - null, |
|
655 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
656 | - ], |
|
657 | - 'EventEspresso\core\services\orm\ModelFieldFactory' => [ |
|
658 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
659 | - ], |
|
660 | - 'LEGACY_MODELS' => [ |
|
661 | - null, |
|
662 | - 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
663 | - ], |
|
664 | - 'EE_Module_Request_Router' => [ |
|
665 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
666 | - ], |
|
667 | - 'EE_Registration_Processor' => [ |
|
668 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
669 | - ], |
|
670 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => [ |
|
671 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
672 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
673 | - ], |
|
674 | - 'EventEspresso\core\services\licensing\LicenseService' => [ |
|
675 | - 'EventEspresso\core\domain\services\pue\Stats' => EE_Dependency_Map::load_from_cache, |
|
676 | - 'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache, |
|
677 | - ], |
|
678 | - 'EE_Admin_Transactions_List_Table' => [ |
|
679 | - null, |
|
680 | - 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
681 | - ], |
|
682 | - 'EventEspresso\core\domain\services\pue\Stats' => [ |
|
683 | - 'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache, |
|
684 | - 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
685 | - 'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache, |
|
686 | - ], |
|
687 | - 'EventEspresso\core\domain\services\pue\Config' => [ |
|
688 | - 'EE_Network_Config' => EE_Dependency_Map::load_from_cache, |
|
689 | - 'EE_Config' => EE_Dependency_Map::load_from_cache, |
|
690 | - ], |
|
691 | - 'EventEspresso\core\domain\services\pue\StatsGatherer' => [ |
|
692 | - 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
693 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
694 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
695 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
696 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
697 | - 'EEM_Transaction' => EE_Dependency_Map::load_from_cache, |
|
698 | - 'EE_Config' => EE_Dependency_Map::load_from_cache, |
|
699 | - ], |
|
700 | - 'EventEspresso\core\domain\services\admin\ExitModal' => [ |
|
701 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
702 | - ], |
|
703 | - 'EventEspresso\core\domain\services\admin\PluginUpsells' => [ |
|
704 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
705 | - ], |
|
706 | - 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => [ |
|
707 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
708 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
709 | - ], |
|
710 | - 'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings' => [ |
|
711 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
712 | - ], |
|
713 | - 'EventEspresso\modules\ticket_selector\DisplayTicketSelector' => [ |
|
714 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
715 | - 'EE_Ticket_Selector_Config' => EE_Dependency_Map::load_from_cache, |
|
716 | - ], |
|
717 | - 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => [ |
|
718 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
719 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
720 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
721 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
722 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
723 | - ], |
|
724 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => [ |
|
725 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
726 | - ], |
|
727 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => [ |
|
728 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
729 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
730 | - ], |
|
731 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' => [ |
|
732 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
733 | - ], |
|
734 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' => [ |
|
735 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
736 | - ], |
|
737 | - 'EE_CPT_Strategy' => [ |
|
738 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
739 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
740 | - ], |
|
741 | - 'EventEspresso\core\services\loaders\ObjectIdentifier' => [ |
|
742 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
743 | - ], |
|
744 | - 'EventEspresso\core\domain\services\assets\CoreAssetManager' => [ |
|
745 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
746 | - 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
747 | - 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
748 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
749 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
750 | - ], |
|
751 | - 'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => [ |
|
752 | - 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
753 | - 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
754 | - ], |
|
755 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => [ |
|
756 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
757 | - ], |
|
758 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => [ |
|
759 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
760 | - 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
761 | - ], |
|
762 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => [ |
|
763 | - 'EEM_Checkin' => EE_Dependency_Map::load_from_cache, |
|
764 | - ], |
|
765 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => [ |
|
766 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
767 | - ], |
|
768 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => [ |
|
769 | - 'EEM_Transaction' => EE_Dependency_Map::load_from_cache, |
|
770 | - ], |
|
771 | - 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => [ |
|
772 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
773 | - ], |
|
774 | - 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => [ |
|
775 | - 'EEM_Answer' => EE_Dependency_Map::load_from_cache, |
|
776 | - 'EEM_Question' => EE_Dependency_Map::load_from_cache, |
|
777 | - ], |
|
778 | - 'EventEspresso\core\CPTs\CptQueryModifier' => [ |
|
779 | - null, |
|
780 | - null, |
|
781 | - null, |
|
782 | - 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
783 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
784 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
785 | - ], |
|
786 | - 'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => [ |
|
787 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
788 | - 'EE_Config' => EE_Dependency_Map::load_from_cache, |
|
789 | - ], |
|
790 | - 'EventEspresso\core\services\editor\BlockRegistrationManager' => [ |
|
791 | - 'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache, |
|
792 | - 'EventEspresso\core\domain\entities\editor\BlockCollection' => EE_Dependency_Map::load_from_cache, |
|
793 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache, |
|
794 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
795 | - ], |
|
796 | - 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => [ |
|
797 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
798 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
799 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
800 | - ], |
|
801 | - 'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => [ |
|
802 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
803 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
804 | - ], |
|
805 | - 'EventEspresso\core\domain\entities\editor\blocks\EventAttendees' => [ |
|
806 | - 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => self::load_from_cache, |
|
807 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
808 | - 'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => self::load_from_cache, |
|
809 | - ], |
|
810 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => [ |
|
811 | - 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
812 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
813 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
814 | - ], |
|
815 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => [ |
|
816 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache, |
|
817 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
818 | - ], |
|
819 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => [ |
|
820 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache, |
|
821 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache, |
|
822 | - ], |
|
823 | - 'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => [ |
|
824 | - 'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => EE_Dependency_Map::load_from_cache, |
|
825 | - ], |
|
826 | - 'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => [ |
|
827 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
828 | - ], |
|
829 | - 'EventEspresso\core\libraries\rest_api\controllers\model\Read' => [ |
|
830 | - 'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => EE_Dependency_Map::load_from_cache, |
|
831 | - ], |
|
832 | - 'EventEspresso\core\libraries\rest_api\calculations\Datetime' => [ |
|
833 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
834 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
835 | - ], |
|
836 | - 'EventEspresso\core\libraries\rest_api\calculations\Event' => [ |
|
837 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
838 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
839 | - ], |
|
840 | - 'EventEspresso\core\libraries\rest_api\calculations\Registration' => [ |
|
841 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
842 | - ], |
|
843 | - 'EventEspresso\core\services\session\SessionStartHandler' => [ |
|
844 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
845 | - ], |
|
846 | - 'EE_URL_Validation_Strategy' => [ |
|
847 | - null, |
|
848 | - null, |
|
849 | - 'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache, |
|
850 | - ], |
|
851 | - 'EventEspresso\admin_pages\general_settings\OrganizationSettings' => [ |
|
852 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
853 | - 'EE_Organization_Config' => EE_Dependency_Map::load_from_cache, |
|
854 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
855 | - 'EE_Network_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
856 | - 'EventEspresso\core\services\address\CountrySubRegionDao' => EE_Dependency_Map::load_from_cache, |
|
857 | - ], |
|
858 | - 'EventEspresso\core\services\address\CountrySubRegionDao' => [ |
|
859 | - 'EEM_State' => EE_Dependency_Map::load_from_cache, |
|
860 | - 'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache, |
|
861 | - ], |
|
862 | - 'EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat' => [ |
|
863 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
864 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
865 | - ], |
|
866 | - 'EventEspresso\core\domain\services\admin\ajax\EventEditorHeartbeat' => [ |
|
867 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
868 | - 'EE_Environment_Config' => EE_Dependency_Map::load_from_cache, |
|
869 | - ], |
|
870 | - 'EventEspresso\core\services\request\files\FilesDataHandler' => [ |
|
871 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
872 | - ], |
|
873 | - 'EventEspressoBatchRequest\BatchRequestProcessor' => [ |
|
874 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
875 | - ], |
|
876 | - 'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder' => [ |
|
877 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
878 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
879 | - null, |
|
880 | - ], |
|
881 | - 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader' => [ |
|
882 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
883 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
884 | - ], |
|
885 | - 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader' => [ |
|
886 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
887 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
888 | - ], |
|
889 | - 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader' => [ |
|
890 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
891 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
892 | - ], |
|
893 | - 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader' => [ |
|
894 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
895 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
896 | - ], |
|
897 | - 'EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion' => [ |
|
898 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
899 | - ], |
|
900 | - 'EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion' => [ |
|
901 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
902 | - ], |
|
903 | - 'EventEspresso\core\domain\services\admin\events\data\PreviewDeletion' => [ |
|
904 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
905 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
906 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
907 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
908 | - ], |
|
909 | - 'EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion' => [ |
|
910 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
911 | - ], |
|
912 | - 'EventEspresso\core\services\request\CurrentPage' => [ |
|
913 | - 'EE_CPT_Strategy' => EE_Dependency_Map::load_from_cache, |
|
914 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
915 | - ], |
|
916 | - 'EventEspresso\core\services\shortcodes\LegacyShortcodesManager' => [ |
|
917 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
918 | - 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
919 | - ], |
|
920 | - 'EventEspresso\core\services\shortcodes\ShortcodesManager' => [ |
|
921 | - 'EventEspresso\core\services\shortcodes\LegacyShortcodesManager' => EE_Dependency_Map::load_from_cache, |
|
922 | - 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
923 | - ], |
|
924 | - ]; |
|
925 | - } |
|
926 | - |
|
927 | - |
|
928 | - /** |
|
929 | - * Registers how core classes are loaded. |
|
930 | - * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
931 | - * 'EE_Request_Handler' => 'load_core' |
|
932 | - * 'EE_Messages_Queue' => 'load_lib' |
|
933 | - * 'EEH_Debug_Tools' => 'load_helper' |
|
934 | - * or, if greater control is required, by providing a custom closure. For example: |
|
935 | - * 'Some_Class' => function () { |
|
936 | - * return new Some_Class(); |
|
937 | - * }, |
|
938 | - * This is required for instantiating dependencies |
|
939 | - * where an interface has been type hinted in a class constructor. For example: |
|
940 | - * 'Required_Interface' => function () { |
|
941 | - * return new A_Class_That_Implements_Required_Interface(); |
|
942 | - * }, |
|
943 | - */ |
|
944 | - protected function _register_core_class_loaders() |
|
945 | - { |
|
946 | - $this->_class_loaders = [ |
|
947 | - // load_core |
|
948 | - 'EE_Dependency_Map' => function () { |
|
949 | - return $this; |
|
950 | - }, |
|
951 | - 'EE_Capabilities' => 'load_core', |
|
952 | - 'EE_Encryption' => 'load_core', |
|
953 | - 'EE_Front_Controller' => 'load_core', |
|
954 | - 'EE_Module_Request_Router' => 'load_core', |
|
955 | - 'EE_Registry' => 'load_core', |
|
956 | - 'EE_Request' => function () { |
|
957 | - return $this->legacy_request; |
|
958 | - }, |
|
959 | - 'EventEspresso\core\services\request\Request' => function () { |
|
960 | - return $this->request; |
|
961 | - }, |
|
962 | - 'EventEspresso\core\services\request\Response' => function () { |
|
963 | - return $this->response; |
|
964 | - }, |
|
965 | - 'EE_Base' => 'load_core', |
|
966 | - 'EE_Request_Handler' => 'load_core', |
|
967 | - 'EE_Session' => 'load_core', |
|
968 | - 'EE_Cron_Tasks' => 'load_core', |
|
969 | - 'EE_System' => 'load_core', |
|
970 | - 'EE_Maintenance_Mode' => 'load_core', |
|
971 | - 'EE_Register_CPTs' => 'load_core', |
|
972 | - 'EE_Admin' => 'load_core', |
|
973 | - 'EE_CPT_Strategy' => 'load_core', |
|
974 | - // load_class |
|
975 | - 'EE_Registration_Processor' => 'load_class', |
|
976 | - // load_lib |
|
977 | - 'EE_Message_Resource_Manager' => 'load_lib', |
|
978 | - 'EE_Message_Type_Collection' => 'load_lib', |
|
979 | - 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
980 | - 'EE_Messenger_Collection' => 'load_lib', |
|
981 | - 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
982 | - 'EE_Messages_Processor' => 'load_lib', |
|
983 | - 'EE_Message_Repository' => 'load_lib', |
|
984 | - 'EE_Messages_Queue' => 'load_lib', |
|
985 | - 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
986 | - 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
987 | - 'EE_Payment_Method_Manager' => 'load_lib', |
|
988 | - 'EE_DMS_Core_4_1_0' => 'load_dms', |
|
989 | - 'EE_DMS_Core_4_2_0' => 'load_dms', |
|
990 | - 'EE_DMS_Core_4_3_0' => 'load_dms', |
|
991 | - 'EE_DMS_Core_4_5_0' => 'load_dms', |
|
992 | - 'EE_DMS_Core_4_6_0' => 'load_dms', |
|
993 | - 'EE_DMS_Core_4_7_0' => 'load_dms', |
|
994 | - 'EE_DMS_Core_4_8_0' => 'load_dms', |
|
995 | - 'EE_DMS_Core_4_9_0' => 'load_dms', |
|
996 | - 'EE_DMS_Core_4_10_0' => 'load_dms', |
|
997 | - 'EE_Messages_Generator' => function () { |
|
998 | - return EE_Registry::instance()->load_lib( |
|
999 | - 'Messages_Generator', |
|
1000 | - [], |
|
1001 | - false, |
|
1002 | - false |
|
1003 | - ); |
|
1004 | - }, |
|
1005 | - 'EE_Messages_Template_Defaults' => function ($arguments = []) { |
|
1006 | - return EE_Registry::instance()->load_lib( |
|
1007 | - 'Messages_Template_Defaults', |
|
1008 | - $arguments, |
|
1009 | - false, |
|
1010 | - false |
|
1011 | - ); |
|
1012 | - }, |
|
1013 | - // load_helper |
|
1014 | - 'EEH_Parse_Shortcodes' => function () { |
|
1015 | - if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
1016 | - return new EEH_Parse_Shortcodes(); |
|
1017 | - } |
|
1018 | - return null; |
|
1019 | - }, |
|
1020 | - 'EE_Template_Config' => function () { |
|
1021 | - return EE_Config::instance()->template_settings; |
|
1022 | - }, |
|
1023 | - 'EE_Currency_Config' => function () { |
|
1024 | - return EE_Config::instance()->currency; |
|
1025 | - }, |
|
1026 | - 'EE_Registration_Config' => function () { |
|
1027 | - return EE_Config::instance()->registration; |
|
1028 | - }, |
|
1029 | - 'EE_Core_Config' => function () { |
|
1030 | - return EE_Config::instance()->core; |
|
1031 | - }, |
|
1032 | - 'EventEspresso\core\services\loaders\Loader' => function () { |
|
1033 | - return LoaderFactory::getLoader(); |
|
1034 | - }, |
|
1035 | - 'EE_Network_Config' => function () { |
|
1036 | - return EE_Network_Config::instance(); |
|
1037 | - }, |
|
1038 | - 'EE_Config' => function () { |
|
1039 | - return EE_Config::instance(); |
|
1040 | - }, |
|
1041 | - 'EventEspresso\core\domain\Domain' => function () { |
|
1042 | - return DomainFactory::getEventEspressoCoreDomain(); |
|
1043 | - }, |
|
1044 | - 'EE_Admin_Config' => function () { |
|
1045 | - return EE_Config::instance()->admin; |
|
1046 | - }, |
|
1047 | - 'EE_Organization_Config' => function () { |
|
1048 | - return EE_Config::instance()->organization; |
|
1049 | - }, |
|
1050 | - 'EE_Network_Core_Config' => function () { |
|
1051 | - return EE_Network_Config::instance()->core; |
|
1052 | - }, |
|
1053 | - 'EE_Environment_Config' => function () { |
|
1054 | - return EE_Config::instance()->environment; |
|
1055 | - }, |
|
1056 | - 'EE_Ticket_Selector_Config' => function () { |
|
1057 | - return EE_Config::instance()->template_settings->EED_Ticket_Selector; |
|
1058 | - }, |
|
1059 | - ]; |
|
1060 | - } |
|
1061 | - |
|
1062 | - |
|
1063 | - /** |
|
1064 | - * can be used for supplying alternate names for classes, |
|
1065 | - * or for connecting interface names to instantiable classes |
|
1066 | - */ |
|
1067 | - protected function _register_core_aliases() |
|
1068 | - { |
|
1069 | - $aliases = [ |
|
1070 | - 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
1071 | - 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
1072 | - 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
1073 | - 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
1074 | - 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
1075 | - 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
1076 | - 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
1077 | - 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
1078 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
1079 | - 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
1080 | - 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
1081 | - 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
1082 | - 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
1083 | - 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
1084 | - 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
1085 | - 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
1086 | - 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
1087 | - 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
1088 | - 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
1089 | - 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
1090 | - 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
1091 | - 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
1092 | - 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
1093 | - 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
1094 | - 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
1095 | - 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
1096 | - 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
1097 | - 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
1098 | - 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
1099 | - 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
1100 | - 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
1101 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
1102 | - 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
1103 | - 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
1104 | - 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
1105 | - 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
1106 | - 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
1107 | - 'Registration_Processor' => 'EE_Registration_Processor', |
|
1108 | - ]; |
|
1109 | - foreach ($aliases as $alias => $fqn) { |
|
1110 | - if (is_array($fqn)) { |
|
1111 | - foreach ($fqn as $class => $for_class) { |
|
1112 | - $this->class_cache->addAlias($class, $alias, $for_class); |
|
1113 | - } |
|
1114 | - continue; |
|
1115 | - } |
|
1116 | - $this->class_cache->addAlias($fqn, $alias); |
|
1117 | - } |
|
1118 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
1119 | - $this->class_cache->addAlias( |
|
1120 | - 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
|
1121 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' |
|
1122 | - ); |
|
1123 | - } |
|
1124 | - } |
|
1125 | - |
|
1126 | - |
|
1127 | - public function debug($for_class = '') |
|
1128 | - { |
|
1129 | - $this->class_cache->debug($for_class); |
|
1130 | - } |
|
1131 | - |
|
1132 | - |
|
1133 | - /** |
|
1134 | - * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
1135 | - * request Primarily used by unit tests. |
|
1136 | - */ |
|
1137 | - public function reset() |
|
1138 | - { |
|
1139 | - $this->_register_core_class_loaders(); |
|
1140 | - $this->_register_core_dependencies(); |
|
1141 | - } |
|
1142 | - |
|
1143 | - |
|
1144 | - /** |
|
1145 | - * PLZ NOTE: a better name for this method would be is_alias() |
|
1146 | - * because it returns TRUE if the provided fully qualified name IS an alias |
|
1147 | - * WHY? |
|
1148 | - * Because if a class is type hinting for a concretion, |
|
1149 | - * then why would we need to find another class to supply it? |
|
1150 | - * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
1151 | - * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
1152 | - * Don't go looking for some substitute. |
|
1153 | - * Whereas if a class is type hinting for an interface... |
|
1154 | - * then we need to find an actual class to use. |
|
1155 | - * So the interface IS the alias for some other FQN, |
|
1156 | - * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
1157 | - * represents some other class. |
|
1158 | - * |
|
1159 | - * @param string $fqn |
|
1160 | - * @param string $for_class |
|
1161 | - * @return bool |
|
1162 | - * @deprecated 4.9.62.p |
|
1163 | - */ |
|
1164 | - public function has_alias($fqn = '', $for_class = '') |
|
1165 | - { |
|
1166 | - return $this->isAlias($fqn, $for_class); |
|
1167 | - } |
|
1168 | - |
|
1169 | - |
|
1170 | - /** |
|
1171 | - * PLZ NOTE: a better name for this method would be get_fqn_for_alias() |
|
1172 | - * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
1173 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
1174 | - * for example: |
|
1175 | - * if the following two entries were added to the _aliases array: |
|
1176 | - * array( |
|
1177 | - * 'interface_alias' => 'some\namespace\interface' |
|
1178 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
1179 | - * ) |
|
1180 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
1181 | - * to load an instance of 'some\namespace\classname' |
|
1182 | - * |
|
1183 | - * @param string $alias |
|
1184 | - * @param string $for_class |
|
1185 | - * @return string |
|
1186 | - * @deprecated 4.9.62.p |
|
1187 | - */ |
|
1188 | - public function get_alias($alias = '', $for_class = '') |
|
1189 | - { |
|
1190 | - return $this->getFqnForAlias($alias, $for_class); |
|
1191 | - } |
|
23 | + /** |
|
24 | + * This means that the requested class dependency is not present in the dependency map |
|
25 | + */ |
|
26 | + const not_registered = 0; |
|
27 | + |
|
28 | + /** |
|
29 | + * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
30 | + */ |
|
31 | + const load_new_object = 1; |
|
32 | + |
|
33 | + /** |
|
34 | + * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
35 | + * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
36 | + */ |
|
37 | + const load_from_cache = 2; |
|
38 | + |
|
39 | + /** |
|
40 | + * When registering a dependency, |
|
41 | + * this indicates to keep any existing dependencies that already exist, |
|
42 | + * and simply discard any new dependencies declared in the incoming data |
|
43 | + */ |
|
44 | + const KEEP_EXISTING_DEPENDENCIES = 0; |
|
45 | + |
|
46 | + /** |
|
47 | + * When registering a dependency, |
|
48 | + * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
49 | + */ |
|
50 | + const OVERWRITE_DEPENDENCIES = 1; |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * @type EE_Dependency_Map $_instance |
|
55 | + */ |
|
56 | + protected static $_instance; |
|
57 | + |
|
58 | + /** |
|
59 | + * @var ClassInterfaceCache $class_cache |
|
60 | + */ |
|
61 | + private $class_cache; |
|
62 | + |
|
63 | + /** |
|
64 | + * @type RequestInterface $request |
|
65 | + */ |
|
66 | + protected $request; |
|
67 | + |
|
68 | + /** |
|
69 | + * @type LegacyRequestInterface $legacy_request |
|
70 | + */ |
|
71 | + protected $legacy_request; |
|
72 | + |
|
73 | + /** |
|
74 | + * @type ResponseInterface $response |
|
75 | + */ |
|
76 | + protected $response; |
|
77 | + |
|
78 | + /** |
|
79 | + * @type LoaderInterface $loader |
|
80 | + */ |
|
81 | + protected $loader; |
|
82 | + |
|
83 | + /** |
|
84 | + * @type array $_dependency_map |
|
85 | + */ |
|
86 | + protected $_dependency_map = []; |
|
87 | + |
|
88 | + /** |
|
89 | + * @type array $_class_loaders |
|
90 | + */ |
|
91 | + protected $_class_loaders = []; |
|
92 | + |
|
93 | + |
|
94 | + /** |
|
95 | + * EE_Dependency_Map constructor. |
|
96 | + * |
|
97 | + * @param ClassInterfaceCache $class_cache |
|
98 | + */ |
|
99 | + protected function __construct(ClassInterfaceCache $class_cache) |
|
100 | + { |
|
101 | + $this->class_cache = $class_cache; |
|
102 | + do_action('EE_Dependency_Map____construct', $this); |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + /** |
|
107 | + * @return void |
|
108 | + */ |
|
109 | + public function initialize() |
|
110 | + { |
|
111 | + $this->_register_core_dependencies(); |
|
112 | + $this->_register_core_class_loaders(); |
|
113 | + $this->_register_core_aliases(); |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * @singleton method used to instantiate class object |
|
119 | + * @param ClassInterfaceCache|null $class_cache |
|
120 | + * @return EE_Dependency_Map |
|
121 | + */ |
|
122 | + public static function instance(ClassInterfaceCache $class_cache = null) |
|
123 | + { |
|
124 | + // check if class object is instantiated, and instantiated properly |
|
125 | + if ( |
|
126 | + ! self::$_instance instanceof EE_Dependency_Map |
|
127 | + && $class_cache instanceof ClassInterfaceCache |
|
128 | + ) { |
|
129 | + self::$_instance = new EE_Dependency_Map($class_cache); |
|
130 | + } |
|
131 | + return self::$_instance; |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * @param RequestInterface $request |
|
137 | + */ |
|
138 | + public function setRequest(RequestInterface $request) |
|
139 | + { |
|
140 | + $this->request = $request; |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * @param LegacyRequestInterface $legacy_request |
|
146 | + */ |
|
147 | + public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
148 | + { |
|
149 | + $this->legacy_request = $legacy_request; |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * @param ResponseInterface $response |
|
155 | + */ |
|
156 | + public function setResponse(ResponseInterface $response) |
|
157 | + { |
|
158 | + $this->response = $response; |
|
159 | + } |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * @param LoaderInterface $loader |
|
164 | + */ |
|
165 | + public function setLoader(LoaderInterface $loader) |
|
166 | + { |
|
167 | + $this->loader = $loader; |
|
168 | + } |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * @param string $class |
|
173 | + * @param array $dependencies |
|
174 | + * @param int $overwrite |
|
175 | + * @return bool |
|
176 | + */ |
|
177 | + public static function register_dependencies( |
|
178 | + $class, |
|
179 | + array $dependencies, |
|
180 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
181 | + ) { |
|
182 | + return self::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * Assigns an array of class names and corresponding load sources (new or cached) |
|
188 | + * to the class specified by the first parameter. |
|
189 | + * IMPORTANT !!! |
|
190 | + * The order of elements in the incoming $dependencies array MUST match |
|
191 | + * the order of the constructor parameters for the class in question. |
|
192 | + * This is especially important when overriding any existing dependencies that are registered. |
|
193 | + * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
194 | + * |
|
195 | + * @param string $class |
|
196 | + * @param array $dependencies |
|
197 | + * @param int $overwrite |
|
198 | + * @return bool |
|
199 | + */ |
|
200 | + public function registerDependencies( |
|
201 | + $class, |
|
202 | + array $dependencies, |
|
203 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
204 | + ) { |
|
205 | + $class = trim($class, '\\'); |
|
206 | + $registered = false; |
|
207 | + if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
208 | + self::$_instance->_dependency_map[ $class ] = []; |
|
209 | + } |
|
210 | + // we need to make sure that any aliases used when registering a dependency |
|
211 | + // get resolved to the correct class name |
|
212 | + foreach ($dependencies as $dependency => $load_source) { |
|
213 | + $alias = self::$_instance->getFqnForAlias($dependency); |
|
214 | + if ( |
|
215 | + $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
216 | + || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
217 | + ) { |
|
218 | + unset($dependencies[ $dependency ]); |
|
219 | + $dependencies[ $alias ] = $load_source; |
|
220 | + $registered = true; |
|
221 | + } |
|
222 | + } |
|
223 | + // now add our two lists of dependencies together. |
|
224 | + // using Union (+=) favours the arrays in precedence from left to right, |
|
225 | + // so $dependencies is NOT overwritten because it is listed first |
|
226 | + // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
227 | + // Union is way faster than array_merge() but should be used with caution... |
|
228 | + // especially with numerically indexed arrays |
|
229 | + $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
230 | + // now we need to ensure that the resulting dependencies |
|
231 | + // array only has the entries that are required for the class |
|
232 | + // so first count how many dependencies were originally registered for the class |
|
233 | + $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
234 | + // if that count is non-zero (meaning dependencies were already registered) |
|
235 | + self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
236 | + // then truncate the final array to match that count |
|
237 | + ? array_slice($dependencies, 0, $dependency_count) |
|
238 | + // otherwise just take the incoming array because nothing previously existed |
|
239 | + : $dependencies; |
|
240 | + return $registered; |
|
241 | + } |
|
242 | + |
|
243 | + |
|
244 | + /** |
|
245 | + * @param string $class_name |
|
246 | + * @param string $loader |
|
247 | + * @param bool $overwrite |
|
248 | + * @return bool |
|
249 | + * @throws DomainException |
|
250 | + */ |
|
251 | + public static function register_class_loader($class_name, $loader = 'load_core', $overwrite = false) |
|
252 | + { |
|
253 | + if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
254 | + throw new DomainException( |
|
255 | + esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
256 | + ); |
|
257 | + } |
|
258 | + // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
259 | + if ( |
|
260 | + ! is_callable($loader) |
|
261 | + && ( |
|
262 | + strpos($loader, 'load_') !== 0 |
|
263 | + || ! method_exists('EE_Registry', $loader) |
|
264 | + ) |
|
265 | + ) { |
|
266 | + throw new DomainException( |
|
267 | + sprintf( |
|
268 | + esc_html__( |
|
269 | + '"%1$s" is not a valid loader method on EE_Registry.', |
|
270 | + 'event_espresso' |
|
271 | + ), |
|
272 | + $loader |
|
273 | + ) |
|
274 | + ); |
|
275 | + } |
|
276 | + $class_name = self::$_instance->getFqnForAlias($class_name); |
|
277 | + if ($overwrite || ! isset(self::$_instance->_class_loaders[ $class_name ])) { |
|
278 | + self::$_instance->_class_loaders[ $class_name ] = $loader; |
|
279 | + return true; |
|
280 | + } |
|
281 | + return false; |
|
282 | + } |
|
283 | + |
|
284 | + |
|
285 | + /** |
|
286 | + * @return array |
|
287 | + */ |
|
288 | + public function dependency_map() |
|
289 | + { |
|
290 | + return $this->_dependency_map; |
|
291 | + } |
|
292 | + |
|
293 | + |
|
294 | + /** |
|
295 | + * returns TRUE if dependency map contains a listing for the provided class name |
|
296 | + * |
|
297 | + * @param string $class_name |
|
298 | + * @return boolean |
|
299 | + */ |
|
300 | + public function has($class_name = '') |
|
301 | + { |
|
302 | + // all legacy models have the same dependencies |
|
303 | + if (strpos($class_name, 'EEM_') === 0) { |
|
304 | + $class_name = 'LEGACY_MODELS'; |
|
305 | + } |
|
306 | + return isset($this->_dependency_map[ $class_name ]); |
|
307 | + } |
|
308 | + |
|
309 | + |
|
310 | + /** |
|
311 | + * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
312 | + * |
|
313 | + * @param string $class_name |
|
314 | + * @param string $dependency |
|
315 | + * @return bool |
|
316 | + */ |
|
317 | + public function has_dependency_for_class($class_name = '', $dependency = '') |
|
318 | + { |
|
319 | + // all legacy models have the same dependencies |
|
320 | + if (strpos($class_name, 'EEM_') === 0) { |
|
321 | + $class_name = 'LEGACY_MODELS'; |
|
322 | + } |
|
323 | + $dependency = $this->getFqnForAlias($dependency, $class_name); |
|
324 | + return isset($this->_dependency_map[ $class_name ][ $dependency ]); |
|
325 | + } |
|
326 | + |
|
327 | + |
|
328 | + /** |
|
329 | + * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
330 | + * |
|
331 | + * @param string $class_name |
|
332 | + * @param string $dependency |
|
333 | + * @return int |
|
334 | + */ |
|
335 | + public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
336 | + { |
|
337 | + // all legacy models have the same dependencies |
|
338 | + if (strpos($class_name, 'EEM_') === 0) { |
|
339 | + $class_name = 'LEGACY_MODELS'; |
|
340 | + } |
|
341 | + $dependency = $this->getFqnForAlias($dependency); |
|
342 | + return $this->has_dependency_for_class($class_name, $dependency) |
|
343 | + ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
344 | + : EE_Dependency_Map::not_registered; |
|
345 | + } |
|
346 | + |
|
347 | + |
|
348 | + /** |
|
349 | + * @param string $class_name |
|
350 | + * @return string | Closure |
|
351 | + */ |
|
352 | + public function class_loader($class_name) |
|
353 | + { |
|
354 | + // all legacy models use load_model() |
|
355 | + if (strpos($class_name, 'EEM_') === 0) { |
|
356 | + return 'load_model'; |
|
357 | + } |
|
358 | + // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc |
|
359 | + // perform strpos() first to avoid loading regex every time we load a class |
|
360 | + if ( |
|
361 | + strpos($class_name, 'EE_CPT_') === 0 |
|
362 | + && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name) |
|
363 | + ) { |
|
364 | + return 'load_core'; |
|
365 | + } |
|
366 | + $class_name = $this->getFqnForAlias($class_name); |
|
367 | + return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : ''; |
|
368 | + } |
|
369 | + |
|
370 | + |
|
371 | + /** |
|
372 | + * @return array |
|
373 | + */ |
|
374 | + public function class_loaders() |
|
375 | + { |
|
376 | + return $this->_class_loaders; |
|
377 | + } |
|
378 | + |
|
379 | + |
|
380 | + /** |
|
381 | + * adds an alias for a classname |
|
382 | + * |
|
383 | + * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
384 | + * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
385 | + * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
386 | + */ |
|
387 | + public function add_alias($fqcn, $alias, $for_class = '') |
|
388 | + { |
|
389 | + $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
390 | + } |
|
391 | + |
|
392 | + |
|
393 | + /** |
|
394 | + * Returns TRUE if the provided fully qualified name IS an alias |
|
395 | + * WHY? |
|
396 | + * Because if a class is type hinting for a concretion, |
|
397 | + * then why would we need to find another class to supply it? |
|
398 | + * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
399 | + * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
400 | + * Don't go looking for some substitute. |
|
401 | + * Whereas if a class is type hinting for an interface... |
|
402 | + * then we need to find an actual class to use. |
|
403 | + * So the interface IS the alias for some other FQN, |
|
404 | + * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
405 | + * represents some other class. |
|
406 | + * |
|
407 | + * @param string $fqn |
|
408 | + * @param string $for_class |
|
409 | + * @return bool |
|
410 | + */ |
|
411 | + public function isAlias($fqn = '', $for_class = '') |
|
412 | + { |
|
413 | + return $this->class_cache->isAlias($fqn, $for_class); |
|
414 | + } |
|
415 | + |
|
416 | + |
|
417 | + /** |
|
418 | + * Returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
419 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
420 | + * for example: |
|
421 | + * if the following two entries were added to the _aliases array: |
|
422 | + * array( |
|
423 | + * 'interface_alias' => 'some\namespace\interface' |
|
424 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
425 | + * ) |
|
426 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
427 | + * to load an instance of 'some\namespace\classname' |
|
428 | + * |
|
429 | + * @param string $alias |
|
430 | + * @param string $for_class |
|
431 | + * @return string |
|
432 | + */ |
|
433 | + public function getFqnForAlias($alias = '', $for_class = '') |
|
434 | + { |
|
435 | + return $this->class_cache->getFqnForAlias($alias, $for_class); |
|
436 | + } |
|
437 | + |
|
438 | + |
|
439 | + /** |
|
440 | + * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
441 | + * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
442 | + * This is done by using the following class constants: |
|
443 | + * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
444 | + * EE_Dependency_Map::load_new_object - generates a new object every time |
|
445 | + */ |
|
446 | + protected function _register_core_dependencies() |
|
447 | + { |
|
448 | + $this->_dependency_map = [ |
|
449 | + 'EE_Admin' => [ |
|
450 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
451 | + ], |
|
452 | + 'EE_Request_Handler' => [ |
|
453 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
454 | + 'EventEspresso\core\services\request\Response' => EE_Dependency_Map::load_from_cache, |
|
455 | + ], |
|
456 | + 'EE_System' => [ |
|
457 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
458 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
459 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
460 | + 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
461 | + ], |
|
462 | + 'EE_Session' => [ |
|
463 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
464 | + 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
465 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
466 | + 'EventEspresso\core\services\session\SessionStartHandler' => EE_Dependency_Map::load_from_cache, |
|
467 | + 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
468 | + ], |
|
469 | + 'EE_Cart' => [ |
|
470 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
471 | + ], |
|
472 | + 'EE_Front_Controller' => [ |
|
473 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
474 | + 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
475 | + 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
476 | + ], |
|
477 | + 'EE_Messenger_Collection_Loader' => [ |
|
478 | + 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
479 | + ], |
|
480 | + 'EE_Message_Type_Collection_Loader' => [ |
|
481 | + 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
482 | + ], |
|
483 | + 'EE_Message_Resource_Manager' => [ |
|
484 | + 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
485 | + 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
486 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
487 | + ], |
|
488 | + 'EE_Message_Factory' => [ |
|
489 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
490 | + ], |
|
491 | + 'EE_messages' => [ |
|
492 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
493 | + ], |
|
494 | + 'EE_Messages_Generator' => [ |
|
495 | + 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
496 | + 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
497 | + 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
498 | + 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
499 | + ], |
|
500 | + 'EE_Messages_Processor' => [ |
|
501 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
502 | + ], |
|
503 | + 'EE_Messages_Queue' => [ |
|
504 | + 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
505 | + ], |
|
506 | + 'EE_Messages_Template_Defaults' => [ |
|
507 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
508 | + 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
509 | + ], |
|
510 | + 'EE_Message_To_Generate_From_Request' => [ |
|
511 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
512 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
513 | + ], |
|
514 | + 'EventEspresso\core\services\commands\CommandBus' => [ |
|
515 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
516 | + ], |
|
517 | + 'EventEspresso\services\commands\CommandHandler' => [ |
|
518 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
519 | + 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
520 | + ], |
|
521 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => [ |
|
522 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
523 | + ], |
|
524 | + 'EventEspresso\core\services\commands\CompositeCommandHandler' => [ |
|
525 | + 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
526 | + 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
527 | + ], |
|
528 | + 'EventEspresso\core\services\commands\CommandFactory' => [ |
|
529 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
530 | + ], |
|
531 | + 'EventEspresso\core\services\commands\middleware\CapChecker' => [ |
|
532 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
533 | + ], |
|
534 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => [ |
|
535 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
536 | + ], |
|
537 | + 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => [ |
|
538 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
539 | + ], |
|
540 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => [ |
|
541 | + 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
542 | + ], |
|
543 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => [ |
|
544 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
545 | + ], |
|
546 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => [ |
|
547 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
548 | + ], |
|
549 | + 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => [ |
|
550 | + 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
551 | + ], |
|
552 | + 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => [ |
|
553 | + 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
554 | + ], |
|
555 | + 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => [ |
|
556 | + 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
557 | + ], |
|
558 | + 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => [ |
|
559 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
560 | + ], |
|
561 | + 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => [ |
|
562 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
563 | + ], |
|
564 | + 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => [ |
|
565 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
566 | + ], |
|
567 | + 'EventEspresso\core\services\database\TableManager' => [ |
|
568 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
569 | + ], |
|
570 | + 'EE_Data_Migration_Class_Base' => [ |
|
571 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
572 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
573 | + ], |
|
574 | + 'EE_DMS_Core_4_1_0' => [ |
|
575 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
576 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
577 | + ], |
|
578 | + 'EE_DMS_Core_4_2_0' => [ |
|
579 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
580 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
581 | + ], |
|
582 | + 'EE_DMS_Core_4_3_0' => [ |
|
583 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
584 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
585 | + ], |
|
586 | + 'EE_DMS_Core_4_4_0' => [ |
|
587 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
588 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
589 | + ], |
|
590 | + 'EE_DMS_Core_4_5_0' => [ |
|
591 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
592 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
593 | + ], |
|
594 | + 'EE_DMS_Core_4_6_0' => [ |
|
595 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
596 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
597 | + ], |
|
598 | + 'EE_DMS_Core_4_7_0' => [ |
|
599 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
600 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
601 | + ], |
|
602 | + 'EE_DMS_Core_4_8_0' => [ |
|
603 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
604 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
605 | + ], |
|
606 | + 'EE_DMS_Core_4_9_0' => [ |
|
607 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
608 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
609 | + ], |
|
610 | + 'EE_DMS_Core_4_10_0' => [ |
|
611 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
612 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
613 | + 'EE_DMS_Core_4_9_0' => EE_Dependency_Map::load_from_cache, |
|
614 | + ], |
|
615 | + 'EventEspresso\core\services\assets\I18nRegistry' => [ |
|
616 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
617 | + ], |
|
618 | + 'EventEspresso\core\services\assets\Registry' => [ |
|
619 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
620 | + 'EventEspresso\core\services\assets\I18nRegistry' => EE_Dependency_Map::load_from_cache, |
|
621 | + ], |
|
622 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => [ |
|
623 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
624 | + ], |
|
625 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => [ |
|
626 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
627 | + ], |
|
628 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => [ |
|
629 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
630 | + ], |
|
631 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => [ |
|
632 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
633 | + ], |
|
634 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => [ |
|
635 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
636 | + ], |
|
637 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => [ |
|
638 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
639 | + ], |
|
640 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => [ |
|
641 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
642 | + ], |
|
643 | + 'EventEspresso\core\services\cache\BasicCacheManager' => [ |
|
644 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
645 | + ], |
|
646 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => [ |
|
647 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
648 | + ], |
|
649 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => [ |
|
650 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
651 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
652 | + ], |
|
653 | + 'EventEspresso\core\domain\values\EmailAddress' => [ |
|
654 | + null, |
|
655 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
656 | + ], |
|
657 | + 'EventEspresso\core\services\orm\ModelFieldFactory' => [ |
|
658 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
659 | + ], |
|
660 | + 'LEGACY_MODELS' => [ |
|
661 | + null, |
|
662 | + 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
663 | + ], |
|
664 | + 'EE_Module_Request_Router' => [ |
|
665 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
666 | + ], |
|
667 | + 'EE_Registration_Processor' => [ |
|
668 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
669 | + ], |
|
670 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => [ |
|
671 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
672 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
673 | + ], |
|
674 | + 'EventEspresso\core\services\licensing\LicenseService' => [ |
|
675 | + 'EventEspresso\core\domain\services\pue\Stats' => EE_Dependency_Map::load_from_cache, |
|
676 | + 'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache, |
|
677 | + ], |
|
678 | + 'EE_Admin_Transactions_List_Table' => [ |
|
679 | + null, |
|
680 | + 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
681 | + ], |
|
682 | + 'EventEspresso\core\domain\services\pue\Stats' => [ |
|
683 | + 'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache, |
|
684 | + 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
685 | + 'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache, |
|
686 | + ], |
|
687 | + 'EventEspresso\core\domain\services\pue\Config' => [ |
|
688 | + 'EE_Network_Config' => EE_Dependency_Map::load_from_cache, |
|
689 | + 'EE_Config' => EE_Dependency_Map::load_from_cache, |
|
690 | + ], |
|
691 | + 'EventEspresso\core\domain\services\pue\StatsGatherer' => [ |
|
692 | + 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
693 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
694 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
695 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
696 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
697 | + 'EEM_Transaction' => EE_Dependency_Map::load_from_cache, |
|
698 | + 'EE_Config' => EE_Dependency_Map::load_from_cache, |
|
699 | + ], |
|
700 | + 'EventEspresso\core\domain\services\admin\ExitModal' => [ |
|
701 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
702 | + ], |
|
703 | + 'EventEspresso\core\domain\services\admin\PluginUpsells' => [ |
|
704 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
705 | + ], |
|
706 | + 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => [ |
|
707 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
708 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
709 | + ], |
|
710 | + 'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings' => [ |
|
711 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
712 | + ], |
|
713 | + 'EventEspresso\modules\ticket_selector\DisplayTicketSelector' => [ |
|
714 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
715 | + 'EE_Ticket_Selector_Config' => EE_Dependency_Map::load_from_cache, |
|
716 | + ], |
|
717 | + 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => [ |
|
718 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
719 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
720 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
721 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
722 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
723 | + ], |
|
724 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => [ |
|
725 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
726 | + ], |
|
727 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => [ |
|
728 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
729 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
730 | + ], |
|
731 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' => [ |
|
732 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
733 | + ], |
|
734 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' => [ |
|
735 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
736 | + ], |
|
737 | + 'EE_CPT_Strategy' => [ |
|
738 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
739 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
740 | + ], |
|
741 | + 'EventEspresso\core\services\loaders\ObjectIdentifier' => [ |
|
742 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
743 | + ], |
|
744 | + 'EventEspresso\core\domain\services\assets\CoreAssetManager' => [ |
|
745 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
746 | + 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
747 | + 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
748 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
749 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
750 | + ], |
|
751 | + 'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => [ |
|
752 | + 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
753 | + 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
754 | + ], |
|
755 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => [ |
|
756 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
757 | + ], |
|
758 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => [ |
|
759 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
760 | + 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
761 | + ], |
|
762 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => [ |
|
763 | + 'EEM_Checkin' => EE_Dependency_Map::load_from_cache, |
|
764 | + ], |
|
765 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => [ |
|
766 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
767 | + ], |
|
768 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => [ |
|
769 | + 'EEM_Transaction' => EE_Dependency_Map::load_from_cache, |
|
770 | + ], |
|
771 | + 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => [ |
|
772 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
773 | + ], |
|
774 | + 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => [ |
|
775 | + 'EEM_Answer' => EE_Dependency_Map::load_from_cache, |
|
776 | + 'EEM_Question' => EE_Dependency_Map::load_from_cache, |
|
777 | + ], |
|
778 | + 'EventEspresso\core\CPTs\CptQueryModifier' => [ |
|
779 | + null, |
|
780 | + null, |
|
781 | + null, |
|
782 | + 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
783 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
784 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
785 | + ], |
|
786 | + 'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => [ |
|
787 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
788 | + 'EE_Config' => EE_Dependency_Map::load_from_cache, |
|
789 | + ], |
|
790 | + 'EventEspresso\core\services\editor\BlockRegistrationManager' => [ |
|
791 | + 'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache, |
|
792 | + 'EventEspresso\core\domain\entities\editor\BlockCollection' => EE_Dependency_Map::load_from_cache, |
|
793 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache, |
|
794 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
795 | + ], |
|
796 | + 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => [ |
|
797 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
798 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
799 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
800 | + ], |
|
801 | + 'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => [ |
|
802 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
803 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
804 | + ], |
|
805 | + 'EventEspresso\core\domain\entities\editor\blocks\EventAttendees' => [ |
|
806 | + 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => self::load_from_cache, |
|
807 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
808 | + 'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => self::load_from_cache, |
|
809 | + ], |
|
810 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => [ |
|
811 | + 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
812 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
813 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
814 | + ], |
|
815 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => [ |
|
816 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache, |
|
817 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
818 | + ], |
|
819 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => [ |
|
820 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache, |
|
821 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache, |
|
822 | + ], |
|
823 | + 'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => [ |
|
824 | + 'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => EE_Dependency_Map::load_from_cache, |
|
825 | + ], |
|
826 | + 'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => [ |
|
827 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
828 | + ], |
|
829 | + 'EventEspresso\core\libraries\rest_api\controllers\model\Read' => [ |
|
830 | + 'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => EE_Dependency_Map::load_from_cache, |
|
831 | + ], |
|
832 | + 'EventEspresso\core\libraries\rest_api\calculations\Datetime' => [ |
|
833 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
834 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
835 | + ], |
|
836 | + 'EventEspresso\core\libraries\rest_api\calculations\Event' => [ |
|
837 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
838 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
839 | + ], |
|
840 | + 'EventEspresso\core\libraries\rest_api\calculations\Registration' => [ |
|
841 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
842 | + ], |
|
843 | + 'EventEspresso\core\services\session\SessionStartHandler' => [ |
|
844 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
845 | + ], |
|
846 | + 'EE_URL_Validation_Strategy' => [ |
|
847 | + null, |
|
848 | + null, |
|
849 | + 'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache, |
|
850 | + ], |
|
851 | + 'EventEspresso\admin_pages\general_settings\OrganizationSettings' => [ |
|
852 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
853 | + 'EE_Organization_Config' => EE_Dependency_Map::load_from_cache, |
|
854 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
855 | + 'EE_Network_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
856 | + 'EventEspresso\core\services\address\CountrySubRegionDao' => EE_Dependency_Map::load_from_cache, |
|
857 | + ], |
|
858 | + 'EventEspresso\core\services\address\CountrySubRegionDao' => [ |
|
859 | + 'EEM_State' => EE_Dependency_Map::load_from_cache, |
|
860 | + 'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache, |
|
861 | + ], |
|
862 | + 'EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat' => [ |
|
863 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
864 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
865 | + ], |
|
866 | + 'EventEspresso\core\domain\services\admin\ajax\EventEditorHeartbeat' => [ |
|
867 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
868 | + 'EE_Environment_Config' => EE_Dependency_Map::load_from_cache, |
|
869 | + ], |
|
870 | + 'EventEspresso\core\services\request\files\FilesDataHandler' => [ |
|
871 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
872 | + ], |
|
873 | + 'EventEspressoBatchRequest\BatchRequestProcessor' => [ |
|
874 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
875 | + ], |
|
876 | + 'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder' => [ |
|
877 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
878 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
879 | + null, |
|
880 | + ], |
|
881 | + 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader' => [ |
|
882 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
883 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
884 | + ], |
|
885 | + 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader' => [ |
|
886 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
887 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
888 | + ], |
|
889 | + 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader' => [ |
|
890 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
891 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
892 | + ], |
|
893 | + 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader' => [ |
|
894 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
895 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
896 | + ], |
|
897 | + 'EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion' => [ |
|
898 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
899 | + ], |
|
900 | + 'EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion' => [ |
|
901 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
902 | + ], |
|
903 | + 'EventEspresso\core\domain\services\admin\events\data\PreviewDeletion' => [ |
|
904 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
905 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
906 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
907 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
908 | + ], |
|
909 | + 'EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion' => [ |
|
910 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
911 | + ], |
|
912 | + 'EventEspresso\core\services\request\CurrentPage' => [ |
|
913 | + 'EE_CPT_Strategy' => EE_Dependency_Map::load_from_cache, |
|
914 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
915 | + ], |
|
916 | + 'EventEspresso\core\services\shortcodes\LegacyShortcodesManager' => [ |
|
917 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
918 | + 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
919 | + ], |
|
920 | + 'EventEspresso\core\services\shortcodes\ShortcodesManager' => [ |
|
921 | + 'EventEspresso\core\services\shortcodes\LegacyShortcodesManager' => EE_Dependency_Map::load_from_cache, |
|
922 | + 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
923 | + ], |
|
924 | + ]; |
|
925 | + } |
|
926 | + |
|
927 | + |
|
928 | + /** |
|
929 | + * Registers how core classes are loaded. |
|
930 | + * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
931 | + * 'EE_Request_Handler' => 'load_core' |
|
932 | + * 'EE_Messages_Queue' => 'load_lib' |
|
933 | + * 'EEH_Debug_Tools' => 'load_helper' |
|
934 | + * or, if greater control is required, by providing a custom closure. For example: |
|
935 | + * 'Some_Class' => function () { |
|
936 | + * return new Some_Class(); |
|
937 | + * }, |
|
938 | + * This is required for instantiating dependencies |
|
939 | + * where an interface has been type hinted in a class constructor. For example: |
|
940 | + * 'Required_Interface' => function () { |
|
941 | + * return new A_Class_That_Implements_Required_Interface(); |
|
942 | + * }, |
|
943 | + */ |
|
944 | + protected function _register_core_class_loaders() |
|
945 | + { |
|
946 | + $this->_class_loaders = [ |
|
947 | + // load_core |
|
948 | + 'EE_Dependency_Map' => function () { |
|
949 | + return $this; |
|
950 | + }, |
|
951 | + 'EE_Capabilities' => 'load_core', |
|
952 | + 'EE_Encryption' => 'load_core', |
|
953 | + 'EE_Front_Controller' => 'load_core', |
|
954 | + 'EE_Module_Request_Router' => 'load_core', |
|
955 | + 'EE_Registry' => 'load_core', |
|
956 | + 'EE_Request' => function () { |
|
957 | + return $this->legacy_request; |
|
958 | + }, |
|
959 | + 'EventEspresso\core\services\request\Request' => function () { |
|
960 | + return $this->request; |
|
961 | + }, |
|
962 | + 'EventEspresso\core\services\request\Response' => function () { |
|
963 | + return $this->response; |
|
964 | + }, |
|
965 | + 'EE_Base' => 'load_core', |
|
966 | + 'EE_Request_Handler' => 'load_core', |
|
967 | + 'EE_Session' => 'load_core', |
|
968 | + 'EE_Cron_Tasks' => 'load_core', |
|
969 | + 'EE_System' => 'load_core', |
|
970 | + 'EE_Maintenance_Mode' => 'load_core', |
|
971 | + 'EE_Register_CPTs' => 'load_core', |
|
972 | + 'EE_Admin' => 'load_core', |
|
973 | + 'EE_CPT_Strategy' => 'load_core', |
|
974 | + // load_class |
|
975 | + 'EE_Registration_Processor' => 'load_class', |
|
976 | + // load_lib |
|
977 | + 'EE_Message_Resource_Manager' => 'load_lib', |
|
978 | + 'EE_Message_Type_Collection' => 'load_lib', |
|
979 | + 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
980 | + 'EE_Messenger_Collection' => 'load_lib', |
|
981 | + 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
982 | + 'EE_Messages_Processor' => 'load_lib', |
|
983 | + 'EE_Message_Repository' => 'load_lib', |
|
984 | + 'EE_Messages_Queue' => 'load_lib', |
|
985 | + 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
986 | + 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
987 | + 'EE_Payment_Method_Manager' => 'load_lib', |
|
988 | + 'EE_DMS_Core_4_1_0' => 'load_dms', |
|
989 | + 'EE_DMS_Core_4_2_0' => 'load_dms', |
|
990 | + 'EE_DMS_Core_4_3_0' => 'load_dms', |
|
991 | + 'EE_DMS_Core_4_5_0' => 'load_dms', |
|
992 | + 'EE_DMS_Core_4_6_0' => 'load_dms', |
|
993 | + 'EE_DMS_Core_4_7_0' => 'load_dms', |
|
994 | + 'EE_DMS_Core_4_8_0' => 'load_dms', |
|
995 | + 'EE_DMS_Core_4_9_0' => 'load_dms', |
|
996 | + 'EE_DMS_Core_4_10_0' => 'load_dms', |
|
997 | + 'EE_Messages_Generator' => function () { |
|
998 | + return EE_Registry::instance()->load_lib( |
|
999 | + 'Messages_Generator', |
|
1000 | + [], |
|
1001 | + false, |
|
1002 | + false |
|
1003 | + ); |
|
1004 | + }, |
|
1005 | + 'EE_Messages_Template_Defaults' => function ($arguments = []) { |
|
1006 | + return EE_Registry::instance()->load_lib( |
|
1007 | + 'Messages_Template_Defaults', |
|
1008 | + $arguments, |
|
1009 | + false, |
|
1010 | + false |
|
1011 | + ); |
|
1012 | + }, |
|
1013 | + // load_helper |
|
1014 | + 'EEH_Parse_Shortcodes' => function () { |
|
1015 | + if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
1016 | + return new EEH_Parse_Shortcodes(); |
|
1017 | + } |
|
1018 | + return null; |
|
1019 | + }, |
|
1020 | + 'EE_Template_Config' => function () { |
|
1021 | + return EE_Config::instance()->template_settings; |
|
1022 | + }, |
|
1023 | + 'EE_Currency_Config' => function () { |
|
1024 | + return EE_Config::instance()->currency; |
|
1025 | + }, |
|
1026 | + 'EE_Registration_Config' => function () { |
|
1027 | + return EE_Config::instance()->registration; |
|
1028 | + }, |
|
1029 | + 'EE_Core_Config' => function () { |
|
1030 | + return EE_Config::instance()->core; |
|
1031 | + }, |
|
1032 | + 'EventEspresso\core\services\loaders\Loader' => function () { |
|
1033 | + return LoaderFactory::getLoader(); |
|
1034 | + }, |
|
1035 | + 'EE_Network_Config' => function () { |
|
1036 | + return EE_Network_Config::instance(); |
|
1037 | + }, |
|
1038 | + 'EE_Config' => function () { |
|
1039 | + return EE_Config::instance(); |
|
1040 | + }, |
|
1041 | + 'EventEspresso\core\domain\Domain' => function () { |
|
1042 | + return DomainFactory::getEventEspressoCoreDomain(); |
|
1043 | + }, |
|
1044 | + 'EE_Admin_Config' => function () { |
|
1045 | + return EE_Config::instance()->admin; |
|
1046 | + }, |
|
1047 | + 'EE_Organization_Config' => function () { |
|
1048 | + return EE_Config::instance()->organization; |
|
1049 | + }, |
|
1050 | + 'EE_Network_Core_Config' => function () { |
|
1051 | + return EE_Network_Config::instance()->core; |
|
1052 | + }, |
|
1053 | + 'EE_Environment_Config' => function () { |
|
1054 | + return EE_Config::instance()->environment; |
|
1055 | + }, |
|
1056 | + 'EE_Ticket_Selector_Config' => function () { |
|
1057 | + return EE_Config::instance()->template_settings->EED_Ticket_Selector; |
|
1058 | + }, |
|
1059 | + ]; |
|
1060 | + } |
|
1061 | + |
|
1062 | + |
|
1063 | + /** |
|
1064 | + * can be used for supplying alternate names for classes, |
|
1065 | + * or for connecting interface names to instantiable classes |
|
1066 | + */ |
|
1067 | + protected function _register_core_aliases() |
|
1068 | + { |
|
1069 | + $aliases = [ |
|
1070 | + 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
1071 | + 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
1072 | + 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
1073 | + 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
1074 | + 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
1075 | + 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
1076 | + 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
1077 | + 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
1078 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
1079 | + 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
1080 | + 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
1081 | + 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
1082 | + 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
1083 | + 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
1084 | + 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
1085 | + 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
1086 | + 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
1087 | + 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
1088 | + 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
1089 | + 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
1090 | + 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
1091 | + 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
1092 | + 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
1093 | + 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
1094 | + 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
1095 | + 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
1096 | + 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
1097 | + 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
1098 | + 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
1099 | + 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
1100 | + 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
1101 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
1102 | + 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
1103 | + 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
1104 | + 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
1105 | + 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
1106 | + 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
1107 | + 'Registration_Processor' => 'EE_Registration_Processor', |
|
1108 | + ]; |
|
1109 | + foreach ($aliases as $alias => $fqn) { |
|
1110 | + if (is_array($fqn)) { |
|
1111 | + foreach ($fqn as $class => $for_class) { |
|
1112 | + $this->class_cache->addAlias($class, $alias, $for_class); |
|
1113 | + } |
|
1114 | + continue; |
|
1115 | + } |
|
1116 | + $this->class_cache->addAlias($fqn, $alias); |
|
1117 | + } |
|
1118 | + if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
1119 | + $this->class_cache->addAlias( |
|
1120 | + 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
|
1121 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' |
|
1122 | + ); |
|
1123 | + } |
|
1124 | + } |
|
1125 | + |
|
1126 | + |
|
1127 | + public function debug($for_class = '') |
|
1128 | + { |
|
1129 | + $this->class_cache->debug($for_class); |
|
1130 | + } |
|
1131 | + |
|
1132 | + |
|
1133 | + /** |
|
1134 | + * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
1135 | + * request Primarily used by unit tests. |
|
1136 | + */ |
|
1137 | + public function reset() |
|
1138 | + { |
|
1139 | + $this->_register_core_class_loaders(); |
|
1140 | + $this->_register_core_dependencies(); |
|
1141 | + } |
|
1142 | + |
|
1143 | + |
|
1144 | + /** |
|
1145 | + * PLZ NOTE: a better name for this method would be is_alias() |
|
1146 | + * because it returns TRUE if the provided fully qualified name IS an alias |
|
1147 | + * WHY? |
|
1148 | + * Because if a class is type hinting for a concretion, |
|
1149 | + * then why would we need to find another class to supply it? |
|
1150 | + * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
1151 | + * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
1152 | + * Don't go looking for some substitute. |
|
1153 | + * Whereas if a class is type hinting for an interface... |
|
1154 | + * then we need to find an actual class to use. |
|
1155 | + * So the interface IS the alias for some other FQN, |
|
1156 | + * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
1157 | + * represents some other class. |
|
1158 | + * |
|
1159 | + * @param string $fqn |
|
1160 | + * @param string $for_class |
|
1161 | + * @return bool |
|
1162 | + * @deprecated 4.9.62.p |
|
1163 | + */ |
|
1164 | + public function has_alias($fqn = '', $for_class = '') |
|
1165 | + { |
|
1166 | + return $this->isAlias($fqn, $for_class); |
|
1167 | + } |
|
1168 | + |
|
1169 | + |
|
1170 | + /** |
|
1171 | + * PLZ NOTE: a better name for this method would be get_fqn_for_alias() |
|
1172 | + * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
1173 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
1174 | + * for example: |
|
1175 | + * if the following two entries were added to the _aliases array: |
|
1176 | + * array( |
|
1177 | + * 'interface_alias' => 'some\namespace\interface' |
|
1178 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
1179 | + * ) |
|
1180 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
1181 | + * to load an instance of 'some\namespace\classname' |
|
1182 | + * |
|
1183 | + * @param string $alias |
|
1184 | + * @param string $for_class |
|
1185 | + * @return string |
|
1186 | + * @deprecated 4.9.62.p |
|
1187 | + */ |
|
1188 | + public function get_alias($alias = '', $for_class = '') |
|
1189 | + { |
|
1190 | + return $this->getFqnForAlias($alias, $for_class); |
|
1191 | + } |
|
1192 | 1192 | } |
@@ -38,103 +38,103 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.6.2'); |
|
65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.6.2'); |
|
65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.10.30.rc.026'); |
|
106 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | + /** |
|
98 | + * espresso_version |
|
99 | + * Returns the plugin version |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function espresso_version() |
|
104 | + { |
|
105 | + return apply_filters('FHEE__espresso__espresso_version', '4.10.30.rc.026'); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * espresso_plugin_activation |
|
110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | - */ |
|
112 | - function espresso_plugin_activation() |
|
113 | - { |
|
114 | - update_option('ee_espresso_activation', true); |
|
115 | - } |
|
108 | + /** |
|
109 | + * espresso_plugin_activation |
|
110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | + */ |
|
112 | + function espresso_plugin_activation() |
|
113 | + { |
|
114 | + update_option('ee_espresso_activation', true); |
|
115 | + } |
|
116 | 116 | |
117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | - bootstrap_espresso(); |
|
121 | - } |
|
119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | + bootstrap_espresso(); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
124 | - /** |
|
125 | - * deactivate_plugin |
|
126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | - { |
|
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | - } |
|
137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | - deactivate_plugins($plugin_basename); |
|
139 | - } |
|
124 | + /** |
|
125 | + * deactivate_plugin |
|
126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | + { |
|
134 | + if (! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | + } |
|
137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | + deactivate_plugins($plugin_basename); |
|
139 | + } |
|
140 | 140 | } |
141 | 141 | \ No newline at end of file |
@@ -29,210 +29,210 @@ |
||
29 | 29 | */ |
30 | 30 | class ShortcodesManager |
31 | 31 | { |
32 | - /** |
|
33 | - * @type CurrentPage |
|
34 | - */ |
|
35 | - protected $current_page; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var LegacyShortcodesManager $legacy_shortcodes_manager |
|
39 | - */ |
|
40 | - private $legacy_shortcodes_manager; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var ShortcodeInterface[] $shortcodes |
|
44 | - */ |
|
45 | - private $shortcodes; |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * ShortcodesManager constructor |
|
50 | - * |
|
51 | - * @param LegacyShortcodesManager $legacy_shortcodes_manager |
|
52 | - * @param CurrentPage $current_page |
|
53 | - */ |
|
54 | - public function __construct(LegacyShortcodesManager $legacy_shortcodes_manager, CurrentPage $current_page) |
|
55 | - { |
|
56 | - $this->legacy_shortcodes_manager = $legacy_shortcodes_manager; |
|
57 | - $this->current_page = $current_page; |
|
58 | - // assemble a list of installed and active shortcodes |
|
59 | - add_action( |
|
60 | - 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
61 | - [$this, 'registerShortcodes'], |
|
62 | - 999 |
|
63 | - ); |
|
64 | - // call add_shortcode() for all installed shortcodes |
|
65 | - add_action('AHEE__EE_System__core_loaded_and_ready', [$this, 'addShortcodes']); |
|
66 | - // check content for shortcodes the old way |
|
67 | - add_action('parse_query', [$this->legacy_shortcodes_manager, 'initializeShortcodes'], 5); |
|
68 | - // check content for shortcodes the NEW more efficient way |
|
69 | - add_action('template_redirect', [$this, 'templateRedirect'], 999); |
|
70 | - } |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * @return CollectionInterface|ShortcodeInterface[] |
|
75 | - * @throws InvalidIdentifierException |
|
76 | - * @throws InvalidInterfaceException |
|
77 | - * @throws InvalidFilePathException |
|
78 | - * @throws InvalidEntityException |
|
79 | - * @throws InvalidDataTypeException |
|
80 | - * @throws InvalidClassException |
|
81 | - */ |
|
82 | - public function getShortcodes() |
|
83 | - { |
|
84 | - if (! $this->shortcodes instanceof CollectionInterface) { |
|
85 | - $this->shortcodes = $this->loadShortcodesCollection(); |
|
86 | - } |
|
87 | - return $this->shortcodes; |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * @return CollectionInterface|ShortcodeInterface[] |
|
93 | - * @throws InvalidIdentifierException |
|
94 | - * @throws InvalidInterfaceException |
|
95 | - * @throws InvalidFilePathException |
|
96 | - * @throws InvalidEntityException |
|
97 | - * @throws InvalidDataTypeException |
|
98 | - * @throws InvalidClassException |
|
99 | - */ |
|
100 | - protected function loadShortcodesCollection() |
|
101 | - { |
|
102 | - $loader = new CollectionLoader( |
|
103 | - new CollectionDetails( |
|
104 | - // collection name |
|
105 | - 'shortcodes', |
|
106 | - // collection interface |
|
107 | - 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
108 | - // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
109 | - ['EventEspresso\core\domain\entities\shortcodes'], |
|
110 | - // filepaths to classes to add |
|
111 | - [], |
|
112 | - // file mask to use if parsing folder for files to add |
|
113 | - '', |
|
114 | - // what to use as identifier for collection entities |
|
115 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
116 | - CollectionDetails::ID_CLASS_NAME |
|
117 | - ) |
|
118 | - ); |
|
119 | - return $loader->getCollection(); |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - /** |
|
124 | - * @return void |
|
125 | - * @throws DomainException |
|
126 | - * @throws InvalidInterfaceException |
|
127 | - * @throws InvalidIdentifierException |
|
128 | - * @throws InvalidFilePathException |
|
129 | - * @throws InvalidEntityException |
|
130 | - * @throws InvalidDataTypeException |
|
131 | - * @throws InvalidClassException |
|
132 | - * @throws Exception |
|
133 | - */ |
|
134 | - public function registerShortcodes() |
|
135 | - { |
|
136 | - try { |
|
137 | - $this->shortcodes = apply_filters( |
|
138 | - 'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection', |
|
139 | - $this->getShortcodes() |
|
140 | - ); |
|
141 | - if (! $this->shortcodes instanceof CollectionInterface) { |
|
142 | - throw new InvalidEntityException( |
|
143 | - $this->shortcodes, |
|
144 | - 'CollectionInterface', |
|
145 | - sprintf( |
|
146 | - esc_html__( |
|
147 | - 'The "FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection" filter must return a Collection of EspressoShortcode objects. "%1$s" was received instead.', |
|
148 | - 'event_espresso' |
|
149 | - ), |
|
150 | - is_object($this->shortcodes) ? get_class($this->shortcodes) : gettype($this->shortcodes) |
|
151 | - ) |
|
152 | - ); |
|
153 | - } |
|
154 | - $this->legacy_shortcodes_manager->registerShortcodes(); |
|
155 | - } catch (Exception $exception) { |
|
156 | - new ExceptionStackTraceDisplay($exception); |
|
157 | - } |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * @return void |
|
163 | - * @throws Exception |
|
164 | - */ |
|
165 | - public function addShortcodes() |
|
166 | - { |
|
167 | - try { |
|
168 | - // cycle thru shortcode folders |
|
169 | - foreach ($this->shortcodes as $shortcode) { |
|
170 | - if ($shortcode instanceof EnqueueAssetsInterface) { |
|
171 | - add_action('wp_enqueue_scripts', [$shortcode, 'registerScriptsAndStylesheets'], 10); |
|
172 | - add_action('wp_enqueue_scripts', [$shortcode, 'enqueueStylesheets'], 11); |
|
173 | - } |
|
174 | - // add_shortcode() if it has not already been added |
|
175 | - if (! shortcode_exists($shortcode->getTag())) { |
|
176 | - add_shortcode($shortcode->getTag(), [$shortcode, 'processShortcodeCallback']); |
|
177 | - } |
|
178 | - } |
|
179 | - $this->legacy_shortcodes_manager->addShortcodes(); |
|
180 | - } catch (Exception $exception) { |
|
181 | - new ExceptionStackTraceDisplay($exception); |
|
182 | - } |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * callback for the "template_redirect" hook point |
|
188 | - * checks posts for EE shortcodes, and initializes them, |
|
189 | - * then toggles filter switch that loads core default assets |
|
190 | - * |
|
191 | - * @return void |
|
192 | - */ |
|
193 | - public function templateRedirect() |
|
194 | - { |
|
195 | - global $wp_query; |
|
196 | - if (empty($wp_query->posts)) { |
|
197 | - return; |
|
198 | - } |
|
199 | - $load_assets = false; |
|
200 | - // array of posts displayed in current request |
|
201 | - $posts = is_array($wp_query->posts) ? $wp_query->posts : [$wp_query->posts]; |
|
202 | - foreach ($posts as $post) { |
|
203 | - // now check post content and excerpt for EE shortcodes |
|
204 | - $load_assets = $this->parseContentForShortcodes($post->post_content) |
|
205 | - ? true |
|
206 | - : $load_assets; |
|
207 | - } |
|
208 | - if ($load_assets) { |
|
209 | - $this->current_page->setEspressoPage(true); |
|
210 | - add_filter('FHEE_load_css', '__return_true'); |
|
211 | - add_filter('FHEE_load_js', '__return_true'); |
|
212 | - } |
|
213 | - } |
|
214 | - |
|
215 | - |
|
216 | - /** |
|
217 | - * checks supplied content against list of shortcodes, |
|
218 | - * then initializes any found shortcodes, and returns true. |
|
219 | - * returns false if no shortcodes found. |
|
220 | - * |
|
221 | - * @param string $content |
|
222 | - * @return bool |
|
223 | - */ |
|
224 | - public function parseContentForShortcodes($content) |
|
225 | - { |
|
226 | - if (empty($this->shortcodes)) { |
|
227 | - return false; |
|
228 | - } |
|
229 | - $has_shortcode = false; |
|
230 | - foreach ($this->shortcodes as $shortcode) { |
|
231 | - if (has_shortcode($content, $shortcode->getTag())) { |
|
232 | - $shortcode->initializeShortcode(); |
|
233 | - $has_shortcode = true; |
|
234 | - } |
|
235 | - } |
|
236 | - return $has_shortcode; |
|
237 | - } |
|
32 | + /** |
|
33 | + * @type CurrentPage |
|
34 | + */ |
|
35 | + protected $current_page; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var LegacyShortcodesManager $legacy_shortcodes_manager |
|
39 | + */ |
|
40 | + private $legacy_shortcodes_manager; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var ShortcodeInterface[] $shortcodes |
|
44 | + */ |
|
45 | + private $shortcodes; |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * ShortcodesManager constructor |
|
50 | + * |
|
51 | + * @param LegacyShortcodesManager $legacy_shortcodes_manager |
|
52 | + * @param CurrentPage $current_page |
|
53 | + */ |
|
54 | + public function __construct(LegacyShortcodesManager $legacy_shortcodes_manager, CurrentPage $current_page) |
|
55 | + { |
|
56 | + $this->legacy_shortcodes_manager = $legacy_shortcodes_manager; |
|
57 | + $this->current_page = $current_page; |
|
58 | + // assemble a list of installed and active shortcodes |
|
59 | + add_action( |
|
60 | + 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
61 | + [$this, 'registerShortcodes'], |
|
62 | + 999 |
|
63 | + ); |
|
64 | + // call add_shortcode() for all installed shortcodes |
|
65 | + add_action('AHEE__EE_System__core_loaded_and_ready', [$this, 'addShortcodes']); |
|
66 | + // check content for shortcodes the old way |
|
67 | + add_action('parse_query', [$this->legacy_shortcodes_manager, 'initializeShortcodes'], 5); |
|
68 | + // check content for shortcodes the NEW more efficient way |
|
69 | + add_action('template_redirect', [$this, 'templateRedirect'], 999); |
|
70 | + } |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * @return CollectionInterface|ShortcodeInterface[] |
|
75 | + * @throws InvalidIdentifierException |
|
76 | + * @throws InvalidInterfaceException |
|
77 | + * @throws InvalidFilePathException |
|
78 | + * @throws InvalidEntityException |
|
79 | + * @throws InvalidDataTypeException |
|
80 | + * @throws InvalidClassException |
|
81 | + */ |
|
82 | + public function getShortcodes() |
|
83 | + { |
|
84 | + if (! $this->shortcodes instanceof CollectionInterface) { |
|
85 | + $this->shortcodes = $this->loadShortcodesCollection(); |
|
86 | + } |
|
87 | + return $this->shortcodes; |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * @return CollectionInterface|ShortcodeInterface[] |
|
93 | + * @throws InvalidIdentifierException |
|
94 | + * @throws InvalidInterfaceException |
|
95 | + * @throws InvalidFilePathException |
|
96 | + * @throws InvalidEntityException |
|
97 | + * @throws InvalidDataTypeException |
|
98 | + * @throws InvalidClassException |
|
99 | + */ |
|
100 | + protected function loadShortcodesCollection() |
|
101 | + { |
|
102 | + $loader = new CollectionLoader( |
|
103 | + new CollectionDetails( |
|
104 | + // collection name |
|
105 | + 'shortcodes', |
|
106 | + // collection interface |
|
107 | + 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
108 | + // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
109 | + ['EventEspresso\core\domain\entities\shortcodes'], |
|
110 | + // filepaths to classes to add |
|
111 | + [], |
|
112 | + // file mask to use if parsing folder for files to add |
|
113 | + '', |
|
114 | + // what to use as identifier for collection entities |
|
115 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
116 | + CollectionDetails::ID_CLASS_NAME |
|
117 | + ) |
|
118 | + ); |
|
119 | + return $loader->getCollection(); |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + /** |
|
124 | + * @return void |
|
125 | + * @throws DomainException |
|
126 | + * @throws InvalidInterfaceException |
|
127 | + * @throws InvalidIdentifierException |
|
128 | + * @throws InvalidFilePathException |
|
129 | + * @throws InvalidEntityException |
|
130 | + * @throws InvalidDataTypeException |
|
131 | + * @throws InvalidClassException |
|
132 | + * @throws Exception |
|
133 | + */ |
|
134 | + public function registerShortcodes() |
|
135 | + { |
|
136 | + try { |
|
137 | + $this->shortcodes = apply_filters( |
|
138 | + 'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection', |
|
139 | + $this->getShortcodes() |
|
140 | + ); |
|
141 | + if (! $this->shortcodes instanceof CollectionInterface) { |
|
142 | + throw new InvalidEntityException( |
|
143 | + $this->shortcodes, |
|
144 | + 'CollectionInterface', |
|
145 | + sprintf( |
|
146 | + esc_html__( |
|
147 | + 'The "FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection" filter must return a Collection of EspressoShortcode objects. "%1$s" was received instead.', |
|
148 | + 'event_espresso' |
|
149 | + ), |
|
150 | + is_object($this->shortcodes) ? get_class($this->shortcodes) : gettype($this->shortcodes) |
|
151 | + ) |
|
152 | + ); |
|
153 | + } |
|
154 | + $this->legacy_shortcodes_manager->registerShortcodes(); |
|
155 | + } catch (Exception $exception) { |
|
156 | + new ExceptionStackTraceDisplay($exception); |
|
157 | + } |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * @return void |
|
163 | + * @throws Exception |
|
164 | + */ |
|
165 | + public function addShortcodes() |
|
166 | + { |
|
167 | + try { |
|
168 | + // cycle thru shortcode folders |
|
169 | + foreach ($this->shortcodes as $shortcode) { |
|
170 | + if ($shortcode instanceof EnqueueAssetsInterface) { |
|
171 | + add_action('wp_enqueue_scripts', [$shortcode, 'registerScriptsAndStylesheets'], 10); |
|
172 | + add_action('wp_enqueue_scripts', [$shortcode, 'enqueueStylesheets'], 11); |
|
173 | + } |
|
174 | + // add_shortcode() if it has not already been added |
|
175 | + if (! shortcode_exists($shortcode->getTag())) { |
|
176 | + add_shortcode($shortcode->getTag(), [$shortcode, 'processShortcodeCallback']); |
|
177 | + } |
|
178 | + } |
|
179 | + $this->legacy_shortcodes_manager->addShortcodes(); |
|
180 | + } catch (Exception $exception) { |
|
181 | + new ExceptionStackTraceDisplay($exception); |
|
182 | + } |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * callback for the "template_redirect" hook point |
|
188 | + * checks posts for EE shortcodes, and initializes them, |
|
189 | + * then toggles filter switch that loads core default assets |
|
190 | + * |
|
191 | + * @return void |
|
192 | + */ |
|
193 | + public function templateRedirect() |
|
194 | + { |
|
195 | + global $wp_query; |
|
196 | + if (empty($wp_query->posts)) { |
|
197 | + return; |
|
198 | + } |
|
199 | + $load_assets = false; |
|
200 | + // array of posts displayed in current request |
|
201 | + $posts = is_array($wp_query->posts) ? $wp_query->posts : [$wp_query->posts]; |
|
202 | + foreach ($posts as $post) { |
|
203 | + // now check post content and excerpt for EE shortcodes |
|
204 | + $load_assets = $this->parseContentForShortcodes($post->post_content) |
|
205 | + ? true |
|
206 | + : $load_assets; |
|
207 | + } |
|
208 | + if ($load_assets) { |
|
209 | + $this->current_page->setEspressoPage(true); |
|
210 | + add_filter('FHEE_load_css', '__return_true'); |
|
211 | + add_filter('FHEE_load_js', '__return_true'); |
|
212 | + } |
|
213 | + } |
|
214 | + |
|
215 | + |
|
216 | + /** |
|
217 | + * checks supplied content against list of shortcodes, |
|
218 | + * then initializes any found shortcodes, and returns true. |
|
219 | + * returns false if no shortcodes found. |
|
220 | + * |
|
221 | + * @param string $content |
|
222 | + * @return bool |
|
223 | + */ |
|
224 | + public function parseContentForShortcodes($content) |
|
225 | + { |
|
226 | + if (empty($this->shortcodes)) { |
|
227 | + return false; |
|
228 | + } |
|
229 | + $has_shortcode = false; |
|
230 | + foreach ($this->shortcodes as $shortcode) { |
|
231 | + if (has_shortcode($content, $shortcode->getTag())) { |
|
232 | + $shortcode->initializeShortcode(); |
|
233 | + $has_shortcode = true; |
|
234 | + } |
|
235 | + } |
|
236 | + return $has_shortcode; |
|
237 | + } |
|
238 | 238 | } |
@@ -18,513 +18,513 @@ |
||
18 | 18 | final class EE_Front_Controller |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - private $_template_path; |
|
25 | - |
|
26 | - /** |
|
27 | - * @var string |
|
28 | - */ |
|
29 | - private $_template; |
|
30 | - |
|
31 | - /** |
|
32 | - * @type EE_Registry |
|
33 | - */ |
|
34 | - protected $Registry; |
|
35 | - |
|
36 | - /** |
|
37 | - * @type EE_Request_Handler |
|
38 | - */ |
|
39 | - protected $Request_Handler; |
|
40 | - |
|
41 | - /** |
|
42 | - * @type EE_Module_Request_Router |
|
43 | - */ |
|
44 | - protected $Module_Request_Router; |
|
45 | - |
|
46 | - /** |
|
47 | - * @type CurrentPage |
|
48 | - */ |
|
49 | - protected $current_page; |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * class constructor |
|
54 | - * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
|
55 | - * |
|
56 | - * @access public |
|
57 | - * @param EE_Registry $Registry |
|
58 | - * @param CurrentPage $EspressoPage |
|
59 | - * @param EE_Module_Request_Router $Module_Request_Router |
|
60 | - */ |
|
61 | - public function __construct( |
|
62 | - EE_Registry $Registry, |
|
63 | - CurrentPage $EspressoPage, |
|
64 | - EE_Module_Request_Router $Module_Request_Router |
|
65 | - ) { |
|
66 | - $this->Registry = $Registry; |
|
67 | - $this->current_page = $EspressoPage; |
|
68 | - $this->Module_Request_Router = $Module_Request_Router; |
|
69 | - // load other resources and begin to actually run shortcodes and modules |
|
70 | - // analyse the incoming WP request |
|
71 | - add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
72 | - // process request with module factory |
|
73 | - add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
74 | - // before headers sent |
|
75 | - add_action('wp', array($this, 'wp'), 5); |
|
76 | - // primarily used to process any content shortcodes |
|
77 | - add_action('template_redirect', array($this, 'templateRedirect'), 999); |
|
78 | - // header |
|
79 | - add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
80 | - add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10); |
|
81 | - add_filter('template_include', array($this, 'template_include'), 1); |
|
82 | - // display errors |
|
83 | - add_action('loop_start', array($this, 'display_errors'), 2); |
|
84 | - // the content |
|
85 | - // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
86 | - // exclude our private cpt comments |
|
87 | - add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
88 | - // make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
|
89 | - add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
90 | - // action hook EE |
|
91 | - do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * @return EE_Request_Handler |
|
97 | - * @deprecated 4.10.14.p |
|
98 | - */ |
|
99 | - public function Request_Handler() |
|
100 | - { |
|
101 | - if (! $this->Request_Handler instanceof EE_Request_Handler) { |
|
102 | - $this->Request_Handler = LoaderFactory::getLoader()->getShared('EE_Request_Handler'); |
|
103 | - } |
|
104 | - return $this->Request_Handler; |
|
105 | - } |
|
106 | - |
|
107 | - |
|
108 | - /** |
|
109 | - * @return EE_Module_Request_Router |
|
110 | - */ |
|
111 | - public function Module_Request_Router() |
|
112 | - { |
|
113 | - return $this->Module_Request_Router; |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * @return LegacyShortcodesManager |
|
119 | - * @deprecated 4.10.14.p |
|
120 | - */ |
|
121 | - public function getLegacyShortcodesManager() |
|
122 | - { |
|
123 | - return EE_Config::getLegacyShortcodesManager(); |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - |
|
128 | - |
|
129 | - |
|
130 | - /*********************************************** INIT ACTION HOOK ***********************************************/ |
|
131 | - /** |
|
132 | - * filter_wp_comments |
|
133 | - * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
|
134 | - * widgets/queries done on frontend |
|
135 | - * |
|
136 | - * @param array $clauses array of comment clauses setup by WP_Comment_Query |
|
137 | - * @return array array of comment clauses with modifications. |
|
138 | - * @throws InvalidArgumentException |
|
139 | - * @throws InvalidDataTypeException |
|
140 | - * @throws InvalidInterfaceException |
|
141 | - */ |
|
142 | - public function filter_wp_comments($clauses) |
|
143 | - { |
|
144 | - global $wpdb; |
|
145 | - if (strpos($clauses['join'], $wpdb->posts) !== false) { |
|
146 | - /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */ |
|
147 | - $custom_post_types = LoaderFactory::getLoader()->getShared( |
|
148 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
149 | - ); |
|
150 | - $cpts = $custom_post_types->getPrivateCustomPostTypes(); |
|
151 | - foreach ($cpts as $cpt => $details) { |
|
152 | - $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
153 | - } |
|
154 | - } |
|
155 | - return $clauses; |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - /** |
|
160 | - * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
|
161 | - * |
|
162 | - * @param string $url incoming url |
|
163 | - * @return string final assembled url |
|
164 | - */ |
|
165 | - public function maybe_force_admin_ajax_ssl($url) |
|
166 | - { |
|
167 | - if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
168 | - $url = str_replace('http://', 'https://', $url); |
|
169 | - } |
|
170 | - return $url; |
|
171 | - } |
|
172 | - |
|
173 | - |
|
174 | - |
|
175 | - |
|
176 | - |
|
177 | - |
|
178 | - /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
|
179 | - |
|
180 | - |
|
181 | - /** |
|
182 | - * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
|
183 | - * default priority init phases have run |
|
184 | - * |
|
185 | - * @access public |
|
186 | - * @return void |
|
187 | - */ |
|
188 | - public function wp_loaded() |
|
189 | - { |
|
190 | - } |
|
191 | - |
|
192 | - |
|
193 | - |
|
194 | - |
|
195 | - |
|
196 | - /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
|
197 | - /** |
|
198 | - * _get_request |
|
199 | - * |
|
200 | - * @access public |
|
201 | - * @param WP $WP |
|
202 | - * @return void |
|
203 | - */ |
|
204 | - public function get_request(WP $WP) |
|
205 | - { |
|
206 | - do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
207 | - $this->current_page->parseQueryVars($WP); |
|
208 | - do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
209 | - remove_action('parse_request', [$this, 'get_request'], 1); |
|
210 | - } |
|
211 | - |
|
212 | - |
|
213 | - /** |
|
214 | - * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
|
215 | - * |
|
216 | - * @access public |
|
217 | - * @param WP_Query $WP_Query |
|
218 | - * @return void |
|
219 | - * @throws EE_Error |
|
220 | - * @throws ReflectionException |
|
221 | - */ |
|
222 | - public function pre_get_posts($WP_Query) |
|
223 | - { |
|
224 | - // only load Module_Request_Router if this is the main query |
|
225 | - if ( |
|
226 | - $this->Module_Request_Router instanceof EE_Module_Request_Router |
|
227 | - && $WP_Query->is_main_query() |
|
228 | - ) { |
|
229 | - // cycle thru module routes |
|
230 | - while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
231 | - // determine module and method for route |
|
232 | - $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
233 | - if ($module instanceof EED_Module) { |
|
234 | - // get registered view for route |
|
235 | - $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
236 | - // grab module name |
|
237 | - $module_name = $module->module_name(); |
|
238 | - // map the module to the module objects |
|
239 | - $this->Registry->modules->{$module_name} = $module; |
|
240 | - } |
|
241 | - } |
|
242 | - } |
|
243 | - } |
|
244 | - |
|
245 | - |
|
246 | - |
|
247 | - |
|
248 | - |
|
249 | - /*********************************************** WP HOOK ***********************************************/ |
|
250 | - |
|
251 | - |
|
252 | - /** |
|
253 | - * wp - basically last chance to do stuff before headers sent |
|
254 | - * |
|
255 | - * @access public |
|
256 | - * @return void |
|
257 | - */ |
|
258 | - public function wp() |
|
259 | - { |
|
260 | - } |
|
261 | - |
|
262 | - |
|
263 | - |
|
264 | - /*********************** GET_HEADER && WP_HEAD HOOK ***********************/ |
|
265 | - |
|
266 | - |
|
267 | - /** |
|
268 | - * callback for the "template_redirect" hook point |
|
269 | - * checks sidebars for EE widgets |
|
270 | - * loads resources and assets accordingly |
|
271 | - * |
|
272 | - * @return void |
|
273 | - */ |
|
274 | - public function templateRedirect() |
|
275 | - { |
|
276 | - global $wp_query; |
|
277 | - if (empty($wp_query->posts)) { |
|
278 | - return; |
|
279 | - } |
|
280 | - // if we already know this is an espresso page, then load assets |
|
281 | - $load_assets = $this->current_page->isEspressoPage(); |
|
282 | - // if we are already loading assets then just move along, otherwise check for widgets |
|
283 | - $load_assets = $load_assets || $this->espresso_widgets_in_active_sidebars(); |
|
284 | - if ($load_assets) { |
|
285 | - add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10); |
|
286 | - add_action('wp_print_footer_scripts', array($this, 'enqueueScripts'), 10); |
|
287 | - } |
|
288 | - } |
|
289 | - |
|
290 | - |
|
291 | - /** |
|
292 | - * builds list of active widgets then scans active sidebars looking for them |
|
293 | - * returns true is an EE widget is found in an active sidebar |
|
294 | - * Please Note: this does NOT mean that the sidebar or widget |
|
295 | - * is actually in use in a given template, as that is unfortunately not known |
|
296 | - * until a sidebar and it's widgets are actually loaded |
|
297 | - * |
|
298 | - * @return boolean |
|
299 | - */ |
|
300 | - private function espresso_widgets_in_active_sidebars() |
|
301 | - { |
|
302 | - $espresso_widgets = array(); |
|
303 | - foreach ($this->Registry->widgets as $widget_class => $widget) { |
|
304 | - $id_base = EspressoWidget::getIdBase($widget_class); |
|
305 | - if (is_active_widget(false, false, $id_base)) { |
|
306 | - $espresso_widgets[] = $id_base; |
|
307 | - } |
|
308 | - } |
|
309 | - $all_sidebar_widgets = wp_get_sidebars_widgets(); |
|
310 | - foreach ($all_sidebar_widgets as $sidebar_widgets) { |
|
311 | - if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) { |
|
312 | - foreach ($sidebar_widgets as $sidebar_widget) { |
|
313 | - foreach ($espresso_widgets as $espresso_widget) { |
|
314 | - if (strpos($sidebar_widget, $espresso_widget) !== false) { |
|
315 | - return true; |
|
316 | - } |
|
317 | - } |
|
318 | - } |
|
319 | - } |
|
320 | - } |
|
321 | - return false; |
|
322 | - } |
|
323 | - |
|
324 | - |
|
325 | - /** |
|
326 | - * header_meta_tag |
|
327 | - * |
|
328 | - * @access public |
|
329 | - * @return void |
|
330 | - */ |
|
331 | - public function header_meta_tag() |
|
332 | - { |
|
333 | - print( |
|
334 | - apply_filters( |
|
335 | - 'FHEE__EE_Front_Controller__header_meta_tag', |
|
336 | - '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n" |
|
337 | - ) |
|
338 | - ); |
|
339 | - |
|
340 | - // let's exclude all event type taxonomy term archive pages from search engine indexing |
|
341 | - // @see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
|
342 | - // also exclude all critical pages from indexing |
|
343 | - if ( |
|
344 | - ( |
|
345 | - is_tax('espresso_event_type') |
|
346 | - && get_option('blog_public') !== '0' |
|
347 | - ) |
|
348 | - || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array()) |
|
349 | - ) { |
|
350 | - print( |
|
351 | - apply_filters( |
|
352 | - 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
|
353 | - '<meta name="robots" content="noindex,follow" />' . "\n" |
|
354 | - ) |
|
355 | - ); |
|
356 | - } |
|
357 | - } |
|
358 | - |
|
359 | - |
|
360 | - /** |
|
361 | - * wp_print_scripts |
|
362 | - * |
|
363 | - * @return void |
|
364 | - * @throws EE_Error |
|
365 | - */ |
|
366 | - public function wp_print_scripts() |
|
367 | - { |
|
368 | - global $post; |
|
369 | - if ( |
|
370 | - isset($post->EE_Event) |
|
371 | - && $post->EE_Event instanceof EE_Event |
|
372 | - && get_post_type() === 'espresso_events' |
|
373 | - && is_singular() |
|
374 | - ) { |
|
375 | - EEH_Schema::add_json_linked_data_for_event($post->EE_Event); |
|
376 | - } |
|
377 | - } |
|
378 | - |
|
379 | - |
|
380 | - public function enqueueStyle() |
|
381 | - { |
|
382 | - wp_enqueue_style('espresso_default'); |
|
383 | - wp_enqueue_style('espresso_custom_css'); |
|
384 | - } |
|
385 | - |
|
386 | - |
|
387 | - |
|
388 | - /*********************************************** WP_FOOTER ***********************************************/ |
|
389 | - |
|
390 | - |
|
391 | - public function enqueueScripts() |
|
392 | - { |
|
393 | - wp_enqueue_script('espresso_core'); |
|
394 | - } |
|
395 | - |
|
396 | - |
|
397 | - /** |
|
398 | - * display_errors |
|
399 | - * |
|
400 | - * @access public |
|
401 | - * @return void |
|
402 | - * @throws DomainException |
|
403 | - */ |
|
404 | - public function display_errors() |
|
405 | - { |
|
406 | - static $shown_already = false; |
|
407 | - do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
408 | - if ( |
|
409 | - ! $shown_already |
|
410 | - && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
|
411 | - && is_main_query() |
|
412 | - && ! is_feed() |
|
413 | - && in_the_loop() |
|
414 | - && $this->current_page->isEspressoPage() |
|
415 | - ) { |
|
416 | - $shown_already = true; |
|
417 | - if (did_action('wp_head')) { |
|
418 | - $this->printNotices(); |
|
419 | - } else { |
|
420 | - // block enabled themes run their query loop before headers are sent |
|
421 | - // so we need to add our notices onto the beginning of the content |
|
422 | - add_filter('the_content', [$this, 'prependNotices'], 1, 1); |
|
423 | - } |
|
424 | - } |
|
425 | - do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
426 | - } |
|
427 | - |
|
428 | - |
|
429 | - /** |
|
430 | - * @param string $the_content |
|
431 | - * @return string |
|
432 | - * @since $VID:$ |
|
433 | - */ |
|
434 | - public function prependNotices($the_content) |
|
435 | - { |
|
436 | - $notices = $this->printNotices(); |
|
437 | - return $notices ? $notices . $the_content : $the_content; |
|
438 | - } |
|
439 | - |
|
440 | - |
|
441 | - /** |
|
442 | - * @return false|string |
|
443 | - * @since $VID:$ |
|
444 | - */ |
|
445 | - public function printNotices() |
|
446 | - { |
|
447 | - ob_start(); |
|
448 | - echo wp_kses(EE_Error::get_notices(), AllowedTags::getWithFormTags()); |
|
449 | - EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
450 | - return ob_get_clean(); |
|
451 | - } |
|
452 | - |
|
453 | - |
|
454 | - |
|
455 | - /*********************************************** UTILITIES ***********************************************/ |
|
456 | - |
|
457 | - |
|
458 | - /** |
|
459 | - * @param string $template_include_path |
|
460 | - * @return string |
|
461 | - * @throws EE_Error |
|
462 | - * @throws ReflectionException |
|
463 | - */ |
|
464 | - public function template_include($template_include_path = null) |
|
465 | - { |
|
466 | - if ($this->current_page->isEspressoPage()) { |
|
467 | - // despite all helpers having autoloaders set, we need to manually load the template loader |
|
468 | - // because there are some side effects in that class for triggering template tag functions |
|
469 | - $this->Registry->load_helper('EEH_Template'); |
|
470 | - $this->_template_path = ! empty($this->_template_path) |
|
471 | - ? basename($this->_template_path) |
|
472 | - : basename( |
|
473 | - $template_include_path |
|
474 | - ); |
|
475 | - $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
476 | - $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
477 | - $this->_template = basename($this->_template_path); |
|
478 | - return $this->_template_path; |
|
479 | - } |
|
480 | - return $template_include_path; |
|
481 | - } |
|
482 | - |
|
483 | - |
|
484 | - /** |
|
485 | - * @param bool $with_path |
|
486 | - * @return string |
|
487 | - */ |
|
488 | - public function get_selected_template($with_path = false) |
|
489 | - { |
|
490 | - return $with_path ? $this->_template_path : $this->_template; |
|
491 | - } |
|
492 | - |
|
493 | - |
|
494 | - /** |
|
495 | - * @param string $shortcode_class |
|
496 | - * @param WP $wp |
|
497 | - * @throws ReflectionException |
|
498 | - * @deprecated 4.9.26 |
|
499 | - */ |
|
500 | - public function initialize_shortcode($shortcode_class = '', WP $wp = null) |
|
501 | - { |
|
502 | - EE_Error::doing_it_wrong( |
|
503 | - __METHOD__, |
|
504 | - esc_html__( |
|
505 | - 'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.', |
|
506 | - 'event_espresso' |
|
507 | - ), |
|
508 | - '4.9.26' |
|
509 | - ); |
|
510 | - $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp); |
|
511 | - } |
|
512 | - |
|
513 | - |
|
514 | - /** |
|
515 | - * @return void |
|
516 | - * @deprecated 4.9.57.p |
|
517 | - */ |
|
518 | - public function loadPersistentAdminNoticeManager() |
|
519 | - { |
|
520 | - } |
|
521 | - |
|
522 | - |
|
523 | - /** |
|
524 | - * @return void |
|
525 | - * @deprecated 4.9.64.p |
|
526 | - */ |
|
527 | - public function employ_CPT_Strategy() |
|
528 | - { |
|
529 | - } |
|
21 | + /** |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + private $_template_path; |
|
25 | + |
|
26 | + /** |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + private $_template; |
|
30 | + |
|
31 | + /** |
|
32 | + * @type EE_Registry |
|
33 | + */ |
|
34 | + protected $Registry; |
|
35 | + |
|
36 | + /** |
|
37 | + * @type EE_Request_Handler |
|
38 | + */ |
|
39 | + protected $Request_Handler; |
|
40 | + |
|
41 | + /** |
|
42 | + * @type EE_Module_Request_Router |
|
43 | + */ |
|
44 | + protected $Module_Request_Router; |
|
45 | + |
|
46 | + /** |
|
47 | + * @type CurrentPage |
|
48 | + */ |
|
49 | + protected $current_page; |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * class constructor |
|
54 | + * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
|
55 | + * |
|
56 | + * @access public |
|
57 | + * @param EE_Registry $Registry |
|
58 | + * @param CurrentPage $EspressoPage |
|
59 | + * @param EE_Module_Request_Router $Module_Request_Router |
|
60 | + */ |
|
61 | + public function __construct( |
|
62 | + EE_Registry $Registry, |
|
63 | + CurrentPage $EspressoPage, |
|
64 | + EE_Module_Request_Router $Module_Request_Router |
|
65 | + ) { |
|
66 | + $this->Registry = $Registry; |
|
67 | + $this->current_page = $EspressoPage; |
|
68 | + $this->Module_Request_Router = $Module_Request_Router; |
|
69 | + // load other resources and begin to actually run shortcodes and modules |
|
70 | + // analyse the incoming WP request |
|
71 | + add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
72 | + // process request with module factory |
|
73 | + add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
74 | + // before headers sent |
|
75 | + add_action('wp', array($this, 'wp'), 5); |
|
76 | + // primarily used to process any content shortcodes |
|
77 | + add_action('template_redirect', array($this, 'templateRedirect'), 999); |
|
78 | + // header |
|
79 | + add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
80 | + add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10); |
|
81 | + add_filter('template_include', array($this, 'template_include'), 1); |
|
82 | + // display errors |
|
83 | + add_action('loop_start', array($this, 'display_errors'), 2); |
|
84 | + // the content |
|
85 | + // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
86 | + // exclude our private cpt comments |
|
87 | + add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
88 | + // make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
|
89 | + add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
90 | + // action hook EE |
|
91 | + do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * @return EE_Request_Handler |
|
97 | + * @deprecated 4.10.14.p |
|
98 | + */ |
|
99 | + public function Request_Handler() |
|
100 | + { |
|
101 | + if (! $this->Request_Handler instanceof EE_Request_Handler) { |
|
102 | + $this->Request_Handler = LoaderFactory::getLoader()->getShared('EE_Request_Handler'); |
|
103 | + } |
|
104 | + return $this->Request_Handler; |
|
105 | + } |
|
106 | + |
|
107 | + |
|
108 | + /** |
|
109 | + * @return EE_Module_Request_Router |
|
110 | + */ |
|
111 | + public function Module_Request_Router() |
|
112 | + { |
|
113 | + return $this->Module_Request_Router; |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * @return LegacyShortcodesManager |
|
119 | + * @deprecated 4.10.14.p |
|
120 | + */ |
|
121 | + public function getLegacyShortcodesManager() |
|
122 | + { |
|
123 | + return EE_Config::getLegacyShortcodesManager(); |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + |
|
128 | + |
|
129 | + |
|
130 | + /*********************************************** INIT ACTION HOOK ***********************************************/ |
|
131 | + /** |
|
132 | + * filter_wp_comments |
|
133 | + * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
|
134 | + * widgets/queries done on frontend |
|
135 | + * |
|
136 | + * @param array $clauses array of comment clauses setup by WP_Comment_Query |
|
137 | + * @return array array of comment clauses with modifications. |
|
138 | + * @throws InvalidArgumentException |
|
139 | + * @throws InvalidDataTypeException |
|
140 | + * @throws InvalidInterfaceException |
|
141 | + */ |
|
142 | + public function filter_wp_comments($clauses) |
|
143 | + { |
|
144 | + global $wpdb; |
|
145 | + if (strpos($clauses['join'], $wpdb->posts) !== false) { |
|
146 | + /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */ |
|
147 | + $custom_post_types = LoaderFactory::getLoader()->getShared( |
|
148 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
149 | + ); |
|
150 | + $cpts = $custom_post_types->getPrivateCustomPostTypes(); |
|
151 | + foreach ($cpts as $cpt => $details) { |
|
152 | + $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
153 | + } |
|
154 | + } |
|
155 | + return $clauses; |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + /** |
|
160 | + * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
|
161 | + * |
|
162 | + * @param string $url incoming url |
|
163 | + * @return string final assembled url |
|
164 | + */ |
|
165 | + public function maybe_force_admin_ajax_ssl($url) |
|
166 | + { |
|
167 | + if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
168 | + $url = str_replace('http://', 'https://', $url); |
|
169 | + } |
|
170 | + return $url; |
|
171 | + } |
|
172 | + |
|
173 | + |
|
174 | + |
|
175 | + |
|
176 | + |
|
177 | + |
|
178 | + /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
|
179 | + |
|
180 | + |
|
181 | + /** |
|
182 | + * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
|
183 | + * default priority init phases have run |
|
184 | + * |
|
185 | + * @access public |
|
186 | + * @return void |
|
187 | + */ |
|
188 | + public function wp_loaded() |
|
189 | + { |
|
190 | + } |
|
191 | + |
|
192 | + |
|
193 | + |
|
194 | + |
|
195 | + |
|
196 | + /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
|
197 | + /** |
|
198 | + * _get_request |
|
199 | + * |
|
200 | + * @access public |
|
201 | + * @param WP $WP |
|
202 | + * @return void |
|
203 | + */ |
|
204 | + public function get_request(WP $WP) |
|
205 | + { |
|
206 | + do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
207 | + $this->current_page->parseQueryVars($WP); |
|
208 | + do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
209 | + remove_action('parse_request', [$this, 'get_request'], 1); |
|
210 | + } |
|
211 | + |
|
212 | + |
|
213 | + /** |
|
214 | + * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
|
215 | + * |
|
216 | + * @access public |
|
217 | + * @param WP_Query $WP_Query |
|
218 | + * @return void |
|
219 | + * @throws EE_Error |
|
220 | + * @throws ReflectionException |
|
221 | + */ |
|
222 | + public function pre_get_posts($WP_Query) |
|
223 | + { |
|
224 | + // only load Module_Request_Router if this is the main query |
|
225 | + if ( |
|
226 | + $this->Module_Request_Router instanceof EE_Module_Request_Router |
|
227 | + && $WP_Query->is_main_query() |
|
228 | + ) { |
|
229 | + // cycle thru module routes |
|
230 | + while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
231 | + // determine module and method for route |
|
232 | + $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
233 | + if ($module instanceof EED_Module) { |
|
234 | + // get registered view for route |
|
235 | + $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
236 | + // grab module name |
|
237 | + $module_name = $module->module_name(); |
|
238 | + // map the module to the module objects |
|
239 | + $this->Registry->modules->{$module_name} = $module; |
|
240 | + } |
|
241 | + } |
|
242 | + } |
|
243 | + } |
|
244 | + |
|
245 | + |
|
246 | + |
|
247 | + |
|
248 | + |
|
249 | + /*********************************************** WP HOOK ***********************************************/ |
|
250 | + |
|
251 | + |
|
252 | + /** |
|
253 | + * wp - basically last chance to do stuff before headers sent |
|
254 | + * |
|
255 | + * @access public |
|
256 | + * @return void |
|
257 | + */ |
|
258 | + public function wp() |
|
259 | + { |
|
260 | + } |
|
261 | + |
|
262 | + |
|
263 | + |
|
264 | + /*********************** GET_HEADER && WP_HEAD HOOK ***********************/ |
|
265 | + |
|
266 | + |
|
267 | + /** |
|
268 | + * callback for the "template_redirect" hook point |
|
269 | + * checks sidebars for EE widgets |
|
270 | + * loads resources and assets accordingly |
|
271 | + * |
|
272 | + * @return void |
|
273 | + */ |
|
274 | + public function templateRedirect() |
|
275 | + { |
|
276 | + global $wp_query; |
|
277 | + if (empty($wp_query->posts)) { |
|
278 | + return; |
|
279 | + } |
|
280 | + // if we already know this is an espresso page, then load assets |
|
281 | + $load_assets = $this->current_page->isEspressoPage(); |
|
282 | + // if we are already loading assets then just move along, otherwise check for widgets |
|
283 | + $load_assets = $load_assets || $this->espresso_widgets_in_active_sidebars(); |
|
284 | + if ($load_assets) { |
|
285 | + add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10); |
|
286 | + add_action('wp_print_footer_scripts', array($this, 'enqueueScripts'), 10); |
|
287 | + } |
|
288 | + } |
|
289 | + |
|
290 | + |
|
291 | + /** |
|
292 | + * builds list of active widgets then scans active sidebars looking for them |
|
293 | + * returns true is an EE widget is found in an active sidebar |
|
294 | + * Please Note: this does NOT mean that the sidebar or widget |
|
295 | + * is actually in use in a given template, as that is unfortunately not known |
|
296 | + * until a sidebar and it's widgets are actually loaded |
|
297 | + * |
|
298 | + * @return boolean |
|
299 | + */ |
|
300 | + private function espresso_widgets_in_active_sidebars() |
|
301 | + { |
|
302 | + $espresso_widgets = array(); |
|
303 | + foreach ($this->Registry->widgets as $widget_class => $widget) { |
|
304 | + $id_base = EspressoWidget::getIdBase($widget_class); |
|
305 | + if (is_active_widget(false, false, $id_base)) { |
|
306 | + $espresso_widgets[] = $id_base; |
|
307 | + } |
|
308 | + } |
|
309 | + $all_sidebar_widgets = wp_get_sidebars_widgets(); |
|
310 | + foreach ($all_sidebar_widgets as $sidebar_widgets) { |
|
311 | + if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) { |
|
312 | + foreach ($sidebar_widgets as $sidebar_widget) { |
|
313 | + foreach ($espresso_widgets as $espresso_widget) { |
|
314 | + if (strpos($sidebar_widget, $espresso_widget) !== false) { |
|
315 | + return true; |
|
316 | + } |
|
317 | + } |
|
318 | + } |
|
319 | + } |
|
320 | + } |
|
321 | + return false; |
|
322 | + } |
|
323 | + |
|
324 | + |
|
325 | + /** |
|
326 | + * header_meta_tag |
|
327 | + * |
|
328 | + * @access public |
|
329 | + * @return void |
|
330 | + */ |
|
331 | + public function header_meta_tag() |
|
332 | + { |
|
333 | + print( |
|
334 | + apply_filters( |
|
335 | + 'FHEE__EE_Front_Controller__header_meta_tag', |
|
336 | + '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n" |
|
337 | + ) |
|
338 | + ); |
|
339 | + |
|
340 | + // let's exclude all event type taxonomy term archive pages from search engine indexing |
|
341 | + // @see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
|
342 | + // also exclude all critical pages from indexing |
|
343 | + if ( |
|
344 | + ( |
|
345 | + is_tax('espresso_event_type') |
|
346 | + && get_option('blog_public') !== '0' |
|
347 | + ) |
|
348 | + || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array()) |
|
349 | + ) { |
|
350 | + print( |
|
351 | + apply_filters( |
|
352 | + 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
|
353 | + '<meta name="robots" content="noindex,follow" />' . "\n" |
|
354 | + ) |
|
355 | + ); |
|
356 | + } |
|
357 | + } |
|
358 | + |
|
359 | + |
|
360 | + /** |
|
361 | + * wp_print_scripts |
|
362 | + * |
|
363 | + * @return void |
|
364 | + * @throws EE_Error |
|
365 | + */ |
|
366 | + public function wp_print_scripts() |
|
367 | + { |
|
368 | + global $post; |
|
369 | + if ( |
|
370 | + isset($post->EE_Event) |
|
371 | + && $post->EE_Event instanceof EE_Event |
|
372 | + && get_post_type() === 'espresso_events' |
|
373 | + && is_singular() |
|
374 | + ) { |
|
375 | + EEH_Schema::add_json_linked_data_for_event($post->EE_Event); |
|
376 | + } |
|
377 | + } |
|
378 | + |
|
379 | + |
|
380 | + public function enqueueStyle() |
|
381 | + { |
|
382 | + wp_enqueue_style('espresso_default'); |
|
383 | + wp_enqueue_style('espresso_custom_css'); |
|
384 | + } |
|
385 | + |
|
386 | + |
|
387 | + |
|
388 | + /*********************************************** WP_FOOTER ***********************************************/ |
|
389 | + |
|
390 | + |
|
391 | + public function enqueueScripts() |
|
392 | + { |
|
393 | + wp_enqueue_script('espresso_core'); |
|
394 | + } |
|
395 | + |
|
396 | + |
|
397 | + /** |
|
398 | + * display_errors |
|
399 | + * |
|
400 | + * @access public |
|
401 | + * @return void |
|
402 | + * @throws DomainException |
|
403 | + */ |
|
404 | + public function display_errors() |
|
405 | + { |
|
406 | + static $shown_already = false; |
|
407 | + do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
408 | + if ( |
|
409 | + ! $shown_already |
|
410 | + && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
|
411 | + && is_main_query() |
|
412 | + && ! is_feed() |
|
413 | + && in_the_loop() |
|
414 | + && $this->current_page->isEspressoPage() |
|
415 | + ) { |
|
416 | + $shown_already = true; |
|
417 | + if (did_action('wp_head')) { |
|
418 | + $this->printNotices(); |
|
419 | + } else { |
|
420 | + // block enabled themes run their query loop before headers are sent |
|
421 | + // so we need to add our notices onto the beginning of the content |
|
422 | + add_filter('the_content', [$this, 'prependNotices'], 1, 1); |
|
423 | + } |
|
424 | + } |
|
425 | + do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
426 | + } |
|
427 | + |
|
428 | + |
|
429 | + /** |
|
430 | + * @param string $the_content |
|
431 | + * @return string |
|
432 | + * @since $VID:$ |
|
433 | + */ |
|
434 | + public function prependNotices($the_content) |
|
435 | + { |
|
436 | + $notices = $this->printNotices(); |
|
437 | + return $notices ? $notices . $the_content : $the_content; |
|
438 | + } |
|
439 | + |
|
440 | + |
|
441 | + /** |
|
442 | + * @return false|string |
|
443 | + * @since $VID:$ |
|
444 | + */ |
|
445 | + public function printNotices() |
|
446 | + { |
|
447 | + ob_start(); |
|
448 | + echo wp_kses(EE_Error::get_notices(), AllowedTags::getWithFormTags()); |
|
449 | + EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
450 | + return ob_get_clean(); |
|
451 | + } |
|
452 | + |
|
453 | + |
|
454 | + |
|
455 | + /*********************************************** UTILITIES ***********************************************/ |
|
456 | + |
|
457 | + |
|
458 | + /** |
|
459 | + * @param string $template_include_path |
|
460 | + * @return string |
|
461 | + * @throws EE_Error |
|
462 | + * @throws ReflectionException |
|
463 | + */ |
|
464 | + public function template_include($template_include_path = null) |
|
465 | + { |
|
466 | + if ($this->current_page->isEspressoPage()) { |
|
467 | + // despite all helpers having autoloaders set, we need to manually load the template loader |
|
468 | + // because there are some side effects in that class for triggering template tag functions |
|
469 | + $this->Registry->load_helper('EEH_Template'); |
|
470 | + $this->_template_path = ! empty($this->_template_path) |
|
471 | + ? basename($this->_template_path) |
|
472 | + : basename( |
|
473 | + $template_include_path |
|
474 | + ); |
|
475 | + $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
476 | + $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
477 | + $this->_template = basename($this->_template_path); |
|
478 | + return $this->_template_path; |
|
479 | + } |
|
480 | + return $template_include_path; |
|
481 | + } |
|
482 | + |
|
483 | + |
|
484 | + /** |
|
485 | + * @param bool $with_path |
|
486 | + * @return string |
|
487 | + */ |
|
488 | + public function get_selected_template($with_path = false) |
|
489 | + { |
|
490 | + return $with_path ? $this->_template_path : $this->_template; |
|
491 | + } |
|
492 | + |
|
493 | + |
|
494 | + /** |
|
495 | + * @param string $shortcode_class |
|
496 | + * @param WP $wp |
|
497 | + * @throws ReflectionException |
|
498 | + * @deprecated 4.9.26 |
|
499 | + */ |
|
500 | + public function initialize_shortcode($shortcode_class = '', WP $wp = null) |
|
501 | + { |
|
502 | + EE_Error::doing_it_wrong( |
|
503 | + __METHOD__, |
|
504 | + esc_html__( |
|
505 | + 'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.', |
|
506 | + 'event_espresso' |
|
507 | + ), |
|
508 | + '4.9.26' |
|
509 | + ); |
|
510 | + $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp); |
|
511 | + } |
|
512 | + |
|
513 | + |
|
514 | + /** |
|
515 | + * @return void |
|
516 | + * @deprecated 4.9.57.p |
|
517 | + */ |
|
518 | + public function loadPersistentAdminNoticeManager() |
|
519 | + { |
|
520 | + } |
|
521 | + |
|
522 | + |
|
523 | + /** |
|
524 | + * @return void |
|
525 | + * @deprecated 4.9.64.p |
|
526 | + */ |
|
527 | + public function employ_CPT_Strategy() |
|
528 | + { |
|
529 | + } |
|
530 | 530 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function Request_Handler() |
100 | 100 | { |
101 | - if (! $this->Request_Handler instanceof EE_Request_Handler) { |
|
101 | + if ( ! $this->Request_Handler instanceof EE_Request_Handler) { |
|
102 | 102 | $this->Request_Handler = LoaderFactory::getLoader()->getShared('EE_Request_Handler'); |
103 | 103 | } |
104 | 104 | return $this->Request_Handler; |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | print( |
334 | 334 | apply_filters( |
335 | 335 | 'FHEE__EE_Front_Controller__header_meta_tag', |
336 | - '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n" |
|
336 | + '<meta name="generator" content="Event Espresso Version '.EVENT_ESPRESSO_VERSION."\" />\n" |
|
337 | 337 | ) |
338 | 338 | ); |
339 | 339 | |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | print( |
351 | 351 | apply_filters( |
352 | 352 | 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
353 | - '<meta name="robots" content="noindex,follow" />' . "\n" |
|
353 | + '<meta name="robots" content="noindex,follow" />'."\n" |
|
354 | 354 | ) |
355 | 355 | ); |
356 | 356 | } |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | public function prependNotices($the_content) |
435 | 435 | { |
436 | 436 | $notices = $this->printNotices(); |
437 | - return $notices ? $notices . $the_content : $the_content; |
|
437 | + return $notices ? $notices.$the_content : $the_content; |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | { |
447 | 447 | ob_start(); |
448 | 448 | echo wp_kses(EE_Error::get_notices(), AllowedTags::getWithFormTags()); |
449 | - EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
449 | + EEH_Template::display_template(EE_TEMPLATES.'espresso-ajax-notices.template.php'); |
|
450 | 450 | return ob_get_clean(); |
451 | 451 | } |
452 | 452 |