Completed
Branch BUG-10626-dst-unit-test (0025a0)
by
unknown
105:00 queued 94:16
created
core/helpers/EEH_Debug_Tools.helper.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 
376 376
 
377 377
     /**
378
-     * @param mixed      $var
378
+     * @param string      $var
379 379
      * @param string     $var_name
380 380
      * @param string     $file
381 381
      * @param int|string $line
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
      * @param mixed      $var
514 514
      * @param string     $var_name
515 515
      * @param string     $file
516
-     * @param int|string $line
516
+     * @param integer $line
517 517
      * @param int        $heading_tag
518 518
      * @param bool       $die
519 519
      */
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 
577 577
     /**
578 578
      * @deprecated 4.9.39.rc.034
579
-     * @param null $timer_name
579
+     * @param string $timer_name
580 580
      */
581 581
     public function start_timer($timer_name = null)
582 582
     {
Please login to merge, or discard this patch.
Indentation   +642 added lines, -642 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php use EventEspresso\core\services\Benchmark;
2 2
 
3 3
 if (! defined('EVENT_ESPRESSO_VERSION')) {
4
-    exit('No direct script access allowed');
4
+	exit('No direct script access allowed');
5 5
 }
6 6
 
7 7
 
@@ -17,632 +17,632 @@  discard block
 block discarded – undo
17 17
 class EEH_Debug_Tools
18 18
 {
19 19
 
20
-    /**
21
-     *    instance of the EEH_Autoloader object
22
-     *
23
-     * @var    $_instance
24
-     * @access    private
25
-     */
26
-    private static $_instance;
27
-
28
-    /**
29
-     * @var array
30
-     */
31
-    protected $_memory_usage_points = array();
32
-
33
-
34
-
35
-    /**
36
-     * @singleton method used to instantiate class object
37
-     * @access    public
38
-     * @return EEH_Debug_Tools
39
-     */
40
-    public static function instance()
41
-    {
42
-        // check if class object is instantiated, and instantiated properly
43
-        if (! self::$_instance instanceof EEH_Debug_Tools) {
44
-            self::$_instance = new self();
45
-        }
46
-        return self::$_instance;
47
-    }
48
-
49
-
50
-
51
-    /**
52
-     * private class constructor
53
-     */
54
-    private function __construct()
55
-    {
56
-        // load Kint PHP debugging library
57
-        if (! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php')) {
58
-            // despite EE4 having a check for an existing copy of the Kint debugging class,
59
-            // if another plugin was loaded AFTER EE4 and they did NOT perform a similar check,
60
-            // then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error
61
-            // so we've moved it to our test folder so that it is not included with production releases
62
-            // plz use https://wordpress.org/plugins/kint-debugger/  if testing production versions of EE
63
-            require_once(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php');
64
-        }
65
-        // if ( ! defined('DOING_AJAX') || $_REQUEST['noheader'] !== 'true' || ! isset( $_REQUEST['noheader'], $_REQUEST['TB_iframe'] ) ) {
66
-        //add_action( 'shutdown', array($this,'espresso_session_footer_dump') );
67
-        // }
68
-        $plugin = basename(EE_PLUGIN_DIR_PATH);
69
-        add_action("activate_{$plugin}", array('EEH_Debug_Tools', 'ee_plugin_activation_errors'));
70
-        add_action('activated_plugin', array('EEH_Debug_Tools', 'ee_plugin_activation_errors'));
71
-        add_action('shutdown', array('EEH_Debug_Tools', 'show_db_name'));
72
-    }
73
-
74
-
75
-
76
-    /**
77
-     *    show_db_name
78
-     *
79
-     * @return void
80
-     */
81
-    public static function show_db_name()
82
-    {
83
-        if (! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) {
84
-            echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '
85
-                 . DB_NAME
86
-                 . '</p>';
87
-        }
88
-        if (EE_DEBUG) {
89
-            Benchmark::displayResults();
90
-        }
91
-    }
92
-
93
-
94
-
95
-    /**
96
-     *    dump EE_Session object at bottom of page after everything else has happened
97
-     *
98
-     * @return void
99
-     */
100
-    public function espresso_session_footer_dump()
101
-    {
102
-        if (
103
-            (defined('WP_DEBUG') && WP_DEBUG)
104
-            && ! defined('DOING_AJAX')
105
-            && class_exists('Kint')
106
-            && function_exists('wp_get_current_user')
107
-            && current_user_can('update_core')
108
-            && class_exists('EE_Registry')
109
-        ) {
110
-            Kint::dump(EE_Registry::instance()->SSN->id());
111
-            Kint::dump(EE_Registry::instance()->SSN);
112
-            //			Kint::dump( EE_Registry::instance()->SSN->get_session_data('cart')->get_tickets() );
113
-            $this->espresso_list_hooked_functions();
114
-            Benchmark::displayResults();
115
-        }
116
-    }
117
-
118
-
119
-
120
-    /**
121
-     *    List All Hooked Functions
122
-     *    to list all functions for a specific hook, add ee_list_hooks={hook-name} to URL
123
-     *    http://wp.smashingmagazine.com/2009/08/18/10-useful-wordpress-hook-hacks/
124
-     *
125
-     * @param string $tag
126
-     * @return void
127
-     */
128
-    public function espresso_list_hooked_functions($tag = '')
129
-    {
130
-        global $wp_filter;
131
-        echo '<br/><br/><br/><h3>Hooked Functions</h3>';
132
-        if ($tag) {
133
-            $hook[$tag] = $wp_filter[$tag];
134
-            if (! is_array($hook[$tag])) {
135
-                trigger_error("Nothing found for '$tag' hook", E_USER_WARNING);
136
-                return;
137
-            }
138
-            echo '<h5>For Tag: ' . $tag . '</h5>';
139
-        } else {
140
-            $hook = is_array($wp_filter) ? $wp_filter : array($wp_filter);
141
-            ksort($hook);
142
-        }
143
-        foreach ($hook as $tag_name => $priorities) {
144
-            echo "<br />&gt;&gt;&gt;&gt;&gt;\t<strong>$tag_name</strong><br />";
145
-            ksort($priorities);
146
-            foreach ($priorities as $priority => $function) {
147
-                echo $priority;
148
-                foreach ($function as $name => $properties) {
149
-                    echo "\t$name<br />";
150
-                }
151
-            }
152
-        }
153
-    }
154
-
155
-
156
-
157
-    /**
158
-     *    registered_filter_callbacks
159
-     *
160
-     * @param string $hook_name
161
-     * @return array
162
-     */
163
-    public static function registered_filter_callbacks($hook_name = '')
164
-    {
165
-        $filters = array();
166
-        global $wp_filter;
167
-        if (isset($wp_filter[$hook_name])) {
168
-            $filters[$hook_name] = array();
169
-            foreach ($wp_filter[$hook_name] as $priority => $callbacks) {
170
-                $filters[$hook_name][$priority] = array();
171
-                foreach ($callbacks as $callback) {
172
-                    $filters[$hook_name][$priority][] = $callback['function'];
173
-                }
174
-            }
175
-        }
176
-        return $filters;
177
-    }
178
-
179
-
180
-
181
-    /**
182
-     *    captures plugin activation errors for debugging
183
-     *
184
-     * @return void
185
-     * @throws EE_Error
186
-     */
187
-    public static function ee_plugin_activation_errors()
188
-    {
189
-        if (WP_DEBUG) {
190
-            $activation_errors = ob_get_contents();
191
-            if (! empty($activation_errors)) {
192
-                $activation_errors = date('Y-m-d H:i:s') . "\n" . $activation_errors;
193
-            }
194
-            espresso_load_required('EEH_File', EE_HELPERS . 'EEH_File.helper.php');
195
-            if (class_exists('EEH_File')) {
196
-                try {
197
-                    EEH_File::ensure_file_exists_and_is_writable(
198
-                        EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html'
199
-                    );
200
-                    EEH_File::write_to_file(
201
-                        EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html',
202
-                        $activation_errors
203
-                    );
204
-                } catch (EE_Error $e) {
205
-                    EE_Error::add_error(
206
-                        sprintf(
207
-                            __(
208
-                                'The Event Espresso activation errors file could not be setup because: %s',
209
-                                'event_espresso'
210
-                            ),
211
-                            $e->getMessage()
212
-                        ),
213
-                        __FILE__, __FUNCTION__, __LINE__
214
-                    );
215
-                }
216
-            } else {
217
-                // old school attempt
218
-                file_put_contents(
219
-                    EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html',
220
-                    $activation_errors
221
-                );
222
-            }
223
-            $activation_errors = get_option('ee_plugin_activation_errors', '') . $activation_errors;
224
-            update_option('ee_plugin_activation_errors', $activation_errors);
225
-        }
226
-    }
227
-
228
-
229
-
230
-    /**
231
-     * This basically mimics the WordPress _doing_it_wrong() function except adds our own messaging etc.
232
-     * Very useful for providing helpful messages to developers when the method of doing something has been deprecated,
233
-     * or we want to make sure they use something the right way.
234
-     *
235
-     * @access public
236
-     * @param string $function      The function that was called
237
-     * @param string $message       A message explaining what has been done incorrectly
238
-     * @param string $version       The version of Event Espresso where the error was added
239
-     * @param string $applies_when  a version string for when you want the doing_it_wrong notice to begin appearing
240
-     *                              for a deprecated function. This allows deprecation to occur during one version,
241
-     *                              but not have any notices appear until a later version. This allows developers
242
-     *                              extra time to update their code before notices appear.
243
-     * @param int    $error_type
244
-     * @uses   trigger_error()
245
-     */
246
-    public function doing_it_wrong(
247
-        $function,
248
-        $message,
249
-        $version,
250
-        $applies_when = '',
251
-        $error_type = null
252
-    ) {
253
-        $applies_when = ! empty($applies_when) ? $applies_when : espresso_version();
254
-        $error_type = $error_type !== null ? $error_type : E_USER_NOTICE;
255
-        // because we swapped the parameter order around for the last two params,
256
-        // let's verify that some third party isn't still passing an error type value for the third param
257
-        if (is_int($applies_when)) {
258
-            $error_type = $applies_when;
259
-            $applies_when = espresso_version();
260
-        }
261
-        // if not displaying notices yet, then just leave
262
-        if (version_compare(espresso_version(), $applies_when, '<')) {
263
-            return;
264
-        }
265
-        do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version);
266
-        $version = $version === null
267
-            ? ''
268
-            : sprintf(
269
-                __('(This message was added in version %s of Event Espresso)', 'event_espresso'),
270
-                $version
271
-            );
272
-        $error_message = sprintf(
273
-            esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s', 'event_espresso'),
274
-            $function,
275
-            '<strong>',
276
-            '</strong>',
277
-            $message,
278
-            $version
279
-        );
280
-        // don't trigger error if doing ajax,
281
-        // instead we'll add a transient EE_Error notice that in theory should show on the next request.
282
-        if (defined('DOING_AJAX') && DOING_AJAX) {
283
-            $error_message .= ' ' . esc_html__(
284
-                    'This is a doing_it_wrong message that was triggered during an ajax request.  The request params on this request were: ',
285
-                    'event_espresso'
286
-                );
287
-            $error_message .= '<ul><li>';
288
-            $error_message .= implode('</li><li>', EE_Registry::instance()->REQ->params());
289
-            $error_message .= '</ul>';
290
-            EE_Error::add_error($error_message, 'debug::doing_it_wrong', $function, '42');
291
-            //now we set this on the transient so it shows up on the next request.
292
-            EE_Error::get_notices(false, true);
293
-        } else {
294
-            trigger_error($error_message, $error_type);
295
-        }
296
-    }
297
-
298
-
299
-
300
-
301
-    /**
302
-     * Logger helpers
303
-     */
304
-    /**
305
-     * debug
306
-     *
307
-     * @param string $class
308
-     * @param string $func
309
-     * @param string $line
310
-     * @param array  $info
311
-     * @param bool   $display_request
312
-     * @param string $debug_index
313
-     * @param string $debug_key
314
-     * @throws EE_Error
315
-     * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
316
-     */
317
-    public static function log(
318
-        $class = '',
319
-        $func = '',
320
-        $line = '',
321
-        $info = array(),
322
-        $display_request = false,
323
-        $debug_index = '',
324
-        $debug_key = 'EE_DEBUG_SPCO'
325
-    ) {
326
-        if (WP_DEBUG) {
327
-            $debug_key = $debug_key . '_' . EE_Session::instance()->id();
328
-            $debug_data = get_option($debug_key, array());
329
-            $default_data = array(
330
-                $class => $func . '() : ' . $line,
331
-                'REQ'  => $display_request ? $_REQUEST : '',
332
-            );
333
-            // don't serialize objects
334
-            $info = self::strip_objects($info);
335
-            $index = ! empty($debug_index) ? $debug_index : 0;
336
-            if (! isset($debug_data[$index])) {
337
-                $debug_data[$index] = array();
338
-            }
339
-            $debug_data[$index][microtime()] = array_merge($default_data, $info);
340
-            update_option($debug_key, $debug_data);
341
-        }
342
-    }
343
-
344
-
345
-
346
-    /**
347
-     * strip_objects
348
-     *
349
-     * @param array $info
350
-     * @return array
351
-     */
352
-    public static function strip_objects($info = array())
353
-    {
354
-        foreach ($info as $key => $value) {
355
-            if (is_array($value)) {
356
-                $info[$key] = self::strip_objects($value);
357
-            } else if (is_object($value)) {
358
-                $object_class = get_class($value);
359
-                $info[$object_class] = array();
360
-                $info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value);
361
-                if (method_exists($value, 'ID')) {
362
-                    $info[$object_class]['ID'] = $value->ID();
363
-                }
364
-                if (method_exists($value, 'status')) {
365
-                    $info[$object_class]['status'] = $value->status();
366
-                } else if (method_exists($value, 'status_ID')) {
367
-                    $info[$object_class]['status'] = $value->status_ID();
368
-                }
369
-                unset($info[$key]);
370
-            }
371
-        }
372
-        return (array)$info;
373
-    }
374
-
375
-
376
-
377
-    /**
378
-     * @param mixed      $var
379
-     * @param string     $var_name
380
-     * @param string     $file
381
-     * @param int|string $line
382
-     * @param int        $heading_tag
383
-     * @param bool       $die
384
-     * @param string     $margin
385
-     */
386
-    public static function printv(
387
-        $var,
388
-        $var_name = '',
389
-        $file = '',
390
-        $line = '',
391
-        $heading_tag = 5,
392
-        $die = false,
393
-        $margin = ''
394
-    ) {
395
-        $var_name = ! $var_name ? 'string' : $var_name;
396
-        $var_name = ucwords(str_replace('$', '', $var_name));
397
-        $is_method = method_exists($var_name, $var);
398
-        $var_name = ucwords(str_replace('_', ' ', $var_name));
399
-        $heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5';
400
-        $result = EEH_Debug_Tools::heading($var_name, $heading_tag, $margin);
401
-        $result .= $is_method
402
-            ? EEH_Debug_Tools::grey_span('::') . EEH_Debug_Tools::orange_span($var . '()')
403
-            : EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span($var);
404
-        $result .= EEH_Debug_Tools::file_and_line($file, $line);
405
-        $result .= EEH_Debug_Tools::headingX($heading_tag);
406
-        if ($die) {
407
-            die($result);
408
-        }
409
-        echo $result;
410
-    }
411
-
412
-
413
-
414
-    /**
415
-     * @param string $var_name
416
-     * @param string $heading_tag
417
-     * @param string $margin
418
-     * @return string
419
-     */
420
-    protected static function heading($var_name = '', $heading_tag = 'h5', $margin = '')
421
-    {
422
-        if (defined('EE_TESTS_DIR')) {
423
-            return "\n{$var_name}";
424
-        }
425
-        $margin = "25px 0 0 {$margin}";
426
-        return '<' . $heading_tag . ' style="color:#2EA2CC; margin:' . $margin . ';"><b>' . $var_name . '</b>';
427
-    }
428
-
429
-
430
-
431
-    /**
432
-     * @param string $heading_tag
433
-     * @return string
434
-     */
435
-    protected static function headingX($heading_tag = 'h5')
436
-    {
437
-        if (defined('EE_TESTS_DIR')) {
438
-            return '';
439
-        }
440
-        return '</' . $heading_tag . '>';
441
-    }
442
-
443
-
444
-
445
-    /**
446
-     * @param string $content
447
-     * @return string
448
-     */
449
-    protected static function grey_span($content = '')
450
-    {
451
-        if (defined('EE_TESTS_DIR')) {
452
-            return $content;
453
-        }
454
-        return '<span style="color:#999">' . $content . '</span>';
455
-    }
456
-
457
-
458
-
459
-    /**
460
-     * @param string $file
461
-     * @param int    $line
462
-     * @return string
463
-     */
464
-    protected static function file_and_line($file, $line)
465
-    {
466
-        if ($file === '' || $line === '') {
467
-            return '';
468
-        }
469
-        if (defined('EE_TESTS_DIR')) {
470
-            return "\n (" . $file . ' line no: ' . $line . ' ) ';
471
-        }
472
-        return '<br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">'
473
-               . $file
474
-               . '<br />line no: '
475
-               . $line
476
-               . '</span>';
477
-    }
478
-
479
-
480
-
481
-    /**
482
-     * @param string $content
483
-     * @return string
484
-     */
485
-    protected static function orange_span($content = '')
486
-    {
487
-        if (defined('EE_TESTS_DIR')) {
488
-            return $content;
489
-        }
490
-        return '<span style="color:#E76700">' . $content . '</span>';
491
-    }
492
-
493
-
494
-
495
-    /**
496
-     * @param mixed $var
497
-     * @return string
498
-     */
499
-    protected static function pre_span($var)
500
-    {
501
-        ob_start();
502
-        var_dump($var);
503
-        $var = ob_get_clean();
504
-        if (defined('EE_TESTS_DIR')) {
505
-            return "\n" . $var;
506
-        }
507
-        return '<pre style="color:#999; padding:1em; background: #fff">' . $var . '</pre>';
508
-    }
509
-
510
-
511
-
512
-    /**
513
-     * @param mixed      $var
514
-     * @param string     $var_name
515
-     * @param string     $file
516
-     * @param int|string $line
517
-     * @param int        $heading_tag
518
-     * @param bool       $die
519
-     */
520
-    public static function printr(
521
-        $var,
522
-        $var_name = '',
523
-        $file = '',
524
-        $line = '',
525
-        $heading_tag = 5,
526
-        $die = false
527
-    ) {
528
-        // return;
529
-        $file = str_replace(rtrim(ABSPATH, '\\/'), '', $file);
530
-        $margin = is_admin() ? ' 180px' : '0';
531
-        //$print_r = false;
532
-        if (is_string($var)) {
533
-            EEH_Debug_Tools::printv($var, $var_name, $file, $line, $heading_tag, $die, $margin);
534
-            return;
535
-        }
536
-        if (is_object($var)) {
537
-            $var_name = ! $var_name ? 'object' : $var_name;
538
-            //$print_r = true;
539
-        } else if (is_array($var)) {
540
-            $var_name = ! $var_name ? 'array' : $var_name;
541
-            //$print_r = true;
542
-        } else if (is_numeric($var)) {
543
-            $var_name = ! $var_name ? 'numeric' : $var_name;
544
-        } else if ($var === null) {
545
-            $var_name = ! $var_name ? 'null' : $var_name;
546
-        }
547
-        $var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name));
548
-        $heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5';
549
-        $result = EEH_Debug_Tools::heading($var_name, $heading_tag, $margin);
550
-        $result .= EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span(
551
-                EEH_Debug_Tools::pre_span($var)
552
-            );
553
-        $result .= EEH_Debug_Tools::file_and_line($file, $line);
554
-        $result .= EEH_Debug_Tools::headingX($heading_tag);
555
-        if ($die) {
556
-            die($result);
557
-        }
558
-        echo $result;
559
-    }
560
-
561
-
562
-
563
-    /******************** deprecated ********************/
564
-
565
-
566
-
567
-    /**
568
-     * @deprecated 4.9.39.rc.034
569
-     */
570
-    public function reset_times()
571
-    {
572
-        Benchmark::resetTimes();
573
-    }
574
-
575
-
576
-
577
-    /**
578
-     * @deprecated 4.9.39.rc.034
579
-     * @param null $timer_name
580
-     */
581
-    public function start_timer($timer_name = null)
582
-    {
583
-        Benchmark::startTimer($timer_name);
584
-    }
585
-
586
-
587
-
588
-    /**
589
-     * @deprecated 4.9.39.rc.034
590
-     * @param string $timer_name
591
-     */
592
-    public function stop_timer($timer_name = '')
593
-    {
594
-        Benchmark::stopTimer($timer_name);
595
-    }
596
-
597
-
598
-
599
-    /**
600
-     * @deprecated 4.9.39.rc.034
601
-     * @param string  $label      The label to show for this time eg "Start of calling Some_Class::some_function"
602
-     * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called
603
-     * @return void
604
-     */
605
-    public function measure_memory($label, $output_now = false)
606
-    {
607
-        Benchmark::measureMemory($label, $output_now);
608
-    }
609
-
610
-
611
-
612
-    /**
613
-     * @deprecated 4.9.39.rc.034
614
-     * @param int $size
615
-     * @return string
616
-     */
617
-    public function convert($size)
618
-    {
619
-        return Benchmark::convert($size);
620
-    }
621
-
622
-
623
-
624
-    /**
625
-     * @deprecated 4.9.39.rc.034
626
-     * @param bool $output_now
627
-     * @return string
628
-     */
629
-    public function show_times($output_now = true)
630
-    {
631
-        return Benchmark::displayResults($output_now);
632
-    }
633
-
634
-
635
-
636
-    /**
637
-     * @deprecated 4.9.39.rc.034
638
-     * @param string $timer_name
639
-     * @param float  $total_time
640
-     * @return string
641
-     */
642
-    public function format_time($timer_name, $total_time)
643
-    {
644
-        return Benchmark::formatTime($timer_name, $total_time);
645
-    }
20
+	/**
21
+	 *    instance of the EEH_Autoloader object
22
+	 *
23
+	 * @var    $_instance
24
+	 * @access    private
25
+	 */
26
+	private static $_instance;
27
+
28
+	/**
29
+	 * @var array
30
+	 */
31
+	protected $_memory_usage_points = array();
32
+
33
+
34
+
35
+	/**
36
+	 * @singleton method used to instantiate class object
37
+	 * @access    public
38
+	 * @return EEH_Debug_Tools
39
+	 */
40
+	public static function instance()
41
+	{
42
+		// check if class object is instantiated, and instantiated properly
43
+		if (! self::$_instance instanceof EEH_Debug_Tools) {
44
+			self::$_instance = new self();
45
+		}
46
+		return self::$_instance;
47
+	}
48
+
49
+
50
+
51
+	/**
52
+	 * private class constructor
53
+	 */
54
+	private function __construct()
55
+	{
56
+		// load Kint PHP debugging library
57
+		if (! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php')) {
58
+			// despite EE4 having a check for an existing copy of the Kint debugging class,
59
+			// if another plugin was loaded AFTER EE4 and they did NOT perform a similar check,
60
+			// then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error
61
+			// so we've moved it to our test folder so that it is not included with production releases
62
+			// plz use https://wordpress.org/plugins/kint-debugger/  if testing production versions of EE
63
+			require_once(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php');
64
+		}
65
+		// if ( ! defined('DOING_AJAX') || $_REQUEST['noheader'] !== 'true' || ! isset( $_REQUEST['noheader'], $_REQUEST['TB_iframe'] ) ) {
66
+		//add_action( 'shutdown', array($this,'espresso_session_footer_dump') );
67
+		// }
68
+		$plugin = basename(EE_PLUGIN_DIR_PATH);
69
+		add_action("activate_{$plugin}", array('EEH_Debug_Tools', 'ee_plugin_activation_errors'));
70
+		add_action('activated_plugin', array('EEH_Debug_Tools', 'ee_plugin_activation_errors'));
71
+		add_action('shutdown', array('EEH_Debug_Tools', 'show_db_name'));
72
+	}
73
+
74
+
75
+
76
+	/**
77
+	 *    show_db_name
78
+	 *
79
+	 * @return void
80
+	 */
81
+	public static function show_db_name()
82
+	{
83
+		if (! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) {
84
+			echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '
85
+				 . DB_NAME
86
+				 . '</p>';
87
+		}
88
+		if (EE_DEBUG) {
89
+			Benchmark::displayResults();
90
+		}
91
+	}
92
+
93
+
94
+
95
+	/**
96
+	 *    dump EE_Session object at bottom of page after everything else has happened
97
+	 *
98
+	 * @return void
99
+	 */
100
+	public function espresso_session_footer_dump()
101
+	{
102
+		if (
103
+			(defined('WP_DEBUG') && WP_DEBUG)
104
+			&& ! defined('DOING_AJAX')
105
+			&& class_exists('Kint')
106
+			&& function_exists('wp_get_current_user')
107
+			&& current_user_can('update_core')
108
+			&& class_exists('EE_Registry')
109
+		) {
110
+			Kint::dump(EE_Registry::instance()->SSN->id());
111
+			Kint::dump(EE_Registry::instance()->SSN);
112
+			//			Kint::dump( EE_Registry::instance()->SSN->get_session_data('cart')->get_tickets() );
113
+			$this->espresso_list_hooked_functions();
114
+			Benchmark::displayResults();
115
+		}
116
+	}
117
+
118
+
119
+
120
+	/**
121
+	 *    List All Hooked Functions
122
+	 *    to list all functions for a specific hook, add ee_list_hooks={hook-name} to URL
123
+	 *    http://wp.smashingmagazine.com/2009/08/18/10-useful-wordpress-hook-hacks/
124
+	 *
125
+	 * @param string $tag
126
+	 * @return void
127
+	 */
128
+	public function espresso_list_hooked_functions($tag = '')
129
+	{
130
+		global $wp_filter;
131
+		echo '<br/><br/><br/><h3>Hooked Functions</h3>';
132
+		if ($tag) {
133
+			$hook[$tag] = $wp_filter[$tag];
134
+			if (! is_array($hook[$tag])) {
135
+				trigger_error("Nothing found for '$tag' hook", E_USER_WARNING);
136
+				return;
137
+			}
138
+			echo '<h5>For Tag: ' . $tag . '</h5>';
139
+		} else {
140
+			$hook = is_array($wp_filter) ? $wp_filter : array($wp_filter);
141
+			ksort($hook);
142
+		}
143
+		foreach ($hook as $tag_name => $priorities) {
144
+			echo "<br />&gt;&gt;&gt;&gt;&gt;\t<strong>$tag_name</strong><br />";
145
+			ksort($priorities);
146
+			foreach ($priorities as $priority => $function) {
147
+				echo $priority;
148
+				foreach ($function as $name => $properties) {
149
+					echo "\t$name<br />";
150
+				}
151
+			}
152
+		}
153
+	}
154
+
155
+
156
+
157
+	/**
158
+	 *    registered_filter_callbacks
159
+	 *
160
+	 * @param string $hook_name
161
+	 * @return array
162
+	 */
163
+	public static function registered_filter_callbacks($hook_name = '')
164
+	{
165
+		$filters = array();
166
+		global $wp_filter;
167
+		if (isset($wp_filter[$hook_name])) {
168
+			$filters[$hook_name] = array();
169
+			foreach ($wp_filter[$hook_name] as $priority => $callbacks) {
170
+				$filters[$hook_name][$priority] = array();
171
+				foreach ($callbacks as $callback) {
172
+					$filters[$hook_name][$priority][] = $callback['function'];
173
+				}
174
+			}
175
+		}
176
+		return $filters;
177
+	}
178
+
179
+
180
+
181
+	/**
182
+	 *    captures plugin activation errors for debugging
183
+	 *
184
+	 * @return void
185
+	 * @throws EE_Error
186
+	 */
187
+	public static function ee_plugin_activation_errors()
188
+	{
189
+		if (WP_DEBUG) {
190
+			$activation_errors = ob_get_contents();
191
+			if (! empty($activation_errors)) {
192
+				$activation_errors = date('Y-m-d H:i:s') . "\n" . $activation_errors;
193
+			}
194
+			espresso_load_required('EEH_File', EE_HELPERS . 'EEH_File.helper.php');
195
+			if (class_exists('EEH_File')) {
196
+				try {
197
+					EEH_File::ensure_file_exists_and_is_writable(
198
+						EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html'
199
+					);
200
+					EEH_File::write_to_file(
201
+						EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html',
202
+						$activation_errors
203
+					);
204
+				} catch (EE_Error $e) {
205
+					EE_Error::add_error(
206
+						sprintf(
207
+							__(
208
+								'The Event Espresso activation errors file could not be setup because: %s',
209
+								'event_espresso'
210
+							),
211
+							$e->getMessage()
212
+						),
213
+						__FILE__, __FUNCTION__, __LINE__
214
+					);
215
+				}
216
+			} else {
217
+				// old school attempt
218
+				file_put_contents(
219
+					EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html',
220
+					$activation_errors
221
+				);
222
+			}
223
+			$activation_errors = get_option('ee_plugin_activation_errors', '') . $activation_errors;
224
+			update_option('ee_plugin_activation_errors', $activation_errors);
225
+		}
226
+	}
227
+
228
+
229
+
230
+	/**
231
+	 * This basically mimics the WordPress _doing_it_wrong() function except adds our own messaging etc.
232
+	 * Very useful for providing helpful messages to developers when the method of doing something has been deprecated,
233
+	 * or we want to make sure they use something the right way.
234
+	 *
235
+	 * @access public
236
+	 * @param string $function      The function that was called
237
+	 * @param string $message       A message explaining what has been done incorrectly
238
+	 * @param string $version       The version of Event Espresso where the error was added
239
+	 * @param string $applies_when  a version string for when you want the doing_it_wrong notice to begin appearing
240
+	 *                              for a deprecated function. This allows deprecation to occur during one version,
241
+	 *                              but not have any notices appear until a later version. This allows developers
242
+	 *                              extra time to update their code before notices appear.
243
+	 * @param int    $error_type
244
+	 * @uses   trigger_error()
245
+	 */
246
+	public function doing_it_wrong(
247
+		$function,
248
+		$message,
249
+		$version,
250
+		$applies_when = '',
251
+		$error_type = null
252
+	) {
253
+		$applies_when = ! empty($applies_when) ? $applies_when : espresso_version();
254
+		$error_type = $error_type !== null ? $error_type : E_USER_NOTICE;
255
+		// because we swapped the parameter order around for the last two params,
256
+		// let's verify that some third party isn't still passing an error type value for the third param
257
+		if (is_int($applies_when)) {
258
+			$error_type = $applies_when;
259
+			$applies_when = espresso_version();
260
+		}
261
+		// if not displaying notices yet, then just leave
262
+		if (version_compare(espresso_version(), $applies_when, '<')) {
263
+			return;
264
+		}
265
+		do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version);
266
+		$version = $version === null
267
+			? ''
268
+			: sprintf(
269
+				__('(This message was added in version %s of Event Espresso)', 'event_espresso'),
270
+				$version
271
+			);
272
+		$error_message = sprintf(
273
+			esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s', 'event_espresso'),
274
+			$function,
275
+			'<strong>',
276
+			'</strong>',
277
+			$message,
278
+			$version
279
+		);
280
+		// don't trigger error if doing ajax,
281
+		// instead we'll add a transient EE_Error notice that in theory should show on the next request.
282
+		if (defined('DOING_AJAX') && DOING_AJAX) {
283
+			$error_message .= ' ' . esc_html__(
284
+					'This is a doing_it_wrong message that was triggered during an ajax request.  The request params on this request were: ',
285
+					'event_espresso'
286
+				);
287
+			$error_message .= '<ul><li>';
288
+			$error_message .= implode('</li><li>', EE_Registry::instance()->REQ->params());
289
+			$error_message .= '</ul>';
290
+			EE_Error::add_error($error_message, 'debug::doing_it_wrong', $function, '42');
291
+			//now we set this on the transient so it shows up on the next request.
292
+			EE_Error::get_notices(false, true);
293
+		} else {
294
+			trigger_error($error_message, $error_type);
295
+		}
296
+	}
297
+
298
+
299
+
300
+
301
+	/**
302
+	 * Logger helpers
303
+	 */
304
+	/**
305
+	 * debug
306
+	 *
307
+	 * @param string $class
308
+	 * @param string $func
309
+	 * @param string $line
310
+	 * @param array  $info
311
+	 * @param bool   $display_request
312
+	 * @param string $debug_index
313
+	 * @param string $debug_key
314
+	 * @throws EE_Error
315
+	 * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
316
+	 */
317
+	public static function log(
318
+		$class = '',
319
+		$func = '',
320
+		$line = '',
321
+		$info = array(),
322
+		$display_request = false,
323
+		$debug_index = '',
324
+		$debug_key = 'EE_DEBUG_SPCO'
325
+	) {
326
+		if (WP_DEBUG) {
327
+			$debug_key = $debug_key . '_' . EE_Session::instance()->id();
328
+			$debug_data = get_option($debug_key, array());
329
+			$default_data = array(
330
+				$class => $func . '() : ' . $line,
331
+				'REQ'  => $display_request ? $_REQUEST : '',
332
+			);
333
+			// don't serialize objects
334
+			$info = self::strip_objects($info);
335
+			$index = ! empty($debug_index) ? $debug_index : 0;
336
+			if (! isset($debug_data[$index])) {
337
+				$debug_data[$index] = array();
338
+			}
339
+			$debug_data[$index][microtime()] = array_merge($default_data, $info);
340
+			update_option($debug_key, $debug_data);
341
+		}
342
+	}
343
+
344
+
345
+
346
+	/**
347
+	 * strip_objects
348
+	 *
349
+	 * @param array $info
350
+	 * @return array
351
+	 */
352
+	public static function strip_objects($info = array())
353
+	{
354
+		foreach ($info as $key => $value) {
355
+			if (is_array($value)) {
356
+				$info[$key] = self::strip_objects($value);
357
+			} else if (is_object($value)) {
358
+				$object_class = get_class($value);
359
+				$info[$object_class] = array();
360
+				$info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value);
361
+				if (method_exists($value, 'ID')) {
362
+					$info[$object_class]['ID'] = $value->ID();
363
+				}
364
+				if (method_exists($value, 'status')) {
365
+					$info[$object_class]['status'] = $value->status();
366
+				} else if (method_exists($value, 'status_ID')) {
367
+					$info[$object_class]['status'] = $value->status_ID();
368
+				}
369
+				unset($info[$key]);
370
+			}
371
+		}
372
+		return (array)$info;
373
+	}
374
+
375
+
376
+
377
+	/**
378
+	 * @param mixed      $var
379
+	 * @param string     $var_name
380
+	 * @param string     $file
381
+	 * @param int|string $line
382
+	 * @param int        $heading_tag
383
+	 * @param bool       $die
384
+	 * @param string     $margin
385
+	 */
386
+	public static function printv(
387
+		$var,
388
+		$var_name = '',
389
+		$file = '',
390
+		$line = '',
391
+		$heading_tag = 5,
392
+		$die = false,
393
+		$margin = ''
394
+	) {
395
+		$var_name = ! $var_name ? 'string' : $var_name;
396
+		$var_name = ucwords(str_replace('$', '', $var_name));
397
+		$is_method = method_exists($var_name, $var);
398
+		$var_name = ucwords(str_replace('_', ' ', $var_name));
399
+		$heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5';
400
+		$result = EEH_Debug_Tools::heading($var_name, $heading_tag, $margin);
401
+		$result .= $is_method
402
+			? EEH_Debug_Tools::grey_span('::') . EEH_Debug_Tools::orange_span($var . '()')
403
+			: EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span($var);
404
+		$result .= EEH_Debug_Tools::file_and_line($file, $line);
405
+		$result .= EEH_Debug_Tools::headingX($heading_tag);
406
+		if ($die) {
407
+			die($result);
408
+		}
409
+		echo $result;
410
+	}
411
+
412
+
413
+
414
+	/**
415
+	 * @param string $var_name
416
+	 * @param string $heading_tag
417
+	 * @param string $margin
418
+	 * @return string
419
+	 */
420
+	protected static function heading($var_name = '', $heading_tag = 'h5', $margin = '')
421
+	{
422
+		if (defined('EE_TESTS_DIR')) {
423
+			return "\n{$var_name}";
424
+		}
425
+		$margin = "25px 0 0 {$margin}";
426
+		return '<' . $heading_tag . ' style="color:#2EA2CC; margin:' . $margin . ';"><b>' . $var_name . '</b>';
427
+	}
428
+
429
+
430
+
431
+	/**
432
+	 * @param string $heading_tag
433
+	 * @return string
434
+	 */
435
+	protected static function headingX($heading_tag = 'h5')
436
+	{
437
+		if (defined('EE_TESTS_DIR')) {
438
+			return '';
439
+		}
440
+		return '</' . $heading_tag . '>';
441
+	}
442
+
443
+
444
+
445
+	/**
446
+	 * @param string $content
447
+	 * @return string
448
+	 */
449
+	protected static function grey_span($content = '')
450
+	{
451
+		if (defined('EE_TESTS_DIR')) {
452
+			return $content;
453
+		}
454
+		return '<span style="color:#999">' . $content . '</span>';
455
+	}
456
+
457
+
458
+
459
+	/**
460
+	 * @param string $file
461
+	 * @param int    $line
462
+	 * @return string
463
+	 */
464
+	protected static function file_and_line($file, $line)
465
+	{
466
+		if ($file === '' || $line === '') {
467
+			return '';
468
+		}
469
+		if (defined('EE_TESTS_DIR')) {
470
+			return "\n (" . $file . ' line no: ' . $line . ' ) ';
471
+		}
472
+		return '<br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">'
473
+			   . $file
474
+			   . '<br />line no: '
475
+			   . $line
476
+			   . '</span>';
477
+	}
478
+
479
+
480
+
481
+	/**
482
+	 * @param string $content
483
+	 * @return string
484
+	 */
485
+	protected static function orange_span($content = '')
486
+	{
487
+		if (defined('EE_TESTS_DIR')) {
488
+			return $content;
489
+		}
490
+		return '<span style="color:#E76700">' . $content . '</span>';
491
+	}
492
+
493
+
494
+
495
+	/**
496
+	 * @param mixed $var
497
+	 * @return string
498
+	 */
499
+	protected static function pre_span($var)
500
+	{
501
+		ob_start();
502
+		var_dump($var);
503
+		$var = ob_get_clean();
504
+		if (defined('EE_TESTS_DIR')) {
505
+			return "\n" . $var;
506
+		}
507
+		return '<pre style="color:#999; padding:1em; background: #fff">' . $var . '</pre>';
508
+	}
509
+
510
+
511
+
512
+	/**
513
+	 * @param mixed      $var
514
+	 * @param string     $var_name
515
+	 * @param string     $file
516
+	 * @param int|string $line
517
+	 * @param int        $heading_tag
518
+	 * @param bool       $die
519
+	 */
520
+	public static function printr(
521
+		$var,
522
+		$var_name = '',
523
+		$file = '',
524
+		$line = '',
525
+		$heading_tag = 5,
526
+		$die = false
527
+	) {
528
+		// return;
529
+		$file = str_replace(rtrim(ABSPATH, '\\/'), '', $file);
530
+		$margin = is_admin() ? ' 180px' : '0';
531
+		//$print_r = false;
532
+		if (is_string($var)) {
533
+			EEH_Debug_Tools::printv($var, $var_name, $file, $line, $heading_tag, $die, $margin);
534
+			return;
535
+		}
536
+		if (is_object($var)) {
537
+			$var_name = ! $var_name ? 'object' : $var_name;
538
+			//$print_r = true;
539
+		} else if (is_array($var)) {
540
+			$var_name = ! $var_name ? 'array' : $var_name;
541
+			//$print_r = true;
542
+		} else if (is_numeric($var)) {
543
+			$var_name = ! $var_name ? 'numeric' : $var_name;
544
+		} else if ($var === null) {
545
+			$var_name = ! $var_name ? 'null' : $var_name;
546
+		}
547
+		$var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name));
548
+		$heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5';
549
+		$result = EEH_Debug_Tools::heading($var_name, $heading_tag, $margin);
550
+		$result .= EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span(
551
+				EEH_Debug_Tools::pre_span($var)
552
+			);
553
+		$result .= EEH_Debug_Tools::file_and_line($file, $line);
554
+		$result .= EEH_Debug_Tools::headingX($heading_tag);
555
+		if ($die) {
556
+			die($result);
557
+		}
558
+		echo $result;
559
+	}
560
+
561
+
562
+
563
+	/******************** deprecated ********************/
564
+
565
+
566
+
567
+	/**
568
+	 * @deprecated 4.9.39.rc.034
569
+	 */
570
+	public function reset_times()
571
+	{
572
+		Benchmark::resetTimes();
573
+	}
574
+
575
+
576
+
577
+	/**
578
+	 * @deprecated 4.9.39.rc.034
579
+	 * @param null $timer_name
580
+	 */
581
+	public function start_timer($timer_name = null)
582
+	{
583
+		Benchmark::startTimer($timer_name);
584
+	}
585
+
586
+
587
+
588
+	/**
589
+	 * @deprecated 4.9.39.rc.034
590
+	 * @param string $timer_name
591
+	 */
592
+	public function stop_timer($timer_name = '')
593
+	{
594
+		Benchmark::stopTimer($timer_name);
595
+	}
596
+
597
+
598
+
599
+	/**
600
+	 * @deprecated 4.9.39.rc.034
601
+	 * @param string  $label      The label to show for this time eg "Start of calling Some_Class::some_function"
602
+	 * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called
603
+	 * @return void
604
+	 */
605
+	public function measure_memory($label, $output_now = false)
606
+	{
607
+		Benchmark::measureMemory($label, $output_now);
608
+	}
609
+
610
+
611
+
612
+	/**
613
+	 * @deprecated 4.9.39.rc.034
614
+	 * @param int $size
615
+	 * @return string
616
+	 */
617
+	public function convert($size)
618
+	{
619
+		return Benchmark::convert($size);
620
+	}
621
+
622
+
623
+
624
+	/**
625
+	 * @deprecated 4.9.39.rc.034
626
+	 * @param bool $output_now
627
+	 * @return string
628
+	 */
629
+	public function show_times($output_now = true)
630
+	{
631
+		return Benchmark::displayResults($output_now);
632
+	}
633
+
634
+
635
+
636
+	/**
637
+	 * @deprecated 4.9.39.rc.034
638
+	 * @param string $timer_name
639
+	 * @param float  $total_time
640
+	 * @return string
641
+	 */
642
+	public function format_time($timer_name, $total_time)
643
+	{
644
+		return Benchmark::formatTime($timer_name, $total_time);
645
+	}
646 646
 
