Completed
Pull Request — master (#986)
by Rami
20:36
created
includes/class-give-db.php 1 patch
Spacing   +39 added lines, -39 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
 
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * @return object
100 100
 	 */
101
-	public function get( $row_id ) {
101
+	public function get($row_id) {
102 102
 		/* @var WPDB $wpdb */
103 103
 		global $wpdb;
104 104
 
105
-		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
105
+		return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id));
106 106
 	}
107 107
 
108 108
 	/**
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
      *
117 117
      * @return object
118 118
 	 */
119
-	public function get_by( $column, $row_id ) {
119
+	public function get_by($column, $row_id) {
120 120
         /* @var WPDB $wpdb */
121 121
         global $wpdb;
122 122
 
123
-		$column = esc_sql( $column );
124
-		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) );
123
+		$column = esc_sql($column);
124
+		return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id));
125 125
 	}
126 126
 
127 127
 	/**
@@ -135,12 +135,12 @@  discard block
 block discarded – undo
135 135
      *
136 136
 	 * @return string      Column value.
137 137
 	 */
138
-	public function get_column( $column, $row_id ) {
138
+	public function get_column($column, $row_id) {
139 139
         /* @var WPDB $wpdb */
140 140
         global $wpdb;
141 141
 
142
-		$column = esc_sql( $column );
143
-		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
142
+		$column = esc_sql($column);
143
+		return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id));
144 144
 	}
145 145
 
146 146
 	/**
@@ -155,13 +155,13 @@  discard block
 block discarded – undo
155 155
      *
156 156
 	 * @return string
157 157
 	 */
158
-	public function get_column_by( $column, $column_where, $column_value ) {
158
+	public function get_column_by($column, $column_where, $column_value) {
159 159
         /* @var WPDB $wpdb */
160 160
         global $wpdb;
161 161
 
162
-		$column_where = esc_sql( $column_where );
163
-		$column       = esc_sql( $column );
164
-		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) );
162
+		$column_where = esc_sql($column_where);
163
+		$column       = esc_sql($column);
164
+		return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value));
165 165
 	}
166 166
 
167 167
 	/**
@@ -175,12 +175,12 @@  discard block
 block discarded – undo
175 175
      *
176 176
 	 * @return int
177 177
 	 */
