@@ -8,9 +8,12 @@ |
||
8 | 8 | </tr> |
9 | 9 | </tbody> |
10 | 10 | </table> |
11 | -<?php else : ?> |
|
11 | +<?php else { |
|
12 | + : ?> |
|
12 | 13 | <form> |
13 | - <input type="text" id="glbb_hooks_callback" placeholder="<?= esc_attr__('Find callbacks containing', 'blackbar'); ?>"> |
|
14 | + <input type="text" id="glbb_hooks_callback" placeholder="<?= esc_attr__('Find callbacks containing', 'blackbar'); |
|
15 | +} |
|
16 | +?>"> |
|
14 | 17 | <input type="text" id="glbb_hooks_min_time" placeholder="<?= esc_attr__('Minimum total time', 'blackbar'); ?>"> |
15 | 18 | <select id="glbb_hooks_sort_by"> |
16 | 19 | <option value><?= esc_html__('Sort by total time', 'blackbar'); ?></option> |
@@ -1,45 +1,45 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | -<?php if (!$module->hasEntries()) : ?> |
|
3 | +<?php if( !$module->hasEntries() ) : ?> |
|
4 | 4 | <table> |
5 | 5 | <tbody> |
6 | 6 | <tr> |
7 | - <td><?= esc_html__('Please deactivate the Debug Bar Slow Actions plugin.', 'blackbar'); ?></td> |
|
7 | + <td><?= esc_html__( 'Please deactivate the Debug Bar Slow Actions plugin.', 'blackbar' ); ?></td> |
|
8 | 8 | </tr> |
9 | 9 | </tbody> |
10 | 10 | </table> |
11 | 11 | <?php else : ?> |
12 | 12 | <form> |
13 | - <input type="text" id="glbb_hooks_callback" placeholder="<?= esc_attr__('Find callbacks containing', 'blackbar'); ?>"> |
|
14 | - <input type="text" id="glbb_hooks_min_time" placeholder="<?= esc_attr__('Minimum total time', 'blackbar'); ?>"> |
|
13 | + <input type="text" id="glbb_hooks_callback" placeholder="<?= esc_attr__( 'Find callbacks containing', 'blackbar' ); ?>"> |
|
14 | + <input type="text" id="glbb_hooks_min_time" placeholder="<?= esc_attr__( 'Minimum total time', 'blackbar' ); ?>"> |
|
15 | 15 | <select id="glbb_hooks_sort_by"> |
16 | - <option value><?= esc_html__('Sort by total time', 'blackbar'); ?></option> |
|
17 | - <option value="order"><?= esc_html__('Sort by execution order', 'blackbar'); ?></option> |
|
16 | + <option value><?= esc_html__( 'Sort by total time', 'blackbar' ); ?></option> |
|
17 | + <option value="order"><?= esc_html__( 'Sort by execution order', 'blackbar' ); ?></option> |
|
18 | 18 | </select> |
19 | 19 | </form> |
20 | 20 | <table class="glbb-grid"> |
21 | 21 | <thead> |
22 | 22 | <tr> |
23 | - <th><?= esc_html__('Action or Filter (Slowest 50)', 'blackbar'); ?></th> |
|
24 | - <th><?= esc_html__('Callbacks', 'blackbar'); ?></th> |
|
25 | - <th><?= esc_html__('Calls', 'blackbar'); ?></th> |
|
26 | - <th><?= esc_html__('Per Call', 'blackbar'); ?></th> |
|
27 | - <th><?= esc_html__('Total', 'blackbar'); ?></th> |
|
23 | + <th><?= esc_html__( 'Action or Filter (Slowest 50)', 'blackbar' ); ?></th> |
|
24 | + <th><?= esc_html__( 'Callbacks', 'blackbar' ); ?></th> |
|
25 | + <th><?= esc_html__( 'Calls', 'blackbar' ); ?></th> |
|
26 | + <th><?= esc_html__( 'Per Call', 'blackbar' ); ?></th> |
|
27 | + <th><?= esc_html__( 'Total', 'blackbar' ); ?></th> |
|
28 | 28 | </tr> |
29 | 29 | </thead> |
30 | 30 | <tbody> |
31 | - <?php foreach ($module->entries() as $hook => $data) : ?> |
|
32 | - <tr class="glbb-row-collapsed" data-index="<?= esc_attr($data['index']); ?>" data-time="<?= esc_attr($data['total']); ?>"> |
|
33 | - <td><div class="glbb-row-toggle dashicons-before dashicons-arrow-right"><?= esc_html($hook); ?></div></td> |
|
34 | - <td data-callbacks="<?= esc_attr($data['callbacks_count']); ?>"><?= esc_html($data['callbacks_count']); ?></td> |
|
35 | - <td data-calls="<?= esc_attr($data['count']); ?>"><?= esc_html($data['count']); ?></td> |
|
36 | - <td data-percall="<?= esc_attr($data['per_call']); ?>"><?= esc_html($data['per_call']); ?></td> |
|
37 | - <td data-total="<?= esc_attr($data['total']); ?>"><?= esc_html($data['total_formatted']); ?></td> |
|
31 | + <?php foreach( $module->entries() as $hook => $data ) : ?> |
|
32 | + <tr class="glbb-row-collapsed" data-index="<?= esc_attr( $data[ 'index' ] ); ?>" data-time="<?= esc_attr( $data[ 'total' ] ); ?>"> |
|
33 | + <td><div class="glbb-row-toggle dashicons-before dashicons-arrow-right"><?= esc_html( $hook ); ?></div></td> |
|
34 | + <td data-callbacks="<?= esc_attr( $data[ 'callbacks_count' ] ); ?>"><?= esc_html( $data[ 'callbacks_count' ] ); ?></td> |
|
35 | + <td data-calls="<?= esc_attr( $data[ 'count' ] ); ?>"><?= esc_html( $data[ 'count' ] ); ?></td> |
|
36 | + <td data-percall="<?= esc_attr( $data[ 'per_call' ] ); ?>"><?= esc_html( $data[ 'per_call' ] ); ?></td> |
|
37 | + <td data-total="<?= esc_attr( $data[ 'total' ] ); ?>"><?= esc_html( $data[ 'total_formatted' ] ); ?></td> |
|
38 | 38 | <td class="glbb-row-details"> |
39 | 39 | <ol> |
40 | - <?php foreach ($data['callbacks'] as $priority => $callbacks) : ?> |
|
41 | - <?php foreach ($callbacks as $callback) : ?> |
|
42 | - <li value="<?= esc_attr($priority); ?>"><?= esc_html($callback); ?></li> |
|
40 | + <?php foreach( $data[ 'callbacks' ] as $priority => $callbacks ) : ?> |
|
41 | + <?php foreach( $callbacks as $callback ) : ?> |
|
42 | + <li value="<?= esc_attr( $priority ); ?>"><?= esc_html( $callback ); ?></li> |
|
43 | 43 | <?php endforeach; ?> |
44 | 44 | <?php endforeach; ?> |
45 | 45 | </ol> |
@@ -1,11 +1,11 @@ discard block |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | -<?php if (!$module->hasEntries()) : ?> |
|
3 | +<?php if( !$module->hasEntries() ) : ?> |
|
4 | 4 | <div> |
5 | 5 | <table> |
6 | 6 | <tbody> |
7 | 7 | <tr> |
8 | - <td><?= esc_html__('No entries found.', 'blackbar'); ?></td> |
|
8 | + <td><?= esc_html__( 'No entries found.', 'blackbar' ); ?></td> |
|
9 | 9 | </tr> |
10 | 10 | </tbody> |
11 | 11 | </table> |
@@ -14,13 +14,13 @@ discard block |
||
14 | 14 | <div> |
15 | 15 | <table class="glbb-grid"> |
16 | 16 | <tbody> |
17 | - <?php foreach ($module->entries() as $entry) : ?> |
|
18 | - <tr data-errname="<?= esc_attr($entry['errname']); ?>"> |
|
17 | + <?php foreach( $module->entries() as $entry ) : ?> |
|
18 | + <tr data-errname="<?= esc_attr( $entry[ 'errname' ] ); ?>"> |
|
19 | 19 | <td> |
20 | - <span class="glbb-info glbb-<?= $entry['errname']; ?>"><?= esc_html($entry['name']); ?></span> |
|
20 | + <span class="glbb-info glbb-<?= $entry[ 'errname' ]; ?>"><?= esc_html( $entry[ 'name' ] ); ?></span> |
|
21 | 21 | </td> |
22 | 22 | <td> |
23 | - <pre><code><?= esc_html($entry['message']); ?></code></pre> |
|
23 | + <pre><code><?= esc_html( $entry[ 'message' ] ); ?></code></pre> |
|
24 | 24 | </td> |
25 | 25 | </tr> |
26 | 26 | <?php endforeach; ?> |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | </table> |
29 | 29 | </div> |
30 | 30 | <form> |
31 | - <label><input type="checkbox" value="debug"> <?= esc_html__('Debug', 'blackbar'); ?></label> |
|
32 | - <label><input type="checkbox" value="info"> <?= esc_html__('Info', 'blackbar'); ?></label> |
|
33 | - <label><input type="checkbox" value="deprecated"> <?= esc_html__('Deprecated', 'blackbar'); ?></label> |
|
34 | - <label><input type="checkbox" value="notice"> <?= esc_html__('Notice', 'blackbar'); ?></label> |
|
35 | - <label><input type="checkbox" value="strict"> <?= esc_html__('Strict', 'blackbar'); ?></label> |
|
36 | - <label><input type="checkbox" value="warning"> <?= esc_html__('Warning', 'blackbar'); ?></label> |
|
37 | - <label><input type="checkbox" value="error"> <?= esc_html__('Error', 'blackbar'); ?></label> |
|
31 | + <label><input type="checkbox" value="debug"> <?= esc_html__( 'Debug', 'blackbar' ); ?></label> |
|
32 | + <label><input type="checkbox" value="info"> <?= esc_html__( 'Info', 'blackbar' ); ?></label> |
|
33 | + <label><input type="checkbox" value="deprecated"> <?= esc_html__( 'Deprecated', 'blackbar' ); ?></label> |
|
34 | + <label><input type="checkbox" value="notice"> <?= esc_html__( 'Notice', 'blackbar' ); ?></label> |
|
35 | + <label><input type="checkbox" value="strict"> <?= esc_html__( 'Strict', 'blackbar' ); ?></label> |
|
36 | + <label><input type="checkbox" value="warning"> <?= esc_html__( 'Warning', 'blackbar' ); ?></label> |
|
37 | + <label><input type="checkbox" value="error"> <?= esc_html__( 'Error', 'blackbar' ); ?></label> |
|
38 | 38 | </form> |
39 | 39 | <?php endif; ?> |
@@ -10,12 +10,15 @@ |
||
10 | 10 | </tbody> |
11 | 11 | </table> |
12 | 12 | </div> |
13 | -<?php else : ?> |
|
13 | +<?php else { |
|
14 | + : ?> |
|
14 | 15 | <div> |
15 | 16 | <table class="glbb-grid"> |
16 | 17 | <tbody> |
17 | 18 | <?php foreach ($module->entries() as $entry) : ?> |
18 | - <tr data-errname="<?= esc_attr($entry['errname']); ?>"> |
|
19 | + <tr data-errname="<?= esc_attr($entry['errname']); |
|
20 | +} |
|
21 | +?>"> |
|
19 | 22 | <td> |
20 | 23 | <span class="glbb-info glbb-<?= $entry['errname']; ?>"><?= esc_html($entry['name']); ?></span> |
21 | 24 | </td> |
@@ -1,13 +1,13 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | -<?php if ($module->hasEntries()) : ?> |
|
3 | +<?php if( $module->hasEntries() ) : ?> |
|
4 | 4 | <table class="glbb-grid"> |
5 | 5 | <tbody> |
6 | - <?php foreach ($module->entries() as $entry) : ?> |
|
6 | + <?php foreach( $module->entries() as $entry ) : ?> |
|
7 | 7 | <tr class="glbb-row-collapsed"> |
8 | - <td><div class="glbb-row-toggle dashicons-before dashicons-arrow-right"><?= esc_html($entry['name']); ?></div></td> |
|
8 | + <td><div class="glbb-row-toggle dashicons-before dashicons-arrow-right"><?= esc_html( $entry[ 'name' ] ); ?></div></td> |
|
9 | 9 | <td class="glbb-row-details"> |
10 | - <pre><code><?= esc_html($entry['value']); ?></code></pre></td> |
|
10 | + <pre><code><?= esc_html( $entry[ 'value' ] ); ?></code></pre></td> |
|
11 | 11 | </tr> |
12 | 12 | </tr> |
13 | 13 | <?php endforeach; ?> |
@@ -1,12 +1,12 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <table class="glbb-grid"> |
4 | 4 | <tbody> |
5 | - <?php foreach ($module->entries() as $index => $template) : ?> |
|
5 | + <?php foreach( $module->entries() as $index => $template ) : ?> |
|
6 | 6 | <tr> |
7 | 7 | <td> |
8 | 8 | <ol> |
9 | - <li value="<?= esc_attr($index + 1); ?>"><?= esc_html($template); ?></li> |
|
9 | + <li value="<?= esc_attr( $index + 1 ); ?>"><?= esc_html( $template ); ?></li> |
|
10 | 10 | </ol> |
11 | 11 | </td> |
12 | 12 | </tr> |
@@ -4,91 +4,91 @@ |
||
4 | 4 | |
5 | 5 | class Profiler extends Module |
6 | 6 | { |
7 | - /** |
|
8 | - * @var int |
|
9 | - */ |
|
10 | - protected $memory_start = 0; |
|
11 | - /** |
|
12 | - * @var int |
|
13 | - */ |
|
14 | - protected $memory_stop = 0; |
|
15 | - /** |
|
16 | - * The profiler noise to remove from the timer (in nanoseconds). |
|
17 | - * @var int |
|
18 | - */ |
|
19 | - protected $noise = 0; |
|
20 | - /** |
|
21 | - * The hrtime the profiler started measuring (in nanoseconds). |
|
22 | - * @var int |
|
23 | - */ |
|
24 | - protected $start = 0; |
|
25 | - /** |
|
26 | - * The hrtime the profiler stopped measuring (in nanoseconds). |
|
27 | - * @var int |
|
28 | - */ |
|
29 | - protected $stop = 0; |
|
30 | - /** |
|
31 | - * @var array |
|
32 | - */ |
|
33 | - protected $timer = []; |
|
7 | + /** |
|
8 | + * @var int |
|
9 | + */ |
|
10 | + protected $memory_start = 0; |
|
11 | + /** |
|
12 | + * @var int |
|
13 | + */ |
|
14 | + protected $memory_stop = 0; |
|
15 | + /** |
|
16 | + * The profiler noise to remove from the timer (in nanoseconds). |
|
17 | + * @var int |
|
18 | + */ |
|
19 | + protected $noise = 0; |
|
20 | + /** |
|
21 | + * The hrtime the profiler started measuring (in nanoseconds). |
|
22 | + * @var int |
|
23 | + */ |
|
24 | + protected $start = 0; |
|
25 | + /** |
|
26 | + * The hrtime the profiler stopped measuring (in nanoseconds). |
|
27 | + * @var int |
|
28 | + */ |
|
29 | + protected $stop = 0; |
|
30 | + /** |
|
31 | + * @var array |
|
32 | + */ |
|
33 | + protected $timer = []; |
|
34 | 34 | |
35 | - public function entries(): array |
|
36 | - { |
|
37 | - $entries = []; |
|
38 | - foreach ($this->entries as $entry) { |
|
39 | - $entry['time'] = $this->formatTime($entry['time']); |
|
40 | - $entries[] = $entry; |
|
41 | - } |
|
42 | - return $entries; |
|
43 | - } |
|
35 | + public function entries(): array |
|
36 | + { |
|
37 | + $entries = []; |
|
38 | + foreach ($this->entries as $entry) { |
|
39 | + $entry['time'] = $this->formatTime($entry['time']); |
|
40 | + $entries[] = $entry; |
|
41 | + } |
|
42 | + return $entries; |
|
43 | + } |
|
44 | 44 | |
45 | - public function isVisible(): bool |
|
46 | - { |
|
47 | - return $this->hasEntries(); |
|
48 | - } |
|
45 | + public function isVisible(): bool |
|
46 | + { |
|
47 | + return $this->hasEntries(); |
|
48 | + } |
|
49 | 49 | |
50 | - public function label(): string |
|
51 | - { |
|
52 | - return __('Profiler', 'blackbar'); |
|
53 | - } |
|
50 | + public function label(): string |
|
51 | + { |
|
52 | + return __('Profiler', 'blackbar'); |
|
53 | + } |
|
54 | 54 | |
55 | - public function setNoise(int $nanoseconds): void |
|
56 | - { |
|
57 | - $this->noise = $nanoseconds - $this->start; |
|
58 | - } |
|
55 | + public function setNoise(int $nanoseconds): void |
|
56 | + { |
|
57 | + $this->noise = $nanoseconds - $this->start; |
|
58 | + } |
|
59 | 59 | |
60 | - public function setStart(int $nanoseconds): void |
|
61 | - { |
|
62 | - $this->start = $nanoseconds; |
|
63 | - $this->memory_start = memory_get_peak_usage(); |
|
64 | - } |
|
60 | + public function setStart(int $nanoseconds): void |
|
61 | + { |
|
62 | + $this->start = $nanoseconds; |
|
63 | + $this->memory_start = memory_get_peak_usage(); |
|
64 | + } |
|
65 | 65 | |
66 | - public function setStop(int $nanoseconds): void |
|
67 | - { |
|
68 | - $this->stop = $nanoseconds; |
|
69 | - $this->memory_stop = memory_get_peak_usage(); |
|
70 | - } |
|
66 | + public function setStop(int $nanoseconds): void |
|
67 | + { |
|
68 | + $this->stop = $nanoseconds; |
|
69 | + $this->memory_stop = memory_get_peak_usage(); |
|
70 | + } |
|
71 | 71 | |
72 | - public function start(string $name): void |
|
73 | - { |
|
74 | - $this->timer = [ |
|
75 | - 'memory' => memory_get_peak_usage(), |
|
76 | - 'name' => $name, |
|
77 | - 'start' => (int) hrtime(true), |
|
78 | - 'stop' => 0, |
|
79 | - 'time' => 0, |
|
80 | - ]; |
|
81 | - } |
|
72 | + public function start(string $name): void |
|
73 | + { |
|
74 | + $this->timer = [ |
|
75 | + 'memory' => memory_get_peak_usage(), |
|
76 | + 'name' => $name, |
|
77 | + 'start' => (int) hrtime(true), |
|
78 | + 'stop' => 0, |
|
79 | + 'time' => 0, |
|
80 | + ]; |
|
81 | + } |
|
82 | 82 | |
83 | - public function stop(): void |
|
84 | - { |
|
85 | - if (!empty($this->timer)) { |
|
86 | - $nanoseconds = (int) hrtime(true); |
|
87 | - $this->timer['memory'] = max(0, memory_get_peak_usage() - $this->timer['memory']); |
|
88 | - $this->timer['stop'] = $nanoseconds; |
|
89 | - $this->timer['time'] = max(0, $nanoseconds - $this->timer['start'] - $this->noise); |
|
90 | - $this->entries[] = $this->timer; |
|
91 | - $this->timer = []; // reset timer |
|
92 | - } |
|
93 | - } |
|
83 | + public function stop(): void |
|
84 | + { |
|
85 | + if (!empty($this->timer)) { |
|
86 | + $nanoseconds = (int) hrtime(true); |
|
87 | + $this->timer['memory'] = max(0, memory_get_peak_usage() - $this->timer['memory']); |
|
88 | + $this->timer['stop'] = $nanoseconds; |
|
89 | + $this->timer['time'] = max(0, $nanoseconds - $this->timer['start'] - $this->noise); |
|
90 | + $this->entries[] = $this->timer; |
|
91 | + $this->timer = []; // reset timer |
|
92 | + } |
|
93 | + } |
|
94 | 94 | } |
@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * @var array |
32 | 32 | */ |
33 | - protected $timer = []; |
|
33 | + protected $timer = [ ]; |
|
34 | 34 | |
35 | 35 | public function entries(): array |
36 | 36 | { |
37 | - $entries = []; |
|
38 | - foreach ($this->entries as $entry) { |
|
39 | - $entry['time'] = $this->formatTime($entry['time']); |
|
40 | - $entries[] = $entry; |
|
37 | + $entries = [ ]; |
|
38 | + foreach( $this->entries as $entry ) { |
|
39 | + $entry[ 'time' ] = $this->formatTime( $entry[ 'time' ] ); |
|
40 | + $entries[ ] = $entry; |
|
41 | 41 | } |
42 | 42 | return $entries; |
43 | 43 | } |
@@ -49,32 +49,32 @@ discard block |
||
49 | 49 | |
50 | 50 | public function label(): string |
51 | 51 | { |
52 | - return __('Profiler', 'blackbar'); |
|
52 | + return __( 'Profiler', 'blackbar' ); |
|
53 | 53 | } |
54 | 54 | |
55 | - public function setNoise(int $nanoseconds): void |
|
55 | + public function setNoise( int $nanoseconds ): void |
|
56 | 56 | { |
57 | 57 | $this->noise = $nanoseconds - $this->start; |
58 | 58 | } |
59 | 59 | |
60 | - public function setStart(int $nanoseconds): void |
|
60 | + public function setStart( int $nanoseconds ): void |
|
61 | 61 | { |
62 | 62 | $this->start = $nanoseconds; |
63 | 63 | $this->memory_start = memory_get_peak_usage(); |
64 | 64 | } |
65 | 65 | |
66 | - public function setStop(int $nanoseconds): void |
|
66 | + public function setStop( int $nanoseconds ): void |
|
67 | 67 | { |
68 | 68 | $this->stop = $nanoseconds; |
69 | 69 | $this->memory_stop = memory_get_peak_usage(); |
70 | 70 | } |
71 | 71 | |
72 | - public function start(string $name): void |
|
72 | + public function start( string $name ): void |
|
73 | 73 | { |
74 | 74 | $this->timer = [ |
75 | 75 | 'memory' => memory_get_peak_usage(), |
76 | 76 | 'name' => $name, |
77 | - 'start' => (int) hrtime(true), |
|
77 | + 'start' => (int) hrtime( true ), |
|
78 | 78 | 'stop' => 0, |
79 | 79 | 'time' => 0, |
80 | 80 | ]; |
@@ -82,13 +82,13 @@ discard block |
||
82 | 82 | |
83 | 83 | public function stop(): void |
84 | 84 | { |
85 | - if (!empty($this->timer)) { |
|
86 | - $nanoseconds = (int) hrtime(true); |
|
87 | - $this->timer['memory'] = max(0, memory_get_peak_usage() - $this->timer['memory']); |
|
88 | - $this->timer['stop'] = $nanoseconds; |
|
89 | - $this->timer['time'] = max(0, $nanoseconds - $this->timer['start'] - $this->noise); |
|
90 | - $this->entries[] = $this->timer; |
|
91 | - $this->timer = []; // reset timer |
|
85 | + if( !empty( $this->timer ) ) { |
|
86 | + $nanoseconds = (int) hrtime( true ); |
|
87 | + $this->timer[ 'memory' ] = max( 0, memory_get_peak_usage() - $this->timer[ 'memory' ] ); |
|
88 | + $this->timer[ 'stop' ] = $nanoseconds; |
|
89 | + $this->timer[ 'time' ] = max( 0, $nanoseconds - $this->timer[ 'start' ] - $this->noise ); |
|
90 | + $this->entries[ ] = $this->timer; |
|
91 | + $this->timer = [ ]; // reset timer |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | } |
@@ -6,80 +6,80 @@ |
||
6 | 6 | |
7 | 7 | abstract class Module |
8 | 8 | { |
9 | - /** |
|
10 | - * @var Application |
|
11 | - */ |
|
12 | - protected $app; |
|
13 | - /** |
|
14 | - * @var array |
|
15 | - */ |
|
16 | - protected $entries; |
|
9 | + /** |
|
10 | + * @var Application |
|
11 | + */ |
|
12 | + protected $app; |
|
13 | + /** |
|
14 | + * @var array |
|
15 | + */ |
|
16 | + protected $entries; |
|
17 | 17 | |
18 | - public function __construct(Application $app) |
|
19 | - { |
|
20 | - $this->app = $app; |
|
21 | - $this->entries = []; |
|
22 | - } |
|
18 | + public function __construct(Application $app) |
|
19 | + { |
|
20 | + $this->app = $app; |
|
21 | + $this->entries = []; |
|
22 | + } |
|
23 | 23 | |
24 | - public function classes(): string |
|
25 | - { |
|
26 | - return $this->id(); |
|
27 | - } |
|
24 | + public function classes(): string |
|
25 | + { |
|
26 | + return $this->id(); |
|
27 | + } |
|
28 | 28 | |
29 | - abstract public function entries(): array; |
|
29 | + abstract public function entries(): array; |
|
30 | 30 | |
31 | - public function hasEntries(): bool |
|
32 | - { |
|
33 | - return !empty($this->entries); |
|
34 | - } |
|
31 | + public function hasEntries(): bool |
|
32 | + { |
|
33 | + return !empty($this->entries); |
|
34 | + } |
|
35 | 35 | |
36 | - public function id(): string |
|
37 | - { |
|
38 | - return sprintf('glbb-%s', $this->slug()); |
|
39 | - } |
|
36 | + public function id(): string |
|
37 | + { |
|
38 | + return sprintf('glbb-%s', $this->slug()); |
|
39 | + } |
|
40 | 40 | |
41 | - public function info(): string |
|
42 | - { |
|
43 | - return ''; |
|
44 | - } |
|
41 | + public function info(): string |
|
42 | + { |
|
43 | + return ''; |
|
44 | + } |
|
45 | 45 | |
46 | - public function isVisible(): bool |
|
47 | - { |
|
48 | - return true; |
|
49 | - } |
|
46 | + public function isVisible(): bool |
|
47 | + { |
|
48 | + return true; |
|
49 | + } |
|
50 | 50 | |
51 | - abstract public function label(): string; |
|
51 | + abstract public function label(): string; |
|
52 | 52 | |
53 | - public function render(): void |
|
54 | - { |
|
55 | - $this->app->render('panels/'.$this->slug(), ['module' => $this]); |
|
56 | - } |
|
53 | + public function render(): void |
|
54 | + { |
|
55 | + $this->app->render('panels/'.$this->slug(), ['module' => $this]); |
|
56 | + } |
|
57 | 57 | |
58 | - public function slug(): string |
|
59 | - { |
|
60 | - return strtolower((new \ReflectionClass($this))->getShortName()); |
|
61 | - } |
|
58 | + public function slug(): string |
|
59 | + { |
|
60 | + return strtolower((new \ReflectionClass($this))->getShortName()); |
|
61 | + } |
|
62 | 62 | |
63 | - protected function formatTime(int $nanoseconds): string |
|
64 | - { |
|
65 | - if ($nanoseconds >= 1e9) { |
|
66 | - return sprintf('%s s', $this->toDecimal(round($nanoseconds / 1e9, 2))); |
|
67 | - } |
|
68 | - if ($nanoseconds >= 1e6) { |
|
69 | - return sprintf('%s ms', $this->toDecimal(round($nanoseconds / 1e6, 2))); |
|
70 | - } |
|
71 | - if ($nanoseconds >= 1e3) { |
|
72 | - return sprintf('%s µs', round($nanoseconds / 1e3)); |
|
73 | - } |
|
74 | - return sprintf('%s ns', $nanoseconds); |
|
75 | - } |
|
63 | + protected function formatTime(int $nanoseconds): string |
|
64 | + { |
|
65 | + if ($nanoseconds >= 1e9) { |
|
66 | + return sprintf('%s s', $this->toDecimal(round($nanoseconds / 1e9, 2))); |
|
67 | + } |
|
68 | + if ($nanoseconds >= 1e6) { |
|
69 | + return sprintf('%s ms', $this->toDecimal(round($nanoseconds / 1e6, 2))); |
|
70 | + } |
|
71 | + if ($nanoseconds >= 1e3) { |
|
72 | + return sprintf('%s µs', round($nanoseconds / 1e3)); |
|
73 | + } |
|
74 | + return sprintf('%s ns', $nanoseconds); |
|
75 | + } |
|
76 | 76 | |
77 | - protected function toDecimal(float $number): string |
|
78 | - { |
|
79 | - $number = (string) $number; |
|
80 | - if (false !== strpos($number, '.')) { |
|
81 | - $number = rtrim(rtrim($number, '0'), '.'); |
|
82 | - } |
|
83 | - return $number; |
|
84 | - } |
|
77 | + protected function toDecimal(float $number): string |
|
78 | + { |
|
79 | + $number = (string) $number; |
|
80 | + if (false !== strpos($number, '.')) { |
|
81 | + $number = rtrim(rtrim($number, '0'), '.'); |
|
82 | + } |
|
83 | + return $number; |
|
84 | + } |
|
85 | 85 | } |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | */ |
16 | 16 | protected $entries; |
17 | 17 | |
18 | - public function __construct(Application $app) |
|
18 | + public function __construct( Application $app ) |
|
19 | 19 | { |
20 | 20 | $this->app = $app; |
21 | - $this->entries = []; |
|
21 | + $this->entries = [ ]; |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public function classes(): string |
@@ -30,12 +30,12 @@ discard block |
||
30 | 30 | |
31 | 31 | public function hasEntries(): bool |
32 | 32 | { |
33 | - return !empty($this->entries); |
|
33 | + return !empty( $this->entries ); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | public function id(): string |
37 | 37 | { |
38 | - return sprintf('glbb-%s', $this->slug()); |
|
38 | + return sprintf( 'glbb-%s', $this->slug() ); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | public function info(): string |
@@ -52,33 +52,33 @@ discard block |
||
52 | 52 | |
53 | 53 | public function render(): void |
54 | 54 | { |
55 | - $this->app->render('panels/'.$this->slug(), ['module' => $this]); |
|
55 | + $this->app->render( 'panels/' . $this->slug(), [ 'module' => $this ] ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | public function slug(): string |
59 | 59 | { |
60 | - return strtolower((new \ReflectionClass($this))->getShortName()); |
|
60 | + return strtolower( ( new \ReflectionClass( $this ) )->getShortName() ); |
|
61 | 61 | } |
62 | 62 | |
63 | - protected function formatTime(int $nanoseconds): string |
|
63 | + protected function formatTime( int $nanoseconds ): string |
|
64 | 64 | { |
65 | - if ($nanoseconds >= 1e9) { |
|
66 | - return sprintf('%s s', $this->toDecimal(round($nanoseconds / 1e9, 2))); |
|
65 | + if( $nanoseconds >= 1e9 ) { |
|
66 | + return sprintf( '%s s', $this->toDecimal( round( $nanoseconds / 1e9, 2 ) ) ); |
|
67 | 67 | } |
68 | - if ($nanoseconds >= 1e6) { |
|
69 | - return sprintf('%s ms', $this->toDecimal(round($nanoseconds / 1e6, 2))); |
|
68 | + if( $nanoseconds >= 1e6 ) { |
|
69 | + return sprintf( '%s ms', $this->toDecimal( round( $nanoseconds / 1e6, 2 ) ) ); |
|
70 | 70 | } |
71 | - if ($nanoseconds >= 1e3) { |
|
72 | - return sprintf('%s µs', round($nanoseconds / 1e3)); |
|
71 | + if( $nanoseconds >= 1e3 ) { |
|
72 | + return sprintf( '%s µs', round( $nanoseconds / 1e3 ) ); |
|
73 | 73 | } |
74 | - return sprintf('%s ns', $nanoseconds); |
|
74 | + return sprintf( '%s ns', $nanoseconds ); |
|
75 | 75 | } |
76 | 76 | |
77 | - protected function toDecimal(float $number): string |
|
77 | + protected function toDecimal( float $number ): string |
|
78 | 78 | { |
79 | 79 | $number = (string) $number; |
80 | - if (false !== strpos($number, '.')) { |
|
81 | - $number = rtrim(rtrim($number, '0'), '.'); |
|
80 | + if( false !== strpos( $number, '.' ) ) { |
|
81 | + $number = rtrim( rtrim( $number, '0' ), '.' ); |
|
82 | 82 | } |
83 | 83 | return $number; |
84 | 84 | } |
@@ -1,14 +1,14 @@ discard block |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div id="glbb"> |
4 | - <?php foreach ($modules as $module) : /* Ensure that the console entries are loaded last */ ?> |
|
5 | - <?php if (!$module->isVisible() || 'glbb-console' === $module->id()) continue; ?> |
|
4 | + <?php foreach( $modules as $module ) : /* Ensure that the console entries are loaded last */ ?> |
|
5 | + <?php if( !$module->isVisible() || 'glbb-console' === $module->id() ) continue; ?> |
|
6 | 6 | <div id="<?= $module->id(); ?>" class="glbb-panel glbb-hidden"> |
7 | 7 | <?php $module->render(); ?> |
8 | 8 | </div> |
9 | 9 | <?php endforeach; ?> |
10 | - <?php foreach ($modules as $module) : /* Ensure that the console entries are loaded last */ ?> |
|
11 | - <?php if (!$module->isVisible() || 'glbb-console' !== $module->id()) continue; ?> |
|
10 | + <?php foreach( $modules as $module ) : /* Ensure that the console entries are loaded last */ ?> |
|
11 | + <?php if( !$module->isVisible() || 'glbb-console' !== $module->id() ) continue; ?> |
|
12 | 12 | <div id="<?= $module->id(); ?>" class="glbb-panel glbb-hidden"> |
13 | 13 | <?php $module->render(); ?> |
14 | 14 | </div> |
@@ -16,19 +16,19 @@ discard block |
||
16 | 16 | <div class="glbb-panel-links"> |
17 | 17 | <a href="#" class="dashicons-before glbb-toggle"> |
18 | 18 | <span class="screen-reader-text"> |
19 | - <?= esc_html__('Toggle', 'blackbar'); ?> |
|
19 | + <?= esc_html__( 'Toggle', 'blackbar' ); ?> |
|
20 | 20 | </span> |
21 | 21 | </a> |
22 | - <?php foreach ($modules as $module) : ?> |
|
23 | - <?php if (!$module->isVisible()) continue; ?> |
|
24 | - <a href="#" data-panel="<?= esc_attr($module->id()); ?>" data-info="<?= esc_attr($module->info()); ?>" class="dashicons-before <?= $module->classes(); ?>"> |
|
22 | + <?php foreach( $modules as $module ) : ?> |
|
23 | + <?php if( !$module->isVisible() ) continue; ?> |
|
24 | + <a href="#" data-panel="<?= esc_attr( $module->id() ); ?>" data-info="<?= esc_attr( $module->info() ); ?>" class="dashicons-before <?= $module->classes(); ?>"> |
|
25 | 25 | <span><?= $module->label(); ?></span> |
26 | 26 | </a> |
27 | 27 | <?php endforeach; ?> |
28 | 28 | <div> |
29 | 29 | <a href="#" class="dashicons-before glbb-close"> |
30 | 30 | <span class="screen-reader-text"> |
31 | - <?= esc_html__('Close', 'blackbar'); ?> |
|
31 | + <?= esc_html__( 'Close', 'blackbar' ); ?> |
|
32 | 32 | </span> |
33 | 33 | </a> |
34 | 34 | </div> |
@@ -2,13 +2,19 @@ discard block |
||
2 | 2 | |
3 | 3 | <div id="glbb"> |
4 | 4 | <?php foreach ($modules as $module) : /* Ensure that the console entries are loaded last */ ?> |
5 | - <?php if (!$module->isVisible() || 'glbb-console' === $module->id()) continue; ?> |
|
5 | + <?php if (!$module->isVisible() || 'glbb-console' === $module->id()) { |
|
6 | + continue; |
|
7 | +} |
|
8 | +?> |
|
6 | 9 | <div id="<?= $module->id(); ?>" class="glbb-panel glbb-hidden"> |
7 | 10 | <?php $module->render(); ?> |
8 | 11 | </div> |
9 | 12 | <?php endforeach; ?> |
10 | 13 | <?php foreach ($modules as $module) : /* Ensure that the console entries are loaded last */ ?> |
11 | - <?php if (!$module->isVisible() || 'glbb-console' !== $module->id()) continue; ?> |
|
14 | + <?php if (!$module->isVisible() || 'glbb-console' !== $module->id()) { |
|
15 | + continue; |
|
16 | +} |
|
17 | +?> |
|
12 | 18 | <div id="<?= $module->id(); ?>" class="glbb-panel glbb-hidden"> |
13 | 19 | <?php $module->render(); ?> |
14 | 20 | </div> |
@@ -20,7 +26,10 @@ discard block |
||
20 | 26 | </span> |
21 | 27 | </a> |
22 | 28 | <?php foreach ($modules as $module) : ?> |
23 | - <?php if (!$module->isVisible()) continue; ?> |
|
29 | + <?php if (!$module->isVisible()) { |
|
30 | + continue; |
|
31 | +} |
|
32 | +?> |
|
24 | 33 | <a href="#" data-panel="<?= esc_attr($module->id()); ?>" data-info="<?= esc_attr($module->info()); ?>" class="dashicons-before <?= $module->classes(); ?>"> |
25 | 34 | <span><?= $module->label(); ?></span> |
26 | 35 | </a> |
@@ -1,19 +1,19 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <table class="glbb-grid"> |
4 | 4 | <thead> |
5 | 5 | <tr> |
6 | - <th><?= esc_html__('Timer Name', 'blackbar'); ?></th> |
|
7 | - <th><?= esc_html__('Memory Used', 'blackbar'); ?></th> |
|
8 | - <th><?= esc_html__('Total Time', 'blackbar'); ?></th> |
|
6 | + <th><?= esc_html__( 'Timer Name', 'blackbar' ); ?></th> |
|
7 | + <th><?= esc_html__( 'Memory Used', 'blackbar' ); ?></th> |
|
8 | + <th><?= esc_html__( 'Total Time', 'blackbar' ); ?></th> |
|
9 | 9 | </tr> |
10 | 10 | </thead> |
11 | 11 | <tbody> |
12 | - <?php foreach ($module->entries() as $entry) : ?> |
|
12 | + <?php foreach( $module->entries() as $entry ) : ?> |
|
13 | 13 | <tr> |
14 | - <td><?= esc_html($entry['name']); ?></td> |
|
15 | - <td><?= (string) size_format($entry['memory'], 2); ?></td> |
|
16 | - <td><?= esc_html($entry['time']); ?></td> |
|
14 | + <td><?= esc_html( $entry[ 'name' ] ); ?></td> |
|
15 | + <td><?= (string) size_format( $entry[ 'memory' ], 2 ); ?></td> |
|
16 | + <td><?= esc_html( $entry[ 'time' ] ); ?></td> |
|
17 | 17 | </tr> |
18 | 18 | <?php endforeach; ?> |
19 | 19 | </tbody> |
@@ -4,49 +4,49 @@ |
||
4 | 4 | |
5 | 5 | class Globals extends Module |
6 | 6 | { |
7 | - public function entries(): array |
|
8 | - { |
|
9 | - if (!empty($this->entries)) { |
|
10 | - return $this->entries; |
|
11 | - } |
|
12 | - $globals = apply_filters('blackbar/globals', [ |
|
13 | - 'INPUT_COOKIE' => $_COOKIE, |
|
14 | - 'INPUT_ENV' => $_ENV, |
|
15 | - 'INPUT_GET' => $_GET, |
|
16 | - 'INPUT_POST' => $_POST, |
|
17 | - 'INPUT_SERVER' => $_SERVER, |
|
18 | - 'WP_Screen' => $this->wpscreen(), |
|
19 | - ]); |
|
20 | - $globals = array_filter($globals); |
|
21 | - foreach ($globals as $key => $values) { |
|
22 | - $this->entries[] = [ |
|
23 | - 'name' => $key, |
|
24 | - 'value' => var_export($values, true), |
|
25 | - ]; |
|
26 | - } |
|
27 | - return $this->entries; |
|
28 | - } |
|
7 | + public function entries(): array |
|
8 | + { |
|
9 | + if (!empty($this->entries)) { |
|
10 | + return $this->entries; |
|
11 | + } |
|
12 | + $globals = apply_filters('blackbar/globals', [ |
|
13 | + 'INPUT_COOKIE' => $_COOKIE, |
|
14 | + 'INPUT_ENV' => $_ENV, |
|
15 | + 'INPUT_GET' => $_GET, |
|
16 | + 'INPUT_POST' => $_POST, |
|
17 | + 'INPUT_SERVER' => $_SERVER, |
|
18 | + 'WP_Screen' => $this->wpscreen(), |
|
19 | + ]); |
|
20 | + $globals = array_filter($globals); |
|
21 | + foreach ($globals as $key => $values) { |
|
22 | + $this->entries[] = [ |
|
23 | + 'name' => $key, |
|
24 | + 'value' => var_export($values, true), |
|
25 | + ]; |
|
26 | + } |
|
27 | + return $this->entries; |
|
28 | + } |
|
29 | 29 | |
30 | - public function hasEntries(): bool |
|
31 | - { |
|
32 | - return !empty($this->entries()); |
|
33 | - } |
|
30 | + public function hasEntries(): bool |
|
31 | + { |
|
32 | + return !empty($this->entries()); |
|
33 | + } |
|
34 | 34 | |
35 | - public function label(): string |
|
36 | - { |
|
37 | - return __('Globals', 'blackbar'); |
|
38 | - } |
|
35 | + public function label(): string |
|
36 | + { |
|
37 | + return __('Globals', 'blackbar'); |
|
38 | + } |
|
39 | 39 | |
40 | - protected function wpscreen(): array |
|
41 | - { |
|
42 | - $values = []; |
|
43 | - if (is_admin() && $screen = get_current_screen()) { |
|
44 | - $reflection = new \ReflectionClass($screen); |
|
45 | - $properties = $reflection->getProperties(\ReflectionProperty::IS_PUBLIC); |
|
46 | - foreach ($properties as $property) { |
|
47 | - $values[$property->getName()] = $property->getValue($screen); |
|
48 | - } |
|
49 | - } |
|
50 | - return $values; |
|
51 | - } |
|
40 | + protected function wpscreen(): array |
|
41 | + { |
|
42 | + $values = []; |
|
43 | + if (is_admin() && $screen = get_current_screen()) { |
|
44 | + $reflection = new \ReflectionClass($screen); |
|
45 | + $properties = $reflection->getProperties(\ReflectionProperty::IS_PUBLIC); |
|
46 | + foreach ($properties as $property) { |
|
47 | + $values[$property->getName()] = $property->getValue($screen); |
|
48 | + } |
|
49 | + } |
|
50 | + return $values; |
|
51 | + } |
|
52 | 52 | } |
@@ -6,22 +6,22 @@ discard block |
||
6 | 6 | { |
7 | 7 | public function entries(): array |
8 | 8 | { |
9 | - if (!empty($this->entries)) { |
|
9 | + if( !empty( $this->entries ) ) { |
|
10 | 10 | return $this->entries; |
11 | 11 | } |
12 | - $globals = apply_filters('blackbar/globals', [ |
|
12 | + $globals = apply_filters( 'blackbar/globals', [ |
|
13 | 13 | 'INPUT_COOKIE' => $_COOKIE, |
14 | 14 | 'INPUT_ENV' => $_ENV, |
15 | 15 | 'INPUT_GET' => $_GET, |
16 | 16 | 'INPUT_POST' => $_POST, |
17 | 17 | 'INPUT_SERVER' => $_SERVER, |
18 | 18 | 'WP_Screen' => $this->wpscreen(), |
19 | - ]); |
|
20 | - $globals = array_filter($globals); |
|
21 | - foreach ($globals as $key => $values) { |
|
22 | - $this->entries[] = [ |
|
19 | + ] ); |
|
20 | + $globals = array_filter( $globals ); |
|
21 | + foreach( $globals as $key => $values ) { |
|
22 | + $this->entries[ ] = [ |
|
23 | 23 | 'name' => $key, |
24 | - 'value' => var_export($values, true), |
|
24 | + 'value' => var_export( $values, true ), |
|
25 | 25 | ]; |
26 | 26 | } |
27 | 27 | return $this->entries; |
@@ -29,22 +29,22 @@ discard block |
||
29 | 29 | |
30 | 30 | public function hasEntries(): bool |
31 | 31 | { |
32 | - return !empty($this->entries()); |
|
32 | + return !empty( $this->entries() ); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function label(): string |
36 | 36 | { |
37 | - return __('Globals', 'blackbar'); |
|
37 | + return __( 'Globals', 'blackbar' ); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | protected function wpscreen(): array |
41 | 41 | { |
42 | - $values = []; |
|
43 | - if (is_admin() && $screen = get_current_screen()) { |
|
44 | - $reflection = new \ReflectionClass($screen); |
|
45 | - $properties = $reflection->getProperties(\ReflectionProperty::IS_PUBLIC); |
|
46 | - foreach ($properties as $property) { |
|
47 | - $values[$property->getName()] = $property->getValue($screen); |
|
42 | + $values = [ ]; |
|
43 | + if( is_admin() && $screen = get_current_screen() ) { |
|
44 | + $reflection = new \ReflectionClass( $screen ); |
|
45 | + $properties = $reflection->getProperties( \ReflectionProperty::IS_PUBLIC ); |
|
46 | + foreach( $properties as $property ) { |
|
47 | + $values[ $property->getName() ] = $property->getValue( $screen ); |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | return $values; |