Test Failed
Push — master ( 35678a...7fea6f )
by Devin
07:20
created
includes/class-give-db-payment-meta.php 1 patch
Spacing   +3 added lines, -3 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
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		/* @var WPDB $wpdb */
51 51
 		global $wpdb;
52 52
 
53
-		$wpdb->paymentmeta = $this->table_name = $wpdb->prefix . 'give_paymentmeta';
53
+		$wpdb->paymentmeta = $this->table_name = $wpdb->prefix.'give_paymentmeta';
54 54
 		$this->primary_key = 'meta_id';
55 55
 		$this->version     = '1.0';
56 56
 
@@ -84,6 +84,6 @@  discard block
 block discarded – undo
84 84
 	 * @return bool
85 85
 	 */
86 86
 	protected function is_custom_meta_table_active() {
87
-		return give_has_upgrade_completed( 'v20_move_metadata_into_new_table' );
87
+		return give_has_upgrade_completed('v20_move_metadata_into_new_table');
88 88
 	}
89 89
 }
Please login to merge, or discard this patch.
includes/class-give-db-logs-meta.php 1 patch
Spacing   +7 added lines, -7 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
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		/* @var WPDB $wpdb */
51 51
 		global $wpdb;
52 52
 
53
-		$wpdb->logmeta     = $this->table_name = $wpdb->prefix . 'give_logmeta';
53
+		$wpdb->logmeta     = $this->table_name = $wpdb->prefix.'give_logmeta';
54 54
 		$this->primary_key = 'meta_id';
55 55
 		$this->version     = '1.0';
56 56
 
@@ -86,18 +86,18 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @return bool
88 88
 	 */