647 647
 
648 648
 
@@ -655,31 +655,31 @@  discard block
 block discarded – undo
655 655
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
656 656
  */
657 657
 if (class_exists('Kint') && ! function_exists('dump_wp_query')) {
658
-    function dump_wp_query()
659
-    {
660
-        global $wp_query;
661
-        d($wp_query);
662
-    }
658
+	function dump_wp_query()
659
+	{
660
+		global $wp_query;
661
+		d($wp_query);
662
+	}
663 663
 }
664 664
 /**
665 665
  * borrowed from Kint Debugger
666 666
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
667 667
  */
668 668
 if (class_exists('Kint') && ! function_exists('dump_wp')) {
669
-    function dump_wp()
670
-    {
671
-        global $wp;
672
-        d($wp);
673
-    }
669
+	function dump_wp()
670
+	{
671
+		global $wp;
672
+		d($wp);
673
+	}
674 674
 }
675 675
 /**
676 676
  * borrowed from Kint Debugger
677 677
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
678 678
  */
679 679
 if (class_exists('Kint') && ! function_exists('dump_post')) {
680
-    function dump_post()
681
-    {
682
-        global $post;
683
-        d($post);
684
-    }
680
+	function dump_post()
681
+	{
682
+		global $post;
683
+		d($post);
684
+	}
685 685
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php use EventEspresso\core\services\Benchmark;
2 2
 
3
-if (! defined('EVENT_ESPRESSO_VERSION')) {
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4 4
     exit('No direct script access allowed');
5 5
 }
6 6
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     public static function instance()
41 41
     {
42 42
         // check if class object is instantiated, and instantiated properly
43
-        if (! self::$_instance instanceof EEH_Debug_Tools) {
43
+        if ( ! self::$_instance instanceof EEH_Debug_Tools) {
44 44
             self::$_instance = new self();
45 45
         }
46 46
         return self::$_instance;
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
     private function __construct()
55 55
     {
56 56
         // load Kint PHP debugging library
57
-        if (! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php')) {
57
+        if ( ! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php')) {
58 58
             // despite EE4 having a check for an existing copy of the Kint debugging class,
59 59
             // if another plugin was loaded AFTER EE4 and they did NOT perform a similar check,
60 60
             // then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error
61 61
             // so we've moved it to our test folder so that it is not included with production releases
62 62
             // plz use https://wordpress.org/plugins/kint-debugger/  if testing production versions of EE
63
-            require_once(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php');
63
+            require_once(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php');
64 64
         }
65 65
         // if ( ! defined('DOING_AJAX') || $_REQUEST['noheader'] !== 'true' || ! isset( $_REQUEST['noheader'], $_REQUEST['TB_iframe'] ) ) {
66 66
         //add_action( 'shutdown', array($this,'espresso_session_footer_dump') );
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public static function show_db_name()
82 82
     {
83
-        if (! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) {
83
+        if ( ! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) {
84 84
             echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '
85 85
                  . DB_NAME
86 86
                  . '</p>';
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
         echo '<br/><br/><br/><h3>Hooked Functions</h3>';
132 132
         if ($tag) {
133 133
             $hook[$tag] = $wp_filter[$tag];
134
-            if (! is_array($hook[$tag])) {
134
+            if ( ! is_array($hook[$tag])) {
135 135
                 trigger_error("Nothing found for '$tag' hook", E_USER_WARNING);
136 136
                 return;
137 137
             }
138
-            echo '<h5>For Tag: ' . $tag . '</h5>';
138
+            echo '<h5>For Tag: '.$tag.'</h5>';
139 139
         } else {
140 140
             $hook = is_array($wp_filter) ? $wp_filter : array($wp_filter);
141 141
             ksort($hook);
@@ -188,17 +188,17 @@  discard block
 block discarded – undo
188 188
     {
189 189
         if (WP_DEBUG) {
190 190
             $activation_errors = ob_get_contents();
191
-            if (! empty($activation_errors)) {
192
-                $activation_errors = date('Y-m-d H:i:s') . "\n" . $activation_errors;
191
+            if ( ! empty($activation_errors)) {
192
+                $activation_errors = date('Y-m-d H:i:s')."\n".$activation_errors;
193 193
             }
194
-            espresso_load_required('EEH_File', EE_HELPERS . 'EEH_File.helper.php');
194
+            espresso_load_required('EEH_File', EE_HELPERS.'EEH_File.helper.php');
195 195
             if (class_exists('EEH_File')) {
196 196
                 try {
197 197
                     EEH_File::ensure_file_exists_and_is_writable(
198
-                        EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html'
198
+                        EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html'
199 199
                     );
200 200
                     EEH_File::write_to_file(
201
-                        EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html',
201
+                        EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html',
202 202
                         $activation_errors
203 203
                     );
204 204
                 } catch (EE_Error $e) {
@@ -216,11 +216,11 @@  discard block
 block discarded – undo
216 216
             } else {
217 217
                 // old school attempt
218 218
                 file_put_contents(
219
-                    EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html',
219
+                    EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html',
220 220
                     $activation_errors
221 221
                 );
222 222
             }
223
-            $activation_errors = get_option('ee_plugin_activation_errors', '') . $activation_errors;
223
+            $activation_errors = get_option('ee_plugin_activation_errors', '').$activation_errors;
224 224
             update_option('ee_plugin_activation_errors', $activation_errors);
225 225
         }
226 226
     }
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
         // don't trigger error if doing ajax,
281 281
         // instead we'll add a transient EE_Error notice that in theory should show on the next request.
282 282
         if (defined('DOING_AJAX') && DOING_AJAX) {
283
-            $error_message .= ' ' . esc_html__(
283
+            $error_message .= ' '.esc_html__(
284 284
                     'This is a doing_it_wrong message that was triggered during an ajax request.  The request params on this request were: ',
285 285
                     'event_espresso'
286 286
                 );
@@ -324,16 +324,16 @@  discard block
 block discarded – undo
324 324
         $debug_key = 'EE_DEBUG_SPCO'
325 325
     ) {
326 326
         if (WP_DEBUG) {
327
-            $debug_key = $debug_key . '_' . EE_Session::instance()->id();
327
+            $debug_key = $debug_key.'_'.EE_Session::instance()->id();
328 328
             $debug_data = get_option($debug_key, array());
329 329
             $default_data = array(
330
-                $class => $func . '() : ' . $line,
330
+                $class => $func.'() : '.$line,
331 331
                 'REQ'  => $display_request ? $_REQUEST : '',
332 332
             );
333 333
             // don't serialize objects
334 334
             $info = self::strip_objects($info);
335 335
             $index = ! empty($debug_index) ? $debug_index : 0;
336
-            if (! isset($debug_data[$index])) {
336
+            if ( ! isset($debug_data[$index])) {
337 337
                 $debug_data[$index] = array();
338 338
             }
339 339
             $debug_data[$index][microtime()] = array_merge($default_data, $info);
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
                 unset($info[$key]);
370 370
             }
371 371
         }
372
-        return (array)$info;
372
+        return (array) $info;
373 373
     }
374 374
 
375 375
 
@@ -399,8 +399,8 @@  discard block
 block discarded – undo
399 399
         $heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5';
400 400
         $result = EEH_Debug_Tools::heading($var_name, $heading_tag, $margin);
401 401
         $result .= $is_method
402
-            ? EEH_Debug_Tools::grey_span('::') . EEH_Debug_Tools::orange_span($var . '()')
403
-            : EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span($var);
402
+            ? EEH_Debug_Tools::grey_span('::').EEH_Debug_Tools::orange_span($var.'()')
403
+            : EEH_Debug_Tools::grey_span(' : ').EEH_Debug_Tools::orange_span($var);
404 404
         $result .= EEH_Debug_Tools::file_and_line($file, $line);
405 405
         $result .= EEH_Debug_Tools::headingX($heading_tag);
406 406
         if ($die) {
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
             return "\n{$var_name}";
424 424
         }
425 425
         $margin = "25px 0 0 {$margin}";
426
-        return '<' . $heading_tag . ' style="color:#2EA2CC; margin:' . $margin . ';"><b>' . $var_name . '</b>';
426
+        return '<'.$heading_tag.' style="color:#2EA2CC; margin:'.$margin.';"><b>'.$var_name.'</b>';
427 427
     }
428 428
 
429 429
 
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
         if (defined('EE_TESTS_DIR')) {
438 438
             return '';
439 439
         }
440
-        return '</' . $heading_tag . '>';
440
+        return '</'.$heading_tag.'>';
441 441
     }
442 442
 
443 443
 
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
         if (defined('EE_TESTS_DIR')) {
452 452
             return $content;
453 453
         }
454
-        return '<span style="color:#999">' . $content . '</span>';
454
+        return '<span style="color:#999">'.$content.'</span>';
455 455
     }
456 456
 
457 457
 
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
             return '';
468 468
         }
469 469
         if (defined('EE_TESTS_DIR')) {
470
-            return "\n (" . $file . ' line no: ' . $line . ' ) ';
470
+            return "\n (".$file.' line no: '.$line.' ) ';
471 471
         }
472 472
         return '<br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">'
473 473
                . $file
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
         if (defined('EE_TESTS_DIR')) {
488 488
             return $content;
489 489
         }
490
-        return '<span style="color:#E76700">' . $content . '</span>';
490
+        return '<span style="color:#E76700">'.$content.'</span>';
491 491
     }
492 492
 
493 493
 
@@ -502,9 +502,9 @@  discard block
 block discarded – undo
502 502
         var_dump($var);
503 503
         $var = ob_get_clean();
504 504
         if (defined('EE_TESTS_DIR')) {
505
-            return "\n" . $var;
505
+            return "\n".$var;
506 506
         }
507
-        return '<pre style="color:#999; padding:1em; background: #fff">' . $var . '</pre>';
507
+        return '<pre style="color:#999; padding:1em; background: #fff">'.$var.'</pre>';
508 508
     }
509 509
 
510 510
 
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
         $var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name));
548 548
         $heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5';
549 549
         $result = EEH_Debug_Tools::heading($var_name, $heading_tag, $margin);
550
-        $result .= EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span(
550
+        $result .= EEH_Debug_Tools::grey_span(' : ').EEH_Debug_Tools::orange_span(
551 551
                 EEH_Debug_Tools::pre_span($var)
552 552
             );
553 553
         $result .= EEH_Debug_Tools::file_and_line($file, $line);
Please login to merge, or discard this patch.
core/EED_Module.module.php 1 patch
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -14,121 +14,121 @@
 block discarded – undo
14 14
 abstract class EED_Module extends EE_Configurable implements ResettableInterface
15 15
 {
16 16
 
17
-    /**
18
-     * rendered output to be returned to WP
19
-     *
20
-     * @var    string $output
21
-     */
22
-    protected $output = '';
23
-
24
-    /**
25
-     * the current active espresso template theme
26
-     *
27
-     * @var    string $theme
28
-     */
29
-    protected $theme = '';
30
-
31
-
32
-
33
-    /**
34
-     * @return void
35
-     */
36
-    public static function reset()
37
-    {
38
-        $module_name = get_called_class();
39
-        new $module_name();
40
-    }
41
-
42
-
43
-
44
-    /**
45
-     *    set_hooks - for hooking into EE Core, other modules, etc
46
-     *
47
-     * @access    public
48
-     * @return    void
49
-     */
50
-    public static function set_hooks()
51
-    {
52
-    }
53
-
54
-
55
-
56
-    /**
57
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
58
-     *
59
-     * @access    public
60
-     * @return    void
61
-     */
62
-    public static function set_hooks_admin()
63
-    {
64
-    }
65
-
66
-
67
-
68
-    /**
69
-     *    run - initial module setup
70
-     *    this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters
71
-     *
72
-     * @access    public
73
-     * @var            WP $WP
74
-     * @return    void
75
-     */
76
-    abstract public function run($WP);
77
-
78
-
79
-
80
-    /**
81
-     * EED_Module constructor.
82
-     */
83
-    final public function __construct()
84
-    {
85
-        $this->theme = EE_Config::get_current_theme();
86
-        $module_name = $this->module_name();
87
-        EE_Registry::instance()->modules->{$module_name} = $this;
88
-    }
89
-
90
-
91
-
92
-    /**
93
-     * @param $module_name
94
-     * @return EED_Module
95
-     */
96
-    protected static function get_instance($module_name = '')
97
-    {
98
-        $module_name = ! empty($module_name)
99
-            ? $module_name
100
-            : get_called_class();
101
-        if (
102
-            ! isset(EE_Registry::instance()->modules->{$module_name})
103
-            || ! EE_Registry::instance()->modules->{$module_name} instanceof EED_Module
104
-        ) {
105
-            EE_Registry::instance()->add_module($module_name);
106
-        }
107
-        return EE_Registry::instance()->get_module($module_name);
108
-    }
109
-
110
-
111
-
112
-    /**
113
-     *    module_name
114
-     *
115
-     * @access    public
116
-     * @return    string
117
-     */
118
-    public function module_name()
119
-    {
120
-        return get_class($this);
121
-    }
122
-
123
-
124
-
125
-    /**
126
-     * @return string
127
-     */
128
-    public function theme()
129
-    {
130
-        return $this->theme;
131
-    }
17
+	/**
18
+	 * rendered output to be returned to WP
19
+	 *
20
+	 * @var    string $output
21
+	 */
22
+	protected $output = '';
23
+
24
+	/**
25
+	 * the current active espresso template theme
26
+	 *
27
+	 * @var    string $theme
28
+	 */
29
+	protected $theme = '';
30
+
31
+
32
+
33
+	/**
34
+	 * @return void
35
+	 */
36
+	public static function reset()
37
+	{
38
+		$module_name = get_called_class();
39
+		new $module_name();
40
+	}
41
+
42
+
43
+
44
+	/**
45
+	 *    set_hooks - for hooking into EE Core, other modules, etc
46
+	 *
47
+	 * @access    public
48
+	 * @return    void
49
+	 */
50
+	public static function set_hooks()
51
+	{
52
+	}
53
+
54
+
55
+
56
+	/**
57
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
58
+	 *
59
+	 * @access    public
60
+	 * @return    void
61
+	 */
62
+	public static function set_hooks_admin()
63
+	{
64
+	}
65
+
66
+
67
+
68
+	/**
69
+	 *    run - initial module setup
70
+	 *    this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters
71
+	 *
72
+	 * @access    public
73
+	 * @var            WP $WP
74
+	 * @return    void
75
+	 */
76
+	abstract public function run($WP);
77
+
78
+
79
+
80
+	/**
81
+	 * EED_Module constructor.
82
+	 */
83
+	final public function __construct()
84
+	{
85
+		$this->theme = EE_Config::get_current_theme();
86
+		$module_name = $this->module_name();
87
+		EE_Registry::instance()->modules->{$module_name} = $this;
88
+	}
89
+
90
+
91
+
92
+	/**
93
+	 * @param $module_name
94
+	 * @return EED_Module
95
+	 */
96
+	protected static function get_instance($module_name = '')
97
+	{
98
+		$module_name = ! empty($module_name)
99
+			? $module_name
100
+			: get_called_class();
101
+		if (
102
+			! isset(EE_Registry::instance()->modules->{$module_name})
103
+			|| ! EE_Registry::instance()->modules->{$module_name} instanceof EED_Module
104
+		) {
105
+			EE_Registry::instance()->add_module($module_name);
106
+		}
107
+		return EE_Registry::instance()->get_module($module_name);
108
+	}
109
+
110
+
111
+
112
+	/**
113
+	 *    module_name
114
+	 *
115
+	 * @access    public
116
+	 * @return    string
117
+	 */
118
+	public function module_name()
119
+	{
120
+		return get_class($this);
121
+	}
122
+
123
+
124
+
125
+	/**
126
+	 * @return string
127
+	 */
128
+	public function theme()
129
+	{
130
+		return $this->theme;
131
+	}
132 132
 
133 133
 
134 134
 
Please login to merge, or discard this patch.
core/helpers/EEH_Schema.helper.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -17,74 +17,74 @@  discard block
 block discarded – undo
17 17
 class EEH_Schema {
18 18
 
19 19
 
20
-    /**
21
-     * generates JSON-based linked data for an event
22
-     *
23
-     * @param EE_Event $event
24
-     * @throws EE_Error
25
-     */
26
-    public static function add_json_linked_data_for_event(EE_Event $event)
27
-    {
28
-    	//Check we have a valid datetime for the event
29
-    	if(! $event->primary_datetime() instanceof EE_Datetime) {
30
-    		return;
31
-    	}
32
-
33
-        $template_args = array(
34
-            'event_permalink' => '',
35
-            'event_name' => '',
36
-            'event_description' => '',
37
-            'event_start' => '',
38
-            'event_end' => '',
39
-            'currency' => '',
40
-            'event_tickets' => array(),
41
-            'venue_name' => '',
42
-            'venue_url' => '',
43
-            'venue_locality' => '',
44
-            'venue_region' => '',
45
-            'event_image' => '',
46
-        );
47
-        $template_args['event_permalink'] = $event->get_permalink();
48
-        $template_args['event_name'] = $event->name();
49
-        $template_args['event_description'] = wp_strip_all_tags($event->short_description(200));
50
-        // clone datetime so that date formats don't override those for the original datetime
51
-        $primary_datetime = clone $event->primary_datetime();
52
-        $template_args['event_start'] = $primary_datetime->start_date(DateTime::ATOM);
53
-        $template_args['event_end'] = $primary_datetime->end_date(DateTime::ATOM);
54
-        unset($primary_datetime);
55
-        $template_args['currency'] = EE_Registry::instance()->CFG->currency->code;
56
-        foreach ($event->tickets() as $original_ticket) {
57
-            // clone tickets so that date formats don't override those for the original ticket
58
-            $ticket= clone $original_ticket;
59
-            $ID = $ticket->ID();
60
-            $template_args['event_tickets'][$ID]['start_date'] = $ticket->start_date(DateTime::ATOM, null);
61
-            $template_args['event_tickets'][$ID]['end_date'] = $ticket->end_date(DateTime::ATOM, null);
62
-            $template_args['event_tickets'][$ID]['price'] = number_format(
63
-                $ticket->price(),
64
-                EE_Registry::instance()->CFG->currency->dec_plc,
65
-                EE_Registry::instance()->CFG->currency->dec_mrk,
66
-                EE_Registry::instance()->CFG->currency->thsnds
67
-            );
68
-            unset($ticket);
69
-        }
70
-        $VNU_ID = espresso_venue_id();
71
-        if ( ! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) {
72
-            $venue = EEH_Venue_View::get_venue($VNU_ID);
73
-            $template_args['venue_name'] = get_the_title($VNU_ID);
74
-            $template_args['venue_url'] = get_permalink($VNU_ID);
75
-            $template_args['venue_locality'] = $venue->city();
76
-            $template_args['venue_region'] = $venue->state_name();
77
-        }
78
-        $template_args['event_image'] = $event->feature_image_url();
79
-        $template_args = apply_filters(
80
-            'FHEE__EEH_Schema__add_json_linked_data_for_event__template_args',
81
-            $template_args,
82
-            $event,
83
-            $VNU_ID
84
-        );
85
-        extract($template_args, EXTR_OVERWRITE);
86
-        include EE_TEMPLATES . 'json_linked_data_for_event.template.php';
87
-    }
20
+	/**
21
+	 * generates JSON-based linked data for an event
22
+	 *
23
+	 * @param EE_Event $event
24
+	 * @throws EE_Error
25
+	 */
26
+	public static function add_json_linked_data_for_event(EE_Event $event)
27
+	{
28
+		//Check we have a valid datetime for the event
29
+		if(! $event->primary_datetime() instanceof EE_Datetime) {
30
+			return;
31
+		}
32
+
33
+		$template_args = array(
34
+			'event_permalink' => '',
35
+			'event_name' => '',
36
+			'event_description' => '',
37
+			'event_start' => '',
38
+			'event_end' => '',
39
+			'currency' => '',
40
+			'event_tickets' => array(),
41
+			'venue_name' => '',
42
+			'venue_url' => '',
43
+			'venue_locality' => '',
44
+			'venue_region' => '',
45
+			'event_image' => '',
46
+		);
47
+		$template_args['event_permalink'] = $event->get_permalink();
48
+		$template_args['event_name'] = $event->name();
49
+		$template_args['event_description'] = wp_strip_all_tags($event->short_description(200));
50
+		// clone datetime so that date formats don't override those for the original datetime
51
+		$primary_datetime = clone $event->primary_datetime();
52
+		$template_args['event_start'] = $primary_datetime->start_date(DateTime::ATOM);
53
+		$template_args['event_end'] = $primary_datetime->end_date(DateTime::ATOM);
54
+		unset($primary_datetime);
55
+		$template_args['currency'] = EE_Registry::instance()->CFG->currency->code;
56
+		foreach ($event->tickets() as $original_ticket) {
57
+			// clone tickets so that date formats don't override those for the original ticket
58
+			$ticket= clone $original_ticket;
59
+			$ID = $ticket->ID();
60
+			$template_args['event_tickets'][$ID]['start_date'] = $ticket->start_date(DateTime::ATOM, null);
61
+			$template_args['event_tickets'][$ID]['end_date'] = $ticket->end_date(DateTime::ATOM, null);
62
+			$template_args['event_tickets'][$ID]['price'] = number_format(
63
+				$ticket->price(),
64
+				EE_Registry::instance()->CFG->currency->dec_plc,
65
+				EE_Registry::instance()->CFG->currency->dec_mrk,
66
+				EE_Registry::instance()->CFG->currency->thsnds
67
+			);
68
+			unset($ticket);
69
+		}
70
+		$VNU_ID = espresso_venue_id();
71
+		if ( ! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) {
72
+			$venue = EEH_Venue_View::get_venue($VNU_ID);
73
+			$template_args['venue_name'] = get_the_title($VNU_ID);
74
+			$template_args['venue_url'] = get_permalink($VNU_ID);
75
+			$template_args['venue_locality'] = $venue->city();
76
+			$template_args['venue_region'] = $venue->state_name();
77
+		}
78
+		$template_args['event_image'] = $event->feature_image_url();
79
+		$template_args = apply_filters(
80
+			'FHEE__EEH_Schema__add_json_linked_data_for_event__template_args',
81
+			$template_args,
82
+			$event,
83
+			$VNU_ID
84
+		);
85
+		extract($template_args, EXTR_OVERWRITE);
86
+		include EE_TEMPLATES . 'json_linked_data_for_event.template.php';
87
+	}
88 88
 
89 89
 
90 90
 	/**
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 	 */
99 99
 	public static function location( $location = null ) {
100 100
 		return ! empty( $location ) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">'
101
-		                              . $location
102
-		                              . '</div>' : '';
101
+									  . $location
102
+									  . '</div>' : '';
103 103
 	}
104 104
 
105 105
 
@@ -219,8 +219,8 @@  discard block
 block discarded – undo
219 219
 	 */
220 220
 	public static function postalCode( EEI_Address $obj_with_address = null ) {
221 221
 		return $obj_with_address->zip() !== null && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">'
222
-		                                                                              . $obj_with_address->zip()
223
-		                                                                              . '</span>' : '';
222
+																					  . $obj_with_address->zip()
223
+																					  . '</span>' : '';
224 224
 	}
225 225
 
226 226
 
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 		//Check the URL includes a scheme
255 255
 		$parsed_url = parse_url($url);
256 256
 		if ( empty($parsed_url['scheme']) ) {
257
-		    $url = 'http://' . ltrim($url, '/');
257
+			$url = 'http://' . ltrim($url, '/');
258 258
 		}
259 259
 
260 260
 		$atts = '';
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
4
-	exit( 'No direct script access allowed' );
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4
+	exit('No direct script access allowed');
5 5
 }
6 6
 
7 7
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
     public static function add_json_linked_data_for_event(EE_Event $event)
27 27
     {
28 28
     	//Check we have a valid datetime for the event
29
-    	if(! $event->primary_datetime() instanceof EE_Datetime) {
29
+    	if ( ! $event->primary_datetime() instanceof EE_Datetime) {
30 30
     		return;
31 31
     	}
32 32
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
         $template_args['currency'] = EE_Registry::instance()->CFG->currency->code;
56 56
         foreach ($event->tickets() as $original_ticket) {
57 57
             // clone tickets so that date formats don't override those for the original ticket
58
-            $ticket= clone $original_ticket;
58
+            $ticket = clone $original_ticket;
59 59
             $ID = $ticket->ID();
60 60
             $template_args['event_tickets'][$ID]['start_date'] = $ticket->start_date(DateTime::ATOM, null);
61 61
             $template_args['event_tickets'][$ID]['end_date'] = $ticket->end_date(DateTime::ATOM, null);
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
             $VNU_ID
84 84
         );
85 85
         extract($template_args, EXTR_OVERWRITE);
86
-        include EE_TEMPLATES . 'json_linked_data_for_event.template.php';
86
+        include EE_TEMPLATES.'json_linked_data_for_event.template.php';
87 87
     }
88 88
 
89 89
 
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
 	 * @param string $location
97 97
 	 * @return string
98 98
 	 */
99
-	public static function location( $location = null ) {
100
-		return ! empty( $location ) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">'
99
+	public static function location($location = null) {
100
+		return ! empty($location) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">'
101 101
 		                              . $location
102 102
 		                              . '</div>' : '';
103 103
 	}
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 	 * @param string $name
113 113
 	 * @return string
114 114
 	 */
115
-	public static function name( $name = null ) {
116
-		return ! empty( $name ) ? '<span itemprop="name">' . $name . '</span>' : '';
115
+	public static function name($name = null) {
116
+		return ! empty($name) ? '<span itemprop="name">'.$name.'</span>' : '';
117 117
 	}
118 118
 
119 119
 
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
 	 * @param EEI_Address $obj_with_address
127 127
 	 * @return string
128 128
 	 */
129
-	public static function streetAddress( EEI_Address $obj_with_address = null ) {
129
+	public static function streetAddress(EEI_Address $obj_with_address = null) {
130 130
 		return $obj_with_address->address() !== null && $obj_with_address->address() !== ''
131
-			? '<span itemprop="streetAddress">' . $obj_with_address->address() . '</span>' : '';
131
+			? '<span itemprop="streetAddress">'.$obj_with_address->address().'</span>' : '';
132 132
 	}
133 133
 
134 134
 
@@ -141,14 +141,14 @@  discard block
 block discarded – undo
141 141
 	 * @param EEI_Address $obj_with_address
142 142
 	 * @return string
143 143
 	 */
144
-	public static function postOfficeBoxNumber( EEI_Address $obj_with_address = null ) {
144
+	public static function postOfficeBoxNumber(EEI_Address $obj_with_address = null) {
145 145
 		// regex check for some form of PO Box or P.O. Box, etc, etc, etc
146
-		if ( preg_match(
146
+		if (preg_match(
147 147
 			"/^\s*((P(OST)?.?\s*(O(FF(ICE)?)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i",
148 148
 			$obj_with_address->address2()
149
-		) ) {
149
+		)) {
150 150
 			return $obj_with_address->address2() !== null && $obj_with_address->address2() !== ''
151
-				? '<span itemprop="postOfficeBoxNumber">' . $obj_with_address->address2() . '</span>' : '';
151
+				? '<span itemprop="postOfficeBoxNumber">'.$obj_with_address->address2().'</span>' : '';
152 152
 		} else {
153 153
 			return $obj_with_address->address2();
154 154
 		}
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
 	 * @param EEI_Address $obj_with_address
165 165
 	 * @return string
166 166
 	 */
167
-	public static function addressLocality( EEI_Address $obj_with_address = null ) {
167
+	public static function addressLocality(EEI_Address $obj_with_address = null) {
168 168
 		return $obj_with_address->city() !== null && $obj_with_address->city() !== ''
169
-			? '<span itemprop="addressLocality">' . $obj_with_address->city() . '</span>' : '';
169
+			? '<span itemprop="addressLocality">'.$obj_with_address->city().'</span>' : '';
170 170
 	}
171 171
 
172 172
 
@@ -179,10 +179,10 @@  discard block
 block discarded – undo
179 179
 	 * @param EEI_Address $obj_with_address
180 180
 	 * @return string
181 181
 	 */
182
-	public static function addressRegion( EEI_Address $obj_with_address = null ) {
182
+	public static function addressRegion(EEI_Address $obj_with_address = null) {
183 183
 		$state = $obj_with_address->state_name();
184
-		if ( ! empty( $state ) ) {
185
-			return '<span itemprop="addressRegion">' . $state . '</span>';
184
+		if ( ! empty($state)) {
185
+			return '<span itemprop="addressRegion">'.$state.'</span>';
186 186
 		} else {
187 187
 			return '';
188 188
 		}
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
 	 * @param EEI_Address $obj_with_address
199 199
 	 * @return string
200 200
 	 */
201
-	public static function addressCountry( EEI_Address $obj_with_address = null ) {
201
+	public static function addressCountry(EEI_Address $obj_with_address = null) {
202 202
 		$country = $obj_with_address->country_name();
203
-		if ( ! empty( $country ) ) {
204
-			return '<span itemprop="addressCountry">' . $country . '</span>';
203
+		if ( ! empty($country)) {
204
+			return '<span itemprop="addressCountry">'.$country.'</span>';
205 205
 		} else {
206 206
 			return '';
207 207
 		}
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	 * @param EEI_Address $obj_with_address
218 218
 	 * @return string
219 219
 	 */
220
-	public static function postalCode( EEI_Address $obj_with_address = null ) {
220
+	public static function postalCode(EEI_Address $obj_with_address = null) {
221 221
 		return $obj_with_address->zip() !== null && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">'
222 222
 		                                                                              . $obj_with_address->zip()
223 223
 		                                                                              . '</span>' : '';
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
 	 * @param string $phone_nmbr
234 234
 	 * @return string
235 235
 	 */
236
-	public static function telephone( $phone_nmbr = null ) {
237
-		return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">' . $phone_nmbr . '</span>'
236
+	public static function telephone($phone_nmbr = null) {
237
+		return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">'.$phone_nmbr.'</span>'
238 238
 			: '';
239 239
 	}
240 240
 
@@ -250,19 +250,19 @@  discard block
 block discarded – undo
250 250
 	 * @param array  $attributes - array of additional link attributes in  attribute_name => value pairs. ie: array( 'title' => 'click here', 'class' => 'link-class' )
251 251
 	 * @return string (link)
252 252
 	 */
253
-	public static function url( $url = null, $text = null, $attributes = array() ) {
253
+	public static function url($url = null, $text = null, $attributes = array()) {
254 254
 		//Check the URL includes a scheme
255 255
 		$parsed_url = parse_url($url);
256
-		if ( empty($parsed_url['scheme']) ) {
257
-		    $url = 'http://' . ltrim($url, '/');
256
+		if (empty($parsed_url['scheme'])) {
257
+		    $url = 'http://'.ltrim($url, '/');
258 258
 		}
259 259
 
260 260
 		$atts = '';
261
-		foreach ( $attributes as $attribute => $value ) {
262
-			$atts .= ' ' . $attribute . '="' . $value . '"';
261
+		foreach ($attributes as $attribute => $value) {
262
+			$atts .= ' '.$attribute.'="'.$value.'"';
263 263
 		}
264 264
 		$text = $text !== null && $text !== '' ? $text : $url;
265
-		return $url !== null && $url !== '' ? '<a itemprop="url" href="' . $url . '"' . $atts . '>' . $text . '</a>'
265
+		return $url !== null && $url !== '' ? '<a itemprop="url" href="'.$url.'"'.$atts.'>'.$text.'</a>'
266 266
 			: '';
267 267
 	}
268 268
 
Please login to merge, or discard this patch.
admin_pages/events/Events_Admin_List_Table.class.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -165,7 +165,7 @@
 block discarded – undo
165 165
 
166 166
     /**
167 167
      * @param EE_Event $item
168
-     * @return mixed|string
168
+     * @return string
169 169
      */
170 170
     public function column_id(EE_Event $item)
171 171
     {
Please login to merge, or discard this patch.
Indentation   +401 added lines, -401 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -26,406 +26,406 @@  discard block
 block discarded – undo
26 26
 {
27 27
 
28 28
 
29
-    /**
30
-     * @var EE_Datetime
31
-     */
32
-    private $_dtt;
33
-
34
-
35
-    /**
36
-     * Events_Admin_List_Table constructor.
37
-     *
38
-     * @param EE_Admin_Page $admin_page
39
-     */
40
-    public function __construct($admin_page)
41
-    {
42
-        parent::__construct($admin_page);
43
-        require_once(EE_HELPERS . 'EEH_DTT_Helper.helper.php');
44
-    }
45
-
46
-
47
-    /**
48
-     * Initial setup of data properties for the list table.
49
-     */
50
-    protected function _setup_data()
51
-    {
52
-        $this->_data           = $this->_admin_page->get_events($this->_per_page, $this->_current_page);
53
-        $this->_all_data_count = $this->_admin_page->get_events(0, 0, true);
54
-    }
55
-
56
-
57
-    /**
58
-     * Set up of additional properties for the list table.
59
-     */
60
-    protected function _set_properties()
61
-    {
62
-        $this->_wp_list_args = array(
63
-            'singular' => __('event', 'event_espresso'),
64
-            'plural'   => __('events', 'event_espresso'),
65
-            'ajax'     => true, //for now
66
-            'screen'   => $this->_admin_page->get_current_screen()->id,
67
-        );
68
-
69
-
70
-        $this->_columns = array(
71
-            'cb'              => '<input type="checkbox" />',
72
-            'id'              => __('ID', 'event_espresso'),
73
-            'name'            => __('Name', 'event_espresso'),
74
-            'author'          => __('Author', 'event_espresso'),
75
-            'venue'           => __('Venue', 'event_espresso'),
76
-            'start_date_time' => __('Event Start', 'event_espresso'),
77
-            'reg_begins'      => __('On Sale', 'event_espresso'),
78
-            'attendees'       => '<span class="dashicons dashicons-groups ee-icon-color-ee-green ee-icon-size-20"></span>',
79
-            //'tkts_sold' => __('Tickets Sold', 'event_espresso'),
80
-            'actions'         => __('Actions', 'event_espresso'),
81
-        );
82
-
83
-
84
-        $this->_sortable_columns = array(
85
-            'id'              => array('EVT_ID' => true),
86
-            'name'            => array('EVT_name' => false),
87
-            'author'          => array('EVT_wp_user' => false),
88
-            'venue'           => array('Venue.VNU_name' => false),
89
-            'start_date_time' => array('Datetime.DTT_EVT_start' => false),
90
-            'reg_begins'      => array('Datetime.Ticket.TKT_start_date' => false),
91
-        );
92
-
93
-        $this->_primary_column = 'id';
94
-
95
-        $this->_hidden_columns = array('author');
96
-    }
97
-
98
-
99
-    /**
100
-     * @return array
101
-     */
102
-    protected function _get_table_filters()
103
-    {
104
-        return array(); //no filters with decaf
105
-    }
106
-
107
-
108
-    /**
109
-     * Setup of views properties.
110
-     */
111
-    protected function _add_view_counts()
112
-    {
113
-        $this->_views['all']['count']   = $this->_admin_page->total_events();
114
-        $this->_views['draft']['count'] = $this->_admin_page->total_events_draft();
115
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) {
116
-            $this->_views['trash']['count'] = $this->_admin_page->total_trashed_events();
117
-        }
118
-    }
119
-
120
-
121
-    /**
122
-     * @param EE_Event $item
123
-     * @return string
124
-     */
125
-    protected function _get_row_class($item)
126
-    {
127
-        $class = parent::_get_row_class($item);
128
-        //add status class
129
-        $class .= $item instanceof EE_Event ? ' ee-status-strip event-status-' . $item->get_active_status() : '';
130
-        if ($this->_has_checkbox_column) {
131
-            $class .= ' has-checkbox-column';
132
-        }
133
-        return $class;
134
-    }
135
-
136
-
137
-    /**
138
-     * @param EE_Event $item
139
-     * @return string
140
-     */
141
-    public function column_status(EE_Event $item)
142
-    {
143
-        return '<span class="ee-status-strip ee-status-strip-td event-status-' . $item->get_active_status() . '"></span>';
144
-    }/**/
145
-
146
-
147
-    /**
148
-     * @param  EE_Event $item
149
-     * @return string
150
-     */
151
-    public function column_cb($item)
152
-    {
153
-        if (! $item instanceof EE_Event) {
154
-            return '';
155
-        }
156
-        $this->_dtt = $item->primary_datetime(); //set this for use in other columns
157
-
158
-        //does event have any attached registrations?
159
-        $regs = $item->count_related('Registration');
160
-        return $regs > 0 && $this->_view == 'trash' ? '<span class="ee-lock-icon"></span>' : sprintf(
161
-            '<input type="checkbox" name="EVT_IDs[]" value="%s" />', $item->ID()
162
-        );
163
-    }
164
-
165
-
166
-    /**
167
-     * @param EE_Event $item
168
-     * @return mixed|string
169
-     */
170
-    public function column_id(EE_Event $item)
171
-    {
172
-        $content = $item->ID();
173
-        $content .= '  <span class="show-on-mobile-view-only">' . $item->name() . '</span>';
174
-        return $content;
175
-    }
176
-
177
-
178
-    /**
179
-     * @param EE_Event $item
180
-     * @return string
181
-     */
182
-    public function column_name(EE_Event $item)
183
-    {
184
-        $edit_query_args = array(
185
-            'action' => 'edit',
186
-            'post'   => $item->ID(),
187
-        );
188
-        $edit_link       = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
189
-        $actions         = $this->_column_name_action_setup($item);
190
-        $status          = ''; //$item->status() !== 'publish' ? ' (' . $item->status() . ')' : '';
191
-        $content         = '<strong><a class="row-title" href="' . $edit_link . '">' . $item->name() . '</a></strong>' . $status;
192
-        $content         .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->get_active_status(),
193
-                false, 'sentence') . '</span>';
194
-        $content         .= $this->row_actions($actions);
195
-        return $content;
196
-
197
-    }
198
-
199
-
200
-    /**
201
-     * Just a method for setting up the actions for the name column
202
-     *
203
-     * @param EE_Event $item
204
-     * @return array array of actions
205
-     */
206
-    protected function _column_name_action_setup(EE_Event $item)
207
-    {
208
-        //todo: remove when attendees is active
209
-        if (! defined('REG_ADMIN_URL')) {
210
-            define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
211
-        }
212
-
213
-        $actions = array();
214
-
215
-        if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $item->ID())) {
216
-            $edit_query_args = array(
217
-                'action' => 'edit',
218
-                'post'   => $item->ID(),
219
-            );
220
-            $edit_link       = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
221
-            $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr__('Edit Event',
222
-                    'event_espresso') . '">' . __('Edit', 'event_espresso') . '</a>';
223
-
224
-        }
225
-
226
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
227
-            'espresso_registrations_view_registration', $item->ID())) {
228
-            $attendees_query_args = array(
229
-                'action'   => 'default',
230
-                'event_id' => $item->ID(),
231
-            );
232
-            $attendees_link       = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
233
-            $actions['attendees'] = '<a href="' . $attendees_link . '" title="' . esc_attr__('View Registrations',
234
-                    'event_espresso') . '">' . __('Registrations', 'event_espresso') . '</a>';
235
-        }
236
-
237
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_trash_event',
238
-            $item->ID())) {
239
-            $trash_event_query_args = array(
240
-                'action' => 'trash_event',
241
-                'EVT_ID' => $item->ID(),
242
-            );
243
-            $trash_event_link       = EE_Admin_Page::add_query_args_and_nonce($trash_event_query_args,
244
-                EVENTS_ADMIN_URL);
245
-        }
246
-
247
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_restore_event',
248
-            $item->ID())) {
249
-            $restore_event_query_args = array(
250
-                'action' => 'restore_event',
251
-                'EVT_ID' => $item->ID(),
252
-            );
253
-            $restore_event_link       = EE_Admin_Page::add_query_args_and_nonce($restore_event_query_args,
254
-                EVENTS_ADMIN_URL);
255
-        }
256
-
257
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_delete_event',
258
-            $item->ID())) {
259
-            $delete_event_query_args = array(
260
-                'action' => 'delete_event',
261
-                'EVT_ID' => $item->ID(),
262
-            );
263
-            $delete_event_link       = EE_Admin_Page::add_query_args_and_nonce($delete_event_query_args,
264
-                EVENTS_ADMIN_URL);
265
-        }
266
-
267
-        $view_link = get_permalink($item->ID());
268
-
269
-        $actions['view'] = '<a href="' . $view_link . '" title="' . esc_attr__('View Event',
270
-                'event_espresso') . '">' . __('View', 'event_espresso') . '</a>';
271
-
272
-        switch ($item->get('status')) {
273
-            case 'trash' :
274
-                if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_restore_event',
275
-                    $item->ID())) {
276
-                    $actions['restore_from_trash'] = '<a href="' . $restore_event_link . '" title="' . esc_attr__('Restore from Trash',
277
-                            'event_espresso') . '">' . __('Restore from Trash', 'event_espresso') . '</a>';
278
-                }
279
-                if ($item->count_related('Registration') === 0 && EE_Registry::instance()->CAP->current_user_can('ee_delete_event',
280
-                        'espresso_events_delete_event', $item->ID())) {
281
-                    $actions['delete'] = '<a href="' . $delete_event_link . '" title="' . esc_attr__('Delete Permanently',
282
-                            'event_espresso') . '">' . __('Delete Permanently', 'event_espresso') . '</a>';
283
-                }
284
-                break;
285
-            default :
286
-                if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_trash_event',
287
-                    $item->ID())) {
288
-                    $actions['move to trash'] = '<a href="' . $trash_event_link . '" title="' . esc_attr__('Trash Event',
289
-                            'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>';
290
-                }
291
-        }
292
-        return $actions;
293
-    }
294
-
295
-
296
-    /**
297
-     * @param EE_Event $item
298
-     * @return string
299
-     */
300
-    public function column_author(EE_Event $item)
301
-    {
302
-        //user author info
303
-        $event_author = get_userdata($item->wp_user());
304
-        $gravatar     = get_avatar($item->wp_user(), '15');
305
-        //filter link
306
-        $query_args = array(
307
-            'action'      => 'default',
308
-            'EVT_wp_user' => $item->wp_user(),
309
-        );
310
-        $filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL);
311
-        return $gravatar . '  <a href="' . $filter_url . '" title="' . esc_attr__('Click to filter events by this author.',
312
-                'event_espresso') . '">' . $event_author->display_name . '</a>';
313
-    }
314
-
315
-
316
-    /**
317
-     * @param EE_Event $item
318
-     * @return string
319
-     */
320
-    public function column_venue(EE_Event $item)
321
-    {
322
-        $venue = $item->get_first_related('Venue');
323
-        return ! empty($venue) ? $venue->name() : '';
324
-    }
325
-
326
-
327
-    /**
328
-     * @param EE_Event $item
329
-     * @throws EE_Error
330
-     */
331
-    public function column_start_date_time(EE_Event $item)
332
-    {
333
-        echo ! empty($this->_dtt) ? $this->_dtt->get_i18n_datetime('DTT_EVT_start') : __('No Date was saved for this Event',
334
-            'event_espresso');
335
-        //display in user's timezone?
336
-        echo ! empty($this->_dtt) ? $this->_dtt->display_in_my_timezone('DTT_EVT_start', 'get_i18n_datetime', '',
337
-            'My Timezone: ') : '';
338
-
339
-    }
340
-
341
-
342
-    /**
343
-     * @param EE_Event $item
344
-     * @throws EE_Error
345
-     */
346
-    public function column_reg_begins(EE_Event $item)
347
-    {
348
-        $reg_start = $item->get_ticket_with_earliest_start_time();
349
-        echo ! empty($reg_start) ? $reg_start->get_i18n_datetime('TKT_start_date') : __('No Tickets have been setup for this Event',
350
-            'event_espresso');
351
-        //display in user's timezone?
352
-        echo ! empty($reg_start) ? $reg_start->display_in_my_timezone('TKT_start_date', 'get_i18n_datetime', '',
353
-            'My Timezone: ') : '';/**/
354
-    }
355
-
356
-
357
-    /**
358
-     * @param EE_Event $item
359
-     * @return int|string
360
-     */
361
-    public function column_attendees(EE_Event $item)
362
-    {
363
-        $attendees_query_args = array(
364
-            'action'   => 'default',
365
-            'event_id' => $item->ID(),
366
-        );
367
-        $attendees_link       = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
368
-        $registered_attendees = EEM_Registration::instance()->get_event_registration_count($item->ID());
369
-        return EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
370
-            'espresso_registrations_view_registration',
371
-            $item->ID()) ? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>' : $registered_attendees;
372
-    }
373
-
374
-
375
-    /**
376
-     * @param EE_Event $item
377
-     * @return float
378
-     */
379
-    public function column_tkts_sold(EE_Event $item)
380
-    {
381
-        return EEM_Ticket::instance()->sum(array(array('Datetime.EVT_ID' => $item->ID())), 'TKT_sold');
382
-    }
383
-
384
-
385
-    /**
386
-     * @param EE_Event $item
387
-     * @return string
388
-     */
389
-    public function column_actions(EE_Event $item)
390
-    {
391
-        //todo: remove when attendees is active
392
-        if (! defined('REG_ADMIN_URL')) {
393
-            define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
394
-        }
395
-        $actionlinks = array();
396
-
397
-        $view_link = get_permalink($item->ID());
398
-
399
-        $actionlinks[] = '<a href="' . $view_link . '" title="' . esc_attr__('View Event',
400
-                'event_espresso') . '" target="_blank">';
401
-        $actionlinks[] = '<div class="dashicons dashicons-search"></div></a>';
402
-
403
-        if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $item->ID())) {
404
-            $edit_query_args = array(
405
-                'action' => 'edit',
406
-                'post'   => $item->ID(),
407
-            );
408
-            $edit_link       = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
409
-            $actionlinks[]   = '<a href="' . $edit_link . '" title="' . esc_attr__('Edit Event',
410
-                    'event_espresso') . '"><div class="ee-icon ee-icon-calendar-edit"></div></a>';
411
-        }
412
-
413
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
414
-            'espresso_registrations_view_registration', $item->ID())) {
415
-            $attendees_query_args = array(
416
-                'action'   => 'default',
417
-                'event_id' => $item->ID(),
418
-            );
419
-            $attendees_link       = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
420
-            $actionlinks[]        = '<a href="' . $attendees_link . '" title="' . esc_attr__('View Registrants',
421
-                    'event_espresso') . '"><div class="dashicons dashicons-groups"></div></a>';
422
-        }
423
-
424
-        $actionlinks = apply_filters('FHEE__Events_Admin_List_Table__column_actions__action_links', $actionlinks,
425
-            $item);
426
-
427
-        return $this->_action_string(implode("\n\t", $actionlinks), $item, 'div');
428
-    }
29
+	/**
30
+	 * @var EE_Datetime
31
+	 */
32
+	private $_dtt;
33
+
34
+
35
+	/**
36
+	 * Events_Admin_List_Table constructor.
37
+	 *
38
+	 * @param EE_Admin_Page $admin_page
39
+	 */
40
+	public function __construct($admin_page)
41
+	{
42
+		parent::__construct($admin_page);
43
+		require_once(EE_HELPERS . 'EEH_DTT_Helper.helper.php');
44
+	}
45
+
46
+
47
+	/**
48
+	 * Initial setup of data properties for the list table.
49
+	 */
50
+	protected function _setup_data()
51
+	{
52
+		$this->_data           = $this->_admin_page->get_events($this->_per_page, $this->_current_page);
53
+		$this->_all_data_count = $this->_admin_page->get_events(0, 0, true);
54
+	}
55
+
56
+
57
+	/**
58
+	 * Set up of additional properties for the list table.
59
+	 */
60
+	protected function _set_properties()
61
+	{
62
+		$this->_wp_list_args = array(
63
+			'singular' => __('event', 'event_espresso'),
64
+			'plural'   => __('events', 'event_espresso'),
65
+			'ajax'     => true, //for now
66
+			'screen'   => $this->_admin_page->get_current_screen()->id,
67
+		);
68
+
69
+
70
+		$this->_columns = array(
71
+			'cb'              => '<input type="checkbox" />',
72
+			'id'              => __('ID', 'event_espresso'),
73
+			'name'            => __('Name', 'event_espresso'),
74
+			'author'          => __('Author', 'event_espresso'),
75
+			'venue'           => __('Venue', 'event_espresso'),
76
+			'start_date_time' => __('Event Start', 'event_espresso'),
77
+			'reg_begins'      => __('On Sale', 'event_espresso'),
78
+			'attendees'       => '<span class="dashicons dashicons-groups ee-icon-color-ee-green ee-icon-size-20"></span>',
79
+			//'tkts_sold' => __('Tickets Sold', 'event_espresso'),
80
+			'actions'         => __('Actions', 'event_espresso'),
81
+		);
82
+
83
+
84
+		$this->_sortable_columns = array(
85
+			'id'              => array('EVT_ID' => true),
86
+			'name'            => array('EVT_name' => false),
87
+			'author'          => array('EVT_wp_user' => false),
88
+			'venue'           => array('Venue.VNU_name' => false),
89
+			'start_date_time' => array('Datetime.DTT_EVT_start' => false),
90
+			'reg_begins'      => array('Datetime.Ticket.TKT_start_date' => false),
91
+		);
92
+
93
+		$this->_primary_column = 'id';
94
+
95
+		$this->_hidden_columns = array('author');
96
+	}
97
+
98
+
99
+	/**
100
+	 * @return array
101
+	 */
102
+	protected function _get_table_filters()
103
+	{
104
+		return array(); //no filters with decaf
105
+	}
106
+
107
+
108
+	/**
109
+	 * Setup of views properties.
110
+	 */
111
+	protected function _add_view_counts()
112
+	{
113
+		$this->_views['all']['count']   = $this->_admin_page->total_events();
114
+		$this->_views['draft']['count'] = $this->_admin_page->total_events_draft();
115
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) {
116
+			$this->_views['trash']['count'] = $this->_admin_page->total_trashed_events();
117
+		}
118
+	}
119
+
120
+
121
+	/**
122
+	 * @param EE_Event $item
123
+	 * @return string
124
+	 */
125
+	protected function _get_row_class($item)
126
+	{
127
+		$class = parent::_get_row_class($item);
128
+		//add status class
129
+		$class .= $item instanceof EE_Event ? ' ee-status-strip event-status-' . $item->get_active_status() : '';
130
+		if ($this->_has_checkbox_column) {
131
+			$class .= ' has-checkbox-column';
132
+		}
133
+		return $class;
134
+	}
135
+
136
+
137
+	/**
138
+	 * @param EE_Event $item
139
+	 * @return string
140
+	 */
141
+	public function column_status(EE_Event $item)
142
+	{
143
+		return '<span class="ee-status-strip ee-status-strip-td event-status-' . $item->get_active_status() . '"></span>';
144
+	}/**/
145
+
146
+
147
+	/**
148
+	 * @param  EE_Event $item
149
+	 * @return string
150
+	 */
151
+	public function column_cb($item)
152
+	{
153
+		if (! $item instanceof EE_Event) {
154
+			return '';
155
+		}
156
+		$this->_dtt = $item->primary_datetime(); //set this for use in other columns
157
+
158
+		//does event have any attached registrations?
159
+		$regs = $item->count_related('Registration');
160
+		return $regs > 0 && $this->_view == 'trash' ? '<span class="ee-lock-icon"></span>' : sprintf(
161
+			'<input type="checkbox" name="EVT_IDs[]" value="%s" />', $item->ID()
162
+		);
163
+	}
164
+
165
+
166
+	/**
167
+	 * @param EE_Event $item
168
+	 * @return mixed|string
169
+	 */
170
+	public function column_id(EE_Event $item)
171
+	{
172
+		$content = $item->ID();
173
+		$content .= '  <span class="show-on-mobile-view-only">' . $item->name() . '</span>';
174
+		return $content;
175
+	}
176
+
177
+
178
+	/**
179
+	 * @param EE_Event $item
180
+	 * @return string
181
+	 */
182
+	public function column_name(EE_Event $item)
183
+	{
184
+		$edit_query_args = array(
185
+			'action' => 'edit',
186
+			'post'   => $item->ID(),
187
+		);
188
+		$edit_link       = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
189
+		$actions         = $this->_column_name_action_setup($item);
190
+		$status          = ''; //$item->status() !== 'publish' ? ' (' . $item->status() . ')' : '';
191
+		$content         = '<strong><a class="row-title" href="' . $edit_link . '">' . $item->name() . '</a></strong>' . $status;
192
+		$content         .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->get_active_status(),
193
+				false, 'sentence') . '</span>';
194
+		$content         .= $this->row_actions($actions);
195
+		return $content;
196
+
197
+	}
198
+
199
+
200
+	/**
201
+	 * Just a method for setting up the actions for the name column
202
+	 *
203
+	 * @param EE_Event $item
204
+	 * @return array array of actions
205
+	 */
206
+	protected function _column_name_action_setup(EE_Event $item)
207
+	{
208
+		//todo: remove when attendees is active
209
+		if (! defined('REG_ADMIN_URL')) {
210
+			define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
211
+		}
212
+
213
+		$actions = array();
214
+
215
+		if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $item->ID())) {
216
+			$edit_query_args = array(
217
+				'action' => 'edit',
218
+				'post'   => $item->ID(),
219
+			);
220
+			$edit_link       = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
221
+			$actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr__('Edit Event',
222
+					'event_espresso') . '">' . __('Edit', 'event_espresso') . '</a>';
223
+
224
+		}
225
+
226
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
227
+			'espresso_registrations_view_registration', $item->ID())) {
228
+			$attendees_query_args = array(
229
+				'action'   => 'default',
230
+				'event_id' => $item->ID(),
231
+			);
232
+			$attendees_link       = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
233
+			$actions['attendees'] = '<a href="' . $attendees_link . '" title="' . esc_attr__('View Registrations',
234
+					'event_espresso') . '">' . __('Registrations', 'event_espresso') . '</a>';
235
+		}
236
+
237
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_trash_event',
238
+			$item->ID())) {
239
+			$trash_event_query_args = array(
240
+				'action' => 'trash_event',
241
+				'EVT_ID' => $item->ID(),
242
+			);
243
+			$trash_event_link       = EE_Admin_Page::add_query_args_and_nonce($trash_event_query_args,
244
+				EVENTS_ADMIN_URL);
245
+		}
246
+
247
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_restore_event',
248
+			$item->ID())) {
249
+			$restore_event_query_args = array(
250
+				'action' => 'restore_event',
251
+				'EVT_ID' => $item->ID(),
252
+			);
253
+			$restore_event_link       = EE_Admin_Page::add_query_args_and_nonce($restore_event_query_args,
254
+				EVENTS_ADMIN_URL);
255
+		}
256
+
257
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_delete_event',
258
+			$item->ID())) {
259
+			$delete_event_query_args = array(
260
+				'action' => 'delete_event',
261
+				'EVT_ID' => $item->ID(),
262
+			);
263
+			$delete_event_link       = EE_Admin_Page::add_query_args_and_nonce($delete_event_query_args,
264
+				EVENTS_ADMIN_URL);
265
+		}
266
+
267
+		$view_link = get_permalink($item->ID());
268
+
269
+		$actions['view'] = '<a href="' . $view_link . '" title="' . esc_attr__('View Event',
270
+				'event_espresso') . '">' . __('View', 'event_espresso') . '</a>';
271
+
272
+		switch ($item->get('status')) {
273
+			case 'trash' :
274
+				if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_restore_event',
275
+					$item->ID())) {
276
+					$actions['restore_from_trash'] = '<a href="' . $restore_event_link . '" title="' . esc_attr__('Restore from Trash',
277
+							'event_espresso') . '">' . __('Restore from Trash', 'event_espresso') . '</a>';
278
+				}
279
+				if ($item->count_related('Registration') === 0 && EE_Registry::instance()->CAP->current_user_can('ee_delete_event',
280
+						'espresso_events_delete_event', $item->ID())) {
281
+					$actions['delete'] = '<a href="' . $delete_event_link . '" title="' . esc_attr__('Delete Permanently',
282
+							'event_espresso') . '">' . __('Delete Permanently', 'event_espresso') . '</a>';
283
+				}
284
+				break;
285
+			default :
286
+				if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_trash_event',
287
+					$item->ID())) {
288
+					$actions['move to trash'] = '<a href="' . $trash_event_link . '" title="' . esc_attr__('Trash Event',
289
+							'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>';
290
+				}
291
+		}
292
+		return $actions;
293
+	}
294
+
295
+
296
+	/**
297
+	 * @param EE_Event $item
298
+	 * @return string
299
+	 */
300
+	public function column_author(EE_Event $item)
301
+	{
302
+		//user author info
303
+		$event_author = get_userdata($item->wp_user());
304
+		$gravatar     = get_avatar($item->wp_user(), '15');
305
+		//filter link
306
+		$query_args = array(
307
+			'action'      => 'default',
308
+			'EVT_wp_user' => $item->wp_user(),
309
+		);
310
+		$filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL);
311
+		return $gravatar . '  <a href="' . $filter_url . '" title="' . esc_attr__('Click to filter events by this author.',
312
+				'event_espresso') . '">' . $event_author->display_name . '</a>';
313
+	}
314
+
315
+
316
+	/**
317
+	 * @param EE_Event $item
318
+	 * @return string
319
+	 */
320
+	public function column_venue(EE_Event $item)
321
+	{
322
+		$venue = $item->get_first_related('Venue');
323
+		return ! empty($venue) ? $venue->name() : '';
324
+	}
325
+
326
+
327
+	/**
328
+	 * @param EE_Event $item
329
+	 * @throws EE_Error
330
+	 */
331
+	public function column_start_date_time(EE_Event $item)
332
+	{
333
+		echo ! empty($this->_dtt) ? $this->_dtt->get_i18n_datetime('DTT_EVT_start') : __('No Date was saved for this Event',
334
+			'event_espresso');
335
+		//display in user's timezone?
336
+		echo ! empty($this->_dtt) ? $this->_dtt->display_in_my_timezone('DTT_EVT_start', 'get_i18n_datetime', '',
337
+			'My Timezone: ') : '';
338
+
339
+	}
340
+
341
+
342
+	/**
343
+	 * @param EE_Event $item
344
+	 * @throws EE_Error
345
+	 */
346
+	public function column_reg_begins(EE_Event $item)
347
+	{
348
+		$reg_start = $item->get_ticket_with_earliest_start_time();
349
+		echo ! empty($reg_start) ? $reg_start->get_i18n_datetime('TKT_start_date') : __('No Tickets have been setup for this Event',
350
+			'event_espresso');
351
+		//display in user's timezone?
352
+		echo ! empty($reg_start) ? $reg_start->display_in_my_timezone('TKT_start_date', 'get_i18n_datetime', '',
353
+			'My Timezone: ') : '';/**/
354
+	}
355
+
356
+
357
+	/**
358
+	 * @param EE_Event $item
359
+	 * @return int|string
360
+	 */
361
+	public function column_attendees(EE_Event $item)
362
+	{
363
+		$attendees_query_args = array(
364
+			'action'   => 'default',
365
+			'event_id' => $item->ID(),
366
+		);
367
+		$attendees_link       = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
368
+		$registered_attendees = EEM_Registration::instance()->get_event_registration_count($item->ID());
369
+		return EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
370
+			'espresso_registrations_view_registration',
371
+			$item->ID()) ? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>' : $registered_attendees;
372
+	}
373
+
374
+
375
+	/**
376
+	 * @param EE_Event $item
377
+	 * @return float
378
+	 */
379
+	public function column_tkts_sold(EE_Event $item)
380
+	{
381
+		return EEM_Ticket::instance()->sum(array(array('Datetime.EVT_ID' => $item->ID())), 'TKT_sold');
382
+	}
383
+
384
+
385
+	/**
386
+	 * @param EE_Event $item
387
+	 * @return string
388
+	 */
389
+	public function column_actions(EE_Event $item)
390
+	{
391
+		//todo: remove when attendees is active
392
+		if (! defined('REG_ADMIN_URL')) {
393
+			define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
394
+		}
395
+		$actionlinks = array();
396
+
397
+		$view_link = get_permalink($item->ID());
398
+
399
+		$actionlinks[] = '<a href="' . $view_link . '" title="' . esc_attr__('View Event',
400
+				'event_espresso') . '" target="_blank">';
401
+		$actionlinks[] = '<div class="dashicons dashicons-search"></div></a>';
402
+
403
+		if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $item->ID())) {
404
+			$edit_query_args = array(
405
+				'action' => 'edit',
406
+				'post'   => $item->ID(),
407
+			);
408
+			$edit_link       = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
409
+			$actionlinks[]   = '<a href="' . $edit_link . '" title="' . esc_attr__('Edit Event',
410
+					'event_espresso') . '"><div class="ee-icon ee-icon-calendar-edit"></div></a>';
411
+		}
412
+
413
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
414
+			'espresso_registrations_view_registration', $item->ID())) {
415
+			$attendees_query_args = array(
416
+				'action'   => 'default',
417
+				'event_id' => $item->ID(),
418
+			);
419
+			$attendees_link       = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
420
+			$actionlinks[]        = '<a href="' . $attendees_link . '" title="' . esc_attr__('View Registrants',
421
+					'event_espresso') . '"><div class="dashicons dashicons-groups"></div></a>';
422
+		}
423
+
424
+		$actionlinks = apply_filters('FHEE__Events_Admin_List_Table__column_actions__action_links', $actionlinks,
425
+			$item);
426
+
427
+		return $this->_action_string(implode("\n\t", $actionlinks), $item, 'div');
428
+	}
429 429
 
