@@ -8,9 +8,12 @@ |
||
| 8 | 8 | </tr> |
| 9 | 9 | </tbody> |
| 10 | 10 | </table> |
| 11 | -<?php else : ?> |
|
| 11 | +<?php else { |
|
| 12 | + : ?> |
|
| 12 | 13 | <form method="get" class="glbb-queries-filter"> |
| 13 | - <input type="text" name="glbb_query_filter" id="glbb_query_filter" placeholder="<?= __( 'Find queries containing', 'blackbar' ); ?>"> |
|
| 14 | + <input type="text" name="glbb_query_filter" id="glbb_query_filter" placeholder="<?= __( 'Find queries containing', 'blackbar' ); |
|
| 15 | +} |
|
| 16 | +?>"> |
|
| 14 | 17 | <input type="text" name="glbb_query_min_time" id="glbb_query_min_time" placeholder="<?= __( 'Minimum Execution Time', 'blackbar' ); ?>"> |
| 15 | 18 | </form> |
| 16 | 19 | <table class="glbb-queries-table"> |
@@ -17,8 +17,8 @@ |
||
| 17 | 17 | <tbody> |
| 18 | 18 | <?php foreach( $queries as $query ) : ?> |
| 19 | 19 | <tr> |
| 20 | - <td class="glbb-small"><?= $query['ms']; ?></td> |
|
| 21 | - <td><pre><code class="sql"><?= $query['sql']; ?></code></pre></td> |
|
| 20 | + <td class="glbb-small"><?= $query[ 'ms' ]; ?></td> |
|
| 21 | + <td><pre><code class="sql"><?= $query[ 'sql' ]; ?></code></pre></td> |
|
| 22 | 22 | </tr> |
| 23 | 23 | <?php endforeach; ?> |
| 24 | 24 | </tbody> |
@@ -91,7 +91,9 @@ |
||
| 91 | 91 | public function render( $view, array $data = array() ) |
| 92 | 92 | { |
| 93 | 93 | $file = $this->path( sprintf( 'views/%s.php', str_replace( '.php', '', $view ))); |
| 94 | - if( !file_exists( $file ))return; |
|
| 94 | + if( !file_exists( $file )) { |
|
| 95 | + return; |
|
| 96 | + } |
|
| 95 | 97 | extract( $data ); |
| 96 | 98 | include $file; |
| 97 | 99 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | public function __construct() |
| 22 | 22 | { |
| 23 | 23 | $this->console = new Console; |
| 24 | - $this->file = realpath( dirname( __DIR__ ).'/'.static::ID.'.php' ); |
|
| 24 | + $this->file = realpath( dirname( __DIR__ ) . '/' . static::ID . '.php' ); |
|
| 25 | 25 | $this->profiler = new Profiler; |
| 26 | 26 | } |
| 27 | 27 | |
@@ -41,14 +41,14 @@ discard block |
||
| 41 | 41 | 8192 => 'Deprecated', //E_DEPRECATED |
| 42 | 42 | ); |
| 43 | 43 | $errname = array_key_exists( $errno, $errorCodes ) |
| 44 | - ? $errorCodes[$errno] |
|
| 44 | + ? $errorCodes[ $errno ] |
|
| 45 | 45 | : 'Unknown'; |
| 46 | - $hash = md5( $errno.$errstr.$errfile.$errline ); |
|
| 47 | - if( array_key_exists( $hash, $this->errors )) { |
|
| 48 | - $this->errors[$hash]['count']++; |
|
| 46 | + $hash = md5( $errno . $errstr . $errfile . $errline ); |
|
| 47 | + if( array_key_exists( $hash, $this->errors ) ) { |
|
| 48 | + $this->errors[ $hash ][ 'count' ]++; |
|
| 49 | 49 | } |
| 50 | 50 | else { |
| 51 | - $this->errors[$hash] = array( |
|
| 51 | + $this->errors[ $hash ] = array( |
|
| 52 | 52 | "errno" => $errno, |
| 53 | 53 | "message" => $errstr, |
| 54 | 54 | "file" => $errfile, |
@@ -65,17 +65,17 @@ discard block |
||
| 65 | 65 | public function init() |
| 66 | 66 | { |
| 67 | 67 | $controller = new Controller( $this ); |
| 68 | - add_action( 'admin_enqueue_scripts', array( $controller, 'enqueueAssets' )); |
|
| 69 | - add_action( 'wp_enqueue_scripts', array( $controller, 'enqueueAssets' )); |
|
| 70 | - add_action( 'plugins_loaded', array( $controller, 'registerLanguages' )); |
|
| 71 | - add_action( 'admin_footer', array( $controller, 'renderBar' )); |
|
| 72 | - add_action( 'wp_footer', array( $controller, 'renderBar' )); |
|
| 73 | - add_filter( 'admin_body_class', array( $controller, 'filterBodyClasses' )); |
|
| 74 | - add_filter( 'all', array( $controller, 'initConsole' )); |
|
| 75 | - add_filter( 'all', array( $controller, 'initProfiler' )); |
|
| 68 | + add_action( 'admin_enqueue_scripts', array( $controller, 'enqueueAssets' ) ); |
|
| 69 | + add_action( 'wp_enqueue_scripts', array( $controller, 'enqueueAssets' ) ); |
|
| 70 | + add_action( 'plugins_loaded', array( $controller, 'registerLanguages' ) ); |
|
| 71 | + add_action( 'admin_footer', array( $controller, 'renderBar' ) ); |
|
| 72 | + add_action( 'wp_footer', array( $controller, 'renderBar' ) ); |
|
| 73 | + add_filter( 'admin_body_class', array( $controller, 'filterBodyClasses' ) ); |
|
| 74 | + add_filter( 'all', array( $controller, 'initConsole' ) ); |
|
| 75 | + add_filter( 'all', array( $controller, 'initProfiler' ) ); |
|
| 76 | 76 | apply_filters( 'debug', 'Profiler Started' ); |
| 77 | 77 | apply_filters( 'debug', 'blackbar/profiler/noise' ); |
| 78 | - set_error_handler( array( $this, 'errorHandler' ), E_ALL|E_STRICT ); |
|
| 78 | + set_error_handler( array( $this, 'errorHandler' ), E_ALL | E_STRICT ); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public function path( $file = '' ) |
| 86 | 86 | { |
| 87 | - return plugin_dir_path( $this->file ).ltrim( trim( $file ), '/' ); |
|
| 87 | + return plugin_dir_path( $this->file ) . ltrim( trim( $file ), '/' ); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function render( $view, array $data = array() ) |
| 95 | 95 | { |
| 96 | - $file = $this->path( sprintf( 'views/%s.php', str_replace( '.php', '', $view ))); |
|
| 97 | - if( !file_exists( $file ))return; |
|
| 96 | + $file = $this->path( sprintf( 'views/%s.php', str_replace( '.php', '', $view ) ) ); |
|
| 97 | + if( !file_exists( $file ) )return; |
|
| 98 | 98 | extract( $data ); |
| 99 | 99 | include $file; |
| 100 | 100 | } |
@@ -105,6 +105,6 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | public function url( $path = '' ) |
| 107 | 107 | { |
| 108 | - return esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' )); |
|
| 108 | + return esc_url( plugin_dir_url( $this->file ) . ltrim( trim( $path ), '/' ) ); |
|
| 109 | 109 | } |
| 110 | 110 | } |
@@ -8,14 +8,14 @@ |
||
| 8 | 8 | spl_autoload_register( function( $class ) |
| 9 | 9 | { |
| 10 | 10 | $namespaces = [ |
| 11 | - 'GeminiLabs\\BlackBar\\' => __DIR__.'/src/', |
|
| 12 | - 'GeminiLabs\\BlackBar\\Tests\\' => __DIR__.'/tests/', |
|
| 11 | + 'GeminiLabs\\BlackBar\\' => __DIR__ . '/src/', |
|
| 12 | + 'GeminiLabs\\BlackBar\\Tests\\' => __DIR__ . '/tests/', |
|
| 13 | 13 | ]; |
| 14 | 14 | foreach( $namespaces as $prefix => $base_dir ) { |
| 15 | 15 | $len = strlen( $prefix ); |
| 16 | 16 | if( strncmp( $prefix, $class, $len ) !== 0 )continue; |
| 17 | - $file = $base_dir.str_replace( '\\', '/', substr( $class, $len )).'.php'; |
|
| 18 | - if( !file_exists( $file ))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 | } |
@@ -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 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | public function getMemoryString( $timer ) |
| 41 | 41 | { |
| 42 | 42 | $timer = $this->normalize( $timer ); |
| 43 | - return sprintf( '%s kB', round( $timer['memory'] / 1000 )); |
|
| 43 | + return sprintf( '%s kB', round( $timer[ 'memory' ] / 1000 ) ); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | public function getNameString( $timer ) |
| 51 | 51 | { |
| 52 | 52 | $timer = $this->normalize( $timer ); |
| 53 | - return $timer['name']; |
|
| 53 | + return $timer[ 'name' ]; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | public function getTimeString( $timer ) |
| 61 | 61 | { |
| 62 | 62 | $timer = $this->normalize( $timer ); |
| 63 | - $index = array_search( $timer['name'], array_column( $this->timers, 'name' )); |
|
| 63 | + $index = array_search( $timer[ 'name' ], array_column( $this->timers, 'name' ) ); |
|
| 64 | 64 | $start = $this->start + ( $index * $this->noise ); |
| 65 | - $time = number_format( round(( $timer['time'] - $start ) * 1000, 4 ), 4 ); |
|
| 65 | + $time = number_format( round( ( $timer[ 'time' ] - $start ) * 1000, 4 ), 4 ); |
|
| 66 | 66 | return sprintf( '%s ms', $time ); |
| 67 | 67 | } |
| 68 | 68 | |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | $this->noise = $microtime - $this->start; |
| 90 | 90 | return; |
| 91 | 91 | } |
| 92 | - $this->timers[] = array( |
|
| 92 | + $this->timers[ ] = array( |
|
| 93 | 93 | 'memory' => memory_get_peak_usage(), |
| 94 | 94 | 'name' => $name, |
| 95 | 95 | 'time' => $microtime, |
@@ -103,10 +103,10 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | protected function normalize( $timer ) |
| 105 | 105 | { |
| 106 | - return wp_parse_args( (array)$timer, array( |
|
| 106 | + return wp_parse_args( (array) $timer, array( |
|
| 107 | 107 | 'memory' => 0, |
| 108 | 108 | 'name' => '', |
| 109 | 109 | 'time' => 0, |
| 110 | - )); |
|
| 110 | + ) ); |
|
| 111 | 111 | } |
| 112 | 112 | } |
@@ -11,17 +11,17 @@ |
||
| 11 | 11 | <a href="javascript:Blackbar.switchPanel('glbb-globals')" class="glbb-globals"><?= __( 'Globals', 'blackbar' ); ?></a> |
| 12 | 12 | <a href="javascript:Blackbar.close()" class="glbb-close"><?= __( 'Close', 'blackbar' ); ?></a> |
| 13 | 13 | <div id="glbb-queries" class="glbb-debug-panel"> |
| 14 | - <?php $blackbar->render( 'panels/queries', array( 'queries' => $queries )); ?> |
|
| 14 | + <?php $blackbar->render( 'panels/queries', array( 'queries' => $queries ) ); ?> |
|
| 15 | 15 | </div> |
| 16 | 16 | <div id="glbb-console" class="glbb-debug-panel"> |
| 17 | - <?php $blackbar->render( 'panels/console', array( 'entries' => $consoleEntries )); ?> |
|
| 17 | + <?php $blackbar->render( 'panels/console', array( 'entries' => $consoleEntries ) ); ?> |
|
| 18 | 18 | </div> |
| 19 | 19 | <div id="glbb-profiler" class="glbb-debug-panel"> |
| 20 | - <?php $blackbar->render( 'panels/profiler', array( 'profiler' => $profiler )); ?> |
|
| 20 | + <?php $blackbar->render( 'panels/profiler', array( 'profiler' => $profiler ) ); ?> |
|
| 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-globals" class="glbb-debug-panel"> |
@@ -1,7 +1,7 @@ |
||
| 1 | 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( isset( $_SESSION ) ? $_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( isset( $_SESSION ) ? $_SESSION : [ ], true ) ); ?>;</code></pre><br/> |
|
| 7 | +<pre><code class="php">$_SERVER = <?= esc_html( var_export( $_SERVER, true ) ); ?>;</code></pre><br/> |
|
@@ -2,15 +2,15 @@ |
||
| 2 | 2 | |
| 3 | 3 | <table> |
| 4 | 4 | <tbody> |
| 5 | - <?php if( empty( $entries )) : ?> |
|
| 5 | + <?php if( empty( $entries ) ) : ?> |
|
| 6 | 6 | <tr> |
| 7 | 7 | <td><?= __( 'No entries found.', 'blackbar' ); ?></td> |
| 8 | 8 | </tr> |
| 9 | 9 | <?php else : ?> |
| 10 | 10 | <?php foreach( $entries as $entry ) : ?> |
| 11 | 11 | <tr> |
| 12 | - <td class="glbb-small"><?= $entry['name']; ?></td> |
|
| 13 | - <td><pre><?= $entry['message']; ?></pre></td> |
|
| 12 | + <td class="glbb-small"><?= $entry[ 'name' ]; ?></td> |
|
| 13 | + <td><pre><?= $entry[ 'message' ]; ?></pre></td> |
|
| 14 | 14 | </tr> |
| 15 | 15 | <?php endforeach; ?> |
| 16 | 16 | <?php endif; ?> |
@@ -6,10 +6,13 @@ |
||
| 6 | 6 | <tr> |
| 7 | 7 | <td><?= __( 'No entries found.', 'blackbar' ); ?></td> |
| 8 | 8 | </tr> |
| 9 | - <?php else : ?> |
|
| 9 | + <?php else { |
|
| 10 | + : ?> |
|
| 10 | 11 | <?php foreach( $entries as $entry ) : ?> |
| 11 | 12 | <tr> |
| 12 | - <td class="glbb-small"><?= $entry['name']; ?></td> |
|
| 13 | + <td class="glbb-small"><?= $entry['name']; |
|
| 14 | +} |
|
| 15 | +?></td> |
|
| 13 | 16 | <td><pre><?= $entry['message']; ?></pre></td> |
| 14 | 17 | </tr> |
| 15 | 18 | <?php endforeach; ?> |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | <table> |
| 4 | 4 | <tbody> |
| 5 | - <?php if( empty( $profiler->getMeasure() )) : ?> |
|
| 5 | + <?php if( empty( $profiler->getMeasure() ) ) : ?> |
|
| 6 | 6 | <tr> |
| 7 | 7 | <td><?= __( 'No entries found.', 'blackbar' ); ?></td> |
| 8 | 8 | </tr> |
@@ -6,10 +6,13 @@ |
||
| 6 | 6 | <tr> |
| 7 | 7 | <td><?= __( 'No entries found.', 'blackbar' ); ?></td> |
| 8 | 8 | </tr> |
| 9 | - <?php else : ?> |
|
| 9 | + <?php else { |
|
| 10 | + : ?> |
|
| 10 | 11 | <?php foreach( $profiler->getMeasure() as $timer ) : ?> |
| 11 | 12 | <tr> |
| 12 | - <td><?= $profiler->getNameString( $timer ); ?></td> |
|
| 13 | + <td><?= $profiler->getNameString( $timer ); |
|
| 14 | +} |
|
| 15 | +?></td> |
|
| 13 | 16 | <td class="glbb-medium"><?= $profiler->getTimeString( $timer ); ?></td> |
| 14 | 17 | <td class="glbb-medium"><?= $profiler->getMemoryString( $timer ); ?></td> |
| 15 | 18 | </tr> |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * @see https://docs.gravityforms.com/gform_noconflict_scripts/ |
| 8 | 8 | */ |
| 9 | 9 | add_filter( 'gform_noconflict_scripts', function( array $scripts ) { |
| 10 | - $scripts[] = 'blackbar'; |
|
| 10 | + $scripts[ ] = 'blackbar'; |
|
| 11 | 11 | return $scripts; |
| 12 | 12 | }); |
| 13 | 13 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @see https://docs.gravityforms.com/gform_noconflict_styles/ |
| 17 | 17 | */ |
| 18 | 18 | add_filter( 'gform_noconflict_styles', function( array $styles ) { |
| 19 | - $styles[] = 'blackbar'; |
|
| 20 | - $styles[] = 'blackbar-syntax'; |
|
| 19 | + $styles[ ] = 'blackbar'; |
|
| 20 | + $styles[ ] = 'blackbar-syntax'; |
|
| 21 | 21 | return $styles; |
| 22 | 22 | }); |
@@ -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; |