@@ -18,67 +18,67 @@ |
||
18 | 18 | class ExitModal |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var Registry |
|
23 | - */ |
|
24 | - private $assets_registry; |
|
21 | + /** |
|
22 | + * @var Registry |
|
23 | + */ |
|
24 | + private $assets_registry; |
|
25 | 25 | |
26 | - /** |
|
27 | - * ExitModal constructor. |
|
28 | - * |
|
29 | - * @param Registry $assets_registry |
|
30 | - */ |
|
31 | - public function __construct(Registry $assets_registry) |
|
32 | - { |
|
33 | - $this->assets_registry = $assets_registry; |
|
34 | - add_action('in_admin_footer', array($this, 'modalContainer')); |
|
35 | - add_action('admin_enqueue_scripts', array($this, 'enqueues')); |
|
36 | - } |
|
26 | + /** |
|
27 | + * ExitModal constructor. |
|
28 | + * |
|
29 | + * @param Registry $assets_registry |
|
30 | + */ |
|
31 | + public function __construct(Registry $assets_registry) |
|
32 | + { |
|
33 | + $this->assets_registry = $assets_registry; |
|
34 | + add_action('in_admin_footer', array($this, 'modalContainer')); |
|
35 | + add_action('admin_enqueue_scripts', array($this, 'enqueues')); |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * Callback on in_admin_footer that is used to output the exit modal container. |
|
41 | - */ |
|
42 | - public function modalContainer() |
|
43 | - { |
|
44 | - echo '<div id="ee-exit-survey-modal"></div>'; |
|
45 | - } |
|
39 | + /** |
|
40 | + * Callback on in_admin_footer that is used to output the exit modal container. |
|
41 | + */ |
|
42 | + public function modalContainer() |
|
43 | + { |
|
44 | + echo '<div id="ee-exit-survey-modal"></div>'; |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * Callback for `admin_enqueue_scripts` to take care of enqueueing scripts and styles specific to the modal. |
|
50 | - * |
|
51 | - * @throws InvalidArgumentException |
|
52 | - */ |
|
53 | - public function enqueues() |
|
54 | - { |
|
55 | - $this->assets_registry->addData( |
|
56 | - 'exitModali18n', |
|
57 | - array( |
|
58 | - 'introText' => htmlspecialchars( |
|
59 | - __( |
|
60 | - 'Do you have a moment to share why you are deactivating Event Espresso?', |
|
61 | - 'event_espresso' |
|
62 | - ), |
|
63 | - ENT_NOQUOTES |
|
64 | - ), |
|
65 | - 'doSurveyButtonText' => htmlspecialchars( |
|
66 | - __( |
|
67 | - 'Sure I\'ll help', |
|
68 | - 'event_espresso' |
|
69 | - ), |
|
70 | - ENT_NOQUOTES |
|
71 | - ), |
|
72 | - 'skipButtonText' => htmlspecialchars( |
|
73 | - __( |
|
74 | - 'Skip', |
|
75 | - 'event_espresso' |
|
76 | - ), |
|
77 | - ENT_NOQUOTES |
|
78 | - ) |
|
79 | - ) |
|
80 | - ); |
|
81 | - wp_enqueue_script('ee-exit-modal-survey'); |
|
82 | - wp_enqueue_style('ee-exit-modal-survey'); |
|
83 | - } |
|
48 | + /** |
|
49 | + * Callback for `admin_enqueue_scripts` to take care of enqueueing scripts and styles specific to the modal. |
|
50 | + * |
|
51 | + * @throws InvalidArgumentException |
|
52 | + */ |
|
53 | + public function enqueues() |
|
54 | + { |
|
55 | + $this->assets_registry->addData( |
|
56 | + 'exitModali18n', |
|
57 | + array( |
|
58 | + 'introText' => htmlspecialchars( |
|
59 | + __( |
|
60 | + 'Do you have a moment to share why you are deactivating Event Espresso?', |
|
61 | + 'event_espresso' |
|
62 | + ), |
|
63 | + ENT_NOQUOTES |
|
64 | + ), |
|
65 | + 'doSurveyButtonText' => htmlspecialchars( |
|
66 | + __( |
|
67 | + 'Sure I\'ll help', |
|
68 | + 'event_espresso' |
|
69 | + ), |
|
70 | + ENT_NOQUOTES |
|
71 | + ), |
|
72 | + 'skipButtonText' => htmlspecialchars( |
|
73 | + __( |
|
74 | + 'Skip', |
|
75 | + 'event_espresso' |
|
76 | + ), |
|
77 | + ENT_NOQUOTES |
|
78 | + ) |
|
79 | + ) |
|
80 | + ); |
|
81 | + wp_enqueue_script('ee-exit-modal-survey'); |
|
82 | + wp_enqueue_style('ee-exit-modal-survey'); |
|
83 | + } |
|
84 | 84 | } |
85 | 85 | \ No newline at end of file |
@@ -24,483 +24,483 @@ |
||
24 | 24 | class Registry |
25 | 25 | { |
26 | 26 | |
27 | - /** |
|
28 | - * @var EE_Template_Config $template_config |
|
29 | - */ |
|
30 | - protected $template_config; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var EE_Currency_Config $currency_config |
|
34 | - */ |
|
35 | - protected $currency_config; |
|
36 | - |
|
37 | - /** |
|
38 | - * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script. |
|
39 | - * |
|
40 | - * @var array |
|
41 | - */ |
|
42 | - protected $jsdata = array(); |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * This keeps track of all scripts with registered data. It is used to prevent duplicate data objects setup in the |
|
47 | - * page source. |
|
48 | - * @var array |
|
49 | - */ |
|
50 | - protected $script_handles_with_data = array(); |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * @var DomainInterface |
|
55 | - */ |
|
56 | - protected $domain; |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * Registry constructor. |
|
61 | - * Hooking into WP actions for script registry. |
|
62 | - * |
|
63 | - * @param EE_Template_Config $template_config |
|
64 | - * @param EE_Currency_Config $currency_config |
|
65 | - * @param DomainInterface $domain |
|
66 | - */ |
|
67 | - public function __construct( |
|
68 | - EE_Template_Config $template_config, |
|
69 | - EE_Currency_Config $currency_config, |
|
70 | - DomainInterface $domain |
|
71 | - ) { |
|
72 | - $this->template_config = $template_config; |
|
73 | - $this->currency_config = $currency_config; |
|
74 | - $this->domain = $domain; |
|
75 | - add_action('wp_enqueue_scripts', array($this, 'scripts'), 1); |
|
76 | - add_action('admin_enqueue_scripts', array($this, 'scripts'), 1); |
|
77 | - add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 2); |
|
78 | - add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 2); |
|
79 | - add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1); |
|
80 | - add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1); |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * Callback for the WP script actions. |
|
87 | - * Used to register globally accessible core scripts. |
|
88 | - * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency. |
|
89 | - */ |
|
90 | - public function scripts() |
|
91 | - { |
|
92 | - global $wp_version; |
|
93 | - wp_register_script( |
|
94 | - 'eejs-core', |
|
95 | - EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js', |
|
96 | - array(), |
|
97 | - EVENT_ESPRESSO_VERSION, |
|
98 | - true |
|
99 | - ); |
|
100 | - //only run this if WordPress 4.4.0 > is in use. |
|
101 | - if (version_compare($wp_version, '4.4.0', '>')) { |
|
102 | - //js.api |
|
103 | - wp_register_script( |
|
104 | - 'eejs-api', |
|
105 | - EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
106 | - array('underscore', 'eejs-core'), |
|
107 | - EVENT_ESPRESSO_VERSION, |
|
108 | - true |
|
109 | - ); |
|
110 | - $this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest'); |
|
111 | - $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/')); |
|
112 | - } |
|
113 | - if (! is_admin()) { |
|
114 | - $this->loadCoreCss(); |
|
115 | - } |
|
116 | - $this->loadCoreJs(); |
|
117 | - $this->loadJqueryValidate(); |
|
118 | - $this->loadAccountingJs(); |
|
119 | - $this->loadQtipJs(); |
|
120 | - $this->registerAdminAssets(); |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * Call back for the script print in frontend and backend. |
|
127 | - * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point. |
|
128 | - * |
|
129 | - * @since 4.9.31.rc.015 |
|
130 | - */ |
|
131 | - public function enqueueData() |
|
132 | - { |
|
133 | - $this->removeAlreadyRegisteredDataForScriptHandles(); |
|
134 | - wp_localize_script('eejs-core', 'eejs', array('data' => $this->jsdata)); |
|
135 | - wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
|
136 | - $this->localizeAccountingJs(); |
|
137 | - $this->addRegisteredScriptHandlesWithData('eejs-core'); |
|
138 | - $this->addRegisteredScriptHandlesWithData('espresso_core'); |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * Used to add data to eejs.data object. |
|
145 | - * Note: Overriding existing data is not allowed. |
|
146 | - * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript. |
|
147 | - * If the data you add is something like this: |
|
148 | - * $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) ); |
|
149 | - * It will be exposed in the page source as: |
|
150 | - * eejs.data.my_plugin_data.foo == gar |
|
151 | - * |
|
152 | - * @param string $key Key used to access your data |
|
153 | - * @param string|array $value Value to attach to key |
|
154 | - * @throws InvalidArgumentException |
|
155 | - */ |
|
156 | - public function addData($key, $value) |
|
157 | - { |
|
158 | - if ($this->verifyDataNotExisting($key)) { |
|
159 | - $this->jsdata[$key] = $value; |
|
160 | - } |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - |
|
165 | - /** |
|
166 | - * Similar to addData except this allows for users to push values to an existing key where the values on key are |
|
167 | - * elements in an array. |
|
168 | - * When you use this method, the value you include will be appended to the end of an array on $key. |
|
169 | - * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript |
|
170 | - * object like this, eejs.data.test = [ my_data, |
|
171 | - * ] |
|
172 | - * If there has already been a scalar value attached to the data object given key, then |
|
173 | - * this will throw an exception. |
|
174 | - * |
|
175 | - * @param string $key Key to attach data to. |
|
176 | - * @param string|array $value Value being registered. |
|
177 | - * @throws InvalidArgumentException |
|
178 | - */ |
|
179 | - public function pushData($key, $value) |
|
180 | - { |
|
181 | - if (isset($this->jsdata[$key]) |
|
182 | - && ! is_array($this->jsdata[$key]) |
|
183 | - ) { |
|
184 | - throw new invalidArgumentException( |
|
185 | - sprintf( |
|
186 | - __( |
|
187 | - 'The value for %1$s is already set and it is not an array. The %2$s method can only be used to |
|
27 | + /** |
|
28 | + * @var EE_Template_Config $template_config |
|
29 | + */ |
|
30 | + protected $template_config; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var EE_Currency_Config $currency_config |
|
34 | + */ |
|
35 | + protected $currency_config; |
|
36 | + |
|
37 | + /** |
|
38 | + * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script. |
|
39 | + * |
|
40 | + * @var array |
|
41 | + */ |
|
42 | + protected $jsdata = array(); |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * This keeps track of all scripts with registered data. It is used to prevent duplicate data objects setup in the |
|
47 | + * page source. |
|
48 | + * @var array |
|
49 | + */ |
|
50 | + protected $script_handles_with_data = array(); |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * @var DomainInterface |
|
55 | + */ |
|
56 | + protected $domain; |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * Registry constructor. |
|
61 | + * Hooking into WP actions for script registry. |
|
62 | + * |
|
63 | + * @param EE_Template_Config $template_config |
|
64 | + * @param EE_Currency_Config $currency_config |
|
65 | + * @param DomainInterface $domain |
|
66 | + */ |
|
67 | + public function __construct( |
|
68 | + EE_Template_Config $template_config, |
|
69 | + EE_Currency_Config $currency_config, |
|
70 | + DomainInterface $domain |
|
71 | + ) { |
|
72 | + $this->template_config = $template_config; |
|
73 | + $this->currency_config = $currency_config; |
|
74 | + $this->domain = $domain; |
|
75 | + add_action('wp_enqueue_scripts', array($this, 'scripts'), 1); |
|
76 | + add_action('admin_enqueue_scripts', array($this, 'scripts'), 1); |
|
77 | + add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 2); |
|
78 | + add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 2); |
|
79 | + add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1); |
|
80 | + add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1); |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * Callback for the WP script actions. |
|
87 | + * Used to register globally accessible core scripts. |
|
88 | + * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency. |
|
89 | + */ |
|
90 | + public function scripts() |
|
91 | + { |
|
92 | + global $wp_version; |
|
93 | + wp_register_script( |
|
94 | + 'eejs-core', |
|
95 | + EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js', |
|
96 | + array(), |
|
97 | + EVENT_ESPRESSO_VERSION, |
|
98 | + true |
|
99 | + ); |
|
100 | + //only run this if WordPress 4.4.0 > is in use. |
|
101 | + if (version_compare($wp_version, '4.4.0', '>')) { |
|
102 | + //js.api |
|
103 | + wp_register_script( |
|
104 | + 'eejs-api', |
|
105 | + EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
106 | + array('underscore', 'eejs-core'), |
|
107 | + EVENT_ESPRESSO_VERSION, |
|
108 | + true |
|
109 | + ); |
|
110 | + $this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest'); |
|
111 | + $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/')); |
|
112 | + } |
|
113 | + if (! is_admin()) { |
|
114 | + $this->loadCoreCss(); |
|
115 | + } |
|
116 | + $this->loadCoreJs(); |
|
117 | + $this->loadJqueryValidate(); |
|
118 | + $this->loadAccountingJs(); |
|
119 | + $this->loadQtipJs(); |
|
120 | + $this->registerAdminAssets(); |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * Call back for the script print in frontend and backend. |
|
127 | + * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point. |
|
128 | + * |
|
129 | + * @since 4.9.31.rc.015 |
|
130 | + */ |
|
131 | + public function enqueueData() |
|
132 | + { |
|
133 | + $this->removeAlreadyRegisteredDataForScriptHandles(); |
|
134 | + wp_localize_script('eejs-core', 'eejs', array('data' => $this->jsdata)); |
|
135 | + wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
|
136 | + $this->localizeAccountingJs(); |
|
137 | + $this->addRegisteredScriptHandlesWithData('eejs-core'); |
|
138 | + $this->addRegisteredScriptHandlesWithData('espresso_core'); |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * Used to add data to eejs.data object. |
|
145 | + * Note: Overriding existing data is not allowed. |
|
146 | + * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript. |
|
147 | + * If the data you add is something like this: |
|
148 | + * $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) ); |
|
149 | + * It will be exposed in the page source as: |
|
150 | + * eejs.data.my_plugin_data.foo == gar |
|
151 | + * |
|
152 | + * @param string $key Key used to access your data |
|
153 | + * @param string|array $value Value to attach to key |
|
154 | + * @throws InvalidArgumentException |
|
155 | + */ |
|
156 | + public function addData($key, $value) |
|
157 | + { |
|
158 | + if ($this->verifyDataNotExisting($key)) { |
|
159 | + $this->jsdata[$key] = $value; |
|
160 | + } |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + |
|
165 | + /** |
|
166 | + * Similar to addData except this allows for users to push values to an existing key where the values on key are |
|
167 | + * elements in an array. |
|
168 | + * When you use this method, the value you include will be appended to the end of an array on $key. |
|
169 | + * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript |
|
170 | + * object like this, eejs.data.test = [ my_data, |
|
171 | + * ] |
|
172 | + * If there has already been a scalar value attached to the data object given key, then |
|
173 | + * this will throw an exception. |
|
174 | + * |
|
175 | + * @param string $key Key to attach data to. |
|
176 | + * @param string|array $value Value being registered. |
|
177 | + * @throws InvalidArgumentException |
|
178 | + */ |
|
179 | + public function pushData($key, $value) |
|
180 | + { |
|
181 | + if (isset($this->jsdata[$key]) |
|
182 | + && ! is_array($this->jsdata[$key]) |
|
183 | + ) { |
|
184 | + throw new invalidArgumentException( |
|
185 | + sprintf( |
|
186 | + __( |
|
187 | + 'The value for %1$s is already set and it is not an array. The %2$s method can only be used to |
|
188 | 188 | push values to this data element when it is an array.', |
189 | - 'event_espresso' |
|
190 | - ), |
|
191 | - $key, |
|
192 | - __METHOD__ |
|
193 | - ) |
|
194 | - ); |
|
195 | - } |
|
196 | - $this->jsdata[$key][] = $value; |
|
197 | - } |
|
198 | - |
|
199 | - |
|
200 | - |
|
201 | - /** |
|
202 | - * Used to set content used by javascript for a template. |
|
203 | - * Note: Overrides of existing registered templates are not allowed. |
|
204 | - * |
|
205 | - * @param string $template_reference |
|
206 | - * @param string $template_content |
|
207 | - * @throws InvalidArgumentException |
|
208 | - */ |
|
209 | - public function addTemplate($template_reference, $template_content) |
|
210 | - { |
|
211 | - if (! isset($this->jsdata['templates'])) { |
|
212 | - $this->jsdata['templates'] = array(); |
|
213 | - } |
|
214 | - //no overrides allowed. |
|
215 | - if (isset($this->jsdata['templates'][$template_reference])) { |
|
216 | - throw new invalidArgumentException( |
|
217 | - sprintf( |
|
218 | - __( |
|
219 | - 'The %1$s key already exists for the templates array in the js data array. No overrides are allowed.', |
|
220 | - 'event_espresso' |
|
221 | - ), |
|
222 | - $template_reference |
|
223 | - ) |
|
224 | - ); |
|
225 | - } |
|
226 | - $this->jsdata['templates'][$template_reference] = $template_content; |
|
227 | - } |
|
228 | - |
|
229 | - |
|
230 | - |
|
231 | - /** |
|
232 | - * Retrieve the template content already registered for the given reference. |
|
233 | - * |
|
234 | - * @param string $template_reference |
|
235 | - * @return string |
|
236 | - */ |
|
237 | - public function getTemplate($template_reference) |
|
238 | - { |
|
239 | - return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference]) |
|
240 | - ? $this->jsdata['templates'][$template_reference] |
|
241 | - : ''; |
|
242 | - } |
|
243 | - |
|
244 | - |
|
245 | - |
|
246 | - /** |
|
247 | - * Retrieve registered data. |
|
248 | - * |
|
249 | - * @param string $key Name of key to attach data to. |
|
250 | - * @return mixed If there is no for the given key, then false is returned. |
|
251 | - */ |
|
252 | - public function getData($key) |
|
253 | - { |
|
254 | - return isset($this->jsdata[$key]) |
|
255 | - ? $this->jsdata[$key] |
|
256 | - : false; |
|
257 | - } |
|
258 | - |
|
259 | - |
|
260 | - |
|
261 | - /** |
|
262 | - * Verifies whether the given data exists already on the jsdata array. |
|
263 | - * Overriding data is not allowed. |
|
264 | - * |
|
265 | - * @param string $key Index for data. |
|
266 | - * @return bool If valid then return true. |
|
267 | - * @throws InvalidArgumentException if data already exists. |
|
268 | - */ |
|
269 | - protected function verifyDataNotExisting($key) |
|
270 | - { |
|
271 | - if (isset($this->jsdata[$key])) { |
|
272 | - if (is_array($this->jsdata[$key])) { |
|
273 | - throw new InvalidArgumentException( |
|
274 | - sprintf( |
|
275 | - __( |
|
276 | - 'The value for %1$s already exists in the Registry::eejs object. |
|
189 | + 'event_espresso' |
|
190 | + ), |
|
191 | + $key, |
|
192 | + __METHOD__ |
|
193 | + ) |
|
194 | + ); |
|
195 | + } |
|
196 | + $this->jsdata[$key][] = $value; |
|
197 | + } |
|
198 | + |
|
199 | + |
|
200 | + |
|
201 | + /** |
|
202 | + * Used to set content used by javascript for a template. |
|
203 | + * Note: Overrides of existing registered templates are not allowed. |
|
204 | + * |
|
205 | + * @param string $template_reference |
|
206 | + * @param string $template_content |
|
207 | + * @throws InvalidArgumentException |
|
208 | + */ |
|
209 | + public function addTemplate($template_reference, $template_content) |
|
210 | + { |
|
211 | + if (! isset($this->jsdata['templates'])) { |
|
212 | + $this->jsdata['templates'] = array(); |
|
213 | + } |
|
214 | + //no overrides allowed. |
|
215 | + if (isset($this->jsdata['templates'][$template_reference])) { |
|
216 | + throw new invalidArgumentException( |
|
217 | + sprintf( |
|
218 | + __( |
|
219 | + 'The %1$s key already exists for the templates array in the js data array. No overrides are allowed.', |
|
220 | + 'event_espresso' |
|
221 | + ), |
|
222 | + $template_reference |
|
223 | + ) |
|
224 | + ); |
|
225 | + } |
|
226 | + $this->jsdata['templates'][$template_reference] = $template_content; |
|
227 | + } |
|
228 | + |
|
229 | + |
|
230 | + |
|
231 | + /** |
|
232 | + * Retrieve the template content already registered for the given reference. |
|
233 | + * |
|
234 | + * @param string $template_reference |
|
235 | + * @return string |
|
236 | + */ |
|
237 | + public function getTemplate($template_reference) |
|
238 | + { |
|
239 | + return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference]) |
|
240 | + ? $this->jsdata['templates'][$template_reference] |
|
241 | + : ''; |
|
242 | + } |
|
243 | + |
|
244 | + |
|
245 | + |
|
246 | + /** |
|
247 | + * Retrieve registered data. |
|
248 | + * |
|
249 | + * @param string $key Name of key to attach data to. |
|
250 | + * @return mixed If there is no for the given key, then false is returned. |
|
251 | + */ |
|
252 | + public function getData($key) |
|
253 | + { |
|
254 | + return isset($this->jsdata[$key]) |
|
255 | + ? $this->jsdata[$key] |
|
256 | + : false; |
|
257 | + } |
|
258 | + |
|
259 | + |
|
260 | + |
|
261 | + /** |
|
262 | + * Verifies whether the given data exists already on the jsdata array. |
|
263 | + * Overriding data is not allowed. |
|
264 | + * |
|
265 | + * @param string $key Index for data. |
|
266 | + * @return bool If valid then return true. |
|
267 | + * @throws InvalidArgumentException if data already exists. |
|
268 | + */ |
|
269 | + protected function verifyDataNotExisting($key) |
|
270 | + { |
|
271 | + if (isset($this->jsdata[$key])) { |
|
272 | + if (is_array($this->jsdata[$key])) { |
|
273 | + throw new InvalidArgumentException( |
|
274 | + sprintf( |
|
275 | + __( |
|
276 | + 'The value for %1$s already exists in the Registry::eejs object. |
|
277 | 277 | Overrides are not allowed. Since the value of this data is an array, you may want to use the |
278 | 278 | %2$s method to push your value to the array.', |
279 | - 'event_espresso' |
|
280 | - ), |
|
281 | - $key, |
|
282 | - 'pushData()' |
|
283 | - ) |
|
284 | - ); |
|
285 | - } |
|
286 | - throw new InvalidArgumentException( |
|
287 | - sprintf( |
|
288 | - __( |
|
289 | - 'The value for %1$s already exists in the Registry::eejs object. Overrides are not |
|
279 | + 'event_espresso' |
|
280 | + ), |
|
281 | + $key, |
|
282 | + 'pushData()' |
|
283 | + ) |
|
284 | + ); |
|
285 | + } |
|
286 | + throw new InvalidArgumentException( |
|
287 | + sprintf( |
|
288 | + __( |
|
289 | + 'The value for %1$s already exists in the Registry::eejs object. Overrides are not |
|
290 | 290 | allowed. Consider attaching your value to a different key', |
291 | - 'event_espresso' |
|
292 | - ), |
|
293 | - $key |
|
294 | - ) |
|
295 | - ); |
|
296 | - } |
|
297 | - return true; |
|
298 | - } |
|
299 | - |
|
300 | - |
|
301 | - |
|
302 | - /** |
|
303 | - * registers core default stylesheets |
|
304 | - */ |
|
305 | - private function loadCoreCss() |
|
306 | - { |
|
307 | - if ($this->template_config->enable_default_style) { |
|
308 | - $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
309 | - ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
310 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css'; |
|
311 | - wp_register_style( |
|
312 | - 'espresso_default', |
|
313 | - $default_stylesheet_path, |
|
314 | - array('dashicons'), |
|
315 | - EVENT_ESPRESSO_VERSION |
|
316 | - ); |
|
317 | - //Load custom style sheet if available |
|
318 | - if ($this->template_config->custom_style_sheet !== null) { |
|
319 | - wp_register_style( |
|
320 | - 'espresso_custom_css', |
|
321 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
322 | - array('espresso_default'), |
|
323 | - EVENT_ESPRESSO_VERSION |
|
324 | - ); |
|
325 | - } |
|
326 | - } |
|
327 | - } |
|
328 | - |
|
329 | - |
|
330 | - |
|
331 | - /** |
|
332 | - * registers core default javascript |
|
333 | - */ |
|
334 | - private function loadCoreJs() |
|
335 | - { |
|
336 | - // load core js |
|
337 | - wp_register_script( |
|
338 | - 'espresso_core', |
|
339 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
340 | - array('jquery'), |
|
341 | - EVENT_ESPRESSO_VERSION, |
|
342 | - true |
|
343 | - ); |
|
344 | - } |
|
345 | - |
|
346 | - |
|
347 | - |
|
348 | - /** |
|
349 | - * registers jQuery Validate for form validation |
|
350 | - */ |
|
351 | - private function loadJqueryValidate() |
|
352 | - { |
|
353 | - // register jQuery Validate and additional methods |
|
354 | - wp_register_script( |
|
355 | - 'jquery-validate', |
|
356 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
357 | - array('jquery'), |
|
358 | - '1.15.0', |
|
359 | - true |
|
360 | - ); |
|
361 | - wp_register_script( |
|
362 | - 'jquery-validate-extra-methods', |
|
363 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
364 | - array('jquery', 'jquery-validate'), |
|
365 | - '1.15.0', |
|
366 | - true |
|
367 | - ); |
|
368 | - } |
|
369 | - |
|
370 | - |
|
371 | - |
|
372 | - /** |
|
373 | - * registers accounting.js for performing client-side calculations |
|
374 | - */ |
|
375 | - private function loadAccountingJs() |
|
376 | - { |
|
377 | - //accounting.js library |
|
378 | - // @link http://josscrowcroft.github.io/accounting.js/ |
|
379 | - wp_register_script( |
|
380 | - 'ee-accounting-core', |
|
381 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
382 | - array('underscore'), |
|
383 | - '0.3.2', |
|
384 | - true |
|
385 | - ); |
|
386 | - wp_register_script( |
|
387 | - 'ee-accounting', |
|
388 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
389 | - array('ee-accounting-core'), |
|
390 | - EVENT_ESPRESSO_VERSION, |
|
391 | - true |
|
392 | - ); |
|
393 | - } |
|
394 | - |
|
395 | - |
|
396 | - |
|
397 | - /** |
|
398 | - * registers accounting.js for performing client-side calculations |
|
399 | - */ |
|
400 | - private function localizeAccountingJs() |
|
401 | - { |
|
402 | - wp_localize_script( |
|
403 | - 'ee-accounting', |
|
404 | - 'EE_ACCOUNTING_CFG', |
|
405 | - array( |
|
406 | - 'currency' => array( |
|
407 | - 'symbol' => $this->currency_config->sign, |
|
408 | - 'format' => array( |
|
409 | - 'pos' => $this->currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
410 | - 'neg' => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
411 | - 'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s', |
|
412 | - ), |
|
413 | - 'decimal' => $this->currency_config->dec_mrk, |
|
414 | - 'thousand' => $this->currency_config->thsnds, |
|
415 | - 'precision' => $this->currency_config->dec_plc, |
|
416 | - ), |
|
417 | - 'number' => array( |
|
418 | - 'precision' => $this->currency_config->dec_plc, |
|
419 | - 'thousand' => $this->currency_config->thsnds, |
|
420 | - 'decimal' => $this->currency_config->dec_mrk, |
|
421 | - ), |
|
422 | - ) |
|
423 | - ); |
|
424 | - $this->addRegisteredScriptHandlesWithData('ee-accounting'); |
|
425 | - } |
|
426 | - |
|
427 | - |
|
428 | - |
|
429 | - /** |
|
430 | - * registers assets for cleaning your ears |
|
431 | - */ |
|
432 | - private function loadQtipJs() |
|
433 | - { |
|
434 | - // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
435 | - // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
436 | - if (apply_filters('FHEE_load_qtip', false)) { |
|
437 | - EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
438 | - } |
|
439 | - } |
|
440 | - |
|
441 | - |
|
442 | - /** |
|
443 | - * This is used to set registered script handles that have data. |
|
444 | - * @param string $script_handle |
|
445 | - */ |
|
446 | - private function addRegisteredScriptHandlesWithData($script_handle) |
|
447 | - { |
|
448 | - $this->script_handles_with_data[$script_handle] = $script_handle; |
|
449 | - } |
|
450 | - |
|
451 | - |
|
452 | - /** |
|
453 | - * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the |
|
454 | - * Dependency stored in WP_Scripts if its set. |
|
455 | - */ |
|
456 | - private function removeAlreadyRegisteredDataForScriptHandles() |
|
457 | - { |
|
458 | - if (empty($this->script_handles_with_data)) { |
|
459 | - return; |
|
460 | - } |
|
461 | - foreach ($this->script_handles_with_data as $script_handle) { |
|
462 | - $this->removeAlreadyRegisteredDataForScriptHandle($script_handle); |
|
463 | - } |
|
464 | - } |
|
465 | - |
|
466 | - |
|
467 | - /** |
|
468 | - * Removes any data dependency registered in WP_Scripts if its set. |
|
469 | - * @param string $script_handle |
|
470 | - */ |
|
471 | - private function removeAlreadyRegisteredDataForScriptHandle($script_handle) |
|
472 | - { |
|
473 | - if (isset($this->script_handles_with_data[$script_handle])) { |
|
474 | - global $wp_scripts; |
|
475 | - if ($wp_scripts->get_data($script_handle, 'data')) { |
|
476 | - unset($wp_scripts->registered[$script_handle]->extra['data']); |
|
477 | - unset($this->script_handles_with_data[$script_handle]); |
|
478 | - } |
|
479 | - } |
|
480 | - } |
|
481 | - |
|
482 | - |
|
483 | - /** |
|
484 | - * Registers assets that are used in the WordPress admin. |
|
485 | - */ |
|
486 | - private function registerAdminAssets() |
|
487 | - { |
|
488 | - wp_register_script( |
|
489 | - 'ee-exit-modal-survey', |
|
490 | - $this->domain->distributionAssetsUrl() . 'ee-exit-modal-survey.dist.js', |
|
491 | - array( |
|
492 | - 'jquery', |
|
493 | - 'eejs-core' |
|
494 | - ), |
|
495 | - filemtime($this->domain->distributionAssetsPath() . 'ee-exit-modal-survey.dist.js'), |
|
496 | - true |
|
497 | - ); |
|
498 | - wp_register_style( |
|
499 | - 'ee-exit-modal-survey', |
|
500 | - $this->domain->distributionAssetsUrl() . 'ee-exit-modal-survey.dist.css', |
|
501 | - array(), |
|
502 | - filemtime($this->domain->distributionAssetsPath() . 'ee-exit-modal-survey.dist.css') |
|
503 | - ); |
|
504 | - } |
|
291 | + 'event_espresso' |
|
292 | + ), |
|
293 | + $key |
|
294 | + ) |
|
295 | + ); |
|
296 | + } |
|
297 | + return true; |
|
298 | + } |
|
299 | + |
|
300 | + |
|
301 | + |
|
302 | + /** |
|
303 | + * registers core default stylesheets |
|
304 | + */ |
|
305 | + private function loadCoreCss() |
|
306 | + { |
|
307 | + if ($this->template_config->enable_default_style) { |
|
308 | + $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
309 | + ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
310 | + : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css'; |
|
311 | + wp_register_style( |
|
312 | + 'espresso_default', |
|
313 | + $default_stylesheet_path, |
|
314 | + array('dashicons'), |
|
315 | + EVENT_ESPRESSO_VERSION |
|
316 | + ); |
|
317 | + //Load custom style sheet if available |
|
318 | + if ($this->template_config->custom_style_sheet !== null) { |
|
319 | + wp_register_style( |
|
320 | + 'espresso_custom_css', |
|
321 | + EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
322 | + array('espresso_default'), |
|
323 | + EVENT_ESPRESSO_VERSION |
|
324 | + ); |
|
325 | + } |
|
326 | + } |
|
327 | + } |
|
328 | + |
|
329 | + |
|
330 | + |
|
331 | + /** |
|
332 | + * registers core default javascript |
|
333 | + */ |
|
334 | + private function loadCoreJs() |
|
335 | + { |
|
336 | + // load core js |
|
337 | + wp_register_script( |
|
338 | + 'espresso_core', |
|
339 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
340 | + array('jquery'), |
|
341 | + EVENT_ESPRESSO_VERSION, |
|
342 | + true |
|
343 | + ); |
|
344 | + } |
|
345 | + |
|
346 | + |
|
347 | + |
|
348 | + /** |
|
349 | + * registers jQuery Validate for form validation |
|
350 | + */ |
|
351 | + private function loadJqueryValidate() |
|
352 | + { |
|
353 | + // register jQuery Validate and additional methods |
|
354 | + wp_register_script( |
|
355 | + 'jquery-validate', |
|
356 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
357 | + array('jquery'), |
|
358 | + '1.15.0', |
|
359 | + true |
|
360 | + ); |
|
361 | + wp_register_script( |
|
362 | + 'jquery-validate-extra-methods', |
|
363 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
364 | + array('jquery', 'jquery-validate'), |
|
365 | + '1.15.0', |
|
366 | + true |
|
367 | + ); |
|
368 | + } |
|
369 | + |
|
370 | + |
|
371 | + |
|
372 | + /** |
|
373 | + * registers accounting.js for performing client-side calculations |
|
374 | + */ |
|
375 | + private function loadAccountingJs() |
|
376 | + { |
|
377 | + //accounting.js library |
|
378 | + // @link http://josscrowcroft.github.io/accounting.js/ |
|
379 | + wp_register_script( |
|
380 | + 'ee-accounting-core', |
|
381 | + EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
382 | + array('underscore'), |
|
383 | + '0.3.2', |
|
384 | + true |
|
385 | + ); |
|
386 | + wp_register_script( |
|
387 | + 'ee-accounting', |
|
388 | + EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
389 | + array('ee-accounting-core'), |
|
390 | + EVENT_ESPRESSO_VERSION, |
|
391 | + true |
|
392 | + ); |
|
393 | + } |
|
394 | + |
|
395 | + |
|
396 | + |
|
397 | + /** |
|
398 | + * registers accounting.js for performing client-side calculations |
|
399 | + */ |
|
400 | + private function localizeAccountingJs() |
|
401 | + { |
|
402 | + wp_localize_script( |
|
403 | + 'ee-accounting', |
|
404 | + 'EE_ACCOUNTING_CFG', |
|
405 | + array( |
|
406 | + 'currency' => array( |
|
407 | + 'symbol' => $this->currency_config->sign, |
|
408 | + 'format' => array( |
|
409 | + 'pos' => $this->currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
410 | + 'neg' => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
411 | + 'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s', |
|
412 | + ), |
|
413 | + 'decimal' => $this->currency_config->dec_mrk, |
|
414 | + 'thousand' => $this->currency_config->thsnds, |
|
415 | + 'precision' => $this->currency_config->dec_plc, |
|
416 | + ), |
|
417 | + 'number' => array( |
|
418 | + 'precision' => $this->currency_config->dec_plc, |
|
419 | + 'thousand' => $this->currency_config->thsnds, |
|
420 | + 'decimal' => $this->currency_config->dec_mrk, |
|
421 | + ), |
|
422 | + ) |
|
423 | + ); |
|
424 | + $this->addRegisteredScriptHandlesWithData('ee-accounting'); |
|
425 | + } |
|
426 | + |
|
427 | + |
|
428 | + |
|
429 | + /** |
|
430 | + * registers assets for cleaning your ears |
|
431 | + */ |
|
432 | + private function loadQtipJs() |
|
433 | + { |
|
434 | + // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
435 | + // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
436 | + if (apply_filters('FHEE_load_qtip', false)) { |
|
437 | + EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
438 | + } |
|
439 | + } |
|
440 | + |
|
441 | + |
|
442 | + /** |
|
443 | + * This is used to set registered script handles that have data. |
|
444 | + * @param string $script_handle |
|
445 | + */ |
|
446 | + private function addRegisteredScriptHandlesWithData($script_handle) |
|
447 | + { |
|
448 | + $this->script_handles_with_data[$script_handle] = $script_handle; |
|
449 | + } |
|
450 | + |
|
451 | + |
|
452 | + /** |
|
453 | + * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the |
|
454 | + * Dependency stored in WP_Scripts if its set. |
|
455 | + */ |
|
456 | + private function removeAlreadyRegisteredDataForScriptHandles() |
|
457 | + { |
|
458 | + if (empty($this->script_handles_with_data)) { |
|
459 | + return; |
|
460 | + } |
|
461 | + foreach ($this->script_handles_with_data as $script_handle) { |
|
462 | + $this->removeAlreadyRegisteredDataForScriptHandle($script_handle); |
|
463 | + } |
|
464 | + } |
|
465 | + |
|
466 | + |
|
467 | + /** |
|
468 | + * Removes any data dependency registered in WP_Scripts if its set. |
|
469 | + * @param string $script_handle |
|
470 | + */ |
|
471 | + private function removeAlreadyRegisteredDataForScriptHandle($script_handle) |
|
472 | + { |
|
473 | + if (isset($this->script_handles_with_data[$script_handle])) { |
|
474 | + global $wp_scripts; |
|
475 | + if ($wp_scripts->get_data($script_handle, 'data')) { |
|
476 | + unset($wp_scripts->registered[$script_handle]->extra['data']); |
|
477 | + unset($this->script_handles_with_data[$script_handle]); |
|
478 | + } |
|
479 | + } |
|
480 | + } |
|
481 | + |
|
482 | + |
|
483 | + /** |
|
484 | + * Registers assets that are used in the WordPress admin. |
|
485 | + */ |
|
486 | + private function registerAdminAssets() |
|
487 | + { |
|
488 | + wp_register_script( |
|
489 | + 'ee-exit-modal-survey', |
|
490 | + $this->domain->distributionAssetsUrl() . 'ee-exit-modal-survey.dist.js', |
|
491 | + array( |
|
492 | + 'jquery', |
|
493 | + 'eejs-core' |
|
494 | + ), |
|
495 | + filemtime($this->domain->distributionAssetsPath() . 'ee-exit-modal-survey.dist.js'), |
|
496 | + true |
|
497 | + ); |
|
498 | + wp_register_style( |
|
499 | + 'ee-exit-modal-survey', |
|
500 | + $this->domain->distributionAssetsUrl() . 'ee-exit-modal-survey.dist.css', |
|
501 | + array(), |
|
502 | + filemtime($this->domain->distributionAssetsPath() . 'ee-exit-modal-survey.dist.css') |
|
503 | + ); |
|
504 | + } |
|
505 | 505 | |
506 | 506 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | global $wp_version; |
93 | 93 | wp_register_script( |
94 | 94 | 'eejs-core', |
95 | - EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js', |
|
95 | + EE_PLUGIN_DIR_URL.'core/services/assets/core_assets/eejs-core.js', |
|
96 | 96 | array(), |
97 | 97 | EVENT_ESPRESSO_VERSION, |
98 | 98 | true |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | //js.api |
103 | 103 | wp_register_script( |
104 | 104 | 'eejs-api', |
105 | - EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
105 | + EE_LIBRARIES_URL.'rest_api/assets/js/eejs-api.min.js', |
|
106 | 106 | array('underscore', 'eejs-core'), |
107 | 107 | EVENT_ESPRESSO_VERSION, |
108 | 108 | true |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest'); |
111 | 111 | $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/')); |
112 | 112 | } |
113 | - if (! is_admin()) { |
|
113 | + if ( ! is_admin()) { |
|
114 | 114 | $this->loadCoreCss(); |
115 | 115 | } |
116 | 116 | $this->loadCoreJs(); |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | */ |
209 | 209 | public function addTemplate($template_reference, $template_content) |
210 | 210 | { |
211 | - if (! isset($this->jsdata['templates'])) { |
|
211 | + if ( ! isset($this->jsdata['templates'])) { |
|
212 | 212 | $this->jsdata['templates'] = array(); |
213 | 213 | } |
214 | 214 | //no overrides allowed. |
@@ -305,9 +305,9 @@ discard block |
||
305 | 305 | private function loadCoreCss() |
306 | 306 | { |
307 | 307 | if ($this->template_config->enable_default_style) { |
308 | - $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
308 | + $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css') |
|
309 | 309 | ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
310 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css'; |
|
310 | + : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css'; |
|
311 | 311 | wp_register_style( |
312 | 312 | 'espresso_default', |
313 | 313 | $default_stylesheet_path, |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | if ($this->template_config->custom_style_sheet !== null) { |
319 | 319 | wp_register_style( |
320 | 320 | 'espresso_custom_css', |
321 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
321 | + EVENT_ESPRESSO_UPLOAD_URL.'css/'.$this->template_config->custom_style_sheet, |
|
322 | 322 | array('espresso_default'), |
323 | 323 | EVENT_ESPRESSO_VERSION |
324 | 324 | ); |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | // load core js |
337 | 337 | wp_register_script( |
338 | 338 | 'espresso_core', |
339 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
339 | + EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', |
|
340 | 340 | array('jquery'), |
341 | 341 | EVENT_ESPRESSO_VERSION, |
342 | 342 | true |
@@ -353,14 +353,14 @@ discard block |
||
353 | 353 | // register jQuery Validate and additional methods |
354 | 354 | wp_register_script( |
355 | 355 | 'jquery-validate', |
356 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
356 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', |
|
357 | 357 | array('jquery'), |
358 | 358 | '1.15.0', |
359 | 359 | true |
360 | 360 | ); |
361 | 361 | wp_register_script( |
362 | 362 | 'jquery-validate-extra-methods', |
363 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
363 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js', |
|
364 | 364 | array('jquery', 'jquery-validate'), |
365 | 365 | '1.15.0', |
366 | 366 | true |
@@ -378,14 +378,14 @@ discard block |
||
378 | 378 | // @link http://josscrowcroft.github.io/accounting.js/ |
379 | 379 | wp_register_script( |
380 | 380 | 'ee-accounting-core', |
381 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
381 | + EE_THIRD_PARTY_URL.'accounting/accounting.js', |
|
382 | 382 | array('underscore'), |
383 | 383 | '0.3.2', |
384 | 384 | true |
385 | 385 | ); |
386 | 386 | wp_register_script( |
387 | 387 | 'ee-accounting', |
388 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
388 | + EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', |
|
389 | 389 | array('ee-accounting-core'), |
390 | 390 | EVENT_ESPRESSO_VERSION, |
391 | 391 | true |
@@ -487,19 +487,19 @@ discard block |
||
487 | 487 | { |
488 | 488 | wp_register_script( |
489 | 489 | 'ee-exit-modal-survey', |
490 | - $this->domain->distributionAssetsUrl() . 'ee-exit-modal-survey.dist.js', |
|
490 | + $this->domain->distributionAssetsUrl().'ee-exit-modal-survey.dist.js', |
|
491 | 491 | array( |
492 | 492 | 'jquery', |
493 | 493 | 'eejs-core' |
494 | 494 | ), |
495 | - filemtime($this->domain->distributionAssetsPath() . 'ee-exit-modal-survey.dist.js'), |
|
495 | + filemtime($this->domain->distributionAssetsPath().'ee-exit-modal-survey.dist.js'), |
|
496 | 496 | true |
497 | 497 | ); |
498 | 498 | wp_register_style( |
499 | 499 | 'ee-exit-modal-survey', |
500 | - $this->domain->distributionAssetsUrl() . 'ee-exit-modal-survey.dist.css', |
|
500 | + $this->domain->distributionAssetsUrl().'ee-exit-modal-survey.dist.css', |
|
501 | 501 | array(), |
502 | - filemtime($this->domain->distributionAssetsPath() . 'ee-exit-modal-survey.dist.css') |
|
502 | + filemtime($this->domain->distributionAssetsPath().'ee-exit-modal-survey.dist.css') |
|
503 | 503 | ); |
504 | 504 | } |
505 | 505 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | use EventEspresso\core\services\request\ResponseInterface; |
9 | 9 | |
10 | 10 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
11 | - exit('No direct script access allowed'); |
|
11 | + exit('No direct script access allowed'); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | |
@@ -25,839 +25,839 @@ discard block |
||
25 | 25 | class EE_Dependency_Map |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * This means that the requested class dependency is not present in the dependency map |
|
30 | - */ |
|
31 | - const not_registered = 0; |
|
32 | - |
|
33 | - /** |
|
34 | - * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
35 | - */ |
|
36 | - const load_new_object = 1; |
|
37 | - |
|
38 | - /** |
|
39 | - * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
40 | - * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
41 | - */ |
|
42 | - const load_from_cache = 2; |
|
43 | - |
|
44 | - /** |
|
45 | - * When registering a dependency, |
|
46 | - * this indicates to keep any existing dependencies that already exist, |
|
47 | - * and simply discard any new dependencies declared in the incoming data |
|
48 | - */ |
|
49 | - const KEEP_EXISTING_DEPENDENCIES = 0; |
|
50 | - |
|
51 | - /** |
|
52 | - * When registering a dependency, |
|
53 | - * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
54 | - */ |
|
55 | - const OVERWRITE_DEPENDENCIES = 1; |
|
56 | - |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * @type EE_Dependency_Map $_instance |
|
61 | - */ |
|
62 | - protected static $_instance; |
|
63 | - |
|
64 | - /** |
|
65 | - * @type RequestInterface $request |
|
66 | - */ |
|
67 | - protected $request; |
|
68 | - |
|
69 | - /** |
|
70 | - * @type LegacyRequestInterface $legacy_request |
|
71 | - */ |
|
72 | - protected $legacy_request; |
|
73 | - |
|
74 | - /** |
|
75 | - * @type ResponseInterface $response |
|
76 | - */ |
|
77 | - protected $response; |
|
78 | - |
|
79 | - /** |
|
80 | - * @type LoaderInterface $loader |
|
81 | - */ |
|
82 | - protected $loader; |
|
83 | - |
|
84 | - /** |
|
85 | - * @type array $_dependency_map |
|
86 | - */ |
|
87 | - protected $_dependency_map = array(); |
|
88 | - |
|
89 | - /** |
|
90 | - * @type array $_class_loaders |
|
91 | - */ |
|
92 | - protected $_class_loaders = array(); |
|
93 | - |
|
94 | - /** |
|
95 | - * @type array $_aliases |
|
96 | - */ |
|
97 | - protected $_aliases = array(); |
|
98 | - |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * EE_Dependency_Map constructor. |
|
103 | - */ |
|
104 | - protected function __construct() |
|
105 | - { |
|
106 | - // add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize')); |
|
107 | - do_action('EE_Dependency_Map____construct'); |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * @throws InvalidDataTypeException |
|
114 | - * @throws InvalidInterfaceException |
|
115 | - * @throws InvalidArgumentException |
|
116 | - */ |
|
117 | - public function initialize() |
|
118 | - { |
|
119 | - $this->_register_core_dependencies(); |
|
120 | - $this->_register_core_class_loaders(); |
|
121 | - $this->_register_core_aliases(); |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * @singleton method used to instantiate class object |
|
128 | - * @return EE_Dependency_Map |
|
129 | - */ |
|
130 | - public static function instance() { |
|
131 | - // check if class object is instantiated, and instantiated properly |
|
132 | - if (! self::$_instance instanceof EE_Dependency_Map) { |
|
133 | - self::$_instance = new EE_Dependency_Map(/*$request, $response, $legacy_request*/); |
|
134 | - } |
|
135 | - return self::$_instance; |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * @param RequestInterface $request |
|
141 | - */ |
|
142 | - public function setRequest(RequestInterface $request) |
|
143 | - { |
|
144 | - $this->request = $request; |
|
145 | - } |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * @param LegacyRequestInterface $legacy_request |
|
150 | - */ |
|
151 | - public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
152 | - { |
|
153 | - $this->legacy_request = $legacy_request; |
|
154 | - } |
|
155 | - |
|
156 | - |
|
157 | - /** |
|
158 | - * @param ResponseInterface $response |
|
159 | - */ |
|
160 | - public function setResponse(ResponseInterface $response) |
|
161 | - { |
|
162 | - $this->response = $response; |
|
163 | - } |
|
164 | - |
|
165 | - |
|
166 | - |
|
167 | - /** |
|
168 | - * @param LoaderInterface $loader |
|
169 | - */ |
|
170 | - public function setLoader(LoaderInterface $loader) |
|
171 | - { |
|
172 | - $this->loader = $loader; |
|
173 | - } |
|
174 | - |
|
175 | - |
|
176 | - |
|
177 | - /** |
|
178 | - * @param string $class |
|
179 | - * @param array $dependencies |
|
180 | - * @param int $overwrite |
|
181 | - * @return bool |
|
182 | - */ |
|
183 | - public static function register_dependencies( |
|
184 | - $class, |
|
185 | - array $dependencies, |
|
186 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
187 | - ) { |
|
188 | - return self::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
189 | - } |
|
190 | - |
|
191 | - |
|
192 | - |
|
193 | - /** |
|
194 | - * Assigns an array of class names and corresponding load sources (new or cached) |
|
195 | - * to the class specified by the first parameter. |
|
196 | - * IMPORTANT !!! |
|
197 | - * The order of elements in the incoming $dependencies array MUST match |
|
198 | - * the order of the constructor parameters for the class in question. |
|
199 | - * This is especially important when overriding any existing dependencies that are registered. |
|
200 | - * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
201 | - * |
|
202 | - * @param string $class |
|
203 | - * @param array $dependencies |
|
204 | - * @param int $overwrite |
|
205 | - * @return bool |
|
206 | - */ |
|
207 | - public function registerDependencies( |
|
208 | - $class, |
|
209 | - array $dependencies, |
|
210 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
211 | - ) { |
|
212 | - $class = trim($class, '\\'); |
|
213 | - $registered = false; |
|
214 | - if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
215 | - self::$_instance->_dependency_map[ $class ] = array(); |
|
216 | - } |
|
217 | - // we need to make sure that any aliases used when registering a dependency |
|
218 | - // get resolved to the correct class name |
|
219 | - foreach ($dependencies as $dependency => $load_source) { |
|
220 | - $alias = self::$_instance->get_alias($dependency); |
|
221 | - if ( |
|
222 | - $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
223 | - || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
224 | - ) { |
|
225 | - unset($dependencies[$dependency]); |
|
226 | - $dependencies[$alias] = $load_source; |
|
227 | - $registered = true; |
|
228 | - } |
|
229 | - } |
|
230 | - // now add our two lists of dependencies together. |
|
231 | - // using Union (+=) favours the arrays in precedence from left to right, |
|
232 | - // so $dependencies is NOT overwritten because it is listed first |
|
233 | - // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
234 | - // Union is way faster than array_merge() but should be used with caution... |
|
235 | - // especially with numerically indexed arrays |
|
236 | - $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
237 | - // now we need to ensure that the resulting dependencies |
|
238 | - // array only has the entries that are required for the class |
|
239 | - // so first count how many dependencies were originally registered for the class |
|
240 | - $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
241 | - // if that count is non-zero (meaning dependencies were already registered) |
|
242 | - self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
243 | - // then truncate the final array to match that count |
|
244 | - ? array_slice($dependencies, 0, $dependency_count) |
|
245 | - // otherwise just take the incoming array because nothing previously existed |
|
246 | - : $dependencies; |
|
247 | - return $registered; |
|
248 | - } |
|
249 | - |
|
250 | - |
|
251 | - |
|
252 | - /** |
|
253 | - * @param string $class_name |
|
254 | - * @param string $loader |
|
255 | - * @return bool |
|
256 | - * @throws DomainException |
|
257 | - */ |
|
258 | - public static function register_class_loader($class_name, $loader = 'load_core') |
|
259 | - { |
|
260 | - if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
261 | - throw new DomainException( |
|
262 | - esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
263 | - ); |
|
264 | - } |
|
265 | - // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
266 | - if ( |
|
267 | - ! is_callable($loader) |
|
268 | - && ( |
|
269 | - strpos($loader, 'load_') !== 0 |
|
270 | - || ! method_exists('EE_Registry', $loader) |
|
271 | - ) |
|
272 | - ) { |
|
273 | - throw new DomainException( |
|
274 | - sprintf( |
|
275 | - esc_html__( |
|
276 | - '"%1$s" is not a valid loader method on EE_Registry.', |
|
277 | - 'event_espresso' |
|
278 | - ), |
|
279 | - $loader |
|
280 | - ) |
|
281 | - ); |
|
282 | - } |
|
283 | - $class_name = self::$_instance->get_alias($class_name); |
|
284 | - if (! isset(self::$_instance->_class_loaders[$class_name])) { |
|
285 | - self::$_instance->_class_loaders[$class_name] = $loader; |
|
286 | - return true; |
|
287 | - } |
|
288 | - return false; |
|
289 | - } |
|
290 | - |
|
291 | - |
|
292 | - |
|
293 | - /** |
|
294 | - * @return array |
|
295 | - */ |
|
296 | - public function dependency_map() |
|
297 | - { |
|
298 | - return $this->_dependency_map; |
|
299 | - } |
|
300 | - |
|
301 | - |
|
302 | - |
|
303 | - /** |
|
304 | - * returns TRUE if dependency map contains a listing for the provided class name |
|
305 | - * |
|
306 | - * @param string $class_name |
|
307 | - * @return boolean |
|
308 | - */ |
|
309 | - public function has($class_name = '') |
|
310 | - { |
|
311 | - // all legacy models have the same dependencies |
|
312 | - if (strpos($class_name, 'EEM_') === 0) { |
|
313 | - $class_name = 'LEGACY_MODELS'; |
|
314 | - } |
|
315 | - return isset($this->_dependency_map[$class_name]) ? true : false; |
|
316 | - } |
|
317 | - |
|
318 | - |
|
319 | - |
|
320 | - /** |
|
321 | - * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
322 | - * |
|
323 | - * @param string $class_name |
|
324 | - * @param string $dependency |
|
325 | - * @return bool |
|
326 | - */ |
|
327 | - public function has_dependency_for_class($class_name = '', $dependency = '') |
|
328 | - { |
|
329 | - // all legacy models have the same dependencies |
|
330 | - if (strpos($class_name, 'EEM_') === 0) { |
|
331 | - $class_name = 'LEGACY_MODELS'; |
|
332 | - } |
|
333 | - $dependency = $this->get_alias($dependency); |
|
334 | - return isset($this->_dependency_map[$class_name][$dependency]) |
|
335 | - ? true |
|
336 | - : false; |
|
337 | - } |
|
338 | - |
|
339 | - |
|
340 | - |
|
341 | - /** |
|
342 | - * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
343 | - * |
|
344 | - * @param string $class_name |
|
345 | - * @param string $dependency |
|
346 | - * @return int |
|
347 | - */ |
|
348 | - public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
349 | - { |
|
350 | - // all legacy models have the same dependencies |
|
351 | - if (strpos($class_name, 'EEM_') === 0) { |
|
352 | - $class_name = 'LEGACY_MODELS'; |
|
353 | - } |
|
354 | - $dependency = $this->get_alias($dependency); |
|
355 | - return $this->has_dependency_for_class($class_name, $dependency) |
|
356 | - ? $this->_dependency_map[$class_name][$dependency] |
|
357 | - : EE_Dependency_Map::not_registered; |
|
358 | - } |
|
359 | - |
|
360 | - |
|
361 | - |
|
362 | - /** |
|
363 | - * @param string $class_name |
|
364 | - * @return string | Closure |
|
365 | - */ |
|
366 | - public function class_loader($class_name) |
|
367 | - { |
|
368 | - // all legacy models use load_model() |
|
369 | - if(strpos($class_name, 'EEM_') === 0){ |
|
370 | - return 'load_model'; |
|
371 | - } |
|
372 | - $class_name = $this->get_alias($class_name); |
|
373 | - return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : ''; |
|
374 | - } |
|
375 | - |
|
376 | - |
|
377 | - |
|
378 | - /** |
|
379 | - * @return array |
|
380 | - */ |
|
381 | - public function class_loaders() |
|
382 | - { |
|
383 | - return $this->_class_loaders; |
|
384 | - } |
|
385 | - |
|
386 | - |
|
387 | - |
|
388 | - /** |
|
389 | - * adds an alias for a classname |
|
390 | - * |
|
391 | - * @param string $class_name the class name that should be used (concrete class to replace interface) |
|
392 | - * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
393 | - * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
394 | - */ |
|
395 | - public function add_alias($class_name, $alias, $for_class = '') |
|
396 | - { |
|
397 | - if ($for_class !== '') { |
|
398 | - if (! isset($this->_aliases[$for_class])) { |
|
399 | - $this->_aliases[$for_class] = array(); |
|
400 | - } |
|
401 | - $this->_aliases[$for_class][$class_name] = $alias; |
|
402 | - } |
|
403 | - $this->_aliases[$class_name] = $alias; |
|
404 | - } |
|
405 | - |
|
406 | - |
|
407 | - |
|
408 | - /** |
|
409 | - * returns TRUE if the provided class name has an alias |
|
410 | - * |
|
411 | - * @param string $class_name |
|
412 | - * @param string $for_class |
|
413 | - * @return bool |
|
414 | - */ |
|
415 | - public function has_alias($class_name = '', $for_class = '') |
|
416 | - { |
|
417 | - return isset($this->_aliases[$for_class][$class_name]) |
|
418 | - || ( |
|
419 | - isset($this->_aliases[$class_name]) |
|
420 | - && ! is_array($this->_aliases[$class_name]) |
|
421 | - ); |
|
422 | - } |
|
423 | - |
|
424 | - |
|
425 | - |
|
426 | - /** |
|
427 | - * returns alias for class name if one exists, otherwise returns the original classname |
|
428 | - * functions recursively, so that multiple aliases can be used to drill down to a classname |
|
429 | - * for example: |
|
430 | - * if the following two entries were added to the _aliases array: |
|
431 | - * array( |
|
432 | - * 'interface_alias' => 'some\namespace\interface' |
|
433 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
434 | - * ) |
|
435 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
436 | - * to load an instance of 'some\namespace\classname' |
|
437 | - * |
|
438 | - * @param string $class_name |
|
439 | - * @param string $for_class |
|
440 | - * @return string |
|
441 | - */ |
|
442 | - public function get_alias($class_name = '', $for_class = '') |
|
443 | - { |
|
444 | - if (! $this->has_alias($class_name, $for_class)) { |
|
445 | - return $class_name; |
|
446 | - } |
|
447 | - if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) { |
|
448 | - return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class); |
|
449 | - } |
|
450 | - return $this->get_alias($this->_aliases[$class_name]); |
|
451 | - } |
|
452 | - |
|
453 | - |
|
454 | - |
|
455 | - /** |
|
456 | - * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
457 | - * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
458 | - * This is done by using the following class constants: |
|
459 | - * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
460 | - * EE_Dependency_Map::load_new_object - generates a new object every time |
|
461 | - */ |
|
462 | - protected function _register_core_dependencies() |
|
463 | - { |
|
464 | - $this->_dependency_map = array( |
|
465 | - 'EE_Request_Handler' => array( |
|
466 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
467 | - ), |
|
468 | - 'EE_System' => array( |
|
469 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
470 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
471 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
472 | - 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
473 | - ), |
|
474 | - 'EE_Session' => array( |
|
475 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
476 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
477 | - 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
478 | - ), |
|
479 | - 'EE_Cart' => array( |
|
480 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
481 | - ), |
|
482 | - 'EE_Front_Controller' => array( |
|
483 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
484 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
485 | - 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
486 | - ), |
|
487 | - 'EE_Messenger_Collection_Loader' => array( |
|
488 | - 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
489 | - ), |
|
490 | - 'EE_Message_Type_Collection_Loader' => array( |
|
491 | - 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
492 | - ), |
|
493 | - 'EE_Message_Resource_Manager' => array( |
|
494 | - 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
495 | - 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
496 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
497 | - ), |
|
498 | - 'EE_Message_Factory' => array( |
|
499 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
500 | - ), |
|
501 | - 'EE_messages' => array( |
|
502 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
503 | - ), |
|
504 | - 'EE_Messages_Generator' => array( |
|
505 | - 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
506 | - 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
507 | - 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
508 | - 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
509 | - ), |
|
510 | - 'EE_Messages_Processor' => array( |
|
511 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
512 | - ), |
|
513 | - 'EE_Messages_Queue' => array( |
|
514 | - 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
515 | - ), |
|
516 | - 'EE_Messages_Template_Defaults' => array( |
|
517 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
518 | - 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
519 | - ), |
|
520 | - 'EE_Message_To_Generate_From_Request' => array( |
|
521 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
522 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
523 | - ), |
|
524 | - 'EventEspresso\core\services\commands\CommandBus' => array( |
|
525 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
526 | - ), |
|
527 | - 'EventEspresso\services\commands\CommandHandler' => array( |
|
528 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
529 | - 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
530 | - ), |
|
531 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => array( |
|
532 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
533 | - ), |
|
534 | - 'EventEspresso\core\services\commands\CompositeCommandHandler' => array( |
|
535 | - 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
536 | - 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
537 | - ), |
|
538 | - 'EventEspresso\core\services\commands\CommandFactory' => array( |
|
539 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
540 | - ), |
|
541 | - 'EventEspresso\core\services\commands\middleware\CapChecker' => array( |
|
542 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
543 | - ), |
|
544 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => array( |
|
545 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
546 | - ), |
|
547 | - 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => array( |
|
548 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
549 | - ), |
|
550 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => array( |
|
551 | - 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
552 | - ), |
|
553 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => array( |
|
554 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
555 | - ), |
|
556 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => array( |
|
557 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
558 | - ), |
|
559 | - 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => array( |
|
560 | - 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
561 | - ), |
|
562 | - 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array( |
|
563 | - 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
564 | - ), |
|
565 | - 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => array( |
|
566 | - 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
567 | - ), |
|
568 | - 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => array( |
|
569 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
570 | - ), |
|
571 | - 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => array( |
|
572 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
573 | - ), |
|
574 | - 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => array( |
|
575 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
576 | - ), |
|
577 | - 'EventEspresso\core\services\database\TableManager' => array( |
|
578 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
579 | - ), |
|
580 | - 'EE_Data_Migration_Class_Base' => array( |
|
581 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
582 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
583 | - ), |
|
584 | - 'EE_DMS_Core_4_1_0' => array( |
|
585 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
586 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
587 | - ), |
|
588 | - 'EE_DMS_Core_4_2_0' => array( |
|
589 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
590 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
591 | - ), |
|
592 | - 'EE_DMS_Core_4_3_0' => array( |
|
593 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
594 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
595 | - ), |
|
596 | - 'EE_DMS_Core_4_4_0' => array( |
|
597 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
598 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
599 | - ), |
|
600 | - 'EE_DMS_Core_4_5_0' => array( |
|
601 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
602 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
603 | - ), |
|
604 | - 'EE_DMS_Core_4_6_0' => array( |
|
605 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
606 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
607 | - ), |
|
608 | - 'EE_DMS_Core_4_7_0' => array( |
|
609 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
610 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
611 | - ), |
|
612 | - 'EE_DMS_Core_4_8_0' => array( |
|
613 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
614 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
615 | - ), |
|
616 | - 'EE_DMS_Core_4_9_0' => array( |
|
617 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
618 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
619 | - ), |
|
620 | - 'EventEspresso\core\services\assets\Registry' => array( |
|
621 | - 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
622 | - 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
623 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache |
|
624 | - ), |
|
625 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => array( |
|
626 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
627 | - ), |
|
628 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => array( |
|
629 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
630 | - ), |
|
631 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => array( |
|
632 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
633 | - ), |
|
634 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => array( |
|
635 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
636 | - ), |
|
637 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => array( |
|
638 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
639 | - ), |
|
640 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => array( |
|
641 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
642 | - ), |
|
643 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => array( |
|
644 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
645 | - ), |
|
646 | - 'EventEspresso\core\services\cache\BasicCacheManager' => array( |
|
647 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
648 | - ), |
|
649 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => array( |
|
650 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
651 | - ), |
|
652 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array( |
|
653 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
654 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
655 | - ), |
|
656 | - 'EventEspresso\core\domain\values\EmailAddress' => array( |
|
657 | - null, |
|
658 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
659 | - ), |
|
660 | - 'EventEspresso\core\services\orm\ModelFieldFactory' => array( |
|
661 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
662 | - ), |
|
663 | - 'LEGACY_MODELS' => array( |
|
664 | - null, |
|
665 | - 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
666 | - ), |
|
667 | - 'EE_Module_Request_Router' => array( |
|
668 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
669 | - ), |
|
670 | - 'EE_Registration_Processor' => array( |
|
671 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
672 | - ), |
|
673 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array( |
|
674 | - null, |
|
675 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
676 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
677 | - ), |
|
678 | - 'EventEspresso\core\domain\services\admin\ExitModal' => array( |
|
679 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache |
|
680 | - ) |
|
681 | - ); |
|
682 | - } |
|
683 | - |
|
684 | - |
|
685 | - |
|
686 | - /** |
|
687 | - * Registers how core classes are loaded. |
|
688 | - * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
689 | - * 'EE_Request_Handler' => 'load_core' |
|
690 | - * 'EE_Messages_Queue' => 'load_lib' |
|
691 | - * 'EEH_Debug_Tools' => 'load_helper' |
|
692 | - * or, if greater control is required, by providing a custom closure. For example: |
|
693 | - * 'Some_Class' => function () { |
|
694 | - * return new Some_Class(); |
|
695 | - * }, |
|
696 | - * This is required for instantiating dependencies |
|
697 | - * where an interface has been type hinted in a class constructor. For example: |
|
698 | - * 'Required_Interface' => function () { |
|
699 | - * return new A_Class_That_Implements_Required_Interface(); |
|
700 | - * }, |
|
701 | - * |
|
702 | - * @throws InvalidInterfaceException |
|
703 | - * @throws InvalidDataTypeException |
|
704 | - * @throws InvalidArgumentException |
|
705 | - */ |
|
706 | - protected function _register_core_class_loaders() |
|
707 | - { |
|
708 | - //for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot |
|
709 | - //be used in a closure. |
|
710 | - $request = &$this->request; |
|
711 | - $response = &$this->response; |
|
712 | - $legacy_request = &$this->legacy_request; |
|
713 | - // $loader = &$this->loader; |
|
714 | - $this->_class_loaders = array( |
|
715 | - //load_core |
|
716 | - 'EE_Capabilities' => 'load_core', |
|
717 | - 'EE_Encryption' => 'load_core', |
|
718 | - 'EE_Front_Controller' => 'load_core', |
|
719 | - 'EE_Module_Request_Router' => 'load_core', |
|
720 | - 'EE_Registry' => 'load_core', |
|
721 | - 'EE_Request' => function () use (&$legacy_request) { |
|
722 | - return $legacy_request; |
|
723 | - }, |
|
724 | - 'EventEspresso\core\services\request\Request' => function () use (&$request) { |
|
725 | - return $request; |
|
726 | - }, |
|
727 | - 'EventEspresso\core\services\request\Response' => function () use (&$response) { |
|
728 | - return $response; |
|
729 | - }, |
|
730 | - 'EE_Request_Handler' => 'load_core', |
|
731 | - 'EE_Session' => 'load_core', |
|
732 | - 'EE_Cron_Tasks' => 'load_core', |
|
733 | - 'EE_System' => 'load_core', |
|
734 | - 'EE_Maintenance_Mode' => 'load_core', |
|
735 | - 'EE_Register_CPTs' => 'load_core', |
|
736 | - 'EE_Admin' => 'load_core', |
|
737 | - //load_lib |
|
738 | - 'EE_Message_Resource_Manager' => 'load_lib', |
|
739 | - 'EE_Message_Type_Collection' => 'load_lib', |
|
740 | - 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
741 | - 'EE_Messenger_Collection' => 'load_lib', |
|
742 | - 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
743 | - 'EE_Messages_Processor' => 'load_lib', |
|
744 | - 'EE_Message_Repository' => 'load_lib', |
|
745 | - 'EE_Messages_Queue' => 'load_lib', |
|
746 | - 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
747 | - 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
748 | - 'EE_Payment_Method_Manager' => 'load_lib', |
|
749 | - 'EE_Messages_Generator' => function () { |
|
750 | - return EE_Registry::instance()->load_lib( |
|
751 | - 'Messages_Generator', |
|
752 | - array(), |
|
753 | - false, |
|
754 | - false |
|
755 | - ); |
|
756 | - }, |
|
757 | - 'EE_Messages_Template_Defaults' => function ($arguments = array()) { |
|
758 | - return EE_Registry::instance()->load_lib( |
|
759 | - 'Messages_Template_Defaults', |
|
760 | - $arguments, |
|
761 | - false, |
|
762 | - false |
|
763 | - ); |
|
764 | - }, |
|
765 | - //load_model |
|
766 | - // 'EEM_Attendee' => 'load_model', |
|
767 | - // 'EEM_Message_Template_Group' => 'load_model', |
|
768 | - // 'EEM_Message_Template' => 'load_model', |
|
769 | - //load_helper |
|
770 | - 'EEH_Parse_Shortcodes' => function () { |
|
771 | - if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
772 | - return new EEH_Parse_Shortcodes(); |
|
773 | - } |
|
774 | - return null; |
|
775 | - }, |
|
776 | - 'EE_Template_Config' => function () { |
|
777 | - return EE_Config::instance()->template_settings; |
|
778 | - }, |
|
779 | - 'EE_Currency_Config' => function () { |
|
780 | - return EE_Config::instance()->currency; |
|
781 | - }, |
|
782 | - 'EE_Registration_Config' => function () { |
|
783 | - return EE_Config::instance()->registration; |
|
784 | - }, |
|
785 | - 'EventEspresso\core\services\loaders\Loader' => function () { |
|
786 | - return LoaderFactory::getLoader(); |
|
787 | - }, |
|
788 | - ); |
|
789 | - } |
|
790 | - |
|
791 | - |
|
792 | - |
|
793 | - /** |
|
794 | - * can be used for supplying alternate names for classes, |
|
795 | - * or for connecting interface names to instantiable classes |
|
796 | - */ |
|
797 | - protected function _register_core_aliases() |
|
798 | - { |
|
799 | - $this->_aliases = array( |
|
800 | - 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
801 | - 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
802 | - 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
803 | - 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
804 | - 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
805 | - 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
806 | - 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
807 | - 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
808 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
809 | - 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
810 | - 'CreateRegCodeCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand', |
|
811 | - 'CreateRegUrlLinkCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand', |
|
812 | - 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
813 | - 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
814 | - 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
815 | - 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
816 | - 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
817 | - 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
818 | - 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
819 | - 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
820 | - 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
821 | - 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
822 | - 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
823 | - 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
824 | - 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
825 | - 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
826 | - 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
827 | - 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
828 | - 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
829 | - 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
830 | - 'EventEspresso\core\domain\services\session\SessionIdentifierInterface' => 'EE_Session', |
|
831 | - 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
832 | - 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
833 | - 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
834 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
835 | - 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
836 | - 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
837 | - 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
838 | - 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
839 | - 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
840 | - ); |
|
841 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
842 | - $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices'; |
|
843 | - } |
|
844 | - } |
|
845 | - |
|
846 | - |
|
847 | - |
|
848 | - /** |
|
849 | - * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
850 | - * request Primarily used by unit tests. |
|
851 | - * |
|
852 | - * @throws InvalidDataTypeException |
|
853 | - * @throws InvalidInterfaceException |
|
854 | - * @throws InvalidArgumentException |
|
855 | - */ |
|
856 | - public function reset() |
|
857 | - { |
|
858 | - $this->_register_core_class_loaders(); |
|
859 | - $this->_register_core_dependencies(); |
|
860 | - } |
|
28 | + /** |
|
29 | + * This means that the requested class dependency is not present in the dependency map |
|
30 | + */ |
|
31 | + const not_registered = 0; |
|
32 | + |
|
33 | + /** |
|
34 | + * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
35 | + */ |
|
36 | + const load_new_object = 1; |
|
37 | + |
|
38 | + /** |
|
39 | + * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
40 | + * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
41 | + */ |
|
42 | + const load_from_cache = 2; |
|
43 | + |
|
44 | + /** |
|
45 | + * When registering a dependency, |
|
46 | + * this indicates to keep any existing dependencies that already exist, |
|
47 | + * and simply discard any new dependencies declared in the incoming data |
|
48 | + */ |
|
49 | + const KEEP_EXISTING_DEPENDENCIES = 0; |
|
50 | + |
|
51 | + /** |
|
52 | + * When registering a dependency, |
|
53 | + * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
54 | + */ |
|
55 | + const OVERWRITE_DEPENDENCIES = 1; |
|
56 | + |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * @type EE_Dependency_Map $_instance |
|
61 | + */ |
|
62 | + protected static $_instance; |
|
63 | + |
|
64 | + /** |
|
65 | + * @type RequestInterface $request |
|
66 | + */ |
|
67 | + protected $request; |
|
68 | + |
|
69 | + /** |
|
70 | + * @type LegacyRequestInterface $legacy_request |
|
71 | + */ |
|
72 | + protected $legacy_request; |
|
73 | + |
|
74 | + /** |
|
75 | + * @type ResponseInterface $response |
|
76 | + */ |
|
77 | + protected $response; |
|
78 | + |
|
79 | + /** |
|
80 | + * @type LoaderInterface $loader |
|
81 | + */ |
|
82 | + protected $loader; |
|
83 | + |
|
84 | + /** |
|
85 | + * @type array $_dependency_map |
|
86 | + */ |
|
87 | + protected $_dependency_map = array(); |
|
88 | + |
|
89 | + /** |
|
90 | + * @type array $_class_loaders |
|
91 | + */ |
|
92 | + protected $_class_loaders = array(); |
|
93 | + |
|
94 | + /** |
|
95 | + * @type array $_aliases |
|
96 | + */ |
|
97 | + protected $_aliases = array(); |
|
98 | + |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * EE_Dependency_Map constructor. |
|
103 | + */ |
|
104 | + protected function __construct() |
|
105 | + { |
|
106 | + // add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize')); |
|
107 | + do_action('EE_Dependency_Map____construct'); |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * @throws InvalidDataTypeException |
|
114 | + * @throws InvalidInterfaceException |
|
115 | + * @throws InvalidArgumentException |
|
116 | + */ |
|
117 | + public function initialize() |
|
118 | + { |
|
119 | + $this->_register_core_dependencies(); |
|
120 | + $this->_register_core_class_loaders(); |
|
121 | + $this->_register_core_aliases(); |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * @singleton method used to instantiate class object |
|
128 | + * @return EE_Dependency_Map |
|
129 | + */ |
|
130 | + public static function instance() { |
|
131 | + // check if class object is instantiated, and instantiated properly |
|
132 | + if (! self::$_instance instanceof EE_Dependency_Map) { |
|
133 | + self::$_instance = new EE_Dependency_Map(/*$request, $response, $legacy_request*/); |
|
134 | + } |
|
135 | + return self::$_instance; |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * @param RequestInterface $request |
|
141 | + */ |
|
142 | + public function setRequest(RequestInterface $request) |
|
143 | + { |
|
144 | + $this->request = $request; |
|
145 | + } |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * @param LegacyRequestInterface $legacy_request |
|
150 | + */ |
|
151 | + public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
152 | + { |
|
153 | + $this->legacy_request = $legacy_request; |
|
154 | + } |
|
155 | + |
|
156 | + |
|
157 | + /** |
|
158 | + * @param ResponseInterface $response |
|
159 | + */ |
|
160 | + public function setResponse(ResponseInterface $response) |
|
161 | + { |
|
162 | + $this->response = $response; |
|
163 | + } |
|
164 | + |
|
165 | + |
|
166 | + |
|
167 | + /** |
|
168 | + * @param LoaderInterface $loader |
|
169 | + */ |
|
170 | + public function setLoader(LoaderInterface $loader) |
|
171 | + { |
|
172 | + $this->loader = $loader; |
|
173 | + } |
|
174 | + |
|
175 | + |
|
176 | + |
|
177 | + /** |
|
178 | + * @param string $class |
|
179 | + * @param array $dependencies |
|
180 | + * @param int $overwrite |
|
181 | + * @return bool |
|
182 | + */ |
|
183 | + public static function register_dependencies( |
|
184 | + $class, |
|
185 | + array $dependencies, |
|
186 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
187 | + ) { |
|
188 | + return self::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
189 | + } |
|
190 | + |
|
191 | + |
|
192 | + |
|
193 | + /** |
|
194 | + * Assigns an array of class names and corresponding load sources (new or cached) |
|
195 | + * to the class specified by the first parameter. |
|
196 | + * IMPORTANT !!! |
|
197 | + * The order of elements in the incoming $dependencies array MUST match |
|
198 | + * the order of the constructor parameters for the class in question. |
|
199 | + * This is especially important when overriding any existing dependencies that are registered. |
|
200 | + * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
201 | + * |
|
202 | + * @param string $class |
|
203 | + * @param array $dependencies |
|
204 | + * @param int $overwrite |
|
205 | + * @return bool |
|
206 | + */ |
|
207 | + public function registerDependencies( |
|
208 | + $class, |
|
209 | + array $dependencies, |
|
210 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
211 | + ) { |
|
212 | + $class = trim($class, '\\'); |
|
213 | + $registered = false; |
|
214 | + if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
215 | + self::$_instance->_dependency_map[ $class ] = array(); |
|
216 | + } |
|
217 | + // we need to make sure that any aliases used when registering a dependency |
|
218 | + // get resolved to the correct class name |
|
219 | + foreach ($dependencies as $dependency => $load_source) { |
|
220 | + $alias = self::$_instance->get_alias($dependency); |
|
221 | + if ( |
|
222 | + $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
223 | + || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
224 | + ) { |
|
225 | + unset($dependencies[$dependency]); |
|
226 | + $dependencies[$alias] = $load_source; |
|
227 | + $registered = true; |
|
228 | + } |
|
229 | + } |
|
230 | + // now add our two lists of dependencies together. |
|
231 | + // using Union (+=) favours the arrays in precedence from left to right, |
|
232 | + // so $dependencies is NOT overwritten because it is listed first |
|
233 | + // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
234 | + // Union is way faster than array_merge() but should be used with caution... |
|
235 | + // especially with numerically indexed arrays |
|
236 | + $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
237 | + // now we need to ensure that the resulting dependencies |
|
238 | + // array only has the entries that are required for the class |
|
239 | + // so first count how many dependencies were originally registered for the class |
|
240 | + $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
241 | + // if that count is non-zero (meaning dependencies were already registered) |
|
242 | + self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
243 | + // then truncate the final array to match that count |
|
244 | + ? array_slice($dependencies, 0, $dependency_count) |
|
245 | + // otherwise just take the incoming array because nothing previously existed |
|
246 | + : $dependencies; |
|
247 | + return $registered; |
|
248 | + } |
|
249 | + |
|
250 | + |
|
251 | + |
|
252 | + /** |
|
253 | + * @param string $class_name |
|
254 | + * @param string $loader |
|
255 | + * @return bool |
|
256 | + * @throws DomainException |
|
257 | + */ |
|
258 | + public static function register_class_loader($class_name, $loader = 'load_core') |
|
259 | + { |
|
260 | + if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
261 | + throw new DomainException( |
|
262 | + esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
263 | + ); |
|
264 | + } |
|
265 | + // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
266 | + if ( |
|
267 | + ! is_callable($loader) |
|
268 | + && ( |
|
269 | + strpos($loader, 'load_') !== 0 |
|
270 | + || ! method_exists('EE_Registry', $loader) |
|
271 | + ) |
|
272 | + ) { |
|
273 | + throw new DomainException( |
|
274 | + sprintf( |
|
275 | + esc_html__( |
|
276 | + '"%1$s" is not a valid loader method on EE_Registry.', |
|
277 | + 'event_espresso' |
|
278 | + ), |
|
279 | + $loader |
|
280 | + ) |
|
281 | + ); |
|
282 | + } |
|
283 | + $class_name = self::$_instance->get_alias($class_name); |
|
284 | + if (! isset(self::$_instance->_class_loaders[$class_name])) { |
|
285 | + self::$_instance->_class_loaders[$class_name] = $loader; |
|
286 | + return true; |
|
287 | + } |
|
288 | + return false; |
|
289 | + } |
|
290 | + |
|
291 | + |
|
292 | + |
|
293 | + /** |
|
294 | + * @return array |
|
295 | + */ |
|
296 | + public function dependency_map() |
|
297 | + { |
|
298 | + return $this->_dependency_map; |
|
299 | + } |
|
300 | + |
|
301 | + |
|
302 | + |
|
303 | + /** |
|
304 | + * returns TRUE if dependency map contains a listing for the provided class name |
|
305 | + * |
|
306 | + * @param string $class_name |
|
307 | + * @return boolean |
|
308 | + */ |
|
309 | + public function has($class_name = '') |
|
310 | + { |
|
311 | + // all legacy models have the same dependencies |
|
312 | + if (strpos($class_name, 'EEM_') === 0) { |
|
313 | + $class_name = 'LEGACY_MODELS'; |
|
314 | + } |
|
315 | + return isset($this->_dependency_map[$class_name]) ? true : false; |
|
316 | + } |
|
317 | + |
|
318 | + |
|
319 | + |
|
320 | + /** |
|
321 | + * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
322 | + * |
|
323 | + * @param string $class_name |
|
324 | + * @param string $dependency |
|
325 | + * @return bool |
|
326 | + */ |
|
327 | + public function has_dependency_for_class($class_name = '', $dependency = '') |
|
328 | + { |
|
329 | + // all legacy models have the same dependencies |
|
330 | + if (strpos($class_name, 'EEM_') === 0) { |
|
331 | + $class_name = 'LEGACY_MODELS'; |
|
332 | + } |
|
333 | + $dependency = $this->get_alias($dependency); |
|
334 | + return isset($this->_dependency_map[$class_name][$dependency]) |
|
335 | + ? true |
|
336 | + : false; |
|
337 | + } |
|
338 | + |
|
339 | + |
|
340 | + |
|
341 | + /** |
|
342 | + * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
343 | + * |
|
344 | + * @param string $class_name |
|
345 | + * @param string $dependency |
|
346 | + * @return int |
|
347 | + */ |
|
348 | + public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
349 | + { |
|
350 | + // all legacy models have the same dependencies |
|
351 | + if (strpos($class_name, 'EEM_') === 0) { |
|
352 | + $class_name = 'LEGACY_MODELS'; |
|
353 | + } |
|
354 | + $dependency = $this->get_alias($dependency); |
|
355 | + return $this->has_dependency_for_class($class_name, $dependency) |
|
356 | + ? $this->_dependency_map[$class_name][$dependency] |
|
357 | + : EE_Dependency_Map::not_registered; |
|
358 | + } |
|
359 | + |
|
360 | + |
|
361 | + |
|
362 | + /** |
|
363 | + * @param string $class_name |
|
364 | + * @return string | Closure |
|
365 | + */ |
|
366 | + public function class_loader($class_name) |
|
367 | + { |
|
368 | + // all legacy models use load_model() |
|
369 | + if(strpos($class_name, 'EEM_') === 0){ |
|
370 | + return 'load_model'; |
|
371 | + } |
|
372 | + $class_name = $this->get_alias($class_name); |
|
373 | + return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : ''; |
|
374 | + } |
|
375 | + |
|
376 | + |
|
377 | + |
|
378 | + /** |
|
379 | + * @return array |
|
380 | + */ |
|
381 | + public function class_loaders() |
|
382 | + { |
|
383 | + return $this->_class_loaders; |
|
384 | + } |
|
385 | + |
|
386 | + |
|
387 | + |
|
388 | + /** |
|
389 | + * adds an alias for a classname |
|
390 | + * |
|
391 | + * @param string $class_name the class name that should be used (concrete class to replace interface) |
|
392 | + * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
393 | + * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
394 | + */ |
|
395 | + public function add_alias($class_name, $alias, $for_class = '') |
|
396 | + { |
|
397 | + if ($for_class !== '') { |
|
398 | + if (! isset($this->_aliases[$for_class])) { |
|
399 | + $this->_aliases[$for_class] = array(); |
|
400 | + } |
|
401 | + $this->_aliases[$for_class][$class_name] = $alias; |
|
402 | + } |
|
403 | + $this->_aliases[$class_name] = $alias; |
|
404 | + } |
|
405 | + |
|
406 | + |
|
407 | + |
|
408 | + /** |
|
409 | + * returns TRUE if the provided class name has an alias |
|
410 | + * |
|
411 | + * @param string $class_name |
|
412 | + * @param string $for_class |
|
413 | + * @return bool |
|
414 | + */ |
|
415 | + public function has_alias($class_name = '', $for_class = '') |
|
416 | + { |
|
417 | + return isset($this->_aliases[$for_class][$class_name]) |
|
418 | + || ( |
|
419 | + isset($this->_aliases[$class_name]) |
|
420 | + && ! is_array($this->_aliases[$class_name]) |
|
421 | + ); |
|
422 | + } |
|
423 | + |
|
424 | + |
|
425 | + |
|
426 | + /** |
|
427 | + * returns alias for class name if one exists, otherwise returns the original classname |
|
428 | + * functions recursively, so that multiple aliases can be used to drill down to a classname |
|
429 | + * for example: |
|
430 | + * if the following two entries were added to the _aliases array: |
|
431 | + * array( |
|
432 | + * 'interface_alias' => 'some\namespace\interface' |
|
433 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
434 | + * ) |
|
435 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
436 | + * to load an instance of 'some\namespace\classname' |
|
437 | + * |
|
438 | + * @param string $class_name |
|
439 | + * @param string $for_class |
|
440 | + * @return string |
|
441 | + */ |
|
442 | + public function get_alias($class_name = '', $for_class = '') |
|
443 | + { |
|
444 | + if (! $this->has_alias($class_name, $for_class)) { |
|
445 | + return $class_name; |
|
446 | + } |
|
447 | + if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) { |
|
448 | + return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class); |
|
449 | + } |
|
450 | + return $this->get_alias($this->_aliases[$class_name]); |
|
451 | + } |
|
452 | + |
|
453 | + |
|
454 | + |
|
455 | + /** |
|
456 | + * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
457 | + * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
458 | + * This is done by using the following class constants: |
|
459 | + * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
460 | + * EE_Dependency_Map::load_new_object - generates a new object every time |
|
461 | + */ |
|
462 | + protected function _register_core_dependencies() |
|
463 | + { |
|
464 | + $this->_dependency_map = array( |
|
465 | + 'EE_Request_Handler' => array( |
|
466 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
467 | + ), |
|
468 | + 'EE_System' => array( |
|
469 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
470 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
471 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
472 | + 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
473 | + ), |
|
474 | + 'EE_Session' => array( |
|
475 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
476 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
477 | + 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
478 | + ), |
|
479 | + 'EE_Cart' => array( |
|
480 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
481 | + ), |
|
482 | + 'EE_Front_Controller' => array( |
|
483 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
484 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
485 | + 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
486 | + ), |
|
487 | + 'EE_Messenger_Collection_Loader' => array( |
|
488 | + 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
489 | + ), |
|
490 | + 'EE_Message_Type_Collection_Loader' => array( |
|
491 | + 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
492 | + ), |
|
493 | + 'EE_Message_Resource_Manager' => array( |
|
494 | + 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
495 | + 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
496 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
497 | + ), |
|
498 | + 'EE_Message_Factory' => array( |
|
499 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
500 | + ), |
|
501 | + 'EE_messages' => array( |
|
502 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
503 | + ), |
|
504 | + 'EE_Messages_Generator' => array( |
|
505 | + 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
506 | + 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
507 | + 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
508 | + 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
509 | + ), |
|
510 | + 'EE_Messages_Processor' => array( |
|
511 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
512 | + ), |
|
513 | + 'EE_Messages_Queue' => array( |
|
514 | + 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
515 | + ), |
|
516 | + 'EE_Messages_Template_Defaults' => array( |
|
517 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
518 | + 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
519 | + ), |
|
520 | + 'EE_Message_To_Generate_From_Request' => array( |
|
521 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
522 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
523 | + ), |
|
524 | + 'EventEspresso\core\services\commands\CommandBus' => array( |
|
525 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
526 | + ), |
|
527 | + 'EventEspresso\services\commands\CommandHandler' => array( |
|
528 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
529 | + 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
530 | + ), |
|
531 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => array( |
|
532 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
533 | + ), |
|
534 | + 'EventEspresso\core\services\commands\CompositeCommandHandler' => array( |
|
535 | + 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
536 | + 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
537 | + ), |
|
538 | + 'EventEspresso\core\services\commands\CommandFactory' => array( |
|
539 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
540 | + ), |
|
541 | + 'EventEspresso\core\services\commands\middleware\CapChecker' => array( |
|
542 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
543 | + ), |
|
544 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => array( |
|
545 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
546 | + ), |
|
547 | + 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => array( |
|
548 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
549 | + ), |
|
550 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => array( |
|
551 | + 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
552 | + ), |
|
553 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => array( |
|
554 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
555 | + ), |
|
556 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => array( |
|
557 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
558 | + ), |
|
559 | + 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => array( |
|
560 | + 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
561 | + ), |
|
562 | + 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array( |
|
563 | + 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
564 | + ), |
|
565 | + 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => array( |
|
566 | + 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
567 | + ), |
|
568 | + 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => array( |
|
569 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
570 | + ), |
|
571 | + 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => array( |
|
572 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
573 | + ), |
|
574 | + 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => array( |
|
575 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
576 | + ), |
|
577 | + 'EventEspresso\core\services\database\TableManager' => array( |
|
578 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
579 | + ), |
|
580 | + 'EE_Data_Migration_Class_Base' => array( |
|
581 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
582 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
583 | + ), |
|
584 | + 'EE_DMS_Core_4_1_0' => array( |
|
585 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
586 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
587 | + ), |
|
588 | + 'EE_DMS_Core_4_2_0' => array( |
|
589 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
590 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
591 | + ), |
|
592 | + 'EE_DMS_Core_4_3_0' => array( |
|
593 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
594 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
595 | + ), |
|
596 | + 'EE_DMS_Core_4_4_0' => array( |
|
597 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
598 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
599 | + ), |
|
600 | + 'EE_DMS_Core_4_5_0' => array( |
|
601 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
602 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
603 | + ), |
|
604 | + 'EE_DMS_Core_4_6_0' => array( |
|
605 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
606 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
607 | + ), |
|
608 | + 'EE_DMS_Core_4_7_0' => array( |
|
609 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
610 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
611 | + ), |
|
612 | + 'EE_DMS_Core_4_8_0' => array( |
|
613 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
614 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
615 | + ), |
|
616 | + 'EE_DMS_Core_4_9_0' => array( |
|
617 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
618 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
619 | + ), |
|
620 | + 'EventEspresso\core\services\assets\Registry' => array( |
|
621 | + 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
622 | + 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
623 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache |
|
624 | + ), |
|
625 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => array( |
|
626 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
627 | + ), |
|
628 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => array( |
|
629 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
630 | + ), |
|
631 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => array( |
|
632 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
633 | + ), |
|
634 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => array( |
|
635 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
636 | + ), |
|
637 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => array( |
|
638 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
639 | + ), |
|
640 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => array( |
|
641 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
642 | + ), |
|
643 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => array( |
|
644 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
645 | + ), |
|
646 | + 'EventEspresso\core\services\cache\BasicCacheManager' => array( |
|
647 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
648 | + ), |
|
649 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => array( |
|
650 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
651 | + ), |
|
652 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array( |
|
653 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
654 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
655 | + ), |
|
656 | + 'EventEspresso\core\domain\values\EmailAddress' => array( |
|
657 | + null, |
|
658 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
659 | + ), |
|
660 | + 'EventEspresso\core\services\orm\ModelFieldFactory' => array( |
|
661 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
662 | + ), |
|
663 | + 'LEGACY_MODELS' => array( |
|
664 | + null, |
|
665 | + 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
666 | + ), |
|
667 | + 'EE_Module_Request_Router' => array( |
|
668 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
669 | + ), |
|
670 | + 'EE_Registration_Processor' => array( |
|
671 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
672 | + ), |
|
673 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array( |
|
674 | + null, |
|
675 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
676 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
677 | + ), |
|
678 | + 'EventEspresso\core\domain\services\admin\ExitModal' => array( |
|
679 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache |
|
680 | + ) |
|
681 | + ); |
|
682 | + } |
|
683 | + |
|
684 | + |
|
685 | + |
|
686 | + /** |
|
687 | + * Registers how core classes are loaded. |
|
688 | + * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
689 | + * 'EE_Request_Handler' => 'load_core' |
|
690 | + * 'EE_Messages_Queue' => 'load_lib' |
|
691 | + * 'EEH_Debug_Tools' => 'load_helper' |
|
692 | + * or, if greater control is required, by providing a custom closure. For example: |
|
693 | + * 'Some_Class' => function () { |
|
694 | + * return new Some_Class(); |
|
695 | + * }, |
|
696 | + * This is required for instantiating dependencies |
|
697 | + * where an interface has been type hinted in a class constructor. For example: |
|
698 | + * 'Required_Interface' => function () { |
|
699 | + * return new A_Class_That_Implements_Required_Interface(); |
|
700 | + * }, |
|
701 | + * |
|
702 | + * @throws InvalidInterfaceException |
|
703 | + * @throws InvalidDataTypeException |
|
704 | + * @throws InvalidArgumentException |
|
705 | + */ |
|
706 | + protected function _register_core_class_loaders() |
|
707 | + { |
|
708 | + //for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot |
|
709 | + //be used in a closure. |
|
710 | + $request = &$this->request; |
|
711 | + $response = &$this->response; |
|
712 | + $legacy_request = &$this->legacy_request; |
|
713 | + // $loader = &$this->loader; |
|
714 | + $this->_class_loaders = array( |
|
715 | + //load_core |
|
716 | + 'EE_Capabilities' => 'load_core', |
|
717 | + 'EE_Encryption' => 'load_core', |
|
718 | + 'EE_Front_Controller' => 'load_core', |
|
719 | + 'EE_Module_Request_Router' => 'load_core', |
|
720 | + 'EE_Registry' => 'load_core', |
|
721 | + 'EE_Request' => function () use (&$legacy_request) { |
|
722 | + return $legacy_request; |
|
723 | + }, |
|
724 | + 'EventEspresso\core\services\request\Request' => function () use (&$request) { |
|
725 | + return $request; |
|
726 | + }, |
|
727 | + 'EventEspresso\core\services\request\Response' => function () use (&$response) { |
|
728 | + return $response; |
|
729 | + }, |
|
730 | + 'EE_Request_Handler' => 'load_core', |
|
731 | + 'EE_Session' => 'load_core', |
|
732 | + 'EE_Cron_Tasks' => 'load_core', |
|
733 | + 'EE_System' => 'load_core', |
|
734 | + 'EE_Maintenance_Mode' => 'load_core', |
|
735 | + 'EE_Register_CPTs' => 'load_core', |
|
736 | + 'EE_Admin' => 'load_core', |
|
737 | + //load_lib |
|
738 | + 'EE_Message_Resource_Manager' => 'load_lib', |
|
739 | + 'EE_Message_Type_Collection' => 'load_lib', |
|
740 | + 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
741 | + 'EE_Messenger_Collection' => 'load_lib', |
|
742 | + 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
743 | + 'EE_Messages_Processor' => 'load_lib', |
|
744 | + 'EE_Message_Repository' => 'load_lib', |
|
745 | + 'EE_Messages_Queue' => 'load_lib', |
|
746 | + 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
747 | + 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
748 | + 'EE_Payment_Method_Manager' => 'load_lib', |
|
749 | + 'EE_Messages_Generator' => function () { |
|
750 | + return EE_Registry::instance()->load_lib( |
|
751 | + 'Messages_Generator', |
|
752 | + array(), |
|
753 | + false, |
|
754 | + false |
|
755 | + ); |
|
756 | + }, |
|
757 | + 'EE_Messages_Template_Defaults' => function ($arguments = array()) { |
|
758 | + return EE_Registry::instance()->load_lib( |
|
759 | + 'Messages_Template_Defaults', |
|
760 | + $arguments, |
|
761 | + false, |
|
762 | + false |
|
763 | + ); |
|
764 | + }, |
|
765 | + //load_model |
|
766 | + // 'EEM_Attendee' => 'load_model', |
|
767 | + // 'EEM_Message_Template_Group' => 'load_model', |
|
768 | + // 'EEM_Message_Template' => 'load_model', |
|
769 | + //load_helper |
|
770 | + 'EEH_Parse_Shortcodes' => function () { |
|
771 | + if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
772 | + return new EEH_Parse_Shortcodes(); |
|
773 | + } |
|
774 | + return null; |
|
775 | + }, |
|
776 | + 'EE_Template_Config' => function () { |
|
777 | + return EE_Config::instance()->template_settings; |
|
778 | + }, |
|
779 | + 'EE_Currency_Config' => function () { |
|
780 | + return EE_Config::instance()->currency; |
|
781 | + }, |
|
782 | + 'EE_Registration_Config' => function () { |
|
783 | + return EE_Config::instance()->registration; |
|
784 | + }, |
|
785 | + 'EventEspresso\core\services\loaders\Loader' => function () { |
|
786 | + return LoaderFactory::getLoader(); |
|
787 | + }, |
|
788 | + ); |
|
789 | + } |
|
790 | + |
|
791 | + |
|
792 | + |
|
793 | + /** |
|
794 | + * can be used for supplying alternate names for classes, |
|
795 | + * or for connecting interface names to instantiable classes |
|
796 | + */ |
|
797 | + protected function _register_core_aliases() |
|
798 | + { |
|
799 | + $this->_aliases = array( |
|
800 | + 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
801 | + 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
802 | + 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
803 | + 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
804 | + 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
805 | + 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
806 | + 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
807 | + 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
808 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
809 | + 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
810 | + 'CreateRegCodeCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand', |
|
811 | + 'CreateRegUrlLinkCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand', |
|
812 | + 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
813 | + 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
814 | + 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
815 | + 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
816 | + 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
817 | + 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
818 | + 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
819 | + 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
820 | + 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
821 | + 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
822 | + 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
823 | + 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
824 | + 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
825 | + 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
826 | + 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
827 | + 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
828 | + 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
829 | + 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
830 | + 'EventEspresso\core\domain\services\session\SessionIdentifierInterface' => 'EE_Session', |
|
831 | + 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
832 | + 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
833 | + 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
834 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
835 | + 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
836 | + 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
837 | + 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
838 | + 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
839 | + 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
840 | + ); |
|
841 | + if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
842 | + $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices'; |
|
843 | + } |
|
844 | + } |
|
845 | + |
|
846 | + |
|
847 | + |
|
848 | + /** |
|
849 | + * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
850 | + * request Primarily used by unit tests. |
|
851 | + * |
|
852 | + * @throws InvalidDataTypeException |
|
853 | + * @throws InvalidInterfaceException |
|
854 | + * @throws InvalidArgumentException |
|
855 | + */ |
|
856 | + public function reset() |
|
857 | + { |
|
858 | + $this->_register_core_class_loaders(); |
|
859 | + $this->_register_core_dependencies(); |
|
860 | + } |
|
861 | 861 | |
862 | 862 | |
863 | 863 | } |
@@ -23,458 +23,458 @@ discard block |
||
23 | 23 | final class EE_Admin implements InterminableInterface |
24 | 24 | { |
25 | 25 | |
26 | - /** |
|
27 | - * @var EE_Admin $_instance |
|
28 | - */ |
|
29 | - private static $_instance; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var PersistentAdminNoticeManager $persistent_admin_notice_manager |
|
33 | - */ |
|
34 | - private $persistent_admin_notice_manager; |
|
35 | - |
|
36 | - /** |
|
37 | - * @singleton method used to instantiate class object |
|
38 | - * @return EE_Admin |
|
39 | - * @throws EE_Error |
|
40 | - */ |
|
41 | - public static function instance() |
|
42 | - { |
|
43 | - // check if class object is instantiated |
|
44 | - if (! self::$_instance instanceof EE_Admin) { |
|
45 | - self::$_instance = new self(); |
|
46 | - } |
|
47 | - return self::$_instance; |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * @return EE_Admin |
|
53 | - * @throws EE_Error |
|
54 | - */ |
|
55 | - public static function reset() |
|
56 | - { |
|
57 | - self::$_instance = null; |
|
58 | - return self::instance(); |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * class constructor |
|
64 | - * |
|
65 | - * @throws EE_Error |
|
66 | - * @throws InvalidDataTypeException |
|
67 | - * @throws InvalidInterfaceException |
|
68 | - * @throws InvalidArgumentException |
|
69 | - */ |
|
70 | - protected function __construct() |
|
71 | - { |
|
72 | - // define global EE_Admin constants |
|
73 | - $this->_define_all_constants(); |
|
74 | - // set autoloaders for our admin page classes based on included path information |
|
75 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN); |
|
76 | - // admin hooks |
|
77 | - add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2); |
|
78 | - // load EE_Request_Handler early |
|
79 | - add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request')); |
|
80 | - add_action('AHEE__EE_System__initialize_last', array($this, 'init')); |
|
81 | - add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2); |
|
82 | - add_action('wp_loaded', array($this, 'wp_loaded'), 100); |
|
83 | - add_action('admin_init', array($this, 'admin_init'), 100); |
|
84 | - add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20); |
|
85 | - add_action('admin_notices', array($this, 'display_admin_notices'), 10); |
|
86 | - add_action('network_admin_notices', array($this, 'display_admin_notices'), 10); |
|
87 | - add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2); |
|
88 | - add_filter('admin_footer_text', array($this, 'espresso_admin_footer')); |
|
89 | - add_action('load-plugins.php', array($this, 'hookIntoWpPluginsPage')); |
|
90 | - //reset Environment config (we only do this on admin page loads); |
|
91 | - EE_Registry::instance()->CFG->environment->recheck_values(); |
|
92 | - do_action('AHEE__EE_Admin__loaded'); |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * _define_all_constants |
|
99 | - * define constants that are set globally for all admin pages |
|
100 | - * |
|
101 | - * @return void |
|
102 | - */ |
|
103 | - private function _define_all_constants() |
|
104 | - { |
|
105 | - if (! defined('EE_ADMIN_URL')) { |
|
106 | - define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/'); |
|
107 | - define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/'); |
|
108 | - define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS); |
|
109 | - define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/'); |
|
110 | - define('WP_AJAX_URL', admin_url('admin-ajax.php')); |
|
111 | - } |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * filter_plugin_actions - adds links to the Plugins page listing |
|
117 | - * |
|
118 | - * @param array $links |
|
119 | - * @param string $plugin |
|
120 | - * @return array |
|
121 | - */ |
|
122 | - public function filter_plugin_actions($links, $plugin) |
|
123 | - { |
|
124 | - // set $main_file in stone |
|
125 | - static $main_file; |
|
126 | - // if $main_file is not set yet |
|
127 | - if (! $main_file) { |
|
128 | - $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE); |
|
129 | - } |
|
130 | - if ($plugin === $main_file) { |
|
131 | - // compare current plugin to this one |
|
132 | - if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
133 | - $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"' |
|
134 | - . ' title="Event Espresso is in maintenance mode. Click this link to learn why.">' |
|
135 | - . esc_html__('Maintenance Mode Active', 'event_espresso') |
|
136 | - . '</a>'; |
|
137 | - array_unshift($links, $maintenance_link); |
|
138 | - } else { |
|
139 | - $org_settings_link = '<a href="admin.php?page=espresso_general_settings">' |
|
140 | - . esc_html__('Settings', 'event_espresso') |
|
141 | - . '</a>'; |
|
142 | - $events_link = '<a href="admin.php?page=espresso_events">' |
|
143 | - . esc_html__('Events', 'event_espresso') |
|
144 | - . '</a>'; |
|
145 | - // add before other links |
|
146 | - array_unshift($links, $org_settings_link, $events_link); |
|
147 | - } |
|
148 | - } |
|
149 | - return $links; |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * _get_request |
|
155 | - * |
|
156 | - * @return void |
|
157 | - * @throws EE_Error |
|
158 | - * @throws InvalidArgumentException |
|
159 | - * @throws InvalidDataTypeException |
|
160 | - * @throws InvalidInterfaceException |
|
161 | - * @throws ReflectionException |
|
162 | - */ |
|
163 | - public function get_request() |
|
164 | - { |
|
165 | - EE_Registry::instance()->load_core('Request_Handler'); |
|
166 | - EE_Registry::instance()->load_core('CPT_Strategy'); |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * hide_admin_pages_except_maintenance_mode |
|
173 | - * |
|
174 | - * @param array $admin_page_folder_names |
|
175 | - * @return array |
|
176 | - */ |
|
177 | - public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) |
|
178 | - { |
|
179 | - return array( |
|
180 | - 'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS, |
|
181 | - 'about' => EE_ADMIN_PAGES . 'about' . DS, |
|
182 | - 'support' => EE_ADMIN_PAGES . 'support' . DS, |
|
183 | - ); |
|
184 | - } |
|
185 | - |
|
186 | - |
|
187 | - |
|
188 | - /** |
|
189 | - * init- should fire after shortcode, module, addon, other plugin (default priority), and even |
|
190 | - * EE_Front_Controller's init phases have run |
|
191 | - * |
|
192 | - * @return void |
|
193 | - * @throws EE_Error |
|
194 | - * @throws InvalidArgumentException |
|
195 | - * @throws InvalidDataTypeException |
|
196 | - * @throws InvalidInterfaceException |
|
197 | - * @throws ReflectionException |
|
198 | - * @throws ServiceNotFoundException |
|
199 | - */ |
|
200 | - public function init() |
|
201 | - { |
|
202 | - //only enable most of the EE_Admin IF we're not in full maintenance mode |
|
203 | - if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
204 | - //ok so we want to enable the entire admin |
|
205 | - $this->persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared( |
|
206 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
207 | - ); |
|
208 | - $this->persistent_admin_notice_manager->setReturnUrl( |
|
209 | - EE_Admin_Page::add_query_args_and_nonce( |
|
210 | - array( |
|
211 | - 'page' => EE_Registry::instance()->REQ->get('page', ''), |
|
212 | - 'action' => EE_Registry::instance()->REQ->get('action', ''), |
|
213 | - ), |
|
214 | - EE_ADMIN_URL |
|
215 | - ) |
|
216 | - ); |
|
217 | - $this->maybeSetDatetimeWarningNotice(); |
|
218 | - //at a glance dashboard widget |
|
219 | - add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10); |
|
220 | - //filter for get_edit_post_link used on comments for custom post types |
|
221 | - add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2); |
|
222 | - } |
|
223 | - // run the admin page factory but ONLY if we are doing an ee admin ajax request |
|
224 | - if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
225 | - try { |
|
226 | - //this loads the controller for the admin pages which will setup routing etc |
|
227 | - EE_Registry::instance()->load_core('Admin_Page_Loader'); |
|
228 | - } catch (EE_Error $e) { |
|
229 | - $e->get_error(); |
|
230 | - } |
|
231 | - } |
|
232 | - add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1); |
|
233 | - //make sure our CPTs and custom taxonomy metaboxes get shown for first time users |
|
234 | - add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10); |
|
235 | - add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10); |
|
236 | - //exclude EE critical pages from all nav menus and wp_list_pages |
|
237 | - add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10); |
|
238 | - } |
|
239 | - |
|
240 | - |
|
241 | - /** |
|
242 | - * get_persistent_admin_notices |
|
243 | - * |
|
244 | - * @access public |
|
245 | - * @return void |
|
246 | - * @throws EE_Error |
|
247 | - * @throws InvalidArgumentException |
|
248 | - * @throws InvalidDataTypeException |
|
249 | - * @throws InvalidInterfaceException |
|
250 | - */ |
|
251 | - public function maybeSetDatetimeWarningNotice() |
|
252 | - { |
|
253 | - //add dismissable notice for datetime changes. Only valid if site does not have a timezone_string set. |
|
254 | - //@todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version |
|
255 | - //with this. But after enough time (indeterminate at this point) we can just remove this notice. |
|
256 | - //this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626 |
|
257 | - if (apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true) |
|
258 | - && ! get_option('timezone_string') |
|
259 | - && EEM_Event::instance()->count() > 0 |
|
260 | - ) { |
|
261 | - new PersistentAdminNotice( |
|
262 | - 'datetime_fix_notice', |
|
263 | - sprintf( |
|
264 | - esc_html__( |
|
265 | - '%1$sImportant announcement related to your install of Event Espresso%2$s: There are some changes made to your site that could affect how dates display for your events and other related items with dates and times. Read more about it %3$shere%4$s. If your dates and times are displaying incorrectly (incorrect offset), you can fix it using the tool on %5$sthis page%4$s.', |
|
266 | - 'event_espresso' |
|
267 | - ), |
|
268 | - '<strong>', |
|
269 | - '</strong>', |
|
270 | - '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">', |
|
271 | - '</a>', |
|
272 | - '<a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
273 | - array( |
|
274 | - 'page' => 'espresso_maintenance_settings', |
|
275 | - 'action' => 'datetime_tools' |
|
276 | - ), |
|
277 | - admin_url('admin.php') |
|
278 | - ) . '">' |
|
279 | - ), |
|
280 | - false, |
|
281 | - 'manage_options', |
|
282 | - 'datetime_fix_persistent_notice' |
|
283 | - ); |
|
284 | - } |
|
285 | - } |
|
286 | - |
|
287 | - |
|
288 | - |
|
289 | - /** |
|
290 | - * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from |
|
291 | - * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in |
|
292 | - * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that |
|
293 | - * to override any queries found in the existing query for the given post type. Note that _default_query is not a |
|
294 | - * normal property on the post_type object. It's found ONLY in this particular context. |
|
295 | - * |
|
296 | - * @param WP_Post $post_type WP post type object |
|
297 | - * @return WP_Post |
|
298 | - * @throws InvalidArgumentException |
|
299 | - * @throws InvalidDataTypeException |
|
300 | - * @throws InvalidInterfaceException |
|
301 | - */ |
|
302 | - public function remove_pages_from_nav_menu($post_type) |
|
303 | - { |
|
304 | - //if this isn't the "pages" post type let's get out |
|
305 | - if ($post_type->name !== 'page') { |
|
306 | - return $post_type; |
|
307 | - } |
|
308 | - $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
309 | - $post_type->_default_query = array( |
|
310 | - 'post__not_in' => $critical_pages, |
|
311 | - ); |
|
312 | - return $post_type; |
|
313 | - } |
|
314 | - |
|
315 | - |
|
316 | - |
|
317 | - /** |
|
318 | - * WP by default only shows three metaboxes in "nav-menus.php" for first times users. We want to make sure our |
|
319 | - * metaboxes get shown as well |
|
320 | - * |
|
321 | - * @return void |
|
322 | - */ |
|
323 | - public function enable_hidden_ee_nav_menu_metaboxes() |
|
324 | - { |
|
325 | - global $wp_meta_boxes, $pagenow; |
|
326 | - if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
327 | - return; |
|
328 | - } |
|
329 | - $user = wp_get_current_user(); |
|
330 | - //has this been done yet? |
|
331 | - if (get_user_option('ee_nav_menu_initialized', $user->ID)) { |
|
332 | - return; |
|
333 | - } |
|
334 | - |
|
335 | - $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID); |
|
336 | - $initial_meta_boxes = apply_filters( |
|
337 | - 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', |
|
338 | - array( |
|
339 | - 'nav-menu-theme-locations', |
|
340 | - 'add-page', |
|
341 | - 'add-custom-links', |
|
342 | - 'add-category', |
|
343 | - 'add-espresso_events', |
|
344 | - 'add-espresso_venues', |
|
345 | - 'add-espresso_event_categories', |
|
346 | - 'add-espresso_venue_categories', |
|
347 | - 'add-post-type-post', |
|
348 | - 'add-post-type-page', |
|
349 | - ) |
|
350 | - ); |
|
351 | - |
|
352 | - if (is_array($hidden_meta_boxes)) { |
|
353 | - foreach ($hidden_meta_boxes as $key => $meta_box_id) { |
|
354 | - if (in_array($meta_box_id, $initial_meta_boxes, true)) { |
|
355 | - unset($hidden_meta_boxes[$key]); |
|
356 | - } |
|
357 | - } |
|
358 | - } |
|
359 | - update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
360 | - update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true); |
|
361 | - } |
|
362 | - |
|
363 | - |
|
364 | - |
|
365 | - /** |
|
366 | - * This method simply registers custom nav menu boxes for "nav_menus.php route" |
|
367 | - * Currently EE is using this to make sure there are menu options for our CPT archive page routes. |
|
368 | - * |
|
369 | - * @todo modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by |
|
370 | - * addons etc. |
|
371 | - * @return void |
|
372 | - */ |
|
373 | - public function register_custom_nav_menu_boxes() |
|
374 | - { |
|
375 | - add_meta_box( |
|
376 | - 'add-extra-nav-menu-pages', |
|
377 | - esc_html__('Event Espresso Pages', 'event_espresso'), |
|
378 | - array($this, 'ee_cpt_archive_pages'), |
|
379 | - 'nav-menus', |
|
380 | - 'side', |
|
381 | - 'core' |
|
382 | - ); |
|
383 | - } |
|
384 | - |
|
385 | - |
|
386 | - |
|
387 | - /** |
|
388 | - * Use this to edit the post link for our cpts so that the edit link points to the correct page. |
|
389 | - * |
|
390 | - * @since 4.3.0 |
|
391 | - * @param string $link the original link generated by wp |
|
392 | - * @param int $id post id |
|
393 | - * @return string the (maybe) modified link |
|
394 | - */ |
|
395 | - public function modify_edit_post_link($link, $id) |
|
396 | - { |
|
397 | - if (! $post = get_post($id)) { |
|
398 | - return $link; |
|
399 | - } |
|
400 | - if ($post->post_type === 'espresso_attendees') { |
|
401 | - $query_args = array( |
|
402 | - 'action' => 'edit_attendee', |
|
403 | - 'post' => $id, |
|
404 | - ); |
|
405 | - return EEH_URL::add_query_args_and_nonce( |
|
406 | - $query_args, |
|
407 | - admin_url('admin.php?page=espresso_registrations') |
|
408 | - ); |
|
409 | - } |
|
410 | - return $link; |
|
411 | - } |
|
412 | - |
|
413 | - |
|
414 | - |
|
415 | - public function ee_cpt_archive_pages() |
|
416 | - { |
|
417 | - global $nav_menu_selected_id; |
|
418 | - $db_fields = false; |
|
419 | - $walker = new Walker_Nav_Menu_Checklist($db_fields); |
|
420 | - $current_tab = 'event-archives'; |
|
421 | - $removed_args = array( |
|
422 | - 'action', |
|
423 | - 'customlink-tab', |
|
424 | - 'edit-menu-item', |
|
425 | - 'menu-item', |
|
426 | - 'page-tab', |
|
427 | - '_wpnonce', |
|
428 | - ); |
|
429 | - ?> |
|
26 | + /** |
|
27 | + * @var EE_Admin $_instance |
|
28 | + */ |
|
29 | + private static $_instance; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var PersistentAdminNoticeManager $persistent_admin_notice_manager |
|
33 | + */ |
|
34 | + private $persistent_admin_notice_manager; |
|
35 | + |
|
36 | + /** |
|
37 | + * @singleton method used to instantiate class object |
|
38 | + * @return EE_Admin |
|
39 | + * @throws EE_Error |
|
40 | + */ |
|
41 | + public static function instance() |
|
42 | + { |
|
43 | + // check if class object is instantiated |
|
44 | + if (! self::$_instance instanceof EE_Admin) { |
|
45 | + self::$_instance = new self(); |
|
46 | + } |
|
47 | + return self::$_instance; |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * @return EE_Admin |
|
53 | + * @throws EE_Error |
|
54 | + */ |
|
55 | + public static function reset() |
|
56 | + { |
|
57 | + self::$_instance = null; |
|
58 | + return self::instance(); |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * class constructor |
|
64 | + * |
|
65 | + * @throws EE_Error |
|
66 | + * @throws InvalidDataTypeException |
|
67 | + * @throws InvalidInterfaceException |
|
68 | + * @throws InvalidArgumentException |
|
69 | + */ |
|
70 | + protected function __construct() |
|
71 | + { |
|
72 | + // define global EE_Admin constants |
|
73 | + $this->_define_all_constants(); |
|
74 | + // set autoloaders for our admin page classes based on included path information |
|
75 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN); |
|
76 | + // admin hooks |
|
77 | + add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2); |
|
78 | + // load EE_Request_Handler early |
|
79 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request')); |
|
80 | + add_action('AHEE__EE_System__initialize_last', array($this, 'init')); |
|
81 | + add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2); |
|
82 | + add_action('wp_loaded', array($this, 'wp_loaded'), 100); |
|
83 | + add_action('admin_init', array($this, 'admin_init'), 100); |
|
84 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20); |
|
85 | + add_action('admin_notices', array($this, 'display_admin_notices'), 10); |
|
86 | + add_action('network_admin_notices', array($this, 'display_admin_notices'), 10); |
|
87 | + add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2); |
|
88 | + add_filter('admin_footer_text', array($this, 'espresso_admin_footer')); |
|
89 | + add_action('load-plugins.php', array($this, 'hookIntoWpPluginsPage')); |
|
90 | + //reset Environment config (we only do this on admin page loads); |
|
91 | + EE_Registry::instance()->CFG->environment->recheck_values(); |
|
92 | + do_action('AHEE__EE_Admin__loaded'); |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * _define_all_constants |
|
99 | + * define constants that are set globally for all admin pages |
|
100 | + * |
|
101 | + * @return void |
|
102 | + */ |
|
103 | + private function _define_all_constants() |
|
104 | + { |
|
105 | + if (! defined('EE_ADMIN_URL')) { |
|
106 | + define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/'); |
|
107 | + define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/'); |
|
108 | + define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS); |
|
109 | + define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/'); |
|
110 | + define('WP_AJAX_URL', admin_url('admin-ajax.php')); |
|
111 | + } |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * filter_plugin_actions - adds links to the Plugins page listing |
|
117 | + * |
|
118 | + * @param array $links |
|
119 | + * @param string $plugin |
|
120 | + * @return array |
|
121 | + */ |
|
122 | + public function filter_plugin_actions($links, $plugin) |
|
123 | + { |
|
124 | + // set $main_file in stone |
|
125 | + static $main_file; |
|
126 | + // if $main_file is not set yet |
|
127 | + if (! $main_file) { |
|
128 | + $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE); |
|
129 | + } |
|
130 | + if ($plugin === $main_file) { |
|
131 | + // compare current plugin to this one |
|
132 | + if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
133 | + $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"' |
|
134 | + . ' title="Event Espresso is in maintenance mode. Click this link to learn why.">' |
|
135 | + . esc_html__('Maintenance Mode Active', 'event_espresso') |
|
136 | + . '</a>'; |
|
137 | + array_unshift($links, $maintenance_link); |
|
138 | + } else { |
|
139 | + $org_settings_link = '<a href="admin.php?page=espresso_general_settings">' |
|
140 | + . esc_html__('Settings', 'event_espresso') |
|
141 | + . '</a>'; |
|
142 | + $events_link = '<a href="admin.php?page=espresso_events">' |
|
143 | + . esc_html__('Events', 'event_espresso') |
|
144 | + . '</a>'; |
|
145 | + // add before other links |
|
146 | + array_unshift($links, $org_settings_link, $events_link); |
|
147 | + } |
|
148 | + } |
|
149 | + return $links; |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * _get_request |
|
155 | + * |
|
156 | + * @return void |
|
157 | + * @throws EE_Error |
|
158 | + * @throws InvalidArgumentException |
|
159 | + * @throws InvalidDataTypeException |
|
160 | + * @throws InvalidInterfaceException |
|
161 | + * @throws ReflectionException |
|
162 | + */ |
|
163 | + public function get_request() |
|
164 | + { |
|
165 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
166 | + EE_Registry::instance()->load_core('CPT_Strategy'); |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * hide_admin_pages_except_maintenance_mode |
|
173 | + * |
|
174 | + * @param array $admin_page_folder_names |
|
175 | + * @return array |
|
176 | + */ |
|
177 | + public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) |
|
178 | + { |
|
179 | + return array( |
|
180 | + 'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS, |
|
181 | + 'about' => EE_ADMIN_PAGES . 'about' . DS, |
|
182 | + 'support' => EE_ADMIN_PAGES . 'support' . DS, |
|
183 | + ); |
|
184 | + } |
|
185 | + |
|
186 | + |
|
187 | + |
|
188 | + /** |
|
189 | + * init- should fire after shortcode, module, addon, other plugin (default priority), and even |
|
190 | + * EE_Front_Controller's init phases have run |
|
191 | + * |
|
192 | + * @return void |
|
193 | + * @throws EE_Error |
|
194 | + * @throws InvalidArgumentException |
|
195 | + * @throws InvalidDataTypeException |
|
196 | + * @throws InvalidInterfaceException |
|
197 | + * @throws ReflectionException |
|
198 | + * @throws ServiceNotFoundException |
|
199 | + */ |
|
200 | + public function init() |
|
201 | + { |
|
202 | + //only enable most of the EE_Admin IF we're not in full maintenance mode |
|
203 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
204 | + //ok so we want to enable the entire admin |
|
205 | + $this->persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared( |
|
206 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
207 | + ); |
|
208 | + $this->persistent_admin_notice_manager->setReturnUrl( |
|
209 | + EE_Admin_Page::add_query_args_and_nonce( |
|
210 | + array( |
|
211 | + 'page' => EE_Registry::instance()->REQ->get('page', ''), |
|
212 | + 'action' => EE_Registry::instance()->REQ->get('action', ''), |
|
213 | + ), |
|
214 | + EE_ADMIN_URL |
|
215 | + ) |
|
216 | + ); |
|
217 | + $this->maybeSetDatetimeWarningNotice(); |
|
218 | + //at a glance dashboard widget |
|
219 | + add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10); |
|
220 | + //filter for get_edit_post_link used on comments for custom post types |
|
221 | + add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2); |
|
222 | + } |
|
223 | + // run the admin page factory but ONLY if we are doing an ee admin ajax request |
|
224 | + if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
225 | + try { |
|
226 | + //this loads the controller for the admin pages which will setup routing etc |
|
227 | + EE_Registry::instance()->load_core('Admin_Page_Loader'); |
|
228 | + } catch (EE_Error $e) { |
|
229 | + $e->get_error(); |
|
230 | + } |
|
231 | + } |
|
232 | + add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1); |
|
233 | + //make sure our CPTs and custom taxonomy metaboxes get shown for first time users |
|
234 | + add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10); |
|
235 | + add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10); |
|
236 | + //exclude EE critical pages from all nav menus and wp_list_pages |
|
237 | + add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10); |
|
238 | + } |
|
239 | + |
|
240 | + |
|
241 | + /** |
|
242 | + * get_persistent_admin_notices |
|
243 | + * |
|
244 | + * @access public |
|
245 | + * @return void |
|
246 | + * @throws EE_Error |
|
247 | + * @throws InvalidArgumentException |
|
248 | + * @throws InvalidDataTypeException |
|
249 | + * @throws InvalidInterfaceException |
|
250 | + */ |
|
251 | + public function maybeSetDatetimeWarningNotice() |
|
252 | + { |
|
253 | + //add dismissable notice for datetime changes. Only valid if site does not have a timezone_string set. |
|
254 | + //@todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version |
|
255 | + //with this. But after enough time (indeterminate at this point) we can just remove this notice. |
|
256 | + //this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626 |
|
257 | + if (apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true) |
|
258 | + && ! get_option('timezone_string') |
|
259 | + && EEM_Event::instance()->count() > 0 |
|
260 | + ) { |
|
261 | + new PersistentAdminNotice( |
|
262 | + 'datetime_fix_notice', |
|
263 | + sprintf( |
|
264 | + esc_html__( |
|
265 | + '%1$sImportant announcement related to your install of Event Espresso%2$s: There are some changes made to your site that could affect how dates display for your events and other related items with dates and times. Read more about it %3$shere%4$s. If your dates and times are displaying incorrectly (incorrect offset), you can fix it using the tool on %5$sthis page%4$s.', |
|
266 | + 'event_espresso' |
|
267 | + ), |
|
268 | + '<strong>', |
|
269 | + '</strong>', |
|
270 | + '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">', |
|
271 | + '</a>', |
|
272 | + '<a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
273 | + array( |
|
274 | + 'page' => 'espresso_maintenance_settings', |
|
275 | + 'action' => 'datetime_tools' |
|
276 | + ), |
|
277 | + admin_url('admin.php') |
|
278 | + ) . '">' |
|
279 | + ), |
|
280 | + false, |
|
281 | + 'manage_options', |
|
282 | + 'datetime_fix_persistent_notice' |
|
283 | + ); |
|
284 | + } |
|
285 | + } |
|
286 | + |
|
287 | + |
|
288 | + |
|
289 | + /** |
|
290 | + * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from |
|
291 | + * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in |
|
292 | + * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that |
|
293 | + * to override any queries found in the existing query for the given post type. Note that _default_query is not a |
|
294 | + * normal property on the post_type object. It's found ONLY in this particular context. |
|
295 | + * |
|
296 | + * @param WP_Post $post_type WP post type object |
|
297 | + * @return WP_Post |
|
298 | + * @throws InvalidArgumentException |
|
299 | + * @throws InvalidDataTypeException |
|
300 | + * @throws InvalidInterfaceException |
|
301 | + */ |
|
302 | + public function remove_pages_from_nav_menu($post_type) |
|
303 | + { |
|
304 | + //if this isn't the "pages" post type let's get out |
|
305 | + if ($post_type->name !== 'page') { |
|
306 | + return $post_type; |
|
307 | + } |
|
308 | + $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
309 | + $post_type->_default_query = array( |
|
310 | + 'post__not_in' => $critical_pages, |
|
311 | + ); |
|
312 | + return $post_type; |
|
313 | + } |
|
314 | + |
|
315 | + |
|
316 | + |
|
317 | + /** |
|
318 | + * WP by default only shows three metaboxes in "nav-menus.php" for first times users. We want to make sure our |
|
319 | + * metaboxes get shown as well |
|
320 | + * |
|
321 | + * @return void |
|
322 | + */ |
|
323 | + public function enable_hidden_ee_nav_menu_metaboxes() |
|
324 | + { |
|
325 | + global $wp_meta_boxes, $pagenow; |
|
326 | + if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
327 | + return; |
|
328 | + } |
|
329 | + $user = wp_get_current_user(); |
|
330 | + //has this been done yet? |
|
331 | + if (get_user_option('ee_nav_menu_initialized', $user->ID)) { |
|
332 | + return; |
|
333 | + } |
|
334 | + |
|
335 | + $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID); |
|
336 | + $initial_meta_boxes = apply_filters( |
|
337 | + 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', |
|
338 | + array( |
|
339 | + 'nav-menu-theme-locations', |
|
340 | + 'add-page', |
|
341 | + 'add-custom-links', |
|
342 | + 'add-category', |
|
343 | + 'add-espresso_events', |
|
344 | + 'add-espresso_venues', |
|
345 | + 'add-espresso_event_categories', |
|
346 | + 'add-espresso_venue_categories', |
|
347 | + 'add-post-type-post', |
|
348 | + 'add-post-type-page', |
|
349 | + ) |
|
350 | + ); |
|
351 | + |
|
352 | + if (is_array($hidden_meta_boxes)) { |
|
353 | + foreach ($hidden_meta_boxes as $key => $meta_box_id) { |
|
354 | + if (in_array($meta_box_id, $initial_meta_boxes, true)) { |
|
355 | + unset($hidden_meta_boxes[$key]); |
|
356 | + } |
|
357 | + } |
|
358 | + } |
|
359 | + update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
360 | + update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true); |
|
361 | + } |
|
362 | + |
|
363 | + |
|
364 | + |
|
365 | + /** |
|
366 | + * This method simply registers custom nav menu boxes for "nav_menus.php route" |
|
367 | + * Currently EE is using this to make sure there are menu options for our CPT archive page routes. |
|
368 | + * |
|
369 | + * @todo modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by |
|
370 | + * addons etc. |
|
371 | + * @return void |
|
372 | + */ |
|
373 | + public function register_custom_nav_menu_boxes() |
|
374 | + { |
|
375 | + add_meta_box( |
|
376 | + 'add-extra-nav-menu-pages', |
|
377 | + esc_html__('Event Espresso Pages', 'event_espresso'), |
|
378 | + array($this, 'ee_cpt_archive_pages'), |
|
379 | + 'nav-menus', |
|
380 | + 'side', |
|
381 | + 'core' |
|
382 | + ); |
|
383 | + } |
|
384 | + |
|
385 | + |
|
386 | + |
|
387 | + /** |
|
388 | + * Use this to edit the post link for our cpts so that the edit link points to the correct page. |
|
389 | + * |
|
390 | + * @since 4.3.0 |
|
391 | + * @param string $link the original link generated by wp |
|
392 | + * @param int $id post id |
|
393 | + * @return string the (maybe) modified link |
|
394 | + */ |
|
395 | + public function modify_edit_post_link($link, $id) |
|
396 | + { |
|
397 | + if (! $post = get_post($id)) { |
|
398 | + return $link; |
|
399 | + } |
|
400 | + if ($post->post_type === 'espresso_attendees') { |
|
401 | + $query_args = array( |
|
402 | + 'action' => 'edit_attendee', |
|
403 | + 'post' => $id, |
|
404 | + ); |
|
405 | + return EEH_URL::add_query_args_and_nonce( |
|
406 | + $query_args, |
|
407 | + admin_url('admin.php?page=espresso_registrations') |
|
408 | + ); |
|
409 | + } |
|
410 | + return $link; |
|
411 | + } |
|
412 | + |
|
413 | + |
|
414 | + |
|
415 | + public function ee_cpt_archive_pages() |
|
416 | + { |
|
417 | + global $nav_menu_selected_id; |
|
418 | + $db_fields = false; |
|
419 | + $walker = new Walker_Nav_Menu_Checklist($db_fields); |
|
420 | + $current_tab = 'event-archives'; |
|
421 | + $removed_args = array( |
|
422 | + 'action', |
|
423 | + 'customlink-tab', |
|
424 | + 'edit-menu-item', |
|
425 | + 'menu-item', |
|
426 | + 'page-tab', |
|
427 | + '_wpnonce', |
|
428 | + ); |
|
429 | + ?> |
|
430 | 430 | <div id="posttype-extra-nav-menu-pages" class="posttypediv"> |
431 | 431 | <ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs"> |
432 | 432 | <li <?php echo('event-archives' === $current_tab ? ' class="tabs"' : ''); ?>> |
433 | 433 | <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" |
434 | 434 | href="<?php if ($nav_menu_selected_id) { |
435 | - echo esc_url( |
|
436 | - add_query_arg( |
|
437 | - 'extra-nav-menu-pages-tab', |
|
438 | - 'event-archives', |
|
439 | - remove_query_arg($removed_args) |
|
440 | - ) |
|
441 | - ); |
|
442 | - } ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives"> |
|
435 | + echo esc_url( |
|
436 | + add_query_arg( |
|
437 | + 'extra-nav-menu-pages-tab', |
|
438 | + 'event-archives', |
|
439 | + remove_query_arg($removed_args) |
|
440 | + ) |
|
441 | + ); |
|
442 | + } ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives"> |
|
443 | 443 | <?php _e('Event Archive Pages', 'event_espresso'); ?> |
444 | 444 | </a> |
445 | 445 | </li> |
446 | 446 | </ul><!-- .posttype-tabs --> |
447 | 447 | |
448 | 448 | <div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php |
449 | - echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
450 | - ?>"> |
|
449 | + echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
450 | + ?>"> |
|
451 | 451 | <ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear"> |
452 | 452 | <?php |
453 | - $pages = $this->_get_extra_nav_menu_pages_items(); |
|
454 | - $args['walker'] = $walker; |
|
455 | - echo walk_nav_menu_tree( |
|
456 | - array_map( |
|
457 | - array($this, '_setup_extra_nav_menu_pages_items'), |
|
458 | - $pages |
|
459 | - ), |
|
460 | - 0, |
|
461 | - (object) $args |
|
462 | - ); |
|
463 | - ?> |
|
453 | + $pages = $this->_get_extra_nav_menu_pages_items(); |
|
454 | + $args['walker'] = $walker; |
|
455 | + echo walk_nav_menu_tree( |
|
456 | + array_map( |
|
457 | + array($this, '_setup_extra_nav_menu_pages_items'), |
|
458 | + $pages |
|
459 | + ), |
|
460 | + 0, |
|
461 | + (object) $args |
|
462 | + ); |
|
463 | + ?> |
|
464 | 464 | </ul> |
465 | 465 | </div><!-- /.tabs-panel --> |
466 | 466 | |
467 | 467 | <p class="button-controls"> |
468 | 468 | <span class="list-controls"> |
469 | 469 | <a href="<?php |
470 | - echo esc_url(add_query_arg( |
|
471 | - array( |
|
472 | - 'extra-nav-menu-pages-tab' => 'event-archives', |
|
473 | - 'selectall' => 1, |
|
474 | - ), |
|
475 | - remove_query_arg($removed_args) |
|
476 | - )); |
|
477 | - ?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a> |
|
470 | + echo esc_url(add_query_arg( |
|
471 | + array( |
|
472 | + 'extra-nav-menu-pages-tab' => 'event-archives', |
|
473 | + 'selectall' => 1, |
|
474 | + ), |
|
475 | + remove_query_arg($removed_args) |
|
476 | + )); |
|
477 | + ?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a> |
|
478 | 478 | </span> |
479 | 479 | <span class="add-to-menu"> |
480 | 480 | <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> |
@@ -487,483 +487,483 @@ discard block |
||
487 | 487 | |
488 | 488 | </div><!-- /.posttypediv --> |
489 | 489 | <?php |
490 | - } |
|
491 | - |
|
492 | - |
|
493 | - /** |
|
494 | - * Returns an array of event archive nav items. |
|
495 | - * |
|
496 | - * @todo for now this method is just in place so when it gets abstracted further we can substitute in whatever |
|
497 | - * method we use for getting the extra nav menu items |
|
498 | - * @return array |
|
499 | - */ |
|
500 | - private function _get_extra_nav_menu_pages_items() |
|
501 | - { |
|
502 | - $menuitems[] = array( |
|
503 | - 'title' => esc_html__('Event List', 'event_espresso'), |
|
504 | - 'url' => get_post_type_archive_link('espresso_events'), |
|
505 | - 'description' => esc_html__('Archive page for all events.', 'event_espresso'), |
|
506 | - ); |
|
507 | - return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems); |
|
508 | - } |
|
509 | - |
|
510 | - |
|
511 | - /** |
|
512 | - * Setup nav menu walker item for usage in the event archive nav menu metabox. It receives a menu_item array with |
|
513 | - * the properties and converts it to the menu item object. |
|
514 | - * |
|
515 | - * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php |
|
516 | - * @param $menu_item_values |
|
517 | - * @return stdClass |
|
518 | - */ |
|
519 | - private function _setup_extra_nav_menu_pages_items($menu_item_values) |
|
520 | - { |
|
521 | - $menu_item = new stdClass(); |
|
522 | - $keys = array( |
|
523 | - 'ID' => 0, |
|
524 | - 'db_id' => 0, |
|
525 | - 'menu_item_parent' => 0, |
|
526 | - 'object_id' => -1, |
|
527 | - 'post_parent' => 0, |
|
528 | - 'type' => 'custom', |
|
529 | - 'object' => '', |
|
530 | - 'type_label' => esc_html__('Extra Nav Menu Item', 'event_espresso'), |
|
531 | - 'title' => '', |
|
532 | - 'url' => '', |
|
533 | - 'target' => '', |
|
534 | - 'attr_title' => '', |
|
535 | - 'description' => '', |
|
536 | - 'classes' => array(), |
|
537 | - 'xfn' => '', |
|
538 | - ); |
|
539 | - |
|
540 | - foreach ($keys as $key => $value) { |
|
541 | - $menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value; |
|
542 | - } |
|
543 | - return $menu_item; |
|
544 | - } |
|
545 | - |
|
546 | - |
|
547 | - /** |
|
548 | - * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an |
|
549 | - * EE_Admin_Page route is called. |
|
550 | - * |
|
551 | - * @return void |
|
552 | - */ |
|
553 | - public function route_admin_request() |
|
554 | - { |
|
555 | - } |
|
556 | - |
|
557 | - |
|
558 | - /** |
|
559 | - * wp_loaded should fire on the WordPress wp_loaded hook. This fires on a VERY late priority. |
|
560 | - * |
|
561 | - * @return void |
|
562 | - */ |
|
563 | - public function wp_loaded() |
|
564 | - { |
|
565 | - } |
|
566 | - |
|
567 | - |
|
568 | - /** |
|
569 | - * admin_init |
|
570 | - * |
|
571 | - * @return void |
|
572 | - * @throws EE_Error |
|
573 | - * @throws InvalidArgumentException |
|
574 | - * @throws InvalidDataTypeException |
|
575 | - * @throws InvalidInterfaceException |
|
576 | - * @throws ReflectionException |
|
577 | - */ |
|
578 | - public function admin_init() |
|
579 | - { |
|
580 | - |
|
581 | - /** |
|
582 | - * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php), |
|
583 | - * so any hooking into core WP routes is taken care of. So in this next few lines of code: |
|
584 | - * - check if doing post processing. |
|
585 | - * - check if doing post processing of one of EE CPTs |
|
586 | - * - instantiate the corresponding EE CPT model for the post_type being processed. |
|
587 | - */ |
|
588 | - if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') { |
|
589 | - EE_Registry::instance()->load_core('Register_CPTs'); |
|
590 | - EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']); |
|
591 | - } |
|
592 | - |
|
593 | - |
|
594 | - /** |
|
595 | - * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting |
|
596 | - * critical pages. The only place critical pages need included in a generated dropdown is on the "Critical |
|
597 | - * Pages" tab in the EE General Settings Admin page. |
|
598 | - * This is for user-proofing. |
|
599 | - */ |
|
600 | - add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages')); |
|
601 | - } |
|
602 | - |
|
603 | - |
|
604 | - /** |
|
605 | - * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection. |
|
606 | - * |
|
607 | - * @param string $output Current output. |
|
608 | - * @return string |
|
609 | - * @throws InvalidArgumentException |
|
610 | - * @throws InvalidDataTypeException |
|
611 | - * @throws InvalidInterfaceException |
|
612 | - */ |
|
613 | - public function modify_dropdown_pages($output) |
|
614 | - { |
|
615 | - //get critical pages |
|
616 | - $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
617 | - |
|
618 | - //split current output by line break for easier parsing. |
|
619 | - $split_output = explode("\n", $output); |
|
620 | - |
|
621 | - //loop through to remove any critical pages from the array. |
|
622 | - foreach ($critical_pages as $page_id) { |
|
623 | - $needle = 'value="' . $page_id . '"'; |
|
624 | - foreach ($split_output as $key => $haystack) { |
|
625 | - if (strpos($haystack, $needle) !== false) { |
|
626 | - unset($split_output[$key]); |
|
627 | - } |
|
628 | - } |
|
629 | - } |
|
630 | - //replace output with the new contents |
|
631 | - return implode("\n", $split_output); |
|
632 | - } |
|
633 | - |
|
634 | - |
|
635 | - /** |
|
636 | - * enqueue all admin scripts that need loaded for admin pages |
|
637 | - * |
|
638 | - * @return void |
|
639 | - */ |
|
640 | - public function enqueue_admin_scripts() |
|
641 | - { |
|
642 | - // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js. |
|
643 | - // Note: the intention of this script is to only do TARGETED injections. I.E, only injecting on certain script |
|
644 | - // calls. |
|
645 | - wp_enqueue_script( |
|
646 | - 'ee-inject-wp', |
|
647 | - EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js', |
|
648 | - array('jquery'), |
|
649 | - EVENT_ESPRESSO_VERSION, |
|
650 | - true |
|
651 | - ); |
|
652 | - // register cookie script for future dependencies |
|
653 | - wp_register_script( |
|
654 | - 'jquery-cookie', |
|
655 | - EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', |
|
656 | - array('jquery'), |
|
657 | - '2.1', |
|
658 | - true |
|
659 | - ); |
|
660 | - //joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again |
|
661 | - // via: add_filter('FHEE_load_joyride', '__return_true' ); |
|
662 | - if (apply_filters('FHEE_load_joyride', false)) { |
|
663 | - //joyride style |
|
664 | - wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1'); |
|
665 | - wp_register_style( |
|
666 | - 'ee-joyride-css', |
|
667 | - EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css', |
|
668 | - array('joyride-css'), |
|
669 | - EVENT_ESPRESSO_VERSION |
|
670 | - ); |
|
671 | - wp_register_script( |
|
672 | - 'joyride-modernizr', |
|
673 | - EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js', |
|
674 | - array(), |
|
675 | - '2.1', |
|
676 | - true |
|
677 | - ); |
|
678 | - //joyride JS |
|
679 | - wp_register_script( |
|
680 | - 'jquery-joyride', |
|
681 | - EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js', |
|
682 | - array('jquery-cookie', 'joyride-modernizr'), |
|
683 | - '2.1', |
|
684 | - true |
|
685 | - ); |
|
686 | - // wanna go for a joyride? |
|
687 | - wp_enqueue_style('ee-joyride-css'); |
|
688 | - wp_enqueue_script('jquery-joyride'); |
|
689 | - } |
|
690 | - } |
|
691 | - |
|
692 | - |
|
693 | - /** |
|
694 | - * display_admin_notices |
|
695 | - * |
|
696 | - * @return void |
|
697 | - */ |
|
698 | - public function display_admin_notices() |
|
699 | - { |
|
700 | - echo EE_Error::get_notices(); |
|
701 | - } |
|
702 | - |
|
703 | - |
|
704 | - |
|
705 | - /** |
|
706 | - * @param array $elements |
|
707 | - * @return array |
|
708 | - * @throws EE_Error |
|
709 | - * @throws InvalidArgumentException |
|
710 | - * @throws InvalidDataTypeException |
|
711 | - * @throws InvalidInterfaceException |
|
712 | - */ |
|
713 | - public function dashboard_glance_items($elements) |
|
714 | - { |
|
715 | - $elements = is_array($elements) ? $elements : array($elements); |
|
716 | - $events = EEM_Event::instance()->count(); |
|
717 | - $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
718 | - array('page' => 'espresso_events'), |
|
719 | - admin_url('admin.php') |
|
720 | - ); |
|
721 | - $items['events']['text'] = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events)); |
|
722 | - $items['events']['title'] = esc_html__('Click to view all Events', 'event_espresso'); |
|
723 | - $registrations = EEM_Registration::instance()->count( |
|
724 | - array( |
|
725 | - array( |
|
726 | - 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), |
|
727 | - ), |
|
728 | - ) |
|
729 | - ); |
|
730 | - $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
731 | - array('page' => 'espresso_registrations'), |
|
732 | - admin_url('admin.php') |
|
733 | - ); |
|
734 | - $items['registrations']['text'] = sprintf( |
|
735 | - _n('%s Registration', '%s Registrations', $registrations), |
|
736 | - number_format_i18n($registrations) |
|
737 | - ); |
|
738 | - $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso'); |
|
739 | - |
|
740 | - $items = (array)apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); |
|
741 | - |
|
742 | - foreach ($items as $type => $item_properties) { |
|
743 | - $elements[] = sprintf( |
|
744 | - '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', |
|
745 | - $item_properties['url'], |
|
746 | - $item_properties['title'], |
|
747 | - $item_properties['text'] |
|
748 | - ); |
|
749 | - } |
|
750 | - return $elements; |
|
751 | - } |
|
752 | - |
|
753 | - |
|
754 | - /** |
|
755 | - * check_for_invalid_datetime_formats |
|
756 | - * if an admin changes their date or time format settings on the WP General Settings admin page, verify that |
|
757 | - * their selected format can be parsed by PHP |
|
758 | - * |
|
759 | - * @param $value |
|
760 | - * @param $option |
|
761 | - * @throws EE_Error |
|
762 | - * @return string |
|
763 | - */ |
|
764 | - public function check_for_invalid_datetime_formats($value, $option) |
|
765 | - { |
|
766 | - // check for date_format or time_format |
|
767 | - switch ($option) { |
|
768 | - case 'date_format': |
|
769 | - $date_time_format = $value . ' ' . get_option('time_format'); |
|
770 | - break; |
|
771 | - case 'time_format': |
|
772 | - $date_time_format = get_option('date_format') . ' ' . $value; |
|
773 | - break; |
|
774 | - default: |
|
775 | - $date_time_format = false; |
|
776 | - } |
|
777 | - // do we have a date_time format to check ? |
|
778 | - if ($date_time_format) { |
|
779 | - $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format); |
|
780 | - |
|
781 | - if (is_array($error_msg)) { |
|
782 | - $msg = '<p>' |
|
783 | - . sprintf( |
|
784 | - esc_html__( |
|
785 | - 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', |
|
786 | - 'event_espresso' |
|
787 | - ), |
|
788 | - date($date_time_format), |
|
789 | - $date_time_format |
|
790 | - ) |
|
791 | - . '</p><p><ul>'; |
|
792 | - |
|
793 | - |
|
794 | - foreach ($error_msg as $error) { |
|
795 | - $msg .= '<li>' . $error . '</li>'; |
|
796 | - } |
|
797 | - |
|
798 | - $msg .= '</ul></p><p>' |
|
799 | - . sprintf( |
|
800 | - esc_html__( |
|
801 | - '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', |
|
802 | - 'event_espresso' |
|
803 | - ), |
|
804 | - '<span style="color:#D54E21;">', |
|
805 | - '</span>' |
|
806 | - ) |
|
807 | - . '</p>'; |
|
808 | - |
|
809 | - // trigger WP settings error |
|
810 | - add_settings_error( |
|
811 | - 'date_format', |
|
812 | - 'date_format', |
|
813 | - $msg |
|
814 | - ); |
|
815 | - |
|
816 | - // set format to something valid |
|
817 | - switch ($option) { |
|
818 | - case 'date_format': |
|
819 | - $value = 'F j, Y'; |
|
820 | - break; |
|
821 | - case 'time_format': |
|
822 | - $value = 'g:i a'; |
|
823 | - break; |
|
824 | - } |
|
825 | - } |
|
826 | - } |
|
827 | - return $value; |
|
828 | - } |
|
829 | - |
|
830 | - |
|
831 | - /** |
|
832 | - * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso" |
|
833 | - * |
|
834 | - * @param $content |
|
835 | - * @return string |
|
836 | - */ |
|
837 | - public function its_eSpresso($content) |
|
838 | - { |
|
839 | - return str_replace('[EXPRESSO_', '[ESPRESSO_', $content); |
|
840 | - } |
|
841 | - |
|
842 | - |
|
843 | - /** |
|
844 | - * espresso_admin_footer |
|
845 | - * |
|
846 | - * @return string |
|
847 | - */ |
|
848 | - public function espresso_admin_footer() |
|
849 | - { |
|
850 | - return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer')); |
|
851 | - } |
|
852 | - |
|
853 | - |
|
854 | - /** |
|
855 | - * static method for registering ee admin page. |
|
856 | - * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register. |
|
857 | - * |
|
858 | - * @since 4.3.0 |
|
859 | - * @deprecated 4.3.0 Use EE_Register_Admin_Page::register() instead |
|
860 | - * @see EE_Register_Admin_Page::register() |
|
861 | - * @param $page_basename |
|
862 | - * @param $page_path |
|
863 | - * @param array $config |
|
864 | - * @return void |
|
865 | - * @throws EE_Error |
|
866 | - */ |
|
867 | - public static function register_ee_admin_page($page_basename, $page_path, $config = array()) |
|
868 | - { |
|
869 | - EE_Error::doing_it_wrong( |
|
870 | - __METHOD__, |
|
871 | - sprintf( |
|
872 | - esc_html__( |
|
873 | - 'Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.', |
|
874 | - 'event_espresso' |
|
875 | - ), |
|
876 | - $page_basename |
|
877 | - ), |
|
878 | - '4.3' |
|
879 | - ); |
|
880 | - if (class_exists('EE_Register_Admin_Page')) { |
|
881 | - $config['page_path'] = $page_path; |
|
882 | - } |
|
883 | - EE_Register_Admin_Page::register($page_basename, $config); |
|
884 | - } |
|
885 | - |
|
886 | - |
|
887 | - /** |
|
888 | - * @deprecated 4.8.41 |
|
889 | - * @param int $post_ID |
|
890 | - * @param \WP_Post $post |
|
891 | - * @return void |
|
892 | - */ |
|
893 | - public static function parse_post_content_on_save($post_ID, $post) |
|
894 | - { |
|
895 | - EE_Error::doing_it_wrong( |
|
896 | - __METHOD__, |
|
897 | - esc_html__('Usage is deprecated', 'event_espresso'), |
|
898 | - '4.8.41' |
|
899 | - ); |
|
900 | - } |
|
901 | - |
|
902 | - |
|
903 | - /** |
|
904 | - * @deprecated 4.8.41 |
|
905 | - * @param $option |
|
906 | - * @param $old_value |
|
907 | - * @param $value |
|
908 | - * @return void |
|
909 | - */ |
|
910 | - public function reset_page_for_posts_on_change($option, $old_value, $value) |
|
911 | - { |
|
912 | - EE_Error::doing_it_wrong( |
|
913 | - __METHOD__, |
|
914 | - esc_html__('Usage is deprecated', 'event_espresso'), |
|
915 | - '4.8.41' |
|
916 | - ); |
|
917 | - } |
|
918 | - |
|
919 | - |
|
920 | - |
|
921 | - /** |
|
922 | - * @deprecated 4.9.27 |
|
923 | - * @return void |
|
924 | - */ |
|
925 | - public function get_persistent_admin_notices() |
|
926 | - { |
|
927 | - EE_Error::doing_it_wrong( |
|
928 | - __METHOD__, |
|
929 | - sprintf( |
|
930 | - __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
931 | - '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
932 | - ), |
|
933 | - '4.9.27' |
|
934 | - ); |
|
935 | - } |
|
936 | - |
|
937 | - |
|
938 | - |
|
939 | - /** |
|
940 | - * @deprecated 4.9.27 |
|
941 | - * @throws InvalidInterfaceException |
|
942 | - * @throws InvalidDataTypeException |
|
943 | - * @throws DomainException |
|
944 | - */ |
|
945 | - public function dismiss_ee_nag_notice_callback() |
|
946 | - { |
|
947 | - EE_Error::doing_it_wrong( |
|
948 | - __METHOD__, |
|
949 | - sprintf( |
|
950 | - __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
951 | - '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
952 | - ), |
|
953 | - '4.9.27' |
|
954 | - ); |
|
955 | - $this->persistent_admin_notice_manager->dismissNotice(); |
|
956 | - } |
|
957 | - |
|
958 | - |
|
959 | - /** |
|
960 | - * Callback on load-plugins.php hook for setting up anything hooking into the wp plugins page. |
|
961 | - * @throws InvalidArgumentException |
|
962 | - * @throws InvalidDataTypeException |
|
963 | - * @throws InvalidInterfaceException |
|
964 | - */ |
|
965 | - public function hookIntoWpPluginsPage() |
|
966 | - { |
|
967 | - LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\ExitModal'); |
|
968 | - } |
|
490 | + } |
|
491 | + |
|
492 | + |
|
493 | + /** |
|
494 | + * Returns an array of event archive nav items. |
|
495 | + * |
|
496 | + * @todo for now this method is just in place so when it gets abstracted further we can substitute in whatever |
|
497 | + * method we use for getting the extra nav menu items |
|
498 | + * @return array |
|
499 | + */ |
|
500 | + private function _get_extra_nav_menu_pages_items() |
|
501 | + { |
|
502 | + $menuitems[] = array( |
|
503 | + 'title' => esc_html__('Event List', 'event_espresso'), |
|
504 | + 'url' => get_post_type_archive_link('espresso_events'), |
|
505 | + 'description' => esc_html__('Archive page for all events.', 'event_espresso'), |
|
506 | + ); |
|
507 | + return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems); |
|
508 | + } |
|
509 | + |
|
510 | + |
|
511 | + /** |
|
512 | + * Setup nav menu walker item for usage in the event archive nav menu metabox. It receives a menu_item array with |
|
513 | + * the properties and converts it to the menu item object. |
|
514 | + * |
|
515 | + * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php |
|
516 | + * @param $menu_item_values |
|
517 | + * @return stdClass |
|
518 | + */ |
|
519 | + private function _setup_extra_nav_menu_pages_items($menu_item_values) |
|
520 | + { |
|
521 | + $menu_item = new stdClass(); |
|
522 | + $keys = array( |
|
523 | + 'ID' => 0, |
|
524 | + 'db_id' => 0, |
|
525 | + 'menu_item_parent' => 0, |
|
526 | + 'object_id' => -1, |
|
527 | + 'post_parent' => 0, |
|
528 | + 'type' => 'custom', |
|
529 | + 'object' => '', |
|
530 | + 'type_label' => esc_html__('Extra Nav Menu Item', 'event_espresso'), |
|
531 | + 'title' => '', |
|
532 | + 'url' => '', |
|
533 | + 'target' => '', |
|
534 | + 'attr_title' => '', |
|
535 | + 'description' => '', |
|
536 | + 'classes' => array(), |
|
537 | + 'xfn' => '', |
|
538 | + ); |
|
539 | + |
|
540 | + foreach ($keys as $key => $value) { |
|
541 | + $menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value; |
|
542 | + } |
|
543 | + return $menu_item; |
|
544 | + } |
|
545 | + |
|
546 | + |
|
547 | + /** |
|
548 | + * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an |
|
549 | + * EE_Admin_Page route is called. |
|
550 | + * |
|
551 | + * @return void |
|
552 | + */ |
|
553 | + public function route_admin_request() |
|
554 | + { |
|
555 | + } |
|
556 | + |
|
557 | + |
|
558 | + /** |
|
559 | + * wp_loaded should fire on the WordPress wp_loaded hook. This fires on a VERY late priority. |
|
560 | + * |
|
561 | + * @return void |
|
562 | + */ |
|
563 | + public function wp_loaded() |
|
564 | + { |
|
565 | + } |
|
566 | + |
|
567 | + |
|
568 | + /** |
|
569 | + * admin_init |
|
570 | + * |
|
571 | + * @return void |
|
572 | + * @throws EE_Error |
|
573 | + * @throws InvalidArgumentException |
|
574 | + * @throws InvalidDataTypeException |
|
575 | + * @throws InvalidInterfaceException |
|
576 | + * @throws ReflectionException |
|
577 | + */ |
|
578 | + public function admin_init() |
|
579 | + { |
|
580 | + |
|
581 | + /** |
|
582 | + * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php), |
|
583 | + * so any hooking into core WP routes is taken care of. So in this next few lines of code: |
|
584 | + * - check if doing post processing. |
|
585 | + * - check if doing post processing of one of EE CPTs |
|
586 | + * - instantiate the corresponding EE CPT model for the post_type being processed. |
|
587 | + */ |
|
588 | + if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') { |
|
589 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
590 | + EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']); |
|
591 | + } |
|
592 | + |
|
593 | + |
|
594 | + /** |
|
595 | + * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting |
|
596 | + * critical pages. The only place critical pages need included in a generated dropdown is on the "Critical |
|
597 | + * Pages" tab in the EE General Settings Admin page. |
|
598 | + * This is for user-proofing. |
|
599 | + */ |
|
600 | + add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages')); |
|
601 | + } |
|
602 | + |
|
603 | + |
|
604 | + /** |
|
605 | + * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection. |
|
606 | + * |
|
607 | + * @param string $output Current output. |
|
608 | + * @return string |
|
609 | + * @throws InvalidArgumentException |
|
610 | + * @throws InvalidDataTypeException |
|
611 | + * @throws InvalidInterfaceException |
|
612 | + */ |
|
613 | + public function modify_dropdown_pages($output) |
|
614 | + { |
|
615 | + //get critical pages |
|
616 | + $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
617 | + |
|
618 | + //split current output by line break for easier parsing. |
|
619 | + $split_output = explode("\n", $output); |
|
620 | + |
|
621 | + //loop through to remove any critical pages from the array. |
|
622 | + foreach ($critical_pages as $page_id) { |
|
623 | + $needle = 'value="' . $page_id . '"'; |
|
624 | + foreach ($split_output as $key => $haystack) { |
|
625 | + if (strpos($haystack, $needle) !== false) { |
|
626 | + unset($split_output[$key]); |
|
627 | + } |
|
628 | + } |
|
629 | + } |
|
630 | + //replace output with the new contents |
|
631 | + return implode("\n", $split_output); |
|
632 | + } |
|
633 | + |
|
634 | + |
|
635 | + /** |
|
636 | + * enqueue all admin scripts that need loaded for admin pages |
|
637 | + * |
|
638 | + * @return void |
|
639 | + */ |
|
640 | + public function enqueue_admin_scripts() |
|
641 | + { |
|
642 | + // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js. |
|
643 | + // Note: the intention of this script is to only do TARGETED injections. I.E, only injecting on certain script |
|
644 | + // calls. |
|
645 | + wp_enqueue_script( |
|
646 | + 'ee-inject-wp', |
|
647 | + EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js', |
|
648 | + array('jquery'), |
|
649 | + EVENT_ESPRESSO_VERSION, |
|
650 | + true |
|
651 | + ); |
|
652 | + // register cookie script for future dependencies |
|
653 | + wp_register_script( |
|
654 | + 'jquery-cookie', |
|
655 | + EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', |
|
656 | + array('jquery'), |
|
657 | + '2.1', |
|
658 | + true |
|
659 | + ); |
|
660 | + //joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again |
|
661 | + // via: add_filter('FHEE_load_joyride', '__return_true' ); |
|
662 | + if (apply_filters('FHEE_load_joyride', false)) { |
|
663 | + //joyride style |
|
664 | + wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1'); |
|
665 | + wp_register_style( |
|
666 | + 'ee-joyride-css', |
|
667 | + EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css', |
|
668 | + array('joyride-css'), |
|
669 | + EVENT_ESPRESSO_VERSION |
|
670 | + ); |
|
671 | + wp_register_script( |
|
672 | + 'joyride-modernizr', |
|
673 | + EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js', |
|
674 | + array(), |
|
675 | + '2.1', |
|
676 | + true |
|
677 | + ); |
|
678 | + //joyride JS |
|
679 | + wp_register_script( |
|
680 | + 'jquery-joyride', |
|
681 | + EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js', |
|
682 | + array('jquery-cookie', 'joyride-modernizr'), |
|
683 | + '2.1', |
|
684 | + true |
|
685 | + ); |
|
686 | + // wanna go for a joyride? |
|
687 | + wp_enqueue_style('ee-joyride-css'); |
|
688 | + wp_enqueue_script('jquery-joyride'); |
|
689 | + } |
|
690 | + } |
|
691 | + |
|
692 | + |
|
693 | + /** |
|
694 | + * display_admin_notices |
|
695 | + * |
|
696 | + * @return void |
|
697 | + */ |
|
698 | + public function display_admin_notices() |
|
699 | + { |
|
700 | + echo EE_Error::get_notices(); |
|
701 | + } |
|
702 | + |
|
703 | + |
|
704 | + |
|
705 | + /** |
|
706 | + * @param array $elements |
|
707 | + * @return array |
|
708 | + * @throws EE_Error |
|
709 | + * @throws InvalidArgumentException |
|
710 | + * @throws InvalidDataTypeException |
|
711 | + * @throws InvalidInterfaceException |
|
712 | + */ |
|
713 | + public function dashboard_glance_items($elements) |
|
714 | + { |
|
715 | + $elements = is_array($elements) ? $elements : array($elements); |
|
716 | + $events = EEM_Event::instance()->count(); |
|
717 | + $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
718 | + array('page' => 'espresso_events'), |
|
719 | + admin_url('admin.php') |
|
720 | + ); |
|
721 | + $items['events']['text'] = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events)); |
|
722 | + $items['events']['title'] = esc_html__('Click to view all Events', 'event_espresso'); |
|
723 | + $registrations = EEM_Registration::instance()->count( |
|
724 | + array( |
|
725 | + array( |
|
726 | + 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), |
|
727 | + ), |
|
728 | + ) |
|
729 | + ); |
|
730 | + $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
731 | + array('page' => 'espresso_registrations'), |
|
732 | + admin_url('admin.php') |
|
733 | + ); |
|
734 | + $items['registrations']['text'] = sprintf( |
|
735 | + _n('%s Registration', '%s Registrations', $registrations), |
|
736 | + number_format_i18n($registrations) |
|
737 | + ); |
|
738 | + $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso'); |
|
739 | + |
|
740 | + $items = (array)apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); |
|
741 | + |
|
742 | + foreach ($items as $type => $item_properties) { |
|
743 | + $elements[] = sprintf( |
|
744 | + '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', |
|
745 | + $item_properties['url'], |
|
746 | + $item_properties['title'], |
|
747 | + $item_properties['text'] |
|
748 | + ); |
|
749 | + } |
|
750 | + return $elements; |
|
751 | + } |
|
752 | + |
|
753 | + |
|
754 | + /** |
|
755 | + * check_for_invalid_datetime_formats |
|
756 | + * if an admin changes their date or time format settings on the WP General Settings admin page, verify that |
|
757 | + * their selected format can be parsed by PHP |
|
758 | + * |
|
759 | + * @param $value |
|
760 | + * @param $option |
|
761 | + * @throws EE_Error |
|
762 | + * @return string |
|
763 | + */ |
|
764 | + public function check_for_invalid_datetime_formats($value, $option) |
|
765 | + { |
|
766 | + // check for date_format or time_format |
|
767 | + switch ($option) { |
|
768 | + case 'date_format': |
|
769 | + $date_time_format = $value . ' ' . get_option('time_format'); |
|
770 | + break; |
|
771 | + case 'time_format': |
|
772 | + $date_time_format = get_option('date_format') . ' ' . $value; |
|
773 | + break; |
|
774 | + default: |
|
775 | + $date_time_format = false; |
|
776 | + } |
|
777 | + // do we have a date_time format to check ? |
|
778 | + if ($date_time_format) { |
|
779 | + $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format); |
|
780 | + |
|
781 | + if (is_array($error_msg)) { |
|
782 | + $msg = '<p>' |
|
783 | + . sprintf( |
|
784 | + esc_html__( |
|
785 | + 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', |
|
786 | + 'event_espresso' |
|
787 | + ), |
|
788 | + date($date_time_format), |
|
789 | + $date_time_format |
|
790 | + ) |
|
791 | + . '</p><p><ul>'; |
|
792 | + |
|
793 | + |
|
794 | + foreach ($error_msg as $error) { |
|
795 | + $msg .= '<li>' . $error . '</li>'; |
|
796 | + } |
|
797 | + |
|
798 | + $msg .= '</ul></p><p>' |
|
799 | + . sprintf( |
|
800 | + esc_html__( |
|
801 | + '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', |
|
802 | + 'event_espresso' |
|
803 | + ), |
|
804 | + '<span style="color:#D54E21;">', |
|
805 | + '</span>' |
|
806 | + ) |
|
807 | + . '</p>'; |
|
808 | + |
|
809 | + // trigger WP settings error |
|
810 | + add_settings_error( |
|
811 | + 'date_format', |
|
812 | + 'date_format', |
|
813 | + $msg |
|
814 | + ); |
|
815 | + |
|
816 | + // set format to something valid |
|
817 | + switch ($option) { |
|
818 | + case 'date_format': |
|
819 | + $value = 'F j, Y'; |
|
820 | + break; |
|
821 | + case 'time_format': |
|
822 | + $value = 'g:i a'; |
|
823 | + break; |
|
824 | + } |
|
825 | + } |
|
826 | + } |
|
827 | + return $value; |
|
828 | + } |
|
829 | + |
|
830 | + |
|
831 | + /** |
|
832 | + * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso" |
|
833 | + * |
|
834 | + * @param $content |
|
835 | + * @return string |
|
836 | + */ |
|
837 | + public function its_eSpresso($content) |
|
838 | + { |
|
839 | + return str_replace('[EXPRESSO_', '[ESPRESSO_', $content); |
|
840 | + } |
|
841 | + |
|
842 | + |
|
843 | + /** |
|
844 | + * espresso_admin_footer |
|
845 | + * |
|
846 | + * @return string |
|
847 | + */ |
|
848 | + public function espresso_admin_footer() |
|
849 | + { |
|
850 | + return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer')); |
|
851 | + } |
|
852 | + |
|
853 | + |
|
854 | + /** |
|
855 | + * static method for registering ee admin page. |
|
856 | + * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register. |
|
857 | + * |
|
858 | + * @since 4.3.0 |
|
859 | + * @deprecated 4.3.0 Use EE_Register_Admin_Page::register() instead |
|
860 | + * @see EE_Register_Admin_Page::register() |
|
861 | + * @param $page_basename |
|
862 | + * @param $page_path |
|
863 | + * @param array $config |
|
864 | + * @return void |
|
865 | + * @throws EE_Error |
|
866 | + */ |
|
867 | + public static function register_ee_admin_page($page_basename, $page_path, $config = array()) |
|
868 | + { |
|
869 | + EE_Error::doing_it_wrong( |
|
870 | + __METHOD__, |
|
871 | + sprintf( |
|
872 | + esc_html__( |
|
873 | + 'Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.', |
|
874 | + 'event_espresso' |
|
875 | + ), |
|
876 | + $page_basename |
|
877 | + ), |
|
878 | + '4.3' |
|
879 | + ); |
|
880 | + if (class_exists('EE_Register_Admin_Page')) { |
|
881 | + $config['page_path'] = $page_path; |
|
882 | + } |
|
883 | + EE_Register_Admin_Page::register($page_basename, $config); |
|
884 | + } |
|
885 | + |
|
886 | + |
|
887 | + /** |
|
888 | + * @deprecated 4.8.41 |
|
889 | + * @param int $post_ID |
|
890 | + * @param \WP_Post $post |
|
891 | + * @return void |
|
892 | + */ |
|
893 | + public static function parse_post_content_on_save($post_ID, $post) |
|
894 | + { |
|
895 | + EE_Error::doing_it_wrong( |
|
896 | + __METHOD__, |
|
897 | + esc_html__('Usage is deprecated', 'event_espresso'), |
|
898 | + '4.8.41' |
|
899 | + ); |
|
900 | + } |
|
901 | + |
|
902 | + |
|
903 | + /** |
|
904 | + * @deprecated 4.8.41 |
|
905 | + * @param $option |
|
906 | + * @param $old_value |
|
907 | + * @param $value |
|
908 | + * @return void |
|
909 | + */ |
|
910 | + public function reset_page_for_posts_on_change($option, $old_value, $value) |
|
911 | + { |
|
912 | + EE_Error::doing_it_wrong( |
|
913 | + __METHOD__, |
|
914 | + esc_html__('Usage is deprecated', 'event_espresso'), |
|
915 | + '4.8.41' |
|
916 | + ); |
|
917 | + } |
|
918 | + |
|
919 | + |
|
920 | + |
|
921 | + /** |
|
922 | + * @deprecated 4.9.27 |
|
923 | + * @return void |
|
924 | + */ |
|
925 | + public function get_persistent_admin_notices() |
|
926 | + { |
|
927 | + EE_Error::doing_it_wrong( |
|
928 | + __METHOD__, |
|
929 | + sprintf( |
|
930 | + __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
931 | + '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
932 | + ), |
|
933 | + '4.9.27' |
|
934 | + ); |
|
935 | + } |
|
936 | + |
|
937 | + |
|
938 | + |
|
939 | + /** |
|
940 | + * @deprecated 4.9.27 |
|
941 | + * @throws InvalidInterfaceException |
|
942 | + * @throws InvalidDataTypeException |
|
943 | + * @throws DomainException |
|
944 | + */ |
|
945 | + public function dismiss_ee_nag_notice_callback() |
|
946 | + { |
|
947 | + EE_Error::doing_it_wrong( |
|
948 | + __METHOD__, |
|
949 | + sprintf( |
|
950 | + __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
951 | + '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
952 | + ), |
|
953 | + '4.9.27' |
|
954 | + ); |
|
955 | + $this->persistent_admin_notice_manager->dismissNotice(); |
|
956 | + } |
|
957 | + |
|
958 | + |
|
959 | + /** |
|
960 | + * Callback on load-plugins.php hook for setting up anything hooking into the wp plugins page. |
|
961 | + * @throws InvalidArgumentException |
|
962 | + * @throws InvalidDataTypeException |
|
963 | + * @throws InvalidInterfaceException |
|
964 | + */ |
|
965 | + public function hookIntoWpPluginsPage() |
|
966 | + { |
|
967 | + LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\ExitModal'); |
|
968 | + } |
|
969 | 969 | } |