178
-	public function insert( $data, $type = '' ) {
178
+	public function insert($data, $type = '') {
179 179
         /* @var WPDB $wpdb */
180 180
         global $wpdb;
181 181
 
182 182
 		// Set default values.
183
-		$data = wp_parse_args( $data, $this->get_column_defaults() );
183
+		$data = wp_parse_args($data, $this->get_column_defaults());
184 184
 
185 185
 		/**
186 186
 		 * Fires before inserting data to the database.
@@ -189,22 +189,22 @@  discard block
 block discarded – undo
189 189
 		 *
190 190
 		 * @param array $data
191 191
 		 */
192
-		do_action( "give_pre_insert_{$type}", $data );
192
+		do_action("give_pre_insert_{$type}", $data);
193 193
 
194 194
 		// Initialise column format array
195 195
 		$column_formats = $this->get_columns();
196 196
 
197 197
 		// Force fields to lower case
198
-		$data = array_change_key_case( $data );
198
+		$data = array_change_key_case($data);
199 199
 
200 200
 		// White list columns
201
-		$data = array_intersect_key( $data, $column_formats );
201
+		$data = array_intersect_key($data, $column_formats);
202 202
 
203 203
 		// Reorder $column_formats to match the order of columns given in $data
204
-		$data_keys      = array_keys( $data );
205
-		$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
204
+		$data_keys      = array_keys($data);
205
+		$column_formats = array_merge(array_flip($data_keys), $column_formats);
206 206
 
207
-		$wpdb->insert( $this->table_name, $data, $column_formats );
207
+		$wpdb->insert($this->table_name, $data, $column_formats);
208 208
 
209 209
 		/**
210 210
 		 * Fires after inserting data to the database.
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 		 * @param int   $insert_id
215 215
 		 * @param array $data
216 216
 		 */
217
-		do_action( "give_post_insert_{$type}", $wpdb->insert_id, $data );
217
+		do_action("give_post_insert_{$type}", $wpdb->insert_id, $data);
218 218
 
219 219
 		return $wpdb->insert_id;
220 220
 	}
@@ -231,18 +231,18 @@  discard block
 block discarded – undo
231 231
      *
232 232
 	 * @return bool
233 233
 	 */
234
-	public function update( $row_id, $data = array(), $where = '' ) {
234
+	public function update($row_id, $data = array(), $where = '') {
235 235
         /* @var WPDB $wpdb */
236 236
         global $wpdb;
237 237
 
238 238
 		// Row ID must be positive integer
239
-		$row_id = absint( $row_id );
239
+		$row_id = absint($row_id);
240 240
 
241
-		if ( empty( $row_id ) ) {
241
+		if (empty($row_id)) {
242 242
 			return false;
243 243
 		}
244 244
 
245
-		if ( empty( $where ) ) {
245
+		if (empty($where)) {
246 246
 			$where = $this->primary_key;
247 247
 		}
248 248
 
@@ -250,16 +250,16 @@  discard block
 block discarded – undo
250 250
 		$column_formats = $this->get_columns();
251 251
 
252 252
 		// Force fields to lower case
253
-		$data = array_change_key_case( $data );
253
+		$data = array_change_key_case($data);
254 254
 
255 255
 		// White list columns
256
-		$data = array_intersect_key( $data, $column_formats );
256
+		$data = array_intersect_key($data, $column_formats);
257 257
 
258 258
 		// Reorder $column_formats to match the order of columns given in $data
259
-		$data_keys      = array_keys( $data );
260
-		$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
259
+		$data_keys      = array_keys($data);
260
+		$column_formats = array_merge(array_flip($data_keys), $column_formats);
261 261
 
262
-		if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) {
262
+		if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) {
263 263
 			return false;
264 264
 		}
265 265
 
@@ -276,18 +276,18 @@  discard block
 block discarded – undo
276 276
      *
277 277
 	 * @return bool
278 278
 	 */
279
-	public function delete( $row_id = 0 ) {
279
+	public function delete($row_id = 0) {
280 280
         /* @var WPDB $wpdb */
281 281
         global $wpdb;
282 282
 
283 283
 		// Row ID must be positive integer
284
-		$row_id = absint( $row_id );
284
+		$row_id = absint($row_id);
285 285
 
286
-		if ( empty( $row_id ) ) {
286
+		if (empty($row_id)) {
287 287
 			return false;
288 288
 		}
289 289
 
290
-		if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) {
290
+		if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) {
291 291
 			return false;
292 292
 		}
293 293
 
@@ -304,13 +304,13 @@  discard block
 block discarded – undo
304 304
      *
305 305
 	 * @return bool          If the table name exists.
306 306
 	 */
307
-	public function table_exists( $table ) {
307
+	public function table_exists($table) {
308 308
         /* @var WPDB $wpdb */
309 309
 		global $wpdb;
310 310
 
311
-		$table = sanitize_text_field( $table );
311
+		$table = sanitize_text_field($table);
312 312
 
313
-		return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table;
313
+		return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table;
314 314
 	}
315 315
 
316 316
 	/**
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	 * @return bool Returns if the customers table was installed and upgrade routine run.
323 323
 	 */
324 324
 	public function installed() {
325
-		return $this->table_exists( $this->table_name );
325
+		return $this->table_exists($this->table_name);
326 326
 	}
327 327
 
328 328
 }
Please login to merge, or discard this patch.
includes/shortcodes.php 1 patch
Spacing   +109 added lines, -109 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
 
@@ -25,28 +25,28 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_donation_history() {
27 27
 
28
-	$email_access = give_get_option( 'email_access' );
28
+	$email_access = give_get_option('email_access');
29 29
 
30 30
 	//Is user logged in? Does a session exist? Does an email-access token exist?
31
-	if ( is_user_logged_in() || Give()->session->get_session_expiration() !== false || ( $email_access == 'on' && Give()->email_access->token_exists ) ) {
31
+	if (is_user_logged_in() || Give()->session->get_session_expiration() !== false || ($email_access == 'on' && Give()->email_access->token_exists)) {
32 32
 		ob_start();
33
-		give_get_template_part( 'history', 'donations' );
33
+		give_get_template_part('history', 'donations');
34 34
 
35 35
 		return ob_get_clean();
36 36
 	} //Is Email-based access enabled?
37
-	elseif ( $email_access == 'on' ) {
37
+	elseif ($email_access == 'on') {
38 38
 
39 39
 		ob_start();
40
-		give_get_template_part( 'email', 'login-form' );
40
+		give_get_template_part('email', 'login-form');
41 41
 
42 42
 		return ob_get_clean();
43 43
 	} else {
44
-		$message = esc_html__( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' );
45
-		echo apply_filters( 'give_donation_history_nonuser_message', give_output_error( $message, false ), $message );
44
+		$message = esc_html__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give');
45
+		echo apply_filters('give_donation_history_nonuser_message', give_output_error($message, false), $message);
46 46
 	}
47 47
 }
48 48
 
49
-add_shortcode( 'donation_history', 'give_donation_history' );
49
+add_shortcode('donation_history', 'give_donation_history');
50 50
 
51 51
 /**
52 52
  * Donation Form Shortcode
@@ -60,53 +60,53 @@  discard block
 block discarded – undo
60 60
  *
61 61
  * @return string
62 62
  */
63
-function give_form_shortcode( $atts, $content = null ) {
64
-	$atts = shortcode_atts( array(
63
+function give_form_shortcode($atts, $content = null) {
64
+	$atts = shortcode_atts(array(
65 65
 		'id'            => '',
66 66
 		'show_title'    => true,
67 67
 		'show_goal'     => true,
68 68
 		'show_content'  => '',
69 69
 		'float_labels'  => '',
70 70
 		'display_style' => '',
71
-	), $atts, 'give_form' );
71
+	), $atts, 'give_form');
72 72
 
73
-	foreach ( $atts as $key => $value ) {
73
+	foreach ($atts as $key => $value) {
74 74
 		//convert shortcode_atts values to booleans
75
-		if ( $key == 'show_title' ) {
76
-			$atts[ $key ] = filter_var( $atts[ $key ], FILTER_VALIDATE_BOOLEAN );
77
-		} elseif ( $key == 'show_goal' ) {
78
-			$atts[ $key ] = filter_var( $atts[ $key ], FILTER_VALIDATE_BOOLEAN );
75
+		if ($key == 'show_title') {
76
+			$atts[$key] = filter_var($atts[$key], FILTER_VALIDATE_BOOLEAN);
77
+		} elseif ($key == 'show_goal') {
78
+			$atts[$key] = filter_var($atts[$key], FILTER_VALIDATE_BOOLEAN);
79 79
 		}
80 80
 
81 81
 		//validate show_content value
82
-		if ( $key == 'show_content' ) {
83
-			if ( ! in_array( $value, array( 'none', 'above', 'below' ) ) ) {
84
-				$atts[ $key ] = '';
85
-			} else if ( $value == 'above' ) {
86
-				$atts[ $key ] = 'give_pre_form';
87
-			} else if ( $value == 'below' ) {
88
-				$atts[ $key ] = 'give_post_form';
82
+		if ($key == 'show_content') {
83
+			if ( ! in_array($value, array('none', 'above', 'below'))) {
84
+				$atts[$key] = '';
85
+			} else if ($value == 'above') {
86
+				$atts[$key] = 'give_pre_form';
87
+			} else if ($value == 'below') {
88
+				$atts[$key] = 'give_post_form';
89 89
 			}
90 90
 		}
91 91
 
92 92
 		//validate display_style and float_labels value
93
-		if ( ( $key == 'display_style' && ! in_array( $value, array( 'onpage', 'reveal', 'modal' ) ) )
94
-		     || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) )
93
+		if (($key == 'display_style' && ! in_array($value, array('onpage', 'reveal', 'modal')))
94
+		     || ($key == 'float_labels' && ! in_array($value, array('enabled', 'disabled')))
95 95
 		) {
96 96
 
97
-			$atts[ $key ] = '';
97
+			$atts[$key] = '';
98 98
 		}
99 99
 	}
100 100
 
101 101
 	//get the Give Form
102 102
 	ob_start();
103
-	give_get_donation_form( $atts );
103
+	give_get_donation_form($atts);
104 104
 	$final_output = ob_get_clean();
105 105
 
106
-	return apply_filters( 'give_donate_form', $final_output, $atts );
106
+	return apply_filters('give_donate_form', $final_output, $atts);
107 107
 }
108 108
 
109
-add_shortcode( 'give_form', 'give_form_shortcode' );
109
+add_shortcode('give_form', 'give_form_shortcode');
110 110
 
111 111
 /**
112 112
  * Donation Form Goal Shortcode.
@@ -120,37 +120,37 @@  discard block
 block discarded – undo
120 120
  *
121 121
  * @return string
122 122
  */
123
-function give_goal_shortcode( $atts, $content = null ) {
124
-	$atts = shortcode_atts( array(
123
+function give_goal_shortcode($atts, $content = null) {
124
+	$atts = shortcode_atts(array(
125 125
 		'id'        => '',
126 126
 		'show_text' => true,
127 127
 		'show_bar'  => true,
128
-	), $atts, 'give_goal' );
128
+	), $atts, 'give_goal');
129 129
 
130 130
 
131 131
 	//get the Give Form.
132 132
 	ob_start();
133 133
 
134 134
 	//Sanity check 1: ensure there is an ID Provided.
135
-	if ( empty( $atts['id'] ) ) {
136
-		give_output_error( esc_html__( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true );
135
+	if (empty($atts['id'])) {
136
+		give_output_error(esc_html__('The shortcode is missing Donation Form ID attribute.', 'give'), true);
137 137
 	}
138 138
 
139 139
 	//Sanity check 2: Check the form even has Goals enabled.
140
-	$goal_option = get_post_meta( $atts['id'], '_give_goal_option', true );
141
-	if ( empty( $goal_option ) || $goal_option !== 'yes' ) {
142
-		give_output_error( esc_html__( 'The form does not have Goals enabled.', 'give' ), true );
140
+	$goal_option = get_post_meta($atts['id'], '_give_goal_option', true);
141
+	if (empty($goal_option) || $goal_option !== 'yes') {
142
+		give_output_error(esc_html__('The form does not have Goals enabled.', 'give'), true);
143 143
 	} else {
144 144
 		//Passed all sanity checks: output Goal.
145
-		give_show_goal_progress( $atts['id'], $atts );
145
+		give_show_goal_progress($atts['id'], $atts);
146 146
 	}
147 147
 
148 148
 	$final_output = ob_get_clean();
149 149
 
150
-	return apply_filters( 'give_goal_shortcode_output', $final_output, $atts );
150
+	return apply_filters('give_goal_shortcode_output', $final_output, $atts);
151 151
 }
152 152
 
153
-add_shortcode( 'give_goal', 'give_goal_shortcode' );
153
+add_shortcode('give_goal', 'give_goal_shortcode');
154 154
 
155 155
 
156 156
 /**
@@ -167,22 +167,22 @@  discard block
 block discarded – undo
167 167
  * @uses  give_login_form()
168 168
  * @return string
169 169
  */
170
-function give_login_form_shortcode( $atts, $content = null ) {
171
-	$atts = shortcode_atts( array(
170
+function give_login_form_shortcode($atts, $content = null) {
171
+	$atts = shortcode_atts(array(
172 172
         // Add backward compatibility for redirect attribute.
173 173
         'redirect'          => '',
174 174
 
175 175
 		'login-redirect'    => '',
176 176
 		'logout-redirect'   => '',
177
-	), $atts, 'give_login' );
177
+	), $atts, 'give_login');
178 178
 
179 179
     // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute.
180
-    $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect' ] ) ? $atts['redirect'] : '' );
180
+    $atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : '');
181 181
 
182
-	return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] );
182
+	return give_login_form($atts['login-redirect'], $atts['logout-redirect']);
183 183
 }
184 184
 
185
-add_shortcode( 'give_login', 'give_login_form_shortcode' );
185
+add_shortcode('give_login', 'give_login_form_shortcode');
186 186
 
187 187
 /**
188 188
  * Register Shortcode.
@@ -197,15 +197,15 @@  discard block
 block discarded – undo
197 197
  * @uses  give_register_form()
198 198
  * @return string
199 199
  */
200
-function give_register_form_shortcode( $atts, $content = null ) {
201
-	$atts = shortcode_atts( array(
200
+function give_register_form_shortcode($atts, $content = null) {
201
+	$atts = shortcode_atts(array(
202 202
 		'redirect' => '',
203
-	), $atts, 'give_register' );
203
+	), $atts, 'give_register');
204 204
 
205
-	return give_register_form( $atts['redirect'] );
205
+	return give_register_form($atts['redirect']);
206 206
 }
207 207
 
208
-add_shortcode( 'give_register', 'give_register_form_shortcode' );
208
+add_shortcode('give_register', 'give_register_form_shortcode');
209 209
 
210 210
 
211 211
 /**
@@ -220,62 +220,62 @@  discard block
 block discarded – undo
220 220
  *
221 221
  * @return string
222 222
  */
223
-function give_receipt_shortcode( $atts, $content = null ) {
223
+function give_receipt_shortcode($atts, $content = null) {
224 224
 
225 225
 	global $give_receipt_args, $payment;
226 226
 
227
-	$give_receipt_args = shortcode_atts( array(
228
-		'error'          => esc_html__( 'You are missing the payment key to view this donation receipt.', 'give' ),
227
+	$give_receipt_args = shortcode_atts(array(
228
+		'error'          => esc_html__('You are missing the payment key to view this donation receipt.', 'give'),
229 229
 		'price'          => true,
230 230
 		'donor'          => true,
231 231
 		'date'           => true,
232 232
 		'payment_key'    => false,
233 233
 		'payment_method' => true,
234 234
 		'payment_id'     => true
235
-	), $atts, 'give_receipt' );
235
+	), $atts, 'give_receipt');
236 236
 
237 237
 	//set $session var
238 238
 	$session = give_get_purchase_session();
239 239
 
240 240
 	//set payment key var
241
-	if ( isset( $_GET['payment_key'] ) ) {
242
-		$payment_key = urldecode( $_GET['payment_key'] );
243
-	} elseif ( $session ) {
241
+	if (isset($_GET['payment_key'])) {
242
+		$payment_key = urldecode($_GET['payment_key']);
243
+	} elseif ($session) {
244 244
 		$payment_key = $session['purchase_key'];
245
-	} elseif ( $give_receipt_args['payment_key'] ) {
245
+	} elseif ($give_receipt_args['payment_key']) {
246 246
 		$payment_key = $give_receipt_args['payment_key'];
247 247
 	}
248 248
 
249
-	$email_access = give_get_option( 'email_access' );
249
+	$email_access = give_get_option('email_access');
250 250
 
251 251
 	// No payment_key found & Email Access is Turned on:
252
-	if ( ! isset( $payment_key ) && $email_access == 'on' && ! Give()->email_access->token_exists ) {
252
+	if ( ! isset($payment_key) && $email_access == 'on' && ! Give()->email_access->token_exists) {
253 253
 
254 254
 		ob_start();
255 255
 
256
-		give_get_template_part( 'email-login-form' );
256
+		give_get_template_part('email-login-form');
257 257
 
258 258
 		return ob_get_clean();
259 259
 
260
-	} elseif ( ! isset( $payment_key ) ) {
260
+	} elseif ( ! isset($payment_key)) {
261 261
 
262
-		return give_output_error( $give_receipt_args['error'], false, 'error' );
262
+		return give_output_error($give_receipt_args['error'], false, 'error');
263 263
 
264 264
 	}
265 265
 
266
-	$payment_id    = give_get_purchase_id_by_key( $payment_key );
267
-	$user_can_view = give_can_view_receipt( $payment_key );
266
+	$payment_id    = give_get_purchase_id_by_key($payment_key);
267
+	$user_can_view = give_can_view_receipt($payment_key);
268 268
 
269 269
 	// Key was provided, but user is logged out. Offer them the ability to login and view the receipt.
270
-	if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists ) {
270
+	if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists) {
271 271
 
272 272
 		ob_start();
273 273
 
274
-		give_get_template_part( 'email-login-form' );
274
+		give_get_template_part('email-login-form');
275 275
 
276 276
 		return ob_get_clean();
277 277
 
278
-	} elseif ( ! $user_can_view ) {
278
+	} elseif ( ! $user_can_view) {
279 279
 
280 280
 		global $give_login_redirect;
281 281
 
@@ -283,9 +283,9 @@  discard block
 block discarded – undo
283 283
 
284 284
 		ob_start();
285 285
 
286
-		give_output_error( apply_filters( 'give_must_be_logged_in_error_message', esc_html__( 'You must be logged in to view this donation receipt.', 'give' ) ) );
286
+		give_output_error(apply_filters('give_must_be_logged_in_error_message', esc_html__('You must be logged in to view this donation receipt.', 'give')));
287 287
 
288
-		give_get_template_part( 'shortcode', 'login' );
288
+		give_get_template_part('shortcode', 'login');
289 289
 
290 290
 		$login_form = ob_get_clean();
291 291
 
@@ -300,13 +300,13 @@  discard block
 block discarded – undo
300 300
 	 * or if user is logged in and the user can view sensitive shop data.
301 301
 	 *
302 302
 	 */
303
-	if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) {
304
-		return give_output_error( $give_receipt_args['error'], false, 'error' );
303
+	if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) {
304
+		return give_output_error($give_receipt_args['error'], false, 'error');
305 305
 	}
306 306
 
307 307
 	ob_start();
308 308
 
309
-	give_get_template_part( 'shortcode', 'receipt' );
309
+	give_get_template_part('shortcode', 'receipt');
310 310
 
311 311
 	$display = ob_get_clean();
312 312
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 
316 316
 }
317 317
 
318
-add_shortcode( 'give_receipt', 'give_receipt_shortcode' );
318
+add_shortcode('give_receipt', 'give_receipt_shortcode');
319 319
 
320 320
 /**
321 321
  * Profile Editor Shortcode.
@@ -335,18 +335,18 @@  discard block
 block discarded – undo
335 335
  *
336 336
  * @return string Output generated from the profile editor
337 337
  */
338
-function give_profile_editor_shortcode( $atts, $content = null ) {
338
+function give_profile_editor_shortcode($atts, $content = null) {
339 339
 
340 340
 	ob_start();
341 341
 
342
-	give_get_template_part( 'shortcode', 'profile-editor' );
342
+	give_get_template_part('shortcode', 'profile-editor');
343 343
 
344 344
 	$display = ob_get_clean();
345 345
 
346 346
 	return $display;
347 347
 }
348 348
 
349
-add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' );
349
+add_shortcode('give_profile_editor', 'give_profile_editor_shortcode');
350 350
 
351 351
 /**
352 352
  * Process Profile Updater Form.
@@ -359,30 +359,30 @@  discard block
 block discarded – undo
359 359
  *
360 360
  * @return bool
361 361
  */
362
-function give_process_profile_editor_updates( $data ) {
362
+function give_process_profile_editor_updates($data) {
363 363
 	// Profile field change request
364
-	if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) {
364
+	if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) {
365 365
 		return false;
366 366
 	}
367 367
 
368 368
 	// Nonce security
369
-	if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) {
369
+	if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) {
370 370
 		return false;
371 371
 	}
372 372
 
373 373
 	$user_id       = get_current_user_id();
374
-	$old_user_data = get_userdata( $user_id );
375
-
376
-	$display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name;
377
-	$first_name   = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name;
378
-	$last_name    = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name;
379
-	$email        = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email;
380
-	$line1        = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' );
381
-	$line2        = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' );
382
-	$city         = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' );
383
-	$state        = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' );
384
-	$zip          = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' );
385
-	$country      = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' );
374
+	$old_user_data = get_userdata($user_id);
375
+
376
+	$display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name;
377
+	$first_name   = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name;
378
+	$last_name    = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name;
379
+	$email        = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email;
380
+	$line1        = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : '');
381
+	$line2        = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : '');
382
+	$city         = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : '');
383
+	$state        = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : '');
384
+	$zip          = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : '');
385
+	$country      = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : '');
386 386
 
387 387
 	$userdata = array(
388 388
 		'ID'           => $user_id,
@@ -410,38 +410,38 @@  discard block
 block discarded – undo
410 410
 	 * @param int   $user_id  The ID of the user.
411 411
 	 * @param array $userdata User info, including ID, first name, last name, display name and email.
412 412
 	 */
413
-	do_action( 'give_pre_update_user_profile', $user_id, $userdata );
413
+	do_action('give_pre_update_user_profile', $user_id, $userdata);
414 414
 
415 415
 	// New password
416
-	if ( ! empty( $data['give_new_user_pass1'] ) ) {
417
-		if ( $data['give_new_user_pass1'] !== $data['give_new_user_pass2'] ) {
418
-			give_set_error( 'password_mismatch', esc_html__( 'The passwords you entered do not match. Please try again.', 'give' ) );
416
+	if ( ! empty($data['give_new_user_pass1'])) {
417
+		if ($data['give_new_user_pass1'] !== $data['give_new_user_pass2']) {
418
+			give_set_error('password_mismatch', esc_html__('The passwords you entered do not match. Please try again.', 'give'));
419 419
 		} else {
420 420
 			$userdata['user_pass'] = $data['give_new_user_pass1'];
421 421
 		}
422 422
 	}
423 423
 
424 424
 	// Make sure the new email doesn't belong to another user
425
-	if ( $email != $old_user_data->user_email ) {
426
-		if ( email_exists( $email ) ) {
427
-			give_set_error( 'email_exists', esc_html__( 'The email you entered belongs to another user. Please use another.', 'give' ) );
425
+	if ($email != $old_user_data->user_email) {
426
+		if (email_exists($email)) {
427
+			give_set_error('email_exists', esc_html__('The email you entered belongs to another user. Please use another.', 'give'));
428 428
 		}
429 429
 	}
430 430
 
431 431
 	// Check for errors
432 432
 	$errors = give_get_errors();
433 433
 
434
-	if ( $errors ) {
434
+	if ($errors) {
435 435
 		// Send back to the profile editor if there are errors
436
-		wp_redirect( $data['give_redirect'] );
436
+		wp_redirect($data['give_redirect']);
437 437
 		give_die();
438 438
 	}
439 439
 
440 440
 	// Update the user
441
-	$meta    = update_user_meta( $user_id, '_give_user_address', $address );
442
-	$updated = wp_update_user( $userdata );
441
+	$meta    = update_user_meta($user_id, '_give_user_address', $address);
442
+	$updated = wp_update_user($userdata);
443 443
 
444
-	if ( $updated ) {
444
+	if ($updated) {
445 445
 
446 446
 		/**
447 447
 		 * Fires after updating user profile.
@@ -451,13 +451,13 @@  discard block
 block discarded – undo
451 451
 		 * @param int   $user_id  The ID of the user.
452 452
 		 * @param array $userdata User info, including ID, first name, last name, display name and email.
453 453
 		 */
454
-		do_action( 'give_user_profile_updated', $user_id, $userdata );
455
-		wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) );
454
+		do_action('give_user_profile_updated', $user_id, $userdata);
455
+		wp_redirect(add_query_arg('updated', 'true', $data['give_redirect']));
456 456
 		give_die();
457 457
 	}
458 458
 
459 459
 	return false;
460 460
 }
461 461
 
462
-add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' );
462
+add_action('give_edit_user_profile', 'give_process_profile_editor_updates');
463 463
 
Please login to merge, or discard this patch.
includes/emails/class-give-emails.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	public function __construct() {
81 81
 
82
-		if ( 'none' === $this->get_template() ) {
82
+		if ('none' === $this->get_template()) {
83 83
 			$this->html = false;
84 84
 		}
85 85
 
86
-		add_action( 'give_email_send_before', array( $this, 'send_before' ) );
87
-		add_action( 'give_email_send_after', array( $this, 'send_after' ) );
86
+		add_action('give_email_send_before', array($this, 'send_before'));
87
+		add_action('give_email_send_after', array($this, 'send_after'));
88 88
 
89 89
 	}
90 90
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 *
94 94
 	 * @since 1.0
95 95
 	 */
96
-	public function __set( $key, $value ) {
96
+	public function __set($key, $value) {
97 97
 		$this->$key = $value;
98 98
 	}
99 99
 
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
 	 * @since 1.0
104 104
 	 */
105 105
 	public function get_from_name() {
106
-		if ( ! $this->from_name ) {
107
-			$this->from_name = give_get_option( 'from_name', get_bloginfo( 'name' ) );
106
+		if ( ! $this->from_name) {
107
+			$this->from_name = give_get_option('from_name', get_bloginfo('name'));
108 108
 		}
109 109
 
110
-		return apply_filters( 'give_email_from_name', wp_specialchars_decode( $this->from_name ), $this );
110
+		return apply_filters('give_email_from_name', wp_specialchars_decode($this->from_name), $this);
111 111
 	}
112 112
 
113 113
 	/**
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 	 * @since 1.0
117 117
 	 */
118 118
 	public function get_from_address() {
119
-		if ( ! $this->from_address ) {
120
-			$this->from_address = give_get_option( 'from_email', get_option( 'admin_email' ) );
119
+		if ( ! $this->from_address) {
120
+			$this->from_address = give_get_option('from_email', get_option('admin_email'));
121 121
 		}
122 122
 
123
-		return apply_filters( 'give_email_from_address', $this->from_address, $this );
123
+		return apply_filters('give_email_from_address', $this->from_address, $this);
124 124
 	}
125 125
 
126 126
 	/**
@@ -129,13 +129,13 @@  discard block
 block discarded – undo
129 129
 	 * @since 1.0
130 130
 	 */
131 131
 	public function get_content_type() {
132
-		if ( ! $this->content_type && $this->html ) {
133
-			$this->content_type = apply_filters( 'give_email_default_content_type', 'text/html', $this );
134
-		} else if ( ! $this->html ) {
132
+		if ( ! $this->content_type && $this->html) {
133
+			$this->content_type = apply_filters('give_email_default_content_type', 'text/html', $this);
134
+		} else if ( ! $this->html) {
135 135
 			$this->content_type = 'text/plain';
136 136
 		}
137 137
 
138
-		return apply_filters( 'give_email_content_type', $this->content_type, $this );
138
+		return apply_filters('give_email_content_type', $this->content_type, $this);
139 139
 	}
140 140
 
141 141
 	/**
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
 	 * @since 1.0
145 145
 	 */
146 146
 	public function get_headers() {
147
-		if ( ! $this->headers ) {
147
+		if ( ! $this->headers) {
148 148
 			$this->headers = "From: {$this->get_from_name()} <{$this->get_from_address()}>\r\n";
149 149
 			$this->headers .= "Reply-To: {$this->get_from_address()}\r\n";
150 150
 			$this->headers .= "Content-Type: {$this->get_content_type()}; charset=utf-8\r\n";
151 151
 		}
152 152
 
153
-		return apply_filters( 'give_email_headers', $this->headers, $this );
153
+		return apply_filters('give_email_headers', $this->headers, $this);
154 154
 	}
155 155
 
156 156
 	/**
@@ -160,11 +160,11 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	public function get_templates() {
162 162
 		$templates = array(
163
-			'default' => esc_html__( 'Default Template', 'give' ),
164
-			'none'    => esc_html__( 'No template, plain text only', 'give' )
163
+			'default' => esc_html__('Default Template', 'give'),
164
+			'none'    => esc_html__('No template, plain text only', 'give')
165 165
 		);
166 166
 
167
-		return apply_filters( 'give_email_templates', $templates );
167
+		return apply_filters('give_email_templates', $templates);
168 168
 	}
169 169
 
170 170
 	/**
@@ -173,11 +173,11 @@  discard block
 block discarded – undo
173 173
 	 * @since 1.0
174 174
 	 */
175 175
 	public function get_template() {
176
-		if ( ! $this->template ) {
177
-			$this->template = give_get_option( 'email_template', 'default' );
176
+		if ( ! $this->template) {
177
+			$this->template = give_get_option('email_template', 'default');
178 178
 		}
179 179
 
180
-		return apply_filters( 'give_email_template', $this->template );
180
+		return apply_filters('give_email_template', $this->template);
181 181
 	}
182 182
 
183 183
 	/**
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	 * @since 1.0
187 187
 	 */
188 188
 	public function get_heading() {
189
-		return apply_filters( 'give_email_heading', $this->heading );
189
+		return apply_filters('give_email_heading', $this->heading);
190 190
 	}
191 191
 
192 192
 	/**
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	 *
197 197
 	 * @return mixed
198 198
 	 */
199
-	public function parse_tags( $content ) {
199
+	public function parse_tags($content) {
200 200
 		return $content;
201 201
 	}
202 202
 
@@ -205,19 +205,19 @@  discard block
 block discarded – undo
205 205
 	 *
206 206
 	 * @since 1.0
207 207
 	 */
208
-	public function build_email( $message ) {
208
+	public function build_email($message) {
209 209
 
210
-		if ( false === $this->html ) {
211
-			return apply_filters( 'give_email_message', wp_strip_all_tags( $message ), $this );
210
+		if (false === $this->html) {
211
+			return apply_filters('give_email_message', wp_strip_all_tags($message), $this);
212 212
 		}
213 213
 
214
-		$message = $this->text_to_html( $message );
214
+		$message = $this->text_to_html($message);
215 215
 
216 216
 		$template = $this->get_template();
217 217
 
218 218
 		ob_start();
219 219
 
220
-		give_get_template_part( 'emails/header', $template, true );
220
+		give_get_template_part('emails/header', $template, true);
221 221
 
222 222
 		/**
223 223
 		 * Fires in the email head.
@@ -226,17 +226,17 @@  discard block
 block discarded – undo
226 226
 		 *
227 227
 		 * @param Give_Emails $this The email object.
228 228
 		 */
229
-		do_action( 'give_email_header', $this );
229
+		do_action('give_email_header', $this);
230 230
 
231
-		if ( has_action( 'give_email_template_' . $template ) ) {
231
+		if (has_action('give_email_template_'.$template)) {
232 232
 			/**
233 233
 			 * Fires in a specific email template.
234 234
 			 *
235 235
 			 * @since 1.0
236 236
 			 */
237
-			do_action( "give_email_template_{$template}" );
237
+			do_action("give_email_template_{$template}");
238 238
 		} else {
239
-			give_get_template_part( 'emails/body', $template, true );
239
+			give_get_template_part('emails/body', $template, true);
240 240
 		}
241 241
 
242 242
 		/**
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
 		 *
247 247
 		 * @param Give_Emails $this The email object.
248 248
 		 */
249
-		do_action( 'give_email_body', $this );
249
+		do_action('give_email_body', $this);
250 250
 
251
-		give_get_template_part( 'emails/footer', $template, true );
251
+		give_get_template_part('emails/footer', $template, true);
252 252
 
253 253
 		/**
254 254
 		 * Fires in the email footer.
@@ -257,12 +257,12 @@  discard block
 block discarded – undo
257 257
 		 *
258 258
 		 * @param Give_Emails $this The email object.
259 259
 		 */
260
-		do_action( 'give_email_footer', $this );
260
+		do_action('give_email_footer', $this);
261 261
 
262 262
 		$body    = ob_get_clean();
263
-		$message = str_replace( '{email}', $message, $body );
263
+		$message = str_replace('{email}', $message, $body);
264 264
 
265
-		return apply_filters( 'give_email_message', $message, $this );
265
+		return apply_filters('give_email_message', $message, $this);
266 266
 	}
267 267
 
268 268
 	/**
@@ -275,10 +275,10 @@  discard block
 block discarded – undo
275 275
 	 *
276 276
 	 * @return bool
277 277
 	 */
278
-	public function send( $to, $subject, $message, $attachments = '' ) {
278
+	public function send($to, $subject, $message, $attachments = '') {
279 279
 
280
-		if ( ! did_action( 'init' ) && ! did_action( 'admin_init' ) ) {
281
-			_doing_it_wrong( __FUNCTION__, esc_html__( 'You cannot send email with Give_Emails until init/admin_init has been reached.', 'give' ), null );
280
+		if ( ! did_action('init') && ! did_action('admin_init')) {
281
+			_doing_it_wrong(__FUNCTION__, esc_html__('You cannot send email with Give_Emails until init/admin_init has been reached.', 'give'), null);
282 282
 
283 283
 			return false;
284 284
 		}
@@ -290,16 +290,16 @@  discard block
 block discarded – undo
290 290
 		 *
291 291
 		 * @param Give_Emails $this The email object.
292 292
 		 */
293
-		do_action( 'give_email_send_before', $this );
293
+		do_action('give_email_send_before', $this);
294 294
 
295
-		$subject = $this->parse_tags( $subject );
296
-		$message = $this->parse_tags( $message );
295
+		$subject = $this->parse_tags($subject);
296
+		$message = $this->parse_tags($message);
297 297
 
298
-		$message = $this->build_email( $message );
298
+		$message = $this->build_email($message);
299 299
 
300
-		$attachments = apply_filters( 'give_email_attachments', $attachments, $this );
300
+		$attachments = apply_filters('give_email_attachments', $attachments, $this);
301 301
 
302
-		$sent = wp_mail( $to, $subject, $message, $this->get_headers(), $attachments );
302
+		$sent = wp_mail($to, $subject, $message, $this->get_headers(), $attachments);
303 303
 
304 304
 		/**
305 305
 		 * Fires after sending an email.
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 		 *
309 309
 		 * @param Give_Emails $this The email object.
310 310
 		 */
311
-		do_action( 'give_email_send_after', $this );
311
+		do_action('give_email_send_after', $this);
312 312
 
313 313
 		return $sent;
314 314
 
@@ -320,9 +320,9 @@  discard block
 block discarded – undo
320 320
 	 * @since 1.0
321 321
 	 */
322 322
 	public function send_before() {
323
-		add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
324
-		add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
325
-		add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );
323
+		add_filter('wp_mail_from', array($this, 'get_from_address'));
324
+		add_filter('wp_mail_from_name', array($this, 'get_from_name'));
325
+		add_filter('wp_mail_content_type', array($this, 'get_content_type'));
326 326
 	}
327 327
 
328 328
 	/**
@@ -331,9 +331,9 @@  discard block
 block discarded – undo
331 331
 	 * @since 1.0
332 332
 	 */
333 333
 	public function send_after() {
334
-		remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
335
-		remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
336
-		remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );
334
+		remove_filter('wp_mail_from', array($this, 'get_from_address'));
335
+		remove_filter('wp_mail_from_name', array($this, 'get_from_name'));
336
+		remove_filter('wp_mail_content_type', array($this, 'get_content_type'));
337 337
 
338 338
 		// Reset heading to an empty string
339 339
 		$this->heading = '';
@@ -344,10 +344,10 @@  discard block
 block discarded – undo
344 344
 	 *
345 345
 	 * @since 1.0
346 346
 	 */
347
-	public function text_to_html( $message ) {
347
+	public function text_to_html($message) {
348 348
 
349
-		if ( 'text/html' == $this->content_type || true === $this->html ) {
350
-			$message = wpautop( $message );
349
+		if ('text/html' == $this->content_type || true === $this->html) {
350
+			$message = wpautop($message);
351 351
 		}
352 352
 
353 353
 		return $message;
Please login to merge, or discard this patch.
includes/class-give-license-handler.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 		 *
181 181
 		 * @access  private
182 182
 		 * @global  array $give_options
183
-		 * @return  bool
183
+		 * @return  false|null
184 184
 		 */
185 185
 		public function auto_updater() {
186 186
 
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
 		 * @since  1.7
768 768
 		 * @access private
769 769
 		 *
770
-		 * @return void|bool
770
+		 * @return false|null
771 771
 		 */
772 772
 		private function __remove_license_key_from_subscriptions(){
773 773
 			$subscriptions = get_option( 'give_subscriptions', array() );
Please login to merge, or discard this patch.
Spacing   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -8,11 +8,11 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 // Exit if accessed directly
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if ( ! defined('ABSPATH')) {
12 12
 	exit;
13 13
 }
14 14
 
15
-if ( ! class_exists( 'Give_License' ) ) :
15
+if ( ! class_exists('Give_License')) :
16 16
 
17 17
 	/**
18 18
 	 * Give_License Class
@@ -108,19 +108,19 @@  discard block
 block discarded – undo
108 108
 		 * @param string  $_checkout_url
109 109
 		 * @param string  $_account_url
110 110
 		 */
111
-		public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null ) {
111
+		public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null) {
112 112
 			global $give_options;
113 113
 
114 114
 			$this->file           = $_file;
115 115
 			$this->item_name      = $_item_name;
116
-			$this->item_shortname = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) );
116
+			$this->item_shortname = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name)));
117 117
 			$this->version        = $_version;
118
-			$this->license        = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : '';
119
-			$this->license_data   = get_option( $this->item_shortname . '_license_active' );
118
+			$this->license        = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : '';
119
+			$this->license_data   = get_option($this->item_shortname.'_license_active');
120 120
 			$this->author         = $_author;
121
-			$this->api_url        = is_null( $_api_url ) ? $this->api_url : $_api_url;
122
-			$this->checkout_url   = is_null( $_checkout_url ) ? $this->checkout_url : $_checkout_url;
123
-			$this->account_url    = is_null( $_account_url ) ? $this->account_url : $_account_url;
121
+			$this->api_url        = is_null($_api_url) ? $this->api_url : $_api_url;
122
+			$this->checkout_url   = is_null($_checkout_url) ? $this->checkout_url : $_checkout_url;
123
+			$this->account_url    = is_null($_account_url) ? $this->account_url : $_account_url;
124 124
 
125 125
 			// Setup hooks
126 126
 			$this->includes();
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 		 * @return void
139 139
 		 */
140 140
 		private function includes() {
141
-			if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) {
141
+			if ( ! class_exists('EDD_SL_Plugin_Updater')) {
142 142
 				require_once 'admin/EDD_SL_Plugin_Updater.php';
143 143
 			}
144 144
 		}
@@ -155,24 +155,24 @@  discard block
 block discarded – undo
155 155
 		private function hooks() {
156 156
 
157 157
 			// Register settings
158
-			add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 );
158
+			add_filter('give_settings_licenses', array($this, 'settings'), 1);
159 159
 
160 160
 			// Activate license key on settings save
161
-			add_action( 'admin_init', array( $this, 'activate_license' ) );
161
+			add_action('admin_init', array($this, 'activate_license'));
162 162
 
163 163
 			// Deactivate license key
164
-			add_action( 'admin_init', array( $this, 'deactivate_license' ) );
164
+			add_action('admin_init', array($this, 'deactivate_license'));
165 165
 
166 166
 			// Updater
167
-			add_action( 'admin_init', array( $this, 'auto_updater' ), 0 );
167
+			add_action('admin_init', array($this, 'auto_updater'), 0);
168 168
 
169
-			add_action( 'admin_notices', array( $this, 'notices' ) );
169
+			add_action('admin_notices', array($this, 'notices'));
170 170
 
171 171
 			// Check license weekly.
172
-			add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_license_check' ) );
172
+			add_action('give_weekly_scheduled_events', array($this, 'weekly_license_check'));
173 173
 
174 174
 			// Check subscription weekly.
175
-			add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_subscription_check' ) );
175
+			add_action('give_weekly_scheduled_events', array($this, 'weekly_subscription_check'));
176 176
 		}
177 177
 
178 178
 		/**
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 		 */
185 185
 		public function auto_updater() {
186 186
 
187
-			if ( ! $this->is_valid_license() ) {
187
+			if ( ! $this->is_valid_license()) {
188 188
 				return false;
189 189
 			}
190 190
 
@@ -212,16 +212,16 @@  discard block
 block discarded – undo
212 212
 		 *
213 213
 		 * @return array           License settings.
214 214
 		 */
215
-		public function settings( $settings ) {
215
+		public function settings($settings) {
216 216
 
217 217
 			$give_license_settings = array(
218 218
 				array(
219 219
 					'name'    => $this->item_name,
220
-					'id'      => $this->item_shortname . '_license_key',
220
+					'id'      => $this->item_shortname.'_license_key',
221 221
 					'desc'    => '',
222 222
 					'type'    => 'license_key',
223 223
 					'options' => array(
224
-						'license'       => get_option( $this->item_shortname . '_license_active' ),
224
+						'license'       => get_option($this->item_shortname.'_license_active'),
225 225
 						'shortname'     => $this->item_shortname,
226 226
 						'item_name'     => $this->item_name,
227 227
 						'api_url'       => $this->api_url,
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 				)
233 233
 			);
234 234
 
235
-			return array_merge( $settings, $give_license_settings );
235
+			return array_merge($settings, $give_license_settings);
236 236
 		}
237 237
 
238 238
 		/**
@@ -246,18 +246,18 @@  discard block
 block discarded – undo
246 246
 		 *
247 247
 		 * @return array           License settings content.
248 248
 		 */
249
-		public function license_settings_content( $settings ) {
249
+		public function license_settings_content($settings) {
250 250
 
251 251
 			$give_license_settings = array(
252 252
 				array(
253
-					'name' => esc_html__( 'Add-on Licenses', 'give' ),
253
+					'name' => esc_html__('Add-on Licenses', 'give'),
254 254
 					'desc' => '<hr>',
255 255
 					'type' => 'give_title',
256 256
 					'id'   => 'give_title'
257 257
 				),
258 258
 			);
259 259
 
260
-			return array_merge( $settings, $give_license_settings );
260
+			return array_merge($settings, $give_license_settings);
261 261
 		}
262 262
 
263 263
 		/**
@@ -271,37 +271,37 @@  discard block
 block discarded – undo
271 271
 		 */
272 272
 		public function activate_license() {
273 273
 			// Bailout: Check if license key set of not.
274
-			if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
274
+			if ( ! isset($_POST[$this->item_shortname.'_license_key'])) {
275 275
 				return;
276 276
 			}
277 277
 
278 278
 			// Security check.
279
-			if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) {
279
+			if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) {
280 280
 
281
-				wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
281
+				wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
282 282
 
283 283
 			}
284 284
 
285 285
 			// Check if user have correct permissions.
286
-			if ( ! current_user_can( 'manage_give_settings' ) ) {
286
+			if ( ! current_user_can('manage_give_settings')) {
287 287
 				return;
288 288
 			}
289 289
 
290 290
 			// Allow third party addon developers to handle license activation.
291
-			if( $this->__is_third_party_addon() ){
292
-				do_action( 'give_activate_license', $this );
291
+			if ($this->__is_third_party_addon()) {
292
+				do_action('give_activate_license', $this);
293 293
 				return;
294 294
 			}
295 295
 
296 296
 			// Delete previous license setting if a empty license key submitted.
297
-			if ( empty( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
298
-				delete_option( $this->item_shortname . '_license_active' );
297
+			if (empty($_POST[$this->item_shortname.'_license_key'])) {
298
+				delete_option($this->item_shortname.'_license_active');
299 299
 				return;
300 300
 			}
301 301
 
302 302
 			// Do not simultaneously activate any addon if user want to deactivate any addon.
303
-			foreach ( $_POST as $key => $value ) {
304
-				if ( false !== strpos( $key, 'license_key_deactivate' ) ) {
303
+			foreach ($_POST as $key => $value) {
304
+				if (false !== strpos($key, 'license_key_deactivate')) {
305 305
 					// Don't activate a key when deactivating a different key
306 306
 					return;
307 307
 				}
@@ -309,15 +309,15 @@  discard block
 block discarded – undo
309 309
 
310 310
 
311 311
 			// Check if plugin previously installed.
312
-			if ( $this->is_valid_license() ) {
312
+			if ($this->is_valid_license()) {
313 313
 				return;
314 314
 			}
315 315
 
316 316
 			// Get license key.
317
-			$license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] );
317
+			$license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']);
318 318
 
319 319
 			// Bailout.
320
-			if( empty( $license ) ) {
320
+			if (empty($license)) {
321 321
 				return;
322 322
 			}
323 323
 
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 			$api_params = array(
329 329
 				'edd_action' => 'activate_license', //never change from "edd_" to "give_"!
330 330
 				'license'    => $license,
331
-				'item_name'  => urlencode( $this->item_name ),
331
+				'item_name'  => urlencode($this->item_name),
332 332
 				'url'        => home_url()
333 333
 			);
334 334
 
@@ -343,16 +343,16 @@  discard block
 block discarded – undo
343 343
 			);
344 344
 
345 345
 			// Make sure there are no errors
346
-			if ( is_wp_error( $response ) ) {
346
+			if (is_wp_error($response)) {
347 347
 				return;
348 348
 			}
349 349
 
350 350
 			// Tell WordPress to look for updates
351
-			set_site_transient( 'update_plugins', null );
351
+			set_site_transient('update_plugins', null);
352 352
 
353 353
 			// Decode license data
354
-			$license_data = json_decode( wp_remote_retrieve_body( $response ) );
355
-			update_option( $this->item_shortname . '_license_active', $license_data );
354
+			$license_data = json_decode(wp_remote_retrieve_body($response));
355
+			update_option($this->item_shortname.'_license_active', $license_data);
356 356
 
357 357
 			// Check subscription for license key and store this to db (if any).
358 358
 			$this->__single_subscription_check();
@@ -369,34 +369,34 @@  discard block
 block discarded – undo
369 369
 		 */
370 370
 		public function deactivate_license() {
371 371
 
372
-			if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
372
+			if ( ! isset($_POST[$this->item_shortname.'_license_key'])) {
373 373
 				return;
374 374
 			}
375 375
 
376
-			if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) {
376
+			if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) {
377 377
 
378
-				wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
378
+				wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
379 379
 
380 380
 			}
381 381
 
382
-			if ( ! current_user_can( 'manage_give_settings' ) ) {
382
+			if ( ! current_user_can('manage_give_settings')) {
383 383
 				return;
384 384
 			}
385 385
 
386 386
 			// Allow third party addon developers to handle license deactivation.
387
-			if( $this->__is_third_party_addon() ){
388
-				do_action( 'give_deactivate_license', $this );
387
+			if ($this->__is_third_party_addon()) {
388
+				do_action('give_deactivate_license', $this);
389 389
 				return;
390 390
 			}
391 391
 
392 392
 			// Run on deactivate button press
393
-			if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) {
393
+			if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) {
394 394
 
395 395
 				// Data to send to the API
396 396
 				$api_params = array(
397 397
 					'edd_action' => 'deactivate_license', //never change from "edd_" to "give_"!
398 398
 					'license'    => $this->license,
399
-					'item_name'  => urlencode( $this->item_name ),
399
+					'item_name'  => urlencode($this->item_name),
400 400
 					'url'        => home_url()
401 401
 				);
402 402
 
@@ -412,16 +412,16 @@  discard block
 block discarded – undo
412 412
 
413 413
 
414 414
 				// Make sure there are no errors
415
-				if ( is_wp_error( $response ) ) {
415
+				if (is_wp_error($response)) {
416 416
 					return;
417 417
 				}
418 418
 
419 419
 				// Decode the license data
420
-				$license_data = json_decode( wp_remote_retrieve_body( $response ) );
420
+				$license_data = json_decode(wp_remote_retrieve_body($response));
421 421
 
422 422
 
423 423
 				// Remove license data.
424
-				delete_option( $this->item_shortname . '_license_active' );
424
+				delete_option($this->item_shortname.'_license_active');
425 425
 
426 426
 				// Remove license key from subscriptions if exist.
427 427
 				$this->__remove_license_key_from_subscriptions();
@@ -439,18 +439,18 @@  discard block
 block discarded – undo
439 439
 		 */
440 440
 		public function weekly_license_check() {
441 441
 
442
-			if( ! empty( $_POST['give_settings'] ) ) {
442
+			if ( ! empty($_POST['give_settings'])) {
443 443
 				// Don't fire when saving settings
444 444
 				return false;
445 445
 			}
446 446
 
447
-			if( empty( $this->license ) ) {
447
+			if (empty($this->license)) {
448 448
 				return false;
449 449
 			}
450 450
 
451 451
 			// Allow third party addon developers to handle there license check.
452
-			if( $this->__is_third_party_addon() ){
453
-				do_action( 'give_weekly_license_check', $this );
452
+			if ($this->__is_third_party_addon()) {
453
+				do_action('give_weekly_license_check', $this);
454 454
 				return false;
455 455
 			}
456 456
 
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
 			$api_params = array(
459 459
 				'edd_action'=> 'check_license',
460 460
 				'license' 	=> $this->license,
461
-				'item_name' => urlencode( $this->item_name ),
461
+				'item_name' => urlencode($this->item_name),
462 462
 				'url'       => home_url()
463 463
 			);
464 464
 
@@ -473,12 +473,12 @@  discard block
 block discarded – undo
473 473
 			);
474 474
 
475 475
 			// Make sure the response came back okay.
476
-			if ( is_wp_error( $response ) ) {
476
+			if (is_wp_error($response)) {
477 477
 				return false;
478 478
 			}
479 479
 
480
-			$license_data = json_decode( wp_remote_retrieve_body( $response ) );
481
-			update_option( $this->item_shortname . '_license_active', $license_data );
480
+			$license_data = json_decode(wp_remote_retrieve_body($response));
481
+			update_option($this->item_shortname.'_license_active', $license_data);
482 482
 		}
483 483
 
484 484
 
@@ -492,24 +492,24 @@  discard block
 block discarded – undo
492 492
 		 */
493 493
 		public function weekly_subscription_check() {
494 494
 
495
-			if( ! empty( $_POST['give_settings'] ) ) {
495
+			if ( ! empty($_POST['give_settings'])) {
496 496
 				// Don't fire when saving settings
497 497
 				return false;
498 498
 			}
499 499
 
500 500
 			// Remove old subscription data.
501
-			if( absint( get_option( '_give_subscriptions_edit_last', true ) ) < current_time( 'timestamp' , 1 ) ){
502
-				delete_option( 'give_subscriptions' );
503
-				update_option( '_give_subscriptions_edit_last', strtotime( '+ 1 day', current_time( 'timestamp' , 1 ) ) );
501
+			if (absint(get_option('_give_subscriptions_edit_last', true)) < current_time('timestamp', 1)) {
502
+				delete_option('give_subscriptions');
503
+				update_option('_give_subscriptions_edit_last', strtotime('+ 1 day', current_time('timestamp', 1)));
504 504
 			}
505 505
 
506
-			if( empty( $this->license ) ) {
506
+			if (empty($this->license)) {
507 507
 				return false;
508 508
 			}
509 509
 
510 510
 			// Allow third party addon developers to handle there subscription check.
511
-			if( $this->__is_third_party_addon() ){
512
-				do_action( 'give_weekly_subscription_check', $this );
511
+			if ($this->__is_third_party_addon()) {
512
+				do_action('give_weekly_subscription_check', $this);
513 513
 				return false;
514 514
 			}
515 515
 
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 				// This is custom feature to check subscriptions.
524 524
 				'edd_action'=> 'check_subscription',
525 525
 				'license' 	=> $this->license,
526
-				'item_name' => urlencode( $this->item_name ),
526
+				'item_name' => urlencode($this->item_name),
527 527
 				'url'       => home_url()
528 528
 			);
529 529
 
@@ -538,27 +538,27 @@  discard block
 block discarded – undo
538 538
 			);
539 539
 
540 540
 			// Make sure the response came back okay.
541
-			if ( is_wp_error( $response ) ) {
541
+			if (is_wp_error($response)) {
542 542
 				return false;
543 543
 			}
544 544
 
545
-			$subscription_data = json_decode( wp_remote_retrieve_body( $response ), true );
545
+			$subscription_data = json_decode(wp_remote_retrieve_body($response), true);
546 546
 
547
-			if( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) {
548
-				$subscriptions = get_option( 'give_subscriptions', array() );
547
+			if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) {
548
+				$subscriptions = get_option('give_subscriptions', array());
549 549
 
550 550
 				// Update subscription data only if subscription does not exist already.
551
-				if( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) {
552
-					$subscriptions[ $subscription_data['id'] ] = $subscription_data;
553
-					$subscriptions[ $subscription_data['id'] ]['licenses'] = array();
551
+				if ( ! array_key_exists($subscription_data['id'], $subscriptions)) {
552
+					$subscriptions[$subscription_data['id']] = $subscription_data;
553
+					$subscriptions[$subscription_data['id']]['licenses'] = array();
554 554
 				}
555 555
 
556 556
 				// Store licenses for subscription.
557
-				if( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
558
-					$subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license;
557
+				if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) {
558
+					$subscriptions[$subscription_data['id']]['licenses'][] = $this->license;
559 559
 				}
560 560
 
561
-				update_option( 'give_subscriptions', $subscriptions );
561
+				update_option('give_subscriptions', $subscriptions);
562 562
 			}
563 563
 		}
564 564
 
@@ -573,11 +573,11 @@  discard block
 block discarded – undo
573 573
 		 */
574 574
 		private function __single_subscription_check() {
575 575
 			// Do not fire if license key is not set.
576
-			if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
576
+			if ( ! isset($_POST[$this->item_shortname.'_license_key'])) {
577 577
 				return false;
578 578
 			}
579 579
 
580
-			if( empty( $this->license ) ) {
580
+			if (empty($this->license)) {
581 581
 				return false;
582 582
 			}
583 583
 
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
 				// This is custom feature to check subscriptions.
589 589
 				'edd_action'=> 'check_subscription',
590 590
 				'license' 	=> $this->license,
591
-				'item_name' => urlencode( $this->item_name ),
591
+				'item_name' => urlencode($this->item_name),
592 592
 				'url'       => home_url()
593 593
 			);
594 594
 
@@ -603,27 +603,27 @@  discard block
 block discarded – undo
603 603
 			);
604 604
 
605 605
 			// Make sure the response came back okay.
606
-			if ( is_wp_error( $response ) ) {
606
+			if (is_wp_error($response)) {
607 607
 				return false;
608 608
 			}
609 609
 
610
-			$subscription_data = json_decode( wp_remote_retrieve_body( $response ), true );
610
+			$subscription_data = json_decode(wp_remote_retrieve_body($response), true);
611 611
 
612
-			if( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) {
613
-				$subscriptions = get_option( 'give_subscriptions', array() );
612
+			if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) {
613
+				$subscriptions = get_option('give_subscriptions', array());
614 614
 
615 615
 				// Update subscription data only if subscription does not exist already.
616
-				if( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) {
617
-					$subscriptions[ $subscription_data['id'] ] = $subscription_data;
618
-					$subscriptions[ $subscription_data['id'] ]['licenses'] = array();
616
+				if ( ! array_key_exists($subscription_data['id'], $subscriptions)) {
617
+					$subscriptions[$subscription_data['id']] = $subscription_data;
618
+					$subscriptions[$subscription_data['id']]['licenses'] = array();
619 619
 				}
620 620
 
621 621
 				// Store licenses for subscription.
622
-				if( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
623
-					$subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license;
622
+				if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) {
623
+					$subscriptions[$subscription_data['id']]['licenses'][] = $this->license;
624 624
 				}
625 625
 
626
-				update_option( 'give_subscriptions', $subscriptions );
626
+				update_option('give_subscriptions', $subscriptions);
627 627
 			}
628 628
 		}
629 629
 
@@ -641,89 +641,89 @@  discard block
 block discarded – undo
641 641
 			static $addon_license_key_in_subscriptions;
642 642
 
643 643
 			// Set default value.
644
-			$addon_license_key_in_subscriptions = ! empty( $addon_license_key_in_subscriptions ) ? $addon_license_key_in_subscriptions : array();
644
+			$addon_license_key_in_subscriptions = ! empty($addon_license_key_in_subscriptions) ? $addon_license_key_in_subscriptions : array();
645 645
 
646
-			if( empty( $this->license ) ) {
646
+			if (empty($this->license)) {
647 647
 				return;
648 648
 			}
649 649
 
650
-			if( ! current_user_can( 'manage_shop_settings' ) ) {
650
+			if ( ! current_user_can('manage_shop_settings')) {
651 651
 				return;
652 652
 			}
653 653
 
654 654
 			// Do not show licenses notices on license tab.
655
-			if( ! empty( $_GET['tab'] ) && 'licenses' === $_GET['tab'] ) {
655
+			if ( ! empty($_GET['tab']) && 'licenses' === $_GET['tab']) {
656 656
 				return;
657 657
 			}
658 658
 
659 659
 			$messages = array();
660 660
 
661 661
 			// Get subscriptions.
662
-			$subscriptions = get_option( 'give_subscriptions' );
662
+			$subscriptions = get_option('give_subscriptions');
663 663
 
664 664
 
665 665
 			// Show subscription messages.
666
-			if( ! empty( $subscriptions ) && ! $showed_subscriptions_message ) {
666
+			if ( ! empty($subscriptions) && ! $showed_subscriptions_message) {
667 667
 
668
-				foreach ( $subscriptions as $subscription ) {
668
+				foreach ($subscriptions as $subscription) {
669 669
 					// Subscription expires timestamp.
670
-					$subscription_expires = strtotime( $subscription['expires'] );
670
+					$subscription_expires = strtotime($subscription['expires']);
671 671
 
672 672
 					// Start showing subscriptions message before one week of renewal date.
673
-					if( strtotime( '- 7 days', $subscription_expires ) > current_time( 'timestamp', 1 ) ) {
673
+					if (strtotime('- 7 days', $subscription_expires) > current_time('timestamp', 1)) {
674 674
 						continue;
675 675
 					}
676 676
 
677 677
 					// Check if subscription message already exist in messages.
678
-					if( array_key_exists( $subscription['id'], $messages ) ) {
678
+					if (array_key_exists($subscription['id'], $messages)) {
679 679
 						continue;
680 680
 					}
681 681
 
682
-					if( ( ! $this->__is_notice_dismissed( $subscription['id'] ) && 'active' !== $subscription['status'] ) ) {
682
+					if (( ! $this->__is_notice_dismissed($subscription['id']) && 'active' !== $subscription['status'])) {
683 683
 
684
-						if( strtotime( $subscription['expires'] ) < current_time( 'timestamp', 1 ) ) {// Check if license already expired.
684
+						if (strtotime($subscription['expires']) < current_time('timestamp', 1)) {// Check if license already expired.
685 685
 							$messages[$subscription['id']] = sprintf(
686
-								__( 'You Give addon license expired for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ),
687
-								urldecode( $subscription['invoice_url'] ),
686
+								__('You Give addon license expired for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give'),
687
+								urldecode($subscription['invoice_url']),
688 688
 								$subscription['payment_id'],
689 689
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
690
-								esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) )
690
+								esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI']))
691 691
 							);
692
-						}else{
692
+						} else {
693 693
 							$messages[$subscription['id']] = sprintf(
694
-								__( 'You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ),
695
-								human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ),
696
-								urldecode( $subscription['invoice_url'] ),
694
+								__('You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give'),
695
+								human_time_diff(current_time('timestamp', 1), strtotime($subscription['expires'])),
696
+								urldecode($subscription['invoice_url']),
697 697
 								$subscription['payment_id'],
698 698
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
699
-								esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) )
699
+								esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI']))
700 700
 							);
701 701
 						}
702 702
 					}
703 703
 
704 704
 					// Stop validation for these licencse keys.
705
-					$addon_license_key_in_subscriptions = array_merge( $addon_license_key_in_subscriptions, $subscription['licenses'] );
705
+					$addon_license_key_in_subscriptions = array_merge($addon_license_key_in_subscriptions, $subscription['licenses']);
706 706
 				}
707 707
 				$showed_subscriptions_message = true;
708 708
 			}
709 709
 
710 710
 
711 711
 			// Show non subscription addon messages.
712
-			if( ! in_array( $this->license, $addon_license_key_in_subscriptions ) && ! $this->__is_notice_dismissed( 'general' ) && ! $this->is_valid_license() && empty( $showed_invalid_message ) ) {
712
+			if ( ! in_array($this->license, $addon_license_key_in_subscriptions) && ! $this->__is_notice_dismissed('general') && ! $this->is_valid_license() && empty($showed_invalid_message)) {
713 713
 
714 714
 				$messages['general'] = sprintf(
715
-					__( 'You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">Licenses page</a> to correct this issue.', 'give' ),
716
-					admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' )
715
+					__('You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">Licenses page</a> to correct this issue.', 'give'),
716
+					admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')
717 717
 				);
718 718
 				$showed_invalid_message = true;
719 719
 
720 720
 			}
721 721
 
722 722
 			// Print messages.
723
-			if( ! empty( $messages ) ) {
724
-				foreach( $messages as $notice_id => $message ) {
725
-					echo '<div class="notice notice-error is-dismissible give-license-notice" data-dismiss-notice-shortly="' . esc_url( add_query_arg( '_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'] ) ) . '">';
726
-					echo '<p>' . $message . '</p>';
723
+			if ( ! empty($messages)) {
724
+				foreach ($messages as $notice_id => $message) {
725
+					echo '<div class="notice notice-error is-dismissible give-license-notice" data-dismiss-notice-shortly="'.esc_url(add_query_arg('_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'])).'">';
726
+					echo '<p>'.$message.'</p>';
727 727
 					echo '</div>';
728 728
 				}
729 729
 			}
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 		 * @return bool
739 739
 		 */
740 740
 		public function is_valid_license() {
741
-			if( apply_filters( 'give_is_valid_license' , ( is_object( $this->license_data ) && ! empty( $this->license_data ) &&  property_exists( $this->license_data, 'license' )&& 'valid' === $this->license_data->license ) ) ) {
741
+			if (apply_filters('give_is_valid_license', (is_object($this->license_data) && ! empty($this->license_data) && property_exists($this->license_data, 'license') && 'valid' === $this->license_data->license))) {
742 742
 				return true;
743 743
 			}
744 744
 
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 		 * @return bool
755 755
 		 */
756 756
 		private function __is_third_party_addon() {
757
-			return ( false === strpos( $this->api_url, 'givewp.com/' ) );
757
+			return (false === strpos($this->api_url, 'givewp.com/'));
758 758
 		}
759 759
 
760 760
 
@@ -769,26 +769,26 @@  discard block
 block discarded – undo
769 769
 		 *
770 770
 		 * @return void|bool
771 771
 		 */
772
-		private function __remove_license_key_from_subscriptions(){
773
-			$subscriptions = get_option( 'give_subscriptions', array() );
772
+		private function __remove_license_key_from_subscriptions() {
773
+			$subscriptions = get_option('give_subscriptions', array());
774 774
 
775 775
 			// Bailout.
776
-			if( empty( $this->license ) ) {
776
+			if (empty($this->license)) {
777 777
 				return false;
778 778
 			}
779 779
 
780
-			if( ! empty( $subscriptions ) ) {
781
-				foreach ( $subscriptions as $subscription_id => $subscription ) {
782
-					$license_index = array_search( $this->license, $subscription['licenses'] );
783
-					if( false !== $license_index ) {
780
+			if ( ! empty($subscriptions)) {
781
+				foreach ($subscriptions as $subscription_id => $subscription) {
782
+					$license_index = array_search($this->license, $subscription['licenses']);
783
+					if (false !== $license_index) {
784 784
 						// Remove license key.
785
-						unset( $subscriptions[ $subscription_id ]['licenses'][$license_index] );
785
+						unset($subscriptions[$subscription_id]['licenses'][$license_index]);
786 786
 
787 787
 						// Rearrange license keys.
788
-						$subscriptions[ $subscription_id ]['licenses'] = array_values( $subscriptions[ $subscription_id ]['licenses'] );
788
+						$subscriptions[$subscription_id]['licenses'] = array_values($subscriptions[$subscription_id]['licenses']);
789 789
 
790 790
 						// Update subscription information.
791
-						update_option( 'give_subscriptions', $subscriptions );
791
+						update_option('give_subscriptions', $subscriptions);
792 792
 						break;
793 793
 					}
794 794
 				}
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
 		 *
804 804
 		 * @return void
805 805
 		 */
806
-		private function __remove_license_notices_show_blocker(){
806
+		private function __remove_license_notices_show_blocker() {
807 807
 			global $wpdb;
808 808
 
809 809
 			// Delete permanent notice blocker.
@@ -841,18 +841,18 @@  discard block
 block discarded – undo
841 841
 		 *
842 842
 		 * @return bool
843 843
 		 */
844
-		private function __is_notice_dismissed( $notice_id ){
844
+		private function __is_notice_dismissed($notice_id) {
845 845
 			global $current_user;
846 846
 			$is_notice_dismissed = false;
847 847
 
848 848
 			// Ge is notice dismissed permanently.
849
-			$already_dismiss_notices = ( $already_dismiss_notices = get_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', true ) )
849
+			$already_dismiss_notices = ($already_dismiss_notices = get_user_meta($current_user->ID, '_give_hide_license_notices_permanently', true))
850 850
 				? $already_dismiss_notices
851 851
 				: array();
852 852
 
853 853
 
854
-			if( in_array( $notice_id, $already_dismiss_notices ) || get_transient( "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}" ) ) {
855
-				$is_notice_dismissed =  true;
854
+			if (in_array($notice_id, $already_dismiss_notices) || get_transient("_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}")) {
855
+				$is_notice_dismissed = true;
856 856
 			}
857 857
 
858 858
 			return $is_notice_dismissed;
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -689,7 +689,7 @@
 block discarded – undo
689 689
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
690 690
 								esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) )
691 691
 							);
692
-						}else{
692
+						} else{
693 693
 							$messages[$subscription['id']] = sprintf(
694 694
 								__( 'You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ),
695 695
 								human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ),
Please login to merge, or discard this patch.
includes/formatting.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
  * @param $field_args
226 226
  * @param $field
227 227
  *
228
- * @return bool
228
+ * @return false|null
229 229
  */
230 230
 function give_format_admin_multilevel_amount( $field_args, $field ) {
231 231
 
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
  * @param   array  $field_args
376 376
  * @param   object $field
377 377
  *
378
- * @return mixed
378
+ * @return string
379 379
  */
380 380
 function give_sanitize_thousand_separator( $value, $field_args, $field ){
381 381
     return stripslashes( $value );
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
  * @param   array  $field_args
409 409
  * @param   object $field
410 410
  *
411
- * @return  mixed
411
+ * @return  string
412 412
  */
413 413
 function give_sanitize_price_field_value( $value, $field_args, $field ){
414 414
     return give_sanitize_amount( $value );
Please login to merge, or discard this patch.
Spacing   +98 added lines, -98 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
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * @return mixed
24 24
  */
25 25
 function give_get_price_decimals() {
26
-    return apply_filters( 'give_sanitize_amount_decimals', give_get_option( 'number_decimals', 0 ) );
26
+    return apply_filters('give_sanitize_amount_decimals', give_get_option('number_decimals', 0));
27 27
 }
28 28
 
29 29
 /**
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
  * @return mixed
35 35
  */
36 36
 function give_get_price_thousand_separator() {
37
-    return give_get_option( 'thousands_separator', ',' );
37
+    return give_get_option('thousands_separator', ',');
38 38
 }
39 39
 
40 40
 /**
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
  * @return mixed
46 46
  */
47 47
 function give_get_price_decimal_separator() {
48
-    return give_get_option( 'decimal_separator', '.' );
48
+    return give_get_option('decimal_separator', '.');
49 49
 }
50 50
 
51 51
 /**
@@ -62,67 +62,67 @@  discard block
 block discarded – undo
62 62
  *
63 63
  * @return string $amount Newly sanitized amount
64 64
  */
65
-function give_sanitize_amount( $number, $dp = false, $trim_zeros = false ) {
65
+function give_sanitize_amount($number, $dp = false, $trim_zeros = false) {
66 66
 
67 67
     // Bailout.
68
-    if( empty( $number ) ) {
68
+    if (empty($number)) {
69 69
         return $number;
70 70
     }
71 71
 
72 72
 	// Remove slash from amount.
73 73
 	// If thousand or decimal separator is set to ' then in $_POST or $_GET param we will get an escaped number.
74 74
 	// To prevent notices and warning remove slash from amount/number.
75
-	$number = wp_unslash( $number );
75
+	$number = wp_unslash($number);
76 76
 
77 77
     $thousand_separator = give_get_price_thousand_separator();
78 78
 
79 79
     $locale   = localeconv();
80
-    $decimals = array( give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point'] );
80
+    $decimals = array(give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point']);
81 81
 
82 82
     // Remove locale from string
83
-    if ( ! is_float( $number ) ) {
84
-        $number = str_replace( $decimals, '.', $number );
83
+    if ( ! is_float($number)) {
84
+        $number = str_replace($decimals, '.', $number);
85 85
     }
86 86
 
87 87
     // Remove thousand amount formatting if amount has.
88 88
     // This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db.
89 89
     // Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code.
90
-    if(  ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) {
91
-        $number = str_replace( $thousand_separator, '', $number );
92
-    } elseif ( in_array( $thousand_separator, $decimals ) ) {
93
-		$number = preg_replace( '/\.(?=.*\.)/', '', $number );
90
+    if ( ! in_array($thousand_separator, $decimals) && (false !== strpos($number, $thousand_separator))) {
91
+        $number = str_replace($thousand_separator, '', $number);
92
+    } elseif (in_array($thousand_separator, $decimals)) {
93
+		$number = preg_replace('/\.(?=.*\.)/', '', $number);
94 94
 	}
95 95
 
96 96
     // Remove non numeric entity before decimal separator.
97
-    $number     = preg_replace( '/[^0-9\.]/', '', $number );
97
+    $number     = preg_replace('/[^0-9\.]/', '', $number);
98 98
     $default_dp = give_get_price_decimals();
99 99
 
100 100
     // Format number of decimals in number.
101
-    if( false !== $dp ) {
102
-        $dp     = intval(  empty( $dp ) ? $default_dp : $dp );
103
-        $dp     = apply_filters( 'give_sanitize_amount_decimals', $dp, $number );
104
-        $number = number_format( floatval( $number ), $dp, '.', '' );
101
+    if (false !== $dp) {
102
+        $dp     = intval(empty($dp) ? $default_dp : $dp);
103
+        $dp     = apply_filters('give_sanitize_amount_decimals', $dp, $number);
104
+        $number = number_format(floatval($number), $dp, '.', '');
105 105
     }
106 106
 
107 107
     // Reset negative amount to zero.
108
-	if ( 0 > $number ) {
109
-		$number = number_format( 0, $default_dp, '.' );
108
+	if (0 > $number) {
109
+		$number = number_format(0, $default_dp, '.');
110 110
 	}
111 111
 
112 112
     // If number does not have decimal then add number of decimals to it.
113
-    if(
114
-        false === strpos( $number, '.' )
115
-        || ( $default_dp > strlen( substr( $number, strpos( $number , '.' ) + 1 ) ) )
113
+    if (
114
+        false === strpos($number, '.')
115
+        || ($default_dp > strlen(substr($number, strpos($number, '.') + 1)))
116 116
     ) {
117
-        $number = number_format( $number, $default_dp, '.', '' );
117
+        $number = number_format($number, $default_dp, '.', '');
118 118
     }
119 119
 
120 120
     // Trim zeros.
121
-    if ( $trim_zeros && strstr( $number, '.' ) ) {
122
-        $number = rtrim( rtrim( $number, '0' ), '.' );
121
+    if ($trim_zeros && strstr($number, '.')) {
122
+        $number = rtrim(rtrim($number, '0'), '.');
123 123
     }
124 124
 
125
-    return apply_filters( 'give_sanitize_amount', $number );
125
+    return apply_filters('give_sanitize_amount', $number);
126 126
 }
127 127
 
128 128
 /**
@@ -135,22 +135,22 @@  discard block
 block discarded – undo
135 135
  *
136 136
  * @return string $amount Newly formatted amount or Price Not Available
137 137
  */
138
-function give_format_amount( $amount, $decimals = true ) {
139
-	$thousands_sep = give_get_option( 'thousands_separator', ',' );
140
-	$decimal_sep   = give_get_option( 'decimal_separator', '.' );
138
+function give_format_amount($amount, $decimals = true) {
139
+	$thousands_sep = give_get_option('thousands_separator', ',');
140
+	$decimal_sep   = give_get_option('decimal_separator', '.');
141 141
 
142
-	if ( empty( $amount ) ) {
142
+	if (empty($amount)) {
143 143
 		$amount = 0;
144 144
 	} else {
145 145
 		// Sanitize amount before formatting.
146
-		$amount = give_sanitize_amount( $amount );
146
+		$amount = give_sanitize_amount($amount);
147 147
 	}
148 148
 
149 149
 	$decimals = give_get_price_decimals();
150 150
 
151
-	$formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep );
151
+	$formatted = number_format($amount, $decimals, $decimal_sep, $thousands_sep);
152 152
 
153
-	return apply_filters( 'give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep );
153
+	return apply_filters('give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep);
154 154
 }
155 155
 
156 156
 
@@ -166,33 +166,33 @@  discard block
 block discarded – undo
166 166
  * @param string $amount formatted amount number.
167 167
  * @return float|string  formatted amount number with large number names.
168 168
  */
169
-function give_human_format_large_amount( $amount ) {
169
+function give_human_format_large_amount($amount) {
170 170
 
171 171
     // Get thousand separator.
172 172
     $thousands_sep = give_get_price_thousand_separator();
173 173
 
174 174
     // Sanitize amount.
175
-    $sanitize_amount = give_sanitize_amount( $amount );
175
+    $sanitize_amount = give_sanitize_amount($amount);
176 176
 
177 177
     // Explode amount to calculate name of large numbers.
178
-	$amount_array = explode( $thousands_sep, $amount );
178
+	$amount_array = explode($thousands_sep, $amount);
179 179
 
180 180
     // Calculate amount parts count.
181
-    $amount_count_parts = count( $amount_array );
181
+    $amount_count_parts = count($amount_array);
182 182
 
183 183
 	// Human format amount (default).
184 184
 	$human_format_amount = $amount;
185 185
 
186 186
     // Calculate large number formatted amount.
187
-    if ( 4 < $amount_count_parts ){
188
-        $human_format_amount =  sprintf( esc_html__( '%s trillion', 'give' ), round( ( $sanitize_amount / 1000000000000 ), 2 ) );
189
-    } elseif ( 3 < $amount_count_parts ){
190
-        $human_format_amount =  sprintf( esc_html__( '%s billion', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ));
191
-    } elseif ( 2 < $amount_count_parts  ) {
192
-        $human_format_amount =  sprintf( esc_html__( '%s million', 'give' ), round( ( $sanitize_amount / 1000000), 2 ) );
187
+    if (4 < $amount_count_parts) {
188
+        $human_format_amount = sprintf(esc_html__('%s trillion', 'give'), round(($sanitize_amount / 1000000000000), 2));
189
+    } elseif (3 < $amount_count_parts) {
190
+        $human_format_amount = sprintf(esc_html__('%s billion', 'give'), round(($sanitize_amount / 1000000000), 2));
191
+    } elseif (2 < $amount_count_parts) {
192
+        $human_format_amount = sprintf(esc_html__('%s million', 'give'), round(($sanitize_amount / 1000000), 2));
193 193
     }
194 194
 
195
-    return apply_filters( 'give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount );
195
+    return apply_filters('give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount);
196 196
 }
197 197
 
198 198
 /**
@@ -205,15 +205,15 @@  discard block
 block discarded – undo
205 205
  *
206 206
  * @return string $amount Newly formatted amount or Price Not Available
207 207
  */
208
-function give_format_decimal( $amount, $dp = false ){
208
+function give_format_decimal($amount, $dp = false) {
209 209
     $decimal_separator = give_get_price_decimal_separator();
210
-    $formatted_amount  = give_sanitize_amount( $amount, $dp );
210
+    $formatted_amount  = give_sanitize_amount($amount, $dp);
211 211
 
212
-    if( false !== strpos( $formatted_amount, '.' ) ) {
213
-        $formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount );
212
+    if (false !== strpos($formatted_amount, '.')) {
213
+        $formatted_amount = str_replace('.', $decimal_separator, $formatted_amount);
214 214
     }
215 215
 
216
-    return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator );
216
+    return apply_filters('give_format_decimal', $formatted_amount, $amount, $decimal_separator);
217 217
 }
218 218
 
219 219
 
@@ -227,13 +227,13 @@  discard block
 block discarded – undo
227 227
  *
228 228
  * @return bool
229 229
  */
230
-function give_format_admin_multilevel_amount( $field_args, $field ) {
230
+function give_format_admin_multilevel_amount($field_args, $field) {
231 231
 
232
-	if ( empty( $field->value ) ) {
232
+	if (empty($field->value)) {
233 233
 		return false;
234 234
 	}
235 235
 
236
-	$field->value = give_format_decimal( $field->value );
236
+	$field->value = give_format_decimal($field->value);
237 237
 }
238 238
 
239 239
 /**
@@ -246,24 +246,24 @@  discard block
 block discarded – undo
246 246
  *
247 247
  * @return mixed|string|void
248 248
  */
249
-function give_currency_filter( $price = '', $currency = '' ) {
249
+function give_currency_filter($price = '', $currency = '') {
250 250
 
251
-	if ( empty( $currency ) ) {
251
+	if (empty($currency)) {
252 252
 		$currency = give_get_currency();
253 253
 	}
254 254
 
255
-	$position = give_get_option( 'currency_position', 'before' );
255
+	$position = give_get_option('currency_position', 'before');
256 256
 
257 257
 	$negative = $price < 0;
258 258
 
259
-	if ( $negative ) {
259
+	if ($negative) {
260 260
         // Remove proceeding "-".
261
-		$price = substr( $price, 1 );
261
+		$price = substr($price, 1);
262 262
 	}
263 263
 
264
-	$symbol = give_currency_symbol( $currency );
264
+	$symbol = give_currency_symbol($currency);
265 265
 
266
-    switch ( $currency ):
266
+    switch ($currency):
267 267
         case 'GBP' :
268 268
         case 'BRL' :
269 269
         case 'EUR' :
@@ -292,13 +292,13 @@  discard block
 block discarded – undo
292 292
         case 'MAD' :
293 293
         case 'KRW' :
294 294
         case 'ZAR' :
295
-            $formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol );
295
+            $formatted = ('before' === $position ? $symbol.$price : $price.$symbol);
296 296
             break;
297 297
         case 'NOK' :
298
-            $formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol );
298
+            $formatted = ('before' === $position ? $symbol.' '.$price : $price.' '.$symbol);
299 299
             break;
300 300
         default :
301
-            $formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency );
301
+            $formatted = ('before' === $position ? $currency.' '.$price : $price.' '.$currency);
302 302
             break;
303 303
     endswitch;
304 304
 
@@ -314,11 +314,11 @@  discard block
 block discarded – undo
314 314
      *           filter name will be give_usd_currency_filter_after
315 315
      *
316 316
      */
317
-    $formatted = apply_filters( 'give_' . strtolower( $currency ) . "_currency_filter_{$position}", $formatted, $currency, $price );
317
+    $formatted = apply_filters('give_'.strtolower($currency)."_currency_filter_{$position}", $formatted, $currency, $price);
318 318
 
319
-    if ( $negative ) {
319
+    if ($negative) {
320 320
 		// Prepend the minus sign before the currency sign.
321
-		$formatted = '-' . $formatted;
321
+		$formatted = '-'.$formatted;
322 322
 	}
323 323
 
324 324
 	return $formatted;
@@ -334,22 +334,22 @@  discard block
 block discarded – undo
334 334
  */
335 335
 function give_currency_decimal_filter() {
336 336
 
337
-    remove_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' );
337
+    remove_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter');
338 338
 
339 339
     // Set default number of decimals.
340 340
     $decimals = give_get_price_decimals();
341 341
 
342
-    add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' );
342
+    add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter');
343 343
 
344 344
 
345 345
     // Get number of decimals with backward compatibility ( version < 1.6 )
346
-    if( 1 <= func_num_args() ){
347
-        $decimals = ( false === func_get_arg( 0 ) ? $decimals : absint( func_get_arg( 0 ) ) );
346
+    if (1 <= func_num_args()) {
347
+        $decimals = (false === func_get_arg(0) ? $decimals : absint(func_get_arg(0)));
348 348
     }
349 349
 
350 350
 	$currency = give_get_currency();
351 351
 
352
-	switch ( $currency ) {
352
+	switch ($currency) {
353 353
 		case 'RIAL' :
354 354
 		case 'JPY' :
355 355
 		case 'TWD' :
@@ -359,11 +359,11 @@  discard block
 block discarded – undo
359 359
 			break;
360 360
 	}
361 361
 
362
-	return apply_filters( 'give_currency_decimal_count', $decimals, $currency );
362
+	return apply_filters('give_currency_decimal_count', $decimals, $currency);
363 363
 }
364 364
 
365
-add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' );
366
-add_filter( 'give_format_amount_decimals', 'give_currency_decimal_filter' );
365
+add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter');
366
+add_filter('give_format_amount_decimals', 'give_currency_decimal_filter');
367 367
 
368 368
 /**
369 369
  * Sanitize thousand separator
@@ -377,8 +377,8 @@  discard block
 block discarded – undo
377 377
  *
378 378
  * @return mixed
379 379
  */
380
-function give_sanitize_thousand_separator( $value, $field_args, $field ){
381
-    return stripslashes( $value );
380
+function give_sanitize_thousand_separator($value, $field_args, $field) {
381
+    return stripslashes($value);
382 382
 }
383 383
 
384 384
 
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
  *
395 395
  * @return  mixed
396 396
  */
397
-function give_sanitize_number_decimals( $value, $field_args, $field ){
397
+function give_sanitize_number_decimals($value, $field_args, $field) {
398 398
 	return absint($value);
399 399
 }
400 400
 
@@ -410,8 +410,8 @@  discard block
 block discarded – undo
410 410
  *
411 411
  * @return  mixed
412 412
  */
413
-function give_sanitize_price_field_value( $value, $field_args, $field ){
414
-    return give_sanitize_amount( $value );
413
+function give_sanitize_price_field_value($value, $field_args, $field) {
414
+    return give_sanitize_amount($value);
415 415
 }
416 416
 
417 417
 
@@ -425,29 +425,29 @@  discard block
 block discarded – undo
425 425
  *
426 426
  * @return void
427 427
  */
428
-function give_cmb_amount_field_render_row_cb( $field_args, $field ) {
428
+function give_cmb_amount_field_render_row_cb($field_args, $field) {
429 429
 
430 430
 	// Get args.
431 431
 	$id          = $field->args('id');
432
-	$label       = $field->args( 'name' );
433
-	$name        = $field->args( '_name' );
434
-	$description = $field->args( 'description' );
435
-	$attributes  = $field->args( 'attributes' );
432
+	$label       = $field->args('name');
433
+	$name        = $field->args('_name');
434
+	$description = $field->args('description');
435
+	$attributes  = $field->args('attributes');
436 436
 	$attributes_string  = '';
437 437
 	$row_class          = $field->row_classes();
438 438
 
439 439
 	// Get attributes.
440
-	if( ! empty( $attributes ) ) {
441
-		foreach ( $attributes as $attribute_name => $attribute_val ) {
440
+	if ( ! empty($attributes)) {
441
+		foreach ($attributes as $attribute_name => $attribute_val) {
442 442
 			$attributes_string[] = "$attribute_name=\"$attribute_val\"";
443 443
 		}
444 444
 
445
-		$attributes_string = implode( ' ', $attributes_string );
445
+		$attributes_string = implode(' ', $attributes_string);
446 446
 	}
447 447
 
448 448
 	// Get row class.
449
-	if( ! empty( $row_class ) && is_array( $row_class ) ) {
450
-		$row_class = implode( ' ', $row_class );
449
+	if ( ! empty($row_class) && is_array($row_class)) {
450
+		$row_class = implode(' ', $row_class);
451 451
 	}
452 452
 	?>
453 453
 	<div class="cmb-row <?php echo $row_class; ?>">
@@ -455,9 +455,9 @@  discard block
 block discarded – undo
455 455
 			<label for="<?php echo $id; ?>"><?php echo $label; ?></label>
456 456
 		</div>
457 457
 		<div class="cmb-td">
458
-			<?php echo ( give_get_option( 'currency_position' ) == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '' ); ?>
458
+			<?php echo (give_get_option('currency_position') == 'before' ? '<span class="give-money-symbol give-money-symbol-before">'.give_currency_symbol().'</span>' : ''); ?>
459 459
 			<input id="<?php echo $id; ?>" type="text" name="<?php echo $name; ?>" <?php echo $attributes_string?>/>
460
-			<?php echo ( give_get_option( 'currency_position' ) == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '' ); ?>
460
+			<?php echo (give_get_option('currency_position') == 'after' ? '<span class="give-money-symbol give-money-symbol-after">'.give_currency_symbol().'</span>' : ''); ?>
461 461
 
462 462
 			<span class="cmb2-metabox-description"><?php echo $description; ?></span>
463 463
 		</div>
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
  *
477 477
  * @return string                  Date format string
478 478
  */
479
-function give_date_format ( $date_context = '' ) {
479
+function give_date_format($date_context = '') {
480 480
 	/**
481 481
 	 * Filter the date context
482 482
 	 *
@@ -497,18 +497,18 @@  discard block
 block discarded – undo
497 497
 	 *
498 498
 	 *    }
499 499
 	 */
500
-	$date_format_contexts = apply_filters( 'give_date_format_contexts', array() );
500
+	$date_format_contexts = apply_filters('give_date_format_contexts', array());
501 501
 
502 502
 	// Set date format to default date format.
503 503
 	$date_format = get_option('date_format');
504 504
 
505 505
 
506 506
 	// Update date format if we have non empty date format context array and non empty date format string for that context.
507
-	if( $date_context &&  ! empty( $date_format_contexts ) && array_key_exists( $date_context, $date_format_contexts ) ) {
508
-		$date_format = ! empty( $date_format_contexts[ $date_context ] )
509
-			? $date_format_contexts[ $date_context ]
507
+	if ($date_context && ! empty($date_format_contexts) && array_key_exists($date_context, $date_format_contexts)) {
508
+		$date_format = ! empty($date_format_contexts[$date_context])
509
+			? $date_format_contexts[$date_context]
510 510
 			: $date_format;
511 511
 	}
512 512
 
513
-	return apply_filters( 'give_date_format', $date_format );
513
+	return apply_filters('give_date_format', $date_format);
514 514
 }
515 515
\ No newline at end of file
Please login to merge, or discard this patch.
includes/scripts.php 1 patch
Spacing   +146 added lines, -146 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
 
@@ -26,106 +26,106 @@  discard block
 block discarded – undo
26 26
  */
27 27
 function give_load_scripts() {
28 28
 
29
-	$js_dir         = GIVE_PLUGIN_URL . 'assets/js/frontend/';
30
-	$js_plugins     = GIVE_PLUGIN_URL . 'assets/js/plugins/';
31
-	$scripts_footer = ( give_get_option( 'scripts_footer' ) == 'on' ) ? true : false;
29
+	$js_dir         = GIVE_PLUGIN_URL.'assets/js/frontend/';
30
+	$js_plugins     = GIVE_PLUGIN_URL.'assets/js/plugins/';
31
+	$scripts_footer = (give_get_option('scripts_footer') == 'on') ? true : false;
32 32
 
33 33
 	// Use minified libraries if SCRIPT_DEBUG is turned off
34
-	$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
34
+	$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
35 35
 
36 36
 	//Localize / PHP to AJAX vars
37
-	$localize_give_checkout = apply_filters( 'give_global_script_vars', array(
37
+	$localize_give_checkout = apply_filters('give_global_script_vars', array(
38 38
 		'ajaxurl'             => give_get_ajax_url(),
39
-		'checkout_nonce'      => wp_create_nonce( 'give_checkout_nonce' ),
40
-		'currency_sign'       => give_currency_filter( '' ),
39
+		'checkout_nonce'      => wp_create_nonce('give_checkout_nonce'),
40
+		'currency_sign'       => give_currency_filter(''),
41 41
 		'currency_pos'        => give_get_currency_position(),
42 42
 		'thousands_separator' => give_get_price_thousand_separator(),
43 43
 		'decimal_separator'   => give_get_price_decimal_separator(),
44
-		'no_gateway'          => esc_html__( 'Please select a payment method.', 'give' ),
45
-		'bad_minimum'         => esc_html__( 'The minimum donation amount for this form is', 'give' ),
46
-		'general_loading'     => esc_html__( 'Loading...', 'give' ),
47
-		'purchase_loading'    => esc_html__( 'Please Wait...', 'give' ),
44
+		'no_gateway'          => esc_html__('Please select a payment method.', 'give'),
45
+		'bad_minimum'         => esc_html__('The minimum donation amount for this form is', 'give'),
46
+		'general_loading'     => esc_html__('Loading...', 'give'),
47
+		'purchase_loading'    => esc_html__('Please Wait...', 'give'),
48 48
 		'number_decimals'     => give_get_price_decimals(),
49 49
 		'give_version'        => GIVE_VERSION,
50 50
 		'form_translation'    => apply_filters(
51 51
 			'give_form_translation_js',
52 52
 			array(
53 53
 				// Field name               Validation message.
54
-				'payment-mode'           => esc_html__( 'Please select payment mode.', 'give' ),
55
-				'give_first'             => esc_html__( 'Please enter your first name.', 'give' ),
56
-				'give_email'             => esc_html__( 'Please enter a valid email address.', 'give' ),
57
-				'give_user_login'        => esc_html__( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ),
58
-				'give_user_pass'         => esc_html__( 'Enter a password.', 'give' ),
59
-				'give_user_pass_confirm' => esc_html__( 'Enter a confirm password.', 'give' ),
54
+				'payment-mode'           => esc_html__('Please select payment mode.', 'give'),
55
+				'give_first'             => esc_html__('Please enter your first name.', 'give'),
56
+				'give_email'             => esc_html__('Please enter a valid email address.', 'give'),
57
+				'give_user_login'        => esc_html__('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'),
58
+				'give_user_pass'         => esc_html__('Enter a password.', 'give'),
59
+				'give_user_pass_confirm' => esc_html__('Enter a confirm password.', 'give'),
60 60
 			)
61 61
 		)
62
-	) );
63
-	$localize_give_ajax     = apply_filters( 'give_global_ajax_vars', array(
62
+	));
63
+	$localize_give_ajax = apply_filters('give_global_ajax_vars', array(
64 64
 		'ajaxurl'         => give_get_ajax_url(),
65
-		'loading'         => esc_html__( 'Loading', 'give' ),
65
+		'loading'         => esc_html__('Loading', 'give'),
66 66
 		// General loading message
67
-		'select_option'   => esc_html__( 'Please select an option', 'give' ),
67
+		'select_option'   => esc_html__('Please select an option', 'give'),
68 68
 		// Variable pricing error with multi-donation option enabled
69
-		'default_gateway' => give_get_default_gateway( null ),
70
-		'permalinks'      => get_option( 'permalink_structure' ) ? '1' : '0',
69
+		'default_gateway' => give_get_default_gateway(null),
70
+		'permalinks'      => get_option('permalink_structure') ? '1' : '0',
71 71
 		'number_decimals' => give_get_price_decimals()
72
-	) );
72
+	));
73 73
 
74 74
 	//DEBUG is On
75
-	if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
75
+	if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) {
76 76
 
77
-		if ( give_is_cc_verify_enabled() ) {
78
-			wp_register_script( 'give-cc-validator', $js_plugins . 'jquery.payment' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
79
-			wp_enqueue_script( 'give-cc-validator' );
77
+		if (give_is_cc_verify_enabled()) {
78
+			wp_register_script('give-cc-validator', $js_plugins.'jquery.payment'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
79
+			wp_enqueue_script('give-cc-validator');
80 80
 		}
81 81
 
82
-		wp_register_script( 'give-float-labels', $js_plugins . 'float-labels' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
83
-		wp_enqueue_script( 'give-float-labels' );
82
+		wp_register_script('give-float-labels', $js_plugins.'float-labels'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
83
+		wp_enqueue_script('give-float-labels');
84 84
 
85
-		wp_register_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
86
-		wp_enqueue_script( 'give-blockui' );
85
+		wp_register_script('give-blockui', $js_plugins.'jquery.blockUI'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
86
+		wp_enqueue_script('give-blockui');
87 87
 
88
-		wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
89
-		wp_enqueue_script( 'give-qtip' );
88
+		wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
89
+		wp_enqueue_script('give-qtip');
90 90
 
91
-		wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
92
-		wp_enqueue_script( 'give-accounting' );
91
+		wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
92
+		wp_enqueue_script('give-accounting');
93 93
 
94
-		wp_register_script( 'give-magnific', $js_plugins . 'jquery.magnific-popup' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
95
-		wp_enqueue_script( 'give-magnific' );
94
+		wp_register_script('give-magnific', $js_plugins.'jquery.magnific-popup'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
95
+		wp_enqueue_script('give-magnific');
96 96
 
97
-		wp_register_script( 'give-checkout-global', $js_dir . 'give-checkout-global' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
98
-		wp_enqueue_script( 'give-checkout-global' );
97
+		wp_register_script('give-checkout-global', $js_dir.'give-checkout-global'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
98
+		wp_enqueue_script('give-checkout-global');
99 99
 
100 100
 		//General scripts
101
-		wp_register_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
102
-		wp_enqueue_script( 'give-scripts' );
101
+		wp_register_script('give-scripts', $js_dir.'give'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
102
+		wp_enqueue_script('give-scripts');
103 103
 
104 104
 		// Load AJAX scripts, if enabled
105
-		wp_register_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
106
-		wp_enqueue_script( 'give-ajax' );
105
+		wp_register_script('give-ajax', $js_dir.'give-ajax'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
106
+		wp_enqueue_script('give-ajax');
107 107
 
108 108
 		//Localize / Pass AJAX vars from PHP
109
-		wp_localize_script( 'give-checkout-global', 'give_global_vars', $localize_give_checkout );
110
-		wp_localize_script( 'give-ajax', 'give_scripts', $localize_give_ajax );
109
+		wp_localize_script('give-checkout-global', 'give_global_vars', $localize_give_checkout);
110
+		wp_localize_script('give-ajax', 'give_scripts', $localize_give_ajax);
111 111
 
112 112
 
113 113
 	} else {
114 114
 
115 115
 		//DEBUG is OFF (one JS file to rule them all!)
116
-		wp_register_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
117
-		wp_enqueue_script( 'give' );
116
+		wp_register_script('give', $js_dir.'give.all.min.js', array('jquery'), GIVE_VERSION, $scripts_footer);
117
+		wp_enqueue_script('give');
118 118
 
119 119
 		//Localize / Pass AJAX vars from PHP
120
-		wp_localize_script( 'give', 'give_global_vars', $localize_give_checkout );
121
-		wp_localize_script( 'give', 'give_scripts', $localize_give_ajax );
120
+		wp_localize_script('give', 'give_global_vars', $localize_give_checkout);
121
+		wp_localize_script('give', 'give_scripts', $localize_give_ajax);
122 122
 
123 123
 	}
124 124
 
125 125
 
126 126
 }
127 127
 
128
-add_action( 'wp_enqueue_scripts', 'give_load_scripts' );
128
+add_action('wp_enqueue_scripts', 'give_load_scripts');
129 129
 
130 130
 /**
131 131
  * Register styles.
@@ -137,16 +137,16 @@  discard block
 block discarded – undo
137 137
  */
138 138
 function give_register_styles() {
139 139
 
140
-	if ( give_get_option( 'disable_css', false ) ) {
140
+	if (give_get_option('disable_css', false)) {
141 141
 		return;
142 142
 	}
143 143
 
144
-	wp_register_style( 'give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all' );
145
-	wp_enqueue_style( 'give-styles' );
144
+	wp_register_style('give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all');
145
+	wp_enqueue_style('give-styles');
146 146
 
147 147
 }
148 148
 
149
-add_action( 'wp_enqueue_scripts', 'give_register_styles' );
149
+add_action('wp_enqueue_scripts', 'give_register_styles');
150 150
 
151 151
 
152 152
 /**
@@ -158,39 +158,39 @@  discard block
 block discarded – undo
158 158
 function give_get_stylesheet_uri() {
159 159
 
160 160
 	// Use minified libraries if SCRIPT_DEBUG is turned off
161
-	$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
161
+	$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
162 162
 
163
-	$file          = 'give' . $suffix . '.css';
163
+	$file          = 'give'.$suffix.'.css';
164 164
 	$templates_dir = give_get_theme_template_dir_name();
165 165
 
166
-	$child_theme_style_sheet    = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file;
167
-	$child_theme_style_sheet_2  = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give.css';
168
-	$parent_theme_style_sheet   = trailingslashit( get_template_directory() ) . $templates_dir . $file;
169
-	$parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give.css';
170
-	$give_plugin_style_sheet    = trailingslashit( give_get_templates_dir() ) . $file;
166
+	$child_theme_style_sheet    = trailingslashit(get_stylesheet_directory()).$templates_dir.$file;
167
+	$child_theme_style_sheet_2  = trailingslashit(get_stylesheet_directory()).$templates_dir.'give.css';
168
+	$parent_theme_style_sheet   = trailingslashit(get_template_directory()).$templates_dir.$file;
169
+	$parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give.css';
170
+	$give_plugin_style_sheet    = trailingslashit(give_get_templates_dir()).$file;
171 171
 
172 172
 	$uri = false;
173 173
 
174 174
 	// Look in the child theme directory first, followed by the parent theme, followed by the Give core templates directory
175 175
 	// Also look for the min version first, followed by non minified version, even if SCRIPT_DEBUG is not enabled.
176 176
 	// This allows users to copy just give.css to their theme
177
-	if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) {
178
-		if ( ! empty( $nonmin ) ) {
179
-			$uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give.css';
177
+	if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) {
178
+		if ( ! empty($nonmin)) {
179
+			$uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give.css';
180 180
 		} else {
181
-			$uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file;
181
+			$uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file;
182 182
 		}
183
-	} elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) {
184
-		if ( ! empty( $nonmin ) ) {
185
-			$uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give.css';
183
+	} elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) {
184
+		if ( ! empty($nonmin)) {
185
+			$uri = trailingslashit(get_template_directory_uri()).$templates_dir.'give.css';
186 186
 		} else {
187
-			$uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file;
187
+			$uri = trailingslashit(get_template_directory_uri()).$templates_dir.$file;
188 188
 		}
189
-	} elseif ( file_exists( $give_plugin_style_sheet ) || file_exists( $give_plugin_style_sheet ) ) {
190
-		$uri = trailingslashit( give_get_templates_url() ) . $file;
189
+	} elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) {
190
+		$uri = trailingslashit(give_get_templates_url()).$file;
191 191
 	}
192 192
 
193
-	return apply_filters( 'give_get_stylesheet_uri', $uri );
193
+	return apply_filters('give_get_stylesheet_uri', $uri);
194 194
 
195 195
 }
196 196
 
@@ -208,65 +208,65 @@  discard block
 block discarded – undo
208 208
  *
209 209
  * @return void
210 210
  */
211
-function give_load_admin_scripts( $hook ) {
211
+function give_load_admin_scripts($hook) {
212 212
 
213 213
 	global $wp_version, $post, $post_type, $give_options;
214 214
 
215 215
 	//Directories of assets
216
-	$js_dir     = GIVE_PLUGIN_URL . 'assets/js/admin/';
217
-	$js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/';
218
-	$css_dir    = GIVE_PLUGIN_URL . 'assets/css/';
216
+	$js_dir     = GIVE_PLUGIN_URL.'assets/js/admin/';
217
+	$js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/';
218
+	$css_dir    = GIVE_PLUGIN_URL.'assets/css/';
219 219
 
220 220
 	// Use minified libraries if SCRIPT_DEBUG is turned off
221
-	$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
221
+	$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
222 222
 
223 223
 	//Global Admin:
224
-	wp_register_style( 'give-admin-bar-notification', $css_dir . 'adminbar-style.css' );
225
-	wp_enqueue_style( 'give-admin-bar-notification' );
224
+	wp_register_style('give-admin-bar-notification', $css_dir.'adminbar-style.css');
225
+	wp_enqueue_style('give-admin-bar-notification');
226 226
 
227 227
 	//Give Admin Only:
228
-	if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) {
228
+	if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) {
229 229
 		return;
230 230
 	}
231 231
 
232 232
 	//CSS
233
-	wp_register_style( 'jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css' );
234
-	wp_enqueue_style( 'jquery-ui-css' );
235
-	wp_register_style( 'give-admin', $css_dir . 'give-admin' . $suffix . '.css', GIVE_VERSION );
236
-	wp_enqueue_style( 'give-admin' );
237
-	wp_register_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION );
238
-	wp_enqueue_style( 'jquery-chosen' );
239
-	wp_enqueue_style( 'thickbox' );
233
+	wp_register_style('jquery-ui-css', $css_dir.'jquery-ui-fresh'.$suffix.'.css');
234
+	wp_enqueue_style('jquery-ui-css');
235
+	wp_register_style('give-admin', $css_dir.'give-admin'.$suffix.'.css', GIVE_VERSION);
236
+	wp_enqueue_style('give-admin');
237
+	wp_register_style('jquery-chosen', $css_dir.'chosen'.$suffix.'.css', array(), GIVE_VERSION);
238
+	wp_enqueue_style('jquery-chosen');
239
+	wp_enqueue_style('thickbox');
240 240
 
241 241
 	//JS
242
-	wp_register_script( 'jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
243
-	wp_enqueue_script( 'jquery-chosen' );
242
+	wp_register_script('jquery-chosen', $js_plugins.'chosen.jquery'.$suffix.'.js', array('jquery'), GIVE_VERSION);
243
+	wp_enqueue_script('jquery-chosen');
244 244
 
245
-	wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
246
-	wp_enqueue_script( 'give-accounting' );
245
+	wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
246
+	wp_enqueue_script('give-accounting');
247 247
 
248
-	wp_register_script( 'give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
249
-	wp_enqueue_script( 'give-admin-scripts' );
248
+	wp_register_script('give-admin-scripts', $js_dir.'admin-scripts'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
249
+	wp_enqueue_script('give-admin-scripts');
250 250
 
251
-	wp_register_script( 'jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js' );
252
-	wp_enqueue_script( 'jquery-flot' );
251
+	wp_register_script('jquery-flot', $js_plugins.'jquery.flot'.$suffix.'.js');
252
+	wp_enqueue_script('jquery-flot');
253 253
 
254
-	wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
255
-	wp_enqueue_script( 'give-qtip' );
254
+	wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
255
+	wp_enqueue_script('give-qtip');
256 256
 
257
-	wp_enqueue_script( 'jquery-ui-datepicker' );
258
-	wp_enqueue_script( 'thickbox' );
257
+	wp_enqueue_script('jquery-ui-datepicker');
258
+	wp_enqueue_script('thickbox');
259 259
 
260 260
 	// Forms CPT Script.
261
-	if ( $post_type === 'give_forms' ) {
262
-		wp_register_script( 'give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
263
-		wp_enqueue_script( 'give-admin-forms-scripts' );
261
+	if ($post_type === 'give_forms') {
262
+		wp_register_script('give-admin-forms-scripts', $js_dir.'admin-forms'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
263
+		wp_enqueue_script('give-admin-forms-scripts');
264 264
 	}
265 265
 
266 266
 	//Settings Scripts
267
-	if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-settings' ) {
268
-		wp_register_script( 'give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
269
-		wp_enqueue_script( 'give-admin-settings-scripts' );
267
+	if (isset($_GET['page']) && $_GET['page'] == 'give-settings') {
268
+		wp_register_script('give-admin-settings-scripts', $js_dir.'admin-settings'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
269
+		wp_enqueue_script('give-admin-settings-scripts');
270 270
 	}
271 271
 
272 272
 	// Price Separators.
@@ -274,50 +274,50 @@  discard block
 block discarded – undo
274 274
 	$decimal_separator  = give_get_price_decimal_separator();
275 275
 
276 276
 	//Localize strings & variables for JS
277
-	wp_localize_script( 'give-admin-scripts', 'give_vars', array(
278
-		'post_id'                 => isset( $post->ID ) ? $post->ID : null,
277
+	wp_localize_script('give-admin-scripts', 'give_vars', array(
278
+		'post_id'                 => isset($post->ID) ? $post->ID : null,
279 279
 		'give_version'            => GIVE_VERSION,
280 280
 		'thousands_separator'     => $thousand_separator,
281 281
 		'decimal_separator'       => $decimal_separator,
282
-		'quick_edit_warning'      => esc_html__( 'Not available for variable priced forms.', 'give' ),
283
-		'delete_payment'          => esc_html__( 'Are you sure you wish to delete this payment?', 'give' ),
284
-		'delete_payment_note'     => esc_html__( 'Are you sure you wish to delete this note?', 'give' ),
285
-		'revoke_api_key'          => esc_html__( 'Are you sure you wish to revoke this API key?', 'give' ),
286
-		'regenerate_api_key'      => esc_html__( 'Are you sure you wish to regenerate this API key?', 'give' ),
287
-		'resend_receipt'          => esc_html__( 'Are you sure you wish to resend the donation receipt?', 'give' ),
288
-		'copy_download_link_text' => esc_html__( 'Copy these links to your clipboard and give them to your donor.', 'give' ),
282
+		'quick_edit_warning'      => esc_html__('Not available for variable priced forms.', 'give'),
283
+		'delete_payment'          => esc_html__('Are you sure you wish to delete this payment?', 'give'),
284
+		'delete_payment_note'     => esc_html__('Are you sure you wish to delete this note?', 'give'),
285
+		'revoke_api_key'          => esc_html__('Are you sure you wish to revoke this API key?', 'give'),
286
+		'regenerate_api_key'      => esc_html__('Are you sure you wish to regenerate this API key?', 'give'),
287
+		'resend_receipt'          => esc_html__('Are you sure you wish to resend the donation receipt?', 'give'),
288
+		'copy_download_link_text' => esc_html__('Copy these links to your clipboard and give them to your donor.', 'give'),
289 289
 		/* translators: %s: form singular label */
290
-		'delete_payment_download' => sprintf( esc_html__( 'Are you sure you wish to delete this %s?', 'give' ), give_get_forms_label_singular() ),
291
-		'one_price_min'           => esc_html__( 'You must have at least one price.', 'give' ),
292
-		'one_file_min'            => esc_html__( 'You must have at least one file.', 'give' ),
293
-		'one_field_min'           => esc_html__( 'You must have at least one field.', 'give' ),
290
+		'delete_payment_download' => sprintf(esc_html__('Are you sure you wish to delete this %s?', 'give'), give_get_forms_label_singular()),
291
+		'one_price_min'           => esc_html__('You must have at least one price.', 'give'),
292
+		'one_file_min'            => esc_html__('You must have at least one file.', 'give'),
293
+		'one_field_min'           => esc_html__('You must have at least one field.', 'give'),
294 294
 		/* translators: %s: form singular label */
295
-		'one_option'              => sprintf( esc_html__( 'Choose a %s', 'give' ), give_get_forms_label_singular() ),
295
+		'one_option'              => sprintf(esc_html__('Choose a %s', 'give'), give_get_forms_label_singular()),
296 296
 		/* translators: %s: form plural label */
297
-		'one_or_more_option'      => sprintf( esc_html__( 'Choose one or more %s', 'give' ), give_get_forms_label_plural() ),
298
-		'numeric_item_price'      => esc_html__( 'Item price must be numeric.', 'give' ),
299
-		'numeric_quantity'        => esc_html__( 'Quantity must be numeric.', 'give' ),
300
-		'currency_sign'           => give_currency_filter( '' ),
301
-		'currency_pos'            => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before',
302
-		'currency_decimals'       => give_currency_decimal_filter( give_get_price_decimals() ),
303
-		'new_media_ui'            => apply_filters( 'give_use_35_media_ui', 1 ),
304
-		'remove_text'             => esc_html__( 'Remove', 'give' ),
297
+		'one_or_more_option'      => sprintf(esc_html__('Choose one or more %s', 'give'), give_get_forms_label_plural()),
298
+		'numeric_item_price'      => esc_html__('Item price must be numeric.', 'give'),
299
+		'numeric_quantity'        => esc_html__('Quantity must be numeric.', 'give'),
300
+		'currency_sign'           => give_currency_filter(''),
301
+		'currency_pos'            => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before',
302
+		'currency_decimals'       => give_currency_decimal_filter(give_get_price_decimals()),
303
+		'new_media_ui'            => apply_filters('give_use_35_media_ui', 1),
304
+		'remove_text'             => esc_html__('Remove', 'give'),
305 305
 		/* translators: %s: form plural label */
306
-		'type_to_search'          => sprintf( esc_html__( 'Type to search %s', 'give' ), give_get_forms_label_plural() ),
307
-		'batch_export_no_class'   => esc_html__( 'You must choose a method.', 'give' ),
308
-		'batch_export_no_reqs'    => esc_html__( 'Required fields not completed.', 'give' ),
309
-		'reset_stats_warn'        => __( 'Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give' ),
310
-		'price_format_guide'      => sprintf( esc_html__( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator )
311
-	) );
312
-
313
-	if ( function_exists( 'wp_enqueue_media' ) && version_compare( $wp_version, '3.5', '>=' ) ) {
306
+		'type_to_search'          => sprintf(esc_html__('Type to search %s', 'give'), give_get_forms_label_plural()),
307
+		'batch_export_no_class'   => esc_html__('You must choose a method.', 'give'),
308
+		'batch_export_no_reqs'    => esc_html__('Required fields not completed.', 'give'),
309
+		'reset_stats_warn'        => __('Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give'),
310
+		'price_format_guide'      => sprintf(esc_html__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator)
311
+	));
312
+
313
+	if (function_exists('wp_enqueue_media') && version_compare($wp_version, '3.5', '>=')) {
314 314
 		//call for new media manager
315 315
 		wp_enqueue_media();
316 316
 	}
317 317
 
318 318
 }
319 319
 
320
-add_action( 'admin_enqueue_scripts', 'give_load_admin_scripts', 100 );
320
+add_action('admin_enqueue_scripts', 'give_load_admin_scripts', 100);
321 321
 
322 322
 /**
323 323
  * Admin Give Icon
@@ -334,14 +334,14 @@  discard block
 block discarded – undo
334 334
 	?>
335 335
 	<style type="text/css" media="screen">
336 336
 
337
-		<?php if( version_compare( $wp_version, '3.8-RC', '>=' ) || version_compare( $wp_version, '3.8', '>=' ) ) { ?>
337
+		<?php if (version_compare($wp_version, '3.8-RC', '>=') || version_compare($wp_version, '3.8', '>=')) { ?>
338 338
 		@font-face {
339 339
 			font-family: 'give-icomoon';
340
-			src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?-ngjl88'; ?>');
341
-			src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?#iefix-ngjl88'?>') format('embedded-opentype'),
342
-			url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.woff?-ngjl88'; ?>') format('woff'),
343
-			url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.ttf?-ngjl88'; ?>') format('truetype'),
344
-			url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.svg?-ngjl88#icomoon'; ?>') format('svg');
340
+			src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?-ngjl88'; ?>');
341
+			src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?#iefix-ngjl88'?>') format('embedded-opentype'),
342
+			url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.woff?-ngjl88'; ?>') format('woff'),
343
+			url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.ttf?-ngjl88'; ?>') format('truetype'),
344
+			url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.svg?-ngjl88#icomoon'; ?>') format('svg');
345 345
 			font-weight: normal;
346 346
 			font-style: normal;
347 347
 		}
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	<?php
361 361
 }
362 362
 
363
-add_action( 'admin_head', 'give_admin_icon' );
363
+add_action('admin_head', 'give_admin_icon');
364 364
 
365 365
 /**
366 366
  * Admin js code
@@ -393,4 +393,4 @@  discard block
 block discarded – undo
393 393
 	<?php
394 394
 }
395 395
 
396
-add_action( 'admin_head', 'give_admin_hide_notice_shortly_js' );
396
+add_action('admin_head', 'give_admin_hide_notice_shortly_js');
Please login to merge, or discard this patch.
includes/user-functions.php 1 patch
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -30,36 +30,36 @@  discard block
 block discarded – undo
30 30
  *
31 31
  * @return bool|object List of all user donations
32 32
  */
33
-function give_get_users_purchases( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) {
33
+function give_get_users_purchases($user = 0, $number = 20, $pagination = false, $status = 'complete') {
34 34
 
35
-	if ( empty( $user ) ) {
35
+	if (empty($user)) {
36 36
 		$user = get_current_user_id();
37 37
 	}
38 38
 
39
-	if ( 0 === $user && ! Give()->email_access->token_exists ) {
39
+	if (0 === $user && ! Give()->email_access->token_exists) {
40 40
 		return false;
41 41
 	}
42 42
 
43 43
 	$status = $status === 'complete' ? 'publish' : $status;
44 44
 
45
-	if ( $pagination ) {
46
-		if ( get_query_var( 'paged' ) ) {
47
-			$paged = get_query_var( 'paged' );
48
-		} else if ( get_query_var( 'page' ) ) {
49
-			$paged = get_query_var( 'page' );
45
+	if ($pagination) {
46
+		if (get_query_var('paged')) {
47
+			$paged = get_query_var('paged');
48
+		} else if (get_query_var('page')) {
49
+			$paged = get_query_var('page');
50 50
 		} else {
51 51
 			$paged = 1;
52 52
 		}
53 53
 	}
54 54
 
55
-	$args = apply_filters( 'give_get_users_purchases_args', array(
55
+	$args = apply_filters('give_get_users_purchases_args', array(
56 56
 		'user'    => $user,
57 57
 		'number'  => $number,
58 58
 		'status'  => $status,
59 59
 		'orderby' => 'date'
60
-	) );
60
+	));
61 61
 
62
-	if ( $pagination ) {
62
+	if ($pagination) {
63 63
 
64 64
 		$args['page'] = $paged;
65 65
 
@@ -69,20 +69,20 @@  discard block
 block discarded – undo
69 69
 
70 70
 	}
71 71
 
72
-	$by_user_id = is_numeric( $user ) ? true : false;
73
-	$customer   = new Give_Customer( $user, $by_user_id );
72
+	$by_user_id = is_numeric($user) ? true : false;
73
+	$customer   = new Give_Customer($user, $by_user_id);
74 74
 
75
-	if ( ! empty( $customer->payment_ids ) ) {
75
+	if ( ! empty($customer->payment_ids)) {
76 76
 
77
-		unset( $args['user'] );
78
-		$args['post__in'] = array_map( 'absint', explode( ',', $customer->payment_ids ) );
77
+		unset($args['user']);
78
+		$args['post__in'] = array_map('absint', explode(',', $customer->payment_ids));
79 79
 
80 80
 	}
81 81
 
82
-	$purchases = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) );
82
+	$purchases = give_get_payments(apply_filters('give_get_users_donations_args', $args));
83 83
 
84 84
 	// No donations
85
-	if ( ! $purchases ) {
85
+	if ( ! $purchases) {
86 86
 		return false;
87 87
 	}
88 88
 
@@ -101,65 +101,65 @@  discard block
 block discarded – undo
101 101
  *
102 102
  * @return bool|object List of unique forms donated by user
103 103
  */
104
-function give_get_users_completed_donations( $user = 0, $status = 'complete' ) {
105
-	if ( empty( $user ) ) {
104
+function give_get_users_completed_donations($user = 0, $status = 'complete') {
105
+	if (empty($user)) {
106 106
 		$user = get_current_user_id();
107 107
 	}
108 108
 
109
-	if ( empty( $user ) ) {
109
+	if (empty($user)) {
110 110
 		return false;
111 111
 	}
112 112
 
113
-	$by_user_id = is_numeric( $user ) ? true : false;
113
+	$by_user_id = is_numeric($user) ? true : false;
114 114
 
115
-	$customer = new Give_Customer( $user, $by_user_id );
115
+	$customer = new Give_Customer($user, $by_user_id);
116 116
 
117
-	if ( empty( $customer->payment_ids ) ) {
117
+	if (empty($customer->payment_ids)) {
118 118
 		return false;
119 119
 	}
120 120
 
121 121
 	// Get all the items donated
122
-	$payment_ids    = array_reverse( explode( ',', $customer->payment_ids ) );
123
-	$limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 );
124
-	if ( ! empty( $limit_payments ) ) {
125
-		$payment_ids = array_slice( $payment_ids, 0, $limit_payments );
122
+	$payment_ids    = array_reverse(explode(',', $customer->payment_ids));
123
+	$limit_payments = apply_filters('give_users_completed_donations_payments', 50);
124
+	if ( ! empty($limit_payments)) {
125
+		$payment_ids = array_slice($payment_ids, 0, $limit_payments);
126 126
 	}
127 127
 	$donation_data = array();
128
-	foreach ( $payment_ids as $payment_id ) {
129
-		$donation_data[] = give_get_payment_meta( $payment_id );
128
+	foreach ($payment_ids as $payment_id) {
129
+		$donation_data[] = give_get_payment_meta($payment_id);
130 130
 	}
131 131
 
132
-	if ( empty( $donation_data ) ) {
132
+	if (empty($donation_data)) {
133 133
 		return false;
134 134
 	}
135 135
 
136 136
 	// Grab only the post ids "form_id" of the forms donated on this order
137 137
 	$completed_donations_ids = array();
138
-	foreach ( $donation_data as $purchase_meta ) {
138
+	foreach ($donation_data as $purchase_meta) {
139 139
 		$completed_donations_ids[] = isset($purchase_meta['form_id']) ? $purchase_meta['form_id'] : '';
140 140
 	}
141 141
 
142
-	if ( empty( $completed_donations_ids ) ) {
142
+	if (empty($completed_donations_ids)) {
143 143
 		return false;
144 144
 	}
145 145
 
146 146
 	// Only include each donation once
147
-	$form_ids = array_unique( $completed_donations_ids );
147
+	$form_ids = array_unique($completed_donations_ids);
148 148
 
149 149
 	// Make sure we still have some products and a first item
150
-	if ( empty ( $form_ids ) || ! isset( $form_ids[0] ) ) {
150
+	if (empty ($form_ids) || ! isset($form_ids[0])) {
151 151
 		return false;
152 152
 	}
153 153
 
154
-	$post_type = get_post_type( $form_ids[0] );
154
+	$post_type = get_post_type($form_ids[0]);
155 155
 
156
-	$args = apply_filters( 'give_get_users_completed_donations_args', array(
156
+	$args = apply_filters('give_get_users_completed_donations_args', array(
157 157
 		'include'        => $form_ids,
158 158
 		'post_type'      => $post_type,
159
-		'posts_per_page' => - 1
160
-	) );
159
+		'posts_per_page' => -1
160
+	));
161 161
 
162
-	return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) );
162
+	return apply_filters('give_users_completed_donations_list', get_posts($args));
163 163
 }
164 164
 
165 165
 
@@ -175,12 +175,12 @@  discard block
 block discarded – undo
175 175
  *
176 176
  * @return      bool - true if has donated, false other wise.
177 177
  */
178
-function give_has_purchases( $user_id = null ) {
179
-	if ( empty( $user_id ) ) {
178
+function give_has_purchases($user_id = null) {
179
+	if (empty($user_id)) {
180 180
 		$user_id = get_current_user_id();
181 181
 	}
182 182
 
183
-	if ( give_get_users_purchases( $user_id, 1 ) ) {
183
+	if (give_get_users_purchases($user_id, 1)) {
184 184
 		return true; // User has at least one donation
185 185
 	}
186 186
 
@@ -200,27 +200,27 @@  discard block
 block discarded – undo
200 200
  *
201 201
  * @return      array
202 202
  */
203
-function give_get_purchase_stats_by_user( $user = '' ) {
203
+function give_get_purchase_stats_by_user($user = '') {
204 204
 
205
-	if ( is_email( $user ) ) {
205
+	if (is_email($user)) {
206 206
 
207 207
 		$field = 'email';
208 208
 
209
-	} elseif ( is_numeric( $user ) ) {
209
+	} elseif (is_numeric($user)) {
210 210
 
211 211
 		$field = 'user_id';
212 212
 
213 213
 	}
214 214
 
215 215
 	$stats    = array();
216
-	$customer = Give()->customers->get_customer_by( $field, $user );
216
+	$customer = Give()->customers->get_customer_by($field, $user);
217 217
 
218
-	if ( $customer ) {
218
+	if ($customer) {
219 219
 
220
-		$customer = new Give_Customer( $customer->id );
220
+		$customer = new Give_Customer($customer->id);
221 221
 
222
-		$stats['purchases']   = absint( $customer->purchase_count );
223
-		$stats['total_spent'] = give_sanitize_amount( $customer->purchase_value );
222
+		$stats['purchases']   = absint($customer->purchase_count);
223
+		$stats['total_spent'] = give_sanitize_amount($customer->purchase_value);
224 224
 
225 225
 	}
226 226
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	 *
230 230
 	 * @since 1.7
231 231
 	 */
232
-	$stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user );
232
+	$stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user);
233 233
 
234 234
 	return $stats;
235 235
 }
@@ -247,22 +247,22 @@  discard block
 block discarded – undo
247 247
  *
248 248
  * @return      int - the total number of donations
249 249
  */
250
-function give_count_purchases_of_customer( $user = null ) {
250
+function give_count_purchases_of_customer($user = null) {
251 251
 
252 252
 	//Logged in?
253
-	if ( empty( $user ) ) {
253
+	if (empty($user)) {
254 254
 		$user = get_current_user_id();
255 255
 	}
256 256
 
257 257
 	//Email access?
258
-	if ( empty( $user ) && Give()->email_access->token_email ) {
258
+	if (empty($user) && Give()->email_access->token_email) {
259 259
 		$user = Give()->email_access->token_email;
260 260
 	}
261 261
 
262 262
 
263
-	$stats = ! empty( $user ) ? give_get_purchase_stats_by_user( $user ) : false;
263
+	$stats = ! empty($user) ? give_get_purchase_stats_by_user($user) : false;
264 264
 
265
-	return isset( $stats['purchases'] ) ? $stats['purchases'] : 0;
265
+	return isset($stats['purchases']) ? $stats['purchases'] : 0;
266 266
 }
267 267
 
268 268
 /**
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
  *
276 276
  * @return      float - the total amount the user has spent
277 277
  */
278
-function give_purchase_total_of_user( $user = null ) {
278
+function give_purchase_total_of_user($user = null) {
279 279
 
280
-	$stats = give_get_purchase_stats_by_user( $user );
280
+	$stats = give_get_purchase_stats_by_user($user);
281 281
 
282 282
 	return $stats['total_spent'];
283 283
 }
@@ -293,11 +293,11 @@  discard block
 block discarded – undo
293 293
  *
294 294
  * @return      bool
295 295
  */
296
-function give_validate_username( $username ) {
297
-	$sanitized = sanitize_user( $username, false );
298
-	$valid     = ( $sanitized == $username );
296
+function give_validate_username($username) {
297
+	$sanitized = sanitize_user($username, false);
298
+	$valid     = ($sanitized == $username);
299 299
 
300
-	return (bool) apply_filters( 'give_validate_username', $valid, $username );
300
+	return (bool) apply_filters('give_validate_username', $valid, $username);
301 301
 }
302 302
 
303 303
 
@@ -314,32 +314,32 @@  discard block
 block discarded – undo
314 314
  *
315 315
  * @return      void
316 316
  */
317
-function give_add_past_purchases_to_new_user( $user_id ) {
317
+function give_add_past_purchases_to_new_user($user_id) {
318 318
 
319
-	$email = get_the_author_meta( 'user_email', $user_id );
319
+	$email = get_the_author_meta('user_email', $user_id);
320 320
 
321
-	$payments = give_get_payments( array( 's' => $email ) );
321
+	$payments = give_get_payments(array('s' => $email));
322 322
 
323
-	if ( $payments ) {
324
-		foreach ( $payments as $payment ) {
325
-			if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) {
323
+	if ($payments) {
324
+		foreach ($payments as $payment) {
325
+			if (intval(give_get_payment_user_id($payment->ID)) > 0) {
326 326
 				continue;
327 327
 			} // This payment already associated with an account
328 328
 
329
-			$meta                    = give_get_payment_meta( $payment->ID );
330
-			$meta['user_info']       = maybe_unserialize( $meta['user_info'] );
329
+			$meta                    = give_get_payment_meta($payment->ID);
330
+			$meta['user_info']       = maybe_unserialize($meta['user_info']);
331 331
 			$meta['user_info']['id'] = $user_id;
332 332
 			$meta['user_info']       = $meta['user_info'];
333 333
 
334 334
 			// Store the updated user ID in the payment meta
335
-			give_update_payment_meta( $payment->ID, '_give_payment_meta', $meta );
336
-			give_update_payment_meta( $payment->ID, '_give_payment_user_id', $user_id );
335
+			give_update_payment_meta($payment->ID, '_give_payment_meta', $meta);
336
+			give_update_payment_meta($payment->ID, '_give_payment_user_id', $user_id);
337 337
 		}
338 338
 	}
339 339
 
340 340
 }
341 341
 
342
-add_action( 'user_register', 'give_add_past_purchases_to_new_user' );
342
+add_action('user_register', 'give_add_past_purchases_to_new_user');
343 343
 
344 344
 
345 345
 /**
@@ -361,34 +361,34 @@  discard block
 block discarded – undo
361 361
  * @since         1.0
362 362
  * @return        array - The donor's address, if any
363 363
  */
364
-function give_get_donor_address( $user_id = 0 ) {
365
-	if ( empty( $user_id ) ) {
364
+function give_get_donor_address($user_id = 0) {
365
+	if (empty($user_id)) {
366 366
 		$user_id = get_current_user_id();
367 367
 	}
368 368
 
369
-	$address = get_user_meta( $user_id, '_give_user_address', true );
369
+	$address = get_user_meta($user_id, '_give_user_address', true);
370 370
 
371
-	if ( ! isset( $address['line1'] ) ) {
371
+	if ( ! isset($address['line1'])) {
372 372
 		$address['line1'] = '';
373 373
 	}
374 374
 
375
-	if ( ! isset( $address['line2'] ) ) {
375
+	if ( ! isset($address['line2'])) {
376 376
 		$address['line2'] = '';
377 377
 	}
378 378
 
379
-	if ( ! isset( $address['city'] ) ) {
379
+	if ( ! isset($address['city'])) {
380 380
 		$address['city'] = '';
381 381
 	}
382 382
 
383
-	if ( ! isset( $address['zip'] ) ) {
383
+	if ( ! isset($address['zip'])) {
384 384
 		$address['zip'] = '';
385 385
 	}
386 386
 
387
-	if ( ! isset( $address['country'] ) ) {
387
+	if ( ! isset($address['country'])) {
388 388
 		$address['country'] = '';
389 389
 	}
390 390
 
391
-	if ( ! isset( $address['state'] ) ) {
391
+	if ( ! isset($address['state'])) {
392 392
 		$address['state'] = '';
393 393
 	}
394 394
 
@@ -408,42 +408,42 @@  discard block
 block discarded – undo
408 408
  *
409 409
  * @return        void
410 410
  */
411
-function give_new_user_notification( $user_id = 0, $user_data = array() ) {
411
+function give_new_user_notification($user_id = 0, $user_data = array()) {
412 412
 
413
-	if ( empty( $user_id ) || empty( $user_data ) ) {
413
+	if (empty($user_id) || empty($user_data)) {
414 414
 		return;
415 415
 	}
416
-	$blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
416
+	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
417 417
 
418 418
 	/* translators: %s: site name */
419
-	$message  = sprintf( esc_attr__( 'New user registration on your site %s:', 'give' ), $blogname ) . "\r\n\r\n";
419
+	$message  = sprintf(esc_attr__('New user registration on your site %s:', 'give'), $blogname)."\r\n\r\n";
420 420
 	/* translators: %s: user login */
421
-	$message .= sprintf( esc_attr__( 'Username: %s', 'give' ), $user_data['user_login'] ) . "\r\n\r\n";
421
+	$message .= sprintf(esc_attr__('Username: %s', 'give'), $user_data['user_login'])."\r\n\r\n";
422 422
 	/* translators: %s: user email */
423
-	$message .= sprintf( esc_attr__( 'E-mail: %s', 'give' ), $user_data['user_email'] ) . "\r\n";
423
+	$message .= sprintf(esc_attr__('E-mail: %s', 'give'), $user_data['user_email'])."\r\n";
424 424
 
425 425
 	@wp_mail(
426
-		get_option( 'admin_email' ),
426
+		get_option('admin_email'),
427 427
 		sprintf(
428 428
 			/* translators: %s: site name */
429
-			esc_attr__( '[%s] New User Registration', 'give' ),
429
+			esc_attr__('[%s] New User Registration', 'give'),
430 430
 			$blogname
431 431
 		),
432 432
 		$message
433 433
 	);
434 434
 
435 435
 	/* translators: %s: user login */
436
-	$message  = sprintf( esc_attr__( 'Username: %s', 'give' ), $user_data['user_login'] ) . "\r\n";
436
+	$message  = sprintf(esc_attr__('Username: %s', 'give'), $user_data['user_login'])."\r\n";
437 437
 	/* translators: %s: paswword */
438
-	$message .= sprintf( esc_attr__( 'Password: %s', 'give' ), esc_attr__( '[Password entered during donation]', 'give' ) ) . "\r\n";
438
+	$message .= sprintf(esc_attr__('Password: %s', 'give'), esc_attr__('[Password entered during donation]', 'give'))."\r\n";
439 439
 
440
-	$message .= '<a href="' . wp_login_url() . '"> ' . esc_attr__( 'Click Here to Login &raquo;', 'give' ) . '</a>' . "\r\n";
440
+	$message .= '<a href="'.wp_login_url().'"> '.esc_attr__('Click Here to Login &raquo;', 'give').'</a>'."\r\n";
441 441
 
442 442
 	wp_mail(
443 443
 		$user_data['user_email'],
444 444
 		sprintf(
445 445
 			/* translators: %s: site name */
446
-			esc_attr__( '[%s] Your username and password', 'give' ),
446
+			esc_attr__('[%s] Your username and password', 'give'),
447 447
 			$blogname
448 448
 		),
449 449
 		$message
@@ -451,4 +451,4 @@  discard block
 block discarded – undo
451 451
 
452 452
 }
453 453
 
454
-add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 );
454
+add_action('give_insert_user', 'give_new_user_notification', 10, 2);
Please login to merge, or discard this patch.
includes/misc-functions.php 1 patch
Spacing   +173 added lines, -173 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
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
 	$ret = give_get_option('test_mode', false);
27 27
 
28
-	return (bool) apply_filters( 'give_is_test_mode', $ret );
28
+	return (bool) apply_filters('give_is_test_mode', $ret);
29 29
 
30 30
 }
31 31
 
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
  */
38 38
 function give_get_currency() {
39 39
 
40
-	$currency = give_get_option( 'currency', 'USD' );
40
+	$currency = give_get_option('currency', 'USD');
41 41
 
42
-	return apply_filters( 'give_currency', $currency );
42
+	return apply_filters('give_currency', $currency);
43 43
 }
44 44
 
45 45
 /**
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
  */
52 52
 function give_get_currency_position() {
53 53
 
54
-	$currency_pos = give_get_option( 'currency_position', 'before' );
54
+	$currency_pos = give_get_option('currency_position', 'before');
55 55
 
56
-	return apply_filters( 'give_currency_position', $currency_pos );
56
+	return apply_filters('give_currency_position', $currency_pos);
57 57
 }
58 58
 
59 59
 
@@ -66,39 +66,39 @@  discard block
 block discarded – undo
66 66
 
67 67
 function give_get_currencies() {
68 68
 	$currencies = array(
69
-		'USD'  => esc_html__( 'US Dollars ($)', 'give' ),
70
-		'EUR'  => esc_html__( 'Euros (€)', 'give' ),
71
-		'GBP'  => esc_html__( 'Pounds Sterling (£)', 'give' ),
72
-		'AUD'  => esc_html__( 'Australian Dollars ($)', 'give' ),
73
-		'BRL'  => esc_html__( 'Brazilian Real (R$)', 'give' ),
74
-		'CAD'  => esc_html__( 'Canadian Dollars ($)', 'give' ),
75
-		'CZK'  => esc_html__( 'Czech Koruna (Kč)', 'give' ),
76
-		'DKK'  => esc_html__( 'Danish Krone (kr)', 'give' ),
77
-		'HKD'  => esc_html__( 'Hong Kong Dollar ($)', 'give' ),
78
-		'HUF'  => esc_html__( 'Hungarian Forint (Ft)', 'give' ),
79
-		'ILS'  => esc_html__( 'Israeli Shekel (₪)', 'give' ),
80
-		'JPY'  => esc_html__( 'Japanese Yen (¥)', 'give' ),
81
-		'MYR'  => esc_html__( 'Malaysian Ringgits (RM)', 'give' ),
82
-		'MXN'  => esc_html__( 'Mexican Peso ($)', 'give' ),
83
-		'MAD'  => esc_html__( 'Moroccan Dirham (&#x2e;&#x62f;&#x2e;&#x645;)', 'give' ),
84
-		'NZD'  => esc_html__( 'New Zealand Dollar ($)', 'give' ),
85
-		'NOK'  => esc_html__( 'Norwegian Krone (Kr.)', 'give' ),
86
-		'PHP'  => esc_html__( 'Philippine Pesos (₱)', 'give' ),
87
-		'PLN'  => esc_html__( 'Polish Zloty (zł)', 'give' ),
88
-		'SGD'  => esc_html__( 'Singapore Dollar ($)', 'give' ),
89
-		'KRW'  => esc_html__( 'South Korean Won (₩)', 'give' ),
90
-		'ZAR'  => esc_html__( 'South African Rand (R)', 'give' ),
91
-		'SEK'  => esc_html__( 'Swedish Krona (kr)', 'give' ),
92
-		'CHF'  => esc_html__( 'Swiss Franc (CHF)', 'give' ),
93
-		'TWD'  => esc_html__( 'Taiwan New Dollars (NT$)', 'give' ),
94
-		'THB'  => esc_html__( 'Thai Baht (฿)', 'give' ),
95
-		'INR'  => esc_html__( 'Indian Rupee (₹)', 'give' ),
96
-		'TRY'  => esc_html__( 'Turkish Lira (₺)', 'give' ),
97
-		'RIAL' => esc_html__( 'Iranian Rial (﷼)', 'give' ),
98
-		'RUB'  => esc_html__( 'Russian Rubles (руб)', 'give' )
69
+		'USD'  => esc_html__('US Dollars ($)', 'give'),
70
+		'EUR'  => esc_html__('Euros (€)', 'give'),
71
+		'GBP'  => esc_html__('Pounds Sterling (£)', 'give'),
72
+		'AUD'  => esc_html__('Australian Dollars ($)', 'give'),
73
+		'BRL'  => esc_html__('Brazilian Real (R$)', 'give'),
74
+		'CAD'  => esc_html__('Canadian Dollars ($)', 'give'),
75
+		'CZK'  => esc_html__('Czech Koruna (Kč)', 'give'),
76
+		'DKK'  => esc_html__('Danish Krone (kr)', 'give'),
77
+		'HKD'  => esc_html__('Hong Kong Dollar ($)', 'give'),
78
+		'HUF'  => esc_html__('Hungarian Forint (Ft)', 'give'),
79
+		'ILS'  => esc_html__('Israeli Shekel (₪)', 'give'),
80
+		'JPY'  => esc_html__('Japanese Yen (¥)', 'give'),
81
+		'MYR'  => esc_html__('Malaysian Ringgits (RM)', 'give'),
82
+		'MXN'  => esc_html__('Mexican Peso ($)', 'give'),
83
+		'MAD'  => esc_html__('Moroccan Dirham (&#x2e;&#x62f;&#x2e;&#x645;)', 'give'),
84
+		'NZD'  => esc_html__('New Zealand Dollar ($)', 'give'),
85
+		'NOK'  => esc_html__('Norwegian Krone (Kr.)', 'give'),
86
+		'PHP'  => esc_html__('Philippine Pesos (₱)', 'give'),
87
+		'PLN'  => esc_html__('Polish Zloty (zł)', 'give'),
88
+		'SGD'  => esc_html__('Singapore Dollar ($)', 'give'),
89
+		'KRW'  => esc_html__('South Korean Won (₩)', 'give'),
90
+		'ZAR'  => esc_html__('South African Rand (R)', 'give'),
91
+		'SEK'  => esc_html__('Swedish Krona (kr)', 'give'),
92
+		'CHF'  => esc_html__('Swiss Franc (CHF)', 'give'),
93
+		'TWD'  => esc_html__('Taiwan New Dollars (NT$)', 'give'),
94
+		'THB'  => esc_html__('Thai Baht (฿)', 'give'),
95
+		'INR'  => esc_html__('Indian Rupee (₹)', 'give'),
96
+		'TRY'  => esc_html__('Turkish Lira (₺)', 'give'),
97
+		'RIAL' => esc_html__('Iranian Rial (﷼)', 'give'),
98
+		'RUB'  => esc_html__('Russian Rubles (руб)', 'give')
99 99
 	);
100 100
 
101
-	return apply_filters( 'give_currencies', $currencies );
101
+	return apply_filters('give_currencies', $currencies);
102 102
 }
103 103
 
104 104
 
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
  *
114 114
  * @return string           The symbol to use for the currency
115 115
  */
116
-function give_currency_symbol( $currency = '' ) {
116
+function give_currency_symbol($currency = '') {
117 117
 
118
-	if ( empty( $currency ) ) {
118
+	if (empty($currency)) {
119 119
 		$currency = give_get_currency();
120 120
 	}
121
-	switch ( $currency ) :
121
+	switch ($currency) :
122 122
 		case 'GBP' :
123 123
 			$symbol = '£';
124 124
 			break;
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	endswitch;
198 198
 
199 199
 
200
-	return apply_filters( 'give_currency_symbol', $symbol, $currency );
200
+	return apply_filters('give_currency_symbol', $symbol, $currency);
201 201
 }
202 202
 
203 203
 
@@ -209,13 +209,13 @@  discard block
 block discarded – undo
209 209
  */
210 210
 function give_get_current_page_url() {
211 211
 
212
-	if ( is_front_page() ) {
213
-		$current_url = home_url( '/' );
212
+	if (is_front_page()) {
213
+		$current_url = home_url('/');
214 214
 	} else {
215
-		$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . untrailingslashit( $_SERVER['REQUEST_URI'] ) );
215
+		$current_url = set_url_scheme('http://'.$_SERVER['HTTP_HOST'].untrailingslashit($_SERVER['REQUEST_URI']));
216 216
 	}
217 217
 
218
-	return apply_filters( 'give_get_current_page_url', esc_url( $current_url ) );
218
+	return apply_filters('give_get_current_page_url', esc_url($current_url));
219 219
 }
220 220
 
221 221
 
@@ -236,15 +236,15 @@  discard block
 block discarded – undo
236 236
 	 */
237 237
 	$gateways = give_get_enabled_payment_gateways();
238 238
 
239
-	if ( count( $gateways ) == 1 && ! isset( $gateways['paypal'] ) && ! isset( $gateways['manual'] ) ) {
239
+	if (count($gateways) == 1 && ! isset($gateways['paypal']) && ! isset($gateways['manual'])) {
240 240
 		$ret = true;
241
-	} else if ( count( $gateways ) == 1 ) {
241
+	} else if (count($gateways) == 1) {
242 242
 		$ret = false;
243
-	} else if ( count( $gateways ) == 2 && isset( $gateways['paypal'] ) && isset( $gateways['manual'] ) ) {
243
+	} else if (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) {
244 244
 		$ret = false;
245 245
 	}
246 246
 
247
-	return (bool) apply_filters( 'give_verify_credit_cards', $ret );
247
+	return (bool) apply_filters('give_verify_credit_cards', $ret);
248 248
 }
249 249
 
250 250
 /**
@@ -256,26 +256,26 @@  discard block
 block discarded – undo
256 256
 function give_get_timezone_id() {
257 257
 
258 258
 	// if site timezone string exists, return it
259
-	if ( $timezone = get_option( 'timezone_string' ) ) {
259
+	if ($timezone = get_option('timezone_string')) {
260 260
 		return $timezone;
261 261
 	}
262 262
 
263 263
 	// get UTC offset, if it isn't set return UTC
264
-	if ( ! ( $utc_offset = 3600 * get_option( 'gmt_offset', 0 ) ) ) {
264
+	if ( ! ($utc_offset = 3600 * get_option('gmt_offset', 0))) {
265 265
 		return 'UTC';
266 266
 	}
267 267
 
268 268
 	// attempt to guess the timezone string from the UTC offset
269
-	$timezone = timezone_name_from_abbr( '', $utc_offset );
269
+	$timezone = timezone_name_from_abbr('', $utc_offset);
270 270
 
271 271
 	// last try, guess timezone string manually
272
-	if ( $timezone === false ) {
272
+	if ($timezone === false) {
273 273
 
274
-		$is_dst = date( 'I' );
274
+		$is_dst = date('I');
275 275
 
276
-		foreach ( timezone_abbreviations_list() as $abbr ) {
277
-			foreach ( $abbr as $city ) {
278
-				if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) {
276
+		foreach (timezone_abbreviations_list() as $abbr) {
277
+			foreach ($abbr as $city) {
278
+				if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) {
279 279
 					return $city['timezone_id'];
280 280
 				}
281 281
 			}
@@ -299,17 +299,17 @@  discard block
 block discarded – undo
299 299
 
300 300
 	$ip = '127.0.0.1';
301 301
 
302
-	if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
302
+	if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) {
303 303
 		//check ip from share internet
304 304
 		$ip = $_SERVER['HTTP_CLIENT_IP'];
305
-	} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
305
+	} elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
306 306
 		//to check ip is pass from proxy
307 307
 		$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
308
-	} elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) {
308
+	} elseif ( ! empty($_SERVER['REMOTE_ADDR'])) {
309 309
 		$ip = $_SERVER['REMOTE_ADDR'];
310 310
 	}
311 311
 
312
-	return apply_filters( 'give_get_ip', $ip );
312
+	return apply_filters('give_get_ip', $ip);
313 313
 }
314 314
 
315 315
 
@@ -324,9 +324,9 @@  discard block
 block discarded – undo
324 324
  *
325 325
  * @uses  Give()->session->set()
326 326
  */
327
-function give_set_purchase_session( $purchase_data = array() ) {
328
-	Give()->session->set( 'give_purchase', $purchase_data );
329
-	Give()->session->set( 'give_email', $purchase_data['user_email'] );
327
+function give_set_purchase_session($purchase_data = array()) {
328
+	Give()->session->set('give_purchase', $purchase_data);
329
+	Give()->session->set('give_email', $purchase_data['user_email']);
330 330
 }
331 331
 
332 332
 /**
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
  * @return mixed array | false
341 341
  */
342 342
 function give_get_purchase_session() {
343
-	return Give()->session->get( 'give_purchase' );
343
+	return Give()->session->get('give_purchase');
344 344
 }
345 345
 
346 346
 /**
@@ -355,14 +355,14 @@  discard block
 block discarded – undo
355 355
  *
356 356
  * @return string
357 357
  */
358
-function give_get_purchase_summary( $purchase_data, $email = true ) {
358
+function give_get_purchase_summary($purchase_data, $email = true) {
359 359
 	$summary = '';
360 360
 
361
-	if ( $email ) {
362
-		$summary .= $purchase_data['user_email'] . ' - ';
361
+	if ($email) {
362
+		$summary .= $purchase_data['user_email'].' - ';
363 363
 	}
364 364
 
365
-	$summary .= get_the_title( $purchase_data['post_data']['give-form-id'] );
365
+	$summary .= get_the_title($purchase_data['post_data']['give-form-id']);
366 366
 
367 367
 	return $summary;
368 368
 }
@@ -379,31 +379,31 @@  discard block
 block discarded – undo
379 379
 function give_get_host() {
380 380
 	$host = false;
381 381
 
382
-	if ( defined( 'WPE_APIKEY' ) ) {
382
+	if (defined('WPE_APIKEY')) {
383 383
 		$host = 'WP Engine';
384
-	} elseif ( defined( 'PAGELYBIN' ) ) {
384
+	} elseif (defined('PAGELYBIN')) {
385 385
 		$host = 'Pagely';
386
-	} elseif ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
386
+	} elseif (DB_HOST == 'localhost:/tmp/mysql5.sock') {
387 387
 		$host = 'ICDSoft';
388
-	} elseif ( DB_HOST == 'mysqlv5' ) {
388
+	} elseif (DB_HOST == 'mysqlv5') {
389 389
 		$host = 'NetworkSolutions';
390
-	} elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
390
+	} elseif (strpos(DB_HOST, 'ipagemysql.com') !== false) {
391 391
 		$host = 'iPage';
392
-	} elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
392
+	} elseif (strpos(DB_HOST, 'ipowermysql.com') !== false) {
393 393
 		$host = 'IPower';
394
-	} elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
394
+	} elseif (strpos(DB_HOST, '.gridserver.com') !== false) {
395 395
 		$host = 'MediaTemple Grid';
396
-	} elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) {
396
+	} elseif (strpos(DB_HOST, '.pair.com') !== false) {
397 397
 		$host = 'pair Networks';
398
-	} elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
398
+	} elseif (strpos(DB_HOST, '.stabletransit.com') !== false) {
399 399
 		$host = 'Rackspace Cloud';
400
-	} elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
400
+	} elseif (strpos(DB_HOST, '.sysfix.eu') !== false) {
401 401
 		$host = 'SysFix.eu Power Hosting';
402
-	} elseif ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
402
+	} elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) {
403 403
 		$host = 'Flywheel';
404 404
 	} else {
405 405
 		// Adding a general fallback for data gathering
406
-		$host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME'];
406
+		$host = 'DBH: '.DB_HOST.', SRV: '.$_SERVER['SERVER_NAME'];
407 407
 	}
408 408
 
409 409
 	return $host;
@@ -419,67 +419,67 @@  discard block
 block discarded – undo
419 419
  *
420 420
  * @return bool true if host matches, false if not
421 421
  */
422
-function give_is_host( $host = false ) {
422
+function give_is_host($host = false) {
423 423
 
424 424
 	$return = false;
425 425
 
426
-	if ( $host ) {
427
-		$host = str_replace( ' ', '', strtolower( $host ) );
426
+	if ($host) {
427
+		$host = str_replace(' ', '', strtolower($host));
428 428
 
429
-		switch ( $host ) {
429
+		switch ($host) {
430 430
 			case 'wpengine':
431
-				if ( defined( 'WPE_APIKEY' ) ) {
431
+				if (defined('WPE_APIKEY')) {
432 432
 					$return = true;
433 433
 				}
434 434
 				break;
435 435
 			case 'pagely':
436
-				if ( defined( 'PAGELYBIN' ) ) {
436
+				if (defined('PAGELYBIN')) {
437 437
 					$return = true;
438 438
 				}
439 439
 				break;
440 440
 			case 'icdsoft':
441
-				if ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
441
+				if (DB_HOST == 'localhost:/tmp/mysql5.sock') {
442 442
 					$return = true;
443 443
 				}
444 444
 				break;
445 445
 			case 'networksolutions':
446
-				if ( DB_HOST == 'mysqlv5' ) {
446
+				if (DB_HOST == 'mysqlv5') {
447 447
 					$return = true;
448 448
 				}
449 449
 				break;
450 450
 			case 'ipage':
451
-				if ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
451
+				if (strpos(DB_HOST, 'ipagemysql.com') !== false) {
452 452
 					$return = true;
453 453
 				}
454 454
 				break;
455 455
 			case 'ipower':
456
-				if ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
456
+				if (strpos(DB_HOST, 'ipowermysql.com') !== false) {
457 457
 					$return = true;
458 458
 				}
459 459
 				break;
460 460
 			case 'mediatemplegrid':
461
-				if ( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
461
+				if (strpos(DB_HOST, '.gridserver.com') !== false) {
462 462
 					$return = true;
463 463
 				}
464 464
 				break;
465 465
 			case 'pairnetworks':
466
-				if ( strpos( DB_HOST, '.pair.com' ) !== false ) {
466
+				if (strpos(DB_HOST, '.pair.com') !== false) {
467 467
 					$return = true;
468 468
 				}
469 469
 				break;
470 470
 			case 'rackspacecloud':
471
-				if ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
471
+				if (strpos(DB_HOST, '.stabletransit.com') !== false) {
472 472
 					$return = true;
473 473
 				}
474 474
 				break;
475 475
 			case 'sysfix.eu':
476 476
 			case 'sysfix.eupowerhosting':
477
-				if ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
477
+				if (strpos(DB_HOST, '.sysfix.eu') !== false) {
478 478
 					$return = true;
479 479
 				}
480 480
 				break;
481 481
 			case 'flywheel':
482
-				if ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
482
+				if (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) {
483 483
 					$return = true;
484 484
 				}
485 485
 				break;
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
  * @param string $replacement Optional. The function that should have been called.
513 513
  * @param array  $backtrace   Optional. Contains stack backtrace of deprecated function.
514 514
  */
515
-function _give_deprecated_function( $function, $version, $replacement = null, $backtrace = null ) {
515
+function _give_deprecated_function($function, $version, $replacement = null, $backtrace = null) {
516 516
 
517 517
 	/**
518 518
 	 * Fires while give deprecated function call occurs.
@@ -525,19 +525,19 @@  discard block
 block discarded – undo
525 525
 	 * @param string $replacement Optional. The function that should have been called.
526 526
 	 * @param string $version     The plugin version that deprecated the function.
527 527
 	 */
528
-	do_action( 'give_deprecated_function_run', $function, $replacement, $version );
528
+	do_action('give_deprecated_function_run', $function, $replacement, $version);
529 529
 
530
-	$show_errors = current_user_can( 'manage_options' );
530
+	$show_errors = current_user_can('manage_options');
531 531
 
532 532
 	// Allow plugin to filter the output error trigger
533
-	if ( WP_DEBUG && apply_filters( 'give_deprecated_function_trigger_error', $show_errors ) ) {
534
-		if ( ! is_null( $replacement ) ) {
535
-			trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give' ), $function, $version, $replacement ) );
536
-			trigger_error( print_r( $backtrace, 1 ) ); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
533
+	if (WP_DEBUG && apply_filters('give_deprecated_function_trigger_error', $show_errors)) {
534
+		if ( ! is_null($replacement)) {
535
+			trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give'), $function, $version, $replacement));
536
+			trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
537 537
 			// Alternatively we could dump this to a file.
538 538
 		} else {
539
-			trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give' ), $function, $version ) );
540
-			trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
539
+			trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give'), $function, $version));
540
+			trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
541 541
 			// Alternatively we could dump this to a file.
542 542
 		}
543 543
 	}
@@ -551,8 +551,8 @@  discard block
 block discarded – undo
551 551
  * @return string $post_id
552 552
  */
553 553
 function give_get_admin_post_id() {
554
-	$post_id = isset( $_GET['post'] ) ? $_GET['post'] : null;
555
-	if ( ! $post_id && isset( $_POST['post_id'] ) ) {
554
+	$post_id = isset($_GET['post']) ? $_GET['post'] : null;
555
+	if ( ! $post_id && isset($_POST['post_id'])) {
556 556
 		$post_id = $_POST['post_id'];
557 557
 	}
558 558
 
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
  * @return string Arg separator output
567 567
  */
568 568
 function give_get_php_arg_separator_output() {
569
-	return ini_get( 'arg_separator.output' );
569
+	return ini_get('arg_separator.output');
570 570
 }
571 571
 
572 572
 
@@ -581,10 +581,10 @@  discard block
 block discarded – undo
581 581
  *
582 582
  * @return string Short month name
583 583
  */
584
-function give_month_num_to_name( $n ) {
585
-	$timestamp = mktime( 0, 0, 0, $n, 1, 2005 );
584
+function give_month_num_to_name($n) {
585
+	$timestamp = mktime(0, 0, 0, $n, 1, 2005);
586 586
 
587
-	return date_i18n( "M", $timestamp );
587
+	return date_i18n("M", $timestamp);
588 588
 }
589 589
 
590 590
 
@@ -597,10 +597,10 @@  discard block
 block discarded – undo
597 597
  *
598 598
  * @return bool Whether or not function is disabled.
599 599
  */
600
-function give_is_func_disabled( $function ) {
601
-	$disabled = explode( ',', ini_get( 'disable_functions' ) );
600
+function give_is_func_disabled($function) {
601
+	$disabled = explode(',', ini_get('disable_functions'));
602 602
 
603
-	return in_array( $function, $disabled );
603
+	return in_array($function, $disabled);
604 604
 }
605 605
 
606 606
 
@@ -615,25 +615,25 @@  discard block
 block discarded – undo
615 615
 
616 616
 		<form action="//givewp.us3.list-manage.com/subscribe/post?u=3ccb75d68bda4381e2f45794c&amp;id=12a081aa13" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
617 617
 			<div class="give-newsletter-confirmation">
618
-				<p><?php esc_html_e( 'Thanks for Subscribing!', 'give' ); ?> :)</p>
618
+				<p><?php esc_html_e('Thanks for Subscribing!', 'give'); ?> :)</p>
619 619
 			</div>
620 620
 
621 621
 			<table class="form-table give-newsletter-form">
622 622
 				<tr valign="middle">
623 623
 					<td>
624
-						<label for="mce-EMAIL" class="screen-reader-text"><?php esc_html_e( 'Email Address (required)', 'give' ); ?></label>
625
-						<input type="email" name="EMAIL" id="mce-EMAIL" placeholder="<?php esc_attr_e( 'Email Address (required)', 'give' ); ?>" class="required email" value="">
624
+						<label for="mce-EMAIL" class="screen-reader-text"><?php esc_html_e('Email Address (required)', 'give'); ?></label>
625
+						<input type="email" name="EMAIL" id="mce-EMAIL" placeholder="<?php esc_attr_e('Email Address (required)', 'give'); ?>" class="required email" value="">
626 626
 					</td>
627 627
 					<td>
628
-						<label for="mce-FNAME" class="screen-reader-text"><?php esc_html_e( 'First Name', 'give' ); ?></label>
629
-						<input type="text" name="FNAME" id="mce-FNAME" placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" class="" value="">
628
+						<label for="mce-FNAME" class="screen-reader-text"><?php esc_html_e('First Name', 'give'); ?></label>
629
+						<input type="text" name="FNAME" id="mce-FNAME" placeholder="<?php esc_attr_e('First Name', 'give'); ?>" class="" value="">
630 630
 					</td>
631 631
 					<td>
632
-						<label for="mce-LNAME" class="screen-reader-text"><?php esc_html_e( 'Last Name', 'give' ); ?></label>
633
-						<input type="text" name="LNAME" id="mce-LNAME" placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" class="" value="">
632
+						<label for="mce-LNAME" class="screen-reader-text"><?php esc_html_e('Last Name', 'give'); ?></label>
633
+						<input type="text" name="LNAME" id="mce-LNAME" placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" class="" value="">
634 634
 					</td>
635 635
 					<td>
636
-						<input type="submit" name="subscribe" id="mc-embedded-subscribe" class="button" value="<?php esc_attr_e( 'Subscribe', 'give' ); ?>">
636
+						<input type="submit" name="subscribe" id="mc-embedded-subscribe" class="button" value="<?php esc_attr_e('Subscribe', 'give'); ?>">
637 637
 					</td>
638 638
 				</tr>
639 639
 			</table>
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
 		<a href="https://twitter.com/givewp" class="twitter-follow-button" data-show-count="false"><?php
695 695
 			printf(
696 696
 				/* translators: %s: Give twitter user @givewp */
697
-				esc_html_e( 'Follow %s', 'give' ),
697
+				esc_html_e('Follow %s', 'give'),
698 698
 				'@givewp'
699 699
 			);
700 700
 		?></a>
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
  *
724 724
  * @return mixed
725 725
  */
726
-function give_svg_icons( $icon ) {
726
+function give_svg_icons($icon) {
727 727
 
728 728
 	// Store your SVGs in an associative array
729 729
 	$svgs = array(
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
 	);
736 736
 
737 737
 	// Return the chosen icon's SVG string
738
-	return $svgs[ $icon ];
738
+	return $svgs[$icon];
739 739
 }
740 740
 
741 741
 /**
@@ -747,15 +747,15 @@  discard block
 block discarded – undo
747 747
  *
748 748
  * @return mixed
749 749
  */
750
-function modify_nav_menu_meta_box_object( $post_type ) {
751
-	if ( isset( $post_type->name ) && $post_type->name == 'give_forms' ) {
752
-		$post_type->labels->name = esc_html__( 'Donation Forms', 'give' );
750
+function modify_nav_menu_meta_box_object($post_type) {
751
+	if (isset($post_type->name) && $post_type->name == 'give_forms') {
752
+		$post_type->labels->name = esc_html__('Donation Forms', 'give');
753 753
 	}
754 754
 
755 755
 	return $post_type;
756 756
 }
757 757
 
758
-add_filter( 'nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object' );
758
+add_filter('nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object');
759 759
 
760 760
 
761 761
 /**
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
  * @license    http://opensource.org/licenses/MIT MIT
770 770
  */
771 771
 
772
-if ( ! function_exists( 'array_column' ) ) {
772
+if ( ! function_exists('array_column')) {
773 773
 	/**
774 774
 	 * Returns the values from a single column of the input array, identified by
775 775
 	 * the $columnKey.
@@ -788,56 +788,56 @@  discard block
 block discarded – undo
788 788
 	 *
789 789
 	 * @return array
790 790
 	 */
791
-	function array_column( $input = null, $columnKey = null, $indexKey = null ) {
791
+	function array_column($input = null, $columnKey = null, $indexKey = null) {
792 792
 		// Using func_get_args() in order to check for proper number of
793 793
 		// parameters and trigger errors exactly as the built-in array_column()
794 794
 		// does in PHP 5.5.
795 795
 		$argc   = func_num_args();
796 796
 		$params = func_get_args();
797 797
 
798
-		if ( $argc < 2 ) {
799
-			trigger_error( "array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING );
798
+		if ($argc < 2) {
799
+			trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING);
800 800
 
801 801
 			return null;
802 802
 		}
803 803
 
804
-		if ( ! is_array( $params[0] ) ) {
804
+		if ( ! is_array($params[0])) {
805 805
 			trigger_error(
806
-				'array_column() expects parameter 1 to be array, ' . gettype( $params[0] ) . ' given',
806
+				'array_column() expects parameter 1 to be array, '.gettype($params[0]).' given',
807 807
 				E_USER_WARNING
808 808
 			);
809 809
 
810 810
 			return null;
811 811
 		}
812 812
 
813
-		if ( ! is_int( $params[1] )
814
-		     && ! is_float( $params[1] )
815
-		     && ! is_string( $params[1] )
813
+		if ( ! is_int($params[1])
814
+		     && ! is_float($params[1])
815
+		     && ! is_string($params[1])
816 816
 		     && $params[1] !== null
817
-		     && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) )
817
+		     && ! (is_object($params[1]) && method_exists($params[1], '__toString'))
818 818
 		) {
819
-			trigger_error( 'array_column(): The column key should be either a string or an integer', E_USER_WARNING );
819
+			trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING);
820 820
 
821 821
 			return false;
822 822
 		}
823 823
 
824
-		if ( isset( $params[2] )
825
-		     && ! is_int( $params[2] )
826
-		     && ! is_float( $params[2] )
827
-		     && ! is_string( $params[2] )
828
-		     && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) )
824
+		if (isset($params[2])
825
+		     && ! is_int($params[2])
826
+		     && ! is_float($params[2])
827
+		     && ! is_string($params[2])
828
+		     && ! (is_object($params[2]) && method_exists($params[2], '__toString'))
829 829
 		) {
830
-			trigger_error( 'array_column(): The index key should be either a string or an integer', E_USER_WARNING );
830
+			trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING);
831 831
 
832 832
 			return false;
833 833
 		}
834 834
 
835 835
 		$paramsInput     = $params[0];
836
-		$paramsColumnKey = ( $params[1] !== null ) ? (string) $params[1] : null;
836
+		$paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null;
837 837
 
838 838
 		$paramsIndexKey = null;
839
-		if ( isset( $params[2] ) ) {
840
-			if ( is_float( $params[2] ) || is_int( $params[2] ) ) {
839
+		if (isset($params[2])) {
840
+			if (is_float($params[2]) || is_int($params[2])) {
841 841
 				$paramsIndexKey = (int) $params[2];
842 842
 			} else {
843 843
 				$paramsIndexKey = (string) $params[2];
@@ -846,26 +846,26 @@  discard block
 block discarded – undo
846 846
 
847 847
 		$resultArray = array();
848 848
 
849
-		foreach ( $paramsInput as $row ) {
849
+		foreach ($paramsInput as $row) {
850 850
 			$key    = $value = null;
851 851
 			$keySet = $valueSet = false;
852 852
 
853
-			if ( $paramsIndexKey !== null && array_key_exists( $paramsIndexKey, $row ) ) {
853
+			if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) {
854 854
 				$keySet = true;
855
-				$key    = (string) $row[ $paramsIndexKey ];
855
+				$key    = (string) $row[$paramsIndexKey];
856 856
 			}
857 857
 
858
-			if ( $paramsColumnKey === null ) {
858
+			if ($paramsColumnKey === null) {
859 859
 				$valueSet = true;
860 860
 				$value    = $row;
861
-			} elseif ( is_array( $row ) && array_key_exists( $paramsColumnKey, $row ) ) {
861
+			} elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) {
862 862
 				$valueSet = true;
863
-				$value    = $row[ $paramsColumnKey ];
863
+				$value    = $row[$paramsColumnKey];
864 864
 			}
865 865
 
866
-			if ( $valueSet ) {
867
-				if ( $keySet ) {
868
-					$resultArray[ $key ] = $value;
866
+			if ($valueSet) {
867
+				if ($keySet) {
868
+					$resultArray[$key] = $value;
869 869
 				} else {
870 870
 					$resultArray[] = $value;
871 871
 				}
@@ -887,40 +887,40 @@  discard block
 block discarded – undo
887 887
  *
888 888
  * @return bool Whether the receipt is visible or not.
889 889
  */
890
-function give_can_view_receipt( $payment_key = '' ) {
890
+function give_can_view_receipt($payment_key = '') {
891 891
 
892 892
 	$return = false;
893 893
 
894
-	if ( empty( $payment_key ) ) {
894
+	if (empty($payment_key)) {
895 895
 		return $return;
896 896
 	}
897 897
 
898 898
 	global $give_receipt_args;
899 899
 
900
-	$give_receipt_args['id'] = give_get_purchase_id_by_key( $payment_key );
900
+	$give_receipt_args['id'] = give_get_purchase_id_by_key($payment_key);
901 901
 
902
-	$user_id = (int) give_get_payment_user_id( $give_receipt_args['id'] );
902
+	$user_id = (int) give_get_payment_user_id($give_receipt_args['id']);
903 903
 
904
-	$payment_meta = give_get_payment_meta( $give_receipt_args['id'] );
904
+	$payment_meta = give_get_payment_meta($give_receipt_args['id']);
905 905
 
906
-	if ( is_user_logged_in() ) {
907
-		if ( $user_id === (int) get_current_user_id() ) {
906
+	if (is_user_logged_in()) {
907
+		if ($user_id === (int) get_current_user_id()) {
908 908
 			$return = true;
909
-		} elseif ( wp_get_current_user()->user_email === give_get_payment_user_email( $give_receipt_args['id'] ) ) {
909
+		} elseif (wp_get_current_user()->user_email === give_get_payment_user_email($give_receipt_args['id'])) {
910 910
 			$return = true;
911
-		} elseif ( current_user_can( 'view_give_sensitive_data' ) ) {
911
+		} elseif (current_user_can('view_give_sensitive_data')) {
912 912
 			$return = true;
913 913
 		}
914 914
 	}
915 915
 
916 916
 	$session = give_get_purchase_session();
917
-	if ( ! empty( $session ) && ! is_user_logged_in() ) {
918
-		if ( $session['purchase_key'] === $payment_meta['key'] ) {
917
+	if ( ! empty($session) && ! is_user_logged_in()) {
918
+		if ($session['purchase_key'] === $payment_meta['key']) {
919 919
 			$return = true;
920 920
 		}
921 921
 	}
922 922
 
923
-	return (bool) apply_filters( 'give_can_view_receipt', $return, $payment_key );
923
+	return (bool) apply_filters('give_can_view_receipt', $return, $payment_key);
924 924
 
925 925
 }
926 926
 
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
  *
930 930
  * Fallback in case the calendar extension is not loaded in PHP; Only supports Gregorian calendar
931 931
  */
932
-if ( ! function_exists( 'cal_days_in_month' ) ) {
932
+if ( ! function_exists('cal_days_in_month')) {
933 933
 	/**
934 934
 	 * cal_days_in_month
935 935
 	 *
@@ -939,7 +939,7 @@  discard block
 block discarded – undo
939 939
 	 *
940 940
 	 * @return bool|string
941 941
 	 */
942
-	function cal_days_in_month( $calendar, $month, $year ) {
943
-		return date( 't', mktime( 0, 0, 0, $month, 1, $year ) );
942
+	function cal_days_in_month($calendar, $month, $year) {
943
+		return date('t', mktime(0, 0, 0, $month, 1, $year));
944 944
 	}
945 945
 }
Please login to merge, or discard this patch.
includes/emails/template.php 1 patch
Spacing   +102 added lines, -102 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
 
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
  *
42 42
  * @return string $message Fully formatted message
43 43
  */
44
-function give_email_template_tags( $message, $payment_data, $payment_id, $admin_notice = false ) {
45
-	return give_do_email_tags( $message, $payment_id );
44
+function give_email_template_tags($message, $payment_data, $payment_id, $admin_notice = false) {
45
+	return give_do_email_tags($message, $payment_id);
46 46
 }
47 47
 
48 48
 /**
@@ -56,40 +56,40 @@  discard block
 block discarded – undo
56 56
  *
57 57
  * @return string $message Fully formatted message
58 58
  */
59
-function give_email_preview_template_tags( $message ) {
59
+function give_email_preview_template_tags($message) {
60 60
 
61
-	$price = give_currency_filter( give_format_amount( 10.50 ) );
61
+	$price = give_currency_filter(give_format_amount(10.50));
62 62
 
63 63
 	$gateway = 'PayPal';
64 64
 
65
-	$receipt_id = strtolower( md5( uniqid() ) );
65
+	$receipt_id = strtolower(md5(uniqid()));
66 66
 
67
-	$payment_id = rand( 1, 100 );
67
+	$payment_id = rand(1, 100);
68 68
 
69
-	$receipt_link_url = esc_url( add_query_arg( array( 'payment_key' => $receipt_id, 'give_action' => 'view_receipt' ), home_url() ) );
69
+	$receipt_link_url = esc_url(add_query_arg(array('payment_key' => $receipt_id, 'give_action' => 'view_receipt'), home_url()));
70 70
 	$receipt_link = sprintf(
71 71
 		'<a href="%1$s">%2$s</a>',
72 72
 		$receipt_link_url,
73
-		esc_html__( 'View the receipt in your browser &raquo;', 'give' )
73
+		esc_html__('View the receipt in your browser &raquo;', 'give')
74 74
 	);
75 75
 
76 76
 	$user = wp_get_current_user();
77 77
 
78
-	$message = str_replace( '{name}', $user->display_name, $message );
79
-	$message = str_replace( '{fullname}', $user->display_name, $message );
80
-	$message = str_replace( '{username}', $user->user_login, $message );
81
-	$message = str_replace( '{date}', date( give_date_format(), current_time( 'timestamp' ) ), $message );
82
-	$message = str_replace( '{price}', $price, $message );
83
-	$message = str_replace( '{donation}', esc_html__( 'Sample Donation Form Title', 'give' ), $message );
84
-	$message = str_replace( '{receipt_id}', $receipt_id, $message );
85
-	$message = str_replace( '{payment_method}', $gateway, $message );
86
-	$message = str_replace( '{sitename}', get_bloginfo( 'name' ), $message );
87
-	$message = str_replace( '{payment_id}', $payment_id, $message );
88
-	$message = str_replace( '{receipt_link}', $receipt_link, $message );
89
-	$message = str_replace( '{receipt_link_url}', $receipt_link_url, $message );
90
-	$message = str_replace( '{pdf_receipt}', '<a href="#">Download Receipt</a>', $message );
91
-
92
-	return wpautop( apply_filters( 'give_email_preview_template_tags', $message ) );
78
+	$message = str_replace('{name}', $user->display_name, $message);
79
+	$message = str_replace('{fullname}', $user->display_name, $message);
80
+	$message = str_replace('{username}', $user->user_login, $message);
81
+	$message = str_replace('{date}', date(give_date_format(), current_time('timestamp')), $message);
82
+	$message = str_replace('{price}', $price, $message);
83
+	$message = str_replace('{donation}', esc_html__('Sample Donation Form Title', 'give'), $message);
84
+	$message = str_replace('{receipt_id}', $receipt_id, $message);
85
+	$message = str_replace('{payment_method}', $gateway, $message);
86
+	$message = str_replace('{sitename}', get_bloginfo('name'), $message);
87
+	$message = str_replace('{payment_id}', $payment_id, $message);
88
+	$message = str_replace('{receipt_link}', $receipt_link, $message);
89
+	$message = str_replace('{receipt_link_url}', $receipt_link_url, $message);
90
+	$message = str_replace('{pdf_receipt}', '<a href="#">Download Receipt</a>', $message);
91
+
92
+	return wpautop(apply_filters('give_email_preview_template_tags', $message));
93 93
 }
94 94
 
95 95
 /**
@@ -101,23 +101,23 @@  discard block
 block discarded – undo
101 101
  * @since  1.0
102 102
  * @return array|bool
103 103
  */
104
-function give_email_template_preview( $array ) {
104
+function give_email_template_preview($array) {
105 105
 
106
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
106
+	if ( ! current_user_can('manage_give_settings')) {
107 107
 		return false;
108 108
 	}
109 109
 	$custom_field = array(
110
-		'name' => esc_html__( 'Preview Email', 'give' ),
111
-		'desc' => esc_html__( 'Click the buttons to preview emails.', 'give' ),
110
+		'name' => esc_html__('Preview Email', 'give'),
111
+		'desc' => esc_html__('Click the buttons to preview emails.', 'give'),
112 112
 		'id'   => 'give_email_preview_buttons',
113 113
 		'type' => 'email_preview_buttons'
114 114
 	);
115 115
 
116
-	return give_settings_array_insert( $array, 'donation_subject', array( $custom_field ) );
116
+	return give_settings_array_insert($array, 'donation_subject', array($custom_field));
117 117
 
118 118
 }
119 119
 
120
-add_filter( 'give_settings_emails', 'give_email_template_preview' );
120
+add_filter('give_settings_emails', 'give_email_template_preview');
121 121
 
122 122
 /**
123 123
  * Output Email Template Preview Buttons.
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
 function give_email_preview_buttons_callback() {
130 130
 	ob_start();
131 131
 	?>
132
-	<a href="<?php echo esc_url( add_query_arg( array( 'give_action' => 'preview_email' ), home_url() ) ); ?>" class="button-secondary" target="_blank"><?php esc_html_e( 'Preview Donation Receipt', 'give' ); ?></a>
133
-	<a href="<?php echo wp_nonce_url( add_query_arg( array(
132
+	<a href="<?php echo esc_url(add_query_arg(array('give_action' => 'preview_email'), home_url())); ?>" class="button-secondary" target="_blank"><?php esc_html_e('Preview Donation Receipt', 'give'); ?></a>
133
+	<a href="<?php echo wp_nonce_url(add_query_arg(array(
134 134
 		'give_action'  => 'send_test_email',
135 135
 		'give-message' => 'sent-test-email',
136 136
 		'tag'          => 'emails'
137
-	) ), 'give-test-email' ); ?>" aria-label="<?php esc_attr_e( 'Send demo donation receipt to the emails listed below.', 'give' ); ?>" class="button-secondary"><?php esc_html_e( 'Send Test Email', 'give' ); ?></a>
137
+	)), 'give-test-email'); ?>" aria-label="<?php esc_attr_e('Send demo donation receipt to the emails listed below.', 'give'); ?>" class="button-secondary"><?php esc_html_e('Send Test Email', 'give'); ?></a>
138 138
 	<?php
139 139
 	echo ob_get_clean();
140 140
 }
@@ -147,46 +147,46 @@  discard block
 block discarded – undo
147 147
  */
148 148
 function give_display_email_template_preview() {
149 149
 
150
-	if ( empty( $_GET['give_action'] ) ) {
150
+	if (empty($_GET['give_action'])) {
151 151
 		return;
152 152
 	}
153 153
 
154
-	if ( 'preview_email' !== $_GET['give_action'] ) {
154
+	if ('preview_email' !== $_GET['give_action']) {
155 155
 		return;
156 156
 	}
157 157
 
158
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
158
+	if ( ! current_user_can('manage_give_settings')) {
159 159
 		return;
160 160
 	}
161 161
 
162 162
 
163
-	Give()->emails->heading = esc_html__( 'Donation Receipt', 'give' );
163
+	Give()->emails->heading = esc_html__('Donation Receipt', 'give');
164 164
 
165
-	$payment_id = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : '';
165
+	$payment_id = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : '';
166 166
 
167 167
 	echo give_get_preview_email_header();
168 168
 
169 169
 	//Are we previewing an actual payment?
170
-	if ( ! empty( $payment_id ) ) {
170
+	if ( ! empty($payment_id)) {
171 171
 
172
-		$content = give_get_email_body_content( $payment_id );
172
+		$content = give_get_email_body_content($payment_id);
173 173
 
174
-		$preview_content = give_do_email_tags( $content, $payment_id );
174
+		$preview_content = give_do_email_tags($content, $payment_id);
175 175
 
176 176
 	} else {
177 177
 
178 178
 		//No payment ID, use sample preview content
179
-		$preview_content = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) );
179
+		$preview_content = give_email_preview_template_tags(give_get_email_body_content(0, array()));
180 180
 	}
181 181
 
182 182
 
183
-	echo Give()->emails->build_email( $preview_content );
183
+	echo Give()->emails->build_email($preview_content);
184 184
 
185 185
 	exit;
186 186
 
187 187
 }
188 188
 
189
-add_action( 'init', 'give_display_email_template_preview' );
189
+add_action('init', 'give_display_email_template_preview');
190 190
 
191 191
 /**
192 192
  * Email Template Body.
@@ -198,18 +198,18 @@  discard block
 block discarded – undo
198 198
  *
199 199
  * @return string $email_body Body of the email
200 200
  */
201
-function give_get_email_body_content( $payment_id = 0, $payment_data = array() ) {
201
+function give_get_email_body_content($payment_id = 0, $payment_data = array()) {
202 202
 
203 203
 	$default_email_body = give_get_default_donation_receipt_email();
204 204
 
205
-	$email_content = give_get_option( 'donation_receipt' );
206
-	$email_content = isset( $email_content ) ? stripslashes( $email_content ) : $default_email_body;
205
+	$email_content = give_get_option('donation_receipt');
206
+	$email_content = isset($email_content) ? stripslashes($email_content) : $default_email_body;
207 207
 
208
-	$email_body = wpautop( $email_content );
208
+	$email_body = wpautop($email_content);
209 209
 
210
-	$email_body = apply_filters( "give_donation_receipt_{Give()->emails->get_template()}", $email_body, $payment_id, $payment_data );
210
+	$email_body = apply_filters("give_donation_receipt_{Give()->emails->get_template()}", $email_body, $payment_id, $payment_data);
211 211
 
212
-	return apply_filters( 'give_donation_receipt', $email_body, $payment_id, $payment_data );
212
+	return apply_filters('give_donation_receipt', $email_body, $payment_id, $payment_data);
213 213
 }
214 214
 
215 215
 /**
@@ -222,37 +222,37 @@  discard block
 block discarded – undo
222 222
  *
223 223
  * @return string $email_body Body of the email
224 224
  */
225
-function give_get_donation_notification_body_content( $payment_id = 0, $payment_data = array() ) {
225
+function give_get_donation_notification_body_content($payment_id = 0, $payment_data = array()) {
226 226
 
227
-	$user_info = maybe_unserialize( $payment_data['user_info'] );
228
-	$email     = give_get_payment_user_email( $payment_id );
227
+	$user_info = maybe_unserialize($payment_data['user_info']);
228
+	$email     = give_get_payment_user_email($payment_id);
229 229
 
230
-	if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) {
231
-		$user_data = get_userdata( $user_info['id'] );
230
+	if (isset($user_info['id']) && $user_info['id'] > 0) {
231
+		$user_data = get_userdata($user_info['id']);
232 232
 		$name      = $user_data->display_name;
233
-	} elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) {
234
-		$name = $user_info['first_name'] . ' ' . $user_info['last_name'];
233
+	} elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) {
234
+		$name = $user_info['first_name'].' '.$user_info['last_name'];
235 235
 	} else {
236 236
 		$name = $email;
237 237
 	}
238 238
 
239
-	$gateway = give_get_gateway_admin_label( get_post_meta( $payment_id, '_give_payment_gateway', true ) );
239
+	$gateway = give_get_gateway_admin_label(get_post_meta($payment_id, '_give_payment_gateway', true));
240 240
 
241
-	$default_email_body = esc_html__( 'Hello', 'give' ) . "\n\n";
242
-	$default_email_body .= esc_html__( 'A donation has been made.', 'give' ) . "\n\n";
241
+	$default_email_body = esc_html__('Hello', 'give')."\n\n";
242
+	$default_email_body .= esc_html__('A donation has been made.', 'give')."\n\n";
243 243
 	/* translators: %s: form plural label */
244
-	$default_email_body .= sprintf( esc_html__( '%s sold:', 'give' ), give_get_forms_label_plural() ) . "\n\n";
245
-	$default_email_body .= esc_html__( 'Donor:', 'give' ) . ' ' . html_entity_decode( $name, ENT_COMPAT, 'UTF-8' ) . "\n";
246
-	$default_email_body .= esc_html__( 'Amount:', 'give' ) . ' ' . html_entity_decode( give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ), ENT_COMPAT, 'UTF-8' ) . "\n";
247
-	$default_email_body .= esc_html__( 'Payment Method:', 'give' ) . ' ' . $gateway . "\n\n";
248
-	$default_email_body .= esc_html__( 'Thank you', 'give' );
244
+	$default_email_body .= sprintf(esc_html__('%s sold:', 'give'), give_get_forms_label_plural())."\n\n";
245
+	$default_email_body .= esc_html__('Donor:', 'give').' '.html_entity_decode($name, ENT_COMPAT, 'UTF-8')."\n";
246
+	$default_email_body .= esc_html__('Amount:', 'give').' '.html_entity_decode(give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))), ENT_COMPAT, 'UTF-8')."\n";
247
+	$default_email_body .= esc_html__('Payment Method:', 'give').' '.$gateway."\n\n";
248
+	$default_email_body .= esc_html__('Thank you', 'give');
249 249
 
250
-	$email = give_get_option( 'donation_notification' );
251
-	$email = isset( $email ) ? stripslashes( $email ) : $default_email_body;
250
+	$email = give_get_option('donation_notification');
251
+	$email = isset($email) ? stripslashes($email) : $default_email_body;
252 252
 
253
-	$email_body = give_do_email_tags( $email, $payment_id );
253
+	$email_body = give_do_email_tags($email, $payment_id);
254 254
 
255
-	return apply_filters( 'give_donation_notification', wpautop( $email_body ), $payment_id, $payment_data );
255
+	return apply_filters('give_donation_notification', wpautop($email_body), $payment_id, $payment_data);
256 256
 }
257 257
 
258 258
 /**
@@ -265,19 +265,19 @@  discard block
 block discarded – undo
265 265
  * @since  1.0
266 266
  */
267 267
 function give_render_receipt_in_browser() {
268
-	if ( ! isset( $_GET['payment_key'] ) ) {
269
-		wp_die( esc_html__( 'Missing donation payment key.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
268
+	if ( ! isset($_GET['payment_key'])) {
269
+		wp_die(esc_html__('Missing donation payment key.', 'give'), esc_html__('Error', 'give'), array('response' => 400));
270 270
 	}
271 271
 
272
-	$key = urlencode( $_GET['payment_key'] );
272
+	$key = urlencode($_GET['payment_key']);
273 273
 
274 274
 	ob_start();
275 275
 	//Disallows caching of the page
276
-	header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" );
277
-	header( "Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1
278
-	header( "Cache-Control: post-check=0, pre-check=0", false );
279
-	header( "Pragma: no-cache" ); // HTTP/1.0
280
-	header( "Expires: Sat, 23 Oct 1977 05:00:00 PST" ); // Date in the past
276
+	header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
277
+	header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
278
+	header("Cache-Control: post-check=0, pre-check=0", false);
279
+	header("Pragma: no-cache"); // HTTP/1.0
280
+	header("Expires: Sat, 23 Oct 1977 05:00:00 PST"); // Date in the past
281 281
 	?>
282 282
 	<!DOCTYPE html>
283 283
 	<html lang="en">
@@ -288,10 +288,10 @@  discard block
 block discarded – undo
288 288
 		 *
289 289
 		 * @since 1.0
290 290
 		 */
291
-		do_action( 'give_receipt_head' );
291
+		do_action('give_receipt_head');
292 292
 		?>
293 293
 	</head>
294
-	<body class="<?php echo apply_filters( 'give_receipt_page_body_class', 'give_receipt_page' ); ?>">
294
+	<body class="<?php echo apply_filters('give_receipt_page_body_class', 'give_receipt_page'); ?>">
295 295
 
296 296
 	<div id="give_receipt_wrapper">
297 297
 		<?php
@@ -300,16 +300,16 @@  discard block
 block discarded – undo
300 300
 		 *
301 301
 		 * @since 1.0
302 302
 		 */
303
-		do_action( 'give_render_receipt_in_browser_before' );
303
+		do_action('give_render_receipt_in_browser_before');
304 304
 
305
-		echo do_shortcode( '[give_receipt payment_key=' . $key . ']' );
305
+		echo do_shortcode('[give_receipt payment_key='.$key.']');
306 306
 
307 307
 		/**
308 308
 		 * Fires in the receipt template after the content.
309 309
 		 *
310 310
 		 * @since 1.0
311 311
 		 */
312
-		do_action( 'give_render_receipt_in_browser_after' );
312
+		do_action('give_render_receipt_in_browser_after');
313 313
 		?>
314 314
 	</div>
315 315
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 	 *
320 320
 	 * @since 1.0
321 321
 	 */
322
-	do_action( 'give_receipt_footer' );
322
+	do_action('give_receipt_footer');
323 323
 	?>
324 324
 	</body>
325 325
 	</html>
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 	die();
329 329
 }
330 330
 
331
-add_action( 'give_view_receipt', 'give_render_receipt_in_browser' );
331
+add_action('give_view_receipt', 'give_render_receipt_in_browser');
332 332
 
333 333
 
334 334
 /**
@@ -343,29 +343,29 @@  discard block
 block discarded – undo
343 343
 
344 344
 	//Payment receipt switcher
345 345
 	$payment_count = give_count_payments()->publish;
346
-	$payment_id    = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : '';
346
+	$payment_id    = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : '';
347 347
 
348
-	if ( $payment_count <= 0 ) {
348
+	if ($payment_count <= 0) {
349 349
 		return false;
350 350
 	}
351 351
 
352 352
 	//Get payments.
353
-	$payments = new Give_Payments_Query( array(
353
+	$payments = new Give_Payments_Query(array(
354 354
 		'number' => 100
355
-	) );
355
+	));
356 356
 	$payments = $payments->get_payments();
357 357
 	$options  = array();
358 358
 
359 359
 	//Provide nice human readable options.
360
-	if ( $payments ) {
361
-		$options[0] = esc_html__( '- Select a donation -', 'give' );
362
-		foreach ( $payments as $payment ) {
360
+	if ($payments) {
361
+		$options[0] = esc_html__('- Select a donation -', 'give');
362
+		foreach ($payments as $payment) {
363 363
 
364
-			$options[ $payment->ID ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title );
364
+			$options[$payment->ID] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title);
365 365
 
366 366
 		}
367 367
 	} else {
368
-		$options[0] = esc_html__( 'No donations found.', 'give' );
368
+		$options[0] = esc_html__('No donations found.', 'give');
369 369
 	}
370 370
 
371 371
 	//Start constructing HTML output.
@@ -378,16 +378,16 @@  discard block
 block discarded – undo
378 378
 			        var selected_trans = transactions.options[transactions.selectedIndex];
379 379
 				        console.log(selected_trans);
380 380
 				        if (selected_trans){
381
-				            var url_string = "' . get_bloginfo( 'url' ) . '?give_action=preview_email&preview_id=" + selected_trans.value;
381
+				            var url_string = "' . get_bloginfo('url').'?give_action=preview_email&preview_id=" + selected_trans.value;
382 382
 				                window.location = url_string;
383 383
 				        }
384 384
 				    }
385 385
 			    </script>';
386 386
 
387
-	$transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">' . esc_html__( 'Preview email with a donation:', 'give' ) . '</label>';
387
+	$transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">'.esc_html__('Preview email with a donation:', 'give').'</label>';
388 388
 
389 389
 	//The select field with 100 latest transactions
390
-	$transaction_header .= Give()->html->select( array(
390
+	$transaction_header .= Give()->html->select(array(
391 391
 		'name'             => 'preview_email_payment_id',
392 392
 		'selected'         => $payment_id,
393 393
 		'id'               => 'give_preview_email_payment_id',
@@ -397,12 +397,12 @@  discard block
 block discarded – undo
397 397
 		'select_atts'      => 'onchange="change_preview()">',
398 398
 		'show_option_all'  => false,
399 399
 		'show_option_none' => false
400
-	) );
400
+	));
401 401
 
402 402
 	//Closing tag
403 403
 	$transaction_header .= '</div>';
404 404
 
405
-	return apply_filters( 'give_preview_email_receipt_header', $transaction_header );
405
+	return apply_filters('give_preview_email_receipt_header', $transaction_header);
406 406
 
407 407
 }
408 408
 
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 function give_receipt_head_content() {
417 417
 
418 418
 	//Title.
419
-	$output = '<title>' . esc_html__( 'Donation Receipt', 'give' ) . '</title>';
419
+	$output = '<title>'.esc_html__('Donation Receipt', 'give').'</title>';
420 420
 
421 421
 	//Meta.
422 422
 	$output .= '<meta charset="utf-8"/>
@@ -430,10 +430,10 @@  discard block
 block discarded – undo
430 430
 		<meta name="robots" content="noindex, nofollow"/>';
431 431
 
432 432
 	//CSS
433
-	$output .= '<link rel="stylesheet" href="' . give_get_stylesheet_uri() . '?ver=' . GIVE_VERSION . '">';
433
+	$output .= '<link rel="stylesheet" href="'.give_get_stylesheet_uri().'?ver='.GIVE_VERSION.'">';
434 434
 
435
-	echo apply_filters( 'give_receipt_head_content', $output );
435
+	echo apply_filters('give_receipt_head_content', $output);
436 436
 
437 437
 }
438 438
 
439
-add_action( 'give_receipt_head', 'give_receipt_head_content' );
440 439
\ No newline at end of file
440
+add_action('give_receipt_head', 'give_receipt_head_content');
441 441
\ No newline at end of file
Please login to merge, or discard this patch.