@@ -23,9 +23,9 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public function enqueueAssets() |
| 25 | 25 | { |
| 26 | - wp_enqueue_script( Application::ID, $this->app->url( 'assets/main.js' )); |
|
| 27 | - wp_enqueue_style( Application::ID, $this->app->url( 'assets/main.css' ), array( 'dashicons' )); |
|
| 28 | - wp_enqueue_style( Application::ID.'-syntax', $this->app->url( 'assets/syntax.css' )); |
|
| 26 | + wp_enqueue_script( Application::ID, $this->app->url( 'assets/main.js' ) ); |
|
| 27 | + wp_enqueue_style( Application::ID, $this->app->url( 'assets/main.css' ), array( 'dashicons' ) ); |
|
| 28 | + wp_enqueue_style( Application::ID . '-syntax', $this->app->url( 'assets/syntax.css' ) ); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | public function filterBodyClasses( $classes ) |
| 37 | 37 | { |
| 38 | - return trim( $classes.' '.Application::ID ); |
|
| 38 | + return trim( $classes . ' ' . Application::ID ); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -44,16 +44,16 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function initConsole() |
| 46 | 46 | { |
| 47 | - if( func_get_arg(0) != Application::CONSOLE_HOOK )return; |
|
| 47 | + if( func_get_arg( 0 ) != Application::CONSOLE_HOOK )return; |
|
| 48 | 48 | $args = array_pad( func_get_args(), 4, '' ); |
| 49 | 49 | $backtrace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 4 ); |
| 50 | 50 | $entry = array_pop( $backtrace ); |
| 51 | - $location = $args[3].' '; |
|
| 52 | - if( empty( trim( $location )) && array_key_exists( 'file', $entry )) { |
|
| 53 | - $path = explode( ABSPATH, $entry['file'] ); |
|
| 54 | - $location = sprintf( '[%s:%s] ', array_pop( $path ), $entry['line'] ); |
|
| 51 | + $location = $args[ 3 ] . ' '; |
|
| 52 | + if( empty( trim( $location ) ) && array_key_exists( 'file', $entry ) ) { |
|
| 53 | + $path = explode( ABSPATH, $entry[ 'file' ] ); |
|
| 54 | + $location = sprintf( '[%s:%s] ', array_pop( $path ), $entry[ 'line' ] ); |
|
| 55 | 55 | } |
| 56 | - $this->app->console->store( $args[1], $args[2], $location ); |
|
| 56 | + $this->app->console->store( $args[ 1 ], $args[ 2 ], $location ); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function initProfiler() |
| 64 | 64 | { |
| 65 | - if( func_get_arg(0) != Application::PROFILER_HOOK )return; |
|
| 66 | - $this->app->profiler->trace( func_get_arg(1) ); |
|
| 65 | + if( func_get_arg( 0 ) != Application::PROFILER_HOOK )return; |
|
| 66 | + $this->app->profiler->trace( func_get_arg( 1 ) ); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | public function registerLanguages() |
| 74 | 74 | { |
| 75 | 75 | load_plugin_textdomain( Application::ID, false, |
| 76 | - plugin_basename( $this->app->path() ).Application::LANG |
|
| 76 | + plugin_basename( $this->app->path() ) . Application::LANG |
|
| 77 | 77 | ); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | 'queries' => $this->getQueries(), |
| 95 | 95 | 'queriesLabel' => $this->getQueriesLabel(), |
| 96 | 96 | 'templates' => $this->getTemplates(), |
| 97 | - )); |
|
| 97 | + ) ); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -124,10 +124,10 @@ discard block |
||
| 124 | 124 | $entries = $this->getConsoleEntries(); |
| 125 | 125 | $errorCount = 0; |
| 126 | 126 | foreach( $entries as $entry ) { |
| 127 | - if( in_array( $entry['errno'], [E_NOTICE, E_STRICT, E_DEPRECATED] )) { |
|
| 127 | + if( in_array( $entry[ 'errno' ], [ E_NOTICE, E_STRICT, E_DEPRECATED ] ) ) { |
|
| 128 | 128 | $class = 'glbb-warning'; |
| 129 | 129 | } |
| 130 | - if( in_array( $entry['errno'], [E_WARNING] )) { |
|
| 130 | + if( in_array( $entry[ 'errno' ], [ E_WARNING ] ) ) { |
|
| 131 | 131 | $errorCount++; |
| 132 | 132 | } |
| 133 | 133 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | $entryCount .= sprintf( ', %d!', $errorCount ); |
| 138 | 138 | } |
| 139 | 139 | $label = sprintf( __( 'Console (%s)', 'blackbar' ), $entryCount ); |
| 140 | - return '<span class="'.$class.'">'.$label.'</span>'; |
|
| 140 | + return '<span class="' . $class . '">' . $label . '</span>'; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -148,22 +148,22 @@ discard block |
||
| 148 | 148 | $errors = array(); |
| 149 | 149 | foreach( $this->app->errors as $error ) { |
| 150 | 150 | $class = 'glbb-info'; |
| 151 | - if( in_array( $error['errno'], [E_NOTICE, E_STRICT, E_DEPRECATED] )) { |
|
| 151 | + if( in_array( $error[ 'errno' ], [ E_NOTICE, E_STRICT, E_DEPRECATED ] ) ) { |
|
| 152 | 152 | $class = 'glbb-warning'; |
| 153 | 153 | } |
| 154 | - if( $error['errno'] == E_WARNING ) { |
|
| 154 | + if( $error[ 'errno' ] == E_WARNING ) { |
|
| 155 | 155 | $class = 'glbb-error'; |
| 156 | 156 | } |
| 157 | - if( $error['count'] > 1 ) { |
|
| 158 | - $error['name'] .= ' ('.$error['count'].')'; |
|
| 157 | + if( $error[ 'count' ] > 1 ) { |
|
| 158 | + $error[ 'name' ] .= ' (' . $error[ 'count' ] . ')'; |
|
| 159 | 159 | } |
| 160 | - $errors[] = array( |
|
| 161 | - 'errno' => $error['errno'], |
|
| 162 | - 'name' => '<span class="'.$class.'">'.$error['name'].'</span>', |
|
| 160 | + $errors[ ] = array( |
|
| 161 | + 'errno' => $error[ 'errno' ], |
|
| 162 | + 'name' => '<span class="' . $class . '">' . $error[ 'name' ] . '</span>', |
|
| 163 | 163 | 'message' => sprintf( __( '%s on line %s in file %s', 'blackbar' ), |
| 164 | - $error['message'], |
|
| 165 | - $error['line'], |
|
| 166 | - $error['file'] |
|
| 164 | + $error[ 'message' ], |
|
| 165 | + $error[ 'line' ], |
|
| 166 | + $error[ 'file' ] |
|
| 167 | 167 | ), |
| 168 | 168 | ); |
| 169 | 169 | } |
@@ -178,8 +178,8 @@ discard block |
||
| 178 | 178 | $files = array_values( array_filter( get_included_files(), function( $file ) { |
| 179 | 179 | $bool = strpos( $file, '/themes/' ) !== false |
| 180 | 180 | && strpos( $file, '/functions.php' ) === false; |
| 181 | - return (bool)apply_filters( 'blackbar/templates/file', $bool, $file ); |
|
| 182 | - })); |
|
| 181 | + return (bool) apply_filters( 'blackbar/templates/file', $bool, $file ); |
|
| 182 | + }) ); |
|
| 183 | 183 | return array_map( function( $key, $value ) { |
| 184 | 184 | $value = str_replace( trailingslashit( WP_CONTENT_DIR ), '', $value ); |
| 185 | 185 | return sprintf( '[%s] => %s', $key, $value ); |
@@ -207,14 +207,14 @@ discard block |
||
| 207 | 207 | 'ORDER BY', 'SET', 'WHERE', |
| 208 | 208 | ); |
| 209 | 209 | $replace = array_map( function( $value ) { |
| 210 | - return PHP_EOL.$value; |
|
| 210 | + return PHP_EOL . $value; |
|
| 211 | 211 | }, $search ); |
| 212 | 212 | foreach( $wpdb->queries as $query ) { |
| 213 | - $miliseconds = number_format( round( $query[1] * 1000, 4 ), 4 ); |
|
| 214 | - $sql = preg_replace( '/\s\s+/', ' ', trim( $query[0] )); |
|
| 213 | + $miliseconds = number_format( round( $query[ 1 ] * 1000, 4 ), 4 ); |
|
| 214 | + $sql = preg_replace( '/\s\s+/', ' ', trim( $query[ 0 ] ) ); |
|
| 215 | 215 | $sql = str_replace( PHP_EOL, ' ', $sql ); |
| 216 | 216 | $sql = str_replace( $search, $replace, $sql ); |
| 217 | - $queries[] = array( |
|
| 217 | + $queries[ ] = array( |
|
| 218 | 218 | 'ms' => $miliseconds, |
| 219 | 219 | 'sql' => $sql, |
| 220 | 220 | ); |
@@ -233,10 +233,10 @@ discard block |
||
| 233 | 233 | global $wpdb; |
| 234 | 234 | $queryTime = 0; |
| 235 | 235 | foreach( $wpdb->queries as $query ) { |
| 236 | - $queryTime += $query[1]; |
|
| 236 | + $queryTime += $query[ 1 ]; |
|
| 237 | 237 | } |
| 238 | - $queriesCount = '<span class="glbb-queries-count">'.count( $wpdb->queries ).'</span>'; |
|
| 239 | - $queriesTime = '<span class="glbb-queries-time">'.$this->convertToMiliseconds( $queryTime ).'</span>'; |
|
| 238 | + $queriesCount = '<span class="glbb-queries-count">' . count( $wpdb->queries ) . '</span>'; |
|
| 239 | + $queriesTime = '<span class="glbb-queries-time">' . $this->convertToMiliseconds( $queryTime ) . '</span>'; |
|
| 240 | 240 | return sprintf( __( 'SQL (%s queries | %s ms)', 'blackbar' ), $queriesCount, $queriesTime ); |
| 241 | 241 | } |
| 242 | 242 | |
@@ -246,11 +246,11 @@ discard block |
||
| 246 | 246 | protected function getTemplates() |
| 247 | 247 | { |
| 248 | 248 | if( is_admin() )return; |
| 249 | - if( class_exists( '\GeminiLabs\Castor\Facades\Development' )) { |
|
| 249 | + if( class_exists( '\GeminiLabs\Castor\Facades\Development' ) ) { |
|
| 250 | 250 | ob_start(); |
| 251 | 251 | \GeminiLabs\Castor\Facades\Development::printTemplatePaths(); |
| 252 | 252 | return ob_get_clean(); |
| 253 | 253 | } |
| 254 | - return '<pre>'.implode( PHP_EOL, $this->getIncludedFiles() ).'</pre>'; |
|
| 254 | + return '<pre>' . implode( PHP_EOL, $this->getIncludedFiles() ) . '</pre>'; |
|
| 255 | 255 | } |
| 256 | 256 | } |
@@ -44,7 +44,9 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function initConsole() |
| 46 | 46 | { |
| 47 | - if( func_get_arg(0) != Application::CONSOLE_HOOK )return; |
|
| 47 | + if( func_get_arg(0) != Application::CONSOLE_HOOK ) { |
|
| 48 | + return; |
|
| 49 | + } |
|
| 48 | 50 | $args = array_pad( func_get_args(), 4, '' ); |
| 49 | 51 | $backtrace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 4 ); |
| 50 | 52 | $entry = array_pop( $backtrace ); |
@@ -62,7 +64,9 @@ discard block |
||
| 62 | 64 | */ |
| 63 | 65 | public function initProfiler() |
| 64 | 66 | { |
| 65 | - if( func_get_arg(0) != Application::PROFILER_HOOK )return; |
|
| 67 | + if( func_get_arg(0) != Application::PROFILER_HOOK ) { |
|
| 68 | + return; |
|
| 69 | + } |
|
| 66 | 70 | $this->app->profiler->trace( func_get_arg(1) ); |
| 67 | 71 | } |
| 68 | 72 | |
@@ -175,12 +179,14 @@ discard block |
||
| 175 | 179 | */ |
| 176 | 180 | protected function getIncludedFiles() |
| 177 | 181 | { |
| 178 | - $files = array_values( array_filter( get_included_files(), function( $file ) { |
|
| 182 | + $files = array_values( array_filter( get_included_files(), function( $file ) |
|
| 183 | + { |
|
| 179 | 184 | $bool = strpos( $file, '/themes/' ) !== false |
| 180 | 185 | && strpos( $file, '/functions.php' ) === false; |
| 181 | 186 | return (bool)apply_filters( 'blackbar/templates/file', $bool, $file ); |
| 182 | 187 | })); |
| 183 | - return array_map( function( $key, $value ) { |
|
| 188 | + return array_map( function( $key, $value ) |
|
| 189 | + { |
|
| 184 | 190 | $value = str_replace( trailingslashit( WP_CONTENT_DIR ), '', $value ); |
| 185 | 191 | return sprintf( '[%s] => %s', $key, $value ); |
| 186 | 192 | }, array_keys( $files ), $files ); |
@@ -206,7 +212,8 @@ discard block |
||
| 206 | 212 | 'AND', 'FROM', 'GROUP BY', 'INNER JOIN', 'LIMIT', 'ON DUPLICATE KEY UPDATE', |
| 207 | 213 | 'ORDER BY', 'SET', 'WHERE', |
| 208 | 214 | ); |
| 209 | - $replace = array_map( function( $value ) { |
|
| 215 | + $replace = array_map( function( $value ) |
|
| 216 | + { |
|
| 210 | 217 | return PHP_EOL.$value; |
| 211 | 218 | }, $search ); |
| 212 | 219 | foreach( $wpdb->queries as $query ) { |
@@ -245,7 +252,9 @@ discard block |
||
| 245 | 252 | */ |
| 246 | 253 | protected function getTemplates() |
| 247 | 254 | { |
| 248 | - if( is_admin() )return; |
|
| 255 | + if( is_admin() ) { |
|
| 256 | + return; |
|
| 257 | + } |
|
| 249 | 258 | if( class_exists( '\GeminiLabs\Castor\Facades\Development' )) { |
| 250 | 259 | ob_start(); |
| 251 | 260 | \GeminiLabs\Castor\Facades\Development::printTemplatePaths(); |
@@ -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 | |
@@ -35,14 +35,14 @@ discard block |
||
| 35 | 35 | public function errorHandler( $errno, $errstr, $errfile, $errline ) |
| 36 | 36 | { |
| 37 | 37 | $errname = array_key_exists( $errno, Console::ERROR_CODES ) |
| 38 | - ? Console::ERROR_CODES[$errno] |
|
| 38 | + ? Console::ERROR_CODES[ $errno ] |
|
| 39 | 39 | : 'Unknown'; |
| 40 | - $hash = md5( $errno.$errstr.$errfile.$errline ); |
|
| 41 | - if( array_key_exists( $hash, $this->errors )) { |
|
| 42 | - $this->errors[$hash]['count']++; |
|
| 40 | + $hash = md5( $errno . $errstr . $errfile . $errline ); |
|
| 41 | + if( array_key_exists( $hash, $this->errors ) ) { |
|
| 42 | + $this->errors[ $hash ][ 'count' ]++; |
|
| 43 | 43 | } |
| 44 | 44 | else { |
| 45 | - $this->errors[$hash] = array( |
|
| 45 | + $this->errors[ $hash ] = array( |
|
| 46 | 46 | "errno" => $errno, |
| 47 | 47 | "message" => $errstr, |
| 48 | 48 | "file" => $errfile, |
@@ -59,20 +59,20 @@ discard block |
||
| 59 | 59 | public function init() |
| 60 | 60 | { |
| 61 | 61 | $controller = new Controller( $this ); |
| 62 | - add_filter( 'all', array( $controller, 'initConsole' )); |
|
| 63 | - add_filter( 'all', array( $controller, 'initProfiler' )); |
|
| 64 | - add_action( 'plugins_loaded', array( $controller, 'registerLanguages' )); |
|
| 62 | + add_filter( 'all', array( $controller, 'initConsole' ) ); |
|
| 63 | + add_filter( 'all', array( $controller, 'initProfiler' ) ); |
|
| 64 | + add_action( 'plugins_loaded', array( $controller, 'registerLanguages' ) ); |
|
| 65 | 65 | add_action( 'init', function() use( $controller ) { |
| 66 | - if( !apply_filters( 'blackbar/enabled', true ))return; |
|
| 67 | - add_action( 'admin_enqueue_scripts', array( $controller, 'enqueueAssets' )); |
|
| 68 | - add_action( 'wp_enqueue_scripts', array( $controller, 'enqueueAssets' )); |
|
| 69 | - add_action( 'admin_footer', array( $controller, 'renderBar' )); |
|
| 70 | - add_action( 'wp_footer', array( $controller, 'renderBar' )); |
|
| 71 | - add_filter( 'admin_body_class', array( $controller, 'filterBodyClasses' )); |
|
| 66 | + if( !apply_filters( 'blackbar/enabled', true ) )return; |
|
| 67 | + add_action( 'admin_enqueue_scripts', array( $controller, 'enqueueAssets' ) ); |
|
| 68 | + add_action( 'wp_enqueue_scripts', array( $controller, 'enqueueAssets' ) ); |
|
| 69 | + add_action( 'admin_footer', array( $controller, 'renderBar' ) ); |
|
| 70 | + add_action( 'wp_footer', array( $controller, 'renderBar' ) ); |
|
| 71 | + add_filter( 'admin_body_class', array( $controller, 'filterBodyClasses' ) ); |
|
| 72 | 72 | }); |
| 73 | 73 | apply_filters( 'debug', 'Profiler Started' ); |
| 74 | 74 | apply_filters( 'debug', 'blackbar/profiler/noise' ); |
| 75 | - set_error_handler( array( $this, 'errorHandler' ), E_ALL|E_STRICT ); |
|
| 75 | + set_error_handler( array( $this, 'errorHandler' ), E_ALL | E_STRICT ); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | public function path( $file = '' ) |
| 83 | 83 | { |
| 84 | - return plugin_dir_path( $this->file ).ltrim( trim( $file ), '/' ); |
|
| 84 | + return plugin_dir_path( $this->file ) . ltrim( trim( $file ), '/' ); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -90,8 +90,8 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function render( $view, array $data = array() ) |
| 92 | 92 | { |
| 93 | - $file = $this->path( sprintf( 'views/%s.php', str_replace( '.php', '', $view ))); |
|
| 94 | - if( !file_exists( $file ))return; |
|
| 93 | + $file = $this->path( sprintf( 'views/%s.php', str_replace( '.php', '', $view ) ) ); |
|
| 94 | + if( !file_exists( $file ) )return; |
|
| 95 | 95 | extract( $data ); |
| 96 | 96 | include $file; |
| 97 | 97 | } |
@@ -102,6 +102,6 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function url( $path = '' ) |
| 104 | 104 | { |
| 105 | - return esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' )); |
|
| 105 | + return esc_url( plugin_dir_url( $this->file ) . ltrim( trim( $path ), '/' ) ); |
|
| 106 | 106 | } |
| 107 | 107 | } |
@@ -35,16 +35,16 @@ discard block |
||
| 35 | 35 | public function store( $message, $errno = 0, $location = '' ) |
| 36 | 36 | { |
| 37 | 37 | $errname = 'Debug'; |
| 38 | - if( array_key_exists( $errno, static::MAPPED_ERROR_CODES )) { |
|
| 38 | + if( array_key_exists( $errno, static::MAPPED_ERROR_CODES ) ) { |
|
| 39 | 39 | $errname = ucfirst( $errno ); |
| 40 | - $errno = static::MAPPED_ERROR_CODES[$errno]; |
|
| 40 | + $errno = static::MAPPED_ERROR_CODES[ $errno ]; |
|
| 41 | 41 | } |
| 42 | - else if( array_key_exists( $errno, static::ERROR_CODES )) { |
|
| 43 | - $errname = static::ERROR_CODES[$errno]; |
|
| 42 | + else if( array_key_exists( $errno, static::ERROR_CODES ) ) { |
|
| 43 | + $errname = static::ERROR_CODES[ $errno ]; |
|
| 44 | 44 | } |
| 45 | - $this->entries[] = array( |
|
| 45 | + $this->entries[ ] = array( |
|
| 46 | 46 | 'errno' => $errno, |
| 47 | - 'message' => $location.$this->normalizeValue( $message ), |
|
| 47 | + 'message' => $location . $this->normalizeValue( $message ), |
|
| 48 | 48 | 'name' => sprintf( '<span class="glbb-info glbb-%s">%s</span>', strtolower( $errname ), $errname ), |
| 49 | 49 | ); |
| 50 | 50 | return $this; |
@@ -68,11 +68,11 @@ discard block |
||
| 68 | 68 | if( $value instanceof DateTime ) { |
| 69 | 69 | $value = $value->format( 'Y-m-d H:i:s' ); |
| 70 | 70 | } |
| 71 | - else if( $this->isObjectOrArray( $value )) { |
|
| 72 | - $value = print_r( json_decode( json_encode( $value )), true ); |
|
| 71 | + else if( $this->isObjectOrArray( $value ) ) { |
|
| 72 | + $value = print_r( json_decode( json_encode( $value ) ), true ); |
|
| 73 | 73 | } |
| 74 | - else if( is_resource( $value )) { |
|
| 75 | - $value = (string)$value; |
|
| 74 | + else if( is_resource( $value ) ) { |
|
| 75 | + $value = (string) $value; |
|
| 76 | 76 | } |
| 77 | 77 | return esc_html( $value ); |
| 78 | 78 | } |