@@ -222,7 +222,7 @@ |
||
222 | 222 | /** |
223 | 223 | * constructor |
224 | 224 | * |
225 | - * @param EE_Admin_Page $admin_page the calling admin_page_object |
|
225 | + * @param EE_Admin_Page $adminpage the calling admin_page_object |
|
226 | 226 | */ |
227 | 227 | public function __construct(EE_Admin_Page $adminpage) |
228 | 228 | { |
@@ -13,722 +13,722 @@ |
||
13 | 13 | { |
14 | 14 | |
15 | 15 | |
16 | - /** |
|
17 | - * we're just going to use this to hold the name of the caller class (child class name) |
|
18 | - * |
|
19 | - * @var string |
|
20 | - */ |
|
21 | - public $caller; |
|
22 | - |
|
23 | - |
|
24 | - /** |
|
25 | - * this is just a flag set automatically to indicate whether we've got an extended hook class running (i.e. |
|
26 | - * espresso_events_Registration_Form_Hooks_Extend extends espresso_events_Registration_Form_Hooks). This flag is |
|
27 | - * used later to make sure we require the needed files. |
|
28 | - * |
|
29 | - * @var bool |
|
30 | - */ |
|
31 | - protected $_extend; |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * child classes MUST set this property so that the page object can be loaded correctly |
|
36 | - * |
|
37 | - * @var string |
|
38 | - */ |
|
39 | - protected $_name; |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * This is set by child classes and is an associative array of ajax hooks in the format: |
|
44 | - * array( |
|
45 | - * 'ajax_action_ref' => 'executing_method'; //must be public |
|
46 | - * ) |
|
47 | - * |
|
48 | - * @var array |
|
49 | - */ |
|
50 | - protected $_ajax_func; |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * This is an array of methods that get executed on a page routes admin_init hook. Use the following format: |
|
55 | - * array( |
|
56 | - * 'page_route' => 'executing_method' //must be public |
|
57 | - * ) |
|
58 | - * |
|
59 | - * @var array |
|
60 | - */ |
|
61 | - protected $_init_func; |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * This is an array of methods that output metabox content for the given page route. Use the following format: |
|
66 | - * array( |
|
67 | - * 0 => array( |
|
68 | - * 'page_route' => 'string_for_page_route', //must correspond to a page route in the class being connected |
|
69 | - * with (i.e. "edit_event") If this is in an array then the same params below will be used but the metabox |
|
70 | - * will be added to each route. |
|
71 | - * 'func' => 'executing_method', //must be public (i.e. public function executing_method($post, |
|
72 | - * $callback_args){} ). Note if you include callback args in the array then you need to declare them in the |
|
73 | - * method arguments. |
|
74 | - * 'id' => 'identifier_for_metabox', //so it can be removed by addons (optional, class will set it |
|
75 | - * automatically) |
|
76 | - * 'priority' => 'default', //default 'default' (optional) |
|
77 | - * 'label' => __('Localized Title', 'event_espresso'), |
|
78 | - * 'context' => 'advanced' //advanced is default (optional), |
|
79 | - * 'callback_args' => array() //any callback args to include (optional) |
|
80 | - * ) |
|
81 | - * Why are we indexing numerically? Because it's possible there may be more than one metabox per page_route. |
|
82 | - * |
|
83 | - * @var array |
|
84 | - */ |
|
85 | - protected $_metaboxes; |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * This is an array of values that indicate any metaboxes we want removed from a given page route. Usually this is |
|
90 | - * used when caffeinated functionality is replacing decaffeinated functionality. Use the following format for the |
|
91 | - * array: array( |
|
92 | - * 0 => array( |
|
93 | - * 'page_route' => 'string_for_page_route' //can be string or array of strings that match a page_route(s) |
|
94 | - * that are in the class being connected with (i.e. 'edit', or 'create_new'). |
|
95 | - * 'id' => 'identifier_for_metabox', //what the id is of the metabox being removed |
|
96 | - * 'context' => 'normal', //the context for the metabox being removed (has to match) |
|
97 | - * 'screen' => 'screen_id', //(optional), if not included then this class will attempt to remove the metabox |
|
98 | - * using the currently loaded screen object->id however, there may be cases where you have to specify the |
|
99 | - * id for the screen the metabox is on. |
|
100 | - * ) |
|
101 | - * ) |
|
102 | - * |
|
103 | - * @var array |
|
104 | - */ |
|
105 | - protected $_remove_metaboxes; |
|
106 | - |
|
107 | - |
|
108 | - /** |
|
109 | - * This parent class takes care of loading the scripts and styles if the child class has set the properties for |
|
110 | - * them in the following format. Note, the first array index ('register') is for defining all the registers. The |
|
111 | - * second array index is for indicating what routes each script/style loads on. array( |
|
112 | - * 'registers' => array( |
|
113 | - * 'script_ref' => array( // if more than one script is to be loaded its best to use the 'dependency' |
|
114 | - * argument to link scripts together. |
|
115 | - * 'type' => 'js' // 'js' or 'css' (defaults to js). This tells us what type of wp_function to use |
|
116 | - * 'url' => 'http://urltoscript.css.js', |
|
117 | - * 'depends' => array('jquery'), //an array of dependencies for the scripts. REMEMBER, if a script has |
|
118 | - * already been registered elsewhere in the system. You can just use the depends array to make sure it |
|
119 | - * gets loaded before the one you are setting here. |
|
120 | - * 'footer' => TRUE //defaults to true (styles don't use this parameter) |
|
121 | - * ), |
|
122 | - * 'enqueues' => array( //this time each key corresponds to the script ref followed by an array of page routes |
|
123 | - * the script gets enqueued on. |
|
124 | - * 'script_ref' => array('route_one', 'route_two') |
|
125 | - * ), |
|
126 | - * 'localize' => array( //this allows you to set a localize object. Indicate which script the object is being |
|
127 | - * attached to and then include an array indexed by the name of the object and the array of key/value pairs for |
|
128 | - * the object. |
|
129 | - * 'scrip_ref' => array( |
|
130 | - * 'NAME_OF_JS_OBJECT' => array( |
|
131 | - * 'translate_ref' => __('localized_string', 'event_espresso'), |
|
132 | - * 'some_data' => 5 |
|
133 | - * ) |
|
134 | - * ) |
|
135 | - * ) |
|
136 | - * ) |
|
137 | - * |
|
138 | - * @var array |
|
139 | - */ |
|
140 | - protected $_scripts_styles; |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * This is a property that will contain the current route. |
|
145 | - * |
|
146 | - * @var string; |
|
147 | - */ |
|
148 | - protected $_current_route; |
|
149 | - |
|
150 | - |
|
151 | - /** |
|
152 | - * this optional property can be set by child classes to override the priority for the automatic action/filter hook |
|
153 | - * loading in the `_load_routed_hooks()` method. Please follow this format: array( |
|
154 | - * 'wp_hook_reference' => 1 |
|
155 | - * ) |
|
156 | - * ) |
|
157 | - * |
|
158 | - * @var array |
|
159 | - */ |
|
160 | - protected $_wp_action_filters_priority; |
|
161 | - |
|
162 | - |
|
163 | - /** |
|
164 | - * This just holds a merged array of the $_POST and $_GET vars in favor of $_POST |
|
165 | - * |
|
166 | - * @var array |
|
167 | - */ |
|
168 | - protected $_req_data; |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * This just holds an instance of the page object for this hook |
|
173 | - * |
|
174 | - * @var EE_Admin_Page |
|
175 | - */ |
|
176 | - protected $_page_object; |
|
177 | - |
|
178 | - |
|
179 | - /** |
|
180 | - * This holds the EE_Admin_Page object from the calling admin page that this object hooks into. |
|
181 | - * |
|
182 | - * @var EE_Admin_Page|EE_Admin_Page_CPT |
|
183 | - */ |
|
184 | - protected $_adminpage_obj; |
|
185 | - |
|
186 | - |
|
187 | - /** |
|
188 | - * Holds EE_Registry object |
|
189 | - * |
|
190 | - * @var EE_Registry |
|
191 | - */ |
|
192 | - protected $EE = null; |
|
193 | - |
|
194 | - |
|
195 | - /** |
|
196 | - * constructor |
|
197 | - * |
|
198 | - * @param EE_Admin_Page $admin_page the calling admin_page_object |
|
199 | - */ |
|
200 | - public function __construct(EE_Admin_Page $adminpage) |
|
201 | - { |
|
202 | - |
|
203 | - $this->_adminpage_obj = $adminpage; |
|
204 | - $this->_req_data = array_merge($_GET, $_POST); |
|
205 | - $this->_set_defaults(); |
|
206 | - $this->_set_hooks_properties(); |
|
207 | - // first let's verify we're on the right page |
|
208 | - if (! isset($this->_req_data['page']) |
|
209 | - || (isset($this->_req_data['page']) |
|
210 | - && $this->_adminpage_obj->page_slug |
|
211 | - != $this->_req_data['page'])) { |
|
212 | - return; |
|
213 | - } //get out nothing more to be done here. |
|
214 | - // allow for extends to modify properties |
|
215 | - if (method_exists($this, '_extend_properties')) { |
|
216 | - $this->_extend_properties(); |
|
217 | - } |
|
218 | - $this->_set_page_object(); |
|
219 | - $this->_init_hooks(); |
|
220 | - $this->_load_custom_methods(); |
|
221 | - $this->_load_routed_hooks(); |
|
222 | - add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts_styles')); |
|
223 | - add_action('admin_enqueue_scripts', array($this, 'add_metaboxes'), 20); |
|
224 | - add_action('admin_enqueue_scripts', array($this, 'remove_metaboxes'), 15); |
|
225 | - $this->_ajax_hooks(); |
|
226 | - } |
|
227 | - |
|
228 | - |
|
229 | - /** |
|
230 | - * used by child classes to set the following properties: |
|
231 | - * $_ajax_func (optional) |
|
232 | - * $_init_func (optional) |
|
233 | - * $_metaboxes (optional) |
|
234 | - * $_scripts (optional) |
|
235 | - * $_styles (optional) |
|
236 | - * $_name (required) |
|
237 | - * Also in this method will be registered any scripts or styles loaded on the targeted page (as indicated in the |
|
238 | - * _scripts/_styles properties) Also children should place in this method any filters/actions that have to happen |
|
239 | - * really early on page load (just after admin_init) if they want to have them registered for handling early. |
|
240 | - * |
|
241 | - * @access protected |
|
242 | - * @abstract |
|
243 | - * @return void |
|
244 | - */ |
|
245 | - abstract protected function _set_hooks_properties(); |
|
246 | - |
|
247 | - |
|
248 | - /** |
|
249 | - * The hooks for enqueue_scripts and enqueue_styles will be run in here. Child classes need to define their |
|
250 | - * scripts and styles in the relevant $_scripts and $_styles properties. Child classes must have also already |
|
251 | - * registered the scripts and styles using wp_register_script and wp_register_style functions. |
|
252 | - * |
|
253 | - * @access public |
|
254 | - * @return void |
|
255 | - */ |
|
256 | - public function enqueue_scripts_styles() |
|
257 | - { |
|
258 | - |
|
259 | - if (! empty($this->_scripts_styles)) { |
|
260 | - // first let's do all the registrations |
|
261 | - if (! isset($this->_scripts_styles['registers'])) { |
|
262 | - $msg[] = __( |
|
263 | - 'There is no "registers" index in the <code>$this->_scripts_styles</code> property.', |
|
264 | - 'event_espresso' |
|
265 | - ); |
|
266 | - $msg[] = sprintf( |
|
267 | - __( |
|
268 | - 'Make sure you read the phpdoc comments above the definition of the $_scripts_styles property in the <code>EE_Admin_Hooks</code> class and modify according in the %s child', |
|
269 | - 'event_espresso' |
|
270 | - ), |
|
271 | - '<strong>' . $this->caller . '</strong>' |
|
272 | - ); |
|
273 | - throw new EE_Error(implode('||', $msg)); |
|
274 | - } |
|
275 | - foreach ($this->_scripts_styles['registers'] as $ref => $details) { |
|
276 | - $defaults = array( |
|
277 | - 'type' => 'js', |
|
278 | - 'url' => '', |
|
279 | - 'depends' => array(), |
|
280 | - 'version' => EVENT_ESPRESSO_VERSION, |
|
281 | - 'footer' => true, |
|
282 | - ); |
|
283 | - $details = wp_parse_args($details, $defaults); |
|
284 | - extract($details); |
|
285 | - // let's make sure that we set the 'registers' type if it's not set! We need it later to determine whhich enqueu we do |
|
286 | - $this->_scripts_styles['registers'][ $ref ]['type'] = $type; |
|
287 | - // let's make sure we're not missing any REQUIRED parameters |
|
288 | - if (empty($url)) { |
|
289 | - $msg[] = sprintf( |
|
290 | - __('Missing the url for the requested %s', 'event_espresso'), |
|
291 | - $type == 'js' ? 'script' : 'stylesheet' |
|
292 | - ); |
|
293 | - $msg[] = sprintf( |
|
294 | - __( |
|
295 | - 'Doublecheck your <code>$this->_scripts_styles</code> array in %s and make sure that there is a "url" set for the %s ref', |
|
296 | - 'event_espresso' |
|
297 | - ), |
|
298 | - '<strong>' . $this->caller . '</strong>', |
|
299 | - $ref |
|
300 | - ); |
|
301 | - throw new EE_Error(implode('||', $msg)); |
|
302 | - } |
|
303 | - // made it here so let's do the appropriate registration |
|
304 | - $type == 'js' |
|
305 | - ? wp_register_script($ref, $url, $depends, $version, $footer) |
|
306 | - : wp_register_style( |
|
307 | - $ref, |
|
308 | - $url, |
|
309 | - $depends, |
|
310 | - $version |
|
311 | - ); |
|
312 | - } |
|
313 | - // k now lets do the enqueues |
|
314 | - if (! isset($this->_scripts_styles['enqueues'])) { |
|
315 | - return; |
|
316 | - } //not sure if we should throw an error here or not. |
|
317 | - |
|
318 | - foreach ($this->_scripts_styles['enqueues'] as $ref => $routes) { |
|
319 | - // make sure $routes is an array |
|
320 | - $routes = (array) $routes; |
|
321 | - if (in_array($this->_current_route, $routes)) { |
|
322 | - $this->_scripts_styles['registers'][ $ref ]['type'] == 'js' ? wp_enqueue_script($ref) |
|
323 | - : wp_enqueue_style($ref); |
|
324 | - // if we have a localization for the script let's do that too. |
|
325 | - if (isset($this->_scripts_styles['localize'][ $ref ])) { |
|
326 | - foreach ($this->_scripts_styles['localize'][ $ref ] as $object_name => $indexes) { |
|
327 | - wp_localize_script( |
|
328 | - $ref, |
|
329 | - $object_name, |
|
330 | - $this->_scripts_styles['localize'][ $ref ][ $object_name ] |
|
331 | - ); |
|
332 | - } |
|
333 | - } |
|
334 | - } |
|
335 | - } |
|
336 | - // let's do the deregisters |
|
337 | - if (! isset($this->_scripts_styles['deregisters'])) { |
|
338 | - return; |
|
339 | - } |
|
340 | - foreach ($this->_scripts_styles['deregisters'] as $ref => $details) { |
|
341 | - $defaults = array( |
|
342 | - 'type' => 'js', |
|
343 | - ); |
|
344 | - $details = wp_parse_args($details, $defaults); |
|
345 | - extract($details); |
|
346 | - $type == 'js' ? wp_deregister_script($ref) : wp_deregister_style($ref); |
|
347 | - } |
|
348 | - } |
|
349 | - } |
|
350 | - |
|
351 | - |
|
352 | - /** |
|
353 | - * just set the defaults for the hooks properties. |
|
354 | - * |
|
355 | - * @access private |
|
356 | - * @return void |
|
357 | - */ |
|
358 | - private function _set_defaults() |
|
359 | - { |
|
360 | - $this->_ajax_func = $this->_init_func = $this->_metaboxes = $this->_scripts = $this->_styles = $this->_wp_action_filters_priority = array(); |
|
361 | - $this->_current_route = $this->getCurrentRoute(); |
|
362 | - $this->caller = get_class($this); |
|
363 | - $this->_extend = stripos($this->caller, 'Extend') ? true : false; |
|
364 | - } |
|
365 | - |
|
366 | - |
|
367 | - /** |
|
368 | - * A helper for determining the current route. |
|
369 | - * @return string |
|
370 | - */ |
|
371 | - private function getCurrentRoute() |
|
372 | - { |
|
373 | - // list tables do something else with 'action' for bulk actions. |
|
374 | - $action = ! empty($_REQUEST['action']) && $_REQUEST['action'] !== '-1' ? $_REQUEST['action'] : 'default'; |
|
375 | - // we set a 'route' variable in some cases where action is being used by something else. |
|
376 | - $action = $action === 'default' && isset($_REQUEST['route']) ? $_REQUEST['route'] : $action; |
|
377 | - return sanitize_key($action); |
|
378 | - } |
|
379 | - |
|
380 | - |
|
381 | - /** |
|
382 | - * this sets the _page_object property |
|
383 | - * |
|
384 | - * @access protected |
|
385 | - * @return void |
|
386 | - */ |
|
387 | - protected function _set_page_object() |
|
388 | - { |
|
389 | - // first make sure $this->_name is set |
|
390 | - if (empty($this->_name)) { |
|
391 | - $msg[] = __('We can\'t load the page object', 'event_espresso'); |
|
392 | - $msg[] = sprintf( |
|
393 | - __("This is because the %s child class has not set the '_name' property", 'event_espresso'), |
|
394 | - $this->caller |
|
395 | - ); |
|
396 | - throw new EE_Error(implode('||', $msg)); |
|
397 | - } |
|
398 | - $ref = str_replace('_', ' ', $this->_name); // take the_message -> the message |
|
399 | - $ref = str_replace(' ', '_', ucwords($ref)) . '_Admin_Page'; // take the message -> The_Message |
|
400 | - // first default file (if exists) |
|
401 | - $decaf_file = EE_ADMIN_PAGES . $this->_name . '/' . $ref . '.core.php'; |
|
402 | - if (is_readable($decaf_file)) { |
|
403 | - require_once($decaf_file); |
|
404 | - } |
|
405 | - // now we have to do require for extended file (if needed) |
|
406 | - if ($this->_extend) { |
|
407 | - require_once(EE_CORE_CAF_ADMIN_EXTEND . $this->_name . '/Extend_' . $ref . '.core.php'); |
|
408 | - } |
|
409 | - // if we've got an extended class we use that! |
|
410 | - $ref = $this->_extend ? 'Extend_' . $ref : $ref; |
|
411 | - // let's make sure the class exists |
|
412 | - if (! class_exists($ref)) { |
|
413 | - $msg[] = __('We can\'t load the page object', 'event_espresso'); |
|
414 | - $msg[] = sprintf( |
|
415 | - __( |
|
416 | - 'The class name that was given is %s. Check the spelling and make sure its correct, also there needs to be an autoloader setup for the class', |
|
417 | - 'event_espresso' |
|
418 | - ), |
|
419 | - $ref |
|
420 | - ); |
|
421 | - throw new EE_Error(implode('||', $msg)); |
|
422 | - } |
|
423 | - $a = new ReflectionClass($ref); |
|
424 | - $this->_page_object = $a->newInstance(false); |
|
425 | - } |
|
426 | - |
|
427 | - |
|
428 | - /** |
|
429 | - * Child "hook" classes can declare any methods that they want executed when a specific page route is loaded. The |
|
430 | - * advantage of this is when doing things like running our own db interactions on saves etc. Remember that |
|
431 | - * $this->_req_data (all the _POST and _GET data) is available to your methods. |
|
432 | - * |
|
433 | - * @access private |
|
434 | - * @return void |
|
435 | - */ |
|
436 | - private function _load_custom_methods() |
|
437 | - { |
|
438 | - /** |
|
439 | - * method cannot be named 'default' (@see http://us3.php |
|
440 | - * .net/manual/en/reserved.keywords.php) so need to |
|
441 | - * handle routes that are "default" |
|
442 | - * |
|
443 | - * @since 4.3.0 |
|
444 | - */ |
|
445 | - $method_callback = $this->_current_route == 'default' ? 'default_callback' : $this->_current_route; |
|
446 | - // these run before the Admin_Page route executes. |
|
447 | - if (method_exists($this, $method_callback)) { |
|
448 | - call_user_func(array($this, $method_callback)); |
|
449 | - } |
|
450 | - // these run via the _redirect_after_action method in EE_Admin_Page which usually happens after non_UI methods in EE_Admin_Page classes. There are two redirect actions, the first fires before $query_args might be manipulated by "save and close" actions and the seond fires right before the actual redirect happens. |
|
451 | - // first the actions |
|
452 | - // note that these action hooks will have the $query_args value available. |
|
453 | - $admin_class_name = get_class($this->_adminpage_obj); |
|
454 | - if (method_exists($this, '_redirect_action_early_' . $this->_current_route)) { |
|
455 | - add_action( |
|
456 | - 'AHEE__' |
|
457 | - . $admin_class_name |
|
458 | - . '___redirect_after_action__before_redirect_modification_' |
|
459 | - . $this->_current_route, |
|
460 | - array($this, '_redirect_action_early_' . $this->_current_route), |
|
461 | - 10 |
|
462 | - ); |
|
463 | - } |
|
464 | - if (method_exists($this, '_redirect_action_' . $this->_current_route)) { |
|
465 | - add_action( |
|
466 | - 'AHEE_redirect_' . $admin_class_name . $this->_current_route, |
|
467 | - array($this, '_redirect_action_' . $this->_current_route), |
|
468 | - 10 |
|
469 | - ); |
|
470 | - } |
|
471 | - // let's hook into the _redirect itself and allow for changing where the user goes after redirect. This will have $query_args and $redirect_url available. |
|
472 | - if (method_exists($this, '_redirect_filter_' . $this->_current_route)) { |
|
473 | - add_filter( |
|
474 | - 'FHEE_redirect_' . $admin_class_name . $this->_current_route, |
|
475 | - array($this, '_redirect_filter_' . $this->_current_route), |
|
476 | - 10, |
|
477 | - 2 |
|
478 | - ); |
|
479 | - } |
|
480 | - } |
|
481 | - |
|
482 | - |
|
483 | - /** |
|
484 | - * This method will search for a corresponding method with a name matching the route and the wp_hook to run. This |
|
485 | - * allows child hook classes to target hooking into a specific wp action or filter hook ONLY on a certain route. |
|
486 | - * just remember, methods MUST be public Future hooks should be added in here to be access by child classes. |
|
487 | - * |
|
488 | - * @return void |
|
489 | - */ |
|
490 | - private function _load_routed_hooks() |
|
491 | - { |
|
492 | - |
|
493 | - // this array provides the hook action names that will be referenced. Key is the action. Value is an array with the type (action or filter) and the number of parameters for the hook. We'll default all priorities for automatic hooks to 10. |
|
494 | - $hook_filter_array = array( |
|
495 | - 'admin_footer' => array( |
|
496 | - 'type' => 'action', |
|
497 | - 'argnum' => 1, |
|
498 | - 'priority' => 10, |
|
499 | - ), |
|
500 | - 'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug . '_' . $this->_current_route => array( |
|
501 | - 'type' => 'filter', |
|
502 | - 'argnum' => 1, |
|
503 | - 'priority' => 10, |
|
504 | - ), |
|
505 | - 'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug => array( |
|
506 | - 'type' => 'filter', |
|
507 | - 'argnum' => 1, |
|
508 | - 'priority' => 10, |
|
509 | - ), |
|
510 | - 'FHEE_list_table_views' => array( |
|
511 | - 'type' => 'filter', |
|
512 | - 'argnum' => 1, |
|
513 | - 'priority' => 10, |
|
514 | - ), |
|
515 | - 'AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes' => array( |
|
516 | - 'type' => 'action', |
|
517 | - 'argnum' => 1, |
|
518 | - 'priority' => 10, |
|
519 | - ), |
|
520 | - ); |
|
521 | - foreach ($hook_filter_array as $hook => $args) { |
|
522 | - if (method_exists($this, $this->_current_route . '_' . $hook)) { |
|
523 | - if (isset($this->_wp_action_filters_priority[ $hook ])) { |
|
524 | - $args['priority'] = $this->_wp_action_filters_priority[ $hook ]; |
|
525 | - } |
|
526 | - if ($args['type'] == 'action') { |
|
527 | - add_action( |
|
528 | - $hook, |
|
529 | - array($this, $this->_current_route . '_' . $hook), |
|
530 | - $args['priority'], |
|
531 | - $args['argnum'] |
|
532 | - ); |
|
533 | - } else { |
|
534 | - add_filter( |
|
535 | - $hook, |
|
536 | - array($this, $this->_current_route . '_' . $hook), |
|
537 | - $args['priority'], |
|
538 | - $args['argnum'] |
|
539 | - ); |
|
540 | - } |
|
541 | - } |
|
542 | - } |
|
543 | - } |
|
544 | - |
|
545 | - |
|
546 | - /** |
|
547 | - * Loop throught the $_ajax_func array and add_actions for the array. |
|
548 | - * |
|
549 | - * @return void |
|
550 | - */ |
|
551 | - private function _ajax_hooks() |
|
552 | - { |
|
553 | - |
|
554 | - if (empty($this->_ajax_func)) { |
|
555 | - return; |
|
556 | - } //get out there's nothing to take care of. |
|
557 | - foreach ($this->_ajax_func as $action => $method) { |
|
558 | - // make sure method exists |
|
559 | - if (! method_exists($this, $method)) { |
|
560 | - $msg[] = __( |
|
561 | - 'There is no corresponding method for the hook labeled in the _ajax_func array', |
|
562 | - 'event_espresso' |
|
563 | - ) . '<br />'; |
|
564 | - $msg[] = sprintf( |
|
565 | - __( |
|
566 | - 'The method name given in the array is %s, check the spelling and make sure it exists in the %s class', |
|
567 | - 'event_espresso' |
|
568 | - ), |
|
569 | - $method, |
|
570 | - $this->caller |
|
571 | - ); |
|
572 | - throw new EE_Error(implode('||', $msg)); |
|
573 | - } |
|
574 | - add_action('wp_ajax_' . $action, array($this, $method)); |
|
575 | - } |
|
576 | - } |
|
577 | - |
|
578 | - |
|
579 | - /** |
|
580 | - * Loop throught the $_init_func array and add_actions for the array. |
|
581 | - * |
|
582 | - * @return void |
|
583 | - */ |
|
584 | - protected function _init_hooks() |
|
585 | - { |
|
586 | - if (empty($this->_init_func)) { |
|
587 | - return; |
|
588 | - } //get out there's nothing to take care of. |
|
589 | - // We need to determine what page_route we are on! |
|
590 | - $current_route = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'default'; |
|
591 | - foreach ($this->_init_func as $route => $method) { |
|
592 | - // make sure method exists |
|
593 | - if (! method_exists($this, $method)) { |
|
594 | - $msg[] = __( |
|
595 | - 'There is no corresponding method for the hook labeled in the _init_func array', |
|
596 | - 'event_espresso' |
|
597 | - ) . '<br />'; |
|
598 | - $msg[] = sprintf( |
|
599 | - __( |
|
600 | - 'The method name given in the array is %s, check the spelling and make sure it exists in the %s class', |
|
601 | - 'event_espresso' |
|
602 | - ), |
|
603 | - $method, |
|
604 | - $this->caller |
|
605 | - ); |
|
606 | - throw new EE_Error(implode('||', $msg)); |
|
607 | - } |
|
608 | - if ($route == $this->_current_route) { |
|
609 | - add_action('admin_init', array($this, $method)); |
|
610 | - } |
|
611 | - } |
|
612 | - } |
|
613 | - |
|
614 | - |
|
615 | - /** |
|
616 | - * Loop through the _metaboxes property and add_metaboxes accordingly |
|
617 | - * //todo we could eventually make this a config component class (i.e. new EE_Metabox); |
|
618 | - * |
|
619 | - * @access public |
|
620 | - * @return void |
|
621 | - */ |
|
622 | - public function add_metaboxes() |
|
623 | - { |
|
624 | - if (empty($this->_metaboxes)) { |
|
625 | - return; |
|
626 | - } //get out we don't have any metaboxes to set for this connection |
|
627 | - $this->_handle_metabox_array($this->_metaboxes); |
|
628 | - } |
|
629 | - |
|
630 | - |
|
631 | - private function _handle_metabox_array($boxes, $add = true) |
|
632 | - { |
|
633 | - |
|
634 | - foreach ($boxes as $box) { |
|
635 | - if (! isset($box['page_route'])) { |
|
636 | - continue; |
|
637 | - } //we dont' have a valid array |
|
638 | - // let's make sure $box['page_route'] is an array so the "foreach" will work. |
|
639 | - $box['page_route'] = (array) $box['page_route']; |
|
640 | - foreach ($box['page_route'] as $route) { |
|
641 | - if ($route != $this->_current_route) { |
|
642 | - continue; |
|
643 | - } //get out we only add metaboxes for set route. |
|
644 | - if ($add) { |
|
645 | - $this->_add_metabox($box); |
|
646 | - } else { |
|
647 | - $this->_remove_metabox($box); |
|
648 | - } |
|
649 | - } |
|
650 | - } |
|
651 | - } |
|
652 | - |
|
653 | - |
|
654 | - /** |
|
655 | - * Loop through the _remove_metaboxes property and remove metaboxes accordingly. |
|
656 | - * |
|
657 | - * @access public |
|
658 | - * @return void |
|
659 | - */ |
|
660 | - public function remove_metaboxes() |
|
661 | - { |
|
662 | - |
|
663 | - if (empty($this->_remove_metaboxes)) { |
|
664 | - return; |
|
665 | - } //get out there are no metaboxes to remove |
|
666 | - $this->_handle_metabox_array($this->_remove_metaboxes, false); |
|
667 | - } |
|
668 | - |
|
669 | - |
|
670 | - /** |
|
671 | - * This just handles adding a metabox |
|
672 | - * |
|
673 | - * @access private |
|
674 | - * @param array $args an array of args that have been set for this metabox by the child class |
|
675 | - */ |
|
676 | - private function _add_metabox($args) |
|
677 | - { |
|
678 | - $current_screen = get_current_screen(); |
|
679 | - $screen_id = is_object($current_screen) ? $current_screen->id : null; |
|
680 | - $func = isset($args['func']) ? $args['func'] : 'some_invalid_callback'; |
|
681 | - // set defaults |
|
682 | - $defaults = array( |
|
683 | - 'func' => $func, |
|
684 | - 'id' => $this->caller . '_' . $func . '_metabox', |
|
685 | - 'priority' => 'default', |
|
686 | - 'label' => $this->caller, |
|
687 | - 'context' => 'advanced', |
|
688 | - 'callback_args' => array(), |
|
689 | - 'page' => isset($args['page']) ? $args['page'] : $screen_id, |
|
690 | - ); |
|
691 | - $args = wp_parse_args($args, $defaults); |
|
692 | - extract($args); |
|
693 | - // make sure method exists |
|
694 | - if (! method_exists($this, $func)) { |
|
695 | - $msg[] = __('There is no corresponding method to display the metabox content', 'event_espresso') . '<br />'; |
|
696 | - $msg[] = sprintf( |
|
697 | - __( |
|
698 | - 'The method name given in the array is %s, check the spelling and make sure it exists in the %s class', |
|
699 | - 'event_espresso' |
|
700 | - ), |
|
701 | - $func, |
|
702 | - $this->caller |
|
703 | - ); |
|
704 | - throw new EE_Error(implode('||', $msg)); |
|
705 | - } |
|
706 | - // everything checks out so lets add the metabox |
|
707 | - add_meta_box($id, $label, array($this, $func), $page, $context, $priority, $callback_args); |
|
708 | - } |
|
709 | - |
|
710 | - |
|
711 | - private function _remove_metabox($args) |
|
712 | - { |
|
713 | - $current_screen = get_current_screen(); |
|
714 | - $screen_id = is_object($current_screen) ? $current_screen->id : null; |
|
715 | - $func = isset($args['func']) ? $args['func'] : 'some_invalid_callback'; |
|
716 | - // set defaults |
|
717 | - $defaults = array( |
|
718 | - 'id' => isset($args['id']) |
|
719 | - ? $args['id'] |
|
720 | - : $this->_current_route |
|
721 | - . '_' |
|
722 | - . $this->caller |
|
723 | - . '_' |
|
724 | - . $func |
|
725 | - . '_metabox', |
|
726 | - 'context' => 'default', |
|
727 | - 'screen' => isset($args['screen']) ? $args['screen'] : $screen_id, |
|
728 | - ); |
|
729 | - $args = wp_parse_args($args, $defaults); |
|
730 | - extract($args); |
|
731 | - // everything checks out so lets remove the box! |
|
732 | - remove_meta_box($id, $screen, $context); |
|
733 | - } |
|
16 | + /** |
|
17 | + * we're just going to use this to hold the name of the caller class (child class name) |
|
18 | + * |
|
19 | + * @var string |
|
20 | + */ |
|
21 | + public $caller; |
|
22 | + |
|
23 | + |
|
24 | + /** |
|
25 | + * this is just a flag set automatically to indicate whether we've got an extended hook class running (i.e. |
|
26 | + * espresso_events_Registration_Form_Hooks_Extend extends espresso_events_Registration_Form_Hooks). This flag is |
|
27 | + * used later to make sure we require the needed files. |
|
28 | + * |
|
29 | + * @var bool |
|
30 | + */ |
|
31 | + protected $_extend; |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * child classes MUST set this property so that the page object can be loaded correctly |
|
36 | + * |
|
37 | + * @var string |
|
38 | + */ |
|
39 | + protected $_name; |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * This is set by child classes and is an associative array of ajax hooks in the format: |
|
44 | + * array( |
|
45 | + * 'ajax_action_ref' => 'executing_method'; //must be public |
|
46 | + * ) |
|
47 | + * |
|
48 | + * @var array |
|
49 | + */ |
|
50 | + protected $_ajax_func; |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * This is an array of methods that get executed on a page routes admin_init hook. Use the following format: |
|
55 | + * array( |
|
56 | + * 'page_route' => 'executing_method' //must be public |
|
57 | + * ) |
|
58 | + * |
|
59 | + * @var array |
|
60 | + */ |
|
61 | + protected $_init_func; |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * This is an array of methods that output metabox content for the given page route. Use the following format: |
|
66 | + * array( |
|
67 | + * 0 => array( |
|
68 | + * 'page_route' => 'string_for_page_route', //must correspond to a page route in the class being connected |
|
69 | + * with (i.e. "edit_event") If this is in an array then the same params below will be used but the metabox |
|
70 | + * will be added to each route. |
|
71 | + * 'func' => 'executing_method', //must be public (i.e. public function executing_method($post, |
|
72 | + * $callback_args){} ). Note if you include callback args in the array then you need to declare them in the |
|
73 | + * method arguments. |
|
74 | + * 'id' => 'identifier_for_metabox', //so it can be removed by addons (optional, class will set it |
|
75 | + * automatically) |
|
76 | + * 'priority' => 'default', //default 'default' (optional) |
|
77 | + * 'label' => __('Localized Title', 'event_espresso'), |
|
78 | + * 'context' => 'advanced' //advanced is default (optional), |
|
79 | + * 'callback_args' => array() //any callback args to include (optional) |
|
80 | + * ) |
|
81 | + * Why are we indexing numerically? Because it's possible there may be more than one metabox per page_route. |
|
82 | + * |
|
83 | + * @var array |
|
84 | + */ |
|
85 | + protected $_metaboxes; |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * This is an array of values that indicate any metaboxes we want removed from a given page route. Usually this is |
|
90 | + * used when caffeinated functionality is replacing decaffeinated functionality. Use the following format for the |
|
91 | + * array: array( |
|
92 | + * 0 => array( |
|
93 | + * 'page_route' => 'string_for_page_route' //can be string or array of strings that match a page_route(s) |
|
94 | + * that are in the class being connected with (i.e. 'edit', or 'create_new'). |
|
95 | + * 'id' => 'identifier_for_metabox', //what the id is of the metabox being removed |
|
96 | + * 'context' => 'normal', //the context for the metabox being removed (has to match) |
|
97 | + * 'screen' => 'screen_id', //(optional), if not included then this class will attempt to remove the metabox |
|
98 | + * using the currently loaded screen object->id however, there may be cases where you have to specify the |
|
99 | + * id for the screen the metabox is on. |
|
100 | + * ) |
|
101 | + * ) |
|
102 | + * |
|
103 | + * @var array |
|
104 | + */ |
|
105 | + protected $_remove_metaboxes; |
|
106 | + |
|
107 | + |
|
108 | + /** |
|
109 | + * This parent class takes care of loading the scripts and styles if the child class has set the properties for |
|
110 | + * them in the following format. Note, the first array index ('register') is for defining all the registers. The |
|
111 | + * second array index is for indicating what routes each script/style loads on. array( |
|
112 | + * 'registers' => array( |
|
113 | + * 'script_ref' => array( // if more than one script is to be loaded its best to use the 'dependency' |
|
114 | + * argument to link scripts together. |
|
115 | + * 'type' => 'js' // 'js' or 'css' (defaults to js). This tells us what type of wp_function to use |
|
116 | + * 'url' => 'http://urltoscript.css.js', |
|
117 | + * 'depends' => array('jquery'), //an array of dependencies for the scripts. REMEMBER, if a script has |
|
118 | + * already been registered elsewhere in the system. You can just use the depends array to make sure it |
|
119 | + * gets loaded before the one you are setting here. |
|
120 | + * 'footer' => TRUE //defaults to true (styles don't use this parameter) |
|
121 | + * ), |
|
122 | + * 'enqueues' => array( //this time each key corresponds to the script ref followed by an array of page routes |
|
123 | + * the script gets enqueued on. |
|
124 | + * 'script_ref' => array('route_one', 'route_two') |
|
125 | + * ), |
|
126 | + * 'localize' => array( //this allows you to set a localize object. Indicate which script the object is being |
|
127 | + * attached to and then include an array indexed by the name of the object and the array of key/value pairs for |
|
128 | + * the object. |
|
129 | + * 'scrip_ref' => array( |
|
130 | + * 'NAME_OF_JS_OBJECT' => array( |
|
131 | + * 'translate_ref' => __('localized_string', 'event_espresso'), |
|
132 | + * 'some_data' => 5 |
|
133 | + * ) |
|
134 | + * ) |
|
135 | + * ) |
|
136 | + * ) |
|
137 | + * |
|
138 | + * @var array |
|
139 | + */ |
|
140 | + protected $_scripts_styles; |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * This is a property that will contain the current route. |
|
145 | + * |
|
146 | + * @var string; |
|
147 | + */ |
|
148 | + protected $_current_route; |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * this optional property can be set by child classes to override the priority for the automatic action/filter hook |
|
153 | + * loading in the `_load_routed_hooks()` method. Please follow this format: array( |
|
154 | + * 'wp_hook_reference' => 1 |
|
155 | + * ) |
|
156 | + * ) |
|
157 | + * |
|
158 | + * @var array |
|
159 | + */ |
|
160 | + protected $_wp_action_filters_priority; |
|
161 | + |
|
162 | + |
|
163 | + /** |
|
164 | + * This just holds a merged array of the $_POST and $_GET vars in favor of $_POST |
|
165 | + * |
|
166 | + * @var array |
|
167 | + */ |
|
168 | + protected $_req_data; |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * This just holds an instance of the page object for this hook |
|
173 | + * |
|
174 | + * @var EE_Admin_Page |
|
175 | + */ |
|
176 | + protected $_page_object; |
|
177 | + |
|
178 | + |
|
179 | + /** |
|
180 | + * This holds the EE_Admin_Page object from the calling admin page that this object hooks into. |
|
181 | + * |
|
182 | + * @var EE_Admin_Page|EE_Admin_Page_CPT |
|
183 | + */ |
|
184 | + protected $_adminpage_obj; |
|
185 | + |
|
186 | + |
|
187 | + /** |
|
188 | + * Holds EE_Registry object |
|
189 | + * |
|
190 | + * @var EE_Registry |
|
191 | + */ |
|
192 | + protected $EE = null; |
|
193 | + |
|
194 | + |
|
195 | + /** |
|
196 | + * constructor |
|
197 | + * |
|
198 | + * @param EE_Admin_Page $admin_page the calling admin_page_object |
|
199 | + */ |
|
200 | + public function __construct(EE_Admin_Page $adminpage) |
|
201 | + { |
|
202 | + |
|
203 | + $this->_adminpage_obj = $adminpage; |
|
204 | + $this->_req_data = array_merge($_GET, $_POST); |
|
205 | + $this->_set_defaults(); |
|
206 | + $this->_set_hooks_properties(); |
|
207 | + // first let's verify we're on the right page |
|
208 | + if (! isset($this->_req_data['page']) |
|
209 | + || (isset($this->_req_data['page']) |
|
210 | + && $this->_adminpage_obj->page_slug |
|
211 | + != $this->_req_data['page'])) { |
|
212 | + return; |
|
213 | + } //get out nothing more to be done here. |
|
214 | + // allow for extends to modify properties |
|
215 | + if (method_exists($this, '_extend_properties')) { |
|
216 | + $this->_extend_properties(); |
|
217 | + } |
|
218 | + $this->_set_page_object(); |
|
219 | + $this->_init_hooks(); |
|
220 | + $this->_load_custom_methods(); |
|
221 | + $this->_load_routed_hooks(); |
|
222 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts_styles')); |
|
223 | + add_action('admin_enqueue_scripts', array($this, 'add_metaboxes'), 20); |
|
224 | + add_action('admin_enqueue_scripts', array($this, 'remove_metaboxes'), 15); |
|
225 | + $this->_ajax_hooks(); |
|
226 | + } |
|
227 | + |
|
228 | + |
|
229 | + /** |
|
230 | + * used by child classes to set the following properties: |
|
231 | + * $_ajax_func (optional) |
|
232 | + * $_init_func (optional) |
|
233 | + * $_metaboxes (optional) |
|
234 | + * $_scripts (optional) |
|
235 | + * $_styles (optional) |
|
236 | + * $_name (required) |
|
237 | + * Also in this method will be registered any scripts or styles loaded on the targeted page (as indicated in the |
|
238 | + * _scripts/_styles properties) Also children should place in this method any filters/actions that have to happen |
|
239 | + * really early on page load (just after admin_init) if they want to have them registered for handling early. |
|
240 | + * |
|
241 | + * @access protected |
|
242 | + * @abstract |
|
243 | + * @return void |
|
244 | + */ |
|
245 | + abstract protected function _set_hooks_properties(); |
|
246 | + |
|
247 | + |
|
248 | + /** |
|
249 | + * The hooks for enqueue_scripts and enqueue_styles will be run in here. Child classes need to define their |
|
250 | + * scripts and styles in the relevant $_scripts and $_styles properties. Child classes must have also already |
|
251 | + * registered the scripts and styles using wp_register_script and wp_register_style functions. |
|
252 | + * |
|
253 | + * @access public |
|
254 | + * @return void |
|
255 | + */ |
|
256 | + public function enqueue_scripts_styles() |
|
257 | + { |
|
258 | + |
|
259 | + if (! empty($this->_scripts_styles)) { |
|
260 | + // first let's do all the registrations |
|
261 | + if (! isset($this->_scripts_styles['registers'])) { |
|
262 | + $msg[] = __( |
|
263 | + 'There is no "registers" index in the <code>$this->_scripts_styles</code> property.', |
|
264 | + 'event_espresso' |
|
265 | + ); |
|
266 | + $msg[] = sprintf( |
|
267 | + __( |
|
268 | + 'Make sure you read the phpdoc comments above the definition of the $_scripts_styles property in the <code>EE_Admin_Hooks</code> class and modify according in the %s child', |
|
269 | + 'event_espresso' |
|
270 | + ), |
|
271 | + '<strong>' . $this->caller . '</strong>' |
|
272 | + ); |
|
273 | + throw new EE_Error(implode('||', $msg)); |
|
274 | + } |
|
275 | + foreach ($this->_scripts_styles['registers'] as $ref => $details) { |
|
276 | + $defaults = array( |
|
277 | + 'type' => 'js', |
|
278 | + 'url' => '', |
|
279 | + 'depends' => array(), |
|
280 | + 'version' => EVENT_ESPRESSO_VERSION, |
|
281 | + 'footer' => true, |
|
282 | + ); |
|
283 | + $details = wp_parse_args($details, $defaults); |
|
284 | + extract($details); |
|
285 | + // let's make sure that we set the 'registers' type if it's not set! We need it later to determine whhich enqueu we do |
|
286 | + $this->_scripts_styles['registers'][ $ref ]['type'] = $type; |
|
287 | + // let's make sure we're not missing any REQUIRED parameters |
|
288 | + if (empty($url)) { |
|
289 | + $msg[] = sprintf( |
|
290 | + __('Missing the url for the requested %s', 'event_espresso'), |
|
291 | + $type == 'js' ? 'script' : 'stylesheet' |
|
292 | + ); |
|
293 | + $msg[] = sprintf( |
|
294 | + __( |
|
295 | + 'Doublecheck your <code>$this->_scripts_styles</code> array in %s and make sure that there is a "url" set for the %s ref', |
|
296 | + 'event_espresso' |
|
297 | + ), |
|
298 | + '<strong>' . $this->caller . '</strong>', |
|
299 | + $ref |
|
300 | + ); |
|
301 | + throw new EE_Error(implode('||', $msg)); |
|
302 | + } |
|
303 | + // made it here so let's do the appropriate registration |
|
304 | + $type == 'js' |
|
305 | + ? wp_register_script($ref, $url, $depends, $version, $footer) |
|
306 | + : wp_register_style( |
|
307 | + $ref, |
|
308 | + $url, |
|
309 | + $depends, |
|
310 | + $version |
|
311 | + ); |
|
312 | + } |
|
313 | + // k now lets do the enqueues |
|
314 | + if (! isset($this->_scripts_styles['enqueues'])) { |
|
315 | + return; |
|
316 | + } //not sure if we should throw an error here or not. |
|
317 | + |
|
318 | + foreach ($this->_scripts_styles['enqueues'] as $ref => $routes) { |
|
319 | + // make sure $routes is an array |
|
320 | + $routes = (array) $routes; |
|
321 | + if (in_array($this->_current_route, $routes)) { |
|
322 | + $this->_scripts_styles['registers'][ $ref ]['type'] == 'js' ? wp_enqueue_script($ref) |
|
323 | + : wp_enqueue_style($ref); |
|
324 | + // if we have a localization for the script let's do that too. |
|
325 | + if (isset($this->_scripts_styles['localize'][ $ref ])) { |
|
326 | + foreach ($this->_scripts_styles['localize'][ $ref ] as $object_name => $indexes) { |
|
327 | + wp_localize_script( |
|
328 | + $ref, |
|
329 | + $object_name, |
|
330 | + $this->_scripts_styles['localize'][ $ref ][ $object_name ] |
|
331 | + ); |
|
332 | + } |
|
333 | + } |
|
334 | + } |
|
335 | + } |
|
336 | + // let's do the deregisters |
|
337 | + if (! isset($this->_scripts_styles['deregisters'])) { |
|
338 | + return; |
|
339 | + } |
|
340 | + foreach ($this->_scripts_styles['deregisters'] as $ref => $details) { |
|
341 | + $defaults = array( |
|
342 | + 'type' => 'js', |
|
343 | + ); |
|
344 | + $details = wp_parse_args($details, $defaults); |
|
345 | + extract($details); |
|
346 | + $type == 'js' ? wp_deregister_script($ref) : wp_deregister_style($ref); |
|
347 | + } |
|
348 | + } |
|
349 | + } |
|
350 | + |
|
351 | + |
|
352 | + /** |
|
353 | + * just set the defaults for the hooks properties. |
|
354 | + * |
|
355 | + * @access private |
|
356 | + * @return void |
|
357 | + */ |
|
358 | + private function _set_defaults() |
|
359 | + { |
|
360 | + $this->_ajax_func = $this->_init_func = $this->_metaboxes = $this->_scripts = $this->_styles = $this->_wp_action_filters_priority = array(); |
|
361 | + $this->_current_route = $this->getCurrentRoute(); |
|
362 | + $this->caller = get_class($this); |
|
363 | + $this->_extend = stripos($this->caller, 'Extend') ? true : false; |
|
364 | + } |
|
365 | + |
|
366 | + |
|
367 | + /** |
|
368 | + * A helper for determining the current route. |
|
369 | + * @return string |
|
370 | + */ |
|
371 | + private function getCurrentRoute() |
|
372 | + { |
|
373 | + // list tables do something else with 'action' for bulk actions. |
|
374 | + $action = ! empty($_REQUEST['action']) && $_REQUEST['action'] !== '-1' ? $_REQUEST['action'] : 'default'; |
|
375 | + // we set a 'route' variable in some cases where action is being used by something else. |
|
376 | + $action = $action === 'default' && isset($_REQUEST['route']) ? $_REQUEST['route'] : $action; |
|
377 | + return sanitize_key($action); |
|
378 | + } |
|
379 | + |
|
380 | + |
|
381 | + /** |
|
382 | + * this sets the _page_object property |
|
383 | + * |
|
384 | + * @access protected |
|
385 | + * @return void |
|
386 | + */ |
|
387 | + protected function _set_page_object() |
|
388 | + { |
|
389 | + // first make sure $this->_name is set |
|
390 | + if (empty($this->_name)) { |
|
391 | + $msg[] = __('We can\'t load the page object', 'event_espresso'); |
|
392 | + $msg[] = sprintf( |
|
393 | + __("This is because the %s child class has not set the '_name' property", 'event_espresso'), |
|
394 | + $this->caller |
|
395 | + ); |
|
396 | + throw new EE_Error(implode('||', $msg)); |
|
397 | + } |
|
398 | + $ref = str_replace('_', ' ', $this->_name); // take the_message -> the message |
|
399 | + $ref = str_replace(' ', '_', ucwords($ref)) . '_Admin_Page'; // take the message -> The_Message |
|
400 | + // first default file (if exists) |
|
401 | + $decaf_file = EE_ADMIN_PAGES . $this->_name . '/' . $ref . '.core.php'; |
|
402 | + if (is_readable($decaf_file)) { |
|
403 | + require_once($decaf_file); |
|
404 | + } |
|
405 | + // now we have to do require for extended file (if needed) |
|
406 | + if ($this->_extend) { |
|
407 | + require_once(EE_CORE_CAF_ADMIN_EXTEND . $this->_name . '/Extend_' . $ref . '.core.php'); |
|
408 | + } |
|
409 | + // if we've got an extended class we use that! |
|
410 | + $ref = $this->_extend ? 'Extend_' . $ref : $ref; |
|
411 | + // let's make sure the class exists |
|
412 | + if (! class_exists($ref)) { |
|
413 | + $msg[] = __('We can\'t load the page object', 'event_espresso'); |
|
414 | + $msg[] = sprintf( |
|
415 | + __( |
|
416 | + 'The class name that was given is %s. Check the spelling and make sure its correct, also there needs to be an autoloader setup for the class', |
|
417 | + 'event_espresso' |
|
418 | + ), |
|
419 | + $ref |
|
420 | + ); |
|
421 | + throw new EE_Error(implode('||', $msg)); |
|
422 | + } |
|
423 | + $a = new ReflectionClass($ref); |
|
424 | + $this->_page_object = $a->newInstance(false); |
|
425 | + } |
|
426 | + |
|
427 | + |
|
428 | + /** |
|
429 | + * Child "hook" classes can declare any methods that they want executed when a specific page route is loaded. The |
|
430 | + * advantage of this is when doing things like running our own db interactions on saves etc. Remember that |
|
431 | + * $this->_req_data (all the _POST and _GET data) is available to your methods. |
|
432 | + * |
|
433 | + * @access private |
|
434 | + * @return void |
|
435 | + */ |
|
436 | + private function _load_custom_methods() |
|
437 | + { |
|
438 | + /** |
|
439 | + * method cannot be named 'default' (@see http://us3.php |
|
440 | + * .net/manual/en/reserved.keywords.php) so need to |
|
441 | + * handle routes that are "default" |
|
442 | + * |
|
443 | + * @since 4.3.0 |
|
444 | + */ |
|
445 | + $method_callback = $this->_current_route == 'default' ? 'default_callback' : $this->_current_route; |
|
446 | + // these run before the Admin_Page route executes. |
|
447 | + if (method_exists($this, $method_callback)) { |
|
448 | + call_user_func(array($this, $method_callback)); |
|
449 | + } |
|
450 | + // these run via the _redirect_after_action method in EE_Admin_Page which usually happens after non_UI methods in EE_Admin_Page classes. There are two redirect actions, the first fires before $query_args might be manipulated by "save and close" actions and the seond fires right before the actual redirect happens. |
|
451 | + // first the actions |
|
452 | + // note that these action hooks will have the $query_args value available. |
|
453 | + $admin_class_name = get_class($this->_adminpage_obj); |
|
454 | + if (method_exists($this, '_redirect_action_early_' . $this->_current_route)) { |
|
455 | + add_action( |
|
456 | + 'AHEE__' |
|
457 | + . $admin_class_name |
|
458 | + . '___redirect_after_action__before_redirect_modification_' |
|
459 | + . $this->_current_route, |
|
460 | + array($this, '_redirect_action_early_' . $this->_current_route), |
|
461 | + 10 |
|
462 | + ); |
|
463 | + } |
|
464 | + if (method_exists($this, '_redirect_action_' . $this->_current_route)) { |
|
465 | + add_action( |
|
466 | + 'AHEE_redirect_' . $admin_class_name . $this->_current_route, |
|
467 | + array($this, '_redirect_action_' . $this->_current_route), |
|
468 | + 10 |
|
469 | + ); |
|
470 | + } |
|
471 | + // let's hook into the _redirect itself and allow for changing where the user goes after redirect. This will have $query_args and $redirect_url available. |
|
472 | + if (method_exists($this, '_redirect_filter_' . $this->_current_route)) { |
|
473 | + add_filter( |
|
474 | + 'FHEE_redirect_' . $admin_class_name . $this->_current_route, |
|
475 | + array($this, '_redirect_filter_' . $this->_current_route), |
|
476 | + 10, |
|
477 | + 2 |
|
478 | + ); |
|
479 | + } |
|
480 | + } |
|
481 | + |
|
482 | + |
|
483 | + /** |
|
484 | + * This method will search for a corresponding method with a name matching the route and the wp_hook to run. This |
|
485 | + * allows child hook classes to target hooking into a specific wp action or filter hook ONLY on a certain route. |
|
486 | + * just remember, methods MUST be public Future hooks should be added in here to be access by child classes. |
|
487 | + * |
|
488 | + * @return void |
|
489 | + */ |
|
490 | + private function _load_routed_hooks() |
|
491 | + { |
|
492 | + |
|
493 | + // this array provides the hook action names that will be referenced. Key is the action. Value is an array with the type (action or filter) and the number of parameters for the hook. We'll default all priorities for automatic hooks to 10. |
|
494 | + $hook_filter_array = array( |
|
495 | + 'admin_footer' => array( |
|
496 | + 'type' => 'action', |
|
497 | + 'argnum' => 1, |
|
498 | + 'priority' => 10, |
|
499 | + ), |
|
500 | + 'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug . '_' . $this->_current_route => array( |
|
501 | + 'type' => 'filter', |
|
502 | + 'argnum' => 1, |
|
503 | + 'priority' => 10, |
|
504 | + ), |
|
505 | + 'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug => array( |
|
506 | + 'type' => 'filter', |
|
507 | + 'argnum' => 1, |
|
508 | + 'priority' => 10, |
|
509 | + ), |
|
510 | + 'FHEE_list_table_views' => array( |
|
511 | + 'type' => 'filter', |
|
512 | + 'argnum' => 1, |
|
513 | + 'priority' => 10, |
|
514 | + ), |
|
515 | + 'AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes' => array( |
|
516 | + 'type' => 'action', |
|
517 | + 'argnum' => 1, |
|
518 | + 'priority' => 10, |
|
519 | + ), |
|
520 | + ); |
|
521 | + foreach ($hook_filter_array as $hook => $args) { |
|
522 | + if (method_exists($this, $this->_current_route . '_' . $hook)) { |
|
523 | + if (isset($this->_wp_action_filters_priority[ $hook ])) { |
|
524 | + $args['priority'] = $this->_wp_action_filters_priority[ $hook ]; |
|
525 | + } |
|
526 | + if ($args['type'] == 'action') { |
|
527 | + add_action( |
|
528 | + $hook, |
|
529 | + array($this, $this->_current_route . '_' . $hook), |
|
530 | + $args['priority'], |
|
531 | + $args['argnum'] |
|
532 | + ); |
|
533 | + } else { |
|
534 | + add_filter( |
|
535 | + $hook, |
|
536 | + array($this, $this->_current_route . '_' . $hook), |
|
537 | + $args['priority'], |
|
538 | + $args['argnum'] |
|
539 | + ); |
|
540 | + } |
|
541 | + } |
|
542 | + } |
|
543 | + } |
|
544 | + |
|
545 | + |
|
546 | + /** |
|
547 | + * Loop throught the $_ajax_func array and add_actions for the array. |
|
548 | + * |
|
549 | + * @return void |
|
550 | + */ |
|
551 | + private function _ajax_hooks() |
|
552 | + { |
|
553 | + |
|
554 | + if (empty($this->_ajax_func)) { |
|
555 | + return; |
|
556 | + } //get out there's nothing to take care of. |
|
557 | + foreach ($this->_ajax_func as $action => $method) { |
|
558 | + // make sure method exists |
|
559 | + if (! method_exists($this, $method)) { |
|
560 | + $msg[] = __( |
|
561 | + 'There is no corresponding method for the hook labeled in the _ajax_func array', |
|
562 | + 'event_espresso' |
|
563 | + ) . '<br />'; |
|
564 | + $msg[] = sprintf( |
|
565 | + __( |
|
566 | + 'The method name given in the array is %s, check the spelling and make sure it exists in the %s class', |
|
567 | + 'event_espresso' |
|
568 | + ), |
|
569 | + $method, |
|
570 | + $this->caller |
|
571 | + ); |
|
572 | + throw new EE_Error(implode('||', $msg)); |
|
573 | + } |
|
574 | + add_action('wp_ajax_' . $action, array($this, $method)); |
|
575 | + } |
|
576 | + } |
|
577 | + |
|
578 | + |
|
579 | + /** |
|
580 | + * Loop throught the $_init_func array and add_actions for the array. |
|
581 | + * |
|
582 | + * @return void |
|
583 | + */ |
|
584 | + protected function _init_hooks() |
|
585 | + { |
|
586 | + if (empty($this->_init_func)) { |
|
587 | + return; |
|
588 | + } //get out there's nothing to take care of. |
|
589 | + // We need to determine what page_route we are on! |
|
590 | + $current_route = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'default'; |
|
591 | + foreach ($this->_init_func as $route => $method) { |
|
592 | + // make sure method exists |
|
593 | + if (! method_exists($this, $method)) { |
|
594 | + $msg[] = __( |
|
595 | + 'There is no corresponding method for the hook labeled in the _init_func array', |
|
596 | + 'event_espresso' |
|
597 | + ) . '<br />'; |
|
598 | + $msg[] = sprintf( |
|
599 | + __( |
|
600 | + 'The method name given in the array is %s, check the spelling and make sure it exists in the %s class', |
|
601 | + 'event_espresso' |
|
602 | + ), |
|
603 | + $method, |
|
604 | + $this->caller |
|
605 | + ); |
|
606 | + throw new EE_Error(implode('||', $msg)); |
|
607 | + } |
|
608 | + if ($route == $this->_current_route) { |
|
609 | + add_action('admin_init', array($this, $method)); |
|
610 | + } |
|
611 | + } |
|
612 | + } |
|
613 | + |
|
614 | + |
|
615 | + /** |
|
616 | + * Loop through the _metaboxes property and add_metaboxes accordingly |
|
617 | + * //todo we could eventually make this a config component class (i.e. new EE_Metabox); |
|
618 | + * |
|
619 | + * @access public |
|
620 | + * @return void |
|
621 | + */ |
|
622 | + public function add_metaboxes() |
|
623 | + { |
|
624 | + if (empty($this->_metaboxes)) { |
|
625 | + return; |
|
626 | + } //get out we don't have any metaboxes to set for this connection |
|
627 | + $this->_handle_metabox_array($this->_metaboxes); |
|
628 | + } |
|
629 | + |
|
630 | + |
|
631 | + private function _handle_metabox_array($boxes, $add = true) |
|
632 | + { |
|
633 | + |
|
634 | + foreach ($boxes as $box) { |
|
635 | + if (! isset($box['page_route'])) { |
|
636 | + continue; |
|
637 | + } //we dont' have a valid array |
|
638 | + // let's make sure $box['page_route'] is an array so the "foreach" will work. |
|
639 | + $box['page_route'] = (array) $box['page_route']; |
|
640 | + foreach ($box['page_route'] as $route) { |
|
641 | + if ($route != $this->_current_route) { |
|
642 | + continue; |
|
643 | + } //get out we only add metaboxes for set route. |
|
644 | + if ($add) { |
|
645 | + $this->_add_metabox($box); |
|
646 | + } else { |
|
647 | + $this->_remove_metabox($box); |
|
648 | + } |
|
649 | + } |
|
650 | + } |
|
651 | + } |
|
652 | + |
|
653 | + |
|
654 | + /** |
|
655 | + * Loop through the _remove_metaboxes property and remove metaboxes accordingly. |
|
656 | + * |
|
657 | + * @access public |
|
658 | + * @return void |
|
659 | + */ |
|
660 | + public function remove_metaboxes() |
|
661 | + { |
|
662 | + |
|
663 | + if (empty($this->_remove_metaboxes)) { |
|
664 | + return; |
|
665 | + } //get out there are no metaboxes to remove |
|
666 | + $this->_handle_metabox_array($this->_remove_metaboxes, false); |
|
667 | + } |
|
668 | + |
|
669 | + |
|
670 | + /** |
|
671 | + * This just handles adding a metabox |
|
672 | + * |
|
673 | + * @access private |
|
674 | + * @param array $args an array of args that have been set for this metabox by the child class |
|
675 | + */ |
|
676 | + private function _add_metabox($args) |
|
677 | + { |
|
678 | + $current_screen = get_current_screen(); |
|
679 | + $screen_id = is_object($current_screen) ? $current_screen->id : null; |
|
680 | + $func = isset($args['func']) ? $args['func'] : 'some_invalid_callback'; |
|
681 | + // set defaults |
|
682 | + $defaults = array( |
|
683 | + 'func' => $func, |
|
684 | + 'id' => $this->caller . '_' . $func . '_metabox', |
|
685 | + 'priority' => 'default', |
|
686 | + 'label' => $this->caller, |
|
687 | + 'context' => 'advanced', |
|
688 | + 'callback_args' => array(), |
|
689 | + 'page' => isset($args['page']) ? $args['page'] : $screen_id, |
|
690 | + ); |
|
691 | + $args = wp_parse_args($args, $defaults); |
|
692 | + extract($args); |
|
693 | + // make sure method exists |
|
694 | + if (! method_exists($this, $func)) { |
|
695 | + $msg[] = __('There is no corresponding method to display the metabox content', 'event_espresso') . '<br />'; |
|
696 | + $msg[] = sprintf( |
|
697 | + __( |
|
698 | + 'The method name given in the array is %s, check the spelling and make sure it exists in the %s class', |
|
699 | + 'event_espresso' |
|
700 | + ), |
|
701 | + $func, |
|
702 | + $this->caller |
|
703 | + ); |
|
704 | + throw new EE_Error(implode('||', $msg)); |
|
705 | + } |
|
706 | + // everything checks out so lets add the metabox |
|
707 | + add_meta_box($id, $label, array($this, $func), $page, $context, $priority, $callback_args); |
|
708 | + } |
|
709 | + |
|
710 | + |
|
711 | + private function _remove_metabox($args) |
|
712 | + { |
|
713 | + $current_screen = get_current_screen(); |
|
714 | + $screen_id = is_object($current_screen) ? $current_screen->id : null; |
|
715 | + $func = isset($args['func']) ? $args['func'] : 'some_invalid_callback'; |
|
716 | + // set defaults |
|
717 | + $defaults = array( |
|
718 | + 'id' => isset($args['id']) |
|
719 | + ? $args['id'] |
|
720 | + : $this->_current_route |
|
721 | + . '_' |
|
722 | + . $this->caller |
|
723 | + . '_' |
|
724 | + . $func |
|
725 | + . '_metabox', |
|
726 | + 'context' => 'default', |
|
727 | + 'screen' => isset($args['screen']) ? $args['screen'] : $screen_id, |
|
728 | + ); |
|
729 | + $args = wp_parse_args($args, $defaults); |
|
730 | + extract($args); |
|
731 | + // everything checks out so lets remove the box! |
|
732 | + remove_meta_box($id, $screen, $context); |
|
733 | + } |
|
734 | 734 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | $this->_set_defaults(); |
206 | 206 | $this->_set_hooks_properties(); |
207 | 207 | // first let's verify we're on the right page |
208 | - if (! isset($this->_req_data['page']) |
|
208 | + if ( ! isset($this->_req_data['page']) |
|
209 | 209 | || (isset($this->_req_data['page']) |
210 | 210 | && $this->_adminpage_obj->page_slug |
211 | 211 | != $this->_req_data['page'])) { |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | public function enqueue_scripts_styles() |
257 | 257 | { |
258 | 258 | |
259 | - if (! empty($this->_scripts_styles)) { |
|
259 | + if ( ! empty($this->_scripts_styles)) { |
|
260 | 260 | // first let's do all the registrations |
261 | - if (! isset($this->_scripts_styles['registers'])) { |
|
261 | + if ( ! isset($this->_scripts_styles['registers'])) { |
|
262 | 262 | $msg[] = __( |
263 | 263 | 'There is no "registers" index in the <code>$this->_scripts_styles</code> property.', |
264 | 264 | 'event_espresso' |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | 'Make sure you read the phpdoc comments above the definition of the $_scripts_styles property in the <code>EE_Admin_Hooks</code> class and modify according in the %s child', |
269 | 269 | 'event_espresso' |
270 | 270 | ), |
271 | - '<strong>' . $this->caller . '</strong>' |
|
271 | + '<strong>'.$this->caller.'</strong>' |
|
272 | 272 | ); |
273 | 273 | throw new EE_Error(implode('||', $msg)); |
274 | 274 | } |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | $details = wp_parse_args($details, $defaults); |
284 | 284 | extract($details); |
285 | 285 | // let's make sure that we set the 'registers' type if it's not set! We need it later to determine whhich enqueu we do |
286 | - $this->_scripts_styles['registers'][ $ref ]['type'] = $type; |
|
286 | + $this->_scripts_styles['registers'][$ref]['type'] = $type; |
|
287 | 287 | // let's make sure we're not missing any REQUIRED parameters |
288 | 288 | if (empty($url)) { |
289 | 289 | $msg[] = sprintf( |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | 'Doublecheck your <code>$this->_scripts_styles</code> array in %s and make sure that there is a "url" set for the %s ref', |
296 | 296 | 'event_espresso' |
297 | 297 | ), |
298 | - '<strong>' . $this->caller . '</strong>', |
|
298 | + '<strong>'.$this->caller.'</strong>', |
|
299 | 299 | $ref |
300 | 300 | ); |
301 | 301 | throw new EE_Error(implode('||', $msg)); |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | ); |
312 | 312 | } |
313 | 313 | // k now lets do the enqueues |
314 | - if (! isset($this->_scripts_styles['enqueues'])) { |
|
314 | + if ( ! isset($this->_scripts_styles['enqueues'])) { |
|
315 | 315 | return; |
316 | 316 | } //not sure if we should throw an error here or not. |
317 | 317 | |
@@ -319,22 +319,22 @@ discard block |
||
319 | 319 | // make sure $routes is an array |
320 | 320 | $routes = (array) $routes; |
321 | 321 | if (in_array($this->_current_route, $routes)) { |
322 | - $this->_scripts_styles['registers'][ $ref ]['type'] == 'js' ? wp_enqueue_script($ref) |
|
322 | + $this->_scripts_styles['registers'][$ref]['type'] == 'js' ? wp_enqueue_script($ref) |
|
323 | 323 | : wp_enqueue_style($ref); |
324 | 324 | // if we have a localization for the script let's do that too. |
325 | - if (isset($this->_scripts_styles['localize'][ $ref ])) { |
|
326 | - foreach ($this->_scripts_styles['localize'][ $ref ] as $object_name => $indexes) { |
|
325 | + if (isset($this->_scripts_styles['localize'][$ref])) { |
|
326 | + foreach ($this->_scripts_styles['localize'][$ref] as $object_name => $indexes) { |
|
327 | 327 | wp_localize_script( |
328 | 328 | $ref, |
329 | 329 | $object_name, |
330 | - $this->_scripts_styles['localize'][ $ref ][ $object_name ] |
|
330 | + $this->_scripts_styles['localize'][$ref][$object_name] |
|
331 | 331 | ); |
332 | 332 | } |
333 | 333 | } |
334 | 334 | } |
335 | 335 | } |
336 | 336 | // let's do the deregisters |
337 | - if (! isset($this->_scripts_styles['deregisters'])) { |
|
337 | + if ( ! isset($this->_scripts_styles['deregisters'])) { |
|
338 | 338 | return; |
339 | 339 | } |
340 | 340 | foreach ($this->_scripts_styles['deregisters'] as $ref => $details) { |
@@ -396,20 +396,20 @@ discard block |
||
396 | 396 | throw new EE_Error(implode('||', $msg)); |
397 | 397 | } |
398 | 398 | $ref = str_replace('_', ' ', $this->_name); // take the_message -> the message |
399 | - $ref = str_replace(' ', '_', ucwords($ref)) . '_Admin_Page'; // take the message -> The_Message |
|
399 | + $ref = str_replace(' ', '_', ucwords($ref)).'_Admin_Page'; // take the message -> The_Message |
|
400 | 400 | // first default file (if exists) |
401 | - $decaf_file = EE_ADMIN_PAGES . $this->_name . '/' . $ref . '.core.php'; |
|
401 | + $decaf_file = EE_ADMIN_PAGES.$this->_name.'/'.$ref.'.core.php'; |
|
402 | 402 | if (is_readable($decaf_file)) { |
403 | 403 | require_once($decaf_file); |
404 | 404 | } |
405 | 405 | // now we have to do require for extended file (if needed) |
406 | 406 | if ($this->_extend) { |
407 | - require_once(EE_CORE_CAF_ADMIN_EXTEND . $this->_name . '/Extend_' . $ref . '.core.php'); |
|
407 | + require_once(EE_CORE_CAF_ADMIN_EXTEND.$this->_name.'/Extend_'.$ref.'.core.php'); |
|
408 | 408 | } |
409 | 409 | // if we've got an extended class we use that! |
410 | - $ref = $this->_extend ? 'Extend_' . $ref : $ref; |
|
410 | + $ref = $this->_extend ? 'Extend_'.$ref : $ref; |
|
411 | 411 | // let's make sure the class exists |
412 | - if (! class_exists($ref)) { |
|
412 | + if ( ! class_exists($ref)) { |
|
413 | 413 | $msg[] = __('We can\'t load the page object', 'event_espresso'); |
414 | 414 | $msg[] = sprintf( |
415 | 415 | __( |
@@ -451,28 +451,28 @@ discard block |
||
451 | 451 | // first the actions |
452 | 452 | // note that these action hooks will have the $query_args value available. |
453 | 453 | $admin_class_name = get_class($this->_adminpage_obj); |
454 | - if (method_exists($this, '_redirect_action_early_' . $this->_current_route)) { |
|
454 | + if (method_exists($this, '_redirect_action_early_'.$this->_current_route)) { |
|
455 | 455 | add_action( |
456 | 456 | 'AHEE__' |
457 | 457 | . $admin_class_name |
458 | 458 | . '___redirect_after_action__before_redirect_modification_' |
459 | 459 | . $this->_current_route, |
460 | - array($this, '_redirect_action_early_' . $this->_current_route), |
|
460 | + array($this, '_redirect_action_early_'.$this->_current_route), |
|
461 | 461 | 10 |
462 | 462 | ); |
463 | 463 | } |
464 | - if (method_exists($this, '_redirect_action_' . $this->_current_route)) { |
|
464 | + if (method_exists($this, '_redirect_action_'.$this->_current_route)) { |
|
465 | 465 | add_action( |
466 | - 'AHEE_redirect_' . $admin_class_name . $this->_current_route, |
|
467 | - array($this, '_redirect_action_' . $this->_current_route), |
|
466 | + 'AHEE_redirect_'.$admin_class_name.$this->_current_route, |
|
467 | + array($this, '_redirect_action_'.$this->_current_route), |
|
468 | 468 | 10 |
469 | 469 | ); |
470 | 470 | } |
471 | 471 | // let's hook into the _redirect itself and allow for changing where the user goes after redirect. This will have $query_args and $redirect_url available. |
472 | - if (method_exists($this, '_redirect_filter_' . $this->_current_route)) { |
|
472 | + if (method_exists($this, '_redirect_filter_'.$this->_current_route)) { |
|
473 | 473 | add_filter( |
474 | - 'FHEE_redirect_' . $admin_class_name . $this->_current_route, |
|
475 | - array($this, '_redirect_filter_' . $this->_current_route), |
|
474 | + 'FHEE_redirect_'.$admin_class_name.$this->_current_route, |
|
475 | + array($this, '_redirect_filter_'.$this->_current_route), |
|
476 | 476 | 10, |
477 | 477 | 2 |
478 | 478 | ); |
@@ -497,12 +497,12 @@ discard block |
||
497 | 497 | 'argnum' => 1, |
498 | 498 | 'priority' => 10, |
499 | 499 | ), |
500 | - 'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug . '_' . $this->_current_route => array( |
|
500 | + 'FHEE_list_table_views_'.$this->_adminpage_obj->page_slug.'_'.$this->_current_route => array( |
|
501 | 501 | 'type' => 'filter', |
502 | 502 | 'argnum' => 1, |
503 | 503 | 'priority' => 10, |
504 | 504 | ), |
505 | - 'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug => array( |
|
505 | + 'FHEE_list_table_views_'.$this->_adminpage_obj->page_slug => array( |
|
506 | 506 | 'type' => 'filter', |
507 | 507 | 'argnum' => 1, |
508 | 508 | 'priority' => 10, |
@@ -519,21 +519,21 @@ discard block |
||
519 | 519 | ), |
520 | 520 | ); |
521 | 521 | foreach ($hook_filter_array as $hook => $args) { |
522 | - if (method_exists($this, $this->_current_route . '_' . $hook)) { |
|
523 | - if (isset($this->_wp_action_filters_priority[ $hook ])) { |
|
524 | - $args['priority'] = $this->_wp_action_filters_priority[ $hook ]; |
|
522 | + if (method_exists($this, $this->_current_route.'_'.$hook)) { |
|
523 | + if (isset($this->_wp_action_filters_priority[$hook])) { |
|
524 | + $args['priority'] = $this->_wp_action_filters_priority[$hook]; |
|
525 | 525 | } |
526 | 526 | if ($args['type'] == 'action') { |
527 | 527 | add_action( |
528 | 528 | $hook, |
529 | - array($this, $this->_current_route . '_' . $hook), |
|
529 | + array($this, $this->_current_route.'_'.$hook), |
|
530 | 530 | $args['priority'], |
531 | 531 | $args['argnum'] |
532 | 532 | ); |
533 | 533 | } else { |
534 | 534 | add_filter( |
535 | 535 | $hook, |
536 | - array($this, $this->_current_route . '_' . $hook), |
|
536 | + array($this, $this->_current_route.'_'.$hook), |
|
537 | 537 | $args['priority'], |
538 | 538 | $args['argnum'] |
539 | 539 | ); |
@@ -556,11 +556,11 @@ discard block |
||
556 | 556 | } //get out there's nothing to take care of. |
557 | 557 | foreach ($this->_ajax_func as $action => $method) { |
558 | 558 | // make sure method exists |
559 | - if (! method_exists($this, $method)) { |
|
559 | + if ( ! method_exists($this, $method)) { |
|
560 | 560 | $msg[] = __( |
561 | 561 | 'There is no corresponding method for the hook labeled in the _ajax_func array', |
562 | 562 | 'event_espresso' |
563 | - ) . '<br />'; |
|
563 | + ).'<br />'; |
|
564 | 564 | $msg[] = sprintf( |
565 | 565 | __( |
566 | 566 | 'The method name given in the array is %s, check the spelling and make sure it exists in the %s class', |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | ); |
572 | 572 | throw new EE_Error(implode('||', $msg)); |
573 | 573 | } |
574 | - add_action('wp_ajax_' . $action, array($this, $method)); |
|
574 | + add_action('wp_ajax_'.$action, array($this, $method)); |
|
575 | 575 | } |
576 | 576 | } |
577 | 577 | |
@@ -590,11 +590,11 @@ discard block |
||
590 | 590 | $current_route = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'default'; |
591 | 591 | foreach ($this->_init_func as $route => $method) { |
592 | 592 | // make sure method exists |
593 | - if (! method_exists($this, $method)) { |
|
593 | + if ( ! method_exists($this, $method)) { |
|
594 | 594 | $msg[] = __( |
595 | 595 | 'There is no corresponding method for the hook labeled in the _init_func array', |
596 | 596 | 'event_espresso' |
597 | - ) . '<br />'; |
|
597 | + ).'<br />'; |
|
598 | 598 | $msg[] = sprintf( |
599 | 599 | __( |
600 | 600 | 'The method name given in the array is %s, check the spelling and make sure it exists in the %s class', |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | { |
633 | 633 | |
634 | 634 | foreach ($boxes as $box) { |
635 | - if (! isset($box['page_route'])) { |
|
635 | + if ( ! isset($box['page_route'])) { |
|
636 | 636 | continue; |
637 | 637 | } //we dont' have a valid array |
638 | 638 | // let's make sure $box['page_route'] is an array so the "foreach" will work. |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | // set defaults |
682 | 682 | $defaults = array( |
683 | 683 | 'func' => $func, |
684 | - 'id' => $this->caller . '_' . $func . '_metabox', |
|
684 | + 'id' => $this->caller.'_'.$func.'_metabox', |
|
685 | 685 | 'priority' => 'default', |
686 | 686 | 'label' => $this->caller, |
687 | 687 | 'context' => 'advanced', |
@@ -691,8 +691,8 @@ discard block |
||
691 | 691 | $args = wp_parse_args($args, $defaults); |
692 | 692 | extract($args); |
693 | 693 | // make sure method exists |
694 | - if (! method_exists($this, $func)) { |
|
695 | - $msg[] = __('There is no corresponding method to display the metabox content', 'event_espresso') . '<br />'; |
|
694 | + if ( ! method_exists($this, $func)) { |
|
695 | + $msg[] = __('There is no corresponding method to display the metabox content', 'event_espresso').'<br />'; |
|
696 | 696 | $msg[] = sprintf( |
697 | 697 | __( |
698 | 698 | 'The method name given in the array is %s, check the spelling and make sure it exists in the %s class', |
@@ -13,72 +13,72 @@ |
||
13 | 13 | trait BaseCoreAdmin |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * Core method for going to an Event Espresso Admin page. |
|
18 | - * @param string $page |
|
19 | - * @param string $action |
|
20 | - * @param string $additional_params |
|
21 | - */ |
|
22 | - public function amOnEventEspressoAdminPage($page = '', $action = '', $additional_params = '') |
|
23 | - { |
|
24 | - $this->actor()->amOnAdminPage(CoreAdmin::adminUrl($page, $action, $additional_params)); |
|
25 | - } |
|
16 | + /** |
|
17 | + * Core method for going to an Event Espresso Admin page. |
|
18 | + * @param string $page |
|
19 | + * @param string $action |
|
20 | + * @param string $additional_params |
|
21 | + */ |
|
22 | + public function amOnEventEspressoAdminPage($page = '', $action = '', $additional_params = '') |
|
23 | + { |
|
24 | + $this->actor()->amOnAdminPage(CoreAdmin::adminUrl($page, $action, $additional_params)); |
|
25 | + } |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * Helper method for returning an instance of the Actor. Intended to help with IDE fill out of methods. |
|
30 | - * @return \EventEspressoAcceptanceTester; |
|
31 | - */ |
|
32 | - protected function actor() |
|
33 | - { |
|
34 | - /** @var \EventEspressoAcceptanceTester $this */ |
|
35 | - return $this; |
|
36 | - } |
|
28 | + /** |
|
29 | + * Helper method for returning an instance of the Actor. Intended to help with IDE fill out of methods. |
|
30 | + * @return \EventEspressoAcceptanceTester; |
|
31 | + */ |
|
32 | + protected function actor() |
|
33 | + { |
|
34 | + /** @var \EventEspressoAcceptanceTester $this */ |
|
35 | + return $this; |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * Use this to set the per page option for a list table page. |
|
41 | - * Assumes you are on a page that has this field exposed. |
|
42 | - * |
|
43 | - * @param int|string $per_page_value |
|
44 | - * @throws \Codeception\Exception\TestRuntimeException |
|
45 | - */ |
|
46 | - public function setPerPageOptionForScreen($per_page_value) |
|
47 | - { |
|
48 | - $this->actor()->click(CoreAdmin::WP_SCREEN_SETTINGS_LINK_SELECTOR); |
|
49 | - $this->actor()->fillField(CoreAdmin::WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR, $per_page_value); |
|
50 | - $this->actor()->click(CoreAdmin::WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR); |
|
51 | - $this->actor()->wait(8); |
|
52 | - } |
|
39 | + /** |
|
40 | + * Use this to set the per page option for a list table page. |
|
41 | + * Assumes you are on a page that has this field exposed. |
|
42 | + * |
|
43 | + * @param int|string $per_page_value |
|
44 | + * @throws \Codeception\Exception\TestRuntimeException |
|
45 | + */ |
|
46 | + public function setPerPageOptionForScreen($per_page_value) |
|
47 | + { |
|
48 | + $this->actor()->click(CoreAdmin::WP_SCREEN_SETTINGS_LINK_SELECTOR); |
|
49 | + $this->actor()->fillField(CoreAdmin::WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR, $per_page_value); |
|
50 | + $this->actor()->click(CoreAdmin::WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR); |
|
51 | + $this->actor()->wait(8); |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * Use this to append a given value to a wpEditor instance. |
|
58 | - * How it works is it first switched the instance to the text (or html) view so that the textarea is exposed and |
|
59 | - * the value is added to the text area. |
|
60 | - * |
|
61 | - * @param $field_reference |
|
62 | - * @param $value |
|
63 | - * @throws \Codeception\Exception\ElementNotFound |
|
64 | - */ |
|
65 | - public function appendToWPEditorField($field_reference, $value) |
|
66 | - { |
|
67 | - $this->actor()->click(CoreAdmin::wpEditorTextTabSelector($field_reference)); |
|
68 | - $this->actor()->appendField(CoreAdmin::wpEditorTextAreaSelector($field_reference), $value); |
|
69 | - } |
|
56 | + /** |
|
57 | + * Use this to append a given value to a wpEditor instance. |
|
58 | + * How it works is it first switched the instance to the text (or html) view so that the textarea is exposed and |
|
59 | + * the value is added to the text area. |
|
60 | + * |
|
61 | + * @param $field_reference |
|
62 | + * @param $value |
|
63 | + * @throws \Codeception\Exception\ElementNotFound |
|
64 | + */ |
|
65 | + public function appendToWPEditorField($field_reference, $value) |
|
66 | + { |
|
67 | + $this->actor()->click(CoreAdmin::wpEditorTextTabSelector($field_reference)); |
|
68 | + $this->actor()->appendField(CoreAdmin::wpEditorTextAreaSelector($field_reference), $value); |
|
69 | + } |
|
70 | 70 | |
71 | 71 | |
72 | - /** |
|
73 | - * Use to select and submit the given bulk action. |
|
74 | - * @param string $bulk_action_option |
|
75 | - */ |
|
76 | - public function submitBulkActionOnListTable($bulk_action_option) |
|
77 | - { |
|
78 | - $this->actor()->selectOption( |
|
79 | - CoreAdmin::SELECTOR_LIST_TABLE_BULK_ACTION_FIELD, |
|
80 | - $bulk_action_option |
|
81 | - ); |
|
82 | - $this->actor()->click(CoreAdmin::SELECTOR_LIST_TABLE_BULK_ACTTION_APPLY); |
|
83 | - } |
|
72 | + /** |
|
73 | + * Use to select and submit the given bulk action. |
|
74 | + * @param string $bulk_action_option |
|
75 | + */ |
|
76 | + public function submitBulkActionOnListTable($bulk_action_option) |
|
77 | + { |
|
78 | + $this->actor()->selectOption( |
|
79 | + CoreAdmin::SELECTOR_LIST_TABLE_BULK_ACTION_FIELD, |
|
80 | + $bulk_action_option |
|
81 | + ); |
|
82 | + $this->actor()->click(CoreAdmin::SELECTOR_LIST_TABLE_BULK_ACTTION_APPLY); |
|
83 | + } |
|
84 | 84 | } |
@@ -16,129 +16,129 @@ |
||
16 | 16 | interface NoticesContainerInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @param string $notice |
|
21 | - * @param bool $dismissible |
|
22 | - * @param string $file |
|
23 | - * @param string $func |
|
24 | - * @param string $line |
|
25 | - */ |
|
26 | - public function addInformation($notice, $dismissible = true, $file = '', $func = '', $line = ''); |
|
19 | + /** |
|
20 | + * @param string $notice |
|
21 | + * @param bool $dismissible |
|
22 | + * @param string $file |
|
23 | + * @param string $func |
|
24 | + * @param string $line |
|
25 | + */ |
|
26 | + public function addInformation($notice, $dismissible = true, $file = '', $func = '', $line = ''); |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * @param string $notice |
|
31 | - * @param bool $dismissible |
|
32 | - * @param string $file |
|
33 | - * @param string $func |
|
34 | - * @param string $line |
|
35 | - * @return |
|
36 | - */ |
|
37 | - public function addAttention($notice, $dismissible = true, $file = '', $func = '', $line = ''); |
|
29 | + /** |
|
30 | + * @param string $notice |
|
31 | + * @param bool $dismissible |
|
32 | + * @param string $file |
|
33 | + * @param string $func |
|
34 | + * @param string $line |
|
35 | + * @return |
|
36 | + */ |
|
37 | + public function addAttention($notice, $dismissible = true, $file = '', $func = '', $line = ''); |
|
38 | 38 | |
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * @param string $notice |
|
43 | - * @param bool $dismissible |
|
44 | - * @param string $file |
|
45 | - * @param string $func |
|
46 | - * @param string $line |
|
47 | - */ |
|
48 | - public function addError($notice, $dismissible = true, $file, $func, $line); |
|
41 | + /** |
|
42 | + * @param string $notice |
|
43 | + * @param bool $dismissible |
|
44 | + * @param string $file |
|
45 | + * @param string $func |
|
46 | + * @param string $line |
|
47 | + */ |
|
48 | + public function addError($notice, $dismissible = true, $file, $func, $line); |
|
49 | 49 | |
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * @param string $notice |
|
54 | - * @param bool $dismissible |
|
55 | - * @param string $file |
|
56 | - * @param string $func |
|
57 | - * @param string $line |
|
58 | - */ |
|
59 | - public function addSuccess($notice, $dismissible = true, $file = '', $func = '', $line = ''); |
|
52 | + /** |
|
53 | + * @param string $notice |
|
54 | + * @param bool $dismissible |
|
55 | + * @param string $file |
|
56 | + * @param string $func |
|
57 | + * @param string $line |
|
58 | + */ |
|
59 | + public function addSuccess($notice, $dismissible = true, $file = '', $func = '', $line = ''); |
|
60 | 60 | |
61 | 61 | |
62 | 62 | |
63 | - /** |
|
64 | - * @return boolean |
|
65 | - */ |
|
66 | - public function hasInformation(); |
|
63 | + /** |
|
64 | + * @return boolean |
|
65 | + */ |
|
66 | + public function hasInformation(); |
|
67 | 67 | |
68 | 68 | |
69 | 69 | |
70 | - /** |
|
71 | - * @return boolean |
|
72 | - */ |
|
73 | - public function hasAttention(); |
|
70 | + /** |
|
71 | + * @return boolean |
|
72 | + */ |
|
73 | + public function hasAttention(); |
|
74 | 74 | |
75 | 75 | |
76 | 76 | |
77 | - /** |
|
78 | - * @return boolean |
|
79 | - */ |
|
80 | - public function hasError(); |
|
77 | + /** |
|
78 | + * @return boolean |
|
79 | + */ |
|
80 | + public function hasError(); |
|
81 | 81 | |
82 | 82 | |
83 | 83 | |
84 | - /** |
|
85 | - * @return boolean |
|
86 | - */ |
|
87 | - public function hasSuccess(); |
|
84 | + /** |
|
85 | + * @return boolean |
|
86 | + */ |
|
87 | + public function hasSuccess(); |
|
88 | 88 | |
89 | 89 | |
90 | 90 | |
91 | - /** |
|
92 | - * @return int |
|
93 | - */ |
|
94 | - public function countInformation(); |
|
91 | + /** |
|
92 | + * @return int |
|
93 | + */ |
|
94 | + public function countInformation(); |
|
95 | 95 | |
96 | 96 | |
97 | 97 | |
98 | - /** |
|
99 | - * @return int |
|
100 | - */ |
|
101 | - public function countAttention(); |
|
98 | + /** |
|
99 | + * @return int |
|
100 | + */ |
|
101 | + public function countAttention(); |
|
102 | 102 | |
103 | 103 | |
104 | 104 | |
105 | - /** |
|
106 | - * @return int |
|
107 | - */ |
|
108 | - public function countError(); |
|
105 | + /** |
|
106 | + * @return int |
|
107 | + */ |
|
108 | + public function countError(); |
|
109 | 109 | |
110 | 110 | |
111 | 111 | |
112 | - /** |
|
113 | - * @return int |
|
114 | - */ |
|
115 | - public function countSuccess(); |
|
112 | + /** |
|
113 | + * @return int |
|
114 | + */ |
|
115 | + public function countSuccess(); |
|
116 | 116 | |
117 | 117 | |
118 | 118 | |
119 | - /** |
|
120 | - * @return NoticeInterface[] |
|
121 | - */ |
|
122 | - public function getInformation(); |
|
119 | + /** |
|
120 | + * @return NoticeInterface[] |
|
121 | + */ |
|
122 | + public function getInformation(); |
|
123 | 123 | |
124 | 124 | |
125 | 125 | |
126 | - /** |
|
127 | - * @return NoticeInterface[] |
|
128 | - */ |
|
129 | - public function getAttention(); |
|
126 | + /** |
|
127 | + * @return NoticeInterface[] |
|
128 | + */ |
|
129 | + public function getAttention(); |
|
130 | 130 | |
131 | 131 | |
132 | 132 | |
133 | - /** |
|
134 | - * @return NoticeInterface[] |
|
135 | - */ |
|
136 | - public function getError(); |
|
133 | + /** |
|
134 | + * @return NoticeInterface[] |
|
135 | + */ |
|
136 | + public function getError(); |
|
137 | 137 | |
138 | 138 | |
139 | 139 | |
140 | - /** |
|
141 | - * @return NoticeInterface[] |
|
142 | - */ |
|
143 | - public function getSuccess(); |
|
140 | + /** |
|
141 | + * @return NoticeInterface[] |
|
142 | + */ |
|
143 | + public function getSuccess(); |
|
144 | 144 | } |
@@ -36,7 +36,7 @@ |
||
36 | 36 | $error_string = esc_html__('The following errors occurred:', 'event_espresso'); |
37 | 37 | foreach ($notices->getError() as $notice) { |
38 | 38 | if ($this->getThrowExceptions()) { |
39 | - $error_string .= '<br />' . $notice->message(); |
|
39 | + $error_string .= '<br />'.$notice->message(); |
|
40 | 40 | } else { |
41 | 41 | new AdminNotice($notice); |
42 | 42 | } |
@@ -14,42 +14,42 @@ |
||
14 | 14 | class ConvertNoticesToAdminNotices extends NoticeConverter |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Converts Notice objects into AdminNotice notifications |
|
19 | - * |
|
20 | - * @param NoticesContainerInterface $notices |
|
21 | - * @throws DomainException |
|
22 | - */ |
|
23 | - public function process(NoticesContainerInterface $notices) |
|
24 | - { |
|
25 | - if ($notices->hasAttention()) { |
|
26 | - foreach ($notices->getAttention() as $notice) { |
|
27 | - new AdminNotice($notice); |
|
28 | - } |
|
29 | - } |
|
30 | - if ($notices->hasError()) { |
|
31 | - $error_string = esc_html__('The following errors occurred:', 'event_espresso'); |
|
32 | - foreach ($notices->getError() as $notice) { |
|
33 | - if ($this->getThrowExceptions()) { |
|
34 | - $error_string .= '<br />' . $notice->message(); |
|
35 | - } else { |
|
36 | - new AdminNotice($notice); |
|
37 | - } |
|
38 | - } |
|
39 | - if ($this->getThrowExceptions()) { |
|
40 | - throw new DomainException($error_string); |
|
41 | - } |
|
42 | - } |
|
43 | - if ($notices->hasSuccess()) { |
|
44 | - foreach ($notices->getSuccess() as $notice) { |
|
45 | - new AdminNotice($notice); |
|
46 | - } |
|
47 | - } |
|
48 | - if ($notices->hasInformation()) { |
|
49 | - foreach ($notices->getInformation() as $notice) { |
|
50 | - new AdminNotice($notice); |
|
51 | - } |
|
52 | - } |
|
53 | - $this->clearNotices(); |
|
54 | - } |
|
17 | + /** |
|
18 | + * Converts Notice objects into AdminNotice notifications |
|
19 | + * |
|
20 | + * @param NoticesContainerInterface $notices |
|
21 | + * @throws DomainException |
|
22 | + */ |
|
23 | + public function process(NoticesContainerInterface $notices) |
|
24 | + { |
|
25 | + if ($notices->hasAttention()) { |
|
26 | + foreach ($notices->getAttention() as $notice) { |
|
27 | + new AdminNotice($notice); |
|
28 | + } |
|
29 | + } |
|
30 | + if ($notices->hasError()) { |
|
31 | + $error_string = esc_html__('The following errors occurred:', 'event_espresso'); |
|
32 | + foreach ($notices->getError() as $notice) { |
|
33 | + if ($this->getThrowExceptions()) { |
|
34 | + $error_string .= '<br />' . $notice->message(); |
|
35 | + } else { |
|
36 | + new AdminNotice($notice); |
|
37 | + } |
|
38 | + } |
|
39 | + if ($this->getThrowExceptions()) { |
|
40 | + throw new DomainException($error_string); |
|
41 | + } |
|
42 | + } |
|
43 | + if ($notices->hasSuccess()) { |
|
44 | + foreach ($notices->getSuccess() as $notice) { |
|
45 | + new AdminNotice($notice); |
|
46 | + } |
|
47 | + } |
|
48 | + if ($notices->hasInformation()) { |
|
49 | + foreach ($notices->getInformation() as $notice) { |
|
50 | + new AdminNotice($notice); |
|
51 | + } |
|
52 | + } |
|
53 | + $this->clearNotices(); |
|
54 | + } |
|
55 | 55 | } |
@@ -924,7 +924,7 @@ |
||
924 | 924 | * handles toggling the checkin status for the registration, |
925 | 925 | * |
926 | 926 | * @access protected |
927 | - * @return int|void |
|
927 | + * @return integer |
|
928 | 928 | * @throws EE_Error |
929 | 929 | * @throws InvalidArgumentException |
930 | 930 | * @throws InvalidDataTypeException |
@@ -16,1267 +16,1267 @@ |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * This is used to hold the reports template data which is setup early in the request. |
|
21 | - * |
|
22 | - * @type array |
|
23 | - */ |
|
24 | - protected $_reports_template_data = array(); |
|
19 | + /** |
|
20 | + * This is used to hold the reports template data which is setup early in the request. |
|
21 | + * |
|
22 | + * @type array |
|
23 | + */ |
|
24 | + protected $_reports_template_data = array(); |
|
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * Extend_Registrations_Admin_Page constructor. |
|
29 | - * |
|
30 | - * @param bool $routing |
|
31 | - */ |
|
32 | - public function __construct($routing = true) |
|
33 | - { |
|
34 | - parent::__construct($routing); |
|
35 | - if (! defined('REG_CAF_TEMPLATE_PATH')) { |
|
36 | - define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
37 | - define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
38 | - define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
39 | - } |
|
40 | - } |
|
27 | + /** |
|
28 | + * Extend_Registrations_Admin_Page constructor. |
|
29 | + * |
|
30 | + * @param bool $routing |
|
31 | + */ |
|
32 | + public function __construct($routing = true) |
|
33 | + { |
|
34 | + parent::__construct($routing); |
|
35 | + if (! defined('REG_CAF_TEMPLATE_PATH')) { |
|
36 | + define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
37 | + define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
38 | + define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
39 | + } |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * Extending page configuration. |
|
45 | - */ |
|
46 | - protected function _extend_page_config() |
|
47 | - { |
|
48 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
49 | - $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
50 | - ? $this->_req_data['_REG_ID'] |
|
51 | - : 0; |
|
52 | - $new_page_routes = array( |
|
53 | - 'reports' => array( |
|
54 | - 'func' => '_registration_reports', |
|
55 | - 'capability' => 'ee_read_registrations', |
|
56 | - ), |
|
57 | - 'registration_checkins' => array( |
|
58 | - 'func' => '_registration_checkin_list_table', |
|
59 | - 'capability' => 'ee_read_checkins', |
|
60 | - ), |
|
61 | - 'newsletter_selected_send' => array( |
|
62 | - 'func' => '_newsletter_selected_send', |
|
63 | - 'noheader' => true, |
|
64 | - 'capability' => 'ee_send_message', |
|
65 | - ), |
|
66 | - 'delete_checkin_rows' => array( |
|
67 | - 'func' => '_delete_checkin_rows', |
|
68 | - 'noheader' => true, |
|
69 | - 'capability' => 'ee_delete_checkins', |
|
70 | - ), |
|
71 | - 'delete_checkin_row' => array( |
|
72 | - 'func' => '_delete_checkin_row', |
|
73 | - 'noheader' => true, |
|
74 | - 'capability' => 'ee_delete_checkin', |
|
75 | - 'obj_id' => $reg_id, |
|
76 | - ), |
|
77 | - 'toggle_checkin_status' => array( |
|
78 | - 'func' => '_toggle_checkin_status', |
|
79 | - 'noheader' => true, |
|
80 | - 'capability' => 'ee_edit_checkin', |
|
81 | - 'obj_id' => $reg_id, |
|
82 | - ), |
|
83 | - 'toggle_checkin_status_bulk' => array( |
|
84 | - 'func' => '_toggle_checkin_status', |
|
85 | - 'noheader' => true, |
|
86 | - 'capability' => 'ee_edit_checkins', |
|
87 | - ), |
|
88 | - 'event_registrations' => array( |
|
89 | - 'func' => '_event_registrations_list_table', |
|
90 | - 'capability' => 'ee_read_checkins', |
|
91 | - ), |
|
92 | - 'registrations_checkin_report' => array( |
|
93 | - 'func' => '_registrations_checkin_report', |
|
94 | - 'noheader' => true, |
|
95 | - 'capability' => 'ee_read_registrations', |
|
96 | - ), |
|
97 | - ); |
|
98 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
99 | - $new_page_config = array( |
|
100 | - 'reports' => array( |
|
101 | - 'nav' => array( |
|
102 | - 'label' => esc_html__('Reports', 'event_espresso'), |
|
103 | - 'order' => 30, |
|
104 | - ), |
|
105 | - 'help_tabs' => array( |
|
106 | - 'registrations_reports_help_tab' => array( |
|
107 | - 'title' => esc_html__('Registration Reports', 'event_espresso'), |
|
108 | - 'filename' => 'registrations_reports', |
|
109 | - ), |
|
110 | - ), |
|
111 | - /*'help_tour' => array( 'Registration_Reports_Help_Tour' ),*/ |
|
112 | - 'require_nonce' => false, |
|
113 | - ), |
|
114 | - 'event_registrations' => array( |
|
115 | - 'nav' => array( |
|
116 | - 'label' => esc_html__('Event Check-In', 'event_espresso'), |
|
117 | - 'order' => 10, |
|
118 | - 'persistent' => true, |
|
119 | - ), |
|
120 | - 'help_tabs' => array( |
|
121 | - 'registrations_event_checkin_help_tab' => array( |
|
122 | - 'title' => esc_html__('Registrations Event Check-In', 'event_espresso'), |
|
123 | - 'filename' => 'registrations_event_checkin', |
|
124 | - ), |
|
125 | - 'registrations_event_checkin_table_column_headings_help_tab' => array( |
|
126 | - 'title' => esc_html__('Event Check-In Table Column Headings', 'event_espresso'), |
|
127 | - 'filename' => 'registrations_event_checkin_table_column_headings', |
|
128 | - ), |
|
129 | - 'registrations_event_checkin_filters_help_tab' => array( |
|
130 | - 'title' => esc_html__('Event Check-In Filters', 'event_espresso'), |
|
131 | - 'filename' => 'registrations_event_checkin_filters', |
|
132 | - ), |
|
133 | - 'registrations_event_checkin_views_help_tab' => array( |
|
134 | - 'title' => esc_html__('Event Check-In Views', 'event_espresso'), |
|
135 | - 'filename' => 'registrations_event_checkin_views', |
|
136 | - ), |
|
137 | - 'registrations_event_checkin_other_help_tab' => array( |
|
138 | - 'title' => esc_html__('Event Check-In Other', 'event_espresso'), |
|
139 | - 'filename' => 'registrations_event_checkin_other', |
|
140 | - ), |
|
141 | - ), |
|
142 | - 'help_tour' => array('Event_Checkin_Help_Tour'), |
|
143 | - 'qtips' => array('Registration_List_Table_Tips'), |
|
144 | - 'list_table' => 'EE_Event_Registrations_List_Table', |
|
145 | - 'metaboxes' => array(), |
|
146 | - 'require_nonce' => false, |
|
147 | - ), |
|
148 | - 'registration_checkins' => array( |
|
149 | - 'nav' => array( |
|
150 | - 'label' => esc_html__('Check-In Records', 'event_espresso'), |
|
151 | - 'order' => 15, |
|
152 | - 'persistent' => false, |
|
153 | - 'url' => '', |
|
154 | - ), |
|
155 | - 'list_table' => 'EE_Registration_CheckIn_List_Table', |
|
156 | - // 'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ), |
|
157 | - 'metaboxes' => array(), |
|
158 | - 'require_nonce' => false, |
|
159 | - ), |
|
160 | - ); |
|
161 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
162 | - $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table'; |
|
163 | - $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table'; |
|
164 | - } |
|
43 | + /** |
|
44 | + * Extending page configuration. |
|
45 | + */ |
|
46 | + protected function _extend_page_config() |
|
47 | + { |
|
48 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
49 | + $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
50 | + ? $this->_req_data['_REG_ID'] |
|
51 | + : 0; |
|
52 | + $new_page_routes = array( |
|
53 | + 'reports' => array( |
|
54 | + 'func' => '_registration_reports', |
|
55 | + 'capability' => 'ee_read_registrations', |
|
56 | + ), |
|
57 | + 'registration_checkins' => array( |
|
58 | + 'func' => '_registration_checkin_list_table', |
|
59 | + 'capability' => 'ee_read_checkins', |
|
60 | + ), |
|
61 | + 'newsletter_selected_send' => array( |
|
62 | + 'func' => '_newsletter_selected_send', |
|
63 | + 'noheader' => true, |
|
64 | + 'capability' => 'ee_send_message', |
|
65 | + ), |
|
66 | + 'delete_checkin_rows' => array( |
|
67 | + 'func' => '_delete_checkin_rows', |
|
68 | + 'noheader' => true, |
|
69 | + 'capability' => 'ee_delete_checkins', |
|
70 | + ), |
|
71 | + 'delete_checkin_row' => array( |
|
72 | + 'func' => '_delete_checkin_row', |
|
73 | + 'noheader' => true, |
|
74 | + 'capability' => 'ee_delete_checkin', |
|
75 | + 'obj_id' => $reg_id, |
|
76 | + ), |
|
77 | + 'toggle_checkin_status' => array( |
|
78 | + 'func' => '_toggle_checkin_status', |
|
79 | + 'noheader' => true, |
|
80 | + 'capability' => 'ee_edit_checkin', |
|
81 | + 'obj_id' => $reg_id, |
|
82 | + ), |
|
83 | + 'toggle_checkin_status_bulk' => array( |
|
84 | + 'func' => '_toggle_checkin_status', |
|
85 | + 'noheader' => true, |
|
86 | + 'capability' => 'ee_edit_checkins', |
|
87 | + ), |
|
88 | + 'event_registrations' => array( |
|
89 | + 'func' => '_event_registrations_list_table', |
|
90 | + 'capability' => 'ee_read_checkins', |
|
91 | + ), |
|
92 | + 'registrations_checkin_report' => array( |
|
93 | + 'func' => '_registrations_checkin_report', |
|
94 | + 'noheader' => true, |
|
95 | + 'capability' => 'ee_read_registrations', |
|
96 | + ), |
|
97 | + ); |
|
98 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
99 | + $new_page_config = array( |
|
100 | + 'reports' => array( |
|
101 | + 'nav' => array( |
|
102 | + 'label' => esc_html__('Reports', 'event_espresso'), |
|
103 | + 'order' => 30, |
|
104 | + ), |
|
105 | + 'help_tabs' => array( |
|
106 | + 'registrations_reports_help_tab' => array( |
|
107 | + 'title' => esc_html__('Registration Reports', 'event_espresso'), |
|
108 | + 'filename' => 'registrations_reports', |
|
109 | + ), |
|
110 | + ), |
|
111 | + /*'help_tour' => array( 'Registration_Reports_Help_Tour' ),*/ |
|
112 | + 'require_nonce' => false, |
|
113 | + ), |
|
114 | + 'event_registrations' => array( |
|
115 | + 'nav' => array( |
|
116 | + 'label' => esc_html__('Event Check-In', 'event_espresso'), |
|
117 | + 'order' => 10, |
|
118 | + 'persistent' => true, |
|
119 | + ), |
|
120 | + 'help_tabs' => array( |
|
121 | + 'registrations_event_checkin_help_tab' => array( |
|
122 | + 'title' => esc_html__('Registrations Event Check-In', 'event_espresso'), |
|
123 | + 'filename' => 'registrations_event_checkin', |
|
124 | + ), |
|
125 | + 'registrations_event_checkin_table_column_headings_help_tab' => array( |
|
126 | + 'title' => esc_html__('Event Check-In Table Column Headings', 'event_espresso'), |
|
127 | + 'filename' => 'registrations_event_checkin_table_column_headings', |
|
128 | + ), |
|
129 | + 'registrations_event_checkin_filters_help_tab' => array( |
|
130 | + 'title' => esc_html__('Event Check-In Filters', 'event_espresso'), |
|
131 | + 'filename' => 'registrations_event_checkin_filters', |
|
132 | + ), |
|
133 | + 'registrations_event_checkin_views_help_tab' => array( |
|
134 | + 'title' => esc_html__('Event Check-In Views', 'event_espresso'), |
|
135 | + 'filename' => 'registrations_event_checkin_views', |
|
136 | + ), |
|
137 | + 'registrations_event_checkin_other_help_tab' => array( |
|
138 | + 'title' => esc_html__('Event Check-In Other', 'event_espresso'), |
|
139 | + 'filename' => 'registrations_event_checkin_other', |
|
140 | + ), |
|
141 | + ), |
|
142 | + 'help_tour' => array('Event_Checkin_Help_Tour'), |
|
143 | + 'qtips' => array('Registration_List_Table_Tips'), |
|
144 | + 'list_table' => 'EE_Event_Registrations_List_Table', |
|
145 | + 'metaboxes' => array(), |
|
146 | + 'require_nonce' => false, |
|
147 | + ), |
|
148 | + 'registration_checkins' => array( |
|
149 | + 'nav' => array( |
|
150 | + 'label' => esc_html__('Check-In Records', 'event_espresso'), |
|
151 | + 'order' => 15, |
|
152 | + 'persistent' => false, |
|
153 | + 'url' => '', |
|
154 | + ), |
|
155 | + 'list_table' => 'EE_Registration_CheckIn_List_Table', |
|
156 | + // 'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ), |
|
157 | + 'metaboxes' => array(), |
|
158 | + 'require_nonce' => false, |
|
159 | + ), |
|
160 | + ); |
|
161 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
162 | + $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table'; |
|
163 | + $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table'; |
|
164 | + } |
|
165 | 165 | |
166 | 166 | |
167 | - /** |
|
168 | - * Ajax hooks for all routes in this page. |
|
169 | - */ |
|
170 | - protected function _ajax_hooks() |
|
171 | - { |
|
172 | - parent::_ajax_hooks(); |
|
173 | - add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content')); |
|
174 | - } |
|
167 | + /** |
|
168 | + * Ajax hooks for all routes in this page. |
|
169 | + */ |
|
170 | + protected function _ajax_hooks() |
|
171 | + { |
|
172 | + parent::_ajax_hooks(); |
|
173 | + add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content')); |
|
174 | + } |
|
175 | 175 | |
176 | 176 | |
177 | - /** |
|
178 | - * Global scripts for all routes in this page. |
|
179 | - */ |
|
180 | - public function load_scripts_styles() |
|
181 | - { |
|
182 | - parent::load_scripts_styles(); |
|
183 | - // if newsletter message type is active then let's add filter and load js for it. |
|
184 | - if (EEH_MSG_Template::is_mt_active('newsletter')) { |
|
185 | - // enqueue newsletter js |
|
186 | - wp_enqueue_script( |
|
187 | - 'ee-newsletter-trigger', |
|
188 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
189 | - array('ee-dialog'), |
|
190 | - EVENT_ESPRESSO_VERSION, |
|
191 | - true |
|
192 | - ); |
|
193 | - wp_enqueue_style( |
|
194 | - 'ee-newsletter-trigger-css', |
|
195 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
196 | - array(), |
|
197 | - EVENT_ESPRESSO_VERSION |
|
198 | - ); |
|
199 | - // hook in buttons for newsletter message type trigger. |
|
200 | - add_action( |
|
201 | - 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', |
|
202 | - array($this, 'add_newsletter_action_buttons'), |
|
203 | - 10 |
|
204 | - ); |
|
205 | - } |
|
206 | - } |
|
177 | + /** |
|
178 | + * Global scripts for all routes in this page. |
|
179 | + */ |
|
180 | + public function load_scripts_styles() |
|
181 | + { |
|
182 | + parent::load_scripts_styles(); |
|
183 | + // if newsletter message type is active then let's add filter and load js for it. |
|
184 | + if (EEH_MSG_Template::is_mt_active('newsletter')) { |
|
185 | + // enqueue newsletter js |
|
186 | + wp_enqueue_script( |
|
187 | + 'ee-newsletter-trigger', |
|
188 | + REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
189 | + array('ee-dialog'), |
|
190 | + EVENT_ESPRESSO_VERSION, |
|
191 | + true |
|
192 | + ); |
|
193 | + wp_enqueue_style( |
|
194 | + 'ee-newsletter-trigger-css', |
|
195 | + REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
196 | + array(), |
|
197 | + EVENT_ESPRESSO_VERSION |
|
198 | + ); |
|
199 | + // hook in buttons for newsletter message type trigger. |
|
200 | + add_action( |
|
201 | + 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', |
|
202 | + array($this, 'add_newsletter_action_buttons'), |
|
203 | + 10 |
|
204 | + ); |
|
205 | + } |
|
206 | + } |
|
207 | 207 | |
208 | 208 | |
209 | - /** |
|
210 | - * Scripts and styles for just the reports route. |
|
211 | - */ |
|
212 | - public function load_scripts_styles_reports() |
|
213 | - { |
|
214 | - wp_register_script( |
|
215 | - 'ee-reg-reports-js', |
|
216 | - REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
217 | - array('google-charts'), |
|
218 | - EVENT_ESPRESSO_VERSION, |
|
219 | - true |
|
220 | - ); |
|
221 | - wp_enqueue_script('ee-reg-reports-js'); |
|
222 | - $this->_registration_reports_js_setup(); |
|
223 | - } |
|
209 | + /** |
|
210 | + * Scripts and styles for just the reports route. |
|
211 | + */ |
|
212 | + public function load_scripts_styles_reports() |
|
213 | + { |
|
214 | + wp_register_script( |
|
215 | + 'ee-reg-reports-js', |
|
216 | + REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
217 | + array('google-charts'), |
|
218 | + EVENT_ESPRESSO_VERSION, |
|
219 | + true |
|
220 | + ); |
|
221 | + wp_enqueue_script('ee-reg-reports-js'); |
|
222 | + $this->_registration_reports_js_setup(); |
|
223 | + } |
|
224 | 224 | |
225 | 225 | |
226 | - /** |
|
227 | - * Register screen options for event_registrations route. |
|
228 | - */ |
|
229 | - protected function _add_screen_options_event_registrations() |
|
230 | - { |
|
231 | - $this->_per_page_screen_option(); |
|
232 | - } |
|
226 | + /** |
|
227 | + * Register screen options for event_registrations route. |
|
228 | + */ |
|
229 | + protected function _add_screen_options_event_registrations() |
|
230 | + { |
|
231 | + $this->_per_page_screen_option(); |
|
232 | + } |
|
233 | 233 | |
234 | 234 | |
235 | - /** |
|
236 | - * Register screen options for registration_checkins route |
|
237 | - */ |
|
238 | - protected function _add_screen_options_registration_checkins() |
|
239 | - { |
|
240 | - $page_title = $this->_admin_page_title; |
|
241 | - $this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso'); |
|
242 | - $this->_per_page_screen_option(); |
|
243 | - $this->_admin_page_title = $page_title; |
|
244 | - } |
|
235 | + /** |
|
236 | + * Register screen options for registration_checkins route |
|
237 | + */ |
|
238 | + protected function _add_screen_options_registration_checkins() |
|
239 | + { |
|
240 | + $page_title = $this->_admin_page_title; |
|
241 | + $this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso'); |
|
242 | + $this->_per_page_screen_option(); |
|
243 | + $this->_admin_page_title = $page_title; |
|
244 | + } |
|
245 | 245 | |
246 | 246 | |
247 | - /** |
|
248 | - * Set views property for event_registrations route. |
|
249 | - */ |
|
250 | - protected function _set_list_table_views_event_registrations() |
|
251 | - { |
|
252 | - $this->_views = array( |
|
253 | - 'all' => array( |
|
254 | - 'slug' => 'all', |
|
255 | - 'label' => esc_html__('All', 'event_espresso'), |
|
256 | - 'count' => 0, |
|
257 | - 'bulk_action' => ! isset($this->_req_data['event_id']) |
|
258 | - ? array() |
|
259 | - : array( |
|
260 | - 'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'), |
|
261 | - ), |
|
262 | - ), |
|
263 | - ); |
|
264 | - } |
|
247 | + /** |
|
248 | + * Set views property for event_registrations route. |
|
249 | + */ |
|
250 | + protected function _set_list_table_views_event_registrations() |
|
251 | + { |
|
252 | + $this->_views = array( |
|
253 | + 'all' => array( |
|
254 | + 'slug' => 'all', |
|
255 | + 'label' => esc_html__('All', 'event_espresso'), |
|
256 | + 'count' => 0, |
|
257 | + 'bulk_action' => ! isset($this->_req_data['event_id']) |
|
258 | + ? array() |
|
259 | + : array( |
|
260 | + 'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'), |
|
261 | + ), |
|
262 | + ), |
|
263 | + ); |
|
264 | + } |
|
265 | 265 | |
266 | 266 | |
267 | - /** |
|
268 | - * Set views property for registration_checkins route. |
|
269 | - */ |
|
270 | - protected function _set_list_table_views_registration_checkins() |
|
271 | - { |
|
272 | - $this->_views = array( |
|
273 | - 'all' => array( |
|
274 | - 'slug' => 'all', |
|
275 | - 'label' => esc_html__('All', 'event_espresso'), |
|
276 | - 'count' => 0, |
|
277 | - 'bulk_action' => array('delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')), |
|
278 | - ), |
|
279 | - ); |
|
280 | - } |
|
267 | + /** |
|
268 | + * Set views property for registration_checkins route. |
|
269 | + */ |
|
270 | + protected function _set_list_table_views_registration_checkins() |
|
271 | + { |
|
272 | + $this->_views = array( |
|
273 | + 'all' => array( |
|
274 | + 'slug' => 'all', |
|
275 | + 'label' => esc_html__('All', 'event_espresso'), |
|
276 | + 'count' => 0, |
|
277 | + 'bulk_action' => array('delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')), |
|
278 | + ), |
|
279 | + ); |
|
280 | + } |
|
281 | 281 | |
282 | 282 | |
283 | - /** |
|
284 | - * callback for ajax action. |
|
285 | - * |
|
286 | - * @since 4.3.0 |
|
287 | - * @return void (JSON) |
|
288 | - * @throws EE_Error |
|
289 | - * @throws InvalidArgumentException |
|
290 | - * @throws InvalidDataTypeException |
|
291 | - * @throws InvalidInterfaceException |
|
292 | - */ |
|
293 | - public function get_newsletter_form_content() |
|
294 | - { |
|
295 | - // do a nonce check cause we're not coming in from an normal route here. |
|
296 | - $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field( |
|
297 | - $this->_req_data['get_newsletter_form_content_nonce'] |
|
298 | - ) : ''; |
|
299 | - $nonce_ref = 'get_newsletter_form_content_nonce'; |
|
300 | - $this->_verify_nonce($nonce, $nonce_ref); |
|
301 | - // let's get the mtp for the incoming MTP_ ID |
|
302 | - if (! isset($this->_req_data['GRP_ID'])) { |
|
303 | - EE_Error::add_error( |
|
304 | - esc_html__( |
|
305 | - 'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', |
|
306 | - 'event_espresso' |
|
307 | - ), |
|
308 | - __FILE__, |
|
309 | - __FUNCTION__, |
|
310 | - __LINE__ |
|
311 | - ); |
|
312 | - $this->_template_args['success'] = false; |
|
313 | - $this->_template_args['error'] = true; |
|
314 | - $this->_return_json(); |
|
315 | - } |
|
316 | - $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
|
317 | - if (! $MTPG instanceof EE_Message_Template_Group) { |
|
318 | - EE_Error::add_error( |
|
319 | - sprintf( |
|
320 | - esc_html__( |
|
321 | - 'The GRP_ID given (%d) does not appear to have a corresponding row in the database.', |
|
322 | - 'event_espresso' |
|
323 | - ), |
|
324 | - $this->_req_data['GRP_ID'] |
|
325 | - ), |
|
326 | - __FILE__, |
|
327 | - __FUNCTION__, |
|
328 | - __LINE__ |
|
329 | - ); |
|
330 | - $this->_template_args['success'] = false; |
|
331 | - $this->_template_args['error'] = true; |
|
332 | - $this->_return_json(); |
|
333 | - } |
|
334 | - $MTPs = $MTPG->context_templates(); |
|
335 | - $MTPs = $MTPs['attendee']; |
|
336 | - $template_fields = array(); |
|
337 | - /** @var EE_Message_Template $MTP */ |
|
338 | - foreach ($MTPs as $MTP) { |
|
339 | - $field = $MTP->get('MTP_template_field'); |
|
340 | - if ($field === 'content') { |
|
341 | - $content = $MTP->get('MTP_content'); |
|
342 | - if (! empty($content['newsletter_content'])) { |
|
343 | - $template_fields['newsletter_content'] = $content['newsletter_content']; |
|
344 | - } |
|
345 | - continue; |
|
346 | - } |
|
347 | - $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content'); |
|
348 | - } |
|
349 | - $this->_template_args['success'] = true; |
|
350 | - $this->_template_args['error'] = false; |
|
351 | - $this->_template_args['data'] = array( |
|
352 | - 'batch_message_from' => isset($template_fields['from']) |
|
353 | - ? $template_fields['from'] |
|
354 | - : '', |
|
355 | - 'batch_message_subject' => isset($template_fields['subject']) |
|
356 | - ? $template_fields['subject'] |
|
357 | - : '', |
|
358 | - 'batch_message_content' => isset($template_fields['newsletter_content']) |
|
359 | - ? $template_fields['newsletter_content'] |
|
360 | - : '', |
|
361 | - ); |
|
362 | - $this->_return_json(); |
|
363 | - } |
|
283 | + /** |
|
284 | + * callback for ajax action. |
|
285 | + * |
|
286 | + * @since 4.3.0 |
|
287 | + * @return void (JSON) |
|
288 | + * @throws EE_Error |
|
289 | + * @throws InvalidArgumentException |
|
290 | + * @throws InvalidDataTypeException |
|
291 | + * @throws InvalidInterfaceException |
|
292 | + */ |
|
293 | + public function get_newsletter_form_content() |
|
294 | + { |
|
295 | + // do a nonce check cause we're not coming in from an normal route here. |
|
296 | + $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field( |
|
297 | + $this->_req_data['get_newsletter_form_content_nonce'] |
|
298 | + ) : ''; |
|
299 | + $nonce_ref = 'get_newsletter_form_content_nonce'; |
|
300 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
301 | + // let's get the mtp for the incoming MTP_ ID |
|
302 | + if (! isset($this->_req_data['GRP_ID'])) { |
|
303 | + EE_Error::add_error( |
|
304 | + esc_html__( |
|
305 | + 'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', |
|
306 | + 'event_espresso' |
|
307 | + ), |
|
308 | + __FILE__, |
|
309 | + __FUNCTION__, |
|
310 | + __LINE__ |
|
311 | + ); |
|
312 | + $this->_template_args['success'] = false; |
|
313 | + $this->_template_args['error'] = true; |
|
314 | + $this->_return_json(); |
|
315 | + } |
|
316 | + $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
|
317 | + if (! $MTPG instanceof EE_Message_Template_Group) { |
|
318 | + EE_Error::add_error( |
|
319 | + sprintf( |
|
320 | + esc_html__( |
|
321 | + 'The GRP_ID given (%d) does not appear to have a corresponding row in the database.', |
|
322 | + 'event_espresso' |
|
323 | + ), |
|
324 | + $this->_req_data['GRP_ID'] |
|
325 | + ), |
|
326 | + __FILE__, |
|
327 | + __FUNCTION__, |
|
328 | + __LINE__ |
|
329 | + ); |
|
330 | + $this->_template_args['success'] = false; |
|
331 | + $this->_template_args['error'] = true; |
|
332 | + $this->_return_json(); |
|
333 | + } |
|
334 | + $MTPs = $MTPG->context_templates(); |
|
335 | + $MTPs = $MTPs['attendee']; |
|
336 | + $template_fields = array(); |
|
337 | + /** @var EE_Message_Template $MTP */ |
|
338 | + foreach ($MTPs as $MTP) { |
|
339 | + $field = $MTP->get('MTP_template_field'); |
|
340 | + if ($field === 'content') { |
|
341 | + $content = $MTP->get('MTP_content'); |
|
342 | + if (! empty($content['newsletter_content'])) { |
|
343 | + $template_fields['newsletter_content'] = $content['newsletter_content']; |
|
344 | + } |
|
345 | + continue; |
|
346 | + } |
|
347 | + $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content'); |
|
348 | + } |
|
349 | + $this->_template_args['success'] = true; |
|
350 | + $this->_template_args['error'] = false; |
|
351 | + $this->_template_args['data'] = array( |
|
352 | + 'batch_message_from' => isset($template_fields['from']) |
|
353 | + ? $template_fields['from'] |
|
354 | + : '', |
|
355 | + 'batch_message_subject' => isset($template_fields['subject']) |
|
356 | + ? $template_fields['subject'] |
|
357 | + : '', |
|
358 | + 'batch_message_content' => isset($template_fields['newsletter_content']) |
|
359 | + ? $template_fields['newsletter_content'] |
|
360 | + : '', |
|
361 | + ); |
|
362 | + $this->_return_json(); |
|
363 | + } |
|
364 | 364 | |
365 | 365 | |
366 | - /** |
|
367 | - * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action |
|
368 | - * |
|
369 | - * @since 4.3.0 |
|
370 | - * @param EE_Admin_List_Table $list_table |
|
371 | - * @return void |
|
372 | - * @throws InvalidArgumentException |
|
373 | - * @throws InvalidDataTypeException |
|
374 | - * @throws InvalidInterfaceException |
|
375 | - */ |
|
376 | - public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) |
|
377 | - { |
|
378 | - if (! EE_Registry::instance()->CAP->current_user_can( |
|
379 | - 'ee_send_message', |
|
380 | - 'espresso_registrations_newsletter_selected_send' |
|
381 | - ) |
|
382 | - ) { |
|
383 | - return; |
|
384 | - } |
|
385 | - $routes_to_add_to = array( |
|
386 | - 'contact_list', |
|
387 | - 'event_registrations', |
|
388 | - 'default', |
|
389 | - ); |
|
390 | - if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) { |
|
391 | - if (($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id'])) |
|
392 | - || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash') |
|
393 | - ) { |
|
394 | - echo ''; |
|
395 | - } else { |
|
396 | - $button_text = sprintf( |
|
397 | - esc_html__('Send Batch Message (%s selected)', 'event_espresso'), |
|
398 | - '<span class="send-selected-newsletter-count">0</span>' |
|
399 | - ); |
|
400 | - echo '<button id="selected-batch-send-trigger" class="button secondary-button">' |
|
401 | - . '<span class="dashicons dashicons-email "></span>' |
|
402 | - . $button_text |
|
403 | - . '</button>'; |
|
404 | - add_action('admin_footer', array($this, 'newsletter_send_form_skeleton')); |
|
405 | - } |
|
406 | - } |
|
407 | - } |
|
366 | + /** |
|
367 | + * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action |
|
368 | + * |
|
369 | + * @since 4.3.0 |
|
370 | + * @param EE_Admin_List_Table $list_table |
|
371 | + * @return void |
|
372 | + * @throws InvalidArgumentException |
|
373 | + * @throws InvalidDataTypeException |
|
374 | + * @throws InvalidInterfaceException |
|
375 | + */ |
|
376 | + public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) |
|
377 | + { |
|
378 | + if (! EE_Registry::instance()->CAP->current_user_can( |
|
379 | + 'ee_send_message', |
|
380 | + 'espresso_registrations_newsletter_selected_send' |
|
381 | + ) |
|
382 | + ) { |
|
383 | + return; |
|
384 | + } |
|
385 | + $routes_to_add_to = array( |
|
386 | + 'contact_list', |
|
387 | + 'event_registrations', |
|
388 | + 'default', |
|
389 | + ); |
|
390 | + if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) { |
|
391 | + if (($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id'])) |
|
392 | + || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash') |
|
393 | + ) { |
|
394 | + echo ''; |
|
395 | + } else { |
|
396 | + $button_text = sprintf( |
|
397 | + esc_html__('Send Batch Message (%s selected)', 'event_espresso'), |
|
398 | + '<span class="send-selected-newsletter-count">0</span>' |
|
399 | + ); |
|
400 | + echo '<button id="selected-batch-send-trigger" class="button secondary-button">' |
|
401 | + . '<span class="dashicons dashicons-email "></span>' |
|
402 | + . $button_text |
|
403 | + . '</button>'; |
|
404 | + add_action('admin_footer', array($this, 'newsletter_send_form_skeleton')); |
|
405 | + } |
|
406 | + } |
|
407 | + } |
|
408 | 408 | |
409 | 409 | |
410 | - /** |
|
411 | - * @throws DomainException |
|
412 | - * @throws EE_Error |
|
413 | - * @throws InvalidArgumentException |
|
414 | - * @throws InvalidDataTypeException |
|
415 | - * @throws InvalidInterfaceException |
|
416 | - */ |
|
417 | - public function newsletter_send_form_skeleton() |
|
418 | - { |
|
419 | - $list_table = $this->_list_table_object; |
|
420 | - $codes = array(); |
|
421 | - // need to templates for the newsletter message type for the template selector. |
|
422 | - $values[] = array('text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0); |
|
423 | - $mtps = EEM_Message_Template_Group::instance()->get_all( |
|
424 | - array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email')) |
|
425 | - ); |
|
426 | - foreach ($mtps as $mtp) { |
|
427 | - $name = $mtp->name(); |
|
428 | - $values[] = array( |
|
429 | - 'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name, |
|
430 | - 'id' => $mtp->ID(), |
|
431 | - ); |
|
432 | - } |
|
433 | - // need to get a list of shortcodes that are available for the newsletter message type. |
|
434 | - $shortcodes = EEH_MSG_Template::get_shortcodes( |
|
435 | - 'newsletter', |
|
436 | - 'email', |
|
437 | - array(), |
|
438 | - 'attendee', |
|
439 | - false |
|
440 | - ); |
|
441 | - foreach ($shortcodes as $field => $shortcode_array) { |
|
442 | - $available_shortcodes = array(); |
|
443 | - foreach ($shortcode_array as $shortcode => $shortcode_details) { |
|
444 | - $field_id = $field === '[NEWSLETTER_CONTENT]' |
|
445 | - ? 'content' |
|
446 | - : $field; |
|
447 | - $field_id = 'batch-message-' . strtolower($field_id); |
|
448 | - $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="' |
|
449 | - . $shortcode |
|
450 | - . '" data-linked-input-id="' . $field_id . '">' |
|
451 | - . $shortcode |
|
452 | - . '</span>'; |
|
453 | - } |
|
454 | - $codes[ $field ] = implode(', ', $available_shortcodes); |
|
455 | - } |
|
456 | - $shortcodes = $codes; |
|
457 | - $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
458 | - $form_template_args = array( |
|
459 | - 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
|
460 | - 'form_route' => 'newsletter_selected_send', |
|
461 | - 'form_nonce_name' => 'newsletter_selected_send_nonce', |
|
462 | - 'form_nonce' => wp_create_nonce('newsletter_selected_send_nonce'), |
|
463 | - 'redirect_back_to' => $this->_req_action, |
|
464 | - 'ajax_nonce' => wp_create_nonce('get_newsletter_form_content_nonce'), |
|
465 | - 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values), |
|
466 | - 'shortcodes' => $shortcodes, |
|
467 | - 'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration', |
|
468 | - ); |
|
469 | - EEH_Template::display_template($form_template, $form_template_args); |
|
470 | - } |
|
410 | + /** |
|
411 | + * @throws DomainException |
|
412 | + * @throws EE_Error |
|
413 | + * @throws InvalidArgumentException |
|
414 | + * @throws InvalidDataTypeException |
|
415 | + * @throws InvalidInterfaceException |
|
416 | + */ |
|
417 | + public function newsletter_send_form_skeleton() |
|
418 | + { |
|
419 | + $list_table = $this->_list_table_object; |
|
420 | + $codes = array(); |
|
421 | + // need to templates for the newsletter message type for the template selector. |
|
422 | + $values[] = array('text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0); |
|
423 | + $mtps = EEM_Message_Template_Group::instance()->get_all( |
|
424 | + array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email')) |
|
425 | + ); |
|
426 | + foreach ($mtps as $mtp) { |
|
427 | + $name = $mtp->name(); |
|
428 | + $values[] = array( |
|
429 | + 'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name, |
|
430 | + 'id' => $mtp->ID(), |
|
431 | + ); |
|
432 | + } |
|
433 | + // need to get a list of shortcodes that are available for the newsletter message type. |
|
434 | + $shortcodes = EEH_MSG_Template::get_shortcodes( |
|
435 | + 'newsletter', |
|
436 | + 'email', |
|
437 | + array(), |
|
438 | + 'attendee', |
|
439 | + false |
|
440 | + ); |
|
441 | + foreach ($shortcodes as $field => $shortcode_array) { |
|
442 | + $available_shortcodes = array(); |
|
443 | + foreach ($shortcode_array as $shortcode => $shortcode_details) { |
|
444 | + $field_id = $field === '[NEWSLETTER_CONTENT]' |
|
445 | + ? 'content' |
|
446 | + : $field; |
|
447 | + $field_id = 'batch-message-' . strtolower($field_id); |
|
448 | + $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="' |
|
449 | + . $shortcode |
|
450 | + . '" data-linked-input-id="' . $field_id . '">' |
|
451 | + . $shortcode |
|
452 | + . '</span>'; |
|
453 | + } |
|
454 | + $codes[ $field ] = implode(', ', $available_shortcodes); |
|
455 | + } |
|
456 | + $shortcodes = $codes; |
|
457 | + $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
458 | + $form_template_args = array( |
|
459 | + 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
|
460 | + 'form_route' => 'newsletter_selected_send', |
|
461 | + 'form_nonce_name' => 'newsletter_selected_send_nonce', |
|
462 | + 'form_nonce' => wp_create_nonce('newsletter_selected_send_nonce'), |
|
463 | + 'redirect_back_to' => $this->_req_action, |
|
464 | + 'ajax_nonce' => wp_create_nonce('get_newsletter_form_content_nonce'), |
|
465 | + 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values), |
|
466 | + 'shortcodes' => $shortcodes, |
|
467 | + 'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration', |
|
468 | + ); |
|
469 | + EEH_Template::display_template($form_template, $form_template_args); |
|
470 | + } |
|
471 | 471 | |
472 | 472 | |
473 | - /** |
|
474 | - * Handles sending selected registrations/contacts a newsletter. |
|
475 | - * |
|
476 | - * @since 4.3.0 |
|
477 | - * @return void |
|
478 | - * @throws EE_Error |
|
479 | - * @throws InvalidArgumentException |
|
480 | - * @throws InvalidDataTypeException |
|
481 | - * @throws InvalidInterfaceException |
|
482 | - */ |
|
483 | - protected function _newsletter_selected_send() |
|
484 | - { |
|
485 | - $success = true; |
|
486 | - // first we need to make sure we have a GRP_ID so we know what template we're sending and updating! |
|
487 | - if (empty($this->_req_data['newsletter_mtp_selected'])) { |
|
488 | - EE_Error::add_error( |
|
489 | - esc_html__( |
|
490 | - 'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', |
|
491 | - 'event_espresso' |
|
492 | - ), |
|
493 | - __FILE__, |
|
494 | - __FUNCTION__, |
|
495 | - __LINE__ |
|
496 | - ); |
|
497 | - $success = false; |
|
498 | - } |
|
499 | - if ($success) { |
|
500 | - // update Message template in case there are any changes |
|
501 | - $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID( |
|
502 | - $this->_req_data['newsletter_mtp_selected'] |
|
503 | - ); |
|
504 | - $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group |
|
505 | - ? $Message_Template_Group->context_templates() |
|
506 | - : array(); |
|
507 | - if (empty($Message_Templates)) { |
|
508 | - EE_Error::add_error( |
|
509 | - esc_html__( |
|
510 | - 'Unable to retrieve message template fields from the db. Messages not sent.', |
|
511 | - 'event_espresso' |
|
512 | - ), |
|
513 | - __FILE__, |
|
514 | - __FUNCTION__, |
|
515 | - __LINE__ |
|
516 | - ); |
|
517 | - } |
|
518 | - // let's just update the specific fields |
|
519 | - foreach ($Message_Templates['attendee'] as $Message_Template) { |
|
520 | - if ($Message_Template instanceof EE_Message_Template) { |
|
521 | - $field = $Message_Template->get('MTP_template_field'); |
|
522 | - $content = $Message_Template->get('MTP_content'); |
|
523 | - $new_content = $content; |
|
524 | - switch ($field) { |
|
525 | - case 'from': |
|
526 | - $new_content = ! empty($this->_req_data['batch_message']['from']) |
|
527 | - ? $this->_req_data['batch_message']['from'] |
|
528 | - : $content; |
|
529 | - break; |
|
530 | - case 'subject': |
|
531 | - $new_content = ! empty($this->_req_data['batch_message']['subject']) |
|
532 | - ? $this->_req_data['batch_message']['subject'] |
|
533 | - : $content; |
|
534 | - break; |
|
535 | - case 'content': |
|
536 | - $new_content = $content; |
|
537 | - $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content']) |
|
538 | - ? $this->_req_data['batch_message']['content'] |
|
539 | - : $content['newsletter_content']; |
|
540 | - break; |
|
541 | - default: |
|
542 | - // continue the foreach loop, we don't want to set $new_content nor save. |
|
543 | - continue 2; |
|
544 | - } |
|
545 | - $Message_Template->set('MTP_content', $new_content); |
|
546 | - $Message_Template->save(); |
|
547 | - } |
|
548 | - } |
|
549 | - // great fields are updated! now let's make sure we just have contact objects (EE_Attendee). |
|
550 | - $id_type = ! empty($this->_req_data['batch_message']['id_type']) |
|
551 | - ? $this->_req_data['batch_message']['id_type'] |
|
552 | - : 'registration'; |
|
553 | - // id_type will affect how we assemble the ids. |
|
554 | - $ids = ! empty($this->_req_data['batch_message']['ids']) |
|
555 | - ? json_decode(stripslashes($this->_req_data['batch_message']['ids'])) |
|
556 | - : array(); |
|
557 | - $registrations_used_for_contact_data = array(); |
|
558 | - // using switch because eventually we'll have other contexts that will be used for generating messages. |
|
559 | - switch ($id_type) { |
|
560 | - case 'registration': |
|
561 | - $registrations_used_for_contact_data = EEM_Registration::instance()->get_all( |
|
562 | - array( |
|
563 | - array( |
|
564 | - 'REG_ID' => array('IN', $ids), |
|
565 | - ), |
|
566 | - ) |
|
567 | - ); |
|
568 | - break; |
|
569 | - case 'contact': |
|
570 | - $registrations_used_for_contact_data = EEM_Registration::instance() |
|
571 | - ->get_latest_registration_for_each_of_given_contacts( |
|
572 | - $ids |
|
573 | - ); |
|
574 | - break; |
|
575 | - } |
|
576 | - do_action_ref_array( |
|
577 | - 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
578 | - array( |
|
579 | - $registrations_used_for_contact_data, |
|
580 | - $Message_Template_Group->ID(), |
|
581 | - ) |
|
582 | - ); |
|
583 | - // kept for backward compat, internally we no longer use this action. |
|
584 | - // @deprecated 4.8.36.rc.002 |
|
585 | - $contacts = $id_type === 'registration' |
|
586 | - ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids) |
|
587 | - : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids)))); |
|
588 | - do_action_ref_array( |
|
589 | - 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', |
|
590 | - array( |
|
591 | - $contacts, |
|
592 | - $Message_Template_Group->ID(), |
|
593 | - ) |
|
594 | - ); |
|
595 | - } |
|
596 | - $query_args = array( |
|
597 | - 'action' => ! empty($this->_req_data['redirect_back_to']) |
|
598 | - ? $this->_req_data['redirect_back_to'] |
|
599 | - : 'default', |
|
600 | - ); |
|
601 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
602 | - } |
|
473 | + /** |
|
474 | + * Handles sending selected registrations/contacts a newsletter. |
|
475 | + * |
|
476 | + * @since 4.3.0 |
|
477 | + * @return void |
|
478 | + * @throws EE_Error |
|
479 | + * @throws InvalidArgumentException |
|
480 | + * @throws InvalidDataTypeException |
|
481 | + * @throws InvalidInterfaceException |
|
482 | + */ |
|
483 | + protected function _newsletter_selected_send() |
|
484 | + { |
|
485 | + $success = true; |
|
486 | + // first we need to make sure we have a GRP_ID so we know what template we're sending and updating! |
|
487 | + if (empty($this->_req_data['newsletter_mtp_selected'])) { |
|
488 | + EE_Error::add_error( |
|
489 | + esc_html__( |
|
490 | + 'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', |
|
491 | + 'event_espresso' |
|
492 | + ), |
|
493 | + __FILE__, |
|
494 | + __FUNCTION__, |
|
495 | + __LINE__ |
|
496 | + ); |
|
497 | + $success = false; |
|
498 | + } |
|
499 | + if ($success) { |
|
500 | + // update Message template in case there are any changes |
|
501 | + $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID( |
|
502 | + $this->_req_data['newsletter_mtp_selected'] |
|
503 | + ); |
|
504 | + $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group |
|
505 | + ? $Message_Template_Group->context_templates() |
|
506 | + : array(); |
|
507 | + if (empty($Message_Templates)) { |
|
508 | + EE_Error::add_error( |
|
509 | + esc_html__( |
|
510 | + 'Unable to retrieve message template fields from the db. Messages not sent.', |
|
511 | + 'event_espresso' |
|
512 | + ), |
|
513 | + __FILE__, |
|
514 | + __FUNCTION__, |
|
515 | + __LINE__ |
|
516 | + ); |
|
517 | + } |
|
518 | + // let's just update the specific fields |
|
519 | + foreach ($Message_Templates['attendee'] as $Message_Template) { |
|
520 | + if ($Message_Template instanceof EE_Message_Template) { |
|
521 | + $field = $Message_Template->get('MTP_template_field'); |
|
522 | + $content = $Message_Template->get('MTP_content'); |
|
523 | + $new_content = $content; |
|
524 | + switch ($field) { |
|
525 | + case 'from': |
|
526 | + $new_content = ! empty($this->_req_data['batch_message']['from']) |
|
527 | + ? $this->_req_data['batch_message']['from'] |
|
528 | + : $content; |
|
529 | + break; |
|
530 | + case 'subject': |
|
531 | + $new_content = ! empty($this->_req_data['batch_message']['subject']) |
|
532 | + ? $this->_req_data['batch_message']['subject'] |
|
533 | + : $content; |
|
534 | + break; |
|
535 | + case 'content': |
|
536 | + $new_content = $content; |
|
537 | + $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content']) |
|
538 | + ? $this->_req_data['batch_message']['content'] |
|
539 | + : $content['newsletter_content']; |
|
540 | + break; |
|
541 | + default: |
|
542 | + // continue the foreach loop, we don't want to set $new_content nor save. |
|
543 | + continue 2; |
|
544 | + } |
|
545 | + $Message_Template->set('MTP_content', $new_content); |
|
546 | + $Message_Template->save(); |
|
547 | + } |
|
548 | + } |
|
549 | + // great fields are updated! now let's make sure we just have contact objects (EE_Attendee). |
|
550 | + $id_type = ! empty($this->_req_data['batch_message']['id_type']) |
|
551 | + ? $this->_req_data['batch_message']['id_type'] |
|
552 | + : 'registration'; |
|
553 | + // id_type will affect how we assemble the ids. |
|
554 | + $ids = ! empty($this->_req_data['batch_message']['ids']) |
|
555 | + ? json_decode(stripslashes($this->_req_data['batch_message']['ids'])) |
|
556 | + : array(); |
|
557 | + $registrations_used_for_contact_data = array(); |
|
558 | + // using switch because eventually we'll have other contexts that will be used for generating messages. |
|
559 | + switch ($id_type) { |
|
560 | + case 'registration': |
|
561 | + $registrations_used_for_contact_data = EEM_Registration::instance()->get_all( |
|
562 | + array( |
|
563 | + array( |
|
564 | + 'REG_ID' => array('IN', $ids), |
|
565 | + ), |
|
566 | + ) |
|
567 | + ); |
|
568 | + break; |
|
569 | + case 'contact': |
|
570 | + $registrations_used_for_contact_data = EEM_Registration::instance() |
|
571 | + ->get_latest_registration_for_each_of_given_contacts( |
|
572 | + $ids |
|
573 | + ); |
|
574 | + break; |
|
575 | + } |
|
576 | + do_action_ref_array( |
|
577 | + 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
578 | + array( |
|
579 | + $registrations_used_for_contact_data, |
|
580 | + $Message_Template_Group->ID(), |
|
581 | + ) |
|
582 | + ); |
|
583 | + // kept for backward compat, internally we no longer use this action. |
|
584 | + // @deprecated 4.8.36.rc.002 |
|
585 | + $contacts = $id_type === 'registration' |
|
586 | + ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids) |
|
587 | + : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids)))); |
|
588 | + do_action_ref_array( |
|
589 | + 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', |
|
590 | + array( |
|
591 | + $contacts, |
|
592 | + $Message_Template_Group->ID(), |
|
593 | + ) |
|
594 | + ); |
|
595 | + } |
|
596 | + $query_args = array( |
|
597 | + 'action' => ! empty($this->_req_data['redirect_back_to']) |
|
598 | + ? $this->_req_data['redirect_back_to'] |
|
599 | + : 'default', |
|
600 | + ); |
|
601 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
602 | + } |
|
603 | 603 | |
604 | 604 | |
605 | - /** |
|
606 | - * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
607 | - * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method. |
|
608 | - */ |
|
609 | - protected function _registration_reports_js_setup() |
|
610 | - { |
|
611 | - $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report(); |
|
612 | - $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report(); |
|
613 | - } |
|
605 | + /** |
|
606 | + * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
607 | + * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method. |
|
608 | + */ |
|
609 | + protected function _registration_reports_js_setup() |
|
610 | + { |
|
611 | + $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report(); |
|
612 | + $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report(); |
|
613 | + } |
|
614 | 614 | |
615 | 615 | |
616 | - /** |
|
617 | - * generates Business Reports regarding Registrations |
|
618 | - * |
|
619 | - * @access protected |
|
620 | - * @return void |
|
621 | - * @throws DomainException |
|
622 | - */ |
|
623 | - protected function _registration_reports() |
|
624 | - { |
|
625 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
626 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
627 | - $template_path, |
|
628 | - $this->_reports_template_data, |
|
629 | - true |
|
630 | - ); |
|
631 | - // the final template wrapper |
|
632 | - $this->display_admin_page_with_no_sidebar(); |
|
633 | - } |
|
616 | + /** |
|
617 | + * generates Business Reports regarding Registrations |
|
618 | + * |
|
619 | + * @access protected |
|
620 | + * @return void |
|
621 | + * @throws DomainException |
|
622 | + */ |
|
623 | + protected function _registration_reports() |
|
624 | + { |
|
625 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
626 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
627 | + $template_path, |
|
628 | + $this->_reports_template_data, |
|
629 | + true |
|
630 | + ); |
|
631 | + // the final template wrapper |
|
632 | + $this->display_admin_page_with_no_sidebar(); |
|
633 | + } |
|
634 | 634 | |
635 | 635 | |
636 | - /** |
|
637 | - * Generates Business Report showing total registrations per day. |
|
638 | - * |
|
639 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
640 | - * @return string |
|
641 | - * @throws EE_Error |
|
642 | - * @throws InvalidArgumentException |
|
643 | - * @throws InvalidDataTypeException |
|
644 | - * @throws InvalidInterfaceException |
|
645 | - */ |
|
646 | - private function _registrations_per_day_report($period = '-1 month') |
|
647 | - { |
|
648 | - $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
|
649 | - $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
|
650 | - $results = (array) $results; |
|
651 | - $regs = array(); |
|
652 | - $subtitle = ''; |
|
653 | - if ($results) { |
|
654 | - $column_titles = array(); |
|
655 | - $tracker = 0; |
|
656 | - foreach ($results as $result) { |
|
657 | - $report_column_values = array(); |
|
658 | - foreach ($result as $property_name => $property_value) { |
|
659 | - $property_value = $property_name === 'Registration_REG_date' ? $property_value |
|
660 | - : (int) $property_value; |
|
661 | - $report_column_values[] = $property_value; |
|
662 | - if ($tracker === 0) { |
|
663 | - if ($property_name === 'Registration_REG_date') { |
|
664 | - $column_titles[] = esc_html__( |
|
665 | - 'Date (only days with registrations are shown)', |
|
666 | - 'event_espresso' |
|
667 | - ); |
|
668 | - } else { |
|
669 | - $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
670 | - } |
|
671 | - } |
|
672 | - } |
|
673 | - $tracker++; |
|
674 | - $regs[] = $report_column_values; |
|
675 | - } |
|
676 | - // make sure the column_titles is pushed to the beginning of the array |
|
677 | - array_unshift($regs, $column_titles); |
|
678 | - // setup the date range. |
|
679 | - $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
680 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
681 | - $ending_date = new DateTime("now", $DateTimeZone); |
|
682 | - $subtitle = sprintf( |
|
683 | - _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
|
684 | - $beginning_date->format('Y-m-d'), |
|
685 | - $ending_date->format('Y-m-d') |
|
686 | - ); |
|
687 | - } |
|
688 | - $report_title = esc_html__('Total Registrations per Day', 'event_espresso'); |
|
689 | - $report_params = array( |
|
690 | - 'title' => $report_title, |
|
691 | - 'subtitle' => $subtitle, |
|
692 | - 'id' => $report_ID, |
|
693 | - 'regs' => $regs, |
|
694 | - 'noResults' => empty($regs), |
|
695 | - 'noRegsMsg' => sprintf( |
|
696 | - esc_html__( |
|
697 | - '%sThere are currently no registration records in the last month for this report.%s', |
|
698 | - 'event_espresso' |
|
699 | - ), |
|
700 | - '<h2>' . $report_title . '</h2><p>', |
|
701 | - '</p>' |
|
702 | - ), |
|
703 | - ); |
|
704 | - wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params); |
|
705 | - return $report_ID; |
|
706 | - } |
|
636 | + /** |
|
637 | + * Generates Business Report showing total registrations per day. |
|
638 | + * |
|
639 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
640 | + * @return string |
|
641 | + * @throws EE_Error |
|
642 | + * @throws InvalidArgumentException |
|
643 | + * @throws InvalidDataTypeException |
|
644 | + * @throws InvalidInterfaceException |
|
645 | + */ |
|
646 | + private function _registrations_per_day_report($period = '-1 month') |
|
647 | + { |
|
648 | + $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
|
649 | + $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
|
650 | + $results = (array) $results; |
|
651 | + $regs = array(); |
|
652 | + $subtitle = ''; |
|
653 | + if ($results) { |
|
654 | + $column_titles = array(); |
|
655 | + $tracker = 0; |
|
656 | + foreach ($results as $result) { |
|
657 | + $report_column_values = array(); |
|
658 | + foreach ($result as $property_name => $property_value) { |
|
659 | + $property_value = $property_name === 'Registration_REG_date' ? $property_value |
|
660 | + : (int) $property_value; |
|
661 | + $report_column_values[] = $property_value; |
|
662 | + if ($tracker === 0) { |
|
663 | + if ($property_name === 'Registration_REG_date') { |
|
664 | + $column_titles[] = esc_html__( |
|
665 | + 'Date (only days with registrations are shown)', |
|
666 | + 'event_espresso' |
|
667 | + ); |
|
668 | + } else { |
|
669 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
670 | + } |
|
671 | + } |
|
672 | + } |
|
673 | + $tracker++; |
|
674 | + $regs[] = $report_column_values; |
|
675 | + } |
|
676 | + // make sure the column_titles is pushed to the beginning of the array |
|
677 | + array_unshift($regs, $column_titles); |
|
678 | + // setup the date range. |
|
679 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
680 | + $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
681 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
682 | + $subtitle = sprintf( |
|
683 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
|
684 | + $beginning_date->format('Y-m-d'), |
|
685 | + $ending_date->format('Y-m-d') |
|
686 | + ); |
|
687 | + } |
|
688 | + $report_title = esc_html__('Total Registrations per Day', 'event_espresso'); |
|
689 | + $report_params = array( |
|
690 | + 'title' => $report_title, |
|
691 | + 'subtitle' => $subtitle, |
|
692 | + 'id' => $report_ID, |
|
693 | + 'regs' => $regs, |
|
694 | + 'noResults' => empty($regs), |
|
695 | + 'noRegsMsg' => sprintf( |
|
696 | + esc_html__( |
|
697 | + '%sThere are currently no registration records in the last month for this report.%s', |
|
698 | + 'event_espresso' |
|
699 | + ), |
|
700 | + '<h2>' . $report_title . '</h2><p>', |
|
701 | + '</p>' |
|
702 | + ), |
|
703 | + ); |
|
704 | + wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params); |
|
705 | + return $report_ID; |
|
706 | + } |
|
707 | 707 | |
708 | 708 | |
709 | - /** |
|
710 | - * Generates Business Report showing total registrations per event. |
|
711 | - * |
|
712 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
713 | - * @return string |
|
714 | - * @throws EE_Error |
|
715 | - * @throws InvalidArgumentException |
|
716 | - * @throws InvalidDataTypeException |
|
717 | - * @throws InvalidInterfaceException |
|
718 | - */ |
|
719 | - private function _registrations_per_event_report($period = '-1 month') |
|
720 | - { |
|
721 | - $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
|
722 | - $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
|
723 | - $results = (array) $results; |
|
724 | - $regs = array(); |
|
725 | - $subtitle = ''; |
|
726 | - if ($results) { |
|
727 | - $column_titles = array(); |
|
728 | - $tracker = 0; |
|
729 | - foreach ($results as $result) { |
|
730 | - $report_column_values = array(); |
|
731 | - foreach ($result as $property_name => $property_value) { |
|
732 | - $property_value = $property_name === 'Registration_Event' ? wp_trim_words( |
|
733 | - $property_value, |
|
734 | - 4, |
|
735 | - '...' |
|
736 | - ) : (int) $property_value; |
|
737 | - $report_column_values[] = $property_value; |
|
738 | - if ($tracker === 0) { |
|
739 | - if ($property_name === 'Registration_Event') { |
|
740 | - $column_titles[] = esc_html__('Event', 'event_espresso'); |
|
741 | - } else { |
|
742 | - $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
743 | - } |
|
744 | - } |
|
745 | - } |
|
746 | - $tracker++; |
|
747 | - $regs[] = $report_column_values; |
|
748 | - } |
|
749 | - // make sure the column_titles is pushed to the beginning of the array |
|
750 | - array_unshift($regs, $column_titles); |
|
751 | - // setup the date range. |
|
752 | - $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
753 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
754 | - $ending_date = new DateTime("now", $DateTimeZone); |
|
755 | - $subtitle = sprintf( |
|
756 | - _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
|
757 | - $beginning_date->format('Y-m-d'), |
|
758 | - $ending_date->format('Y-m-d') |
|
759 | - ); |
|
760 | - } |
|
761 | - $report_title = esc_html__('Total Registrations per Event', 'event_espresso'); |
|
762 | - $report_params = array( |
|
763 | - 'title' => $report_title, |
|
764 | - 'subtitle' => $subtitle, |
|
765 | - 'id' => $report_ID, |
|
766 | - 'regs' => $regs, |
|
767 | - 'noResults' => empty($regs), |
|
768 | - 'noRegsMsg' => sprintf( |
|
769 | - esc_html__( |
|
770 | - '%sThere are currently no registration records in the last month for this report.%s', |
|
771 | - 'event_espresso' |
|
772 | - ), |
|
773 | - '<h2>' . $report_title . '</h2><p>', |
|
774 | - '</p>' |
|
775 | - ), |
|
776 | - ); |
|
777 | - wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params); |
|
778 | - return $report_ID; |
|
779 | - } |
|
709 | + /** |
|
710 | + * Generates Business Report showing total registrations per event. |
|
711 | + * |
|
712 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
713 | + * @return string |
|
714 | + * @throws EE_Error |
|
715 | + * @throws InvalidArgumentException |
|
716 | + * @throws InvalidDataTypeException |
|
717 | + * @throws InvalidInterfaceException |
|
718 | + */ |
|
719 | + private function _registrations_per_event_report($period = '-1 month') |
|
720 | + { |
|
721 | + $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
|
722 | + $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
|
723 | + $results = (array) $results; |
|
724 | + $regs = array(); |
|
725 | + $subtitle = ''; |
|
726 | + if ($results) { |
|
727 | + $column_titles = array(); |
|
728 | + $tracker = 0; |
|
729 | + foreach ($results as $result) { |
|
730 | + $report_column_values = array(); |
|
731 | + foreach ($result as $property_name => $property_value) { |
|
732 | + $property_value = $property_name === 'Registration_Event' ? wp_trim_words( |
|
733 | + $property_value, |
|
734 | + 4, |
|
735 | + '...' |
|
736 | + ) : (int) $property_value; |
|
737 | + $report_column_values[] = $property_value; |
|
738 | + if ($tracker === 0) { |
|
739 | + if ($property_name === 'Registration_Event') { |
|
740 | + $column_titles[] = esc_html__('Event', 'event_espresso'); |
|
741 | + } else { |
|
742 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
743 | + } |
|
744 | + } |
|
745 | + } |
|
746 | + $tracker++; |
|
747 | + $regs[] = $report_column_values; |
|
748 | + } |
|
749 | + // make sure the column_titles is pushed to the beginning of the array |
|
750 | + array_unshift($regs, $column_titles); |
|
751 | + // setup the date range. |
|
752 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
753 | + $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
754 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
755 | + $subtitle = sprintf( |
|
756 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
|
757 | + $beginning_date->format('Y-m-d'), |
|
758 | + $ending_date->format('Y-m-d') |
|
759 | + ); |
|
760 | + } |
|
761 | + $report_title = esc_html__('Total Registrations per Event', 'event_espresso'); |
|
762 | + $report_params = array( |
|
763 | + 'title' => $report_title, |
|
764 | + 'subtitle' => $subtitle, |
|
765 | + 'id' => $report_ID, |
|
766 | + 'regs' => $regs, |
|
767 | + 'noResults' => empty($regs), |
|
768 | + 'noRegsMsg' => sprintf( |
|
769 | + esc_html__( |
|
770 | + '%sThere are currently no registration records in the last month for this report.%s', |
|
771 | + 'event_espresso' |
|
772 | + ), |
|
773 | + '<h2>' . $report_title . '</h2><p>', |
|
774 | + '</p>' |
|
775 | + ), |
|
776 | + ); |
|
777 | + wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params); |
|
778 | + return $report_ID; |
|
779 | + } |
|
780 | 780 | |
781 | 781 | |
782 | - /** |
|
783 | - * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration) |
|
784 | - * |
|
785 | - * @access protected |
|
786 | - * @return void |
|
787 | - * @throws EE_Error |
|
788 | - * @throws InvalidArgumentException |
|
789 | - * @throws InvalidDataTypeException |
|
790 | - * @throws InvalidInterfaceException |
|
791 | - * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
792 | - */ |
|
793 | - protected function _registration_checkin_list_table() |
|
794 | - { |
|
795 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
796 | - $reg_id = isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : null; |
|
797 | - /** @var EE_Registration $registration */ |
|
798 | - $registration = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
799 | - if (! $registration instanceof EE_Registration) { |
|
800 | - throw new EE_Error( |
|
801 | - sprintf( |
|
802 | - esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'), |
|
803 | - $reg_id |
|
804 | - ) |
|
805 | - ); |
|
806 | - } |
|
807 | - $attendee = $registration->attendee(); |
|
808 | - $this->_admin_page_title .= $this->get_action_link_or_button( |
|
809 | - 'new_registration', |
|
810 | - 'add-registrant', |
|
811 | - array('event_id' => $registration->event_ID()), |
|
812 | - 'add-new-h2' |
|
813 | - ); |
|
814 | - $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
815 | - $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
816 | - $legend_items = array( |
|
817 | - 'checkin' => array( |
|
818 | - 'class' => $checked_in->cssClasses(), |
|
819 | - 'desc' => $checked_in->legendLabel(), |
|
820 | - ), |
|
821 | - 'checkout' => array( |
|
822 | - 'class' => $checked_out->cssClasses(), |
|
823 | - 'desc' => $checked_out->legendLabel(), |
|
824 | - ), |
|
825 | - ); |
|
826 | - $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
827 | - $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
828 | - /** @var EE_Datetime $datetime */ |
|
829 | - $datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id); |
|
830 | - $datetime_label = ''; |
|
831 | - if ($datetime instanceof EE_Datetime) { |
|
832 | - $datetime_label = $datetime->get_dtt_display_name(true); |
|
833 | - $datetime_label .= ! empty($datetime_label) |
|
834 | - ? ' (' . $datetime->get_dtt_display_name() . ')' |
|
835 | - : $datetime->get_dtt_display_name(); |
|
836 | - } |
|
837 | - $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration |
|
838 | - ? EE_Admin_Page::add_query_args_and_nonce( |
|
839 | - array( |
|
840 | - 'action' => 'event_registrations', |
|
841 | - 'event_id' => $registration->event_ID(), |
|
842 | - 'DTT_ID' => $dtt_id, |
|
843 | - ), |
|
844 | - $this->_admin_base_url |
|
845 | - ) |
|
846 | - : ''; |
|
847 | - $datetime_link = ! empty($datetime_link) |
|
848 | - ? '<a href="' . $datetime_link . '">' |
|
849 | - . '<span id="checkin-dtt">' |
|
850 | - . $datetime_label |
|
851 | - . '</span></a>' |
|
852 | - : $datetime_label; |
|
853 | - $attendee_name = $attendee instanceof EE_Attendee |
|
854 | - ? $attendee->full_name() |
|
855 | - : ''; |
|
856 | - $attendee_link = $attendee instanceof EE_Attendee |
|
857 | - ? $attendee->get_admin_details_link() |
|
858 | - : ''; |
|
859 | - $attendee_link = ! empty($attendee_link) |
|
860 | - ? '<a href="' . $attendee->get_admin_details_link() . '"' |
|
861 | - . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">' |
|
862 | - . '<span id="checkin-attendee-name">' |
|
863 | - . $attendee_name |
|
864 | - . '</span></a>' |
|
865 | - : ''; |
|
866 | - $event_link = $registration->event() instanceof EE_Event |
|
867 | - ? $registration->event()->get_admin_details_link() |
|
868 | - : ''; |
|
869 | - $event_link = ! empty($event_link) |
|
870 | - ? '<a href="' . $event_link . '"' |
|
871 | - . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">' |
|
872 | - . '<span id="checkin-event-name">' |
|
873 | - . $registration->event_name() |
|
874 | - . '</span>' |
|
875 | - . '</a>' |
|
876 | - : ''; |
|
877 | - $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
|
878 | - ? '<h2>' . sprintf( |
|
879 | - esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'), |
|
880 | - $attendee_link, |
|
881 | - $datetime_link, |
|
882 | - $event_link |
|
883 | - ) . '</h2>' |
|
884 | - : ''; |
|
885 | - $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
|
886 | - ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : ''; |
|
887 | - $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
|
888 | - ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
889 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
890 | - } |
|
782 | + /** |
|
783 | + * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration) |
|
784 | + * |
|
785 | + * @access protected |
|
786 | + * @return void |
|
787 | + * @throws EE_Error |
|
788 | + * @throws InvalidArgumentException |
|
789 | + * @throws InvalidDataTypeException |
|
790 | + * @throws InvalidInterfaceException |
|
791 | + * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
792 | + */ |
|
793 | + protected function _registration_checkin_list_table() |
|
794 | + { |
|
795 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
796 | + $reg_id = isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : null; |
|
797 | + /** @var EE_Registration $registration */ |
|
798 | + $registration = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
799 | + if (! $registration instanceof EE_Registration) { |
|
800 | + throw new EE_Error( |
|
801 | + sprintf( |
|
802 | + esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'), |
|
803 | + $reg_id |
|
804 | + ) |
|
805 | + ); |
|
806 | + } |
|
807 | + $attendee = $registration->attendee(); |
|
808 | + $this->_admin_page_title .= $this->get_action_link_or_button( |
|
809 | + 'new_registration', |
|
810 | + 'add-registrant', |
|
811 | + array('event_id' => $registration->event_ID()), |
|
812 | + 'add-new-h2' |
|
813 | + ); |
|
814 | + $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
815 | + $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
816 | + $legend_items = array( |
|
817 | + 'checkin' => array( |
|
818 | + 'class' => $checked_in->cssClasses(), |
|
819 | + 'desc' => $checked_in->legendLabel(), |
|
820 | + ), |
|
821 | + 'checkout' => array( |
|
822 | + 'class' => $checked_out->cssClasses(), |
|
823 | + 'desc' => $checked_out->legendLabel(), |
|
824 | + ), |
|
825 | + ); |
|
826 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
827 | + $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
828 | + /** @var EE_Datetime $datetime */ |
|
829 | + $datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id); |
|
830 | + $datetime_label = ''; |
|
831 | + if ($datetime instanceof EE_Datetime) { |
|
832 | + $datetime_label = $datetime->get_dtt_display_name(true); |
|
833 | + $datetime_label .= ! empty($datetime_label) |
|
834 | + ? ' (' . $datetime->get_dtt_display_name() . ')' |
|
835 | + : $datetime->get_dtt_display_name(); |
|
836 | + } |
|
837 | + $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration |
|
838 | + ? EE_Admin_Page::add_query_args_and_nonce( |
|
839 | + array( |
|
840 | + 'action' => 'event_registrations', |
|
841 | + 'event_id' => $registration->event_ID(), |
|
842 | + 'DTT_ID' => $dtt_id, |
|
843 | + ), |
|
844 | + $this->_admin_base_url |
|
845 | + ) |
|
846 | + : ''; |
|
847 | + $datetime_link = ! empty($datetime_link) |
|
848 | + ? '<a href="' . $datetime_link . '">' |
|
849 | + . '<span id="checkin-dtt">' |
|
850 | + . $datetime_label |
|
851 | + . '</span></a>' |
|
852 | + : $datetime_label; |
|
853 | + $attendee_name = $attendee instanceof EE_Attendee |
|
854 | + ? $attendee->full_name() |
|
855 | + : ''; |
|
856 | + $attendee_link = $attendee instanceof EE_Attendee |
|
857 | + ? $attendee->get_admin_details_link() |
|
858 | + : ''; |
|
859 | + $attendee_link = ! empty($attendee_link) |
|
860 | + ? '<a href="' . $attendee->get_admin_details_link() . '"' |
|
861 | + . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">' |
|
862 | + . '<span id="checkin-attendee-name">' |
|
863 | + . $attendee_name |
|
864 | + . '</span></a>' |
|
865 | + : ''; |
|
866 | + $event_link = $registration->event() instanceof EE_Event |
|
867 | + ? $registration->event()->get_admin_details_link() |
|
868 | + : ''; |
|
869 | + $event_link = ! empty($event_link) |
|
870 | + ? '<a href="' . $event_link . '"' |
|
871 | + . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">' |
|
872 | + . '<span id="checkin-event-name">' |
|
873 | + . $registration->event_name() |
|
874 | + . '</span>' |
|
875 | + . '</a>' |
|
876 | + : ''; |
|
877 | + $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
|
878 | + ? '<h2>' . sprintf( |
|
879 | + esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'), |
|
880 | + $attendee_link, |
|
881 | + $datetime_link, |
|
882 | + $event_link |
|
883 | + ) . '</h2>' |
|
884 | + : ''; |
|
885 | + $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
|
886 | + ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : ''; |
|
887 | + $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
|
888 | + ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
889 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
890 | + } |
|
891 | 891 | |
892 | 892 | |
893 | - /** |
|
894 | - * toggle the Check-in status for the given registration (coming from ajax) |
|
895 | - * |
|
896 | - * @return void (JSON) |
|
897 | - * @throws EE_Error |
|
898 | - * @throws InvalidArgumentException |
|
899 | - * @throws InvalidDataTypeException |
|
900 | - * @throws InvalidInterfaceException |
|
901 | - */ |
|
902 | - public function toggle_checkin_status() |
|
903 | - { |
|
904 | - // first make sure we have the necessary data |
|
905 | - if (! isset($this->_req_data['_regid'])) { |
|
906 | - EE_Error::add_error( |
|
907 | - esc_html__( |
|
908 | - 'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', |
|
909 | - 'event_espresso' |
|
910 | - ), |
|
911 | - __FILE__, |
|
912 | - __FUNCTION__, |
|
913 | - __LINE__ |
|
914 | - ); |
|
915 | - $this->_template_args['success'] = false; |
|
916 | - $this->_template_args['error'] = true; |
|
917 | - $this->_return_json(); |
|
918 | - }; |
|
919 | - // do a nonce check cause we're not coming in from an normal route here. |
|
920 | - $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce']) |
|
921 | - : ''; |
|
922 | - $nonce_ref = 'checkin_nonce'; |
|
923 | - $this->_verify_nonce($nonce, $nonce_ref); |
|
924 | - // beautiful! Made it this far so let's get the status. |
|
925 | - $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status()); |
|
926 | - // setup new class to return via ajax |
|
927 | - $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses(); |
|
928 | - $this->_template_args['success'] = true; |
|
929 | - $this->_return_json(); |
|
930 | - } |
|
893 | + /** |
|
894 | + * toggle the Check-in status for the given registration (coming from ajax) |
|
895 | + * |
|
896 | + * @return void (JSON) |
|
897 | + * @throws EE_Error |
|
898 | + * @throws InvalidArgumentException |
|
899 | + * @throws InvalidDataTypeException |
|
900 | + * @throws InvalidInterfaceException |
|
901 | + */ |
|
902 | + public function toggle_checkin_status() |
|
903 | + { |
|
904 | + // first make sure we have the necessary data |
|
905 | + if (! isset($this->_req_data['_regid'])) { |
|
906 | + EE_Error::add_error( |
|
907 | + esc_html__( |
|
908 | + 'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', |
|
909 | + 'event_espresso' |
|
910 | + ), |
|
911 | + __FILE__, |
|
912 | + __FUNCTION__, |
|
913 | + __LINE__ |
|
914 | + ); |
|
915 | + $this->_template_args['success'] = false; |
|
916 | + $this->_template_args['error'] = true; |
|
917 | + $this->_return_json(); |
|
918 | + }; |
|
919 | + // do a nonce check cause we're not coming in from an normal route here. |
|
920 | + $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce']) |
|
921 | + : ''; |
|
922 | + $nonce_ref = 'checkin_nonce'; |
|
923 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
924 | + // beautiful! Made it this far so let's get the status. |
|
925 | + $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status()); |
|
926 | + // setup new class to return via ajax |
|
927 | + $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses(); |
|
928 | + $this->_template_args['success'] = true; |
|
929 | + $this->_return_json(); |
|
930 | + } |
|
931 | 931 | |
932 | 932 | |
933 | - /** |
|
934 | - * handles toggling the checkin status for the registration, |
|
935 | - * |
|
936 | - * @access protected |
|
937 | - * @return int|void |
|
938 | - * @throws EE_Error |
|
939 | - * @throws InvalidArgumentException |
|
940 | - * @throws InvalidDataTypeException |
|
941 | - * @throws InvalidInterfaceException |
|
942 | - */ |
|
943 | - protected function _toggle_checkin_status() |
|
944 | - { |
|
945 | - // first let's get the query args out of the way for the redirect |
|
946 | - $query_args = array( |
|
947 | - 'action' => 'event_registrations', |
|
948 | - 'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
949 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null, |
|
950 | - ); |
|
951 | - $new_status = false; |
|
952 | - // bulk action check in toggle |
|
953 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
954 | - // cycle thru checkboxes |
|
955 | - while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
|
956 | - $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
957 | - $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID); |
|
958 | - } |
|
959 | - } elseif (isset($this->_req_data['_regid'])) { |
|
960 | - // coming from ajax request |
|
961 | - $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null; |
|
962 | - $query_args['DTT_ID'] = $DTT_ID; |
|
963 | - $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID); |
|
964 | - } else { |
|
965 | - EE_Error::add_error( |
|
966 | - esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'), |
|
967 | - __FILE__, |
|
968 | - __FUNCTION__, |
|
969 | - __LINE__ |
|
970 | - ); |
|
971 | - } |
|
972 | - if (defined('DOING_AJAX')) { |
|
973 | - return $new_status; |
|
974 | - } |
|
975 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
976 | - } |
|
933 | + /** |
|
934 | + * handles toggling the checkin status for the registration, |
|
935 | + * |
|
936 | + * @access protected |
|
937 | + * @return int|void |
|
938 | + * @throws EE_Error |
|
939 | + * @throws InvalidArgumentException |
|
940 | + * @throws InvalidDataTypeException |
|
941 | + * @throws InvalidInterfaceException |
|
942 | + */ |
|
943 | + protected function _toggle_checkin_status() |
|
944 | + { |
|
945 | + // first let's get the query args out of the way for the redirect |
|
946 | + $query_args = array( |
|
947 | + 'action' => 'event_registrations', |
|
948 | + 'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
949 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null, |
|
950 | + ); |
|
951 | + $new_status = false; |
|
952 | + // bulk action check in toggle |
|
953 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
954 | + // cycle thru checkboxes |
|
955 | + while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
|
956 | + $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
957 | + $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID); |
|
958 | + } |
|
959 | + } elseif (isset($this->_req_data['_regid'])) { |
|
960 | + // coming from ajax request |
|
961 | + $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null; |
|
962 | + $query_args['DTT_ID'] = $DTT_ID; |
|
963 | + $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID); |
|
964 | + } else { |
|
965 | + EE_Error::add_error( |
|
966 | + esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'), |
|
967 | + __FILE__, |
|
968 | + __FUNCTION__, |
|
969 | + __LINE__ |
|
970 | + ); |
|
971 | + } |
|
972 | + if (defined('DOING_AJAX')) { |
|
973 | + return $new_status; |
|
974 | + } |
|
975 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
976 | + } |
|
977 | 977 | |
978 | 978 | |
979 | - /** |
|
980 | - * This is toggles a single Check-in for the given registration and datetime. |
|
981 | - * |
|
982 | - * @param int $REG_ID The registration we're toggling |
|
983 | - * @param int $DTT_ID The datetime we're toggling |
|
984 | - * @return int The new status toggled to. |
|
985 | - * @throws EE_Error |
|
986 | - * @throws InvalidArgumentException |
|
987 | - * @throws InvalidDataTypeException |
|
988 | - * @throws InvalidInterfaceException |
|
989 | - */ |
|
990 | - private function _toggle_checkin($REG_ID, $DTT_ID) |
|
991 | - { |
|
992 | - /** @var EE_Registration $REG */ |
|
993 | - $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
994 | - $new_status = $REG->toggle_checkin_status($DTT_ID); |
|
995 | - if ($new_status !== false) { |
|
996 | - EE_Error::add_success($REG->get_checkin_msg($DTT_ID)); |
|
997 | - } else { |
|
998 | - EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__); |
|
999 | - $new_status = false; |
|
1000 | - } |
|
1001 | - return $new_status; |
|
1002 | - } |
|
979 | + /** |
|
980 | + * This is toggles a single Check-in for the given registration and datetime. |
|
981 | + * |
|
982 | + * @param int $REG_ID The registration we're toggling |
|
983 | + * @param int $DTT_ID The datetime we're toggling |
|
984 | + * @return int The new status toggled to. |
|
985 | + * @throws EE_Error |
|
986 | + * @throws InvalidArgumentException |
|
987 | + * @throws InvalidDataTypeException |
|
988 | + * @throws InvalidInterfaceException |
|
989 | + */ |
|
990 | + private function _toggle_checkin($REG_ID, $DTT_ID) |
|
991 | + { |
|
992 | + /** @var EE_Registration $REG */ |
|
993 | + $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
994 | + $new_status = $REG->toggle_checkin_status($DTT_ID); |
|
995 | + if ($new_status !== false) { |
|
996 | + EE_Error::add_success($REG->get_checkin_msg($DTT_ID)); |
|
997 | + } else { |
|
998 | + EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__); |
|
999 | + $new_status = false; |
|
1000 | + } |
|
1001 | + return $new_status; |
|
1002 | + } |
|
1003 | 1003 | |
1004 | 1004 | |
1005 | - /** |
|
1006 | - * Takes care of deleting multiple EE_Checkin table rows |
|
1007 | - * |
|
1008 | - * @access protected |
|
1009 | - * @return void |
|
1010 | - * @throws EE_Error |
|
1011 | - * @throws InvalidArgumentException |
|
1012 | - * @throws InvalidDataTypeException |
|
1013 | - * @throws InvalidInterfaceException |
|
1014 | - */ |
|
1015 | - protected function _delete_checkin_rows() |
|
1016 | - { |
|
1017 | - $query_args = array( |
|
1018 | - 'action' => 'registration_checkins', |
|
1019 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
1020 | - '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
|
1021 | - ); |
|
1022 | - $errors = 0; |
|
1023 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1024 | - while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1025 | - if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
1026 | - $errors++; |
|
1027 | - } |
|
1028 | - } |
|
1029 | - } else { |
|
1030 | - EE_Error::add_error( |
|
1031 | - esc_html__( |
|
1032 | - 'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', |
|
1033 | - 'event_espresso' |
|
1034 | - ), |
|
1035 | - __FILE__, |
|
1036 | - __FUNCTION__, |
|
1037 | - __LINE__ |
|
1038 | - ); |
|
1039 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1040 | - } |
|
1041 | - if ($errors > 0) { |
|
1042 | - EE_Error::add_error( |
|
1043 | - sprintf(__('There were %d records that did not delete successfully', 'event_espresso'), $errors), |
|
1044 | - __FILE__, |
|
1045 | - __FUNCTION__, |
|
1046 | - __LINE__ |
|
1047 | - ); |
|
1048 | - } else { |
|
1049 | - EE_Error::add_success(__('Records were successfully deleted', 'event_espresso')); |
|
1050 | - } |
|
1051 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1052 | - } |
|
1005 | + /** |
|
1006 | + * Takes care of deleting multiple EE_Checkin table rows |
|
1007 | + * |
|
1008 | + * @access protected |
|
1009 | + * @return void |
|
1010 | + * @throws EE_Error |
|
1011 | + * @throws InvalidArgumentException |
|
1012 | + * @throws InvalidDataTypeException |
|
1013 | + * @throws InvalidInterfaceException |
|
1014 | + */ |
|
1015 | + protected function _delete_checkin_rows() |
|
1016 | + { |
|
1017 | + $query_args = array( |
|
1018 | + 'action' => 'registration_checkins', |
|
1019 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
1020 | + '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
|
1021 | + ); |
|
1022 | + $errors = 0; |
|
1023 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1024 | + while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1025 | + if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
1026 | + $errors++; |
|
1027 | + } |
|
1028 | + } |
|
1029 | + } else { |
|
1030 | + EE_Error::add_error( |
|
1031 | + esc_html__( |
|
1032 | + 'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', |
|
1033 | + 'event_espresso' |
|
1034 | + ), |
|
1035 | + __FILE__, |
|
1036 | + __FUNCTION__, |
|
1037 | + __LINE__ |
|
1038 | + ); |
|
1039 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1040 | + } |
|
1041 | + if ($errors > 0) { |
|
1042 | + EE_Error::add_error( |
|
1043 | + sprintf(__('There were %d records that did not delete successfully', 'event_espresso'), $errors), |
|
1044 | + __FILE__, |
|
1045 | + __FUNCTION__, |
|
1046 | + __LINE__ |
|
1047 | + ); |
|
1048 | + } else { |
|
1049 | + EE_Error::add_success(__('Records were successfully deleted', 'event_espresso')); |
|
1050 | + } |
|
1051 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1052 | + } |
|
1053 | 1053 | |
1054 | 1054 | |
1055 | - /** |
|
1056 | - * Deletes a single EE_Checkin row |
|
1057 | - * |
|
1058 | - * @return void |
|
1059 | - * @throws EE_Error |
|
1060 | - * @throws InvalidArgumentException |
|
1061 | - * @throws InvalidDataTypeException |
|
1062 | - * @throws InvalidInterfaceException |
|
1063 | - */ |
|
1064 | - protected function _delete_checkin_row() |
|
1065 | - { |
|
1066 | - $query_args = array( |
|
1067 | - 'action' => 'registration_checkins', |
|
1068 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
1069 | - '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
|
1070 | - ); |
|
1071 | - if (! empty($this->_req_data['CHK_ID'])) { |
|
1072 | - if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
1073 | - EE_Error::add_error( |
|
1074 | - esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
|
1075 | - __FILE__, |
|
1076 | - __FUNCTION__, |
|
1077 | - __LINE__ |
|
1078 | - ); |
|
1079 | - } else { |
|
1080 | - EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso')); |
|
1081 | - } |
|
1082 | - } else { |
|
1083 | - EE_Error::add_error( |
|
1084 | - esc_html__( |
|
1085 | - 'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', |
|
1086 | - 'event_espresso' |
|
1087 | - ), |
|
1088 | - __FILE__, |
|
1089 | - __FUNCTION__, |
|
1090 | - __LINE__ |
|
1091 | - ); |
|
1092 | - } |
|
1093 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1094 | - } |
|
1055 | + /** |
|
1056 | + * Deletes a single EE_Checkin row |
|
1057 | + * |
|
1058 | + * @return void |
|
1059 | + * @throws EE_Error |
|
1060 | + * @throws InvalidArgumentException |
|
1061 | + * @throws InvalidDataTypeException |
|
1062 | + * @throws InvalidInterfaceException |
|
1063 | + */ |
|
1064 | + protected function _delete_checkin_row() |
|
1065 | + { |
|
1066 | + $query_args = array( |
|
1067 | + 'action' => 'registration_checkins', |
|
1068 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
1069 | + '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
|
1070 | + ); |
|
1071 | + if (! empty($this->_req_data['CHK_ID'])) { |
|
1072 | + if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
1073 | + EE_Error::add_error( |
|
1074 | + esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
|
1075 | + __FILE__, |
|
1076 | + __FUNCTION__, |
|
1077 | + __LINE__ |
|
1078 | + ); |
|
1079 | + } else { |
|
1080 | + EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso')); |
|
1081 | + } |
|
1082 | + } else { |
|
1083 | + EE_Error::add_error( |
|
1084 | + esc_html__( |
|
1085 | + 'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', |
|
1086 | + 'event_espresso' |
|
1087 | + ), |
|
1088 | + __FILE__, |
|
1089 | + __FUNCTION__, |
|
1090 | + __LINE__ |
|
1091 | + ); |
|
1092 | + } |
|
1093 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1094 | + } |
|
1095 | 1095 | |
1096 | 1096 | |
1097 | - /** |
|
1098 | - * generates HTML for the Event Registrations List Table |
|
1099 | - * |
|
1100 | - * @access protected |
|
1101 | - * @return void |
|
1102 | - * @throws EE_Error |
|
1103 | - * @throws InvalidArgumentException |
|
1104 | - * @throws InvalidDataTypeException |
|
1105 | - * @throws InvalidInterfaceException |
|
1106 | - */ |
|
1107 | - protected function _event_registrations_list_table() |
|
1108 | - { |
|
1109 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1110 | - $this->_admin_page_title .= isset($this->_req_data['event_id']) |
|
1111 | - ? $this->get_action_link_or_button( |
|
1112 | - 'new_registration', |
|
1113 | - 'add-registrant', |
|
1114 | - array('event_id' => $this->_req_data['event_id']), |
|
1115 | - 'add-new-h2', |
|
1116 | - '', |
|
1117 | - false |
|
1118 | - ) |
|
1119 | - : ''; |
|
1120 | - $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
1121 | - $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
1122 | - $checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never); |
|
1123 | - $legend_items = array( |
|
1124 | - 'star-icon' => array( |
|
1125 | - 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
|
1126 | - 'desc' => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'), |
|
1127 | - ), |
|
1128 | - 'checkin' => array( |
|
1129 | - 'class' => $checked_in->cssClasses(), |
|
1130 | - 'desc' => $checked_in->legendLabel(), |
|
1131 | - ), |
|
1132 | - 'checkout' => array( |
|
1133 | - 'class' => $checked_out->cssClasses(), |
|
1134 | - 'desc' => $checked_out->legendLabel(), |
|
1135 | - ), |
|
1136 | - 'nocheckinrecord' => array( |
|
1137 | - 'class' => $checked_never->cssClasses(), |
|
1138 | - 'desc' => $checked_never->legendLabel(), |
|
1139 | - ), |
|
1140 | - 'approved_status' => array( |
|
1141 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
1142 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
1143 | - ), |
|
1144 | - 'cancelled_status' => array( |
|
1145 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
1146 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
1147 | - ), |
|
1148 | - 'declined_status' => array( |
|
1149 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
1150 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
1151 | - ), |
|
1152 | - 'not_approved' => array( |
|
1153 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
1154 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
1155 | - ), |
|
1156 | - 'pending_status' => array( |
|
1157 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
1158 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
1159 | - ), |
|
1160 | - 'wait_list' => array( |
|
1161 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
1162 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
1163 | - ), |
|
1164 | - ); |
|
1165 | - $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
1166 | - $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
1167 | - /** @var EE_Event $event */ |
|
1168 | - $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
1169 | - $this->_template_args['before_list_table'] = $event instanceof EE_Event |
|
1170 | - ? '<h2>' . sprintf( |
|
1171 | - esc_html__('Viewing Registrations for Event: %s', 'event_espresso'), |
|
1172 | - EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name') |
|
1173 | - ) . '</h2>' |
|
1174 | - : ''; |
|
1175 | - // need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on |
|
1176 | - // the event. |
|
1177 | - $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0; |
|
1178 | - $datetime = null; |
|
1179 | - if ($event instanceof EE_Event) { |
|
1180 | - $datetimes_on_event = $event->datetimes(); |
|
1181 | - if (count($datetimes_on_event) === 1) { |
|
1182 | - $datetime = reset($datetimes_on_event); |
|
1183 | - } |
|
1184 | - } |
|
1185 | - $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
1186 | - if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') { |
|
1187 | - $this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5); |
|
1188 | - $this->_template_args['before_list_table'] .= ' <span class="drk-grey-text">'; |
|
1189 | - $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
1190 | - $this->_template_args['before_list_table'] .= $datetime->name(); |
|
1191 | - $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
1192 | - $this->_template_args['before_list_table'] .= '</span></h2>'; |
|
1193 | - } |
|
1194 | - // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status |
|
1195 | - // column represents |
|
1196 | - if (! $datetime instanceof EE_Datetime) { |
|
1197 | - $this->_template_args['before_list_table'] .= '<br><p class="description">' |
|
1198 | - . esc_html__( |
|
1199 | - 'In this view, the check-in status represents the latest check-in record for the registration in that row.', |
|
1200 | - 'event_espresso' |
|
1201 | - ) |
|
1202 | - . '</p>'; |
|
1203 | - } |
|
1204 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
1205 | - } |
|
1097 | + /** |
|
1098 | + * generates HTML for the Event Registrations List Table |
|
1099 | + * |
|
1100 | + * @access protected |
|
1101 | + * @return void |
|
1102 | + * @throws EE_Error |
|
1103 | + * @throws InvalidArgumentException |
|
1104 | + * @throws InvalidDataTypeException |
|
1105 | + * @throws InvalidInterfaceException |
|
1106 | + */ |
|
1107 | + protected function _event_registrations_list_table() |
|
1108 | + { |
|
1109 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1110 | + $this->_admin_page_title .= isset($this->_req_data['event_id']) |
|
1111 | + ? $this->get_action_link_or_button( |
|
1112 | + 'new_registration', |
|
1113 | + 'add-registrant', |
|
1114 | + array('event_id' => $this->_req_data['event_id']), |
|
1115 | + 'add-new-h2', |
|
1116 | + '', |
|
1117 | + false |
|
1118 | + ) |
|
1119 | + : ''; |
|
1120 | + $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
1121 | + $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
1122 | + $checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never); |
|
1123 | + $legend_items = array( |
|
1124 | + 'star-icon' => array( |
|
1125 | + 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
|
1126 | + 'desc' => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'), |
|
1127 | + ), |
|
1128 | + 'checkin' => array( |
|
1129 | + 'class' => $checked_in->cssClasses(), |
|
1130 | + 'desc' => $checked_in->legendLabel(), |
|
1131 | + ), |
|
1132 | + 'checkout' => array( |
|
1133 | + 'class' => $checked_out->cssClasses(), |
|
1134 | + 'desc' => $checked_out->legendLabel(), |
|
1135 | + ), |
|
1136 | + 'nocheckinrecord' => array( |
|
1137 | + 'class' => $checked_never->cssClasses(), |
|
1138 | + 'desc' => $checked_never->legendLabel(), |
|
1139 | + ), |
|
1140 | + 'approved_status' => array( |
|
1141 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
1142 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
1143 | + ), |
|
1144 | + 'cancelled_status' => array( |
|
1145 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
1146 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
1147 | + ), |
|
1148 | + 'declined_status' => array( |
|
1149 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
1150 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
1151 | + ), |
|
1152 | + 'not_approved' => array( |
|
1153 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
1154 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
1155 | + ), |
|
1156 | + 'pending_status' => array( |
|
1157 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
1158 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
1159 | + ), |
|
1160 | + 'wait_list' => array( |
|
1161 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
1162 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
1163 | + ), |
|
1164 | + ); |
|
1165 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
1166 | + $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
1167 | + /** @var EE_Event $event */ |
|
1168 | + $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
1169 | + $this->_template_args['before_list_table'] = $event instanceof EE_Event |
|
1170 | + ? '<h2>' . sprintf( |
|
1171 | + esc_html__('Viewing Registrations for Event: %s', 'event_espresso'), |
|
1172 | + EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name') |
|
1173 | + ) . '</h2>' |
|
1174 | + : ''; |
|
1175 | + // need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on |
|
1176 | + // the event. |
|
1177 | + $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0; |
|
1178 | + $datetime = null; |
|
1179 | + if ($event instanceof EE_Event) { |
|
1180 | + $datetimes_on_event = $event->datetimes(); |
|
1181 | + if (count($datetimes_on_event) === 1) { |
|
1182 | + $datetime = reset($datetimes_on_event); |
|
1183 | + } |
|
1184 | + } |
|
1185 | + $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
1186 | + if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') { |
|
1187 | + $this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5); |
|
1188 | + $this->_template_args['before_list_table'] .= ' <span class="drk-grey-text">'; |
|
1189 | + $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
1190 | + $this->_template_args['before_list_table'] .= $datetime->name(); |
|
1191 | + $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
1192 | + $this->_template_args['before_list_table'] .= '</span></h2>'; |
|
1193 | + } |
|
1194 | + // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status |
|
1195 | + // column represents |
|
1196 | + if (! $datetime instanceof EE_Datetime) { |
|
1197 | + $this->_template_args['before_list_table'] .= '<br><p class="description">' |
|
1198 | + . esc_html__( |
|
1199 | + 'In this view, the check-in status represents the latest check-in record for the registration in that row.', |
|
1200 | + 'event_espresso' |
|
1201 | + ) |
|
1202 | + . '</p>'; |
|
1203 | + } |
|
1204 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
1205 | + } |
|
1206 | 1206 | |
1207 | - /** |
|
1208 | - * Download the registrations check-in report (same as the normal registration report, but with different where |
|
1209 | - * conditions) |
|
1210 | - * |
|
1211 | - * @return void ends the request by a redirect or download |
|
1212 | - */ |
|
1213 | - public function _registrations_checkin_report() |
|
1214 | - { |
|
1215 | - $this->_registrations_report_base('_get_checkin_query_params_from_request'); |
|
1216 | - } |
|
1207 | + /** |
|
1208 | + * Download the registrations check-in report (same as the normal registration report, but with different where |
|
1209 | + * conditions) |
|
1210 | + * |
|
1211 | + * @return void ends the request by a redirect or download |
|
1212 | + */ |
|
1213 | + public function _registrations_checkin_report() |
|
1214 | + { |
|
1215 | + $this->_registrations_report_base('_get_checkin_query_params_from_request'); |
|
1216 | + } |
|
1217 | 1217 | |
1218 | - /** |
|
1219 | - * Gets the query params from the request, plus adds a where condition for the registration status, |
|
1220 | - * because on the checkin page we only ever want to see approved and pending-approval registrations |
|
1221 | - * |
|
1222 | - * @param array $request |
|
1223 | - * @param int $per_page |
|
1224 | - * @param bool $count |
|
1225 | - * @return array |
|
1226 | - * @throws EE_Error |
|
1227 | - */ |
|
1228 | - protected function _get_checkin_query_params_from_request( |
|
1229 | - $request, |
|
1230 | - $per_page = 10, |
|
1231 | - $count = false |
|
1232 | - ) { |
|
1233 | - $query_params = $this->_get_registration_query_parameters($request, $per_page, $count); |
|
1234 | - // unlike the regular registrations list table, |
|
1235 | - $status_ids_array = apply_filters( |
|
1236 | - 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
1237 | - array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
1238 | - ); |
|
1239 | - $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
1240 | - return $query_params; |
|
1241 | - } |
|
1218 | + /** |
|
1219 | + * Gets the query params from the request, plus adds a where condition for the registration status, |
|
1220 | + * because on the checkin page we only ever want to see approved and pending-approval registrations |
|
1221 | + * |
|
1222 | + * @param array $request |
|
1223 | + * @param int $per_page |
|
1224 | + * @param bool $count |
|
1225 | + * @return array |
|
1226 | + * @throws EE_Error |
|
1227 | + */ |
|
1228 | + protected function _get_checkin_query_params_from_request( |
|
1229 | + $request, |
|
1230 | + $per_page = 10, |
|
1231 | + $count = false |
|
1232 | + ) { |
|
1233 | + $query_params = $this->_get_registration_query_parameters($request, $per_page, $count); |
|
1234 | + // unlike the regular registrations list table, |
|
1235 | + $status_ids_array = apply_filters( |
|
1236 | + 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
1237 | + array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
1238 | + ); |
|
1239 | + $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
1240 | + return $query_params; |
|
1241 | + } |
|
1242 | 1242 | |
1243 | 1243 | |
1244 | - /** |
|
1245 | - * Gets registrations for an event |
|
1246 | - * |
|
1247 | - * @param int $per_page |
|
1248 | - * @param bool $count whether to return count or data. |
|
1249 | - * @param bool $trash |
|
1250 | - * @param string $orderby |
|
1251 | - * @return EE_Registration[]|int |
|
1252 | - * @throws EE_Error |
|
1253 | - * @throws InvalidArgumentException |
|
1254 | - * @throws InvalidDataTypeException |
|
1255 | - * @throws InvalidInterfaceException |
|
1256 | - */ |
|
1257 | - public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname') |
|
1258 | - { |
|
1259 | - // normalize some request params that get setup by the parent `get_registrations` method. |
|
1260 | - $request = $this->_req_data; |
|
1261 | - $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby; |
|
1262 | - $request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC'; |
|
1263 | - if ($trash) { |
|
1264 | - $request['status'] = 'trash'; |
|
1265 | - } |
|
1266 | - $query_params = $this->_get_checkin_query_params_from_request($request, $per_page, $count); |
|
1267 | - /** |
|
1268 | - * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
1269 | - * |
|
1270 | - * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
1271 | - * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
1272 | - * or if you have the development copy of EE you can view this at the path: |
|
1273 | - * /docs/G--Model-System/model-query-params.md |
|
1274 | - */ |
|
1275 | - $query_params['group_by'] = ''; |
|
1244 | + /** |
|
1245 | + * Gets registrations for an event |
|
1246 | + * |
|
1247 | + * @param int $per_page |
|
1248 | + * @param bool $count whether to return count or data. |
|
1249 | + * @param bool $trash |
|
1250 | + * @param string $orderby |
|
1251 | + * @return EE_Registration[]|int |
|
1252 | + * @throws EE_Error |
|
1253 | + * @throws InvalidArgumentException |
|
1254 | + * @throws InvalidDataTypeException |
|
1255 | + * @throws InvalidInterfaceException |
|
1256 | + */ |
|
1257 | + public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname') |
|
1258 | + { |
|
1259 | + // normalize some request params that get setup by the parent `get_registrations` method. |
|
1260 | + $request = $this->_req_data; |
|
1261 | + $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby; |
|
1262 | + $request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC'; |
|
1263 | + if ($trash) { |
|
1264 | + $request['status'] = 'trash'; |
|
1265 | + } |
|
1266 | + $query_params = $this->_get_checkin_query_params_from_request($request, $per_page, $count); |
|
1267 | + /** |
|
1268 | + * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
1269 | + * |
|
1270 | + * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
1271 | + * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
1272 | + * or if you have the development copy of EE you can view this at the path: |
|
1273 | + * /docs/G--Model-System/model-query-params.md |
|
1274 | + */ |
|
1275 | + $query_params['group_by'] = ''; |
|
1276 | 1276 | |
1277 | - return $count |
|
1278 | - ? EEM_Registration::instance()->count($query_params) |
|
1279 | - /** @type EE_Registration[] */ |
|
1280 | - : EEM_Registration::instance()->get_all($query_params); |
|
1281 | - } |
|
1277 | + return $count |
|
1278 | + ? EEM_Registration::instance()->count($query_params) |
|
1279 | + /** @type EE_Registration[] */ |
|
1280 | + : EEM_Registration::instance()->get_all($query_params); |
|
1281 | + } |
|
1282 | 1282 | } |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | public function __construct($routing = true) |
33 | 33 | { |
34 | 34 | parent::__construct($routing); |
35 | - if (! defined('REG_CAF_TEMPLATE_PATH')) { |
|
36 | - define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
37 | - define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
38 | - define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
35 | + if ( ! defined('REG_CAF_TEMPLATE_PATH')) { |
|
36 | + define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'registrations/templates/'); |
|
37 | + define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'registrations/assets/'); |
|
38 | + define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registrations/assets/'); |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | protected function _extend_page_config() |
47 | 47 | { |
48 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
48 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'registrations'; |
|
49 | 49 | $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
50 | 50 | ? $this->_req_data['_REG_ID'] |
51 | 51 | : 0; |
@@ -185,14 +185,14 @@ discard block |
||
185 | 185 | // enqueue newsletter js |
186 | 186 | wp_enqueue_script( |
187 | 187 | 'ee-newsletter-trigger', |
188 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
188 | + REG_CAF_ASSETS_URL.'ee-newsletter-trigger.js', |
|
189 | 189 | array('ee-dialog'), |
190 | 190 | EVENT_ESPRESSO_VERSION, |
191 | 191 | true |
192 | 192 | ); |
193 | 193 | wp_enqueue_style( |
194 | 194 | 'ee-newsletter-trigger-css', |
195 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
195 | + REG_CAF_ASSETS_URL.'ee-newsletter-trigger.css', |
|
196 | 196 | array(), |
197 | 197 | EVENT_ESPRESSO_VERSION |
198 | 198 | ); |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | { |
214 | 214 | wp_register_script( |
215 | 215 | 'ee-reg-reports-js', |
216 | - REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
216 | + REG_CAF_ASSETS_URL.'ee-registration-admin-reports.js', |
|
217 | 217 | array('google-charts'), |
218 | 218 | EVENT_ESPRESSO_VERSION, |
219 | 219 | true |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | $nonce_ref = 'get_newsletter_form_content_nonce'; |
300 | 300 | $this->_verify_nonce($nonce, $nonce_ref); |
301 | 301 | // let's get the mtp for the incoming MTP_ ID |
302 | - if (! isset($this->_req_data['GRP_ID'])) { |
|
302 | + if ( ! isset($this->_req_data['GRP_ID'])) { |
|
303 | 303 | EE_Error::add_error( |
304 | 304 | esc_html__( |
305 | 305 | 'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | $this->_return_json(); |
315 | 315 | } |
316 | 316 | $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
317 | - if (! $MTPG instanceof EE_Message_Template_Group) { |
|
317 | + if ( ! $MTPG instanceof EE_Message_Template_Group) { |
|
318 | 318 | EE_Error::add_error( |
319 | 319 | sprintf( |
320 | 320 | esc_html__( |
@@ -339,12 +339,12 @@ discard block |
||
339 | 339 | $field = $MTP->get('MTP_template_field'); |
340 | 340 | if ($field === 'content') { |
341 | 341 | $content = $MTP->get('MTP_content'); |
342 | - if (! empty($content['newsletter_content'])) { |
|
342 | + if ( ! empty($content['newsletter_content'])) { |
|
343 | 343 | $template_fields['newsletter_content'] = $content['newsletter_content']; |
344 | 344 | } |
345 | 345 | continue; |
346 | 346 | } |
347 | - $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content'); |
|
347 | + $template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content'); |
|
348 | 348 | } |
349 | 349 | $this->_template_args['success'] = true; |
350 | 350 | $this->_template_args['error'] = false; |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | */ |
376 | 376 | public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) |
377 | 377 | { |
378 | - if (! EE_Registry::instance()->CAP->current_user_can( |
|
378 | + if ( ! EE_Registry::instance()->CAP->current_user_can( |
|
379 | 379 | 'ee_send_message', |
380 | 380 | 'espresso_registrations_newsletter_selected_send' |
381 | 381 | ) |
@@ -444,17 +444,17 @@ discard block |
||
444 | 444 | $field_id = $field === '[NEWSLETTER_CONTENT]' |
445 | 445 | ? 'content' |
446 | 446 | : $field; |
447 | - $field_id = 'batch-message-' . strtolower($field_id); |
|
447 | + $field_id = 'batch-message-'.strtolower($field_id); |
|
448 | 448 | $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="' |
449 | 449 | . $shortcode |
450 | - . '" data-linked-input-id="' . $field_id . '">' |
|
450 | + . '" data-linked-input-id="'.$field_id.'">' |
|
451 | 451 | . $shortcode |
452 | 452 | . '</span>'; |
453 | 453 | } |
454 | - $codes[ $field ] = implode(', ', $available_shortcodes); |
|
454 | + $codes[$field] = implode(', ', $available_shortcodes); |
|
455 | 455 | } |
456 | 456 | $shortcodes = $codes; |
457 | - $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
457 | + $form_template = REG_CAF_TEMPLATE_PATH.'newsletter-send-form.template.php'; |
|
458 | 458 | $form_template_args = array( |
459 | 459 | 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
460 | 460 | 'form_route' => 'newsletter_selected_send', |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | */ |
623 | 623 | protected function _registration_reports() |
624 | 624 | { |
625 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
625 | + $template_path = EE_ADMIN_TEMPLATE.'admin_reports.template.php'; |
|
626 | 626 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
627 | 627 | $template_path, |
628 | 628 | $this->_reports_template_data, |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | array_unshift($regs, $column_titles); |
678 | 678 | // setup the date range. |
679 | 679 | $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
680 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
680 | + $beginning_date = new DateTime("now ".$period, $DateTimeZone); |
|
681 | 681 | $ending_date = new DateTime("now", $DateTimeZone); |
682 | 682 | $subtitle = sprintf( |
683 | 683 | _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | '%sThere are currently no registration records in the last month for this report.%s', |
698 | 698 | 'event_espresso' |
699 | 699 | ), |
700 | - '<h2>' . $report_title . '</h2><p>', |
|
700 | + '<h2>'.$report_title.'</h2><p>', |
|
701 | 701 | '</p>' |
702 | 702 | ), |
703 | 703 | ); |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | array_unshift($regs, $column_titles); |
751 | 751 | // setup the date range. |
752 | 752 | $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
753 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
753 | + $beginning_date = new DateTime("now ".$period, $DateTimeZone); |
|
754 | 754 | $ending_date = new DateTime("now", $DateTimeZone); |
755 | 755 | $subtitle = sprintf( |
756 | 756 | _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | '%sThere are currently no registration records in the last month for this report.%s', |
771 | 771 | 'event_espresso' |
772 | 772 | ), |
773 | - '<h2>' . $report_title . '</h2><p>', |
|
773 | + '<h2>'.$report_title.'</h2><p>', |
|
774 | 774 | '</p>' |
775 | 775 | ), |
776 | 776 | ); |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | $reg_id = isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : null; |
797 | 797 | /** @var EE_Registration $registration */ |
798 | 798 | $registration = EEM_Registration::instance()->get_one_by_ID($reg_id); |
799 | - if (! $registration instanceof EE_Registration) { |
|
799 | + if ( ! $registration instanceof EE_Registration) { |
|
800 | 800 | throw new EE_Error( |
801 | 801 | sprintf( |
802 | 802 | esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'), |
@@ -831,7 +831,7 @@ discard block |
||
831 | 831 | if ($datetime instanceof EE_Datetime) { |
832 | 832 | $datetime_label = $datetime->get_dtt_display_name(true); |
833 | 833 | $datetime_label .= ! empty($datetime_label) |
834 | - ? ' (' . $datetime->get_dtt_display_name() . ')' |
|
834 | + ? ' ('.$datetime->get_dtt_display_name().')' |
|
835 | 835 | : $datetime->get_dtt_display_name(); |
836 | 836 | } |
837 | 837 | $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | ) |
846 | 846 | : ''; |
847 | 847 | $datetime_link = ! empty($datetime_link) |
848 | - ? '<a href="' . $datetime_link . '">' |
|
848 | + ? '<a href="'.$datetime_link.'">' |
|
849 | 849 | . '<span id="checkin-dtt">' |
850 | 850 | . $datetime_label |
851 | 851 | . '</span></a>' |
@@ -857,8 +857,8 @@ discard block |
||
857 | 857 | ? $attendee->get_admin_details_link() |
858 | 858 | : ''; |
859 | 859 | $attendee_link = ! empty($attendee_link) |
860 | - ? '<a href="' . $attendee->get_admin_details_link() . '"' |
|
861 | - . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">' |
|
860 | + ? '<a href="'.$attendee->get_admin_details_link().'"' |
|
861 | + . ' title="'.esc_html__('Click for attendee details', 'event_espresso').'">' |
|
862 | 862 | . '<span id="checkin-attendee-name">' |
863 | 863 | . $attendee_name |
864 | 864 | . '</span></a>' |
@@ -867,25 +867,25 @@ discard block |
||
867 | 867 | ? $registration->event()->get_admin_details_link() |
868 | 868 | : ''; |
869 | 869 | $event_link = ! empty($event_link) |
870 | - ? '<a href="' . $event_link . '"' |
|
871 | - . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">' |
|
870 | + ? '<a href="'.$event_link.'"' |
|
871 | + . ' title="'.esc_html__('Click here to edit event.', 'event_espresso').'">' |
|
872 | 872 | . '<span id="checkin-event-name">' |
873 | 873 | . $registration->event_name() |
874 | 874 | . '</span>' |
875 | 875 | . '</a>' |
876 | 876 | : ''; |
877 | 877 | $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
878 | - ? '<h2>' . sprintf( |
|
878 | + ? '<h2>'.sprintf( |
|
879 | 879 | esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'), |
880 | 880 | $attendee_link, |
881 | 881 | $datetime_link, |
882 | 882 | $event_link |
883 | - ) . '</h2>' |
|
883 | + ).'</h2>' |
|
884 | 884 | : ''; |
885 | 885 | $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
886 | - ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : ''; |
|
886 | + ? '<input type="hidden" name="_REG_ID" value="'.$reg_id.'">' : ''; |
|
887 | 887 | $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
888 | - ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
888 | + ? '<input type="hidden" name="DTT_ID" value="'.$dtt_id.'">' : ''; |
|
889 | 889 | $this->display_admin_list_table_page_with_no_sidebar(); |
890 | 890 | } |
891 | 891 | |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | public function toggle_checkin_status() |
903 | 903 | { |
904 | 904 | // first make sure we have the necessary data |
905 | - if (! isset($this->_req_data['_regid'])) { |
|
905 | + if ( ! isset($this->_req_data['_regid'])) { |
|
906 | 906 | EE_Error::add_error( |
907 | 907 | esc_html__( |
908 | 908 | 'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', |
@@ -924,7 +924,7 @@ discard block |
||
924 | 924 | // beautiful! Made it this far so let's get the status. |
925 | 925 | $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status()); |
926 | 926 | // setup new class to return via ajax |
927 | - $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses(); |
|
927 | + $this->_template_args['admin_page_content'] = 'clickable trigger-checkin '.$new_status->cssClasses(); |
|
928 | 928 | $this->_template_args['success'] = true; |
929 | 929 | $this->_return_json(); |
930 | 930 | } |
@@ -950,7 +950,7 @@ discard block |
||
950 | 950 | ); |
951 | 951 | $new_status = false; |
952 | 952 | // bulk action check in toggle |
953 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
953 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
954 | 954 | // cycle thru checkboxes |
955 | 955 | while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
956 | 956 | $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
@@ -1020,9 +1020,9 @@ discard block |
||
1020 | 1020 | '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
1021 | 1021 | ); |
1022 | 1022 | $errors = 0; |
1023 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1023 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1024 | 1024 | while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
1025 | - if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
1025 | + if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
1026 | 1026 | $errors++; |
1027 | 1027 | } |
1028 | 1028 | } |
@@ -1068,8 +1068,8 @@ discard block |
||
1068 | 1068 | 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
1069 | 1069 | '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
1070 | 1070 | ); |
1071 | - if (! empty($this->_req_data['CHK_ID'])) { |
|
1072 | - if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
1071 | + if ( ! empty($this->_req_data['CHK_ID'])) { |
|
1072 | + if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
1073 | 1073 | EE_Error::add_error( |
1074 | 1074 | esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
1075 | 1075 | __FILE__, |
@@ -1138,27 +1138,27 @@ discard block |
||
1138 | 1138 | 'desc' => $checked_never->legendLabel(), |
1139 | 1139 | ), |
1140 | 1140 | 'approved_status' => array( |
1141 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
1141 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved, |
|
1142 | 1142 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
1143 | 1143 | ), |
1144 | 1144 | 'cancelled_status' => array( |
1145 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
1145 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled, |
|
1146 | 1146 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
1147 | 1147 | ), |
1148 | 1148 | 'declined_status' => array( |
1149 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
1149 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined, |
|
1150 | 1150 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
1151 | 1151 | ), |
1152 | 1152 | 'not_approved' => array( |
1153 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
1153 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved, |
|
1154 | 1154 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
1155 | 1155 | ), |
1156 | 1156 | 'pending_status' => array( |
1157 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
1157 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment, |
|
1158 | 1158 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
1159 | 1159 | ), |
1160 | 1160 | 'wait_list' => array( |
1161 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
1161 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list, |
|
1162 | 1162 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
1163 | 1163 | ), |
1164 | 1164 | ); |
@@ -1167,10 +1167,10 @@ discard block |
||
1167 | 1167 | /** @var EE_Event $event */ |
1168 | 1168 | $event = EEM_Event::instance()->get_one_by_ID($event_id); |
1169 | 1169 | $this->_template_args['before_list_table'] = $event instanceof EE_Event |
1170 | - ? '<h2>' . sprintf( |
|
1170 | + ? '<h2>'.sprintf( |
|
1171 | 1171 | esc_html__('Viewing Registrations for Event: %s', 'event_espresso'), |
1172 | 1172 | EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name') |
1173 | - ) . '</h2>' |
|
1173 | + ).'</h2>' |
|
1174 | 1174 | : ''; |
1175 | 1175 | // need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on |
1176 | 1176 | // the event. |
@@ -1188,12 +1188,12 @@ discard block |
||
1188 | 1188 | $this->_template_args['before_list_table'] .= ' <span class="drk-grey-text">'; |
1189 | 1189 | $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>'; |
1190 | 1190 | $this->_template_args['before_list_table'] .= $datetime->name(); |
1191 | - $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
1191 | + $this->_template_args['before_list_table'] .= ' ( '.$datetime->date_and_time_range().' )'; |
|
1192 | 1192 | $this->_template_args['before_list_table'] .= '</span></h2>'; |
1193 | 1193 | } |
1194 | 1194 | // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status |
1195 | 1195 | // column represents |
1196 | - if (! $datetime instanceof EE_Datetime) { |
|
1196 | + if ( ! $datetime instanceof EE_Datetime) { |
|
1197 | 1197 | $this->_template_args['before_list_table'] .= '<br><p class="description">' |
1198 | 1198 | . esc_html__( |
1199 | 1199 | 'In this view, the check-in status represents the latest check-in record for the registration in that row.', |
@@ -12,32 +12,32 @@ |
||
12 | 12 | class EE_Button_Display_Strategy extends EE_Display_Strategy_Base |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * @return string of html to display the input |
|
17 | - */ |
|
18 | - public function display() |
|
19 | - { |
|
20 | - $default_value = $this->_input->get_default(); |
|
21 | - if ($this->_input->get_normalization_strategy() instanceof EE_Normalization_Strategy_Base) { |
|
22 | - $default_value = $this->_input->get_normalization_strategy()->unnormalize($default_value); |
|
23 | - } |
|
24 | - $html = $this->_opening_tag('button'); |
|
25 | - $html .= $this->_attributes_string( |
|
26 | - array_merge( |
|
27 | - $this->_standard_attributes_array(), |
|
28 | - array( |
|
29 | - 'value' => $default_value, |
|
30 | - ) |
|
31 | - ) |
|
32 | - ); |
|
33 | - if ($this->_input instanceof EE_Button_Input) { |
|
34 | - $button_content = $this->_input->button_content(); |
|
35 | - } else { |
|
36 | - $button_content = $this->_input->get_default(); |
|
37 | - } |
|
38 | - $html .= '>'; |
|
39 | - $html .= $button_content; |
|
40 | - $html .= $this->_closing_tag(); |
|
41 | - return $html; |
|
42 | - } |
|
15 | + /** |
|
16 | + * @return string of html to display the input |
|
17 | + */ |
|
18 | + public function display() |
|
19 | + { |
|
20 | + $default_value = $this->_input->get_default(); |
|
21 | + if ($this->_input->get_normalization_strategy() instanceof EE_Normalization_Strategy_Base) { |
|
22 | + $default_value = $this->_input->get_normalization_strategy()->unnormalize($default_value); |
|
23 | + } |
|
24 | + $html = $this->_opening_tag('button'); |
|
25 | + $html .= $this->_attributes_string( |
|
26 | + array_merge( |
|
27 | + $this->_standard_attributes_array(), |
|
28 | + array( |
|
29 | + 'value' => $default_value, |
|
30 | + ) |
|
31 | + ) |
|
32 | + ); |
|
33 | + if ($this->_input instanceof EE_Button_Input) { |
|
34 | + $button_content = $this->_input->button_content(); |
|
35 | + } else { |
|
36 | + $button_content = $this->_input->get_default(); |
|
37 | + } |
|
38 | + $html .= '>'; |
|
39 | + $html .= $button_content; |
|
40 | + $html .= $this->_closing_tag(); |
|
41 | + return $html; |
|
42 | + } |
|
43 | 43 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments) |
42 | 42 | { |
43 | - if (! isset($arguments[0], $arguments[1])) { |
|
43 | + if ( ! isset($arguments[0], $arguments[1])) { |
|
44 | 44 | throw new InvalidArgumentException( |
45 | 45 | esc_html__( |
46 | 46 | 'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class', |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | ); |
50 | 50 | } |
51 | 51 | $domain = LoaderFactory::getLoader()->getShared($domain_fqcn, $arguments); |
52 | - if (! $domain instanceof $domain_fqcn && ! $domain instanceof DomainBase) { |
|
52 | + if ( ! $domain instanceof $domain_fqcn && ! $domain instanceof DomainBase) { |
|
53 | 53 | throw new DomainException( |
54 | 54 | sprintf( |
55 | 55 | esc_html__( |
@@ -28,63 +28,63 @@ |
||
28 | 28 | class DomainFactory |
29 | 29 | { |
30 | 30 | |
31 | - /** |
|
32 | - * @param FullyQualifiedName $domain_fqcn [required] Fully Qualified Class Name for the Domain class |
|
33 | - * @param array $arguments [required] array of arguments to be passed to the Domain class |
|
34 | - * constructor. Must at least include the following two value objects: |
|
35 | - * array( |
|
36 | - * EventEspresso\core\domain\values\FilePath $plugin_file |
|
37 | - * EventEspresso\core\domain\values\Version $version |
|
38 | - * ) |
|
39 | - * @return mixed |
|
40 | - * @throws DomainException |
|
41 | - * @throws InvalidArgumentException |
|
42 | - * @throws InvalidDataTypeException |
|
43 | - * @throws InvalidInterfaceException |
|
44 | - */ |
|
45 | - public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments) |
|
46 | - { |
|
47 | - if (! isset($arguments[0], $arguments[1])) { |
|
48 | - throw new InvalidArgumentException( |
|
49 | - esc_html__( |
|
50 | - 'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class', |
|
51 | - 'event_espresso' |
|
52 | - ) |
|
53 | - ); |
|
54 | - } |
|
55 | - $domain = LoaderFactory::getLoader()->getShared($domain_fqcn, $arguments); |
|
56 | - if (! $domain instanceof $domain_fqcn && ! $domain instanceof DomainBase) { |
|
57 | - throw new DomainException( |
|
58 | - sprintf( |
|
59 | - esc_html__( |
|
60 | - 'The requested Domain class "%1$s" could not be loaded.', |
|
61 | - 'event_espresso' |
|
62 | - ), |
|
63 | - $domain_fqcn |
|
64 | - ) |
|
65 | - ); |
|
66 | - } |
|
67 | - return $domain; |
|
68 | - } |
|
31 | + /** |
|
32 | + * @param FullyQualifiedName $domain_fqcn [required] Fully Qualified Class Name for the Domain class |
|
33 | + * @param array $arguments [required] array of arguments to be passed to the Domain class |
|
34 | + * constructor. Must at least include the following two value objects: |
|
35 | + * array( |
|
36 | + * EventEspresso\core\domain\values\FilePath $plugin_file |
|
37 | + * EventEspresso\core\domain\values\Version $version |
|
38 | + * ) |
|
39 | + * @return mixed |
|
40 | + * @throws DomainException |
|
41 | + * @throws InvalidArgumentException |
|
42 | + * @throws InvalidDataTypeException |
|
43 | + * @throws InvalidInterfaceException |
|
44 | + */ |
|
45 | + public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments) |
|
46 | + { |
|
47 | + if (! isset($arguments[0], $arguments[1])) { |
|
48 | + throw new InvalidArgumentException( |
|
49 | + esc_html__( |
|
50 | + 'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class', |
|
51 | + 'event_espresso' |
|
52 | + ) |
|
53 | + ); |
|
54 | + } |
|
55 | + $domain = LoaderFactory::getLoader()->getShared($domain_fqcn, $arguments); |
|
56 | + if (! $domain instanceof $domain_fqcn && ! $domain instanceof DomainBase) { |
|
57 | + throw new DomainException( |
|
58 | + sprintf( |
|
59 | + esc_html__( |
|
60 | + 'The requested Domain class "%1$s" could not be loaded.', |
|
61 | + 'event_espresso' |
|
62 | + ), |
|
63 | + $domain_fqcn |
|
64 | + ) |
|
65 | + ); |
|
66 | + } |
|
67 | + return $domain; |
|
68 | + } |
|
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * @return Domain |
|
73 | - * @throws DomainException |
|
74 | - * @throws InvalidArgumentException |
|
75 | - * @throws InvalidDataTypeException |
|
76 | - * @throws InvalidFilePathException |
|
77 | - * @throws InvalidInterfaceException |
|
78 | - */ |
|
79 | - public static function getEventEspressoCoreDomain() |
|
80 | - { |
|
81 | - $domain = new Domain( |
|
82 | - new FilePath(EVENT_ESPRESSO_MAIN_FILE), |
|
83 | - Version::fromString(espresso_version()) |
|
84 | - ); |
|
85 | - LoaderFactory::getLoader()->share('EventEspresso\core\domain\Domain', $domain); |
|
86 | - return $domain; |
|
87 | - } |
|
71 | + /** |
|
72 | + * @return Domain |
|
73 | + * @throws DomainException |
|
74 | + * @throws InvalidArgumentException |
|
75 | + * @throws InvalidDataTypeException |
|
76 | + * @throws InvalidFilePathException |
|
77 | + * @throws InvalidInterfaceException |
|
78 | + */ |
|
79 | + public static function getEventEspressoCoreDomain() |
|
80 | + { |
|
81 | + $domain = new Domain( |
|
82 | + new FilePath(EVENT_ESPRESSO_MAIN_FILE), |
|
83 | + Version::fromString(espresso_version()) |
|
84 | + ); |
|
85 | + LoaderFactory::getLoader()->share('EventEspresso\core\domain\Domain', $domain); |
|
86 | + return $domain; |
|
87 | + } |
|
88 | 88 | } |
89 | 89 | |
90 | 90 |
@@ -20,42 +20,42 @@ |
||
20 | 20 | class FilePath |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @var string file_path |
|
25 | - */ |
|
26 | - private $file_path; |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * FilePath constructor. |
|
31 | - * |
|
32 | - * @param string $file_path |
|
33 | - * @throws InvalidDataTypeException |
|
34 | - * @throws InvalidFilePathException |
|
35 | - */ |
|
36 | - public function __construct($file_path) |
|
37 | - { |
|
38 | - if (! is_string($file_path)) { |
|
39 | - throw new InvalidDataTypeException( |
|
40 | - '$file_path', |
|
41 | - $file_path, |
|
42 | - 'string' |
|
43 | - ); |
|
44 | - } |
|
45 | - if (! is_readable($file_path)) { |
|
46 | - throw new InvalidFilePathException($file_path); |
|
47 | - } |
|
48 | - $this->file_path = $file_path; |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * @return string |
|
54 | - */ |
|
55 | - public function __toString() |
|
56 | - { |
|
57 | - return $this->file_path; |
|
58 | - } |
|
23 | + /** |
|
24 | + * @var string file_path |
|
25 | + */ |
|
26 | + private $file_path; |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * FilePath constructor. |
|
31 | + * |
|
32 | + * @param string $file_path |
|
33 | + * @throws InvalidDataTypeException |
|
34 | + * @throws InvalidFilePathException |
|
35 | + */ |
|
36 | + public function __construct($file_path) |
|
37 | + { |
|
38 | + if (! is_string($file_path)) { |
|
39 | + throw new InvalidDataTypeException( |
|
40 | + '$file_path', |
|
41 | + $file_path, |
|
42 | + 'string' |
|
43 | + ); |
|
44 | + } |
|
45 | + if (! is_readable($file_path)) { |
|
46 | + throw new InvalidFilePathException($file_path); |
|
47 | + } |
|
48 | + $this->file_path = $file_path; |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * @return string |
|
54 | + */ |
|
55 | + public function __toString() |
|
56 | + { |
|
57 | + return $this->file_path; |
|
58 | + } |
|
59 | 59 | |
60 | 60 | |
61 | 61 | } |
@@ -35,14 +35,14 @@ |
||
35 | 35 | */ |
36 | 36 | public function __construct($file_path) |
37 | 37 | { |
38 | - if (! is_string($file_path)) { |
|
38 | + if ( ! is_string($file_path)) { |
|
39 | 39 | throw new InvalidDataTypeException( |
40 | 40 | '$file_path', |
41 | 41 | $file_path, |
42 | 42 | 'string' |
43 | 43 | ); |
44 | 44 | } |
45 | - if (! is_readable($file_path)) { |
|
45 | + if ( ! is_readable($file_path)) { |
|
46 | 46 | throw new InvalidFilePathException($file_path); |
47 | 47 | } |
48 | 48 | $this->file_path = $file_path; |
@@ -37,14 +37,14 @@ |
||
37 | 37 | */ |
38 | 38 | public function __construct($fully_qualified_name) |
39 | 39 | { |
40 | - if (! is_string($fully_qualified_name)) { |
|
40 | + if ( ! is_string($fully_qualified_name)) { |
|
41 | 41 | throw new InvalidDataTypeException( |
42 | 42 | '$fully_qualified_name', |
43 | 43 | $fully_qualified_name, |
44 | 44 | 'string' |
45 | 45 | ); |
46 | 46 | } |
47 | - if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
47 | + if ( ! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
48 | 48 | if (strpos($fully_qualified_name, 'Interface') !== false) { |
49 | 49 | throw new InvalidInterfaceException($fully_qualified_name); |
50 | 50 | } |
@@ -21,54 +21,54 @@ |
||
21 | 21 | class FullyQualifiedName |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * @var string $fully_qualified_name |
|
26 | - */ |
|
27 | - private $fully_qualified_name; |
|
24 | + /** |
|
25 | + * @var string $fully_qualified_name |
|
26 | + */ |
|
27 | + private $fully_qualified_name; |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * FullyQualifiedName constructor. |
|
32 | - * |
|
33 | - * @param string $fully_qualified_name |
|
34 | - * @throws InvalidClassException |
|
35 | - * @throws InvalidInterfaceException |
|
36 | - * @throws InvalidDataTypeException |
|
37 | - */ |
|
38 | - public function __construct($fully_qualified_name) |
|
39 | - { |
|
40 | - if (! is_string($fully_qualified_name)) { |
|
41 | - throw new InvalidDataTypeException( |
|
42 | - '$fully_qualified_name', |
|
43 | - $fully_qualified_name, |
|
44 | - 'string' |
|
45 | - ); |
|
46 | - } |
|
47 | - if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
48 | - if (strpos($fully_qualified_name, 'Interface') !== false) { |
|
49 | - throw new InvalidInterfaceException($fully_qualified_name); |
|
50 | - } |
|
51 | - throw new InvalidClassException($fully_qualified_name); |
|
52 | - } |
|
53 | - $this->fully_qualified_name = $fully_qualified_name; |
|
54 | - } |
|
30 | + /** |
|
31 | + * FullyQualifiedName constructor. |
|
32 | + * |
|
33 | + * @param string $fully_qualified_name |
|
34 | + * @throws InvalidClassException |
|
35 | + * @throws InvalidInterfaceException |
|
36 | + * @throws InvalidDataTypeException |
|
37 | + */ |
|
38 | + public function __construct($fully_qualified_name) |
|
39 | + { |
|
40 | + if (! is_string($fully_qualified_name)) { |
|
41 | + throw new InvalidDataTypeException( |
|
42 | + '$fully_qualified_name', |
|
43 | + $fully_qualified_name, |
|
44 | + 'string' |
|
45 | + ); |
|
46 | + } |
|
47 | + if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
48 | + if (strpos($fully_qualified_name, 'Interface') !== false) { |
|
49 | + throw new InvalidInterfaceException($fully_qualified_name); |
|
50 | + } |
|
51 | + throw new InvalidClassException($fully_qualified_name); |
|
52 | + } |
|
53 | + $this->fully_qualified_name = $fully_qualified_name; |
|
54 | + } |
|
55 | 55 | |
56 | 56 | |
57 | - /** |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - public function string() |
|
61 | - { |
|
62 | - return $this->fully_qualified_name; |
|
63 | - } |
|
57 | + /** |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + public function string() |
|
61 | + { |
|
62 | + return $this->fully_qualified_name; |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | - /** |
|
67 | - * @return string |
|
68 | - */ |
|
69 | - public function __toString() |
|
70 | - { |
|
71 | - return $this->fully_qualified_name; |
|
72 | - } |
|
66 | + /** |
|
67 | + * @return string |
|
68 | + */ |
|
69 | + public function __toString() |
|
70 | + { |
|
71 | + return $this->fully_qualified_name; |
|
72 | + } |
|
73 | 73 | |
74 | 74 | } |