Test Failed
Pull Request — master (#2823)
by Devin
05:06
created
includes/class-give-db-meta.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	/**
280 280
 	 * Rename query clauses for new meta table
281 281
 	 *
282
-	 * @param $clause
282
+	 * @param string $clause
283 283
 	 * @param $filter
284 284
 	 *
285 285
 	 * @return mixed
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
 	 * @since 2.0.4
514 514
 	 * @access public
515 515
 	 *
516
-	 * @return string
516
+	 * @return boolean
517 517
 	 */
518 518
 	public function get_meta_type(){
519 519
 		return $this->meta_type;
Please login to merge, or discard this patch.
Spacing   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -77,40 +77,40 @@  discard block
 block discarded – undo
77 77
 		parent::__construct();
78 78
 
79 79
 		// Bailout.
80
-		if ( empty( $this->supports ) || ! $this->is_custom_meta_table_active() ) {
80
+		if (empty($this->supports) || ! $this->is_custom_meta_table_active()) {
81 81
 			return;
82 82
 		}
83 83
 
84
-		if ( in_array( 'add_post_metadata', $this->supports ) ) {
85
-			add_filter( 'add_post_metadata', array( $this, '__add_meta' ), 0, 5 );
84
+		if (in_array('add_post_metadata', $this->supports)) {
85
+			add_filter('add_post_metadata', array($this, '__add_meta'), 0, 5);
86 86
 		}
87 87
 
88
-		if ( in_array( 'get_post_metadata', $this->supports ) ) {
89
-			add_filter( 'get_post_metadata', array( $this, '__get_meta' ), 0, 4 );
88
+		if (in_array('get_post_metadata', $this->supports)) {
89
+			add_filter('get_post_metadata', array($this, '__get_meta'), 0, 4);
90 90
 		}
91 91
 
92
-		if ( in_array( 'update_post_metadata', $this->supports ) ) {
93
-			add_filter( 'update_post_metadata', array( $this, '__update_meta' ), 0, 5 );
92
+		if (in_array('update_post_metadata', $this->supports)) {
93
+			add_filter('update_post_metadata', array($this, '__update_meta'), 0, 5);
94 94
 		}
95 95
 
96
-		if ( in_array( 'delete_post_metadata', $this->supports ) ) {
97
-			add_filter( 'delete_post_metadata', array( $this, '__delete_meta' ), 0, 5 );
96
+		if (in_array('delete_post_metadata', $this->supports)) {
97
+			add_filter('delete_post_metadata', array($this, '__delete_meta'), 0, 5);
98 98
 		}
99 99
 
100
-		if ( in_array( 'posts_where', $this->supports ) ) {
101
-			add_filter( 'posts_where', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 );
100
+		if (in_array('posts_where', $this->supports)) {
101
+			add_filter('posts_where', array($this, '__rename_meta_table_name_in_query'), 99999, 2);
102 102
 		}
103 103
 
104
-		if ( in_array( 'posts_join', $this->supports ) ) {
105
-			add_filter( 'posts_join', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 );
104
+		if (in_array('posts_join', $this->supports)) {
105
+			add_filter('posts_join', array($this, '__rename_meta_table_name_in_query'), 99999, 2);
106 106
 		}
107 107
 
108
-		if ( in_array( 'posts_groupby', $this->supports ) ) {
109
-			add_filter( 'posts_groupby', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 );
108
+		if (in_array('posts_groupby', $this->supports)) {
109
+			add_filter('posts_groupby', array($this, '__rename_meta_table_name_in_query'), 99999, 2);
110 110
 		}
111 111
 
112
-		if ( in_array( 'posts_orderby', $this->supports ) ) {
113
-			add_filter( 'posts_orderby', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 );
112
+		if (in_array('posts_orderby', $this->supports)) {
113
+			add_filter('posts_orderby', array($this, '__rename_meta_table_name_in_query'), 99999, 2);
114 114
 		}
115 115
 	}
116 116
 
@@ -128,16 +128,16 @@  discard block
 block discarded – undo
128 128
 	 * @return  mixed                 Will be an array if $single is false. Will be value of meta data field if $single
129 129
 	 *                                is true.
130 130
 	 */
131
-	public function get_meta( $id = 0, $meta_key = '', $single = false ) {
132
-		$id = $this->sanitize_id( $id );
131
+	public function get_meta($id = 0, $meta_key = '', $single = false) {
132
+		$id = $this->sanitize_id($id);
133 133
 
134 134
 		// Bailout.
135
-		if ( ! $this->is_valid_post_type( $id ) ) {
135
+		if ( ! $this->is_valid_post_type($id)) {
136 136
 			return $this->check;
137 137
 		}
138 138
 
139
-		if ( $this->raw_result ) {
140
-			if ( ! ( $value = get_metadata( $this->meta_type, $id, $meta_key, false ) ) ) {
139
+		if ($this->raw_result) {
140
+			if ( ! ($value = get_metadata($this->meta_type, $id, $meta_key, false))) {
141 141
 				$value = '';
142 142
 			}
143 143
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 			$this->raw_result = false;
146 146
 
147 147
 		} else {
148
-			$value = get_metadata( $this->meta_type, $id, $meta_key, $single );
148
+			$value = get_metadata($this->meta_type, $id, $meta_key, $single);
149 149
 		}
150 150
 
151 151
 		return $value;
@@ -167,18 +167,18 @@  discard block
 block discarded – undo
167 167
 	 *
168 168
 	 * @return  int|bool                  False for failure. True for success.
169 169
 	 */
170
-	public function add_meta( $id = 0, $meta_key = '', $meta_value, $unique = false ) {
171
-		$id = $this->sanitize_id( $id );
170
+	public function add_meta($id = 0, $meta_key = '', $meta_value, $unique = false) {
171
+		$id = $this->sanitize_id($id);
172 172
 
173 173
 		// Bailout.
174
-		if ( ! $this->is_valid_post_type( $id ) ) {
174
+		if ( ! $this->is_valid_post_type($id)) {
175 175
 			return $this->check;
176 176
 		}
177 177
 
178
-		$meta_id = add_metadata( $this->meta_type, $id, $meta_key, $meta_value, $unique );
178
+		$meta_id = add_metadata($this->meta_type, $id, $meta_key, $meta_value, $unique);
179 179
 
180
-		if ( $meta_id ) {
181
-			$this->delete_cache( $id );
180
+		if ($meta_id) {
181
+			$this->delete_cache($id);
182 182
 		}
183 183
 
184 184
 		return $meta_id;
@@ -204,18 +204,18 @@  discard block
 block discarded – undo
204 204
 	 *
205 205
 	 * @return  int|bool                  False on failure, true if success.
206 206
 	 */
207
-	public function update_meta( $id = 0, $meta_key = '', $meta_value, $prev_value = '' ) {
208
-		$id = $this->sanitize_id( $id );
207
+	public function update_meta($id = 0, $meta_key = '', $meta_value, $prev_value = '') {
208
+		$id = $this->sanitize_id($id);
209 209
 
210 210
 		// Bailout.
211
-		if ( ! $this->is_valid_post_type( $id ) ) {
211
+		if ( ! $this->is_valid_post_type($id)) {
212 212
 			return $this->check;
213 213
 		}
214 214
 
215
-		$meta_id = update_metadata( $this->meta_type, $id, $meta_key, $meta_value, $prev_value );
215
+		$meta_id = update_metadata($this->meta_type, $id, $meta_key, $meta_value, $prev_value);
216 216
 
217
-		if ( $meta_id ) {
218
-			$this->delete_cache( $id );
217
+		if ($meta_id) {
218
+			$this->delete_cache($id);
219 219
 		}
220 220
 
221 221
 		return $meta_id;
@@ -238,18 +238,18 @@  discard block
 block discarded – undo
238 238
 	 *
239 239
 	 * @return  bool                  False for failure. True for success.
240 240
 	 */
241
-	public function delete_meta( $id = 0, $meta_key = '', $meta_value = '', $delete_all = '' ) {
242
-		$id = $this->sanitize_id( $id );
241
+	public function delete_meta($id = 0, $meta_key = '', $meta_value = '', $delete_all = '') {
242
+		$id = $this->sanitize_id($id);
243 243
 
244 244
 		// Bailout.
245
-		if ( ! $this->is_valid_post_type( $id ) ) {
245
+		if ( ! $this->is_valid_post_type($id)) {
246 246
 			return $this->check;
247 247
 		}
248 248
 
249
-		$is_meta_deleted = delete_metadata( $this->meta_type, $id, $meta_key, $meta_value, $delete_all );
249
+		$is_meta_deleted = delete_metadata($this->meta_type, $id, $meta_key, $meta_value, $delete_all);
250 250
 
251
-		if ( $is_meta_deleted ) {
252
-			$this->delete_cache( $id );
251
+		if ($is_meta_deleted) {
252
+			$this->delete_cache($id);
253 253
 		}
254 254
 
255 255
 		return $is_meta_deleted;
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
 	 *
267 267
 	 * @return string
268 268
 	 */
269
-	public function __rename_meta_table_name_in_query( $clause, $wp_query ) {
269
+	public function __rename_meta_table_name_in_query($clause, $wp_query) {
270 270
 		// Add new table to sql query.
271
-		if ( $this->is_post_type_query( $wp_query ) && ! empty( $wp_query->meta_query->queries ) ) {
272
-			$clause = $this->__rename_meta_table_name( $clause, current_filter() );
271
+		if ($this->is_post_type_query($wp_query) && ! empty($wp_query->meta_query->queries)) {
272
+			$clause = $this->__rename_meta_table_name($clause, current_filter());
273 273
 		}
274 274
 
275 275
 		return $clause;
@@ -284,39 +284,39 @@  discard block
 block discarded – undo
284 284
 	 *
285 285
 	 * @return mixed
286 286
 	 */
287
-	public function __rename_meta_table_name( $clause, $filter ){
287
+	public function __rename_meta_table_name($clause, $filter) {
288 288
 		global $wpdb;
289 289
 
290
-		$clause = str_replace( "{$wpdb->postmeta}.post_id", "{$this->table_name}.{$this->meta_type}_id", $clause );
291
-		$clause = str_replace( $wpdb->postmeta, $this->table_name, $clause );
290
+		$clause = str_replace("{$wpdb->postmeta}.post_id", "{$this->table_name}.{$this->meta_type}_id", $clause);
291
+		$clause = str_replace($wpdb->postmeta, $this->table_name, $clause);
292 292
 
293
-		switch( $filter ) {
293
+		switch ($filter) {
294 294
 			case 'posts_join':
295
-				$joins = array( 'INNER JOIN', 'LEFT JOIN' );
295
+				$joins = array('INNER JOIN', 'LEFT JOIN');
296 296
 
297
-				foreach ( $joins as $join ) {
298
-					if( false !== strpos( $clause, $join ) ) {
299
-						$clause = explode( $join, $clause );
297
+				foreach ($joins as $join) {
298
+					if (false !== strpos($clause, $join)) {
299
+						$clause = explode($join, $clause);
300 300
 
301
-						foreach ( $clause as $key => $clause_part ) {
302
-							if( empty( $clause_part ) ) {
301
+						foreach ($clause as $key => $clause_part) {
302
+							if (empty($clause_part)) {
303 303
 								continue;
304 304
 							}
305 305
 
306
-							preg_match( '/' . $wpdb->prefix . 'give_' . $this->meta_type . 'meta AS (.*) ON/', $clause_part, $alias_table_name );
306
+							preg_match('/'.$wpdb->prefix.'give_'.$this->meta_type.'meta AS (.*) ON/', $clause_part, $alias_table_name);
307 307
 
308
-							if( isset( $alias_table_name[1] ) ) {
309
-								$clause[$key] = str_replace( "{$alias_table_name[1]}.post_id", "{$alias_table_name[1]}.{$this->meta_type}_id", $clause_part );
308
+							if (isset($alias_table_name[1])) {
309
+								$clause[$key] = str_replace("{$alias_table_name[1]}.post_id", "{$alias_table_name[1]}.{$this->meta_type}_id", $clause_part);
310 310
 							}
311 311
 						}
312 312
 
313
-						$clause = implode( "{$join} ", $clause );
313
+						$clause = implode("{$join} ", $clause);
314 314
 					}
315 315
 				}
316 316
 				break;
317 317
 
318 318
 			case 'posts_where':
319
-				$clause = str_replace( array( 'mt2.post_id', 'mt1.post_id' ), array( "mt2.{$this->meta_type}_id", "mt1.{$this->meta_type}_id" ), $clause );
319
+				$clause = str_replace(array('mt2.post_id', 'mt1.post_id'), array("mt2.{$this->meta_type}_id", "mt1.{$this->meta_type}_id"), $clause);
320 320
 				break;
321 321
 		}
322 322
 
@@ -334,19 +334,19 @@  discard block
 block discarded – undo
334 334
 	 *
335 335
 	 * @return bool
336 336
 	 */
337
-	protected function is_post_type_query( $wp_query ) {
337
+	protected function is_post_type_query($wp_query) {
338 338
 		$status = false;
339 339
 
340 340
 		// Check if it is payment query.
341
-		if ( ! empty( $wp_query->query['post_type'] ) ) {
341
+		if ( ! empty($wp_query->query['post_type'])) {
342 342
 			if (
343
-				is_string( $wp_query->query['post_type'] ) &&
343
+				is_string($wp_query->query['post_type']) &&
344 344
 				$this->post_type === $wp_query->query['post_type']
345 345
 			) {
346 346
 				$status = true;
347 347
 			} elseif (
348
-				is_array( $wp_query->query['post_type'] ) &&
349
-				in_array( $this->post_type, $wp_query->query['post_type'] )
348
+				is_array($wp_query->query['post_type']) &&
349
+				in_array($this->post_type, $wp_query->query['post_type'])
350 350
 			) {
351 351
 				$status = true;
352 352
 			}
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
 	 *
366 366
 	 * @return bool
367 367
 	 */
368
-	protected function is_valid_post_type( $ID ) {
369
-		return $ID && ( $this->post_type === get_post_type( $ID ) );
368
+	protected function is_valid_post_type($ID) {
369
+		return $ID && ($this->post_type === get_post_type($ID));
370 370
 	}
371 371
 
372 372
 	/**
@@ -392,8 +392,8 @@  discard block
 block discarded – undo
392 392
 	 *
393 393
 	 * @return void
394 394
 	 */
395
-	private function delete_cache( $id, $meta_type = '' ) {
396
-		$meta_type = empty( $meta_type ) ? $this->meta_type : $meta_type;
395
+	private function delete_cache($id, $meta_type = '') {
396
+		$meta_type = empty($meta_type) ? $this->meta_type : $meta_type;
397 397
 
398 398
 		$group = array(
399 399
 			// 'form'    => 'give-forms',
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
 			// 'log'     => 'give-logs',
404 404
 		);
405 405
 
406
-		if ( array_key_exists( $meta_type, $group ) ) {
407
-			Give_Cache::delete_group( $id, $group[ $meta_type ] );
406
+		if (array_key_exists($meta_type, $group)) {
407
+			Give_Cache::delete_group($id, $group[$meta_type]);
408 408
 		}
409 409
 	}
410 410
 
@@ -419,8 +419,8 @@  discard block
 block discarded – undo
419 419
 	 *
420 420
 	 * @return mixed
421 421
 	 */
422
-	public function __call( $name, $arguments ) {
423
-		switch ( $name ) {
422
+	public function __call($name, $arguments) {
423
+		switch ($name) {
424 424
 			case '__add_meta':
425 425
 				$this->check = $arguments[0];
426 426
 				$id          = $arguments[1];
@@ -429,11 +429,11 @@  discard block
 block discarded – undo
429 429
 				$unique      = $arguments[4];
430 430
 
431 431
 				// Bailout.
432
-				if ( ! $this->is_valid_post_type( $id ) ) {
432
+				if ( ! $this->is_valid_post_type($id)) {
433 433
 					return $this->check;
434 434
 				}
435 435
 
436
-				return $this->add_meta( $id, $meta_key, $meta_value, $unique );
436
+				return $this->add_meta($id, $meta_key, $meta_value, $unique);
437 437
 
438 438
 			case '__get_meta':
439 439
 				$this->check = $arguments[0];
@@ -442,13 +442,13 @@  discard block
 block discarded – undo
442 442
 				$single      = $arguments[3];
443 443
 
444 444
 				// Bailout.
445
-				if ( ! $this->is_valid_post_type( $id ) ) {
445
+				if ( ! $this->is_valid_post_type($id)) {
446 446
 					return $this->check;
447 447
 				}
448 448
 
449 449
 				$this->raw_result = true;
450 450
 
451
-				return $this->get_meta( $id, $meta_key, $single );
451
+				return $this->get_meta($id, $meta_key, $single);
452 452
 
453 453
 			case '__update_meta':
454 454
 				$this->check = $arguments[0];
@@ -457,11 +457,11 @@  discard block
 block discarded – undo
457 457
 				$meta_value  = $arguments[3];
458 458
 
459 459
 				// Bailout.
460
-				if ( ! $this->is_valid_post_type( $id ) ) {
460
+				if ( ! $this->is_valid_post_type($id)) {
461 461
 					return $this->check;
462 462
 				}
463 463
 
464
-				return $this->update_meta( $id, $meta_key, $meta_value );
464
+				return $this->update_meta($id, $meta_key, $meta_value);
465 465
 
466 466
 			case '__delete_meta':
467 467
 				$this->check = $arguments[0];
@@ -471,11 +471,11 @@  discard block
 block discarded – undo
471 471
 				$delete_all  = $arguments[3];
472 472
 
473 473
 				// Bailout.
474
-				if ( ! $this->is_valid_post_type( $id ) ) {
474
+				if ( ! $this->is_valid_post_type($id)) {
475 475
 					return $this->check;
476 476
 				}
477 477
 
478
-				return $this->delete_meta( $id, $meta_key, $meta_value, $delete_all );
478
+				return $this->delete_meta($id, $meta_key, $meta_value, $delete_all);
479 479
 		}
480 480
 	}
481 481
 
@@ -500,10 +500,10 @@  discard block
 block discarded – undo
500 500
 			KEY meta_key (meta_key({$this->min_index_length}))
501 501
 			) {$charset_collate};";
502 502
 
503
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
504
-		dbDelta( $sql );
503
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
504
+		dbDelta($sql);
505 505
 
506
-		update_option( $this->table_name . '_db_version', $this->version );
506
+		update_option($this->table_name.'_db_version', $this->version);
507 507
 	}
508 508
 
509 509
 
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 	 *
516 516
 	 * @return string
517 517
 	 */
518
-	public function get_meta_type(){
518
+	public function get_meta_type() {
519 519
 		return $this->meta_type;
520 520
 	}
521 521
 }
522 522
\ No newline at end of file
Please login to merge, or discard this patch.
give.php 1 patch
Spacing   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
  */
40 40
 
41 41
 // Exit if accessed directly.
42
-if ( ! defined( 'ABSPATH' ) ) {
42
+if ( ! defined('ABSPATH')) {
43 43
 	exit;
44 44
 }
45 45
 
46
-if ( ! class_exists( 'Give' ) ) :
46
+if ( ! class_exists('Give')) :
47 47
 
48 48
 	/**
49 49
 	 * Main Give Class
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 		 * @return    Give
238 238
 		 */
239 239
 		public static function instance() {
240
-			if ( is_null( self::$_instance ) ) {
240
+			if (is_null(self::$_instance)) {
241 241
 				self::$_instance = new self();
242 242
 			}
243 243
 
@@ -249,13 +249,13 @@  discard block
 block discarded – undo
249 249
 		 */
250 250
 		public function __construct() {
251 251
 			// PHP version
252
-			if ( ! defined( 'GIVE_REQUIRED_PHP_VERSION' ) ) {
253
-				define( 'GIVE_REQUIRED_PHP_VERSION', '5.3' );
252
+			if ( ! defined('GIVE_REQUIRED_PHP_VERSION')) {
253
+				define('GIVE_REQUIRED_PHP_VERSION', '5.3');
254 254
 			}
255 255
 
256 256
 			// Bailout: Need minimum php version to load plugin.
257
-			if ( function_exists( 'phpversion' ) && version_compare( GIVE_REQUIRED_PHP_VERSION, phpversion(), '>' ) ) {
258
-				add_action( 'admin_notices', array( $this, 'minmum_phpversion_notice' ) );
257
+			if (function_exists('phpversion') && version_compare(GIVE_REQUIRED_PHP_VERSION, phpversion(), '>')) {
258
+				add_action('admin_notices', array($this, 'minmum_phpversion_notice'));
259 259
 
260 260
 				return;
261 261
 			}
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 			$this->includes();
266 266
 			$this->init_hooks();
267 267
 
268
-			do_action( 'give_loaded' );
268
+			do_action('give_loaded');
269 269
 		}
270 270
 
271 271
 		/**
@@ -274,8 +274,8 @@  discard block
 block discarded – undo
274 274
 		 * @since  1.8.9
275 275
 		 */
276 276
 		private function init_hooks() {
277
-			register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' );
278
-			add_action( 'plugins_loaded', array( $this, 'init' ), 0 );
277
+			register_activation_hook(GIVE_PLUGIN_FILE, 'give_install');
278
+			add_action('plugins_loaded', array($this, 'init'), 0);
279 279
 		}
280 280
 
281 281
 		/**
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 			 *
291 291
 			 * @since 1.8.9
292 292
 			 */
293
-			do_action( 'before_give_init' );
293
+			do_action('before_give_init');
294 294
 
295 295
 			// Set up localization.
296 296
 			$this->load_textdomain();
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 			 *
321 321
 			 * @since 1.8.7
322 322
 			 */
323
-			do_action( 'give_init', $this );
323
+			do_action('give_init', $this);
324 324
 
325 325
 		}
326 326
 
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 		 */
338 338
 		public function __clone() {
339 339
 			// Cloning instances of the class is forbidden.
340
-			give_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'give' ), '1.0' );
340
+			give_doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'give'), '1.0');
341 341
 		}
342 342
 
343 343
 		/**
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 		 */
351 351
 		public function __wakeup() {
352 352
 			// Unserializing instances of the class is forbidden.
353
-			give_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'give' ), '1.0' );
353
+			give_doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'give'), '1.0');
354 354
 		}
355 355
 
356 356
 		/**
@@ -364,33 +364,33 @@  discard block
 block discarded – undo
364 364
 		private function setup_constants() {
365 365
 
366 366
 			// Plugin version
367
-			if ( ! defined( 'GIVE_VERSION' ) ) {
368
-				define( 'GIVE_VERSION', '2.0.4' );
367
+			if ( ! defined('GIVE_VERSION')) {
368
+				define('GIVE_VERSION', '2.0.4');
369 369
 			}
370 370
 
371 371
 			// Plugin Root File
372
-			if ( ! defined( 'GIVE_PLUGIN_FILE' ) ) {
373
-				define( 'GIVE_PLUGIN_FILE', __FILE__ );
372
+			if ( ! defined('GIVE_PLUGIN_FILE')) {
373
+				define('GIVE_PLUGIN_FILE', __FILE__);
374 374
 			}
375 375
 
376 376
 			// Plugin Folder Path
377
-			if ( ! defined( 'GIVE_PLUGIN_DIR' ) ) {
378
-				define( 'GIVE_PLUGIN_DIR', plugin_dir_path( GIVE_PLUGIN_FILE ) );
377
+			if ( ! defined('GIVE_PLUGIN_DIR')) {
378
+				define('GIVE_PLUGIN_DIR', plugin_dir_path(GIVE_PLUGIN_FILE));
379 379
 			}
380 380
 
381 381
 			// Plugin Folder URL
382
-			if ( ! defined( 'GIVE_PLUGIN_URL' ) ) {
383
-				define( 'GIVE_PLUGIN_URL', plugin_dir_url( GIVE_PLUGIN_FILE ) );
382
+			if ( ! defined('GIVE_PLUGIN_URL')) {
383
+				define('GIVE_PLUGIN_URL', plugin_dir_url(GIVE_PLUGIN_FILE));
384 384
 			}
385 385
 
386 386
 			// Plugin Basename aka: "give/give.php"
387
-			if ( ! defined( 'GIVE_PLUGIN_BASENAME' ) ) {
388
-				define( 'GIVE_PLUGIN_BASENAME', plugin_basename( GIVE_PLUGIN_FILE ) );
387
+			if ( ! defined('GIVE_PLUGIN_BASENAME')) {
388
+				define('GIVE_PLUGIN_BASENAME', plugin_basename(GIVE_PLUGIN_FILE));
389 389
 			}
390 390
 
391 391
 			// Make sure CAL_GREGORIAN is defined
392
-			if ( ! defined( 'CAL_GREGORIAN' ) ) {
393
-				define( 'CAL_GREGORIAN', 1 );
392
+			if ( ! defined('CAL_GREGORIAN')) {
393
+				define('CAL_GREGORIAN', 1);
394 394
 			}
395 395
 		}
396 396
 
@@ -408,152 +408,152 @@  discard block
 block discarded – undo
408 408
 			/**
409 409
 			 * Load libraries.
410 410
 			 */
411
-			if ( ! class_exists( 'WP_Async_Request' ) ) {
412
-				include_once( GIVE_PLUGIN_DIR . 'includes/libraries/wp-async-request.php' );
411
+			if ( ! class_exists('WP_Async_Request')) {
412
+				include_once(GIVE_PLUGIN_DIR.'includes/libraries/wp-async-request.php');
413 413
 			}
414 414
 
415
-			if ( ! class_exists( 'WP_Background_Process' ) ) {
416
-				include_once( GIVE_PLUGIN_DIR . 'includes/libraries/wp-background-process.php' );
415
+			if ( ! class_exists('WP_Background_Process')) {
416
+				include_once(GIVE_PLUGIN_DIR.'includes/libraries/wp-background-process.php');
417 417
 			}
418 418
 
419 419
 			/**
420 420
 			 * Load plugin files
421 421
 			 */
422
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-settings.php';
423
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-settings.php';
422
+			require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-settings.php';
423
+			require_once GIVE_PLUGIN_DIR.'includes/admin/class-give-settings.php';
424 424
 			$give_options = give_get_settings();
425 425
 
426
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php';
427
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-async-process.php';
428
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/give-metabox-functions.php';
429
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-cache.php';
430
-			require_once GIVE_PLUGIN_DIR . 'includes/post-types.php';
431
-			require_once GIVE_PLUGIN_DIR . 'includes/scripts.php';
432
-			require_once GIVE_PLUGIN_DIR . 'includes/ajax-functions.php';
433
-			require_once GIVE_PLUGIN_DIR . 'includes/actions.php';
434
-			require_once GIVE_PLUGIN_DIR . 'includes/filters.php';
435
-			require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api.php';
436
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-tooltips.php';
437
-			require_once GIVE_PLUGIN_DIR . 'includes/class-notices.php';
438
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-translation.php';
439
-
440
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-roles.php';
441
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-template-loader.php';
442
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-donate-form.php';
443
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db.php';
444
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-meta.php';
445
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-donors.php';
446
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-donor-meta.php';
447
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-donor.php';
448
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-stats.php';
449
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-session.php';
450
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-html-elements.php';
451
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php';
452
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php';
453
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-email-access.php';
454
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-payment-meta.php';
455
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-form-meta.php';
456
-
457
-			require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php';
458
-			require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php';
459
-			require_once GIVE_PLUGIN_DIR . 'includes/misc-functions.php';
460
-			require_once GIVE_PLUGIN_DIR . 'includes/import-functions.php';
461
-			require_once GIVE_PLUGIN_DIR . 'includes/forms/functions.php';
462
-			require_once GIVE_PLUGIN_DIR . 'includes/forms/template.php';
463
-			require_once GIVE_PLUGIN_DIR . 'includes/forms/widget.php';
464
-			require_once GIVE_PLUGIN_DIR . 'includes/shortcodes.php';
465
-			require_once GIVE_PLUGIN_DIR . 'includes/formatting.php';
466
-			require_once GIVE_PLUGIN_DIR . 'includes/currency-functions.php';
467
-			require_once GIVE_PLUGIN_DIR . 'includes/price-functions.php';
468
-			require_once GIVE_PLUGIN_DIR . 'includes/error-tracking.php';
469
-			require_once GIVE_PLUGIN_DIR . 'includes/process-donation.php';
470
-			require_once GIVE_PLUGIN_DIR . 'includes/login-register.php';
471
-			require_once GIVE_PLUGIN_DIR . 'includes/user-functions.php';
472
-			require_once GIVE_PLUGIN_DIR . 'includes/plugin-compatibility.php';
473
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-classes.php';
474
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-functions.php';
475
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-actions.php';
476
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-filters.php';
477
-
478
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/backward-compatibility.php';
479
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/functions.php';
480
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/actions.php';
481
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payment-stats.php';
482
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payments-query.php';
483
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-payment.php';
484
-
485
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/functions.php';
486
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/actions.php';
487
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/paypal-standard.php';
488
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/offline-donations.php';
489
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/manual.php';
490
-
491
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-emails.php';
492
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-email-tags.php';
493
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/class-email-notifications.php';
494
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/functions.php';
495
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php';
496
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php';
497
-
498
-			require_once GIVE_PLUGIN_DIR . 'includes/donors/class-give-donors-query.php';
499
-			require_once GIVE_PLUGIN_DIR . 'includes/donors/backward-compatibility.php';
500
-
501
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/class-give-updates.php';
502
-
503
-			if ( defined( 'WP_CLI' ) && WP_CLI ) {
504
-				require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php';
426
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-cron.php';
427
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-async-process.php';
428
+			require_once GIVE_PLUGIN_DIR.'includes/admin/give-metabox-functions.php';
429
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-cache.php';
430
+			require_once GIVE_PLUGIN_DIR.'includes/post-types.php';
431
+			require_once GIVE_PLUGIN_DIR.'includes/scripts.php';
432
+			require_once GIVE_PLUGIN_DIR.'includes/ajax-functions.php';
433
+			require_once GIVE_PLUGIN_DIR.'includes/actions.php';
434
+			require_once GIVE_PLUGIN_DIR.'includes/filters.php';
435
+			require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api.php';
436
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-tooltips.php';
437
+			require_once GIVE_PLUGIN_DIR.'includes/class-notices.php';
438
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-translation.php';
439
+
440
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-roles.php';
441
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-template-loader.php';
442
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-donate-form.php';
443
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db.php';
444
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db-meta.php';
445
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db-donors.php';
446
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db-donor-meta.php';
447
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-donor.php';
448
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-stats.php';
449
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-session.php';
450
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-html-elements.php';
451
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-logging.php';
452
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-license-handler.php';
453
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-email-access.php';
454
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db-payment-meta.php';
455
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db-form-meta.php';
456
+
457
+			require_once GIVE_PLUGIN_DIR.'includes/country-functions.php';
458
+			require_once GIVE_PLUGIN_DIR.'includes/template-functions.php';
459
+			require_once GIVE_PLUGIN_DIR.'includes/misc-functions.php';
460
+			require_once GIVE_PLUGIN_DIR.'includes/import-functions.php';
461
+			require_once GIVE_PLUGIN_DIR.'includes/forms/functions.php';
462
+			require_once GIVE_PLUGIN_DIR.'includes/forms/template.php';
463
+			require_once GIVE_PLUGIN_DIR.'includes/forms/widget.php';
464
+			require_once GIVE_PLUGIN_DIR.'includes/shortcodes.php';
465
+			require_once GIVE_PLUGIN_DIR.'includes/formatting.php';
466
+			require_once GIVE_PLUGIN_DIR.'includes/currency-functions.php';
467
+			require_once GIVE_PLUGIN_DIR.'includes/price-functions.php';
468
+			require_once GIVE_PLUGIN_DIR.'includes/error-tracking.php';
469
+			require_once GIVE_PLUGIN_DIR.'includes/process-donation.php';
470
+			require_once GIVE_PLUGIN_DIR.'includes/login-register.php';
471
+			require_once GIVE_PLUGIN_DIR.'includes/user-functions.php';
472
+			require_once GIVE_PLUGIN_DIR.'includes/plugin-compatibility.php';
473
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-classes.php';
474
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-functions.php';
475
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-actions.php';
476
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-filters.php';
477
+
478
+			require_once GIVE_PLUGIN_DIR.'includes/payments/backward-compatibility.php';
479
+			require_once GIVE_PLUGIN_DIR.'includes/payments/functions.php';
480
+			require_once GIVE_PLUGIN_DIR.'includes/payments/actions.php';
481
+			require_once GIVE_PLUGIN_DIR.'includes/payments/class-payment-stats.php';
482
+			require_once GIVE_PLUGIN_DIR.'includes/payments/class-payments-query.php';
483
+			require_once GIVE_PLUGIN_DIR.'includes/payments/class-give-payment.php';
484
+
485
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/functions.php';
486
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/actions.php';
487
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/paypal-standard.php';
488
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/offline-donations.php';
489
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/manual.php';
490
+
491
+			require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-emails.php';
492
+			require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-email-tags.php';
493
+			require_once GIVE_PLUGIN_DIR.'includes/admin/emails/class-email-notifications.php';
494
+			require_once GIVE_PLUGIN_DIR.'includes/emails/functions.php';
495
+			require_once GIVE_PLUGIN_DIR.'includes/emails/template.php';
496
+			require_once GIVE_PLUGIN_DIR.'includes/emails/actions.php';
497
+
498
+			require_once GIVE_PLUGIN_DIR.'includes/donors/class-give-donors-query.php';
499
+			require_once GIVE_PLUGIN_DIR.'includes/donors/backward-compatibility.php';
500
+
501
+			require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/class-give-updates.php';
502
+
503
+			if (defined('WP_CLI') && WP_CLI) {
504
+				require_once GIVE_PLUGIN_DIR.'includes/class-give-cli-commands.php';
505 505
 			}
506 506
 
507
-			if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
508
-
509
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-footer.php';
510
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/welcome.php';
511
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-pages.php';
512
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php';
513
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/class-i18n-module.php';
514
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-actions.php';
515
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-filters.php';
516
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/add-ons.php';
517
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/plugins.php';
518
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/dashboard-widgets.php';
519
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/class-blank-slate.php';
520
-
521
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/actions.php';
522
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/payments-history.php';
523
-
524
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donors.php';
525
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donor-functions.php';
526
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donor-actions.php';
527
-
528
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/metabox.php';
529
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/class-metabox-form-data.php';
530
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/dashboard-columns.php';
531
-
532
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-functions.php';
533
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-export.php';
534
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-actions.php';
535
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/pdf-reports.php';
536
-
537
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/reports.php';
538
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/class-give-graph.php';
539
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/graphing.php';
540
-
541
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/logs.php';
542
-
543
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/tools-actions.php';
544
-
545
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/abstract-shortcode-generator.php';
546
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-button.php';
547
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-form.php';
548
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-goal.php';
549
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-login.php';
550
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-register.php';
551
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-profile-editor.php';
552
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-history.php';
553
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-receipt.php';
507
+			if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
508
+
509
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-footer.php';
510
+				require_once GIVE_PLUGIN_DIR.'includes/admin/welcome.php';
511
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-pages.php';
512
+				require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php';
513
+				require_once GIVE_PLUGIN_DIR.'includes/admin/class-i18n-module.php';
514
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-actions.php';
515
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-filters.php';
516
+				require_once GIVE_PLUGIN_DIR.'includes/admin/add-ons.php';
517
+				require_once GIVE_PLUGIN_DIR.'includes/admin/plugins.php';
518
+				require_once GIVE_PLUGIN_DIR.'includes/admin/dashboard-widgets.php';
519
+				require_once GIVE_PLUGIN_DIR.'includes/admin/class-blank-slate.php';
520
+
521
+				require_once GIVE_PLUGIN_DIR.'includes/admin/payments/actions.php';
522
+				require_once GIVE_PLUGIN_DIR.'includes/admin/payments/payments-history.php';
523
+
524
+				require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donors.php';
525
+				require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donor-functions.php';
526
+				require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donor-actions.php';
527
+
528
+				require_once GIVE_PLUGIN_DIR.'includes/admin/forms/metabox.php';
529
+				require_once GIVE_PLUGIN_DIR.'includes/admin/forms/class-metabox-form-data.php';
530
+				require_once GIVE_PLUGIN_DIR.'includes/admin/forms/dashboard-columns.php';
531
+
532
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/export-functions.php';
533
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-export.php';
534
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/export-actions.php';
535
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/pdf-reports.php';
536
+
537
+				require_once GIVE_PLUGIN_DIR.'includes/admin/reports/reports.php';
538
+				require_once GIVE_PLUGIN_DIR.'includes/admin/reports/class-give-graph.php';
539
+				require_once GIVE_PLUGIN_DIR.'includes/admin/reports/graphing.php';
540
+
541
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/logs/logs.php';
542
+
543
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/tools-actions.php';
544
+
545
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/abstract-shortcode-generator.php';
546
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/class-shortcode-button.php';
547
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-form.php';
548
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-goal.php';
549
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-login.php';
550
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-register.php';
551
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-profile-editor.php';
552
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-donation-history.php';
553
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-receipt.php';
554 554
 			}// End if().
555 555
 
556
-			require_once GIVE_PLUGIN_DIR . 'includes/install.php';
556
+			require_once GIVE_PLUGIN_DIR.'includes/install.php';
557 557
 
558 558
 		}
559 559
 
@@ -568,16 +568,16 @@  discard block
 block discarded – undo
568 568
 		public function load_textdomain() {
569 569
 
570 570
 			// Set filter for Give's languages directory
571
-			$give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/';
572
-			$give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir );
571
+			$give_lang_dir = dirname(plugin_basename(GIVE_PLUGIN_FILE)).'/languages/';
572
+			$give_lang_dir = apply_filters('give_languages_directory', $give_lang_dir);
573 573
 
574 574
 			// Traditional WordPress plugin locale filter.
575
-			$locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
576
-			$locale = apply_filters( 'plugin_locale', $locale, 'give' );
575
+			$locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
576
+			$locale = apply_filters('plugin_locale', $locale, 'give');
577 577
 
578
-			unload_textdomain( 'give' );
579
-			load_textdomain( 'give', WP_LANG_DIR . '/give/give-' . $locale . '.mo' );
580
-			load_plugin_textdomain( 'give', false, $give_lang_dir );
578
+			unload_textdomain('give');
579
+			load_textdomain('give', WP_LANG_DIR.'/give/give-'.$locale.'.mo');
580
+			load_plugin_textdomain('give', false, $give_lang_dir);
581 581
 
582 582
 		}
583 583
 
@@ -590,17 +590,17 @@  discard block
 block discarded – undo
590 590
 		 */
591 591
 		public function minmum_phpversion_notice() {
592 592
 			// Bailout.
593
-			if ( ! is_admin() ) {
593
+			if ( ! is_admin()) {
594 594
 				return;
595 595
 			}
596 596
 
597
-			$notice_desc = '<p><strong>' . __( 'Your site could be faster and more secure with a newer PHP version.', 'give' ) . '</strong></p>';
598
-			$notice_desc .= '<p>' . __( 'Hey, we\'ve noticed that you\'re running an outdated version of PHP. PHP is the programming language that WordPress and Give are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you this notice.', 'give' ) . '</p>';
599
-			$notice_desc .= '<p>' . __( 'Hosts have the ability to update your PHP version, but sometimes they don\'t dare to do that because they\'re afraid they\'ll break your site.', 'give' ) . '</p>';
600
-			$notice_desc .= '<p><strong>' . __( 'To which version should I update?', 'give' ) . '</strong></p>';
601
-			$notice_desc .= '<p>' . __( 'You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. PHP7 is much faster than PHP 5.6. It\'s also the only PHP version still in active development and therefore the better option for your site in the long run.', 'give' ) . '</p>';
602
-			$notice_desc .= '<p><strong>' . __( 'Can\'t update? Ask your host!', 'give' ) . '</strong></p>';
603
-			$notice_desc .= '<p>' . sprintf( __( 'If you cannot upgrade your PHP version yourself, you can send an email to your host. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %1$sWordPress hosting partners%2$s.', 'give' ), sprintf( '<a href="%1$s" target="_blank">', esc_url( 'https://wordpress.org/hosting/' ) ), '</a>' ) . '</p>';
597
+			$notice_desc = '<p><strong>'.__('Your site could be faster and more secure with a newer PHP version.', 'give').'</strong></p>';
598
+			$notice_desc .= '<p>'.__('Hey, we\'ve noticed that you\'re running an outdated version of PHP. PHP is the programming language that WordPress and Give are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you this notice.', 'give').'</p>';
599
+			$notice_desc .= '<p>'.__('Hosts have the ability to update your PHP version, but sometimes they don\'t dare to do that because they\'re afraid they\'ll break your site.', 'give').'</p>';
600
+			$notice_desc .= '<p><strong>'.__('To which version should I update?', 'give').'</strong></p>';
601
+			$notice_desc .= '<p>'.__('You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. PHP7 is much faster than PHP 5.6. It\'s also the only PHP version still in active development and therefore the better option for your site in the long run.', 'give').'</p>';
602
+			$notice_desc .= '<p><strong>'.__('Can\'t update? Ask your host!', 'give').'</strong></p>';
603
+			$notice_desc .= '<p>'.sprintf(__('If you cannot upgrade your PHP version yourself, you can send an email to your host. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %1$sWordPress hosting partners%2$s.', 'give'), sprintf('<a href="%1$s" target="_blank">', esc_url('https://wordpress.org/hosting/')), '</a>').'</p>';
604 604
 
605 605
 			echo sprintf(
606 606
 				'<div class="notice notice-error">%1$s</div>',
Please login to merge, or discard this patch.
includes/class-give-db.php 1 patch
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
 	 * @access public
73 73
 	 */
74 74
 	public function __construct() {
75
-		if( is_multisite() ) {
76
-			add_action( 'switch_blog', array( $this, 'handle_switch_blog' ), 10, 2 );
75
+		if (is_multisite()) {
76
+			add_action('switch_blog', array($this, 'handle_switch_blog'), 10, 2);
77 77
 		}
78 78
 	}
79 79
 
@@ -111,16 +111,16 @@  discard block
 block discarded – undo
111 111
 	 *
112 112
 	 * @return object
113 113
 	 */
114
-	public function get( $row_id ) {
114
+	public function get($row_id) {
115 115
 		/* @var WPDB $wpdb */
116 116
 		global $wpdb;
117 117
 
118 118
 		// Bailout.
119
-		if ( empty( $row_id ) ) {
119
+		if (empty($row_id)) {
120 120
 			return null;
121 121
 		}
122 122
 
123
-		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
123
+		return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id));
124 124
 	}
125 125
 
126 126
 	/**
@@ -134,18 +134,18 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @return object
136 136
 	 */
137
-	public function get_by( $column, $row_id ) {
137
+	public function get_by($column, $row_id) {
138 138
 		/* @var WPDB $wpdb */
139 139
 		global $wpdb;
140 140
 
141 141
 		// Bailout.
142
-		if ( empty( $column ) || empty( $row_id ) ) {
142
+		if (empty($column) || empty($row_id)) {
143 143
 			return null;
144 144
 		}
145 145
 
146
-		$column = esc_sql( $column );
146
+		$column = esc_sql($column);
147 147
 
148
-		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) );
148
+		return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id));
149 149
 	}
150 150
 
151 151
 	/**
@@ -159,18 +159,18 @@  discard block
 block discarded – undo
159 159
 	 *
160 160
 	 * @return string      Column value.
161 161
 	 */
162
-	public function get_column( $column, $row_id ) {
162
+	public function get_column($column, $row_id) {
163 163
 		/* @var WPDB $wpdb */
164 164
 		global $wpdb;
165 165
 
166 166
 		// Bailout.
167
-		if ( empty( $column ) || empty( $row_id ) ) {
167
+		if (empty($column) || empty($row_id)) {
168 168
 			return null;
169 169
 		}
170 170
 
171
-		$column = esc_sql( $column );
171
+		$column = esc_sql($column);
172 172
 
173
-		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
173
+		return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id));
174 174
 	}
175 175
 
176 176
 	/**
@@ -185,19 +185,19 @@  discard block
 block discarded – undo
185 185
 	 *
186 186
 	 * @return string
187 187
 	 */
188
-	public function get_column_by( $column, $column_where, $column_value ) {
188
+	public function get_column_by($column, $column_where, $column_value) {
189 189
 		/* @var WPDB $wpdb */
190 190
 		global $wpdb;
191 191
 
192 192
 		// Bailout.
193
-		if ( empty( $column ) || empty( $column_where ) || empty( $column_value ) ) {
193
+		if (empty($column) || empty($column_where) || empty($column_value)) {
194 194
 			return null;
195 195
 		}
196 196
 
197
-		$column_where = esc_sql( $column_where );
198
-		$column       = esc_sql( $column );
197
+		$column_where = esc_sql($column_where);
198
+		$column       = esc_sql($column);
199 199
 
200
-		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) );
200
+		return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value));
201 201
 	}
202 202
 
203 203
 	/**
@@ -211,12 +211,12 @@  discard block
 block discarded – undo
211 211
 	 *
212 212
 	 * @return int
213 213
 	 */
214
-	public function insert( $data, $type = '' ) {
214
+	public function insert($data, $type = '') {
215 215
 		/* @var WPDB $wpdb */
216 216
 		global $wpdb;
217 217
 
218 218
 		// Set default values.
219
-		$data = wp_parse_args( $data, $this->get_column_defaults() );
219
+		$data = wp_parse_args($data, $this->get_column_defaults());
220 220
 
221 221
 		/**
222 222
 		 * Fires before inserting data to the database.
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 		 *
226 226
 		 * @param array $data
227 227
 		 */
228
-		do_action( "give_pre_insert_{$type}", $data );
228
+		do_action("give_pre_insert_{$type}", $data);
229 229
 
230 230
 		// Initialise column format array
231 231
 		$column_formats = $this->get_columns();
@@ -234,13 +234,13 @@  discard block
 block discarded – undo
234 234
 		// $data = array_change_key_case( $data );
235 235
 
236 236
 		// White list columns
237
-		$data = array_intersect_key( $data, $column_formats );
237
+		$data = array_intersect_key($data, $column_formats);
238 238
 
239 239
 		// Reorder $column_formats to match the order of columns given in $data
240
-		$data_keys      = array_keys( $data );
241
-		$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
240
+		$data_keys      = array_keys($data);
241
+		$column_formats = array_merge(array_flip($data_keys), $column_formats);
242 242
 
243
-		$wpdb->insert( $this->table_name, $data, $column_formats );
243
+		$wpdb->insert($this->table_name, $data, $column_formats);
244 244
 
245 245
 		/**
246 246
 		 * Fires after inserting data to the database.
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 		 * @param int   $insert_id
251 251
 		 * @param array $data
252 252
 		 */
253
-		do_action( "give_post_insert_{$type}", $wpdb->insert_id, $data );
253
+		do_action("give_post_insert_{$type}", $wpdb->insert_id, $data);
254 254
 
255 255
 		return $wpdb->insert_id;
256 256
 	}
@@ -267,18 +267,18 @@  discard block
 block discarded – undo
267 267
 	 *
268 268
 	 * @return bool
269 269
 	 */
270
-	public function update( $row_id, $data = array(), $where = '' ) {
270
+	public function update($row_id, $data = array(), $where = '') {
271 271
 		/* @var WPDB $wpdb */
272 272
 		global $wpdb;
273 273
 
274 274
 		// Row ID must be positive integer
275
-		$row_id = absint( $row_id );
275
+		$row_id = absint($row_id);
276 276
 
277
-		if ( empty( $row_id ) ) {
277
+		if (empty($row_id)) {
278 278
 			return false;
279 279
 		}
280 280
 
281
-		if ( empty( $where ) ) {
281
+		if (empty($where)) {
282 282
 			$where = $this->primary_key;
283 283
 		}
284 284
 
@@ -286,16 +286,16 @@  discard block
 block discarded – undo
286 286
 		$column_formats = $this->get_columns();
287 287
 
288 288
 		// Force fields to lower case
289
-		$data = array_change_key_case( $data );
289
+		$data = array_change_key_case($data);
290 290
 
291 291
 		// White list columns
292
-		$data = array_intersect_key( $data, $column_formats );
292
+		$data = array_intersect_key($data, $column_formats);
293 293
 
294 294
 		// Reorder $column_formats to match the order of columns given in $data
295
-		$data_keys      = array_keys( $data );
296
-		$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
295
+		$data_keys      = array_keys($data);
296
+		$column_formats = array_merge(array_flip($data_keys), $column_formats);
297 297
 
298
-		if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) {
298
+		if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) {
299 299
 			return false;
300 300
 		}
301 301
 
@@ -312,18 +312,18 @@  discard block
 block discarded – undo
312 312
 	 *
313 313
 	 * @return bool
314 314
 	 */
315
-	public function delete( $row_id = 0 ) {
315
+	public function delete($row_id = 0) {
316 316
 		/* @var WPDB $wpdb */
317 317
 		global $wpdb;
318 318
 
319 319
 		// Row ID must be positive integer
320
-		$row_id = absint( $row_id );
320
+		$row_id = absint($row_id);
321 321
 
322
-		if ( empty( $row_id ) ) {
322
+		if (empty($row_id)) {
323 323
 			return false;
324 324
 		}
325 325
 
326
-		if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) {
326
+		if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) {
327 327
 			return false;
328 328
 		}
329 329
 
@@ -340,13 +340,13 @@  discard block
 block discarded – undo
340 340
 	 *
341 341
 	 * @return bool          If the table name exists.
342 342
 	 */
343
-	public function table_exists( $table ) {
343
+	public function table_exists($table) {
344 344
 		/* @var WPDB $wpdb */
345 345
 		global $wpdb;
346 346
 
347
-		$table = sanitize_text_field( $table );
347
+		$table = sanitize_text_field($table);
348 348
 
349
-		return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table;
349
+		return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table;
350 350
 	}
351 351
 
352 352
 	/**
@@ -360,16 +360,16 @@  discard block
 block discarded – undo
360 360
 	 *
361 361
 	 * @return bool
362 362
 	 */
363
-	public function does_column_exist( $column_name ) {
363
+	public function does_column_exist($column_name) {
364 364
 
365 365
 		global $wpdb;
366 366
 
367
-		$column = $wpdb->get_results( $wpdb->prepare(
367
+		$column = $wpdb->get_results($wpdb->prepare(
368 368
 			"SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = %s AND TABLE_NAME = %s AND COLUMN_NAME = %s ",
369 369
 			DB_NAME, $this->table_name, $column_name
370
-		) );
370
+		));
371 371
 
372
-		if ( ! empty( $column ) ) {
372
+		if ( ! empty($column)) {
373 373
 			return true;
374 374
 		}
375 375
 
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 	 * @return bool Returns if the customers table was installed and upgrade routine run.
386 386
 	 */
387 387
 	public function installed() {
388
-		return $this->table_exists( $this->table_name );
388
+		return $this->table_exists($this->table_name);
389 389
 	}
390 390
 
391 391
 	/**
@@ -395,8 +395,8 @@  discard block
 block discarded – undo
395 395
 	 * @access public
396 396
 	 */
397 397
 	public function register_table() {
398
-		$current_version = get_option( $this->table_name . '_db_version' );
399
-		if ( ! $current_version || version_compare( $current_version, $this->version, '<' ) ) {
398
+		$current_version = get_option($this->table_name.'_db_version');
399
+		if ( ! $current_version || version_compare($current_version, $this->version, '<')) {
400 400
 			$this->create_table();
401 401
 		}
402 402
 	}
@@ -421,23 +421,23 @@  discard block
 block discarded – undo
421 421
 	 *
422 422
 	 * @return int|bool                The normalized log ID or false if it's found to not be valid.
423 423
 	 */
424
-	public function sanitize_id( $id ) {
425
-		if ( ! is_numeric( $id ) ) {
424
+	public function sanitize_id($id) {
425
+		if ( ! is_numeric($id)) {
426 426
 			return false;
427 427
 		}
428 428
 
429 429
 		$id = (int) $id;
430 430
 
431 431
 		// We were given a non positive number.
432
-		if ( absint( $id ) !== $id ) {
432
+		if (absint($id) !== $id) {
433 433
 			return false;
434 434
 		}
435 435
 
436
-		if ( empty( $id ) ) {
436
+		if (empty($id)) {
437 437
 			return false;
438 438
 		}
439 439
 
440
-		return absint( $id );
440
+		return absint($id);
441 441
 
442 442
 	}
443 443
 
@@ -451,23 +451,23 @@  discard block
 block discarded – undo
451 451
 	 * @param $new_blog_id
452 452
 	 * @param $prev_blog_id
453 453
 	 */
454
-	public function handle_switch_blog( $new_blog_id, $prev_blog_id ) {
454
+	public function handle_switch_blog($new_blog_id, $prev_blog_id) {
455 455
 		global $wpdb;
456 456
 
457 457
 		// Bailout.
458
-		if ( $new_blog_id === $prev_blog_id ) {
458
+		if ($new_blog_id === $prev_blog_id) {
459 459
 			return;
460 460
 		}
461 461
 
462 462
 
463 463
 		$this->table_name = str_replace(
464
-			1 != $prev_blog_id ? $wpdb->get_blog_prefix( $prev_blog_id ) : $wpdb->base_prefix,
465
-			1 != $new_blog_id ? $wpdb->get_blog_prefix( $new_blog_id ) : $wpdb->base_prefix,
464
+			1 != $prev_blog_id ? $wpdb->get_blog_prefix($prev_blog_id) : $wpdb->base_prefix,
465
+			1 != $new_blog_id ? $wpdb->get_blog_prefix($new_blog_id) : $wpdb->base_prefix,
466 466
 			$this->table_name
467 467
 		);
468 468
 
469
-		if ( $this instanceof Give_DB_Meta ) {
470
-			$wpdb->{$this->get_meta_type() . 'meta'} = $this->table_name;
469
+		if ($this instanceof Give_DB_Meta) {
470
+			$wpdb->{$this->get_meta_type().'meta'} = $this->table_name;
471 471
 		}
472 472
 
473 473
 	}
Please login to merge, or discard this patch.
includes/admin/class-blank-slate.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  * @since       1.8.13
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
@@ -75,63 +75,63 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	public function init() {
77 77
 		// Bail early if screen cannot be detected.
78
-		if ( empty( $this->screen ) ) {
78
+		if (empty($this->screen)) {
79 79
 			return null;
80 80
 		}
81 81
 
82 82
 		$content = array();
83 83
 
84 84
 		// Define content and hook into the appropriate action.
85
-		switch ( $this->screen ) {
85
+		switch ($this->screen) {
86 86
 			// Forms screen.
87 87
 			case 'edit-give_forms':
88
-				$this->form = $this->post_exists( 'give_forms' );
88
+				$this->form = $this->post_exists('give_forms');
89 89
 
90
-				if ( $this->form ) {
90
+				if ($this->form) {
91 91
 					// Form exists. Bail out.
92 92
 					return false;
93 93
 				} else {
94 94
 					// No forms exist.
95
-					$content = $this->get_content( 'no_forms' );
95
+					$content = $this->get_content('no_forms');
96 96
 				}
97 97
 
98
-				add_action( 'manage_posts_extra_tablenav', array( $this, 'render' ) );
98
+				add_action('manage_posts_extra_tablenav', array($this, 'render'));
99 99
 				break;
100 100
 			// Donations screen.
101 101
 			case 'give_forms_page_give-payment-history':
102
-				$this->form     = $this->post_exists( 'give_forms' );
103
-				$this->donation = $this->post_exists( 'give_payment' );
102
+				$this->form     = $this->post_exists('give_forms');
103
+				$this->donation = $this->post_exists('give_payment');
104 104
 
105
-				if ( $this->donation ) {
105
+				if ($this->donation) {
106 106
 					// Donation exists. Bail out.
107 107
 					return false;
108
-				} elseif ( ! $this->form ) {
108
+				} elseif ( ! $this->form) {
109 109
 					// No forms and no donations exist.
110
-					$content = $this->get_content( 'no_donations_or_forms' );
110
+					$content = $this->get_content('no_donations_or_forms');
111 111
 				} else {
112 112
 					// No donations exist but a form does exist.
113
-					$content = $this->get_content( 'no_donations' );
113
+					$content = $this->get_content('no_donations');
114 114
 				}
115 115
 
116
-				add_action( 'give_payments_page_bottom', array( $this, 'render' ) );
116
+				add_action('give_payments_page_bottom', array($this, 'render'));
117 117
 				break;
118 118
 			// Donors screen.
119 119
 			case 'give_forms_page_give-donors':
120
-				$this->form  = $this->post_exists( 'give_forms' );
120
+				$this->form  = $this->post_exists('give_forms');
121 121
 				$this->donor = $this->donor_exists();
122 122
 
123
-				if ( $this->donor ) {
123
+				if ($this->donor) {
124 124
 					// Donor exists. Bail out.
125 125
 					return false;
126
-				} elseif ( ! $this->form ) {
126
+				} elseif ( ! $this->form) {
127 127
 					// No forms and no donors exist.
128
-					$content = $this->get_content( 'no_donors_or_forms' );
128
+					$content = $this->get_content('no_donors_or_forms');
129 129
 				} else {
130 130
 					// No donors exist but a form does exist.
131
-					$content = $this->get_content( 'no_donors' );
131
+					$content = $this->get_content('no_donors');
132 132
 				}
133 133
 
134
-				add_action( 'give_donors_table_bottom', array( $this, 'render' ) );
134
+				add_action('give_donors_table_bottom', array($this, 'render'));
135 135
 				break;
136 136
 			default:
137 137
 				return null;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 		$this->content = $content;
141 141
 
142 142
 		// Hide non-essential UI elements.
143
-		add_action( 'admin_head', array( $this, 'hide_ui' ) );
143
+		add_action('admin_head', array($this, 'hide_ui'));
144 144
 	}
145 145
 
146 146
 	/**
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
 	 *
151 151
 	 * @param string $which The location of the list table hook: 'top' or 'bottom'.
152 152
 	 */
153
-	public function render( $which = 'bottom') {
153
+	public function render($which = 'bottom') {
154 154
 		// Bail out to prevent content from rendering twice.
155
-		if ( 'top' === $which ) {
155
+		if ('top' === $which) {
156 156
 			return null;
157 157
 		}
158 158
 
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
 		 *
178 178
 		 * @param string $screen The current screen ID.
179 179
 		 */
180
-		$content = apply_filters( 'give_blank_slate_content', $this->content, $screen );
180
+		$content = apply_filters('give_blank_slate_content', $this->content, $screen);
181 181
 
182
-		$template_path = GIVE_PLUGIN_DIR . 'includes/admin/views/blank-slate.php';
182
+		$template_path = GIVE_PLUGIN_DIR.'includes/admin/views/blank-slate.php';
183 183
 
184 184
 		include $template_path;
185 185
 	}
@@ -214,17 +214,17 @@  discard block
 block discarded – undo
214 214
 	 * @param string $post_type Post type used in the query.
215 215
 	 * @return bool True if post exists, otherwise false.
216 216
 	 */
217
-	private function post_exists( $post_type ) {
217
+	private function post_exists($post_type) {
218 218
 		// Attempt to get a single post of the post type.
219
-		$query = new WP_Query( array(
219
+		$query = new WP_Query(array(
220 220
 			'post_type'              => $post_type,
221 221
 			'posts_per_page'         => 1,
222 222
 			'no_found_rows'          => false,
223 223
 			'update_post_meta_cache' => false,
224 224
 			'update_post_term_cache' => false,
225 225
 			'fields'                 => 'ids',
226
-			'post_status'            => array( 'any', 'trash' ),
227
-		) );
226
+			'post_status'            => array('any', 'trash'),
227
+		));
228 228
 
229 229
 		return $query->have_posts();
230 230
 	}
@@ -237,9 +237,9 @@  discard block
 block discarded – undo
237 237
 	 * @return bool True if donor exists, otherwise false.
238 238
 	 */
239 239
 	private function donor_exists() {
240
-		$donors = Give()->donors->get_donors( array( 'number' => 1 ) );
240
+		$donors = Give()->donors->get_donors(array('number' => 1));
241 241
 
242
-		return ! empty( $donors );
242
+		return ! empty($donors);
243 243
 	}
244 244
 
245 245
 	/**
@@ -250,17 +250,17 @@  discard block
 block discarded – undo
250 250
 	 * @param string $context The key used to determine which content is returned.
251 251
 	 * @return array Blank slate content.
252 252
 	 */
253
-	private function get_content( $context ) {
253
+	private function get_content($context) {
254 254
 		// Define default content.
255 255
 		$defaults = array(
256
-			'image_url' => GIVE_PLUGIN_URL . 'assets/images/svg/give-icon-full-circle.svg',
257
-			'image_alt' => __( 'Give Icon', 'give' ),
258
-			'heading'   => __( 'No donation forms  found.', 'give' ),
259
-			'message'   => __( 'The first step towards accepting online donations is to create a form.', 'give' ),
260
-			'cta_text'  => __( 'Create Donation Form', 'give' ),
261
-			'cta_link'  => admin_url( 'post-new.php?post_type=give_forms' ),
256
+			'image_url' => GIVE_PLUGIN_URL.'assets/images/svg/give-icon-full-circle.svg',
257
+			'image_alt' => __('Give Icon', 'give'),
258
+			'heading'   => __('No donation forms  found.', 'give'),
259
+			'message'   => __('The first step towards accepting online donations is to create a form.', 'give'),
260
+			'cta_text'  => __('Create Donation Form', 'give'),
261
+			'cta_link'  => admin_url('post-new.php?post_type=give_forms'),
262 262
 			'help'      => sprintf(
263
-				__( 'Need help? Get started with %sGive 101%s.', 'give' ),
263
+				__('Need help? Get started with %sGive 101%s.', 'give'),
264 264
 				'<a href="http://docs.givewp.com/give101/" target="_blank">',
265 265
 				'</a>'
266 266
 			),
@@ -269,40 +269,40 @@  discard block
 block discarded – undo
269 269
 		// Define contextual content.
270 270
 		$content = array(
271 271
 			'no_donations_or_forms' => array(
272
-				'heading' => __( 'No donations found.', 'give' ),
273
-				'message' => __( 'Your donation history will appear here, but first, you need a donation form!', 'give' ),
272
+				'heading' => __('No donations found.', 'give'),
273
+				'message' => __('Your donation history will appear here, but first, you need a donation form!', 'give'),
274 274
 			),
275 275
 			'no_donations'          => array(
276
-				'heading'  => __( 'No donations found.', 'give' ),
277
-				'message'  => __( 'When your first donation arrives, a record of the donation will appear here.', 'give' ),
278
-				'cta_text' => __( 'View All Forms', 'give' ),
279
-				'cta_link' => admin_url( 'edit.php?post_type=give_forms' ),
276
+				'heading'  => __('No donations found.', 'give'),
277
+				'message'  => __('When your first donation arrives, a record of the donation will appear here.', 'give'),
278
+				'cta_text' => __('View All Forms', 'give'),
279
+				'cta_link' => admin_url('edit.php?post_type=give_forms'),
280 280
 				'help'     => sprintf(
281
-					__( 'Need help? Learn more about %sDonations%s.', 'give' ),
281
+					__('Need help? Learn more about %sDonations%s.', 'give'),
282 282
 					'<a href="http://docs.givewp.com/core-donations/">',
283 283
 					'</a>'
284 284
 				),
285 285
 			),
286 286
 			'no_donors_or_forms'    => array(
287
-				'heading' => __( 'No donors  found.', 'give' ),
288
-				'message' => __( 'Your donor history will appear here, but first, you need a donation form!', 'give' ),
287
+				'heading' => __('No donors  found.', 'give'),
288
+				'message' => __('Your donor history will appear here, but first, you need a donation form!', 'give'),
289 289
 			),
290 290
 			'no_donors'             => array(
291
-				'heading'  => __( 'No donors found.', 'give' ),
292
-				'message'  => __( 'When your first donation arrives, the donor will appear here.', 'give' ),
293
-				'cta_text' => __( 'View All Forms', 'give' ),
294
-				'cta_link' => admin_url( 'edit.php?post_type=give_forms' ),
291
+				'heading'  => __('No donors found.', 'give'),
292
+				'message'  => __('When your first donation arrives, the donor will appear here.', 'give'),
293
+				'cta_text' => __('View All Forms', 'give'),
294
+				'cta_link' => admin_url('edit.php?post_type=give_forms'),
295 295
 				'help'     => sprintf(
296
-					__( 'Need help? Learn more about %sDonors%s.', 'give' ),
296
+					__('Need help? Learn more about %sDonors%s.', 'give'),
297 297
 					'<a href="http://docs.givewp.com/core-donors/">',
298 298
 					'</a>'
299 299
 				),
300 300
 			),
301 301
 		);
302 302
 
303
-		if ( isset( $content[ $context ] ) ) {
303
+		if (isset($content[$context])) {
304 304
 			// Merge contextual content with defaults.
305
-			return wp_parse_args( $content[ $context ], $defaults );
305
+			return wp_parse_args($content[$context], $defaults);
306 306
 		} else {
307 307
 			// Return defaults if context is undefined.
308 308
 			return $defaults;
Please login to merge, or discard this patch.
includes/admin/upgrades/class-give-updates.php 1 patch
Spacing   +248 added lines, -254 removed lines patch added patch discarded remove patch
@@ -80,34 +80,34 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @param array $args
82 82
 	 */
83
-	public function register( $args ) {
83
+	public function register($args) {
84 84
 		$args_default = array(
85 85
 			'id'       => '',
86 86
 			'version'  => '',
87 87
 			'callback' => '',
88 88
 		);
89 89
 
90
-		$args = wp_parse_args( $args, $args_default );
90
+		$args = wp_parse_args($args, $args_default);
91 91
 
92 92
 		// You can only register database upgrade.
93 93
 		$args['type'] = 'database';
94 94
 
95 95
 		// Bailout.
96 96
 		if (
97
-			empty( $args['id'] ) ||
98
-			empty( $args['version'] ) ||
99
-			empty( $args['callback'] ) ||
100
-			! is_callable( $args['callback'] )
97
+			empty($args['id']) ||
98
+			empty($args['version']) ||
99
+			empty($args['callback']) ||
100
+			! is_callable($args['callback'])
101 101
 		) {
102 102
 			return;
103 103
 		}
104 104
 
105 105
 		// Change depend param to array.
106
-		if ( isset( $args['depend'] ) && is_string( $args['depend'] ) ) {
107
-			$args['depend'] = array( $args['depend'] );
106
+		if (isset($args['depend']) && is_string($args['depend'])) {
107
+			$args['depend'] = array($args['depend']);
108 108
 		}
109 109
 
110
-		$this->updates[ $args['type'] ][] = $args;
110
+		$this->updates[$args['type']][] = $args;
111 111
 	}
112 112
 
113 113
 	/**
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 * @return static
119 119
 	 */
120 120
 	static function get_instance() {
121
-		if ( is_null( self::$instance ) ) {
121
+		if (is_null(self::$instance)) {
122 122
 			self::$instance = new self();
123 123
 		}
124 124
 
@@ -136,27 +136,27 @@  discard block
 block discarded – undo
136 136
 		/**
137 137
 		 * Load file
138 138
 		 */
139
-		require_once GIVE_PLUGIN_DIR . 'includes/class-give-background-updater.php';
140
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
139
+		require_once GIVE_PLUGIN_DIR.'includes/class-give-background-updater.php';
140
+		require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php';
141 141
 
142 142
 		self::$background_updater = new Give_Background_Updater();
143 143
 
144 144
 		/**
145 145
 		 * Setup hooks.
146 146
 		 */
147
-		add_action( 'init', array( $this, '__register_upgrade' ), 9999 );
148
-		add_action( 'give_set_upgrade_completed', array( $this, '__flush_resume_updates' ), 9999 );
149
-		add_action( 'wp_ajax_give_db_updates_info', array( $this, '__give_db_updates_info' ) );
150
-		add_action( 'wp_ajax_give_run_db_updates', array( $this, '__give_start_updating' ) );
151
-		add_action( 'admin_init', array( $this, '__redirect_admin' ) );
152
-		add_action( 'admin_init', array( $this, '__pause_db_update' ), - 1 );
153
-		add_action( 'admin_init', array( $this, '__restart_db_update' ), - 1 );
154
-		add_action( 'admin_notices', array( $this, '__show_notice' ) );
155
-		add_action( 'give_restart_db_upgrade', array( $this, '__health_background_update' ) );
156
-
157
-		if ( is_admin() ) {
158
-			add_action( 'admin_init', array( $this, '__change_donations_label' ), 9999 );
159
-			add_action( 'admin_menu', array( $this, '__register_menu' ), 9999 );
147
+		add_action('init', array($this, '__register_upgrade'), 9999);
148
+		add_action('give_set_upgrade_completed', array($this, '__flush_resume_updates'), 9999);
149
+		add_action('wp_ajax_give_db_updates_info', array($this, '__give_db_updates_info'));
150
+		add_action('wp_ajax_give_run_db_updates', array($this, '__give_start_updating'));
151
+		add_action('admin_init', array($this, '__redirect_admin'));
152
+		add_action('admin_init', array($this, '__pause_db_update'), - 1);
153
+		add_action('admin_init', array($this, '__restart_db_update'), - 1);
154
+		add_action('admin_notices', array($this, '__show_notice'));
155
+		add_action('give_restart_db_upgrade', array($this, '__health_background_update'));
156
+
157
+		if (is_admin()) {
158
+			add_action('admin_init', array($this, '__change_donations_label'), 9999);
159
+			add_action('admin_menu', array($this, '__register_menu'), 9999);
160 160
 		}
161 161
 	}
162 162
 
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
 		$addons         = give_get_plugins();
171 171
 		$plugin_updates = get_plugin_updates();
172 172
 
173
-		foreach ( $addons as $key => $info ) {
174
-			if ( 'active' != $info['Status'] || 'add-on' != $info['Type'] || empty( $plugin_updates[ $key ] ) ) {
173
+		foreach ($addons as $key => $info) {
174
+			if ('active' != $info['Status'] || 'add-on' != $info['Type'] || empty($plugin_updates[$key])) {
175 175
 				continue;
176 176
 			}
177 177
 
178
-			$this->updates['plugin'][] = array_merge( $info, (array) $plugin_updates[ $key ] );
178
+			$this->updates['plugin'][] = array_merge($info, (array) $plugin_updates[$key]);
179 179
 		}
180 180
 	}
181 181
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	 * @access public
188 188
 	 */
189 189
 	public function __register_upgrade() {
190
-		if ( ! is_admin() ) {
190
+		if ( ! is_admin()) {
191 191
 			return;
192 192
 		}
193 193
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 		 *
197 197
 		 * @since 1.8.12
198 198
 		 */
199
-		do_action( 'give_register_updates', $this );
199
+		do_action('give_register_updates', $this);
200 200
 	}
201 201
 
202 202
 	/**
@@ -209,23 +209,22 @@  discard block
 block discarded – undo
209 209
 		global $menu;
210 210
 
211 211
 		// Bailout.
212
-		if ( empty( $menu ) || ! $this->get_total_update_count() ) {
212
+		if (empty($menu) || ! $this->get_total_update_count()) {
213 213
 			return;
214 214
 		}
215 215
 
216
-		$is_update = ( $this->is_doing_updates() && ! self::$background_updater->is_paused_process() );
216
+		$is_update = ($this->is_doing_updates() && ! self::$background_updater->is_paused_process());
217 217
 
218
-		foreach ( $menu as $index => $menu_item ) {
219
-			if ( 'edit.php?post_type=give_forms' !== $menu_item[2] ) {
218
+		foreach ($menu as $index => $menu_item) {
219
+			if ('edit.php?post_type=give_forms' !== $menu_item[2]) {
220 220
 				continue;
221 221
 			}
222 222
 
223
-			$menu[ $index ][0] = sprintf(
223
+			$menu[$index][0] = sprintf(
224 224
 				'%1$s <span class="update-plugins"><span class="plugin-count give-update-progress-count">%2$s%3$s</span></span>',
225
-				__( 'Donations', 'give' ),
225
+				__('Donations', 'give'),
226 226
 				$is_update ?
227
-					$this->get_db_update_processing_percentage() :
228
-					$this->get_total_update_count(),
227
+					$this->get_db_update_processing_percentage() : $this->get_total_update_count(),
229 228
 				$is_update ? '%' : ''
230 229
 			);
231 230
 
@@ -241,7 +240,7 @@  discard block
 block discarded – undo
241 240
 	 */
242 241
 	public function __register_menu() {
243 242
 		// Bailout.
244
-		if ( ! give_test_ajax_works() ) {
243
+		if ( ! give_test_ajax_works()) {
245 244
 			return;
246 245
 		}
247 246
 
@@ -249,41 +248,40 @@  discard block
 block discarded – undo
249 248
 		$this->__register_plugin_addon_updates();
250 249
 
251 250
 		// Bailout.
252
-		if ( ! $this->get_total_update_count() ) {
251
+		if ( ! $this->get_total_update_count()) {
253 252
 			// Show complete update message if still on update setting page.
254
-			if ( isset( $_GET['page'] ) && 'give-updates' === $_GET['page'] ) {
253
+			if (isset($_GET['page']) && 'give-updates' === $_GET['page']) {
255 254
 				// Upgrades
256 255
 				add_submenu_page(
257 256
 					'edit.php?post_type=give_forms',
258
-					esc_html__( 'Give Updates Complete', 'give' ),
259
-					__( 'Updates', 'give' ),
257
+					esc_html__('Give Updates Complete', 'give'),
258
+					__('Updates', 'give'),
260 259
 					'manage_give_settings',
261 260
 					'give-updates',
262
-					array( $this, 'render_complete_page' )
261
+					array($this, 'render_complete_page')
263 262
 				);
264 263
 			}
265 264
 
266 265
 			return;
267 266
 		}
268 267
 
269
-		$is_update = ( $this->is_doing_updates() && ! self::$background_updater->is_paused_process() );
268
+		$is_update = ($this->is_doing_updates() && ! self::$background_updater->is_paused_process());
270 269
 
271 270
 		// Upgrades
272 271
 		add_submenu_page(
273 272
 			'edit.php?post_type=give_forms',
274
-			esc_html__( 'Give Updates', 'give' ),
273
+			esc_html__('Give Updates', 'give'),
275 274
 			sprintf(
276 275
 				'%1$s <span class="update-plugins"%2$s><span class="plugin-count give-update-progress-count">%3$s%4$s</span></span>',
277
-				__( 'Updates', 'give' ),
278
-				isset( $_GET['give-pause-db-upgrades'] ) ? ' style="display:none;"' : '',
276
+				__('Updates', 'give'),
277
+				isset($_GET['give-pause-db-upgrades']) ? ' style="display:none;"' : '',
279 278
 				$is_update ?
280
-					$this->get_db_update_processing_percentage() :
281
-					$this->get_total_update_count(),
279
+					$this->get_db_update_processing_percentage() : $this->get_total_update_count(),
282 280
 				$is_update ? '%' : ''
283 281
 			),
284 282
 			'manage_give_settings',
285 283
 			'give-updates',
286
-			array( $this, 'render_page' )
284
+			array($this, 'render_page')
287 285
 		);
288 286
 	}
289 287
 
@@ -298,13 +296,13 @@  discard block
 block discarded – undo
298 296
 		// Show db upgrade completed notice.
299 297
 		if (
300 298
 			! wp_doing_ajax() &&
301
-			current_user_can( 'manage_give_settings' ) &&
302
-			get_option( 'give_show_db_upgrade_complete_notice' ) &&
303
-			! isset( $_GET['give-db-update-completed'] )
299
+			current_user_can('manage_give_settings') &&
300
+			get_option('give_show_db_upgrade_complete_notice') &&
301
+			! isset($_GET['give-db-update-completed'])
304 302
 		) {
305
-			delete_option( 'give_show_db_upgrade_complete_notice' );
303
+			delete_option('give_show_db_upgrade_complete_notice');
306 304
 
307
-			wp_redirect( add_query_arg( array( 'give-db-update-completed' => 'give_db_upgrade_completed' ) ) );
305
+			wp_redirect(add_query_arg(array('give-db-update-completed' => 'give_db_upgrade_completed')));
308 306
 			exit();
309 307
 		}
310 308
 	}
@@ -320,15 +318,15 @@  discard block
 block discarded – undo
320 318
 	 *
321 319
 	 * @return bool
322 320
 	 */
323
-	public function __pause_db_update( $force = false ) {
321
+	public function __pause_db_update($force = false) {
324 322
 		// Bailout.
325 323
 		if (
326 324
 			! $force &&
327 325
 			(
328 326
 				wp_doing_ajax() ||
329
-				! isset( $_GET['page'] ) ||
327
+				! isset($_GET['page']) ||
330 328
 				'give-updates' !== $_GET['page'] ||
331
-				! isset( $_GET['give-pause-db-upgrades'] ) ||
329
+				! isset($_GET['give-pause-db-upgrades']) ||
332 330
 				self::$background_updater->is_paused_process()
333 331
 			)
334 332
 
@@ -336,13 +334,13 @@  discard block
 block discarded – undo
336 334
 			return false;
337 335
 		}
338 336
 
339
-		delete_option( 'give_upgrade_error' );
337
+		delete_option('give_upgrade_error');
340 338
 
341
-		$this->__health_background_update( $this );
339
+		$this->__health_background_update($this);
342 340
 		$batch = self::$background_updater->get_all_batch();
343 341
 
344 342
 		// Bailout: if batch is empty
345
-		if ( empty( $batch->data ) ) {
343
+		if (empty($batch->data)) {
346 344
 			return false;
347 345
 		}
348 346
 
@@ -351,25 +349,25 @@  discard block
 block discarded – undo
351 349
 
352 350
 		// Do not stop background process immediately if task running.
353 351
 		// @see Give_Background_Updater::lock_process
354
-		if ( ! $force && self::$background_updater->is_process_running() ) {
355
-			update_option( 'give_pause_upgrade', 1 );
352
+		if ( ! $force && self::$background_updater->is_process_running()) {
353
+			update_option('give_pause_upgrade', 1);
356 354
 
357 355
 			return true;
358 356
 		}
359 357
 
360
-		update_option( 'give_paused_batches', $batch, 'no' );
361
-		delete_option( $batch->key );
362
-		delete_site_transient( self::$background_updater->get_identifier() . '_process_lock' );
363
-		wp_clear_scheduled_hook( self::$background_updater->get_cron_identifier() );
358
+		update_option('give_paused_batches', $batch, 'no');
359
+		delete_option($batch->key);
360
+		delete_site_transient(self::$background_updater->get_identifier().'_process_lock');
361
+		wp_clear_scheduled_hook(self::$background_updater->get_cron_identifier());
364 362
 
365
-		Give()->logs->add( 'Update Pause', print_r( $batch, true ), 0, 'update' );
363
+		Give()->logs->add('Update Pause', print_r($batch, true), 0, 'update');
366 364
 
367 365
 		/**
368 366
 		 * Fire action when pause db updates
369 367
 		 *
370 368
 		 * @since 2.0.1
371 369
 		 */
372
-		do_action( 'give_pause_db_upgrade', $this );
370
+		do_action('give_pause_db_upgrade', $this);
373 371
 
374 372
 		return true;
375 373
 	}
@@ -386,31 +384,31 @@  discard block
 block discarded – undo
386 384
 		// Bailout.
387 385
 		if (
388 386
 			wp_doing_ajax() ||
389
-			! isset( $_GET['page'] ) ||
387
+			! isset($_GET['page']) ||
390 388
 			'give-updates' !== $_GET['page'] ||
391
-			! isset( $_GET['give-restart-db-upgrades'] ) ||
389
+			! isset($_GET['give-restart-db-upgrades']) ||
392 390
 			! self::$background_updater->is_paused_process()
393 391
 		) {
394 392
 			return false;
395 393
 		}
396 394
 
397 395
 		Give_Background_Updater::flush_cache();
398
-		$batch = get_option( 'give_paused_batches' );
396
+		$batch = get_option('give_paused_batches');
399 397
 
400
-		if ( ! empty( $batch ) ) {
401
-			wp_cache_delete( $batch->key, 'options' );
402
-			update_option( $batch->key, $batch->data );
398
+		if ( ! empty($batch)) {
399
+			wp_cache_delete($batch->key, 'options');
400
+			update_option($batch->key, $batch->data);
403 401
 
404
-			delete_option( 'give_paused_batches' );
402
+			delete_option('give_paused_batches');
405 403
 
406
-			Give()->logs->add( 'Update Restart', print_r( $batch, true ), 0, 'update' );
404
+			Give()->logs->add('Update Restart', print_r($batch, true), 0, 'update');
407 405
 
408 406
 
409 407
 			/** Fire action when restart db updates
410 408
 			 *
411 409
 			 * @since 2.0.1
412 410
 			 */
413
-			do_action( 'give_restart_db_upgrade', $this );
411
+			do_action('give_restart_db_upgrade', $this);
414 412
 
415 413
 			self::$background_updater->dispatch();
416 414
 		}
@@ -426,53 +424,53 @@  discard block
 block discarded – undo
426 424
 	 *
427 425
 	 * @param Give_Updates $give_updates
428 426
 	 */
429
-	public function __health_background_update( $give_updates ) {
430
-		if ( ! $this->is_doing_updates() ) {
427
+	public function __health_background_update($give_updates) {
428
+		if ( ! $this->is_doing_updates()) {
431 429
 			return;
432 430
 		}
433 431
 
434 432
 		Give_Background_Updater::flush_cache();
435 433
 
436 434
 		$batch                = Give_Updates::$background_updater->get_all_batch();
437
-		$batch_data_count     = count( $batch->data );
438
-		$all_updates          = $give_updates->get_updates( 'database', 'all' );
439
-		$all_update_ids       = wp_list_pluck( $all_updates, 'id' );
440
-		$all_batch_update_ids = ! empty( $batch->data ) ? wp_list_pluck( $batch->data, 'id' ) : array();
435
+		$batch_data_count     = count($batch->data);
436
+		$all_updates          = $give_updates->get_updates('database', 'all');
437
+		$all_update_ids       = wp_list_pluck($all_updates, 'id');
438
+		$all_batch_update_ids = ! empty($batch->data) ? wp_list_pluck($batch->data, 'id') : array();
441 439
 		$log_data             = '';
442
-		$doing_upgrade_args   = get_option( 'give_doing_upgrade' );
440
+		$doing_upgrade_args   = get_option('give_doing_upgrade');
443 441
 
444
-		if ( ! empty( $doing_upgrade_args ) ) {
445
-			$log_data .= 'Doing update:' . "\n";
446
-			$log_data .= print_r( $doing_upgrade_args, true ) . "\n";
442
+		if ( ! empty($doing_upgrade_args)) {
443
+			$log_data .= 'Doing update:'."\n";
444
+			$log_data .= print_r($doing_upgrade_args, true)."\n";
447 445
 		}
448 446
 
449 447
 		/**
450 448
 		 * Add remove upgrade from batch
451 449
 		 */
452
-		if ( ! empty( $batch->data ) ) {
450
+		if ( ! empty($batch->data)) {
453 451
 
454
-			foreach ( $batch->data as $index => $update ) {
455
-				$log_data = print_r( $update, true ) . "\n";
452
+			foreach ($batch->data as $index => $update) {
453
+				$log_data = print_r($update, true)."\n";
456 454
 
457
-				if ( ! is_callable( $update['callback'] ) ) {
458
-					$log_data .= 'Removing missing callback update: ' . "{$update['id']}\n";
459
-					unset( $batch->data[ $index ] );
460
-				} elseif ( give_has_upgrade_completed( $update['id'] ) ) {
461
-					$log_data .= 'Removing already completed update: ' . "{$update['id']}\n";
462
-					unset( $batch->data[ $index ] );
455
+				if ( ! is_callable($update['callback'])) {
456
+					$log_data .= 'Removing missing callback update: '."{$update['id']}\n";
457
+					unset($batch->data[$index]);
458
+				} elseif (give_has_upgrade_completed($update['id'])) {
459
+					$log_data .= 'Removing already completed update: '."{$update['id']}\n";
460
+					unset($batch->data[$index]);
463 461
 				}
464 462
 
465
-				if ( ! empty( $update['depend'] ) ) {
463
+				if ( ! empty($update['depend'])) {
466 464
 
467
-					foreach ( $update['depend'] as $depend ) {
468
-						if ( give_has_upgrade_completed( $depend ) ) {
469
-							$log_data .= 'Completed update: ' . "{$depend}\n";
465
+					foreach ($update['depend'] as $depend) {
466
+						if (give_has_upgrade_completed($depend)) {
467
+							$log_data .= 'Completed update: '."{$depend}\n";
470 468
 							continue;
471 469
 						}
472 470
 
473
-						if ( in_array( $depend, $all_update_ids ) && ! in_array( $depend, $all_batch_update_ids ) ) {
474
-							$log_data .= 'Adding missing update: ' . "{$depend}\n";
475
-							array_unshift( $batch->data, $all_updates[ array_search( $depend, $all_update_ids ) ] );
471
+						if (in_array($depend, $all_update_ids) && ! in_array($depend, $all_batch_update_ids)) {
472
+							$log_data .= 'Adding missing update: '."{$depend}\n";
473
+							array_unshift($batch->data, $all_updates[array_search($depend, $all_update_ids)]);
476 474
 						}
477 475
 					}
478 476
 				}
@@ -482,63 +480,63 @@  discard block
 block discarded – undo
482 480
 		/**
483 481
 		 * Add new upgrade to batch
484 482
 		 */
485
-		if ( $new_updates = $this->get_updates( 'database', 'new' ) ) {
486
-			$all_batch_update_ids = ! empty( $batch->data ) ? wp_list_pluck( $batch->data, 'id' ) : array();
483
+		if ($new_updates = $this->get_updates('database', 'new')) {
484
+			$all_batch_update_ids = ! empty($batch->data) ? wp_list_pluck($batch->data, 'id') : array();
487 485
 
488
-			foreach ( $new_updates as $index => $new_update ) {
489
-				if ( give_has_upgrade_completed( $new_update['id'] ) || in_array( $new_update['id'], $all_batch_update_ids ) ) {
490
-					unset( $new_updates[ $index ] );
486
+			foreach ($new_updates as $index => $new_update) {
487
+				if (give_has_upgrade_completed($new_update['id']) || in_array($new_update['id'], $all_batch_update_ids)) {
488
+					unset($new_updates[$index]);
491 489
 				}
492 490
 			}
493 491
 
494
-			if ( ! empty( $new_updates ) ) {
495
-				$log_data .= 'Adding new update: ' . "\n";
496
-				$log_data .= print_r( $new_updates, true ) . "\n";
492
+			if ( ! empty($new_updates)) {
493
+				$log_data .= 'Adding new update: '."\n";
494
+				$log_data .= print_r($new_updates, true)."\n";
497 495
 
498
-				$batch->data = array_merge( (array) $batch->data, $new_updates );
499
-				update_option( 'give_db_update_count', ( absint( get_option( 'give_db_update_count' ) ) + count( $new_updates ) ) );
496
+				$batch->data = array_merge((array) $batch->data, $new_updates);
497
+				update_option('give_db_update_count', (absint(get_option('give_db_update_count')) + count($new_updates)));
500 498
 			}
501 499
 		}
502 500
 
503 501
 		/**
504 502
 		 * Fix batch
505 503
 		 */
506
-		if ( empty( $batch->data ) ) {
504
+		if (empty($batch->data)) {
507 505
 			// Complete batch if do not have any data to process.
508
-			self::$background_updater->delete( $batch->key );
506
+			self::$background_updater->delete($batch->key);
509 507
 
510
-			if ( self::$background_updater->has_queue() ) {
511
-				$this->__health_background_update( $this );
508
+			if (self::$background_updater->has_queue()) {
509
+				$this->__health_background_update($this);
512 510
 			} else {
513
-				delete_site_transient( self::$background_updater->get_identifier() . '_process_lock' );
514
-				wp_clear_scheduled_hook( self::$background_updater->get_cron_identifier() );
511
+				delete_site_transient(self::$background_updater->get_identifier().'_process_lock');
512
+				wp_clear_scheduled_hook(self::$background_updater->get_cron_identifier());
515 513
 
516 514
 				self::$background_updater->complete();
517 515
 			}
518 516
 
519
-		} elseif ( $batch_data_count !== count( $batch->data ) ) {
517
+		} elseif ($batch_data_count !== count($batch->data)) {
520 518
 
521
-			$log_data .= 'Updating batch' . "\n";
522
-			$log_data .= print_r( $batch, true );
519
+			$log_data .= 'Updating batch'."\n";
520
+			$log_data .= print_r($batch, true);
523 521
 
524
-			$doing_upgrade_args['heading']          = sprintf( 'Update %s of %s', $doing_upgrade_args['update'], get_option( 'give_db_update_count' ) );
522
+			$doing_upgrade_args['heading']          = sprintf('Update %s of %s', $doing_upgrade_args['update'], get_option('give_db_update_count'));
525 523
 			$doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage();
526
-			update_option( 'give_doing_upgrade', $doing_upgrade_args );
524
+			update_option('give_doing_upgrade', $doing_upgrade_args);
527 525
 
528
-			if ( ! empty( $batch->key ) ) {
529
-				wp_cache_delete( $batch->key, 'options' );
530
-				update_option( $batch->key, $batch->data );
526
+			if ( ! empty($batch->key)) {
527
+				wp_cache_delete($batch->key, 'options');
528
+				update_option($batch->key, $batch->data);
531 529
 			} else {
532 530
 
533
-				update_option( 'give_db_update_count', count( $batch->data ) );
531
+				update_option('give_db_update_count', count($batch->data));
534 532
 
535 533
 				$doing_upgrade_args['update']  = $give_updates->update;
536
-				$doing_upgrade_args['heading'] = sprintf( 'Update %s of %s', 1, count( $batch->data ) );
534
+				$doing_upgrade_args['heading'] = sprintf('Update %s of %s', 1, count($batch->data));
537 535
 
538
-				update_option( 'give_doing_upgrade', $doing_upgrade_args );
536
+				update_option('give_doing_upgrade', $doing_upgrade_args);
539 537
 
540
-				foreach ( $batch->data as $data ) {
541
-					Give_Updates::$background_updater->push_to_queue( $data );
538
+				foreach ($batch->data as $data) {
539
+					Give_Updates::$background_updater->push_to_queue($data);
542 540
 				}
543 541
 
544 542
 				Give_Updates::$background_updater->save();
@@ -550,27 +548,27 @@  discard block
 block discarded – undo
550 548
 		 * Fix give_doing_upgrade option
551 549
 		 */
552 550
 		$update_option = false;
553
-		$fresh_new_db_count = $this->get_total_new_db_update_count( true );
554
-		if ( $fresh_new_db_count < $doing_upgrade_args['update'] ) {
555
-			update_option( 'give_db_update_count', $fresh_new_db_count );
551
+		$fresh_new_db_count = $this->get_total_new_db_update_count(true);
552
+		if ($fresh_new_db_count < $doing_upgrade_args['update']) {
553
+			update_option('give_db_update_count', $fresh_new_db_count);
556 554
 			$doing_upgrade_args['update']  = 1;
557
-			$doing_upgrade_args['heading'] = sprintf( 'Update %s of %s', 1, $fresh_new_db_count );
555
+			$doing_upgrade_args['heading'] = sprintf('Update %s of %s', 1, $fresh_new_db_count);
558 556
 			$update_option                 = true;
559 557
 		}
560 558
 
561
-		if ( 101 < $doing_upgrade_args['total_percentage'] ) {
562
-			$doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage( true );
559
+		if (101 < $doing_upgrade_args['total_percentage']) {
560
+			$doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage(true);
563 561
 			$update_option                          = true;
564 562
 		}
565 563
 
566
-		if ( $update_option ) {
567
-			update_option( 'give_doing_upgrade', $doing_upgrade_args );
564
+		if ($update_option) {
565
+			update_option('give_doing_upgrade', $doing_upgrade_args);
568 566
 
569
-			$log_data .= 'Updated doing update:' . "\n";
570
-			$log_data .= print_r( $doing_upgrade_args, true ) . "\n";
567
+			$log_data .= 'Updated doing update:'."\n";
568
+			$log_data .= print_r($doing_upgrade_args, true)."\n";
571 569
 		}
572 570
 
573
-		Give()->logs->add( 'Update Health Check', $log_data, 0, 'update' );
571
+		Give()->logs->add('Update Health Check', $log_data, 0, 'update');
574 572
 	}
575 573
 
576 574
 
@@ -582,66 +580,66 @@  discard block
 block discarded – undo
582 580
 	 */
583 581
 	public function __show_notice() {
584 582
 		// Bailout.
585
-		if ( ! current_user_can( 'manage_give_settings' ) ) {
583
+		if ( ! current_user_can('manage_give_settings')) {
586 584
 			return;
587 585
 		}
588 586
 
589 587
 		// Run DB updates.
590
-		if ( ! empty( $_GET['give-run-db-update'] ) ) {
588
+		if ( ! empty($_GET['give-run-db-update'])) {
591 589
 			$this->run_db_update();
592 590
 		}
593 591
 
594 592
 
595 593
 		// Bailout.
596
-		if ( isset( $_GET['page'] ) && 'give-updates' === $_GET['page'] ) {
594
+		if (isset($_GET['page']) && 'give-updates' === $_GET['page']) {
597 595
 			return;
598 596
 		}
599 597
 
600 598
 		// Show notice if upgrade paused.
601
-		if ( self::$background_updater->is_paused_process() ) {
599
+		if (self::$background_updater->is_paused_process()) {
602 600
 			ob_start();
603 601
 
604
-			$upgrade_error = get_option( 'give_upgrade_error' );
605
-			if ( ! $upgrade_error ) : ?>
606
-				<strong><?php _e( 'Database Update', 'give' ); ?></strong>
607
-				&nbsp;&#8211;&nbsp;<?php _e( 'GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a backup before proceeding.', 'give' ); ?>
602
+			$upgrade_error = get_option('give_upgrade_error');
603
+			if ( ! $upgrade_error) : ?>
604
+				<strong><?php _e('Database Update', 'give'); ?></strong>
605
+				&nbsp;&#8211;&nbsp;<?php _e('GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a backup before proceeding.', 'give'); ?>
608 606
 				<br>
609 607
 				<br>
610
-				<a href="<?php echo esc_url( add_query_arg( array( 'give-restart-db-upgrades' => 1 ), admin_url( 'edit.php?post_type=give_forms&page=give-updates' ) ) ); ?>" class="button button-primary give-restart-updater-btn">
611
-					<?php _e( 'Restart the updater', 'give' ); ?>
608
+				<a href="<?php echo esc_url(add_query_arg(array('give-restart-db-upgrades' => 1), admin_url('edit.php?post_type=give_forms&page=give-updates'))); ?>" class="button button-primary give-restart-updater-btn">
609
+					<?php _e('Restart the updater', 'give'); ?>
612 610
 				</a>
613 611
 				<script type="text/javascript">
614 612
 					jQuery('.give-restart-updater-btn').click('click', function () {
615
-						return window.confirm('<?php echo esc_js( __( 'It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give' ) ); ?>'); // jshint ignore:line
613
+						return window.confirm('<?php echo esc_js(__('It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give')); ?>'); // jshint ignore:line
616 614
 					});
617 615
 				</script>
618 616
 			<?php else: ?>
619
-				<strong><?php _e( 'Database Update', 'give' ); ?></strong>
620
-				&nbsp;&#8211;&nbsp;<?php _e( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); ?>
617
+				<strong><?php _e('Database Update', 'give'); ?></strong>
618
+				&nbsp;&#8211;&nbsp;<?php _e('An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give'); ?>
621 619
 			<?php
622 620
 			endif;
623 621
 			$desc_html = ob_get_clean();
624 622
 
625
-			Give()->notices->register_notice( array(
623
+			Give()->notices->register_notice(array(
626 624
 				'id'          => 'give_upgrade_db',
627 625
 				'type'        => 'error',
628 626
 				'dismissible' => false,
629 627
 				'description' => $desc_html,
630
-			) );
628
+			));
631 629
 		}
632 630
 
633 631
 		// Bailout if doing upgrades.
634
-		if ( $this->is_doing_updates() ) {
632
+		if ($this->is_doing_updates()) {
635 633
 			return;
636 634
 		}
637 635
 
638 636
 		// Show notice if ajax is not working.
639
-		if ( ! give_test_ajax_works() ) {
637
+		if ( ! give_test_ajax_works()) {
640 638
 			Give()->notices->register_notice(
641 639
 				array(
642 640
 					'id'          => 'give_db_upgrade_ajax_inaccessible',
643 641
 					'type'        => 'error',
644
-					'description' => sprintf( '%1$s <a href="%2$s" target="_blank">%3$s</a>', __( 'Give needs to upgrade the database but cannot because AJAX does not appear accessible. This could be because your website is password protected, in maintenance mode, or has a specific hosting configuration or plugin active that is preventing access.', 'give' ), 'http://docs.givewp.com/admin-ajax-error', __( 'Read More', 'give' ) . ' &raquo;' ),
642
+					'description' => sprintf('%1$s <a href="%2$s" target="_blank">%3$s</a>', __('Give needs to upgrade the database but cannot because AJAX does not appear accessible. This could be because your website is password protected, in maintenance mode, or has a specific hosting configuration or plugin active that is preventing access.', 'give'), 'http://docs.givewp.com/admin-ajax-error', __('Read More', 'give').' &raquo;'),
645 643
 					'show'        => true,
646 644
 				)
647 645
 			);
@@ -650,45 +648,45 @@  discard block
 block discarded – undo
650 648
 		}
651 649
 
652 650
 		// Show db upgrade completed notice.
653
-		if ( ! empty( $_GET['give-db-update-completed'] ) ) {
654
-			Give()->notices->register_notice( array(
651
+		if ( ! empty($_GET['give-db-update-completed'])) {
652
+			Give()->notices->register_notice(array(
655 653
 				'id'          => 'give_db_upgrade_completed',
656 654
 				'type'        => 'updated',
657
-				'description' => __( 'Give database updates completed successfully. Thank you for updating to the latest version!', 'give' ),
655
+				'description' => __('Give database updates completed successfully. Thank you for updating to the latest version!', 'give'),
658 656
 				'show'        => true,
659
-			) );
657
+			));
660 658
 
661 659
 			// Start update.
662
-		} elseif ( ! empty( $_GET['give-run-db-update'] ) ) {
660
+		} elseif ( ! empty($_GET['give-run-db-update'])) {
663 661
 			$this->run_db_update();
664 662
 
665 663
 			// Show run the update notice.
666
-		} elseif ( $this->get_total_new_db_update_count() ) {
664
+		} elseif ($this->get_total_new_db_update_count()) {
667 665
 			ob_start();
668 666
 			?>
669 667
 			<p>
670
-				<strong><?php _e( 'Database Update', 'give' ); ?></strong>
671
-				&nbsp;&#8211;&nbsp;<?php _e( 'GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a complete backup before proceeding.', 'give' ); ?>
668
+				<strong><?php _e('Database Update', 'give'); ?></strong>
669
+				&nbsp;&#8211;&nbsp;<?php _e('GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a complete backup before proceeding.', 'give'); ?>
672 670
 			</p>
673 671
 			<p class="submit">
674
-				<a href="<?php echo esc_url( add_query_arg( array( 'give-run-db-update' => 1 ), admin_url( 'edit.php?post_type=give_forms&page=give-updates' ) ) ); ?>" class="button button-primary give-run-update-now">
675
-					<?php _e( 'Run the updater', 'give' ); ?>
672
+				<a href="<?php echo esc_url(add_query_arg(array('give-run-db-update' => 1), admin_url('edit.php?post_type=give_forms&page=give-updates'))); ?>" class="button button-primary give-run-update-now">
673
+					<?php _e('Run the updater', 'give'); ?>
676 674
 				</a>
677 675
 			</p>
678 676
 			<script type="text/javascript">
679 677
 				jQuery('.give-run-update-now').click('click', function () {
680
-					return window.confirm('<?php echo esc_js( __( 'It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give' ) ); ?>'); // jshint ignore:line
678
+					return window.confirm('<?php echo esc_js(__('It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give')); ?>'); // jshint ignore:line
681 679
 				});
682 680
 			</script>
683 681
 			<?php
684 682
 			$desc_html = ob_get_clean();
685 683
 
686
-			Give()->notices->register_notice( array(
684
+			Give()->notices->register_notice(array(
687 685
 				'id'          => 'give_upgrade_db',
688 686
 				'type'        => 'updated',
689 687
 				'dismissible' => false,
690 688
 				'description' => $desc_html,
691
-			) );
689
+			));
692 690
 		}
693 691
 	}
694 692
 
@@ -699,7 +697,7 @@  discard block
 block discarded – undo
699 697
 	 * @access public
700 698
 	 */
701 699
 	public function render_complete_page() {
702
-		include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades-complete.php';
700
+		include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades-complete.php';
703 701
 	}
704 702
 
705 703
 	/**
@@ -709,7 +707,7 @@  discard block
 block discarded – undo
709 707
 	 * @access public
710 708
 	 */
711 709
 	public function render_page() {
712
-		include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades.php';
710
+		include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades.php';
713 711
 	}
714 712
 
715 713
 	/**
@@ -720,26 +718,26 @@  discard block
 block discarded – undo
720 718
 	 */
721 719
 	private function run_db_update() {
722 720
 		// Bailout.
723
-		if ( $this->is_doing_updates() || ! $this->get_total_new_db_update_count() ) {
721
+		if ($this->is_doing_updates() || ! $this->get_total_new_db_update_count()) {
724 722
 			return;
725 723
 		}
726 724
 
727
-		$updates = $this->get_updates( 'database', 'new' );
725
+		$updates = $this->get_updates('database', 'new');
728 726
 
729
-		foreach ( $updates as $update ) {
730
-			self::$background_updater->push_to_queue( $update );
727
+		foreach ($updates as $update) {
728
+			self::$background_updater->push_to_queue($update);
731 729
 		}
732 730
 
733
-		add_option( 'give_db_update_count', count( $updates ), '', 'no' );
731
+		add_option('give_db_update_count', count($updates), '', 'no');
734 732
 
735
-		add_option( 'give_doing_upgrade', array(
733
+		add_option('give_doing_upgrade', array(
736 734
 			'update_info'      => $updates[0],
737 735
 			'step'             => 1,
738 736
 			'update'           => 1,
739
-			'heading'          => sprintf( 'Update %s of %s', 1, count( $updates ) ),
737
+			'heading'          => sprintf('Update %s of %s', 1, count($updates)),
740 738
 			'percentage'       => 0,
741 739
 			'total_percentage' => 0,
742
-		), '', 'no' );
740
+		), '', 'no');
743 741
 
744 742
 		self::$background_updater->save()->dispatch();
745 743
 	}
@@ -753,14 +751,13 @@  discard block
 block discarded – undo
753 751
 	 */
754 752
 	public function __flush_resume_updates() {
755 753
 		//delete_option( 'give_doing_upgrade' );
756
-		update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
754
+		update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
757 755
 
758 756
 		// Reset counter.
759 757
 		$this->step = $this->percentage = 0;
760 758
 
761
-		$this->update = ( $this->get_total_db_update_count() > $this->update ) ?
762
-			( $this->update + 1 ) :
763
-			$this->update;
759
+		$this->update = ($this->get_total_db_update_count() > $this->update) ?
760
+			($this->update + 1) : $this->update;
764 761
 	}
765 762
 
766 763
 
@@ -775,7 +772,7 @@  discard block
 block discarded – undo
775 772
 	public function __give_start_updating() {
776 773
 		// Check permission.
777 774
 		if (
778
-			! current_user_can( 'manage_give_settings' ) ||
775
+			! current_user_can('manage_give_settings') ||
779 776
 			$this->is_doing_updates()
780 777
 		) {
781 778
 			wp_send_json_error();
@@ -783,7 +780,7 @@  discard block
 block discarded – undo
783 780
 
784 781
 		// @todo: validate nonce
785 782
 		// @todo: set http method to post
786
-		if ( empty( $_POST['run_db_update'] ) ) {
783
+		if (empty($_POST['run_db_update'])) {
787 784
 			wp_send_json_error();
788 785
 		}
789 786
 
@@ -802,34 +799,34 @@  discard block
 block discarded – undo
802 799
 	 * @return string
803 800
 	 */
804 801
 	public function __give_db_updates_info() {
805
-		$update_info   = get_option( 'give_doing_upgrade' );
802
+		$update_info   = get_option('give_doing_upgrade');
806 803
 		$response_type = '';
807 804
 
808
-		if ( self::$background_updater->is_paused_process() ) {
805
+		if (self::$background_updater->is_paused_process()) {
809 806
 			$update_info = array(
810
-				'message'    => __( 'The updates have been paused.', 'give' ),
811
-				'heading'    => __( '', 'give' ),
807
+				'message'    => __('The updates have been paused.', 'give'),
808
+				'heading'    => __('', 'give'),
812 809
 				'percentage' => 0,
813 810
 			);
814 811
 
815
-			if ( get_option( 'give_upgrade_error' ) ) {
816
-				$update_info['message'] = __( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' );
812
+			if (get_option('give_upgrade_error')) {
813
+				$update_info['message'] = __('An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give');
817 814
 			}
818 815
 
819 816
 			$response_type = 'error';
820 817
 
821
-		} elseif ( empty( $update_info ) ) {
818
+		} elseif (empty($update_info)) {
822 819
 			$update_info   = array(
823
-				'message'    => __( 'Give database updates completed successfully. Thank you for updating to the latest version!', 'give' ),
824
-				'heading'    => __( 'Updates Completed.', 'give' ),
820
+				'message'    => __('Give database updates completed successfully. Thank you for updating to the latest version!', 'give'),
821
+				'heading'    => __('Updates Completed.', 'give'),
825 822
 				'percentage' => 0,
826 823
 			);
827 824
 			$response_type = 'success';
828 825
 
829
-			delete_option( 'give_show_db_upgrade_complete_notice' );
826
+			delete_option('give_show_db_upgrade_complete_notice');
830 827
 		}
831 828
 
832
-		$this->send_ajax_response( $update_info, $response_type );
829
+		$this->send_ajax_response($update_info, $response_type);
833 830
 	}
834 831
 
835 832
 	/**
@@ -841,7 +838,7 @@  discard block
 block discarded – undo
841 838
 	 * @param        $data
842 839
 	 * @param string $type
843 840
 	 */
844
-	public function send_ajax_response( $data, $type = '' ) {
841
+	public function send_ajax_response($data, $type = '') {
845 842
 		$default = array(
846 843
 			'message'    => '',
847 844
 			'heading'    => '',
@@ -851,24 +848,24 @@  discard block
 block discarded – undo
851 848
 		);
852 849
 
853 850
 		// Set data.
854
-		$data = wp_parse_args( $data, $default );
851
+		$data = wp_parse_args($data, $default);
855 852
 
856 853
 		// Enable cache.
857 854
 		Give_Cache::enable();
858 855
 
859
-		switch ( $type ) {
856
+		switch ($type) {
860 857
 			case 'success':
861
-				wp_send_json_success( $data );
858
+				wp_send_json_success($data);
862 859
 				break;
863 860
 
864 861
 			case 'error':
865
-				wp_send_json_error( $data );
862
+				wp_send_json_error($data);
866 863
 				break;
867 864
 
868 865
 			default:
869
-				wp_send_json( array(
866
+				wp_send_json(array(
870 867
 					'data' => $data,
871
-				) );
868
+				));
872 869
 				break;
873 870
 		}
874 871
 	}
@@ -882,12 +879,12 @@  discard block
 block discarded – undo
882 879
 	 * @param $total
883 880
 	 * @param $current_total
884 881
 	 */
885
-	public function set_percentage( $total, $current_total ) {
882
+	public function set_percentage($total, $current_total) {
886 883
 		// Set percentage.
887
-		$this->percentage = $total ? ( ( $current_total ) / $total ) * 100 : 0;
884
+		$this->percentage = $total ? (($current_total) / $total) * 100 : 0;
888 885
 
889 886
 		// Verify percentage.
890
-		$this->percentage = ( 100 < $this->percentage ) ? 100 : $this->percentage;
887
+		$this->percentage = (100 < $this->percentage) ? 100 : $this->percentage;
891 888
 	}
892 889
 
893 890
 	/**
@@ -900,22 +897,22 @@  discard block
 block discarded – undo
900 897
 	 *
901 898
 	 * @return bool|null
902 899
 	 */
903
-	public function is_parent_updates_completed( $update ) {
900
+	public function is_parent_updates_completed($update) {
904 901
 		// Bailout.
905
-		if ( empty( $update['depend'] ) ) {
902
+		if (empty($update['depend'])) {
906 903
 			return true;
907 904
 		}
908 905
 
909 906
 		// Check if dependency is valid or not.
910
-		if ( ! $this->has_valid_dependency( $update ) ) {
907
+		if ( ! $this->has_valid_dependency($update)) {
911 908
 			return null;
912 909
 		}
913 910
 
914 911
 		$is_dependency_completed = true;
915 912
 
916
-		foreach ( $update['depend'] as $depend ) {
913
+		foreach ($update['depend'] as $depend) {
917 914
 
918
-			if ( ! give_has_upgrade_completed( $depend ) ) {
915
+			if ( ! give_has_upgrade_completed($depend)) {
919 916
 				$is_dependency_completed = false;
920 917
 				break;
921 918
 			}
@@ -932,7 +929,7 @@  discard block
 block discarded – undo
932 929
 	 * @return bool
933 930
 	 */
934 931
 	public function is_doing_updates() {
935
-		return (bool) get_option( 'give_doing_upgrade' );
932
+		return (bool) get_option('give_doing_upgrade');
936 933
 	}
937 934
 
938 935
 
@@ -946,7 +943,7 @@  discard block
 block discarded – undo
946 943
 	 *
947 944
 	 * @return bool
948 945
 	 */
949
-	public function has_valid_dependency( $update ) {
946
+	public function has_valid_dependency($update) {
950 947
 		$is_valid_dependency = true;
951 948
 		// $update_ids          = wp_list_pluck( $this->get_updates( 'database', 'all' ), 'id' );
952 949
 		//
@@ -972,33 +969,33 @@  discard block
 block discarded – undo
972 969
 	 *
973 970
 	 * @return array
974 971
 	 */
975
-	public function get_updates( $update_type = '', $status = 'all' ) {
972
+	public function get_updates($update_type = '', $status = 'all') {
976 973
 		// return all updates.
977
-		if ( empty( $update_type ) ) {
974
+		if (empty($update_type)) {
978 975
 			return $this->updates;
979 976
 		}
980 977
 
981 978
 		// Get specific update.
982
-		$updates = ! empty( $this->updates[ $update_type ] ) ? $this->updates[ $update_type ] : array();
979
+		$updates = ! empty($this->updates[$update_type]) ? $this->updates[$update_type] : array();
983 980
 
984 981
 		// Bailout.
985
-		if ( empty( $updates ) ) {
982
+		if (empty($updates)) {
986 983
 			return $updates;
987 984
 		}
988 985
 
989
-		switch ( $status ) {
986
+		switch ($status) {
990 987
 			case 'new':
991 988
 				// Remove already completed updates.
992
-				wp_cache_delete( 'give_completed_upgrades', 'options' );
989
+				wp_cache_delete('give_completed_upgrades', 'options');
993 990
 				$completed_updates = give_get_completed_upgrades();
994 991
 
995
-				if ( ! empty( $completed_updates ) ) {
996
-					foreach ( $updates as $index => $update ) {
997
-						if ( in_array( $update['id'], $completed_updates ) ) {
998
-							unset( $updates[ $index ] );
992
+				if ( ! empty($completed_updates)) {
993
+					foreach ($updates as $index => $update) {
994
+						if (in_array($update['id'], $completed_updates)) {
995
+							unset($updates[$index]);
999 996
 						}
1000 997
 					}
1001
-					$updates = array_values( $updates );
998
+					$updates = array_values($updates);
1002 999
 				}
1003 1000
 
1004 1001
 				break;
@@ -1015,7 +1012,7 @@  discard block
 block discarded – undo
1015 1012
 	 * @return int
1016 1013
 	 */
1017 1014
 	public function get_total_plugin_update_count() {
1018
-		return count( $this->get_updates( 'plugin' ) );
1015
+		return count($this->get_updates('plugin'));
1019 1016
 	}
1020 1017
 
1021 1018
 	/**
@@ -1030,7 +1027,7 @@  discard block
 block discarded – undo
1030 1027
 		$db_update_count     = $this->get_pending_db_update_count();
1031 1028
 		$plugin_update_count = $this->get_total_plugin_update_count();
1032 1029
 
1033
-		return ( $db_update_count + $plugin_update_count );
1030
+		return ($db_update_count + $plugin_update_count);
1034 1031
 	}
1035 1032
 
1036 1033
 	/**
@@ -1042,7 +1039,7 @@  discard block
 block discarded – undo
1042 1039
 	 * @return int
1043 1040
 	 */
1044 1041
 	public function get_pending_db_update_count() {
1045
-		return count( $this->get_updates( 'database', 'new' ) );
1042
+		return count($this->get_updates('database', 'new'));
1046 1043
 	}
1047 1044
 
1048 1045
 	/**
@@ -1054,7 +1051,7 @@  discard block
 block discarded – undo
1054 1051
 	 * @return int
1055 1052
 	 */
1056 1053
 	public function get_total_db_update_count() {
1057
-		return count( $this->get_updates( 'database', 'all' ) );
1054
+		return count($this->get_updates('database', 'all'));
1058 1055
 	}
1059 1056
 
1060 1057
 	/**
@@ -1067,10 +1064,9 @@  discard block
 block discarded – undo
1067 1064
 	 *
1068 1065
 	 * @return int
1069 1066
 	 */
1070
-	public function get_total_new_db_update_count( $refresh = false ) {
1067
+	public function get_total_new_db_update_count($refresh = false) {
1071 1068
 		$update_count = $this->is_doing_updates() && ! $refresh ?
1072
-			get_option( 'give_db_update_count' ) :
1073
-			$this->get_pending_db_update_count();
1069
+			get_option('give_db_update_count') : $this->get_pending_db_update_count();
1074 1070
 
1075 1071
 		return $update_count;
1076 1072
 	}
@@ -1085,11 +1081,11 @@  discard block
 block discarded – undo
1085 1081
 	 *
1086 1082
 	 * @return int
1087 1083
 	 */
1088
-	public function get_running_db_update( $refresh = false ) {
1084
+	public function get_running_db_update($refresh = false) {
1089 1085
 		$current_update = 1;
1090 1086
 
1091
-		if ( $this->is_doing_updates() && ! $refresh ) {
1092
-			$current_update = get_option( 'give_doing_upgrade' );
1087
+		if ($this->is_doing_updates() && ! $refresh) {
1088
+			$current_update = get_option('give_doing_upgrade');
1093 1089
 			$current_update = $current_update['update'];
1094 1090
 		}
1095 1091
 
@@ -1106,25 +1102,23 @@  discard block
 block discarded – undo
1106 1102
 	 *
1107 1103
 	 * @return float|int
1108 1104
 	 */
1109
-	public function get_db_update_processing_percentage( $refresh = false ) {
1105
+	public function get_db_update_processing_percentage($refresh = false) {
1110 1106
 		// Bailout.
1111
-		if ( ! $this->get_total_new_db_update_count( $refresh ) ) {
1107
+		if ( ! $this->get_total_new_db_update_count($refresh)) {
1112 1108
 			return 0;
1113 1109
 		}
1114 1110
 
1115
-		$resume_update            = get_option( 'give_doing_upgrade' );
1116
-		$update_count_percentages = ( ( $this->get_running_db_update( $refresh ) - 1 ) / $this->get_total_new_db_update_count( $refresh ) ) * 100;
1117
-		$update_percentage_share  = ( 1 / $this->get_total_new_db_update_count() ) * 100;
1118
-		$upgrade_percentage       = ( ( $resume_update['percentage'] * $update_percentage_share ) / 100 );
1111
+		$resume_update            = get_option('give_doing_upgrade');
1112
+		$update_count_percentages = (($this->get_running_db_update($refresh) - 1) / $this->get_total_new_db_update_count($refresh)) * 100;
1113
+		$update_percentage_share  = (1 / $this->get_total_new_db_update_count()) * 100;
1114
+		$upgrade_percentage       = (($resume_update['percentage'] * $update_percentage_share) / 100);
1119 1115
 
1120 1116
 		$final_percentage = $update_count_percentages + $upgrade_percentage;
1121 1117
 
1122 1118
 		return $this->is_doing_updates() ?
1123
-			( absint( $final_percentage ) ?
1124
-				absint( $final_percentage ) :
1125
-				round( $final_percentage, 2 )
1126
-			) :
1127
-			0;
1119
+			(absint($final_percentage) ?
1120
+				absint($final_percentage) : round($final_percentage, 2)
1121
+			) : 0;
1128 1122
 	}
1129 1123
 
1130 1124
 
@@ -1136,8 +1130,8 @@  discard block
 block discarded – undo
1136 1130
 	 * @return array
1137 1131
 	 */
1138 1132
 	public function get_update_ids() {
1139
-		$all_updates    = $this->get_updates( 'database', 'all' );
1140
-		$all_update_ids = wp_list_pluck( $all_updates, 'id' );
1133
+		$all_updates    = $this->get_updates('database', 'all');
1134
+		$all_update_ids = wp_list_pluck($all_updates, 'id');
1141 1135
 
1142 1136
 		return $all_update_ids;
1143 1137
 	}
Please login to merge, or discard this patch.