Passed
Pull Request — master (#281)
by Kiran
04:07
created
action-scheduler/classes/abstracts/ActionScheduler_TimezoneHelper.php 2 patches
Indentation   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -4,149 +4,149 @@
 block discarded – undo
4 4
  * Class ActionScheduler_TimezoneHelper
5 5
  */
6 6
 abstract class ActionScheduler_TimezoneHelper {
7
-	private static $local_timezone = NULL;
8
-
9
-	/**
10
-	 * Set a DateTime's timezone to the WordPress site's timezone, or a UTC offset
11
-	 * if no timezone string is available.
12
-	 *
13
-	 * @since  2.1.0
14
-	 *
15
-	 * @param DateTime $date
16
-	 * @return ActionScheduler_DateTime
17
-	 */
18
-	public static function set_local_timezone( DateTime $date ) {
19
-
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' ) );
23
-		}
24
-
25
-		if ( get_option( 'timezone_string' ) ) {
26
-			$date->setTimezone( new DateTimeZone( self::get_local_timezone_string() ) );
27
-		} else {
28
-			$date->setUtcOffset( self::get_local_timezone_offset() );
29
-		}
30
-
31
-		return $date;
32
-	}
33
-
34
-	/**
35
-	 * Helper to retrieve the timezone string for a site until a WP core method exists
36
-	 * (see https://core.trac.wordpress.org/ticket/24730).
37
-	 *
38
-	 * Adapted from wc_timezone_string() and https://secure.php.net/manual/en/function.timezone-name-from-abbr.php#89155.
39
-	 *
40
-	 * If no timezone string is set, and its not possible to match the UTC offset set for the site to a timezone
41
-	 * string, then an empty string will be returned, and the UTC offset should be used to set a DateTime's
42
-	 * timezone.
43
-	 *
44
-	 * @since 2.1.0
45
-	 * @return string PHP timezone string for the site or empty if no timezone string is available.
46
-	 */
47
-	protected static function get_local_timezone_string( $reset = false ) {
48
-		// If site timezone string exists, return it.
49
-		$timezone = get_option( 'timezone_string' );
50
-		if ( $timezone ) {
51
-			return $timezone;
52
-		}
53
-
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 ) {
57
-			return 'UTC';
58
-		}
59
-
60
-		// Adjust UTC offset from hours to seconds.
61
-		$utc_offset *= 3600;
62
-
63
-		// Attempt to guess the timezone string from the UTC offset.
64
-		$timezone = timezone_name_from_abbr( '', $utc_offset );
65
-		if ( $timezone ) {
66
-			return $timezone;
67
-		}
68
-
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 ) {
73
-					return $city['timezone_id'];
74
-				}
75
-			}
76
-		}
77
-
78
-		// No timezone string
79
-		return '';
80
-	}
81
-
82
-	/**
83
-	 * Get timezone offset in seconds.
84
-	 *
85
-	 * @since  2.1.0
86
-	 * @return float
87
-	 */
88
-	protected static function get_local_timezone_offset() {
89
-		$timezone = get_option( 'timezone_string' );
90
-
91
-		if ( $timezone ) {
92
-			$timezone_object = new DateTimeZone( $timezone );
93
-			return $timezone_object->getOffset( new DateTime( 'now' ) );
94
-		} else {
95
-			return floatval( get_option( 'gmt_offset', 0 ) ) * HOUR_IN_SECONDS;
96
-		}
97
-	}
98
-
99
-	/**
100
-	 * @deprecated 2.1.0
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 ) {
105
-			self::$local_timezone = NULL;
106
-		}
107
-		if ( !isset(self::$local_timezone) ) {
108
-			$tzstring = get_option('timezone_string');
109
-
110
-			if ( empty($tzstring) ) {
111
-				$gmt_offset = get_option('gmt_offset');
112
-				if ( $gmt_offset == 0 ) {
113
-					$tzstring = 'UTC';
114
-				} else {
115
-					$gmt_offset *= HOUR_IN_SECONDS;
116
-					$tzstring   = timezone_name_from_abbr( '', $gmt_offset, 1 );
117
-
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 );
121
-					}
122
-
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 ) {
129
-									// If there's no valid timezone ID, keep looking.
130
-									if ( null === $city['timezone_id'] ) {
131
-										continue;
132
-									}
133
-
134
-									$tzstring = $city['timezone_id'];
135
-									break 2;
136
-								}
137
-							}
138
-						}
139
-					}
140
-
141
-					// If we still have no valid string, then fall back to UTC.
142
-					if ( false === $tzstring ) {
143
-						$tzstring = 'UTC';
144
-					}
145
-				}
146
-			}
147
-
148
-			self::$local_timezone = new DateTimeZone($tzstring);
149
-		}
150
-		return self::$local_timezone;
151
-	}
7
+    private static $local_timezone = NULL;
8
+
9
+    /**
10
+     * Set a DateTime's timezone to the WordPress site's timezone, or a UTC offset
11
+     * if no timezone string is available.
12
+     *
13
+     * @since  2.1.0
14
+     *
15
+     * @param DateTime $date
16
+     * @return ActionScheduler_DateTime
17
+     */
18
+    public static function set_local_timezone( DateTime $date ) {
19
+
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' ) );
23
+        }
24
+
25
+        if ( get_option( 'timezone_string' ) ) {
26
+            $date->setTimezone( new DateTimeZone( self::get_local_timezone_string() ) );
27
+        } else {
28
+            $date->setUtcOffset( self::get_local_timezone_offset() );
29
+        }
30
+
31
+        return $date;
32
+    }
33
+
34
+    /**
35
+     * Helper to retrieve the timezone string for a site until a WP core method exists
36
+     * (see https://core.trac.wordpress.org/ticket/24730).
37
+     *
38
+     * Adapted from wc_timezone_string() and https://secure.php.net/manual/en/function.timezone-name-from-abbr.php#89155.
39
+     *
40
+     * If no timezone string is set, and its not possible to match the UTC offset set for the site to a timezone
41
+     * string, then an empty string will be returned, and the UTC offset should be used to set a DateTime's
42
+     * timezone.
43
+     *
44
+     * @since 2.1.0
45
+     * @return string PHP timezone string for the site or empty if no timezone string is available.
46
+     */
47
+    protected static function get_local_timezone_string( $reset = false ) {
48
+        // If site timezone string exists, return it.
49
+        $timezone = get_option( 'timezone_string' );
50
+        if ( $timezone ) {
51
+            return $timezone;
52
+        }
53
+
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 ) {
57
+            return 'UTC';
58
+        }
59
+
60
+        // Adjust UTC offset from hours to seconds.
61
+        $utc_offset *= 3600;
62
+
63
+        // Attempt to guess the timezone string from the UTC offset.
64
+        $timezone = timezone_name_from_abbr( '', $utc_offset );
65
+        if ( $timezone ) {
66
+            return $timezone;
67
+        }
68
+
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 ) {
73
+                    return $city['timezone_id'];
74
+                }
75
+            }
76
+        }
77
+
78
+        // No timezone string
79
+        return '';
80
+    }
81
+
82
+    /**
83
+     * Get timezone offset in seconds.
84
+     *
85
+     * @since  2.1.0
86
+     * @return float
87
+     */
88
+    protected static function get_local_timezone_offset() {
89
+        $timezone = get_option( 'timezone_string' );
90
+
91
+        if ( $timezone ) {
92
+            $timezone_object = new DateTimeZone( $timezone );
93
+            return $timezone_object->getOffset( new DateTime( 'now' ) );
94
+        } else {
95
+            return floatval( get_option( 'gmt_offset', 0 ) ) * HOUR_IN_SECONDS;
96
+        }
97
+    }
98
+
99
+    /**
100
+     * @deprecated 2.1.0
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 ) {
105
+            self::$local_timezone = NULL;
106
+        }
107
+        if ( !isset(self::$local_timezone) ) {
108
+            $tzstring = get_option('timezone_string');
109
+
110
+            if ( empty($tzstring) ) {
111
+                $gmt_offset = get_option('gmt_offset');
112
+                if ( $gmt_offset == 0 ) {
113
+                    $tzstring = 'UTC';
114
+                } else {
115
+                    $gmt_offset *= HOUR_IN_SECONDS;
116
+                    $tzstring   = timezone_name_from_abbr( '', $gmt_offset, 1 );
117
+
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 );
121
+                    }
122
+
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 ) {
129
+                                    // If there's no valid timezone ID, keep looking.
130
+                                    if ( null === $city['timezone_id'] ) {
131
+                                        continue;
132
+                                    }
133
+
134
+                                    $tzstring = $city['timezone_id'];
135
+                                    break 2;
136
+                                }
137
+                            }
138
+                        }
139
+                    }
140
+
141
+                    // If we still have no valid string, then fall back to UTC.
142
+                    if ( false === $tzstring ) {
143
+                        $tzstring = 'UTC';
144
+                    }
145
+                }
146
+            }
147
+
148
+            self::$local_timezone = new DateTimeZone($tzstring);
149
+        }
150
+        return self::$local_timezone;
151
+    }
152 152
 }
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -15,17 +15,17 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 				}
Please login to merge, or discard this patch.
libraries/action-scheduler/classes/abstracts/ActionScheduler_Store.php 2 patches
Indentation   +337 added lines, -337 removed lines patch added patch discarded remove patch
@@ -5,341 +5,341 @@
 block discarded – undo
5 5
  * @codeCoverageIgnore
6 6
  */