430 430
 
431 431
 }
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
     exit('NO direct script access allowed');
4 4
 }
5 5
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     public function __construct($admin_page)
41 41
     {
42 42
         parent::__construct($admin_page);
43
-        require_once(EE_HELPERS . 'EEH_DTT_Helper.helper.php');
43
+        require_once(EE_HELPERS.'EEH_DTT_Helper.helper.php');
44 44
     }
45 45
 
46 46
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     {
127 127
         $class = parent::_get_row_class($item);
128 128
         //add status class
129
-        $class .= $item instanceof EE_Event ? ' ee-status-strip event-status-' . $item->get_active_status() : '';
129
+        $class .= $item instanceof EE_Event ? ' ee-status-strip event-status-'.$item->get_active_status() : '';
130 130
         if ($this->_has_checkbox_column) {
131 131
             $class .= ' has-checkbox-column';
132 132
         }
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
      */
141 141
     public function column_status(EE_Event $item)
142 142
     {
143
-        return '<span class="ee-status-strip ee-status-strip-td event-status-' . $item->get_active_status() . '"></span>';
143
+        return '<span class="ee-status-strip ee-status-strip-td event-status-'.$item->get_active_status().'"></span>';
144 144
     }/**/
145 145
 
146 146
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      */
151 151
     public function column_cb($item)
152 152
     {
153
-        if (! $item instanceof EE_Event) {
153
+        if ( ! $item instanceof EE_Event) {
154 154
             return '';
155 155
         }
156 156
         $this->_dtt = $item->primary_datetime(); //set this for use in other columns
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
     public function column_id(EE_Event $item)
171 171
     {
172 172
         $content = $item->ID();
173
-        $content .= '  <span class="show-on-mobile-view-only">' . $item->name() . '</span>';
173
+        $content .= '  <span class="show-on-mobile-view-only">'.$item->name().'</span>';
174 174
         return $content;
175 175
     }
176 176
 
@@ -188,9 +188,9 @@  discard block
 block discarded – undo
188 188
         $edit_link       = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
189 189
         $actions         = $this->_column_name_action_setup($item);
190 190
         $status          = ''; //$item->status() !== 'publish' ? ' (' . $item->status() . ')' : '';
191
-        $content         = '<strong><a class="row-title" href="' . $edit_link . '">' . $item->name() . '</a></strong>' . $status;
192
-        $content         .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->get_active_status(),
193
-                false, 'sentence') . '</span>';
191
+        $content         = '<strong><a class="row-title" href="'.$edit_link.'">'.$item->name().'</a></strong>'.$status;
192
+        $content         .= '<br><span class="ee-status-text-small">'.EEH_Template::pretty_status($item->get_active_status(),
193
+                false, 'sentence').'</span>';
194 194
         $content         .= $this->row_actions($actions);
195 195
         return $content;
196 196
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
     protected function _column_name_action_setup(EE_Event $item)
207 207
     {
208 208
         //todo: remove when attendees is active
209
-        if (! defined('REG_ADMIN_URL')) {
209
+        if ( ! defined('REG_ADMIN_URL')) {
210 210
             define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
211 211
         }
212 212
 
@@ -218,8 +218,8 @@  discard block
 block discarded – undo
218 218
                 'post'   => $item->ID(),
219 219
             );
220 220
             $edit_link       = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
221
-            $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr__('Edit Event',
222
-                    'event_espresso') . '">' . __('Edit', 'event_espresso') . '</a>';
221
+            $actions['edit'] = '<a href="'.$edit_link.'" title="'.esc_attr__('Edit Event',
222
+                    'event_espresso').'">'.__('Edit', 'event_espresso').'</a>';
223 223
 
224 224
         }
225 225
 
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
                 'event_id' => $item->ID(),
231 231
             );
232 232
             $attendees_link       = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
233
-            $actions['attendees'] = '<a href="' . $attendees_link . '" title="' . esc_attr__('View Registrations',
234
-                    'event_espresso') . '">' . __('Registrations', 'event_espresso') . '</a>';
233
+            $actions['attendees'] = '<a href="'.$attendees_link.'" title="'.esc_attr__('View Registrations',
234
+                    'event_espresso').'">'.__('Registrations', 'event_espresso').'</a>';
235 235
         }
