Completed
Branch master (5145aa)
by Juliette
02:36
created
class-debug-bar-cron.php 3 patches
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,6 @@
 block discarded – undo
72 72
 
73 73
 	/**
74 74
 	 * Show the contents of the page.
75
-
76 75
 	 * @return  void
77 76
 	 */
78 77
 	public function render() {
Please login to merge, or discard this patch.
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
 	 * @return void
47 47
 	 */
48 48
 	public function init() {
49
-		$this->title( __( 'Cron', 'debug-bar' ) );
50
-		add_action( 'wp_print_styles', array( $this, 'print_styles' ) );
51
-		add_action( 'admin_print_styles', array( $this, 'print_styles' ) );
49
+		$this->title(__('Cron', 'debug-bar'));
50
+		add_action('wp_print_styles', array($this, 'print_styles'));
51
+		add_action('admin_print_styles', array($this, 'print_styles'));
52 52
 	}
53 53
 
54 54
 	/**
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
 	 * @return  void
58 58
 	 */
59 59
 	public function print_styles() {
60
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.dev' : '';
61
-		wp_enqueue_style( 'zt-debug-bar-cron', plugins_url( "css/debug-bar-cron$suffix.css", __FILE__ ), array(), '20131228' );
60
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
61
+		wp_enqueue_style('zt-debug-bar-cron', plugins_url("css/debug-bar-cron$suffix.css", __FILE__), array(), '20131228');
62 62
 	}
63 63
 
64 64
 	/**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 * @return  void
68 68
 	 */
69 69
 	public function prerender() {
70
-		$this->set_visible( true );
70
+		$this->set_visible(true);
71 71
 	}
72 72
 
73 73
 	/**
@@ -78,42 +78,42 @@  discard block
 block discarded – undo
78 78
 	public function render() {
79 79
 		$this->get_crons();
80 80
 
81
-		$this->_doing_cron = get_transient( 'doing_cron' ) ? __( 'Yes', 'zt-debug-bar-cron' ) : __( 'No', 'zt-debug-bar-cron' );
81
+		$this->_doing_cron = get_transient('doing_cron') ? __('Yes', 'zt-debug-bar-cron') : __('No', 'zt-debug-bar-cron');
82 82
 
83 83
 		// Get the time of the next event
84
-		$cron_times = array_keys( $this->_crons );
84
+		$cron_times = array_keys($this->_crons);
85 85
 		$unix_time_next_cron = $cron_times[0];
86
-		$time_next_cron = date( 'Y-m-d H:i:s', $unix_time_next_cron );
86
+		$time_next_cron = date('Y-m-d H:i:s', $unix_time_next_cron);
87 87
 
88
-		$human_time_next_cron = human_time_diff( $unix_time_next_cron );
88
+		$human_time_next_cron = human_time_diff($unix_time_next_cron);
89 89
 
90 90
 		// Add a class if past current time and doing cron is not running
91 91
 		$times_class = time() > $unix_time_next_cron && 'No' == $this->_doing_cron ? ' past' : '';
92 92
 
93 93
 		echo '<div class="debug-bar-cron">';
94
-		echo '<h2><span>' . __( 'Total Events', 'zt-debug-bar-cron' ) . ':</span>' . (int) $this->_total_crons . '</h2>';
95
-		echo '<h2><span>' . __( 'Doing Cron', 'zt-debug-bar-cron' ) . ':</span>' . $this->_doing_cron . '</h2>';
96
-		echo '<h2 class="times' . esc_attr( $times_class ) . '"><span>' . __( 'Next Event', 'zt-debug-bar-cron' ) . ':</span>' . $time_next_cron . '<br />' . $unix_time_next_cron . '<br />' . $human_time_next_cron . $this->display_past_time( $unix_time_next_cron ) . '</h2>';
97
-		echo '<h2><span>' . __( 'Current Time', 'zt-debug-bar-cron' ) . ':</span>' . date( 'H:i:s' ) . '</h2>';
94
+		echo '<h2><span>'.__('Total Events', 'zt-debug-bar-cron').':</span>'.(int) $this->_total_crons.'</h2>';
95
+		echo '<h2><span>'.__('Doing Cron', 'zt-debug-bar-cron').':</span>'.$this->_doing_cron.'</h2>';
96
+		echo '<h2 class="times'.esc_attr($times_class).'"><span>'.__('Next Event', 'zt-debug-bar-cron').':</span>'.$time_next_cron.'<br />'.$unix_time_next_cron.'<br />'.$human_time_next_cron.$this->display_past_time($unix_time_next_cron).'</h2>';
97
+		echo '<h2><span>'.__('Current Time', 'zt-debug-bar-cron').':</span>'.date('H:i:s').'</h2>';
98 98
 		echo '<div class="clear"></div>';
99 99
 
100
-		echo '<h3>' . __( 'Custom Events', 'zt-debug-bar-cron' ) . '</h3>';
100
+		echo '<h3>'.__('Custom Events', 'zt-debug-bar-cron').'</h3>';
101 101
 
102
-		if ( ! is_null( $this->_user_crons ) )
103
-			$this->display_events( $this->_user_crons );
102
+		if ( ! is_null($this->_user_crons))
103
+			$this->display_events($this->_user_crons);
104 104
 		else
105
-			echo '<p>' . __( 'No Custom Events scheduled.', 'zt-debug-bar-cron' ) . '</p>';
105
+			echo '<p>'.__('No Custom Events scheduled.', 'zt-debug-bar-cron').'</p>';
106 106
 
107
-		echo '<h3>' . __( 'Schedules', 'zt-debug-bar-cron' ) . '</h3>';
107
+		echo '<h3>'.__('Schedules', 'zt-debug-bar-cron').'</h3>';
108 108
 
109 109
 		$this->display_schedules();
110 110
 
111
-		echo '<h3>' . __( 'Core Events', 'zt-debug-bar-cron' ) . '</h3>';
111
+		echo '<h3>'.__('Core Events', 'zt-debug-bar-cron').'</h3>';
112 112
 
113
-		if ( ! is_null( $this->_core_crons ) )
114
-			$this->display_events( $this->_core_crons );
113
+		if ( ! is_null($this->_core_crons))
114
+			$this->display_events($this->_core_crons);
115 115
 		else
116
-			echo '<p>' . __( 'No Core Events scheduled.', 'zt-debug-bar-cron' ) . '</p>';
116
+			echo '<p>'.__('No Core Events scheduled.', 'zt-debug-bar-cron').'</p>';
117 117
 
118 118
 		echo '</div>';
119 119
 	}
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
 	 * @return  array   Array of crons.
128 128
 	 */
129 129
 	private function get_crons() {
130
-		if ( ! is_null( $this->_crons ) )
130
+		if ( ! is_null($this->_crons))
131 131
 			return $this->_crons;
132 132
 
133
-		if ( ! $crons = _get_cron_array() )
133
+		if ( ! $crons = _get_cron_array())
134 134
 			return $this->_crons;
135 135
 
136 136
 		$this->_crons = $crons;
@@ -150,14 +150,14 @@  discard block
 block discarded – undo
150 150
 		);
151 151
 
152 152
 		// Sort and count crons
153
-		foreach ( $this->_crons as $time => $time_cron_array ) {
154
-			foreach ( $time_cron_array as $hook => $data ) {
153
+		foreach ($this->_crons as $time => $time_cron_array) {
154
+			foreach ($time_cron_array as $hook => $data) {
155 155
 				$this->_total_crons++;
156 156
 
157
-				if ( in_array( $hook, $core_cron_hooks ) )
158
-					$this->_core_crons[ $time ][ $hook ] = $data;
157
+				if (in_array($hook, $core_cron_hooks))
158
+					$this->_core_crons[$time][$hook] = $data;
159 159
 				else
160
-					$this->_user_crons[ $time ][ $hook ] = $data;
160
+					$this->_user_crons[$time][$hook] = $data;
161 161
 			}
162 162
 		}
163 163
 
@@ -170,44 +170,44 @@  discard block
 block discarded – undo
170 170
 	 * @param   array   $events     Array of events.
171 171
 	 * @return  void|string         Void on failure; table display of events on success.
172 172
 	 */
173
-	private function display_events( $events ) {
174
-		if ( is_null( $events ) || empty( $events ) )
173
+	private function display_events($events) {
174
+		if (is_null($events) || empty($events))
175 175
 			return;
176 176
 
177 177
 		echo '<table class="zt-debug-bar-cron-event-table" cellspacing="0">';
178 178
 		echo '<thead><tr>';
179
-		echo '<th class="col1">' . __( 'Next Execution', 'zt-debug-bar-cron' ) . '</th>';
180
-		echo '<th class="col2">' . __( 'Hook', 'zt-debug-bar-cron' ) . '</th>';
181
-		echo '<th class="col3">' . __( 'Interval Hook', 'zt-debug-bar-cron' ) . '</th>';
182
-		echo '<th class="col4">' . __( 'Interval Value', 'zt-debug-bar-cron' ) . '</th>';
183
-		echo '<th class="col5">' . __( 'Args', 'zt-debug-bar-cron' ) . '</th>';
179
+		echo '<th class="col1">'.__('Next Execution', 'zt-debug-bar-cron').'</th>';
180
+		echo '<th class="col2">'.__('Hook', 'zt-debug-bar-cron').'</th>';
181
+		echo '<th class="col3">'.__('Interval Hook', 'zt-debug-bar-cron').'</th>';
182
+		echo '<th class="col4">'.__('Interval Value', 'zt-debug-bar-cron').'</th>';
183
+		echo '<th class="col5">'.__('Args', 'zt-debug-bar-cron').'</th>';
184 184
 		echo '</tr></thead>';
185 185
 		echo '<tbody>';
186 186
 
187
-		foreach ( $events as $time => $time_cron_array ) {
188
-			foreach ( $time_cron_array as $hook => $data ) {
187
+		foreach ($events as $time => $time_cron_array) {
188
+			foreach ($time_cron_array as $hook => $data) {
189 189
 				// Add a class if past current time
190 190
 				$times_class = time() > $time && 'No' == $this->_doing_cron ? ' class="past"' : '';
191 191
 
192 192
 				echo '<tr>';
193
-				echo '<td' . $times_class . '>' . date( 'Y-m-d H:i:s', $time ) . '<br />' . $time . '<br />' . human_time_diff( $time ) . $this->display_past_time( $time ) . '</td>';
194
-				echo '<td>' . wp_strip_all_tags( $hook ) . '</td>';
193
+				echo '<td'.$times_class.'>'.date('Y-m-d H:i:s', $time).'<br />'.$time.'<br />'.human_time_diff($time).$this->display_past_time($time).'</td>';
194
+				echo '<td>'.wp_strip_all_tags($hook).'</td>';
195 195
 
196
-				foreach ( $data as $hash => $info ) {
196
+				foreach ($data as $hash => $info) {
197 197
 					// Report the schedule
198 198
 					echo '<td>';
199
-					if ( $info['schedule'] )
200
-						echo wp_strip_all_tags( $info['schedule'] );
199
+					if ($info['schedule'])
200
+						echo wp_strip_all_tags($info['schedule']);
201 201
 					else
202 202
 						echo 'Single Event';
203 203
 					echo '</td>';
204 204
 
205 205
 					// Report the interval
206 206
 					echo '<td>';
207
-					if ( isset( $info['interval'] ) ) {
208
-						echo wp_strip_all_tags( $info['interval'] ) . 's<br />';
209
-						echo $info['interval'] / 60 . 'm<br />';
210
-						echo $info['interval'] / ( 60  * 60 ). 'h';
207
+					if (isset($info['interval'])) {
208
+						echo wp_strip_all_tags($info['interval']).'s<br />';
209
+						echo $info['interval'] / 60.'m<br />';
210
+						echo $info['interval'] / (60 * 60).'h';
211 211
 					} else {
212 212
 						echo 'Single Event';
213 213
 					}
@@ -215,12 +215,12 @@  discard block
 block discarded – undo
215 215
 
216 216
 					// Report the args
217 217
 					echo '<td>';
218
-					if ( is_array( $info['args'] ) && ! empty( $info['args'] ) ) {
219
-						foreach ( $info['args'] as $key => $value ) {
220
-							$this->display_cron_arguments( $key, $value );
218
+					if (is_array($info['args']) && ! empty($info['args'])) {
219
+						foreach ($info['args'] as $key => $value) {
220
+							$this->display_cron_arguments($key, $value);
221 221
 						}
222
-					} else if ( is_string( $info['args'] ) && $info['args'] !== '' ) {
223
-						echo esc_html( $info['args'] );
222
+					} else if (is_string($info['args']) && $info['args'] !== '') {
223
+						echo esc_html($info['args']);
224 224
 					} else {
225 225
 						echo 'No Args';
226 226
 					}
@@ -244,17 +244,17 @@  discard block
 block discarded – undo
244 244
 	 * @param   int            $depth      Current recursion depth.
245 245
 	 * @return  void
246 246
 	 */
247
-	function display_cron_arguments( $key, $value, $depth = 0 ) {
248
-		if ( is_string( $value ) || is_int( $value ) ) {
249
-			echo str_repeat( '&nbsp;', ( $depth * 2 ) ) . wp_strip_all_tags( $key ) . ' => ' . esc_html( $value ) . '<br />';
250
-		} else if ( is_array( $value ) ) {
251
-			if ( count( $value ) > 0 ) {
252
-				echo str_repeat( '&nbsp;', ( $depth * 2 ) ) . wp_strip_all_tags( $key ) . ' => array(<br />';
247
+	function display_cron_arguments($key, $value, $depth = 0) {
248
+		if (is_string($value) || is_int($value)) {
249
+			echo str_repeat('&nbsp;', ($depth * 2)).wp_strip_all_tags($key).' => '.esc_html($value).'<br />';
250
+		} else if (is_array($value)) {
251
+			if (count($value) > 0) {
252
+				echo str_repeat('&nbsp;', ($depth * 2)).wp_strip_all_tags($key).' => array(<br />';
253 253
 				$depth++;
254
-				foreach ( $value as $k => $v ) {
255
-					$this->display_cron_arguments( $k, $v, $depth );
254
+				foreach ($value as $k => $v) {
255
+					$this->display_cron_arguments($k, $v, $depth);
256 256
 				}
257
-				echo str_repeat( '&nbsp;', ( ( $depth - 1 ) * 2 ) ) . ')';
257
+				echo str_repeat('&nbsp;', (($depth - 1) * 2)).')';
258 258
 			} else {
259 259
 				echo 'Empty Array';
260 260
 			}
@@ -269,21 +269,21 @@  discard block
 block discarded – undo
269 269
 	private function display_schedules() {
270 270
 		echo '<table class="zt-debug-bar-cron-event-table" cellspacing="0">';
271 271
 		echo '<thead><tr>';
272
-		echo '<th class="col1">' . __( 'Interval Hook', 'zt-debug-bar-cron' ) . '</th>';
273
-		echo '<th class="col2">' . __( 'Interval (S)', 'zt-debug-bar-cron' ) . '</th>';
274
-		echo '<th class="col3">' . __( 'Interval (M)', 'zt-debug-bar-cron' ) . '</th>';
275
-		echo '<th class="col4">' . __( 'Interval (H)', 'zt-debug-bar-cron' ) . '</th>';
276
-		echo '<th class="col5">' . __( 'Display Name', 'zt-debug-bar-cron' ) . '</th>';
272
+		echo '<th class="col1">'.__('Interval Hook', 'zt-debug-bar-cron').'</th>';
273
+		echo '<th class="col2">'.__('Interval (S)', 'zt-debug-bar-cron').'</th>';
274
+		echo '<th class="col3">'.__('Interval (M)', 'zt-debug-bar-cron').'</th>';
275
+		echo '<th class="col4">'.__('Interval (H)', 'zt-debug-bar-cron').'</th>';
276
+		echo '<th class="col5">'.__('Display Name', 'zt-debug-bar-cron').'</th>';
277 277
 		echo '</tr></thead>';
278 278
 		echo '<tbody>';
279 279
 
280
-		foreach ( wp_get_schedules() as $interval_hook => $data ) {
280
+		foreach (wp_get_schedules() as $interval_hook => $data) {
281 281
 			echo '<tr>';
282
-			echo '<td>' . esc_html( $interval_hook ) . '</td>';
283
-			echo '<td>' . wp_strip_all_tags( $data['interval'] ) . '</td>';
284
-			echo '<td>' . wp_strip_all_tags( $data['interval'] ) / 60 . '</td>';
285
-			echo '<td>' . wp_strip_all_tags( $data['interval'] ) / ( 60  * 60 ). '</td>';
286
-			echo '<td>' . esc_html( $data['display'] ) . '</td>';
282
+			echo '<td>'.esc_html($interval_hook).'</td>';
283
+			echo '<td>'.wp_strip_all_tags($data['interval']).'</td>';
284
+			echo '<td>'.wp_strip_all_tags($data['interval']) / 60.'</td>';
285
+			echo '<td>'.wp_strip_all_tags($data['interval']) / (60 * 60).'</td>';
286
+			echo '<td>'.esc_html($data['display']).'</td>';
287 287
 			echo '</tr>';
288 288
 		}
289 289
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	 * @param   int     $time   Unix time of event.
298 298
 	 * @return  string
299 299
 	 */
300
-	private function display_past_time( $time ) {
301
-		return time() > $time ? ' ' . __( 'ago', 'zt-debug-bar-cron' ) : '';
300
+	private function display_past_time($time) {
301
+		return time() > $time ? ' '.__('ago', 'zt-debug-bar-cron') : '';
302 302
 	}
303 303
 }
Please login to merge, or discard this patch.
Braces   +29 added lines, -22 removed lines patch added patch discarded remove patch
@@ -99,10 +99,11 @@  discard block
 block discarded – undo
99 99
 
100 100
 		echo '<h3>' . __( 'Custom Events', 'zt-debug-bar-cron' ) . '</h3>';
101 101
 
102
-		if ( ! is_null( $this->_user_crons ) )
103
-			$this->display_events( $this->_user_crons );
104
-		else
105
-			echo '<p>' . __( 'No Custom Events scheduled.', 'zt-debug-bar-cron' ) . '</p>';
102
+		if ( ! is_null( $this->_user_crons ) ) {
103
+					$this->display_events( $this->_user_crons );
104
+		} else {
105
+					echo '<p>' . __( 'No Custom Events scheduled.', 'zt-debug-bar-cron' ) . '</p>';
106
+		}
106 107
 
107 108
 		echo '<h3>' . __( 'Schedules', 'zt-debug-bar-cron' ) . '</h3>';
108 109
 
@@ -110,10 +111,11 @@  discard block
 block discarded – undo
110 111
 
111 112
 		echo '<h3>' . __( 'Core Events', 'zt-debug-bar-cron' ) . '</h3>';
112 113
 
113
-		if ( ! is_null( $this->_core_crons ) )
114
-			$this->display_events( $this->_core_crons );
115
-		else
116
-			echo '<p>' . __( 'No Core Events scheduled.', 'zt-debug-bar-cron' ) . '</p>';
114
+		if ( ! is_null( $this->_core_crons ) ) {
115
+					$this->display_events( $this->_core_crons );
116
+		} else {
117
+					echo '<p>' . __( 'No Core Events scheduled.', 'zt-debug-bar-cron' ) . '</p>';
118
+		}
117 119
 
118 120
 		echo '</div>';
119 121
 	}
@@ -127,11 +129,13 @@  discard block
 block discarded – undo
127 129
 	 * @return  array   Array of crons.
128 130
 	 */
129 131
 	private function get_crons() {
130
-		if ( ! is_null( $this->_crons ) )
131
-			return $this->_crons;
132
+		if ( ! is_null( $this->_crons ) ) {
133
+					return $this->_crons;
134
+		}
132 135
 
133
-		if ( ! $crons = _get_cron_array() )
134
-			return $this->_crons;
136
+		if ( ! $crons = _get_cron_array() ) {
137
+					return $this->_crons;
138
+		}
135 139
 
136 140
 		$this->_crons = $crons;
137 141
 
@@ -154,10 +158,11 @@  discard block
 block discarded – undo
154 158
 			foreach ( $time_cron_array as $hook => $data ) {
155 159
 				$this->_total_crons++;
156 160
 
157
-				if ( in_array( $hook, $core_cron_hooks ) )
158
-					$this->_core_crons[ $time ][ $hook ] = $data;
159
-				else
160
-					$this->_user_crons[ $time ][ $hook ] = $data;
161
+				if ( in_array( $hook, $core_cron_hooks ) ) {
162
+									$this->_core_crons[ $time ][ $hook ] = $data;
163
+				} else {
164
+									$this->_user_crons[ $time ][ $hook ] = $data;
165
+				}
161 166
 			}
162 167
 		}
163 168
 
@@ -171,8 +176,9 @@  discard block
 block discarded – undo
171 176
 	 * @return  void|string         Void on failure; table display of events on success.
172 177
 	 */
173 178
 	private function display_events( $events ) {
174
-		if ( is_null( $events ) || empty( $events ) )
175
-			return;
179
+		if ( is_null( $events ) || empty( $events ) ) {
180
+					return;
181
+		}
176 182
 
177 183
 		echo '<table class="zt-debug-bar-cron-event-table" cellspacing="0">';
178 184
 		echo '<thead><tr>';
@@ -196,10 +202,11 @@  discard block
 block discarded – undo
196 202
 				foreach ( $data as $hash => $info ) {
197 203
 					// Report the schedule
198 204
 					echo '<td>';
199
-					if ( $info['schedule'] )
200
-						echo wp_strip_all_tags( $info['schedule'] );
201
-					else
202
-						echo 'Single Event';
205
+					if ( $info['schedule'] ) {
206
+											echo wp_strip_all_tags( $info['schedule'] );
207
+					} else {
208
+											echo 'Single Event';
209
+					}
203 210
 					echo '</td>';
204 211
 
205 212
 					// Report the interval
Please login to merge, or discard this patch.
debug-bar-cron.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@
 block discarded – undo
15 15
  * @param $panels array
16 16
  * @return array
17 17
  */
18
-function zt_add_debug_bar_cron_panel( $panels ) {
19
-	if ( ! class_exists( 'ZT_Debug_Bar_Cron' ) ) {
20
-		include ( 'class-debug-bar-cron.php' );
18
+function zt_add_debug_bar_cron_panel($panels) {
19
+	if ( ! class_exists('ZT_Debug_Bar_Cron')) {
20
+		include ('class-debug-bar-cron.php');
21 21
 		$panels[] = new ZT_Debug_Bar_Cron();
22 22
 	}
23 23
 	return $panels;
24 24
 }
25
-add_filter( 'debug_bar_panels', 'zt_add_debug_bar_cron_panel' );
26 25
\ No newline at end of file
26
+add_filter('debug_bar_panels', 'zt_add_debug_bar_cron_panel');
27 27
\ No newline at end of file
Please login to merge, or discard this patch.