Passed
Push — master ( 0a9164...47344e )
by Brian
20:43
created
libraries/action-scheduler/classes/abstracts/ActionScheduler_Lock.php 1 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 1 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 1 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 1 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 1 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.
action-scheduler/lib/cron-expression/CronExpression_AbstractField.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@
 block discarded – undo
89 89
             return false;
90 90
         }
91 91
 
92
-        for ($i = $offset; $i <= $to; $i+= $stepSize) {
92
+        for ($i = $offset; $i <= $to; $i += $stepSize) {
93 93
             if ($i == $dateValue) {
94 94
                 return true;
95 95
             }
Please login to merge, or discard this patch.
includes/libraries/action-scheduler/lib/cron-expression/CronExpression.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -240,7 +240,7 @@
 block discarded – undo
240 240
             $currentTime = new DateTime($currentTime);
241 241
             $currentTime->setTime($currentTime->format('H'), $currentTime->format('i'), 0);
242 242
             $currentDate = $currentTime->format('Y-m-d H:i');
243
-            $currentTime = (int)($currentTime->getTimestamp());
243
+            $currentTime = (int) ($currentTime->getTimestamp());
244 244
         }
245 245
 
246 246
         return $this->getNextRunDate($currentDate, 0, true)->getTimestamp() == $currentTime;
Please login to merge, or discard this patch.
includes/gateways/manual.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly
3
-if ( ! defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5
-add_action( 'wpinv_manual_cc_form', '__return_false' );
6
-add_filter( 'wpinv_manual_support_subscription', '__return_true' );
5
+add_action('wpinv_manual_cc_form', '__return_false');
6
+add_filter('wpinv_manual_support_subscription', '__return_true');
7 7
 
8
-function wpinv_process_manual_payment( $purchase_data ) {
9
-    if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) {
10
-        wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
8
+function wpinv_process_manual_payment($purchase_data) {
9
+    if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) {
10
+        wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
11 11
     }
12 12
 
13 13
     /*
@@ -42,45 +42,45 @@  discard block
 block discarded – undo
42 42
     );
43 43
 
44 44
     // Record the pending payment
45
-    $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] );
45
+    $invoice = wpinv_get_invoice($purchase_data['invoice_id']);
46 46
     
47
-    if ( !empty( $invoice ) ) {        
48
-        wpinv_set_payment_transaction_id( $invoice->ID, $invoice->generate_key() );
49
-        wpinv_update_payment_status( $invoice, 'publish' );
47
+    if (!empty($invoice)) {        
48
+        wpinv_set_payment_transaction_id($invoice->ID, $invoice->generate_key());
49
+        wpinv_update_payment_status($invoice, 'publish');
50 50
         
51 51
         // Empty the shopping cart
52 52
         wpinv_empty_cart();
53 53
 
54 54
         // (Maybe) set recurring hooks.
55
-        wpinv_start_manual_subscription_profile( $purchase_data['invoice_id'] );
55
+        wpinv_start_manual_subscription_profile($purchase_data['invoice_id']);
56 56
         
57
-        do_action( 'wpinv_send_to_success_page', $invoice->ID, $payment_data );
57
+        do_action('wpinv_send_to_success_page', $invoice->ID, $payment_data);
58 58
         
59
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
59
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
60 60
     } else {
61
-        wpinv_record_gateway_error( __( 'Payment Error', 'invoicing' ), sprintf( __( 'Payment creation failed while processing a manual (free or test) purchase. Payment data: %s', 'invoicing' ), json_encode( $payment_data ) ), $invoice );
61
+        wpinv_record_gateway_error(__('Payment Error', 'invoicing'), sprintf(__('Payment creation failed while processing a manual (free or test) purchase. Payment data: %s', 'invoicing'), json_encode($payment_data)), $invoice);
62 62
         // If errors are present, send the user back to the purchase page so they can be corrected
63
-        wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] );
63
+        wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']);
64 64
     }
65 65
 }
66
-add_action( 'wpinv_gateway_manual', 'wpinv_process_manual_payment' );
66
+add_action('wpinv_gateway_manual', 'wpinv_process_manual_payment');
67 67
 
68 68
 /**
69 69
  * Starts a manual subscription profile.
70 70
  */
71
-function wpinv_start_manual_subscription_profile( $invoice_id ) {
71
+function wpinv_start_manual_subscription_profile($invoice_id) {
72 72
 
73 73
     // Retrieve the subscription.
74
-    $subscription = wpinv_get_subscription( $invoice_id );
75
-    if ( empty( $subscription ) ) {
74
+    $subscription = wpinv_get_subscription($invoice_id);
75
+    if (empty($subscription)) {
76 76
         return;
77 77
     }
78 78
 
79 79
     // Schedule an action to run when the subscription expires.
80 80
     $action_id = as_schedule_single_action(
81
-        strtotime( $subscription->expiration ),
81
+        strtotime($subscription->expiration),
82 82
         'wpinv_renew_manual_subscription_profile',
83
-        array( $invoice_id ),
83
+        array($invoice_id),
84 84
         'invoicing'
85 85
     );
86 86
 
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
 /**
98 98
  * Renews a manual subscription profile.
99 99
  */
100
-function wpinv_renew_manual_subscription_profile( $invoice_id ) {
100
+function wpinv_renew_manual_subscription_profile($invoice_id) {
101 101
 
102 102
     // Retrieve the subscription.
103
-    $subscription = wpinv_get_subscription( $invoice_id );
104
-    if ( empty( $subscription ) ) {
103
+    $subscription = wpinv_get_subscription($invoice_id);
104
+    if (empty($subscription)) {
105 105
         return;
106 106
     }
107 107
 
@@ -109,29 +109,29 @@  discard block
 block discarded – undo
109 109
     $max_bills    = $subscription->bill_times;
110 110
 
111 111
     // If we have not maxed out on bill times...
112
-    if ( empty( $bill_times ) || $times_billed > $max_bills ) {
112
+    if (empty($bill_times) || $times_billed > $max_bills) {
113 113
 
114 114
         // Renew the subscription.
115
-        $subscription->add_payment( array(
115
+        $subscription->add_payment(array(
116 116
             'amount'         => $subscription->recurring_amount,
117 117
             'transaction_id' => time(),
118 118
             'gateway'        => 'manual'
119
-        ) );
119
+        ));
120 120
 
121 121
         // Calculate the new expiration.
122
-        $new_expiration = strtotime( "+ {$subscription->frequency} {$subscription->period}", strtotime( $subscription->expiration ) );
122
+        $new_expiration = strtotime("+ {$subscription->frequency} {$subscription->period}", strtotime($subscription->expiration));
123 123
 
124 124
         // Schedule an action to run when the subscription expires.
125 125
         $action_id = as_schedule_single_action(
126 126
             $new_expiration,
127 127
             'wpinv_renew_manual_subscription_profile',
128
-            array( $invoice_id ),
128
+            array($invoice_id),
129 129
             'invoicing'
130 130
         );
131 131
 
132 132
         $subscription->update(
133 133
             array(
134
-                'expiration' => date_i18n( 'Y-m-d H:i:s', $new_expiration ),
134
+                'expiration' => date_i18n('Y-m-d H:i:s', $new_expiration),
135 135
                 'status'     => 'active',
136 136
                 'profile_id' => $action_id, 
137 137
             )
@@ -149,4 +149,4 @@  discard block
 block discarded – undo
149 149
     }
150 150
 
151 151
 }
152
-add_action( 'wpinv_renew_manual_subscription_profile', 'wpinv_renew_manual_subscription_profile' );
152
+add_action('wpinv_renew_manual_subscription_profile', 'wpinv_renew_manual_subscription_profile');
Please login to merge, or discard this patch.
includes/class-wpinv-subscriptions.php 1 patch
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly.
3
-if (!defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5 5
 function wpinv_subscription_init() {
6 6
     return WPInv_Subscriptions::instance();
7 7
 }
8
-add_action( 'plugins_loaded', 'wpinv_subscription_init', 100 );
8
+add_action('plugins_loaded', 'wpinv_subscription_init', 100);
9 9
 
10 10
 /**
11 11
  * WPInv_Subscriptions Class.
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
      * Main WPInv_Subscriptions Instance
21 21
      */
22 22
     public static function instance() {
23
-        if ( ! isset( self::$instance ) ) {
23
+        if (!isset(self::$instance)) {
24 24
             self::$instance = new WPInv_Subscriptions;
25 25
 
26 26
             self::$instance->init();
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      *
35 35
      * @since 1.0.0
36 36
      */
37
-    private function __construct(){
37
+    private function __construct() {
38 38
 
39 39
     }
40 40
 
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
     private function setup_constants() {
64 64
 
65 65
         // Make sure CAL_GREGORIAN is defined.
66
-        if ( ! defined( 'CAL_GREGORIAN' ) ) {
67
-            define( 'CAL_GREGORIAN', 1 );
66
+        if (!defined('CAL_GREGORIAN')) {
67
+            define('CAL_GREGORIAN', 1);
68 68
         }
69 69
     }
70 70
 
@@ -76,13 +76,13 @@  discard block
 block discarded – undo
76 76
      */
77 77
     private function actions() {
78 78
 
79
-        add_action( 'admin_menu', array( $this, 'wpinv_subscriptions_list' ), 10 );
80
-        add_action( 'admin_notices', array( $this, 'notices' ) );
81
-        add_action( 'init', array( $this, 'wpinv_post_actions' ) );
82
-        add_action( 'init', array( $this, 'wpinv_get_actions' ) );
83
-        add_action( 'wpinv_cancel_subscription', array( $this, 'wpinv_process_cancellation' ) );
84
-        add_action( 'wpinv_checkout_before_send_to_gateway', array( $this, 'wpinv_checkout_add_subscription' ), -999, 2 );
85
-        add_action( 'wpinv_subscriptions_front_notices', array( $this, 'notices' ) );
79
+        add_action('admin_menu', array($this, 'wpinv_subscriptions_list'), 10);
80
+        add_action('admin_notices', array($this, 'notices'));
81
+        add_action('init', array($this, 'wpinv_post_actions'));
82
+        add_action('init', array($this, 'wpinv_get_actions'));
83
+        add_action('wpinv_cancel_subscription', array($this, 'wpinv_process_cancellation'));
84
+        add_action('wpinv_checkout_before_send_to_gateway', array($this, 'wpinv_checkout_add_subscription'), -999, 2);
85
+        add_action('wpinv_subscriptions_front_notices', array($this, 'notices'));
86 86
     }
87 87
 
88 88
     /**
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
     public function wpinv_subscriptions_list() {
105 105
         add_submenu_page(
106 106
             'wpinv',
107
-            __( 'Subscriptions', 'invoicing' ),
108
-            __( 'Subscriptions', 'invoicing' ),
107
+            __('Subscriptions', 'invoicing'),
108
+            __('Subscriptions', 'invoicing'),
109 109
             wpinv_get_capability(),
110 110
             'wpinv-subscriptions',
111 111
             'wpinv_subscriptions_page'
@@ -114,37 +114,37 @@  discard block
 block discarded – undo
114 114
 
115 115
     public function notices() {
116 116
 
117
-        if( empty( $_GET['wpinv-message'] ) ) {
117
+        if (empty($_GET['wpinv-message'])) {
118 118
             return;
119 119
         }
120 120
 
121 121
         $type    = 'updated';
122 122
         $message = '';
123 123
 
124
-        switch( strtolower( $_GET['wpinv-message'] ) ) {
124
+        switch (strtolower($_GET['wpinv-message'])) {
125 125
 
126 126
             case 'updated' :
127 127
 
128
-                $message = __( 'Subscription updated successfully.', 'invoicing' );
128
+                $message = __('Subscription updated successfully.', 'invoicing');
129 129
 
130 130
                 break;
131 131
 
132 132
             case 'deleted' :
133 133
 
134
-                $message = __( 'Subscription deleted successfully.', 'invoicing' );
134
+                $message = __('Subscription deleted successfully.', 'invoicing');
135 135
 
136 136
                 break;
137 137
 
138 138
             case 'cancelled' :
139 139
 
140
-                $message = __( 'Subscription cancelled successfully.', 'invoicing' );
140
+                $message = __('Subscription cancelled successfully.', 'invoicing');
141 141
 
142 142
                 break;
143 143
 
144 144
         }
145 145
 
146
-        if ( ! empty( $message ) ) {
147
-            echo '<div class="' . esc_attr( $type ) . '"><p>' . $message . '</p></div>';
146
+        if (!empty($message)) {
147
+            echo '<div class="' . esc_attr($type) . '"><p>' . $message . '</p></div>';
148 148
         }
149 149
 
150 150
     }
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
      * @return void
158 158
      */
159 159
     function wpinv_get_actions() {
160
-        if ( isset( $_GET['wpinv_action'] ) ) {
161
-            do_action( 'wpinv_' . $_GET['wpinv_action'], $_GET );
160
+        if (isset($_GET['wpinv_action'])) {
161
+            do_action('wpinv_' . $_GET['wpinv_action'], $_GET);
162 162
         }
163 163
     }
164 164
 
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
      * @return void
171 171
      */
172 172
     function wpinv_post_actions() {
173
-        if ( isset( $_POST['wpinv_action'] ) ) {
174
-            do_action( 'wpinv_' . $_POST['wpinv_action'], $_POST );
173
+        if (isset($_POST['wpinv_action'])) {
174
+            do_action('wpinv_' . $_POST['wpinv_action'], $_POST);
175 175
         }
176 176
     }
177 177
 
@@ -182,24 +182,24 @@  discard block
 block discarded – undo
182 182
      * @param int $frequency_count The frequency of the period.
183 183
      * @return mixed|string|void
184 184
      */
185
-    public static function wpinv_get_pretty_subscription_frequency( $period, $frequency_count = 1) {
185
+    public static function wpinv_get_pretty_subscription_frequency($period, $frequency_count = 1) {
186 186
         $frequency = '';
187 187
         //Format period details
188
-        switch ( $period ) {
188
+        switch ($period) {
189 189
             case 'day' :
190
-                $frequency = sprintf( _n('%d Day', '%d Days', $frequency_count, 'invoicing'), $frequency_count);
190
+                $frequency = sprintf(_n('%d Day', '%d Days', $frequency_count, 'invoicing'), $frequency_count);
191 191
                 break;
192 192
             case 'week' :
193
-                $frequency = sprintf( _n('%d Week', '%d Weeks', $frequency_count, 'invoicing'), $frequency_count);
193
+                $frequency = sprintf(_n('%d Week', '%d Weeks', $frequency_count, 'invoicing'), $frequency_count);
194 194
                 break;
195 195
             case 'month' :
196
-                $frequency = sprintf( _n('%d Month', '%d Months', $frequency_count, 'invoicing'), $frequency_count);
196
+                $frequency = sprintf(_n('%d Month', '%d Months', $frequency_count, 'invoicing'), $frequency_count);
197 197
                 break;
198 198
             case 'year' :
199
-                $frequency = sprintf( _n('%d Year', '%d Years', $frequency_count, 'invoicing'), $frequency_count);
199
+                $frequency = sprintf(_n('%d Year', '%d Years', $frequency_count, 'invoicing'), $frequency_count);
200 200
                 break;
201 201
             default :
202
-                $frequency = apply_filters( 'wpinv_recurring_subscription_frequency', $frequency, $period, $frequency_count );
202
+                $frequency = apply_filters('wpinv_recurring_subscription_frequency', $frequency, $period, $frequency_count);
203 203
                 break;
204 204
         }
205 205
 
@@ -214,50 +214,50 @@  discard block
 block discarded – undo
214 214
      * @since       1.0.0
215 215
      * @return      void
216 216
      */
217
-    public function wpinv_process_cancellation( $data ) {
217
+    public function wpinv_process_cancellation($data) {
218 218
 
219 219
 
220
-        if( empty( $data['sub_id'] ) ) {
220
+        if (empty($data['sub_id'])) {
221 221
             return;
222 222
         }
223 223
 
224
-        if( ! is_user_logged_in() ) {
224
+        if (!is_user_logged_in()) {
225 225
             return;
226 226
         }
227 227
 
228
-        if( ! wp_verify_nonce( $data['_wpnonce'], 'wpinv-recurring-cancel' ) ) {
229
-            wp_die( __( 'Error', 'invoicing' ), __( 'Nonce verification failed', 'invoicing' ), array( 'response' => 403 ) );
228
+        if (!wp_verify_nonce($data['_wpnonce'], 'wpinv-recurring-cancel')) {
229
+            wp_die(__('Error', 'invoicing'), __('Nonce verification failed', 'invoicing'), array('response' => 403));
230 230
         }
231 231
 
232
-        $data['sub_id'] = absint( $data['sub_id'] );
233
-        $subscription   = new WPInv_Subscription( $data['sub_id'] );
232
+        $data['sub_id'] = absint($data['sub_id']);
233
+        $subscription   = new WPInv_Subscription($data['sub_id']);
234 234
 
235
-        if( ! $subscription->can_cancel() ) {
236
-            wp_die( __( 'Error', 'invoicing' ), __( 'This subscription cannot be cancelled', 'invoicing' ), array( 'response' => 403 ) );
235
+        if (!$subscription->can_cancel()) {
236
+            wp_die(__('Error', 'invoicing'), __('This subscription cannot be cancelled', 'invoicing'), array('response' => 403));
237 237
         }
238 238
 
239 239
         try {
240 240
 
241
-            do_action( 'wpinv_recurring_cancel_' . $subscription->gateway . '_subscription', $subscription, true );
241
+            do_action('wpinv_recurring_cancel_' . $subscription->gateway . '_subscription', $subscription, true);
242 242
 
243 243
             $subscription->cancel();
244 244
 
245
-            if( is_admin() ) {
245
+            if (is_admin()) {
246 246
 
247
-                wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=cancelled&id=' . $subscription->id ) );
247
+                wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=cancelled&id=' . $subscription->id));
248 248
                 exit;
249 249
 
250 250
             } else {
251 251
 
252
-                $redirect = remove_query_arg( array( '_wpnonce', 'wpinv_action', 'sub_id' ), add_query_arg( array( 'wpinv-message' => 'cancelled' ) ) );
253
-                $redirect = apply_filters( 'wpinv_recurring_cancellation_redirect', $redirect, $subscription );
254
-                wp_safe_redirect( $redirect );
252
+                $redirect = remove_query_arg(array('_wpnonce', 'wpinv_action', 'sub_id'), add_query_arg(array('wpinv-message' => 'cancelled')));
253
+                $redirect = apply_filters('wpinv_recurring_cancellation_redirect', $redirect, $subscription);
254
+                wp_safe_redirect($redirect);
255 255
                 exit;
256 256
 
257 257
             }
258 258
 
259
-        } catch ( Exception $e ) {
260
-            wp_die( __( 'Error', 'invoicing' ), $e->getMessage(), array( 'response' => 403 ) );
259
+        } catch (Exception $e) {
260
+            wp_die(__('Error', 'invoicing'), $e->getMessage(), array('response' => 403));
261 261
         }
262 262
 
263 263
     }
@@ -270,40 +270,40 @@  discard block
 block discarded – undo
270 270
      * @since       1.0.0
271 271
      * @return      void
272 272
      */
273
-    public function wpinv_checkout_add_subscription( $invoice, $invoice_data ) {
274
-        if ( ! ( ! empty( $invoice->ID ) && $invoice->is_recurring() ) ) {
273
+    public function wpinv_checkout_add_subscription($invoice, $invoice_data) {
274
+        if (!(!empty($invoice->ID) && $invoice->is_recurring())) {
275 275
             return;
276 276
         }
277 277
 
278 278
         // Should we create a subscription for the invoice?
279
-        if ( apply_filters( 'wpinv_skip_invoice_subscription_creation', false, $invoice ) ) {
279
+        if (apply_filters('wpinv_skip_invoice_subscription_creation', false, $invoice)) {
280 280
             return;
281 281
         }
282 282
 
283
-        $item               = $invoice->get_recurring( true );
284
-        if ( empty( $item ) ) {
283
+        $item = $invoice->get_recurring(true);
284
+        if (empty($item)) {
285 285
             return;
286 286
         }
287 287
 
288
-        $invoice_date       = $invoice->get_invoice_date( false );
288
+        $invoice_date       = $invoice->get_invoice_date(false);
289 289
         $status             = 'pending';
290 290
 
291
-        $period             = $item->get_recurring_period( true );
291
+        $period             = $item->get_recurring_period(true);
292 292
         $interval           = $item->get_recurring_interval();
293
-        $bill_times         = (int)$item->get_recurring_limit();
293
+        $bill_times         = (int) $item->get_recurring_limit();
294 294
         $add_period         = $interval . ' ' . $period;
295 295
         $trial_period       = '';
296 296
 
297
-        if ( $invoice->is_free_trial() ) {
297
+        if ($invoice->is_free_trial()) {
298 298
             $status         = 'trialling';
299
-            $trial_period   = $item->get_trial_period( true );
299
+            $trial_period   = $item->get_trial_period(true);
300 300
             $free_interval  = $item->get_trial_interval();
301 301
             $trial_period   = $free_interval . ' ' . $trial_period;
302 302
 
303 303
             $add_period     = $trial_period;
304 304
         }
305 305
 
306
-        $expiration         = date_i18n( 'Y-m-d H:i:s', strtotime( '+' . $add_period  . ' 23:59:59', strtotime( $invoice_date ) ) );
306
+        $expiration         = date_i18n('Y-m-d H:i:s', strtotime('+' . $add_period . ' 23:59:59', strtotime($invoice_date)));
307 307
 
308 308
         $args = array(
309 309
             'product_id'        => $item->ID,
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
             'frequency'         => $interval,
314 314
             'period'            => $period,
315 315
             'initial_amount'    => $invoice->get_total(),
316
-            'recurring_amount'  => $invoice->get_recurring_details( 'total' ),
316
+            'recurring_amount'  => $invoice->get_recurring_details('total'),
317 317
             'bill_times'        => $bill_times,
318 318
             'created'           => $invoice_date,
319 319
             'expiration'        => $expiration,
@@ -322,11 +322,11 @@  discard block
 block discarded – undo
322 322
             'transaction_id'    => '',
323 323
         );
324 324
 
325
-        $subscription = wpinv_get_subscription( $invoice );
325
+        $subscription = wpinv_get_subscription($invoice);
326 326
 
327
-        if ( empty( $subscription ) ) {
327
+        if (empty($subscription)) {
328 328
             $subscription = new WPInv_Subscription();
329
-            $subscription->create( $args );
329
+            $subscription->create($args);
330 330
         }
331 331
         
332 332
         return $subscription;
Please login to merge, or discard this patch.