@@ -13,31 +13,31 @@ |
||
13 | 13 | */ |
14 | 14 | class ExitModal |
15 | 15 | { |
16 | - /** |
|
17 | - * ExitModal constructor. |
|
18 | - */ |
|
19 | - public function __construct() |
|
20 | - { |
|
21 | - add_action('in_admin_footer', array($this, 'modalContainer')); |
|
22 | - add_action('admin_enqueue_scripts', array($this, 'enqueues')); |
|
23 | - } |
|
16 | + /** |
|
17 | + * ExitModal constructor. |
|
18 | + */ |
|
19 | + public function __construct() |
|
20 | + { |
|
21 | + add_action('in_admin_footer', array($this, 'modalContainer')); |
|
22 | + add_action('admin_enqueue_scripts', array($this, 'enqueues')); |
|
23 | + } |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * Callback on in_admin_footer that is used to output the exit modal container. |
|
28 | - */ |
|
29 | - public function modalContainer() |
|
30 | - { |
|
31 | - echo '<div id="ee-exit-survey-modal"></div>'; |
|
32 | - } |
|
26 | + /** |
|
27 | + * Callback on in_admin_footer that is used to output the exit modal container. |
|
28 | + */ |
|
29 | + public function modalContainer() |
|
30 | + { |
|
31 | + echo '<div id="ee-exit-survey-modal"></div>'; |
|
32 | + } |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * Callback for `admin_enqueue_scripts` to take care of enqueueing scripts and styles specific to the modal. |
|
37 | - */ |
|
38 | - public function enqueues() |
|
39 | - { |
|
40 | - wp_enqueue_script('ee-exit-modal-survey'); |
|
41 | - wp_enqueue_style('ee-exit-modal-survey'); |
|
42 | - } |
|
35 | + /** |
|
36 | + * Callback for `admin_enqueue_scripts` to take care of enqueueing scripts and styles specific to the modal. |
|
37 | + */ |
|
38 | + public function enqueues() |
|
39 | + { |
|
40 | + wp_enqueue_script('ee-exit-modal-survey'); |
|
41 | + wp_enqueue_style('ee-exit-modal-survey'); |
|
42 | + } |
|
43 | 43 | } |
44 | 44 | \ No newline at end of file |
@@ -24,482 +24,482 @@ |
||
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 | - ), |
|
494 | - filemtime($this->domain->distributionAssetsPath() . 'ee-exit-modal-survey.dist.js'), |
|
495 | - true |
|
496 | - ); |
|
497 | - wp_register_style( |
|
498 | - 'ee-exit-modal-survey', |
|
499 | - $this->domain->distributionAssetsUrl() . 'ee-exit-modal-survey.style.css', |
|
500 | - array(), |
|
501 | - filemtime($this->domain->distributionAssetsPath() . 'ee-exit-modal-survey.style.css') |
|
502 | - ); |
|
503 | - } |
|
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 | + ), |
|
494 | + filemtime($this->domain->distributionAssetsPath() . 'ee-exit-modal-survey.dist.js'), |
|
495 | + true |
|
496 | + ); |
|
497 | + wp_register_style( |
|
498 | + 'ee-exit-modal-survey', |
|
499 | + $this->domain->distributionAssetsUrl() . 'ee-exit-modal-survey.style.css', |
|
500 | + array(), |
|
501 | + filemtime($this->domain->distributionAssetsPath() . 'ee-exit-modal-survey.style.css') |
|
502 | + ); |
|
503 | + } |
|
504 | 504 | |
505 | 505 | } |
@@ -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,18 +487,18 @@ 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 | ), |
494 | - filemtime($this->domain->distributionAssetsPath() . 'ee-exit-modal-survey.dist.js'), |
|
494 | + filemtime($this->domain->distributionAssetsPath().'ee-exit-modal-survey.dist.js'), |
|
495 | 495 | true |
496 | 496 | ); |
497 | 497 | wp_register_style( |
498 | 498 | 'ee-exit-modal-survey', |
499 | - $this->domain->distributionAssetsUrl() . 'ee-exit-modal-survey.style.css', |
|
499 | + $this->domain->distributionAssetsUrl().'ee-exit-modal-survey.style.css', |
|
500 | 500 | array(), |
501 | - filemtime($this->domain->distributionAssetsPath() . 'ee-exit-modal-survey.style.css') |
|
501 | + filemtime($this->domain->distributionAssetsPath().'ee-exit-modal-survey.style.css') |
|
502 | 502 | ); |
503 | 503 | } |
504 | 504 |
@@ -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,480 +487,480 @@ 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 | - */ |
|
962 | - public function hookIntoWpPluginsPage() |
|
963 | - { |
|
964 | - new ExitModal(); |
|
965 | - } |
|
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 | + */ |
|
962 | + public function hookIntoWpPluginsPage() |
|
963 | + { |
|
964 | + new ExitModal(); |
|
965 | + } |
|
966 | 966 | } |