236 236
 
237 237
         if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_trash_event',
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
                 'action' => 'trash_event',
241 241
                 'EVT_ID' => $item->ID(),
242 242
             );
243
-            $trash_event_link       = EE_Admin_Page::add_query_args_and_nonce($trash_event_query_args,
243
+            $trash_event_link = EE_Admin_Page::add_query_args_and_nonce($trash_event_query_args,
244 244
                 EVENTS_ADMIN_URL);
245 245
         }
246 246
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
                 'action' => 'restore_event',
251 251
                 'EVT_ID' => $item->ID(),
252 252
             );
253
-            $restore_event_link       = EE_Admin_Page::add_query_args_and_nonce($restore_event_query_args,
253
+            $restore_event_link = EE_Admin_Page::add_query_args_and_nonce($restore_event_query_args,
254 254
                 EVENTS_ADMIN_URL);
255 255
         }
256 256
 
@@ -260,33 +260,33 @@  discard block
 block discarded – undo
260 260
                 'action' => 'delete_event',
261 261
                 'EVT_ID' => $item->ID(),
262 262
             );
263
-            $delete_event_link       = EE_Admin_Page::add_query_args_and_nonce($delete_event_query_args,
263
+            $delete_event_link = EE_Admin_Page::add_query_args_and_nonce($delete_event_query_args,
264 264
                 EVENTS_ADMIN_URL);
265 265
         }