7 7
 abstract class ActionScheduler_Store extends ActionScheduler_Store_Deprecated {
8
-	const STATUS_COMPLETE = 'complete';
9
-	const STATUS_PENDING  = 'pending';
10
-	const STATUS_RUNNING  = 'in-progress';
11
-	const STATUS_FAILED   = 'failed';
12
-	const STATUS_CANCELED = 'canceled';
13
-	const DEFAULT_CLASS   = 'ActionScheduler_wpPostStore';
14
-
15
-	/** @var ActionScheduler_Store */
16
-	private static $store = NULL;
17
-
18
-	/** @var int */
19
-	protected static $max_args_length = 191;
20
-
21
-	/**
22
-	 * @param ActionScheduler_Action $action
23
-	 * @param DateTime $scheduled_date Optional Date of the first instance
24
-	 *        to store. Otherwise uses the first date of the action's
25
-	 *        schedule.
26
-	 *
27
-	 * @return string The action ID
28
-	 */
29
-	abstract public function save_action( ActionScheduler_Action $action, DateTime $scheduled_date = NULL );
30
-
31
-	/**
32
-	 * @param string $action_id
33
-	 *
34
-	 * @return ActionScheduler_Action
35
-	 */
36
-	abstract public function fetch_action( $action_id );
37
-
38
-	/**
39
-	 * @param string $hook Hook name/slug.
40
-	 * @param array  $params Hook arguments.
41
-	 * @return string ID of the next action matching the criteria.
42
-	 */
43
-	abstract public function find_action( $hook, $params = array() );
44
-
45
-	/**
46
-	 * @param array  $query Query parameters.
47
-	 * @param string $query_type Whether to select or count the results. Default, select.
48
-	 *
49
-	 * @return array|int The IDs of or count of actions matching the query.
50
-	 */
51
-	abstract public function query_actions( $query = array(), $query_type = 'select' );
52
-
53
-	/**
54
-	 * Get a count of all actions in the store, grouped by status
55
-	 *
56
-	 * @return array
57
-	 */
58
-	abstract public function action_counts();
59
-
60
-	/**
61
-	 * @param string $action_id
62
-	 */
63
-	abstract public function cancel_action( $action_id );
64
-
65
-	/**
66
-	 * @param string $action_id
67
-	 */
68
-	abstract public function delete_action( $action_id );
69
-
70
-	/**
71
-	 * @param string $action_id
72
-	 *
73
-	 * @return DateTime The date the action is schedule to run, or the date that it ran.
74
-	 */
75
-	abstract public function get_date( $action_id );
76
-
77
-
78
-	/**
79
-	 * @param int      $max_actions
80
-	 * @param DateTime $before_date Claim only actions schedule before the given date. Defaults to now.
81
-	 * @param array    $hooks       Claim only actions with a hook or hooks.
82
-	 * @param string   $group       Claim only actions in the given group.
83
-	 *
84
-	 * @return ActionScheduler_ActionClaim
85
-	 */
86
-	abstract public function stake_claim( $max_actions = 10, DateTime $before_date = null, $hooks = array(), $group = '' );
87
-
88
-	/**
89
-	 * @return int
90
-	 */
91
-	abstract public function get_claim_count();
92
-
93
-	/**
94
-	 * @param ActionScheduler_ActionClaim $claim
95
-	 */
96
-	abstract public function release_claim( ActionScheduler_ActionClaim $claim );
97
-
98
-	/**
99
-	 * @param string $action_id
100
-	 */
101
-	abstract public function unclaim_action( $action_id );
102
-
103
-	/**
104
-	 * @param string $action_id
105
-	 */
106
-	abstract public function mark_failure( $action_id );
107
-
108
-	/**
109
-	 * @param string $action_id
110
-	 */
111
-	abstract public function log_execution( $action_id );
112
-
113
-	/**
114
-	 * @param string $action_id
115
-	 */
116
-	abstract public function mark_complete( $action_id );
117
-
118
-	/**
119
-	 * @param string $action_id
120
-	 *
121
-	 * @return string
122
-	 */
123
-	abstract public function get_status( $action_id );
124
-
125
-	/**
126
-	 * @param string $action_id
127
-	 * @return mixed
128
-	 */
129
-	abstract public function get_claim_id( $action_id );
130
-
131
-	/**
132
-	 * @param string $claim_id
133
-	 * @return array
134
-	 */
135
-	abstract public function find_actions_by_claim_id( $claim_id );
136
-
137
-	/**
138
-	 * @param string $comparison_operator
139
-	 * @return string
140
-	 */
141
-	protected function validate_sql_comparator( $comparison_operator ) {
142
-		if ( in_array( $comparison_operator, array('!=', '>', '>=', '<', '<=', '=') ) ) {
143
-			return $comparison_operator;
144
-		}
145
-		return '=';
146
-	}
147
-
148
-	/**
149
-	 * Get the time MySQL formated date/time string for an action's (next) scheduled date.
150
-	 *
151
-	 * @param ActionScheduler_Action $action
152
-	 * @param DateTime $scheduled_date (optional)
153
-	 * @return string
154
-	 */
155
-	protected function get_scheduled_date_string( ActionScheduler_Action $action, DateTime $scheduled_date = NULL ) {
156
-		$next = null === $scheduled_date ? $action->get_schedule()->get_date() : $scheduled_date;
157
-		if ( ! $next ) {
158
-			return '0000-00-00 00:00:00';
159
-		}
160
-		$next->setTimezone( new DateTimeZone( 'UTC' ) );
161
-
162
-		return $next->format( 'Y-m-d H:i:s' );
163
-	}
164
-
165
-	/**
166
-	 * Get the time MySQL formated date/time string for an action's (next) scheduled date.
167
-	 *
168
-	 * @param ActionScheduler_Action $action
169
-	 * @param DateTime $scheduled_date (optional)
170
-	 * @return string
171
-	 */
172
-	protected function get_scheduled_date_string_local( ActionScheduler_Action $action, DateTime $scheduled_date = NULL ) {
173
-		$next = null === $scheduled_date ? $action->get_schedule()->get_date() : $scheduled_date;
174
-		if ( ! $next ) {
175
-			return '0000-00-00 00:00:00';
176
-		}
177
-
178
-		ActionScheduler_TimezoneHelper::set_local_timezone( $next );
179
-		return $next->format( 'Y-m-d H:i:s' );
180
-	}
181
-
182
-	/**
183
-	 * Validate that we could decode action arguments.
184
-	 *
185
-	 * @param mixed $args      The decoded arguments.
186
-	 * @param int   $action_id The action ID.
187
-	 *
188
-	 * @throws ActionScheduler_InvalidActionException When the decoded arguments are invalid.
189
-	 */
190
-	protected function validate_args( $args, $action_id ) {
191
-		// Ensure we have an array of args.
192
-		if ( ! is_array( $args ) ) {
193
-			throw ActionScheduler_InvalidActionException::from_decoding_args( $action_id );
194
-		}
195
-
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 );
199
-		}
200
-	}
201
-
202
-	/**
203
-	 * Validate a ActionScheduler_Schedule object.
204
-	 *
205
-	 * @param mixed $schedule  The unserialized ActionScheduler_Schedule object.
206
-	 * @param int   $action_id The action ID.
207
-	 *
208
-	 * @throws ActionScheduler_InvalidActionException When the schedule is invalid.
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 );
213
-		}
214
-	}
215
-
216
-	/**
217
-	 * InnoDB indexes have a maximum size of 767 bytes by default, which is only 191 characters with utf8mb4.
218
-	 *
219
-	 * Previously, AS wasn't concerned about args length, as we used the (unindex) post_content column. However,
220
-	 * with custom tables, we use an indexed VARCHAR column instead.
221
-	 *
222
-	 * @param  ActionScheduler_Action $action Action to be validated.
223
-	 * @throws InvalidArgumentException When json encoded args is too long.
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 ) );
228
-		}
229
-	}
230
-
231
-	/**
232
-	 * Cancel pending actions by hook.
233
-	 *
234
-	 * @since 3.0.0
235
-	 *
236
-	 * @param string $hook Hook name.
237
-	 *
238
-	 * @return void
239
-	 */
240
-	public function cancel_actions_by_hook( $hook ) {
241
-		$action_ids = true;
242
-		while ( ! empty( $action_ids ) ) {
243
-			$action_ids = $this->query_actions(
244
-				array(
245
-					'hook' => $hook,
246
-					'status' => self::STATUS_PENDING,
247
-					'per_page' => 1000,
248
-				)
249
-			);
250
-
251
-			$this->bulk_cancel_actions( $action_ids );
252
-		}
253
-	}
254
-
255
-	/**
256
-	 * Cancel pending actions by group.
257
-	 *
258
-	 * @since 3.0.0
259
-	 *
260
-	 * @param string $group Group slug.
261
-	 *
262
-	 * @return void
263
-	 */
264
-	public function cancel_actions_by_group( $group ) {
265
-		$action_ids = true;
266
-		while ( ! empty( $action_ids ) ) {
267
-			$action_ids = $this->query_actions(
268
-				array(
269
-					'group' => $group,
270
-					'status' => self::STATUS_PENDING,
271
-					'per_page' => 1000,
272
-				)
273
-			);
274
-
275
-			$this->bulk_cancel_actions( $action_ids );
276
-		}
277
-	}
278
-
279
-	/**
280
-	 * Cancel a set of action IDs.
281
-	 *
282
-	 * @since 3.0.0
283
-	 *
284
-	 * @param array $action_ids List of action IDs.
285
-	 *
286
-	 * @return void
287
-	 */
288
-	private function bulk_cancel_actions( $action_ids ) {
289
-		foreach ( $action_ids as $action_id ) {
290
-			$this->cancel_action( $action_id );
291
-		}
292
-
293
-		do_action( 'action_scheduler_bulk_cancel_actions', $action_ids );
294
-	}
295
-
296
-	/**
297
-	 * @return array
298
-	 */
299
-	public function get_status_labels() {
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' ),
306
-		);
307
-	}
308
-
309
-	/**
310
-	 * Check if there are any pending scheduled actions due to run.
311
-	 *
312
-	 * @param ActionScheduler_Action $action
313
-	 * @param DateTime $scheduled_date (optional)
314
-	 * @return string
315
-	 */
316
-	public function has_pending_actions_due() {
317
-		$pending_actions = $this->query_actions( array(
318
-			'date'   => as_get_datetime_object(),
319
-			'status' => ActionScheduler_Store::STATUS_PENDING,
320
-		) );
321
-
322
-		return ! empty( $pending_actions );
323
-	}
324
-
325
-	/**
326
-	 * Callable initialization function optionally overridden in derived classes.
327
-	 */
328
-	public function init() {}
329
-
330
-	/**
331
-	 * Callable function to mark an action as migrated optionally overridden in derived classes.
332
-	 */
333
-	public function mark_migrated( $action_id ) {}
334
-
335
-	/**
336
-	 * @return ActionScheduler_Store
337
-	 */
338
-	public static function instance() {
339
-		if ( empty( self::$store ) ) {
340
-			$class = apply_filters( 'action_scheduler_store_class', self::DEFAULT_CLASS );
341
-			self::$store = new $class();
342
-		}
343
-		return self::$store;
344
-	}
8
+    const STATUS_COMPLETE = 'complete';
9
+    const STATUS_PENDING  = 'pending';
10
+    const STATUS_RUNNING  = 'in-progress';
11
+    const STATUS_FAILED   = 'failed';
12
+    const STATUS_CANCELED = 'canceled';
13
+    const DEFAULT_CLASS   = 'ActionScheduler_wpPostStore';
14
+
15
+    /** @var ActionScheduler_Store */
16
+    private static $store = NULL;
17
+
18
+    /** @var int */
19
+    protected static $max_args_length = 191;
20
+
21
+    /**
22
+     * @param ActionScheduler_Action $action
23
+     * @param DateTime $scheduled_date Optional Date of the first instance
24
+     *        to store. Otherwise uses the first date of the action's
25
+     *        schedule.
26
+     *
27
+     * @return string The action ID
28
+     */
29
+    abstract public function save_action( ActionScheduler_Action $action, DateTime $scheduled_date = NULL );
30
+
31
+    /**
32
+     * @param string $action_id
33
+     *
34
+     * @return ActionScheduler_Action
35
+     */
36
+    abstract public function fetch_action( $action_id );
37
+
38
+    /**
39
+     * @param string $hook Hook name/slug.
40
+     * @param array  $params Hook arguments.
41
+     * @return string ID of the next action matching the criteria.
42
+     */
43
+    abstract public function find_action( $hook, $params = array() );
44
+
45
+    /**
46
+     * @param array  $query Query parameters.
47
+     * @param string $query_type Whether to select or count the results. Default, select.
48
+     *
49
+     * @return array|int The IDs of or count of actions matching the query.
50
+     */
51
+    abstract public function query_actions( $query = array(), $query_type = 'select' );
52
+
53
+    /**
54
+     * Get a count of all actions in the store, grouped by status
55
+     *
56
+     * @return array
57
+     */
58
+    abstract public function action_counts();
59
+
60
+    /**
61
+     * @param string $action_id
62
+     */
63
+    abstract public function cancel_action( $action_id );
64
+
65
+    /**
66
+     * @param string $action_id
67
+     */
68
+    abstract public function delete_action( $action_id );
69
+
70
+    /**
71
+     * @param string $action_id
72
+     *
73
+     * @return DateTime The date the action is schedule to run, or the date that it ran.
74
+     */
75
+    abstract public function get_date( $action_id );
76
+
77
+
78
+    /**
79
+     * @param int      $max_actions
80
+     * @param DateTime $before_date Claim only actions schedule before the given date. Defaults to now.
81
+     * @param array    $hooks       Claim only actions with a hook or hooks.
82
+     * @param string   $group       Claim only actions in the given group.
83
+     *
84
+     * @return ActionScheduler_ActionClaim
85
+     */
86
+    abstract public function stake_claim( $max_actions = 10, DateTime $before_date = null, $hooks = array(), $group = '' );
87
+
88
+    /**
89
+     * @return int
90
+     */
91
+    abstract public function get_claim_count();
92
+
93
+    /**
94
+     * @param ActionScheduler_ActionClaim $claim
95
+     */
96
+    abstract public function release_claim( ActionScheduler_ActionClaim $claim );
97
+
98
+    /**
99
+     * @param string $action_id
100
+     */
101
+    abstract public function unclaim_action( $action_id );
102
+
103
+    /**
104
+     * @param string $action_id
105
+     */
106
+    abstract public function mark_failure( $action_id );
107
+
108
+    /**
109
+     * @param string $action_id
110
+     */
111
+    abstract public function log_execution( $action_id );
112
+
113
+    /**
114
+     * @param string $action_id
115
+     */
116
+    abstract public function mark_complete( $action_id );
117
+
118
+    /**
119
+     * @param string $action_id
120
+     *
121
+     * @return string
122
+     */
123
+    abstract public function get_status( $action_id );
124
+
125
+    /**
126
+     * @param string $action_id
127
+     * @return mixed
128
+     */
129
+    abstract public function get_claim_id( $action_id );
130
+
131
+    /**
132
+     * @param string $claim_id
133
+     * @return array
134
+     */
135
+    abstract public function find_actions_by_claim_id( $claim_id );
136
+
137
+    /**
138
+     * @param string $comparison_operator
139
+     * @return string
140
+     */
141
+    protected function validate_sql_comparator( $comparison_operator ) {
142
+        if ( in_array( $comparison_operator, array('!=', '>', '>=', '<', '<=', '=') ) ) {
143
+            return $comparison_operator;
144
+        }
145
+        return '=';
146
+    }
147
+
148
+    /**
149
+     * Get the time MySQL formated date/time string for an action's (next) scheduled date.
150
+     *
151
+     * @param ActionScheduler_Action $action
152
+     * @param DateTime $scheduled_date (optional)
153
+     * @return string
154
+     */
155
+    protected function get_scheduled_date_string( ActionScheduler_Action $action, DateTime $scheduled_date = NULL ) {
156
+        $next = null === $scheduled_date ? $action->get_schedule()->get_date() : $scheduled_date;
157
+        if ( ! $next ) {
158
+            return '0000-00-00 00:00:00';
159
+        }
160
+        $next->setTimezone( new DateTimeZone( 'UTC' ) );
161
+
162
+        return $next->format( 'Y-m-d H:i:s' );
163
+    }
164
+
165
+    /**
166
+     * Get the time MySQL formated date/time string for an action's (next) scheduled date.
167
+     *
168
+     * @param ActionScheduler_Action $action
169
+     * @param DateTime $scheduled_date (optional)
170
+     * @return string
171
+     */
172
+    protected function get_scheduled_date_string_local( ActionScheduler_Action $action, DateTime $scheduled_date = NULL ) {
173
+        $next = null === $scheduled_date ? $action->get_schedule()->get_date() : $scheduled_date;
174
+        if ( ! $next ) {
175
+            return '0000-00-00 00:00:00';
176
+        }
177
+
178
+        ActionScheduler_TimezoneHelper::set_local_timezone( $next );
179
+        return $next->format( 'Y-m-d H:i:s' );
180
+    }
181
+
182
+    /**
183
+     * Validate that we could decode action arguments.
184
+     *
185
+     * @param mixed $args      The decoded arguments.
186
+     * @param int   $action_id The action ID.
187
+     *
188
+     * @throws ActionScheduler_InvalidActionException When the decoded arguments are invalid.
189
+     */
190
+    protected function validate_args( $args, $action_id ) {
191
+        // Ensure we have an array of args.
192
+        if ( ! is_array( $args ) ) {
193
+            throw ActionScheduler_InvalidActionException::from_decoding_args( $action_id );
194
+        }
195
+
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 );
199
+        }
200
+    }
201
+
202
+    /**
203
+     * Validate a ActionScheduler_Schedule object.
204
+     *
205
+     * @param mixed $schedule  The unserialized ActionScheduler_Schedule object.
206
+     * @param int   $action_id The action ID.
207
+     *
208
+     * @throws ActionScheduler_InvalidActionException When the schedule is invalid.
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 );
213
+        }
214
+    }
215
+
216
+    /**
217
+     * InnoDB indexes have a maximum size of 767 bytes by default, which is only 191 characters with utf8mb4.
218
+     *
219
+     * Previously, AS wasn't concerned about args length, as we used the (unindex) post_content column. However,
220
+     * with custom tables, we use an indexed VARCHAR column instead.
221
+     *
222
+     * @param  ActionScheduler_Action $action Action to be validated.
223
+     * @throws InvalidArgumentException When json encoded args is too long.
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 ) );
228
+        }
229
+    }
230
+
231
+    /**
232
+     * Cancel pending actions by hook.
233
+     *
234
+     * @since 3.0.0
235
+     *
236
+     * @param string $hook Hook name.
237
+     *
238
+     * @return void
239
+     */
240
+    public function cancel_actions_by_hook( $hook ) {
241
+        $action_ids = true;
242
+        while ( ! empty( $action_ids ) ) {
243
+            $action_ids = $this->query_actions(
244
+                array(
245
+                    'hook' => $hook,
246
+                    'status' => self::STATUS_PENDING,
247
+                    'per_page' => 1000,
248
+                )
249
+            );
250
+
251
+            $this->bulk_cancel_actions( $action_ids );
252
+        }
253
+    }
254
+
255
+    /**
256
+     * Cancel pending actions by group.
257
+     *
258
+     * @since 3.0.0
259
+     *
260
+     * @param string $group Group slug.
261
+     *
262
+     * @return void
263
+     */
264
+    public function cancel_actions_by_group( $group ) {
265
+        $action_ids = true;
266
+        while ( ! empty( $action_ids ) ) {
267
+            $action_ids = $this->query_actions(
268
+                array(
269
+                    'group' => $group,
270
+                    'status' => self::STATUS_PENDING,
271
+                    'per_page' => 1000,
272
+                )
273
+            );
274
+
275
+            $this->bulk_cancel_actions( $action_ids );
276
+        }
277
+    }
278
+
279
+    /**
280
+     * Cancel a set of action IDs.
281
+     *
282
+     * @since 3.0.0
283
+     *
284
+     * @param array $action_ids List of action IDs.
285
+     *
286
+     * @return void
287
+     */
288
+    private function bulk_cancel_actions( $action_ids ) {
289
+        foreach ( $action_ids as $action_id ) {
290
+            $this->cancel_action( $action_id );
291
+        }
292
+
293
+        do_action( 'action_scheduler_bulk_cancel_actions', $action_ids );
294
+    }
295
+
296
+    /**
297
+     * @return array
298
+     */
299
+    public function get_status_labels() {
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' ),
306
+        );
307
+    }
308
+
309
+    /**
310
+     * Check if there are any pending scheduled actions due to run.
311
+     *
312
+     * @param ActionScheduler_Action $action
313
+     * @param DateTime $scheduled_date (optional)
314
+     * @return string
315
+     */
316
+    public function has_pending_actions_due() {
317
+        $pending_actions = $this->query_actions( array(
318
+            'date'   => as_get_datetime_object(),
319
+            'status' => ActionScheduler_Store::STATUS_PENDING,
320
+        ) );
321
+
322
+        return ! empty( $pending_actions );
323
+    }
324
+
325
+    /**
326
+     * Callable initialization function optionally overridden in derived classes.
327
+     */
328
+    public function init() {}
329
+
330
+    /**
331
+     * Callable function to mark an action as migrated optionally overridden in derived classes.
332
+     */
333
+    public function mark_migrated( $action_id ) {}
334
+
335
+    /**
336
+     * @return ActionScheduler_Store
337
+     */
338
+    public static function instance() {
339
+        if ( empty( self::$store ) ) {
340
+            $class = apply_filters( 'action_scheduler_store_class', self::DEFAULT_CLASS );
341
+            self::$store = new $class();
342
+        }
343
+        return self::$store;
344
+    }
345 345
 }
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -26,21 +26,21 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
action-scheduler/classes/abstracts/ActionScheduler_Abstract_Schedule.php 2 patches
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -5,79 +5,79 @@
 block discarded – undo
