Completed
Branch FET-10416-autoload-b4-bootstra... (42a01c)
by
unknown
13:17
created
core/helpers/EEH_Debug_Tools.helper.php 3 patches
Doc Comments   +2 added lines, -2 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    $line
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 
571 571
     /**
572 572
      * @deprecated 4.9.39.rc.034
573
-     * @param null $timer_name
573
+     * @param string $timer_name
574 574
      */
575 575
     public function start_timer($timer_name = null)
576 576
     {
Please login to merge, or discard this patch.
Indentation   +636 added lines, -636 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,626 +17,626 @@  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    $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 = __FILE__,
390
-        $line = __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\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 "\n";
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 (defined('EE_TESTS_DIR')) {
467
-            return "\n (" . $file . ' line no: ' . $line . ' ) ';
468
-        }
469
-        return '<br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">'
470
-               . $file
471
-               . '<br />line no: '
472
-               . $line
473
-               . '</span>';
474
-    }
475
-
476
-
477
-
478
-    /**
479
-     * @param string $content
480
-     * @return string
481
-     */
482
-    protected static function orange_span($content = '')
483
-    {
484
-        if (defined('EE_TESTS_DIR')) {
485
-            return $content;
486
-        }
487
-        return '<span style="color:#E76700">' . $content . '</span>';
488
-    }
489
-
490
-
491
-
492
-    /**
493
-     * @param mixed $var
494
-     * @return string
495
-     */
496
-    protected static function pre_span($var)
497
-    {
498
-        ob_start();
499
-        var_dump($var);
500
-        $var = ob_get_clean();
501
-        if (defined('EE_TESTS_DIR')) {
502
-            return "\n" . $var;
503
-        }
504
-        return '<pre style="color:#999; padding:1em; background: #fff">' . $var . '</pre>';
505
-    }
506
-
507
-
508
-
509
-    /**
510
-     * @param mixed  $var
511
-     * @param string $var_name
512
-     * @param string $file
513
-     * @param int    $line
514
-     * @param int    $heading_tag
515
-     * @param bool   $die
516
-     */
517
-    public static function printr(
518
-        $var,
519
-        $var_name = '',
520
-        $file = __FILE__,
521
-        $line = __LINE__,
522
-        $heading_tag = 5,
523
-        $die = false
524
-    ) {
525
-        // return;
526
-        $file = str_replace(rtrim(ABSPATH, '\\/'), '', $file);
527
-        $margin = is_admin() ? ' 180px' : '0';
528
-        //$print_r = false;
529
-        if (is_string($var)) {
530
-            EEH_Debug_Tools::printv($var, $var_name, $file, $line, $heading_tag, $die, $margin);
531
-            return;
532
-        }
533
-        if (is_object($var)) {
534
-            $var_name = ! $var_name ? 'object' : $var_name;
535
-            //$print_r = true;
536
-        } else if (is_array($var)) {
537
-            $var_name = ! $var_name ? 'array' : $var_name;
538
-            //$print_r = true;
539
-        } else if (is_numeric($var)) {
540
-            $var_name = ! $var_name ? 'numeric' : $var_name;
541
-        } else if ($var === null) {
542
-            $var_name = ! $var_name ? 'null' : $var_name;
543
-        }
544
-        $var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name));
545
-        $heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5';
546
-        $result = EEH_Debug_Tools::heading($var_name, $heading_tag, $margin);
547
-        $result .= EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span(
548
-                EEH_Debug_Tools::pre_span($var)
549
-            );
550
-        $result .= EEH_Debug_Tools::file_and_line($file, $line);
551
-        $result .= EEH_Debug_Tools::headingX($heading_tag);
552
-        if ($die) {
553
-            die($result);
554
-        }
555
-        echo $result;
556
-    }
557
-
558
-
559
-
560
-    /******************** deprecated ********************/
561
-    /**
562
-     * @deprecated 4.9.39.rc.034
563
-     */
564
-    public function reset_times()
565
-    {
566
-        Benchmark::resetTimes();
567
-    }
568
-
569
-
570
-
571
-    /**
572
-     * @deprecated 4.9.39.rc.034
573
-     * @param null $timer_name
574
-     */
575
-    public function start_timer($timer_name = null)
576
-    {
577
-        Benchmark::startTimer($timer_name);
578
-    }
579
-
580
-
581
-
582
-    /**
583
-     * @deprecated 4.9.39.rc.034
584
-     * @param string $timer_name
585
-     */
586
-    public function stop_timer($timer_name = '')
587
-    {
588
-        Benchmark::stopTimer($timer_name);
589
-    }
590
-
591
-
592
-
593
-    /**
594
-     * @deprecated 4.9.39.rc.034
595
-     * @param string  $label      The label to show for this time eg "Start of calling Some_Class::some_function"
596
-     * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called
597
-     * @return void
598
-     */
599
-    public function measure_memory($label, $output_now = false)
600
-    {
601
-        Benchmark::measureMemory($label, $output_now);
602
-    }
603
-
604
-
605
-
606
-    /**
607
-     * @deprecated 4.9.39.rc.034
608
-     * @param int $size
609
-     * @return string
610
-     */
611
-    public function convert($size)
612
-    {
613
-        return Benchmark::convert($size);
614
-    }
615
-
616
-
617
-
618
-    /**
619
-     * @deprecated 4.9.39.rc.034
620
-     * @param bool $output_now
621
-     * @return string
622
-     */
623
-    public function show_times($output_now = true)
624
-    {
625
-        return Benchmark::displayResults($output_now);
626
-    }
627
-
628
-
629
-
630
-    /**
631
-     * @deprecated 4.9.39.rc.034
632
-     * @param string $timer_name
633
-     * @param float  $total_time
634
-     * @return string
635
-     */
636
-    public function format_time($timer_name, $total_time)
637
-    {
638
-        return Benchmark::formatTime($timer_name, $total_time);
639
-    }
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    $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 = __FILE__,
390
+		$line = __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\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 "\n";
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 (defined('EE_TESTS_DIR')) {
467
+			return "\n (" . $file . ' line no: ' . $line . ' ) ';
468
+		}
469
+		return '<br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">'
470
+			   . $file
471
+			   . '<br />line no: '
472
+			   . $line
473
+			   . '</span>';
474
+	}
475
+
476
+
477
+
478
+	/**
479
+	 * @param string $content
480
+	 * @return string
481
+	 */
482
+	protected static function orange_span($content = '')
483
+	{
484
+		if (defined('EE_TESTS_DIR')) {
485
+			return $content;
486
+		}
487
+		return '<span style="color:#E76700">' . $content . '</span>';
488
+	}
489
+
490
+
491
+
492
+	/**
493
+	 * @param mixed $var
494
+	 * @return string
495
+	 */
496
+	protected static function pre_span($var)
497
+	{
498
+		ob_start();
499
+		var_dump($var);
500
+		$var = ob_get_clean();
501
+		if (defined('EE_TESTS_DIR')) {
502
+			return "\n" . $var;
503
+		}
504
+		return '<pre style="color:#999; padding:1em; background: #fff">' . $var . '</pre>';
505
+	}
506
+
507
+
508
+
509
+	/**
510
+	 * @param mixed  $var
511
+	 * @param string $var_name
512
+	 * @param string $file
513
+	 * @param int    $line
514
+	 * @param int    $heading_tag
515
+	 * @param bool   $die
516
+	 */
517
+	public static function printr(
518
+		$var,
519
+		$var_name = '',
520
+		$file = __FILE__,
521
+		$line = __LINE__,
522
+		$heading_tag = 5,
523
+		$die = false
524
+	) {
525
+		// return;
526
+		$file = str_replace(rtrim(ABSPATH, '\\/'), '', $file);
527
+		$margin = is_admin() ? ' 180px' : '0';
528
+		//$print_r = false;
529
+		if (is_string($var)) {
530
+			EEH_Debug_Tools::printv($var, $var_name, $file, $line, $heading_tag, $die, $margin);
531
+			return;
532
+		}
533
+		if (is_object($var)) {
534
+			$var_name = ! $var_name ? 'object' : $var_name;
535
+			//$print_r = true;
536
+		} else if (is_array($var)) {
537
+			$var_name = ! $var_name ? 'array' : $var_name;
538
+			//$print_r = true;
539
+		} else if (is_numeric($var)) {
540
+			$var_name = ! $var_name ? 'numeric' : $var_name;
541
+		} else if ($var === null) {
542
+			$var_name = ! $var_name ? 'null' : $var_name;
543
+		}
544
+		$var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name));
545
+		$heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5';
546
+		$result = EEH_Debug_Tools::heading($var_name, $heading_tag, $margin);
547
+		$result .= EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span(
548
+				EEH_Debug_Tools::pre_span($var)
549
+			);
550
+		$result .= EEH_Debug_Tools::file_and_line($file, $line);
551
+		$result .= EEH_Debug_Tools::headingX($heading_tag);
552
+		if ($die) {
553
+			die($result);
554
+		}
555
+		echo $result;
556
+	}
557
+
558
+
559
+
560
+	/******************** deprecated ********************/
561
+	/**
562
+	 * @deprecated 4.9.39.rc.034
563
+	 */
564
+	public function reset_times()
565
+	{
566
+		Benchmark::resetTimes();
567
+	}
568
+
569
+
570
+
571
+	/**
572
+	 * @deprecated 4.9.39.rc.034
573
+	 * @param null $timer_name
574
+	 */
575
+	public function start_timer($timer_name = null)
576
+	{
577
+		Benchmark::startTimer($timer_name);
578
+	}
579
+
580
+
581
+
582
+	/**
583
+	 * @deprecated 4.9.39.rc.034
584
+	 * @param string $timer_name
585
+	 */
586
+	public function stop_timer($timer_name = '')
587
+	{
588
+		Benchmark::stopTimer($timer_name);
589
+	}
590
+
591
+
592
+
593
+	/**
594
+	 * @deprecated 4.9.39.rc.034
595
+	 * @param string  $label      The label to show for this time eg "Start of calling Some_Class::some_function"
596
+	 * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called
597
+	 * @return void
598
+	 */
599
+	public function measure_memory($label, $output_now = false)
600
+	{
601
+		Benchmark::measureMemory($label, $output_now);
602
+	}
603
+
604
+
605
+
606
+	/**
607
+	 * @deprecated 4.9.39.rc.034
608
+	 * @param int $size
609
+	 * @return string
610
+	 */
611
+	public function convert($size)
612
+	{
613
+		return Benchmark::convert($size);
614
+	}
615
+
616
+
617
+
618
+	/**
619
+	 * @deprecated 4.9.39.rc.034
620
+	 * @param bool $output_now
621
+	 * @return string
622
+	 */
623
+	public function show_times($output_now = true)
624
+	{
625
+		return Benchmark::displayResults($output_now);
626
+	}
627
+
628
+
629
+
630
+	/**
631
+	 * @deprecated 4.9.39.rc.034
632
+	 * @param string $timer_name
633
+	 * @param float  $total_time
634
+	 * @return string
635
+	 */
636
+	public function format_time($timer_name, $total_time)
637
+	{
638
+		return Benchmark::formatTime($timer_name, $total_time);
639
+	}
640 640
 
641 641
 
642 642
 
@@ -649,31 +649,31 @@  discard block
 block discarded – undo
649 649
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
650 650
  */
651 651
 if (class_exists('Kint') && ! function_exists('dump_wp_query')) {
652
-    function dump_wp_query()
653
-    {
654
-        global $wp_query;
655
-        d($wp_query);
656
-    }
652
+	function dump_wp_query()
653
+	{
654
+		global $wp_query;
655
+		d($wp_query);
656
+	}
657 657
 }
658 658
 /**
659 659
  * borrowed from Kint Debugger
660 660
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
661 661
  */
662 662
 if (class_exists('Kint') && ! function_exists('dump_wp')) {
663
-    function dump_wp()
664
-    {
665
-        global $wp;
666
-        d($wp);
667
-    }
663
+	function dump_wp()
664
+	{
665
+		global $wp;
666
+		d($wp);
667
+	}
668 668
 }