266 266
 
267 267
         $view_link = get_permalink($item->ID());
268 268
 
269
-        $actions['view'] = '<a href="' . $view_link . '" title="' . esc_attr__('View Event',
270
-                'event_espresso') . '">' . __('View', 'event_espresso') . '</a>';
269
+        $actions['view'] = '<a href="'.$view_link.'" title="'.esc_attr__('View Event',
270
+                'event_espresso').'">'.__('View', 'event_espresso').'</a>';
271 271
 
272 272
         switch ($item->get('status')) {
273 273
             case 'trash' :
274 274
                 if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_restore_event',
275 275
                     $item->ID())) {
276
-                    $actions['restore_from_trash'] = '<a href="' . $restore_event_link . '" title="' . esc_attr__('Restore from Trash',
277
-                            'event_espresso') . '">' . __('Restore from Trash', 'event_espresso') . '</a>';
276
+                    $actions['restore_from_trash'] = '<a href="'.$restore_event_link.'" title="'.esc_attr__('Restore from Trash',
277
+                            'event_espresso').'">'.__('Restore from Trash', 'event_espresso').'</a>';
278 278
                 }
279 279
                 if ($item->count_related('Registration') === 0 && EE_Registry::instance()->CAP->current_user_can('ee_delete_event',
280 280
                         'espresso_events_delete_event', $item->ID())) {
281
-                    $actions['delete'] = '<a href="' . $delete_event_link . '" title="' . esc_attr__('Delete Permanently',
282
-                            'event_espresso') . '">' . __('Delete Permanently', 'event_espresso') . '</a>';
281
+                    $actions['delete'] = '<a href="'.$delete_event_link.'" title="'.esc_attr__('Delete Permanently',
282
+                            'event_espresso').'">'.__('Delete Permanently', 'event_espresso').'</a>';
283 283
                 }
284 284
                 break;
285 285
             default :
286 286
                 if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_trash_event',
287 287
                     $item->ID())) {
288
-                    $actions['move to trash'] = '<a href="' . $trash_event_link . '" title="' . esc_attr__('Trash Event',
289
-                            'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>';
288
+                    $actions['move to trash'] = '<a href="'.$trash_event_link.'" title="'.esc_attr__('Trash Event',
289
+                            'event_espresso').'">'.__('Trash', 'event_espresso').'</a>';
290 290
                 }
291 291
         }
292 292
         return $actions;
@@ -308,8 +308,8 @@  discard block
 block discarded – undo
308 308
             'EVT_wp_user' => $item->wp_user(),
309 309
         );
310 310
         $filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL);
311
-        return $gravatar . '  <a href="' . $filter_url . '" title="' . esc_attr__('Click to filter events by this author.',
312
-                'event_espresso') . '">' . $event_author->display_name . '</a>';
311
+        return $gravatar.'  <a href="'.$filter_url.'" title="'.esc_attr__('Click to filter events by this author.',
312
+                'event_espresso').'">'.$event_author->display_name.'</a>';
313 313
     }
314 314
 
315 315
 
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
             'event_espresso');
351 351
         //display in user's timezone?
352 352
         echo ! empty($reg_start) ? $reg_start->display_in_my_timezone('TKT_start_date', 'get_i18n_datetime', '',
353
-            'My Timezone: ') : '';/**/
353
+            'My Timezone: ') : ''; /**/
354 354
     }
355 355
 
356 356
 
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
         $registered_attendees = EEM_Registration::instance()->get_event_registration_count($item->ID());
369 369
         return EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
370 370
             'espresso_registrations_view_registration',
371
-            $item->ID()) ? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>' : $registered_attendees;
371
+            $item->ID()) ? '<a href="'.$attendees_link.'">'.$registered_attendees.'</a>' : $registered_attendees;
372 372
     }
373 373
 
374 374
 
@@ -389,15 +389,15 @@  discard block
 block discarded – undo
389 389
     public function column_actions(EE_Event $item)
390 390
     {
391 391
         //todo: remove when attendees is active
392
-        if (! defined('REG_ADMIN_URL')) {
392
+        if ( ! defined('REG_ADMIN_URL')) {
393 393
             define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
394 394
         }
395 395
         $actionlinks = array();
396 396
 
397 397
         $view_link = get_permalink($item->ID());
398 398
 
399
-        $actionlinks[] = '<a href="' . $view_link . '" title="' . esc_attr__('View Event',
400
-                'event_espresso') . '" target="_blank">';
399
+        $actionlinks[] = '<a href="'.$view_link.'" title="'.esc_attr__('View Event',
400
+                'event_espresso').'" target="_blank">';
401 401
         $actionlinks[] = '<div class="dashicons dashicons-search"></div></a>';
402 402
 
403 403
         if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $item->ID())) {
@@ -406,8 +406,8 @@  discard block
 block discarded – undo
406 406
                 'post'   => $item->ID(),
407 407
             );
408 408
             $edit_link       = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
409
-            $actionlinks[]   = '<a href="' . $edit_link . '" title="' . esc_attr__('Edit Event',
410
-                    'event_espresso') . '"><div class="ee-icon ee-icon-calendar-edit"></div></a>';
409
+            $actionlinks[]   = '<a href="'.$edit_link.'" title="'.esc_attr__('Edit Event',
410
+                    'event_espresso').'"><div class="ee-icon ee-icon-calendar-edit"></div></a>';
411 411
         }
412 412
 
413 413
         if (EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
@@ -417,8 +417,8 @@  discard block
 block discarded – undo
417 417
                 'event_id' => $item->ID(),
418 418
             );
419 419
             $attendees_link       = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
420
-            $actionlinks[]        = '<a href="' . $attendees_link . '" title="' . esc_attr__('View Registrants',
421
-                    'event_espresso') . '"><div class="dashicons dashicons-groups"></div></a>';
420
+            $actionlinks[]        = '<a href="'.$attendees_link.'" title="'.esc_attr__('View Registrants',
421
+                    'event_espresso').'"><div class="dashicons dashicons-groups"></div></a>';
422 422
         }
423 423
 