5 5
  */
6 6
 abstract class ActionScheduler_Abstract_Schedule extends ActionScheduler_Schedule_Deprecated {
7 7
 
8
-	/**
9
-	 * The date & time the schedule is set to run.
10
-	 *
11
-	 * @var DateTime
12
-	 */
13
-	private $scheduled_date = NULL;
8
+    /**
9
+     * The date & time the schedule is set to run.
10
+     *
11
+     * @var DateTime
12
+     */
13
+    private $scheduled_date = NULL;
14 14
 
15
-	/**
16
-	 * Timestamp equivalent of @see $this->scheduled_date
17
-	 *
18
-	 * @var int
19
-	 */
20
-	protected $scheduled_timestamp = NULL;
15
+    /**
16
+     * Timestamp equivalent of @see $this->scheduled_date
17
+     *
18
+     * @var int
19
+     */
20
+    protected $scheduled_timestamp = NULL;
21 21
 
22
-	/**
23
-	 * @param DateTime $date The date & time to run the action.
24
-	 */
25
-	public function __construct( DateTime $date ) {
26
-		$this->scheduled_date = $date;
27
-	}
22
+    /**
23
+     * @param DateTime $date The date & time to run the action.
24
+     */
25
+    public function __construct( DateTime $date ) {
26
+        $this->scheduled_date = $date;
27
+    }
28 28
 
29
-	/**
30
-	 * Check if a schedule should recur.
31
-	 *
32
-	 * @return bool
33
-	 */
34
-	abstract public function is_recurring();
29
+    /**
30
+     * Check if a schedule should recur.
31
+     *
32
+     * @return bool
33
+     */
34
+    abstract public function is_recurring();
35 35
 
36
-	/**
37
-	 * Calculate when the next instance of this schedule would run based on a given date & time.
38
-	 *
39
-	 * @param DateTime $after
40
-	 * @return DateTime
41
-	 */
42
-	abstract protected function calculate_next( DateTime $after );
36
+    /**
37
+     * Calculate when the next instance of this schedule would run based on a given date & time.
38
+     *
39
+     * @param DateTime $after
40
+     * @return DateTime
41
+     */
42
+    abstract protected function calculate_next( DateTime $after );
43 43
 
44
-	/**
45
-	 * Get the next date & time when this schedule should run after a given date & time.
46
-	 *
47
-	 * @param DateTime $after
48
-	 * @return DateTime|null
49
-	 */
50
-	public function get_next( DateTime $after ) {
51
-		$after = clone $after;
52
-		if ( $after > $this->scheduled_date ) {
53
-			$after = $this->calculate_next( $after );
54
-			return $after;
55
-		}
56
-		return clone $this->scheduled_date;
57
-	}
44
+    /**
45
+     * Get the next date & time when this schedule should run after a given date & time.
46
+     *
47
+     * @param DateTime $after
48
+     * @return DateTime|null
49
+     */
50
+    public function get_next( DateTime $after ) {
51
+        $after = clone $after;
52
+        if ( $after > $this->scheduled_date ) {
53
+            $after = $this->calculate_next( $after );
54
+            return $after;
55
+        }
56
+        return clone $this->scheduled_date;
57
+    }
58 58
 
59
-	/**
60
-	 * Get the date & time the schedule is set to run.
61
-	 *
62
-	 * @return DateTime|null
63
-	 */
64
-	public function get_date() {
65
-		return $this->scheduled_date;
66
-	}
59
+    /**
60
+     * Get the date & time the schedule is set to run.
61
+     *
62
+     * @return DateTime|null
63
+     */
64
+    public function get_date() {
65
+        return $this->scheduled_date;
66
+    }
67 67
 
68
-	/**
69
-	 * For PHP 5.2 compat, since DateTime objects can't be serialized
70
-	 * @return array
71
-	 */
72
-	public function __sleep() {
73
-		$this->scheduled_timestamp = $this->scheduled_date->getTimestamp();
74
-		return array(
75
-			'scheduled_timestamp',
76
-		);
77
-	}
68
+    /**
69
+     * For PHP 5.2 compat, since DateTime objects can't be serialized
70
+     * @return array
71
+     */
72
+    public function __sleep() {
73
+        $this->scheduled_timestamp = $this->scheduled_date->getTimestamp();
74
+        return array(
75
+            'scheduled_timestamp',
76
+        );
77
+    }
78 78
 
79
-	public function __wakeup() {
80
-		$this->scheduled_date = as_get_datetime_object( $this->scheduled_timestamp );
81
-		unset( $this->scheduled_timestamp );
82
-	}
79
+    public function __wakeup() {
80
+        $this->scheduled_date = as_get_datetime_object( $this->scheduled_timestamp );
81
+        unset( $this->scheduled_timestamp );
82
+    }
83 83
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
libraries/action-scheduler/classes/abstracts/ActionScheduler_Logger.php 2 patches
Indentation   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -5,172 +5,172 @@
 block discarded – undo
5 5
  * @codeCoverageIgnore
6 6
  */
7 7
 abstract class ActionScheduler_Logger {
8
-	private static $logger = NULL;
9
-
10
-	/**
11
-	 * @return ActionScheduler_Logger
12
-	 */
13
-	public static function instance() {
14
-		if ( empty(self::$logger) ) {
15
-			$class = apply_filters('action_scheduler_logger_class', 'ActionScheduler_wpCommentLogger');
16
-			self::$logger = new $class();
17
-		}
18
-		return self::$logger;
19
-	}
20
-
21
-	/**
22
-	 * @param string $action_id
23
-	 * @param string $message
24
-	 * @param DateTime $date
25
-	 *
26
-	 * @return string The log entry ID
27
-	 */
28
-	abstract public function log( $action_id, $message, DateTime $date = NULL );
29
-
30
-	/**
31
-	 * @param string $entry_id
32
-	 *
33
-	 * @return ActionScheduler_LogEntry
34
-	 */
35
-	abstract public function get_entry( $entry_id );
36
-
37
-	/**
38
-	 * @param string $action_id
39
-	 *
40
-	 * @return ActionScheduler_LogEntry[]
41
-	 */
42
-	abstract public function get_logs( $action_id );
43
-
44
-
45
-	/**
46
-	 * @codeCoverageIgnore
47
-	 */
48
-	public function init() {
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 );
61
-	}
62
-
63
-	public function hook_stored_action() {
64
-		add_action( 'action_scheduler_stored_action', array( $this, 'log_stored_action' ) );
65
-	}
66
-
67
-	public function unhook_stored_action() {
68
-		remove_action( 'action_scheduler_stored_action', array( $this, 'log_stored_action' ) );
69
-	}
70
-
71
-	public function log_stored_action( $action_id ) {
72
-		$this->log( $action_id, __( 'action created', 'action-scheduler' ) );
73
-	}
74
-
75
-	public function log_canceled_action( $action_id ) {
76
-		$this->log( $action_id, __( 'action canceled', 'action-scheduler' ) );
77
-	}
78
-
79
-	public function log_started_action( $action_id, $context = '' ) {
80
-		if ( ! empty( $context ) ) {
81
-			/* translators: %s: context */
82
-			$message = sprintf( __( 'action started via %s', 'action-scheduler' ), $context );
83
-		} else {
84
-			$message = __( 'action started', 'action-scheduler' );
85
-		}
86
-		$this->log( $action_id, $message );
87
-	}
88
-
89
-	public function log_completed_action( $action_id, $action = NULL, $context = '' ) {
90
-		if ( ! empty( $context ) ) {
91
-			/* translators: %s: context */
92
-			$message = sprintf( __( 'action complete via %s', 'action-scheduler' ), $context );
93
-		} else {
94
-			$message = __( 'action complete', 'action-scheduler' );
95
-		}
96
-		$this->log( $action_id, $message );
97
-	}
98
-
99
-	public function log_failed_action( $action_id, Exception $exception, $context = '' ) {
100
-		if ( ! empty( $context ) ) {
101
-			/* translators: 1: context 2: exception message */
102
-			$message = sprintf( __( 'action failed via %1$s: %2$s', 'action-scheduler' ), $context, $exception->getMessage() );
103
-		} else {
104
-			/* translators: %s: exception message */
105
-			$message = sprintf( __( 'action failed: %s', 'action-scheduler' ), $exception->getMessage() );
106
-		}
107
-		$this->log( $action_id, $message );
108
-	}
109
-
110
-	public function log_timed_out_action( $action_id, $timeout ) {
111
-		/* translators: %s: amount of time */
112
-		$this->log( $action_id, sprintf( __( 'action timed out after %s seconds', 'action-scheduler' ), $timeout ) );
113
-	}
114
-
115
-	public function log_unexpected_shutdown( $action_id, $error ) {
116
-		if ( ! empty( $error ) ) {
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'] ) );
119
-		}
120
-	}
121
-
122
-	public function log_reset_action( $action_id ) {
123
-		$this->log( $action_id, __( 'action reset', 'action-scheduler' ) );
124
-	}
125
-
126
-	public function log_ignored_action( $action_id, $context = '' ) {
127
-		if ( ! empty( $context ) ) {
128
-			/* translators: %s: context */
129
-			$message = sprintf( __( 'action ignored via %s', 'action-scheduler' ), $context );
130
-		} else {
131
-			$message = __( 'action ignored', 'action-scheduler' );
132
-		}
133
-		$this->log( $action_id, $message );
134
-	}
135
-
136
-	/**
137
-	 * @param string $action_id
138
-	 * @param Exception|NULL $exception The exception which occured when fetching the action. NULL by default for backward compatibility.
139
-	 *
140
-	 * @return ActionScheduler_LogEntry[]
141
-	 */
142
-	public function log_failed_fetch_action( $action_id, Exception $exception = NULL ) {
143
-
144
-		if ( ! is_null( $exception ) ) {
145
-			/* translators: %s: exception message */
146
-			$log_message = sprintf( __( 'There was a failure fetching this action: %s', 'action-scheduler' ), $exception->getMessage() );
147
-		} else {
148
-			$log_message = __( 'There was a failure fetching this action', 'action-scheduler' );
149
-		}
150
-
151
-		$this->log( $action_id, $log_message );
152
-	}
153
-
154
-	public function log_failed_schedule_next_instance( $action_id, Exception $exception ) {
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() ) );
157
-	}
158
-
159
-	/**
160
-	 * Bulk add cancel action log entries.
161
-	 *
162
-	 * Implemented here for backward compatibility. Should be implemented in parent loggers
163
-	 * for more performant bulk logging.
164
-	 *
165
-	 * @param array $action_ids List of action ID.
166
-	 */
167
-	public function bulk_log_cancel_actions( $action_ids ) {
168
-		if ( empty( $action_ids ) ) {
169
-			return;
170
-		}
171
-
172
-		foreach ( $action_ids as $action_id ) {
173
-			$this->log_canceled_action( $action_id );
174
-		}
175
-	}
8
+    private static $logger = NULL;
9
+
10
+    /**
11
+     * @return ActionScheduler_Logger
12
+     */
13
+    public static function instance() {
14
+        if ( empty(self::$logger) ) {
15
+            $class = apply_filters('action_scheduler_logger_class', 'ActionScheduler_wpCommentLogger');
16
+            self::$logger = new $class();
17
+        }
18
+        return self::$logger;
19
+    }
20
+
21
+    /**
22
+     * @param string $action_id
23
+     * @param string $message
24
+     * @param DateTime $date
25
+     *
26
+     * @return string The log entry ID
27
+     */
28
+    abstract public function log( $action_id, $message, DateTime $date = NULL );
29
+
30
+    /**
31
+     * @param string $entry_id
32
+     *
33
+     * @return ActionScheduler_LogEntry
34
+     */
35
+    abstract public function get_entry( $entry_id );
36
+
37
+    /**
38
+     * @param string $action_id
39
+     *
40
+     * @return ActionScheduler_LogEntry[]
41
+     */
42
+    abstract public function get_logs( $action_id );
43
+
44
+
45
+    /**
46
+     * @codeCoverageIgnore
47
+     */
48
+    public function init() {
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 );
61
+    }
62
+
63
+    public function hook_stored_action() {
64
+        add_action( 'action_scheduler_stored_action', array( $this, 'log_stored_action' ) );
65
+    }
66
+
67
+    public function unhook_stored_action() {
68
+        remove_action( 'action_scheduler_stored_action', array( $this, 'log_stored_action' ) );
69
+    }
70
+
71
+    public function log_stored_action( $action_id ) {
72
+        $this->log( $action_id, __( 'action created', 'action-scheduler' ) );
73
+    }
74
+
75
+    public function log_canceled_action( $action_id ) {
76
+        $this->log( $action_id, __( 'action canceled', 'action-scheduler' ) );
77
+    }
78
+
79
+    public function log_started_action( $action_id, $context = '' ) {
80
+        if ( ! empty( $context ) ) {
81
+            /* translators: %s: context */
82
+            $message = sprintf( __( 'action started via %s', 'action-scheduler' ), $context );
83
+        } else {
84
+            $message = __( 'action started', 'action-scheduler' );
85
+        }
86
+        $this->log( $action_id, $message );
87
+    }
88
+
89
+    public function log_completed_action( $action_id, $action = NULL, $context = '' ) {
90
+        if ( ! empty( $context ) ) {
91
+            /* translators: %s: context */
92
+            $message = sprintf( __( 'action complete via %s', 'action-scheduler' ), $context );
93
+        } else {
94
+            $message = __( 'action complete', 'action-scheduler' );
95
+        }
96
+        $this->log( $action_id, $message );
97
+    }
98
+
99
+    public function log_failed_action( $action_id, Exception $exception, $context = '' ) {
100
+        if ( ! empty( $context ) ) {
101
+            /* translators: 1: context 2: exception message */
102
+            $message = sprintf( __( 'action failed via %1$s: %2$s', 'action-scheduler' ), $context, $exception->getMessage() );
103
+        } else {
104
+            /* translators: %s: exception message */
105
+            $message = sprintf( __( 'action failed: %s', 'action-scheduler' ), $exception->getMessage() );
106
+        }
107
+        $this->log( $action_id, $message );
108
+    }
109
+
110
+    public function log_timed_out_action( $action_id, $timeout ) {
111
+        /* translators: %s: amount of time */
112
+        $this->log( $action_id, sprintf( __( 'action timed out after %s seconds', 'action-scheduler' ), $timeout ) );
113
+    }
114
+
115
+    public function log_unexpected_shutdown( $action_id, $error ) {
116
+        if ( ! empty( $error ) ) {
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'] ) );
119
+        }
120
+    }
121
+
122
+    public function log_reset_action( $action_id ) {
123
+        $this->log( $action_id, __( 'action reset', 'action-scheduler' ) );
124
+    }
125
+
126
+    public function log_ignored_action( $action_id, $context = '' ) {
127
+        if ( ! empty( $context ) ) {
128
+            /* translators: %s: context */
129
+            $message = sprintf( __( 'action ignored via %s', 'action-scheduler' ), $context );
130
+        } else {
131
+            $message = __( 'action ignored', 'action-scheduler' );
132
+        }
133
+        $this->log( $action_id, $message );
134
+    }
135
+
136
+    /**
137
+     * @param string $action_id
138
+     * @param Exception|NULL $exception The exception which occured when fetching the action. NULL by default for backward compatibility.
139
+     *
140
+     * @return ActionScheduler_LogEntry[]
141
+     */
142
+    public function log_failed_fetch_action( $action_id, Exception $exception = NULL ) {
143
+
144
+        if ( ! is_null( $exception ) ) {
145
+            /* translators: %s: exception message */
146
+            $log_message = sprintf( __( 'There was a failure fetching this action: %s', 'action-scheduler' ), $exception->getMessage() );
147
+        } else {
148
+            $log_message = __( 'There was a failure fetching this action', 'action-scheduler' );
149
+        }
150
+
151
+        $this->log( $action_id, $log_message );
152
+    }
153
+
154
+    public function log_failed_schedule_next_instance( $action_id, Exception $exception ) {
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() ) );
157
+    }
158
+
159
+    /**
160
+     * Bulk add cancel action log entries.
161
+     *
162
+     * Implemented here for backward compatibility. Should be implemented in parent loggers
163
+     * for more performant bulk logging.
164
+     *
165
+     * @param array $action_ids List of action ID.
166
+     */
167
+    public function bulk_log_cancel_actions( $action_ids ) {
168
+        if ( empty( $action_ids ) ) {
169
+            return;
170
+        }
171
+
172
+        foreach ( $action_ids as $action_id ) {
173
+            $this->log_canceled_action( $action_id );
174
+        }
175
+    }
176 176
 }
