@@ -53,8 +53,7 @@ discard block |
||
| 53 | 53 | $hash = md5( $errno.$errstr.$errfile.$errline ); |
| 54 | 54 | if( array_key_exists( $hash, $this->errors )) { |
| 55 | 55 | $this->errors[$hash]['count']++; |
| 56 | - } |
|
| 57 | - else { |
|
| 56 | + } else { |
|
| 58 | 57 | $this->errors[$hash] = array( |
| 59 | 58 | "errno" => $errno, |
| 60 | 59 | "message" => $errstr, |
@@ -119,7 +118,9 @@ discard block |
||
| 119 | 118 | */ |
| 120 | 119 | public function initProfiler() |
| 121 | 120 | { |
| 122 | - if( func_get_arg(0) != static::DEBUG )return; |
|
| 121 | + if( func_get_arg(0) != static::DEBUG ) { |
|
| 122 | + return; |
|
| 123 | + } |
|
| 123 | 124 | $this->profiler->trace( func_get_arg(1) ); |
| 124 | 125 | } |
| 125 | 126 | |
@@ -140,7 +141,9 @@ discard block |
||
| 140 | 141 | public function render( $view, array $data = array() ) |
| 141 | 142 | { |
| 142 | 143 | $file = $this->path( sprintf( 'views/%s.php', str_replace( '.php', '', $view ))); |
| 143 | - if( !file_exists( $file ))return; |
|
| 144 | + if( !file_exists( $file )) { |
|
| 145 | + return; |
|
| 146 | + } |
|
| 144 | 147 | extract( $data ); |
| 145 | 148 | include $file; |
| 146 | 149 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | public function __construct() |
| 18 | 18 | { |
| 19 | - $this->file = realpath( dirname( __DIR__ ).'/'.static::ID.'.php' ); |
|
| 19 | + $this->file = realpath(dirname(__DIR__).'/'.static::ID.'.php'); |
|
| 20 | 20 | $this->profiler = new Profiler; |
| 21 | 21 | } |
| 22 | 22 | |
@@ -27,9 +27,9 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | public function enqueueAssets() |
| 29 | 29 | { |
| 30 | - wp_enqueue_script( static::ID, $this->url( 'assets/main.js' )); |
|
| 31 | - wp_enqueue_style( static::ID, $this->url( 'assets/main.css' ), array( 'dashicons' )); |
|
| 32 | - wp_enqueue_style( static::ID.'-syntax', $this->url( 'assets/syntax.css' )); |
|
| 30 | + wp_enqueue_script(static::ID, $this->url('assets/main.js')); |
|
| 31 | + wp_enqueue_style(static::ID, $this->url('assets/main.css'), array('dashicons')); |
|
| 32 | + wp_enqueue_style(static::ID.'-syntax', $this->url('assets/syntax.css')); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @param int $errline |
| 40 | 40 | * @return void |
| 41 | 41 | */ |
| 42 | - public function errorHandler( $errno, $errstr, $errfile, $errline ) |
|
| 42 | + public function errorHandler($errno, $errstr, $errfile, $errline) |
|
| 43 | 43 | { |
| 44 | 44 | $errorCodes = array( |
| 45 | 45 | 2 => 'Warning', |
@@ -47,11 +47,11 @@ discard block |
||
| 47 | 47 | 2048 => 'Strict', |
| 48 | 48 | 8192 => 'Deprecated', |
| 49 | 49 | ); |
| 50 | - $errname = array_key_exists( $errno, $errorCodes ) |
|
| 50 | + $errname = array_key_exists($errno, $errorCodes) |
|
| 51 | 51 | ? $errorCodes[$errno] |
| 52 | 52 | : 'Unknown'; |
| 53 | - $hash = md5( $errno.$errstr.$errfile.$errline ); |
|
| 54 | - if( array_key_exists( $hash, $this->errors )) { |
|
| 53 | + $hash = md5($errno.$errstr.$errfile.$errline); |
|
| 54 | + if (array_key_exists($hash, $this->errors)) { |
|
| 55 | 55 | $this->errors[$hash]['count']++; |
| 56 | 56 | } |
| 57 | 57 | else { |
@@ -70,15 +70,15 @@ discard block |
||
| 70 | 70 | * @param string $classes |
| 71 | 71 | * @return string |
| 72 | 72 | */ |
| 73 | - public function filterBodyClasses( $classes ) |
|
| 73 | + public function filterBodyClasses($classes) |
|
| 74 | 74 | { |
| 75 | - return trim( $classes.' '.static::ID ); |
|
| 75 | + return trim($classes.' '.static::ID); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * @return array |
| 80 | 80 | */ |
| 81 | - public function filterNoconflictScripts( $scripts ) |
|
| 81 | + public function filterNoconflictScripts($scripts) |
|
| 82 | 82 | { |
| 83 | 83 | $scripts[] = static::ID; |
| 84 | 84 | return $scripts; |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | /** |
| 88 | 88 | * @return array |
| 89 | 89 | */ |
| 90 | - public function filterNoconflictStyles( $styles ) |
|
| 90 | + public function filterNoconflictStyles($styles) |
|
| 91 | 91 | { |
| 92 | 92 | $styles[] = static::ID; |
| 93 | 93 | $styles[] = static::ID.'-syntax'; |
@@ -99,18 +99,18 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | public function init() |
| 101 | 101 | { |
| 102 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueueAssets' )); |
|
| 103 | - add_action( 'admin_footer', array( $this, 'renderBar' )); |
|
| 104 | - add_action( 'plugins_loaded', array( $this, 'registerLanguages' )); |
|
| 105 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueueAssets' )); |
|
| 106 | - add_action( 'wp_footer', array( $this, 'renderBar' )); |
|
| 107 | - add_filter( 'admin_body_class', array( $this, 'filterBodyClasses' )); |
|
| 108 | - add_filter( 'all', array( $this, 'initProfiler' )); |
|
| 109 | - add_filter( 'gform_noconflict_scripts', array( $this, 'filterNoconflictScripts' )); |
|
| 110 | - add_filter( 'gform_noconflict_styles', array( $this, 'filterNoconflictStyles' )); |
|
| 111 | - apply_filters( 'debug', 'Profiler Started' ); |
|
| 112 | - apply_filters( 'debug', 'blackbar/profiler/noise' ); |
|
| 113 | - set_error_handler( array( $this, 'errorHandler' ), E_ALL|E_STRICT ); |
|
| 102 | + add_action('admin_enqueue_scripts', array($this, 'enqueueAssets')); |
|
| 103 | + add_action('admin_footer', array($this, 'renderBar')); |
|
| 104 | + add_action('plugins_loaded', array($this, 'registerLanguages')); |
|
| 105 | + add_action('wp_enqueue_scripts', array($this, 'enqueueAssets')); |
|
| 106 | + add_action('wp_footer', array($this, 'renderBar')); |
|
| 107 | + add_filter('admin_body_class', array($this, 'filterBodyClasses')); |
|
| 108 | + add_filter('all', array($this, 'initProfiler')); |
|
| 109 | + add_filter('gform_noconflict_scripts', array($this, 'filterNoconflictScripts')); |
|
| 110 | + add_filter('gform_noconflict_styles', array($this, 'filterNoconflictStyles')); |
|
| 111 | + apply_filters('debug', 'Profiler Started'); |
|
| 112 | + apply_filters('debug', 'blackbar/profiler/noise'); |
|
| 113 | + set_error_handler(array($this, 'errorHandler'), E_ALL|E_STRICT); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -119,8 +119,8 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | public function initProfiler() |
| 121 | 121 | { |
| 122 | - if( func_get_arg(0) != static::DEBUG )return; |
|
| 123 | - $this->profiler->trace( func_get_arg(1) ); |
|
| 122 | + if (func_get_arg(0) != static::DEBUG)return; |
|
| 123 | + $this->profiler->trace(func_get_arg(1)); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | public function registerLanguages() |
| 130 | 130 | { |
| 131 | - load_plugin_textdomain( static::ID, false, plugin_basename( $this->path() ).static::LANG ); |
|
| 131 | + load_plugin_textdomain(static::ID, false, plugin_basename($this->path()).static::LANG); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -137,11 +137,11 @@ discard block |
||
| 137 | 137 | * @param string $view |
| 138 | 138 | * @return void |
| 139 | 139 | */ |
| 140 | - public function render( $view, array $data = array() ) |
|
| 140 | + public function render($view, array $data = array()) |
|
| 141 | 141 | { |
| 142 | - $file = $this->path( sprintf( 'views/%s.php', str_replace( '.php', '', $view ))); |
|
| 143 | - if( !file_exists( $file ))return; |
|
| 144 | - extract( $data ); |
|
| 142 | + $file = $this->path(sprintf('views/%s.php', str_replace('.php', '', $view))); |
|
| 143 | + if (!file_exists($file))return; |
|
| 144 | + extract($data); |
|
| 145 | 145 | include $file; |
| 146 | 146 | } |
| 147 | 147 | |
@@ -152,8 +152,8 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | public function renderBar() |
| 154 | 154 | { |
| 155 | - apply_filters( 'debug', 'Profiler Stopped' ); |
|
| 156 | - $this->render( 'debug-bar', array( |
|
| 155 | + apply_filters('debug', 'Profiler Stopped'); |
|
| 156 | + $this->render('debug-bar', array( |
|
| 157 | 157 | 'blackbar' => $this, |
| 158 | 158 | 'errors' => $this->getErrors(), |
| 159 | 159 | 'errorsLabel' => $this->getErrorsLabel(), |
@@ -167,9 +167,9 @@ discard block |
||
| 167 | 167 | /** |
| 168 | 168 | * @return string |
| 169 | 169 | */ |
| 170 | - protected function convertToMiliseconds( $time, $decimals = 2 ) |
|
| 170 | + protected function convertToMiliseconds($time, $decimals = 2) |
|
| 171 | 171 | { |
| 172 | - return number_format( $time * 1000, $decimals ); |
|
| 172 | + return number_format($time * 1000, $decimals); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | /** |
@@ -178,16 +178,16 @@ discard block |
||
| 178 | 178 | protected function getErrors() |
| 179 | 179 | { |
| 180 | 180 | $errors = array(); |
| 181 | - foreach( $this->errors as $error ) { |
|
| 182 | - if( $error['errno'] == E_WARNING ) { |
|
| 181 | + foreach ($this->errors as $error) { |
|
| 182 | + if ($error['errno'] == E_WARNING) { |
|
| 183 | 183 | $error['name'] = '<span class="glbb-error">'.$error['name'].'</span>'; |
| 184 | 184 | } |
| 185 | - if( $error['count'] > 1 ) { |
|
| 185 | + if ($error['count'] > 1) { |
|
| 186 | 186 | $error['name'] .= ' ('.$error['count'].')'; |
| 187 | 187 | } |
| 188 | 188 | $errors[] = array( |
| 189 | 189 | 'name' => $error['name'], |
| 190 | - 'message' => sprintf( __( '%s on line %s in file %s', 'blackbar' ), |
|
| 190 | + 'message' => sprintf(__('%s on line %s in file %s', 'blackbar'), |
|
| 191 | 191 | $error['message'], |
| 192 | 192 | $error['line'], |
| 193 | 193 | $error['file'] |
@@ -203,14 +203,14 @@ discard block |
||
| 203 | 203 | protected function getErrorsLabel() |
| 204 | 204 | { |
| 205 | 205 | $warningCount = 0; |
| 206 | - foreach( $this->errors as $error ) { |
|
| 207 | - if( $error['errno'] == E_WARNING ) { |
|
| 206 | + foreach ($this->errors as $error) { |
|
| 207 | + if ($error['errno'] == E_WARNING) { |
|
| 208 | 208 | $warningCount++; |
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | - $errorCount = count( $this->errors ); |
|
| 212 | - $warnings = $warningCount > 0 ? sprintf( ', %d!', $warningCount ) : ''; |
|
| 213 | - return sprintf( __( 'Errors (%s)', 'blackbar' ), $errorCount.$warnings ); |
|
| 211 | + $errorCount = count($this->errors); |
|
| 212 | + $warnings = $warningCount > 0 ? sprintf(', %d!', $warningCount) : ''; |
|
| 213 | + return sprintf(__('Errors (%s)', 'blackbar'), $errorCount.$warnings); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | /** |
@@ -218,8 +218,8 @@ discard block |
||
| 218 | 218 | */ |
| 219 | 219 | protected function getProfilerLabel() |
| 220 | 220 | { |
| 221 | - $profilerTime = $this->convertToMiliseconds( $this->profiler->getTotalTime(), 0 ); |
|
| 222 | - return sprintf( __( 'Profiler (%s ms)', 'blackbar' ), $profilerTime ); |
|
| 221 | + $profilerTime = $this->convertToMiliseconds($this->profiler->getTotalTime(), 0); |
|
| 222 | + return sprintf(__('Profiler (%s ms)', 'blackbar'), $profilerTime); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | /** |
@@ -240,14 +240,14 @@ discard block |
||
| 240 | 240 | 'SET', |
| 241 | 241 | 'WHERE', |
| 242 | 242 | ); |
| 243 | - $replace = array_map( function( $value ) { |
|
| 243 | + $replace = array_map(function($value) { |
|
| 244 | 244 | return PHP_EOL.$value; |
| 245 | - }, $search ); |
|
| 246 | - foreach( $wpdb->queries as $query ) { |
|
| 247 | - $miliseconds = number_format( round( $query[1] * 1000, 4 ), 4 ); |
|
| 248 | - $sql = preg_replace( '/\s\s+/', ' ', trim( $query[0] )); |
|
| 249 | - $sql = str_replace( PHP_EOL, ' ', $sql ); |
|
| 250 | - $sql = str_replace( $search, $replace, $sql ); |
|
| 245 | + }, $search); |
|
| 246 | + foreach ($wpdb->queries as $query) { |
|
| 247 | + $miliseconds = number_format(round($query[1] * 1000, 4), 4); |
|
| 248 | + $sql = preg_replace('/\s\s+/', ' ', trim($query[0])); |
|
| 249 | + $sql = str_replace(PHP_EOL, ' ', $sql); |
|
| 250 | + $sql = str_replace($search, $replace, $sql); |
|
| 251 | 251 | $queries[] = array( |
| 252 | 252 | 'ms' => $miliseconds, |
| 253 | 253 | 'sql' => $sql, |
@@ -263,29 +263,29 @@ discard block |
||
| 263 | 263 | { |
| 264 | 264 | global $wpdb; |
| 265 | 265 | $queryTime = 0; |
| 266 | - foreach( $wpdb->queries as $query ) { |
|
| 266 | + foreach ($wpdb->queries as $query) { |
|
| 267 | 267 | $queryTime += $query[1]; |
| 268 | 268 | } |
| 269 | - $queriesCount = '<span class="glbb-queries-count">'.count( $wpdb->queries ).'</span>'; |
|
| 270 | - $queriesTime = '<span class="glbb-queries-time">'.$this->convertToMiliseconds( $queryTime ).'</span>'; |
|
| 271 | - return sprintf( __( 'SQL (%s queries in %s ms)', 'blackbar' ), $queriesCount, $queriesTime ); |
|
| 269 | + $queriesCount = '<span class="glbb-queries-count">'.count($wpdb->queries).'</span>'; |
|
| 270 | + $queriesTime = '<span class="glbb-queries-time">'.$this->convertToMiliseconds($queryTime).'</span>'; |
|
| 271 | + return sprintf(__('SQL (%s queries in %s ms)', 'blackbar'), $queriesCount, $queriesTime); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | /** |
| 275 | 275 | * @param string $file |
| 276 | 276 | * @return string |
| 277 | 277 | */ |
| 278 | - protected function path( $file = '' ) |
|
| 278 | + protected function path($file = '') |
|
| 279 | 279 | { |
| 280 | - return plugin_dir_path( $this->file ).ltrim( trim( $file ), '/' ); |
|
| 280 | + return plugin_dir_path($this->file).ltrim(trim($file), '/'); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | /** |
| 284 | 284 | * @param string $path |
| 285 | 285 | * @return string |
| 286 | 286 | */ |
| 287 | - protected function url( $path = '' ) |
|
| 287 | + protected function url($path = '') |
|
| 288 | 288 | { |
| 289 | - return esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' )); |
|
| 289 | + return esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/')); |
|
| 290 | 290 | } |
| 291 | 291 | } |
@@ -1,3 +1,3 @@ |
||
| 1 | -<?php defined( 'WPINC' ) || die; |
|
| 1 | +<?php defined('WPINC') || die; |
|
| 2 | 2 | |
| 3 | 3 | Development::printTemplatePaths(); |
@@ -1,7 +1,7 @@ |
||
| 1 | -<?php defined( 'WPINC' ) || die; ?> |
|
| 1 | +<?php defined('WPINC') || die; ?> |
|
| 2 | 2 | |
| 3 | -<pre><code class="php">$_GET = <?= esc_html( var_export( $_GET, true )); ?>;</code></pre><br/> |
|
| 4 | -<pre><code class="php">$_POST = <?= esc_html( var_export( $_POST, true )); ?>;</code></pre><br/> |
|
| 5 | -<pre><code class="php">$_COOKIE = <?= esc_html( var_export( $_COOKIE, true )); ?>;</code></pre><br/> |
|
| 6 | -<pre><code class="php">$_SESSION = <?= esc_html( var_export( $_SESSION, true )); ?>;</code></pre><br/> |
|
| 7 | -<pre><code class="php">$_SERVER = <?= esc_html( var_export( $_SERVER, true )); ?>;</code></pre><br/> |
|
| 3 | +<pre><code class="php">$_GET = <?= esc_html(var_export($_GET, true)); ?>;</code></pre><br/> |
|
| 4 | +<pre><code class="php">$_POST = <?= esc_html(var_export($_POST, true)); ?>;</code></pre><br/> |
|
| 5 | +<pre><code class="php">$_COOKIE = <?= esc_html(var_export($_COOKIE, true)); ?>;</code></pre><br/> |
|
| 6 | +<pre><code class="php">$_SESSION = <?= esc_html(var_export($_SESSION, true)); ?>;</code></pre><br/> |
|
| 7 | +<pre><code class="php">$_SERVER = <?= esc_html(var_export($_SERVER, true)); ?>;</code></pre><br/> |
|
@@ -1,12 +1,12 @@ |
||
| 1 | -<?php defined( 'WPINC' ) || die; ?> |
|
| 1 | +<?php defined('WPINC') || die; ?> |
|
| 2 | 2 | |
| 3 | 3 | <table> |
| 4 | 4 | <tbody> |
| 5 | - <?php foreach( $profiler->getMeasure() as $timer ) : ?> |
|
| 5 | + <?php foreach ($profiler->getMeasure() as $timer) : ?> |
|
| 6 | 6 | <tr> |
| 7 | - <td><?= $profiler->getNameString( $timer ); ?></td> |
|
| 8 | - <td class="glbb-number"><?= $profiler->getTimeString( $timer ); ?></td> |
|
| 9 | - <td><?= $profiler->getMemoryString( $timer ); ?></td> |
|
| 7 | + <td><?= $profiler->getNameString($timer); ?></td> |
|
| 8 | + <td class="glbb-number"><?= $profiler->getTimeString($timer); ?></td> |
|
| 9 | + <td><?= $profiler->getMemoryString($timer); ?></td> |
|
| 10 | 10 | </tr> |
| 11 | 11 | <?php endforeach; ?> |
| 12 | 12 | </tbody> |
@@ -1,32 +1,32 @@ |
||
| 1 | -<?php defined( 'WPINC' ) || die; |
|
| 2 | -$isCastorTheme = class_exists( '\GeminiLabs\Castor\Application' ); |
|
| 1 | +<?php defined('WPINC') || die; |
|
| 2 | +$isCastorTheme = class_exists('\GeminiLabs\Castor\Application'); |
|
| 3 | 3 | ?> |
| 4 | 4 | |
| 5 | 5 | <div id="glbb-debug-bar"> |
| 6 | - <a href="#" class="glbb-toggle glbb-off"><?= __( 'Toggle', 'blackbar' ); ?></a> |
|
| 7 | - <a href="javascript:Blackbar.switchPanel('glbb-globals')" class="glbb-globals"><?= __( 'Globals', 'blackbar' ); ?></a> |
|
| 6 | + <a href="#" class="glbb-toggle glbb-off"><?= __('Toggle', 'blackbar'); ?></a> |
|
| 7 | + <a href="javascript:Blackbar.switchPanel('glbb-globals')" class="glbb-globals"><?= __('Globals', 'blackbar'); ?></a> |
|
| 8 | 8 | <a href="javascript:Blackbar.switchPanel('glbb-profiler')" class="glbb-profiler"><?= $profilerLabel; ?></a> |
| 9 | 9 | <a href="javascript:Blackbar.switchPanel('glbb-queries')" class="glbb-queries"><?= $queriesLabel; ?></a> |
| 10 | - <?php if( $isCastorTheme ) : ?> |
|
| 11 | - <a href="javascript:Blackbar.switchPanel('glbb-templates')" class="glbb-templates"><?= __( 'Templates', 'blackbar' ); ?></a> |
|
| 10 | + <?php if ($isCastorTheme) : ?> |
|
| 11 | + <a href="javascript:Blackbar.switchPanel('glbb-templates')" class="glbb-templates"><?= __('Templates', 'blackbar'); ?></a> |
|
| 12 | 12 | <?php endif; ?> |
| 13 | 13 | <a href="javascript:Blackbar.switchPanel('glbb-errors')" class="glbb-errors"><?= $errorsLabel; ?></a> |
| 14 | - <a href="javascript:Blackbar.close()" class="glbb-close"><?= __( 'Close', 'blackbar' ); ?></a> |
|
| 14 | + <a href="javascript:Blackbar.close()" class="glbb-close"><?= __('Close', 'blackbar'); ?></a> |
|
| 15 | 15 | <div id="glbb-globals" class="glbb-debug-panel"> |
| 16 | - <?php $blackbar->render( 'panels/globals' ); ?> |
|
| 16 | + <?php $blackbar->render('panels/globals'); ?> |
|
| 17 | 17 | </div> |
| 18 | 18 | <div id="glbb-profiler" class="glbb-debug-panel"> |
| 19 | - <?php $blackbar->render( 'panels/profiler', array( 'profiler' => $profiler )); ?> |
|
| 19 | + <?php $blackbar->render('panels/profiler', array('profiler' => $profiler)); ?> |
|
| 20 | 20 | </div> |
| 21 | 21 | <div id="glbb-queries" class="glbb-debug-panel"> |
| 22 | - <?php $blackbar->render( 'panels/queries', array( 'queries' => $queries )); ?> |
|
| 22 | + <?php $blackbar->render('panels/queries', array('queries' => $queries)); ?> |
|
| 23 | 23 | </div> |
| 24 | - <?php if( $isCastorTheme ) : ?> |
|
| 24 | + <?php if ($isCastorTheme) : ?> |
|
| 25 | 25 | <div id="glbb-templates" class="glbb-debug-panel"> |
| 26 | - <?php $blackbar->render( 'panels/templates' ); ?> |
|
| 26 | + <?php $blackbar->render('panels/templates'); ?> |
|
| 27 | 27 | </div> |
| 28 | 28 | <?php endif; ?> |
| 29 | 29 | <div id="glbb-errors" class="glbb-debug-panel"> |
| 30 | - <?php $blackbar->render( 'panels/errors', array( 'errors' => $errors )); ?> |
|
| 30 | + <?php $blackbar->render('panels/errors', array('errors' => $errors)); ?> |
|
| 31 | 31 | </div> |
| 32 | 32 | </div> |
@@ -13,9 +13,13 @@ |
||
| 13 | 13 | ]; |
| 14 | 14 | foreach( $namespaces as $prefix => $base_dir ) { |
| 15 | 15 | $len = strlen( $prefix ); |
| 16 | - if( strncmp( $prefix, $class, $len ) !== 0 )continue; |
|
| 16 | + if( strncmp( $prefix, $class, $len ) !== 0 ) { |
|
| 17 | + continue; |
|
| 18 | + } |
|
| 17 | 19 | $file = $base_dir . str_replace( '\\', '/', substr( $class, $len )).'.php'; |
| 18 | - if( !file_exists( $file ))continue; |
|
| 20 | + if( !file_exists( $file )) { |
|
| 21 | + continue; |
|
| 22 | + } |
|
| 19 | 23 | require $file; |
| 20 | 24 | break; |
| 21 | 25 | } |
@@ -1,21 +1,21 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -defined( 'WPINC' ) || die; |
|
| 3 | +defined('WPINC') || die; |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * PSR-4 autoloader |
| 7 | 7 | */ |
| 8 | -spl_autoload_register( function( $class ) |
|
| 8 | +spl_autoload_register(function($class) |
|
| 9 | 9 | { |
| 10 | 10 | $namespaces = [ |
| 11 | 11 | 'GeminiLabs\\BlackBar\\' => __DIR__.'/src/', |
| 12 | 12 | 'GeminiLabs\\BlackBar\\Tests\\' => __DIR__.'/tests/', |
| 13 | 13 | ]; |
| 14 | - foreach( $namespaces as $prefix => $base_dir ) { |
|
| 15 | - $len = strlen( $prefix ); |
|
| 16 | - if( strncmp( $prefix, $class, $len ) !== 0 )continue; |
|
| 17 | - $file = $base_dir . str_replace( '\\', '/', substr( $class, $len )).'.php'; |
|
| 18 | - if( !file_exists( $file ))continue; |
|
| 14 | + foreach ($namespaces as $prefix => $base_dir) { |
|
| 15 | + $len = strlen($prefix); |
|
| 16 | + if (strncmp($prefix, $class, $len) !== 0)continue; |
|
| 17 | + $file = $base_dir.str_replace('\\', '/', substr($class, $len)).'.php'; |
|
| 18 | + if (!file_exists($file))continue; |
|
| 19 | 19 | require $file; |
| 20 | 20 | break; |
| 21 | 21 | } |
@@ -1,12 +1,12 @@ |
||
| 1 | -<?php defined( 'WPINC' ) || die; ?> |
|
| 1 | +<?php defined('WPINC') || die; ?> |
|
| 2 | 2 | |
| 3 | 3 | <form method="get" class="glbb-queries-filter"> |
| 4 | - <input type="text" name="glbb_query_filter" id="glbb_query_filter" placeholder="<?= __( 'Find queries containing', 'blackbar' ); ?>"> |
|
| 5 | - <input type="text" name="glbb_query_min_time" id="glbb_query_min_time" placeholder="<?= __( 'Minimum Execution Time', 'blackbar' ); ?>"> |
|
| 4 | + <input type="text" name="glbb_query_filter" id="glbb_query_filter" placeholder="<?= __('Find queries containing', 'blackbar'); ?>"> |
|
| 5 | + <input type="text" name="glbb_query_min_time" id="glbb_query_min_time" placeholder="<?= __('Minimum Execution Time', 'blackbar'); ?>"> |
|
| 6 | 6 | </form> |
| 7 | 7 | <table class="glbb-queries-table"> |
| 8 | 8 | <tbody> |
| 9 | - <?php foreach( $queries as $query ) : ?> |
|
| 9 | + <?php foreach ($queries as $query) : ?> |
|
| 10 | 10 | <tr> |
| 11 | 11 | <td class="glbb-number"><?= $query['ms']; ?></td> |
| 12 | 12 | <td><pre><code class="sql"><?= $query['sql']; ?></code></pre></td> |
@@ -1,13 +1,13 @@ |
||
| 1 | -<?php defined( 'WPINC' ) || die; ?> |
|
| 1 | +<?php defined('WPINC') || die; ?> |
|
| 2 | 2 | |
| 3 | 3 | <table> |
| 4 | 4 | <tbody> |
| 5 | - <?php if( empty( $errors )) : ?> |
|
| 5 | + <?php if (empty($errors)) : ?> |
|
| 6 | 6 | <tr> |
| 7 | - <td><?= __( 'No errors found.', 'blackbar' ); ?></td> |
|
| 7 | + <td><?= __('No errors found.', 'blackbar'); ?></td> |
|
| 8 | 8 | </tr> |
| 9 | 9 | <?php else : ?> |
| 10 | - <?php foreach( $errors as $error ) : ?> |
|
| 10 | + <?php foreach ($errors as $error) : ?> |
|
| 11 | 11 | <tr> |
| 12 | 12 | <td><?= $error['name']; ?></td> |
| 13 | 13 | <td><?= $error['message']; ?></td> |
@@ -6,10 +6,13 @@ |
||
| 6 | 6 | <tr> |
| 7 | 7 | <td><?= __( 'No errors found.', 'blackbar' ); ?></td> |
| 8 | 8 | </tr> |
| 9 | - <?php else : ?> |
|
| 9 | + <?php else { |
|
| 10 | + : ?> |
|
| 10 | 11 | <?php foreach( $errors as $error ) : ?> |
| 11 | 12 | <tr> |
| 12 | - <td><?= $error['name']; ?></td> |
|
| 13 | + <td><?= $error['name']; |
|
| 14 | +} |
|
| 15 | +?></td> |
|
| 13 | 16 | <td><?= $error['message']; ?></td> |
| 14 | 17 | </tr> |
| 15 | 18 | <?php endforeach; ?> |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -defined( 'WPINC' ) || die; |
|
| 3 | +defined('WPINC') || die; |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Checks for minimum system requirments on plugin activation |
@@ -29,46 +29,46 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * @return bool |
| 31 | 31 | */ |
| 32 | - public static function isValid( array $args = array() ) |
|
| 32 | + public static function isValid(array $args = array()) |
|
| 33 | 33 | { |
| 34 | - $versions = static::normalize( $args ); |
|
| 35 | - return static::isPhpValid( $versions->php ) && static::isWpValid( $versions->wordpress ); |
|
| 34 | + $versions = static::normalize($args); |
|
| 35 | + return static::isPhpValid($versions->php) && static::isWpValid($versions->wordpress); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * @param string $version |
| 40 | 40 | * @return bool |
| 41 | 41 | */ |
| 42 | - public static function isPhpValid( $version = '' ) |
|
| 42 | + public static function isPhpValid($version = '') |
|
| 43 | 43 | { |
| 44 | - $versions = static::normalize( array( 'php' => $version )); |
|
| 45 | - return !version_compare( PHP_VERSION, $versions->php, '<' ); |
|
| 44 | + $versions = static::normalize(array('php' => $version)); |
|
| 45 | + return !version_compare(PHP_VERSION, $versions->php, '<'); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * @param string $version |
| 50 | 50 | * @return bool |
| 51 | 51 | */ |
| 52 | - public static function isWpValid( $version = '' ) |
|
| 52 | + public static function isWpValid($version = '') |
|
| 53 | 53 | { |
| 54 | 54 | global $wp_version; |
| 55 | - $versions = static::normalize( array( 'wordpress' => $version )); |
|
| 56 | - return !version_compare( $wp_version, $versions->wordpress, '<' ); |
|
| 55 | + $versions = static::normalize(array('wordpress' => $version)); |
|
| 56 | + return !version_compare($wp_version, $versions->wordpress, '<'); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * @return bool |
| 61 | 61 | */ |
| 62 | - public static function shouldDeactivate( $file, array $args = [] ) |
|
| 62 | + public static function shouldDeactivate($file, array $args = []) |
|
| 63 | 63 | { |
| 64 | - if( empty( static::$instance )) { |
|
| 65 | - static::$file = realpath( $file ); |
|
| 64 | + if (empty(static::$instance)) { |
|
| 65 | + static::$file = realpath($file); |
|
| 66 | 66 | static::$instance = new static; |
| 67 | - static::$versions = static::normalize( $args ); |
|
| 67 | + static::$versions = static::normalize($args); |
|
| 68 | 68 | } |
| 69 | - if( !static::isValid() ) { |
|
| 70 | - add_action( 'activated_plugin', array( static::$instance, 'deactivate' )); |
|
| 71 | - add_action( 'admin_notices', array( static::$instance, 'deactivate' )); |
|
| 69 | + if (!static::isValid()) { |
|
| 70 | + add_action('activated_plugin', array(static::$instance, 'deactivate')); |
|
| 71 | + add_action('admin_notices', array(static::$instance, 'deactivate')); |
|
| 72 | 72 | return true; |
| 73 | 73 | } |
| 74 | 74 | return false; |
@@ -77,24 +77,24 @@ discard block |
||
| 77 | 77 | /** |
| 78 | 78 | * @return void |
| 79 | 79 | */ |
| 80 | - public function deactivate( $plugin ) |
|
| 80 | + public function deactivate($plugin) |
|
| 81 | 81 | { |
| 82 | - if( static::isValid() )return; |
|
| 83 | - $pluginSlug = plugin_basename( static::$file ); |
|
| 84 | - if( $plugin == $pluginSlug ) { |
|
| 82 | + if (static::isValid())return; |
|
| 83 | + $pluginSlug = plugin_basename(static::$file); |
|
| 84 | + if ($plugin == $pluginSlug) { |
|
| 85 | 85 | $this->redirect(); //exit |
| 86 | 86 | } |
| 87 | - $pluginData = get_file_data( static::$file, array( 'name' => 'Plugin Name' ), 'plugin' ); |
|
| 88 | - deactivate_plugins( $pluginSlug ); |
|
| 89 | - $this->printNotice( $pluginData['name'] ); |
|
| 87 | + $pluginData = get_file_data(static::$file, array('name' => 'Plugin Name'), 'plugin'); |
|
| 88 | + deactivate_plugins($pluginSlug); |
|
| 89 | + $this->printNotice($pluginData['name']); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | 93 | * @return object |
| 94 | 94 | */ |
| 95 | - protected static function normalize( array $args = [] ) |
|
| 95 | + protected static function normalize(array $args = []) |
|
| 96 | 96 | { |
| 97 | - return (object) wp_parse_args( $args, array( |
|
| 97 | + return (object) wp_parse_args($args, array( |
|
| 98 | 98 | 'php' => static::MIN_PHP_VERSION, |
| 99 | 99 | 'wordpress' => static::MIN_WORDPRESS_VERSION, |
| 100 | 100 | )); |
@@ -105,10 +105,10 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | protected function redirect() |
| 107 | 107 | { |
| 108 | - wp_safe_redirect( self_admin_url( sprintf( 'plugins.php?plugin_status=%s&paged=%s&s=%s', |
|
| 109 | - filter_input( INPUT_GET, 'plugin_status' ), |
|
| 110 | - filter_input( INPUT_GET, 'paged' ), |
|
| 111 | - filter_input( INPUT_GET, 's' ) |
|
| 108 | + wp_safe_redirect(self_admin_url(sprintf('plugins.php?plugin_status=%s&paged=%s&s=%s', |
|
| 109 | + filter_input(INPUT_GET, 'plugin_status'), |
|
| 110 | + filter_input(INPUT_GET, 'paged'), |
|
| 111 | + filter_input(INPUT_GET, 's') |
|
| 112 | 112 | ))); |
| 113 | 113 | exit; |
| 114 | 114 | } |
@@ -117,29 +117,29 @@ discard block |
||
| 117 | 117 | * @param string $pluginName |
| 118 | 118 | * @return void |
| 119 | 119 | */ |
| 120 | - protected function printNotice( $pluginName ) |
|
| 120 | + protected function printNotice($pluginName) |
|
| 121 | 121 | { |
| 122 | 122 | $noticeTemplate = '<div id="message" class="notice notice-error error is-dismissible"><p><strong>%s</strong></p><p>%s</p><p>%s</p></div>'; |
| 123 | 123 | $messages = array( |
| 124 | - __( 'The %s plugin was deactivated.', 'blackbar' ), |
|
| 125 | - __( 'Sorry, this plugin requires %s or greater in order to work properly.', 'blackbar' ), |
|
| 126 | - __( 'Please contact your hosting provider or server administrator to upgrade the version of PHP on your server (your server is running PHP version %s), or try to find an alternative plugin.', 'blackbar' ), |
|
| 127 | - __( 'PHP version', 'blackbar' ), |
|
| 128 | - __( 'WordPress version', 'blackbar' ), |
|
| 129 | - __( 'Update WordPress', 'blackbar' ), |
|
| 124 | + __('The %s plugin was deactivated.', 'blackbar'), |
|
| 125 | + __('Sorry, this plugin requires %s or greater in order to work properly.', 'blackbar'), |
|
| 126 | + __('Please contact your hosting provider or server administrator to upgrade the version of PHP on your server (your server is running PHP version %s), or try to find an alternative plugin.', 'blackbar'), |
|
| 127 | + __('PHP version', 'blackbar'), |
|
| 128 | + __('WordPress version', 'blackbar'), |
|
| 129 | + __('Update WordPress', 'blackbar'), |
|
| 130 | 130 | ); |
| 131 | - if( !static::isPhpValid() ) { |
|
| 132 | - printf( $noticeTemplate, |
|
| 133 | - sprintf( $messages[0], $pluginName ), |
|
| 134 | - sprintf( $messages[1], $messages[3].' '.static::$versions->php ), |
|
| 135 | - sprintf( $messages[2], PHP_VERSION ) |
|
| 131 | + if (!static::isPhpValid()) { |
|
| 132 | + printf($noticeTemplate, |
|
| 133 | + sprintf($messages[0], $pluginName), |
|
| 134 | + sprintf($messages[1], $messages[3].' '.static::$versions->php), |
|
| 135 | + sprintf($messages[2], PHP_VERSION) |
|
| 136 | 136 | ); |
| 137 | 137 | } |
| 138 | - else if( !static::isWpValid() ) { |
|
| 139 | - printf( $noticeTemplate, |
|
| 140 | - sprintf( $messages[0], $pluginName ), |
|
| 141 | - sprintf( $messages[1], $messages[4].' '.static::$versions->wordpress ), |
|
| 142 | - sprintf( '<a href="%s">%s</a>', admin_url( 'update-core.php' ), $messages[5] ) |
|
| 138 | + else if (!static::isWpValid()) { |
|
| 139 | + printf($noticeTemplate, |
|
| 140 | + sprintf($messages[0], $pluginName), |
|
| 141 | + sprintf($messages[1], $messages[4].' '.static::$versions->wordpress), |
|
| 142 | + sprintf('<a href="%s">%s</a>', admin_url('update-core.php'), $messages[5]) |
|
| 143 | 143 | ); |
| 144 | 144 | } |
| 145 | 145 | } |
@@ -79,7 +79,9 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | public function deactivate( $plugin ) |
| 81 | 81 | { |
| 82 | - if( static::isValid() )return; |
|
| 82 | + if( static::isValid() ) { |
|
| 83 | + return; |
|
| 84 | + } |
|
| 83 | 85 | $pluginSlug = plugin_basename( static::$file ); |
| 84 | 86 | if( $plugin == $pluginSlug ) { |
| 85 | 87 | $this->redirect(); //exit |
@@ -134,8 +136,7 @@ discard block |
||
| 134 | 136 | sprintf( $messages[1], $messages[3].' '.static::$versions->php ), |
| 135 | 137 | sprintf( $messages[2], PHP_VERSION ) |
| 136 | 138 | ); |
| 137 | - } |
|
| 138 | - else if( !static::isWpValid() ) { |
|
| 139 | + } else if( !static::isWpValid() ) { |
|
| 139 | 140 | printf( $noticeTemplate, |
| 140 | 141 | sprintf( $messages[0], $pluginName ), |
| 141 | 142 | sprintf( $messages[1], $messages[4].' '.static::$versions->wordpress ), |