@@ -11,8 +11,8 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | private $versions = array(); |
| 13 | 13 | |
| 14 | - public function register( $version_string, $initialization_callback ) { |
|
| 15 | - if ( isset($this->versions[$version_string]) ) { |
|
| 14 | + public function register($version_string, $initialization_callback) { |
|
| 15 | + if (isset($this->versions[$version_string])) { |
|
| 16 | 16 | return FALSE; |
| 17 | 17 | } |
| 18 | 18 | $this->versions[$version_string] = $initialization_callback; |
@@ -25,16 +25,16 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | public function latest_version() { |
| 27 | 27 | $keys = array_keys($this->versions); |
| 28 | - if ( empty($keys) ) { |
|
| 28 | + if (empty($keys)) { |
|
| 29 | 29 | return false; |
| 30 | 30 | } |
| 31 | - uasort( $keys, 'version_compare' ); |
|
| 31 | + uasort($keys, 'version_compare'); |
|
| 32 | 32 | return end($keys); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public function latest_version_callback() { |
| 36 | 36 | $latest = $this->latest_version(); |
| 37 | - if ( empty($latest) || !isset($this->versions[$latest]) ) { |
|
| 37 | + if (empty($latest) || !isset($this->versions[$latest])) { |
|
| 38 | 38 | return '__return_null'; |
| 39 | 39 | } |
| 40 | 40 | return $this->versions[$latest]; |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @codeCoverageIgnore |
| 46 | 46 | */ |
| 47 | 47 | public static function instance() { |
| 48 | - if ( empty(self::$instance) ) { |
|
| 48 | + if (empty(self::$instance)) { |
|
| 49 | 49 | self::$instance = new self(); |
| 50 | 50 | } |
| 51 | 51 | return self::$instance; |
@@ -31,13 +31,13 @@ discard block |
||
| 31 | 31 | * @param ActionScheduler_FatalErrorMonitor $monitor |
| 32 | 32 | * @param ActionScheduler_QueueCleaner $cleaner |
| 33 | 33 | */ |
| 34 | - public function __construct( ActionScheduler_Store $store = null, ActionScheduler_FatalErrorMonitor $monitor = null, ActionScheduler_QueueCleaner $cleaner = null ) { |
|
| 34 | + public function __construct(ActionScheduler_Store $store = null, ActionScheduler_FatalErrorMonitor $monitor = null, ActionScheduler_QueueCleaner $cleaner = null) { |
|
| 35 | 35 | |
| 36 | - $this->created_time = microtime( true ); |
|
| 36 | + $this->created_time = microtime(true); |
|
| 37 | 37 | |
| 38 | 38 | $this->store = $store ? $store : ActionScheduler_Store::instance(); |
| 39 | - $this->monitor = $monitor ? $monitor : new ActionScheduler_FatalErrorMonitor( $this->store ); |
|
| 40 | - $this->cleaner = $cleaner ? $cleaner : new ActionScheduler_QueueCleaner( $this->store ); |
|
| 39 | + $this->monitor = $monitor ? $monitor : new ActionScheduler_FatalErrorMonitor($this->store); |
|
| 40 | + $this->cleaner = $cleaner ? $cleaner : new ActionScheduler_QueueCleaner($this->store); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -47,35 +47,35 @@ discard block |
||
| 47 | 47 | * @param string $context Optional identifer for the context in which this action is being processed, e.g. 'WP CLI' or 'WP Cron' |
| 48 | 48 | * Generally, this should be capitalised and not localised as it's a proper noun. |
| 49 | 49 | */ |
| 50 | - public function process_action( $action_id, $context = '' ) { |
|
| 50 | + public function process_action($action_id, $context = '') { |
|
| 51 | 51 | try { |
| 52 | 52 | $valid_action = false; |
| 53 | - do_action( 'action_scheduler_before_execute', $action_id, $context ); |
|
| 53 | + do_action('action_scheduler_before_execute', $action_id, $context); |
|
| 54 | 54 | |
| 55 | - if ( ActionScheduler_Store::STATUS_PENDING !== $this->store->get_status( $action_id ) ) { |
|
| 56 | - do_action( 'action_scheduler_execution_ignored', $action_id, $context ); |
|
| 55 | + if (ActionScheduler_Store::STATUS_PENDING !== $this->store->get_status($action_id)) { |
|
| 56 | + do_action('action_scheduler_execution_ignored', $action_id, $context); |
|
| 57 | 57 | return; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | $valid_action = true; |
| 61 | - do_action( 'action_scheduler_begin_execute', $action_id, $context ); |
|
| 61 | + do_action('action_scheduler_begin_execute', $action_id, $context); |
|
| 62 | 62 | |
| 63 | - $action = $this->store->fetch_action( $action_id ); |
|
| 64 | - $this->store->log_execution( $action_id ); |
|
| 63 | + $action = $this->store->fetch_action($action_id); |
|
| 64 | + $this->store->log_execution($action_id); |
|
| 65 | 65 | $action->execute(); |
| 66 | - do_action( 'action_scheduler_after_execute', $action_id, $action, $context ); |
|
| 67 | - $this->store->mark_complete( $action_id ); |
|
| 68 | - } catch ( Exception $e ) { |
|
| 69 | - if ( $valid_action ) { |
|
| 70 | - $this->store->mark_failure( $action_id ); |
|
| 71 | - do_action( 'action_scheduler_failed_execution', $action_id, $e, $context ); |
|
| 66 | + do_action('action_scheduler_after_execute', $action_id, $action, $context); |
|
| 67 | + $this->store->mark_complete($action_id); |
|
| 68 | + } catch (Exception $e) { |
|
| 69 | + if ($valid_action) { |
|
| 70 | + $this->store->mark_failure($action_id); |
|
| 71 | + do_action('action_scheduler_failed_execution', $action_id, $e, $context); |
|
| 72 | 72 | } else { |
| 73 | - do_action( 'action_scheduler_failed_validation', $action_id, $e, $context ); |
|
| 73 | + do_action('action_scheduler_failed_validation', $action_id, $e, $context); |
|
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - if ( isset( $action ) && is_a( $action, 'ActionScheduler_Action' ) && $action->get_schedule()->is_recurring() ) { |
|
| 78 | - $this->schedule_next_instance( $action, $action_id ); |
|
| 77 | + if (isset($action) && is_a($action, 'ActionScheduler_Action') && $action->get_schedule()->is_recurring()) { |
|
| 78 | + $this->schedule_next_instance($action, $action_id); |
|
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | |
@@ -85,11 +85,11 @@ discard block |
||
| 85 | 85 | * @param ActionScheduler_Action $action |
| 86 | 86 | * @param int $action_id |
| 87 | 87 | */ |
| 88 | - protected function schedule_next_instance( ActionScheduler_Action $action, $action_id ) { |
|
| 88 | + protected function schedule_next_instance(ActionScheduler_Action $action, $action_id) { |
|
| 89 | 89 | try { |
| 90 | - ActionScheduler::factory()->repeat( $action ); |
|
| 91 | - } catch ( Exception $e ) { |
|
| 92 | - do_action( 'action_scheduler_failed_to_schedule_next_instance', $action_id, $e, $action ); |
|
| 90 | + ActionScheduler::factory()->repeat($action); |
|
| 91 | + } catch (Exception $e) { |
|
| 92 | + do_action('action_scheduler_failed_to_schedule_next_instance', $action_id, $e, $action); |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * @author Jeremy Pry |
| 100 | 100 | */ |
| 101 | 101 | protected function run_cleanup() { |
| 102 | - $this->cleaner->clean( 10 * $this->get_time_limit() ); |
|
| 102 | + $this->cleaner->clean(10 * $this->get_time_limit()); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * @return int |
| 109 | 109 | */ |
| 110 | 110 | public function get_allowed_concurrent_batches() { |
| 111 | - return apply_filters( 'action_scheduler_queue_runner_concurrent_batches', 1 ); |
|
| 111 | + return apply_filters('action_scheduler_queue_runner_concurrent_batches', 1); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -130,12 +130,12 @@ discard block |
||
| 130 | 130 | $time_limit = 30; |
| 131 | 131 | |
| 132 | 132 | // Apply deprecated filter from deprecated get_maximum_execution_time() method |
| 133 | - if ( has_filter( 'action_scheduler_maximum_execution_time' ) ) { |
|
| 134 | - _deprecated_function( 'action_scheduler_maximum_execution_time', '2.1.1', 'action_scheduler_queue_runner_time_limit' ); |
|
| 135 | - $time_limit = apply_filters( 'action_scheduler_maximum_execution_time', $time_limit ); |
|
| 133 | + if (has_filter('action_scheduler_maximum_execution_time')) { |
|
| 134 | + _deprecated_function('action_scheduler_maximum_execution_time', '2.1.1', 'action_scheduler_queue_runner_time_limit'); |
|
| 135 | + $time_limit = apply_filters('action_scheduler_maximum_execution_time', $time_limit); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - return absint( apply_filters( 'action_scheduler_queue_runner_time_limit', $time_limit ) ); |
|
| 138 | + return absint(apply_filters('action_scheduler_queue_runner_time_limit', $time_limit)); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -144,14 +144,14 @@ discard block |
||
| 144 | 144 | * @return int The number of seconds. |
| 145 | 145 | */ |
| 146 | 146 | protected function get_execution_time() { |
| 147 | - $execution_time = microtime( true ) - $this->created_time; |
|
| 147 | + $execution_time = microtime(true) - $this->created_time; |
|
| 148 | 148 | |
| 149 | 149 | // Get the CPU time if the hosting environment uses it rather than wall-clock time to calculate a process's execution time. |
| 150 | - if ( function_exists( 'getrusage' ) && apply_filters( 'action_scheduler_use_cpu_execution_time', defined( 'PANTHEON_ENVIRONMENT' ) ) ) { |
|
| 150 | + if (function_exists('getrusage') && apply_filters('action_scheduler_use_cpu_execution_time', defined('PANTHEON_ENVIRONMENT'))) { |
|
| 151 | 151 | $resource_usages = getrusage(); |
| 152 | 152 | |
| 153 | - if ( isset( $resource_usages['ru_stime.tv_usec'], $resource_usages['ru_stime.tv_usec'] ) ) { |
|
| 154 | - $execution_time = $resource_usages['ru_stime.tv_sec'] + ( $resource_usages['ru_stime.tv_usec'] / 1000000 ); |
|
| 153 | + if (isset($resource_usages['ru_stime.tv_usec'], $resource_usages['ru_stime.tv_usec'])) { |
|
| 154 | + $execution_time = $resource_usages['ru_stime.tv_sec'] + ($resource_usages['ru_stime.tv_usec'] / 1000000); |
|
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | |
@@ -164,15 +164,15 @@ discard block |
||
| 164 | 164 | * @param int $processed_actions The number of actions processed so far - used to determine the likelihood of exceeding the time limit if processing another action |
| 165 | 165 | * @return bool |
| 166 | 166 | */ |
| 167 | - protected function time_likely_to_be_exceeded( $processed_actions ) { |
|
| 167 | + protected function time_likely_to_be_exceeded($processed_actions) { |
|
| 168 | 168 | |
| 169 | 169 | $execution_time = $this->get_execution_time(); |
| 170 | 170 | $max_execution_time = $this->get_time_limit(); |
| 171 | 171 | $time_per_action = $execution_time / $processed_actions; |
| 172 | - $estimated_time = $execution_time + ( $time_per_action * 3 ); |
|
| 172 | + $estimated_time = $execution_time + ($time_per_action * 3); |
|
| 173 | 173 | $likely_to_be_exceeded = $estimated_time > $max_execution_time; |
| 174 | 174 | |
| 175 | - return apply_filters( 'action_scheduler_maximum_execution_time_likely_to_be_exceeded', $likely_to_be_exceeded, $this, $processed_actions, $execution_time, $max_execution_time ); |
|
| 175 | + return apply_filters('action_scheduler_maximum_execution_time_likely_to_be_exceeded', $likely_to_be_exceeded, $this, $processed_actions, $execution_time, $max_execution_time); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
@@ -183,18 +183,18 @@ discard block |
||
| 183 | 183 | * @return int |
| 184 | 184 | */ |
| 185 | 185 | protected function get_memory_limit() { |
| 186 | - if ( function_exists( 'ini_get' ) ) { |
|
| 187 | - $memory_limit = ini_get( 'memory_limit' ); |
|
| 186 | + if (function_exists('ini_get')) { |
|
| 187 | + $memory_limit = ini_get('memory_limit'); |
|
| 188 | 188 | } else { |
| 189 | 189 | $memory_limit = '128M'; // Sensible default, and minimum required by WooCommerce |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - if ( ! $memory_limit || -1 === $memory_limit || '-1' === $memory_limit ) { |
|
| 192 | + if (!$memory_limit || -1 === $memory_limit || '-1' === $memory_limit) { |
|
| 193 | 193 | // Unlimited, set to 32GB. |
| 194 | 194 | $memory_limit = '32G'; |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - return ActionScheduler_Compatibility::convert_hr_to_bytes( $memory_limit ); |
|
| 197 | + return ActionScheduler_Compatibility::convert_hr_to_bytes($memory_limit); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | /** |
@@ -209,10 +209,10 @@ discard block |
||
| 209 | 209 | protected function memory_exceeded() { |
| 210 | 210 | |
| 211 | 211 | $memory_limit = $this->get_memory_limit() * 0.90; |
| 212 | - $current_memory = memory_get_usage( true ); |
|
| 212 | + $current_memory = memory_get_usage(true); |
|
| 213 | 213 | $memory_exceeded = $current_memory >= $memory_limit; |
| 214 | 214 | |
| 215 | - return apply_filters( 'action_scheduler_memory_exceeded', $memory_exceeded, $this ); |
|
| 215 | + return apply_filters('action_scheduler_memory_exceeded', $memory_exceeded, $this); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
@@ -224,8 +224,8 @@ discard block |
||
| 224 | 224 | * @param int $processed_actions The number of actions processed so far - used to determine the likelihood of exceeding the time limit if processing another action |
| 225 | 225 | * @return bool |
| 226 | 226 | */ |
| 227 | - protected function batch_limits_exceeded( $processed_actions ) { |
|
| 228 | - return $this->memory_exceeded() || $this->time_likely_to_be_exceeded( $processed_actions ); |
|
| 227 | + protected function batch_limits_exceeded($processed_actions) { |
|
| 228 | + return $this->memory_exceeded() || $this->time_likely_to_be_exceeded($processed_actions); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
@@ -236,5 +236,5 @@ discard block |
||
| 236 | 236 | * Generally, this should be capitalised and not localised as it's a proper noun. |
| 237 | 237 | * @return int The number of actions processed. |
| 238 | 238 | */ |
| 239 | - abstract public function run( $context = '' ); |
|
| 239 | + abstract public function run($context = ''); |
|
| 240 | 240 | } |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
| 4 | - require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); |
|
| 3 | +if (!class_exists('WP_List_Table')) { |
|
| 4 | + require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php'); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | /** |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @deprecated 3.0.0 |
| 110 | 110 | */ |
| 111 | - protected function translate( $text, $context = '' ) { |
|
| 111 | + protected function translate($text, $context = '') { |
|
| 112 | 112 | return $text; |
| 113 | 113 | } |
| 114 | 114 | |
@@ -120,12 +120,12 @@ discard block |
||
| 120 | 120 | protected function get_bulk_actions() { |
| 121 | 121 | $actions = array(); |
| 122 | 122 | |
| 123 | - foreach ( $this->bulk_actions as $action => $label ) { |
|
| 124 | - if ( ! is_callable( array( $this, 'bulk_' . $action ) ) ) { |
|
| 125 | - throw new RuntimeException( "The bulk action $action does not have a callback method" ); |
|
| 123 | + foreach ($this->bulk_actions as $action => $label) { |
|
| 124 | + if (!is_callable(array($this, 'bulk_' . $action))) { |
|
| 125 | + throw new RuntimeException("The bulk action $action does not have a callback method"); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - $actions[ $action ] = $label; |
|
| 128 | + $actions[$action] = $label; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | return $actions; |
@@ -140,22 +140,22 @@ discard block |
||
| 140 | 140 | global $wpdb; |
| 141 | 141 | // Detect when a bulk action is being triggered. |
| 142 | 142 | $action = $this->current_action(); |
| 143 | - if ( ! $action ) { |
|
| 143 | + if (!$action) { |
|
| 144 | 144 | return; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - check_admin_referer( 'bulk-' . $this->_args['plural'] ); |
|
| 147 | + check_admin_referer('bulk-' . $this->_args['plural']); |
|
| 148 | 148 | |
| 149 | 149 | $method = 'bulk_' . $action; |
| 150 | - if ( array_key_exists( $action, $this->bulk_actions ) && is_callable( array( $this, $method ) ) && ! empty( $_GET['ID'] ) && is_array( $_GET['ID'] ) ) { |
|
| 151 | - $ids_sql = '(' . implode( ',', array_fill( 0, count( $_GET['ID'] ), '%s' ) ) . ')'; |
|
| 152 | - $this->$method( $_GET['ID'], $wpdb->prepare( $ids_sql, $_GET['ID'] ) ); |
|
| 150 | + if (array_key_exists($action, $this->bulk_actions) && is_callable(array($this, $method)) && !empty($_GET['ID']) && is_array($_GET['ID'])) { |
|
| 151 | + $ids_sql = '(' . implode(',', array_fill(0, count($_GET['ID']), '%s')) . ')'; |
|
| 152 | + $this->$method($_GET['ID'], $wpdb->prepare($ids_sql, $_GET['ID'])); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - wp_redirect( remove_query_arg( |
|
| 156 | - array( '_wp_http_referer', '_wpnonce', 'ID', 'action', 'action2' ), |
|
| 157 | - wp_unslash( $_SERVER['REQUEST_URI'] ) |
|
| 158 | - ) ); |
|
| 155 | + wp_redirect(remove_query_arg( |
|
| 156 | + array('_wp_http_referer', '_wpnonce', 'ID', 'action', 'action2'), |
|
| 157 | + wp_unslash($_SERVER['REQUEST_URI']) |
|
| 158 | + )); |
|
| 159 | 159 | exit; |
| 160 | 160 | } |
| 161 | 161 | |
@@ -163,10 +163,10 @@ discard block |
||
| 163 | 163 | * Default code for deleting entries. |
| 164 | 164 | * validated already by process_bulk_action() |
| 165 | 165 | */ |
| 166 | - protected function bulk_delete( array $ids, $ids_sql ) { |
|
| 166 | + protected function bulk_delete(array $ids, $ids_sql) { |
|
| 167 | 167 | $store = ActionScheduler::store(); |
| 168 | - foreach ( $ids as $action_id ) { |
|
| 169 | - $store->delete( $action_id ); |
|
| 168 | + foreach ($ids as $action_id) { |
|
| 169 | + $store->delete($action_id); |
|
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | |
@@ -188,8 +188,8 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | public function get_sortable_columns() { |
| 190 | 190 | $sort_by = array(); |
| 191 | - foreach ( $this->sort_by as $column ) { |
|
| 192 | - $sort_by[ $column ] = array( $column, true ); |
|
| 191 | + foreach ($this->sort_by as $column) { |
|
| 192 | + $sort_by[$column] = array($column, true); |
|
| 193 | 193 | } |
| 194 | 194 | return $sort_by; |
| 195 | 195 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | public function get_columns() { |
| 202 | 202 | $columns = array_merge( |
| 203 | - array( 'cb' => '<input type="checkbox" />' ), |
|
| 203 | + array('cb' => '<input type="checkbox" />'), |
|
| 204 | 204 | $this->columns |
| 205 | 205 | ); |
| 206 | 206 | |
@@ -217,8 +217,8 @@ discard block |
||
| 217 | 217 | protected function get_items_query_limit() { |
| 218 | 218 | global $wpdb; |
| 219 | 219 | |
| 220 | - $per_page = $this->get_items_per_page( $this->package . '_items_per_page', $this->items_per_page ); |
|
| 221 | - return $wpdb->prepare( 'LIMIT %d', $per_page ); |
|
| 220 | + $per_page = $this->get_items_per_page($this->package . '_items_per_page', $this->items_per_page); |
|
| 221 | + return $wpdb->prepare('LIMIT %d', $per_page); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | /** |
@@ -227,10 +227,10 @@ discard block |
||
| 227 | 227 | * @return int |
| 228 | 228 | */ |
| 229 | 229 | protected function get_items_offset() { |
| 230 | - $per_page = $this->get_items_per_page( $this->package . '_items_per_page', $this->items_per_page ); |
|
| 230 | + $per_page = $this->get_items_per_page($this->package . '_items_per_page', $this->items_per_page); |
|
| 231 | 231 | $current_page = $this->get_pagenum(); |
| 232 | - if ( 1 < $current_page ) { |
|
| 233 | - $offset = $per_page * ( $current_page - 1 ); |
|
| 232 | + if (1 < $current_page) { |
|
| 233 | + $offset = $per_page * ($current_page - 1); |
|
| 234 | 234 | } else { |
| 235 | 235 | $offset = 0; |
| 236 | 236 | } |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | protected function get_items_query_offset() { |
| 249 | 249 | global $wpdb; |
| 250 | 250 | |
| 251 | - return $wpdb->prepare( 'OFFSET %d', $this->get_items_offset() ); |
|
| 251 | + return $wpdb->prepare('OFFSET %d', $this->get_items_offset()); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | /** |
@@ -257,12 +257,12 @@ discard block |
||
| 257 | 257 | * column and sortable. It will also use order (ASC|DESC) using DESC by default. |
| 258 | 258 | */ |
| 259 | 259 | protected function get_items_query_order() { |
| 260 | - if ( empty( $this->sort_by ) ) { |
|
| 260 | + if (empty($this->sort_by)) { |
|
| 261 | 261 | return ''; |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - $orderby = esc_sql( $this->get_request_orderby() ); |
|
| 265 | - $order = esc_sql( $this->get_request_order() ); |
|
| 264 | + $orderby = esc_sql($this->get_request_orderby()); |
|
| 265 | + $order = esc_sql($this->get_request_order()); |
|
| 266 | 266 | |
| 267 | 267 | return "ORDER BY {$orderby} {$order}"; |
| 268 | 268 | } |
@@ -274,10 +274,10 @@ discard block |
||
| 274 | 274 | */ |
| 275 | 275 | protected function get_request_orderby() { |
| 276 | 276 | |
| 277 | - $valid_sortable_columns = array_values( $this->sort_by ); |
|
| 277 | + $valid_sortable_columns = array_values($this->sort_by); |
|
| 278 | 278 | |
| 279 | - if ( ! empty( $_GET['orderby'] ) && in_array( $_GET['orderby'], $valid_sortable_columns ) ) { |
|
| 280 | - $orderby = sanitize_text_field( $_GET['orderby'] ); |
|
| 279 | + if (!empty($_GET['orderby']) && in_array($_GET['orderby'], $valid_sortable_columns)) { |
|
| 280 | + $orderby = sanitize_text_field($_GET['orderby']); |
|
| 281 | 281 | } else { |
| 282 | 282 | $orderby = $valid_sortable_columns[0]; |
| 283 | 283 | } |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | */ |
| 293 | 293 | protected function get_request_order() { |
| 294 | 294 | |
| 295 | - if ( ! empty( $_GET['order'] ) && 'desc' === strtolower( $_GET['order'] ) ) { |
|
| 295 | + if (!empty($_GET['order']) && 'desc' === strtolower($_GET['order'])) { |
|
| 296 | 296 | $order = 'DESC'; |
| 297 | 297 | } else { |
| 298 | 298 | $order = 'ASC'; |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | * @return string |
| 308 | 308 | */ |
| 309 | 309 | protected function get_request_status() { |
| 310 | - $status = ( ! empty( $_GET['status'] ) ) ? $_GET['status'] : ''; |
|
| 310 | + $status = (!empty($_GET['status'])) ? $_GET['status'] : ''; |
|
| 311 | 311 | return $status; |
| 312 | 312 | } |
| 313 | 313 | |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | * @return string |
| 318 | 318 | */ |
| 319 | 319 | protected function get_request_search_query() { |
| 320 | - $search_query = ( ! empty( $_GET['s'] ) ) ? $_GET['s'] : ''; |
|
| 320 | + $search_query = (!empty($_GET['s'])) ? $_GET['s'] : ''; |
|
| 321 | 321 | return $search_query; |
| 322 | 322 | } |
| 323 | 323 | |
@@ -328,8 +328,8 @@ discard block |
||
| 328 | 328 | * @return array |
| 329 | 329 | */ |
| 330 | 330 | protected function get_table_columns() { |
| 331 | - $columns = array_keys( $this->columns ); |
|
| 332 | - if ( ! in_array( $this->ID, $columns ) ) { |
|
| 331 | + $columns = array_keys($this->columns); |
|
| 332 | + if (!in_array($this->ID, $columns)) { |
|
| 333 | 333 | $columns[] = $this->ID; |
| 334 | 334 | } |
| 335 | 335 | |
@@ -351,15 +351,15 @@ discard block |
||
| 351 | 351 | protected function get_items_query_search() { |
| 352 | 352 | global $wpdb; |
| 353 | 353 | |
| 354 | - if ( empty( $_GET['s'] ) || empty( $this->search_by ) ) { |
|
| 354 | + if (empty($_GET['s']) || empty($this->search_by)) { |
|
| 355 | 355 | return ''; |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | - $filter = array(); |
|
| 359 | - foreach ( $this->search_by as $column ) { |
|
| 360 | - $filter[] = $wpdb->prepare('`' . $column . '` like "%%s%"', $wpdb->esc_like( $_GET['s'] )); |
|
| 358 | + $filter = array(); |
|
| 359 | + foreach ($this->search_by as $column) { |
|
| 360 | + $filter[] = $wpdb->prepare('`' . $column . '` like "%%s%"', $wpdb->esc_like($_GET['s'])); |
|
| 361 | 361 | } |
| 362 | - return implode( ' OR ', $filter ); |
|
| 362 | + return implode(' OR ', $filter); |
|
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | /** |
@@ -369,21 +369,21 @@ discard block |
||
| 369 | 369 | protected function get_items_query_filters() { |
| 370 | 370 | global $wpdb; |
| 371 | 371 | |
| 372 | - if ( ! $this->filter_by || empty( $_GET['filter_by'] ) || ! is_array( $_GET['filter_by'] ) ) { |
|
| 372 | + if (!$this->filter_by || empty($_GET['filter_by']) || !is_array($_GET['filter_by'])) { |
|
| 373 | 373 | return ''; |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | $filter = array(); |
| 377 | 377 | |
| 378 | - foreach ( $this->filter_by as $column => $options ) { |
|
| 379 | - if ( empty( $_GET['filter_by'][ $column ] ) || empty( $options[ $_GET['filter_by'][ $column ] ] ) ) { |
|
| 378 | + foreach ($this->filter_by as $column => $options) { |
|
| 379 | + if (empty($_GET['filter_by'][$column]) || empty($options[$_GET['filter_by'][$column]])) { |
|
| 380 | 380 | continue; |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - $filter[] = $wpdb->prepare( "`$column` = %s", $_GET['filter_by'][ $column ] ); |
|
| 383 | + $filter[] = $wpdb->prepare("`$column` = %s", $_GET['filter_by'][$column]); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | - return implode( ' AND ', $filter ); |
|
| 386 | + return implode(' AND ', $filter); |
|
| 387 | 387 | |
| 388 | 388 | } |
| 389 | 389 | |
@@ -403,9 +403,9 @@ discard block |
||
| 403 | 403 | |
| 404 | 404 | $this->process_row_actions(); |
| 405 | 405 | |
| 406 | - if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) { |
|
| 406 | + if (!empty($_REQUEST['_wp_http_referer'])) { |
|
| 407 | 407 | // _wp_http_referer is used only on bulk actions, we remove it to keep the $_GET shorter |
| 408 | - wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); |
|
| 408 | + wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI']))); |
|
| 409 | 409 | exit; |
| 410 | 410 | } |
| 411 | 411 | |
@@ -418,53 +418,53 @@ discard block |
||
| 418 | 418 | $this->get_items_query_search(), |
| 419 | 419 | $this->get_items_query_filters(), |
| 420 | 420 | )); |
| 421 | - $columns = '`' . implode( '`, `', $this->get_table_columns() ) . '`'; |
|
| 421 | + $columns = '`' . implode('`, `', $this->get_table_columns()) . '`'; |
|
| 422 | 422 | |
| 423 | - if ( ! empty( $where ) ) { |
|
| 424 | - $where = 'WHERE ('. implode( ') AND (', $where ) . ')'; |
|
| 423 | + if (!empty($where)) { |
|
| 424 | + $where = 'WHERE (' . implode(') AND (', $where) . ')'; |
|
| 425 | 425 | } else { |
| 426 | 426 | $where = ''; |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | $sql = "SELECT $columns FROM {$this->table_name} {$where} {$order} {$limit} {$offset}"; |
| 430 | 430 | |
| 431 | - $this->set_items( $wpdb->get_results( $sql, ARRAY_A ) ); |
|
| 431 | + $this->set_items($wpdb->get_results($sql, ARRAY_A)); |
|
| 432 | 432 | |
| 433 | 433 | $query_count = "SELECT COUNT({$this->ID}) FROM {$this->table_name} {$where}"; |
| 434 | - $total_items = $wpdb->get_var( $query_count ); |
|
| 435 | - $per_page = $this->get_items_per_page( $this->package . '_items_per_page', $this->items_per_page ); |
|
| 436 | - $this->set_pagination_args( array( |
|
| 434 | + $total_items = $wpdb->get_var($query_count); |
|
| 435 | + $per_page = $this->get_items_per_page($this->package . '_items_per_page', $this->items_per_page); |
|
| 436 | + $this->set_pagination_args(array( |
|
| 437 | 437 | 'total_items' => $total_items, |
| 438 | 438 | 'per_page' => $per_page, |
| 439 | - 'total_pages' => ceil( $total_items / $per_page ), |
|
| 440 | - ) ); |
|
| 439 | + 'total_pages' => ceil($total_items / $per_page), |
|
| 440 | + )); |
|
| 441 | 441 | } |
| 442 | 442 | |
| 443 | - public function extra_tablenav( $which ) { |
|
| 444 | - if ( ! $this->filter_by || 'top' !== $which ) { |
|
| 443 | + public function extra_tablenav($which) { |
|
| 444 | + if (!$this->filter_by || 'top' !== $which) { |
|
| 445 | 445 | return; |
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | echo '<div class="alignleft actions">'; |
| 449 | 449 | |
| 450 | - foreach ( $this->filter_by as $id => $options ) { |
|
| 451 | - $default = ! empty( $_GET['filter_by'][ $id ] ) ? $_GET['filter_by'][ $id ] : ''; |
|
| 452 | - if ( empty( $options[ $default ] ) ) { |
|
| 450 | + foreach ($this->filter_by as $id => $options) { |
|
| 451 | + $default = !empty($_GET['filter_by'][$id]) ? $_GET['filter_by'][$id] : ''; |
|
| 452 | + if (empty($options[$default])) { |
|
| 453 | 453 | $default = ''; |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | - echo '<select name="filter_by[' . esc_attr( $id ) . ']" class="first" id="filter-by-' . esc_attr( $id ) . '">'; |
|
| 456 | + echo '<select name="filter_by[' . esc_attr($id) . ']" class="first" id="filter-by-' . esc_attr($id) . '">'; |
|
| 457 | 457 | |
| 458 | - foreach ( $options as $value => $label ) { |
|
| 459 | - echo '<option value="' . esc_attr( $value ) . '" ' . esc_html( $value == $default ? 'selected' : '' ) .'>' |
|
| 460 | - . esc_html( $label ) |
|
| 458 | + foreach ($options as $value => $label) { |
|
| 459 | + echo '<option value="' . esc_attr($value) . '" ' . esc_html($value == $default ? 'selected' : '') . '>' |
|
| 460 | + . esc_html($label) |
|
| 461 | 461 | . '</option>'; |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | echo '</select>'; |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | - submit_button( esc_html__( 'Filter', 'action-scheduler' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); |
|
| 467 | + submit_button(esc_html__('Filter', 'action-scheduler'), '', 'filter_action', false, array('id' => 'post-query-submit')); |
|
| 468 | 468 | echo '</div>'; |
| 469 | 469 | } |
| 470 | 470 | |
@@ -472,10 +472,10 @@ discard block |
||
| 472 | 472 | * Set the data for displaying. It will attempt to unserialize (There is a chance that some columns |
| 473 | 473 | * are serialized). This can be override in child classes for futher data transformation. |
| 474 | 474 | */ |
| 475 | - protected function set_items( array $items ) { |
|
| 475 | + protected function set_items(array $items) { |
|
| 476 | 476 | $this->items = array(); |
| 477 | - foreach ( $items as $item ) { |
|
| 478 | - $this->items[ $item[ $this->ID ] ] = array_map( 'maybe_unserialize', $item ); |
|
| 477 | + foreach ($items as $item) { |
|
| 478 | + $this->items[$item[$this->ID]] = array_map('maybe_unserialize', $item); |
|
| 479 | 479 | } |
| 480 | 480 | } |
| 481 | 481 | |
@@ -484,8 +484,8 @@ discard block |
||
| 484 | 484 | * of how the primary key is named (to keep the code simpler). The bulk actions will do the proper |
| 485 | 485 | * name transformation though using `$this->ID`. |
| 486 | 486 | */ |
| 487 | - public function column_cb( $row ) { |
|
| 488 | - return '<input name="ID[]" type="checkbox" value="' . esc_attr( $row[ $this->ID ] ) .'" />'; |
|
| 487 | + public function column_cb($row) { |
|
| 488 | + return '<input name="ID[]" type="checkbox" value="' . esc_attr($row[$this->ID]) . '" />'; |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | /** |
@@ -498,62 +498,62 @@ discard block |
||
| 498 | 498 | * @param $column_name Current row |
| 499 | 499 | * @return |
| 500 | 500 | */ |
| 501 | - protected function maybe_render_actions( $row, $column_name ) { |
|
| 502 | - if ( empty( $this->row_actions[ $column_name ] ) ) { |
|
| 501 | + protected function maybe_render_actions($row, $column_name) { |
|
| 502 | + if (empty($this->row_actions[$column_name])) { |
|
| 503 | 503 | return; |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | - $row_id = $row[ $this->ID ]; |
|
| 506 | + $row_id = $row[$this->ID]; |
|
| 507 | 507 | |
| 508 | 508 | $actions = '<div class="row-actions">'; |
| 509 | 509 | $action_count = 0; |
| 510 | - foreach ( $this->row_actions[ $column_name ] as $action_key => $action ) { |
|
| 510 | + foreach ($this->row_actions[$column_name] as $action_key => $action) { |
|
| 511 | 511 | |
| 512 | 512 | $action_count++; |
| 513 | 513 | |
| 514 | - if ( ! method_exists( $this, 'row_action_' . $action_key ) ) { |
|
| 514 | + if (!method_exists($this, 'row_action_' . $action_key)) { |
|
| 515 | 515 | continue; |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | - $action_link = ! empty( $action['link'] ) ? $action['link'] : add_query_arg( array( 'row_action' => $action_key, 'row_id' => $row_id, 'nonce' => wp_create_nonce( $action_key . '::' . $row_id ) ) ); |
|
| 519 | - $span_class = ! empty( $action['class'] ) ? $action['class'] : $action_key; |
|
| 520 | - $separator = ( $action_count < count( $this->row_actions[ $column_name ] ) ) ? ' | ' : ''; |
|
| 518 | + $action_link = !empty($action['link']) ? $action['link'] : add_query_arg(array('row_action' => $action_key, 'row_id' => $row_id, 'nonce' => wp_create_nonce($action_key . '::' . $row_id))); |
|
| 519 | + $span_class = !empty($action['class']) ? $action['class'] : $action_key; |
|
| 520 | + $separator = ($action_count < count($this->row_actions[$column_name])) ? ' | ' : ''; |
|
| 521 | 521 | |
| 522 | - $actions .= sprintf( '<span class="%s">', esc_attr( $span_class ) ); |
|
| 523 | - $actions .= sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', esc_url( $action_link ), esc_attr( $action['desc'] ), esc_html( $action['name'] ) ); |
|
| 524 | - $actions .= sprintf( '%s</span>', $separator ); |
|
| 522 | + $actions .= sprintf('<span class="%s">', esc_attr($span_class)); |
|
| 523 | + $actions .= sprintf('<a href="%1$s" title="%2$s">%3$s</a>', esc_url($action_link), esc_attr($action['desc']), esc_html($action['name'])); |
|
| 524 | + $actions .= sprintf('%s</span>', $separator); |
|
| 525 | 525 | } |
| 526 | 526 | $actions .= '</div>'; |
| 527 | 527 | return $actions; |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | protected function process_row_actions() { |
| 531 | - $parameters = array( 'row_action', 'row_id', 'nonce' ); |
|
| 532 | - foreach ( $parameters as $parameter ) { |
|
| 533 | - if ( empty( $_REQUEST[ $parameter ] ) ) { |
|
| 531 | + $parameters = array('row_action', 'row_id', 'nonce'); |
|
| 532 | + foreach ($parameters as $parameter) { |
|
| 533 | + if (empty($_REQUEST[$parameter])) { |
|
| 534 | 534 | return; |
| 535 | 535 | } |
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | $method = 'row_action_' . $_REQUEST['row_action']; |
| 539 | 539 | |
| 540 | - if ( $_REQUEST['nonce'] === wp_create_nonce( $_REQUEST[ 'row_action' ] . '::' . $_REQUEST[ 'row_id' ] ) && method_exists( $this, $method ) ) { |
|
| 541 | - $this->$method( $_REQUEST['row_id'] ); |
|
| 540 | + if ($_REQUEST['nonce'] === wp_create_nonce($_REQUEST['row_action'] . '::' . $_REQUEST['row_id']) && method_exists($this, $method)) { |
|
| 541 | + $this->$method($_REQUEST['row_id']); |
|
| 542 | 542 | } |
| 543 | 543 | |
| 544 | - wp_redirect( remove_query_arg( |
|
| 545 | - array( 'row_id', 'row_action', 'nonce' ), |
|
| 546 | - wp_unslash( $_SERVER['REQUEST_URI'] ) |
|
| 547 | - ) ); |
|
| 544 | + wp_redirect(remove_query_arg( |
|
| 545 | + array('row_id', 'row_action', 'nonce'), |
|
| 546 | + wp_unslash($_SERVER['REQUEST_URI']) |
|
| 547 | + )); |
|
| 548 | 548 | exit; |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | /** |
| 552 | 552 | * Default column formatting, it will escape everythig for security. |
| 553 | 553 | */ |
| 554 | - public function column_default( $item, $column_name ) { |
|
| 555 | - $column_html = esc_html( $item[ $column_name ] ); |
|
| 556 | - $column_html .= $this->maybe_render_actions( $item, $column_name ); |
|
| 554 | + public function column_default($item, $column_name) { |
|
| 555 | + $column_html = esc_html($item[$column_name]); |
|
| 556 | + $column_html .= $this->maybe_render_actions($item, $column_name); |
|
| 557 | 557 | return $column_html; |
| 558 | 558 | } |
| 559 | 559 | |
@@ -561,10 +561,10 @@ discard block |
||
| 561 | 561 | * Display the table heading and search query, if any |
| 562 | 562 | */ |
| 563 | 563 | protected function display_header() { |
| 564 | - echo '<h1 class="wp-heading-inline">' . esc_attr( $this->table_header ) . '</h1>'; |
|
| 565 | - if ( $this->get_request_search_query() ) { |
|
| 564 | + echo '<h1 class="wp-heading-inline">' . esc_attr($this->table_header) . '</h1>'; |
|
| 565 | + if ($this->get_request_search_query()) { |
|
| 566 | 566 | /* translators: %s: search query */ |
| 567 | - echo '<span class="subtitle">' . esc_attr( sprintf( __( 'Search results for "%s"', 'action-scheduler' ), $this->get_request_search_query() ) ) . '</span>'; |
|
| 567 | + echo '<span class="subtitle">' . esc_attr(sprintf(__('Search results for "%s"', 'action-scheduler'), $this->get_request_search_query())) . '</span>'; |
|
| 568 | 568 | } |
| 569 | 569 | echo '<hr class="wp-header-end">'; |
| 570 | 570 | } |
@@ -573,9 +573,9 @@ discard block |
||
| 573 | 573 | * Display the table heading and search query, if any |
| 574 | 574 | */ |
| 575 | 575 | protected function display_admin_notices() { |
| 576 | - foreach ( $this->admin_notices as $notice ) { |
|
| 576 | + foreach ($this->admin_notices as $notice) { |
|
| 577 | 577 | echo '<div id="message" class="' . $notice['class'] . '">'; |
| 578 | - echo ' <p>' . wp_kses_post( $notice['message'] ) . '</p>'; |
|
| 578 | + echo ' <p>' . wp_kses_post($notice['message']) . '</p>'; |
|
| 579 | 579 | echo '</div>'; |
| 580 | 580 | } |
| 581 | 581 | } |
@@ -589,30 +589,30 @@ discard block |
||
| 589 | 589 | $request_status = $this->get_request_status(); |
| 590 | 590 | |
| 591 | 591 | // Helper to set 'all' filter when not set on status counts passed in |
| 592 | - if ( ! isset( $this->status_counts['all'] ) ) { |
|
| 593 | - $this->status_counts = array( 'all' => array_sum( $this->status_counts ) ) + $this->status_counts; |
|
| 592 | + if (!isset($this->status_counts['all'])) { |
|
| 593 | + $this->status_counts = array('all' => array_sum($this->status_counts)) + $this->status_counts; |
|
| 594 | 594 | } |
| 595 | 595 | |
| 596 | - foreach ( $this->status_counts as $status_name => $count ) { |
|
| 596 | + foreach ($this->status_counts as $status_name => $count) { |
|
| 597 | 597 | |
| 598 | - if ( 0 === $count ) { |
|
| 598 | + if (0 === $count) { |
|
| 599 | 599 | continue; |
| 600 | 600 | } |
| 601 | 601 | |
| 602 | - if ( $status_name === $request_status || ( empty( $request_status ) && 'all' === $status_name ) ) { |
|
| 602 | + if ($status_name === $request_status || (empty($request_status) && 'all' === $status_name)) { |
|
| 603 | 603 | $status_list_item = '<li class="%1$s"><strong>%3$s</strong> (%4$d)</li>'; |
| 604 | 604 | } else { |
| 605 | 605 | $status_list_item = '<li class="%1$s"><a href="%2$s">%3$s</a> (%4$d)</li>'; |
| 606 | 606 | } |
| 607 | 607 | |
| 608 | - $status_filter_url = ( 'all' === $status_name ) ? remove_query_arg( 'status' ) : add_query_arg( 'status', $status_name ); |
|
| 609 | - $status_filter_url = remove_query_arg( array( 'paged', 's' ), $status_filter_url ); |
|
| 610 | - $status_list_items[] = sprintf( $status_list_item, esc_attr( $status_name ), esc_url( $status_filter_url ), esc_html( ucfirst( $status_name ) ), absint( $count ) ); |
|
| 608 | + $status_filter_url = ('all' === $status_name) ? remove_query_arg('status') : add_query_arg('status', $status_name); |
|
| 609 | + $status_filter_url = remove_query_arg(array('paged', 's'), $status_filter_url); |
|
| 610 | + $status_list_items[] = sprintf($status_list_item, esc_attr($status_name), esc_url($status_filter_url), esc_html(ucfirst($status_name)), absint($count)); |
|
| 611 | 611 | } |
| 612 | 612 | |
| 613 | - if ( $status_list_items ) { |
|
| 613 | + if ($status_list_items) { |
|
| 614 | 614 | echo '<ul class="subsubsub">'; |
| 615 | - echo implode( " | \n", $status_list_items ); |
|
| 615 | + echo implode(" | \n", $status_list_items); |
|
| 616 | 616 | echo '</ul>'; |
| 617 | 617 | } |
| 618 | 618 | } |
@@ -623,15 +623,15 @@ discard block |
||
| 623 | 623 | * forget about any extra HTML. |
| 624 | 624 | */ |
| 625 | 625 | protected function display_table() { |
| 626 | - echo '<form id="' . esc_attr( $this->_args['plural'] ) . '-filter" method="get">'; |
|
| 627 | - foreach ( $_GET as $key => $value ) { |
|
| 628 | - if ( '_' === $key[0] || 'paged' === $key ) { |
|
| 626 | + echo '<form id="' . esc_attr($this->_args['plural']) . '-filter" method="get">'; |
|
| 627 | + foreach ($_GET as $key => $value) { |
|
| 628 | + if ('_' === $key[0] || 'paged' === $key) { |
|
| 629 | 629 | continue; |
| 630 | 630 | } |
| 631 | - echo '<input type="hidden" name="' . esc_attr( $key ) . '" value="' . esc_attr( $value ) . '" />'; |
|
| 631 | + echo '<input type="hidden" name="' . esc_attr($key) . '" value="' . esc_attr($value) . '" />'; |
|
| 632 | 632 | } |
| 633 | - if ( ! empty( $this->search_by ) ) { |
|
| 634 | - echo $this->search_box( $this->get_search_box_button_text(), 'plugin' ); // WPCS: XSS OK |
|
| 633 | + if (!empty($this->search_by)) { |
|
| 634 | + echo $this->search_box($this->get_search_box_button_text(), 'plugin'); // WPCS: XSS OK |
|
| 635 | 635 | } |
| 636 | 636 | parent::display(); |
| 637 | 637 | echo '</form>'; |
@@ -644,9 +644,9 @@ discard block |
||
| 644 | 644 | $this->process_bulk_action(); |
| 645 | 645 | $this->process_row_actions(); |
| 646 | 646 | |
| 647 | - if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) { |
|
| 647 | + if (!empty($_REQUEST['_wp_http_referer'])) { |
|
| 648 | 648 | // _wp_http_referer is used only on bulk actions, we remove it to keep the $_GET shorter |
| 649 | - wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); |
|
| 649 | + wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI']))); |
|
| 650 | 650 | exit; |
| 651 | 651 | } |
| 652 | 652 | } |
@@ -669,6 +669,6 @@ discard block |
||
| 669 | 669 | * Get the text to display in the search box on the list table. |
| 670 | 670 | */ |
| 671 | 671 | protected function get_search_box_placeholder() { |
| 672 | - return esc_html__( 'Search', 'action-scheduler' ); |
|
| 672 | + return esc_html__('Search', 'action-scheduler'); |
|
| 673 | 673 | } |
| 674 | 674 | } |
@@ -39,9 +39,9 @@ discard block |
||
| 39 | 39 | * @param mixed $recurrence The data used to determine the schedule's recurrance. |
| 40 | 40 | * @param DateTime|null $first (Optional) The date & time the first instance of this interval schedule ran. Default null, meaning this is the first instance. |
| 41 | 41 | */ |
| 42 | - public function __construct( DateTime $date, $recurrence, DateTime $first = null ) { |
|
| 43 | - parent::__construct( $date ); |
|
| 44 | - $this->first_date = empty( $first ) ? $date : $first; |
|
| 42 | + public function __construct(DateTime $date, $recurrence, DateTime $first = null) { |
|
| 43 | + parent::__construct($date); |
|
| 44 | + $this->first_date = empty($first) ? $date : $first; |
|
| 45 | 45 | $this->recurrence = $recurrence; |
| 46 | 46 | } |
| 47 | 47 | |
@@ -75,10 +75,10 @@ discard block |
||
| 75 | 75 | public function __sleep() { |
| 76 | 76 | $sleep_params = parent::__sleep(); |
| 77 | 77 | $this->first_timestamp = $this->first_date->getTimestamp(); |
| 78 | - return array_merge( $sleep_params, array( |
|
| 78 | + return array_merge($sleep_params, array( |
|
| 79 | 79 | 'first_timestamp', |
| 80 | 80 | 'recurrence' |
| 81 | - ) ); |
|
| 81 | + )); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function __wakeup() { |
| 95 | 95 | parent::__wakeup(); |
| 96 | - if ( $this->first_timestamp > 0 ) { |
|
| 97 | - $this->first_date = as_get_datetime_object( $this->first_timestamp ); |
|
| 96 | + if ($this->first_timestamp > 0) { |
|
| 97 | + $this->first_date = as_get_datetime_object($this->first_timestamp); |
|
| 98 | 98 | } else { |
| 99 | 99 | $this->first_date = $this->get_date(); |
| 100 | 100 | } |
@@ -15,17 +15,17 @@ discard block |
||
| 15 | 15 | * @param DateTime $date |
| 16 | 16 | * @return ActionScheduler_DateTime |
| 17 | 17 | */ |
| 18 | - public static function set_local_timezone( DateTime $date ) { |
|
| 18 | + public static function set_local_timezone(DateTime $date) { |
|
| 19 | 19 | |
| 20 | 20 | // Accept a DateTime for easier backward compatibility, even though we require methods on ActionScheduler_DateTime |
| 21 | - if ( ! is_a( $date, 'ActionScheduler_DateTime' ) ) { |
|
| 22 | - $date = as_get_datetime_object( $date->format( 'U' ) ); |
|
| 21 | + if (!is_a($date, 'ActionScheduler_DateTime')) { |
|
| 22 | + $date = as_get_datetime_object($date->format('U')); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - if ( get_option( 'timezone_string' ) ) { |
|
| 26 | - $date->setTimezone( new DateTimeZone( self::get_local_timezone_string() ) ); |
|
| 25 | + if (get_option('timezone_string')) { |
|
| 26 | + $date->setTimezone(new DateTimeZone(self::get_local_timezone_string())); |
|
| 27 | 27 | } else { |
| 28 | - $date->setUtcOffset( self::get_local_timezone_offset() ); |
|
| 28 | + $date->setUtcOffset(self::get_local_timezone_offset()); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | return $date; |
@@ -44,16 +44,16 @@ discard block |
||
| 44 | 44 | * @since 2.1.0 |
| 45 | 45 | * @return string PHP timezone string for the site or empty if no timezone string is available. |
| 46 | 46 | */ |
| 47 | - protected static function get_local_timezone_string( $reset = false ) { |
|
| 47 | + protected static function get_local_timezone_string($reset = false) { |
|
| 48 | 48 | // If site timezone string exists, return it. |
| 49 | - $timezone = get_option( 'timezone_string' ); |
|
| 50 | - if ( $timezone ) { |
|
| 49 | + $timezone = get_option('timezone_string'); |
|
| 50 | + if ($timezone) { |
|
| 51 | 51 | return $timezone; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // Get UTC offset, if it isn't set then return UTC. |
| 55 | - $utc_offset = intval( get_option( 'gmt_offset', 0 ) ); |
|
| 56 | - if ( 0 === $utc_offset ) { |
|
| 55 | + $utc_offset = intval(get_option('gmt_offset', 0)); |
|
| 56 | + if (0 === $utc_offset) { |
|
| 57 | 57 | return 'UTC'; |
| 58 | 58 | } |
| 59 | 59 | |
@@ -61,15 +61,15 @@ discard block |
||
| 61 | 61 | $utc_offset *= 3600; |
| 62 | 62 | |
| 63 | 63 | // Attempt to guess the timezone string from the UTC offset. |
| 64 | - $timezone = timezone_name_from_abbr( '', $utc_offset ); |
|
| 65 | - if ( $timezone ) { |
|
| 64 | + $timezone = timezone_name_from_abbr('', $utc_offset); |
|
| 65 | + if ($timezone) { |
|
| 66 | 66 | return $timezone; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | // Last try, guess timezone string manually. |
| 70 | - foreach ( timezone_abbreviations_list() as $abbr ) { |
|
| 71 | - foreach ( $abbr as $city ) { |
|
| 72 | - if ( (bool) date( 'I' ) === (bool) $city['dst'] && $city['timezone_id'] && intval( $city['offset'] ) === $utc_offset ) { |
|
| 70 | + foreach (timezone_abbreviations_list() as $abbr) { |
|
| 71 | + foreach ($abbr as $city) { |
|
| 72 | + if ((bool) date('I') === (bool) $city['dst'] && $city['timezone_id'] && intval($city['offset']) === $utc_offset) { |
|
| 73 | 73 | return $city['timezone_id']; |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -86,48 +86,48 @@ discard block |
||
| 86 | 86 | * @return float |
| 87 | 87 | */ |
| 88 | 88 | protected static function get_local_timezone_offset() { |
| 89 | - $timezone = get_option( 'timezone_string' ); |
|
| 89 | + $timezone = get_option('timezone_string'); |
|
| 90 | 90 | |
| 91 | - if ( $timezone ) { |
|
| 92 | - $timezone_object = new DateTimeZone( $timezone ); |
|
| 93 | - return $timezone_object->getOffset( new DateTime( 'now' ) ); |
|
| 91 | + if ($timezone) { |
|
| 92 | + $timezone_object = new DateTimeZone($timezone); |
|
| 93 | + return $timezone_object->getOffset(new DateTime('now')); |
|
| 94 | 94 | } else { |
| 95 | - return floatval( get_option( 'gmt_offset', 0 ) ) * HOUR_IN_SECONDS; |
|
| 95 | + return floatval(get_option('gmt_offset', 0)) * HOUR_IN_SECONDS; |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * @deprecated 2.1.0 |
| 101 | 101 | */ |
| 102 | - public static function get_local_timezone( $reset = FALSE ) { |
|
| 103 | - _deprecated_function( __FUNCTION__, '2.1.0', 'ActionScheduler_TimezoneHelper::set_local_timezone()' ); |
|
| 104 | - if ( $reset ) { |
|
| 102 | + public static function get_local_timezone($reset = FALSE) { |
|
| 103 | + _deprecated_function(__FUNCTION__, '2.1.0', 'ActionScheduler_TimezoneHelper::set_local_timezone()'); |
|
| 104 | + if ($reset) { |
|
| 105 | 105 | self::$local_timezone = NULL; |
| 106 | 106 | } |
| 107 | - if ( !isset(self::$local_timezone) ) { |
|
| 107 | + if (!isset(self::$local_timezone)) { |
|
| 108 | 108 | $tzstring = get_option('timezone_string'); |
| 109 | 109 | |
| 110 | - if ( empty($tzstring) ) { |
|
| 110 | + if (empty($tzstring)) { |
|
| 111 | 111 | $gmt_offset = get_option('gmt_offset'); |
| 112 | - if ( $gmt_offset == 0 ) { |
|
| 112 | + if ($gmt_offset == 0) { |
|
| 113 | 113 | $tzstring = 'UTC'; |
| 114 | 114 | } else { |
| 115 | 115 | $gmt_offset *= HOUR_IN_SECONDS; |
| 116 | - $tzstring = timezone_name_from_abbr( '', $gmt_offset, 1 ); |
|
| 116 | + $tzstring = timezone_name_from_abbr('', $gmt_offset, 1); |
|
| 117 | 117 | |
| 118 | 118 | // If there's no timezone string, try again with no DST. |
| 119 | - if ( false === $tzstring ) { |
|
| 120 | - $tzstring = timezone_name_from_abbr( '', $gmt_offset, 0 ); |
|
| 119 | + if (false === $tzstring) { |
|
| 120 | + $tzstring = timezone_name_from_abbr('', $gmt_offset, 0); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | // Try mapping to the first abbreviation we can find. |
| 124 | - if ( false === $tzstring ) { |
|
| 125 | - $is_dst = date( 'I' ); |
|
| 126 | - foreach ( timezone_abbreviations_list() as $abbr ) { |
|
| 127 | - foreach ( $abbr as $city ) { |
|
| 128 | - if ( $city['dst'] == $is_dst && $city['offset'] == $gmt_offset ) { |
|
| 124 | + if (false === $tzstring) { |
|
| 125 | + $is_dst = date('I'); |
|
| 126 | + foreach (timezone_abbreviations_list() as $abbr) { |
|
| 127 | + foreach ($abbr as $city) { |
|
| 128 | + if ($city['dst'] == $is_dst && $city['offset'] == $gmt_offset) { |
|
| 129 | 129 | // If there's no valid timezone ID, keep looking. |
| 130 | - if ( null === $city['timezone_id'] ) { |
|
| 130 | + if (null === $city['timezone_id']) { |
|
| 131 | 131 | continue; |
| 132 | 132 | } |
| 133 | 133 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | // If we still have no valid string, then fall back to UTC. |
| 142 | - if ( false === $tzstring ) { |
|
| 142 | + if (false === $tzstring) { |
|
| 143 | 143 | $tzstring = 'UTC'; |
| 144 | 144 | } |
| 145 | 145 | } |
@@ -26,21 +26,21 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @return string The action ID |
| 28 | 28 | */ |
| 29 | - abstract public function save_action( ActionScheduler_Action $action, DateTime $scheduled_date = NULL ); |
|
| 29 | + abstract public function save_action(ActionScheduler_Action $action, DateTime $scheduled_date = NULL); |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * @param string $action_id |
| 33 | 33 | * |
| 34 | 34 | * @return ActionScheduler_Action |
| 35 | 35 | */ |
| 36 | - abstract public function fetch_action( $action_id ); |
|
| 36 | + abstract public function fetch_action($action_id); |
|
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * @param string $hook Hook name/slug. |
| 40 | 40 | * @param array $params Hook arguments. |
| 41 | 41 | * @return string ID of the next action matching the criteria. |
| 42 | 42 | */ |
| 43 | - abstract public function find_action( $hook, $params = array() ); |
|
| 43 | + abstract public function find_action($hook, $params = array()); |
|
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | 46 | * @param array $query Query parameters. |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @return array|int The IDs of or count of actions matching the query. |
| 50 | 50 | */ |
| 51 | - abstract public function query_actions( $query = array(), $query_type = 'select' ); |
|
| 51 | + abstract public function query_actions($query = array(), $query_type = 'select'); |
|
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * Get a count of all actions in the store, grouped by status |
@@ -60,19 +60,19 @@ discard block |
||
| 60 | 60 | /** |
| 61 | 61 | * @param string $action_id |
| 62 | 62 | */ |
| 63 | - abstract public function cancel_action( $action_id ); |
|
| 63 | + abstract public function cancel_action($action_id); |
|
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | 66 | * @param string $action_id |
| 67 | 67 | */ |
| 68 | - abstract public function delete_action( $action_id ); |
|
| 68 | + abstract public function delete_action($action_id); |
|
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * @param string $action_id |
| 72 | 72 | * |
| 73 | 73 | * @return DateTime The date the action is schedule to run, or the date that it ran. |
| 74 | 74 | */ |
| 75 | - abstract public function get_date( $action_id ); |
|
| 75 | + abstract public function get_date($action_id); |
|
| 76 | 76 | |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * |
| 84 | 84 | * @return ActionScheduler_ActionClaim |
| 85 | 85 | */ |
| 86 | - abstract public function stake_claim( $max_actions = 10, DateTime $before_date = null, $hooks = array(), $group = '' ); |
|
| 86 | + abstract public function stake_claim($max_actions = 10, DateTime $before_date = null, $hooks = array(), $group = ''); |
|
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * @return int |
@@ -93,53 +93,53 @@ discard block |
||
| 93 | 93 | /** |
| 94 | 94 | * @param ActionScheduler_ActionClaim $claim |
| 95 | 95 | */ |
| 96 | - abstract public function release_claim( ActionScheduler_ActionClaim $claim ); |
|
| 96 | + abstract public function release_claim(ActionScheduler_ActionClaim $claim); |
|
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | 99 | * @param string $action_id |
| 100 | 100 | */ |
| 101 | - abstract public function unclaim_action( $action_id ); |
|
| 101 | + abstract public function unclaim_action($action_id); |
|
| 102 | 102 | |
| 103 | 103 | /** |
| 104 | 104 | * @param string $action_id |
| 105 | 105 | */ |
| 106 | - abstract public function mark_failure( $action_id ); |
|
| 106 | + abstract public function mark_failure($action_id); |
|
| 107 | 107 | |
| 108 | 108 | /** |
| 109 | 109 | * @param string $action_id |
| 110 | 110 | */ |
| 111 | - abstract public function log_execution( $action_id ); |
|
| 111 | + abstract public function log_execution($action_id); |
|
| 112 | 112 | |
| 113 | 113 | /** |
| 114 | 114 | * @param string $action_id |
| 115 | 115 | */ |
| 116 | - abstract public function mark_complete( $action_id ); |
|
| 116 | + abstract public function mark_complete($action_id); |
|
| 117 | 117 | |
| 118 | 118 | /** |
| 119 | 119 | * @param string $action_id |
| 120 | 120 | * |
| 121 | 121 | * @return string |
| 122 | 122 | */ |
| 123 | - abstract public function get_status( $action_id ); |
|
| 123 | + abstract public function get_status($action_id); |
|
| 124 | 124 | |
| 125 | 125 | /** |
| 126 | 126 | * @param string $action_id |
| 127 | 127 | * @return mixed |
| 128 | 128 | */ |
| 129 | - abstract public function get_claim_id( $action_id ); |
|
| 129 | + abstract public function get_claim_id($action_id); |
|
| 130 | 130 | |
| 131 | 131 | /** |
| 132 | 132 | * @param string $claim_id |
| 133 | 133 | * @return array |
| 134 | 134 | */ |
| 135 | - abstract public function find_actions_by_claim_id( $claim_id ); |
|
| 135 | + abstract public function find_actions_by_claim_id($claim_id); |
|
| 136 | 136 | |
| 137 | 137 | /** |
| 138 | 138 | * @param string $comparison_operator |
| 139 | 139 | * @return string |
| 140 | 140 | */ |
| 141 | - protected function validate_sql_comparator( $comparison_operator ) { |
|
| 142 | - if ( in_array( $comparison_operator, array('!=', '>', '>=', '<', '<=', '=') ) ) { |
|
| 141 | + protected function validate_sql_comparator($comparison_operator) { |
|
| 142 | + if (in_array($comparison_operator, array('!=', '>', '>=', '<', '<=', '='))) { |
|
| 143 | 143 | return $comparison_operator; |
| 144 | 144 | } |
| 145 | 145 | return '='; |
@@ -152,14 +152,14 @@ discard block |
||
| 152 | 152 | * @param DateTime $scheduled_date (optional) |
| 153 | 153 | * @return string |
| 154 | 154 | */ |
| 155 | - protected function get_scheduled_date_string( ActionScheduler_Action $action, DateTime $scheduled_date = NULL ) { |
|
| 155 | + protected function get_scheduled_date_string(ActionScheduler_Action $action, DateTime $scheduled_date = NULL) { |
|
| 156 | 156 | $next = null === $scheduled_date ? $action->get_schedule()->get_date() : $scheduled_date; |
| 157 | - if ( ! $next ) { |
|
| 157 | + if (!$next) { |
|
| 158 | 158 | return '0000-00-00 00:00:00'; |
| 159 | 159 | } |
| 160 | - $next->setTimezone( new DateTimeZone( 'UTC' ) ); |
|
| 160 | + $next->setTimezone(new DateTimeZone('UTC')); |
|
| 161 | 161 | |
| 162 | - return $next->format( 'Y-m-d H:i:s' ); |
|
| 162 | + return $next->format('Y-m-d H:i:s'); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -169,14 +169,14 @@ discard block |
||
| 169 | 169 | * @param DateTime $scheduled_date (optional) |
| 170 | 170 | * @return string |
| 171 | 171 | */ |
| 172 | - protected function get_scheduled_date_string_local( ActionScheduler_Action $action, DateTime $scheduled_date = NULL ) { |
|
| 172 | + protected function get_scheduled_date_string_local(ActionScheduler_Action $action, DateTime $scheduled_date = NULL) { |
|
| 173 | 173 | $next = null === $scheduled_date ? $action->get_schedule()->get_date() : $scheduled_date; |
| 174 | - if ( ! $next ) { |
|
| 174 | + if (!$next) { |
|
| 175 | 175 | return '0000-00-00 00:00:00'; |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - ActionScheduler_TimezoneHelper::set_local_timezone( $next ); |
|
| 179 | - return $next->format( 'Y-m-d H:i:s' ); |
|
| 178 | + ActionScheduler_TimezoneHelper::set_local_timezone($next); |
|
| 179 | + return $next->format('Y-m-d H:i:s'); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -187,15 +187,15 @@ discard block |
||
| 187 | 187 | * |
| 188 | 188 | * @throws ActionScheduler_InvalidActionException When the decoded arguments are invalid. |
| 189 | 189 | */ |
| 190 | - protected function validate_args( $args, $action_id ) { |
|
| 190 | + protected function validate_args($args, $action_id) { |
|
| 191 | 191 | // Ensure we have an array of args. |
| 192 | - if ( ! is_array( $args ) ) { |
|
| 193 | - throw ActionScheduler_InvalidActionException::from_decoding_args( $action_id ); |
|
| 192 | + if (!is_array($args)) { |
|
| 193 | + throw ActionScheduler_InvalidActionException::from_decoding_args($action_id); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | // Validate JSON decoding if possible. |
| 197 | - if ( function_exists( 'json_last_error' ) && JSON_ERROR_NONE !== json_last_error() ) { |
|
| 198 | - throw ActionScheduler_InvalidActionException::from_decoding_args( $action_id, $args ); |
|
| 197 | + if (function_exists('json_last_error') && JSON_ERROR_NONE !== json_last_error()) { |
|
| 198 | + throw ActionScheduler_InvalidActionException::from_decoding_args($action_id, $args); |
|
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | 201 | |
@@ -207,9 +207,9 @@ discard block |
||
| 207 | 207 | * |
| 208 | 208 | * @throws ActionScheduler_InvalidActionException When the schedule is invalid. |
| 209 | 209 | */ |
| 210 | - protected function validate_schedule( $schedule, $action_id ) { |
|
| 211 | - if ( empty( $schedule ) || ! is_a( $schedule, 'ActionScheduler_Schedule' ) ) { |
|
| 212 | - throw ActionScheduler_InvalidActionException::from_schedule( $action_id, $schedule ); |
|
| 210 | + protected function validate_schedule($schedule, $action_id) { |
|
| 211 | + if (empty($schedule) || !is_a($schedule, 'ActionScheduler_Schedule')) { |
|
| 212 | + throw ActionScheduler_InvalidActionException::from_schedule($action_id, $schedule); |
|
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | |
@@ -222,9 +222,9 @@ discard block |
||
| 222 | 222 | * @param ActionScheduler_Action $action Action to be validated. |
| 223 | 223 | * @throws InvalidArgumentException When json encoded args is too long. |
| 224 | 224 | */ |
| 225 | - protected function validate_action( ActionScheduler_Action $action ) { |
|
| 226 | - if ( strlen( json_encode( $action->get_args() ) ) > static::$max_args_length ) { |
|
| 227 | - throw new InvalidArgumentException( sprintf( __( 'ActionScheduler_Action::$args too long. To ensure the args column can be indexed, action args should not be more than %d characters when encoded as JSON.', 'action-scheduler' ), static::$max_args_length ) ); |
|
| 225 | + protected function validate_action(ActionScheduler_Action $action) { |
|
| 226 | + if (strlen(json_encode($action->get_args())) > static::$max_args_length) { |
|
| 227 | + throw new InvalidArgumentException(sprintf(__('ActionScheduler_Action::$args too long. To ensure the args column can be indexed, action args should not be more than %d characters when encoded as JSON.', 'action-scheduler'), static::$max_args_length)); |
|
| 228 | 228 | } |
| 229 | 229 | } |
| 230 | 230 | |
@@ -237,9 +237,9 @@ discard block |
||
| 237 | 237 | * |
| 238 | 238 | * @return void |
| 239 | 239 | */ |
| 240 | - public function cancel_actions_by_hook( $hook ) { |
|
| 240 | + public function cancel_actions_by_hook($hook) { |
|
| 241 | 241 | $action_ids = true; |
| 242 | - while ( ! empty( $action_ids ) ) { |
|
| 242 | + while (!empty($action_ids)) { |
|
| 243 | 243 | $action_ids = $this->query_actions( |
| 244 | 244 | array( |
| 245 | 245 | 'hook' => $hook, |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | ) |
| 249 | 249 | ); |
| 250 | 250 | |
| 251 | - $this->bulk_cancel_actions( $action_ids ); |
|
| 251 | + $this->bulk_cancel_actions($action_ids); |
|
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | |
@@ -261,9 +261,9 @@ discard block |
||
| 261 | 261 | * |
| 262 | 262 | * @return void |
| 263 | 263 | */ |
| 264 | - public function cancel_actions_by_group( $group ) { |
|
| 264 | + public function cancel_actions_by_group($group) { |
|
| 265 | 265 | $action_ids = true; |
| 266 | - while ( ! empty( $action_ids ) ) { |
|
| 266 | + while (!empty($action_ids)) { |
|
| 267 | 267 | $action_ids = $this->query_actions( |
| 268 | 268 | array( |
| 269 | 269 | 'group' => $group, |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | ) |
| 273 | 273 | ); |
| 274 | 274 | |
| 275 | - $this->bulk_cancel_actions( $action_ids ); |
|
| 275 | + $this->bulk_cancel_actions($action_ids); |
|
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | |
@@ -285,12 +285,12 @@ discard block |
||
| 285 | 285 | * |
| 286 | 286 | * @return void |
| 287 | 287 | */ |
| 288 | - private function bulk_cancel_actions( $action_ids ) { |
|
| 289 | - foreach ( $action_ids as $action_id ) { |
|
| 290 | - $this->cancel_action( $action_id ); |
|
| 288 | + private function bulk_cancel_actions($action_ids) { |
|
| 289 | + foreach ($action_ids as $action_id) { |
|
| 290 | + $this->cancel_action($action_id); |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - do_action( 'action_scheduler_bulk_cancel_actions', $action_ids ); |
|
| 293 | + do_action('action_scheduler_bulk_cancel_actions', $action_ids); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | /** |
@@ -298,11 +298,11 @@ discard block |
||
| 298 | 298 | */ |
| 299 | 299 | public function get_status_labels() { |
| 300 | 300 | return array( |
| 301 | - self::STATUS_COMPLETE => __( 'Complete', 'action-scheduler' ), |
|
| 302 | - self::STATUS_PENDING => __( 'Pending', 'action-scheduler' ), |
|
| 303 | - self::STATUS_RUNNING => __( 'In-progress', 'action-scheduler' ), |
|
| 304 | - self::STATUS_FAILED => __( 'Failed', 'action-scheduler' ), |
|
| 305 | - self::STATUS_CANCELED => __( 'Canceled', 'action-scheduler' ), |
|
| 301 | + self::STATUS_COMPLETE => __('Complete', 'action-scheduler'), |
|
| 302 | + self::STATUS_PENDING => __('Pending', 'action-scheduler'), |
|
| 303 | + self::STATUS_RUNNING => __('In-progress', 'action-scheduler'), |
|
| 304 | + self::STATUS_FAILED => __('Failed', 'action-scheduler'), |
|
| 305 | + self::STATUS_CANCELED => __('Canceled', 'action-scheduler'), |
|
| 306 | 306 | ); |
| 307 | 307 | } |
| 308 | 308 | |
@@ -314,12 +314,12 @@ discard block |
||
| 314 | 314 | * @return string |
| 315 | 315 | */ |
| 316 | 316 | public function has_pending_actions_due() { |
| 317 | - $pending_actions = $this->query_actions( array( |
|
| 317 | + $pending_actions = $this->query_actions(array( |
|
| 318 | 318 | 'date' => as_get_datetime_object(), |
| 319 | 319 | 'status' => ActionScheduler_Store::STATUS_PENDING, |
| 320 | - ) ); |
|
| 320 | + )); |
|
| 321 | 321 | |
| 322 | - return ! empty( $pending_actions ); |
|
| 322 | + return !empty($pending_actions); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | /** |
@@ -330,14 +330,14 @@ discard block |
||
| 330 | 330 | /** |
| 331 | 331 | * Callable function to mark an action as migrated optionally overridden in derived classes. |
| 332 | 332 | */ |
| 333 | - public function mark_migrated( $action_id ) {} |
|
| 333 | + public function mark_migrated($action_id) {} |
|
| 334 | 334 | |
| 335 | 335 | /** |
| 336 | 336 | * @return ActionScheduler_Store |
| 337 | 337 | */ |
| 338 | 338 | public static function instance() { |
| 339 | - if ( empty( self::$store ) ) { |
|
| 340 | - $class = apply_filters( 'action_scheduler_store_class', self::DEFAULT_CLASS ); |
|
| 339 | + if (empty(self::$store)) { |
|
| 340 | + $class = apply_filters('action_scheduler_store_class', self::DEFAULT_CLASS); |
|
| 341 | 341 | self::$store = new $class(); |
| 342 | 342 | } |
| 343 | 343 | return self::$store; |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | /** |
| 23 | 23 | * @param DateTime $date The date & time to run the action. |
| 24 | 24 | */ |
| 25 | - public function __construct( DateTime $date ) { |
|
| 25 | + public function __construct(DateTime $date) { |
|
| 26 | 26 | $this->scheduled_date = $date; |
| 27 | 27 | } |
| 28 | 28 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @param DateTime $after |
| 40 | 40 | * @return DateTime |
| 41 | 41 | */ |
| 42 | - abstract protected function calculate_next( DateTime $after ); |
|
| 42 | + abstract protected function calculate_next(DateTime $after); |
|
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * Get the next date & time when this schedule should run after a given date & time. |
@@ -47,10 +47,10 @@ discard block |
||
| 47 | 47 | * @param DateTime $after |
| 48 | 48 | * @return DateTime|null |
| 49 | 49 | */ |
| 50 | - public function get_next( DateTime $after ) { |
|
| 50 | + public function get_next(DateTime $after) { |
|
| 51 | 51 | $after = clone $after; |
| 52 | - if ( $after > $this->scheduled_date ) { |
|
| 53 | - $after = $this->calculate_next( $after ); |
|
| 52 | + if ($after > $this->scheduled_date) { |
|
| 53 | + $after = $this->calculate_next($after); |
|
| 54 | 54 | return $after; |
| 55 | 55 | } |
| 56 | 56 | return clone $this->scheduled_date; |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | public function __wakeup() { |
| 80 | - $this->scheduled_date = as_get_datetime_object( $this->scheduled_timestamp ); |
|
| 81 | - unset( $this->scheduled_timestamp ); |
|
| 80 | + $this->scheduled_date = as_get_datetime_object($this->scheduled_timestamp); |
|
| 81 | + unset($this->scheduled_timestamp); |
|
| 82 | 82 | } |
| 83 | 83 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @return ActionScheduler_Logger |
| 12 | 12 | */ |
| 13 | 13 | public static function instance() { |
| 14 | - if ( empty(self::$logger) ) { |
|
| 14 | + if (empty(self::$logger)) { |
|
| 15 | 15 | $class = apply_filters('action_scheduler_logger_class', 'ActionScheduler_wpCommentLogger'); |
| 16 | 16 | self::$logger = new $class(); |
| 17 | 17 | } |
@@ -25,21 +25,21 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | * @return string The log entry ID |
| 27 | 27 | */ |
| 28 | - abstract public function log( $action_id, $message, DateTime $date = NULL ); |
|
| 28 | + abstract public function log($action_id, $message, DateTime $date = NULL); |
|
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * @param string $entry_id |
| 32 | 32 | * |
| 33 | 33 | * @return ActionScheduler_LogEntry |
| 34 | 34 | */ |
| 35 | - abstract public function get_entry( $entry_id ); |
|
| 35 | + abstract public function get_entry($entry_id); |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * @param string $action_id |
| 39 | 39 | * |
| 40 | 40 | * @return ActionScheduler_LogEntry[] |
| 41 | 41 | */ |
| 42 | - abstract public function get_logs( $action_id ); |
|
| 42 | + abstract public function get_logs($action_id); |
|
| 43 | 43 | |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -47,90 +47,90 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | public function init() { |
| 49 | 49 | $this->hook_stored_action(); |
| 50 | - add_action( 'action_scheduler_canceled_action', array( $this, 'log_canceled_action' ), 10, 1 ); |
|
| 51 | - add_action( 'action_scheduler_begin_execute', array( $this, 'log_started_action' ), 10, 2 ); |
|
| 52 | - add_action( 'action_scheduler_after_execute', array( $this, 'log_completed_action' ), 10, 3 ); |
|
| 53 | - add_action( 'action_scheduler_failed_execution', array( $this, 'log_failed_action' ), 10, 3 ); |
|
| 54 | - add_action( 'action_scheduler_failed_action', array( $this, 'log_timed_out_action' ), 10, 2 ); |
|
| 55 | - add_action( 'action_scheduler_unexpected_shutdown', array( $this, 'log_unexpected_shutdown' ), 10, 2 ); |
|
| 56 | - add_action( 'action_scheduler_reset_action', array( $this, 'log_reset_action' ), 10, 1 ); |
|
| 57 | - add_action( 'action_scheduler_execution_ignored', array( $this, 'log_ignored_action' ), 10, 2 ); |
|
| 58 | - add_action( 'action_scheduler_failed_fetch_action', array( $this, 'log_failed_fetch_action' ), 10, 2 ); |
|
| 59 | - add_action( 'action_scheduler_failed_to_schedule_next_instance', array( $this, 'log_failed_schedule_next_instance' ), 10, 2 ); |
|
| 60 | - add_action( 'action_scheduler_bulk_cancel_actions', array( $this, 'bulk_log_cancel_actions' ), 10, 1 ); |
|
| 50 | + add_action('action_scheduler_canceled_action', array($this, 'log_canceled_action'), 10, 1); |
|
| 51 | + add_action('action_scheduler_begin_execute', array($this, 'log_started_action'), 10, 2); |
|
| 52 | + add_action('action_scheduler_after_execute', array($this, 'log_completed_action'), 10, 3); |
|
| 53 | + add_action('action_scheduler_failed_execution', array($this, 'log_failed_action'), 10, 3); |
|
| 54 | + add_action('action_scheduler_failed_action', array($this, 'log_timed_out_action'), 10, 2); |
|
| 55 | + add_action('action_scheduler_unexpected_shutdown', array($this, 'log_unexpected_shutdown'), 10, 2); |
|
| 56 | + add_action('action_scheduler_reset_action', array($this, 'log_reset_action'), 10, 1); |
|
| 57 | + add_action('action_scheduler_execution_ignored', array($this, 'log_ignored_action'), 10, 2); |
|
| 58 | + add_action('action_scheduler_failed_fetch_action', array($this, 'log_failed_fetch_action'), 10, 2); |
|
| 59 | + add_action('action_scheduler_failed_to_schedule_next_instance', array($this, 'log_failed_schedule_next_instance'), 10, 2); |
|
| 60 | + add_action('action_scheduler_bulk_cancel_actions', array($this, 'bulk_log_cancel_actions'), 10, 1); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | public function hook_stored_action() { |
| 64 | - add_action( 'action_scheduler_stored_action', array( $this, 'log_stored_action' ) ); |
|
| 64 | + add_action('action_scheduler_stored_action', array($this, 'log_stored_action')); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | public function unhook_stored_action() { |
| 68 | - remove_action( 'action_scheduler_stored_action', array( $this, 'log_stored_action' ) ); |
|
| 68 | + remove_action('action_scheduler_stored_action', array($this, 'log_stored_action')); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - public function log_stored_action( $action_id ) { |
|
| 72 | - $this->log( $action_id, __( 'action created', 'action-scheduler' ) ); |
|
| 71 | + public function log_stored_action($action_id) { |
|
| 72 | + $this->log($action_id, __('action created', 'action-scheduler')); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - public function log_canceled_action( $action_id ) { |
|
| 76 | - $this->log( $action_id, __( 'action canceled', 'action-scheduler' ) ); |
|
| 75 | + public function log_canceled_action($action_id) { |
|
| 76 | + $this->log($action_id, __('action canceled', 'action-scheduler')); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - public function log_started_action( $action_id, $context = '' ) { |
|
| 80 | - if ( ! empty( $context ) ) { |
|
| 79 | + public function log_started_action($action_id, $context = '') { |
|
| 80 | + if (!empty($context)) { |
|
| 81 | 81 | /* translators: %s: context */ |
| 82 | - $message = sprintf( __( 'action started via %s', 'action-scheduler' ), $context ); |
|
| 82 | + $message = sprintf(__('action started via %s', 'action-scheduler'), $context); |
|
| 83 | 83 | } else { |
| 84 | - $message = __( 'action started', 'action-scheduler' ); |
|
| 84 | + $message = __('action started', 'action-scheduler'); |
|
| 85 | 85 | } |
| 86 | - $this->log( $action_id, $message ); |
|
| 86 | + $this->log($action_id, $message); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - public function log_completed_action( $action_id, $action = NULL, $context = '' ) { |
|
| 90 | - if ( ! empty( $context ) ) { |
|
| 89 | + public function log_completed_action($action_id, $action = NULL, $context = '') { |
|
| 90 | + if (!empty($context)) { |
|
| 91 | 91 | /* translators: %s: context */ |
| 92 | - $message = sprintf( __( 'action complete via %s', 'action-scheduler' ), $context ); |
|
| 92 | + $message = sprintf(__('action complete via %s', 'action-scheduler'), $context); |
|
| 93 | 93 | } else { |
| 94 | - $message = __( 'action complete', 'action-scheduler' ); |
|
| 94 | + $message = __('action complete', 'action-scheduler'); |
|
| 95 | 95 | } |
| 96 | - $this->log( $action_id, $message ); |
|
| 96 | + $this->log($action_id, $message); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - public function log_failed_action( $action_id, Exception $exception, $context = '' ) { |
|
| 100 | - if ( ! empty( $context ) ) { |
|
| 99 | + public function log_failed_action($action_id, Exception $exception, $context = '') { |
|
| 100 | + if (!empty($context)) { |
|
| 101 | 101 | /* translators: 1: context 2: exception message */ |
| 102 | - $message = sprintf( __( 'action failed via %1$s: %2$s', 'action-scheduler' ), $context, $exception->getMessage() ); |
|
| 102 | + $message = sprintf(__('action failed via %1$s: %2$s', 'action-scheduler'), $context, $exception->getMessage()); |
|
| 103 | 103 | } else { |
| 104 | 104 | /* translators: %s: exception message */ |
| 105 | - $message = sprintf( __( 'action failed: %s', 'action-scheduler' ), $exception->getMessage() ); |
|
| 105 | + $message = sprintf(__('action failed: %s', 'action-scheduler'), $exception->getMessage()); |
|
| 106 | 106 | } |
| 107 | - $this->log( $action_id, $message ); |
|
| 107 | + $this->log($action_id, $message); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - public function log_timed_out_action( $action_id, $timeout ) { |
|
| 110 | + public function log_timed_out_action($action_id, $timeout) { |
|
| 111 | 111 | /* translators: %s: amount of time */ |
| 112 | - $this->log( $action_id, sprintf( __( 'action timed out after %s seconds', 'action-scheduler' ), $timeout ) ); |
|
| 112 | + $this->log($action_id, sprintf(__('action timed out after %s seconds', 'action-scheduler'), $timeout)); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - public function log_unexpected_shutdown( $action_id, $error ) { |
|
| 116 | - if ( ! empty( $error ) ) { |
|
| 115 | + public function log_unexpected_shutdown($action_id, $error) { |
|
| 116 | + if (!empty($error)) { |
|
| 117 | 117 | /* translators: 1: error message 2: filename 3: line */ |
| 118 | - $this->log( $action_id, sprintf( __( 'unexpected shutdown: PHP Fatal error %1$s in %2$s on line %3$s', 'action-scheduler' ), $error['message'], $error['file'], $error['line'] ) ); |
|
| 118 | + $this->log($action_id, sprintf(__('unexpected shutdown: PHP Fatal error %1$s in %2$s on line %3$s', 'action-scheduler'), $error['message'], $error['file'], $error['line'])); |
|
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - public function log_reset_action( $action_id ) { |
|
| 123 | - $this->log( $action_id, __( 'action reset', 'action-scheduler' ) ); |
|
| 122 | + public function log_reset_action($action_id) { |
|
| 123 | + $this->log($action_id, __('action reset', 'action-scheduler')); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - public function log_ignored_action( $action_id, $context = '' ) { |
|
| 127 | - if ( ! empty( $context ) ) { |
|
| 126 | + public function log_ignored_action($action_id, $context = '') { |
|
| 127 | + if (!empty($context)) { |
|
| 128 | 128 | /* translators: %s: context */ |
| 129 | - $message = sprintf( __( 'action ignored via %s', 'action-scheduler' ), $context ); |
|
| 129 | + $message = sprintf(__('action ignored via %s', 'action-scheduler'), $context); |
|
| 130 | 130 | } else { |
| 131 | - $message = __( 'action ignored', 'action-scheduler' ); |
|
| 131 | + $message = __('action ignored', 'action-scheduler'); |
|
| 132 | 132 | } |
| 133 | - $this->log( $action_id, $message ); |
|
| 133 | + $this->log($action_id, $message); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -139,21 +139,21 @@ discard block |
||
| 139 | 139 | * |
| 140 | 140 | * @return ActionScheduler_LogEntry[] |
| 141 | 141 | */ |
| 142 | - public function log_failed_fetch_action( $action_id, Exception $exception = NULL ) { |
|
| 142 | + public function log_failed_fetch_action($action_id, Exception $exception = NULL) { |
|
| 143 | 143 | |
| 144 | - if ( ! is_null( $exception ) ) { |
|
| 144 | + if (!is_null($exception)) { |
|
| 145 | 145 | /* translators: %s: exception message */ |
| 146 | - $log_message = sprintf( __( 'There was a failure fetching this action: %s', 'action-scheduler' ), $exception->getMessage() ); |
|
| 146 | + $log_message = sprintf(__('There was a failure fetching this action: %s', 'action-scheduler'), $exception->getMessage()); |
|
| 147 | 147 | } else { |
| 148 | - $log_message = __( 'There was a failure fetching this action', 'action-scheduler' ); |
|
| 148 | + $log_message = __('There was a failure fetching this action', 'action-scheduler'); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - $this->log( $action_id, $log_message ); |
|
| 151 | + $this->log($action_id, $log_message); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - public function log_failed_schedule_next_instance( $action_id, Exception $exception ) { |
|
| 154 | + public function log_failed_schedule_next_instance($action_id, Exception $exception) { |
|
| 155 | 155 | /* translators: %s: exception message */ |
| 156 | - $this->log( $action_id, sprintf( __( 'There was a failure scheduling the next instance of this action: %s', 'action-scheduler' ), $exception->getMessage() ) ); |
|
| 156 | + $this->log($action_id, sprintf(__('There was a failure scheduling the next instance of this action: %s', 'action-scheduler'), $exception->getMessage())); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -164,13 +164,13 @@ discard block |
||
| 164 | 164 | * |
| 165 | 165 | * @param array $action_ids List of action ID. |
| 166 | 166 | */ |
| 167 | - public function bulk_log_cancel_actions( $action_ids ) { |
|
| 168 | - if ( empty( $action_ids ) ) { |
|
| 167 | + public function bulk_log_cancel_actions($action_ids) { |
|
| 168 | + if (empty($action_ids)) { |
|
| 169 | 169 | return; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - foreach ( $action_ids as $action_id ) { |
|
| 173 | - $this->log_canceled_action( $action_id ); |
|
| 172 | + foreach ($action_ids as $action_id) { |
|
| 173 | + $this->log_canceled_action($action_id); |
|
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | 176 | } |
@@ -19,8 +19,8 @@ discard block |
||
| 19 | 19 | * @param string $lock_type A string to identify different lock types. |
| 20 | 20 | * @return bool |
| 21 | 21 | */ |
| 22 | - public function is_locked( $lock_type ) { |
|
| 23 | - return ( $this->get_expiration( $lock_type ) >= time() ); |
|
| 22 | + public function is_locked($lock_type) { |
|
| 23 | + return ($this->get_expiration($lock_type) >= time()); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @param string $lock_type A string to identify different lock types. |
| 30 | 30 | * @return bool |
| 31 | 31 | */ |
| 32 | - abstract public function set( $lock_type ); |
|
| 32 | + abstract public function set($lock_type); |
|
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * If a lock is set, return the timestamp it was set to expiry. |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @param string $lock_type A string to identify different lock types. |
| 38 | 38 | * @return bool|int False if no lock is set, otherwise the timestamp for when the lock is set to expire. |
| 39 | 39 | */ |
| 40 | - abstract public function get_expiration( $lock_type ); |
|
| 40 | + abstract public function get_expiration($lock_type); |
|
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * Get the amount of time to set for a given lock. 60 seconds by default. |
@@ -45,16 +45,16 @@ discard block |
||
| 45 | 45 | * @param string $lock_type A string to identify different lock types. |
| 46 | 46 | * @return int |
| 47 | 47 | */ |
| 48 | - protected function get_duration( $lock_type ) { |
|
| 49 | - return apply_filters( 'action_scheduler_lock_duration', self::$lock_duration, $lock_type ); |
|
| 48 | + protected function get_duration($lock_type) { |
|
| 49 | + return apply_filters('action_scheduler_lock_duration', self::$lock_duration, $lock_type); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * @return ActionScheduler_Lock |
| 54 | 54 | */ |
| 55 | 55 | public static function instance() { |
| 56 | - if ( empty( self::$locker ) ) { |
|
| 57 | - $class = apply_filters( 'action_scheduler_lock_class', 'ActionScheduler_OptionLock' ); |
|
| 56 | + if (empty(self::$locker)) { |
|
| 57 | + $class = apply_filters('action_scheduler_lock_class', 'ActionScheduler_OptionLock'); |
|
| 58 | 58 | self::$locker = new $class(); |
| 59 | 59 | } |
| 60 | 60 | return self::$locker; |