@@ -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 | } |
@@ -25,7 +25,8 @@ discard block |
||
| 25 | 25 | 'FROM', 'GROUP BY', 'INNER JOIN', 'LEFT JOIN', 'LIMIT', |
| 26 | 26 | 'ON DUPLICATE KEY UPDATE', 'ORDER BY', 'OFFSET', ' SET', 'WHERE', |
| 27 | 27 | ]; |
| 28 | - $replace = array_map(function ($value) { |
|
| 28 | + $replace = array_map(function ($value) |
|
| 29 | + { |
|
| 29 | 30 | return PHP_EOL.$value; |
| 30 | 31 | }, $search); |
| 31 | 32 | foreach ($wpdb->queries as $query) { |
@@ -35,7 +36,8 @@ discard block |
||
| 35 | 36 | $sql = str_replace(['( ',' )',' ,'], ['(',')',','], $sql); |
| 36 | 37 | $sql = str_replace($search, $replace, $sql); |
| 37 | 38 | $parts = explode(PHP_EOL, $sql); |
| 38 | - $sql = array_reduce($parts, function ($carry, $part) { |
|
| 39 | + $sql = array_reduce($parts, function ($carry, $part) |
|
| 40 | + { |
|
| 39 | 41 | if (str_starts_with($part, 'SELECT') && strlen($part) > 100) { |
| 40 | 42 | $part = preg_replace('/\s*(,)\s*/', ','.PHP_EOL.' ', $part); |
| 41 | 43 | } |
@@ -89,7 +89,8 @@ discard block |
||
| 89 | 89 | $class = 'glbb-error'; |
| 90 | 90 | $info = sprintf('<span class="glbb-link-info">(%d, %d!)</span>', $entryCount, $errorCount); |
| 91 | 91 | $label = sprintf('%s %s', $label, $info); |
| 92 | - } elseif ($entryCount > 0) { |
|
| 92 | + } |
|
| 93 | + elseif ($entryCount > 0) { |
|
| 93 | 94 | $info = sprintf('<span class="glbb-link-info">(%d)</span>', $entryCount); |
| 94 | 95 | $label = sprintf('%s %s', $label, $info); |
| 95 | 96 | } |
@@ -109,7 +110,8 @@ discard block |
||
| 109 | 110 | if (array_key_exists((int) $errno, static::ERROR_CODES)) { |
| 110 | 111 | $errname = static::ERROR_CODES[$errno]; |
| 111 | 112 | } |
| 112 | - } else { |
|
| 113 | + } |
|
| 114 | + else { |
|
| 113 | 115 | // entry likely stored by filter hook |
| 114 | 116 | $errname = 'Debug'; |
| 115 | 117 | if (array_key_exists($errno, static::MAPPED_ERROR_CODES)) { |
@@ -121,7 +123,8 @@ discard block |
||
| 121 | 123 | $hash = md5($errno.$errname.$message.$location); |
| 122 | 124 | if (array_key_exists($hash, $this->entries)) { |
| 123 | 125 | ++$this->entries[$hash]['count']; |
| 124 | - } else { |
|
| 126 | + } |
|
| 127 | + else { |
|
| 125 | 128 | $this->entries[$hash] = [ |
| 126 | 129 | 'count' => 0, |
| 127 | 130 | 'errname' => $errname, |
@@ -136,9 +139,11 @@ discard block |
||
| 136 | 139 | error_log('1:: '.$message); |
| 137 | 140 | if ($message instanceof \DateTime) { |
| 138 | 141 | $message = $message->format('Y-m-d H:i:s'); |
| 139 | - } elseif (is_object($message) || is_array($message)) { |
|
| 142 | + } |
|
| 143 | + elseif (is_object($message) || is_array($message)) { |
|
| 140 | 144 | $message = (new Dump())->dump($message); |
| 141 | - } else { |
|
| 145 | + } |
|
| 146 | + else { |
|
| 142 | 147 | $message = esc_html(trim((string) $message)); |
| 143 | 148 | } |
| 144 | 149 | $location = trim($location); |
@@ -58,9 +58,11 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | $this->hooks[$action]['callbacks'][$priority][] = sprintf('%s::%s', $object, $method); |
| 61 | - } elseif (is_object($callback['function'])) { |
|
| 61 | + } |
|
| 62 | + elseif (is_object($callback['function'])) { |
|
| 62 | 63 | $this->hooks[$action]['callbacks'][$priority][] = get_class($callback['function']); |
| 63 | - } else { |
|
| 64 | + } |
|
| 65 | + else { |
|
| 64 | 66 | $this->hooks[$action]['callbacks'][$priority][] = $callback['function']; |
| 65 | 67 | } |
| 66 | 68 | ++$this->hooks[$action]['callbacks_count']; |
@@ -84,7 +86,8 @@ discard block |
||
| 84 | 86 | $this->totalActions += $data['count']; |
| 85 | 87 | $this->callbacksForHook($action); |
| 86 | 88 | } |
| 87 | - $this->hooks = array_filter($this->hooks, function ($hook) { |
|
| 89 | + $this->hooks = array_filter($this->hooks, function ($hook) |
|
| 90 | + { |
|
| 88 | 91 | return !empty($hook['callbacks_count']); // skip blackbar callbacks |
| 89 | 92 | }); |
| 90 | 93 | uasort($this->hooks, [$this, 'sortByTime']); |
@@ -74,13 +74,17 @@ |
||
| 74 | 74 | $microtime = microtime(true); |
| 75 | 75 | if ('timer:start' === $hook) { |
| 76 | 76 | $this->app->profiler->start($name); |
| 77 | - } elseif ('timer:stop' === $hook) { |
|
| 77 | + } |
|
| 78 | + elseif ('timer:stop' === $hook) { |
|
| 78 | 79 | $this->app->profiler->stop($name); |
| 79 | - } elseif ('blackbar/profiler/noise' === $hook) { |
|
| 80 | + } |
|
| 81 | + elseif ('blackbar/profiler/noise' === $hook) { |
|
| 80 | 82 | $this->app->profiler->setNoise($microtime); |
| 81 | - } elseif ('blackbar/profiler/start' === $hook) { |
|
| 83 | + } |
|
| 84 | + elseif ('blackbar/profiler/start' === $hook) { |
|
| 82 | 85 | $this->app->profiler->setStart($microtime); |
| 83 | - } elseif ('blackbar/profiler/stop' === $hook) { |
|
| 86 | + } |
|
| 87 | + elseif ('blackbar/profiler/stop' === $hook) { |
|
| 84 | 88 | $this->app->profiler->setStop($microtime); |
| 85 | 89 | } |
| 86 | 90 | } |
@@ -41,7 +41,8 @@ discard block |
||
| 41 | 41 | if (is_string($key) && "\0" === $key[0]) { |
| 42 | 42 | $keyParts = explode("\0", $key); |
| 43 | 43 | $result[] = $keyParts[2].(('*' === $keyParts[1]) ? ':protected' : ':private'); |
| 44 | - } else { |
|
| 44 | + } |
|
| 45 | + else { |
|
| 45 | 46 | $result[] = $key; |
| 46 | 47 | } |
| 47 | 48 | $result[] = '] => '; |
@@ -57,11 +58,14 @@ discard block |
||
| 57 | 58 | ++$this->level; |
| 58 | 59 | if ($subject instanceof \Closure) { |
| 59 | 60 | $this->inspectClosure($subject); |
| 60 | - } elseif (is_object($subject)) { |
|
| 61 | + } |
|
| 62 | + elseif (is_object($subject)) { |
|
| 61 | 63 | $this->inspectObject($subject); |
| 62 | - } elseif (is_array($subject)) { |
|
| 64 | + } |
|
| 65 | + elseif (is_array($subject)) { |
|
| 63 | 66 | $this->inspectArray($subject); |
| 64 | - } else { |
|
| 67 | + } |
|
| 68 | + else { |
|
| 65 | 69 | $this->inspectPrimitive($subject); |
| 66 | 70 | } |
| 67 | 71 | --$this->level; |
@@ -96,7 +100,8 @@ discard block |
||
| 96 | 100 | protected function inspectClosure(\Closure $subject) |
| 97 | 101 | { |
| 98 | 102 | $reflection = new \ReflectionFunction($subject); |
| 99 | - $params = array_map(function ($param) { |
|
| 103 | + $params = array_map(function ($param) |
|
| 104 | + { |
|
| 100 | 105 | return ($param->isPassedByReference() ? '&$' : '$').$param->name; |
| 101 | 106 | }, $reflection->getParameters()); |
| 102 | 107 | $this->result[] = 'Closure ('.implode(', ', $params).') { ... }'."\n"; |
@@ -115,7 +120,8 @@ discard block |
||
| 115 | 120 | } |
| 116 | 121 | if ($subject instanceof \ArrayObject) { |
| 117 | 122 | $this->result[] = $classname." ArrayObject (\n"; |
| 118 | - } else { |
|
| 123 | + } |
|
| 124 | + else { |
|
| 119 | 125 | $this->result[] = $classname." Object (\n"; |
| 120 | 126 | $subject = (array) $subject; |
| 121 | 127 | } |
@@ -136,9 +142,11 @@ discard block |
||
| 136 | 142 | { |
| 137 | 143 | if (true === $subject) { |
| 138 | 144 | $subject = '(bool) true'; |
| 139 | - } elseif (false === $subject) { |
|
| 145 | + } |
|
| 146 | + elseif (false === $subject) { |
|
| 140 | 147 | $subject = '(bool) false'; |
| 141 | - } elseif (null === $subject) { |
|
| 148 | + } |
|
| 149 | + elseif (null === $subject) { |
|
| 142 | 150 | $subject = '(null)'; |
| 143 | 151 | } |
| 144 | 152 | $this->result[] = $subject."\n"; |
@@ -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()); ?>" class="dashicons-before <?= $module->id(); ?>"> |
| 25 | 34 | <span><?= $module->label(); ?></span> |
| 26 | 35 | </a> |
@@ -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> |
@@ -7,7 +7,8 @@ discard block |
||
| 7 | 7 | <td><?= __('No entries found.', 'blackbar'); ?></td> |
| 8 | 8 | </tr> |
| 9 | 9 | </tbody> |
| 10 | - <?php else : ?> |
|
| 10 | + <?php else { |
|
| 11 | + : ?> |
|
| 11 | 12 | <thead> |
| 12 | 13 | <tr> |
| 13 | 14 | <th>Timer Name</th> |
@@ -20,7 +21,9 @@ discard block |
||
| 20 | 21 | <tbody> |
| 21 | 22 | <?php foreach ($profiler->entries() as $entry) : ?> |
| 22 | 23 | <tr> |
| 23 | - <td><?= esc_html($entry['name']); ?></td> |
|
| 24 | + <td><?= esc_html($entry['name']); |
|
| 25 | +} |
|
| 26 | +?></td> |
|
| 24 | 27 | <td style="text-align: right;"><?= esc_html($entry['memory']); ?> KB</td> |
| 25 | 28 | <td style="text-align: right;"><?= esc_html($entry['start']); ?></td> |
| 26 | 29 | <td style="text-align: right;"><?= esc_html($entry['stop']); ?></td> |