Passed
Push — master ( 662319...acf75d )
by Paul
04:11
created
activate.php 2 patches
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
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
@@ -29,46 +29,46 @@  discard block
 block discarded – undo
29 29
 	/**
30 30
 	 * @return bool
31 31
 	 */
32
-	public static function isValid( array $args = array() )
32
+	public static function isValid(array $args = array())
33 33
 	{
34
-		$versions = static::normalize( $args );
35
-		return static::isPhpValid( $versions->php ) && static::isWpValid( $versions->wordpress );
34
+		$versions = static::normalize($args);
35
+		return static::isPhpValid($versions->php) && static::isWpValid($versions->wordpress);
36 36
 	}
37 37
 
38 38
 	/**
39 39
 	 * @param string $version
40 40
 	 * @return bool
41 41
 	 */
42
-	public static function isPhpValid( $version = '' )
42
+	public static function isPhpValid($version = '')
43 43
 	{
44
-		$versions = static::normalize( array( 'php' => $version ));
45
-		return !version_compare( PHP_VERSION, $versions->php, '<' );
44
+		$versions = static::normalize(array('php' => $version));
45
+		return !version_compare(PHP_VERSION, $versions->php, '<');
46 46
 	}
47 47
 
48 48
 	/**
49 49
 	 * @param string $version
50 50
 	 * @return bool
51 51
 	 */
52
-	public static function isWpValid( $version = '' )
52
+	public static function isWpValid($version = '')
53 53
 	{
54 54
 		global $wp_version;
55
-		$versions = static::normalize( array( 'wordpress' => $version ));
56
-		return !version_compare( $wp_version, $versions->wordpress, '<' );
55
+		$versions = static::normalize(array('wordpress' => $version));
56
+		return !version_compare($wp_version, $versions->wordpress, '<');
57 57
 	}
58 58
 
59 59
 	/**
60 60
 	 * @return bool
61 61
 	 */