669 669
 /**
670 670
  * borrowed from Kint Debugger
671 671
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
672 672
  */
673 673
 if (class_exists('Kint') && ! function_exists('dump_post')) {
674
-    function dump_post()
675
-    {
676
-        global $post;
677
-        d($post);
678
-    }
674
+	function dump_post()
675
+	{
676
+		global $post;
677
+		d($post);
678
+	}
679 679
 }
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\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 "\n";
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
 
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
     protected static function file_and_line($file, $line)
465 465
     {
466 466
         if (defined('EE_TESTS_DIR')) {
467
-            return "\n (" . $file . ' line no: ' . $line . ' ) ';
467
+            return "\n (".$file.' line no: '.$line.' ) ';
468 468
         }
469 469
         return '<br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">'
470 470
                . $file
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
         if (defined('EE_TESTS_DIR')) {
485 485
             return $content;
486 486
         }
487
-        return '<span style="color:#E76700">' . $content . '</span>';
487
+        return '<span style="color:#E76700">'.$content.'</span>';
488 488
     }
489 489
 
490 490
 
@@ -499,9 +499,9 @@  discard block
 block discarded – undo
499 499
         var_dump($var);
500 500
         $var = ob_get_clean();
501 501
         if (defined('EE_TESTS_DIR')) {
502
-            return "\n" . $var;
502
+            return "\n".$var;
503 503
         }
504
-        return '<pre style="color:#999; padding:1em; background: #fff">' . $var . '</pre>';
504
+        return '<pre style="color:#999; padding:1em; background: #fff">'.$var.'</pre>';
505 505
     }
506 506
 
507 507
 
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
         $var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name));
545 545
         $heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5';
546 546
         $result = EEH_Debug_Tools::heading($var_name, $heading_tag, $margin);
