Completed
Branch BUG/11475/decode-site-title-fo... (bbd86e)
by
unknown
13:39 queued 25s
created

EEH_Debug_Tools   D

Complexity

Total Complexity 99

Size/Duplication

Total Lines 638
Duplicated Lines 2.19 %

Coupling/Cohesion

Components 2
Dependencies 6

Importance

Changes 0
Metric Value
dl 14
loc 638
rs 4.7173
c 0
b 0
f 0
wmc 99
lcom 2
cbo 6

26 Methods

Rating   Name   Duplication   Size   Complexity  
A instance() 0 8 2
A __construct() 0 19 3
B show_db_name() 0 11 5
B espresso_session_footer_dump() 0 17 8
C espresso_list_hooked_functions() 0 26 7
A registered_filter_callbacks() 0 15 4
B ee_plugin_activation_errors() 0 40 5
C doing_it_wrong() 0 51 8
B log() 0 26 5
C strip_objects() 14 22 8
C printv() 0 27 7
A plainOutput() 0 4 3
A heading() 0 8 2
A headingX() 0 7 2
A grey_span() 0 7 2
A file_and_line() 0 11 4
A orange_span() 0 7 2
A pre_span() 0 10 2
C printr() 0 40 13
A reset_times() 0 4 1
A start_timer() 0 4 1
A stop_timer() 0 4 1
A measure_memory() 0 4 1
A convert() 0 4 1
A show_times() 0 4 1
A format_time() 0 4 1

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like EEH_Debug_Tools often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use EEH_Debug_Tools, and based on these observations, apply Extract Interface, too.

1
<?php use EventEspresso\core\services\Benchmark;
2
3
if (! defined('EVENT_ESPRESSO_VERSION')) {
4
    exit('No direct script access allowed');
5
}
6
7
8
9
/**
10
 * Class EEH_Debug_Tools
11
 *
12
 * @package               Event Espresso
13
 * @subpackage            core
14
 * @author                Brent Christensen, Michael Nelson
15
 * @since                 4.0
16
 */
17
class EEH_Debug_Tools
18
{
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];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$hook was never initialized. Although not strictly required by PHP, it is generally a good practice to add $hook = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
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 View Code Duplication
            } else if (is_object($value)) {
358
                $object_class = get_class($value);
359
                $info[$object_class] = array();
360
                $info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value);
361
                if (method_exists($value, 'ID')) {
362
                    $info[$object_class]['ID'] = $value->ID();
363
                }
364
                if (method_exists($value, 'status')) {
365
                    $info[$object_class]['status'] = $value->status();
366
                } else if (method_exists($value, 'status_ID')) {
367
                    $info[$object_class]['status'] = $value->status_ID();
368
                }
369
                unset($info[$key]);
370
            }
371
        }
372
        return (array)$info;
373
    }
374
375
376
377
    /**
378
     * @param mixed      $var
379
     * @param string     $var_name
380
     * @param string     $file
381
     * @param int|string $line
382
     * @param int        $heading_tag
383
     * @param bool       $die
384
     * @param string     $margin
385
     */
386
    public static function printv(
387
        $var,
388
        $var_name = '',
389
        $file = '',
390
        $line = '',
391
        $heading_tag = 5,
392
        $die = false,
393
        $margin = ''
394
    ) {
395
        $var_name = ! $var_name ? 'string' : $var_name;
396
        $var_name = ucwords(str_replace('$', '', $var_name));
397
        $is_method = method_exists($var_name, $var);
398
        $var_name = ucwords(str_replace('_', ' ', $var_name));
399
        $heading_tag = absint($heading_tag);
400
        $result = $heading_tag < 3 ? "\n" : '';
401
        $heading_tag = $heading_tag > 0 && $heading_tag < 7 ? "h{$heading_tag}" : 'h5';
402
        $result .= EEH_Debug_Tools::heading($var_name, $heading_tag, $margin, $line);
403
        $result .= $is_method
404
            ? EEH_Debug_Tools::grey_span('::') . EEH_Debug_Tools::orange_span($var . '()')
405
            : EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span($var);
406
        $result .= EEH_Debug_Tools::file_and_line($file, $line);
407
        $result .= EEH_Debug_Tools::headingX($heading_tag);
408
        if ($die) {
409
            die($result);
410
        }
411
        echo $result;
412
    }