424 424
         $actionlinks = apply_filters('FHEE__Events_Admin_List_Table__column_actions__action_links', $actionlinks,
Please login to merge, or discard this patch.
core/EE_Module_Request_Router.core.php 2 patches
Indentation   +215 added lines, -215 removed lines patch added patch discarded remove patch
@@ -17,243 +17,243 @@
 block discarded – undo
17 17
 final class EE_Module_Request_Router implements InterminableInterface
18 18
 {
19 19
 
20
-    /**
21
-     * @var array $_previous_routes
22
-     */
23
-    private static $_previous_routes = array();
20
+	/**
21
+	 * @var array $_previous_routes
22
+	 */
23
+	private static $_previous_routes = array();
24 24
 
25
-    /**
26
-     * @var WP_Query $WP_Query
27
-     */
28
-    public $WP_Query;
25
+	/**
26
+	 * @var WP_Query $WP_Query
27
+	 */
28
+	public $WP_Query;
29 29
 
30 30
 
31 31
 
32
-    /**
33
-     * EE_Module_Request_Router constructor.
34
-     */
35
-    public function __construct()
36
-    {
37
-    }
32
+	/**
33
+	 * EE_Module_Request_Router constructor.
34
+	 */
35
+	public function __construct()
36
+	{
37
+	}
38 38
 
39 39
 
40 40
 
41
-    /**
42
-     * on the first call  to this method, it checks the EE_Request_Handler for a "route"
43
-     * on subsequent calls to this method,
44
-     * instead of checking the EE_Request_Handler for a route, it checks the previous routes array,
45
-     * and checks if the last called route has any forwarding routes registered for it
46
-     *
47
-     * @param WP_Query $WP_Query
48
-     * @return NULL|string
49
-     * @throws EE_Error
50
-     * @throws ReflectionException
51
-     */
52
-    public function get_route(WP_Query $WP_Query)
53
-    {
54
-        $this->WP_Query = $WP_Query;
55
-        // assume this if first route being called
56
-        $previous_route = false;
57
-        // but is it really ???
58
-        if (! empty(self::$_previous_routes)) {
59
-            // get last run route
60
-            $previous_routes = array_values(self::$_previous_routes);
61
-            $previous_route = array_pop($previous_routes);
62
-        }
63
-        //  has another route already been run ?
64
-        if ($previous_route) {
65
-            // check if  forwarding has been set
66
-            $current_route = $this->get_forward($previous_route);
67
-            try {
68
-                //check for recursive forwarding
69
-                if (isset(self::$_previous_routes[$current_route])) {
70
-                    throw new EE_Error(
71
-                        sprintf(
72
-                            __(
73
-                                'An error occurred. The %s route has already been called, and therefore can not be forwarded to, because an infinite loop would be created and break the interweb.',
74
-                                'event_espresso'
75
-                            ),
76
-                            $current_route
77
-                        )
78
-                    );
79
-                }
80
-            } catch (EE_Error $e) {
81
-                $e->get_error();
82
-                return null;
83
-            }
84
-        } else {
85
-            // first route called
86
-            $current_route = null;
87
-            // grab all routes
88
-            $routes = EE_Config::get_routes();
89
-            //d( $routes );
90
-            foreach ($routes as $key => $route) {
91
-                // check request for module route
92
-                if (EE_Registry::instance()->REQ->is_set($key)) {
93
-                    //echo '<b style="color:#2EA2CC;">key : <span style="color:#E76700">' . $key . '</span></b><br />';
94
-                    $current_route = sanitize_text_field(EE_Registry::instance()->REQ->get($key));
95
-                    if ($current_route) {
96
-                        $current_route = array($key, $current_route);
97
-                        //echo '<b style="color:#2EA2CC;">current_route : <span style="color:#E76700">' . $current_route . '</span></b><br />';
98
-                        break;
99
-                    }
100
-                }
101
-            }
102
-        }
103
-        // sorry, but I can't read what you route !
104
-        if (empty($current_route)) {
105
-            return null;
106
-        }
107
-        //add route to previous routes array
108
-        self::$_previous_routes[] = $current_route;
109
-        return $current_route;
110
-    }
41
+	/**
42
+	 * on the first call  to this method, it checks the EE_Request_Handler for a "route"
43
+	 * on subsequent calls to this method,
44
+	 * instead of checking the EE_Request_Handler for a route, it checks the previous routes array,
45
+	 * and checks if the last called route has any forwarding routes registered for it
46
+	 *
47
+	 * @param WP_Query $WP_Query
48
+	 * @return NULL|string
49
+	 * @throws EE_Error
50
+	 * @throws ReflectionException
51
+	 */
52
+	public function get_route(WP_Query $WP_Query)
53
+	{
54
+		$this->WP_Query = $WP_Query;
55
+		// assume this if first route being called
56
+		$previous_route = false;
57
+		// but is it really ???
58
+		if (! empty(self::$_previous_routes)) {
59
+			// get last run route
60
+			$previous_routes = array_values(self::$_previous_routes);
61
+			$previous_route = array_pop($previous_routes);
62
+		}
63
+		//  has another route already been run ?
64
+		if ($previous_route) {
65
+			// check if  forwarding has been set
66
+			$current_route = $this->get_forward($previous_route);
67
+			try {
68
+				//check for recursive forwarding
69
+				if (isset(self::$_previous_routes[$current_route])) {
70
+					throw new EE_Error(
71
+						sprintf(
72
+							__(
73
+								'An error occurred. The %s route has already been called, and therefore can not be forwarded to, because an infinite loop would be created and break the interweb.',
74
+								'event_espresso'
75
+							),
76
+							$current_route
77
+						)
78
+					);
79
+				}
80
+			} catch (EE_Error $e) {
81
+				$e->get_error();
82
+				return null;
83
+			}
84
+		} else {
85
+			// first route called
86
+			$current_route = null;
87
+			// grab all routes
88
+			$routes = EE_Config::get_routes();
89
+			//d( $routes );
90
+			foreach ($routes as $key => $route) {
91
+				// check request for module route
92
+				if (EE_Registry::instance()->REQ->is_set($key)) {
93
+					//echo '<b style="color:#2EA2CC;">key : <span style="color:#E76700">' . $key . '</span></b><br />';
94
+					$current_route = sanitize_text_field(EE_Registry::instance()->REQ->get($key));
95
+					if ($current_route) {
96
+						$current_route = array($key, $current_route);
97
+						//echo '<b style="color:#2EA2CC;">current_route : <span style="color:#E76700">' . $current_route . '</span></b><br />';
98
+						break;
99
+					}
100
+				}
101
+			}
102
+		}
103
+		// sorry, but I can't read what you route !
104
+		if (empty($current_route)) {
105
+			return null;
106
+		}
107
+		//add route to previous routes array
108
+		self::$_previous_routes[] = $current_route;
109
+		return $current_route;
110
+	}
111 111
 
112 112
 
113 113
 
114
-    /**
115
-     * this method simply takes a valid route, and resolves what module class method the route points to
116
-     *
117
-     * @param string $key
118
-     * @param string $current_route
119
-     * @return mixed EED_Module | boolean
120
-     * @throws EE_Error
121
-     * @throws ReflectionException
122
-     */
123
-    public function resolve_route($key, $current_route)
124
-    {
125
-        // get module method that route has been mapped to
126
-        $module_method = EE_Config::get_route($current_route, $key);
127
-        //EEH_Debug_Tools::printr( $module_method, '$module_method  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
128
-        // verify result was returned
129
-        if (empty($module_method)) {
130
-            $msg = sprintf(
131
-                __('The requested route %s could not be mapped to any registered modules.', 'event_espresso'),
132
-                $current_route
133
-            );
134
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
135
-            return false;
136
-        }
137
-        // verify that result is an array
138
-        if (! is_array($module_method)) {
139
-            $msg = sprintf(__('The %s  route has not been properly registered.', 'event_espresso'), $current_route);
140
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
141
-            return false;
142
-        }
143
-        // grab module name
144
-        $module_name = $module_method[0];
145
-        // verify that a class method was registered properly
146
-        if (! isset($module_method[1])) {
147
-            $msg = sprintf(
148
-                __('A class method for the %s  route has not been properly registered.', 'event_espresso'),
149
-                $current_route
150
-            );
151
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
152
-            return false;
153
-        }
154
-        // grab method
155
-        $method = $module_method[1];
156
-        // verify that class exists
157
-        if (! class_exists($module_name)) {
158
-            $msg = sprintf(__('The requested %s class could not be found.', 'event_espresso'), $module_name);
159
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
160
-            return false;
161
-        }
162
-        // verify that method exists
163
-        if (! method_exists($module_name, $method)) {
164
-            $msg = sprintf(
165
-                __('The class method %s for the %s route is in invalid.', 'event_espresso'), $method, $current_route
166
-            );
167
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
168
-            return false;
169
-        }
170
-        // instantiate module and call route method
171
-        return $this->_module_router($module_name, $method);
172
-    }
114
+	/**
115
+	 * this method simply takes a valid route, and resolves what module class method the route points to
116
+	 *
117
+	 * @param string $key
118
+	 * @param string $current_route
119
+	 * @return mixed EED_Module | boolean
120
+	 * @throws EE_Error
121
+	 * @throws ReflectionException
122
+	 */
123
+	public function resolve_route($key, $current_route)
124
+	{
125
+		// get module method that route has been mapped to
126
+		$module_method = EE_Config::get_route($current_route, $key);
127
+		//EEH_Debug_Tools::printr( $module_method, '$module_method  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
128
+		// verify result was returned
129
+		if (empty($module_method)) {
130
+			$msg = sprintf(
131
+				__('The requested route %s could not be mapped to any registered modules.', 'event_espresso'),
132
+				$current_route
133
+			);
134
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
135
+			return false;
136
+		}
137
+		// verify that result is an array
138
+		if (! is_array($module_method)) {
139
+			$msg = sprintf(__('The %s  route has not been properly registered.', 'event_espresso'), $current_route);
140
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
141
+			return false;
142
+		}
143
+		// grab module name
144
+		$module_name = $module_method[0];
145
+		// verify that a class method was registered properly
146
+		if (! isset($module_method[1])) {
147
+			$msg = sprintf(
148
+				__('A class method for the %s  route has not been properly registered.', 'event_espresso'),
149
+				$current_route
150
+			);
151
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
152
+			return false;
153
+		}
154
+		// grab method
155
+		$method = $module_method[1];
156
+		// verify that class exists
157
+		if (! class_exists($module_name)) {
158
+			$msg = sprintf(__('The requested %s class could not be found.', 'event_espresso'), $module_name);
159
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
160
+			return false;
161
+		}
162
+		// verify that method exists
163
+		if (! method_exists($module_name, $method)) {
164
+			$msg = sprintf(
165
+				__('The class method %s for the %s route is in invalid.', 'event_espresso'), $method, $current_route
166
+			);
167
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
168
+			return false;
169
+		}
170
+		// instantiate module and call route method
171
+		return $this->_module_router($module_name, $method);
172
+	}
173 173
 
174 174
 
175 175
 
176
-    /**
177
-     * this method instantiates modules and calls the method that was defined when the route was registered
178
-     *
179
-     * @param string $module_name
180
-     * @return EED_Module|object|null
181
-     * @throws ReflectionException
182
-     */
183
-    public static function module_factory($module_name)
184
-    {
185
-        if ($module_name === 'EED_Module') {
186
-            EE_Error::add_error(
187
-                sprintf(
188
-                    __(
189
-                        'EED_Module is an abstract parent class an can not be instantiated. Please provide a proper module name.',
190
-                        'event_espresso'
191
-                    ), $module_name
192
-                ), __FILE__, __FUNCTION__, __LINE__
193
-            );
194
-            return null;
195
-        }
196
-        // instantiate module class
197
-        $module = new $module_name();
198
-        // ensure that class is actually a module
199
-        if (! $module instanceof EED_Module) {
200
-            EE_Error::add_error(
201
-                sprintf(__('The requested %s module is not of the class EED_Module.', 'event_espresso'), $module_name),
202
-                __FILE__, __FUNCTION__, __LINE__
203
-            );
204
-            return null;
205
-        }
206
-        return $module;
207
-    }
176
+	/**
177
+	 * this method instantiates modules and calls the method that was defined when the route was registered
178
+	 *
179
+	 * @param string $module_name
180
+	 * @return EED_Module|object|null
181
+	 * @throws ReflectionException
182
+	 */
183
+	public static function module_factory($module_name)
184
+	{
185
+		if ($module_name === 'EED_Module') {
186
+			EE_Error::add_error(
187
+				sprintf(
188
+					__(
189
+						'EED_Module is an abstract parent class an can not be instantiated. Please provide a proper module name.',
190
+						'event_espresso'
191
+					), $module_name
192
+				), __FILE__, __FUNCTION__, __LINE__
193
+			);
194
+			return null;
195
+		}
196
+		// instantiate module class
197
+		$module = new $module_name();
198
+		// ensure that class is actually a module
199
+		if (! $module instanceof EED_Module) {
200
+			EE_Error::add_error(
201
+				sprintf(__('The requested %s module is not of the class EED_Module.', 'event_espresso'), $module_name),
202
+				__FILE__, __FUNCTION__, __LINE__
203
+			);
204
+			return null;
205
+		}
206
+		return $module;
207
+	}
208 208
 
209 209
 
210 210
 
211
-    /**
212
-     * this method instantiates modules and calls the method that was defined when the route was registered
213
-     *
214
-     * @param string $module_name
215
-     * @param string $method
216
-     * @return EED_Module|null
217
-     * @throws EE_Error
218
-     * @throws ReflectionException
219
-     */
220
-    private function _module_router($module_name, $method)
221
-    {
222
-        // instantiate module class
223
-        $module = EE_Module_Request_Router::module_factory($module_name);
224
-        if ($module instanceof EED_Module) {
225
-            // and call whatever action the route was for
226
-            try {
227
-                call_user_func(array($module, $method), $this->WP_Query);
228
-            } catch (EE_Error $e) {
229
-                $e->get_error();
230
-                return null;
231
-            }
232
-        }
233
-        return $module;
234
-    }
211
+	/**
212
+	 * this method instantiates modules and calls the method that was defined when the route was registered
213
+	 *
214
+	 * @param string $module_name
215
+	 * @param string $method
216
+	 * @return EED_Module|null
217
+	 * @throws EE_Error
218
+	 * @throws ReflectionException
219
+	 */
220
+	private function _module_router($module_name, $method)
221
+	{
222
+		// instantiate module class
223
+		$module = EE_Module_Request_Router::module_factory($module_name);
224
+		if ($module instanceof EED_Module) {
225
+			// and call whatever action the route was for
226
+			try {
227
+				call_user_func(array($module, $method), $this->WP_Query);
228
+			} catch (EE_Error $e) {
229
+				$e->get_error();
230
+				return null;
231
+			}
232
+		}
233
+		return $module;
234
+	}
235 235
 
236 236
 
237 237
 
238
-    /**
239
-     * @param $current_route
240
-     * @return string
241
-     */
242
-    public function get_forward($current_route)
243
-    {
244
-        return EE_Config::get_forward($current_route);
245
-    }
238
+	/**
239
+	 * @param $current_route
240
+	 * @return string
241
+	 */
242
+	public function get_forward($current_route)
243
+	{
244
+		return EE_Config::get_forward($current_route);
245
+	}
246 246
 
247 247
 
248 248
 
249
-    /**
250
-     * @param $current_route
251
-     * @return string
252
-     */
253
-    public function get_view($current_route)
254
-    {
255
-        return EE_Config::get_view($current_route);
256
-    }
249
+	/**
250
+	 * @param $current_route
251
+	 * @return string
252
+	 */
253
+	public function get_view($current_route)
254
+	{
255
+		return EE_Config::get_view($current_route);
256
+	}
257 257
 
258 258
 
259 259
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
         // assume this if first route being called
56 56
         $previous_route = false;
57 57
         // but is it really ???
58
-        if (! empty(self::$_previous_routes)) {
58
+        if ( ! empty(self::$_previous_routes)) {
59 59
             // get last run route
60 60
             $previous_routes = array_values(self::$_previous_routes);
61 61
             $previous_route = array_pop($previous_routes);
@@ -135,36 +135,36 @@  discard block
 block discarded – undo
135 135
             return false;
136 136
         }
137 137
         // verify that result is an array
138
-        if (! is_array($module_method)) {
138
+        if ( ! is_array($module_method)) {
139 139
             $msg = sprintf(__('The %s  route has not been properly registered.', 'event_espresso'), $current_route);
140
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
140
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
141 141
             return false;
142 142
         }
143 143
         // grab module name
144 144
         $module_name = $module_method[0];
145 145
         // verify that a class method was registered properly
146
-        if (! isset($module_method[1])) {
146
+        if ( ! isset($module_method[1])) {
147 147
             $msg = sprintf(
148 148
                 __('A class method for the %s  route has not been properly registered.', 'event_espresso'),
149 149
                 $current_route
150 150
             );
151
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
151
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
152 152
             return false;
153 153
         }
154 154
         // grab method
155 155
         $method = $module_method[1];
156 156
         // verify that class exists
157
-        if (! class_exists($module_name)) {
157
+        if ( ! class_exists($module_name)) {
158 158
             $msg = sprintf(__('The requested %s class could not be found.', 'event_espresso'), $module_name);
159 159
             EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
160 160
             return false;
161 161
         }
162 162
         // verify that method exists
163
-        if (! method_exists($module_name, $method)) {
163
+        if ( ! method_exists($module_name, $method)) {
164 164
             $msg = sprintf(
165 165
                 __('The class method %s for the %s route is in invalid.', 'event_espresso'), $method, $current_route
166 166
             );
167
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
167
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
168 168
             return false;
169 169
         }
170 170
         // instantiate module and call route method
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         // instantiate module class
197 197
         $module = new $module_name();
198 198
         // ensure that class is actually a module
199
-        if (! $module instanceof EED_Module) {
199
+        if ( ! $module instanceof EED_Module) {
200 200
             EE_Error::add_error(
201 201
                 sprintf(__('The requested %s module is not of the class EED_Module.', 'event_espresso'), $module_name),
202 202
                 __FILE__, __FUNCTION__, __LINE__
Please login to merge, or discard this patch.
admin/extend/registrations/Extend_EE_Registrations_List_Table.class.php 2 patches
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if (! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 /**
@@ -23,104 +23,104 @@  discard block
 block discarded – undo
23 23
 {
24 24
 
25 25
 
26
-    /**
27
-     *        REG_date
28
-     */
29
-    function column_REG_date(EE_Registration $item)
30
-    {
26
+	/**
27
+	 *        REG_date
28
+	 */
29
+	function column_REG_date(EE_Registration $item)
30
+	{
31 31
 
32
-        //Build row actions
33
-        $actions = array();
32
+		//Build row actions
33
+		$actions = array();
34 34
 
35
-        //Build row actions
36
-        $check_in_url        = EE_Admin_Page::add_query_args_and_nonce(array(
37
-            'action'   => 'event_registrations',
38
-            'event_id' => $item->event_ID(),
39
-        ), REG_ADMIN_URL);
40
-        $actions['check_in'] = EE_Registry::instance()->CAP->current_user_can('ee_read_checkin',
41
-            'espresso_registrations_registration_checkins', $item->ID()) ? '
35
+		//Build row actions
36
+		$check_in_url        = EE_Admin_Page::add_query_args_and_nonce(array(
37
+			'action'   => 'event_registrations',
38
+			'event_id' => $item->event_ID(),
39
+		), REG_ADMIN_URL);
40
+		$actions['check_in'] = EE_Registry::instance()->CAP->current_user_can('ee_read_checkin',
41
+			'espresso_registrations_registration_checkins', $item->ID()) ? '
42 42
 			<a href="' . $check_in_url . '" title="' . esc_attr__('The Check-In List allows you to easily toggle check-in status for this event',
43
-                'event_espresso') . '">' . __('View Check-ins', 'event_espresso') . '</a>' : __('View Check-ins',
44
-            'event_espresso');
43
+				'event_espresso') . '">' . __('View Check-ins', 'event_espresso') . '</a>' : __('View Check-ins',
44
+			'event_espresso');
45 45
 
46
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
47
-            'action' => 'view_transaction',
48
-            'TXN_ID' => $item->transaction()->ID(),
49
-        ), TXN_ADMIN_URL);
50
-        $REG_date     = EE_Regisry::instance()->CAP->current_user_can('ee_read_transaction',
51
-            'espresso_transactions_view_transaction') ? '<a href="' . $view_lnk_url . '" title="' . esc_attr__('View Transaction Details',
52
-                'event_espresso') . '">' . $item->get_i18n_datetime('REG_date') . '</a>' : $item->get_i18n_datetime('REG_date');
46
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
47
+			'action' => 'view_transaction',
48
+			'TXN_ID' => $item->transaction()->ID(),
49
+		), TXN_ADMIN_URL);
50
+		$REG_date     = EE_Regisry::instance()->CAP->current_user_can('ee_read_transaction',
51
+			'espresso_transactions_view_transaction') ? '<a href="' . $view_lnk_url . '" title="' . esc_attr__('View Transaction Details',
52
+				'event_espresso') . '">' . $item->get_i18n_datetime('REG_date') . '</a>' : $item->get_i18n_datetime('REG_date');
53 53
 
54
-        return sprintf('%1$s %2$s', $REG_date, $this->row_actions($actions));
54
+		return sprintf('%1$s %2$s', $REG_date, $this->row_actions($actions));
55 55
 
56
-    }
56
+	}
57 57
 
58 58
 
59
-    /**
60
-     *        column_default
61
-     *
62
-     * @param \EE_Registration $item
63
-     * @return string
64
-     */
65
-    public function column_DTT_EVT_start(EE_Registration $item)
66
-    {
67
-        $remove_defaults = array('default_where_conditions' => 'none');
68
-        $ticket          = $item->ticket();
69
-        $datetimes       = $ticket instanceof EE_Ticket ? $ticket->datetimes($remove_defaults) : array();
70
-        $EVT_ID          = $item->event_ID();
71
-        $datetime_string = '';
72
-        foreach ($datetimes as $datetime) {
73
-            if (
74
-            EE_Registry::instance()->CAP->current_user_can(
75
-                'ee_read_checkin',
76
-                'espresso_registrations_registration_checkins',
77
-                $item->ID()
78
-            )
79
-            ) {
80
-                // open "a" tag and "href"
81
-                $datetime_string .= '<a href="';
82
-                // checkin URL
83
-                $datetime_string .= EE_Admin_Page::add_query_args_and_nonce(
84
-                    array(
85
-                        'action'   => 'event_registrations',
86
-                        'event_id' => $EVT_ID,
87
-                        'DTT_ID'   => $datetime->ID(),
88
-                    ),
89
-                    REG_ADMIN_URL
90
-                );
91
-                // close "href"
92
-                $datetime_string .= '"';
93
-                // open "title" tag
94
-                $datetime_string .= ' title="';
95
-                // link title text
96
-                $datetime_string .= esc_attr__('View Checkins for this Event', 'event_espresso');
97
-                // close "title" tag and end of "a" tag opening
98
-                $datetime_string .= '">';
99
-                // link text
100
-                $datetime_string .= $datetime->get_i18n_datetime('DTT_EVT_start');
101
-                // close "a" tag
102
-                $datetime_string .= '</a>';
103
-            } else {
104
-                $datetime_string .= $datetime->get_i18n_datetime('DTT_EVT_start');
105
-            }
106
-            // add a "View Registrations" link that filters list by event AND datetime
107
-            $datetime_string .= $this->row_actions(
108
-                array(
109
-                    'event_datetime_filter' => '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
110
-                            array('event_id' => $EVT_ID, 'datetime_id' => $datetime->ID()),
111
-                            REG_ADMIN_URL
112
-                        ) . '" title="' . sprintf(
113
-                                                   esc_attr__(
114
-                                                       'Filter this list to only show registrations for this datetime %s',
115
-                                                       'event_espresso'
116
-                                                   ),
117
-                                                   $datetime->name()
118
-                                               ) . '">' . __('View Registrations', 'event_espresso') . '</a>',
119
-                )
120
-            );
121
-        }
122
-        return $datetime_string;
123
-    }
59
+	/**
60
+	 *        column_default
61
+	 *
62
+	 * @param \EE_Registration $item
63
+	 * @return string
64
+	 */
65
+	public function column_DTT_EVT_start(EE_Registration $item)
66
+	{
67
+		$remove_defaults = array('default_where_conditions' => 'none');
68
+		$ticket          = $item->ticket();
69
+		$datetimes       = $ticket instanceof EE_Ticket ? $ticket->datetimes($remove_defaults) : array();
70
+		$EVT_ID          = $item->event_ID();
71
+		$datetime_string = '';
72
+		foreach ($datetimes as $datetime) {
73
+			if (
74
+			EE_Registry::instance()->CAP->current_user_can(
75
+				'ee_read_checkin',
76
+				'espresso_registrations_registration_checkins',
77
+				$item->ID()
78
+			)
79
+			) {
80
+				// open "a" tag and "href"
81
+				$datetime_string .= '<a href="';
82
+				// checkin URL
83
+				$datetime_string .= EE_Admin_Page::add_query_args_and_nonce(
84
+					array(
85
+						'action'   => 'event_registrations',
86
+						'event_id' => $EVT_ID,
87
+						'DTT_ID'   => $datetime->ID(),
88
+					),
89
+					REG_ADMIN_URL
90
+				);
91
+				// close "href"
92
+				$datetime_string .= '"';
93
+				// open "title" tag
94
+				$datetime_string .= ' title="';
95
+				// link title text
96
+				$datetime_string .= esc_attr__('View Checkins for this Event', 'event_espresso');
97
+				// close "title" tag and end of "a" tag opening
98
+				$datetime_string .= '">';
99
+				// link text
100
+				$datetime_string .= $datetime->get_i18n_datetime('DTT_EVT_start');
101
+				// close "a" tag
102
+				$datetime_string .= '</a>';
103
+			} else {
104
+				$datetime_string .= $datetime->get_i18n_datetime('DTT_EVT_start');
105
+			}
106
+			// add a "View Registrations" link that filters list by event AND datetime
107
+			$datetime_string .= $this->row_actions(
108
+				array(
109
+					'event_datetime_filter' => '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
110
+							array('event_id' => $EVT_ID, 'datetime_id' => $datetime->ID()),
111
+							REG_ADMIN_URL
112
+						) . '" title="' . sprintf(
113
+												   esc_attr__(
114
+													   'Filter this list to only show registrations for this datetime %s',
115
+													   'event_espresso'
116
+												   ),
117
+												   $datetime->name()
118
+											   ) . '">' . __('View Registrations', 'event_espresso') . '</a>',
119
+				)
120
+			);
121
+		}
122
+		return $datetime_string;
123
+	}
124 124
 
125 125
 
126 126
 } //end Extend_EE_Registrations_List_Table
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if (! defined('EVENT_ESPRESSO_VERSION')) {
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2 2
     exit('No direct script access allowed');
3 3
 }
4 4
 
@@ -33,23 +33,23 @@  discard block
 block discarded – undo
33 33
         $actions = array();
34 34
 
35 35
         //Build row actions
36
-        $check_in_url        = EE_Admin_Page::add_query_args_and_nonce(array(
36
+        $check_in_url = EE_Admin_Page::add_query_args_and_nonce(array(
37 37
             'action'   => 'event_registrations',
38 38
             'event_id' => $item->event_ID(),
39 39
         ), REG_ADMIN_URL);
40 40
         $actions['check_in'] = EE_Registry::instance()->CAP->current_user_can('ee_read_checkin',
41 41
             'espresso_registrations_registration_checkins', $item->ID()) ? '
42
-			<a href="' . $check_in_url . '" title="' . esc_attr__('The Check-In List allows you to easily toggle check-in status for this event',
43
-                'event_espresso') . '">' . __('View Check-ins', 'event_espresso') . '</a>' : __('View Check-ins',
42
+			<a href="' . $check_in_url.'" title="'.esc_attr__('The Check-In List allows you to easily toggle check-in status for this event',
43
+                'event_espresso').'">'.__('View Check-ins', 'event_espresso').'</a>' : __('View Check-ins',
44 44
             'event_espresso');
45 45
 
46 46
         $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
47 47
             'action' => 'view_transaction',
48 48
             'TXN_ID' => $item->transaction()->ID(),
49 49
         ), TXN_ADMIN_URL);
50
-        $REG_date     = EE_Regisry::instance()->CAP->current_user_can('ee_read_transaction',
51
-            'espresso_transactions_view_transaction') ? '<a href="' . $view_lnk_url . '" title="' . esc_attr__('View Transaction Details',
52
-                'event_espresso') . '">' . $item->get_i18n_datetime('REG_date') . '</a>' : $item->get_i18n_datetime('REG_date');
50
+        $REG_date = EE_Regisry::instance()->CAP->current_user_can('ee_read_transaction',
51
+            'espresso_transactions_view_transaction') ? '<a href="'.$view_lnk_url.'" title="'.esc_attr__('View Transaction Details',
52
+                'event_espresso').'">'.$item->get_i18n_datetime('REG_date').'</a>' : $item->get_i18n_datetime('REG_date');
53 53
 
54 54
         return sprintf('%1$s %2$s', $REG_date, $this->row_actions($actions));
55 55
 
@@ -106,16 +106,16 @@  discard block
 block discarded – undo
106 106
             // add a "View Registrations" link that filters list by event AND datetime
107 107
             $datetime_string .= $this->row_actions(
108 108
                 array(
109
-                    'event_datetime_filter' => '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
109
+                    'event_datetime_filter' => '<a href="'.EE_Admin_Page::add_query_args_and_nonce(
110 110
                             array('event_id' => $EVT_ID, 'datetime_id' => $datetime->ID()),
111 111
                             REG_ADMIN_URL
112
-                        ) . '" title="' . sprintf(
112
+                        ).'" title="'.sprintf(
113 113
                                                    esc_attr__(
114 114
                                                        'Filter this list to only show registrations for this datetime %s',
115 115
                                                        'event_espresso'
116 116
                                                    ),
117 117
                                                    $datetime->name()
118
-                                               ) . '">' . __('View Registrations', 'event_espresso') . '</a>',
118
+                                               ).'">'.__('View Registrations', 'event_espresso').'</a>',
119 119
                 )
120 120
             );