89
-	public function delete_row( $log_id = 0 ) {
89
+	public function delete_row($log_id = 0) {
90 90
 		/* @var WPDB $wpdb */
91 91
 		global $wpdb;
92 92
 
93 93
 		// Row ID must be positive integer
94
-		$log_id = absint( $log_id );
94
+		$log_id = absint($log_id);
95 95
 
96
-		if ( empty( $log_id ) ) {
96
+		if (empty($log_id)) {
97 97
 			return false;
98 98
 		}
99 99
 
100
-		if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE log_id = %d", $log_id ) ) ) {
100
+		if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE log_id = %d", $log_id))) {
101 101
 			return false;
102 102
 		}
103 103
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 *
115 115
 	 * @return bool
116 116
 	 */
117
-	protected function is_valid_post_type( $ID ) {
117
+	protected function is_valid_post_type($ID) {
118 118
 		return $ID && true;
119 119
 	}
120 120
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-donor-stats.php 1 patch
Spacing   +37 added lines, -37 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
 
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
 	/**
49 49
 	 * Constructor.
50 50
 	 */
51
-	public function __construct( $_step = 1 ) {
52
-		parent::__construct( $_step );
51
+	public function __construct($_step = 1) {
52
+		parent::__construct($_step);
53 53
 
54 54
 		$this->is_writable = true;
55 55
 	}
@@ -66,32 +66,32 @@  discard block
 block discarded – undo
66 66
 
67 67
 		$args = array(
68 68
 			'number'  => $this->per_step,
69
-			'offset'  => $this->per_step * ( $this->step - 1 ),
69
+			'offset'  => $this->per_step * ($this->step - 1),
70 70
 			'orderby' => 'id',
71 71
 			'order'   => 'DESC',
72 72
 		);
73 73
 
74
-		$donors = Give()->donors->get_donors( $args );
74
+		$donors = Give()->donors->get_donors($args);
75 75
 
76
-		if ( $donors ) {
76
+		if ($donors) {
77 77
 
78
-			$allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() );
78
+			$allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys());
79 79
 
80
-			foreach ( $donors as $donor ) {
80
+			foreach ($donors as $donor) {
81 81
 
82
-				$attached_payment_ids = explode( ',', $donor->payment_ids );
82
+				$attached_payment_ids = explode(',', $donor->payment_ids);
83 83
 
84 84
 				$attached_args = array(
85 85
 					'post__in' => $attached_payment_ids,
86
-					'number'   => - 1,
86
+					'number'   => -1,
87 87
 					'status'   => $allowed_payment_status,
88 88
 				);
89 89
 
90
-				$attached_payments = (array) give_get_payments( $attached_args );
90
+				$attached_payments = (array) give_get_payments($attached_args);
91 91
 
92 92
 				$unattached_args = array(
93 93
 					'post__not_in' => $attached_payment_ids,
94
-					'number'       => - 1,
94
+					'number'       => -1,
95 95
 					'status'       => $allowed_payment_status,
96 96
 					'meta_query'   => array(
97 97
 						array(
@@ -102,29 +102,29 @@  discard block
 block discarded – undo
102 102
 					),
103 103
 				);
104 104
 
105
-				$unattached_payments = give_get_payments( $unattached_args );
105
+				$unattached_payments = give_get_payments($unattached_args);
106 106
 
107
-				$payments = array_merge( $attached_payments, $unattached_payments );
107
+				$payments = array_merge($attached_payments, $unattached_payments);
108 108
 
109 109
 				$purchase_value = 0.00;
110 110
 				$purchase_count = 0;
111 111
 				$payment_ids    = array();
112 112
 
113
-				if ( $payments ) {
113
+				if ($payments) {
114 114
 
115
-					foreach ( $payments as $payment ) {
115
+					foreach ($payments as $payment) {
116 116
 
117 117
 						$should_process_payment = 'publish' == $payment->post_status ? true : false;
118
-						$should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment );
118
+						$should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment);
119 119
 
120
-						if ( true === $should_process_payment ) {
120
+						if (true === $should_process_payment) {
121 121
 
122
-							if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) {
123
-								$purchase_value += (float) give_donation_amount( $payment->ID, array( 'type' => 'stats' ) );
122
+							if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) {
123
+								$purchase_value += (float) give_donation_amount($payment->ID, array('type' => 'stats'));
124 124
 							}
125 125
 
126
-							if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) {
127
-								$purchase_count ++;
126
+							if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) {
127
+								$purchase_count++;
128 128
 							}
129 129
 						}
130 130
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 					}
133 133
 				}
134 134
 
135
-				$payment_ids = implode( ',', $payment_ids );
135
+				$payment_ids = implode(',', $payment_ids);
136 136
 
137 137
 				$donor_update_data = array(
138 138
 					'purchase_count' => $purchase_count,
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 					'payment_ids'    => $payment_ids,
141 141
 				);
142 142
 
143
-				$donor_instance = new Give_Donor( $donor->id );
144
-				$donor_instance->update( $donor_update_data );
143
+				$donor_instance = new Give_Donor($donor->id);
144
+				$donor_instance->update($donor_update_data);
145 145
 
146 146
 			}// End foreach().
147 147
 
@@ -161,21 +161,21 @@  discard block
 block discarded – undo
161 161
 	public function get_percentage_complete() {
162 162
 
163 163
 		$args = array(
164
-			'number'  => - 1,
164
+			'number'  => -1,
165 165
 			'orderby' => 'id',
166 166
 			'order'   => 'DESC',
167 167
 		);
168 168
 
169
-		$donors = Give()->donors->get_donors( $args );
170
-		$total     = count( $donors );
169
+		$donors = Give()->donors->get_donors($args);
170
+		$total = count($donors);
171 171
 
172 172
 		$percentage = 100;
173 173
 
174
-		if ( $total > 0 ) {
175
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
174
+		if ($total > 0) {
175
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
176 176
 		}
177 177
 
178
-		if ( $percentage > 100 ) {
178
+		if ($percentage > 100) {
179 179
 			$percentage = 100;
180 180
 		}
181 181
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 *
190 190
 	 * @param array $request The Form Data passed into the batch processing
191 191
 	 */
192
-	public function set_properties( $request ) {
192
+	public function set_properties($request) {
193 193
 	}
194 194
 
195 195
 	/**
@@ -200,21 +200,21 @@  discard block
 block discarded – undo
200 200
 	 */
201 201
 	public function process_step() {
202 202
 
203
-		if ( ! $this->can_export() ) {
204
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array(
203
+		if ( ! $this->can_export()) {
204
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array(
205 205
 				'response' => 403,
206
-			) );
206
+			));
207 207
 		}
208 208
 
209 209
 		$had_data = $this->get_data();
210 210
 
211
-		if ( $had_data ) {
211
+		if ($had_data) {
212 212
 			$this->done = false;
213 213
 
214 214
 			return true;
215 215
 		} else {
216 216
 			$this->done    = true;
217
-			$this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' );
217
+			$this->message = esc_html__('Donor stats have been successfully recounted.', 'give');
218 218
 
219 219
 			return false;
220 220
 		}
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-single-donor-stats.php 1 patch
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 * Constructor.
48 48
 	 */
49
-	public function __construct( $_step = 1 ) {
50
-		parent::__construct( $_step );
49
+	public function __construct($_step = 1) {
50
+		parent::__construct($_step);
51 51
 
52 52
 		$this->is_writable = true;
53 53
 	}
@@ -62,40 +62,40 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	public function get_data() {
64 64
 
65
-		$donor    = new Give_Donor( $this->customer_id );
66
-		$payments = $this->get_stored_data( 'give_recount_donor_payments_' . $donor->id );
65
+		$donor    = new Give_Donor($this->customer_id);
66
+		$payments = $this->get_stored_data('give_recount_donor_payments_'.$donor->id);
67 67
 
68
-		$offset     = ( $this->step - 1 ) * $this->per_step;
69
-		$step_items = array_slice( $payments, $offset, $this->per_step );
68
+		$offset     = ($this->step - 1) * $this->per_step;
69
+		$step_items = array_slice($payments, $offset, $this->per_step);
70 70
 
71
-		if ( count( $step_items ) > 0 ) {
72
-			$pending_total = (float) $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id );
71
+		if (count($step_items) > 0) {
72
+			$pending_total = (float) $this->get_stored_data('give_stats_donor_pending_total'.$donor->id);
73 73
 			$step_total    = 0;
74 74
 
75
-			$found_payment_ids = $this->get_stored_data( 'give_stats_found_payments_' . $donor->id );
75
+			$found_payment_ids = $this->get_stored_data('give_stats_found_payments_'.$donor->id);
76 76
 
77
-			foreach ( $step_items as $payment ) {
78
-				$payment = get_post( $payment->ID );
77
+			foreach ($step_items as $payment) {
78
+				$payment = get_post($payment->ID);
79 79
 
80
-				if ( is_null( $payment ) || is_wp_error( $payment ) || 'give_payment' !== $payment->post_type ) {
80
+				if (is_null($payment) || is_wp_error($payment) || 'give_payment' !== $payment->post_type) {
81 81
 
82
-					$missing_payments   = $this->get_stored_data( 'give_stats_missing_payments' . $donor->id );
82
+					$missing_payments   = $this->get_stored_data('give_stats_missing_payments'.$donor->id);
83 83
 					$missing_payments[] = $payment->ID;
84
-					$this->store_data( 'give_stats_missing_payments' . $donor->id, $missing_payments );
84
+					$this->store_data('give_stats_missing_payments'.$donor->id, $missing_payments);
85 85
 
86 86
 					continue;
87 87
 				}
88 88
 
89 89
 				$should_process_payment = 'publish' == $payment->post_status ? true : false;
90
-				$should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment );
90
+				$should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment);
91 91
 
92
-				if ( true === $should_process_payment ) {
92
+				if (true === $should_process_payment) {
93 93
 
94 94
 					$found_payment_ids[] = $payment->ID;
95 95
 
96
-					if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) {
97
-						$payment_amount = (float) give_donation_amount( $payment->ID, array( 'type' => 'stats' ) );
98
-						$step_total     += $payment_amount;
96
+					if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) {
97
+						$payment_amount = (float) give_donation_amount($payment->ID, array('type' => 'stats'));
98
+						$step_total += $payment_amount;
99 99
 					}
100 100
 
101 101
 				}
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 			}
104 104
 
105 105
 			$updated_total = $pending_total + $step_total;
106
-			$this->store_data( 'give_stats_donor_pending_total' . $donor->id, $updated_total );
107
-			$this->store_data( 'give_stats_found_payments_' . $donor->id, $found_payment_ids );
106
+			$this->store_data('give_stats_donor_pending_total'.$donor->id, $updated_total);
107
+			$this->store_data('give_stats_found_payments_'.$donor->id, $found_payment_ids);
108 108
 
109 109
 			return true;
110 110
 		}
@@ -121,16 +121,16 @@  discard block
 block discarded – undo
121 121
 	 */
122 122
 	public function get_percentage_complete() {
123 123
 
124
-		$payments = $this->get_stored_data( 'give_recount_donor_payments_' . $this->customer_id );
125
-		$total    = count( $payments );
124
+		$payments = $this->get_stored_data('give_recount_donor_payments_'.$this->customer_id);
125
+		$total    = count($payments);
126 126
 
127 127
 		$percentage = 100;
128 128
 
129
-		if ( $total > 0 ) {
130
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
129
+		if ($total > 0) {
130
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
131 131
 		}
132 132
 
133
-		if ( $percentage > 100 ) {
133
+		if ($percentage > 100) {
134 134
 			$percentage = 100;
135 135
 		}
136 136
 
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 	 *
145 145
 	 * @param array $request The Form Data passed into the batch processing
146 146
 	 */
147
-	public function set_properties( $request ) {
148
-		$this->customer_id = isset( $request['customer_id'] ) ? sanitize_text_field( $request['customer_id'] ) : false;
147
+	public function set_properties($request) {
148
+		$this->customer_id = isset($request['customer_id']) ? sanitize_text_field($request['customer_id']) : false;
149 149
 	}
150 150
 
151 151
 	/**
@@ -156,53 +156,53 @@  discard block
 block discarded – undo
156 156
 	 */
157 157
 	public function process_step() {
158 158
 
159
-		if ( ! $this->can_export() ) {
160
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
159
+		if ( ! $this->can_export()) {
160
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
161 161
 		}
162 162
 
163 163
 		$had_data = $this->get_data();
164 164
 
165
-		if ( $had_data ) {
165
+		if ($had_data) {
166 166
 			$this->done = false;
167 167
 
168 168
 			return true;
169 169
 		} else {
170
-			$donor       = new Give_Donor( $this->customer_id );
171
-			$payment_ids = get_option( 'give_stats_found_payments_' . $donor->id, array() );
172
-			$this->delete_data( 'give_stats_found_payments_' . $donor->id );
170
+			$donor       = new Give_Donor($this->customer_id);
171
+			$payment_ids = get_option('give_stats_found_payments_'.$donor->id, array());
172
+			$this->delete_data('give_stats_found_payments_'.$donor->id);
173 173
 
174
-			$removed_payments = array_unique( get_option( 'give_stats_missing_payments' . $donor->id, array() ) );
174
+			$removed_payments = array_unique(get_option('give_stats_missing_payments'.$donor->id, array()));
175 175
 
176 176
 			// Find non-existing payments (deleted) and total up the donation count
177 177
 			$purchase_count = 0;
178
-			foreach ( $payment_ids as $key => $payment_id ) {
179
-				if ( in_array( $payment_id, $removed_payments ) ) {
180
-					unset( $payment_ids[ $key ] );
178
+			foreach ($payment_ids as $key => $payment_id) {
179
+				if (in_array($payment_id, $removed_payments)) {
180
+					unset($payment_ids[$key]);
181 181
 					continue;
182 182
 				}
183 183
 
184
-				$payment = get_post( $payment_id );
185
-				if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) {
186
-					$purchase_count ++;
184
+				$payment = get_post($payment_id);
185
+				if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) {
186
+					$purchase_count++;
187 187
 				}
188 188
 			}
189 189
 
190
-			$this->delete_data( 'give_stats_missing_payments' . $donor->id );
190
+			$this->delete_data('give_stats_missing_payments'.$donor->id);
191 191
 
192
-			$pending_total = $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id );
193
-			$this->delete_data( 'give_stats_donor_pending_total' . $donor->id );
194
-			$this->delete_data( 'give_recount_donor_stats_' . $donor->id );
195
-			$this->delete_data( 'give_recount_donor_payments_' . $this->customer_id );
192
+			$pending_total = $this->get_stored_data('give_stats_donor_pending_total'.$donor->id);
193
+			$this->delete_data('give_stats_donor_pending_total'.$donor->id);
194
+			$this->delete_data('give_recount_donor_stats_'.$donor->id);
195
+			$this->delete_data('give_recount_donor_payments_'.$this->customer_id);
196 196
 
197
-			$payment_ids = implode( ',', $payment_ids );
198
-			$donor->update( array(
197
+			$payment_ids = implode(',', $payment_ids);
198
+			$donor->update(array(
199 199
 				'payment_ids'    => $payment_ids,
200 200
 				'purchase_count' => $purchase_count,
201 201
 				'purchase_value' => $pending_total,
202
-			) );
202
+			));
203 203
 
204 204
 			$this->done    = true;
205
-			$this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' );
205
+			$this->message = esc_html__('Donor stats have been successfully recounted.', 'give');
206 206
 
207 207
 			return false;
208 208
 		}
@@ -235,26 +235,26 @@  discard block
 block discarded – undo
235 235
 	 * @return void
236 236
 	 */
237 237
 	public function pre_fetch() {
238
-		if ( $this->step === 1 ) {
239
-			$allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() );
238
+		if ($this->step === 1) {
239
+			$allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys());
240 240
 
241 241
 			// Before we start, let's zero out the customer's data
242
-			$donor = new Give_Donor( $this->customer_id );
243
-			$donor->update( array( 'purchase_value' => give_format_amount( 0, array( 'sanitize' => false ) ), 'purchase_count' => 0 ) );
242
+			$donor = new Give_Donor($this->customer_id);
243
+			$donor->update(array('purchase_value' => give_format_amount(0, array('sanitize' => false)), 'purchase_count' => 0));
244 244
 
245
-			$attached_payment_ids = explode( ',', $donor->payment_ids );
245
+			$attached_payment_ids = explode(',', $donor->payment_ids);
246 246
 
247 247
 			$attached_args = array(
248 248
 				'post__in' => $attached_payment_ids,
249
-				'number'   => - 1,
249
+				'number'   => -1,
250 250
 				'status'   => $allowed_payment_status,
251 251
 			);
252 252
 
253
-			$attached_payments = give_get_payments( $attached_args );
253
+			$attached_payments = give_get_payments($attached_args);
254 254
 
255 255
 			$unattached_args = array(
256 256
 				'post__not_in' => $attached_payment_ids,
257
-				'number'       => - 1,
257
+				'number'       => -1,
258 258
 				'status'       => $allowed_payment_status,
259 259
 				'meta_query'   => array(
260 260
 					array(
@@ -264,11 +264,11 @@  discard block
 block discarded – undo
264 264
 				),
265 265
 			);
266 266
 
267
-			$unattached_payments = give_get_payments( $unattached_args );
267
+			$unattached_payments = give_get_payments($unattached_args);
268 268
 
269
-			$payments = array_merge( $attached_payments, $unattached_payments );
269
+			$payments = array_merge($attached_payments, $unattached_payments);
270 270
 
271
-			$this->store_data( 'give_recount_donor_payments_' . $donor->id, $payments );
271
+			$this->store_data('give_recount_donor_payments_'.$donor->id, $payments);
272 272
 		}
273 273
 	}
274 274
 
@@ -281,17 +281,17 @@  discard block
 block discarded – undo
281 281
 	 *
282 282
 	 * @return mixed       Returns the data from the database
283 283
 	 */
284
-	private function get_stored_data( $key ) {
284
+	private function get_stored_data($key) {
285 285
 		global $wpdb;
286
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
286
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
287 287
 
288
-		if ( empty( $value ) ) {
288
+		if (empty($value)) {
289 289
 			return false;
290 290
 		}
291 291
 
292
-		$maybe_json = json_decode( $value );
293
-		if ( ! is_null( $maybe_json ) ) {
294
-			$value = json_decode( $value, true );
292
+		$maybe_json = json_decode($value);
293
+		if ( ! is_null($maybe_json)) {
294
+			$value = json_decode($value, true);
295 295
 		}
296 296
 
297 297
 		return $value;
@@ -307,10 +307,10 @@  discard block
 block discarded – undo
307 307
 	 *
308 308
 	 * @return void
309 309
 	 */
310
-	private function store_data( $key, $value ) {
310
+	private function store_data($key, $value) {
311 311
 		global $wpdb;
312 312
 
313
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
313
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
314 314
 
315 315
 		$data = array(
316 316
 			'option_name'  => $key,
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 			'%s',
325 325
 		);
326 326
 
327
-		$wpdb->replace( $wpdb->options, $data, $formats );
327
+		$wpdb->replace($wpdb->options, $data, $formats);
328 328
 	}
329 329
 
330 330
 	/**
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
 	 *
337 337
 	 * @return void
338 338
 	 */
339
-	private function delete_data( $key ) {
339
+	private function delete_data($key) {
340 340
 		global $wpdb;
341
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
341
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
342 342
 	}
343 343
 
344 344
 }
Please login to merge, or discard this patch.
includes/template-functions.php 1 patch
Spacing   +89 added lines, -89 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
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  * @return string
22 22
  */
23 23
 function give_get_templates_dir() {
24
-	return GIVE_PLUGIN_DIR . 'templates';
24
+	return GIVE_PLUGIN_DIR.'templates';
25 25
 }
26 26
 
27 27
 /**
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
  * @return string
32 32
  */
33 33
 function give_get_templates_url() {
34
-	return GIVE_PLUGIN_URL . 'templates';
34
+	return GIVE_PLUGIN_URL.'templates';
35 35
 }
36 36
 
37 37
 /**
@@ -44,24 +44,24 @@  discard block
 block discarded – undo
44 44
  * @param string $template_path Template file path. Default is empty.
45 45
  * @param string $default_path  Default path. Default is empty.
46 46
  */
47
-function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
48
-	if ( ! empty( $args ) && is_array( $args ) ) {
49
-		extract( $args );
47
+function give_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
48
+	if ( ! empty($args) && is_array($args)) {
49
+		extract($args);
50 50
 	}
51 51
 
52 52
 	$template_names = "{$template_name}.php";
53 53
 
54
-	$located = give_get_locate_template( $template_names, $template_path, $default_path );
54
+	$located = give_get_locate_template($template_names, $template_path, $default_path);
55 55
 
56
-	if ( ! file_exists( $located ) ) {
56
+	if ( ! file_exists($located)) {
57 57
 		/* translators: %s: the template */
58
-		Give()->notices->print_frontend_notice( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true );
58
+		Give()->notices->print_frontend_notice(sprintf(__('The %s template was not found.', 'give'), $located), true);
59 59
 
60 60
 		return;
61 61
 	}
62 62
 
63 63
 	// Allow 3rd party plugin filter template file from their plugin.
64
-	$located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path );
64
+	$located = apply_filters('give_get_template', $located, $template_name, $args, $template_path, $default_path);
65 65
 
66 66
 	/**
67 67
 	 * Fires in give template, before the file is included.
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 	 * @param string $located       Template file filter by 3rd party plugin.
76 76
 	 * @param array  $args          Passed arguments.
77 77
 	 */
78
-	do_action( 'give_before_template_part', $template_name, $template_path, $located, $args );
78
+	do_action('give_before_template_part', $template_name, $template_path, $located, $args);
79 79
 
80
-	include( $located );
80
+	include($located);
81 81
 
82 82
 	/**
83 83
 	 * Fires in give template, after the file is included.
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * @param string $located       Template file filter by 3rd party plugin.
92 92
 	 * @param array  $args          Passed arguments.
93 93
 	 */
94
-	do_action( 'give_after_template_part', $template_name, $template_path, $located, $args );
94
+	do_action('give_after_template_part', $template_name, $template_path, $located, $args);
95 95
 }
96 96
 
97 97
 /**
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
  *
108 108
  * @return string
109 109
  */
110
-function give_get_template_part( $slug, $name = null, $load = true ) {
110
+function give_get_template_part($slug, $name = null, $load = true) {
111 111
 
112 112
 	/**
113 113
 	 * Fires in give template part, before the template part is retrieved.
@@ -119,20 +119,20 @@  discard block
 block discarded – undo
119 119
 	 * @param string $slug Template part file slug {slug}.php.
120 120
 	 * @param string $name Template part file name {slug}-{name}.php.
121 121
 	 */
122
-	do_action( "get_template_part_{$slug}", $slug, $name );
122
+	do_action("get_template_part_{$slug}", $slug, $name);
123 123
 
124 124
 	// Setup possible parts
125 125
 	$templates = array();
126
-	if ( isset( $name ) ) {
127
-		$templates[] = $slug . '-' . $name . '.php';
126
+	if (isset($name)) {
127
+		$templates[] = $slug.'-'.$name.'.php';
128 128
 	}
129
-	$templates[] = $slug . '.php';
129
+	$templates[] = $slug.'.php';
130 130
 
131 131
 	// Allow template parts to be filtered
132
-	$templates = apply_filters( 'give_get_template_part', $templates, $slug, $name );
132
+	$templates = apply_filters('give_get_template_part', $templates, $slug, $name);
133 133
 
134 134
 	// Return the part that is found
135
-	return give_locate_template( $templates, $load, false );
135
+	return give_locate_template($templates, $load, false);
136 136
 }
137 137
 
138 138
 /**
@@ -153,37 +153,37 @@  discard block
 block discarded – undo
153 153
  *
154 154
  * @return string The template filename if one is located.
155 155
  */
156
-function give_locate_template( $template_names, $load = false, $require_once = true ) {
156
+function give_locate_template($template_names, $load = false, $require_once = true) {
157 157
 	// No file found yet
158 158
 	$located = false;
159 159
 
160 160
 	// Try to find a template file
161
-	foreach ( (array) $template_names as $template_name ) {
161
+	foreach ((array) $template_names as $template_name) {
162 162
 
163 163
 		// Continue if template is empty
164
-		if ( empty( $template_name ) ) {
164
+		if (empty($template_name)) {
165 165
 			continue;
166 166
 		}
167 167
 
168 168
 		// Trim off any slashes from the template name
169
-		$template_name = ltrim( $template_name, '/' );
169
+		$template_name = ltrim($template_name, '/');
170 170
 
171 171
 		// try locating this template file by looping through the template paths
172
-		foreach ( give_get_theme_template_paths() as $template_path ) {
172
+		foreach (give_get_theme_template_paths() as $template_path) {
173 173
 
174
-			if ( file_exists( $template_path . $template_name ) ) {
175
-				$located = $template_path . $template_name;
174
+			if (file_exists($template_path.$template_name)) {
175
+				$located = $template_path.$template_name;
176 176
 				break;
177 177
 			}
178 178
 		}
179 179
 
180
-		if ( $located ) {
180
+		if ($located) {
181 181
 			break;
182 182
 		}
183 183
 	}
184 184
 
185
-	if ( ( true == $load ) && ! empty( $located ) ) {
186
-		load_template( $located, $require_once );
185
+	if ((true == $load) && ! empty($located)) {
186
+		load_template($located, $require_once);
187 187
 	}
188 188
 
189 189
 	return $located;
@@ -207,26 +207,26 @@  discard block
 block discarded – undo
207 207
  *
208 208
  * @return string
209 209
  */
210
-function give_get_locate_template( $template_name, $template_path = '', $default_path = '' ) {
211
-	if ( ! $template_path ) {
212
-		$template_path = give_get_theme_template_dir_name() . '/';
210
+function give_get_locate_template($template_name, $template_path = '', $default_path = '') {
211
+	if ( ! $template_path) {
212
+		$template_path = give_get_theme_template_dir_name().'/';
213 213
 	}
214 214
 
215
-	if ( ! $default_path ) {
216
-		$default_path = GIVE_PLUGIN_DIR . 'templates/';
215
+	if ( ! $default_path) {
216
+		$default_path = GIVE_PLUGIN_DIR.'templates/';
217 217
 	}
218 218
 
219 219
 	// Look within passed path within the theme - this is priority.
220 220
 	$template = locate_template(
221 221
 		array(
222
-			trailingslashit( $template_path ) . $template_name,
222
+			trailingslashit($template_path).$template_name,
223 223
 			$template_name,
224 224
 		)
225 225
 	);
226 226
 
227 227
 	// Get default template/
228
-	if ( ! $template ) {
229
-		$template = $default_path . $template_name;
228
+	if ( ! $template) {
229
+		$template = $default_path.$template_name;
230 230
 	}
231 231
 
232 232
 	/**
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	 *
235 235
 	 * @since 2.0.3
236 236
 	 */
237
-	return apply_filters( 'give_get_locate_template', $template, $template_name, $template_path );
237
+	return apply_filters('give_get_locate_template', $template, $template_name, $template_path);
238 238
 }
239 239
 
240 240
 /**
@@ -248,17 +248,17 @@  discard block
 block discarded – undo
248 248
 	$template_dir = give_get_theme_template_dir_name();
249 249
 
250 250
 	$file_paths = array(
251
-		1   => trailingslashit( get_stylesheet_directory() ) . $template_dir,
252
-		10  => trailingslashit( get_template_directory() ) . $template_dir,
251
+		1   => trailingslashit(get_stylesheet_directory()).$template_dir,
252
+		10  => trailingslashit(get_template_directory()).$template_dir,
253 253
 		100 => give_get_templates_dir(),
254 254
 	);
255 255
 
256
-	$file_paths = apply_filters( 'give_template_paths', $file_paths );
256
+	$file_paths = apply_filters('give_template_paths', $file_paths);
257 257
 
258 258
 	// sort the file paths based on priority
259
-	ksort( $file_paths, SORT_NUMERIC );
259
+	ksort($file_paths, SORT_NUMERIC);
260 260
 
261
-	return array_map( 'trailingslashit', $file_paths );
261
+	return array_map('trailingslashit', $file_paths);
262 262
 }
263 263
 
264 264
 /**
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
  * @return string
271 271
  */
272 272
 function give_get_theme_template_dir_name() {
273
-	return trailingslashit( apply_filters( 'give_templates_dir', 'give' ) );
273
+	return trailingslashit(apply_filters('give_templates_dir', 'give'));
274 274
 }
275 275
 
276 276
 /**
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
  * @return void
281 281
  */
282 282
 function give_version_in_header() {
283
-	echo '<meta name="generator" content="Give v' . GIVE_VERSION . '" />' . "\n";
283
+	echo '<meta name="generator" content="Give v'.GIVE_VERSION.'" />'."\n";
284 284
 }
285 285
 
286
-add_action( 'wp_head', 'give_version_in_header' );
286
+add_action('wp_head', 'give_version_in_header');
287 287
 
288 288
 /**
289 289
  * Determines if we're currently on the Donations History page.
@@ -293,9 +293,9 @@  discard block
 block discarded – undo
293 293
  */
294 294
 function give_is_donation_history_page() {
295 295
 
296
-	$ret = is_page( give_get_option( 'history_page' ) );
296
+	$ret = is_page(give_get_option('history_page'));
297 297
 
298
-	return apply_filters( 'give_is_donation_history_page', $ret );
298
+	return apply_filters('give_is_donation_history_page', $ret);
299 299
 }
300 300
 
301 301
 /**
@@ -307,25 +307,25 @@  discard block
 block discarded – undo
307 307
  *
308 308
  * @return array Modified array of classes
309 309
  */
310
-function give_add_body_classes( $class ) {
310
+function give_add_body_classes($class) {
311 311
 	$classes = (array) $class;
312 312
 
313
-	if ( give_is_success_page() ) {
313
+	if (give_is_success_page()) {
314 314
 		$classes[] = 'give-success';
315 315
 		$classes[] = 'give-page';
316 316
 	}
317 317
 
318
-	if ( give_is_failed_transaction_page() ) {
318
+	if (give_is_failed_transaction_page()) {
319 319
 		$classes[] = 'give-failed-transaction';
320 320
 		$classes[] = 'give-page';
321 321
 	}
322 322
 
323
-	if ( give_is_donation_history_page() ) {
323
+	if (give_is_donation_history_page()) {
324 324
 		$classes[] = 'give-donation-history';
325 325
 		$classes[] = 'give-page';
326 326
 	}
327 327
 
328
-	if ( give_is_test_mode() ) {
328
+	if (give_is_test_mode()) {
329 329
 		$classes[] = 'give-test-mode';
330 330
 		$classes[] = 'give-page';
331 331
 	}
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 	/* @var WP_Theme $current_theme */
335 335
 	$current_theme = wp_get_theme();
336 336
 
337
-	switch ( $current_theme->get_template() ) {
337
+	switch ($current_theme->get_template()) {
338 338
 
339 339
 		case 'Divi':
340 340
 			$classes[] = 'give-divi';
@@ -351,10 +351,10 @@  discard block
 block discarded – undo
351 351
 
352 352
 	}
353 353
 
354
-	return array_unique( $classes );
354
+	return array_unique($classes);
355 355
 }
356 356
 
357
-add_filter( 'body_class', 'give_add_body_classes' );
357
+add_filter('body_class', 'give_add_body_classes');
358 358
 
359 359
 
360 360
 /**
@@ -370,22 +370,22 @@  discard block
 block discarded – undo
370 370
  *
371 371
  * @return array
372 372
  */
373
-function give_add_post_class( $classes, $class = '', $post_id = '' ) {
374
-	if ( ! $post_id || 'give_forms' !== get_post_type( $post_id ) ) {
373
+function give_add_post_class($classes, $class = '', $post_id = '') {
374
+	if ( ! $post_id || 'give_forms' !== get_post_type($post_id)) {
375 375
 		return $classes;
376 376
 	}
377 377
 
378 378
 	//@TODO: Add classes for custom taxonomy and form configurations (multi vs single donations, etc).
379 379
 
380
-	if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) {
381
-		unset( $classes[ $key ] );
380
+	if (false !== ($key = array_search('hentry', $classes))) {
381
+		unset($classes[$key]);
382 382
 	}
383 383
 
384 384
 	return $classes;
385 385
 }
386 386
 
387 387
 
388
-add_filter( 'post_class', 'give_add_post_class', 20, 3 );
388
+add_filter('post_class', 'give_add_post_class', 20, 3);
389 389
 
390 390
 /**
391 391
  * Get the placeholder image URL for forms etc
@@ -395,74 +395,74 @@  discard block
 block discarded – undo
395 395
  */
396 396
 function give_get_placeholder_img_src() {
397 397
 
398
-	$placeholder_url = '//placehold.it/600x600&text=' . urlencode( esc_attr__( 'Give Placeholder Image', 'give' ) );
398
+	$placeholder_url = '//placehold.it/600x600&text='.urlencode(esc_attr__('Give Placeholder Image', 'give'));
399 399
 
400
-	return apply_filters( 'give_placeholder_img_src', $placeholder_url );
400
+	return apply_filters('give_placeholder_img_src', $placeholder_url);
401 401
 }
402 402
 
403 403
 
404 404
 /**
405 405
  * Global
406 406
  */
407
-if ( ! function_exists( 'give_output_content_wrapper' ) ) {
407
+if ( ! function_exists('give_output_content_wrapper')) {
408 408
 
409 409
 	/**
410 410
 	 * Output the start of the page wrapper.
411 411
 	 */
412 412
 	function give_output_content_wrapper() {
413
-		give_get_template_part( 'global/wrapper-start' );
413
+		give_get_template_part('global/wrapper-start');
414 414
 	}
415 415
 }
416
-if ( ! function_exists( 'give_output_content_wrapper_end' ) ) {
416
+if ( ! function_exists('give_output_content_wrapper_end')) {
417 417
 
418 418
 	/**
419 419
 	 * Output the end of the page wrapper.
420 420
 	 */
421 421
 	function give_output_content_wrapper_end() {
422
-		give_get_template_part( 'global/wrapper-end' );
422
+		give_get_template_part('global/wrapper-end');
423 423
 	}
424 424
 }
425 425
 
426 426
 /**
427 427
  * Single Give Form
428 428
  */
429
-if ( ! function_exists( 'give_left_sidebar_pre_wrap' ) ) {
429
+if ( ! function_exists('give_left_sidebar_pre_wrap')) {
430 430
 	function give_left_sidebar_pre_wrap() {
431
-		echo apply_filters( 'give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">' );
431
+		echo apply_filters('give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">');
432 432
 	}
433 433
 }
434 434
 
435
-if ( ! function_exists( 'give_left_sidebar_post_wrap' ) ) {
435
+if ( ! function_exists('give_left_sidebar_post_wrap')) {
436 436
 	function give_left_sidebar_post_wrap() {
437
-		echo apply_filters( 'give_left_sidebar_post_wrap', '</div>' );
437
+		echo apply_filters('give_left_sidebar_post_wrap', '</div>');
438 438
 	}
439 439
 }
440 440
 
441
-if ( ! function_exists( 'give_get_forms_sidebar' ) ) {
441
+if ( ! function_exists('give_get_forms_sidebar')) {
442 442
 	function give_get_forms_sidebar() {
443
-		give_get_template_part( 'single-give-form/sidebar' );
443
+		give_get_template_part('single-give-form/sidebar');
444 444
 	}
445 445
 }
446 446
 
447
-if ( ! function_exists( 'give_show_form_images' ) ) {
447
+if ( ! function_exists('give_show_form_images')) {
448 448
 
449 449
 	/**
450 450
 	 * Output the donation form featured image.
451 451
 	 */
452 452
 	function give_show_form_images() {
453
-		if ( give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) {
454
-			give_get_template_part( 'single-give-form/featured-image' );
453
+		if (give_is_setting_enabled(give_get_option('form_featured_img'))) {
454
+			give_get_template_part('single-give-form/featured-image');
455 455
 		}
456 456
 	}
457 457
 }
458 458
 
459
-if ( ! function_exists( 'give_template_single_title' ) ) {
459
+if ( ! function_exists('give_template_single_title')) {
460 460
 
461 461
 	/**
462 462
 	 * Output the form title.
463 463
 	 */
464 464
 	function give_template_single_title() {
465
-		give_get_template_part( 'single-give-form/title' );
465
+		give_get_template_part('single-give-form/title');
466 466
 	}
467 467
 }
468 468
 
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
  * Conditional Functions
471 471
  */
472 472
 
473
-if ( ! function_exists( 'is_give_form' ) ) {
473
+if ( ! function_exists('is_give_form')) {
474 474
 
475 475
 	/**
476 476
 	 * is_give_form
@@ -482,11 +482,11 @@  discard block
 block discarded – undo
482 482
 	 * @return bool
483 483
 	 */
484 484
 	function is_give_form() {
485
-		return is_singular( array( 'give_form' ) );
485
+		return is_singular(array('give_form'));
486 486
 	}
487 487
 }
488 488
 
489
-if ( ! function_exists( 'is_give_category' ) ) {
489
+if ( ! function_exists('is_give_category')) {
490 490
 
491 491
 	/**
492 492
 	 * is_give_category
@@ -501,12 +501,12 @@  discard block
 block discarded – undo
501 501
 	 *
502 502
 	 * @return bool
503 503
 	 */
504
-	function is_give_category( $term = '' ) {
505
-		return is_tax( 'give_forms_category', $term );
504
+	function is_give_category($term = '') {
505
+		return is_tax('give_forms_category', $term);
506 506
 	}
507 507
 }
508 508
 
509
-if ( ! function_exists( 'is_give_tag' ) ) {
509
+if ( ! function_exists('is_give_tag')) {
510 510
 
511 511
 	/**
512 512
 	 * is_give_tag
@@ -521,12 +521,12 @@  discard block
 block discarded – undo
521 521
 	 *
522 522
 	 * @return bool
523 523
 	 */
524
-	function is_give_tag( $term = '' ) {
525
-		return is_tax( 'give_forms_tag', $term );
524
+	function is_give_tag($term = '') {
525
+		return is_tax('give_forms_tag', $term);
526 526
 	}
527 527
 }
528 528
 
529
-if ( ! function_exists( 'is_give_taxonomy' ) ) {
529
+if ( ! function_exists('is_give_taxonomy')) {
530 530
 
531 531
 	/**
532 532
 	 * is_give_taxonomy
@@ -538,6 +538,6 @@  discard block
 block discarded – undo
538 538
 	 * @return bool
539 539
 	 */
540 540
 	function is_give_taxonomy() {
541
-		return is_tax( get_object_taxonomies( 'give_form' ) );
541
+		return is_tax(get_object_taxonomies('give_form'));
542 542
 	}
543 543
 }
Please login to merge, or discard this patch.
includes/class-give-background-updater.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -202,8 +202,8 @@
 block discarded – undo
202 202
 		// 2. Processing percentage greater then 100%
203 203
 		if( (
204 204
 			101 < $resume_update['total_percentage'] ) ||
205
-		    ( $give_updates->get_total_db_update_count() < $resume_update['update'] ) ||
206
-		    ! in_array( $resume_update['update_info']['id'], $give_updates->get_update_ids() )
205
+			( $give_updates->get_total_db_update_count() < $resume_update['update'] ) ||
206
+			! in_array( $resume_update['update_info']['id'], $give_updates->get_update_ids() )
207 207
 		) {
208 208
 			if( ! $this->is_paused_process() ){
209 209
 				$give_updates->__pause_db_update(true);
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @category Class
12 12
  * @author   WordImpress
13 13
  */
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 * @return bool
56 56
 	 */
57 57
 	public function has_queue() {
58
-		return ( ! parent::is_queue_empty() );
58
+		return ( ! parent::is_queue_empty());
59 59
 	}
60 60
 
61 61
 
@@ -71,12 +71,12 @@  discard block
 block discarded – undo
71 71
 	 */
72 72
 	protected function lock_process() {
73 73
 		// Check if admin want to pause upgrade.
74
-		if( get_option('give_pause_upgrade') ) {
74
+		if (get_option('give_pause_upgrade')) {
75 75
 			self::flush_cache();
76 76
 
77
-			delete_option( 'give_paused_batches' );
77
+			delete_option('give_paused_batches');
78 78
 
79
-			Give_Updates::get_instance()->__pause_db_update( true );
79
+			Give_Updates::get_instance()->__pause_db_update(true);
80 80
 
81 81
 			delete_option('give_pause_upgrade');
82 82
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 			 *
86 86
 			 * @since 2.0.1
87 87
 			 */
88
-			do_action( 'give_pause_db_upgrade', Give_Updates::get_instance() );
88
+			do_action('give_pause_db_upgrade', Give_Updates::get_instance());
89 89
 
90 90
 			wp_die();
91 91
 		}
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
 
94 94
 		$this->start_time = time(); // Set start time of current process.
95 95
 
96
-		$lock_duration = ( property_exists( $this, 'queue_lock_time' ) ) ? $this->queue_lock_time : 60; // 1 minute
97
-		$lock_duration = apply_filters( $this->identifier . '_queue_lock_time', $lock_duration );
96
+		$lock_duration = (property_exists($this, 'queue_lock_time')) ? $this->queue_lock_time : 60; // 1 minute
97
+		$lock_duration = apply_filters($this->identifier.'_queue_lock_time', $lock_duration);
98 98
 
99
-		set_site_transient( $this->identifier . '_process_lock', microtime(), $lock_duration );
99
+		set_site_transient($this->identifier.'_process_lock', microtime(), $lock_duration);
100 100
 	}
101 101
 
102 102
 	/**
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
 	 * and data exists in the queue.
107 107
 	 */
108 108
 	public function handle_cron_healthcheck() {
109
-		if ( $this->is_process_running() || $this->is_paused_process()  ) {
109
+		if ($this->is_process_running() || $this->is_paused_process()) {
110 110
 			// Background process already running.
111 111
 			return;
112 112
 		}
113 113
 
114
-		if ( $this->is_queue_empty() ) {
114
+		if ($this->is_queue_empty()) {
115 115
 			// No data to process.
116 116
 			$this->clear_scheduled_event();
117 117
 
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
 	 * Schedule fallback event.
126 126
 	 */
127 127
 	protected function schedule_event() {
128
-		if ( ! wp_next_scheduled( $this->cron_hook_identifier ) && ! $this->is_paused_process() ) {
129
-			wp_schedule_event( time() + 10, $this->cron_interval_identifier, $this->cron_hook_identifier );
128
+		if ( ! wp_next_scheduled($this->cron_hook_identifier) && ! $this->is_paused_process()) {
129
+			wp_schedule_event(time() + 10, $this->cron_interval_identifier, $this->cron_hook_identifier);
130 130
 		}
131 131
 	}
132 132
 
@@ -142,13 +142,13 @@  discard block
 block discarded – undo
142 142
 	 *
143 143
 	 * @return mixed
144 144
 	 */
145
-	protected function task( $update ) {
145
+	protected function task($update) {
146 146
 		// Pause upgrade immediately if admin pausing upgrades.
147
-		if( $this->is_paused_process() ) {
147
+		if ($this->is_paused_process()) {
148 148
 			wp_die();
149 149
 		}
150 150
 
151
-		if ( empty( $update ) ) {
151
+		if (empty($update)) {
152 152
 			return false;
153 153
 		}
154 154
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 				'update_info'      => $update,
166 166
 				'step'             => 1,
167 167
 				'update'           => 1,
168
-				'heading'          => sprintf( 'Update %s of {update_count}', 1 ),
168
+				'heading'          => sprintf('Update %s of {update_count}', 1),
169 169
 				'percentage'       => $give_updates->percentage,
170 170
 				'total_percentage' => 0,
171 171
 			)
@@ -174,22 +174,22 @@  discard block
 block discarded – undo
174 174
 		// Continuously skip update if previous update does not complete yet.
175 175
 		if (
176 176
 			$resume_update['update_info']['id'] !== $update['id'] &&
177
-			! give_has_upgrade_completed( $resume_update['update_info']['id'] )
177
+			! give_has_upgrade_completed($resume_update['update_info']['id'])
178 178
 		) {
179 179
 			return $update;
180 180
 		}
181 181
 
182 182
 		// Set params.
183 183
 		$resume_update['update_info'] = $update;
184
-		$give_updates->step           = absint( $resume_update['step'] );
185
-		$give_updates->update         = absint( $resume_update['update'] );
186
-		$is_parent_update_completed   = $give_updates->is_parent_updates_completed( $update );
184
+		$give_updates->step           = absint($resume_update['step']);
185
+		$give_updates->update         = absint($resume_update['update']);
186
+		$is_parent_update_completed   = $give_updates->is_parent_updates_completed($update);
187 187
 
188 188
 
189 189
 		// Skip update if dependency update does not complete yet.
190
-		if ( empty( $is_parent_update_completed ) ) {
190
+		if (empty($is_parent_update_completed)) {
191 191
 			// @todo: set error when you have only one update with invalid dependency
192
-			if ( ! is_null( $is_parent_update_completed ) ) {
192
+			if ( ! is_null($is_parent_update_completed)) {
193 193
 				return $update;
194 194
 			}
195 195
 
@@ -200,23 +200,23 @@  discard block
 block discarded – undo
200 200
 		// Pause upgrade immediately if found following:
201 201
 		// 1. Running update number greater then total update count
202 202
 		// 2. Processing percentage greater then 100%
203
-		if( (
203
+		if ((
204 204
 			101 < $resume_update['total_percentage'] ) ||
205
-		    ( $give_updates->get_total_db_update_count() < $resume_update['update'] ) ||
206
-		    ! in_array( $resume_update['update_info']['id'], $give_updates->get_update_ids() )
205
+		    ($give_updates->get_total_db_update_count() < $resume_update['update']) ||
206
+		    ! in_array($resume_update['update_info']['id'], $give_updates->get_update_ids())
207 207
 		) {
208
-			if( ! $this->is_paused_process() ){
208
+			if ( ! $this->is_paused_process()) {
209 209
 				$give_updates->__pause_db_update(true);
210 210
 			}
211 211
 
212
-			update_option( 'give_upgrade_error', 1 );
212
+			update_option('give_upgrade_error', 1);
213 213
 
214
-			$log_data = 'Update Task' . "\n";
214
+			$log_data = 'Update Task'."\n";
215 215
 			$log_data .= "Total update count: {$give_updates->get_total_db_update_count()}\n";
216
-			$log_data .= 'Update IDs: ' . print_r( $give_updates->get_update_ids() , true );
217
-			$log_data .= 'Update: ' . print_r( $resume_update , true );
216
+			$log_data .= 'Update IDs: '.print_r($give_updates->get_update_ids(), true);
217
+			$log_data .= 'Update: '.print_r($resume_update, true);
218 218
 
219
-			Give()->logs->add( 'Update Error', $log_data, 0, 'update' );
219
+			Give()->logs->add('Update Error', $log_data, 0, 'update');
220 220
 
221 221
 			wp_die();
222 222
 		}
@@ -224,25 +224,25 @@  discard block
 block discarded – undo
224 224
 		// Disable cache.
225 225
 		Give_Cache::disable();
226 226
 
227
-		try{
227
+		try {
228 228
 			// Run update.
229
-			if ( is_array( $update['callback'] ) ) {
229
+			if (is_array($update['callback'])) {
230 230
 				$update['callback'][0]->$update['callback'][1]();
231 231
 			} else {
232 232
 				$update['callback']();
233 233
 			}
234
-		} catch ( Exception $e ){
234
+		} catch (Exception $e) {
235 235
 
236
-			if( ! $this->is_paused_process() ){
236
+			if ( ! $this->is_paused_process()) {
237 237
 				$give_updates->__pause_db_update(true);
238 238
 			}
239 239
 
240
-			$log_data = 'Update Task' . "\n";
241
-			$log_data .= print_r( $resume_update, true ) . "\n\n";
240
+			$log_data = 'Update Task'."\n";
241
+			$log_data .= print_r($resume_update, true)."\n\n";
242 242
 			$log_data .= "Error\n {$e->getMessage()}";
243 243
 
244
-			Give()->logs->add( 'Update Error', $log_data, 0, 'update' );
245
-			update_option( 'give_upgrade_error', 1 );
244
+			Give()->logs->add('Update Error', $log_data, 0, 'update');
245
+			update_option('give_upgrade_error', 1);
246 246
 
247 247
 			wp_die();
248 248
 		}
@@ -250,21 +250,21 @@  discard block
 block discarded – undo
250 250
 		// Set update info.
251 251
 		$doing_upgrade_args = array(
252 252
 			'update_info'      => $update,
253
-			'step'             => ++ $give_updates->step,
253
+			'step'             => ++$give_updates->step,
254 254
 			'update'           => $give_updates->update,
255
-			'heading'          => sprintf( 'Update %s of %s', $give_updates->update, get_option( 'give_db_update_count' ) ),
255
+			'heading'          => sprintf('Update %s of %s', $give_updates->update, get_option('give_db_update_count')),
256 256
 			'percentage'       => $give_updates->percentage,
257 257
 			'total_percentage' => $give_updates->get_db_update_processing_percentage(),
258 258
 		);
259 259
 
260 260
 		// Cache upgrade.
261
-		update_option( 'give_doing_upgrade', $doing_upgrade_args );
261
+		update_option('give_doing_upgrade', $doing_upgrade_args);
262 262
 
263 263
 		// Enable cache.
264 264
 		Give_Cache::enable();
265 265
 
266 266
 		// Check if current update completed or not.
267
-		if ( give_has_upgrade_completed( $update['id'] ) ) {
267
+		if (give_has_upgrade_completed($update['id'])) {
268 268
 			return false;
269 269
 		}
270 270
 
@@ -278,23 +278,23 @@  discard block
 block discarded – undo
278 278
 	 * performed, or, call parent::complete().
279 279
 	 */
280 280
 	public function complete() {
281
-		if ( $this->is_paused_process() ) {
281
+		if ($this->is_paused_process()) {
282 282
 			return false;
283 283
 		}
284 284
 
285 285
 		parent::complete();
286 286
 
287
-		delete_option( 'give_pause_upgrade' );
288
-		delete_option( 'give_upgrade_error' );
289
-		delete_option( 'give_db_update_count' );
290
-		delete_option( 'give_doing_upgrade' );
291
-		add_option( 'give_show_db_upgrade_complete_notice', 1, '', 'no' );
287
+		delete_option('give_pause_upgrade');
288
+		delete_option('give_upgrade_error');
289
+		delete_option('give_db_update_count');
290
+		delete_option('give_doing_upgrade');
291
+		add_option('give_show_db_upgrade_complete_notice', 1, '', 'no');
292 292
 
293 293
 		// Flush cache.
294 294
 		Give_Cache::get_instance()->flush_cache();
295 295
 
296
-		if ( $cache_keys = Give_Cache::get_options_like( '' ) ) {
297
-			Give_Cache::delete( $cache_keys );
296
+		if ($cache_keys = Give_Cache::get_options_like('')) {
297
+			Give_Cache::delete($cache_keys);
298 298
 		}
299 299
 	}
300 300
 
@@ -304,19 +304,19 @@  discard block
 block discarded – undo
304 304
 	 * @return int
305 305
 	 */
306 306
 	protected function get_memory_limit() {
307
-		if ( function_exists( 'ini_get' ) ) {
308
-			$memory_limit = ini_get( 'memory_limit' );
307
+		if (function_exists('ini_get')) {
308
+			$memory_limit = ini_get('memory_limit');
309 309
 		} else {
310 310
 			// Sensible default.
311 311
 			$memory_limit = '128M';
312 312
 		}
313 313
 
314
-		if ( ! $memory_limit || '-1' === $memory_limit ) {
314
+		if ( ! $memory_limit || '-1' === $memory_limit) {
315 315
 			// Unlimited, set to 32GB.
316 316
 			$memory_limit = '32000M';
317 317
 		}
318 318
 
319
-		return intval( $memory_limit ) * 1024 * 1024;
319
+		return intval($memory_limit) * 1024 * 1024;
320 320
 	}
321 321
 
322 322
 	/**
@@ -329,17 +329,17 @@  discard block
 block discarded – undo
329 329
 		// Don't lock up other requests while processing
330 330
 		session_write_close();
331 331
 
332
-		if ( $this->is_process_running() || $this->is_paused_process() ) {
332
+		if ($this->is_process_running() || $this->is_paused_process()) {
333 333
 			// Background process already running.
334 334
 			wp_die();
335 335
 		}
336 336
 
337
-		if ( $this->is_queue_empty() ) {
337
+		if ($this->is_queue_empty()) {
338 338
 			// No data to process.
339 339
 			wp_die();
340 340
 		}
341 341
 
342
-		check_ajax_referer( $this->identifier, 'nonce' );
342
+		check_ajax_referer($this->identifier, 'nonce');
343 343
 
344 344
 		$this->handle();
345 345
 
@@ -354,13 +354,13 @@  discard block
 block discarded – undo
354 354
 	 * @access public
355 355
 	 * @return bool
356 356
 	 */
357
-	public function is_paused_process(){
357
+	public function is_paused_process() {
358 358
 		// Delete cache.
359
-		wp_cache_delete( 'give_paused_batches', 'options' );
359
+		wp_cache_delete('give_paused_batches', 'options');
360 360
 
361 361
 		$paused_batches = get_option('give_paused_batches');
362 362
 
363
-		return ! empty( $paused_batches );
363
+		return ! empty($paused_batches);
364 364
 	}
365 365
 
366 366
 
@@ -406,8 +406,8 @@  discard block
 block discarded – undo
406 406
 		);
407 407
 
408 408
 
409
-		foreach ( $options as $option ) {
410
-			wp_cache_delete( $option, 'options' );
409
+		foreach ($options as $option) {
410
+			wp_cache_delete($option, 'options');
411 411
 		}
412 412
 	}
413 413
 }
Please login to merge, or discard this patch.
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   +89 added lines, -89 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' ), 10, 4 );
88
+		if (in_array('get_post_metadata', $this->supports)) {
89
+			add_filter('get_post_metadata', array($this, '__get_meta'), 10, 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
 
@@ -529,12 +529,12 @@  discard block
 block discarded – undo
529 529
 	 *
530 530
 	 * @return  bool  False for failure. True for success.
531 531
 	 */
532
-	public function delete_all_meta( $id = 0 ) {
532
+	public function delete_all_meta($id = 0) {
533 533
 		global $wpdb;
534
-		$status = $wpdb->delete( $this->table_name, array( "{$this->meta_type}_id" => $id ), array( '%d' ) );
534
+		$status = $wpdb->delete($this->table_name, array("{$this->meta_type}_id" => $id), array('%d'));
535 535
 
536
-		if ( $status ) {
537
-			$this->delete_cache( $id, $this->meta_type );
536
+		if ($status) {
537
+			$this->delete_cache($id, $this->meta_type);
538 538
 		}
539 539
 
540 540
 		return $status;
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-addon-activation-banner.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -505,7 +505,7 @@
 block discarded – undo
505 505
 	 *
506 506
 	 * @param string $main_file Plugin Main File.
507 507
 	 *
508
-	 * @return bool|mixed|string
508
+	 * @return string
509 509
 	 */
510 510
 	public function get_plugin_folder_name( $main_file ) {
511 511
 		// Remove plugin file and get the Add-on's folder name only.
Please login to merge, or discard this patch.
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // Exit if accessed directly.
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if ( ! defined('ABSPATH')) {
11 11
 	exit;
12 12
 }
13 13
 
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
 	 *                               'testing'           => false, // (required) Never leave as "true" in production!!!
36 36
 	 *                               }
37 37
 	 */
38
-	function __construct( $_banner_details ) {
38
+	function __construct($_banner_details) {
39 39
 		global $give_addons, $pagenow;
40 40
 
41 41
 		// Append add-on information to the global variable.
42 42
 		$give_addons[] = $_banner_details;
43 43
 
44
-		if ( 'plugins.php' === $pagenow ) {
44
+		if ('plugins.php' === $pagenow) {
45 45
 
46 46
 			// Get the current user.
47 47
 			$current_user  = wp_get_current_user();
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
 			$this->add_addon_activate_meta();
55 55
 
56 56
 			// Check if notice callback is already hooked.
57
-			if ( ! $this->is_banner_notice_hooked() ) {
57
+			if ( ! $this->is_banner_notice_hooked()) {
58 58
 				// If multiple add-on are activated then show activation banner in tab view.
59
-				add_action( 'admin_notices', array( $this, 'addon_activation_banner_notices' ), 10 );
59
+				add_action('admin_notices', array($this, 'addon_activation_banner_notices'), 10);
60 60
 			}
61 61
 		}
62 62
 	}
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * @return string
71 71
 	 */
72
-	public static function get_banner_user_meta_key( $addon_banner_key ) {
73
-		$addon_slug = sanitize_text_field( $addon_banner_key );
72
+	public static function get_banner_user_meta_key($addon_banner_key) {
73
+		$addon_slug = sanitize_text_field($addon_banner_key);
74 74
 
75 75
 		return "give_addon_{$addon_slug}_active_by_user";
76 76
 	}
@@ -85,24 +85,24 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	public function init() {
87 87
 		// Get the current page to add the notice to
88
-		add_action( 'current_screen', array( $this, 'give_addon_notice_ignore' ) );
88
+		add_action('current_screen', array($this, 'give_addon_notice_ignore'));
89 89
 
90 90
 		// Get the Give add-ons.
91 91
 		$give_addons = $this->get_plugin_file_names();
92 92
 
93
-		if ( ! empty( $give_addons ) ) {
93
+		if ( ! empty($give_addons)) {
94 94
 
95 95
 			// Go through each of the add-on and hook deactivate action.
96
-			foreach ( $give_addons as $addon_name => $give_addon ) {
96
+			foreach ($give_addons as $addon_name => $give_addon) {
97 97
 
98 98
 				// Testing?
99
-				if ( true === $give_addon['testing'] ) {
100
-					$nag_meta_key = 'give_addon_activation_ignore_' . $addon_name;
101
-					delete_user_meta( $this->user_id, $nag_meta_key );
99
+				if (true === $give_addon['testing']) {
100
+					$nag_meta_key = 'give_addon_activation_ignore_'.$addon_name;
101
+					delete_user_meta($this->user_id, $nag_meta_key);
102 102
 				}
103 103
 
104 104
 				// Add deactivate hook.
105
-				add_action( 'deactivate_' . $give_addon['plugin_main_file'], array( $this, 'remove_addon_activate_meta' ) );
105
+				add_action('deactivate_'.$give_addon['plugin_main_file'], array($this, 'remove_addon_activate_meta'));
106 106
 			}
107 107
 		}
108 108
 	}
@@ -118,29 +118,29 @@  discard block
 block discarded – undo
118 118
 		global $give_addons;
119 119
 
120 120
 		// Get recently activated plugins.
121
-		$active_plugins = get_option( 'active_plugins' );
121
+		$active_plugins = get_option('active_plugins');
122 122
 
123 123
 		$file_names = array();
124 124
 
125
-		if ( empty( $give_addons ) ) {
125
+		if (empty($give_addons)) {
126 126
 			return $file_names;
127 127
 		}
128 128
 
129 129
 		// Go through each addon and get the plugin file url.
130
-		foreach ( $give_addons as $give_addon ) {
130
+		foreach ($give_addons as $give_addon) {
131 131
 			$file_name = '';
132
-			$file_path = explode( '/plugins/', $give_addon['file'] );
133
-			if ( $file_path ) {
134
-				$file_path = array_pop( $file_path );
135
-				$file_name = current( explode( '/', $file_path ) );
132
+			$file_path = explode('/plugins/', $give_addon['file']);
133
+			if ($file_path) {
134
+				$file_path = array_pop($file_path);
135
+				$file_name = current(explode('/', $file_path));
136 136
 			}
137 137
 
138
-			if ( ! empty( $file_name ) ) {
139
-				foreach ( $active_plugins as $plugin ) {
140
-					if ( false !== strpos( $plugin, $file_name ) ) {
141
-						$add_on_key                     = sanitize_title( $give_addon['name'] );
138
+			if ( ! empty($file_name)) {
139
+				foreach ($active_plugins as $plugin) {
140
+					if (false !== strpos($plugin, $file_name)) {
141
+						$add_on_key                     = sanitize_title($give_addon['name']);
142 142
 						$give_addon['plugin_main_file'] = $plugin; // Include plugin file.
143
-						$file_names[ $add_on_key ]      = $give_addon;
143
+						$file_names[$add_on_key]      = $give_addon;
144 144
 						break;
145 145
 					}
146 146
 				}
@@ -160,16 +160,16 @@  discard block
 block discarded – undo
160 160
 		// Get all activated add-ons.
161 161
 		$give_addons = $this->get_plugin_file_names();
162 162
 
163
-		if ( ! empty( $give_addons ) ) {
163
+		if ( ! empty($give_addons)) {
164 164
 
165 165
 			// Go through rach add-ons and add meta data.
166
-			foreach ( $give_addons as $banner_addon_name => $addon ) {
166
+			foreach ($give_addons as $banner_addon_name => $addon) {
167 167
 
168 168
 				// User meta key.
169
-				$user_id = __give_get_active_by_user_meta( $banner_addon_name );
169
+				$user_id = __give_get_active_by_user_meta($banner_addon_name);
170 170
 
171
-				if ( ! $user_id ) {
172
-					update_option( self::get_banner_user_meta_key( $banner_addon_name ), $this->user_id, '' );
171
+				if ( ! $user_id) {
172
+					update_option(self::get_banner_user_meta_key($banner_addon_name), $this->user_id, '');
173 173
 				}
174 174
 			}
175 175
 		}
@@ -186,14 +186,14 @@  discard block
 block discarded – undo
186 186
 		global $wp_filter;
187 187
 		$notice_already_hooked = false;
188 188
 
189
-		if ( isset( $wp_filter['admin_notices']->callbacks[10] ) ) {
189
+		if (isset($wp_filter['admin_notices']->callbacks[10])) {
190 190
 			// Get all of the hooks.
191
-			$admin_notice_callbacks = array_keys( $wp_filter['admin_notices']->callbacks[10] );
191
+			$admin_notice_callbacks = array_keys($wp_filter['admin_notices']->callbacks[10]);
192 192
 
193
-			if ( ! empty( $admin_notice_callbacks ) ) {
194
-				foreach ( $admin_notice_callbacks as $key ) {
193
+			if ( ! empty($admin_notice_callbacks)) {
194
+				foreach ($admin_notice_callbacks as $key) {
195 195
 					//If the key is found in your string, set $found to true
196
-					if ( false !== strpos( $key, 'addon_activation_banner_notices' ) ) {
196
+					if (false !== strpos($key, 'addon_activation_banner_notices')) {
197 197
 						$notice_already_hooked = true;
198 198
 					}
199 199
 				}
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 		global $pagenow, $give_addons;
213 213
 
214 214
 		// Bailout.
215
-		if ( 'plugins.php' !== $pagenow ) {
215
+		if ('plugins.php' !== $pagenow) {
216 216
 			return false;
217 217
 		}
218 218
 
@@ -224,55 +224,55 @@  discard block
 block discarded – undo
224 224
 		$latest_addon     = array();
225 225
 
226 226
 		// Get the plugin folder name, because many give-addon not sending proper plugin_file.
227
-		if ( ! empty( $recent_activated ) ) {
228
-			foreach ( $recent_activated as $recent_addon ) {
227
+		if ( ! empty($recent_activated)) {
228
+			foreach ($recent_activated as $recent_addon) {
229 229
 				// Get the add-on folder name.
230
-				$latest_addon[] = substr( $recent_addon, 0, strpos( $recent_addon, '/' ) );
230
+				$latest_addon[] = substr($recent_addon, 0, strpos($recent_addon, '/'));
231 231
 			}
232 232
 		}
233 233
 
234 234
 		// Go through each of the give add-on.
235
-		foreach ( $give_addons as $addon ) {
236
-			$addon_sanitized_name = sanitize_title( $addon['name'] );
235
+		foreach ($give_addons as $addon) {
236
+			$addon_sanitized_name = sanitize_title($addon['name']);
237 237
 
238 238
 			// Get the add-on dismiss status.
239
-			$add_on_state = get_user_meta( $this->user_id, "give_addon_activation_ignore_{$addon_sanitized_name}", true );
239
+			$add_on_state = get_user_meta($this->user_id, "give_addon_activation_ignore_{$addon_sanitized_name}", true);
240 240
 
241 241
 			// Get the option key.
242
-			$activate_by_user = (int) __give_get_active_by_user_meta( $addon_sanitized_name );
242
+			$activate_by_user = (int) __give_get_active_by_user_meta($addon_sanitized_name);
243 243
 
244 244
 			// Remove plugin file and get the Add-on's folder name only.
245
-			$file_path = $this->get_plugin_folder_name( $addon['file'] );
245
+			$file_path = $this->get_plugin_folder_name($addon['file']);
246 246
 
247 247
 			// If add-on were never dismissed.
248
-			if ( 'true' !== $add_on_state && $this->user_id === $activate_by_user ) {
249
-				if ( ! empty( $latest_addon ) && ( in_array( $file_path, $latest_addon, true ) || empty( $latest_addon ) ) ) {
248
+			if ('true' !== $add_on_state && $this->user_id === $activate_by_user) {
249
+				if ( ! empty($latest_addon) && (in_array($file_path, $latest_addon, true) || empty($latest_addon))) {
250 250
 					$addon_to_display[] = $addon;
251 251
 				}
252 252
 			}
253 253
 		}
254 254
 
255
-		if ( ! empty( $addon_to_display ) ) {
255
+		if ( ! empty($addon_to_display)) {
256 256
 			ob_start();
257 257
 
258 258
 			// Output inline styles here because there's no reason
259 259
 			// to enqueued them after the alert is dismissed.
260 260
 			$this->print_css_js();
261 261
 			?>
262
-			<div class="<?php echo ( 1 !== count( $addon_to_display ) ) ? 'give-alert-tab-wrapper' : ''; ?> updated give-addon-alert give-notice">
262
+			<div class="<?php echo (1 !== count($addon_to_display)) ? 'give-alert-tab-wrapper' : ''; ?> updated give-addon-alert give-notice">
263 263
 				<?php
264 264
 				// If multiple add-on are activated.
265
-				if ( 1 !== count( $addon_to_display ) ) {
265
+				if (1 !== count($addon_to_display)) {
266 266
 					?>
267 267
 					<div class="give-vertical-tab">
268 268
 						<div class="give-addon-tab-list">
269 269
 							<ul class="give-alert-addon-list">
270 270
 								<?php
271 271
 								$is_first = true;
272
-								foreach ( $addon_to_display as $banner ) {
272
+								foreach ($addon_to_display as $banner) {
273 273
 									?>
274
-									<li class="give-tab-list<?php echo ( true === $is_first ) ? ' active' : ''; ?>" id="give-addon-<?php echo esc_attr( basename( $banner['file'], '.php' ) ); ?>">
275
-										<a href="#"><?php echo esc_html( $banner['name'] ); ?></a>
274
+									<li class="give-tab-list<?php echo (true === $is_first) ? ' active' : ''; ?>" id="give-addon-<?php echo esc_attr(basename($banner['file'], '.php')); ?>">
275
+										<a href="#"><?php echo esc_html($banner['name']); ?></a>
276 276
 									</li>
277 277
 									<?php
278 278
 									$is_first = false;
@@ -282,11 +282,11 @@  discard block
 block discarded – undo
282 282
 							</ul>
283 283
 						</div>
284 284
 						<div class="give-right-side-block">
285
-							<?php foreach ( $addon_to_display as $banner ) : ?>
286
-								<div class="give-tab-details <?php echo ( true === $is_first ) ? ' active' : ''; ?> " id="give-addon-<?php echo esc_attr( basename( $banner['file'], '.php' ) ); ?>">
285
+							<?php foreach ($addon_to_display as $banner) : ?>
286
+								<div class="give-tab-details <?php echo (true === $is_first) ? ' active' : ''; ?> " id="give-addon-<?php echo esc_attr(basename($banner['file'], '.php')); ?>">
287 287
 									<?php
288 288
 										// Render single add banner.
289
-										$this->render_single_addon_banner( $banner, false );
289
+										$this->render_single_addon_banner($banner, false);
290 290
 										$is_first = false;
291 291
 									?>
292 292
 								</div>
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 					</div>
296 296
 					<?php
297 297
 				} else {
298
-					$this->render_single_addon_banner( $addon_to_display[0], true );
298
+					$this->render_single_addon_banner($addon_to_display[0], true);
299 299
 				}
300 300
 				?>
301 301
 			</div>
@@ -303,12 +303,12 @@  discard block
 block discarded – undo
303 303
 			$notice_html = ob_get_clean();
304 304
 
305 305
 			// Register notice.
306
-			Give()->notices->register_notice( array(
306
+			Give()->notices->register_notice(array(
307 307
 				'id'               => 'give_add_on_activation_notice',
308 308
 				'type'             => 'updated',
309 309
 				'description_html' => $notice_html,
310 310
 				'show'             => true,
311
-			) );
311
+			));
312 312
 		}
313 313
 	}
314 314
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	 * @param array $banner_arr Banner options.
321 321
 	 * @param bool  $is_single  Is single.
322 322
 	 */
323
-	private function render_single_addon_banner( $banner_arr, $is_single ) {
323
+	private function render_single_addon_banner($banner_arr, $is_single) {
324 324
 		// Get all give add-on.
325 325
 		$give_addons = give_get_plugins();
326 326
 
@@ -328,80 +328,80 @@  discard block
 block discarded – undo
328 328
 		$plugin_file = $banner_arr['file'];
329 329
 
330 330
 		// Get the plugin main file.
331
-		foreach ( $give_addons as $main_file => $addon ) {
331
+		foreach ($give_addons as $main_file => $addon) {
332 332
 			// Plugin should be activated.
333
-			if ( ! is_plugin_active( $main_file ) ) {
333
+			if ( ! is_plugin_active($main_file)) {
334 334
 				continue;
335 335
 			}
336 336
 
337 337
 			if (
338
-				isset( $banner_arr['name'] )
338
+				isset($banner_arr['name'])
339 339
 				&& 'add-on' === $addon['Type']
340
-				&& $this->get_plugin_folder_name( $main_file ) === $this->get_plugin_folder_name( $plugin_file )
340
+				&& $this->get_plugin_folder_name($main_file) === $this->get_plugin_folder_name($plugin_file)
341 341
 			) {
342
-				$plugin_file = WP_PLUGIN_DIR . '/' . $main_file;
342
+				$plugin_file = WP_PLUGIN_DIR.'/'.$main_file;
343 343
 				break;
344 344
 			}
345 345
 		}
346 346
 
347 347
 		// Create dismiss URL.
348 348
 		$dismiss_url = $is_single
349
-			? admin_url( 'plugins.php?give_addon_activation_ignore=1&give_addon=' . sanitize_title( $banner_arr['name'] ) )
350
-			: admin_url( 'plugins.php?give_addon_activation_ignore=1&give_addon=all' );
349
+			? admin_url('plugins.php?give_addon_activation_ignore=1&give_addon='.sanitize_title($banner_arr['name']))
350
+			: admin_url('plugins.php?give_addon_activation_ignore=1&give_addon=all');
351 351
 
352 352
 		// Get the add-on details.
353
-		$plugin_data = get_plugin_data( $plugin_file );
353
+		$plugin_data = get_plugin_data($plugin_file);
354 354
 		?>
355
-		<img src="<?php echo esc_url( GIVE_PLUGIN_URL . 'assets/dist/images/give-icon-full-circle.svg' ); ?>" class="give-logo" />
355
+		<img src="<?php echo esc_url(GIVE_PLUGIN_URL.'assets/dist/images/give-icon-full-circle.svg'); ?>" class="give-logo" />
356 356
 		<div class="give-alert-message">
357 357
 			<h3>
358 358
 				<?php
359 359
 				printf(
360 360
 					/* translators: %s: Add-on name */
361 361
 					'%s<span>%s</span>',
362
-					__( 'New Give Add-on Activated: ', 'give' ),
363
-					esc_html( $banner_arr['name'] )
362
+					__('New Give Add-on Activated: ', 'give'),
363
+					esc_html($banner_arr['name'])
364 364
 				);
365 365
 				?>
366 366
 			</h3>
367
-			<a href="<?php echo esc_url( $dismiss_url ); ?>" class="dismiss">
367
+			<a href="<?php echo esc_url($dismiss_url); ?>" class="dismiss">
368 368
 				<span class="dashicons dashicons-dismiss"></span>
369 369
 			</a>
370 370
 			<div class="alert-actions">
371 371
 				<?php
372 372
 				//Point them to your settings page.
373
-				if ( ! empty( $plugin_data['Description'] ) ) {
373
+				if ( ! empty($plugin_data['Description'])) {
374 374
 					?>
375 375
 					<span class="give-addon-description">
376
-					<em><?php echo esc_html( strip_tags( $plugin_data['Description'] ) ); ?></em></span><br />
376
+					<em><?php echo esc_html(strip_tags($plugin_data['Description'])); ?></em></span><br />
377 377
 					<?php
378 378
 				}
379
-				if ( isset( $banner_arr['settings_url'] ) ) {
379
+				if (isset($banner_arr['settings_url'])) {
380 380
 					printf(
381 381
 						'<a href="%s"><span class="dashicons dashicons-admin-settings"></span>%s</a>',
382
-						esc_url( $banner_arr['settings_url'] ),
383
-						esc_html__( 'Go to Settings', 'give' )
382
+						esc_url($banner_arr['settings_url']),
383
+						esc_html__('Go to Settings', 'give')
384 384
 					);
385 385
 				}
386 386
 				// Show them how to configure the Addon.
387
-				if ( isset( $banner_arr['documentation_url'] ) ) {
387
+				if (isset($banner_arr['documentation_url'])) {
388 388
 					printf(
389 389
 						'<a href="%s" target="_blank"><span class="dashicons dashicons-media-text"></span>%s</a>',
390
-						esc_url( $banner_arr['documentation_url'] ),
390
+						esc_url($banner_arr['documentation_url']),
391 391
 						sprintf(
392 392
 							/* translators: %s: Add-on name */
393
-							esc_html__( 'Documentation: %s Add-on', 'give' ),
394
-							esc_html( $banner_arr['name'] )
393
+							esc_html__('Documentation: %s Add-on', 'give'),
394
+							esc_html($banner_arr['name'])
395 395
 						)
396 396
 					);
397 397
 				}
398 398
 
399 399
 				//Let them signup for plugin updates
400
-				if ( isset( $banner_arr['support_url'] ) ) {
400
+				if (isset($banner_arr['support_url'])) {
401 401
 					printf(
402 402
 						'<a href="%s" target="_blank"><span class="dashicons dashicons-sos"></span>%s</a>',
403
-						esc_url( $banner_arr['support_url'] ),
404
-						esc_html__( 'Get Support', 'give' )
403
+						esc_url($banner_arr['support_url']),
404
+						esc_html__('Get Support', 'give')
405 405
 					);
406 406
 				}
407 407
 				?>
@@ -424,30 +424,30 @@  discard block
 block discarded – undo
424 424
 		 * See here: http://codex.wordpress.org/Function_Reference/add_user_meta
425 425
 		 */
426 426
 		if (
427
-			isset( $_GET['give_addon'], $_GET['give_addon_activation_ignore'] )
427
+			isset($_GET['give_addon'], $_GET['give_addon_activation_ignore'])
428 428
 			&& '1' === $_GET['give_addon_activation_ignore']
429 429
 		) {
430 430
 			// Get the value of the 'give_addon' query string.
431
-			$addon_query_arg    = sanitize_text_field( wp_unslash( $_GET['give_addon'] ) );
431
+			$addon_query_arg    = sanitize_text_field(wp_unslash($_GET['give_addon']));
432 432
 			$deactivated_addons = array();
433 433
 
434 434
 			// If All add-on requested to dismiss.
435
-			if ( 'all' === $addon_query_arg ) {
435
+			if ('all' === $addon_query_arg) {
436 436
 				// Get all activated add-ons.
437 437
 				$give_addons = $this->get_plugin_file_names();
438 438
 
439
-				if ( ! empty( $give_addons ) ) {
440
-					$deactivated_addons = array_keys( $give_addons );
439
+				if ( ! empty($give_addons)) {
440
+					$deactivated_addons = array_keys($give_addons);
441 441
 				}
442 442
 			} else {
443 443
 				// Store the addon to deactivate.
444 444
 				$deactivated_addons[] = $addon_query_arg;
445 445
 			}
446 446
 
447
-			if ( ! empty( $deactivated_addons ) ) {
448
-				foreach ( $deactivated_addons as $addon ) {
447
+			if ( ! empty($deactivated_addons)) {
448
+				foreach ($deactivated_addons as $addon) {
449 449
 					// Record it user meta.
450
-					add_user_meta( $this->user_id, "give_addon_activation_ignore_{$addon}", 'true', true );
450
+					add_user_meta($this->user_id, "give_addon_activation_ignore_{$addon}", 'true', true);
451 451
 				}
452 452
 			}
453 453
 		}
@@ -462,26 +462,26 @@  discard block
 block discarded – undo
462 462
 	 */
463 463
 	public function remove_addon_activate_meta() {
464 464
 		// Get the hook name and then grab the plugin file from it.
465
-		$plugin_file = str_replace( 'deactivate_', '', current_action() );
465
+		$plugin_file = str_replace('deactivate_', '', current_action());
466 466
 
467 467
 		// Get all activated add-ons.
468 468
 		$give_addons = $this->get_plugin_file_names();
469 469
 
470
-		if ( ! empty( $give_addons ) ) {
471
-			foreach ( $give_addons as $banner_addon_name => $addon ) {
472
-				if ( $plugin_file === $addon['plugin_main_file'] ) {
470
+		if ( ! empty($give_addons)) {
471
+			foreach ($give_addons as $banner_addon_name => $addon) {
472
+				if ($plugin_file === $addon['plugin_main_file']) {
473 473
 
474 474
 					// Get the user meta key.
475
-					$user_id = (int) __give_get_active_by_user_meta( $banner_addon_name );
475
+					$user_id = (int) __give_get_active_by_user_meta($banner_addon_name);
476 476
 
477
-					if ( $user_id ) {
477
+					if ($user_id) {
478 478
 						// Get user meta for this add-on.
479 479
 						$nag_meta_key = "give_addon_activation_ignore_{$banner_addon_name}";
480 480
 
481 481
 						// Delete plugin activation option key.
482
-						delete_option( self::get_banner_user_meta_key( $banner_addon_name ) );
482
+						delete_option(self::get_banner_user_meta_key($banner_addon_name));
483 483
 						// Delete user meta of plugin activation.
484
-						delete_user_meta( $user_id, $nag_meta_key );
484
+						delete_user_meta($user_id, $nag_meta_key);
485 485
 					}
486 486
 				}
487 487
 			}
@@ -508,11 +508,11 @@  discard block
 block discarded – undo
508 508
 	 *
509 509
 	 * @return bool|mixed|string
510 510
 	 */
511
-	public function get_plugin_folder_name( $main_file ) {
511
+	public function get_plugin_folder_name($main_file) {
512 512
 		// Remove plugin file and get the Add-on's folder name only.
513
-		$file_path       = explode( '/plugins/', $main_file );
514
-		$addon_file_path = array_pop( $file_path );
515
-		$addon_file_path = substr( $addon_file_path, 0, strpos( $addon_file_path, '/' ) );
513
+		$file_path       = explode('/plugins/', $main_file);
514
+		$addon_file_path = array_pop($file_path);
515
+		$addon_file_path = substr($addon_file_path, 0, strpos($addon_file_path, '/'));
516 516
 
517 517
 		return $addon_file_path;
518 518
 	}
Please login to merge, or discard this patch.