diff --git a/classes/ActionScheduler_AdminView.php b/classes/ActionScheduler_AdminView.php index 9d851cff1..e0ed08a26 100644 --- a/classes/ActionScheduler_AdminView.php +++ b/classes/ActionScheduler_AdminView.php @@ -35,7 +35,7 @@ public static function instance() { * @codeCoverageIgnore */ public function init() { - if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || false == DOING_AJAX ) ) { + if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || false === DOING_AJAX ) ) { if ( class_exists( 'WooCommerce' ) ) { add_action( 'woocommerce_admin_status_content_action-scheduler', array( $this, 'render_admin_ui' ) ); @@ -200,13 +200,19 @@ protected function check_pastdue_actions() { echo '
'; printf( // translators: 1) is the number of affected actions, 2) is a link to an admin screen. - _n( - 'Action Scheduler: %1$d past-due action found; something may be wrong. Read documentation »', - 'Action Scheduler: %1$d past-due actions found; something may be wrong. Read documentation »', - $num_pastdue_actions, - 'action-scheduler' + wp_kses( + _n( + 'Action Scheduler: %1$d past-due action found; something may be wrong. Read documentation »', + 'Action Scheduler: %1$d past-due actions found; something may be wrong. Read documentation »', + $num_pastdue_actions, + 'action-scheduler' + ), + array( + 'strong' => array(), + 'a' => array( 'href', 'target' ), + ) ), - $num_pastdue_actions, + absint( $num_pastdue_actions ), esc_attr( esc_url( $actions_url ) ) ); echo '
' . $action->get_hook() . '
';
- if ( 1 == $notification['success'] ) {
+ if ( 1 === absint( $notification['success'] ) ) {
$class = 'updated';
switch ( $notification['row_action_type'] ) {
case 'run' :
diff --git a/classes/ActionScheduler_LogEntry.php b/classes/ActionScheduler_LogEntry.php
index 10cedf546..e1be1d74d 100644
--- a/classes/ActionScheduler_LogEntry.php
+++ b/classes/ActionScheduler_LogEntry.php
@@ -8,12 +8,12 @@ class ActionScheduler_LogEntry {
/**
* @var int $action_id
*/
- protected $action_id = '';
+ protected $action_id = '';
/**
* @var string $message
*/
- protected $message = '';
+ protected $message = '';
/**
* @var Datetime $date
@@ -43,7 +43,7 @@ public function __construct( $action_id, $message, $date = null ) {
$this->action_id = $action_id;
$this->message = $message;
- $this->date = $date ? $date : new Datetime;
+ $this->date = $date ? $date : new Datetime();
}
/**
diff --git a/classes/ActionScheduler_QueueCleaner.php b/classes/ActionScheduler_QueueCleaner.php
index a8f27ce57..9fdf5bee8 100644
--- a/classes/ActionScheduler_QueueCleaner.php
+++ b/classes/ActionScheduler_QueueCleaner.php
@@ -86,8 +86,8 @@ public function delete_old_actions() {
* @return array Actions deleted.
*/
public function clean_actions( array $statuses_to_purge, DateTime $cutoff_date, $batch_size = null, $context = 'old' ) {
- $batch_size = $batch_size !== null ? $batch_size : $this->batch_size;
- $cutoff = $cutoff_date !== null ? $cutoff_date : as_get_datetime_object( $this->month_in_seconds . ' seconds ago' );
+ $batch_size = ! is_null( $batch_size ) ? $batch_size : $this->batch_size;
+ $cutoff = ! is_null( $cutoff_date ) ? $cutoff_date : as_get_datetime_object( $this->month_in_seconds . ' seconds ago' );
$lifespan = time() - $cutoff->getTimestamp();
if ( empty( $statuses_to_purge ) ) {
$statuses_to_purge = $this->default_statuses_to_purge;
@@ -119,7 +119,7 @@ public function clean_actions( array $statuses_to_purge, DateTime $cutoff_date,
*/
private function delete_actions( array $actions_to_delete, $lifespan = null, $context = 'old' ) {
$deleted_actions = [];
- if ( $lifespan === null ) {
+ if ( is_null( $lifespan ) ) {
$lifespan = $this->month_in_seconds;
}
@@ -209,7 +209,6 @@ public function mark_failures( $time_limit = 300 ) {
* Do all of the cleaning actions.
*
* @param int $time_limit The number of seconds to use as the timeout and failure period. Default 300 (5 minutes).
- * @author Jeremy Pry
*/
public function clean( $time_limit = 300 ) {
$this->delete_old_actions();
@@ -220,7 +219,6 @@ public function clean( $time_limit = 300 ) {
/**
* Get the batch size for cleaning the queue.
*
- * @author Jeremy Pry
* @return int
*/
protected function get_batch_size() {
diff --git a/classes/ActionScheduler_QueueRunner.php b/classes/ActionScheduler_QueueRunner.php
index 2e60f7fe1..ed7491ce5 100644
--- a/classes/ActionScheduler_QueueRunner.php
+++ b/classes/ActionScheduler_QueueRunner.php
@@ -52,6 +52,7 @@ public function __construct( ActionScheduler_Store $store = null, ActionSchedule
*/
public function init() {
+ // phpcs:ignore WordPress.WP.CronInterval.CronSchedulesInterval
add_filter( 'cron_schedules', array( self::instance(), 'add_wp_cron_schedule' ) );
// Check for and remove any WP Cron hook scheduled by Action Scheduler < 3.0.0, which didn't include the $context param.
@@ -163,8 +164,8 @@ protected function do_batch( $size = 100, $context = '' ) {
$processed_actions = 0;
foreach ( $claim->get_actions() as $action_id ) {
- // bail if we lost the claim.
- if ( ! in_array( $action_id, $this->store->find_actions_by_claim_id( $claim->get_id() ) ) ) {
+ // bail if we lost the claim
+ if ( ! in_array( $action_id, $this->store->find_actions_by_claim_id( $claim->get_id() ), true ) ) {
break;
}
$this->process_action( $action_id, $context );
diff --git a/classes/ActionScheduler_Versions.php b/classes/ActionScheduler_Versions.php
index 98c1b1acc..27f84020a 100644
--- a/classes/ActionScheduler_Versions.php
+++ b/classes/ActionScheduler_Versions.php
@@ -19,10 +19,10 @@ class ActionScheduler_Versions {
* @param callable $initialization_callback Callback to initialize the version.
*/
public function register( $version_string, $initialization_callback ) {
- if ( isset($this->versions[$version_string]) ) {
+ if ( isset($this->versions[ $version_string ]) ) {
return FALSE;
}
- $this->versions[$version_string] = $initialization_callback;
+ $this->versions[ $version_string ] = $initialization_callback;
return TRUE;
}
@@ -50,10 +50,10 @@ public function latest_version() {
*/
public function latest_version_callback() {
$latest = $this->latest_version();
- if ( empty($latest) || !isset($this->versions[$latest]) ) {
+ if ( empty($latest) || ! isset($this->versions[ $latest ]) ) {
return '__return_null';
}
- return $this->versions[$latest];
+ return $this->versions[ $latest ];
}
/**
diff --git a/classes/ActionScheduler_WPCommentCleaner.php b/classes/ActionScheduler_WPCommentCleaner.php
index 9e2b0f87c..6fccf6e71 100644
--- a/classes/ActionScheduler_WPCommentCleaner.php
+++ b/classes/ActionScheduler_WPCommentCleaner.php
@@ -66,7 +66,11 @@ public static function has_logs() {
* Attached to the migration complete hook 'action_scheduler/migration_complete'.
*/
public static function maybe_schedule_cleanup() {
- if ( (bool) get_comments( array( 'type' => ActionScheduler_wpCommentLogger::TYPE, 'number' => 1, 'fields' => 'ids' ) ) ) {
+ if ( (bool) get_comments( array(
+ 'type' => ActionScheduler_wpCommentLogger::TYPE,
+ 'number' => 1,
+ 'fields' => 'ids',
+ ) ) ) {
update_option( self::$has_logs_option_key, 'yes' );
if ( ! as_next_scheduled_action( self::$cleanup_hook ) ) {
@@ -80,7 +84,10 @@ public static function maybe_schedule_cleanup() {
*/
public static function delete_all_action_comments() {
global $wpdb;
- $wpdb->delete( $wpdb->comments, array( 'comment_type' => ActionScheduler_wpCommentLogger::TYPE, 'comment_agent' => ActionScheduler_wpCommentLogger::AGENT ) );
+ $wpdb->delete( $wpdb->comments, array(
+ 'comment_type' => ActionScheduler_wpCommentLogger::TYPE,
+ 'comment_agent' => ActionScheduler_wpCommentLogger::AGENT,
+ ) );
delete_option( self::$has_logs_option_key );
}
diff --git a/classes/WP_CLI/ActionScheduler_WPCLI_Clean_Command.php b/classes/WP_CLI/ActionScheduler_WPCLI_Clean_Command.php
index fea2ffc98..9284d3de3 100644
--- a/classes/WP_CLI/ActionScheduler_WPCLI_Clean_Command.php
+++ b/classes/WP_CLI/ActionScheduler_WPCLI_Clean_Command.php
@@ -41,7 +41,7 @@ public function clean( $args, $assoc_args ) {
$batches_completed = 0;
$actions_deleted = 0;
- $unlimited = $batches === 0;
+ $unlimited = 0 === $batches;
try {
$lifespan = as_get_datetime_object( $before );
} catch ( Exception $e ) {
diff --git a/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php b/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php
index 4c5d9c2d6..68e5fdf98 100644
--- a/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php
+++ b/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php
@@ -39,8 +39,6 @@ public function __construct( ActionScheduler_Store $store = null, ActionSchedule
/**
* Set up the Queue before processing.
*
- * @author Jeremy Pry
- *
* @param int $batch_size The batch size to process.
* @param array $hooks The hooks being used to filter the actions claimed in this batch.
* @param string $group The group of actions to claim with this batch.
@@ -72,8 +70,6 @@ public function setup( $batch_size, $hooks = array(), $group = '', $force = fals
/**
* Add our hooks to the appropriate actions.
- *
- * @author Jeremy Pry
*/
protected function add_hooks() {
add_action( 'action_scheduler_before_execute', array( $this, 'before_execute' ) );
@@ -83,8 +79,6 @@ protected function add_hooks() {
/**
* Set up the WP CLI progress bar.
- *
- * @author Jeremy Pry
*/
protected function setup_progress_bar() {
$count = count( $this->actions );
@@ -98,8 +92,6 @@ protected function setup_progress_bar() {
/**
* Process actions in the queue.
*
- * @author Jeremy Pry
- *
* @param string $context Optional runner context. Default 'WP CLI'.
*
* @return int The number of actions processed.
@@ -109,7 +101,7 @@ public function run( $context = 'WP CLI' ) {
$this->setup_progress_bar();
foreach ( $this->actions as $action_id ) {
// Error if we lost the claim.
- if ( ! in_array( $action_id, $this->store->find_actions_by_claim_id( $this->claim->get_id() ) ) ) {
+ if ( ! in_array( $action_id, $this->store->find_actions_by_claim_id( $this->claim->get_id() ), true ) ) {
WP_CLI::warning( __( 'The claim has been lost. Aborting current batch.', 'action-scheduler' ) );
break;
}
@@ -129,8 +121,6 @@ public function run( $context = 'WP CLI' ) {
/**
* Handle WP CLI message when the action is starting.
*
- * @author Jeremy Pry
- *
* @param int $action_id Action ID.
*/
public function before_execute( $action_id ) {
@@ -141,8 +131,6 @@ public function before_execute( $action_id ) {
/**
* Handle WP CLI message when the action has completed.
*
- * @author Jeremy Pry
- *
* @param int $action_id ActionID.
* @param null|ActionScheduler_Action $action The instance of the action. Default to null for backward compatibility.
*/
@@ -158,8 +146,6 @@ public function after_execute( $action_id, $action = null ) {
/**
* Handle WP CLI message when the action has failed.
*
- * @author Jeremy Pry
- *
* @param int $action_id Action ID.
* @param Exception $exception Exception.
* @throws \WP_CLI\ExitException With failure message.
diff --git a/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php b/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php
index c8eb3bf16..d52f1b7cc 100644
--- a/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php
+++ b/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php
@@ -91,7 +91,7 @@ public function run( $args, $assoc_args ) {
$batches_completed = 0;
$actions_completed = 0;
- $unlimited = $batches === 0;
+ $unlimited = 0 === $batches;
if ( is_callable( [ ActionScheduler::store(), 'set_claim_filter' ] ) ) {
$exclude_groups = $this->parse_comma_separated_string( $exclude_groups );
@@ -141,8 +141,6 @@ private function parse_comma_separated_string( $string ): array {
/**
* Print WP CLI message about how many actions are about to be processed.
*
- * @author Jeremy Pry
- *
* @param int $total Number of actions found.
*/
protected function print_total_actions( $total ) {
@@ -158,8 +156,6 @@ protected function print_total_actions( $total ) {
/**
* Print WP CLI message about how many batches of actions were processed.
*
- * @author Jeremy Pry
- *
* @param int $batches_completed Number of completed batches.
*/
protected function print_total_batches( $batches_completed ) {
@@ -175,8 +171,6 @@ protected function print_total_batches( $batches_completed ) {
/**
* Convert an exception into a WP CLI error.
*
- * @author Jeremy Pry
- *
* @param Exception $e The error object.
*
* @throws \WP_CLI\ExitException
@@ -194,8 +188,6 @@ protected function print_error( Exception $e ) {
/**
* Print a success message with the number of completed actions.
*
- * @author Jeremy Pry
- *
* @param int $actions_completed Number of completed actions.
*/
protected function print_success( $actions_completed ) {
diff --git a/classes/WP_CLI/Migration_Command.php b/classes/WP_CLI/Migration_Command.php
index 289f2f42e..d63bf5aba 100644
--- a/classes/WP_CLI/Migration_Command.php
+++ b/classes/WP_CLI/Migration_Command.php
@@ -81,9 +81,9 @@ public function migrate( $positional_args, $assoc_args ) {
$runner = new Runner( $config );
$runner->init_destination();
- $batch_size = isset( $assoc_args[ 'batch-size' ] ) ? (int) $assoc_args[ 'batch-size' ] : 100;
- $free_on = isset( $assoc_args[ 'free-memory-on' ] ) ? (int) $assoc_args[ 'free-memory-on' ] : 50;
- $sleep = isset( $assoc_args[ 'pause' ] ) ? (int) $assoc_args[ 'pause' ] : 0;
+ $batch_size = isset( $assoc_args['batch-size'] ) ? (int) $assoc_args['batch-size'] : 100;
+ $free_on = isset( $assoc_args['free-memory-on'] ) ? (int) $assoc_args['free-memory-on'] : 50;
+ $sleep = isset( $assoc_args['pause'] ) ? (int) $assoc_args['pause'] : 0;
\ActionScheduler_DataController::set_free_ticks( $free_on );
\ActionScheduler_DataController::set_sleep_time( $sleep );
@@ -114,7 +114,7 @@ private function get_migration_config( $args ) {
] );
$config = Controller::instance()->get_migration_config_object();
- $config->set_dry_run( ! empty( $args[ 'dry-run' ] ) );
+ $config->set_dry_run( ! empty( $args['dry-run'] ) );
return $config;
}
@@ -139,6 +139,7 @@ private function init_logging() {
WP_CLI::debug( sprintf( 'Migrated source action with ID %d to new store with ID %d', $source_id, $destination_id ) );
}, 10, 2 );
add_action( 'action_scheduler/migration_batch_starting', function ( $batch ) {
+ // phpcs:ignore WordPress.PHP.DevelopmentFunctions
WP_CLI::debug( 'Beginning migration of batch: ' . print_r( $batch, true ) );
}, 10, 1 );
add_action( 'action_scheduler/migration_batch_complete', function ( $batch ) {
diff --git a/classes/abstracts/ActionScheduler.php b/classes/abstracts/ActionScheduler.php
index 4b747b366..fc7c627a6 100644
--- a/classes/abstracts/ActionScheduler.php
+++ b/classes/abstracts/ActionScheduler.php
@@ -19,7 +19,7 @@ abstract class ActionScheduler {
* Factory.
*/
public static function factory() {
- if ( !isset(self::$factory) ) {
+ if ( ! isset(self::$factory) ) {
self::$factory = new ActionScheduler_ActionFactory();
}
return self::$factory;
@@ -115,7 +115,7 @@ public static function autoload( $class ) {
$dir = $classes_dir . 'schema' . $d;
} elseif ( strpos( $class, 'ActionScheduler' ) === 0 ) {
$segments = explode( '_', $class );
- $type = isset( $segments[ 1 ] ) ? $segments[ 1 ] : '';
+ $type = isset( $segments[1] ) ? $segments[1] : '';
switch ( $type ) {
case 'WPCLI':
@@ -251,7 +251,7 @@ public static function is_initialized( $function_name = null ) {
__( '%s() was called before the Action Scheduler data store was initialized', 'action-scheduler' ),
esc_attr( $function_name )
);
- _doing_it_wrong( $function_name, $message, '3.1.6' );
+ _doing_it_wrong( esc_html( $function_name ), esc_html( $message ), '3.1.6' );
}
return self::$data_store_initialized;
@@ -306,7 +306,7 @@ protected static function is_class_migration( $class ) {
);
$segments = explode( '_', $class );
- $segment = isset( $segments[ 1 ] ) ? $segments[ 1 ] : $class;
+ $segment = isset( $segments[1] ) ? $segments[1] : $class;
return isset( $migration_segments[ $segment ] ) && $migration_segments[ $segment ];
}
@@ -328,7 +328,7 @@ protected static function is_class_cli( $class ) {
);
$segments = explode( '_', $class );
- $segment = isset( $segments[ 1 ] ) ? $segments[ 1 ] : $class;
+ $segment = isset( $segments[1] ) ? $segments[1] : $class;
return isset( $cli_segments[ $segment ] ) && $cli_segments[ $segment ];
}
diff --git a/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php b/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php
index f3526badd..30b25d6a5 100644
--- a/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php
+++ b/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php
@@ -50,6 +50,7 @@ public function __construct( ActionScheduler_Store $store = null, ActionSchedule
*/
public function process_action( $action_id, $context = '' ) {
// Temporarily override the error handler while we process the current action.
+ // phpcs:ignore WordPress.PHP.DevelopmentFunctions
set_error_handler(
/**
* Temporary error handler which can catch errors and convert them into exceptions. This facilitates more
@@ -193,7 +194,7 @@ private function recurring_action_is_consistently_failing( ActionScheduler_Actio
'date' => date_create( 'now', timezone_open( 'UTC' ) )->format( 'Y-m-d H:i:s' ),
'date_compare' => '<',
'per_page' => 1,
- 'offset' => $consistent_failure_threshold - 1
+ 'offset' => $consistent_failure_threshold - 1,
);
$first_failing_action_id = $this->store->query_actions( $query_args );
@@ -223,8 +224,6 @@ private function recurring_action_is_consistently_failing( ActionScheduler_Actio
/**
* Run the queue cleaner.
- *
- * @author Jeremy Pry
*/
protected function run_cleanup() {
$this->cleaner->clean( 10 * $this->get_time_limit() );
@@ -364,7 +363,6 @@ protected function batch_limits_exceeded( $processed_actions ) {
/**
* Process actions in the queue.
*
- * @author Jeremy Pry
* @param string $context Optional identifier for the context in which this action is being processed, e.g. 'WP CLI' or 'WP Cron'
* Generally, this should be capitalised and not localised as it's a proper noun.
* @return int The number of actions processed.
diff --git a/classes/abstracts/ActionScheduler_Abstract_RecurringSchedule.php b/classes/abstracts/ActionScheduler_Abstract_RecurringSchedule.php
index 8b32219d1..841dcfedd 100644
--- a/classes/abstracts/ActionScheduler_Abstract_RecurringSchedule.php
+++ b/classes/abstracts/ActionScheduler_Abstract_RecurringSchedule.php
@@ -77,7 +77,7 @@ public function __sleep() {
$this->first_timestamp = $this->first_date->getTimestamp();
return array_merge( $sleep_params, array(
'first_timestamp',
- 'recurrence'
+ 'recurrence',
) );
}
diff --git a/classes/abstracts/ActionScheduler_Store.php b/classes/abstracts/ActionScheduler_Store.php
index bec673c5e..bac91bacd 100644
--- a/classes/abstracts/ActionScheduler_Store.php
+++ b/classes/abstracts/ActionScheduler_Store.php
@@ -270,7 +270,7 @@ abstract public function find_actions_by_claim_id( $claim_id );
* @return string
*/
protected function validate_sql_comparator( $comparison_operator ) {
- if ( in_array( $comparison_operator, array('!=', '>', '>=', '<', '<=', '=') ) ) {
+ if ( in_array( $comparison_operator, array( '!=', '>', '>=', '<', '<=', '=' ), true ) ) {
return $comparison_operator;
}
return '=';
diff --git a/classes/abstracts/ActionScheduler_TimezoneHelper.php b/classes/abstracts/ActionScheduler_TimezoneHelper.php
index f064656ee..9b1da0c21 100644
--- a/classes/abstracts/ActionScheduler_TimezoneHelper.php
+++ b/classes/abstracts/ActionScheduler_TimezoneHelper.php
@@ -110,12 +110,12 @@ public static function get_local_timezone( $reset = FALSE ) {
if ( $reset ) {
self::$local_timezone = NULL;
}
- if ( !isset(self::$local_timezone) ) {
+ if ( ! isset(self::$local_timezone) ) {
$tzstring = get_option('timezone_string');
if ( empty($tzstring) ) {
- $gmt_offset = get_option('gmt_offset');
- if ( $gmt_offset == 0 ) {
+ $gmt_offset = absint( get_option('gmt_offset') );
+ if ( 0 === $gmt_offset ) {
$tzstring = 'UTC';
} else {
$gmt_offset *= HOUR_IN_SECONDS;
@@ -131,7 +131,7 @@ public static function get_local_timezone( $reset = FALSE ) {
$is_dst = date( 'I' ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date -- we are actually interested in the runtime timezone.
foreach ( timezone_abbreviations_list() as $abbr ) {
foreach ( $abbr as $city ) {
- if ( $city['dst'] == $is_dst && $city['offset'] == $gmt_offset ) {
+ if ( absint( $city['dst'] ) === $is_dst && absint( $city['offset'] ) === $gmt_offset ) {
// If there's no valid timezone ID, keep looking.
if ( null === $city['timezone_id'] ) {
continue;
diff --git a/classes/data-stores/ActionScheduler_DBStore.php b/classes/data-stores/ActionScheduler_DBStore.php
index 3554d2c9e..a97129e40 100644
--- a/classes/data-stores/ActionScheduler_DBStore.php
+++ b/classes/data-stores/ActionScheduler_DBStore.php
@@ -222,7 +222,7 @@ private function get_placeholder_for_column( $column_name ) {
'extended_args',
);
- return in_array( $column_name, $string_columns ) ? '%s' : '%d';
+ return in_array( $column_name, $string_columns, true ) ? '%s' : '%d';
}
/**
@@ -412,7 +412,7 @@ protected function get_query_actions_sql( array $query, $select_or_count = 'sele
'offset' => 0,
'orderby' => 'date',
'order' => 'ASC',
- ) );
+ ) );
/** @var \wpdb $wpdb */
global $wpdb;
diff --git a/classes/data-stores/ActionScheduler_wpCommentLogger.php b/classes/data-stores/ActionScheduler_wpCommentLogger.php
index 063bdb5fc..0408b784a 100644
--- a/classes/data-stores/ActionScheduler_wpCommentLogger.php
+++ b/classes/data-stores/ActionScheduler_wpCommentLogger.php
@@ -38,13 +38,13 @@ protected function create_wp_comment( $action_id, $message, DateTime $date ) {
$comment_date_gmt = $date->format('Y-m-d H:i:s');
ActionScheduler_TimezoneHelper::set_local_timezone( $date );
$comment_data = array(
- 'comment_post_ID' => $action_id,
- 'comment_date' => $date->format('Y-m-d H:i:s'),
+ 'comment_post_ID' => $action_id,
+ 'comment_date' => $date->format('Y-m-d H:i:s'),
'comment_date_gmt' => $comment_date_gmt,
- 'comment_author' => self::AGENT,
- 'comment_content' => $message,
- 'comment_agent' => self::AGENT,
- 'comment_type' => self::TYPE,
+ 'comment_author' => self::AGENT,
+ 'comment_content' => $message,
+ 'comment_agent' => self::AGENT,
+ 'comment_type' => self::TYPE,
);
return wp_insert_comment($comment_data);
}
@@ -58,7 +58,7 @@ protected function create_wp_comment( $action_id, $message, DateTime $date ) {
*/
public function get_entry( $entry_id ) {
$comment = $this->get_comment( $entry_id );
- if ( empty($comment) || $comment->comment_type != self::TYPE ) {
+ if ( empty($comment) || self::TYPE !== $comment->comment_type ) {
return new ActionScheduler_NullLogEntry();
}
@@ -76,20 +76,20 @@ public function get_entry( $entry_id ) {
*/
public function get_logs( $action_id ) {
$status = 'all';
- if ( get_post_status($action_id) == 'trash' ) {
+ if ( get_post_status($action_id) === 'trash' ) {
$status = 'post-trashed';
}
$comments = get_comments(array(
'post_id' => $action_id,
'orderby' => 'comment_date_gmt',
- 'order' => 'ASC',
- 'type' => self::TYPE,
- 'status' => $status,
+ 'order' => 'ASC',
+ 'type' => self::TYPE,
+ 'status' => $status,
));
$logs = array();
foreach ( $comments as $c ) {
$entry = $this->get_entry( $c );
- if ( !empty($entry) ) {
+ if ( ! empty($entry) ) {
$logs[] = $entry;
}
}
@@ -113,9 +113,9 @@ protected function get_comment( $comment_id ) {
* @param WP_Comment_Query $query Comment query object.
*/
public function filter_comment_queries( $query ) {
- foreach ( array('ID', 'parent', 'post_author', 'post_name', 'post_parent', 'type', 'post_type', 'post_id', 'post_ID') as $key ) {
- if ( !empty($query->query_vars[$key]) ) {
- return; // don't slow down queries that wouldn't include action_log comments anyway.
+ foreach ( array( 'ID', 'parent', 'post_author', 'post_name', 'post_parent', 'type', 'post_type', 'post_id', 'post_ID' ) as $key ) {
+ if ( ! empty($query->query_vars[ $key ]) ) {
+ return; // don't slow down queries that wouldn't include action_log comments anyway
}
}
$query->query_vars['action_log_filter'] = TRUE;
@@ -131,7 +131,7 @@ public function filter_comment_queries( $query ) {
* @return array
*/
public function filter_comment_query_clauses( $clauses, $query ) {
- if ( !empty($query->query_vars['action_log_filter']) ) {
+ if ( ! empty($query->query_vars['action_log_filter']) ) {
$clauses['where'] .= $this->get_where_clause();
}
return $clauses;
@@ -198,11 +198,17 @@ protected function get_comment_count() {
$total = 0;
$stats = array();
- $approved = array( '0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed' );
+ $approved = array(
+ '0' => 'moderated',
+ '1' => 'approved',
+ 'spam' => 'spam',
+ 'trash' => 'trash',
+ 'post-trashed' => 'post-trashed',
+ );
foreach ( (array) $count as $row ) {
- // Don't count post-trashed toward totals.
- if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) {
+ // Don't count post-trashed toward totals
+ if ( 'post-trashed' !== $row['comment_approved'] && 'trash' !== $row['comment_approved'] ) {
$total += $row['num_comments'];
}
if ( isset( $approved[ $row['comment_approved'] ] ) ) {
diff --git a/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php b/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php
index c3421daf7..dd77fb8cb 100644
--- a/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php
+++ b/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php
@@ -19,29 +19,29 @@ public function register() {
*/
protected function post_type_args() {
$args = array(
- 'label' => __( 'Scheduled Actions', 'action-scheduler' ),
- 'description' => __( 'Scheduled actions are hooks triggered on a certain date and time.', 'action-scheduler' ),
- 'public' => false,
+ 'label' => __( 'Scheduled Actions', 'action-scheduler' ),
+ 'description' => __( 'Scheduled actions are hooks triggered on a certain date and time.', 'action-scheduler' ),
+ 'public' => false,
'map_meta_cap' => true,
'hierarchical' => false,
- 'supports' => array('title', 'editor','comments'),
- 'rewrite' => false,
- 'query_var' => false,
- 'can_export' => true,
- 'ep_mask' => EP_NONE,
- 'labels' => array(
- 'name' => __( 'Scheduled Actions', 'action-scheduler' ),
- 'singular_name' => __( 'Scheduled Action', 'action-scheduler' ),
- 'menu_name' => _x( 'Scheduled Actions', 'Admin menu name', 'action-scheduler' ),
- 'add_new' => __( 'Add', 'action-scheduler' ),
- 'add_new_item' => __( 'Add New Scheduled Action', 'action-scheduler' ),
- 'edit' => __( 'Edit', 'action-scheduler' ),
- 'edit_item' => __( 'Edit Scheduled Action', 'action-scheduler' ),
- 'new_item' => __( 'New Scheduled Action', 'action-scheduler' ),
- 'view' => __( 'View Action', 'action-scheduler' ),
- 'view_item' => __( 'View Action', 'action-scheduler' ),
- 'search_items' => __( 'Search Scheduled Actions', 'action-scheduler' ),
- 'not_found' => __( 'No actions found', 'action-scheduler' ),
+ 'supports' => array( 'title', 'editor', 'comments' ),
+ 'rewrite' => false,
+ 'query_var' => false,
+ 'can_export' => true,
+ 'ep_mask' => EP_NONE,
+ 'labels' => array(
+ 'name' => __( 'Scheduled Actions', 'action-scheduler' ),
+ 'singular_name' => __( 'Scheduled Action', 'action-scheduler' ),
+ 'menu_name' => _x( 'Scheduled Actions', 'Admin menu name', 'action-scheduler' ),
+ 'add_new' => __( 'Add', 'action-scheduler' ),
+ 'add_new_item' => __( 'Add New Scheduled Action', 'action-scheduler' ),
+ 'edit' => __( 'Edit', 'action-scheduler' ),
+ 'edit_item' => __( 'Edit Scheduled Action', 'action-scheduler' ),
+ 'new_item' => __( 'New Scheduled Action', 'action-scheduler' ),
+ 'view' => __( 'View Action', 'action-scheduler' ),
+ 'view_item' => __( 'View Action', 'action-scheduler' ),
+ 'search_items' => __( 'Search Scheduled Actions', 'action-scheduler' ),
+ 'not_found' => __( 'No actions found', 'action-scheduler' ),
'not_found_in_trash' => __( 'No actions found in trash', 'action-scheduler' ),
),
);
diff --git a/classes/data-stores/ActionScheduler_wpPostStore_TaxonomyRegistrar.php b/classes/data-stores/ActionScheduler_wpPostStore_TaxonomyRegistrar.php
index 0ea252017..ab8ac47ef 100644
--- a/classes/data-stores/ActionScheduler_wpPostStore_TaxonomyRegistrar.php
+++ b/classes/data-stores/ActionScheduler_wpPostStore_TaxonomyRegistrar.php
@@ -18,12 +18,12 @@ public function register() {
*/
protected function taxonomy_args() {
$args = array(
- 'label' => __( 'Action Group', 'action-scheduler' ),
- 'public' => false,
- 'hierarchical' => false,
+ 'label' => __( 'Action Group', 'action-scheduler' ),
+ 'public' => false,
+ 'hierarchical' => false,
'show_admin_column' => true,
- 'query_var' => false,
- 'rewrite' => false,
+ 'query_var' => false,
+ 'rewrite' => false,
);
$args = apply_filters( 'action_scheduler_taxonomy_args', $args );
diff --git a/classes/migration/ActionMigrator.php b/classes/migration/ActionMigrator.php
index f4511a4e6..724824ed2 100644
--- a/classes/migration/ActionMigrator.php
+++ b/classes/migration/ActionMigrator.php
@@ -68,8 +68,8 @@ public function migrate( $source_action_id ) {
try {
- // Make sure the last attempt date is set correctly for completed and failed actions.
- $last_attempt_date = ( $status !== \ActionScheduler_Store::STATUS_PENDING ) ? $this->source->get_date( $source_action_id ) : null;
+ // Make sure the last attempt date is set correctly for completed and failed actions
+ $last_attempt_date = ( \ActionScheduler_Store::STATUS_PENDING !== $status ) ? $this->source->get_date( $source_action_id ) : null;
$destination_action_id = $this->destination->save_action( $action, null, $last_attempt_date );
} catch ( \Exception $e ) {
diff --git a/classes/migration/ActionScheduler_DBStoreMigrator.php b/classes/migration/ActionScheduler_DBStoreMigrator.php
index 9e87ad0aa..9f3618fc9 100644
--- a/classes/migration/ActionScheduler_DBStoreMigrator.php
+++ b/classes/migration/ActionScheduler_DBStoreMigrator.php
@@ -23,7 +23,7 @@ class ActionScheduler_DBStoreMigrator extends ActionScheduler_DBStore {
* @return string The action ID
* @throws \RuntimeException When the action is not saved.
*/
- public function save_action( ActionScheduler_Action $action, \DateTime $scheduled_date = null, \DateTime $last_attempt_date = null ){
+ public function save_action( ActionScheduler_Action $action, \DateTime $scheduled_date = null, \DateTime $last_attempt_date = null ) {
try {
/** @var \wpdb $wpdb */
global $wpdb;
diff --git a/classes/migration/Controller.php b/classes/migration/Controller.php
index 3da09c7a3..14e5f4e4f 100644
--- a/classes/migration/Controller.php
+++ b/classes/migration/Controller.php
@@ -179,8 +179,6 @@ private function hook() {
/**
* Possibly hook the migration scheduler action.
- *
- * @author Jeremy Pry
*/
public function maybe_hook_migration() {
if ( ! $this->allow_migration() || \ActionScheduler_DataController::is_migration_complete() ) {
diff --git a/classes/migration/LogMigrator.php b/classes/migration/LogMigrator.php
index b85da8550..edc10c4d3 100644
--- a/classes/migration/LogMigrator.php
+++ b/classes/migration/LogMigrator.php
@@ -25,11 +25,11 @@ class LogMigrator {
* ActionMigrator constructor.
*
* @param ActionScheduler_Logger $source_logger Source logger object.
- * @param ActionScheduler_Logger $destination_Logger Destination logger object.
+ * @param ActionScheduler_Logger $destination_logger Destination logger object.
*/
- public function __construct( ActionScheduler_Logger $source_logger, ActionScheduler_Logger $destination_Logger ) {
+ public function __construct( ActionScheduler_Logger $source_logger, ActionScheduler_Logger $destination_logger ) {
$this->source = $source_logger;
- $this->destination = $destination_Logger;
+ $this->destination = $destination_logger;
}
/**
@@ -41,7 +41,7 @@ public function __construct( ActionScheduler_Logger $source_logger, ActionSchedu
public function migrate( $source_action_id, $destination_action_id ) {
$logs = $this->source->get_logs( $source_action_id );
foreach ( $logs as $log ) {
- if ( $log->get_action_id() == $source_action_id ) {
+ if ( absint( $log->get_action_id() ) === $source_action_id ) {
$this->destination->log( $destination_action_id, $log->get_message(), $log->get_date() );
}
}
diff --git a/classes/migration/Scheduler.php b/classes/migration/Scheduler.php
index dcbe2db5f..9649aad97 100644
--- a/classes/migration/Scheduler.php
+++ b/classes/migration/Scheduler.php
@@ -40,7 +40,7 @@ public function run_migration() {
$migration_runner = $this->get_migration_runner();
$count = $migration_runner->run( $this->get_batch_size() );
- if ( $count === 0 ) {
+ if ( 0 === $count ) {
$this->mark_complete();
} else {
$this->schedule_migration( time() + $this->get_schedule_interval() );
diff --git a/classes/schedules/ActionScheduler_CronSchedule.php b/classes/schedules/ActionScheduler_CronSchedule.php
index 4d32706c7..65db15c27 100644
--- a/classes/schedules/ActionScheduler_CronSchedule.php
+++ b/classes/schedules/ActionScheduler_CronSchedule.php
@@ -81,7 +81,7 @@ public function __sleep() {
return array_merge( $sleep_params, array(
'start_timestamp',
- 'cron'
+ 'cron',
) );
}
diff --git a/classes/schedules/ActionScheduler_IntervalSchedule.php b/classes/schedules/ActionScheduler_IntervalSchedule.php
index c88a480c1..c580f861d 100644
--- a/classes/schedules/ActionScheduler_IntervalSchedule.php
+++ b/classes/schedules/ActionScheduler_IntervalSchedule.php
@@ -61,7 +61,7 @@ public function __sleep() {
return array_merge( $sleep_params, array(
'start_timestamp',
- 'interval_in_seconds'
+ 'interval_in_seconds',
) );
}
diff --git a/functions.php b/functions.php
index dbbec6edf..59e5542c3 100644
--- a/functions.php
+++ b/functions.php
@@ -127,6 +127,7 @@ function as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook,
// We expect an integer and allow it to be passed using float and string types, but otherwise
// should reject unexpected values.
+ // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
if ( ! is_numeric( $interval_in_seconds ) || $interval_in_seconds != $interval ) {
_doing_it_wrong(
__METHOD__,
@@ -456,7 +457,7 @@ function as_get_scheduled_actions( $args = array(), $return_format = OBJECT ) {
$actions[ $action_id ] = $store->fetch_action( $action_id );
}
- if ( ARRAY_A == $return_format ) {
+ if ( ARRAY_A === $return_format ) {
foreach ( $actions as $action_id => $action_object ) {
$actions[ $action_id ] = get_object_vars( $action_object );
}