62
-	public static function shouldDeactivate( $file, array $args = [] )
62
+	public static function shouldDeactivate($file, array $args = [])
63 63
 	{
64
-		if( empty( static::$instance )) {
65
-			static::$file = realpath( $file );
64
+		if (empty(static::$instance)) {
65
+			static::$file = realpath($file);
66 66
 			static::$instance = new static;
67
-			static::$versions = static::normalize( $args );
67
+			static::$versions = static::normalize($args);
68 68
 		}
69
-		if( !static::isValid() ) {
70
-			add_action( 'activated_plugin', array( static::$instance, 'deactivate' ));
71
-			add_action( 'admin_notices', array( static::$instance, 'deactivate' ));
69
+		if (!static::isValid()) {
70
+			add_action('activated_plugin', array(static::$instance, 'deactivate'));
71
+			add_action('admin_notices', array(static::$instance, 'deactivate'));
72 72
 			return true;
73 73
 		}
74 74
 		return false;
@@ -77,24 +77,24 @@  discard block
 block discarded – undo
77 77
 	/**
78 78
 	 * @return void
79 79
 	 */
80
-	public function deactivate( $plugin )
80
+	public function deactivate($plugin)
81 81
 	{
82
-		if( static::isValid() )return;
83
-		$pluginSlug = plugin_basename( static::$file );
84
-		if( $plugin == $pluginSlug ) {
82
+		if (static::isValid())return;
83
+		$pluginSlug = plugin_basename(static::$file);
84
+		if ($plugin == $pluginSlug) {
85 85
 			$this->redirect(); //exit
86 86
 		}
87
-		$pluginData = get_file_data( static::$file, array( 'name' => 'Plugin Name' ), 'plugin' );
88
-		deactivate_plugins( $pluginSlug );
89
-		$this->printNotice( $pluginData['name'] );
87
+		$pluginData = get_file_data(static::$file, array('name' => 'Plugin Name'), 'plugin');
88
+		deactivate_plugins($pluginSlug);
89
+		$this->printNotice($pluginData['name']);
90 90
 	}
91 91
 
92 92
 	/**
93 93
 	 * @return object
94 94
 	 */
95
-	protected static function normalize( array $args = [] )
95
+	protected static function normalize(array $args = [])
96 96
 	{
97
-		return (object) wp_parse_args( $args, array(
97
+		return (object) wp_parse_args($args, array(
98 98
 			'php' => static::MIN_PHP_VERSION,
99 99
 			'wordpress' => static::MIN_WORDPRESS_VERSION,
100 100
 		));
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
 	 */
106 106
 	protected function redirect()
107 107
 	{
108
-		wp_safe_redirect( self_admin_url( sprintf( 'plugins.php?plugin_status=%s&paged=%s&s=%s',
109
-			filter_input( INPUT_GET, 'plugin_status' ),
110
-			filter_input( INPUT_GET, 'paged' ),
111
-			filter_input( INPUT_GET, 's' )
108
+		wp_safe_redirect(self_admin_url(sprintf('plugins.php?plugin_status=%s&paged=%s&s=%s',
109
+			filter_input(INPUT_GET, 'plugin_status'),
110
+			filter_input(INPUT_GET, 'paged'),
111
+			filter_input(INPUT_GET, 's')
112 112
 		)));
113 113
 		exit;
114 114
 	}
@@ -117,29 +117,29 @@  discard block
 block discarded – undo
117 117
 	 * @param string $pluginName
118 118
 	 * @return void
119 119
 	 */
120
-	protected function printNotice( $pluginName )
120
+	protected function printNotice($pluginName)
121 121
 	{
122 122
 		$noticeTemplate = '<div id="message" class="notice notice-error error is-dismissible"><p><strong>%s</strong></p><p>%s</p><p>%s</p></div>';
123 123
 		$messages = array(
124
-			__( 'The %s plugin was deactivated.', 'blackbar' ),
125
-			__( 'Sorry, this plugin requires %s or greater in order to work properly.', 'blackbar' ),
126
-			__( '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' ),
127
-			__( 'PHP version', 'blackbar' ),
128
-			__( 'WordPress version', 'blackbar' ),
129
-			__( 'Update WordPress', 'blackbar' ),
124
+			__('The %s plugin was deactivated.', 'blackbar'),
125
+			__('Sorry, this plugin requires %s or greater in order to work properly.', 'blackbar'),
126
+			__('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'),
127
+			__('PHP version', 'blackbar'),
128
+			__('WordPress version', 'blackbar'),
129
+			__('Update WordPress', 'blackbar'),
130 130
 		);
131
-		if( !static::isPhpValid() ) {
132
-			printf( $noticeTemplate,
133
-				sprintf( $messages[0], $pluginName ),
134
-				sprintf( $messages[1], $messages[3].' '.static::$versions->php ),
135
-				sprintf( $messages[2], PHP_VERSION )
131
+		if (!static::isPhpValid()) {
132
+			printf($noticeTemplate,
133
+				sprintf($messages[0], $pluginName),
134
+				sprintf($messages[1], $messages[3].' '.static::$versions->php),
135
+				sprintf($messages[2], PHP_VERSION)
136 136
 			);
137 137
 		}
138
-		else if( !static::isWpValid() ) {
139
-			printf( $noticeTemplate,
140
-				sprintf( $messages[0], $pluginName ),
141
-				sprintf( $messages[1], $messages[4].' '.static::$versions->wordpress ),
142
-				sprintf( '<a href="%s">%s</a>', admin_url( 'update-core.php' ), $messages[5] )
138
+		else if (!static::isWpValid()) {
139
+			printf($noticeTemplate,
140
+				sprintf($messages[0], $pluginName),
141
+				sprintf($messages[1], $messages[4].' '.static::$versions->wordpress),
142
+				sprintf('<a href="%s">%s</a>', admin_url('update-core.php'), $messages[5])
143 143
 			);
144 144
 		}
145 145
 	}
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -79,7 +79,9 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	public function deactivate( $plugin )
81 81
 	{
82
-		if( static::isValid() )return;
82
+		if( static::isValid() ) {
83
+			return;
84
+		}
83 85
 		$pluginSlug = plugin_basename( static::$file );
84 86
 		if( $plugin == $pluginSlug ) {
85 87
 			$this->redirect(); //exit
@@ -134,8 +136,7 @@  discard block
 block discarded – undo
134 136
 				sprintf( $messages[1], $messages[3].' '.static::$versions->php ),
135 137
 				sprintf( $messages[2], PHP_VERSION )
136 138
 			);
137
-		}
138
-		else if( !static::isWpValid() ) {
139
+		} else if( !static::isWpValid() ) {
139 140
 			printf( $noticeTemplate,
140 141
 				sprintf( $messages[0], $pluginName ),
141 142
 				sprintf( $messages[1], $messages[4].' '.static::$versions->wordpress ),
Please login to merge, or discard this patch.
src/Application.php 1 patch
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,
@@ -263,29 +263,29 @@  discard block
 block discarded – undo
263 263
 	{
264 264
 		global $wpdb;
265 265
 		$queryTime = 0;
266
-		foreach( $wpdb->queries as $query ) {
266
+		foreach ($wpdb->queries as $query) {
267 267
 			$queryTime += $query[1];
268 268
 		}
269
-		$queriesCount = '<span class="glbb-queries-count">'.count( $wpdb->queries ).'</span>';
270
-		$queriesTime = '<span class="glbb-queries-time">'.$this->convertToMiliseconds( $queryTime ).'</span>';
271
-		return sprintf( __( 'SQL (%s queries in %s ms)', 'blackbar' ), $queriesCount, $queriesTime );
269
+		$queriesCount = '<span class="glbb-queries-count">'.count($wpdb->queries).'</span>';
270
+		$queriesTime = '<span class="glbb-queries-time">'.$this->convertToMiliseconds($queryTime).'</span>';
271
+		return sprintf(__('SQL (%s queries in %s ms)', 'blackbar'), $queriesCount, $queriesTime);
272 272
 	}
273 273
 
274 274
 	/**
275 275
 	 * @param string $file
276 276
 	 * @return string
277 277
 	 */
278
-	protected function path( $file = '' )
278
+	protected function path($file = '')
279 279
 	{
280
-		return plugin_dir_path( $this->file ).ltrim( trim( $file ), '/' );
280
+		return plugin_dir_path($this->file).ltrim(trim($file), '/');
281 281
 	}
282 282
 
283 283
 	/**
284 284
 	 * @param string $path
285 285
 	 * @return string
286 286
 	 */
287
-	protected function url( $path = '' )
287
+	protected function url($path = '')
288 288
 	{
289
-		return esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ));
289
+		return esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/'));
290 290
 	}
291 291
 }
Please login to merge, or discard this patch.
src/Profiler.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -37,19 +37,19 @@  discard block
 block discarded – undo
37 37
 	 * @param array $timer
38 38
 	 * @return string
39 39
 	 */
40
-	public function getMemoryString( $timer )
40
+	public function getMemoryString($timer)
41 41
 	{
42
-		$timer = $this->normalize( $timer );
43
-		return sprintf( '%s kB', round( $timer['memory'] / 1000 ));
42
+		$timer = $this->normalize($timer);
43
+		return sprintf('%s kB', round($timer['memory'] / 1000));
44 44
 	}
45 45
 
46 46
 	/**
47 47
 	 * @param array $timer
48 48
 	 * @return string
49 49
 	 */
50
-	public function getNameString( $timer )
50
+	public function getNameString($timer)
51 51
 	{
52
-		$timer = $this->normalize( $timer );
52
+		$timer = $this->normalize($timer);
53 53
 		return $timer['name'];
54 54
 	}
55 55
 
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
 	 * @param array $timer
58 58
 	 * @return string
59 59
 	 */
60
-	public function getTimeString( $timer )
60
+	public function getTimeString($timer)
61 61
 	{
62
-		$timer = $this->normalize( $timer );
63
-		$index = array_search( $timer['name'], array_column( $this->timers, 'name' ));
64
-		$start = $this->start + ( $index * $this->noise );
65
-		$time = number_format( round(( $timer['time'] - $start ) * 1000, 4 ), 4 );
66
-		return sprintf( '%s ms', $time );
62
+		$timer = $this->normalize($timer);
63
+		$index = array_search($timer['name'], array_column($this->timers, 'name'));
64
+		$start = $this->start + ($index * $this->noise);
65
+		$time = number_format(round(($timer['time'] - $start) * 1000, 4), 4);
66
+		return sprintf('%s ms', $time);
67 67
 	}
68 68
 
69 69
 	/**
@@ -71,20 +71,20 @@  discard block
 block discarded – undo
71 71
 	 */
72 72
 	public function getTotalTime()
73 73
 	{
74
-		$totalNoise = ( count( $this->timers ) - 1 ) * $this->noise;
74
+		$totalNoise = (count($this->timers) - 1) * $this->noise;
75 75
 		return $this->stop - $this->start - $totalNoise;
76 76
 	}
77 77
 
78 78
 	/**
79 79
 	 * @param string $name
80 80
 	 */
81
-	public function trace( $name )
81
+	public function trace($name)
82 82
 	{
83
-		$microtime = microtime( true );
84
-		if( !$this->start ) {
83
+		$microtime = microtime(true);
84
+		if (!$this->start) {
85 85
 			$this->start = $microtime;
86 86
 		}
87
-		if( $name === 'blackbar/profiler/noise' ) {
87
+		if ($name === 'blackbar/profiler/noise') {
88 88
 			$this->noise = $microtime - $this->start;
89 89
 			return;
90 90
 		}
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
 	/**
100 100
 	 * @return array
101 101
 	 */
102
-	protected function normalize( $timer )
102
+	protected function normalize($timer)
103 103
 	{
104
-		return wp_parse_args( (array) $timer, array(
104
+		return wp_parse_args((array) $timer, array(
105 105
 			'name' => '',
106 106
 			'time' => 0,
107 107
 			'memory' => 0,
Please login to merge, or discard this patch.
blackbar.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,11 +16,11 @@
 block discarded – undo
16 16
  * Domain Path: languages
17 17
  */
18 18
 
19
-defined( 'WPINC' ) || die;
19
+defined('WPINC') || die;
20 20
 
21 21
 require_once __DIR__.'/activate.php';
22 22
 require_once __DIR__.'/autoload.php';
23 23
 
24
-if( !GL_Activate::shouldDeactivate( __FILE__, array( 'wordpress' => '4.0.0' ))) {
24
+if (!GL_Activate::shouldDeactivate(__FILE__, array('wordpress' => '4.0.0'))) {
25 25
 	(new GeminiLabs\BlackBar\Application)->init();
26 26
 }
Please login to merge, or discard this patch.