@@ -55,7 +55,8 @@ |
||
| 55 | 55 | do_action('blackbar/profiler/start'); // start profiler |
| 56 | 56 | do_action('blackbar/profiler/noise'); // measure profiler noise |
| 57 | 57 | add_action('plugins_loaded', [$controller, 'registerLanguages']); |
| 58 | - add_action('init', function () use ($controller) { |
|
| 58 | + add_action('init', function () use ($controller) |
|
| 59 | + { |
|
| 59 | 60 | if (!apply_filters('blackbar/enabled', current_user_can('administrator'))) { |
| 60 | 61 | return; |
| 61 | 62 | } |
@@ -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_queries_sql" placeholder="<?= esc_attr__('Find SQL containing', 'blackbar'); ?>"> |
|
| 14 | + <input type="text" id="glbb_queries_sql" placeholder="<?= esc_attr__('Find SQL containing', 'blackbar'); |
|
| 15 | +} |
|
| 16 | +?>"> |
|
| 14 | 17 | <input type="text" id="glbb_queries_min_time" placeholder="<?= esc_attr__('Minimum execution time', 'blackbar'); ?>"> |
| 15 | 18 | <select id="glbb_queries_sort_by"> |
| 16 | 19 | <option value><?= esc_html__('Sort by execution time', 'blackbar'); ?></option> |
@@ -36,7 +36,8 @@ discard block |
||
| 36 | 36 | if (is_string($key) && "\0" === $key[0]) { |
| 37 | 37 | $keyParts = explode("\0", $key); |
| 38 | 38 | $result[] = $keyParts[2].(('*' === $keyParts[1]) ? ':protected' : ':private'); |
| 39 | - } else { |
|
| 39 | + } |
|
| 40 | + else { |
|
| 40 | 41 | $result[] = $key; |
| 41 | 42 | } |
| 42 | 43 | $result[] = '] => '; |
@@ -51,11 +52,14 @@ discard block |
||
| 51 | 52 | ++$this->level; |
| 52 | 53 | if ($subject instanceof \Closure) { |
| 53 | 54 | $this->inspectClosure($subject); |
| 54 | - } elseif (is_object($subject)) { |
|
| 55 | + } |
|
| 56 | + elseif (is_object($subject)) { |
|
| 55 | 57 | $this->inspectObject($subject); |
| 56 | - } elseif (is_array($subject)) { |
|
| 58 | + } |
|
| 59 | + elseif (is_array($subject)) { |
|
| 57 | 60 | $this->inspectArray($subject); |
| 58 | - } else { |
|
| 61 | + } |
|
| 62 | + else { |
|
| 59 | 63 | $this->inspectPrimitive($subject); |
| 60 | 64 | } |
| 61 | 65 | --$this->level; |
@@ -84,7 +88,8 @@ discard block |
||
| 84 | 88 | protected function inspectClosure(\Closure $subject): void |
| 85 | 89 | { |
| 86 | 90 | $reflection = new \ReflectionFunction($subject); |
| 87 | - $params = array_map(function ($param) { |
|
| 91 | + $params = array_map(function ($param) |
|
| 92 | + { |
|
| 88 | 93 | return ($param->isPassedByReference() ? '&$' : '$').$param->name; |
| 89 | 94 | }, $reflection->getParameters()); |
| 90 | 95 | $this->result[] = 'Closure ('.implode(', ', $params).') { ... }'."\n"; |
@@ -102,7 +107,8 @@ discard block |
||
| 102 | 107 | } |
| 103 | 108 | if ($subject instanceof \ArrayObject) { |
| 104 | 109 | $this->result[] = $classname." ArrayObject (\n"; |
| 105 | - } else { |
|
| 110 | + } |
|
| 111 | + else { |
|
| 106 | 112 | $this->result[] = $classname." Object (\n"; |
| 107 | 113 | $subject = (array) $subject; |
| 108 | 114 | } |
@@ -122,9 +128,11 @@ discard block |
||
| 122 | 128 | { |
| 123 | 129 | if (true === $subject) { |
| 124 | 130 | $subject = '(bool) true'; |
| 125 | - } elseif (false === $subject) { |
|
| 131 | + } |
|
| 132 | + elseif (false === $subject) { |
|
| 126 | 133 | $subject = '(bool) false'; |
| 127 | - } elseif (null === $subject) { |
|
| 134 | + } |
|
| 135 | + elseif (null === $subject) { |
|
| 128 | 136 | $subject = '(null)'; |
| 129 | 137 | } |
| 130 | 138 | $this->result[] = $subject."\n"; |
@@ -74,7 +74,8 @@ discard block |
||
| 74 | 74 | if (array_key_exists((int) $errno, static::ERROR_CODES)) { |
| 75 | 75 | $errname = static::ERROR_CODES[$errno]; |
| 76 | 76 | } |
| 77 | - } else { // entry likely stored by filter hook |
|
| 77 | + } |
|
| 78 | + else { // entry likely stored by filter hook |
|
| 78 | 79 | $errname = 'Debug'; |
| 79 | 80 | if (array_key_exists($errno, static::MAPPED_ERROR_CODES)) { |
| 80 | 81 | $errname = $errno; |
@@ -85,7 +86,8 @@ discard block |
||
| 85 | 86 | $hash = md5($errno.$errname.$message.$location); |
| 86 | 87 | if (array_key_exists($hash, $this->entries)) { |
| 87 | 88 | ++$this->entries[$hash]['count']; |
| 88 | - } else { |
|
| 89 | + } |
|
| 90 | + else { |
|
| 89 | 91 | $this->entries[$hash] = [ |
| 90 | 92 | 'count' => 0, |
| 91 | 93 | 'errname' => $errname, |
@@ -99,9 +101,11 @@ discard block |
||
| 99 | 101 | { |
| 100 | 102 | if ($message instanceof \DateTime) { |
| 101 | 103 | $message = $message->format('Y-m-d H:i:s'); |
| 102 | - } elseif (is_object($message) || is_array($message)) { |
|
| 104 | + } |
|
| 105 | + elseif (is_object($message) || is_array($message)) { |
|
| 103 | 106 | $message = (new Dump())->dump($message); |
| 104 | - } else { |
|
| 107 | + } |
|
| 108 | + else { |
|
| 105 | 109 | $message = esc_html(trim((string) $message)); |
| 106 | 110 | } |
| 107 | 111 | $location = trim($location); |
@@ -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> |
@@ -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> |
@@ -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> |
@@ -26,7 +26,8 @@ |
||
| 26 | 26 | if (!empty($this->hooks)) { |
| 27 | 27 | return $this->hooks; |
| 28 | 28 | } |
| 29 | - array_walk($this->entries, function (&$data) { |
|
| 29 | + array_walk($this->entries, function (&$data) |
|
| 30 | + { |
|
| 30 | 31 | $total = $this->totalTimeForHook($data); |
| 31 | 32 | $perCall = (int) round($total / $data['count']); |
| 32 | 33 | $data['per_call'] = $this->formatTime($perCall); |
@@ -13,7 +13,8 @@ discard block |
||
| 13 | 13 | 'FROM', 'GROUP BY', 'INNER JOIN', 'LEFT JOIN', 'LIMIT', |
| 14 | 14 | 'ON DUPLICATE KEY UPDATE', 'ORDER BY', 'OFFSET', ' SET', 'WHERE', |
| 15 | 15 | ]; |
| 16 | - $replace = array_map(function ($value) { |
|
| 16 | + $replace = array_map(function ($value) |
|
| 17 | + { |
|
| 17 | 18 | return PHP_EOL.$value; |
| 18 | 19 | }, $search); |
| 19 | 20 | foreach ($wpdb->queries as $query) { |
@@ -22,7 +23,8 @@ discard block |
||
| 22 | 23 | $sql = str_replace(['( ', ' )', ' ,'], ['(', ')', ','], $sql); |
| 23 | 24 | $sql = str_replace($search, $replace, $sql); |
| 24 | 25 | $parts = explode(PHP_EOL, $sql); |
| 25 | - $sql = array_reduce($parts, function ($carry, $part) { |
|
| 26 | + $sql = array_reduce($parts, function ($carry, $part) |
|
| 27 | + { |
|
| 26 | 28 | if (str_starts_with($part, 'SELECT') && strlen($part) > 100) { |
| 27 | 29 | $part = preg_replace('/\s*(,)\s*/', ','.PHP_EOL.' ', $part); |
| 28 | 30 | } |