PluginProbe ʕ •ᴥ•ʔ
External Links – nofollow, noopener & new window / 2.63
External Links – nofollow, noopener & new window v2.63
0.31 0.32 0.33 0.34 0.35 1.01 1.02 1.03 1.10 1.20 1.21 1.30 1.31 1.40 1.41 1.50 1.51 1.52 1.53 1.54 1.55 1.56 1.60 1.61 1.62 1.70 1.80 1.81 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.1.0 2.1.1 2.1.2 2.1.3 2.2.0 2.3 2.32 2.35 2.40 2.42 2.43 2.45 2.46 2.47 2.48 2.50 2.51 2.55 2.56 2.57 2.58 2.59 2.60 2.61 2.62 2.63 2.64 2.65 trunk 0.10 0.11 0.12 0.20 0.21 0.30
wp-external-links / libs / fwp / class-fwp-debug.php
wp-external-links / libs / fwp Last commit date
component-bases 1 year ago filter-hooks 3 years ago class-fwp-debug.php 1 year ago class-fwp-html-element.php 3 years ago class-fwp-html-fields.php 3 years ago
class-fwp-debug.php
107 lines
1 <?php
2 /**
3 * Class FWP_Debug_1x0x0
4 *
5 * @package FWP
6 * @category WordPress Library
7 * @version 1.0.0
8
9 * @link https://www.webfactoryltd.com/
10 */
11 class FWP_Debug_1x0x0 extends WPRun_Base_1x0x0
12 {
13
14 /**
15 * @var array
16 */
17 private $settings = array(
18 'debug_func_name' => 'debug',
19 'log_hooks' => false,
20 );
21
22 /**
23 * @var array
24 */
25 private static $benchmarks = array();
26
27 /**
28 * Initialize
29 * @param array $settings Optional
30 */
31 protected function init( array $settings = array() )
32 {
33 $this->settings = wp_parse_args( $settings, $this->settings );
34
35 $this->create_func();
36
37 if ( $this->settings[ 'log_hooks' ] ) {
38 register_shutdown_function( $this->get_callback( 'log_hooks' ) );
39 }
40 }
41
42 /**
43 * Create logbal debug function
44 * @return void
45 */
46 private function create_func()
47 {
48 $func = $this->settings[ 'debug_func_name' ];
49
50 if ( function_exists( $func ) || !is_callable( $func, true ) ) {
51 return;
52 }
53
54 }
55
56 /**
57 * @param mixed $entry
58 */
59 public static function log( $entry, $title = '' )
60 {
61 $content = '';
62
63 if ( !empty($title) ) {
64 $content = $title . ': ';
65 }
66
67 $content .= var_export( $entry, true ); // phpcs:ignore
68 }
69
70 /**
71 * Log all hooks being applied
72 * @global array $wp_filter
73 */
74 protected function log_hooks()
75 {
76 global $wp_filter;
77
78 $hooks = array_keys( $wp_filter );
79 self::log( $hooks, 'WP Hooks' );
80 }
81
82 /**
83 *
84 */
85 public static function start_benchmark( $label = 'benchmark' )
86 {
87 self::$benchmarks[ $label ][ 'start' ] = microtime( true );
88 }
89
90 /**
91 *
92 */
93 public static function end_benchmark( $label = 'benchmark' )
94 {
95 $end_time = microtime( true );
96 self::$benchmarks[ $label ][ 'end' ] = $end_time;
97 $start_time = self::$benchmarks[ $label ][ 'start' ];
98
99 $total_time = $end_time - $start_time;
100
101 self::log( $total_time, $label );
102
103 return $total_time;
104 }
105
106 }
107