Please login to merge, or discard this patch.
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
libraries/action-scheduler/classes/abstracts/ActionScheduler_Lock.php 2 patches
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -7,56 +7,56 @@
 block discarded – undo
7 7
  */
8 8
 abstract class ActionScheduler_Lock {
9 9
 
10
-	/** @var ActionScheduler_Lock */
11
-	private static $locker = NULL;
12
-
13
-	/** @var int */
14
-	protected static $lock_duration = MINUTE_IN_SECONDS;
15
-
16
-	/**
17
-	 * Check if a lock is set for a given lock type.
18
-	 *
19
-	 * @param string $lock_type A string to identify different lock types.
20
-	 * @return bool
21
-	 */
22
-	public function is_locked( $lock_type ) {
23
-		return ( $this->get_expiration( $lock_type ) >= time() );
24
-	}
25
-
26
-	/**
27
-	 * Set a lock.
28
-	 *
29
-	 * @param string $lock_type A string to identify different lock types.
30
-	 * @return bool
31
-	 */
32
-	abstract public function set( $lock_type );
33
-
34
-	/**
35
-	 * If a lock is set, return the timestamp it was set to expiry.
36
-	 *
37
-	 * @param string $lock_type A string to identify different lock types.
38
-	 * @return bool|int False if no lock is set, otherwise the timestamp for when the lock is set to expire.
39
-	 */
40
-	abstract public function get_expiration( $lock_type );
41
-
42
-	/**
43
-	 * Get the amount of time to set for a given lock. 60 seconds by default.
44
-	 *
45
-	 * @param string $lock_type A string to identify different lock types.
46
-	 * @return int
47
-	 */
48
-	protected function get_duration( $lock_type ) {
49
-		return apply_filters( 'action_scheduler_lock_duration', self::$lock_duration, $lock_type );
50
-	}
51
-
52
-	/**
53
-	 * @return ActionScheduler_Lock
54
-	 */
55
-	public static function instance() {
56
-		if ( empty( self::$locker ) ) {
57
-			$class = apply_filters( 'action_scheduler_lock_class', 'ActionScheduler_OptionLock' );
58
-			self::$locker = new $class();
59
-		}
60
-		return self::$locker;
61
-	}
10
+    /** @var ActionScheduler_Lock */
11
+    private static $locker = NULL;
12
+
13
+    /** @var int */
14
+    protected static $lock_duration = MINUTE_IN_SECONDS;
15
+
16
+    /**
17
+     * Check if a lock is set for a given lock type.
18
+     *
19
+     * @param string $lock_type A string to identify different lock types.
20
+     * @return bool
21
+     */
22
+    public function is_locked( $lock_type ) {
23
+        return ( $this->get_expiration( $lock_type ) >= time() );
24
+    }
25
+
26
+    /**
27
+     * Set a lock.
28
+     *
29
+     * @param string $lock_type A string to identify different lock types.
30
+     * @return bool
31
+     */
32
+    abstract public function set( $lock_type );
33
+
34
+    /**
35
+     * If a lock is set, return the timestamp it was set to expiry.
36
+     *
37
+     * @param string $lock_type A string to identify different lock types.
38
+     * @return bool|int False if no lock is set, otherwise the timestamp for when the lock is set to expire.
39
+     */
40
+    abstract public function get_expiration( $lock_type );
41
+
42
+    /**
43
+     * Get the amount of time to set for a given lock. 60 seconds by default.
44
+     *
45
+     * @param string $lock_type A string to identify different lock types.
46
+     * @return int
47
+     */
48
+    protected function get_duration( $lock_type ) {
49
+        return apply_filters( 'action_scheduler_lock_duration', self::$lock_duration, $lock_type );
50
+    }
51
+
52
+    /**
53
+     * @return ActionScheduler_Lock
54
+     */
55
+    public static function instance() {
56
+        if ( empty( self::$locker ) ) {
57
+            $class = apply_filters( 'action_scheduler_lock_class', 'ActionScheduler_OptionLock' );
58
+            self::$locker = new $class();
59
+        }
60
+        return self::$locker;
61
+    }
62 62
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
includes/libraries/action-scheduler/classes/abstracts/ActionScheduler.php 2 patches
Indentation   +264 added lines, -264 removed lines patch added patch discarded remove patch
@@ -8,268 +8,268 @@
 block discarded – undo
8 8
  * @codeCoverageIgnore
9 9
  */
10 10
 abstract class ActionScheduler {
11
-	private static $plugin_file = '';
12
-	/** @var ActionScheduler_ActionFactory */
13
-	private static $factory = NULL;
14
-
15
-	public static function factory() {
16
-		if ( !isset(self::$factory) ) {
17
-			self::$factory = new ActionScheduler_ActionFactory();
18
-		}
19
-		return self::$factory;
20
-	}
21
-
22
-	public static function store() {
23
-		return ActionScheduler_Store::instance();
24
-	}
25
-
26
-	public static function lock() {
27
-		return ActionScheduler_Lock::instance();
28
-	}
29
-
30
-	public static function logger() {
31
-		return ActionScheduler_Logger::instance();
32
-	}
33
-
34
-	public static function runner() {
35
-		return ActionScheduler_QueueRunner::instance();
36
-	}
37
-
38
-	public static function admin_view() {
39
-		return ActionScheduler_AdminView::instance();
40
-	}
41
-
42
-	/**
43
-	 * Get the absolute system path to the plugin directory, or a file therein
44
-	 * @static
45
-	 * @param string $path
46
-	 * @return string
47
-	 */
48
-	public static function plugin_path( $path ) {
49
-		$base = dirname(self::$plugin_file);
50
-		if ( $path ) {
51
-			return trailingslashit($base).$path;
52
-		} else {
53
-			return untrailingslashit($base);
54
-		}
55
-	}
56
-
57
-	/**
58
-	 * Get the absolute URL to the plugin directory, or a file therein
59
-	 * @static
60
-	 * @param string $path
61
-	 * @return string
62
-	 */
63
-	public static function plugin_url( $path ) {
64
-		return plugins_url($path, self::$plugin_file);
65
-	}
66
-
67
-	public static function autoload( $class ) {
68
-		$d           = DIRECTORY_SEPARATOR;
69
-		$classes_dir = self::plugin_path( 'classes' . $d );
70
-		$separator   = strrpos( $class, '\\' );
71
-		if ( false !== $separator ) {
72
-			if ( 0 !== strpos( $class, 'Action_Scheduler' ) ) {
73
-				return;
74
-			}
75
-			$class = substr( $class, $separator + 1 );
76
-		}
77
-
78
-		if ( 'Deprecated' === substr( $class, -10 ) ) {
79
-			$dir = self::plugin_path( 'deprecated' . $d );
80
-		} elseif ( self::is_class_abstract( $class ) ) {
81
-			$dir = $classes_dir . 'abstracts' . $d;
82
-		} elseif ( self::is_class_migration( $class ) ) {
83
-			$dir = $classes_dir . 'migration' . $d;
84
-		} elseif ( 'Schedule' === substr( $class, -8 ) ) {
85
-			$dir = $classes_dir . 'schedules' . $d;
86
-		} elseif ( 'Action' === substr( $class, -6 ) ) {
87
-			$dir = $classes_dir . 'actions' . $d;
88
-		} elseif ( 'Schema' === substr( $class, -6 ) ) {
89
-			$dir = $classes_dir . 'schema' . $d;
90
-		} elseif ( strpos( $class, 'ActionScheduler' ) === 0 ) {
91
-			$segments = explode( '_', $class );
92
-			$type = isset( $segments[ 1 ] ) ? $segments[ 1 ] : '';
93
-
94
-			switch ( $type ) {
95
-				case 'WPCLI':
96
-					$dir = $classes_dir . 'WP_CLI' . $d;
97
-					break;
98
-				case 'DBLogger':
99
-				case 'DBStore':
100
-				case 'HybridStore':
101
-				case 'wpPostStore':
102
-				case 'wpCommentLogger':
103
-					$dir = $classes_dir . 'data-stores' . $d;
104
-					break;
105
-				default:
106
-					$dir = $classes_dir;
107
-					break;
108
-			}
109
-		} elseif ( self::is_class_cli( $class ) ) {
110
-			$dir = $classes_dir . 'WP_CLI' . $d;
111
-		} elseif ( strpos( $class, 'CronExpression' ) === 0 ) {
112
-			$dir = self::plugin_path( 'lib' . $d . 'cron-expression' . $d );
113
-		} elseif ( strpos( $class, 'WP_Async_Request' ) === 0 ) {
114
-			$dir = self::plugin_path( 'lib' . $d );
115
-		} else {
116
-			return;
117
-		}
118
-
119
-		if ( file_exists( "{$dir}{$class}.php" ) ) {
120
-			include( "{$dir}{$class}.php" );
121
-			return;
122
-		}
123
-	}
124
-
125
-	/**
126
-	 * Initialize the plugin
127
-	 *
128
-	 * @static
129
-	 * @param string $plugin_file
130
-	 */
131
-	public static function init( $plugin_file ) {
132
-		self::$plugin_file = $plugin_file;
133
-		spl_autoload_register( array( __CLASS__, 'autoload' ) );
134
-
135
-		/**
136
-		 * Fires in the early stages of Action Scheduler init hook.
137
-		 */
138
-		do_action( 'action_scheduler_pre_init' );
139
-
140
-		require_once( self::plugin_path( 'functions.php' ) );
141
-		ActionScheduler_DataController::init();
142
-
143
-		$store      = self::store();
144
-		$logger     = self::logger();
145
-		$runner     = self::runner();
146
-		$admin_view = self::admin_view();
147
-
148
-		// Ensure initialization on plugin activation.
149
-		if ( ! did_action( 'init' ) ) {
150
-			add_action( 'init', array( $admin_view, 'init' ), 0, 0 ); // run before $store::init()
151
-			add_action( 'init', array( $store, 'init' ), 1, 0 );
152
-			add_action( 'init', array( $logger, 'init' ), 1, 0 );
153
-			add_action( 'init', array( $runner, 'init' ), 1, 0 );
154
-		} else {
155
-			$admin_view->init();
156
-			$store->init();
157
-			$logger->init();
158
-			$runner->init();
159
-		}
160
-
161
-		if ( apply_filters( 'action_scheduler_load_deprecated_functions', true ) ) {
162
-			require_once( self::plugin_path( 'deprecated/functions.php' ) );
163
-		}
164
-
165
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
166
-			WP_CLI::add_command( 'action-scheduler', 'ActionScheduler_WPCLI_Scheduler_command' );
167
-			if ( ! ActionScheduler_DataController::is_migration_complete() && Controller::instance()->allow_migration() ) {
168
-				$command = new Migration_Command();
169
-				$command->register();
170
-			}
171
-		}
172
-
173
-		/**
174
-		 * Handle WP comment cleanup after migration.
175
-		 */
176
-		if ( is_a( $logger, 'ActionScheduler_DBLogger' ) && ActionScheduler_DataController::is_migration_complete() && ActionScheduler_WPCommentCleaner::has_logs() ) {
177
-			ActionScheduler_WPCommentCleaner::init();
178
-		}
179
-
180
-		add_action( 'action_scheduler/migration_complete', 'ActionScheduler_WPCommentCleaner::maybe_schedule_cleanup' );
181
-	}
182
-
183
-	/**
184
-	 * Determine if the class is one of our abstract classes.
185
-	 *
186
-	 * @since 3.0.0
187
-	 *
188
-	 * @param string $class The class name.
189
-	 *
190
-	 * @return bool
191
-	 */
192
-	protected static function is_class_abstract( $class ) {
193
-		static $abstracts = array(
194
-			'ActionScheduler'                            => true,
195
-			'ActionScheduler_Abstract_ListTable'         => true,
196
-			'ActionScheduler_Abstract_QueueRunner'       => true,
197
-			'ActionScheduler_Abstract_Schedule'          => true,
198
-			'ActionScheduler_Abstract_RecurringSchedule' => true,
199
-			'ActionScheduler_Lock'                       => true,
200
-			'ActionScheduler_Logger'                     => true,
201
-			'ActionScheduler_Abstract_Schema'            => true,
202
-			'ActionScheduler_Store'                      => true,
203
-			'ActionScheduler_TimezoneHelper'             => true,
204
-		);
205
-
206
-		return isset( $abstracts[ $class ] ) && $abstracts[ $class ];
207
-	}
208
-
209
-	/**
210
-	 * Determine if the class is one of our migration classes.
211
-	 *
212
-	 * @since 3.0.0
213
-	 *
214
-	 * @param string $class The class name.
215
-	 *
216
-	 * @return bool
217
-	 */
218
-	protected static function is_class_migration( $class ) {
219
-		static $migration_segments = array(
220
-			'ActionMigrator'  => true,
221
-			'BatchFetcher'    => true,
222
-			'DBStoreMigrator' => true,
223
-			'DryRun'          => true,
224
-			'LogMigrator'     => true,
225
-			'Config'          => true,
226
-			'Controller'      => true,
227
-			'Runner'          => true,
228
-			'Scheduler'       => true,
229
-		);
230
-
231
-		$segments = explode( '_', $class );
232
-		$segment = isset( $segments[ 1 ] ) ? $segments[ 1 ] : $class;
233
-
234
-		return isset( $migration_segments[ $segment ] ) && $migration_segments[ $segment ];
235
-	}
236
-
237
-	/**
238
-	 * Determine if the class is one of our WP CLI classes.
239
-	 *
240
-	 * @since 3.0.0
241
-	 *
242
-	 * @param string $class The class name.
243
-	 *
244
-	 * @return bool
245
-	 */
246
-	protected static function is_class_cli( $class ) {
247
-		static $cli_segments = array(
248
-			'QueueRunner' => true,
249
-			'Command'     => true,
250
-			'ProgressBar' => true,
251
-		);
252
-
253
-		$segments = explode( '_', $class );
254
-		$segment = isset( $segments[ 1 ] ) ? $segments[ 1 ] : $class;
255
-
256
-		return isset( $cli_segments[ $segment ] ) && $cli_segments[ $segment ];
257
-	}
258
-
259
-	final public function __clone() {
260
-		trigger_error("Singleton. No cloning allowed!", E_USER_ERROR);
261
-	}
262
-
263
-	final public function __wakeup() {
264
-		trigger_error("Singleton. No serialization allowed!", E_USER_ERROR);
265
-	}
266
-
267
-	final private function __construct() {}
268
-
269
-	/** Deprecated **/
270
-
271
-	public static function get_datetime_object( $when = null, $timezone = 'UTC' ) {
272
-		_deprecated_function( __METHOD__, '2.0', 'wcs_add_months()' );
273
-		return as_get_datetime_object( $when, $timezone );
274
-	}
11
+    private static $plugin_file = '';
12
+    /** @var ActionScheduler_ActionFactory */
13
+    private static $factory = NULL;
14
+
15
+    public static function factory() {
16
+        if ( !isset(self::$factory) ) {
17
+            self::$factory = new ActionScheduler_ActionFactory();
18
+        }
19
+        return self::$factory;
20
+    }
21
+
22
+    public static function store() {
23
+        return ActionScheduler_Store::instance();
24
+    }
25
+
26
+    public static function lock() {
27
+        return ActionScheduler_Lock::instance();
28
+    }
29
+
30
+    public static function logger() {
31
+        return ActionScheduler_Logger::instance();
32
+    }
33
+
34
+    public static function runner() {
35
+        return ActionScheduler_QueueRunner::instance();
36
+    }
37
+
38
+    public static function admin_view() {
39
+        return ActionScheduler_AdminView::instance();
40
+    }
41
+
42
+    /**
43
+     * Get the absolute system path to the plugin directory, or a file therein
44
+     * @static
45
+     * @param string $path
46
+     * @return string
47
+     */
48
+    public static function plugin_path( $path ) {
49
+        $base = dirname(self::$plugin_file);
50
+        if ( $path ) {
51
+            return trailingslashit($base).$path;
52
+        } else {
53
+            return untrailingslashit($base);
54
+        }
55
+    }
56
+
57
+    /**
58
+     * Get the absolute URL to the plugin directory, or a file therein
59
+     * @static
60
+     * @param string $path
61
+     * @return string
62
+     */
63
+    public static function plugin_url( $path ) {
64
+        return plugins_url($path, self::$plugin_file);
65
+    }
66
+
67
+    public static function autoload( $class ) {
68
+        $d           = DIRECTORY_SEPARATOR;
69
+        $classes_dir = self::plugin_path( 'classes' . $d );
70
+        $separator   = strrpos( $class, '\\' );
71
+        if ( false !== $separator ) {
72
+            if ( 0 !== strpos( $class, 'Action_Scheduler' ) ) {
73
+                return;
74
+            }
75
+            $class = substr( $class, $separator + 1 );
76
+        }
77
+
78
+        if ( 'Deprecated' === substr( $class, -10 ) ) {
79
+            $dir = self::plugin_path( 'deprecated' . $d );
80
+        } elseif ( self::is_class_abstract( $class ) ) {
81
+            $dir = $classes_dir . 'abstracts' . $d;
82
+        } elseif ( self::is_class_migration( $class ) ) {
83
+            $dir = $classes_dir . 'migration' . $d;
84
+        } elseif ( 'Schedule' === substr( $class, -8 ) ) {
85
+            $dir = $classes_dir . 'schedules' . $d;
86
+        } elseif ( 'Action' === substr( $class, -6 ) ) {
87
+            $dir = $classes_dir . 'actions' . $d;
88
+        } elseif ( 'Schema' === substr( $class, -6 ) ) {
89
+            $dir = $classes_dir . 'schema' . $d;
90
+        } elseif ( strpos( $class, 'ActionScheduler' ) === 0 ) {
91
+            $segments = explode( '_', $class );
92
+            $type = isset( $segments[ 1 ] ) ? $segments[ 1 ] : '';
93
+
94
+            switch ( $type ) {
95
+                case 'WPCLI':
96
+                    $dir = $classes_dir . 'WP_CLI' . $d;
97
+                    break;
98
+                case 'DBLogger':
99
+                case 'DBStore':
100
+                case 'HybridStore':
101
+                case 'wpPostStore':
102
+                case 'wpCommentLogger':
103
+                    $dir = $classes_dir . 'data-stores' . $d;
104
+                    break;
105
+                default:
106
+                    $dir = $classes_dir;
107
+                    break;
108
+            }
109
+        } elseif ( self::is_class_cli( $class ) ) {
110
+            $dir = $classes_dir . 'WP_CLI' . $d;
111
+        } elseif ( strpos( $class, 'CronExpression' ) === 0 ) {
112
+            $dir = self::plugin_path( 'lib' . $d . 'cron-expression' . $d );
113
+        } elseif ( strpos( $class, 'WP_Async_Request' ) === 0 ) {
114
+            $dir = self::plugin_path( 'lib' . $d );
115
+        } else {
116
+            return;
117
+        }
118
+
119
+        if ( file_exists( "{$dir}{$class}.php" ) ) {
120
+            include( "{$dir}{$class}.php" );
121
+            return;
122
+        }
123
+    }
124
+
125
+    /**
126
+     * Initialize the plugin
127
+     *
128
+     * @static
129
+     * @param string $plugin_file
130
+     */
131
+    public static function init( $plugin_file ) {
132
+        self::$plugin_file = $plugin_file;
133
+        spl_autoload_register( array( __CLASS__, 'autoload' ) );
134
+
135
+        /**
136
+         * Fires in the early stages of Action Scheduler init hook.
137
+         */
138
+        do_action( 'action_scheduler_pre_init' );
139
+
140
+        require_once( self::plugin_path( 'functions.php' ) );
141
+        ActionScheduler_DataController::init();
142
+
143
+        $store      = self::store();
144
+        $logger     = self::logger();
145
+        $runner     = self::runner();
146
+        $admin_view = self::admin_view();
147
+
148
+        // Ensure initialization on plugin activation.
149
+        if ( ! did_action( 'init' ) ) {
150
+            add_action( 'init', array( $admin_view, 'init' ), 0, 0 ); // run before $store::init()
151
+            add_action( 'init', array( $store, 'init' ), 1, 0 );
152
+            add_action( 'init', array( $logger, 'init' ), 1, 0 );
153
+            add_action( 'init', array( $runner, 'init' ), 1, 0 );
154
+        } else {
155
+            $admin_view->init();
156
+            $store->init();
157
+            $logger->init();
158
+            $runner->init();
159
+        }
160
+
161
+        if ( apply_filters( 'action_scheduler_load_deprecated_functions', true ) ) {
162
+            require_once( self::plugin_path( 'deprecated/functions.php' ) );
163
+        }
164
+
165
+        if ( defined( 'WP_CLI' ) && WP_CLI ) {
166
+            WP_CLI::add_command( 'action-scheduler', 'ActionScheduler_WPCLI_Scheduler_command' );
167
+            if ( ! ActionScheduler_DataController::is_migration_complete() && Controller::instance()->allow_migration() ) {
168
+                $command = new Migration_Command();
169
+                $command->register();
170
+            }
171
+        }
172
+
173
+        /**
174
+         * Handle WP comment cleanup after migration.
175
+         */
176
+        if ( is_a( $logger, 'ActionScheduler_DBLogger' ) && ActionScheduler_DataController::is_migration_complete() && ActionScheduler_WPCommentCleaner::has_logs() ) {
177
+            ActionScheduler_WPCommentCleaner::init();
178
+        }
179
+
180
+        add_action( 'action_scheduler/migration_complete', 'ActionScheduler_WPCommentCleaner::maybe_schedule_cleanup' );
181
+    }
182
+
183
+    /**
184
+     * Determine if the class is one of our abstract classes.
185
+     *
186
+     * @since 3.0.0
187
+     *
188
+     * @param string $class The class name.
189
+     *
190
+     * @return bool
191
+     */
192
+    protected static function is_class_abstract( $class ) {
193
+        static $abstracts = array(
194
+            'ActionScheduler'                            => true,
195
+            'ActionScheduler_Abstract_ListTable'         => true,
196
+            'ActionScheduler_Abstract_QueueRunner'       => true,
197
+            'ActionScheduler_Abstract_Schedule'          => true,
198
+            'ActionScheduler_Abstract_RecurringSchedule' => true,
199
+            'ActionScheduler_Lock'                       => true,
200
+            'ActionScheduler_Logger'                     => true,
201
+            'ActionScheduler_Abstract_Schema'            => true,
202
+            'ActionScheduler_Store'                      => true,
203
+            'ActionScheduler_TimezoneHelper'             => true,
204
+        );
205
+
206
+        return isset( $abstracts[ $class ] ) && $abstracts[ $class ];
207
+    }
208
+
209
+    /**
210
+     * Determine if the class is one of our migration classes.
211
+     *
212
+     * @since 3.0.0
213
+     *
214
+     * @param string $class The class name.
215
+     *
216
+     * @return bool
217
+     */
218
+    protected static function is_class_migration( $class ) {
219
+        static $migration_segments = array(
220
+            'ActionMigrator'  => true,
221
+            'BatchFetcher'    => true,
222
+            'DBStoreMigrator' => true,
223
+            'DryRun'          => true,
224
+            'LogMigrator'     => true,
225
+            'Config'          => true,
226
+            'Controller'      => true,
227
+            'Runner'          => true,
228
+            'Scheduler'       => true,
229
+        );
230
+
231
+        $segments = explode( '_', $class );
232
+        $segment = isset( $segments[ 1 ] ) ? $segments[ 1 ] : $class;
233
+
234
+        return isset( $migration_segments[ $segment ] ) && $migration_segments[ $segment ];
235
+    }
236
+
237
+    /**
238
+     * Determine if the class is one of our WP CLI classes.
239
+     *
240
+     * @since 3.0.0
241
+     *
242
+     * @param string $class The class name.
243
+     *
244
+     * @return bool
245
+     */
246
+    protected static function is_class_cli( $class ) {
247
+        static $cli_segments = array(
248
+            'QueueRunner' => true,
249
+            'Command'     => true,
250
+            'ProgressBar' => true,
251
+        );
252
+
253
+        $segments = explode( '_', $class );
254
+        $segment = isset( $segments[ 1 ] ) ? $segments[ 1 ] : $class;
255
+
256
+        return isset( $cli_segments[ $segment ] ) && $cli_segments[ $segment ];
257
+    }
258
+
259
+    final public function __clone() {
260
+        trigger_error("Singleton. No cloning allowed!", E_USER_ERROR);
261
+    }
262
+
263
+    final public function __wakeup() {
264
+        trigger_error("Singleton. No serialization allowed!", E_USER_ERROR);
265
+    }
266
+
267
+    final private function __construct() {}
268
+
269
+    /** Deprecated **/
270
+
271
+    public static function get_datetime_object( $when = null, $timezone = 'UTC' ) {
272
+        _deprecated_function( __METHOD__, '2.0', 'wcs_add_months()' );
273
+        return as_get_datetime_object( $when, $timezone );
274
+    }
275 275
 }
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	private static $factory = NULL;
14 14
 