413
414
415
    protected static function plainOutput()
416
    {
417
        return defined('EE_TESTS_DIR') || (defined('DOING_AJAX') && DOING_AJAX);
418
    }
419
420
421
    /**
422
     * @param string $var_name
423
     * @param string $heading_tag
424
     * @param string $margin
425
     * @param int    $line
426
     * @return string
427
     */
428
    protected static function heading($var_name = '', $heading_tag = 'h5', $margin = '', $line = 0)
429
    {
430
        if (EEH_Debug_Tools::plainOutput()) {
431
            return "\n{$line}) {$var_name}";
432
        }
433
        $margin = "25px 0 0 {$margin}";
434
        return '<' . $heading_tag . ' style="color:#2EA2CC; margin:' . $margin . ';"><b>' . $var_name . '</b>';
435
    }
436
437
438
439
    /**
440
     * @param string $heading_tag
441
     * @return string
442
     */
443
    protected static function headingX($heading_tag = 'h5')
444
    {
445
        if (EEH_Debug_Tools::plainOutput()) {
446
            return '';
447
        }
448
        return '</' . $heading_tag . '>';
449
    }
450
451
452
453
    /**
454
     * @param string $content
455
     * @return string
456
     */
457
    protected static function grey_span($content = '')
458
    {
459
        if (EEH_Debug_Tools::plainOutput()) {
460
            return $content;
461
        }
462
        return '<span style="color:#999">' . $content . '</span>';
463
    }
464
465
466
467
    /**
468
     * @param string $file
469
     * @param int    $line
470
     * @return string
471
     */
472
    protected static function file_and_line($file, $line)
473
    {
474
        if ($file === '' || $line === '' || EEH_Debug_Tools::plainOutput()) {
0 ignored issues
show
Unused Code Bug introduced by
The strict comparison === seems to always evaluate to false as the types of $line (integer) and '' (string) can never be identical. Maybe you want to use a loose comparison == instead?
Loading history...
475
            return '';
476
        }
477
        return '<br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">'
478
               . $file
479
               . '<br />line no: '
480
               . $line
481
               . '</span>';
482
    }
483
484
485
486
    /**
487
     * @param string $content
488
     * @return string
489
     */
490
    protected static function orange_span($content = '')
491
    {
492
        if (EEH_Debug_Tools::plainOutput()) {
493
            return $content;
494
        }
495
        return '<span style="color:#E76700">' . $content . '</span>';
496
    }
497
498
499
500
    /**
501
     * @param mixed $var
502
     * @return string
503
     */
504
    protected static function pre_span($var)
505
    {
506
        ob_start();
507
        var_dump($var);
508
        $var = ob_get_clean();
509
        if (EEH_Debug_Tools::plainOutput()) {
510
            return "\n" . $var;
511
        }
512
        return '<pre style="color:#999; padding:1em; background: #fff">' . $var . '</pre>';
513
    }
514
515
516
517
    /**
518
     * @param mixed      $var
519
     * @param string     $var_name
520
     * @param string     $file
521
     * @param int|string $line
522
     * @param int        $heading_tag
523
     * @param bool       $die
524
     */
525
    public static function printr(
526
        $var,
527
        $var_name = '',
528
        $file = '',
529
        $line = '',
530
        $heading_tag = 5,
531
        $die = false
532
    ) {
533
        // return;
534
        $file = str_replace(rtrim(ABSPATH, '\\/'), '', $file);
535
        $margin = is_admin() ? ' 180px' : '0';
536
        //$print_r = false;
537
        if (is_string($var)) {
538
            EEH_Debug_Tools::printv($var, $var_name, $file, $line, $heading_tag, $die, $margin);
539
            return;
540
        }
541
        if (is_object($var)) {
542
            $var_name = ! $var_name ? 'object' : $var_name;
543
            //$print_r = true;
544
        } else if (is_array($var)) {
545
            $var_name = ! $var_name ? 'array' : $var_name;
546
            //$print_r = true;
547
        } else if (is_numeric($var)) {
548
            $var_name = ! $var_name ? 'numeric' : $var_name;
549
        } else if ($var === null) {
550
            $var_name = ! $var_name ? 'null' : $var_name;
551
        }
552
        $var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name));
