@@ -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 |
@@ -30,21 +30,21 @@ discard block |
||
| 30 | 30 | * @param string $version |
| 31 | 31 | * @return bool |
| 32 | 32 | */ |
| 33 | - public static function isPhpValid( $version = '' ) |
|
| 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 | - return !version_compare( PHP_VERSION, static::$versions->php, '<' ); |
|
| 38 | + return !version_compare(PHP_VERSION, static::$versions->php, '<'); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * @return bool |
| 43 | 43 | */ |
| 44 | - public static function isValid( array $args = array() ) |
|
| 44 | + public static function isValid(array $args = array()) |
|
| 45 | 45 | { |
| 46 | - if( !empty( $args )) { |
|
| 47 | - static::normalize( $args ); |
|
| 46 | + if (!empty($args)) { |
|
| 47 | + static::normalize($args); |
|
| 48 | 48 | } |
| 49 | 49 | return static::isPhpValid() && static::isWpValid(); |
| 50 | 50 | } |
@@ -53,28 +53,28 @@ discard block |
||
| 53 | 53 | * @param string $version |
| 54 | 54 | * @return bool |
| 55 | 55 | */ |
| 56 | - public static function isWpValid( $version = '' ) |
|
| 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 | - return !version_compare( $wp_version, static::$versions->wordpress, '<' ); |
|
| 62 | + return !version_compare($wp_version, static::$versions->wordpress, '<'); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | 66 | * @return bool |
| 67 | 67 | */ |
| 68 | - public static function shouldDeactivate( $file, array $args = array() ) |
|
| 68 | + public static function shouldDeactivate($file, array $args = array()) |
|
| 69 | 69 | { |
| 70 | - if( empty( static::$instance )) { |
|
| 71 | - static::$file = realpath( $file ); |
|
| 70 | + if (empty(static::$instance)) { |
|
| 71 | + static::$file = realpath($file); |
|
| 72 | 72 | static::$instance = new static; |
| 73 | - static::$versions = static::normalize( $args ); |
|
| 73 | + static::$versions = static::normalize($args); |
|
| 74 | 74 | } |
| 75 | - if( !static::isValid() ) { |
|
| 76 | - add_action( 'activated_plugin', array( static::$instance, 'deactivate' )); |
|
| 77 | - add_action( 'admin_notices', array( static::$instance, 'deactivate' )); |
|
| 75 | + if (!static::isValid()) { |
|
| 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; |
@@ -83,24 +83,24 @@ discard block |
||
| 83 | 83 | /** |
| 84 | 84 | * @return void |
| 85 | 85 | */ |
| 86 | - public function deactivate( $plugin ) |
|
| 86 | + public function deactivate($plugin) |
|
| 87 | 87 | { |
| 88 | - if( static::isValid() )return; |
|
| 89 | - $pluginSlug = plugin_basename( static::$file ); |
|
| 90 | - if( $plugin == $pluginSlug ) { |
|
| 88 | + if (static::isValid())return; |
|
| 89 | + $pluginSlug = plugin_basename(static::$file); |
|
| 90 | + if ($plugin == $pluginSlug) { |
|
| 91 | 91 | $this->redirect(); //exit |
| 92 | 92 | } |
| 93 | - $pluginData = get_file_data( static::$file, array( 'name' => 'Plugin Name' ), 'plugin' ); |
|
| 94 | - deactivate_plugins( $pluginSlug ); |
|
| 95 | - $this->printNotice( $pluginData['name'] ); |
|
| 93 | + $pluginData = get_file_data(static::$file, array('name' => 'Plugin Name'), 'plugin'); |
|
| 94 | + deactivate_plugins($pluginSlug); |
|
| 95 | + $this->printNotice($pluginData['name']); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | 99 | * @return object |
| 100 | 100 | */ |
| 101 | - protected static function normalize( array $args = array() ) |
|
| 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 | )); |
@@ -111,10 +111,10 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | protected function redirect() |
| 113 | 113 | { |
| 114 | - wp_safe_redirect( self_admin_url( sprintf( 'plugins.php?plugin_status=%s&paged=%s&s=%s', |
|
| 115 | - filter_input( INPUT_GET, 'plugin_status' ), |
|
| 116 | - filter_input( INPUT_GET, 'paged' ), |
|
| 117 | - filter_input( INPUT_GET, 's' ) |
|
| 114 | + wp_safe_redirect(self_admin_url(sprintf('plugins.php?plugin_status=%s&paged=%s&s=%s', |
|
| 115 | + filter_input(INPUT_GET, 'plugin_status'), |
|
| 116 | + filter_input(INPUT_GET, 'paged'), |
|
| 117 | + filter_input(INPUT_GET, 's') |
|
| 118 | 118 | ))); |
| 119 | 119 | exit; |
| 120 | 120 | } |
@@ -123,29 +123,29 @@ discard block |
||
| 123 | 123 | * @param string $pluginName |
| 124 | 124 | * @return void |
| 125 | 125 | */ |
| 126 | - protected function printNotice( $pluginName ) |
|
| 126 | + protected function printNotice($pluginName) |
|
| 127 | 127 | { |
| 128 | 128 | $noticeTemplate = '<div id="message" class="notice notice-error error is-dismissible"><p><strong>%s</strong></p><p>%s</p><p>%s</p></div>'; |
| 129 | 129 | $messages = array( |
| 130 | - __( 'The %s plugin was deactivated.', 'blackbar' ), |
|
| 131 | - __( 'Sorry, this plugin requires %s or greater in order to work properly.', 'blackbar' ), |
|
| 132 | - __( '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' ), |
|
| 133 | - __( 'PHP version', 'blackbar' ), |
|
| 134 | - __( 'WordPress version', 'blackbar' ), |
|
| 135 | - __( 'Update WordPress', 'blackbar' ), |
|
| 130 | + __('The %s plugin was deactivated.', 'blackbar'), |
|
| 131 | + __('Sorry, this plugin requires %s or greater in order to work properly.', 'blackbar'), |
|
| 132 | + __('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'), |
|
| 133 | + __('PHP version', 'blackbar'), |
|
| 134 | + __('WordPress version', 'blackbar'), |
|
| 135 | + __('Update WordPress', 'blackbar'), |
|
| 136 | 136 | ); |
| 137 | - if( !static::isPhpValid() ) { |
|
| 138 | - printf( $noticeTemplate, |
|
| 139 | - sprintf( $messages[0], $pluginName ), |
|
| 140 | - sprintf( $messages[1], $messages[3].' '.static::$versions->php ), |
|
| 141 | - sprintf( $messages[2], PHP_VERSION ) |
|
| 137 | + if (!static::isPhpValid()) { |
|
| 138 | + printf($noticeTemplate, |
|
| 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 | - else if( !static::isWpValid() ) { |
|
| 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] ) |
|
| 144 | + else if (!static::isWpValid()) { |
|
| 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]) |
|
| 149 | 149 | ); |
| 150 | 150 | } |
| 151 | 151 | } |
@@ -1,21 +1,21 @@ |
||
| 1 | -<?php defined( 'WPINC' ) || die; ?> |
|
| 1 | +<?php defined('WPINC') || die; ?> |
|
| 2 | 2 | |
| 3 | -<?php if( !SAVEQUERIES ) : ?> |
|
| 3 | +<?php if (!SAVEQUERIES) : ?> |
|
| 4 | 4 | <table> |
| 5 | 5 | <tbody> |
| 6 | 6 | <tr> |
| 7 | - <td><a href="https://codex.wordpress.org/Debugging_in_WordPress#SAVEQUERIES">SAVEQUERIES</a> <?= __( 'must be enabled to view SQL queries', 'blackbar' ); ?>.</td> |
|
| 7 | + <td><a href="https://codex.wordpress.org/Debugging_in_WordPress#SAVEQUERIES">SAVEQUERIES</a> <?= __('must be enabled to view SQL queries', 'blackbar'); ?>.</td> |
|
| 8 | 8 | </tr> |
| 9 | 9 | </tbody> |
| 10 | 10 | </table> |
| 11 | 11 | <?php else : ?> |
| 12 | 12 | <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_min_time" id="glbb_query_min_time" placeholder="<?= __( 'Minimum Execution Time', 'blackbar' ); ?>"> |
|
| 13 | + <input type="text" name="glbb_query_filter" id="glbb_query_filter" placeholder="<?= __('Find queries containing', 'blackbar'); ?>"> |
|
| 14 | + <input type="text" name="glbb_query_min_time" id="glbb_query_min_time" placeholder="<?= __('Minimum Execution Time', 'blackbar'); ?>"> |
|
| 15 | 15 | </form> |
| 16 | 16 | <table class="glbb-queries-table"> |
| 17 | 17 | <tbody> |
| 18 | - <?php foreach( $queries as $query ) : ?> |
|
| 18 | + <?php foreach ($queries as $query) : ?> |
|
| 19 | 19 | <tr> |
| 20 | 20 | <td class="glbb-small"><?= $query['ms']; ?></td> |
| 21 | 21 | <td><pre><code class="sql"><?= $query['sql']; ?></code></pre></td> |
@@ -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"> |
@@ -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 class="glbb-small"><?= $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 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; ?> |
@@ -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-medium"><?= $profiler->getTimeString( $timer ); ?></td> |
|
| 9 | - <td class="glbb-medium"><?= $profiler->getMemoryString( $timer ); ?></td> |
|
| 7 | + <td><?= $profiler->getNameString($timer); ?></td> |
|
| 8 | + <td class="glbb-medium"><?= $profiler->getTimeString($timer); ?></td> |
|
| 9 | + <td class="glbb-medium"><?= $profiler->getMemoryString($timer); ?></td> |
|
| 10 | 10 | </tr> |
| 11 | 11 | <?php endforeach; ?> |
| 12 | 12 | </tbody> |
@@ -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, |
@@ -261,34 +261,34 @@ discard block |
||
| 261 | 261 | */ |
| 262 | 262 | protected function getQueriesLabel() |
| 263 | 263 | { |
| 264 | - if( !SAVEQUERIES ) { |
|
| 265 | - return __( 'SQL', 'blackbar' ); |
|
| 264 | + if (!SAVEQUERIES) { |
|
| 265 | + return __('SQL', 'blackbar'); |
|
| 266 | 266 | } |
| 267 | 267 | global $wpdb; |
| 268 | 268 | $queryTime = 0; |
| 269 | - foreach( $wpdb->queries as $query ) { |
|
| 269 | + foreach ($wpdb->queries as $query) { |
|
| 270 | 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>'; |
|
| 274 | - return sprintf( __( 'SQL (%s queries in %s ms)', 'blackbar' ), $queriesCount, $queriesTime ); |
|
| 272 | + $queriesCount = '<span class="glbb-queries-count">'.count($wpdb->queries).'</span>'; |
|
| 273 | + $queriesTime = '<span class="glbb-queries-time">'.$this->convertToMiliseconds($queryTime).'</span>'; |
|
| 274 | + return sprintf(__('SQL (%s queries in %s ms)', 'blackbar'), $queriesCount, $queriesTime); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
| 278 | 278 | * @param string $file |
| 279 | 279 | * @return string |
| 280 | 280 | */ |
| 281 | - protected function path( $file = '' ) |
|
| 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 | /** |
| 287 | 287 | * @param string $path |
| 288 | 288 | * @return string |
| 289 | 289 | */ |
| 290 | - protected function url( $path = '' ) |
|
| 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 | } |
@@ -16,16 +16,16 @@ |
||
| 16 | 16 | * Domain Path: languages |
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | -defined( 'WPINC' ) || die; |
|
| 19 | +defined('WPINC') || die; |
|
| 20 | 20 | |
| 21 | -if( !class_exists( 'GL_Plugin_Check' )) { |
|
| 21 | +if (!class_exists('GL_Plugin_Check')) { |
|
| 22 | 22 | require_once __DIR__.'/activate.php'; |
| 23 | 23 | } |
| 24 | 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' )) { |
|
| 28 | - define( 'SAVEQUERIES', 1 ); |
|
| 26 | +if (!GL_Plugin_Check::shouldDeactivate(__FILE__, array('php' => '5.4', 'wordpress' => '4.0.0'))) { |
|
| 27 | + if (!defined('SAVEQUERIES')) { |
|
| 28 | + define('SAVEQUERIES', 1); |
|
| 29 | 29 | } |
| 30 | 30 | (new GeminiLabs\BlackBar\Application)->init(); |
| 31 | 31 | } |