@@ -6,7 +6,8 @@ discard block |
||
| 6 | 6 | * @return array |
| 7 | 7 | * @see https://docs.gravityforms.com/gform_noconflict_scripts/ |
| 8 | 8 | */ |
| 9 | -add_filter('gform_noconflict_scripts', function (array $scripts) { |
|
| 9 | +add_filter('gform_noconflict_scripts', function (array $scripts) |
|
| 10 | +{ |
|
| 10 | 11 | $scripts[] = 'blackbar'; |
| 11 | 12 | return $scripts; |
| 12 | 13 | }); |
@@ -15,7 +16,8 @@ discard block |
||
| 15 | 16 | * @return array |
| 16 | 17 | * @see https://docs.gravityforms.com/gform_noconflict_styles/ |
| 17 | 18 | */ |
| 18 | -add_filter('gform_noconflict_styles', function (array $styles) { |
|
| 19 | +add_filter('gform_noconflict_styles', function (array $styles) |
|
| 20 | +{ |
|
| 19 | 21 | $styles[] = 'blackbar'; |
| 20 | 22 | $styles[] = 'blackbar-syntax'; |
| 21 | 23 | return $styles; |
@@ -2,7 +2,8 @@ |
||
| 2 | 2 | |
| 3 | 3 | defined('WPINC') || die; |
| 4 | 4 | |
| 5 | -spl_autoload_register(function ($className) { |
|
| 5 | +spl_autoload_register(function ($className) |
|
| 6 | +{ |
|
| 6 | 7 | $namespaces = [ |
| 7 | 8 | 'GeminiLabs\\BlackBar\\' => __DIR__.'/plugin/', |
| 8 | 9 | 'GeminiLabs\\BlackBar\\Tests\\' => __DIR__.'/tests/', |
@@ -124,7 +124,8 @@ |
||
| 124 | 124 | sprintf($messages['wrong_version'], $messages['php_version'].' '.$this->versions['php']), |
| 125 | 125 | sprintf($messages['update_php'], PHP_VERSION).'</p><p>'.$rollbackMessage |
| 126 | 126 | ); |
| 127 | - } elseif (!$this->isWpValid()) { |
|
| 127 | + } |
|
| 128 | + elseif (!$this->isWpValid()) { |
|
| 128 | 129 | printf($noticeTemplate, |
| 129 | 130 | sprintf($messages['notice'], $pluginName), |
| 130 | 131 | sprintf($messages['wrong_version'], $messages['wp_version'].' '.$this->versions['wordpress']), |
@@ -30,12 +30,15 @@ |
||
| 30 | 30 | && class_exists('\GeminiLabs\Castor\Helpers\Development') |
| 31 | 31 | && method_exists('\GeminiLabs\Castor\Helpers\Development', 'templatePaths')) { // @phpstan-ignore-line |
| 32 | 32 | $this->entries = \GeminiLabs\Castor\Facades\Development::templatePaths(); |
| 33 | - } else { |
|
| 34 | - $files = array_values(array_filter(get_included_files(), function ($file) { |
|
| 33 | + } |
|
| 34 | + else { |
|
| 35 | + $files = array_values(array_filter(get_included_files(), function ($file) |
|
| 36 | + { |
|
| 35 | 37 | $bool = false !== strpos($file, '/themes/') && false === strpos($file, '/functions.php'); |
| 36 | 38 | return (bool) apply_filters('blackbar/templates/file', $bool, $file); |
| 37 | 39 | })); |
| 38 | - $this->entries = array_map(function ($file) { |
|
| 40 | + $this->entries = array_map(function ($file) |
|
| 41 | + { |
|
| 39 | 42 | return str_replace(trailingslashit(WP_CONTENT_DIR), '', $file); |
| 40 | 43 | }, $files); |
| 41 | 44 | } |
@@ -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 | } |