553
        $heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5';
554
        $result = EEH_Debug_Tools::heading($var_name, $heading_tag, $margin, $line);
555
        $result .= EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span(
556
                EEH_Debug_Tools::pre_span($var)
557
            );
558
        $result .= EEH_Debug_Tools::file_and_line($file, $line);
559
        $result .= EEH_Debug_Tools::headingX($heading_tag);
560
        if ($die) {
561
            die($result);
562
        }
563
        echo $result;
564
    }
565
566
567
568
    /******************** deprecated ********************/
569
570
571
572
    /**
573
     * @deprecated 4.9.39.rc.034
574
     */
575
    public function reset_times()
576
    {
577
        Benchmark::resetTimes();
578
    }
579
580
581
582
    /**
583
     * @deprecated 4.9.39.rc.034
584
     * @param null $timer_name
585
     */
586
    public function start_timer($timer_name = null)
587
    {
588
        Benchmark::startTimer($timer_name);
589
    }
590
591
592
593
    /**
594
     * @deprecated 4.9.39.rc.034
595
     * @param string $timer_name
596
     */
597
    public function stop_timer($timer_name = '')
598
    {
599
        Benchmark::stopTimer($timer_name);
600
    }
601
602
603
604
    /**
605
     * @deprecated 4.9.39.rc.034
606
     * @param string  $label      The label to show for this time eg "Start of calling Some_Class::some_function"
607
     * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called
608
     * @return void
609
     */
610
    public function measure_memory($label, $output_now = false)
611
    {
612
        Benchmark::measureMemory($label, $output_now);
613
    }
614
615
616
617
    /**
618
     * @deprecated 4.9.39.rc.034
619
     * @param int $size
620
     * @return string
621
     */
622
    public function convert($size)
623
    {
624
        return Benchmark::convert($size);
625
    }
626
627
628
629
    /**
630
     * @deprecated 4.9.39.rc.034
631
     * @param bool $output_now
632
     * @return string
633
     */
634
    public function show_times($output_now = true)
635
    {
636
        return Benchmark::displayResults($output_now);
637
    }
638
639
640
641
    /**
642
     * @deprecated 4.9.39.rc.034
643
     * @param string $timer_name
644
     * @param float  $total_time
645
     * @return string
646
     */
647
    public function format_time($timer_name, $total_time)
648
    {
649
        return Benchmark::formatTime($timer_name, $total_time);
650
    }
651
652
653
654
}
655
656
657
658
/**
659
 * borrowed from Kint Debugger
660
 * Plugin URI: http://upthemes.com/plugins/kint-debugger/
661
 */
662
if (class_exists('Kint') && ! function_exists('dump_wp_query')) {
663
    function dump_wp_query()
664
    {
665
        global $wp_query;
666
        d($wp_query);
667
    }
668
}
669
/**
670
 * borrowed from Kint Debugger
671
 * Plugin URI: http://upthemes.com/plugins/kint-debugger/
672
 */
673
if (class_exists('Kint') && ! function_exists('dump_wp')) {
674
    function dump_wp()
675
    {
676
        global $wp;
677
        d($wp);
678
    }
679
}
680
/**
681
 * borrowed from Kint Debugger
682
 * Plugin URI: http://upthemes.com/plugins/kint-debugger/
683
 */
684
if (class_exists('Kint') && ! function_exists('dump_post')) {
685
    function dump_post()
686
    {
687
        global $post;
688
        d($post);
689
    }
690
}
691