15 15
 	public static function factory() {
16
-		if ( !isset(self::$factory) ) {
16
+		if (!isset(self::$factory)) {
17 17
 			self::$factory = new ActionScheduler_ActionFactory();
18 18
 		}
19 19
 		return self::$factory;
@@ -45,10 +45,10 @@  discard block
 block discarded – undo
45 45
 	 * @param string $path
46 46
 	 * @return string
47 47
 	 */
48
-	public static function plugin_path( $path ) {
48
+	public static function plugin_path($path) {
49 49
 		$base = dirname(self::$plugin_file);
50
-		if ( $path ) {
51
-			return trailingslashit($base).$path;
50
+		if ($path) {
51
+			return trailingslashit($base) . $path;
52 52
 		} else {
53 53
 			return untrailingslashit($base);
54 54
 		}
@@ -60,38 +60,38 @@  discard block
 block discarded – undo
60 60
 	 * @param string $path
61 61
 	 * @return string
62 62
 	 */
63
-	public static function plugin_url( $path ) {
63
+	public static function plugin_url($path) {
64 64
 		return plugins_url($path, self::$plugin_file);
65 65
 	}
66 66
 
67
-	public static function autoload( $class ) {
67
+	public static function autoload($class) {
68 68
 		$d           = DIRECTORY_SEPARATOR;
69
-		$classes_dir = self::plugin_path( 'classes' . $d );
70
-		$separator   = strrpos( $class, '\\' );
71
-		if ( false !== $separator ) {
72
-			if ( 0 !== strpos( $class, 'Action_Scheduler' ) ) {
69
+		$classes_dir = self::plugin_path('classes' . $d);
70
+		$separator   = strrpos($class, '\\');
71
+		if (false !== $separator) {
72
+			if (0 !== strpos($class, 'Action_Scheduler')) {
73 73
 				return;
74 74
 			}
75
-			$class = substr( $class, $separator + 1 );
75
+			$class = substr($class, $separator + 1);
76 76
 		}
77 77
 
78
-		if ( 'Deprecated' === substr( $class, -10 ) ) {
79
-			$dir = self::plugin_path( 'deprecated' . $d );
80
-		} elseif ( self::is_class_abstract( $class ) ) {
78
+		if ('Deprecated' === substr($class, -10)) {
79
+			$dir = self::plugin_path('deprecated' . $d);
80
+		} elseif (self::is_class_abstract($class)) {
81 81
 			$dir = $classes_dir . 'abstracts' . $d;
82
-		} elseif ( self::is_class_migration( $class ) ) {
82
+		} elseif (self::is_class_migration($class)) {
83 83
 			$dir = $classes_dir . 'migration' . $d;
84
-		} elseif ( 'Schedule' === substr( $class, -8 ) ) {
84
+		} elseif ('Schedule' === substr($class, -8)) {
85 85
 			$dir = $classes_dir . 'schedules' . $d;
86
-		} elseif ( 'Action' === substr( $class, -6 ) ) {
86
+		} elseif ('Action' === substr($class, -6)) {
87 87
 			$dir = $classes_dir . 'actions' . $d;
88
-		} elseif ( 'Schema' === substr( $class, -6 ) ) {
88
+		} elseif ('Schema' === substr($class, -6)) {
89 89
 			$dir = $classes_dir . 'schema' . $d;
90
-		} elseif ( strpos( $class, 'ActionScheduler' ) === 0 ) {
91
-			$segments = explode( '_', $class );
92
-			$type = isset( $segments[ 1 ] ) ? $segments[ 1 ] : '';
90
+		} elseif (strpos($class, 'ActionScheduler') === 0) {
91
+			$segments = explode('_', $class);
92
+			$type = isset($segments[1]) ? $segments[1] : '';
93 93
 
94
-			switch ( $type ) {
94
+			switch ($type) {
95 95
 				case 'WPCLI':
96 96
 					$dir = $classes_dir . 'WP_CLI' . $d;
97 97
 					break;
@@ -106,18 +106,18 @@  discard block
 block discarded – undo
106 106
 					$dir = $classes_dir;
107 107
 					break;
108 108
 			}
109
-		} elseif ( self::is_class_cli( $class ) ) {
109
+		} elseif (self::is_class_cli($class)) {
110 110
 			$dir = $classes_dir . 'WP_CLI' . $d;
111
-		} elseif ( strpos( $class, 'CronExpression' ) === 0 ) {
112
-			$dir = self::plugin_path( 'lib' . $d . 'cron-expression' . $d );
113
-		} elseif ( strpos( $class, 'WP_Async_Request' ) === 0 ) {
114
-			$dir = self::plugin_path( 'lib' . $d );
111
+		} elseif (strpos($class, 'CronExpression') === 0) {
112
+			$dir = self::plugin_path('lib' . $d . 'cron-expression' . $d);
113
+		} elseif (strpos($class, 'WP_Async_Request') === 0) {
114
+			$dir = self::plugin_path('lib' . $d);
115 115
 		} else {
116 116
 			return;
117 117
 		}
118 118
 
119
-		if ( file_exists( "{$dir}{$class}.php" ) ) {
120
-			include( "{$dir}{$class}.php" );
119
+		if (file_exists("{$dir}{$class}.php")) {
120
+			include("{$dir}{$class}.php");
121 121
 			return;
122 122
 		}
123 123
 	}
@@ -128,16 +128,16 @@  discard block
 block discarded – undo
128 128
 	 * @static
129 129
 	 * @param string $plugin_file
130 130
 	 */
131
-	public static function init( $plugin_file ) {
131
+	public static function init($plugin_file) {
132 132
 		self::$plugin_file = $plugin_file;
133
-		spl_autoload_register( array( __CLASS__, 'autoload' ) );
133
+		spl_autoload_register(array(__CLASS__, 'autoload'));
134 134
 
135 135
 		/**
136 136
 		 * Fires in the early stages of Action Scheduler init hook.
137 137
 		 */
138
-		do_action( 'action_scheduler_pre_init' );
138
+		do_action('action_scheduler_pre_init');
139 139
 
140
-		require_once( self::plugin_path( 'functions.php' ) );
140
+		require_once(self::plugin_path('functions.php'));
141 141
 		ActionScheduler_DataController::init();
142 142
 
143 143
 		$store      = self::store();
@@ -146,11 +146,11 @@  discard block
 block discarded – undo
146 146
 		$admin_view = self::admin_view();
147 147
 
148 148
 		// Ensure initialization on plugin activation.
149
-		if ( ! did_action( 'init' ) ) {
150
-			add_action( 'init', array( $admin_view, 'init' ), 0, 0 ); // run before $store::init()
151
-			add_action( 'init', array( $store, 'init' ), 1, 0 );
152
-			add_action( 'init', array( $logger, 'init' ), 1, 0 );
153
-			add_action( 'init', array( $runner, 'init' ), 1, 0 );
149
+		if (!did_action('init')) {
150
+			add_action('init', array($admin_view, 'init'), 0, 0); // run before $store::init()
151
+			add_action('init', array($store, 'init'), 1, 0);
152
+			add_action('init', array($logger, 'init'), 1, 0);
153
+			add_action('init', array($runner, 'init'), 1, 0);
154 154
 		} else {
155 155
 			$admin_view->init();
156 156
 			$store->init();
@@ -158,13 +158,13 @@  discard block
 block discarded – undo
158 158
 			$runner->init();
159 159
 		}
160 160
 
161
-		if ( apply_filters( 'action_scheduler_load_deprecated_functions', true ) ) {
162
-			require_once( self::plugin_path( 'deprecated/functions.php' ) );
161
+		if (apply_filters('action_scheduler_load_deprecated_functions', true)) {
162
+			require_once(self::plugin_path('deprecated/functions.php'));
163 163
 		}
164 164
 
165
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
166
-			WP_CLI::add_command( 'action-scheduler', 'ActionScheduler_WPCLI_Scheduler_command' );
167
-			if ( ! ActionScheduler_DataController::is_migration_complete() && Controller::instance()->allow_migration() ) {
165
+		if (defined('WP_CLI') && WP_CLI) {
166
+			WP_CLI::add_command('action-scheduler', 'ActionScheduler_WPCLI_Scheduler_command');
167
+			if (!ActionScheduler_DataController::is_migration_complete() && Controller::instance()->allow_migration()) {
168 168
 				$command = new Migration_Command();
169 169
 				$command->register();
170 170
 			}
@@ -173,11 +173,11 @@  discard block
 block discarded – undo
173 173
 		/**
174 174
 		 * Handle WP comment cleanup after migration.
175 175
 		 */
176
-		if ( is_a( $logger, 'ActionScheduler_DBLogger' ) && ActionScheduler_DataController::is_migration_complete() && ActionScheduler_WPCommentCleaner::has_logs() ) {
176
+		if (is_a($logger, 'ActionScheduler_DBLogger') && ActionScheduler_DataController::is_migration_complete() && ActionScheduler_WPCommentCleaner::has_logs()) {
177 177
 			ActionScheduler_WPCommentCleaner::init();
178 178
 		}
179 179
 
180
-		add_action( 'action_scheduler/migration_complete', 'ActionScheduler_WPCommentCleaner::maybe_schedule_cleanup' );
180
+		add_action('action_scheduler/migration_complete', 'ActionScheduler_WPCommentCleaner::maybe_schedule_cleanup');
181 181
 	}
182 182
 
183 183
 	/**
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 *
190 190
 	 * @return bool
191 191
 	 */
192
-	protected static function is_class_abstract( $class ) {
192
+	protected static function is_class_abstract($class) {
193 193
 		static $abstracts = array(
194 194
 			'ActionScheduler'                            => true,
195 195
 			'ActionScheduler_Abstract_ListTable'         => true,
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 			'ActionScheduler_TimezoneHelper'             => true,
204 204
 		);
205 205
 
206
-		return isset( $abstracts[ $class ] ) && $abstracts[ $class ];
206
+		return isset($abstracts[$class]) && $abstracts[$class];
207 207
 	}
208 208
 
209 209
 	/**
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	 *
216 216
 	 * @return bool
217 217
 	 */
218
-	protected static function is_class_migration( $class ) {
218
+	protected static function is_class_migration($class) {
219 219
 		static $migration_segments = array(
220 220
 			'ActionMigrator'  => true,
221 221
 			'BatchFetcher'    => true,
@@ -228,10 +228,10 @@  discard block
 block discarded – undo
228 228
 			'Scheduler'       => true,
229 229
 		);
230 230
 
231
-		$segments = explode( '_', $class );
232
-		$segment = isset( $segments[ 1 ] ) ? $segments[ 1 ] : $class;
231
+		$segments = explode('_', $class);
232
+		$segment = isset($segments[1]) ? $segments[1] : $class;
233 233
 
234
-		return isset( $migration_segments[ $segment ] ) && $migration_segments[ $segment ];
234
+		return isset($migration_segments[$segment]) && $migration_segments[$segment];
235 235
 	}
236 236
 
237 237
 	/**
@@ -243,17 +243,17 @@  discard block
 block discarded – undo
243 243
 	 *
244 244
 	 * @return bool
245 245
 	 */
246
-	protected static function is_class_cli( $class ) {
246
+	protected static function is_class_cli($class) {
247 247
 		static $cli_segments = array(
248 248
 			'QueueRunner' => true,
249 249
 			'Command'     => true,
250 250
 			'ProgressBar' => true,
251 251
 		);
252 252
 
253
-		$segments = explode( '_', $class );
254
-		$segment = isset( $segments[ 1 ] ) ? $segments[ 1 ] : $class;
253
+		$segments = explode('_', $class);
254
+		$segment = isset($segments[1]) ? $segments[1] : $class;
255 255
 
256
-		return isset( $cli_segments[ $segment ] ) && $cli_segments[ $segment ];
256
+		return isset($cli_segments[$segment]) && $cli_segments[$segment];
257 257
 	}
258 258
 
259 259
 	final public function __clone() {
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
 
269 269
 	/** Deprecated **/
270 270
 
271
-	public static function get_datetime_object( $when = null, $timezone = 'UTC' ) {
272
-		_deprecated_function( __METHOD__, '2.0', 'wcs_add_months()' );
273
-		return as_get_datetime_object( $when, $timezone );
271
+	public static function get_datetime_object($when = null, $timezone = 'UTC') {
272
+		_deprecated_function(__METHOD__, '2.0', 'wcs_add_months()');
273
+		return as_get_datetime_object($when, $timezone);
274 274
 	}
275 275
 }
Please login to merge, or discard this patch.
action-scheduler/classes/abstracts/ActionScheduler_Abstract_Schema.php 2 patches
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -12,124 +12,124 @@
 block discarded – undo
12 12
  */
13 13
 abstract class ActionScheduler_Abstract_Schema {
14 14
 
15
-	/**
16
-	 * @var int Increment this value in derived class to trigger a schema update.
17
-	 */
18
-	protected $schema_version = 1;
19
-
20
-	/**
21
-	 * @var array Names of tables that will be registered by this class.
22
-	 */
23
-	protected $tables = [];
24
-
25
-	/**
26
-	 * Register tables with WordPress, and create them if needed.
27
-	 *
28
-	 * @param bool $force_update Optional. Default false. Use true to always run the schema update.
29
-	 *
30
-	 * @return void
31
-	 */
32
-	public function register_tables( $force_update = false ) {
33
-		global $wpdb;
34
-
35
-		// make WP aware of our tables
36
-		foreach ( $this->tables as $table ) {
37
-			$wpdb->tables[] = $table;
38
-			$name           = $this->get_full_table_name( $table );
39
-			$wpdb->$table   = $name;
40
-		}
41
-
42
-		// create the tables
43
-		if ( $this->schema_update_required() || $force_update ) {
44
-			foreach ( $this->tables as $table ) {
45
-				$this->update_table( $table );
46
-			}
47
-			$this->mark_schema_update_complete();
48
-		}
49
-	}
50
-
51
-	/**
52
-	 * @param string $table The name of the table
53
-	 *
54
-	 * @return string The CREATE TABLE statement, suitable for passing to dbDelta
55
-	 */
56
-	abstract protected function get_table_definition( $table );
57
-
58
-	/**
59
-	 * Determine if the database schema is out of date
60
-	 * by comparing the integer found in $this->schema_version
61
-	 * with the option set in the WordPress options table
62
-	 *
63
-	 * @return bool
64
-	 */
65
-	private function schema_update_required() {
66
-		$option_name         = 'schema-' . static::class;
67
-		$version_found_in_db = get_option( $option_name, 0 );
68
-
69
-		// Check for schema option stored by the Action Scheduler Custom Tables plugin in case site has migrated from that plugin with an older schema
70
-		if ( 0 === $version_found_in_db ) {
71
-
72
-			$plugin_option_name = 'schema-';
73
-
74
-			switch ( static::class ) {
75
-				case 'ActionScheduler_StoreSchema' :
76
-					$plugin_option_name .= 'Action_Scheduler\Custom_Tables\DB_Store_Table_Maker';
77
-					break;
78
-				case 'ActionScheduler_LoggerSchema' :
79
-					$plugin_option_name .= 'Action_Scheduler\Custom_Tables\DB_Logger_Table_Maker';
80
-					break;
81
-			}
82
-
83
-			$version_found_in_db = get_option( $plugin_option_name, 0 );
84
-
85
-			delete_option( $plugin_option_name );
86
-		}
87
-
88
-		return version_compare( $version_found_in_db, $this->schema_version, '<' );
89
-	}
90
-
91
-	/**
92
-	 * Update the option in WordPress to indicate that
93
-	 * our schema is now up to date
94
-	 *
95
-	 * @return void
96
-	 */
97
-	private function mark_schema_update_complete() {
98
-		$option_name = 'schema-' . static::class;
99
-
100
-		// work around race conditions and ensure that our option updates
101
-		$value_to_save = (string) $this->schema_version . '.0.' . time();
102
-
103
-		update_option( $option_name, $value_to_save );
104
-	}
105
-
106
-	/**
107
-	 * Update the schema for the given table
108
-	 *
109
-	 * @param string $table The name of the table to update
110
-	 *
111
-	 * @return void
112
-	 */
113
-	private function update_table( $table ) {
114
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
115
-		$definition = $this->get_table_definition( $table );
116
-		if ( $definition ) {
117
-			$updated = dbDelta( $definition );
118
-			foreach ( $updated as $updated_table => $update_description ) {
119
-				if ( strpos( $update_description, 'Created table' ) === 0 ) {
120
-					do_action( 'action_scheduler/created_table', $updated_table, $table );
121
-				}
122
-			}
123
-		}
124
-	}
125
-
126
-	/**
127
-	 * @param string $table
128
-	 *
129
-	 * @return string The full name of the table, including the
130
-	 *                table prefix for the current blog
131
-	 */
132
-	protected function get_full_table_name( $table ) {
133
-		return $GLOBALS[ 'wpdb' ]->prefix . $table;
134
-	}
15
+    /**
16
+     * @var int Increment this value in derived class to trigger a schema update.
17
+     */
18
+    protected $schema_version = 1;
19
+
20
+    /**
21
+     * @var array Names of tables that will be registered by this class.
22
+     */
23
+    protected $tables = [];
24
+
25
+    /**
26
+     * Register tables with WordPress, and create them if needed.
27
+     *
28
+     * @param bool $force_update Optional. Default false. Use true to always run the schema update.
29
+     *
30
+     * @return void
31
+     */
32
+    public function register_tables( $force_update = false ) {
33
+        global $wpdb;
34
+
35
+        // make WP aware of our tables
36
+        foreach ( $this->tables as $table ) {
37
+            $wpdb->tables[] = $table;
38
+            $name           = $this->get_full_table_name( $table );
39
+            $wpdb->$table   = $name;
40
+        }
41
+
42
+        // create the tables
43
+        if ( $this->schema_update_required() || $force_update ) {
44
+            foreach ( $this->tables as $table ) {
45
+                $this->update_table( $table );
46
+            }
47
+            $this->mark_schema_update_complete();
48
+        }
49
+    }
50
+
51
+    /**
52
+     * @param string $table The name of the table
53
+     *
54
+     * @return string The CREATE TABLE statement, suitable for passing to dbDelta
55
+     */
56
+    abstract protected function get_table_definition( $table );
57
+
58
+    /**
59
+     * Determine if the database schema is out of date
60
+     * by comparing the integer found in $this->schema_version
61
+     * with the option set in the WordPress options table
62
+     *
63
+     * @return bool
64
+     */
65
+    private function schema_update_required() {
66
+        $option_name         = 'schema-' . static::class;
67
+        $version_found_in_db = get_option( $option_name, 0 );
68
+
69
+        // Check for schema option stored by the Action Scheduler Custom Tables plugin in case site has migrated from that plugin with an older schema
70
+        if ( 0 === $version_found_in_db ) {
71
+
72
+            $plugin_option_name = 'schema-';
73
+
74
+            switch ( static::class ) {
75
+                case 'ActionScheduler_StoreSchema' :
76
+                    $plugin_option_name .= 'Action_Scheduler\Custom_Tables\DB_Store_Table_Maker';
77
+                    break;
78
+                case 'ActionScheduler_LoggerSchema' :
79
+                    $plugin_option_name .= 'Action_Scheduler\Custom_Tables\DB_Logger_Table_Maker';
80
+                    break;
81
+            }
82
+
83
+            $version_found_in_db = get_option( $plugin_option_name, 0 );
84
+
85
+            delete_option( $plugin_option_name );
86
+        }
87
+
88
+        return version_compare( $version_found_in_db, $this->schema_version, '<' );
89
+    }
90
+
91
+    /**
92
+     * Update the option in WordPress to indicate that
93
+     * our schema is now up to date
94
+     *
95
+     * @return void
96
+     */
97
+    private function mark_schema_update_complete() {
98
+        $option_name = 'schema-' . static::class;
99
+
100
+        // work around race conditions and ensure that our option updates
101
+        $value_to_save = (string) $this->schema_version . '.0.' . time();
102
+
103
+        update_option( $option_name, $value_to_save );
104
+    }
105
+
106
+    /**
107
+     * Update the schema for the given table
108
+     *
109
+     * @param string $table The name of the table to update
110
+     *
111
+     * @return void
112
+     */
113
+    private function update_table( $table ) {
114
+        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
115
+        $definition = $this->get_table_definition( $table );
116
+        if ( $definition ) {
117
+            $updated = dbDelta( $definition );
118
+            foreach ( $updated as $updated_table => $update_description ) {
119
+                if ( strpos( $update_description, 'Created table' ) === 0 ) {
120
+                    do_action( 'action_scheduler/created_table', $updated_table, $table );
121
+                }
122
+            }
123
+        }
124
+    }
125
+
126
+    /**
127
+     * @param string $table
128
+     *
129
+     * @return string The full name of the table, including the
130
+     *                table prefix for the current blog
131
+     */
132
+    protected function get_full_table_name( $table ) {
133
+        return $GLOBALS[ 'wpdb' ]->prefix . $table;
134
+    }
135 135
 }
136 136
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -29,20 +29,20 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @return void
31 31
 	 */
32
-	public function register_tables( $force_update = false ) {
32
+	public function register_tables($force_update = false) {
33 33
 		global $wpdb;
34 34
 
35 35
 		// make WP aware of our tables
36
-		foreach ( $this->tables as $table ) {
36
+		foreach ($this->tables as $table) {
37 37
 			$wpdb->tables[] = $table;
38
-			$name           = $this->get_full_table_name( $table );
38
+			$name           = $this->get_full_table_name($table);
39 39
 			$wpdb->$table   = $name;
40 40
 		}
41 41
 
42 42
 		// create the tables
43
-		if ( $this->schema_update_required() || $force_update ) {
44
-			foreach ( $this->tables as $table ) {
45
-				$this->update_table( $table );
43
+		if ($this->schema_update_required() || $force_update) {
44
+			foreach ($this->tables as $table) {
45
+				$this->update_table($table);
46 46
 			}
47 47
 			$this->mark_schema_update_complete();
48 48
 		}
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @return string The CREATE TABLE statement, suitable for passing to dbDelta
55 55
 	 */
56
-	abstract protected function get_table_definition( $table );
56
+	abstract protected function get_table_definition($table);
57 57
 
58 58
 	/**
59 59
 	 * Determine if the database schema is out of date
@@ -64,14 +64,14 @@  discard block
 block discarded – undo
64 64
 	 */
65 65
 	private function schema_update_required() {
66 66
 		$option_name         = 'schema-' . static::class;
67
-		$version_found_in_db = get_option( $option_name, 0 );
67
+		$version_found_in_db = get_option($option_name, 0);
68 68
 
69 69
 		// Check for schema option stored by the Action Scheduler Custom Tables plugin in case site has migrated from that plugin with an older schema
70
-		if ( 0 === $version_found_in_db ) {
70
+		if (0 === $version_found_in_db) {
71 71
 
72 72
 			$plugin_option_name = 'schema-';
73 73
 
74
-			switch ( static::class ) {
74
+			switch (static::class) {
75 75
 				case 'ActionScheduler_StoreSchema' :
76 76
 					$plugin_option_name .= 'Action_Scheduler\Custom_Tables\DB_Store_Table_Maker';
77 77
 					break;
@@ -80,12 +80,12 @@  discard block
 block discarded – undo
80 80
 					break;
81 81
 			}
82 82
 
83
-			$version_found_in_db = get_option( $plugin_option_name, 0 );
83
+			$version_found_in_db = get_option($plugin_option_name, 0);
84 84
 
85
-			delete_option( $plugin_option_name );
85
+			delete_option($plugin_option_name);
86 86
 		}
87 87
 
88
-		return version_compare( $version_found_in_db, $this->schema_version, '<' );
88
+		return version_compare($version_found_in_db, $this->schema_version, '<');
89 89
 	}
90 90
 
91 91
 	/**
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 		// work around race conditions and ensure that our option updates
101 101
 		$value_to_save = (string) $this->schema_version . '.0.' . time();
102 102
 
103
-		update_option( $option_name, $value_to_save );
103
+		update_option($option_name, $value_to_save);
104 104
 	}
105 105
 
106 106
 	/**
@@ -110,14 +110,14 @@  discard block
 block discarded – undo
110 110
 	 *
111 111
 	 * @return void
112 112
 	 */
113
-	private function update_table( $table ) {
114
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
115
-		$definition = $this->get_table_definition( $table );
116
-		if ( $definition ) {
117
-			$updated = dbDelta( $definition );
118
-			foreach ( $updated as $updated_table => $update_description ) {
119
-				if ( strpos( $update_description, 'Created table' ) === 0 ) {
120
-					do_action( 'action_scheduler/created_table', $updated_table, $table );
113
+	private function update_table($table) {
114
+		require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
115
+		$definition = $this->get_table_definition($table);
116
+		if ($definition) {
117
+			$updated = dbDelta($definition);
118
+			foreach ($updated as $updated_table => $update_description) {
119
+				if (strpos($update_description, 'Created table') === 0) {
120
+					do_action('action_scheduler/created_table', $updated_table, $table);
121 121
 				}
122 122
 			}
123 123
 		}
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	 * @return string The full name of the table, including the
130 130
 	 *                table prefix for the current blog
131 131
 	 */
132
-	protected function get_full_table_name( $table ) {
133
-		return $GLOBALS[ 'wpdb' ]->prefix . $table;
132
+	protected function get_full_table_name($table) {
133
+		return $GLOBALS['wpdb']->prefix . $table;
134 134
 	}
135 135
 }
136 136
\ No newline at end of file
Please login to merge, or discard this patch.
libraries/action-scheduler/classes/ActionScheduler_Compatibility.php 2 patches
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -5,95 +5,95 @@
 block discarded – undo
5 5
  */
6 6
 class ActionScheduler_Compatibility {
7 7
 
8
-	/**
9
-	 * Converts a shorthand byte value to an integer byte value.
10
-	 *
11
-	 * Wrapper for wp_convert_hr_to_bytes(), moved to load.php in WordPress 4.6 from media.php
12
-	 *
13
-	 * @link https://secure.php.net/manual/en/function.ini-get.php
14
-	 * @link https://secure.php.net/manual/en/faq.using.php#faq.using.shorthandbytes
15
-	 *
16
-	 * @param string $value A (PHP ini) byte value, either shorthand or ordinary.
17
-	 * @return int An integer byte value.
18
-	 */
19
-	public static function convert_hr_to_bytes( $value ) {
20
-		if ( function_exists( 'wp_convert_hr_to_bytes' ) ) {
21
-			return wp_convert_hr_to_bytes( $value );
22
-		}
8
+    /**
9
+     * Converts a shorthand byte value to an integer byte value.
10
+     *
11
+     * Wrapper for wp_convert_hr_to_bytes(), moved to load.php in WordPress 4.6 from media.php
12
+     *
13
+     * @link https://secure.php.net/manual/en/function.ini-get.php
14
+     * @link https://secure.php.net/manual/en/faq.using.php#faq.using.shorthandbytes
15
+     *
16
+     * @param string $value A (PHP ini) byte value, either shorthand or ordinary.
17
+     * @return int An integer byte value.
18
+     */
19
+    public static function convert_hr_to_bytes( $value ) {
20
+        if ( function_exists( 'wp_convert_hr_to_bytes' ) ) {
21
+            return wp_convert_hr_to_bytes( $value );
22
+        }
23 23
 
24
-		$value = strtolower( trim( $value ) );
25
-		$bytes = (int) $value;
24
+        $value = strtolower( trim( $value ) );
25
+        $bytes = (int) $value;
26 26
 
27
-		if ( false !== strpos( $value, 'g' ) ) {
28
-			$bytes *= GB_IN_BYTES;
29
-		} elseif ( false !== strpos( $value, 'm' ) ) {
30
-			$bytes *= MB_IN_BYTES;
31
-		} elseif ( false !== strpos( $value, 'k' ) ) {
32
-			$bytes *= KB_IN_BYTES;
33
-		}
27
+        if ( false !== strpos( $value, 'g' ) ) {
28
+            $bytes *= GB_IN_BYTES;
29
+        } elseif ( false !== strpos( $value, 'm' ) ) {
30
+            $bytes *= MB_IN_BYTES;
31
+        } elseif ( false !== strpos( $value, 'k' ) ) {
32
+            $bytes *= KB_IN_BYTES;
33
+        }
34 34
 
35
-		// Deal with large (float) values which run into the maximum integer size.
36
-		return min( $bytes, PHP_INT_MAX );
37
-	}
35
+        // Deal with large (float) values which run into the maximum integer size.
36
+        return min( $bytes, PHP_INT_MAX );
37
+    }
38 38
 
39
-	/**
40
-	 * Attempts to raise the PHP memory limit for memory intensive processes.
41
-	 *
42
-	 * Only allows raising the existing limit and prevents lowering it.
43
-	 *
44
-	 * Wrapper for wp_raise_memory_limit(), added in WordPress v4.6.0
45
-	 *
46
-	 * @return bool|int|string The limit that was set or false on failure.
47
-	 */
48
-	public static function raise_memory_limit() {
49
-		if ( function_exists( 'wp_raise_memory_limit' ) ) {
50
-			return wp_raise_memory_limit( 'admin' );
51
-		}
39
+    /**
40
+     * Attempts to raise the PHP memory limit for memory intensive processes.
41
+     *
42
+     * Only allows raising the existing limit and prevents lowering it.
43
+     *
44
+     * Wrapper for wp_raise_memory_limit(), added in WordPress v4.6.0
45
+     *
46
+     * @return bool|int|string The limit that was set or false on failure.
47
+     */
48
+    public static function raise_memory_limit() {
49
+        if ( function_exists( 'wp_raise_memory_limit' ) ) {
50
+            return wp_raise_memory_limit( 'admin' );
51
+        }
52 52
 
53
-		$current_limit     = @ini_get( 'memory_limit' );
54
-		$current_limit_int = self::convert_hr_to_bytes( $current_limit );
53
+        $current_limit     = @ini_get( 'memory_limit' );
54
+        $current_limit_int = self::convert_hr_to_bytes( $current_limit );
55 55
 
56
-		if ( -1 === $current_limit_int ) {
57
-			return false;
58
-		}
56
+        if ( -1 === $current_limit_int ) {
57
+            return false;
58
+        }
59 59
 
60
-		$wp_max_limit       = WP_MAX_MEMORY_LIMIT;
61
-		$wp_max_limit_int   = self::convert_hr_to_bytes( $wp_max_limit );
62
-		$filtered_limit     = apply_filters( 'admin_memory_limit', $wp_max_limit );
63
-		$filtered_limit_int = self::convert_hr_to_bytes( $filtered_limit );
60
+        $wp_max_limit       = WP_MAX_MEMORY_LIMIT;
61
+        $wp_max_limit_int   = self::convert_hr_to_bytes( $wp_max_limit );
62
+        $filtered_limit     = apply_filters( 'admin_memory_limit', $wp_max_limit );
63
+        $filtered_limit_int = self::convert_hr_to_bytes( $filtered_limit );
64 64
 
65
-		if ( -1 === $filtered_limit_int || ( $filtered_limit_int > $wp_max_limit_int && $filtered_limit_int > $current_limit_int ) ) {
66
-			if ( false !== @ini_set( 'memory_limit', $filtered_limit ) ) {
67
-				return $filtered_limit;
68
-			} else {
69
-				return false;
70
-			}
71
-		} elseif ( -1 === $wp_max_limit_int || $wp_max_limit_int > $current_limit_int ) {
72
-			if ( false !== @ini_set( 'memory_limit', $wp_max_limit ) ) {
73
-				return $wp_max_limit;
74
-			} else {
75
-				return false;
76
-			}
77
-		}
78
-		return false;
79
-	}
65
+        if ( -1 === $filtered_limit_int || ( $filtered_limit_int > $wp_max_limit_int && $filtered_limit_int > $current_limit_int ) ) {
66
+            if ( false !== @ini_set( 'memory_limit', $filtered_limit ) ) {
67
+                return $filtered_limit;
68
+            } else {
69
+                return false;
70
+            }
71
+        } elseif ( -1 === $wp_max_limit_int || $wp_max_limit_int > $current_limit_int ) {
72
+            if ( false !== @ini_set( 'memory_limit', $wp_max_limit ) ) {
73
+                return $wp_max_limit;
74
+            } else {
75
+                return false;
76
+            }
77
+        }
78
+        return false;
79
+    }
80 80
 
81
-	/**
82
-	 * Attempts to raise the PHP timeout for time intensive processes.
83
-	 *
84
-	 * Only allows raising the existing limit and prevents lowering it. Wrapper for wc_set_time_limit(), when available.
85
-	 *
86
-	 * @param int The time limit in seconds.
87
-	 */
88
-	public static function raise_time_limit( $limit = 0 ) {
89
-		if ( $limit < ini_get( 'max_execution_time' ) ) {
90
-			return;
91
-		}
81
+    /**
82
+     * Attempts to raise the PHP timeout for time intensive processes.
83
+     *
84
+     * Only allows raising the existing limit and prevents lowering it. Wrapper for wc_set_time_limit(), when available.
85
+     *
86
+     * @param int The time limit in seconds.
87
+     */
88
+    public static function raise_time_limit( $limit = 0 ) {
89
+        if ( $limit < ini_get( 'max_execution_time' ) ) {
90
+            return;
91
+        }
92 92
 
93
-		if ( function_exists( 'wc_set_time_limit' ) ) {
94
-			wc_set_time_limit( $limit );
95
-		} elseif ( function_exists( 'set_time_limit' ) && false === strpos( ini_get( 'disable_functions' ), 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
96
-			@set_time_limit( $limit );
97
-		}
98
-	}
93
+        if ( function_exists( 'wc_set_time_limit' ) ) {
94
+            wc_set_time_limit( $limit );
95
+        } elseif ( function_exists( 'set_time_limit' ) && false === strpos( ini_get( 'disable_functions' ), 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
96
+            @set_time_limit( $limit );
97
+        }
98
+    }
99 99
 }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -16,24 +16,24 @@  discard block
 block discarded – undo
16 16
 	 * @param string $value A (PHP ini) byte value, either shorthand or ordinary.
17 17
 	 * @return int An integer byte value.
18 18
 	 */
19
-	public static function convert_hr_to_bytes( $value ) {
20
-		if ( function_exists( 'wp_convert_hr_to_bytes' ) ) {
21
-			return wp_convert_hr_to_bytes( $value );
19
+	public static function convert_hr_to_bytes($value) {
20
+		if (function_exists('wp_convert_hr_to_bytes')) {
21
+			return wp_convert_hr_to_bytes($value);
22 22
 		}
23 23
 
24
-		$value = strtolower( trim( $value ) );
24
+		$value = strtolower(trim($value));
25 25
 		$bytes = (int) $value;
26 26
 
27
-		if ( false !== strpos( $value, 'g' ) ) {
27
+		if (false !== strpos($value, 'g')) {
28 28
 			$bytes *= GB_IN_BYTES;
29
-		} elseif ( false !== strpos( $value, 'm' ) ) {
29
+		} elseif (false !== strpos($value, 'm')) {
30 30
 			$bytes *= MB_IN_BYTES;
31
-		} elseif ( false !== strpos( $value, 'k' ) ) {
31
+		} elseif (false !== strpos($value, 'k')) {
32 32
 			$bytes *= KB_IN_BYTES;
33 33
 		}
34 34
 
35 35
 		// Deal with large (float) values which run into the maximum integer size.
36
-		return min( $bytes, PHP_INT_MAX );
36
+		return min($bytes, PHP_INT_MAX);
37 37
 	}
38 38
 
39 39
 	/**
@@ -46,30 +46,30 @@  discard block
 block discarded – undo
46 46
 	 * @return bool|int|string The limit that was set or false on failure.
47 47
 	 */
48 48
 	public static function raise_memory_limit() {
49
-		if ( function_exists( 'wp_raise_memory_limit' ) ) {
50
-			return wp_raise_memory_limit( 'admin' );
49
+		if (function_exists('wp_raise_memory_limit')) {
50
+			return wp_raise_memory_limit('admin');
51 51
 		}
52 52
 
53
-		$current_limit     = @ini_get( 'memory_limit' );
54
-		$current_limit_int = self::convert_hr_to_bytes( $current_limit );
53
+		$current_limit     = @ini_get('memory_limit');
54
+		$current_limit_int = self::convert_hr_to_bytes($current_limit);
55 55
 
56 56
 		if ( -1 === $current_limit_int ) {
57 57
 			return false;
58 58
 		}
59 59
 
60 60
 		$wp_max_limit       = WP_MAX_MEMORY_LIMIT;
61
-		$wp_max_limit_int   = self::convert_hr_to_bytes( $wp_max_limit );
62
-		$filtered_limit     = apply_filters( 'admin_memory_limit', $wp_max_limit );
63
-		$filtered_limit_int = self::convert_hr_to_bytes( $filtered_limit );
61
+		$wp_max_limit_int   = self::convert_hr_to_bytes($wp_max_limit);
62
+		$filtered_limit     = apply_filters('admin_memory_limit', $wp_max_limit);
63
+		$filtered_limit_int = self::convert_hr_to_bytes($filtered_limit);
64 64
 
65
-		if ( -1 === $filtered_limit_int || ( $filtered_limit_int > $wp_max_limit_int && $filtered_limit_int > $current_limit_int ) ) {
66
-			if ( false !== @ini_set( 'memory_limit', $filtered_limit ) ) {
65
+		if ( -1 === $filtered_limit_int || ($filtered_limit_int > $wp_max_limit_int && $filtered_limit_int > $current_limit_int) ) {
66
+			if (false !== @ini_set('memory_limit', $filtered_limit)) {
67 67
 				return $filtered_limit;
68 68
 			} else {
69 69
 				return false;
70 70
 			}
71 71
 		} elseif ( -1 === $wp_max_limit_int || $wp_max_limit_int > $current_limit_int ) {
72
-			if ( false !== @ini_set( 'memory_limit', $wp_max_limit ) ) {
72
+			if (false !== @ini_set('memory_limit', $wp_max_limit)) {
73 73
 				return $wp_max_limit;
74 74
 			} else {
75 75
 				return false;
@@ -85,15 +85,15 @@  discard block
 block discarded – undo
85 85
 	 *
86 86
 	 * @param int The time limit in seconds.
87 87
 	 */
88
-	public static function raise_time_limit( $limit = 0 ) {
89
-		if ( $limit < ini_get( 'max_execution_time' ) ) {
88
+	public static function raise_time_limit($limit = 0) {
89
+		if ($limit < ini_get('max_execution_time')) {
90 90
 			return;
91 91
 		}
92 92
 
93
-		if ( function_exists( 'wc_set_time_limit' ) ) {
94
-			wc_set_time_limit( $limit );
95
-		} elseif ( function_exists( 'set_time_limit' ) && false === strpos( ini_get( 'disable_functions' ), 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
96
-			@set_time_limit( $limit );
93
+		if (function_exists('wc_set_time_limit')) {
94
+			wc_set_time_limit($limit);
95
+		} elseif (function_exists('set_time_limit') && false === strpos(ini_get('disable_functions'), 'set_time_limit') && !ini_get('safe_mode')) {
96
+			@set_time_limit($limit);
97 97
 		}
98 98
 	}
99 99
 }
Please login to merge, or discard this patch.
includes/libraries/action-scheduler/lib/WP_Async_Request.php 2 patches
Indentation   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -14,157 +14,157 @@
 block discarded – undo
14 14
 
15 15
 if ( ! class_exists( 'WP_Async_Request' ) ) {
16 16
 
17
-	/**
18
-	 * Abstract WP_Async_Request class.
19
-	 *
20
-	 * @abstract
21
-	 */
22
-	abstract class WP_Async_Request {
23
-
24
-		/**
25
-		 * Prefix
26
-		 *
27
-		 * (default value: 'wp')
28
-		 *
29
-		 * @var string
30
-		 * @access protected
31
-		 */
32
-		protected $prefix = 'wp';
33
-
34
-		/**
35
-		 * Action
36
-		 *
37
-		 * (default value: 'async_request')
38
-		 *
39
-		 * @var string
40
-		 * @access protected
41
-		 */
42
-		protected $action = 'async_request';
43
-
44
-		/**
45
-		 * Identifier
46
-		 *
47
-		 * @var mixed
48
-		 * @access protected
49
-		 */
50
-		protected $identifier;
51
-
52
-		/**
53
-		 * Data
54
-		 *
55
-		 * (default value: array())
56
-		 *
57
-		 * @var array
58
-		 * @access protected
59
-		 */
60
-		protected $data = array();
61
-
62
-		/**
63
-		 * Initiate new async request
64
-		 */
65
-		public function __construct() {
66
-			$this->identifier = $this->prefix . '_' . $this->action;
67
-
68
-			add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) );
69
-			add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) );
70
-		}
71
-
72
-		/**
73
-		 * Set data used during the request
74
-		 *
75
-		 * @param array $data Data.
76
-		 *
77
-		 * @return $this
78
-		 */
79
-		public function data( $data ) {
80
-			$this->data = $data;
81
-
82
-			return $this;
83
-		}
84
-
85
-		/**
86
-		 * Dispatch the async request
87
-		 *
88
-		 * @return array|WP_Error
89
-		 */
90
-		public function dispatch() {
91
-			$url  = add_query_arg( $this->get_query_args(), $this->get_query_url() );
92
-			$args = $this->get_post_args();
93
-
94
-			return wp_remote_post( esc_url_raw( $url ), $args );
95
-		}
96
-
97
-		/**
98
-		 * Get query args
99
-		 *
100
-		 * @return array
101
-		 */
102
-		protected function get_query_args() {
103
-			if ( property_exists( $this, 'query_args' ) ) {
104
-				return $this->query_args;
105
-			}
106
-
107
-			return array(
108
-				'action' => $this->identifier,
109
-				'nonce'  => wp_create_nonce( $this->identifier ),
110
-			);
111
-		}
112
-
113
-		/**
114
-		 * Get query URL
115
-		 *
116
-		 * @return string
117
-		 */
118
-		protected function get_query_url() {
119
-			if ( property_exists( $this, 'query_url' ) ) {
120
-				return $this->query_url;
121
-			}
122
-
123
-			return admin_url( 'admin-ajax.php' );
124
-		}
125
-
126
-		/**
127
-		 * Get post args
128
-		 *
129
-		 * @return array
130
-		 */
131
-		protected function get_post_args() {
132
-			if ( property_exists( $this, 'post_args' ) ) {
133
-				return $this->post_args;
134
-			}
135
-
136
-			return array(
137
-				'timeout'   => 0.01,
138
-				'blocking'  => false,
139
-				'body'      => $this->data,
140
-				'cookies'   => $_COOKIE,
141
-				'sslverify' => apply_filters( 'https_local_ssl_verify', false ),
142
-			);
143
-		}
144
-
145
-		/**
146
-		 * Maybe handle
147
-		 *
148
-		 * Check for correct nonce and pass to handler.
149
-		 */
150
-		public function maybe_handle() {
151
-			// Don't lock up other requests while processing
152
-			session_write_close();
153
-
154
-			check_ajax_referer( $this->identifier, 'nonce' );
155
-
156
-			$this->handle();
157
-
158
-			wp_die();
159
-		}
160
-
161
-		/**
162
-		 * Handle
163
-		 *
164
-		 * Override this method to perform any actions required
165
-		 * during the async request.
166
-		 */
167
-		abstract protected function handle();
168
-
169
-	}
17
+    /**
18
+     * Abstract WP_Async_Request class.
19
+     *
20
+     * @abstract
21
+     */
22
+    abstract class WP_Async_Request {
23
+
24
+        /**
25
+         * Prefix
26
+         *
27
+         * (default value: 'wp')
28
+         *
29
+         * @var string
30
+         * @access protected
31
+         */
32
+        protected $prefix = 'wp';
33
+
34
+        /**
35
+         * Action
36
+         *
37
+         * (default value: 'async_request')
38
+         *
39
+         * @var string
40
+         * @access protected
41
+         */
42
+        protected $action = 'async_request';
43
+
44
+        /**
45
+         * Identifier
46
+         *
47
+         * @var mixed
48
+         * @access protected
49
+         */
50
+        protected $identifier;
51
+
52
+        /**
53
+         * Data
54
+         *
55
+         * (default value: array())
56
+         *
57
+         * @var array
58
+         * @access protected
59
+         */
60
+        protected $data = array();
61
+
62
+        /**
63
+         * Initiate new async request
64
+         */
65
+        public function __construct() {
66
+            $this->identifier = $this->prefix . '_' . $this->action;
67
+
68
+            add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) );
69
+            add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) );
70
+        }
71
+
72
+        /**
73
+         * Set data used during the request
74
+         *
75
+         * @param array $data Data.
76
+         *
77
+         * @return $this
78
+         */
79
+        public function data( $data ) {
80
+            $this->data = $data;
81
+
82
+            return $this;
83
+        }
84
+
85
+        /**
86
+         * Dispatch the async request
87
+         *
88
+         * @return array|WP_Error
89
+         */
90
+        public function dispatch() {
91
+            $url  = add_query_arg( $this->get_query_args(), $this->get_query_url() );
92
+            $args = $this->get_post_args();
93
+
94
+            return wp_remote_post( esc_url_raw( $url ), $args );
95
+        }
96
+
97
+        /**
98
+         * Get query args
99
+         *
100
+         * @return array
101
+         */
102
+        protected function get_query_args() {
103
+            if ( property_exists( $this, 'query_args' ) ) {
104
+                return $this->query_args;
105
+            }
106
+
107
+            return array(
108
+                'action' => $this->identifier,
109
+                'nonce'  => wp_create_nonce( $this->identifier ),
110
+            );
111
+        }
112
+
113
+        /**
114
+         * Get query URL
115
+         *
116
+         * @return string
117
+         */
118
+        protected function get_query_url() {
119
+            if ( property_exists( $this, 'query_url' ) ) {
120
+                return $this->query_url;
121
+            }
122
+
123
+            return admin_url( 'admin-ajax.php' );
124
+        }
125
+
126
+        /**
127
+         * Get post args
128
+         *
129
+         * @return array
130
+         */
131
+        protected function get_post_args() {
132
+            if ( property_exists( $this, 'post_args' ) ) {
133
+                return $this->post_args;
134
+            }
135
+
136
+            return array(
137
+                'timeout'   => 0.01,
138
+                'blocking'  => false,
139
+                'body'      => $this->data,
140
+                'cookies'   => $_COOKIE,
141
+                'sslverify' => apply_filters( 'https_local_ssl_verify', false ),
142
+            );
143
+        }
144
+
145
+        /**
146
+         * Maybe handle
147
+         *
148
+         * Check for correct nonce and pass to handler.
149
+         */
150
+        public function maybe_handle() {
151
+            // Don't lock up other requests while processing
152
+            session_write_close();
153
+
154
+            check_ajax_referer( $this->identifier, 'nonce' );
155
+
156
+            $this->handle();
157
+
158
+            wp_die();
159
+        }
160
+
161
+        /**
162
+         * Handle
163
+         *
164
+         * Override this method to perform any actions required
165
+         * during the async request.
166
+         */
167
+        abstract protected function handle();
168
+
169
+    }
170 170
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 License URI: https://github.com/deliciousbrains/wp-background-processing/commit/126d7945dd3d39f39cb6488ca08fe1fb66cb351a
13 13
 */
14 14
 
15
-if ( ! class_exists( 'WP_Async_Request' ) ) {
15
+if (!class_exists('WP_Async_Request')) {
16 16
 
17 17
 	/**
18 18
 	 * Abstract WP_Async_Request class.
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
 		public function __construct() {
66 66
 			$this->identifier = $this->prefix . '_' . $this->action;
67 67
 
68
-			add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) );
69
-			add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) );
68
+			add_action('wp_ajax_' . $this->identifier, array($this, 'maybe_handle'));
69
+			add_action('wp_ajax_nopriv_' . $this->identifier, array($this, 'maybe_handle'));
70 70
 		}
71 71
 
72 72
 		/**
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 		 *
77 77
 		 * @return $this
78 78
 		 */
79
-		public function data( $data ) {
79
+		public function data($data) {
80 80
 			$this->data = $data;
81 81
 
82 82
 			return $this;
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
 		 * @return array|WP_Error
89 89
 		 */
90 90
 		public function dispatch() {
91
-			$url  = add_query_arg( $this->get_query_args(), $this->get_query_url() );
91
+			$url  = add_query_arg($this->get_query_args(), $this->get_query_url());
92 92
 			$args = $this->get_post_args();
93 93
 
94
-			return wp_remote_post( esc_url_raw( $url ), $args );
94
+			return wp_remote_post(esc_url_raw($url), $args);
95 95
 		}
96 96
 
97 97
 		/**
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
 		 * @return array
101 101
 		 */
102 102
 		protected function get_query_args() {
103
-			if ( property_exists( $this, 'query_args' ) ) {
103
+			if (property_exists($this, 'query_args')) {
104 104
 				return $this->query_args;
105 105
 			}
106 106
 
107 107
 			return array(
108 108
 				'action' => $this->identifier,
109
-				'nonce'  => wp_create_nonce( $this->identifier ),
109
+				'nonce'  => wp_create_nonce($this->identifier),
110 110
 			);
111 111
 		}
112 112
 
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 		 * @return string
117 117
 		 */
118 118
 		protected function get_query_url() {
119
-			if ( property_exists( $this, 'query_url' ) ) {
119
+			if (property_exists($this, 'query_url')) {
120 120
 				return $this->query_url;
121 121
 			}
122 122
 
123
-			return admin_url( 'admin-ajax.php' );
123
+			return admin_url('admin-ajax.php');
124 124
 		}
125 125
 
126 126
 		/**
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 		 * @return array
130 130
 		 */
131 131
 		protected function get_post_args() {
132
-			if ( property_exists( $this, 'post_args' ) ) {
132
+			if (property_exists($this, 'post_args')) {
133 133
 				return $this->post_args;
134 134
 			}
135 135
 
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 				'blocking'  => false,
139 139
 				'body'      => $this->data,
140 140
 				'cookies'   => $_COOKIE,
141
-				'sslverify' => apply_filters( 'https_local_ssl_verify', false ),
141
+				'sslverify' => apply_filters('https_local_ssl_verify', false),
142 142
 			);
143 143
 		}
144 144
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 			// Don't lock up other requests while processing
152 152
 			session_write_close();
153 153
 
154
-			check_ajax_referer( $this->identifier, 'nonce' );
154
+			check_ajax_referer($this->identifier, 'nonce');
155 155
 
156 156
 			$this->handle();
157 157
 
Please login to merge, or discard this patch.