@@ -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 | /** |
@@ -48,14 +48,14 @@ discard block |
||
48 | 48 | 8192 => 'Deprecated', |
49 | 49 | ); |
50 | 50 | $errname = array_key_exists( $errno, $errorCodes ) |
51 | - ? $errorCodes[$errno] |
|
51 | + ? $errorCodes[ $errno ] |
|
52 | 52 | : 'Unknown'; |
53 | - $hash = md5( $errno.$errstr.$errfile.$errline ); |
|
54 | - if( array_key_exists( $hash, $this->errors )) { |
|
55 | - $this->errors[$hash]['count']++; |
|
53 | + $hash = md5( $errno . $errstr . $errfile . $errline ); |
|
54 | + if( array_key_exists( $hash, $this->errors ) ) { |
|
55 | + $this->errors[ $hash ][ 'count' ]++; |
|
56 | 56 | } |
57 | 57 | else { |
58 | - $this->errors[$hash] = array( |
|
58 | + $this->errors[ $hash ] = array( |
|
59 | 59 | "errno" => $errno, |
60 | 60 | "message" => $errstr, |
61 | 61 | "file" => $errfile, |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 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 | /** |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function filterNoconflictScripts( $scripts ) |
82 | 82 | { |
83 | - $scripts[] = static::ID; |
|
83 | + $scripts[ ] = static::ID; |
|
84 | 84 | return $scripts; |
85 | 85 | } |
86 | 86 | |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function filterNoconflictStyles( $styles ) |
91 | 91 | { |
92 | - $styles[] = static::ID; |
|
93 | - $styles[] = static::ID.'-syntax'; |
|
92 | + $styles[ ] = static::ID; |
|
93 | + $styles[ ] = static::ID . '-syntax'; |
|
94 | 94 | return $styles; |
95 | 95 | } |
96 | 96 | |
@@ -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' )); |
|
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 | 111 | apply_filters( 'debug', 'Profiler Started' ); |
112 | 112 | apply_filters( 'debug', 'blackbar/profiler/noise' ); |
113 | - set_error_handler( array( $this, 'errorHandler' ), E_ALL|E_STRICT ); |
|
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 | /** |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | */ |
140 | 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; |
|
142 | + $file = $this->path( sprintf( 'views/%s.php', str_replace( '.php', '', $view ) ) ); |
|
143 | + if( !file_exists( $file ) )return; |
|
144 | 144 | extract( $data ); |
145 | 145 | include $file; |
146 | 146 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | 'queries' => $this->getQueries(), |
163 | 163 | 'queriesLabel' => $this->getQueriesLabel(), |
164 | 164 | 'templates' => $this->getTemplates(), |
165 | - )); |
|
165 | + ) ); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -180,18 +180,18 @@ discard block |
||
180 | 180 | { |
181 | 181 | $errors = array(); |
182 | 182 | foreach( $this->errors as $error ) { |
183 | - if( $error['errno'] == E_WARNING ) { |
|
184 | - $error['name'] = '<span class="glbb-error">'.$error['name'].'</span>'; |
|
183 | + if( $error[ 'errno' ] == E_WARNING ) { |
|
184 | + $error[ 'name' ] = '<span class="glbb-error">' . $error[ 'name' ] . '</span>'; |
|
185 | 185 | } |
186 | - if( $error['count'] > 1 ) { |
|
187 | - $error['name'] .= ' ('.$error['count'].')'; |
|
186 | + if( $error[ 'count' ] > 1 ) { |
|
187 | + $error[ 'name' ] .= ' (' . $error[ 'count' ] . ')'; |
|
188 | 188 | } |
189 | - $errors[] = array( |
|
190 | - 'name' => $error['name'], |
|
189 | + $errors[ ] = array( |
|
190 | + 'name' => $error[ 'name' ], |
|
191 | 191 | 'message' => sprintf( __( '%s on line %s in file %s', 'blackbar' ), |
192 | - $error['message'], |
|
193 | - $error['line'], |
|
194 | - $error['file'] |
|
192 | + $error[ 'message' ], |
|
193 | + $error[ 'line' ], |
|
194 | + $error[ 'file' ] |
|
195 | 195 | ), |
196 | 196 | ); |
197 | 197 | } |
@@ -205,13 +205,13 @@ discard block |
||
205 | 205 | { |
206 | 206 | $warningCount = 0; |
207 | 207 | foreach( $this->errors as $error ) { |
208 | - if( $error['errno'] == E_WARNING ) { |
|
208 | + if( $error[ 'errno' ] == E_WARNING ) { |
|
209 | 209 | $warningCount++; |
210 | 210 | } |
211 | 211 | } |
212 | 212 | $errorCount = count( $this->errors ); |
213 | 213 | $warnings = $warningCount > 0 ? sprintf( ', %d!', $warningCount ) : ''; |
214 | - return sprintf( __( 'Errors (%s)', 'blackbar' ), $errorCount.$warnings ); |
|
214 | + return sprintf( __( 'Errors (%s)', 'blackbar' ), $errorCount . $warnings ); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -222,8 +222,8 @@ discard block |
||
222 | 222 | $includes = array_values( array_filter( get_included_files(), function( $include ) { |
223 | 223 | $bool = strpos( $include, '/themes/' ) !== false |
224 | 224 | && strpos( $include, '/functions.php' ) === false; |
225 | - return (bool)apply_filters( 'blackbar/templates/include', $bool, $include ); |
|
226 | - })); |
|
225 | + return (bool) apply_filters( 'blackbar/templates/include', $bool, $include ); |
|
226 | + }) ); |
|
227 | 227 | return array_map( function( $key, $value ) { |
228 | 228 | $value = str_replace( trailingslashit( WP_CONTENT_DIR ), '', $value ); |
229 | 229 | return sprintf( '[%s] => %s', $key, $value ); |
@@ -258,14 +258,14 @@ discard block |
||
258 | 258 | 'WHERE', |
259 | 259 | ); |
260 | 260 | $replace = array_map( function( $value ) { |
261 | - return PHP_EOL.$value; |
|
261 | + return PHP_EOL . $value; |
|
262 | 262 | }, $search ); |
263 | 263 | foreach( $wpdb->queries as $query ) { |
264 | - $miliseconds = number_format( round( $query[1] * 1000, 4 ), 4 ); |
|
265 | - $sql = preg_replace( '/\s\s+/', ' ', trim( $query[0] )); |
|
264 | + $miliseconds = number_format( round( $query[ 1 ] * 1000, 4 ), 4 ); |
|
265 | + $sql = preg_replace( '/\s\s+/', ' ', trim( $query[ 0 ] ) ); |
|
266 | 266 | $sql = str_replace( PHP_EOL, ' ', $sql ); |
267 | 267 | $sql = str_replace( $search, $replace, $sql ); |
268 | - $queries[] = array( |
|
268 | + $queries[ ] = array( |
|
269 | 269 | 'ms' => $miliseconds, |
270 | 270 | 'sql' => $sql, |
271 | 271 | ); |
@@ -284,10 +284,10 @@ discard block |
||
284 | 284 | global $wpdb; |
285 | 285 | $queryTime = 0; |
286 | 286 | foreach( $wpdb->queries as $query ) { |
287 | - $queryTime += $query[1]; |
|
287 | + $queryTime += $query[ 1 ]; |
|
288 | 288 | } |
289 | - $queriesCount = '<span class="glbb-queries-count">'.count( $wpdb->queries ).'</span>'; |
|
290 | - $queriesTime = '<span class="glbb-queries-time">'.$this->convertToMiliseconds( $queryTime ).'</span>'; |
|
289 | + $queriesCount = '<span class="glbb-queries-count">' . count( $wpdb->queries ) . '</span>'; |
|
290 | + $queriesTime = '<span class="glbb-queries-time">' . $this->convertToMiliseconds( $queryTime ) . '</span>'; |
|
291 | 291 | return sprintf( __( 'SQL (%s queries in %s ms)', 'blackbar' ), $queriesCount, $queriesTime ); |
292 | 292 | } |
293 | 293 | |
@@ -297,12 +297,12 @@ discard block |
||
297 | 297 | protected function getTemplates() |
298 | 298 | { |
299 | 299 | if( is_admin() )return; |
300 | - if( class_exists( '\GeminiLabs\Castor\Facades\Development' )) { |
|
300 | + if( class_exists( '\GeminiLabs\Castor\Facades\Development' ) ) { |
|
301 | 301 | ob_start(); |
302 | 302 | \GeminiLabs\Castor\Facades\Development::printTemplatePaths(); |
303 | 303 | return ob_get_clean(); |
304 | 304 | } |
305 | - return '<pre>'.implode( PHP_EOL, $this->getIncludedFiles() ).'</pre>'; |
|
305 | + return '<pre>' . implode( PHP_EOL, $this->getIncludedFiles() ) . '</pre>'; |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | */ |
312 | 312 | protected function path( $file = '' ) |
313 | 313 | { |
314 | - return plugin_dir_path( $this->file ).ltrim( trim( $file ), '/' ); |
|
314 | + return plugin_dir_path( $this->file ) . ltrim( trim( $file ), '/' ); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -320,6 +320,6 @@ discard block |
||
320 | 320 | */ |
321 | 321 | protected function url( $path = '' ) |
322 | 322 | { |
323 | - return esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' )); |
|
323 | + return esc_url( plugin_dir_url( $this->file ) . ltrim( trim( $path ), '/' ) ); |
|
324 | 324 | } |
325 | 325 | } |
@@ -119,7 +119,9 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function initProfiler() |
121 | 121 | { |
122 | - if( func_get_arg(0) != static::DEBUG )return; |
|
122 | + if( func_get_arg(0) != static::DEBUG ) { |
|
123 | + return; |
|
124 | + } |
|
123 | 125 | $this->profiler->trace( func_get_arg(1) ); |
124 | 126 | } |
125 | 127 | |
@@ -140,7 +142,9 @@ discard block |
||
140 | 142 | public function render( $view, array $data = array() ) |
141 | 143 | { |
142 | 144 | $file = $this->path( sprintf( 'views/%s.php', str_replace( '.php', '', $view ))); |
143 | - if( !file_exists( $file ))return; |
|
145 | + if( !file_exists( $file )) { |
|
146 | + return; |
|
147 | + } |
|
144 | 148 | extract( $data ); |
145 | 149 | include $file; |
146 | 150 | } |
@@ -219,12 +223,14 @@ discard block |
||
219 | 223 | */ |
220 | 224 | protected function getIncludedFiles() |
221 | 225 | { |
222 | - $includes = array_values( array_filter( get_included_files(), function( $include ) { |
|
226 | + $includes = array_values( array_filter( get_included_files(), function( $include ) |
|
227 | + { |
|
223 | 228 | $bool = strpos( $include, '/themes/' ) !== false |
224 | 229 | && strpos( $include, '/functions.php' ) === false; |
225 | 230 | return (bool)apply_filters( 'blackbar/templates/include', $bool, $include ); |
226 | 231 | })); |
227 | - return array_map( function( $key, $value ) { |
|
232 | + return array_map( function( $key, $value ) |
|
233 | + { |
|
228 | 234 | $value = str_replace( trailingslashit( WP_CONTENT_DIR ), '', $value ); |
229 | 235 | return sprintf( '[%s] => %s', $key, $value ); |
230 | 236 | }, array_keys( $includes ), $includes ); |
@@ -257,7 +263,8 @@ discard block |
||
257 | 263 | 'SET', |
258 | 264 | 'WHERE', |
259 | 265 | ); |
260 | - $replace = array_map( function( $value ) { |
|
266 | + $replace = array_map( function( $value ) |
|
267 | + { |
|
261 | 268 | return PHP_EOL.$value; |
262 | 269 | }, $search ); |
263 | 270 | foreach( $wpdb->queries as $query ) { |
@@ -296,7 +303,9 @@ discard block |
||
296 | 303 | */ |
297 | 304 | protected function getTemplates() |
298 | 305 | { |
299 | - if( is_admin() )return; |
|
306 | + if( is_admin() ) { |
|
307 | + return; |
|
308 | + } |
|
300 | 309 | if( class_exists( '\GeminiLabs\Castor\Facades\Development' )) { |
301 | 310 | ob_start(); |
302 | 311 | \GeminiLabs\Castor\Facades\Development::printTemplatePaths(); |
@@ -14,17 +14,17 @@ |
||
14 | 14 | <?php $blackbar->render( 'panels/globals' ); ?> |
15 | 15 | </div> |
16 | 16 | <div id="glbb-profiler" class="glbb-debug-panel"> |
17 | - <?php $blackbar->render( 'panels/profiler', array( 'profiler' => $profiler )); ?> |
|
17 | + <?php $blackbar->render( 'panels/profiler', array( 'profiler' => $profiler ) ); ?> |
|
18 | 18 | </div> |
19 | 19 | <div id="glbb-queries" class="glbb-debug-panel"> |
20 | - <?php $blackbar->render( 'panels/queries', array( 'queries' => $queries )); ?> |
|
20 | + <?php $blackbar->render( 'panels/queries', array( 'queries' => $queries ) ); ?> |
|
21 | 21 | </div> |
22 | 22 | <?php if( !is_admin() ) : ?> |
23 | 23 | <div id="glbb-templates" class="glbb-debug-panel"> |
24 | - <?php $blackbar->render( 'panels/templates', array( 'templates' => $templates )); ?> |
|
24 | + <?php $blackbar->render( 'panels/templates', array( 'templates' => $templates ) ); ?> |
|
25 | 25 | </div> |
26 | 26 | <?php endif; ?> |
27 | 27 | <div id="glbb-errors" class="glbb-debug-panel"> |
28 | - <?php $blackbar->render( 'panels/errors', array( 'errors' => $errors )); ?> |
|
28 | + <?php $blackbar->render( 'panels/errors', array( 'errors' => $errors ) ); ?> |
|
29 | 29 | </div> |
30 | 30 | </div> |