547
-        $result .= EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span(
547
+        $result .= EEH_Debug_Tools::grey_span(' : ').EEH_Debug_Tools::orange_span(
548 548
                 EEH_Debug_Tools::pre_span($var)
549 549
             );
550 550
         $result .= EEH_Debug_Tools::file_and_line($file, $line);
Please login to merge, or discard this patch.
core/services/Benchmark.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
     {
123 123
         add_action(
124 124
             'shutdown',
125
-            function () {
125
+            function() {
126 126
                 Benchmark::displayResults();
127 127
             }
128 128
         );
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
             return '';
143 143
         }
144 144
         $output = '';
145
-        if (! empty(Benchmark::$times)) {
145
+        if ( ! empty(Benchmark::$times)) {
146 146
             $total = 0;
147 147
             $output .= '<span style="color:#999999; font-size:.8em;">( time in milliseconds )</span><br />';
148 148
             foreach (Benchmark::$times as $timer_name => $total_time) {
149
-                $output .= Benchmark::formatTime($timer_name, $total_time) . '<br />';
149
+                $output .= Benchmark::formatTime($timer_name, $total_time).'<br />';
150 150
                 $total += $total_time;
151 151
             }
152 152
             $output .= '<br />';
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
             $output .= '<span style="color:darkorange">Zoinks!</span><br />';
163 163
             $output .= '<span style="color:red">Like...HEEELLLP</span><br />';
164 164
         }
165
-        if (! empty(Benchmark::$memory_usage)) {
166
-            $output .= '<h5>Memory</h5>' . implode('<br />', Benchmark::$memory_usage);
165
+        if ( ! empty(Benchmark::$memory_usage)) {
166
+            $output .= '<h5>Memory</h5>'.implode('<br />', Benchmark::$memory_usage);
167 167
         }
168 168
         if (empty($output)) {
169 169
             return '';
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
     public static function convert($size)
193 193
     {
194 194
         $unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb');
195
-        return round($size / pow(1024, $i = floor(log($size, 1024))), 2) . ' ' . $unit[absint($i)];
195
+        return round($size / pow(1024, $i = floor(log($size, 1024))), 2).' '.$unit[absint($i)];
196 196
     }
197 197
 
198 198
 
Please login to merge, or discard this patch.
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -17,229 +17,229 @@
 block discarded – undo
17 17
 class Benchmark
18 18
 {
19 19
 
20
-    /**
21
-     * array containing the start time for the timers
22
-     */
23
-    private static $start_times;
24
-
25
-    /**
26
-     * array containing all the timer'd times, which can be outputted via show_times()
27
-     */
28
-    private static $times = array();
29
-
30
-    /**
31
-     * @var array
32
-     */
33
-    protected static $memory_usage = array();
34
-
35
-
36
-
37
-    /**
38
-     * whether to benchmark code or not
39
-     */
40
-    public static function doNotRun()
41
-    {
42
-        return ! WP_DEBUG || (defined('DOING_AJAX') && DOING_AJAX);
43
-    }
44
-
45
-
46
-
47
-    /**
48
-     * resetTimes
49
-     */
50
-    public static function resetTimes()
51
-    {
52
-        Benchmark::$times = array();
53
-    }
54
-
55
-
56
-
57
-    /**
58
-     * Add Benchmark::startTimer() before a block of code you want to measure the performance of
59
-     *
60
-     * @param null $timer_name
61
-     */
62
-    public static function startTimer($timer_name = null)
63
-    {
64
-        if (Benchmark::doNotRun()) {
65
-            return;
66
-        }
67
-        $timer_name = $timer_name !== '' ? $timer_name : get_called_class();
68
-        Benchmark::$start_times[$timer_name] = microtime(true);
69
-    }
70
-
71
-
72
-
73
-    /**
74
-     * Add Benchmark::stopTimer() after a block of code you want to measure the performance of
75
-     *
76
-     * @param string $timer_name
77
-     */
78
-    public static function stopTimer($timer_name = '')
79
-    {
80
-        if (Benchmark::doNotRun()) {
81
-            return;
82
-        }
83
-        $timer_name = $timer_name !== '' ? $timer_name : get_called_class();
84
-        if (isset(Benchmark::$start_times[$timer_name])) {
85
-            $start_time = Benchmark::$start_times[$timer_name];
86
-            unset(Benchmark::$start_times[$timer_name]);
87
-        } else {
88
-            $start_time = array_pop(Benchmark::$start_times);
89
-        }
90
-        Benchmark::$times[$timer_name] = number_format(microtime(true) - $start_time, 8);
91
-    }
92
-
93
-
94
-
95
-    /**
96
-     * Measure the memory usage by PHP so far.
97
-     *
98
-     * @param string  $label      The label to show for this time eg "Start of calling Some_Class::some_function"
99
-     * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called
100
-     * @return void
101
-     */
102
-    public static function measureMemory($label, $output_now = false)
103
-    {
104
-        if (Benchmark::doNotRun()) {
105
-            return;
106
-        }
107
-        $memory_used = Benchmark::convert(memory_get_peak_usage(true));
108
-        Benchmark::$memory_usage[$label] = $memory_used;
109
-        if ($output_now) {
110
-            echo "\r\n<br>$label : $memory_used";
111
-        }
112
-    }
113
-
114
-
115
-
116
-    /**
117
-     * will display the benchmarking results at shutdown
118
-     *
119
-     * @return void
120
-     */
121
-    public static function displayResultsAtShutdown()
122
-    {
123
-        add_action(
124
-            'shutdown',
125
-            function () {
126
-                Benchmark::displayResults();
127
-            }
128
-        );
129
-    }
130
-
131
-
132
-
133
-    /**
134
-     * displayResults
135
-     *
136
-     * @param bool $echo
137
-     * @return string
138
-     */
139
-    public static function displayResults($echo = true)
140
-    {
141
-        if (Benchmark::doNotRun()) {
142
-            return '';
143
-        }
144
-        $output = '';
145
-        if (! empty(Benchmark::$times)) {
146
-            $total = 0;
147
-            $output .= '<span style="color:#999999; font-size:.8em;">( time in milliseconds )</span><br />';
148
-            foreach (Benchmark::$times as $timer_name => $total_time) {
149
-                $output .= Benchmark::formatTime($timer_name, $total_time) . '<br />';
150
-                $total += $total_time;
151
-            }
152
-            $output .= '<br />';
153
-            $output .= '<h4>TOTAL TIME</h4>';
154
-            $output .= Benchmark::formatTime('', $total);
155
-            $output .= '<span style="color:#999999; font-size:.8em;"> milliseconds</span><br />';
156
-            $output .= '<br />';
157
-            $output .= '<h5>Performance scale (from best to worse)</h5>';
158
-            $output .= '<span style="color:mediumpurple">Like wow! How about a Scooby snack?</span><br />';
159
-            $output .= '<span style="color:deepskyblue">Like...no way man!</span><br />';
160
-            $output .= '<span style="color:limegreen">Like...groovy!</span><br />';
161
-            $output .= '<span style="color:gold">Ruh Oh</span><br />';
162
-            $output .= '<span style="color:darkorange">Zoinks!</span><br />';
163
-            $output .= '<span style="color:red">Like...HEEELLLP</span><br />';
164
-        }
165
-        if (! empty(Benchmark::$memory_usage)) {
166
-            $output .= '<h5>Memory</h5>' . implode('<br />', Benchmark::$memory_usage);
167
-        }
168
-        if (empty($output)) {
169
-            return '';
170
-        }
171
-        $output = '<div style="border:1px solid #dddddd; background-color:#ffffff;'
172
-                  . (is_admin() ? ' margin:2em 2em 2em 180px;' : ' margin:2em;')
173
-                  . ' padding:2em;">'
174
-                  . '<h4>BENCHMARKING</h4>'
175
-                  . $output
176
-                  . '</div>';
177
-        if ($echo) {
178
-            echo $output;
179
-            return '';
180
-        }
181
-        return $output;
182
-    }
183
-
184
-
185
-
186
-    /**
187
-     * Converts a measure of memory bytes into the most logical units (eg kb, mb, etc)
188
-     *
189
-     * @param int $size
190
-     * @return string
191
-     */
192
-    public static function convert($size)
193
-    {
194
-        $unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb');
195
-        return round($size / pow(1024, $i = floor(log($size, 1024))), 2) . ' ' . $unit[absint($i)];
196
-    }
197
-
198
-
199
-
200
-    /**
201
-     * @param string $timer_name
202
-     * @param float  $total_time
203
-     * @return string
204
-     */
205
-    public static function formatTime($timer_name, $total_time)
206
-    {
207
-        $total_time *= 1000;
208
-        switch ($total_time) {
209
-            case $total_time > 12500 :
210
-                $color = 'red';
211
-                $bold = 'bold';
212
-                break;
213
-            case $total_time > 2500 :
214
-                $color = 'darkorange';
215
-                $bold = 'bold';
216
-                break;
217
-            case $total_time > 500 :
218
-                $color = 'gold';
219
-                $bold = 'bold';
220
-                break;
221
-            case $total_time > 100 :
222
-                $color = 'limegreen';
223
-                $bold = 'normal';
224
-                break;
225
-            case $total_time > 20 :
226
-                $color = 'deepskyblue';
227
-                $bold = 'normal';
228
-                break;
229
-            default :
230
-                $color = 'mediumpurple';
231
-                $bold = 'normal';
232
-                break;
233
-        }
234
-        return '<span style="min-width: 10px; margin:0 1em; color:'
235
-               . $color
236
-               . '; font-weight:'
237
-               . $bold
238
-               . '; font-size:1.2em;">'
239
-               . str_pad(number_format($total_time, 3), 9, '0', STR_PAD_LEFT)
240
-               . '</span> '
241
-               . $timer_name;
242
-    }
20
+	/**
21
+	 * array containing the start time for the timers
22
+	 */
23
+	private static $start_times;
24
+
25
+	/**
26
+	 * array containing all the timer'd times, which can be outputted via show_times()
27
+	 */
28
+	private static $times = array();
29
+
30
+	/**
31
+	 * @var array
32
+	 */
33
+	protected static $memory_usage = array();
34
+
35
+
36
+
37
+	/**
38
+	 * whether to benchmark code or not
39
+	 */
40
+	public static function doNotRun()
41
+	{
42
+		return ! WP_DEBUG || (defined('DOING_AJAX') && DOING_AJAX);
43
+	}
44
+
45
+
46
+
47
+	/**
48
+	 * resetTimes
49
+	 */
50
+	public static function resetTimes()
51
+	{
52
+		Benchmark::$times = array();
53
+	}
54
+
55
+
56
+
57
+	/**
58
+	 * Add Benchmark::startTimer() before a block of code you want to measure the performance of
59
+	 *
60
+	 * @param null $timer_name
61
+	 */
62
+	public static function startTimer($timer_name = null)
63
+	{
64
+		if (Benchmark::doNotRun()) {
65
+			return;
66
+		}
67
+		$timer_name = $timer_name !== '' ? $timer_name : get_called_class();
68
+		Benchmark::$start_times[$timer_name] = microtime(true);
69
+	}
70
+
71
+
72
+
73
+	/**
74
+	 * Add Benchmark::stopTimer() after a block of code you want to measure the performance of
75
+	 *
76
+	 * @param string $timer_name
77
+	 */
78
+	public static function stopTimer($timer_name = '')
79
+	{
80
+		if (Benchmark::doNotRun()) {
81
+			return;
82
+		}
83
+		$timer_name = $timer_name !== '' ? $timer_name : get_called_class();
84
+		if (isset(Benchmark::$start_times[$timer_name])) {
85
+			$start_time = Benchmark::$start_times[$timer_name];
86
+			unset(Benchmark::$start_times[$timer_name]);
87
+		} else {
88
+			$start_time = array_pop(Benchmark::$start_times);
89
+		}
90
+		Benchmark::$times[$timer_name] = number_format(microtime(true) - $start_time, 8);
91
+	}
92
+
93
+
94
+
95
+	/**
96
+	 * Measure the memory usage by PHP so far.
97
+	 *
98
+	 * @param string  $label      The label to show for this time eg "Start of calling Some_Class::some_function"
99
+	 * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called
100
+	 * @return void
101
+	 */
102
+	public static function measureMemory($label, $output_now = false)
103
+	{
104
+		if (Benchmark::doNotRun()) {
105
+			return;
106
+		}
107
+		$memory_used = Benchmark::convert(memory_get_peak_usage(true));
108
+		Benchmark::$memory_usage[$label] = $memory_used;
109
+		if ($output_now) {
110
+			echo "\r\n<br>$label : $memory_used";
111
+		}
112
+	}
113
+
114
+
115
+
116
+	/**
117
+	 * will display the benchmarking results at shutdown
118
+	 *
119
+	 * @return void
120
+	 */
121
+	public static function displayResultsAtShutdown()
122
+	{
123
+		add_action(
124
+			'shutdown',
125
+			function () {
126
+				Benchmark::displayResults();
127
+			}
128
+		);
129
+	}
130
+
131
+
132
+
133
+	/**
134
+	 * displayResults
135
+	 *
136
+	 * @param bool $echo
137
+	 * @return string
138
+	 */
139
+	public static function displayResults($echo = true)
140
+	{
141
+		if (Benchmark::doNotRun()) {
142
+			return '';
143
+		}
144
+		$output = '';
145
+		if (! empty(Benchmark::$times)) {
146
+			$total = 0;
147
+			$output .= '<span style="color:#999999; font-size:.8em;">( time in milliseconds )</span><br />';
148
+			foreach (Benchmark::$times as $timer_name => $total_time) {
149
+				$output .= Benchmark::formatTime($timer_name, $total_time) . '<br />';
150
+				$total += $total_time;
151
+			}
152
+			$output .= '<br />';
153
+			$output .= '<h4>TOTAL TIME</h4>';
154
+			$output .= Benchmark::formatTime('', $total);
155
+			$output .= '<span style="color:#999999; font-size:.8em;"> milliseconds</span><br />';
156
+			$output .= '<br />';
157
+			$output .= '<h5>Performance scale (from best to worse)</h5>';
158
+			$output .= '<span style="color:mediumpurple">Like wow! How about a Scooby snack?</span><br />';
159
+			$output .= '<span style="color:deepskyblue">Like...no way man!</span><br />';
160
+			$output .= '<span style="color:limegreen">Like...groovy!</span><br />';
161
+			$output .= '<span style="color:gold">Ruh Oh</span><br />';
162
+			$output .= '<span style="color:darkorange">Zoinks!</span><br />';
163
+			$output .= '<span style="color:red">Like...HEEELLLP</span><br />';
164
+		}
165
+		if (! empty(Benchmark::$memory_usage)) {
166
+			$output .= '<h5>Memory</h5>' . implode('<br />', Benchmark::$memory_usage);
167
+		}
168
+		if (empty($output)) {
169
+			return '';
170
+		}
171
+		$output = '<div style="border:1px solid #dddddd; background-color:#ffffff;'
172
+				  . (is_admin() ? ' margin:2em 2em 2em 180px;' : ' margin:2em;')
173
+				  . ' padding:2em;">'
174
+				  . '<h4>BENCHMARKING</h4>'
175
+				  . $output
176
+				  . '</div>';
177
+		if ($echo) {
178
+			echo $output;
179
+			return '';
180
+		}
181
+		return $output;
182
+	}
183
+
184
+
185
+
186
+	/**
187
+	 * Converts a measure of memory bytes into the most logical units (eg kb, mb, etc)
188
+	 *
189
+	 * @param int $size
190
+	 * @return string
191
+	 */
192
+	public static function convert($size)
193
+	{
194
+		$unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb');
195
+		return round($size / pow(1024, $i = floor(log($size, 1024))), 2) . ' ' . $unit[absint($i)];
196
+	}
197
+
198
+
199
+
200
+	/**
201
+	 * @param string $timer_name
202
+	 * @param float  $total_time
203
+	 * @return string
204
+	 */
205
+	public static function formatTime($timer_name, $total_time)
206
+	{
207
+		$total_time *= 1000;
208
+		switch ($total_time) {
209
+			case $total_time > 12500 :
210
+				$color = 'red';
211
+				$bold = 'bold';
212
+				break;
213
+			case $total_time > 2500 :
214
+				$color = 'darkorange';
215
+				$bold = 'bold';
216
+				break;
217
+			case $total_time > 500 :
218
+				$color = 'gold';
219
+				$bold = 'bold';
220
+				break;
221
+			case $total_time > 100 :
222
+				$color = 'limegreen';
223
+				$bold = 'normal';
224
+				break;
225
+			case $total_time > 20 :
226
+				$color = 'deepskyblue';
227
+				$bold = 'normal';
228
+				break;
229
+			default :
230
+				$color = 'mediumpurple';
231
+				$bold = 'normal';
232
+				break;
233
+		}
234
+		return '<span style="min-width: 10px; margin:0 1em; color:'
235
+			   . $color
236
+			   . '; font-weight:'
237
+			   . $bold
238
+			   . '; font-size:1.2em;">'
239
+			   . str_pad(number_format($total_time, 3), 9, '0', STR_PAD_LEFT)
240
+			   . '</span> '
241
+			   . $timer_name;
242
+	}
243 243
 
244 244
 
245 245
 
Please login to merge, or discard this patch.
acceptance_tests/Helpers/TicketSelector.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
     /**
16 16
      * Use to select a quantity from the first ticket for the given event (so this can be used on a event archive page).
17 17
      * @param int|string $event_id
18
-     * @param int|string $quantity
18
+     * @param integer $quantity
19 19
      */
20 20
     public function selectQuantityOfFirstTicketForEventId($event_id, $quantity = 1)
21 21
     {
Please login to merge, or discard this patch.
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -12,23 +12,23 @@
 block discarded – undo
12 12
 trait TicketSelector
13 13
 {
14 14
 
15
-    /**
16
-     * Use to select a quantity from the first ticket for the given event (so this can be used on a event archive page).
17
-     * @param int|string $event_id
18
-     * @param int|string $quantity
19
-     */
20
-    public function selectQuantityOfFirstTicketForEventId($event_id, $quantity = 1)
21
-    {
22
-        $this->actor()->selectOption(TicketSelectorElements::ticketOptionByEventIdSelector($event_id), $quantity);
23
-    }
15
+	/**
16
+	 * Use to select a quantity from the first ticket for the given event (so this can be used on a event archive page).
17
+	 * @param int|string $event_id
18
+	 * @param int|string $quantity
19
+	 */
20
+	public function selectQuantityOfFirstTicketForEventId($event_id, $quantity = 1)
21
+	{
22
+		$this->actor()->selectOption(TicketSelectorElements::ticketOptionByEventIdSelector($event_id), $quantity);
23
+	}
24 24
 
25 25
 
26
-    /**
27
-     * Used to submit the ticket selection for the given event id (so this can be used on an event archive page).
28
-     * @param int|string $event_id
29
-     */
30
-    public function submitTicketSelectionsForEventId($event_id)
31
-    {
32
-        $this->actor()->click(TicketSelectorElements::ticketSelectionSubmitSelectorByEventId($event_id));
33
-    }
26
+	/**
27
+	 * Used to submit the ticket selection for the given event id (so this can be used on an event archive page).
28
+	 * @param int|string $event_id
29
+	 */
30
+	public function submitTicketSelectionsForEventId($event_id)
31
+	{
32
+		$this->actor()->click(TicketSelectorElements::ticketSelectionSubmitSelectorByEventId($event_id));
33
+	}
34 34
 }
35 35
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/Helpers/Checkout.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -13,39 +13,39 @@
 block discarded – undo
13 13
  */
14 14
 trait Checkout
15 15
 {
16
-    /**
17
-     * @param     $value
18
-     * @param int $attendee_number
19
-     */
20
-    public function fillOutFirstNameFieldForAttendee($value, $attendee_number = 1)
21
-    {
22
-        $this->actor()->fillField(CheckoutPage::firstNameFieldSelectorForAttendeeNumber($attendee_number), $value);
23
-    }
24
-
25
-    /**
26
-     * @param     $value
27
-     * @param int $attendee_number
28
-     */
29
-    public function fillOutLastNameFieldForAttendee($value, $attendee_number = 1)
30
-    {
31
-        $this->actor()->fillField(CheckoutPage::lastNameFieldSelectorForAttendeeNumber($attendee_number), $value);
32
-    }
33
-
34
-    /**
35
-     * @param     $value
36
-     * @param int $attendee_number
37
-     */
38
-    public function fillOutEmailFieldForAttendee($value, $attendee_number = 1)
39
-    {
40
-        $this->actor()->fillField(CheckoutPage::emailFieldSelectorForAttendeeNumber($attendee_number), $value);
41
-    }
42
-
43
-
44
-    /**
45
-     * Clicks the next registration step button.
46
-     */
47
-    public function goToNextRegistrationStep()
48
-    {
49
-        $this->actor()->click(CheckoutPage::NEXT_STEP_BUTTON_SELECTOR);
50
-    }
16
+	/**
17
+	 * @param     $value
18
+	 * @param int $attendee_number
19
+	 */
20
+	public function fillOutFirstNameFieldForAttendee($value, $attendee_number = 1)
21
+	{
22
+		$this->actor()->fillField(CheckoutPage::firstNameFieldSelectorForAttendeeNumber($attendee_number), $value);
23
+	}
24
+
25
+	/**
26
+	 * @param     $value
27
+	 * @param int $attendee_number
28
+	 */
29
+	public function fillOutLastNameFieldForAttendee($value, $attendee_number = 1)
30
+	{
31
+		$this->actor()->fillField(CheckoutPage::lastNameFieldSelectorForAttendeeNumber($attendee_number), $value);
32
+	}
33
+
34
+	/**
35
+	 * @param     $value
36
+	 * @param int $attendee_number
37
+	 */
38
+	public function fillOutEmailFieldForAttendee($value, $attendee_number = 1)
39
+	{
40
+		$this->actor()->fillField(CheckoutPage::emailFieldSelectorForAttendeeNumber($attendee_number), $value);
41
+	}
42
+
43
+
44
+	/**
45
+	 * Clicks the next registration step button.
46
+	 */
47
+	public function goToNextRegistrationStep()
48
+	{
49
+		$this->actor()->click(CheckoutPage::NEXT_STEP_BUTTON_SELECTOR);
50
+	}
51 51
 }
52 52
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/Page/Checkout.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -13,48 +13,48 @@
 block discarded – undo
13 13
 class Checkout
14 14
 {
15 15
 
16
-    /**
17
-     * The class selector for the next step button in the checkout.
18
-     * @var string
19
-     */
20
-    const NEXT_STEP_BUTTON_SELECTOR = '.spco-next-step-btn';
21
-
22
-    /**
23
-     * @param int $attendee_number
24
-     * @return string
25
-     */
26
-    public static function firstNameFieldSelectorForAttendeeNumber($attendee_number = 1)
27
-    {
28
-        return self::fieldSelectorForAttendeeNumber('fname', $attendee_number);
29
-    }
30
-
31
-
32
-    /**
33
-     * @param int $attendee_number
34
-     * @return string
35
-     */
36
-    public static function lastNameFieldSelectorForAttendeeNumber($attendee_number = 1)
37
-    {
38
-        return self::fieldSelectorForAttendeeNumber('lname', $attendee_number);
39
-    }
40
-
41
-
42
-    /**
43
-     * @param int $attendee_number
44
-     * @return string
45
-     */
46
-    public static function emailFieldSelectorForAttendeeNumber($attendee_number = 1)
47
-    {
48
-        return self::fieldSelectorForAttendeeNumber('email', $attendee_number);
49
-    }
50
-
51
-    /**
52
-     * @param     $field_name
53
-     * @param int $attendee_number
54
-     * @return string
55
-     */
56
-    public static function fieldSelectorForAttendeeNumber($field_name, $attendee_number = 1)
57
-    {
58
-        return "//div[starts-with(@id, 'spco-attendee-panel-dv-$attendee_number')]//input[contains(@class, 'ee-reg-qstn-$field_name')]";
59
-    }
16
+	/**
17
+	 * The class selector for the next step button in the checkout.
18
+	 * @var string
19
+	 */
20
+	const NEXT_STEP_BUTTON_SELECTOR = '.spco-next-step-btn';
21
+
22
+	/**
23
+	 * @param int $attendee_number
24
+	 * @return string
25
+	 */
26
+	public static function firstNameFieldSelectorForAttendeeNumber($attendee_number = 1)
27
+	{
28
+		return self::fieldSelectorForAttendeeNumber('fname', $attendee_number);
29
+	}
30
+
31
+
32
+	/**
33
+	 * @param int $attendee_number
34
+	 * @return string
35
+	 */
36
+	public static function lastNameFieldSelectorForAttendeeNumber($attendee_number = 1)
37
+	{
38
+		return self::fieldSelectorForAttendeeNumber('lname', $attendee_number);
39
+	}
40
+
41
+
42
+	/**
43
+	 * @param int $attendee_number
44
+	 * @return string
45
+	 */
46
+	public static function emailFieldSelectorForAttendeeNumber($attendee_number = 1)
47
+	{
48
+		return self::fieldSelectorForAttendeeNumber('email', $attendee_number);
49
+	}
50
+
51
+	/**
52
+	 * @param     $field_name
53
+	 * @param int $attendee_number
54
+	 * @return string
55
+	 */
56
+	public static function fieldSelectorForAttendeeNumber($field_name, $attendee_number = 1)
57
+	{
58
+		return "//div[starts-with(@id, 'spco-attendee-panel-dv-$attendee_number')]//input[contains(@class, 'ee-reg-qstn-$field_name')]";
59
+	}
60 60
 }
Please login to merge, or discard this patch.
acceptance_tests/Page/MessagesAdmin.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -103,8 +103,8 @@
 block discarded – undo
103 103
     public static function editMessageTemplateClassByMessageType($message_type_slug, $context = '')
104 104
     {
105 105
         return $context
106
-            ? '.' . $message_type_slug . '-' . $context . '-edit-link'
107
-            : '.' . $message_type_slug . '-edit-link';
106
+            ? '.'.$message_type_slug.'-'.$context.'-edit-link'
107
+            : '.'.$message_type_slug.'-edit-link';
108 108
     }
109 109
 
110 110
 
Please login to merge, or discard this patch.
Indentation   +243 added lines, -243 removed lines patch added patch discarded remove patch
@@ -12,255 +12,255 @@
 block discarded – undo
12 12
 class MessagesAdmin extends CoreAdmin
13 13
 {
14 14
 
15
-    /**
16
-     * Context slug for the admin messages context.
17
-     * @var string
18
-     */
19
-    const ADMIN_CONTEXT_SLUG = 'admin';
15
+	/**
16
+	 * Context slug for the admin messages context.
17
+	 * @var string
18
+	 */
19
+	const ADMIN_CONTEXT_SLUG = 'admin';
20 20
 
21
-    /**
22
-     * Context slug for the primary attendee messages context
23
-     * @var string
24
-     */
25
-    const PRIMARY_ATTENDEE_CONTEXT_SLUG = 'primary_attendee';
21
+	/**
22
+	 * Context slug for the primary attendee messages context
23
+	 * @var string
24
+	 */
25
+	const PRIMARY_ATTENDEE_CONTEXT_SLUG = 'primary_attendee';
26 26
 
27 27
 
28
-    /**
29
-     * Status reference for the EEM_Message::status_sent status.
30
-     * @var string
31
-     */
32
-    const MESSAGE_STATUS_SENT = 'MSN';
28
+	/**
29
+	 * Status reference for the EEM_Message::status_sent status.
30
+	 * @var string
31
+	 */
32
+	const MESSAGE_STATUS_SENT = 'MSN';
33 33
 
34 34
 
35
-    /**
36
-     * Message type slug for the Payment Failed message type
37
-     */
38
-    const PAYMENT_FAILED_MESSAGE_TYPE_SLUG = 'payment_failed';
35
+	/**
36
+	 * Message type slug for the Payment Failed message type
37
+	 */
38
+	const PAYMENT_FAILED_MESSAGE_TYPE_SLUG = 'payment_failed';
39 39
 
40 40
 
41
-    /**
42
-     * Selector for the Global Messages "Send on same request" field in the Messages Settings tab.
43
-     * @var string
44
-     */
45
-    const GLOBAL_MESSAGES_SETTINGS_ON_REQUEST_SELECTION_SELECTOR =
46
-        '#global_messages_settings-do-messages-on-same-request';
47
-
41
+	/**
42
+	 * Selector for the Global Messages "Send on same request" field in the Messages Settings tab.
43
+	 * @var string
44
+	 */
45
+	const GLOBAL_MESSAGES_SETTINGS_ON_REQUEST_SELECTION_SELECTOR =
46
+		'#global_messages_settings-do-messages-on-same-request';
47
+
48 48
 
49
-    /**
50
-     * Selector for the Global Messages Settings submit button in the Messages Settings tab.
51
-     * @var string
52
-     */
53
-    const GLOBAL_MESSAGES_SETTINGS_SUBMIT_SELECTOR = '#global_messages_settings-update-settings-submit';
54
-
55
-
56
-    /**
57
-     * This is the container where active message types for a messenger are found/dragged to.
58
-     * @var string
59
-     */
60
-    const MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR = '#active-message-types';
61
-
62
-
63
-    /**
64
-     * Locator for the context switcher selector on the Message Template Editor page.
65
-     * @var string
66
-     */
67
-    const MESSAGES_CONTEXT_SWITCHER_SELECTOR = "//form[@id='ee-msg-context-switcher-frm']/select";
68
-
69
-
70
-    /**
71
-     * Locator for the context switcher submit button in the Message Template Editor page.
72
-     * @var string
73
-     */
74
-    const MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR = "#submit-msg-context-switcher-sbmt";
75
-
76
-
77
-    /**
78
-     * Locator for the dialog container used for housing viewed messages in the message activity list table.
79
-     * @var string
80
-     */
81
-    const MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR = '.ee-admin-dialog-container-inner-content';
82
-
83
-
84
-
85
-    /**
86
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
87
-     *                                  a string.
88
-     * @return string
89
-     */
90
-    public static function messageActivityListTableUrl($additional_params = '')
91
-    {
92
-        return self::adminUrl('espresso_messages', 'default', $additional_params);
93
-    }
94
-
95
-
96
-    /**
97
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
98
-     *                                  a string.
99
-     * @return string
100
-     */
101
-    public static function defaultMessageTemplateListTableUrl($additional_params = '')
102
-    {
103
-        return self::adminUrl('espresso_messages', 'global_mtps', $additional_params);
104
-    }
105
-
106
-
107
-    /**
108
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
109
-     *                                  a string.
110
-     * @return string
111
-     */
112
-    public static function customMessageTemplateListTableUrl($additional_params = '')
113
-    {
114
-        return self::adminUrl('espresso_messages', 'custom_mtps', $additional_params);
115
-    }
116
-
117
-
118
-    /**
119
-     * @return string
120
-     */
121
-    public static function messageSettingsUrl()
122
-    {
123
-        return self::adminUrl('espresso_messages', 'settings');
124
-    }
125
-
126
-
127
-
128
-    public static function draggableSettingsBoxSelectorForMessageTypeAndMessenger(
129
-        $message_type_slug,
130
-        $messenger_slug = 'email'
131
-    ) {
132
-        return "#$message_type_slug-messagetype-$messenger_slug";
133
-    }
134
-
135
-
136
-    /**
137
-     * @param string $message_type_slug
138
-     * @param string $context
139
-     * @return string
140
-     */
141
-    public static function editMessageTemplateClassByMessageType($message_type_slug, $context = '')
142
-    {
143
-        return $context
144
-            ? '.' . $message_type_slug . '-' . $context . '-edit-link'
145
-            : '.' . $message_type_slug . '-edit-link';
146
-    }
147
-
148
-
149
-    /**
150
-     * Selector for (a) specific table cell(s) in the Messages Activity list table for the given parameters.
151
-     *
152
-     * @param        $field
153
-     * @param        $message_type_label
154
-     * @param string $message_status
155
-     * @param string $messenger
156
-     * @param string $context
157
-     * @param string $table_cell_content_for_field
158
-     * @param int    $number_in_set   It's possible that the given parameters could match multiple items in the view.
159
-     *                                This allows you to indicate which item from the set to match.  If this is set to 0
160
-     *                                then all matches for the locator will be returned.
161
-     * @return string
162
-     */
163
-    public static function messagesActivityListTableCellSelectorFor(
164
-        $field,
165
-        $message_type_label,
166
-        $message_status = self::MESSAGE_STATUS_SENT,
167
-        $messenger = 'Email',
168
-        $context = 'Event Admin',
169
-        $table_cell_content_for_field = '',
170
-        $number_in_set = 1
171
-    ) {
172
-        $selector = $number_in_set > 0 ? '(' : '';
173
-        $selector .= "//tr[contains(@class, 'msg-status-$message_status')]"
174
-                     . "//td[contains(@class, 'message_type') and text()='$message_type_label']";
175
-        if ($messenger) {
176
-            $selector .= "/ancestor::tr/td[contains(@class, 'messenger') and text()='$messenger']";
177
-        }
178
-        $selector .= "/ancestor::tr/td[contains(@class, 'column-context') and text()='$context']";
179
-        $selector .= $table_cell_content_for_field
180
-            ? "/ancestor::tr/td[contains(@class, 'column-$field') and text()='$table_cell_content_for_field']"
181
-            : "/ancestor::tr/td[contains(@class, 'column-$field')]";
182
-        $selector .= $number_in_set > 0 ? ")[$number_in_set]" : '';
183
-        return $selector;
184
-    }
185
-
186
-
187
-    /**
188
-     * Selector for the Create Custom button found in the message template list table.
189
-     * @param string $message_type_label
190
-     * @param string $messenger_label
191
-     * @return string
192
-     */
193
-    public static function createCustomButtonForMessageTypeAndMessenger($message_type_label, $messenger_label)
194
-    {
195
-        $selector = "//tr/td[contains(@class, 'message_type') and text()='$message_type_label']"
196
-                    . "//ancestor::tr/td[contains(@class, 'messenger') and contains(., '$messenger_label')]"
197
-                    . "//ancestor::tr/td/a[@class='button button-small']";
198
-        return $selector;
199
-    }
200
-
201
-
202
-    /**
203
-     * Note, this could potentially match multiple buttons in the view so the selector is intentionally restricted to
204
-     * the FIRST match (which will be the latest message sent if the table is default sorted).
205
-     *
206
-     * @param string $message_type_label    The visible message type label for the row you want to match
207
-     * @param string $message_status        The status of the message for the row you want to match.
208
-     * @param string $messenger             The visible messenger label for the row you want to match.
209
-     * @param string $context               The visible context label for the row you want to match.
210
-     * @param int    $number_in_set         It's possible that the given parameters could match multiple items in the
211
-     *                                      view. This allows you to indicate which item from the set to match.
212
-     * @return string
213
-     */
214
-    public static function messagesActivityListTableViewButtonSelectorFor(
215
-        $message_type_label,
216
-        $message_status = self::MESSAGE_STATUS_SENT,
217
-        $messenger = 'Email',
218
-        $context = 'Event Admin',
219
-        $number_in_set = 1
220
-    ) {
221
-        $selector = self::messagesActivityListTableCellSelectorFor(
222
-            'action',
223
-            $message_type_label,
224
-            $message_status,
225
-            $messenger,
226
-            $context,
227
-            '',
228
-            $number_in_set
229
-        );
230
-        $selector .= "/a/span[contains(@class, 'ee-message-action-link-view')"
231
-                     . " and not(contains(@class, 'ee-message-action-link-view_transaction'))]";
232
-        return $selector;
233
-    }
234
-
235
-
236
-
237
-    /**
238
-     * Locator for the delete action link for a message item in the message activity list table.
239
-     * Note: The link is not visible by default, so the column would need hovered over for the link to appear.
240
-     * @param        $message_type_label
241
-     * @param string $message_status
242
-     * @param string $messenger
243
-     * @param string $context
244
-     * @param int    $number_in_set
245
-     * @return string
246
-     */
247
-    public static function messagesActivityListTableDeleteActionSelectorFor(
248
-        $message_type_label,
249
-        $message_status = self::MESSAGE_STATUS_SENT,
250
-        $messenger = 'Email',
251
-        $context = 'Event Admin',
252
-        $number_in_set = 1
253
-    ) {
254
-        $selector = self::messagesActivityListTableCellSelectorFor(
255
-            'to',
256
-            $message_type_label,
257
-            $message_status,
258
-            $messenger,
259
-            $context,
260
-            '',
261
-            $number_in_set
262
-        );
263
-        $selector .= "/div/span[@class='delete']/a";
264
-        return $selector;
265
-    }
49
+	/**
50
+	 * Selector for the Global Messages Settings submit button in the Messages Settings tab.
51
+	 * @var string
52
+	 */
53
+	const GLOBAL_MESSAGES_SETTINGS_SUBMIT_SELECTOR = '#global_messages_settings-update-settings-submit';
54
+
55
+
56
+	/**
57
+	 * This is the container where active message types for a messenger are found/dragged to.
58
+	 * @var string
59
+	 */
60
+	const MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR = '#active-message-types';
61
+
62
+
63
+	/**
64
+	 * Locator for the context switcher selector on the Message Template Editor page.
65
+	 * @var string
66
+	 */
67
+	const MESSAGES_CONTEXT_SWITCHER_SELECTOR = "//form[@id='ee-msg-context-switcher-frm']/select";
68
+
69
+
70
+	/**
71
+	 * Locator for the context switcher submit button in the Message Template Editor page.
72
+	 * @var string
73
+	 */
74
+	const MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR = "#submit-msg-context-switcher-sbmt";
75
+
76
+
77
+	/**
78
+	 * Locator for the dialog container used for housing viewed messages in the message activity list table.
79
+	 * @var string
80
+	 */
81
+	const MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR = '.ee-admin-dialog-container-inner-content';
82
+
83
+
84
+
85
+	/**
86
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
87
+	 *                                  a string.
88
+	 * @return string
89
+	 */
90
+	public static function messageActivityListTableUrl($additional_params = '')
91
+	{
92
+		return self::adminUrl('espresso_messages', 'default', $additional_params);
93
+	}
94
+
95
+
96
+	/**
97
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
98
+	 *                                  a string.
99
+	 * @return string
100
+	 */
101
+	public static function defaultMessageTemplateListTableUrl($additional_params = '')
102
+	{
103
+		return self::adminUrl('espresso_messages', 'global_mtps', $additional_params);
104
+	}
105
+
106
+
107
+	/**
108
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
109
+	 *                                  a string.
110
+	 * @return string
111
+	 */
112
+	public static function customMessageTemplateListTableUrl($additional_params = '')
113
+	{
114
+		return self::adminUrl('espresso_messages', 'custom_mtps', $additional_params);
115
+	}
116
+
117
+
118
+	/**
119
+	 * @return string
120
+	 */
121
+	public static function messageSettingsUrl()
122
+	{
123
+		return self::adminUrl('espresso_messages', 'settings');
124
+	}
125
+
126
+
127
+
128
+	public static function draggableSettingsBoxSelectorForMessageTypeAndMessenger(
129
+		$message_type_slug,
130
+		$messenger_slug = 'email'
131
+	) {
132
+		return "#$message_type_slug-messagetype-$messenger_slug";
133
+	}
134
+
135
+
136
+	/**
137
+	 * @param string $message_type_slug
138
+	 * @param string $context
139
+	 * @return string
140
+	 */
141
+	public static function editMessageTemplateClassByMessageType($message_type_slug, $context = '')
142
+	{
143
+		return $context
144
+			? '.' . $message_type_slug . '-' . $context . '-edit-link'
145
+			: '.' . $message_type_slug . '-edit-link';
146
+	}
147
+
148
+
149
+	/**
150
+	 * Selector for (a) specific table cell(s) in the Messages Activity list table for the given parameters.
151
+	 *
152
+	 * @param        $field
153
+	 * @param        $message_type_label
154
+	 * @param string $message_status
155
+	 * @param string $messenger
156
+	 * @param string $context
157
+	 * @param string $table_cell_content_for_field
158
+	 * @param int    $number_in_set   It's possible that the given parameters could match multiple items in the view.
159
+	 *                                This allows you to indicate which item from the set to match.  If this is set to 0
160
+	 *                                then all matches for the locator will be returned.
161
+	 * @return string
162
+	 */
163
+	public static function messagesActivityListTableCellSelectorFor(
164
+		$field,
165
+		$message_type_label,
166
+		$message_status = self::MESSAGE_STATUS_SENT,
167
+		$messenger = 'Email',
168
+		$context = 'Event Admin',
169
+		$table_cell_content_for_field = '',
170
+		$number_in_set = 1
171
+	) {
172
+		$selector = $number_in_set > 0 ? '(' : '';
173
+		$selector .= "//tr[contains(@class, 'msg-status-$message_status')]"
174
+					 . "//td[contains(@class, 'message_type') and text()='$message_type_label']";
175
+		if ($messenger) {
176
+			$selector .= "/ancestor::tr/td[contains(@class, 'messenger') and text()='$messenger']";
177
+		}
178
+		$selector .= "/ancestor::tr/td[contains(@class, 'column-context') and text()='$context']";
179
+		$selector .= $table_cell_content_for_field
180
+			? "/ancestor::tr/td[contains(@class, 'column-$field') and text()='$table_cell_content_for_field']"
181
+			: "/ancestor::tr/td[contains(@class, 'column-$field')]";
182
+		$selector .= $number_in_set > 0 ? ")[$number_in_set]" : '';
183
+		return $selector;
184
+	}
185
+
186
+
187
+	/**
188
+	 * Selector for the Create Custom button found in the message template list table.
189
+	 * @param string $message_type_label
190
+	 * @param string $messenger_label
191
+	 * @return string
192
+	 */
193
+	public static function createCustomButtonForMessageTypeAndMessenger($message_type_label, $messenger_label)
194
+	{
195
+		$selector = "//tr/td[contains(@class, 'message_type') and text()='$message_type_label']"
196
+					. "//ancestor::tr/td[contains(@class, 'messenger') and contains(., '$messenger_label')]"
197
+					. "//ancestor::tr/td/a[@class='button button-small']";
198
+		return $selector;
199
+	}
200
+
201
+
202
+	/**
203
+	 * Note, this could potentially match multiple buttons in the view so the selector is intentionally restricted to
204
+	 * the FIRST match (which will be the latest message sent if the table is default sorted).
205
+	 *
206
+	 * @param string $message_type_label    The visible message type label for the row you want to match
207
+	 * @param string $message_status        The status of the message for the row you want to match.
208
+	 * @param string $messenger             The visible messenger label for the row you want to match.
209
+	 * @param string $context               The visible context label for the row you want to match.
210
+	 * @param int    $number_in_set         It's possible that the given parameters could match multiple items in the
211
+	 *                                      view. This allows you to indicate which item from the set to match.
212
+	 * @return string
213
+	 */
214
+	public static function messagesActivityListTableViewButtonSelectorFor(
215
+		$message_type_label,
216
+		$message_status = self::MESSAGE_STATUS_SENT,
217
+		$messenger = 'Email',
218
+		$context = 'Event Admin',
219
+		$number_in_set = 1
220
+	) {
221
+		$selector = self::messagesActivityListTableCellSelectorFor(
222
+			'action',
223
+			$message_type_label,
224
+			$message_status,
225
+			$messenger,
226
+			$context,
227
+			'',
228
+			$number_in_set
229
+		);
230
+		$selector .= "/a/span[contains(@class, 'ee-message-action-link-view')"
231
+					 . " and not(contains(@class, 'ee-message-action-link-view_transaction'))]";
232
+		return $selector;
233
+	}
234
+
235
+
236
+
237
+	/**
238
+	 * Locator for the delete action link for a message item in the message activity list table.
239
+	 * Note: The link is not visible by default, so the column would need hovered over for the link to appear.
240
+	 * @param        $message_type_label
241
+	 * @param string $message_status
242
+	 * @param string $messenger
243
+	 * @param string $context
244
+	 * @param int    $number_in_set
245
+	 * @return string
246
+	 */
247
+	public static function messagesActivityListTableDeleteActionSelectorFor(
248
+		$message_type_label,
249
+		$message_status = self::MESSAGE_STATUS_SENT,
250
+		$messenger = 'Email',
251
+		$context = 'Event Admin',
252
+		$number_in_set = 1
253
+	) {
254
+		$selector = self::messagesActivityListTableCellSelectorFor(
255
+			'to',
256
+			$message_type_label,
257
+			$message_status,
258
+			$messenger,
259
+			$context,
260
+			'',
261
+			$number_in_set
262
+		);
263
+		$selector .= "/div/span[@class='delete']/a";
264
+		return $selector;
265
+	}
266 266
 }
267 267
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/Page/TicketSelector.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -12,24 +12,24 @@
 block discarded – undo
12 12
 class TicketSelector
13 13
 {
14 14
 
15
-    /**
16
-     * Return the selector for the ticket option select input for the given event id.
17
-     * @param int|string $event_id
18
-     * @return string
19
-     */
20
-    public static function ticketOptionByEventIdSelector($event_id)
21
-    {
22
-        return "//select[@id='ticket-selector-tbl-qty-slct-$event_id-1']";
23
-    }
15
+	/**
16
+	 * Return the selector for the ticket option select input for the given event id.
17
+	 * @param int|string $event_id
18
+	 * @return string
19
+	 */
20
+	public static function ticketOptionByEventIdSelector($event_id)
21
+	{
22
+		return "//select[@id='ticket-selector-tbl-qty-slct-$event_id-1']";
23
+	}
24 24
 
25 25
 
26
-    /**
27
-     * Return the selector for the submit button for the ticket selector for the given event id.
28
-     * @param int|string $event_id
29
-     * @return string
30
-     */
31
-    public static function ticketSelectionSubmitSelectorByEventId($event_id)
32
-    {
33
-        return "#ticket-selector-submit-$event_id-btn";
34
-    }
26
+	/**
27
+	 * Return the selector for the submit button for the ticket selector for the given event id.
28
+	 * @param int|string $event_id
29
+	 * @return string
30
+	 */
31
+	public static function ticketSelectionSubmitSelectorByEventId($event_id)
32
+	{
33
+		return "#ticket-selector-submit-$event_id-btn";
34
+	}
35 35
 }
36 36
\ No newline at end of file
Please login to merge, or discard this patch.
payment_methods/Invoice/EE_PMT_Invoice.pm.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
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
 /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * ------------------------------------------------------------------------
27 27
  */
28
-class EE_PMT_Invoice extends EE_PMT_Base{
28
+class EE_PMT_Invoice extends EE_PMT_Base {
29 29
 
30 30
 
31 31
 
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	public function __construct($pm_instance = NULL) {
38 38
 		$this->_pretty_name = esc_html__("Invoice", 'event_espresso');
39 39
 		$this->_default_description = sprintf(
40
-			esc_html__( 'After clicking "Finalize Registration", you will be given instructions on how to access your invoice and complete your payment.%sPlease note that event spaces will not be reserved until payment is received in full, and any remaining tickets could be sold to others in the meantime.', 'event_espresso' ),
40
+			esc_html__('After clicking "Finalize Registration", you will be given instructions on how to access your invoice and complete your payment.%sPlease note that event spaces will not be reserved until payment is received in full, and any remaining tickets could be sold to others in the meantime.', 'event_espresso'),
41 41
 			'<br />'
42 42
 		);
43 43
 		parent::__construct($pm_instance);
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * @param \EE_Transaction $transaction
52 52
 	 * @return NULL
53 53
 	 */
54
-	public function generate_new_billing_form( EE_Transaction $transaction = NULL ) {
54
+	public function generate_new_billing_form(EE_Transaction $transaction = NULL) {
55 55
 		return NULL;
56 56
 	}
57 57
 
@@ -64,53 +64,53 @@  discard block
 block discarded – undo
64 64
 	public function generate_new_settings_form() {
65 65
 		$pdf_payee_input_name = 'pdf_payee_name';
66 66
 		$confirmation_text_input_name = 'page_confirmation_text';
67
-		$form =  new EE_Payment_Method_Form(array(
67
+		$form = new EE_Payment_Method_Form(array(
68 68
 //				'payment_method_type' => $this,
69 69
 				'extra_meta_inputs'=>array(
70 70
 					$pdf_payee_input_name => new EE_Text_Input(array(
71
-						'html_label_text' => sprintf( esc_html__( 'Payee Name %s', 'event_espresso' ), $this->get_help_tab_link())
71
+						'html_label_text' => sprintf(esc_html__('Payee Name %s', 'event_espresso'), $this->get_help_tab_link())
72 72
 					)),
73 73
 					'pdf_payee_email' => new EE_Email_Input(array(
74
-						'html_label_text' => sprintf( esc_html__( 'Payee Email %s', 'event_espresso' ), $this->get_help_tab_link()),
74
+						'html_label_text' => sprintf(esc_html__('Payee Email %s', 'event_espresso'), $this->get_help_tab_link()),
75 75
 					)),
76 76
 					'pdf_payee_tax_number' => new EE_Text_Input(array(
77
-						'html_label_text' => sprintf( esc_html__( 'Payee Tax Number %s', 'event_espresso' ), $this->get_help_tab_link()),
77
+						'html_label_text' => sprintf(esc_html__('Payee Tax Number %s', 'event_espresso'), $this->get_help_tab_link()),
78 78
 						)),
79
-					'pdf_payee_address' => new EE_Text_Area_Input( array(
80
-						'html_label_text' => sprintf( esc_html__( 'Payee Address %s', 'event_espresso' ), $this->get_help_tab_link() ),
81
-						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
79
+					'pdf_payee_address' => new EE_Text_Area_Input(array(
80
+						'html_label_text' => sprintf(esc_html__('Payee Address %s', 'event_espresso'), $this->get_help_tab_link()),
81
+						'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
82 82
 					)),
83 83
 					'pdf_instructions'=>new EE_Text_Area_Input(array(
84
-						'html_label_text'=>  sprintf(esc_html__("Instructions %s", "event_espresso"),  $this->get_help_tab_link()),
84
+						'html_label_text'=>  sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
85 85
 						'default'=>  esc_html__("Please send this invoice with payment attached to the address above, or use the payment link below. Payment must be received within 48 hours of event date.", 'event_espresso'),
86
-						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
86
+						'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
87 87
 					)),
88 88
 					'pdf_logo_image'=>new EE_Admin_File_Uploader_Input(array(
89
-						'html_label_text'=>  sprintf(esc_html__("Logo Image %s", "event_espresso"),  $this->get_help_tab_link()),
89
+						'html_label_text'=>  sprintf(esc_html__("Logo Image %s", "event_espresso"), $this->get_help_tab_link()),
90 90
 						'default'=>  EE_Config::instance()->organization->logo_url,
91 91
 						'html_help_text'=>  esc_html__("(Logo for the top left of the invoice)", 'event_espresso'),
92 92
 					)),
93 93
 					$confirmation_text_input_name =>new EE_Text_Area_Input(array(
94
-						'html_label_text'=>  sprintf(esc_html__("Confirmation Text %s", "event_espresso"),  $this->get_help_tab_link()),
94
+						'html_label_text'=>  sprintf(esc_html__("Confirmation Text %s", "event_espresso"), $this->get_help_tab_link()),
95 95
 						'default'=>  esc_html__("Payment must be received within 48 hours of event date. Details about where to send the payment are included on the invoice.", 'event_espresso'), 
96
-						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
96
+						'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
97 97
 					)),
98 98
 					'page_extra_info'=>new EE_Text_Area_Input(array(
99
-						'html_label_text'=>  sprintf(esc_html__("Extra Info %s", "event_espresso"),  $this->get_help_tab_link()),
100
-						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
99
+						'html_label_text'=>  sprintf(esc_html__("Extra Info %s", "event_espresso"), $this->get_help_tab_link()),
100
+						'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
101 101
 					)),
102 102
 				),
103 103
 				'include'=>array(
104
-					'PMD_ID', 'PMD_name','PMD_desc','PMD_admin_name','PMD_admin_desc', 'PMD_type','PMD_slug', 'PMD_open_by_default','PMD_button_url','PMD_scope','Currency','PMD_order',
105
-					$pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions','pdf_logo_image',
104
+					'PMD_ID', 'PMD_name', 'PMD_desc', 'PMD_admin_name', 'PMD_admin_desc', 'PMD_type', 'PMD_slug', 'PMD_open_by_default', 'PMD_button_url', 'PMD_scope', 'Currency', 'PMD_order',
105
+					$pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions', 'pdf_logo_image',
106 106
 					$confirmation_text_input_name, 'page_extra_info'),
107 107
 			));
108 108
 		$form->add_subsections(
109
-			array( 'header1' => new EE_Form_Section_HTML_From_Template( 'payment_methods/Invoice/templates/invoice_settings_header_display.template.php' )),
109
+			array('header1' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_display.template.php')),
110 110
 			$pdf_payee_input_name
111 111
 		);
112 112
 		$form->add_subsections(
113
-			array( 'header2'=>new EE_Form_Section_HTML_From_Template( 'payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php' )),
113
+			array('header2'=>new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php')),
114 114
 			$confirmation_text_input_name
115 115
 		);
116 116
 		return $form;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	 * @see EE_PMT_Base::help_tabs_config()
124 124
 	 * @return array
125 125
 	 */
126
-	public function help_tabs_config(){
126
+	public function help_tabs_config() {
127 127
 		return array(
128 128
 			$this->get_help_tab_name() => array(
129 129
 				'title' => esc_html__('Invoice Settings', 'event_espresso'),
@@ -141,16 +141,16 @@  discard block
 block discarded – undo
141 141
 	 * @param \EE_Payment $payment
142 142
 	 * @return string
143 143
 	 */
144
-	public function payment_overview_content( EE_Payment $payment ){
144
+	public function payment_overview_content(EE_Payment $payment) {
145 145
 		return EEH_Template::locate_template(
146
-			'payment_methods' . DS . 'Invoice'. DS . 'templates'.DS.'invoice_payment_details_content.template.php',
146
+			'payment_methods'.DS.'Invoice'.DS.'templates'.DS.'invoice_payment_details_content.template.php',
147 147
 			array_merge(
148 148
 				array(
149 149
 					'payment_method'			=> $this->_pm_instance,
150 150
 					'payment'						=> $payment,
151 151
 					'page_confirmation_text'					=> '',
152 152
 					'page_extra_info'	=> '',
153
-					'invoice_url' 					=> $payment->transaction()->primary_registration()->invoice_url( 'html' )
153
+					'invoice_url' 					=> $payment->transaction()->primary_registration()->invoice_url('html')
154 154
 				),
155 155
 				$this->_pm_instance->all_extra_meta_array()
156 156
 			)
Please login to merge, or discard this patch.
core/services/assets/Registry.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
         global $wp_version;
72 72
         wp_register_script(
73 73
             'eejs-core',
74
-            EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js',
74
+            EE_PLUGIN_DIR_URL.'core/services/assets/core_assets/eejs-core.js',
75 75
             array(),
76 76
             EVENT_ESPRESSO_VERSION,
77 77
             true
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
             //js.api
82 82
             wp_register_script(
83 83
                 'eejs-api',
84
-                EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
84
+                EE_LIBRARIES_URL.'rest_api/assets/js/eejs-api.min.js',
85 85
                 array('underscore', 'eejs-core'),
86 86
                 EVENT_ESPRESSO_VERSION,
87 87
                 true
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
             $this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest');
90 90
             $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/'));
91 91
         }
92
-        if (! is_admin()) {
92
+        if ( ! is_admin()) {
93 93
             $this->loadCoreCss();
94 94
         }
95 95
         $this->loadCoreJs();
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
      */
183 183
     public function addTemplate($template_reference, $template_content)
184 184
     {
185
-        if (! isset($this->jsdata['templates'])) {
185
+        if ( ! isset($this->jsdata['templates'])) {
186 186
             $this->jsdata['templates'] = array();
187 187
         }
188 188
         //no overrides allowed.
@@ -279,9 +279,9 @@  discard block
 block discarded – undo
279 279
     private function loadCoreCss()
280 280
     {
281 281
         if ($this->template_config->enable_default_style) {
282
-            $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
283
-                ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
284
-                : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css';
282
+            $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css')
283
+                ? EVENT_ESPRESSO_UPLOAD_DIR.'css/espresso_default.css'
284
+                : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css';
285 285
             wp_register_style(
286 286
                 'espresso_default',
287 287
                 $default_stylesheet_path,
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
             if ($this->template_config->custom_style_sheet !== null) {
293 293
                 wp_register_style(
294 294
                     'espresso_custom_css',
295
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
295
+                    EVENT_ESPRESSO_UPLOAD_URL.'css/'.$this->template_config->custom_style_sheet,
296 296
                     array('espresso_default'),
297 297
                     EVENT_ESPRESSO_VERSION
298 298
                 );
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
         // load core js
311 311
         wp_register_script(
312 312
             'espresso_core',
313
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
313
+            EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js',
314 314
             array('jquery'),
315 315
             EVENT_ESPRESSO_VERSION,
316 316
             true
@@ -328,14 +328,14 @@  discard block
 block discarded – undo
328 328
         // register jQuery Validate and additional methods
329 329
         wp_register_script(
330 330
             'jquery-validate',
331
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
331
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js',
332 332
             array('jquery'),
333 333
             '1.15.0',
334 334
             true
335 335
         );
336 336
         wp_register_script(
337 337
             'jquery-validate-extra-methods',
338
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
338
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js',
339 339
             array('jquery', 'jquery-validate'),
340 340
             '1.15.0',
341 341
             true
@@ -353,14 +353,14 @@  discard block
 block discarded – undo
353 353
         // @link http://josscrowcroft.github.io/accounting.js/
354 354
         wp_register_script(
355 355
             'ee-accounting-core',
356
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
356
+            EE_THIRD_PARTY_URL.'accounting/accounting.js',
357 357
             array('underscore'),
358 358
             '0.3.2',
359 359
             true
360 360
         );
361 361
         wp_register_script(
362 362
             'ee-accounting',
363
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
363
+            EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js',
364 364
             array('ee-accounting-core'),
365 365
             EVENT_ESPRESSO_VERSION,
366 366
             true
Please login to merge, or discard this patch.
Indentation   +386 added lines, -386 removed lines patch added patch discarded remove patch
@@ -23,396 +23,396 @@
 block discarded – undo
23 23
 class Registry
24 24
 {
25 25
 
26
-    /**
27
-     * @var EE_Template_Config $template_config
28
-     */
29
-    protected $template_config;
30
-
31
-    /**
32
-     * @var EE_Currency_Config $currency_config
33
-     */
34
-    protected $currency_config;
35
-
36
-    /**
37
-     * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
38
-     *
39
-     * @var array
40
-     */
41
-    protected $jsdata = array();
42
-
43
-
44
-
45
-    /**
46
-     * Registry constructor.
47
-     * Hooking into WP actions for script registry.
48
-     *
49
-     * @param EE_Template_Config $template_config
50
-     * @param EE_Currency_Config $currency_config
51
-     */
52
-    public function __construct(EE_Template_Config $template_config, EE_Currency_Config $currency_config)
53
-    {
54
-        $this->template_config = $template_config;
55
-        $this->currency_config = $currency_config;
56
-        add_action('wp_enqueue_scripts', array($this, 'scripts'), 1);
57
-        add_action('admin_enqueue_scripts', array($this, 'scripts'), 1);
58
-        add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 2);
59
-        add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 2);
60
-        add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
61
-        add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
62
-    }
63
-
64
-
65
-
66
-    /**
67
-     * Callback for the WP script actions.
68
-     * Used to register globally accessible core scripts.
69
-     * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency.
70
-     */
71
-    public function scripts()
72
-    {
73
-        global $wp_version;
74
-        wp_register_script(
75
-            'eejs-core',
76
-            EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js',
77
-            array(),
78
-            EVENT_ESPRESSO_VERSION,
79
-            true
80
-        );
81
-        //only run this if WordPress 4.4.0 > is in use.
82
-        if (version_compare($wp_version, '4.4.0', '>')) {
83
-            //js.api
84
-            wp_register_script(
85
-                'eejs-api',
86
-                EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
87
-                array('underscore', 'eejs-core'),
88
-                EVENT_ESPRESSO_VERSION,
89
-                true
90
-            );
91
-            $this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest');
92
-            $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/'));
93
-        }
94
-        if (! is_admin()) {
95
-            $this->loadCoreCss();
96
-        }
97
-        $this->loadCoreJs();
98
-        $this->loadJqueryValidate();
99
-        $this->loadAccountingJs();
100
-        $this->loadQtipJs();
101
-    }
102
-
103
-
104
-
105
-    /**
106
-     * Call back for the script print in frontend and backend.
107
-     * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
108
-     *
109
-     * @since 4.9.31.rc.015
110
-     */
111
-    public function enqueueData()
112
-    {
113
-        wp_localize_script('eejs-core', 'eejs', array('data' => $this->jsdata));
114
-        wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
115
-        $this->localizeAccountingJs();
116
-    }
117
-
118
-
119
-
120
-    /**
121
-     * Used to add data to eejs.data object.
122
-     * Note:  Overriding existing data is not allowed.
123
-     * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
124
-     * If the data you add is something like this:
125
-     *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
126
-     * It will be exposed in the page source as:
127
-     *  eejs.data.my_plugin_data.foo == gar
128
-     *
129
-     * @param string       $key   Key used to access your data
130
-     * @param string|array $value Value to attach to key
131
-     * @throws InvalidArgumentException
132
-     */
133
-    public function addData($key, $value)
134
-    {
135
-        if ($this->verifyDataNotExisting($key)) {
136
-            $this->jsdata[$key] = $value;
137
-        }
138
-    }
139
-
140
-
141
-
142
-    /**
143
-     * Similar to addData except this allows for users to push values to an existing key where the values on key are
144
-     * elements in an array.
145
-     * When you use this method, the value you include will be appended to the end of an array on $key.
146
-     * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript
147
-     * object like this, eejs.data.test = [ my_data,
148
-     * ]
149
-     * If there has already been a scalar value attached to the data object given key, then
150
-     * this will throw an exception.
151
-     *
152
-     * @param string       $key   Key to attach data to.
153
-     * @param string|array $value Value being registered.
154
-     * @throws InvalidArgumentException
155
-     */
156
-    public function pushData($key, $value)
157
-    {
158
-        if (isset($this->jsdata[$key])
159
-            && ! is_array($this->jsdata[$key])
160
-        ) {
161
-            throw new invalidArgumentException(
162
-                sprintf(
163
-                    __(
164
-                        'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
26
+	/**
27
+	 * @var EE_Template_Config $template_config
28
+	 */
29
+	protected $template_config;
30
+
31
+	/**
32
+	 * @var EE_Currency_Config $currency_config
33
+	 */
34
+	protected $currency_config;
35
+
36
+	/**
37
+	 * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
38
+	 *
39
+	 * @var array
40
+	 */
41
+	protected $jsdata = array();
42
+
43
+
44
+
45
+	/**
46
+	 * Registry constructor.
47
+	 * Hooking into WP actions for script registry.
48
+	 *
49
+	 * @param EE_Template_Config $template_config
50
+	 * @param EE_Currency_Config $currency_config
51
+	 */
52
+	public function __construct(EE_Template_Config $template_config, EE_Currency_Config $currency_config)
53
+	{
54
+		$this->template_config = $template_config;
55
+		$this->currency_config = $currency_config;
56
+		add_action('wp_enqueue_scripts', array($this, 'scripts'), 1);
57
+		add_action('admin_enqueue_scripts', array($this, 'scripts'), 1);
58
+		add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 2);
59
+		add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 2);
60
+		add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
61
+		add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
62
+	}
63
+
64
+
65
+
66
+	/**
67
+	 * Callback for the WP script actions.
68
+	 * Used to register globally accessible core scripts.
69
+	 * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency.
70
+	 */
71
+	public function scripts()
72
+	{
73
+		global $wp_version;
74
+		wp_register_script(
75
+			'eejs-core',
76
+			EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js',
77
+			array(),
78
+			EVENT_ESPRESSO_VERSION,
79
+			true
80
+		);
81
+		//only run this if WordPress 4.4.0 > is in use.
82
+		if (version_compare($wp_version, '4.4.0', '>')) {
83
+			//js.api
84
+			wp_register_script(
85
+				'eejs-api',
86
+				EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
87
+				array('underscore', 'eejs-core'),
88
+				EVENT_ESPRESSO_VERSION,
89
+				true
90
+			);
91
+			$this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest');
92
+			$this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/'));
93
+		}
94
+		if (! is_admin()) {
95
+			$this->loadCoreCss();
96
+		}
97
+		$this->loadCoreJs();
98
+		$this->loadJqueryValidate();
99
+		$this->loadAccountingJs();
100
+		$this->loadQtipJs();
101
+	}
102
+
103
+
104
+
105
+	/**
106
+	 * Call back for the script print in frontend and backend.
107
+	 * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
108
+	 *
109
+	 * @since 4.9.31.rc.015
110
+	 */
111
+	public function enqueueData()
112
+	{
113
+		wp_localize_script('eejs-core', 'eejs', array('data' => $this->jsdata));
114
+		wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
115
+		$this->localizeAccountingJs();
116
+	}
117
+
118
+
119
+
120
+	/**
121
+	 * Used to add data to eejs.data object.
122
+	 * Note:  Overriding existing data is not allowed.
123
+	 * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
124
+	 * If the data you add is something like this:
125
+	 *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
126
+	 * It will be exposed in the page source as:
127
+	 *  eejs.data.my_plugin_data.foo == gar
128
+	 *
129
+	 * @param string       $key   Key used to access your data
130
+	 * @param string|array $value Value to attach to key
131
+	 * @throws InvalidArgumentException
132
+	 */
133
+	public function addData($key, $value)
134
+	{
135
+		if ($this->verifyDataNotExisting($key)) {
136
+			$this->jsdata[$key] = $value;
137
+		}
138
+	}
139
+
140
+
141
+
142
+	/**
143
+	 * Similar to addData except this allows for users to push values to an existing key where the values on key are
144
+	 * elements in an array.
145
+	 * When you use this method, the value you include will be appended to the end of an array on $key.
146
+	 * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript
147
+	 * object like this, eejs.data.test = [ my_data,
148
+	 * ]
149
+	 * If there has already been a scalar value attached to the data object given key, then
150
+	 * this will throw an exception.
151
+	 *
152
+	 * @param string       $key   Key to attach data to.
153
+	 * @param string|array $value Value being registered.
154
+	 * @throws InvalidArgumentException
155
+	 */
156
+	public function pushData($key, $value)
157
+	{
158
+		if (isset($this->jsdata[$key])
159
+			&& ! is_array($this->jsdata[$key])
160
+		) {
161
+			throw new invalidArgumentException(
162
+				sprintf(
163
+					__(
164
+						'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
165 165
                          push values to this data element when it is an array.',
166
-                        'event_espresso'
167
-                    ),
168
-                    $key,
169
-                    __METHOD__
170
-                )
171
-            );
172
-        }
173
-        $this->jsdata[$key][] = $value;
174
-    }
175
-
176
-
177
-
178
-    /**
179
-     * Used to set content used by javascript for a template.
180
-     * Note: Overrides of existing registered templates are not allowed.
181
-     *
182
-     * @param string $template_reference
183
-     * @param string $template_content
184
-     * @throws InvalidArgumentException
185
-     */
186
-    public function addTemplate($template_reference, $template_content)
187
-    {
188
-        if (! isset($this->jsdata['templates'])) {
189
-            $this->jsdata['templates'] = array();
190
-        }
191
-        //no overrides allowed.
192
-        if (isset($this->jsdata['templates'][$template_reference])) {
193
-            throw new invalidArgumentException(
194
-                sprintf(
195
-                    __(
196
-                        'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
197
-                        'event_espresso'
198
-                    ),
199
-                    $template_reference
200
-                )
201
-            );
202
-        }
203
-        $this->jsdata['templates'][$template_reference] = $template_content;
204
-    }
205
-
206
-
207
-
208
-    /**
209
-     * Retrieve the template content already registered for the given reference.
210
-     *
211
-     * @param string $template_reference
212
-     * @return string
213
-     */
214
-    public function getTemplate($template_reference)
215
-    {
216
-        return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference])
217
-            ? $this->jsdata['templates'][$template_reference]
218
-            : '';
219
-    }
220
-
221
-
222
-
223
-    /**
224
-     * Retrieve registered data.
225
-     *
226
-     * @param string $key Name of key to attach data to.
227
-     * @return mixed                If there is no for the given key, then false is returned.
228
-     */
229
-    public function getData($key)
230
-    {
231
-        return isset($this->jsdata[$key])
232
-            ? $this->jsdata[$key]
233
-            : false;
234
-    }
235
-
236
-
237
-
238
-    /**
239
-     * Verifies whether the given data exists already on the jsdata array.
240
-     * Overriding data is not allowed.
241
-     *
242
-     * @param string $key Index for data.
243
-     * @return bool        If valid then return true.
244
-     * @throws InvalidArgumentException if data already exists.
245
-     */
246
-    protected function verifyDataNotExisting($key)
247
-    {
248
-        if (isset($this->jsdata[$key])) {
249
-            if (is_array($this->jsdata[$key])) {
250
-                throw new InvalidArgumentException(
251
-                    sprintf(
252
-                        __(
253
-                            'The value for %1$s already exists in the Registry::eejs object.
166
+						'event_espresso'
167
+					),
168
+					$key,
169
+					__METHOD__
170
+				)
171
+			);
172
+		}
173
+		$this->jsdata[$key][] = $value;
174
+	}
175
+
176
+
177
+
178
+	/**
179
+	 * Used to set content used by javascript for a template.
180
+	 * Note: Overrides of existing registered templates are not allowed.
181
+	 *
182
+	 * @param string $template_reference
183
+	 * @param string $template_content
184
+	 * @throws InvalidArgumentException
185
+	 */
186
+	public function addTemplate($template_reference, $template_content)
187
+	{
188
+		if (! isset($this->jsdata['templates'])) {
189
+			$this->jsdata['templates'] = array();
190
+		}
191
+		//no overrides allowed.
192
+		if (isset($this->jsdata['templates'][$template_reference])) {
193
+			throw new invalidArgumentException(
194
+				sprintf(
195
+					__(
196
+						'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
197
+						'event_espresso'
198
+					),
199
+					$template_reference
200
+				)
201
+			);
202
+		}
203
+		$this->jsdata['templates'][$template_reference] = $template_content;
204
+	}
205
+
206
+
207
+
208
+	/**
209
+	 * Retrieve the template content already registered for the given reference.
210
+	 *
211
+	 * @param string $template_reference
212
+	 * @return string
213
+	 */
214
+	public function getTemplate($template_reference)
215
+	{
216
+		return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference])
217
+			? $this->jsdata['templates'][$template_reference]
218
+			: '';
219
+	}
220
+
221
+
222
+
223
+	/**
224
+	 * Retrieve registered data.
225
+	 *
226
+	 * @param string $key Name of key to attach data to.
227
+	 * @return mixed                If there is no for the given key, then false is returned.
228
+	 */
229
+	public function getData($key)
230
+	{
231
+		return isset($this->jsdata[$key])
232
+			? $this->jsdata[$key]
233
+			: false;
234
+	}
235
+
236
+
237
+
238
+	/**
239
+	 * Verifies whether the given data exists already on the jsdata array.
240
+	 * Overriding data is not allowed.
241
+	 *
242
+	 * @param string $key Index for data.
243
+	 * @return bool        If valid then return true.
244
+	 * @throws InvalidArgumentException if data already exists.
245
+	 */
246
+	protected function verifyDataNotExisting($key)
247
+	{
248
+		if (isset($this->jsdata[$key])) {
249
+			if (is_array($this->jsdata[$key])) {
250
+				throw new InvalidArgumentException(
251
+					sprintf(
252
+						__(
253
+							'The value for %1$s already exists in the Registry::eejs object.
254 254
                             Overrides are not allowed. Since the value of this data is an array, you may want to use the
255 255
                             %2$s method to push your value to the array.',
256
-                            'event_espresso'
257
-                        ),
258
-                        $key,
259
-                        'pushData()'
260
-                    )
261
-                );
262
-            }
263
-            throw new InvalidArgumentException(
264
-                sprintf(
265
-                    __(
266
-                        'The value for %1$s already exists in the Registry::eejs object. Overrides are not
256
+							'event_espresso'
257
+						),
258
+						$key,
259
+						'pushData()'
260
+					)
261
+				);
262
+			}
263
+			throw new InvalidArgumentException(
264
+				sprintf(
265
+					__(
266
+						'The value for %1$s already exists in the Registry::eejs object. Overrides are not
267 267
                         allowed.  Consider attaching your value to a different key',
268
-                        'event_espresso'
269
-                    ),
270
-                    $key
271
-                )
272
-            );
273
-        }
274
-        return true;
275
-    }
276
-
277
-
278
-
279
-    /**
280
-     * registers core default stylesheets
281
-     */
282
-    private function loadCoreCss()
283
-    {
284
-        if ($this->template_config->enable_default_style) {
285
-            $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
286
-                ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
287
-                : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css';
288
-            wp_register_style(
289
-                'espresso_default',
290
-                $default_stylesheet_path,
291
-                array('dashicons'),
292
-                EVENT_ESPRESSO_VERSION
293
-            );
294
-            //Load custom style sheet if available
295
-            if ($this->template_config->custom_style_sheet !== null) {
296
-                wp_register_style(
297
-                    'espresso_custom_css',
298
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
299
-                    array('espresso_default'),
300
-                    EVENT_ESPRESSO_VERSION
301
-                );
302
-            }
303
-        }
304
-    }
305
-
306
-
307
-
308
-    /**
309
-     * registers core default javascript
310
-     */
311
-    private function loadCoreJs()
312
-    {
313
-        // load core js
314
-        wp_register_script(
315
-            'espresso_core',
316
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
317
-            array('jquery'),
318
-            EVENT_ESPRESSO_VERSION,
319
-            true
320
-        );
321
-    }
322
-
323
-
324
-
325
-    /**
326
-     * registers jQuery Validate for form validation
327
-     */
328
-    private function loadJqueryValidate()
329
-    {
330
-        // register jQuery Validate and additional methods
331
-        wp_register_script(
332
-            'jquery-validate',
333
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
334
-            array('jquery'),
335
-            '1.15.0',
336
-            true
337
-        );
338
-        wp_register_script(
339
-            'jquery-validate-extra-methods',
340
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
341
-            array('jquery', 'jquery-validate'),
342
-            '1.15.0',
343
-            true
344
-        );
345
-    }
346
-
347
-
348
-
349
-    /**
350
-     * registers accounting.js for performing client-side calculations
351
-     */
352
-    private function loadAccountingJs()
353
-    {
354
-        //accounting.js library
355
-        // @link http://josscrowcroft.github.io/accounting.js/
356
-        wp_register_script(
357
-            'ee-accounting-core',
358
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
359
-            array('underscore'),
360
-            '0.3.2',
361
-            true
362
-        );
363
-        wp_register_script(
364
-            'ee-accounting',
365
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
366
-            array('ee-accounting-core'),
367
-            EVENT_ESPRESSO_VERSION,
368
-            true
369
-        );
370
-    }
371
-
372
-
373
-
374
-    /**
375
-     * registers accounting.js for performing client-side calculations
376
-     */
377
-    private function localizeAccountingJs()
378
-    {
379
-        wp_localize_script(
380
-            'ee-accounting',
381
-            'EE_ACCOUNTING_CFG',
382
-            array(
383
-                'currency' => array(
384
-                    'symbol'    => $this->currency_config->sign,
385
-                    'format'    => array(
386
-                        'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
387
-                        'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
388
-                        'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
389
-                    ),
390
-                    'decimal'   => $this->currency_config->dec_mrk,
391
-                    'thousand'  => $this->currency_config->thsnds,
392
-                    'precision' => $this->currency_config->dec_plc,
393
-                ),
394
-                'number'   => array(
395
-                    'precision' => 0,
396
-                    'thousand'  => $this->currency_config->thsnds,
397
-                    'decimal'   => $this->currency_config->dec_mrk,
398
-                ),
399
-            )
400
-        );
401
-    }
402
-
403
-
404
-
405
-    /**
406
-     * registers assets for cleaning your ears
407
-     */
408
-    private function loadQtipJs()
409
-    {
410
-        // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
411
-        // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
412
-        if (apply_filters('FHEE_load_qtip', false)) {
413
-            EEH_Qtip_Loader::instance()->register_and_enqueue();
414
-        }
415
-    }
268
+						'event_espresso'
269
+					),
270
+					$key
271
+				)
272
+			);
273
+		}
274
+		return true;
275
+	}
276
+
277
+
278
+
279
+	/**
280
+	 * registers core default stylesheets
281
+	 */
282
+	private function loadCoreCss()
283
+	{
284
+		if ($this->template_config->enable_default_style) {
285
+			$default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
286
+				? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
287
+				: EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css';
288
+			wp_register_style(
289
+				'espresso_default',
290
+				$default_stylesheet_path,
291
+				array('dashicons'),
292
+				EVENT_ESPRESSO_VERSION
293
+			);
294
+			//Load custom style sheet if available
295
+			if ($this->template_config->custom_style_sheet !== null) {
296
+				wp_register_style(
297
+					'espresso_custom_css',
298
+					EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
299
+					array('espresso_default'),
300
+					EVENT_ESPRESSO_VERSION
301
+				);
302
+			}
303
+		}
304
+	}
305
+
306
+
307
+
308
+	/**
309
+	 * registers core default javascript
310
+	 */
311
+	private function loadCoreJs()
312
+	{
313
+		// load core js
314
+		wp_register_script(
315
+			'espresso_core',
316
+			EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
317
+			array('jquery'),
318
+			EVENT_ESPRESSO_VERSION,
319
+			true
320
+		);
321
+	}
322
+
323
+
324
+
325
+	/**
326
+	 * registers jQuery Validate for form validation
327
+	 */
328
+	private function loadJqueryValidate()
329
+	{
330
+		// register jQuery Validate and additional methods
331
+		wp_register_script(
332
+			'jquery-validate',
333
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
334
+			array('jquery'),
335
+			'1.15.0',
336
+			true
337
+		);
338
+		wp_register_script(
339
+			'jquery-validate-extra-methods',
340
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
341
+			array('jquery', 'jquery-validate'),
342
+			'1.15.0',
343
+			true
344
+		);
345
+	}
346
+
347
+
348
+
349
+	/**
350
+	 * registers accounting.js for performing client-side calculations
351
+	 */
352
+	private function loadAccountingJs()
353
+	{
354
+		//accounting.js library
355
+		// @link http://josscrowcroft.github.io/accounting.js/
356
+		wp_register_script(
357
+			'ee-accounting-core',
358
+			EE_THIRD_PARTY_URL . 'accounting/accounting.js',
359
+			array('underscore'),
360
+			'0.3.2',
361
+			true
362
+		);
363
+		wp_register_script(
364
+			'ee-accounting',
365
+			EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
366
+			array('ee-accounting-core'),
367
+			EVENT_ESPRESSO_VERSION,
368
+			true
369
+		);
370
+	}
371
+
372
+
373
+
374
+	/**
375
+	 * registers accounting.js for performing client-side calculations
376
+	 */
377
+	private function localizeAccountingJs()
378
+	{
379
+		wp_localize_script(
380
+			'ee-accounting',
381
+			'EE_ACCOUNTING_CFG',
382
+			array(
383
+				'currency' => array(
384
+					'symbol'    => $this->currency_config->sign,
385
+					'format'    => array(
386
+						'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
387
+						'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
388
+						'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
389
+					),
390
+					'decimal'   => $this->currency_config->dec_mrk,
391
+					'thousand'  => $this->currency_config->thsnds,
392
+					'precision' => $this->currency_config->dec_plc,
393
+				),
394
+				'number'   => array(
395
+					'precision' => 0,
396
+					'thousand'  => $this->currency_config->thsnds,
397
+					'decimal'   => $this->currency_config->dec_mrk,
398
+				),
399
+			)
400
+		);
401
+	}
402
+
403
+
404
+
405
+	/**
406
+	 * registers assets for cleaning your ears
407
+	 */
408
+	private function loadQtipJs()
409
+	{
410
+		// qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
411
+		// can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
412
+		if (apply_filters('FHEE_load_qtip', false)) {
413
+			EEH_Qtip_Loader::instance()->register_and_enqueue();
414
+		}
415
+	}
416 416
 
417 417
 
418 418
 
Please login to merge, or discard this patch.