@@ -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 | } |
@@ -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 | } |
@@ -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> |
@@ -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 class="glbb-small"><?= $error['name']; ?></td> |
|
| 13 | + <td class="glbb-small"><?= $error['name']; |
|
| 14 | +} |
|
| 15 | +?></td> |
|
| 13 | 16 | <td><?= $error['message']; ?></td> |
| 14 | 17 | </tr> |
| 15 | 18 | <?php endforeach; ?> |
@@ -2,15 +2,15 @@ |
||
| 2 | 2 | |
| 3 | 3 | <table> |
| 4 | 4 | <tbody> |
| 5 | - <?php if( empty( $errors )) : ?> |
|
| 5 | + <?php if( empty( $errors ) ) : ?> |
|
| 6 | 6 | <tr> |
| 7 | 7 | <td><?= __( 'No errors found.', 'blackbar' ); ?></td> |
| 8 | 8 | </tr> |
| 9 | 9 | <?php else : ?> |
| 10 | 10 | <?php foreach( $errors as $error ) : ?> |
| 11 | 11 | <tr> |
| 12 | - <td class="glbb-small"><?= $error['name']; ?></td> |
|
| 13 | - <td><?= $error['message']; ?></td> |
|
| 12 | + <td class="glbb-small"><?= $error[ 'name' ]; ?></td> |
|
| 13 | + <td><?= $error[ 'message' ]; ?></td> |
|
| 14 | 14 | </tr> |
| 15 | 15 | <?php endforeach; ?> |
| 16 | 16 | <?php endif; ?> |
@@ -32,8 +32,8 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public static function isPhpValid( $version = '' ) |
| 34 | 34 | { |
| 35 | - if( !empty( $version )) { |
|
| 36 | - static::normalize( array( 'php' => $version )); |
|
| 35 | + if( !empty( $version ) ) { |
|
| 36 | + static::normalize( array( 'php' => $version ) ); |
|
| 37 | 37 | } |
| 38 | 38 | return !version_compare( PHP_VERSION, static::$versions->php, '<' ); |
| 39 | 39 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public static function isValid( array $args = array() ) |
| 45 | 45 | { |
| 46 | - if( !empty( $args )) { |
|
| 46 | + if( !empty( $args ) ) { |
|
| 47 | 47 | static::normalize( $args ); |
| 48 | 48 | } |
| 49 | 49 | return static::isPhpValid() && static::isWpValid(); |
@@ -56,8 +56,8 @@ discard block |
||
| 56 | 56 | public static function isWpValid( $version = '' ) |
| 57 | 57 | { |
| 58 | 58 | global $wp_version; |
| 59 | - if( !empty( $version )) { |
|
| 60 | - static::normalize( array( 'wordpress' => $version )); |
|
| 59 | + if( !empty( $version ) ) { |
|
| 60 | + static::normalize( array( 'wordpress' => $version ) ); |
|
| 61 | 61 | } |
| 62 | 62 | return !version_compare( $wp_version, static::$versions->wordpress, '<' ); |
| 63 | 63 | } |
@@ -67,14 +67,14 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | public static function shouldDeactivate( $file, array $args = array() ) |
| 69 | 69 | { |
| 70 | - if( empty( static::$instance )) { |
|
| 70 | + if( empty( static::$instance ) ) { |
|
| 71 | 71 | static::$file = realpath( $file ); |
| 72 | 72 | static::$instance = new static; |
| 73 | 73 | static::$versions = static::normalize( $args ); |
| 74 | 74 | } |
| 75 | 75 | if( !static::isValid() ) { |
| 76 | - add_action( 'activated_plugin', array( static::$instance, 'deactivate' )); |
|
| 77 | - add_action( 'admin_notices', array( static::$instance, 'deactivate' )); |
|
| 76 | + add_action( 'activated_plugin', array( static::$instance, 'deactivate' ) ); |
|
| 77 | + add_action( 'admin_notices', array( static::$instance, 'deactivate' ) ); |
|
| 78 | 78 | return true; |
| 79 | 79 | } |
| 80 | 80 | return false; |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | $pluginData = get_file_data( static::$file, array( 'name' => 'Plugin Name' ), 'plugin' ); |
| 94 | 94 | deactivate_plugins( $pluginSlug ); |
| 95 | - $this->printNotice( $pluginData['name'] ); |
|
| 95 | + $this->printNotice( $pluginData[ 'name' ] ); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -100,10 +100,10 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | protected static function normalize( array $args = array() ) |
| 102 | 102 | { |
| 103 | - return (object)wp_parse_args( $args, array( |
|
| 103 | + return (object) wp_parse_args( $args, array( |
|
| 104 | 104 | 'php' => static::MIN_PHP_VERSION, |
| 105 | 105 | 'wordpress' => static::MIN_WORDPRESS_VERSION, |
| 106 | - )); |
|
| 106 | + ) ); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | filter_input( INPUT_GET, 'plugin_status' ), |
| 116 | 116 | filter_input( INPUT_GET, 'paged' ), |
| 117 | 117 | filter_input( INPUT_GET, 's' ) |
| 118 | - ))); |
|
| 118 | + ) ) ); |
|
| 119 | 119 | exit; |
| 120 | 120 | } |
| 121 | 121 | |
@@ -136,16 +136,16 @@ discard block |
||
| 136 | 136 | ); |
| 137 | 137 | if( !static::isPhpValid() ) { |
| 138 | 138 | printf( $noticeTemplate, |
| 139 | - sprintf( $messages[0], $pluginName ), |
|
| 140 | - sprintf( $messages[1], $messages[3].' '.static::$versions->php ), |
|
| 141 | - sprintf( $messages[2], PHP_VERSION ) |
|
| 139 | + sprintf( $messages[ 0 ], $pluginName ), |
|
| 140 | + sprintf( $messages[ 1 ], $messages[ 3 ] . ' ' . static::$versions->php ), |
|
| 141 | + sprintf( $messages[ 2 ], PHP_VERSION ) |
|
| 142 | 142 | ); |
| 143 | 143 | } |
| 144 | 144 | else if( !static::isWpValid() ) { |
| 145 | 145 | printf( $noticeTemplate, |
| 146 | - sprintf( $messages[0], $pluginName ), |
|
| 147 | - sprintf( $messages[1], $messages[4].' '.static::$versions->wordpress ), |
|
| 148 | - sprintf( '<a href="%s">%s</a>', admin_url( 'update-core.php' ), $messages[5] ) |
|
| 146 | + sprintf( $messages[ 0 ], $pluginName ), |
|
| 147 | + sprintf( $messages[ 1 ], $messages[ 4 ] . ' ' . static::$versions->wordpress ), |
|
| 148 | + sprintf( '<a href="%s">%s</a>', admin_url( 'update-core.php' ), $messages[ 5 ] ) |
|
| 149 | 149 | ); |
| 150 | 150 | } |
| 151 | 151 | } |
@@ -85,7 +85,9 @@ |
||
| 85 | 85 | */ |
| 86 | 86 | public function deactivate( $plugin ) |
| 87 | 87 | { |
| 88 | - if( static::isValid() )return; |
|
| 88 | + if( static::isValid() ) { |
|
| 89 | + return; |
|
| 90 | + } |
|
| 89 | 91 | $pluginSlug = plugin_basename( static::$file ); |
| 90 | 92 | if( $plugin == $pluginSlug ) { |
| 91 | 93 | $this->redirect(); //exit |
@@ -16,10 +16,10 @@ discard block |
||
| 16 | 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 | 24 | <?php if( $isCastorTheme ) : ?> |
| 25 | 25 | <div id="glbb-templates" class="glbb-debug-panel"> |
@@ -27,6 +27,6 @@ discard block |
||
| 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> |
@@ -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( $_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/> |
|
@@ -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 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | 'profilerLabel' => $this->getProfilerLabel(), |
| 162 | 162 | 'queries' => $this->getQueries(), |
| 163 | 163 | 'queriesLabel' => $this->getQueriesLabel(), |
| 164 | - )); |
|
| 164 | + ) ); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -179,18 +179,18 @@ discard block |
||
| 179 | 179 | { |
| 180 | 180 | $errors = array(); |
| 181 | 181 | foreach( $this->errors as $error ) { |
| 182 | - if( $error['errno'] == E_WARNING ) { |
|
| 183 | - $error['name'] = '<span class="glbb-error">'.$error['name'].'</span>'; |
|
| 182 | + if( $error[ 'errno' ] == E_WARNING ) { |
|
| 183 | + $error[ 'name' ] = '<span class="glbb-error">' . $error[ 'name' ] . '</span>'; |
|
| 184 | 184 | } |
| 185 | - if( $error['count'] > 1 ) { |
|
| 186 | - $error['name'] .= ' ('.$error['count'].')'; |
|
| 185 | + if( $error[ 'count' ] > 1 ) { |
|
| 186 | + $error[ 'name' ] .= ' (' . $error[ 'count' ] . ')'; |
|
| 187 | 187 | } |
| 188 | - $errors[] = array( |
|
| 189 | - 'name' => $error['name'], |
|
| 188 | + $errors[ ] = array( |
|
| 189 | + 'name' => $error[ 'name' ], |
|
| 190 | 190 | 'message' => sprintf( __( '%s on line %s in file %s', 'blackbar' ), |
| 191 | - $error['message'], |
|
| 192 | - $error['line'], |
|
| 193 | - $error['file'] |
|
| 191 | + $error[ 'message' ], |
|
| 192 | + $error[ 'line' ], |
|
| 193 | + $error[ 'file' ] |
|
| 194 | 194 | ), |
| 195 | 195 | ); |
| 196 | 196 | } |
@@ -204,13 +204,13 @@ discard block |
||
| 204 | 204 | { |
| 205 | 205 | $warningCount = 0; |
| 206 | 206 | foreach( $this->errors as $error ) { |
| 207 | - if( $error['errno'] == E_WARNING ) { |
|
| 207 | + if( $error[ 'errno' ] == E_WARNING ) { |
|
| 208 | 208 | $warningCount++; |
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | 211 | $errorCount = count( $this->errors ); |
| 212 | 212 | $warnings = $warningCount > 0 ? sprintf( ', %d!', $warningCount ) : ''; |
| 213 | - return sprintf( __( 'Errors (%s)', 'blackbar' ), $errorCount.$warnings ); |
|
| 213 | + return sprintf( __( 'Errors (%s)', 'blackbar' ), $errorCount . $warnings ); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | /** |
@@ -241,14 +241,14 @@ discard block |
||
| 241 | 241 | 'WHERE', |
| 242 | 242 | ); |
| 243 | 243 | $replace = array_map( function( $value ) { |
| 244 | - return PHP_EOL.$value; |
|
| 244 | + return PHP_EOL . $value; |
|
| 245 | 245 | }, $search ); |
| 246 | 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] )); |
|
| 247 | + $miliseconds = number_format( round( $query[ 1 ] * 1000, 4 ), 4 ); |
|
| 248 | + $sql = preg_replace( '/\s\s+/', ' ', trim( $query[ 0 ] ) ); |
|
| 249 | 249 | $sql = str_replace( PHP_EOL, ' ', $sql ); |
| 250 | 250 | $sql = str_replace( $search, $replace, $sql ); |
| 251 | - $queries[] = array( |
|
| 251 | + $queries[ ] = array( |
|
| 252 | 252 | 'ms' => $miliseconds, |
| 253 | 253 | 'sql' => $sql, |
| 254 | 254 | ); |
@@ -267,10 +267,10 @@ discard block |
||
| 267 | 267 | global $wpdb; |
| 268 | 268 | $queryTime = 0; |
| 269 | 269 | foreach( $wpdb->queries as $query ) { |
| 270 | - $queryTime += $query[1]; |
|
| 270 | + $queryTime += $query[ 1 ]; |
|
| 271 | 271 | } |
| 272 | - $queriesCount = '<span class="glbb-queries-count">'.count( $wpdb->queries ).'</span>'; |
|
| 273 | - $queriesTime = '<span class="glbb-queries-time">'.$this->convertToMiliseconds( $queryTime ).'</span>'; |
|
| 272 | + $queriesCount = '<span class="glbb-queries-count">' . count( $wpdb->queries ) . '</span>'; |
|
| 273 | + $queriesTime = '<span class="glbb-queries-time">' . $this->convertToMiliseconds( $queryTime ) . '</span>'; |
|
| 274 | 274 | return sprintf( __( 'SQL (%s queries in %s ms)', 'blackbar' ), $queriesCount, $queriesTime ); |
| 275 | 275 | } |
| 276 | 276 | |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | */ |
| 281 | 281 | protected function path( $file = '' ) |
| 282 | 282 | { |
| 283 | - return plugin_dir_path( $this->file ).ltrim( trim( $file ), '/' ); |
|
| 283 | + return plugin_dir_path( $this->file ) . ltrim( trim( $file ), '/' ); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | /** |
@@ -289,6 +289,6 @@ discard block |
||
| 289 | 289 | */ |
| 290 | 290 | protected function url( $path = '' ) |
| 291 | 291 | { |
| 292 | - return esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' )); |
|
| 292 | + return esc_url( plugin_dir_url( $this->file ) . ltrim( trim( $path ), '/' ) ); |
|
| 293 | 293 | } |
| 294 | 294 | } |
@@ -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 | } |
@@ -240,7 +244,8 @@ discard block |
||
| 240 | 244 | 'SET', |
| 241 | 245 | 'WHERE', |
| 242 | 246 | ); |
| 243 | - $replace = array_map( function( $value ) { |
|
| 247 | + $replace = array_map( function( $value ) |
|
| 248 | + { |
|
| 244 | 249 | return PHP_EOL.$value; |
| 245 | 250 | }, $search ); |
| 246 | 251 | foreach( $wpdb->queries as $query ) { |
@@ -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 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | $this->noise = $microtime - $this->start; |
| 89 | 89 | return; |
| 90 | 90 | } |
| 91 | - $this->timers[] = array( |
|
| 91 | + $this->timers[ ] = array( |
|
| 92 | 92 | 'name' => $name, |
| 93 | 93 | 'time' => $microtime, |
| 94 | 94 | 'memory' => memory_get_peak_usage(), |
@@ -105,6 +105,6 @@ discard block |
||
| 105 | 105 | 'name' => '', |
| 106 | 106 | 'time' => 0, |
| 107 | 107 | 'memory' => 0, |
| 108 | - )); |
|
| 108 | + ) ); |
|
| 109 | 109 | } |
| 110 | 110 | } |
@@ -18,14 +18,14 @@ |
||
| 18 | 18 | |
| 19 | 19 | defined( 'WPINC' ) || die; |
| 20 | 20 | |
| 21 | -if( !class_exists( 'GL_Plugin_Check' )) { |
|
| 22 | - require_once __DIR__.'/activate.php'; |
|
| 21 | +if( !class_exists( 'GL_Plugin_Check' ) ) { |
|
| 22 | + require_once __DIR__ . '/activate.php'; |
|
| 23 | 23 | } |
| 24 | -require_once __DIR__.'/autoload.php'; |
|
| 24 | +require_once __DIR__ . '/autoload.php'; |
|
| 25 | 25 | |
| 26 | -if( !GL_Plugin_Check::shouldDeactivate( __FILE__, array( 'php' => '5.4', 'wordpress' => '4.0.0' ))) { |
|
| 27 | - if( !defined( 'SAVEQUERIES' )) { |
|
| 26 | +if( !GL_Plugin_Check::shouldDeactivate( __FILE__, array( 'php' => '5.4', 'wordpress' => '4.0.0' ) ) ) { |
|
| 27 | + if( !defined( 'SAVEQUERIES' ) ) { |
|
| 28 | 28 | define( 'SAVEQUERIES', 1 ); |
| 29 | 29 | } |
| 30 | - (new GeminiLabs\BlackBar\Application)->init(); |
|
| 30 | + ( new GeminiLabs\BlackBar\Application )->init(); |
|
| 31 | 31 | } |