121 121
         }
Please login to merge, or discard this patch.
core/db_models/EEM_Change_Log.model.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
                 ),
107 107
             ),
108 108
         );
109
-        $this->_model_relations    = array();
109
+        $this->_model_relations = array();
110 110
         foreach ($models_this_can_attach_to as $model) {
111 111
             if ($model == 'WP_User') {
112 112
                 $this->_model_relations[$model] = new EE_Belongs_To_Relation();
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
      */
164 164
     public function gateway_log($message, $related_obj_id, $related_obj_type)
165 165
     {
166
-        if (! EE_Registry::instance()->is_model_name($related_obj_type)) {
166
+        if ( ! EE_Registry::instance()->is_model_name($related_obj_type)) {
167 167
             throw new EE_Error(
168 168
                 sprintf(
169 169
                     esc_html__(
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         global $wpdb;
213 213
         return $wpdb->query(
214 214
             $wpdb->prepare(
215
-                'DELETE FROM ' . $this->table() . ' WHERE LOG_type = %s AND LOG_time < %s',
215
+                'DELETE FROM '.$this->table().' WHERE LOG_type = %s AND LOG_time < %s',
216 216
                 EEM_Change_Log::type_gateway,
217 217
                 $datetime->format(EE_Datetime_Field::mysql_timestamp_format)
218 218
             )
Please login to merge, or discard this patch.
Indentation   +228 added lines, -228 removed lines patch added patch discarded remove patch
@@ -13,246 +13,246 @@
 block discarded – undo
13 13
 class EEM_Change_Log extends EEM_Base
14 14
 {
15 15
 
16
-    /**
17
-     * the related object was created log type
18
-     */
19
-    const type_create = 'create';
20
-    /**
21
-     * the related object was updated (changed, or soft-deleted)
22
-     */
23
-    const type_update = 'update';
24
-    /**
25
-     * the related object was deleted permanently
26
-     */
27
-    const type_delete = 'delete';
28
-    /**
29
-     * the related item had something worth noting happen on it, but
30
-     * only for the purposes of debugging problems
31
-     */
32
-    const type_debug = 'debug';
33
-    /**
34
-     * the related item had an error occur on it
35
-     */
36
-    const type_error = 'error';
37
-    /**
38
-     * the related item is regarding some gateway interaction, like an IPN
39
-     * or request to process a payment
40
-     */
41
-    const type_gateway = 'gateway';
16
+	/**
17
+	 * the related object was created log type
18
+	 */
19
+	const type_create = 'create';
20
+	/**
21
+	 * the related object was updated (changed, or soft-deleted)
22
+	 */
23
+	const type_update = 'update';
24
+	/**
25
+	 * the related object was deleted permanently
26
+	 */
27
+	const type_delete = 'delete';
28
+	/**
29
+	 * the related item had something worth noting happen on it, but
30
+	 * only for the purposes of debugging problems
31
+	 */
32
+	const type_debug = 'debug';
33
+	/**
34
+	 * the related item had an error occur on it
35
+	 */
36
+	const type_error = 'error';
37
+	/**
38
+	 * the related item is regarding some gateway interaction, like an IPN
39
+	 * or request to process a payment
40
+	 */
41
+	const type_gateway = 'gateway';
42 42
 
43
-    /**
44
-     * private instance of the EEM_Change_Log object
45
-     *
46
-     * @access private
47
-     * @var EEM_Change_Log $_instance
48
-     */
49
-    protected static $_instance = null;
43
+	/**
44
+	 * private instance of the EEM_Change_Log object
45
+	 *
46
+	 * @access private
47
+	 * @var EEM_Change_Log $_instance
48
+	 */
49
+	protected static $_instance = null;
50 50
 
51 51
 
52
-    /**
53
-     * constructor
54
-     *
55
-     * @access protected
56
-     * @param null $timezone
57
-     * @throws EE_Error
58
-     */
59
-    protected function __construct($timezone = null)
60
-    {
61
-        global $current_user;
62
-        $this->singular_item       = esc_html__('Log', 'event_espresso');
63
-        $this->plural_item         = esc_html__('Logs', 'event_espresso');
64
-        $this->_tables             = array(
65
-            'Log' => new EE_Primary_Table('esp_log', 'LOG_ID'),
66
-        );
67
-        $models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models);
68
-        $this->_fields             = array(
69
-            'Log' => array(
70
-                'LOG_ID'      => new EE_Primary_Key_Int_Field('LOG_ID', esc_html__('Log ID', 'event_espresso')),
71
-                'LOG_time'    => new EE_Datetime_Field(
72
-                    'LOG_time',
73
-                    esc_html__("Log Time", 'event_espresso'),
74
-                    false,
75
-                    EE_Datetime_Field::now
76
-                ),
77
-                'OBJ_ID'      => new EE_Foreign_Key_String_Field(
78
-                    'OBJ_ID',
79
-                    esc_html__("Object ID (int or string)", 'event_espresso'),
80
-                    true,
81
-                    null,
82
-                    $models_this_can_attach_to
83
-                ),
84
-                'OBJ_type'    => new EE_Any_Foreign_Model_Name_Field(
85
-                    'OBJ_type',
86
-                    esc_html__("Object Type", 'event_espresso'),
87
-                    true,
88
-                    null,
89
-                    $models_this_can_attach_to
90
-                ),
91
-                'LOG_type'    => new EE_Plain_Text_Field(
92
-                    'LOG_type',
93
-                    esc_html__("Type of log entry", "event_espresso"),
94
-                    false,
95
-                    self::type_debug
96
-                ),
97
-                'LOG_message' => new EE_Maybe_Serialized_Text_Field(
98
-                    'LOG_message',
99
-                    esc_html__("Log Message (body)", 'event_espresso'),
100
-                    true
101
-                ),
102
-                'LOG_wp_user' => new EE_WP_User_Field(
103
-                    'LOG_wp_user',
104
-                    esc_html__("User who was logged in while this occurred", 'event_espresso'),
105
-                    true
106
-                ),
107
-            ),
108
-        );
109
-        $this->_model_relations    = array();
110
-        foreach ($models_this_can_attach_to as $model) {
111
-            if ($model == 'WP_User') {
112
-                $this->_model_relations[$model] = new EE_Belongs_To_Relation();
113
-            } elseif ($model != 'Change_Log') {
114
-                $this->_model_relations[$model] = new EE_Belongs_To_Any_Relation();
115
-            }
116
-        }
117
-        //use completely custom caps for this
118
-        $this->_cap_restriction_generators = false;
119
-        //caps-wise this is all-or-nothing: if you have the default role you can access anything, otherwise nothing
120
-        foreach ($this->_cap_contexts_to_cap_action_map as $cap_context => $action) {
121
-            $this->_cap_restrictions[$cap_context][EE_Restriction_Generator_Base::get_default_restrictions_cap()]
122
-                = new EE_Return_None_Where_Conditions();
123
-        }
124
-        parent::__construct($timezone);
125
-    }
52
+	/**
53
+	 * constructor
54
+	 *
55
+	 * @access protected
56
+	 * @param null $timezone
57
+	 * @throws EE_Error
58
+	 */
59
+	protected function __construct($timezone = null)
60
+	{
61
+		global $current_user;
62
+		$this->singular_item       = esc_html__('Log', 'event_espresso');
63
+		$this->plural_item         = esc_html__('Logs', 'event_espresso');
64
+		$this->_tables             = array(
65
+			'Log' => new EE_Primary_Table('esp_log', 'LOG_ID'),
66
+		);
67
+		$models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models);
68
+		$this->_fields             = array(
69
+			'Log' => array(
70
+				'LOG_ID'      => new EE_Primary_Key_Int_Field('LOG_ID', esc_html__('Log ID', 'event_espresso')),
71
+				'LOG_time'    => new EE_Datetime_Field(
72
+					'LOG_time',
73
+					esc_html__("Log Time", 'event_espresso'),
74
+					false,
75
+					EE_Datetime_Field::now
76
+				),
77
+				'OBJ_ID'      => new EE_Foreign_Key_String_Field(
78
+					'OBJ_ID',
79
+					esc_html__("Object ID (int or string)", 'event_espresso'),
80
+					true,
81
+					null,
82
+					$models_this_can_attach_to
83
+				),
84
+				'OBJ_type'    => new EE_Any_Foreign_Model_Name_Field(
85
+					'OBJ_type',
86
+					esc_html__("Object Type", 'event_espresso'),
87
+					true,
88
+					null,
89
+					$models_this_can_attach_to
90
+				),
91
+				'LOG_type'    => new EE_Plain_Text_Field(
92
+					'LOG_type',
93
+					esc_html__("Type of log entry", "event_espresso"),
94
+					false,
95
+					self::type_debug
96
+				),
97
+				'LOG_message' => new EE_Maybe_Serialized_Text_Field(
98
+					'LOG_message',
99
+					esc_html__("Log Message (body)", 'event_espresso'),
100
+					true
101
+				),
102
+				'LOG_wp_user' => new EE_WP_User_Field(
103
+					'LOG_wp_user',
104
+					esc_html__("User who was logged in while this occurred", 'event_espresso'),
105
+					true
106
+				),
107
+			),
108
+		);
109
+		$this->_model_relations    = array();
110
+		foreach ($models_this_can_attach_to as $model) {
111
+			if ($model == 'WP_User') {
112
+				$this->_model_relations[$model] = new EE_Belongs_To_Relation();
113
+			} elseif ($model != 'Change_Log') {
114
+				$this->_model_relations[$model] = new EE_Belongs_To_Any_Relation();
115
+			}
116
+		}
117
+		//use completely custom caps for this
118
+		$this->_cap_restriction_generators = false;
119
+		//caps-wise this is all-or-nothing: if you have the default role you can access anything, otherwise nothing
120
+		foreach ($this->_cap_contexts_to_cap_action_map as $cap_context => $action) {
121
+			$this->_cap_restrictions[$cap_context][EE_Restriction_Generator_Base::get_default_restrictions_cap()]
122
+				= new EE_Return_None_Where_Conditions();
123
+		}
124
+		parent::__construct($timezone);
125
+	}
126 126
 
127
-    /**
128
-     * @param string        $log_type !see the acceptable values of LOG_type in EEM__Change_Log::__construct
129
-     * @param mixed         $message  array|string of the message you want to record
130
-     * @param EE_Base_Class $related_model_obj
131
-     * @return EE_Change_Log
132
-     * @throws EE_Error
133
-     */
134
-    public function log($log_type, $message, $related_model_obj)
135
-    {
136
-        if ($related_model_obj instanceof EE_Base_Class) {
137
-            $obj_id   = $related_model_obj->ID();
138
-            $obj_type = $related_model_obj->get_model()->get_this_model_name();
139
-        } else {
140
-            $obj_id   = null;
141
-            $obj_type = null;
142
-        }
143
-        /** @var EE_Change_Log $log */
144
-        $log = EE_Change_Log::new_instance(array(
145
-            'LOG_type'    => $log_type,
146
-            'LOG_message' => $message,
147
-            'OBJ_ID'      => $obj_id,
148
-            'OBJ_type'    => $obj_type,
149
-        ));
150
-        $log->save();
151
-        return $log;
152
-    }
127
+	/**
128
+	 * @param string        $log_type !see the acceptable values of LOG_type in EEM__Change_Log::__construct
129
+	 * @param mixed         $message  array|string of the message you want to record
130
+	 * @param EE_Base_Class $related_model_obj
131
+	 * @return EE_Change_Log
132
+	 * @throws EE_Error
133
+	 */
134
+	public function log($log_type, $message, $related_model_obj)
135
+	{
136
+		if ($related_model_obj instanceof EE_Base_Class) {
137
+			$obj_id   = $related_model_obj->ID();
138
+			$obj_type = $related_model_obj->get_model()->get_this_model_name();
139
+		} else {
140
+			$obj_id   = null;
141
+			$obj_type = null;
142
+		}
143
+		/** @var EE_Change_Log $log */
144
+		$log = EE_Change_Log::new_instance(array(
145
+			'LOG_type'    => $log_type,
146
+			'LOG_message' => $message,
147
+			'OBJ_ID'      => $obj_id,
148
+			'OBJ_type'    => $obj_type,
149
+		));
150
+		$log->save();
151
+		return $log;
152
+	}
153 153
 
154 154
 
155
-    /**
156
-     * Adds a gateway log for the specified object, given its ID and type
157
-     *
158
-     * @param string $message
159
-     * @param mixed  $related_obj_id
160
-     * @param string $related_obj_type
161
-     * @throws EE_Error
162
-     * @return EE_Change_Log
163
-     */
164
-    public function gateway_log($message, $related_obj_id, $related_obj_type)
165
-    {
166
-        if (! EE_Registry::instance()->is_model_name($related_obj_type)) {
167
-            throw new EE_Error(
168
-                sprintf(
169
-                    esc_html__(
170
-                        "'%s' is not a model name. A model name must be provided when making a gateway log. Eg, 'Payment', 'Payment_Method', etc",
171
-                        "event_espresso"
172
-                    ),
173
-                    $related_obj_type
174
-                )
175
-            );
176
-        }
177
-        /** @var EE_Change_Log $log */
178
-        $log = EE_Change_Log::new_instance(array(
179
-            'LOG_type'    => EEM_Change_Log::type_gateway,
180
-            'LOG_message' => $message,
181
-            'OBJ_ID'      => $related_obj_id,
182
-            'OBJ_type'    => $related_obj_type,
183
-        ));
184
-        $log->save();
185
-        return $log;
186
-    }
155
+	/**
156
+	 * Adds a gateway log for the specified object, given its ID and type
157
+	 *
158
+	 * @param string $message
159
+	 * @param mixed  $related_obj_id
160
+	 * @param string $related_obj_type
161
+	 * @throws EE_Error
162
+	 * @return EE_Change_Log
163
+	 */
164
+	public function gateway_log($message, $related_obj_id, $related_obj_type)
165
+	{
166
+		if (! EE_Registry::instance()->is_model_name($related_obj_type)) {
167
+			throw new EE_Error(
168
+				sprintf(
169
+					esc_html__(
170
+						"'%s' is not a model name. A model name must be provided when making a gateway log. Eg, 'Payment', 'Payment_Method', etc",
171
+						"event_espresso"
172
+					),
173
+					$related_obj_type
174
+				)
175
+			);
176
+		}
177
+		/** @var EE_Change_Log $log */
178
+		$log = EE_Change_Log::new_instance(array(
179
+			'LOG_type'    => EEM_Change_Log::type_gateway,
180
+			'LOG_message' => $message,
181
+			'OBJ_ID'      => $related_obj_id,
182
+			'OBJ_type'    => $related_obj_type,
183
+		));
184
+		$log->save();
185
+		return $log;
186
+	}
187 187
 
188 188
 
189
-    /**
190
-     * Just gets the bare-bones wpdb results as an array in cases where efficiency is essential
191
-     *
192
-     * @param array $query_params @see EEM_Base::get_all
193
-     * @return array of arrays
194
-     * @throws EE_Error
195
-     */
196
-    public function get_all_efficiently($query_params)
197
-    {
198
-        return $this->_get_all_wpdb_results($query_params);
199
-    }
189
+	/**
190
+	 * Just gets the bare-bones wpdb results as an array in cases where efficiency is essential
191
+	 *
192
+	 * @param array $query_params @see EEM_Base::get_all
193
+	 * @return array of arrays
194
+	 * @throws EE_Error
195
+	 */
196
+	public function get_all_efficiently($query_params)
197
+	{
198
+		return $this->_get_all_wpdb_results($query_params);
199
+	}
200 200
 
201 201
 
202
-    /**
203
-     * Executes a database query to delete gateway logs. Does not affect model objects, so if you attempt to use
204
-     * models after this, they may be out-of-sync with the database
205
-     *
206
-     * @param DateTime $datetime
207
-     * @return false|int
208
-     * @throws EE_Error
209
-     */
210
-    public function delete_gateway_logs_older_than(DateTime $datetime)
211
-    {
212
-        global $wpdb;
213
-        return $wpdb->query(
214
-            $wpdb->prepare(
215
-                'DELETE FROM ' . $this->table() . ' WHERE LOG_type = %s AND LOG_time < %s',
216
-                EEM_Change_Log::type_gateway,
217
-                $datetime->format(EE_Datetime_Field::mysql_timestamp_format)
218
-            )
219
-        );
220
-    }
202
+	/**
203
+	 * Executes a database query to delete gateway logs. Does not affect model objects, so if you attempt to use
204
+	 * models after this, they may be out-of-sync with the database
205
+	 *
206
+	 * @param DateTime $datetime
207
+	 * @return false|int
208
+	 * @throws EE_Error
209
+	 */
210
+	public function delete_gateway_logs_older_than(DateTime $datetime)
211
+	{
212
+		global $wpdb;
213
+		return $wpdb->query(
214
+			$wpdb->prepare(
215
+				'DELETE FROM ' . $this->table() . ' WHERE LOG_type = %s AND LOG_time < %s',
216
+				EEM_Change_Log::type_gateway,
217
+				$datetime->format(EE_Datetime_Field::mysql_timestamp_format)
218
+			)
219
+		);
220
+	}
221 221
 
222 222
 
223
-    /**
224
-     * Returns the map of type to pretty label for identifiers used for `LOG_type`.  Client code can register their own
225
-     * map vai the given filter.
226
-     *
227
-     * @return array
228
-     */
229
-    public static function get_pretty_label_map_for_registered_types()
230
-    {
231
-        return apply_filters(
232
-            'FHEE__EEM_Change_Log__get_pretty_label_map_for_registered_types',
233
-            array(
234
-                self::type_create=>  esc_html__("Create", "event_espresso"),
235
-                self::type_update=>  esc_html__("Update", "event_espresso"),
236
-                self::type_delete => esc_html__("Delete", "event_espresso"),
237
-                self::type_debug=>  esc_html__("Debug", "event_espresso"),
238
-                self::type_error=>  esc_html__("Error", "event_espresso"),
239
-                self::type_gateway=> esc_html__("Gateway Interaction (IPN or Direct Payment)", 'event_espresso')
240
-            )
241
-        );
242
-    }
223
+	/**
224
+	 * Returns the map of type to pretty label for identifiers used for `LOG_type`.  Client code can register their own
225
+	 * map vai the given filter.
226
+	 *
227
+	 * @return array
228
+	 */
229
+	public static function get_pretty_label_map_for_registered_types()
230
+	{
231
+		return apply_filters(
232
+			'FHEE__EEM_Change_Log__get_pretty_label_map_for_registered_types',
233
+			array(
234
+				self::type_create=>  esc_html__("Create", "event_espresso"),
235
+				self::type_update=>  esc_html__("Update", "event_espresso"),
236
+				self::type_delete => esc_html__("Delete", "event_espresso"),
237
+				self::type_debug=>  esc_html__("Debug", "event_espresso"),
238
+				self::type_error=>  esc_html__("Error", "event_espresso"),
239
+				self::type_gateway=> esc_html__("Gateway Interaction (IPN or Direct Payment)", 'event_espresso')
240
+			)
241
+		);
242
+	}
243 243
 
244 244
 
245
-    /**
246
-     * Return the pretty (localized) label for the given log type identifier.
247
-     * @param string $type_identifier
248
-     * @return string
249
-     */
250
-    public static function get_pretty_label_for_type($type_identifier)
251
-    {
252
-        $type_identifier_map = self::get_pretty_label_map_for_registered_types();
253
-        //we fallback to the incoming type identifier if there is no localized label for it.
254
-        return isset($type_identifier_map[$type_identifier])
255
-            ? $type_identifier_map[$type_identifier]
256
-            : $type_identifier;
257
-    }
245
+	/**
246
+	 * Return the pretty (localized) label for the given log type identifier.
247
+	 * @param string $type_identifier
248
+	 * @return string
249
+	 */
250
+	public static function get_pretty_label_for_type($type_identifier)
251
+	{
252
+		$type_identifier_map = self::get_pretty_label_map_for_registered_types();
253
+		//we fallback to the incoming type identifier if there is no localized label for it.
254
+		return isset($type_identifier_map[$type_identifier])
255
+			? $type_identifier_map[$type_identifier]
256
+			: $type_identifier;
257
+	}
258 258
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Change_Log.class.php 2 patches
Indentation   +212 added lines, -212 removed lines patch added patch discarded remove patch
@@ -13,216 +13,216 @@
 block discarded – undo
13 13
 class EE_Change_Log extends EE_Base_Class
14 14
 {
15 15
 
16
-    /**
17
-     * @param array  $props_n_values          incoming values
18
-     * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
19
-     *                                        used.)
20
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
21
-     *                                        date_format and the second value is the time format
22
-     * @return EE_Change_Log
23
-     * @throws EE_Error
24
-     */
25
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
26
-    {
27
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
28
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
29
-    }
30
-
31
-
32
-    /**
33
-     * @param array  $props_n_values  incoming values from the database
34
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
35
-     *                                the website will be used.
36
-     * @return EE_Change_Log
37
-     */
38
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
39
-    {
40
-        return new self($props_n_values, true, $timezone);
41
-    }
42
-
43
-    /**
44
-     * Gets message
45
-     *
46
-     * @return mixed
47
-     * @throws EE_Error
48
-     */
49
-    public function message()
50
-    {
51
-        return $this->get('LOG_message');
52
-    }
53
-
54
-    /**
55
-     * Sets message
56
-     *
57
-     * @param mixed $message
58
-     * @throws EE_Error
59
-     */
60
-    public function set_message($message)
61
-    {
62
-        $this->set('LOG_message', $message);
63
-    }
64
-
65
-    /**
66
-     * Gets time
67
-     *
68
-     * @return string
69
-     * @throws EE_Error
70
-     */
71
-    public function time()
72
-    {
73
-        return $this->get('LOG_time');
74
-    }
75
-
76
-    /**
77
-     * Sets time
78
-     *
79
-     * @param string $time
80
-     * @throws EE_Error
81
-     */
82
-    public function set_time($time)
83
-    {
84
-        $this->set('LOG_time', $time);
85
-    }
86
-
87
-    /**
88
-     * Gets log_type
89
-     *
90
-     * @return string
91
-     * @throws EE_Error
92
-     */
93
-    public function log_type()
94
-    {
95
-        return $this->get('LOG_type');
96
-    }
97
-
98
-
99
-    /**
100
-     * Return the localized log type label.
101
-     * @return string
102
-     * @throws EE_Error
103
-     */
104
-    public function log_type_label()
105
-    {
106
-        return EEM_Change_Log::get_pretty_label_for_type($this->log_type());
107
-    }
108
-
109
-    /**
110
-     * Sets log_type
111
-     *
112
-     * @param string $log_type
113
-     * @throws EE_Error
114
-     */
115
-    public function set_log_type($log_type)
116
-    {
117
-        $this->set('LOG_type', $log_type);
118
-    }
119
-
120
-    /**
121
-     * Gets type of the model object related to this log
122
-     *
123
-     * @return string
124
-     * @throws EE_Error
125
-     */
126
-    public function OBJ_type()
127
-    {
128
-        return $this->get('OBJ_type');
129
-    }
130
-
131
-    /**
132
-     * Sets type
133
-     *
134
-     * @param string $type
135
-     * @throws EE_Error
136
-     */
137
-    public function set_OBJ_type($type)
138
-    {
139
-        $this->set('OBJ_type', $type);
140
-    }
141
-
142
-    /**
143
-     * Gets OBJ_ID (the ID of the item related to this log)
144
-     *
145
-     * @return mixed
146
-     * @throws EE_Error
147
-     */
148
-    public function OBJ_ID()
149
-    {
150
-        return $this->get('OBJ_ID');
151
-    }
152
-
153
-    /**
154
-     * Sets OBJ_ID
155
-     *
156
-     * @param mixed $OBJ_ID
157
-     * @throws EE_Error
158
-     */
159
-    public function set_OBJ_ID($OBJ_ID)
160
-    {
161
-        $this->set('OBJ_ID', $OBJ_ID);
162
-    }
163
-
164
-    /**
165
-     * Gets wp_user
166
-     *
167
-     * @return int
168
-     * @throws EE_Error
169
-     */
170
-    public function wp_user()
171
-    {
172
-        return $this->get('LOG_wp_user');
173
-    }
174
-
175
-    /**
176
-     * Sets wp_user
177
-     *
178
-     * @param int $wp_user_id
179
-     * @throws EE_Error
180
-     */
181
-    public function set_wp_user($wp_user_id)
182
-    {
183
-        $this->set('LOG_wp_user', $wp_user_id);
184
-    }
185
-
186
-    /**
187
-     * Gets the model object attached to this log
188
-     *
189
-     * @return EE_Base_Class
190
-     * @throws EE_Error
191
-     */
192
-    public function object()
193
-    {
194
-        $model_name_of_related_obj = $this->OBJ_type();
195
-        $is_model_name             = EE_Registry::instance()->is_model_name($model_name_of_related_obj);
196
-        if (! $is_model_name) {
197
-            return null;
198
-        } else {
199
-            return $this->get_first_related($model_name_of_related_obj);
200
-        }
201
-    }
202
-
203
-    /**
204
-     * Shorthand for setting the OBJ_ID and OBJ_type. Slightly handier than using
205
-     * _add_relation_to because you don't have to specify what type of model you're
206
-     * associating it with
207
-     *
208
-     * @param EE_Base_Class $object
209
-     * @param boolean       $save
210
-     * @return bool if $save=true, NULL is $save=false
211
-     * @throws EE_Error
212
-     */
213
-    public function set_object($object, $save = true)
214
-    {
215
-        if ($object instanceof EE_Base_Class) {
216
-            $this->set_OBJ_type($object->get_model()->get_this_model_name());
217
-            $this->set_OBJ_ID($object->ID());
218
-        } else {
219
-            $this->set_OBJ_type(null);
220
-            $this->set_OBJ_ID(null);
221
-        }
222
-        if ($save) {
223
-            return $this->save();
224
-        } else {
225
-            return null;
226
-        }
227
-    }
16
+	/**
17
+	 * @param array  $props_n_values          incoming values
18
+	 * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
19
+	 *                                        used.)
20
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
21
+	 *                                        date_format and the second value is the time format
22
+	 * @return EE_Change_Log
23
+	 * @throws EE_Error
24
+	 */
25
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
26
+	{
27
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
28
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
29
+	}
30
+
31
+
32
+	/**
33
+	 * @param array  $props_n_values  incoming values from the database
34
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
35
+	 *                                the website will be used.
36
+	 * @return EE_Change_Log
37
+	 */
38
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
39
+	{
40
+		return new self($props_n_values, true, $timezone);
41
+	}
42
+
43
+	/**
44
+	 * Gets message
45
+	 *
46
+	 * @return mixed
47
+	 * @throws EE_Error
48
+	 */
49
+	public function message()
50
+	{
51
+		return $this->get('LOG_message');
52
+	}
53
+
54
+	/**
55
+	 * Sets message
56
+	 *
57
+	 * @param mixed $message
58
+	 * @throws EE_Error
59
+	 */
60
+	public function set_message($message)
61
+	{
62
+		$this->set('LOG_message', $message);
63
+	}
64
+
65
+	/**
66
+	 * Gets time
67
+	 *
68
+	 * @return string
69
+	 * @throws EE_Error
70
+	 */
71
+	public function time()
72
+	{
73
+		return $this->get('LOG_time');
74
+	}
75
+
76
+	/**
77
+	 * Sets time
78
+	 *
79
+	 * @param string $time
80
+	 * @throws EE_Error
81
+	 */
82
+	public function set_time($time)
83
+	{
84
+		$this->set('LOG_time', $time);
85
+	}
86
+
87
+	/**
88
+	 * Gets log_type
89
+	 *
90
+	 * @return string
91
+	 * @throws EE_Error
92
+	 */
93
+	public function log_type()
94
+	{
95
+		return $this->get('LOG_type');
96
+	}
97
+
98
+
99
+	/**
100
+	 * Return the localized log type label.
101
+	 * @return string
102
+	 * @throws EE_Error
103
+	 */
104
+	public function log_type_label()
105
+	{
106
+		return EEM_Change_Log::get_pretty_label_for_type($this->log_type());
107
+	}
108
+
109
+	/**
110
+	 * Sets log_type
111
+	 *
112
+	 * @param string $log_type
113
+	 * @throws EE_Error
114
+	 */
115
+	public function set_log_type($log_type)
116
+	{
117
+		$this->set('LOG_type', $log_type);
118
+	}
119
+
120
+	/**
121
+	 * Gets type of the model object related to this log
122
+	 *
123
+	 * @return string
124
+	 * @throws EE_Error
125
+	 */
126
+	public function OBJ_type()
127
+	{
128
+		return $this->get('OBJ_type');
129
+	}
130
+
131
+	/**
132
+	 * Sets type
133
+	 *
134
+	 * @param string $type
135
+	 * @throws EE_Error
136
+	 */
137
+	public function set_OBJ_type($type)
138
+	{
139
+		$this->set('OBJ_type', $type);
140
+	}
141
+
142
+	/**
143
+	 * Gets OBJ_ID (the ID of the item related to this log)
144
+	 *
145
+	 * @return mixed
146
+	 * @throws EE_Error
147
+	 */
148
+	public function OBJ_ID()
149
+	{
150
+		return $this->get('OBJ_ID');
151
+	}
152
+
153
+	/**
154
+	 * Sets OBJ_ID
155
+	 *
156
+	 * @param mixed $OBJ_ID
157
+	 * @throws EE_Error
158
+	 */
159
+	public function set_OBJ_ID($OBJ_ID)
160
+	{
161
+		$this->set('OBJ_ID', $OBJ_ID);
162
+	}
163
+
164
+	/**
165
+	 * Gets wp_user
166
+	 *
167
+	 * @return int
168
+	 * @throws EE_Error
169
+	 */
170
+	public function wp_user()
171
+	{
172
+		return $this->get('LOG_wp_user');
173
+	}
174
+
175
+	/**
176
+	 * Sets wp_user
177
+	 *
178
+	 * @param int $wp_user_id
179
+	 * @throws EE_Error
180
+	 */
181
+	public function set_wp_user($wp_user_id)
182
+	{
183
+		$this->set('LOG_wp_user', $wp_user_id);
184
+	}
185
+
186
+	/**
187
+	 * Gets the model object attached to this log
188
+	 *
189
+	 * @return EE_Base_Class
190
+	 * @throws EE_Error
191
+	 */
192
+	public function object()
193
+	{
194
+		$model_name_of_related_obj = $this->OBJ_type();
195
+		$is_model_name             = EE_Registry::instance()->is_model_name($model_name_of_related_obj);
196
+		if (! $is_model_name) {
197
+			return null;
198
+		} else {
199
+			return $this->get_first_related($model_name_of_related_obj);
200
+		}
201
+	}
202
+
203
+	/**
204
+	 * Shorthand for setting the OBJ_ID and OBJ_type. Slightly handier than using
205
+	 * _add_relation_to because you don't have to specify what type of model you're
206
+	 * associating it with
207
+	 *
208
+	 * @param EE_Base_Class $object
209
+	 * @param boolean       $save
210
+	 * @return bool if $save=true, NULL is $save=false
211
+	 * @throws EE_Error
212
+	 */
213
+	public function set_object($object, $save = true)
214
+	{
215
+		if ($object instanceof EE_Base_Class) {
216
+			$this->set_OBJ_type($object->get_model()->get_this_model_name());
217
+			$this->set_OBJ_ID($object->ID());
218
+		} else {
219
+			$this->set_OBJ_type(null);
220
+			$this->set_OBJ_ID(null);
221
+		}
222
+		if ($save) {
223
+			return $this->save();
224
+		} else {
225
+			return null;
226
+		}
227
+	}
228 228
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -193,7 +193,7 @@
 block discarded – undo
193 193
     {
194 194
         $model_name_of_related_obj = $this->OBJ_type();
195 195
         $is_model_name             = EE_Registry::instance()->is_model_name($model_name_of_related_obj);
196
-        if (! $is_model_name) {
196
+        if ( ! $is_model_name) {
197 197
             return null;
198 198
         } else {
199 199
             return $this->get_first_related($model_name_of_related_obj);
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('ABSPATH')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /*
5 5
   Plugin Name:		Event Espresso
@@ -40,243 +40,243 @@  discard block
 block discarded – undo
40 40
  * @since            4.0
41 41
  */
42 42
 if (function_exists('espresso_version')) {
43
-    /**
44
-     *    espresso_duplicate_plugin_error
45
-     *    displays if more than one version of EE is activated at the same time
46
-     */
47
-    function espresso_duplicate_plugin_error()
48
-    {
49
-        ?>
43
+	/**
44
+	 *    espresso_duplicate_plugin_error
45
+	 *    displays if more than one version of EE is activated at the same time
46
+	 */
47
+	function espresso_duplicate_plugin_error()
48
+	{
49
+		?>
50 50
         <div class="error">
51 51
             <p>
52 52
                 <?php echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                ); ?>
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+				); ?>
56 56
             </p>
57 57
         </div>
58 58
         <?php
59
-        espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-    }
59
+		espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+	}
61 61
 
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
-    if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
+	if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                            esc_html__(
79
-                                    'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                                    'event_espresso'
81
-                            ),
82
-                            EE_MIN_PHP_VER_REQUIRED,
83
-                            PHP_VERSION,
84
-                            '<br/>',
85
-                            '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+							esc_html__(
79
+									'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+									'event_espresso'
81
+							),
82
+							EE_MIN_PHP_VER_REQUIRED,
83
+							PHP_VERSION,
84
+							'<br/>',
85
+							'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        /**
97
-         * espresso_version
98
-         * Returns the plugin version
99
-         *
100
-         * @return string
101
-         */
102
-        function espresso_version()
103
-        {
104
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.46.rc.013');
105
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		/**
97
+		 * espresso_version
98
+		 * Returns the plugin version
99
+		 *
100
+		 * @return string
101
+		 */
102
+		function espresso_version()
103
+		{
104
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.46.rc.013');
105
+		}
106 106
 
107
-        // define versions
108
-        define('EVENT_ESPRESSO_VERSION', espresso_version());
109
-        define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
-        define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
-        define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
-        //used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
-        if ( ! defined('DS')) {
115
-            define('DS', '/');
116
-        }
117
-        if ( ! defined('PS')) {
118
-            define('PS', PATH_SEPARATOR);
119
-        }
120
-        if ( ! defined('SP')) {
121
-            define('SP', ' ');
122
-        }
123
-        if ( ! defined('EENL')) {
124
-            define('EENL', "\n");
125
-        }
126
-        define('EE_SUPPORT_EMAIL', '[email protected]');
127
-        // define the plugin directory and URL
128
-        define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
-        define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
-        define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
-        // main root folder paths
132
-        define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
-        define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
-        define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
-        define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
-        define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
-        define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
-        define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
-        define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
-        // core system paths
141
-        define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
-        define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
-        define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
-        define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
-        define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
-        define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
-        define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
-        define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
-        define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
-        define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
-        define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
-        define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
-        // gateways
154
-        define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
-        define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
-        // asset URL paths
157
-        define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
-        define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
-        define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
-        define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
-        define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
-        define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
-        // define upload paths
164
-        $uploads = wp_upload_dir();
165
-        // define the uploads directory and URL
166
-        define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
-        define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
-        // define the templates directory and URL
169
-        define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
-        define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
-        // define the gateway directory and URL
172
-        define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
-        define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
-        // languages folder/path
175
-        define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
-        define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
-        //check for dompdf fonts in uploads
178
-        if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
-            define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
-        }
181
-        //ajax constants
182
-        define(
183
-                'EE_FRONT_AJAX',
184
-                isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
-        );
186
-        define(
187
-                'EE_ADMIN_AJAX',
188
-                isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
-        );
190
-        //just a handy constant occasionally needed for finding values representing infinity in the DB
191
-        //you're better to use this than its straight value (currently -1) in case you ever
192
-        //want to change its default value! or find when -1 means infinity
193
-        define('EE_INF_IN_DB', -1);
194
-        define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
-        define('EE_DEBUG', false);
196
-        // for older WP versions
197
-        if ( ! defined('MONTH_IN_SECONDS')) {
198
-            define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
-        }
200
-        /**
201
-         *    espresso_plugin_activation
202
-         *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
-         */
204
-        function espresso_plugin_activation()
205
-        {
206
-            update_option('ee_espresso_activation', true);
207
-        }
107
+		// define versions
108
+		define('EVENT_ESPRESSO_VERSION', espresso_version());
109
+		define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
+		define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
+		define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
+		//used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
+		if ( ! defined('DS')) {
115
+			define('DS', '/');
116
+		}
117
+		if ( ! defined('PS')) {
118
+			define('PS', PATH_SEPARATOR);
119
+		}
120
+		if ( ! defined('SP')) {
121
+			define('SP', ' ');
122
+		}
123
+		if ( ! defined('EENL')) {
124
+			define('EENL', "\n");
125
+		}
126
+		define('EE_SUPPORT_EMAIL', '[email protected]');
127
+		// define the plugin directory and URL
128
+		define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
+		define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
+		define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
+		// main root folder paths
132
+		define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
+		define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
+		define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
+		define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
+		define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
+		define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
+		define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
+		define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
+		// core system paths
141
+		define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
+		define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
+		define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
+		define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
+		define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
+		define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
+		define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
+		define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
+		define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
+		define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
+		define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
+		define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
+		// gateways
154
+		define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
+		define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
+		// asset URL paths
157
+		define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
+		define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
+		define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
+		define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
+		define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
+		define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
+		// define upload paths
164
+		$uploads = wp_upload_dir();
165
+		// define the uploads directory and URL
166
+		define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
+		define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
+		// define the templates directory and URL
169
+		define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
+		define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
+		// define the gateway directory and URL
172
+		define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
+		define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
+		// languages folder/path
175
+		define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
+		define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
+		//check for dompdf fonts in uploads
178
+		if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
+			define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
+		}
181
+		//ajax constants
182
+		define(
183
+				'EE_FRONT_AJAX',
184
+				isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
+		);
186
+		define(
187
+				'EE_ADMIN_AJAX',
188
+				isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
+		);
190
+		//just a handy constant occasionally needed for finding values representing infinity in the DB
191
+		//you're better to use this than its straight value (currently -1) in case you ever
192
+		//want to change its default value! or find when -1 means infinity
193
+		define('EE_INF_IN_DB', -1);
194
+		define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
+		define('EE_DEBUG', false);
196
+		// for older WP versions
197
+		if ( ! defined('MONTH_IN_SECONDS')) {
198
+			define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
+		}
200
+		/**
201
+		 *    espresso_plugin_activation
202
+		 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
+		 */
204
+		function espresso_plugin_activation()
205
+		{
206
+			update_option('ee_espresso_activation', true);
207
+		}
208 208
 
209
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
-        /**
211
-         *    espresso_load_error_handling
212
-         *    this function loads EE's class for handling exceptions and errors
213
-         */
214
-        function espresso_load_error_handling()
215
-        {
216
-            // load debugging tools
217
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
-                require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
-                EEH_Debug_Tools::instance();
220
-            }
221
-            // load error handling
222
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
-                require_once(EE_CORE . 'EE_Error.core.php');
224
-            } else {
225
-                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
-            }
227
-        }
209
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
+		/**
211
+		 *    espresso_load_error_handling
212
+		 *    this function loads EE's class for handling exceptions and errors
213
+		 */
214
+		function espresso_load_error_handling()
215
+		{
216
+			// load debugging tools
217
+			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
+				require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
+				EEH_Debug_Tools::instance();
220
+			}
221
+			// load error handling
222
+			if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
+				require_once(EE_CORE . 'EE_Error.core.php');
224
+			} else {
225
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
+			}
227
+		}
228 228
 
229
-        /**
230
-         *    espresso_load_required
231
-         *    given a class name and path, this function will load that file or throw an exception
232
-         *
233
-         * @param    string $classname
234
-         * @param    string $full_path_to_file
235
-         * @throws    EE_Error
236
-         */
237
-        function espresso_load_required($classname, $full_path_to_file)
238
-        {
239
-            static $error_handling_loaded = false;
240
-            if ( ! $error_handling_loaded) {
241
-                espresso_load_error_handling();
242
-                $error_handling_loaded = true;
243
-            }
244
-            if (is_readable($full_path_to_file)) {
245
-                require_once($full_path_to_file);
246
-            } else {
247
-                throw new EE_Error (
248
-                        sprintf(
249
-                                esc_html__(
250
-                                        'The %s class file could not be located or is not readable due to file permissions.',
251
-                                        'event_espresso'
252
-                                ),
253
-                                $classname
254
-                        )
255
-                );
256
-            }
257
-        }
229
+		/**
230
+		 *    espresso_load_required
231
+		 *    given a class name and path, this function will load that file or throw an exception
232
+		 *
233
+		 * @param    string $classname
234
+		 * @param    string $full_path_to_file
235
+		 * @throws    EE_Error
236
+		 */
237
+		function espresso_load_required($classname, $full_path_to_file)
238
+		{
239
+			static $error_handling_loaded = false;
240
+			if ( ! $error_handling_loaded) {
241
+				espresso_load_error_handling();
242
+				$error_handling_loaded = true;
243
+			}
244
+			if (is_readable($full_path_to_file)) {
245
+				require_once($full_path_to_file);
246
+			} else {
247
+				throw new EE_Error (
248
+						sprintf(
249
+								esc_html__(
250
+										'The %s class file could not be located or is not readable due to file permissions.',
251
+										'event_espresso'
252
+								),
253
+								$classname
254
+						)
255
+				);
256
+			}
257
+		}
258 258
 
259
-        espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
-        espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
-        espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
-        new EE_Bootstrap();
263
-    }
259
+		espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
+		espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
+		espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
+		new EE_Bootstrap();
263
+	}
264 264
 }
265 265
 if ( ! function_exists('espresso_deactivate_plugin')) {
266
-    /**
267
-     *    deactivate_plugin
268
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
-     *
270
-     * @access public
271
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
-     * @return    void
273
-     */
274
-    function espresso_deactivate_plugin($plugin_basename = '')
275
-    {
276
-        if ( ! function_exists('deactivate_plugins')) {
277
-            require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
-        }
279
-        unset($_GET['activate'], $_REQUEST['activate']);
280
-        deactivate_plugins($plugin_basename);
281
-    }
266
+	/**
267
+	 *    deactivate_plugin
268
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
+	 *
270
+	 * @access public
271
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
+	 * @return    void
273
+	 */
274
+	function espresso_deactivate_plugin($plugin_basename = '')
275
+	{
276
+		if ( ! function_exists('deactivate_plugins')) {
277
+			require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
+		}
279
+		unset($_GET['activate'], $_REQUEST['activate']);
280
+		deactivate_plugins($plugin_basename);
281
+	}
282 282
 }
283 283
\ No newline at end of file
Please login to merge, or discard this patch.