@@ -10,16 +10,16 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Avoid direct calls to this file. |
| 13 | -if ( ! function_exists( 'add_action' ) ) { |
|
| 14 | - header( 'Status: 403 Forbidden' ); |
|
| 15 | - header( 'HTTP/1.1 403 Forbidden' ); |
|
| 13 | +if ( ! function_exists('add_action')) { |
|
| 14 | + header('Status: 403 Forbidden'); |
|
| 15 | + header('HTTP/1.1 403 Forbidden'); |
|
| 16 | 16 | exit(); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * The class in this file extends the functionality provided by the parent plugin "Debug Bar". |
| 21 | 21 | */ |
| 22 | -if ( ! class_exists( 'ZT_Debug_Bar_Cron' ) && class_exists( 'Debug_Bar_Panel' ) ) { |
|
| 22 | +if ( ! class_exists('ZT_Debug_Bar_Cron') && class_exists('Debug_Bar_Panel')) { |
|
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * Add a new Debug Bar Panel. |
@@ -86,10 +86,10 @@ discard block |
||
| 86 | 86 | * @return void |
| 87 | 87 | */ |
| 88 | 88 | public function init() { |
| 89 | - load_plugin_textdomain( 'zt-debug-bar-cron', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); |
|
| 90 | - $this->title( __( 'Cron', 'zt-debug-bar-cron' ) ); |
|
| 91 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts_styles' ) ); |
|
| 92 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts_styles' ) ); |
|
| 89 | + load_plugin_textdomain('zt-debug-bar-cron', false, dirname(plugin_basename(__FILE__)).'/languages/'); |
|
| 90 | + $this->title(__('Cron', 'zt-debug-bar-cron')); |
|
| 91 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles')); |
|
| 92 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts_styles')); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | |
@@ -99,12 +99,12 @@ discard block |
||
| 99 | 99 | * @return void |
| 100 | 100 | */ |
| 101 | 101 | public function enqueue_scripts_styles() { |
| 102 | - $suffix = ( ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min' ); |
|
| 102 | + $suffix = ((defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'); |
|
| 103 | 103 | |
| 104 | 104 | wp_enqueue_style( |
| 105 | 105 | self::DBCRON_NAME, |
| 106 | - plugins_url( 'css/' . self::DBCRON_NAME . $suffix . '.css', __FILE__ ), |
|
| 107 | - array( 'debug-bar' ), |
|
| 106 | + plugins_url('css/'.self::DBCRON_NAME.$suffix.'.css', __FILE__), |
|
| 107 | + array('debug-bar'), |
|
| 108 | 108 | self::DBCRON_STYLES_VERSION |
| 109 | 109 | ); |
| 110 | 110 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * @return void |
| 117 | 117 | */ |
| 118 | 118 | public function prerender() { |
| 119 | - $this->set_visible( true ); |
|
| 119 | + $this->set_visible(true); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | |
@@ -128,49 +128,49 @@ discard block |
||
| 128 | 128 | public function render() { |
| 129 | 129 | $this->get_crons(); |
| 130 | 130 | |
| 131 | - $this->_doing_cron = get_transient( 'doing_cron' ) ? __( 'Yes', 'zt-debug-bar-cron' ) : __( 'No', 'zt-debug-bar-cron' ); |
|
| 131 | + $this->_doing_cron = get_transient('doing_cron') ? __('Yes', 'zt-debug-bar-cron') : __('No', 'zt-debug-bar-cron'); |
|
| 132 | 132 | |
| 133 | 133 | // Get the time of the next event. |
| 134 | - $cron_times = ( is_array( $this->_crons ) ? array_keys( $this->_crons ) : array() ); |
|
| 134 | + $cron_times = (is_array($this->_crons) ? array_keys($this->_crons) : array()); |
|
| 135 | 135 | $unix_time_next_cron = (int) $cron_times[0]; |
| 136 | - $time_next_cron = date( 'Y-m-d H:i:s', $unix_time_next_cron ); |
|
| 136 | + $time_next_cron = date('Y-m-d H:i:s', $unix_time_next_cron); |
|
| 137 | 137 | |
| 138 | - $human_time_next_cron = human_time_diff( $unix_time_next_cron ); |
|
| 138 | + $human_time_next_cron = human_time_diff($unix_time_next_cron); |
|
| 139 | 139 | |
| 140 | 140 | // Add a class if past current time and doing cron is not running. |
| 141 | - $times_class = $this->is_time_in_past( $unix_time_next_cron ) ? ' past' : ''; |
|
| 141 | + $times_class = $this->is_time_in_past($unix_time_next_cron) ? ' past' : ''; |
|
| 142 | 142 | |
| 143 | 143 | $this->load_debug_bar_pretty_output(); |
| 144 | 144 | |
| 145 | 145 | echo // WPCS: XSS ok. |
| 146 | 146 | ' |
| 147 | 147 | <div class="debug-bar-cron"> |
| 148 | - <h2><span>', esc_html__( 'Total Events', 'zt-debug-bar-cron' ), ':</span>', $this->_total_crons, '</h2> |
|
| 149 | - <h2><span>', esc_html__( 'Core Events', 'zt-debug-bar-cron' ), ':</span>', $this->_total_core_crons, '</h2> |
|
| 150 | - <h2><span>', esc_html__( 'Custom Events', 'zt-debug-bar-cron' ), ':</span>', $this->_total_user_crons, '</h2> |
|
| 151 | - <h2><span>', esc_html__( 'Doing Cron', 'zt-debug-bar-cron' ), ':</span>', esc_html( $this->_doing_cron ), '</h2> |
|
| 152 | - <h2 class="times', esc_attr( $times_class ), '"><span>', esc_html__( 'Next Event', 'zt-debug-bar-cron' ), ':</span> |
|
| 153 | - ', esc_html( $time_next_cron ), '<br /> |
|
| 148 | + <h2><span>', esc_html__('Total Events', 'zt-debug-bar-cron'), ':</span>', $this->_total_crons, '</h2> |
|
| 149 | + <h2><span>', esc_html__('Core Events', 'zt-debug-bar-cron'), ':</span>', $this->_total_core_crons, '</h2> |
|
| 150 | + <h2><span>', esc_html__('Custom Events', 'zt-debug-bar-cron'), ':</span>', $this->_total_user_crons, '</h2> |
|
| 151 | + <h2><span>', esc_html__('Doing Cron', 'zt-debug-bar-cron'), ':</span>', esc_html($this->_doing_cron), '</h2> |
|
| 152 | + <h2 class="times', esc_attr($times_class), '"><span>', esc_html__('Next Event', 'zt-debug-bar-cron'), ':</span> |
|
| 153 | + ', esc_html($time_next_cron), '<br /> |
|
| 154 | 154 | ', $unix_time_next_cron, '<br /> |
| 155 | - ', esc_html( $this->display_past_time( $human_time_next_cron, $unix_time_next_cron ) ), ' |
|
| 155 | + ', esc_html($this->display_past_time($human_time_next_cron, $unix_time_next_cron)), ' |
|
| 156 | 156 | </h2> |
| 157 | - <h2><span>', esc_html__( 'Current Time', 'zt-debug-bar-cron' ), ':</span>', esc_html( date( 'H:i:s' ) ), '</h2> |
|
| 157 | + <h2><span>', esc_html__('Current Time', 'zt-debug-bar-cron'), ':</span>', esc_html(date('H:i:s')), '</h2> |
|
| 158 | 158 | |
| 159 | 159 | <div class="clear"></div> |
| 160 | 160 | |
| 161 | - <h3>', esc_html__( 'Schedules', 'zt-debug-bar-cron' ), '</h3>'; |
|
| 161 | + <h3>', esc_html__('Schedules', 'zt-debug-bar-cron'), '</h3>'; |
|
| 162 | 162 | |
| 163 | 163 | $this->display_schedules(); |
| 164 | 164 | |
| 165 | 165 | echo ' |
| 166 | - <h3>', esc_html__( 'Custom Events', 'zt-debug-bar-cron' ), '</h3>'; |
|
| 166 | + <h3>', esc_html__('Custom Events', 'zt-debug-bar-cron'), '</h3>'; |
|
| 167 | 167 | |
| 168 | - $this->display_events( $this->_user_crons, __( 'No Custom Events scheduled.', 'zt-debug-bar-cron' ) ); |
|
| 168 | + $this->display_events($this->_user_crons, __('No Custom Events scheduled.', 'zt-debug-bar-cron')); |
|
| 169 | 169 | |
| 170 | 170 | echo ' |
| 171 | - <h3>', esc_html__( 'Core Events', 'zt-debug-bar-cron' ), '</h3>'; |
|
| 171 | + <h3>', esc_html__('Core Events', 'zt-debug-bar-cron'), '</h3>'; |
|
| 172 | 172 | |
| 173 | - $this->display_events( $this->_core_crons, __( 'No Core Events scheduled.', 'zt-debug-bar-cron' ) ); |
|
| 173 | + $this->display_events($this->_core_crons, __('No Core Events scheduled.', 'zt-debug-bar-cron')); |
|
| 174 | 174 | |
| 175 | 175 | echo ' |
| 176 | 176 | </div>'; |
@@ -188,12 +188,12 @@ discard block |
||
| 188 | 188 | * @return array|null Array of crons. |
| 189 | 189 | */ |
| 190 | 190 | private function get_crons() { |
| 191 | - if ( is_array( $this->_crons ) ) { |
|
| 191 | + if (is_array($this->_crons)) { |
|
| 192 | 192 | return $this->_crons; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | $crons = _get_cron_array(); |
| 196 | - if ( ! is_array( $crons ) || array() === $crons ) { |
|
| 196 | + if ( ! is_array($crons) || array() === $crons) { |
|
| 197 | 197 | return $this->_crons; |
| 198 | 198 | } |
| 199 | 199 | |
@@ -203,30 +203,30 @@ discard block |
||
| 203 | 203 | // @internal To find all, search WP trunk for `wp_schedule_(single_)?event`. |
| 204 | 204 | $core_cron_hooks = array( |
| 205 | 205 | 'do_pings', |
| 206 | - 'importer_scheduled_cleanup', // WP 3.1+. |
|
| 206 | + 'importer_scheduled_cleanup', // WP 3.1+. |
|
| 207 | 207 | 'publish_future_post', |
| 208 | - 'update_network_counts', // WP 3.1+. |
|
| 209 | - 'upgrader_scheduled_cleanup', // WP 3.3+. |
|
| 210 | - 'wp_maybe_auto_update', // WP 3.7+. |
|
| 208 | + 'update_network_counts', // WP 3.1+. |
|
| 209 | + 'upgrader_scheduled_cleanup', // WP 3.3+. |
|
| 210 | + 'wp_maybe_auto_update', // WP 3.7+. |
|
| 211 | 211 | 'wp_scheduled_auto_draft_delete', // WP 3.4+. |
| 212 | - 'wp_scheduled_delete', // WP 2.9+. |
|
| 213 | - 'wp_split_shared_term_batch', // WP 4.3+. |
|
| 212 | + 'wp_scheduled_delete', // WP 2.9+. |
|
| 213 | + 'wp_split_shared_term_batch', // WP 4.3+. |
|
| 214 | 214 | 'wp_update_plugins', |
| 215 | 215 | 'wp_update_themes', |
| 216 | 216 | 'wp_version_check', |
| 217 | 217 | ); |
| 218 | 218 | |
| 219 | 219 | // Sort and count crons. |
| 220 | - foreach ( $this->_crons as $time => $time_cron_array ) { |
|
| 221 | - foreach ( $time_cron_array as $hook => $data ) { |
|
| 222 | - $this->_total_crons += count( $data ); |
|
| 220 | + foreach ($this->_crons as $time => $time_cron_array) { |
|
| 221 | + foreach ($time_cron_array as $hook => $data) { |
|
| 222 | + $this->_total_crons += count($data); |
|
| 223 | 223 | |
| 224 | - if ( in_array( $hook, $core_cron_hooks, true ) ) { |
|
| 225 | - $this->_core_crons[ $time ][ $hook ] = $data; |
|
| 226 | - $this->_total_core_crons += count( $data ); |
|
| 224 | + if (in_array($hook, $core_cron_hooks, true)) { |
|
| 225 | + $this->_core_crons[$time][$hook] = $data; |
|
| 226 | + $this->_total_core_crons += count($data); |
|
| 227 | 227 | } else { |
| 228 | - $this->_user_crons[ $time ][ $hook ] = $data; |
|
| 229 | - $this->_total_user_crons += count( $data ); |
|
| 228 | + $this->_user_crons[$time][$hook] = $data; |
|
| 229 | + $this->_total_user_crons += count($data); |
|
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | 232 | } |
@@ -241,77 +241,77 @@ discard block |
||
| 241 | 241 | * @param array $events Array of events. |
| 242 | 242 | * @param string $no_events_msg Message to display if there are no events. |
| 243 | 243 | */ |
| 244 | - private function display_events( $events, $no_events_msg ) { |
|
| 244 | + private function display_events($events, $no_events_msg) { |
|
| 245 | 245 | // Exit early if no events found. |
| 246 | - if ( ! is_array( $events ) || empty( $events ) ) { |
|
| 246 | + if ( ! is_array($events) || empty($events)) { |
|
| 247 | 247 | echo ' |
| 248 | - <p>', esc_html( $no_events_msg ), '</p>'; |
|
| 248 | + <p>', esc_html($no_events_msg), '</p>'; |
|
| 249 | 249 | return; |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | echo ' |
| 253 | 253 | <table class="zt-debug-bar-cron-event-table"> |
| 254 | 254 | <thead><tr> |
| 255 | - <th class="col1">', esc_html__( 'Next Execution', 'zt-debug-bar-cron' ), '</th> |
|
| 256 | - <th class="col2">', esc_html__( 'Hook', 'zt-debug-bar-cron' ), '</th> |
|
| 257 | - <th class="col3">', esc_html__( 'Interval Hook', 'zt-debug-bar-cron' ), '</th> |
|
| 258 | - <th class="col4">', esc_html__( 'Interval Value', 'zt-debug-bar-cron' ), '</th> |
|
| 259 | - <th class="col5">', esc_html__( 'Args', 'zt-debug-bar-cron' ), '</th> |
|
| 255 | + <th class="col1">', esc_html__('Next Execution', 'zt-debug-bar-cron'), '</th> |
|
| 256 | + <th class="col2">', esc_html__('Hook', 'zt-debug-bar-cron'), '</th> |
|
| 257 | + <th class="col3">', esc_html__('Interval Hook', 'zt-debug-bar-cron'), '</th> |
|
| 258 | + <th class="col4">', esc_html__('Interval Value', 'zt-debug-bar-cron'), '</th> |
|
| 259 | + <th class="col5">', esc_html__('Args', 'zt-debug-bar-cron'), '</th> |
|
| 260 | 260 | </tr></thead> |
| 261 | 261 | <tbody>'; |
| 262 | 262 | |
| 263 | - foreach ( $events as $time => $time_cron_array ) { |
|
| 263 | + foreach ($events as $time => $time_cron_array) { |
|
| 264 | 264 | $time = (int) $time; |
| 265 | - foreach ( $time_cron_array as $hook => $data ) { |
|
| 266 | - foreach ( $data as $hash => $info ) { |
|
| 265 | + foreach ($time_cron_array as $hook => $data) { |
|
| 266 | + foreach ($data as $hash => $info) { |
|
| 267 | 267 | echo ' |
| 268 | 268 | <tr> |
| 269 | 269 | <td'; |
| 270 | 270 | |
| 271 | 271 | // Add a class if past current time. |
| 272 | - if ( $this->is_time_in_past( $time ) ) { |
|
| 272 | + if ($this->is_time_in_past($time)) { |
|
| 273 | 273 | echo ' class="past"'; |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | echo // WPCS: XSS ok. |
| 277 | 277 | '> |
| 278 | - ', date( 'Y-m-d H:i:s', $time ), '<br /> |
|
| 278 | + ', date('Y-m-d H:i:s', $time), '<br /> |
|
| 279 | 279 | ', $time, '<br /> |
| 280 | - ', esc_html( $this->display_past_time( human_time_diff( $time ), $time ) ), ' |
|
| 280 | + ', esc_html($this->display_past_time(human_time_diff($time), $time)), ' |
|
| 281 | 281 | </td> |
| 282 | - <td>', esc_html( $hook ), '</td>'; |
|
| 282 | + <td>', esc_html($hook), '</td>'; |
|
| 283 | 283 | |
| 284 | 284 | |
| 285 | 285 | // Report the schedule. |
| 286 | 286 | echo ' |
| 287 | 287 | <td>'; |
| 288 | - if ( $info['schedule'] ) { |
|
| 289 | - echo esc_html( $info['schedule'] ); |
|
| 288 | + if ($info['schedule']) { |
|
| 289 | + echo esc_html($info['schedule']); |
|
| 290 | 290 | } else { |
| 291 | - echo esc_html__( 'Single Event', 'zt-debug-bar-cron' ); |
|
| 291 | + echo esc_html__('Single Event', 'zt-debug-bar-cron'); |
|
| 292 | 292 | } |
| 293 | 293 | echo '</td>'; |
| 294 | 294 | |
| 295 | 295 | // Report the interval. |
| 296 | 296 | echo ' |
| 297 | 297 | <td>'; |
| 298 | - if ( isset( $info['interval'] ) ) { |
|
| 298 | + if (isset($info['interval'])) { |
|
| 299 | 299 | $interval = (int) $info['interval']; |
| 300 | 300 | /* TRANSLATORS: %s is number of seconds. */ |
| 301 | - printf( esc_html__( '%ss', 'zt-debug-bar-cron' ) . '<br />', $interval ); // WPCS: XSS ok. |
|
| 301 | + printf(esc_html__('%ss', 'zt-debug-bar-cron').'<br />', $interval); // WPCS: XSS ok. |
|
| 302 | 302 | /* TRANSLATORS: %s is number of minutes. */ |
| 303 | - printf( esc_html__( '%sm', 'zt-debug-bar-cron' ) . '<br />', $this->get_minutes( $interval ) ); // WPCS: XSS ok. |
|
| 303 | + printf(esc_html__('%sm', 'zt-debug-bar-cron').'<br />', $this->get_minutes($interval)); // WPCS: XSS ok. |
|
| 304 | 304 | /* TRANSLATORS: %s is number of hours. */ |
| 305 | - printf( esc_html__( '%sh', 'zt-debug-bar-cron' ), $this->get_hours( $interval ) ); // WPCS: XSS ok. |
|
| 305 | + printf(esc_html__('%sh', 'zt-debug-bar-cron'), $this->get_hours($interval)); // WPCS: XSS ok. |
|
| 306 | 306 | } else { |
| 307 | - echo esc_html__( 'Single Event', 'zt-debug-bar-cron' ); |
|
| 307 | + echo esc_html__('Single Event', 'zt-debug-bar-cron'); |
|
| 308 | 308 | } |
| 309 | 309 | echo '</td>'; |
| 310 | 310 | |
| 311 | 311 | // Report the args. |
| 312 | 312 | echo ' |
| 313 | 313 | <td>'; |
| 314 | - $this->display_cron_arguments( $info['args'] ); |
|
| 314 | + $this->display_cron_arguments($info['args']); |
|
| 315 | 315 | echo '</td> |
| 316 | 316 | </tr>'; |
| 317 | 317 | } |
@@ -331,15 +331,15 @@ discard block |
||
| 331 | 331 | * |
| 332 | 332 | * @return void |
| 333 | 333 | */ |
| 334 | - private function display_cron_arguments( $args ) { |
|
| 334 | + private function display_cron_arguments($args) { |
|
| 335 | 335 | // Arguments defaults to an empty array if no arguments are given. |
| 336 | - if ( is_array( $args ) && array() === $args ) { |
|
| 337 | - echo esc_html__( 'No Args', 'zt-debug-bar-cron' ); |
|
| 336 | + if (is_array($args) && array() === $args) { |
|
| 337 | + echo esc_html__('No Args', 'zt-debug-bar-cron'); |
|
| 338 | 338 | return; |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | // Ok, we have an argument, let's pretty print it. |
| 342 | - $this->print_pretty_output( $args ); |
|
| 342 | + $this->print_pretty_output($args); |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | |
@@ -352,26 +352,26 @@ discard block |
||
| 352 | 352 | echo ' |
| 353 | 353 | <table class="zt-debug-bar-cron-event-table"> |
| 354 | 354 | <thead><tr> |
| 355 | - <th class="col1">', esc_html__( 'Interval Hook', 'zt-debug-bar-cron' ), '</th> |
|
| 356 | - <th class="col2">', esc_html__( 'Interval (S)', 'zt-debug-bar-cron' ), '</th> |
|
| 357 | - <th class="col3">', esc_html__( 'Interval (M)', 'zt-debug-bar-cron' ), '</th> |
|
| 358 | - <th class="col4">', esc_html__( 'Interval (H)', 'zt-debug-bar-cron' ), '</th> |
|
| 359 | - <th class="col5">', esc_html__( 'Display Name', 'zt-debug-bar-cron' ), '</th> |
|
| 355 | + <th class="col1">', esc_html__('Interval Hook', 'zt-debug-bar-cron'), '</th> |
|
| 356 | + <th class="col2">', esc_html__('Interval (S)', 'zt-debug-bar-cron'), '</th> |
|
| 357 | + <th class="col3">', esc_html__('Interval (M)', 'zt-debug-bar-cron'), '</th> |
|
| 358 | + <th class="col4">', esc_html__('Interval (H)', 'zt-debug-bar-cron'), '</th> |
|
| 359 | + <th class="col5">', esc_html__('Display Name', 'zt-debug-bar-cron'), '</th> |
|
| 360 | 360 | </tr></thead> |
| 361 | 361 | <tbody>'; |
| 362 | 362 | |
| 363 | 363 | |
| 364 | 364 | $schedules = wp_get_schedules(); |
| 365 | - foreach ( $schedules as $interval_hook => $data ) { |
|
| 365 | + foreach ($schedules as $interval_hook => $data) { |
|
| 366 | 366 | $interval = (int) $data['interval']; |
| 367 | 367 | echo // WPCS: XSS ok. |
| 368 | 368 | ' |
| 369 | 369 | <tr> |
| 370 | - <td>', esc_html( $interval_hook ), '</td> |
|
| 370 | + <td>', esc_html($interval_hook), '</td> |
|
| 371 | 371 | <td>', $interval, '</td> |
| 372 | - <td>', $this->get_minutes( $interval ), '</td> |
|
| 373 | - <td>', $this->get_hours( $interval ), '</td> |
|
| 374 | - <td>', esc_html( $data['display'] ) . '</td> |
|
| 372 | + <td>', $this->get_minutes($interval), '</td> |
|
| 373 | + <td>', $this->get_hours($interval), '</td> |
|
| 374 | + <td>', esc_html($data['display']).'</td> |
|
| 375 | 375 | </tr>'; |
| 376 | 376 | } |
| 377 | 377 | |
@@ -388,8 +388,8 @@ discard block |
||
| 388 | 388 | * |
| 389 | 389 | * @return bool True if the time has passed, false otherwise. |
| 390 | 390 | */ |
| 391 | - private function is_time_in_past( $time ) { |
|
| 392 | - return ( time() > $time && 'No' === $this->_doing_cron ); |
|
| 391 | + private function is_time_in_past($time) { |
|
| 392 | + return (time() > $time && 'No' === $this->_doing_cron); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | |
@@ -400,8 +400,8 @@ discard block |
||
| 400 | 400 | * |
| 401 | 401 | * @return int|float |
| 402 | 402 | */ |
| 403 | - private function get_minutes( $time ) { |
|
| 404 | - return $this->bc_calc( (int) $time, '/', 60, true, 2 ); |
|
| 403 | + private function get_minutes($time) { |
|
| 404 | + return $this->bc_calc((int) $time, '/', 60, true, 2); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | |
@@ -412,8 +412,8 @@ discard block |
||
| 412 | 412 | * |
| 413 | 413 | * @return int|float |
| 414 | 414 | */ |
| 415 | - private function get_hours( $time ) { |
|
| 416 | - return $this->bc_calc( (int) $time, '/', 3600, true, 2 ); |
|
| 415 | + private function get_hours($time) { |
|
| 416 | + return $this->bc_calc((int) $time, '/', 3600, true, 2); |
|
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | |
@@ -449,51 +449,51 @@ discard block |
||
| 449 | 449 | * - for all other operations, the result will either be an integer (preferred) |
| 450 | 450 | * or a float. |
| 451 | 451 | */ |
| 452 | - private function bc_calc( $number1, $action, $number2, $round = false, $decimals = 0, $precision = 10 ) { |
|
| 453 | - if ( ! is_scalar( $number1 ) || ! is_scalar( $number2 ) ) { |
|
| 452 | + private function bc_calc($number1, $action, $number2, $round = false, $decimals = 0, $precision = 10) { |
|
| 453 | + if ( ! is_scalar($number1) || ! is_scalar($number2)) { |
|
| 454 | 454 | return false; |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | - $bc = extension_loaded( 'bcmath' ); |
|
| 457 | + $bc = extension_loaded('bcmath'); |
|
| 458 | 458 | |
| 459 | - if ( $bc ) { |
|
| 460 | - $number1 = number_format( $number1, 10, '.', '' ); |
|
| 461 | - $number2 = number_format( $number2, 10, '.', '' ); |
|
| 459 | + if ($bc) { |
|
| 460 | + $number1 = number_format($number1, 10, '.', ''); |
|
| 461 | + $number2 = number_format($number2, 10, '.', ''); |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | $result = null; |
| 465 | 465 | $compare = false; |
| 466 | 466 | |
| 467 | - switch ( $action ) { |
|
| 467 | + switch ($action) { |
|
| 468 | 468 | case '+': |
| 469 | 469 | case 'add': |
| 470 | 470 | case 'addition': |
| 471 | - $result = ( $bc ) ? bcadd( $number1, $number2, $precision ) /* string */ : ( $number1 + $number2 ); |
|
| 471 | + $result = ($bc) ? bcadd($number1, $number2, $precision) /* string */ : ($number1 + $number2); |
|
| 472 | 472 | break; |
| 473 | 473 | |
| 474 | 474 | case '-': |
| 475 | 475 | case 'sub': |
| 476 | 476 | case 'subtract': |
| 477 | - $result = ( $bc ) ? bcsub( $number1, $number2, $precision ) /* string */ : ( $number1 - $number2 ); |
|
| 477 | + $result = ($bc) ? bcsub($number1, $number2, $precision) /* string */ : ($number1 - $number2); |
|
| 478 | 478 | break; |
| 479 | 479 | |
| 480 | 480 | case '*': |
| 481 | 481 | case 'mul': |
| 482 | 482 | case 'multiply': |
| 483 | - $result = ( $bc ) ? bcmul( $number1, $number2, $precision ) /* string */ : ( $number1 * $number2 ); |
|
| 483 | + $result = ($bc) ? bcmul($number1, $number2, $precision) /* string */ : ($number1 * $number2); |
|
| 484 | 484 | break; |
| 485 | 485 | |
| 486 | 486 | case '/': |
| 487 | 487 | case 'div': |
| 488 | 488 | case 'divide': |
| 489 | - if ( $bc ) { |
|
| 490 | - $result = bcdiv( $number1, $number2, $precision ); // String, or NULL if right_operand is 0. |
|
| 489 | + if ($bc) { |
|
| 490 | + $result = bcdiv($number1, $number2, $precision); // String, or NULL if right_operand is 0. |
|
| 491 | 491 | } |
| 492 | - else if ( $number2 != 0 ) { |
|
| 492 | + else if ($number2 != 0) { |
|
| 493 | 493 | $result = $number1 / $number2; |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | - if ( ! isset( $result ) ) { |
|
| 496 | + if ( ! isset($result)) { |
|
| 497 | 497 | $result = 0; |
| 498 | 498 | } |
| 499 | 499 | break; |
@@ -501,14 +501,14 @@ discard block |
||
| 501 | 501 | case '%': |
| 502 | 502 | case 'mod': |
| 503 | 503 | case 'modulus': |
| 504 | - if ( $bc ) { |
|
| 505 | - $result = bcmod( $number1, $number2, $precision ); // String, or NULL if modulus is 0. |
|
| 504 | + if ($bc) { |
|
| 505 | + $result = bcmod($number1, $number2, $precision); // String, or NULL if modulus is 0. |
|
| 506 | 506 | } |
| 507 | - else if ( $number2 != 0 ) { |
|
| 507 | + else if ($number2 != 0) { |
|
| 508 | 508 | $result = $number1 % $number2; |
| 509 | 509 | } |
| 510 | 510 | |
| 511 | - if ( ! isset( $result ) ) { |
|
| 511 | + if ( ! isset($result)) { |
|
| 512 | 512 | $result = 0; |
| 513 | 513 | } |
| 514 | 514 | break; |
@@ -517,25 +517,25 @@ discard block |
||
| 517 | 517 | case 'comp': |
| 518 | 518 | case 'compare': |
| 519 | 519 | $compare = true; |
| 520 | - if ( $bc ) { |
|
| 521 | - $result = bccomp( $number1, $number2, $precision ); // Returns int 0, 1 or -1. |
|
| 520 | + if ($bc) { |
|
| 521 | + $result = bccomp($number1, $number2, $precision); // Returns int 0, 1 or -1. |
|
| 522 | 522 | } |
| 523 | 523 | else { |
| 524 | - $result = ( $number1 == $number2 ) ? 0 : ( ( $number1 > $number2 ) ? 1 : -1 ); |
|
| 524 | + $result = ($number1 == $number2) ? 0 : (($number1 > $number2) ? 1 : -1); |
|
| 525 | 525 | } |
| 526 | 526 | break; |
| 527 | 527 | } |
| 528 | 528 | |
| 529 | - if ( isset( $result ) ) { |
|
| 530 | - if ( $compare === false ) { |
|
| 531 | - if ( $round === true ) { |
|
| 532 | - $result = round( floatval( $result ), $decimals ); |
|
| 533 | - if ( $decimals === 0 ) { |
|
| 529 | + if (isset($result)) { |
|
| 530 | + if ($compare === false) { |
|
| 531 | + if ($round === true) { |
|
| 532 | + $result = round(floatval($result), $decimals); |
|
| 533 | + if ($decimals === 0) { |
|
| 534 | 534 | $result = (int) $result; |
| 535 | 535 | } |
| 536 | 536 | } |
| 537 | 537 | else { |
| 538 | - $result = ( intval( $result ) == $result ) ? intval( $result ) : floatval( $result ); |
|
| 538 | + $result = (intval($result) == $result) ? intval($result) : floatval($result); |
|
| 539 | 539 | } |
| 540 | 540 | } |
| 541 | 541 | return $result; |
@@ -553,10 +553,10 @@ discard block |
||
| 553 | 553 | * |
| 554 | 554 | * @return string |
| 555 | 555 | */ |
| 556 | - private function display_past_time( $human_time, $time ) { |
|
| 557 | - if ( time() > $time ) { |
|
| 556 | + private function display_past_time($human_time, $time) { |
|
| 557 | + if (time() > $time) { |
|
| 558 | 558 | /* TRANSLATORS: %s is a human readable time difference. */ |
| 559 | - return sprintf( __( '%s ago', 'zt-debug-bar-cron' ), $human_time ); |
|
| 559 | + return sprintf(__('%s ago', 'zt-debug-bar-cron'), $human_time); |
|
| 560 | 560 | } else { |
| 561 | 561 | return $human_time; |
| 562 | 562 | } |
@@ -567,13 +567,13 @@ discard block |
||
| 567 | 567 | * Load the pretty output class & set the recursion limit. |
| 568 | 568 | */ |
| 569 | 569 | private function load_debug_bar_pretty_output() { |
| 570 | - if ( ! class_exists( 'Debug_Bar_Pretty_Output' ) ) { |
|
| 571 | - require_once plugin_dir_path( __FILE__ ) . 'inc/debug-bar-pretty-output/class-debug-bar-pretty-output.php'; |
|
| 570 | + if ( ! class_exists('Debug_Bar_Pretty_Output')) { |
|
| 571 | + require_once plugin_dir_path(__FILE__).'inc/debug-bar-pretty-output/class-debug-bar-pretty-output.php'; |
|
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | // Limit recursion depth if possible - method available since DBPO v1.4. |
| 575 | - if ( method_exists( 'Debug_Bar_Pretty_Output', 'limit_recursion' ) ) { |
|
| 576 | - Debug_Bar_Pretty_Output::limit_recursion( 2 ); |
|
| 575 | + if (method_exists('Debug_Bar_Pretty_Output', 'limit_recursion')) { |
|
| 576 | + Debug_Bar_Pretty_Output::limit_recursion(2); |
|
| 577 | 577 | } |
| 578 | 578 | } |
| 579 | 579 | |
@@ -583,13 +583,13 @@ discard block |
||
| 583 | 583 | * |
| 584 | 584 | * @param mixed $variable The variable to print. |
| 585 | 585 | */ |
| 586 | - private function print_pretty_output( $variable ) { |
|
| 587 | - if ( defined( 'Debug_Bar_Pretty_Output::VERSION' ) ) { |
|
| 588 | - echo Debug_Bar_Pretty_Output::get_output( $variable, '', true ); // WPCS: XSS ok. |
|
| 586 | + private function print_pretty_output($variable) { |
|
| 587 | + if (defined('Debug_Bar_Pretty_Output::VERSION')) { |
|
| 588 | + echo Debug_Bar_Pretty_Output::get_output($variable, '', true); // WPCS: XSS ok. |
|
| 589 | 589 | } else { |
| 590 | 590 | // An old version of the pretty output class was loaded. |
| 591 | 591 | // Real possibility as there are several DB plugins using the pretty print class. |
| 592 | - Debug_Bar_Pretty_Output::output( $variable, '', true ); |
|
| 592 | + Debug_Bar_Pretty_Output::output($variable, '', true); |
|
| 593 | 593 | } |
| 594 | 594 | } |
| 595 | 595 | |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | * @internal Method available since DBPO v1.4. |
| 601 | 601 | */ |
| 602 | 602 | private function reset_debug_bar_pretty_output() { |
| 603 | - if ( method_exists( 'Debug_Bar_Pretty_Output', 'unset_recursion_limit' ) ) { |
|
| 603 | + if (method_exists('Debug_Bar_Pretty_Output', 'unset_recursion_limit')) { |
|
| 604 | 604 | Debug_Bar_Pretty_Output::unset_recursion_limit(); |
| 605 | 605 | } |
| 606 | 606 | } |
@@ -488,8 +488,7 @@ discard block |
||
| 488 | 488 | case 'divide': |
| 489 | 489 | if ( $bc ) { |
| 490 | 490 | $result = bcdiv( $number1, $number2, $precision ); // String, or NULL if right_operand is 0. |
| 491 | - } |
|
| 492 | - else if ( $number2 != 0 ) { |
|
| 491 | + } else if ( $number2 != 0 ) { |
|
| 493 | 492 | $result = $number1 / $number2; |
| 494 | 493 | } |
| 495 | 494 | |
@@ -503,8 +502,7 @@ discard block |
||
| 503 | 502 | case 'modulus': |
| 504 | 503 | if ( $bc ) { |
| 505 | 504 | $result = bcmod( $number1, $number2, $precision ); // String, or NULL if modulus is 0. |
| 506 | - } |
|
| 507 | - else if ( $number2 != 0 ) { |
|
| 505 | + } else if ( $number2 != 0 ) { |
|
| 508 | 506 | $result = $number1 % $number2; |
| 509 | 507 | } |
| 510 | 508 | |
@@ -519,8 +517,7 @@ discard block |
||
| 519 | 517 | $compare = true; |
| 520 | 518 | if ( $bc ) { |
| 521 | 519 | $result = bccomp( $number1, $number2, $precision ); // Returns int 0, 1 or -1. |
| 522 | - } |
|
| 523 | - else { |
|
| 520 | + } else { |
|
| 524 | 521 | $result = ( $number1 == $number2 ) ? 0 : ( ( $number1 > $number2 ) ? 1 : -1 ); |
| 525 | 522 | } |
| 526 | 523 | break; |
@@ -533,8 +530,7 @@ discard block |
||
| 533 | 530 | if ( $decimals === 0 ) { |
| 534 | 531 | $result = (int) $result; |
| 535 | 532 | } |
| 536 | - } |
|
| 537 | - else { |
|
| 533 | + } else { |
|
| 538 | 534 | $result = ( intval( $result ) == $result ) ? intval( $result ) : floatval( $result ); |
| 539 | 535 | } |
| 540 | 536 | } |