Completed
Push — master ( b2b30d...461219 )
by Matt
20:30
created
includes/class-give-logging.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 	 * @param  array $log_data Log entry data.
224 224
 	 * @param  array $log_meta Log entry meta.
225 225
 	 *
226
-	 * @return bool            True if successful, false otherwise.
226
+	 * @return boolean|null            True if successful, false otherwise.
227 227
 	 */
228 228
 	public function update_log( $log_data = array(), $log_meta = array() ) {
229 229
 
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
  * @param  int    $parent  Parent log. Default is 0.
407 407
  * @param  string $type    Log type. Default is null.
408 408
  *
409
- * @return mixed           ID of the new log entry.
409
+ * @return integer           ID of the new log entry.
410 410
  */
411 411
 function give_record_log( $title = '', $message = '', $parent = 0, $type = null ) {
412 412
 	/* @var Give_Logging $give_logs */
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 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
 
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 	public function __construct() {
37 37
 
38 38
 		// Create the log post type
39
-		add_action( 'init', array( $this, 'register_post_type' ), 1 );
39
+		add_action('init', array($this, 'register_post_type'), 1);
40 40
 
41 41
 		// Create types taxonomy and default types
42
-		add_action( 'init', array( $this, 'register_taxonomy' ), 1 );
42
+		add_action('init', array($this, 'register_taxonomy'), 1);
43 43
 
44 44
 	}
45 45
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	public function register_post_type() {
57 57
 		/* Logs post type */
58 58
 		$log_args = array(
59
-			'labels'              => array( 'name' => esc_html__( 'Logs', 'give' ) ),
59
+			'labels'              => array('name' => esc_html__('Logs', 'give')),
60 60
 			'public'              => false,
61 61
 			'exclude_from_search' => true,
62 62
 			'publicly_queryable'  => false,
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
 			'query_var'           => false,
65 65
 			'rewrite'             => false,
66 66
 			'capability_type'     => 'post',
67
-			'supports'            => array( 'title', 'editor' ),
67
+			'supports'            => array('title', 'editor'),
68 68
 			'can_export'          => true
69 69
 		);
70 70
 
71
-		register_post_type( 'give_log', $log_args );
71
+		register_post_type('give_log', $log_args);
72 72
 	}
73 73
 
74 74
 	/**
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	 * @return void
83 83
 	 */
84 84
 	public function register_taxonomy() {
85
-		register_taxonomy( 'give_log_type', 'give_log', array( 'public' => false ) );
85
+		register_taxonomy('give_log_type', 'give_log', array('public' => false));
86 86
 	}
87 87
 
88 88
 	/**
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 			'api_request'
103 103
 		);
104 104
 
105
-		return apply_filters( 'give_log_types', $terms );
105
+		return apply_filters('give_log_types', $terms);
106 106
 	}
107 107
 
108 108
 	/**
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
 	 *
118 118
 	 * @return bool         Whether log type is valid.
119 119
 	 */
120
-	public function valid_type( $type ) {
121
-		return in_array( $type, $this->log_types() );
120
+	public function valid_type($type) {
121
+		return in_array($type, $this->log_types());
122 122
 	}
123 123
 
124 124
 	/**
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 *
138 138
 	 * @return int             Log ID.
139 139
 	 */
140
-	public function add( $title = '', $message = '', $parent = 0, $type = null ) {
140
+	public function add($title = '', $message = '', $parent = 0, $type = null) {
141 141
 		$log_data = array(
142 142
 			'post_title'   => $title,
143 143
 			'post_content' => $message,
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 			'log_type'     => $type
146 146
 		);
147 147
 
148
-		return $this->insert_log( $log_data );
148
+		return $this->insert_log($log_data);
149 149
 	}
150 150
 
151 151
 	/**
@@ -162,12 +162,12 @@  discard block
 block discarded – undo
162 162
 	 *
163 163
 	 * @return array             An array of the connected logs.
164 164
 	 */
165
-	public function get_logs( $object_id = 0, $type = null, $paged = null ) {
166
-		return $this->get_connected_logs( array(
165
+	public function get_logs($object_id = 0, $type = null, $paged = null) {
166
+		return $this->get_connected_logs(array(
167 167
 			'post_parent' => $object_id,
168 168
 			'paged'       => $paged,
169 169
 			'log_type'    => $type
170
-		) );
170
+		));
171 171
 	}
172 172
 
173 173
 	/**
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 *
182 182
 	 * @return int             The ID of the newly created log item.
183 183
 	 */
184
-	public function insert_log( $log_data = array(), $log_meta = array() ) {
184
+	public function insert_log($log_data = array(), $log_meta = array()) {
185 185
 		$defaults = array(
186 186
 			'post_type'    => 'give_log',
187 187
 			'post_status'  => 'publish',
@@ -190,26 +190,26 @@  discard block
 block discarded – undo
190 190
 			'log_type'     => false
191 191
 		);
192 192
 
193
-		$args = wp_parse_args( $log_data, $defaults );
193
+		$args = wp_parse_args($log_data, $defaults);
194 194
 
195
-		do_action( 'give_pre_insert_log', $log_data, $log_meta );
195
+		do_action('give_pre_insert_log', $log_data, $log_meta);
196 196
 
197 197
 		// Store the log entry
198
-		$log_id = wp_insert_post( $args );
198
+		$log_id = wp_insert_post($args);
199 199
 
200 200
 		// Set the log type, if any
201
-		if ( $log_data['log_type'] && $this->valid_type( $log_data['log_type'] ) ) {
202
-			wp_set_object_terms( $log_id, $log_data['log_type'], 'give_log_type', false );
201
+		if ($log_data['log_type'] && $this->valid_type($log_data['log_type'])) {
202
+			wp_set_object_terms($log_id, $log_data['log_type'], 'give_log_type', false);
203 203
 		}
204 204
 
205 205
 		// Set log meta, if any
206
-		if ( $log_id && ! empty( $log_meta ) ) {
207
-			foreach ( (array) $log_meta as $key => $meta ) {
208
-				update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
206
+		if ($log_id && ! empty($log_meta)) {
207
+			foreach ((array) $log_meta as $key => $meta) {
208
+				update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta);
209 209
 			}
210 210
 		}
211 211
 
212
-		do_action( 'give_post_insert_log', $log_id, $log_data, $log_meta );
212
+		do_action('give_post_insert_log', $log_id, $log_data, $log_meta);
213 213
 
214 214
 		return $log_id;
215 215
 	}
@@ -225,9 +225,9 @@  discard block
 block discarded – undo
225 225
 	 *
226 226
 	 * @return bool            True if successful, false otherwise.
227 227
 	 */
228
-	public function update_log( $log_data = array(), $log_meta = array() ) {
228
+	public function update_log($log_data = array(), $log_meta = array()) {
229 229
 
230
-		do_action( 'give_pre_update_log', $log_data, $log_meta );
230
+		do_action('give_pre_update_log', $log_data, $log_meta);
231 231
 
232 232
 		$defaults = array(
233 233
 			'post_type'   => 'give_log',
@@ -235,20 +235,20 @@  discard block
 block discarded – undo
235 235
 			'post_parent' => 0
236 236
 		);
237 237
 
238
-		$args = wp_parse_args( $log_data, $defaults );
238
+		$args = wp_parse_args($log_data, $defaults);
239 239
 
240 240
 		// Store the log entry
241
-		$log_id = wp_update_post( $args );
241
+		$log_id = wp_update_post($args);
242 242
 
243
-		if ( $log_id && ! empty( $log_meta ) ) {
244
-			foreach ( (array) $log_meta as $key => $meta ) {
245
-				if ( ! empty( $meta ) ) {
246
-					update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
243
+		if ($log_id && ! empty($log_meta)) {
244
+			foreach ((array) $log_meta as $key => $meta) {
245
+				if ( ! empty($meta)) {
246
+					update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta);
247 247
 				}
248 248
 			}
249 249
 		}
250 250
 
251
-		do_action( 'give_post_update_log', $log_id, $log_data, $log_meta );
251
+		do_action('give_post_update_log', $log_id, $log_data, $log_meta);
252 252
 	}
253 253
 
254 254
 	/**
@@ -263,19 +263,19 @@  discard block
 block discarded – undo
263 263
 	 *
264 264
 	 * @return array|false Array if logs were found, false otherwise.
265 265
 	 */
266
-	public function get_connected_logs( $args = array() ) {
266
+	public function get_connected_logs($args = array()) {
267 267
 
268 268
 		$defaults = array(
269 269
 			'post_type'      => 'give_log',
270 270
 			'posts_per_page' => 20,
271 271
 			'post_status'    => 'publish',
272
-			'paged'          => get_query_var( 'paged' ),
272
+			'paged'          => get_query_var('paged'),
273 273
 			'log_type'       => false
274 274
 		);
275 275
 
276
-		$query_args = wp_parse_args( $args, $defaults );
276
+		$query_args = wp_parse_args($args, $defaults);
277 277
 
278
-		if ( $query_args['log_type'] && $this->valid_type( $query_args['log_type'] ) ) {
278
+		if ($query_args['log_type'] && $this->valid_type($query_args['log_type'])) {
279 279
 			$query_args['tax_query'] = array(
280 280
 				array(
281 281
 					'taxonomy' => 'give_log_type',
@@ -285,9 +285,9 @@  discard block
 block discarded – undo
285 285
 			);
286 286
 		}
287 287
 		
288
-		$logs = get_posts( $query_args );
288
+		$logs = get_posts($query_args);
289 289
 	
290
-		if ( $logs ) {
290
+		if ($logs) {
291 291
 			return $logs;
292 292
 		}
293 293
 
@@ -310,17 +310,17 @@  discard block
 block discarded – undo
310 310
 	 *
311 311
 	 * @return int                Log count.
312 312
 	 */
313
-	public function get_log_count( $object_id = 0, $type = null, $meta_query = null, $date_query = null ) {
313
+	public function get_log_count($object_id = 0, $type = null, $meta_query = null, $date_query = null) {
314 314
 
315 315
 		$query_args = array(
316 316
 			'post_parent'    => $object_id,
317 317
 			'post_type'      => 'give_log',
318
-			'posts_per_page' => - 1,
318
+			'posts_per_page' => -1,
319 319
 			'post_status'    => 'publish',
320 320
 			'fields'         => 'ids',
321 321
 		);
322 322
 
323
-		if ( ! empty( $type ) && $this->valid_type( $type ) ) {
323
+		if ( ! empty($type) && $this->valid_type($type)) {
324 324
 			$query_args['tax_query'] = array(
325 325
 				array(
326 326
 					'taxonomy' => 'give_log_type',
@@ -330,15 +330,15 @@  discard block
 block discarded – undo
330 330
 			);
331 331
 		}
332 332
 
333
-		if ( ! empty( $meta_query ) ) {
333
+		if ( ! empty($meta_query)) {
334 334
 			$query_args['meta_query'] = $meta_query;
335 335
 		}
336 336
 
337
-		if ( ! empty( $date_query ) ) {
337
+		if ( ! empty($date_query)) {
338 338
 			$query_args['date_query'] = $date_query;
339 339
 		}
340 340
 
341
-		$logs = new WP_Query( $query_args );
341
+		$logs = new WP_Query($query_args);
342 342
 
343 343
 		return (int) $logs->post_count;
344 344
 	}
@@ -357,16 +357,16 @@  discard block
 block discarded – undo
357 357
 	 *
358 358
 	 * @return void
359 359
 	 */
360
-	public function delete_logs( $object_id = 0, $type = null, $meta_query = null ) {
360
+	public function delete_logs($object_id = 0, $type = null, $meta_query = null) {
361 361
 		$query_args = array(
362 362
 			'post_parent'    => $object_id,
363 363
 			'post_type'      => 'give_log',
364
-			'posts_per_page' => - 1,
364
+			'posts_per_page' => -1,
365 365
 			'post_status'    => 'publish',
366 366
 			'fields'         => 'ids'
367 367
 		);
368 368
 
369
-		if ( ! empty( $type ) && $this->valid_type( $type ) ) {
369
+		if ( ! empty($type) && $this->valid_type($type)) {
370 370
 			$query_args['tax_query'] = array(
371 371
 				array(
372 372
 					'taxonomy' => 'give_log_type',
@@ -376,15 +376,15 @@  discard block
 block discarded – undo
376 376
 			);
377 377
 		}
378 378
 
379
-		if ( ! empty( $meta_query ) ) {
379
+		if ( ! empty($meta_query)) {
380 380
 			$query_args['meta_query'] = $meta_query;
381 381
 		}
382 382
 
383
-		$logs = get_posts( $query_args );
383
+		$logs = get_posts($query_args);
384 384
 
385
-		if ( $logs ) {
386
-			foreach ( $logs as $log ) {
387
-				wp_delete_post( $log, true );
385
+		if ($logs) {
386
+			foreach ($logs as $log) {
387
+				wp_delete_post($log, true);
388 388
 			}
389 389
 		}
390 390
 	}
@@ -408,10 +408,10 @@  discard block
 block discarded – undo
408 408
  *
409 409
  * @return mixed           ID of the new log entry.
410 410
  */
411
-function give_record_log( $title = '', $message = '', $parent = 0, $type = null ) {
411
+function give_record_log($title = '', $message = '', $parent = 0, $type = null) {
412 412
 	/* @var Give_Logging $give_logs */
413 413
 	global $give_logs;
414
-	$log = $give_logs->add( $title, $message, $parent, $type );
414
+	$log = $give_logs->add($title, $message, $parent, $type);
415 415
 
416 416
 	return $log;
417 417
 }
Please login to merge, or discard this patch.
includes/forms/functions.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
  * Used to redirect a user back to the purchase
157 157
  * page if there are errors present.
158 158
  *
159
- * @param array $args
159
+ * @param string $args
160 160
  *
161 161
  * @access public
162 162
  * @since  1.0
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
  *
391 391
  * @param int $form_id Give Form ID
392 392
  *
393
- * @return int $earnings Earnings for a certain form
393
+ * @return double $earnings Earnings for a certain form
394 394
  */
395 395
 function give_get_form_earnings_stats( $form_id = 0 ) {
396 396
 	$give_form = new Give_Donate_Form( $form_id );
Please login to merge, or discard this patch.
Spacing   +193 added lines, -193 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,14 +23,14 @@  discard block
 block discarded – undo
23 23
 
24 24
 	global $typenow;
25 25
 
26
-	if ( $typenow != 'give_forms' ) {
26
+	if ($typenow != 'give_forms') {
27 27
 		return true;
28 28
 	}
29 29
 
30 30
 	return false;
31 31
 }
32 32
 
33
-add_filter( 'give_shortcode_button_condition', 'give_shortcode_button_condition' );
33
+add_filter('give_shortcode_button_condition', 'give_shortcode_button_condition');
34 34
 
35 35
 
36 36
 /**
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
  *
41 41
  * @return int|false
42 42
  */
43
-function get_form_id_from_args( $args ) {
43
+function get_form_id_from_args($args) {
44 44
 
45
-	if ( isset( $args['form_id'] ) && $args['form_id'] != 0 ) {
45
+	if (isset($args['form_id']) && $args['form_id'] != 0) {
46 46
 
47
-		return intval( $args['form_id'] );
47
+		return intval($args['form_id']);
48 48
 	}
49 49
 
50 50
 	return false;
@@ -59,23 +59,23 @@  discard block
 block discarded – undo
59 59
  *
60 60
  * @return bool
61 61
  */
62
-function give_is_float_labels_enabled( $args ) {
62
+function give_is_float_labels_enabled($args) {
63 63
 
64 64
 	$float_labels = '';
65 65
 
66
-	if ( ! empty( $args['float_labels'] ) ) {
66
+	if ( ! empty($args['float_labels'])) {
67 67
 		$float_labels = $args['float_labels'];
68 68
 	}
69 69
 
70
-	if ( empty( $float_labels ) ) {
71
-		$float_labels = get_post_meta( $args['form_id'], '_give_form_floating_labels', true );
70
+	if (empty($float_labels)) {
71
+		$float_labels = get_post_meta($args['form_id'], '_give_form_floating_labels', true);
72 72
 	}
73 73
 
74
-	if ( empty( $float_labels ) ) {
75
-		$float_labels = give_get_option( 'enable_floatlabels' ) ? 'enabled' : 'disabled';
74
+	if (empty($float_labels)) {
75
+		$float_labels = give_get_option('enable_floatlabels') ? 'enabled' : 'disabled';
76 76
 	}
77 77
 
78
-	return ( $float_labels == 'enabled' ) ? true : false;
78
+	return ($float_labels == 'enabled') ? true : false;
79 79
 }
80 80
 
81 81
 /**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
 	$can_checkout = true;
93 93
 
94
-	return (bool) apply_filters( 'give_can_checkout', $can_checkout );
94
+	return (bool) apply_filters('give_can_checkout', $can_checkout);
95 95
 }
96 96
 
97 97
 /**
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 function give_get_success_page_uri() {
106 106
 	global $give_options;
107 107
 
108
-	$success_page = isset( $give_options['success_page'] ) ? get_permalink( absint( $give_options['success_page'] ) ) : get_bloginfo( 'url' );
108
+	$success_page = isset($give_options['success_page']) ? get_permalink(absint($give_options['success_page'])) : get_bloginfo('url');
109 109
 
110
-	return apply_filters( 'give_get_success_page_uri', $success_page );
110
+	return apply_filters('give_get_success_page_uri', $success_page);
111 111
 }
112 112
 
113 113
 /**
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
  */
120 120
 function give_is_success_page() {
121 121
 	global $give_options;
122
-	$is_success_page = isset( $give_options['success_page'] ) ? is_page( $give_options['success_page'] ) : false;
122
+	$is_success_page = isset($give_options['success_page']) ? is_page($give_options['success_page']) : false;
123 123
 
124
-	return apply_filters( 'give_is_success_page', $is_success_page );
124
+	return apply_filters('give_is_success_page', $is_success_page);
125 125
 }
126 126
 
127 127
 /**
@@ -135,17 +135,17 @@  discard block
 block discarded – undo
135 135
  * @since       1.0
136 136
  * @return      void
137 137
  */
138
-function give_send_to_success_page( $query_string = null ) {
138
+function give_send_to_success_page($query_string = null) {
139 139
 
140 140
 	$redirect = give_get_success_page_uri();
141 141
 
142
-	if ( $query_string ) {
142
+	if ($query_string) {
143 143
 		$redirect .= $query_string;
144 144
 	}
145 145
 
146
-	$gateway = isset( $_REQUEST['give-gateway'] ) ? $_REQUEST['give-gateway'] : '';
146
+	$gateway = isset($_REQUEST['give-gateway']) ? $_REQUEST['give-gateway'] : '';
147 147
 
148
-	wp_redirect( apply_filters( 'give_success_page_redirect', $redirect, $gateway, $query_string ) );
148
+	wp_redirect(apply_filters('give_success_page_redirect', $redirect, $gateway, $query_string));
149 149
 	give_die();
150 150
 }
151 151
 
@@ -162,20 +162,20 @@  discard block
 block discarded – undo
162 162
  * @since  1.0
163 163
  * @return Void
164 164
  */
165
-function give_send_back_to_checkout( $args = array() ) {
165
+function give_send_back_to_checkout($args = array()) {
166 166
 
167
-	$url = isset( $_POST['give-current-url'] ) ? sanitize_text_field( $_POST['give-current-url'] ) : '';
167
+	$url = isset($_POST['give-current-url']) ? sanitize_text_field($_POST['give-current-url']) : '';
168 168
 
169 169
 	//Set the form_id.
170
-	if ( isset( $_POST['give-form-id'] ) ) {
171
-		$form_id = sanitize_text_field( $_POST['give-form-id'] );
170
+	if (isset($_POST['give-form-id'])) {
171
+		$form_id = sanitize_text_field($_POST['give-form-id']);
172 172
 	} else {
173 173
 		$form_id = 0;
174 174
 	}
175 175
 
176 176
 	//Need a URL to continue. If none, redirect back to single form.
177
-	if ( empty( $url ) ) {
178
-		wp_safe_redirect( get_permalink( $form_id ) );
177
+	if (empty($url)) {
178
+		wp_safe_redirect(get_permalink($form_id));
179 179
 		give_die();
180 180
 	}
181 181
 
@@ -184,36 +184,36 @@  discard block
 block discarded – undo
184 184
 	);
185 185
 
186 186
 	// Check for backward compatibility.
187
-	if ( is_string( $args ) ) {
188
-		$args = str_replace( '?', '', $args );
187
+	if (is_string($args)) {
188
+		$args = str_replace('?', '', $args);
189 189
 	}
190 190
 
191
-	$args = wp_parse_args( $args, $defaults );
191
+	$args = wp_parse_args($args, $defaults);
192 192
 
193 193
 	// Merge URL query with $args to maintain third-party URL parameters after redirect.
194
-	$url_data = wp_parse_url( $url );
194
+	$url_data = wp_parse_url($url);
195 195
 
196 196
 	//Check if an array to prevent notices before parsing.
197
-	if ( isset( $url_data['query'] ) && ! empty( $url_data['query'] ) ) {
198
-		parse_str( $url_data['query'], $query );
197
+	if (isset($url_data['query']) && ! empty($url_data['query'])) {
198
+		parse_str($url_data['query'], $query);
199 199
 
200 200
 		//Precaution: don't allow any CC info.
201
-		unset( $query['card_number'] );
202
-		unset( $query['card_cvc'] );
201
+		unset($query['card_number']);
202
+		unset($query['card_cvc']);
203 203
 
204 204
 	} else {
205 205
 		//No $url_data so pass empty array.
206 206
 		$query = array();
207 207
 	}
208 208
 
209
-	$new_query        = array_merge( $args, $query );
210
-	$new_query_string = http_build_query( $new_query );
209
+	$new_query        = array_merge($args, $query);
210
+	$new_query_string = http_build_query($new_query);
211 211
 
212 212
 	// Assemble URL parts.
213
-	$redirect = home_url( '/' . $url_data['path'] . '?' . $new_query_string . '#give-form-' . $form_id . '-wrap' );
213
+	$redirect = home_url('/'.$url_data['path'].'?'.$new_query_string.'#give-form-'.$form_id.'-wrap');
214 214
 
215 215
 	//Redirect them.
216
-	wp_safe_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) );
216
+	wp_safe_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args));
217 217
 	give_die();
218 218
 	
219 219
 }
@@ -229,16 +229,16 @@  discard block
 block discarded – undo
229 229
  * @since       1.0
230 230
  * @return      string
231 231
  */
232
-function give_get_success_page_url( $query_string = null ) {
232
+function give_get_success_page_url($query_string = null) {
233 233
 
234
-	$success_page = give_get_option( 'success_page', 0 );
235
-	$success_page = get_permalink( $success_page );
234
+	$success_page = give_get_option('success_page', 0);
235
+	$success_page = get_permalink($success_page);
236 236
 
237
-	if ( $query_string ) {
237
+	if ($query_string) {
238 238
 		$success_page .= $query_string;
239 239
 	}
240 240
 
241
-	return apply_filters( 'give_success_page_url', $success_page );
241
+	return apply_filters('give_success_page_url', $success_page);
242 242
 
243 243
 }
244 244
 
@@ -252,15 +252,15 @@  discard block
 block discarded – undo
252 252
  *
253 253
  * @return mixed|void Full URL to the Transaction Failed page, if present, home page if it doesn't exist
254 254
  */
255
-function give_get_failed_transaction_uri( $extras = false ) {
255
+function give_get_failed_transaction_uri($extras = false) {
256 256
 	global $give_options;
257 257
 
258
-	$uri = ! empty( $give_options['failure_page'] ) ? trailingslashit( get_permalink( $give_options['failure_page'] ) ) : home_url();
259
-	if ( $extras ) {
258
+	$uri = ! empty($give_options['failure_page']) ? trailingslashit(get_permalink($give_options['failure_page'])) : home_url();
259
+	if ($extras) {
260 260
 		$uri .= $extras;
261 261
 	}
262 262
 
263
-	return apply_filters( 'give_get_failed_transaction_uri', $uri );
263
+	return apply_filters('give_get_failed_transaction_uri', $uri);
264 264
 }
265 265
 
266 266
 /**
@@ -271,9 +271,9 @@  discard block
 block discarded – undo
271 271
  */
272 272
 function give_is_failed_transaction_page() {
273 273
 	global $give_options;
274
-	$ret = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false;
274
+	$ret = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false;
275 275
 
276
-	return apply_filters( 'give_is_failure_page', $ret );
276
+	return apply_filters('give_is_failure_page', $ret);
277 277
 }
278 278
 
279 279
 /**
@@ -285,18 +285,18 @@  discard block
 block discarded – undo
285 285
  */
286 286
 function give_listen_for_failed_payments() {
287 287
 
288
-	$failed_page = give_get_option( 'failure_page', 0 );
288
+	$failed_page = give_get_option('failure_page', 0);
289 289
 
290
-	if ( ! empty( $failed_page ) && is_page( $failed_page ) && ! empty( $_GET['payment-id'] ) ) {
290
+	if ( ! empty($failed_page) && is_page($failed_page) && ! empty($_GET['payment-id'])) {
291 291
 
292
-		$payment_id = absint( $_GET['payment-id'] );
293
-		give_update_payment_status( $payment_id, 'failed' );
292
+		$payment_id = absint($_GET['payment-id']);
293
+		give_update_payment_status($payment_id, 'failed');
294 294
 
295 295
 	}
296 296
 
297 297
 }
298 298
 
299
-add_action( 'template_redirect', 'give_listen_for_failed_payments' );
299
+add_action('template_redirect', 'give_listen_for_failed_payments');
300 300
 
301 301
 
302 302
 /**
@@ -309,11 +309,11 @@  discard block
 block discarded – undo
309 309
  * @since       1.0
310 310
  * @return      bool
311 311
  */
312
-function give_field_is_required( $field = '', $form_id ) {
312
+function give_field_is_required($field = '', $form_id) {
313 313
 
314
-	$required_fields = give_purchase_form_required_fields( $form_id );
314
+	$required_fields = give_purchase_form_required_fields($form_id);
315 315
 
316
-	return array_key_exists( $field, $required_fields );
316
+	return array_key_exists($field, $required_fields);
317 317
 }
318 318
 
319 319
 /**
@@ -331,14 +331,14 @@  discard block
 block discarded – undo
331 331
  *
332 332
  * @return void
333 333
  */
334
-function give_record_sale_in_log( $give_form_id = 0, $payment_id, $price_id = false, $sale_date = null ) {
334
+function give_record_sale_in_log($give_form_id = 0, $payment_id, $price_id = false, $sale_date = null) {
335 335
 	global $give_logs;
336 336
 
337 337
 	$log_data = array(
338 338
 		'post_parent'   => $give_form_id,
339 339
 		'log_type'      => 'sale',
340
-		'post_date'     => isset( $sale_date ) ? $sale_date : null,
341
-		'post_date_gmt' => isset( $sale_date ) ? $sale_date : null
340
+		'post_date'     => isset($sale_date) ? $sale_date : null,
341
+		'post_date_gmt' => isset($sale_date) ? $sale_date : null
342 342
 	);
343 343
 
344 344
 	$log_meta = array(
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 		'price_id'   => (int) $price_id
347 347
 	);
348 348
 
349
-	$give_logs->insert_log( $log_data, $log_meta );
349
+	$give_logs->insert_log($log_data, $log_meta);
350 350
 }
351 351
 
352 352
 
@@ -360,11 +360,11 @@  discard block
 block discarded – undo
360 360
  *
361 361
  * @return bool|int
362 362
  */
363
-function give_increase_purchase_count( $form_id = 0, $quantity = 1 ) {
363
+function give_increase_purchase_count($form_id = 0, $quantity = 1) {
364 364
 	$quantity = (int) $quantity;
365
-	$form     = new Give_Donate_Form( $form_id );
365
+	$form     = new Give_Donate_Form($form_id);
366 366
 
367
-	return $form->increase_sales( $quantity );
367
+	return $form->increase_sales($quantity);
368 368
 }
369 369
 
370 370
 /**
@@ -377,11 +377,11 @@  discard block
 block discarded – undo
377 377
  *
378 378
  * @return bool|int
379 379
  */
380
-function give_decrease_purchase_count( $form_id = 0, $quantity = 1 ) {
380
+function give_decrease_purchase_count($form_id = 0, $quantity = 1) {
381 381
 	$quantity = (int) $quantity;
382
-	$form     = new Give_Donate_Form( $form_id );
382
+	$form     = new Give_Donate_Form($form_id);
383 383
 
384
-	return $form->decrease_sales( $quantity );
384
+	return $form->decrease_sales($quantity);
385 385
 }
386 386
 
387 387
 /**
@@ -394,10 +394,10 @@  discard block
 block discarded – undo
394 394
  *
395 395
  * @return bool|int
396 396
  */
397
-function give_increase_earnings( $give_form_id = 0, $amount ) {
398
-	$form = new Give_Donate_Form( $give_form_id );
397
+function give_increase_earnings($give_form_id = 0, $amount) {
398
+	$form = new Give_Donate_Form($give_form_id);
399 399
 
400
-	return $form->increase_earnings( $amount );
400
+	return $form->increase_earnings($amount);
401 401
 }
402 402
 
403 403
 /**
@@ -410,10 +410,10 @@  discard block
 block discarded – undo
410 410
  *
411 411
  * @return bool|int
412 412
  */
413
-function give_decrease_earnings( $form_id = 0, $amount ) {
414
-	$form = new Give_Donate_Form( $form_id );
413
+function give_decrease_earnings($form_id = 0, $amount) {
414
+	$form = new Give_Donate_Form($form_id);
415 415
 
416
-	return $form->decrease_earnings( $amount );
416
+	return $form->decrease_earnings($amount);
417 417
 }
418 418
 
419 419
 
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
  *
427 427
  * @return int $earnings Earnings for a certain form
428 428
  */
429
-function give_get_form_earnings_stats( $form_id = 0 ) {
430
-	$give_form = new Give_Donate_Form( $form_id );
429
+function give_get_form_earnings_stats($form_id = 0) {
430
+	$give_form = new Give_Donate_Form($form_id);
431 431
 
432 432
 	return $give_form->earnings;
433 433
 }
@@ -442,8 +442,8 @@  discard block
 block discarded – undo
442 442
  *
443 443
  * @return int $sales Amount of sales for a certain form
444 444
  */
445
-function give_get_form_sales_stats( $give_form_id = 0 ) {
446
-	$give_form = new Give_Donate_Form( $give_form_id );
445
+function give_get_form_sales_stats($give_form_id = 0) {
446
+	$give_form = new Give_Donate_Form($give_form_id);
447 447
 
448 448
 	return $give_form->sales;
449 449
 }
@@ -458,16 +458,16 @@  discard block
 block discarded – undo
458 458
  *
459 459
  * @return float $sales Average monthly sales
460 460
  */
461
-function give_get_average_monthly_form_sales( $form_id = 0 ) {
462
-	$sales        = give_get_form_sales_stats( $form_id );
463
-	$release_date = get_post_field( 'post_date', $form_id );
461
+function give_get_average_monthly_form_sales($form_id = 0) {
462
+	$sales        = give_get_form_sales_stats($form_id);
463
+	$release_date = get_post_field('post_date', $form_id);
464 464
 
465
-	$diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) );
465
+	$diff = abs(current_time('timestamp') - strtotime($release_date));
466 466
 
467
-	$months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication
467
+	$months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication
468 468
 
469
-	if ( $months > 0 ) {
470
-		$sales = ( $sales / $months );
469
+	if ($months > 0) {
470
+		$sales = ($sales / $months);
471 471
 	}
472 472
 
473 473
 	return $sales;
@@ -483,16 +483,16 @@  discard block
 block discarded – undo
483 483
  *
484 484
  * @return float $earnings Average monthly earnings
485 485
  */
486
-function give_get_average_monthly_form_earnings( $form_id = 0 ) {
487
-	$earnings     = give_get_form_earnings_stats( $form_id );
488
-	$release_date = get_post_field( 'post_date', $form_id );
486
+function give_get_average_monthly_form_earnings($form_id = 0) {
487
+	$earnings     = give_get_form_earnings_stats($form_id);
488
+	$release_date = get_post_field('post_date', $form_id);
489 489
 
490
-	$diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) );
490
+	$diff = abs(current_time('timestamp') - strtotime($release_date));
491 491
 
492
-	$months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication
492
+	$months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication
493 493
 
494
-	if ( $months > 0 ) {
495
-		$earnings = ( $earnings / $months );
494
+	if ($months > 0) {
495
+		$earnings = ($earnings / $months);
496 496
 	}
497 497
 
498 498
 	return $earnings < 0 ? 0 : $earnings;
@@ -512,25 +512,25 @@  discard block
 block discarded – undo
512 512
  *
513 513
  * @return string $price_name Name of the price option
514 514
  */
515
-function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0 ) {
515
+function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0) {
516 516
 
517
-	$prices     = give_get_variable_prices( $form_id );
517
+	$prices     = give_get_variable_prices($form_id);
518 518
 	$price_name = '';
519 519
 
520
-	foreach ( $prices as $price ) {
520
+	foreach ($prices as $price) {
521 521
 
522
-		if ( intval( $price['_give_id']['level_id'] ) == intval( $price_id ) ) {
522
+		if (intval($price['_give_id']['level_id']) == intval($price_id)) {
523 523
 
524
-			$price_text     = isset( $price['_give_text'] ) ? $price['_give_text'] : '';
525
-			$price_fallback = give_currency_filter( give_format_amount( $price['_give_amount'] ) );
526
-			$price_name     = ! empty( $price_text ) ? $price_text : $price_fallback;
524
+			$price_text     = isset($price['_give_text']) ? $price['_give_text'] : '';
525
+			$price_fallback = give_currency_filter(give_format_amount($price['_give_amount']));
526
+			$price_name     = ! empty($price_text) ? $price_text : $price_fallback;
527 527
 
528 528
 		}
529 529
 
530 530
 	}
531 531
 
532 532
 
533
-	return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id );
533
+	return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id);
534 534
 }
535 535
 
536 536
 
@@ -543,14 +543,14 @@  discard block
 block discarded – undo
543 543
  *
544 544
  * @return string $range A fully formatted price range
545 545
  */
546
-function give_price_range( $form_id = 0 ) {
547
-	$low   = give_get_lowest_price_option( $form_id );
548
-	$high  = give_get_highest_price_option( $form_id );
549
-	$range = '<span class="give_price_range_low">' . give_currency_filter( give_format_amount( $low ) ) . '</span>';
546
+function give_price_range($form_id = 0) {
547
+	$low   = give_get_lowest_price_option($form_id);
548
+	$high  = give_get_highest_price_option($form_id);
549
+	$range = '<span class="give_price_range_low">'.give_currency_filter(give_format_amount($low)).'</span>';
550 550
 	$range .= '<span class="give_price_range_sep">&nbsp;&ndash;&nbsp;</span>';
551
-	$range .= '<span class="give_price_range_high">' . give_currency_filter( give_format_amount( $high ) ) . '</span>';
551
+	$range .= '<span class="give_price_range_high">'.give_currency_filter(give_format_amount($high)).'</span>';
552 552
 
553
-	return apply_filters( 'give_price_range', $range, $form_id, $low, $high );
553
+	return apply_filters('give_price_range', $range, $form_id, $low, $high);
554 554
 }
555 555
 
556 556
 
@@ -565,36 +565,36 @@  discard block
 block discarded – undo
565 565
  *
566 566
  * @return int ID of the lowest price
567 567
  */
568
-function give_get_lowest_price_id( $form_id = 0 ) {
568
+function give_get_lowest_price_id($form_id = 0) {
569 569
 
570
-	if ( empty( $form_id ) ) {
570
+	if (empty($form_id)) {
571 571
 		$form_id = get_the_ID();
572 572
 	}
573 573
 
574
-	if ( ! give_has_variable_prices( $form_id ) ) {
575
-		return give_get_form_price( $form_id );
574
+	if ( ! give_has_variable_prices($form_id)) {
575
+		return give_get_form_price($form_id);
576 576
 	}
577 577
 
578
-	$prices = give_get_variable_prices( $form_id );
578
+	$prices = give_get_variable_prices($form_id);
579 579
 
580 580
 	$low    = 0.00;
581 581
 	$min_id = 1;
582 582
 
583
-	if ( ! empty( $prices ) ) {
583
+	if ( ! empty($prices)) {
584 584
 
585
-		foreach ( $prices as $key => $price ) {
585
+		foreach ($prices as $key => $price) {
586 586
 
587
-			if ( empty( $price['_give_amount'] ) ) {
587
+			if (empty($price['_give_amount'])) {
588 588
 				continue;
589 589
 			}
590 590
 
591
-			if ( ! isset( $min ) ) {
591
+			if ( ! isset($min)) {
592 592
 				$min = $price['_give_amount'];
593 593
 			} else {
594
-				$min = min( $min, $price['_give_amount'] );
594
+				$min = min($min, $price['_give_amount']);
595 595
 			}
596 596
 
597
-			if ( $price['_give_amount'] == $min ) {
597
+			if ($price['_give_amount'] == $min) {
598 598
 				$min_id = $price['_give_id']['level_id'];
599 599
 			}
600 600
 		}
@@ -612,43 +612,43 @@  discard block
 block discarded – undo
612 612
  *
613 613
  * @return float Amount of the lowest price
614 614
  */
615
-function give_get_lowest_price_option( $form_id = 0 ) {
616
-	if ( empty( $form_id ) ) {
615
+function give_get_lowest_price_option($form_id = 0) {
616
+	if (empty($form_id)) {
617 617
 		$form_id = get_the_ID();
618 618
 	}
619 619
 
620
-	if ( ! give_has_variable_prices( $form_id ) ) {
621
-		return give_get_form_price( $form_id );
620
+	if ( ! give_has_variable_prices($form_id)) {
621
+		return give_get_form_price($form_id);
622 622
 	}
623 623
 
624
-	$prices = give_get_variable_prices( $form_id );
624
+	$prices = give_get_variable_prices($form_id);
625 625
 
626 626
 	$low = 0.00;
627 627
 
628
-	if ( ! empty( $prices ) ) {
628
+	if ( ! empty($prices)) {
629 629
 
630
-		foreach ( $prices as $key => $price ) {
630
+		foreach ($prices as $key => $price) {
631 631
 
632
-			if ( empty( $price['_give_amount'] ) ) {
632
+			if (empty($price['_give_amount'])) {
633 633
 				continue;
634 634
 			}
635 635
 
636
-			if ( ! isset( $min ) ) {
636
+			if ( ! isset($min)) {
637 637
 				$min = $price['_give_amount'];
638 638
 			} else {
639
-				$min = min( $min, give_sanitize_amount( $price['_give_amount'] ) );
639
+				$min = min($min, give_sanitize_amount($price['_give_amount']));
640 640
 			}
641 641
 
642
-			if ( $price['_give_amount'] == $min ) {
642
+			if ($price['_give_amount'] == $min) {
643 643
 				$min_id = $key;
644 644
 			}
645 645
 		}
646 646
 
647
-		$low = $prices[ $min_id ]['_give_amount'];
647
+		$low = $prices[$min_id]['_give_amount'];
648 648
 
649 649
 	}
650 650
 
651
-	return give_sanitize_amount( $low );
651
+	return give_sanitize_amount($low);
652 652
 }
653 653
 
654 654
 /**
@@ -660,41 +660,41 @@  discard block
 block discarded – undo
660 660
  *
661 661
  * @return float Amount of the highest price
662 662
  */
663
-function give_get_highest_price_option( $form_id = 0 ) {
663
+function give_get_highest_price_option($form_id = 0) {
664 664
 
665
-	if ( empty( $form_id ) ) {
665
+	if (empty($form_id)) {
666 666
 		$form_id = get_the_ID();
667 667
 	}
668 668
 
669
-	if ( ! give_has_variable_prices( $form_id ) ) {
670
-		return give_get_form_price( $form_id );
669
+	if ( ! give_has_variable_prices($form_id)) {
670
+		return give_get_form_price($form_id);
671 671
 	}
672 672
 
673
-	$prices = give_get_variable_prices( $form_id );
673
+	$prices = give_get_variable_prices($form_id);
674 674
 
675 675
 	$high = 0.00;
676 676
 
677
-	if ( ! empty( $prices ) ) {
677
+	if ( ! empty($prices)) {
678 678
 
679 679
 		$max = 0;
680 680
 
681
-		foreach ( $prices as $key => $price ) {
682
-			if ( empty( $price['_give_amount'] ) ) {
681
+		foreach ($prices as $key => $price) {
682
+			if (empty($price['_give_amount'])) {
683 683
 				continue;
684 684
 			}
685
-			$give_amount = give_sanitize_amount( $price['_give_amount'] );
685
+			$give_amount = give_sanitize_amount($price['_give_amount']);
686 686
 
687
-			$max = max( $max, $give_amount );
687
+			$max = max($max, $give_amount);
688 688
 
689
-			if ( $give_amount == $max ) {
689
+			if ($give_amount == $max) {
690 690
 				$max_id = $key;
691 691
 			}
692 692
 		}
693 693
 
694
-		$high = $prices[ $max_id ]['_give_amount'];
694
+		$high = $prices[$max_id]['_give_amount'];
695 695
 	}
696 696
 
697
-	return give_sanitize_amount( $high );
697
+	return give_sanitize_amount($high);
698 698
 }
699 699
 
700 700
 /**
@@ -706,15 +706,15 @@  discard block
 block discarded – undo
706 706
  *
707 707
  * @return mixed string|int Price of the form
708 708
  */
709
-function give_get_form_price( $form_id = 0 ) {
709
+function give_get_form_price($form_id = 0) {
710 710
 
711
-	if ( empty( $form_id ) ) {
711
+	if (empty($form_id)) {
712 712
 		return false;
713 713
 	}
714 714
 
715
-	$form = new Give_Donate_Form( $form_id );
715
+	$form = new Give_Donate_Form($form_id);
716 716
 
717
-	return $form->__get( 'price' );
717
+	return $form->__get('price');
718 718
 }
719 719
 
720 720
 /**
@@ -726,15 +726,15 @@  discard block
 block discarded – undo
726 726
  *
727 727
  * @return mixed string|int Minimum price of the form
728 728
  */
729
-function give_get_form_minimum_price( $form_id = 0 ) {
729
+function give_get_form_minimum_price($form_id = 0) {
730 730
 
731
-	if ( empty( $form_id ) ) {
731
+	if (empty($form_id)) {
732 732
 		return false;
733 733
 	}
734 734
 
735
-	$form = new Give_Donate_Form( $form_id );
735
+	$form = new Give_Donate_Form($form_id);
736 736
 
737
-	return $form->__get( 'minimum_price' );
737
+	return $form->__get('minimum_price');
738 738
 
739 739
 }
740 740
 
@@ -749,52 +749,52 @@  discard block
 block discarded – undo
749 749
  *
750 750
  * @return int $formatted_price
751 751
  */
752
-function give_price( $form_id = 0, $echo = true, $price_id = false ) {
752
+function give_price($form_id = 0, $echo = true, $price_id = false) {
753 753
 
754
-	if ( empty( $form_id ) ) {
754
+	if (empty($form_id)) {
755 755
 		$form_id = get_the_ID();
756 756
 	}
757 757
 
758
-	if ( give_has_variable_prices( $form_id ) ) {
758
+	if (give_has_variable_prices($form_id)) {
759 759
 
760
-		$prices = give_get_variable_prices( $form_id );
760
+		$prices = give_get_variable_prices($form_id);
761 761
 
762
-		if ( false !== $price_id ) {
762
+		if (false !== $price_id) {
763 763
 
764 764
 			//loop through multi-prices to see which is default
765
-			foreach ( $prices as $price ) {
765
+			foreach ($prices as $price) {
766 766
 				//this is the default price
767
-				if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) {
767
+				if (isset($price['_give_default']) && $price['_give_default'] === 'default') {
768 768
 					$price = (float) $price['_give_amount'];
769 769
 				};
770 770
 			}
771 771
 
772 772
 		} else {
773 773
 
774
-			$price = give_get_lowest_price_option( $form_id );
774
+			$price = give_get_lowest_price_option($form_id);
775 775
 		}
776 776
 
777
-		$price = give_sanitize_amount( $price );
777
+		$price = give_sanitize_amount($price);
778 778
 
779 779
 	} else {
780 780
 
781
-		$price = give_get_form_price( $form_id );
781
+		$price = give_get_form_price($form_id);
782 782
 
783 783
 	}
784 784
 
785
-	$price           = apply_filters( 'give_form_price', give_sanitize_amount( $price ), $form_id );
786
-	$formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>';
787
-	$formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price );
785
+	$price           = apply_filters('give_form_price', give_sanitize_amount($price), $form_id);
786
+	$formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>';
787
+	$formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price);
788 788
 
789
-	if ( $echo ) {
789
+	if ($echo) {
790 790
 		echo $formatted_price;
791 791
 	} else {
792 792
 		return $formatted_price;
793 793
 	}
794 794
 }
795 795
 
796
-add_filter( 'give_form_price', 'give_format_amount', 10 );
797
-add_filter( 'give_form_price', 'give_currency_filter', 20 );
796
+add_filter('give_form_price', 'give_format_amount', 10);
797
+add_filter('give_form_price', 'give_currency_filter', 20);
798 798
 
799 799
 
800 800
 /**
@@ -807,19 +807,19 @@  discard block
 block discarded – undo
807 807
  *
808 808
  * @return float $amount Amount of the price option
809 809
  */
810
-function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) {
811
-	$prices = give_get_variable_prices( $form_id );
810
+function give_get_price_option_amount($form_id = 0, $price_id = 0) {
811
+	$prices = give_get_variable_prices($form_id);
812 812
 
813 813
 	$amount = 0.00;
814 814
 
815
-	foreach ( $prices as $price ) {
816
-		if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) {
817
-			$amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00;
815
+	foreach ($prices as $price) {
816
+		if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] == $price_id) {
817
+			$amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00;
818 818
 			break;
819 819
 		};
820 820
 	}
821 821
 
822
-	return apply_filters( 'give_get_price_option_amount', give_sanitize_amount( $amount ), $form_id, $price_id );
822
+	return apply_filters('give_get_price_option_amount', give_sanitize_amount($amount), $form_id, $price_id);
823 823
 }
824 824
 
825 825
 /**
@@ -831,13 +831,13 @@  discard block
 block discarded – undo
831 831
  *
832 832
  * @return mixed string|int Goal of the form
833 833
  */
834
-function give_get_form_goal( $form_id = 0 ) {
834
+function give_get_form_goal($form_id = 0) {
835 835
 
836
-	if ( empty( $form_id ) ) {
836
+	if (empty($form_id)) {
837 837
 		return false;
838 838
 	}
839 839
 
840
-	$form = new Give_Donate_Form( $form_id );
840
+	$form = new Give_Donate_Form($form_id);
841 841
 
842 842
 	return $form->goal;
843 843
 
@@ -853,27 +853,27 @@  discard block
 block discarded – undo
853 853
  *
854 854
  * @return string $formatted_goal
855 855
  */
856
-function give_goal( $form_id = 0, $echo = true ) {
856
+function give_goal($form_id = 0, $echo = true) {
857 857
 
858
-	if ( empty( $form_id ) ) {
858
+	if (empty($form_id)) {
859 859
 		$form_id = get_the_ID();
860 860
 	}
861 861
 
862
-	$goal = give_get_form_goal( $form_id );
862
+	$goal = give_get_form_goal($form_id);
863 863
 
864
-	$goal           = apply_filters( 'give_form_goal', give_sanitize_amount( $goal ), $form_id );
865
-	$formatted_goal = '<span class="give_price" id="give_price_' . $form_id . '">' . $goal . '</span>';
866
-	$formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal );
864
+	$goal           = apply_filters('give_form_goal', give_sanitize_amount($goal), $form_id);
865
+	$formatted_goal = '<span class="give_price" id="give_price_'.$form_id.'">'.$goal.'</span>';
866
+	$formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal);
867 867
 
868
-	if ( $echo ) {
868
+	if ($echo) {
869 869
 		echo $formatted_goal;
870 870
 	} else {
871 871
 		return $formatted_goal;
872 872
 	}
873 873
 }
874 874
 
875
-add_filter( 'give_form_goal', 'give_format_amount', 10 );
876
-add_filter( 'give_form_goal', 'give_currency_filter', 20 );
875
+add_filter('give_form_goal', 'give_format_amount', 10);
876
+add_filter('give_form_goal', 'give_currency_filter', 20);
877 877
 
878 878
 
879 879
 /**
@@ -887,13 +887,13 @@  discard block
 block discarded – undo
887 887
  *
888 888
  * @return bool  $ret Whether or not the logged_in_only setting is set
889 889
  */
890
-function give_logged_in_only( $form_id ) {
890
+function give_logged_in_only($form_id) {
891 891
 
892
-	$form_option = get_post_meta( $form_id, '_give_logged_in_only', true );
892
+	$form_option = get_post_meta($form_id, '_give_logged_in_only', true);
893 893
 
894
-	$ret = ! empty( $form_option ) ? $form_option : false;
894
+	$ret = ! empty($form_option) ? $form_option : false;
895 895
 
896
-	return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id );
896
+	return (bool) apply_filters('give_logged_in_only', $ret, $form_id);
897 897
 
898 898
 }
899 899
 
@@ -907,10 +907,10 @@  discard block
 block discarded – undo
907 907
  *
908 908
  * @return string
909 909
  */
910
-function give_show_login_register_option( $form_id ) {
910
+function give_show_login_register_option($form_id) {
911 911
 
912
-	$show_register_form = get_post_meta( $form_id, '_give_show_register_form', true );
912
+	$show_register_form = get_post_meta($form_id, '_give_show_register_form', true);
913 913
 
914
-	return apply_filters( 'give_show_register_form', $show_register_form, $form_id );
914
+	return apply_filters('give_show_register_form', $show_register_form, $form_id);
915 915
 
916 916
 }
917 917
\ No newline at end of file
Please login to merge, or discard this patch.
includes/payments/functions.php 3 patches
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
  * @param  int $year      Year number. Default is null.
631 631
  * @param  int $hour      Hour number. Default is null.
632 632
  *
633
- * @return int $earnings  Earnings
633
+ * @return double $earnings  Earnings
634 634
  */
635 635
 function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
636 636
 
@@ -932,7 +932,7 @@  discard block
 block discarded – undo
932 932
  *
933 933
  * @param int $payment_id Payment ID
934 934
  *
935
- * @return array $user_info User Info Meta Values
935
+ * @return string $user_info User Info Meta Values
936 936
  */
937 937
 function give_get_payment_meta_user_info( $payment_id ) {
938 938
 	$payment = new Give_Payment( $payment_id );
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
  *
949 949
  * @param int $payment_id Payment ID
950 950
  *
951
- * @return int $form_id
951
+ * @return string $form_id
952 952
  */
953 953
 function give_get_payment_form_id( $payment_id ) {
954 954
 	$payment = new Give_Payment( $payment_id );
@@ -994,7 +994,7 @@  discard block
 block discarded – undo
994 994
  *
995 995
  * @param int $payment_id Payment ID
996 996
  *
997
- * @return string $user_id User ID
997
+ * @return integer $user_id User ID
998 998
  */
999 999
 function give_get_payment_user_id( $payment_id ) {
1000 1000
 	$payment = new Give_Payment( $payment_id );
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
  *
1010 1010
  * @param int $payment_id Payment ID
1011 1011
  *
1012
- * @return string $customer_id Customer ID
1012
+ * @return integer $customer_id Customer ID
1013 1013
  */
1014 1014
 function give_get_payment_customer_id( $payment_id ) {
1015 1015
 	$payment = new Give_Payment( $payment_id );
@@ -1606,7 +1606,7 @@  discard block
 block discarded – undo
1606 1606
  * @param array $where
1607 1607
  * @param object $wp_comment_query WordPress Comment Query Object
1608 1608
  *
1609
- * @return array $where
1609
+ * @return string $where
1610 1610
  */
1611 1611
 function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) {
1612 1612
 	global $wpdb;
Please login to merge, or discard this patch.
Indentation   +33 added lines, -34 removed lines patch added patch discarded remove patch
@@ -228,7 +228,6 @@  discard block
 block discarded – undo
228 228
  * Deletes a Donation
229 229
  *
230 230
  * @since  1.0
231
-
232 231
  * @global $give_logs
233 232
  *
234 233
  * @param  int  $payment_id      Payment ID (default: 0)
@@ -610,7 +609,7 @@  discard block
 block discarded – undo
610 609
  * Retrieves keys for all available statuses for payments
611 610
  *
612 611
  * @since  1.0
613
-  *
612
+ *
614 613
  * @return array $payment_status All the available payment statuses.
615 614
  */
616 615
 function give_get_payment_status_keys() {
@@ -1807,13 +1806,13 @@  discard block
 block discarded – undo
1807 1806
  * @return string/void
1808 1807
  */
1809 1808
 function give_get_form_dropdown( $args = array(), $echo = false ){
1810
-    $form_dropdown_html = Give()->html->forms_dropdown( $args );
1809
+	$form_dropdown_html = Give()->html->forms_dropdown( $args );
1811 1810
 
1812
-    if( ! $echo ) {
1813
-        return $form_dropdown_html;
1814
-    }
1811
+	if( ! $echo ) {
1812
+		return $form_dropdown_html;
1813
+	}
1815 1814
 
1816
-    echo $form_dropdown_html;
1815
+	echo $form_dropdown_html;
1817 1816
 }
1818 1817
 
1819 1818
 /**
@@ -1828,39 +1827,39 @@  discard block
 block discarded – undo
1828 1827
  */
1829 1828
 function give_get_form_variable_price_dropdown( $args = array(), $echo = false ){
1830 1829
     
1831
-    // Check for give form id.
1832
-    if( empty( $args['id'] ) ) {
1833
-        return false;
1834
-    }
1835
-
1836
-    // Check if form has variable prices or not.
1837
-    if( ! ( $variable_prices = give_has_variable_prices( $args['id'] ) ) ) {
1838
-        return false;
1839
-    }
1830
+	// Check for give form id.
1831
+	if( empty( $args['id'] ) ) {
1832
+		return false;
1833
+	}
1834
+
1835
+	// Check if form has variable prices or not.
1836
+	if( ! ( $variable_prices = give_has_variable_prices( $args['id'] ) ) ) {
1837
+		return false;
1838
+	}
1840 1839
     
1841
-    $variable_prices = give_get_variable_prices( absint( $args['id'] ) );
1842
-    $variable_price_options = array();
1840
+	$variable_prices = give_get_variable_prices( absint( $args['id'] ) );
1841
+	$variable_price_options = array();
1843 1842
 
1844
-    // Check if multi donation form support custom donation or not.
1845
-    if( give_is_custom_price_mode( absint( $args['id'] ) ) ) {
1846
-        $variable_price_options['custom']  = _x( 'Custom', 'custom donation dropdown item', 'give' );
1847
-    }
1843
+	// Check if multi donation form support custom donation or not.
1844
+	if( give_is_custom_price_mode( absint( $args['id'] ) ) ) {
1845
+		$variable_price_options['custom']  = _x( 'Custom', 'custom donation dropdown item', 'give' );
1846
+	}
1848 1847
 
1849
-    // Get variable price and ID from variable price array.
1850
-    foreach ( $variable_prices as $variable_price ) {
1851
-        $variable_price_options[ $variable_price['_give_id']['level_id'] ] =  $variable_price['_give_text'];
1852
-    }
1848
+	// Get variable price and ID from variable price array.
1849
+	foreach ( $variable_prices as $variable_price ) {
1850
+		$variable_price_options[ $variable_price['_give_id']['level_id'] ] =  $variable_price['_give_text'];
1851
+	}
1853 1852
 
1854 1853
 
1855
-    // Update options.
1856
-    $args = array_merge( $args, array( 'options' => $variable_price_options ) );
1854
+	// Update options.
1855
+	$args = array_merge( $args, array( 'options' => $variable_price_options ) );
1857 1856
 
1858
-    // Generate select html.
1859
-    $form_dropdown_html = Give()->html->select( $args );
1857
+	// Generate select html.
1858
+	$form_dropdown_html = Give()->html->select( $args );
1860 1859
 
1861
-    if( ! $echo ) {
1862
-        return $form_dropdown_html;
1863
-    }
1860
+	if( ! $echo ) {
1861
+		return $form_dropdown_html;
1862
+	}
1864 1863
 
1865
-    echo $form_dropdown_html;
1864
+	echo $form_dropdown_html;
1866 1865
 }
1867 1866
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +394 added lines, -394 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
 
@@ -43,15 +43,15 @@  discard block
 block discarded – undo
43 43
  *
44 44
  * @return object $payments Payments retrieved from the database
45 45
  */
46
-function give_get_payments( $args = array() ) {
46
+function give_get_payments($args = array()) {
47 47
 
48 48
 	// Fallback to post objects to ensure backwards compatibility
49
-	if ( ! isset( $args['output'] ) ) {
49
+	if ( ! isset($args['output'])) {
50 50
 		$args['output'] = 'posts';
51 51
 	}
52 52
 
53
-	$args     = apply_filters( 'give_get_payments_args', $args );
54
-	$payments = new Give_Payments_Query( $args );
53
+	$args     = apply_filters('give_get_payments_args', $args);
54
+	$payments = new Give_Payments_Query($args);
55 55
 
56 56
 	return $payments->get_payments();
57 57
 }
@@ -66,48 +66,48 @@  discard block
 block discarded – undo
66 66
  *
67 67
  * @return mixed
68 68
  */
69
-function give_get_payment_by( $field = '', $value = '' ) {
69
+function give_get_payment_by($field = '', $value = '') {
70 70
 
71
-	if ( empty( $field ) || empty( $value ) ) {
71
+	if (empty($field) || empty($value)) {
72 72
 		return false;
73 73
 	}
74 74
 
75
-	switch ( strtolower( $field ) ) {
75
+	switch (strtolower($field)) {
76 76
 
77 77
 		case 'id':
78
-			$payment = new Give_Payment( $value );
78
+			$payment = new Give_Payment($value);
79 79
 			$id      = $payment->ID;
80 80
 
81
-			if ( empty( $id ) ) {
81
+			if (empty($id)) {
82 82
 				return false;
83 83
 			}
84 84
 
85 85
 			break;
86 86
 
87 87
 		case 'key':
88
-			$payment = give_get_payments( array(
88
+			$payment = give_get_payments(array(
89 89
 				'meta_key'       => '_give_payment_purchase_key',
90 90
 				'meta_value'     => $value,
91 91
 				'posts_per_page' => 1,
92 92
 				'fields'         => 'ids',
93
-			) );
93
+			));
94 94
 
95
-			if ( $payment ) {
96
-				$payment = new Give_Payment( $payment[0] );
95
+			if ($payment) {
96
+				$payment = new Give_Payment($payment[0]);
97 97
 			}
98 98
 
99 99
 			break;
100 100
 
101 101
 		case 'payment_number':
102
-			$payment = give_get_payments( array(
102
+			$payment = give_get_payments(array(
103 103
 				'meta_key'       => '_give_payment_number',
104 104
 				'meta_value'     => $value,
105 105
 				'posts_per_page' => 1,
106 106
 				'fields'         => 'ids',
107
-			) );
107
+			));
108 108
 
109
-			if ( $payment ) {
110
-				$payment = new Give_Payment( $payment[0] );
109
+			if ($payment) {
110
+				$payment = new Give_Payment($payment[0]);
111 111
 			}
112 112
 
113 113
 			break;
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 			return false;
117 117
 	}
118 118
 
119
-	if ( $payment ) {
119
+	if ($payment) {
120 120
 		return $payment;
121 121
 	}
122 122
 
@@ -132,23 +132,23 @@  discard block
 block discarded – undo
132 132
  *
133 133
  * @return int|bool Payment ID if payment is inserted, false otherwise
134 134
  */
135
-function give_insert_payment( $payment_data = array() ) {
135
+function give_insert_payment($payment_data = array()) {
136 136
 
137
-	if ( empty( $payment_data ) ) {
137
+	if (empty($payment_data)) {
138 138
 		return false;
139 139
 	}
140 140
 
141 141
 	$payment    = new Give_Payment();
142
-	$gateway    = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : '';
143
-	$gateway    = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway;
144
-	$form_id    = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0;
145
-	$price_id   = isset( $payment_data['give_price_id'] ) ? $payment_data['give_price_id'] : give_get_price_id( $payment_data['give_form_id'], $payment_data['price'] );
146
-	$form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id );
142
+	$gateway    = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : '';
143
+	$gateway    = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway;
144
+	$form_id    = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0;
145
+	$price_id   = isset($payment_data['give_price_id']) ? $payment_data['give_price_id'] : give_get_price_id($payment_data['give_form_id'], $payment_data['price']);
146
+	$form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id);
147 147
 
148 148
 	//Set properties
149 149
 	$payment->total          = $payment_data['price'];
150
-	$payment->status         = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending';
151
-	$payment->currency       = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency();
150
+	$payment->status         = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending';
151
+	$payment->currency       = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency();
152 152
 	$payment->user_info      = $payment_data['user_info'];
153 153
 	$payment->gateway        = $gateway;
154 154
 	$payment->form_title     = $form_title;
@@ -162,40 +162,40 @@  discard block
 block discarded – undo
162 162
 	$payment->ip             = give_get_ip();
163 163
 	$payment->key            = $payment_data['purchase_key'];
164 164
 	$payment->mode           = give_is_test_mode() ? 'test' : 'live';
165
-	$payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : '';
165
+	$payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : '';
166 166
 
167 167
 	//Add the donation
168 168
 	$args = array(
169 169
 		'price'    => $payment->total,
170 170
 		'price_id' => $payment->price_id,
171
-		'fees'     => isset( $payment_data['fees'] ) ? $payment_data['fees'] : array()
171
+		'fees'     => isset($payment_data['fees']) ? $payment_data['fees'] : array()
172 172
 	);
173 173
 
174
-	$payment->add_donation( $payment->form_id, $args );
174
+	$payment->add_donation($payment->form_id, $args);
175 175
 
176 176
 	//Set date if present
177
-	if ( isset( $payment_data['post_date'] ) ) {
177
+	if (isset($payment_data['post_date'])) {
178 178
 		$payment->date = $payment_data['post_date'];
179 179
 	}
180 180
 
181 181
 	//Handle sequential payments
182
-	if ( give_get_option( 'enable_sequential' ) ) {
182
+	if (give_get_option('enable_sequential')) {
183 183
 		$number          = give_get_next_payment_number();
184
-		$payment->number = give_format_payment_number( $number );
185
-		update_option( 'give_last_payment_number', $number );
184
+		$payment->number = give_format_payment_number($number);
185
+		update_option('give_last_payment_number', $number);
186 186
 	}
187 187
 
188 188
 	// Clear the user's purchased cache
189
-	delete_transient( 'give_user_' . $payment_data['user_info']['id'] . '_purchases' );
189
+	delete_transient('give_user_'.$payment_data['user_info']['id'].'_purchases');
190 190
 
191 191
 	//Save payment
192 192
 	$payment->save();
193 193
 
194 194
 	//Hook it
195
-	do_action( 'give_insert_payment', $payment->ID, $payment_data );
195
+	do_action('give_insert_payment', $payment->ID, $payment_data);
196 196
 
197 197
 	//Return payment ID upon success
198
-	if ( ! empty( $payment->ID ) ) {
198
+	if ( ! empty($payment->ID)) {
199 199
 		return $payment->ID;
200 200
 	}
201 201
 
@@ -214,9 +214,9 @@  discard block
 block discarded – undo
214 214
  *
215 215
  * @return bool
216 216
  */
217
-function give_update_payment_status( $payment_id, $new_status = 'publish' ) {
217
+function give_update_payment_status($payment_id, $new_status = 'publish') {
218 218
 
219
-	$payment         = new Give_Payment( $payment_id );
219
+	$payment         = new Give_Payment($payment_id);
220 220
 	$payment->status = $new_status;
221 221
 	$updated         = $payment->save();
222 222
 
@@ -236,52 +236,52 @@  discard block
 block discarded – undo
236 236
  *
237 237
  * @return void
238 238
  */
239
-function give_delete_purchase( $payment_id = 0, $update_customer = true ) {
239
+function give_delete_purchase($payment_id = 0, $update_customer = true) {
240 240
 	global $give_logs;
241 241
 
242
-	$payment     = new Give_Payment( $payment_id );
243
-	$amount      = give_get_payment_amount( $payment_id );
242
+	$payment     = new Give_Payment($payment_id);
243
+	$amount      = give_get_payment_amount($payment_id);
244 244
 	$status      = $payment->post_status;
245
-	$customer_id = give_get_payment_customer_id( $payment_id );
246
-	$customer    = new Give_Customer( $customer_id );
245
+	$customer_id = give_get_payment_customer_id($payment_id);
246
+	$customer    = new Give_Customer($customer_id);
247 247
 
248 248
 	//Only undo purchases that aren't these statuses
249
-	$dont_undo_statuses = apply_filters( 'give_undo_purchase_statuses', array(
249
+	$dont_undo_statuses = apply_filters('give_undo_purchase_statuses', array(
250 250
 		'pending',
251 251
 		'cancelled'
252
-	) );
252
+	));
253 253
 
254
-	if ( ! in_array( $status, $dont_undo_statuses ) ) {
255
-		give_undo_purchase( false, $payment_id );
254
+	if ( ! in_array($status, $dont_undo_statuses)) {
255
+		give_undo_purchase(false, $payment_id);
256 256
 	}
257 257
 
258
-	if ( $status == 'publish' ) {
258
+	if ($status == 'publish') {
259 259
 
260 260
 		// Only decrease earnings if they haven't already been decreased (or were never increased for this payment)
261
-		give_decrease_total_earnings( $amount );
261
+		give_decrease_total_earnings($amount);
262 262
 		// Clear the This Month earnings (this_monththis_month is NOT a typo)
263
-		delete_transient( md5( 'give_earnings_this_monththis_month' ) );
263
+		delete_transient(md5('give_earnings_this_monththis_month'));
264 264
 
265
-		if ( $customer->id && $update_customer ) {
265
+		if ($customer->id && $update_customer) {
266 266
 
267 267
 			// Decrement the stats for the customer
268 268
 			$customer->decrease_purchase_count();
269
-			$customer->decrease_value( $amount );
269
+			$customer->decrease_value($amount);
270 270
 
271 271
 		}
272 272
 	}
273 273
 
274
-	do_action( 'give_payment_delete', $payment_id );
274
+	do_action('give_payment_delete', $payment_id);
275 275
 
276
-	if ( $customer->id && $update_customer ) {
276
+	if ($customer->id && $update_customer) {
277 277
 
278 278
 		// Remove the payment ID from the customer
279
-		$customer->remove_payment( $payment_id );
279
+		$customer->remove_payment($payment_id);
280 280
 
281 281
 	}
282 282
 
283 283
 	// Remove the payment
284
-	wp_delete_post( $payment_id, true );
284
+	wp_delete_post($payment_id, true);
285 285
 
286 286
 	// Remove related sale log entries
287 287
 	$give_logs->delete_logs(
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 		)
296 296
 	);
297 297
 
298
-	do_action( 'give_payment_deleted', $payment_id );
298
+	do_action('give_payment_deleted', $payment_id);
299 299
 }
300 300
 
301 301
 /**
@@ -311,25 +311,25 @@  discard block
 block discarded – undo
311 311
  *
312 312
  * @return void
313 313
  */
314
-function give_undo_purchase( $form_id = false, $payment_id ) {
314
+function give_undo_purchase($form_id = false, $payment_id) {
315 315
 
316
-	if ( ! empty( $form_id ) ) {
316
+	if ( ! empty($form_id)) {
317 317
 		$form_id = false;
318
-		_give_deprected_argument( 'form_id', 'give_undo_purchase', '1.5' );
318
+		_give_deprected_argument('form_id', 'give_undo_purchase', '1.5');
319 319
 	}
320 320
 
321
-	$payment = new Give_Payment( $payment_id );
321
+	$payment = new Give_Payment($payment_id);
322 322
 
323
-	$maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id );
324
-	if ( true === $maybe_decrease_earnings ) {
323
+	$maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id);
324
+	if (true === $maybe_decrease_earnings) {
325 325
 		// decrease earnings
326
-		give_decrease_earnings( $payment->form_id, $payment->total );
326
+		give_decrease_earnings($payment->form_id, $payment->total);
327 327
 	}
328 328
 
329
-	$maybe_decrease_sales = apply_filters( 'give_decrease_sales_on_undo', true, $payment, $payment->form_id );
330
-	if ( true === $maybe_decrease_sales ) {
329
+	$maybe_decrease_sales = apply_filters('give_decrease_sales_on_undo', true, $payment, $payment->form_id);
330
+	if (true === $maybe_decrease_sales) {
331 331
 		// decrease purchase count
332
-		give_decrease_purchase_count( $payment->form_id );
332
+		give_decrease_purchase_count($payment->form_id);
333 333
 	}
334 334
 
335 335
 }
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
  *
347 347
  * @return array $count Number of payments sorted by payment status
348 348
  */
349
-function give_count_payments( $args = array() ) {
349
+function give_count_payments($args = array()) {
350 350
 
351 351
 	global $wpdb;
352 352
 
@@ -358,18 +358,18 @@  discard block
 block discarded – undo
358 358
 		'form_id'    => null,
359 359
 	);
360 360
 
361
-	$args = wp_parse_args( $args, $defaults );
361
+	$args = wp_parse_args($args, $defaults);
362 362
 
363 363
 	$select = "SELECT p.post_status,count( * ) AS num_posts";
364 364
 	$join   = '';
365 365
 	$where  = "WHERE p.post_type = 'give_payment'";
366 366
 
367 367
 	// Count payments for a specific user
368
-	if ( ! empty( $args['user'] ) ) {
368
+	if ( ! empty($args['user'])) {
369 369
 
370
-		if ( is_email( $args['user'] ) ) {
370
+		if (is_email($args['user'])) {
371 371
 			$field = 'email';
372
-		} elseif ( is_numeric( $args['user'] ) ) {
372
+		} elseif (is_numeric($args['user'])) {
373 373
 			$field = 'id';
374 374
 		} else {
375 375
 			$field = '';
@@ -377,108 +377,108 @@  discard block
 block discarded – undo
377 377
 
378 378
 		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
379 379
 
380
-		if ( ! empty( $field ) ) {
380
+		if ( ! empty($field)) {
381 381
 			$where .= "
382 382
 				AND m.meta_key = '_give_payment_user_{$field}'
383 383
 				AND m.meta_value = '{$args['user']}'";
384 384
 		}
385 385
 
386 386
 		// Count payments for a search
387
-	} elseif ( ! empty( $args['s'] ) ) {
387
+	} elseif ( ! empty($args['s'])) {
388 388
 
389
-		if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) {
389
+		if (is_email($args['s']) || strlen($args['s']) == 32) {
390 390
 
391
-			if ( is_email( $args['s'] ) ) {
391
+			if (is_email($args['s'])) {
392 392
 				$field = '_give_payment_user_email';
393 393
 			} else {
394 394
 				$field = '_give_payment_purchase_key';
395 395
 			}
396 396
 
397 397
 			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
398
-			$where .= $wpdb->prepare( "
398
+			$where .= $wpdb->prepare("
399 399
 				AND m.meta_key = %s
400 400
 				AND m.meta_value = %s",
401 401
 				$field,
402 402
 				$args['s']
403 403
 			);
404 404
 
405
-		} elseif ( '#' == substr( $args['s'], 0, 1 ) ) {
405
+		} elseif ('#' == substr($args['s'], 0, 1)) {
406 406
 
407
-			$search = str_replace( '#:', '', $args['s'] );
408
-			$search = str_replace( '#', '', $search );
407
+			$search = str_replace('#:', '', $args['s']);
408
+			$search = str_replace('#', '', $search);
409 409
 
410 410
 			$select = "SELECT p2.post_status,count( * ) AS num_posts ";
411 411
 			$join   = "LEFT JOIN $wpdb->postmeta m ON m.meta_key = '_give_log_payment_id' AND m.post_id = p.ID ";
412 412
 			$join .= "INNER JOIN $wpdb->posts p2 ON m.meta_value = p2.ID ";
413 413
 			$where = "WHERE p.post_type = 'give_log' ";
414
-			$where .= $wpdb->prepare( "AND p.post_parent = %d} ", $search );
414
+			$where .= $wpdb->prepare("AND p.post_parent = %d} ", $search);
415 415
 
416
-		} elseif ( is_numeric( $args['s'] ) ) {
416
+		} elseif (is_numeric($args['s'])) {
417 417
 
418 418
 			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
419
-			$where .= $wpdb->prepare( "
419
+			$where .= $wpdb->prepare("
420 420
 				AND m.meta_key = '_give_payment_user_id'
421 421
 				AND m.meta_value = %d",
422 422
 				$args['s']
423 423
 			);
424 424
 
425 425
 		} else {
426
-			$search = $wpdb->esc_like( $args['s'] );
427
-			$search = '%' . $search . '%';
426
+			$search = $wpdb->esc_like($args['s']);
427
+			$search = '%'.$search.'%';
428 428
 
429
-			$where .= $wpdb->prepare( "AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))", $search, $search );
429
+			$where .= $wpdb->prepare("AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))", $search, $search);
430 430
 		}
431 431
 
432 432
 	}
433 433
 
434
-	if ( ! empty( $args['form_id'] ) && is_numeric( $args['form_id'] ) ) {
434
+	if ( ! empty($args['form_id']) && is_numeric($args['form_id'])) {
435 435
 
436
-		$where .= $wpdb->prepare( " AND p.post_parent = %d", $args['form_id'] );
436
+		$where .= $wpdb->prepare(" AND p.post_parent = %d", $args['form_id']);
437 437
 
438 438
 	}
439 439
 	// Limit payments count by date
440
-	if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) {
440
+	if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) {
441 441
 
442
-		$date_parts = explode( '/', $args['start-date'] );
443
-		$month      = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0;
444
-		$day        = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0;
445
-		$year       = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0;
442
+		$date_parts = explode('/', $args['start-date']);
443
+		$month      = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0;
444
+		$day        = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0;
445
+		$year       = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0;
446 446
 
447
-		$is_date = checkdate( $month, $day, $year );
448
-		if ( false !== $is_date ) {
447
+		$is_date = checkdate($month, $day, $year);
448
+		if (false !== $is_date) {
449 449
 
450
-			$date = new DateTime( $args['start-date'] );
451
-			$where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) );
450
+			$date = new DateTime($args['start-date']);
451
+			$where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d'));
452 452
 
453 453
 		}
454 454
 
455 455
 		// Fixes an issue with the payments list table counts when no end date is specified (partiy with stats class)
456
-		if ( empty( $args['end-date'] ) ) {
456
+		if (empty($args['end-date'])) {
457 457
 			$args['end-date'] = $args['start-date'];
458 458
 		}
459 459
 
460 460
 	}
461 461
 
462
-	if ( ! empty ( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) {
462
+	if ( ! empty ($args['end-date']) && false !== strpos($args['end-date'], '/')) {
463 463
 
464
-		$date_parts = explode( '/', $args['end-date'] );
464
+		$date_parts = explode('/', $args['end-date']);
465 465
 
466
-		$month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0;
467
-		$day   = ! empty( $date_parts[1] ) ? $date_parts[1] : 0;
468
-		$year  = ! empty( $date_parts[2] ) ? $date_parts[2] : 0;
466
+		$month = ! empty($date_parts[0]) ? $date_parts[0] : 0;
467
+		$day   = ! empty($date_parts[1]) ? $date_parts[1] : 0;
468
+		$year  = ! empty($date_parts[2]) ? $date_parts[2] : 0;
469 469
 
470
-		$is_date = checkdate( $month, $day, $year );
471
-		if ( false !== $is_date ) {
470
+		$is_date = checkdate($month, $day, $year);
471
+		if (false !== $is_date) {
472 472
 
473
-			$date = new DateTime( $args['end-date'] );
474
-			$where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) );
473
+			$date = new DateTime($args['end-date']);
474
+			$where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d'));
475 475
 
476 476
 		}
477 477
 
478 478
 	}
479 479
 
480
-	$where = apply_filters( 'give_count_payments_where', $where );
481
-	$join  = apply_filters( 'give_count_payments_join', $join );
480
+	$where = apply_filters('give_count_payments_where', $where);
481
+	$join  = apply_filters('give_count_payments_join', $join);
482 482
 
483 483
 	$query = "$select
484 484
 		FROM $wpdb->posts p
@@ -487,36 +487,36 @@  discard block
 block discarded – undo
487 487
 		GROUP BY p.post_status
488 488
 	";
489 489
 
490
-	$cache_key = md5( $query );
490
+	$cache_key = md5($query);
491 491
 
492
-	$count = wp_cache_get( $cache_key, 'counts' );
493
-	if ( false !== $count ) {
492
+	$count = wp_cache_get($cache_key, 'counts');
493
+	if (false !== $count) {
494 494
 		return $count;
495 495
 	}
496 496
 
497
-	$count = $wpdb->get_results( $query, ARRAY_A );
497
+	$count = $wpdb->get_results($query, ARRAY_A);
498 498
 
499 499
 	$stats    = array();
500 500
 	$statuses = get_post_stati();
501
-	if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) {
502
-		unset( $statuses['private'] );
501
+	if (isset($statuses['private']) && empty($args['s'])) {
502
+		unset($statuses['private']);
503 503
 	}
504 504
 
505
-	foreach ( $statuses as $state ) {
506
-		$stats[ $state ] = 0;
505
+	foreach ($statuses as $state) {
506
+		$stats[$state] = 0;
507 507
 	}
508 508
 
509
-	foreach ( (array) $count as $row ) {
509
+	foreach ((array) $count as $row) {
510 510
 
511
-		if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) {
511
+		if ('private' == $row['post_status'] && empty($args['s'])) {
512 512
 			continue;
513 513
 		}
514 514
 
515
-		$stats[ $row['post_status'] ] = $row['num_posts'];
515
+		$stats[$row['post_status']] = $row['num_posts'];
516 516
 	}
517 517
 
518 518
 	$stats = (object) $stats;
519
-	wp_cache_set( $cache_key, $stats, 'counts' );
519
+	wp_cache_set($cache_key, $stats, 'counts');
520 520
 
521 521
 	return $stats;
522 522
 }
@@ -531,12 +531,12 @@  discard block
 block discarded – undo
531 531
  *
532 532
  * @return bool             True if payment exists, false otherwise
533 533
  */
534
-function give_check_for_existing_payment( $payment_id ) {
534
+function give_check_for_existing_payment($payment_id) {
535 535
 	$exists  = false;
536
-	$payment = new Give_Payment( $payment_id );
536
+	$payment = new Give_Payment($payment_id);
537 537
 
538 538
 
539
-	if ( $payment_id === $payment->ID && 'publish' === $payment->status ) {
539
+	if ($payment_id === $payment->ID && 'publish' === $payment->status) {
540 540
 		$exists = true;
541 541
 	}
542 542
 
@@ -553,29 +553,29 @@  discard block
 block discarded – undo
553 553
  *
554 554
  * @return bool|mixed           True if payment status exists, false otherwise
555 555
  */
556
-function give_get_payment_status( $payment, $return_label = false ) {
556
+function give_get_payment_status($payment, $return_label = false) {
557 557
 
558
-	if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) {
558
+	if ( ! is_object($payment) || ! isset($payment->post_status)) {
559 559
 		return false;
560 560
 	}
561 561
 
562 562
 	$statuses = give_get_payment_statuses();
563 563
 
564
-	if ( ! is_array( $statuses ) || empty( $statuses ) ) {
564
+	if ( ! is_array($statuses) || empty($statuses)) {
565 565
 		return false;
566 566
 	}
567 567
 
568
-	$payment = new Give_Payment( $payment->ID );
568
+	$payment = new Give_Payment($payment->ID);
569 569
 
570
-	if ( array_key_exists( $payment->status, $statuses ) ) {
571
-		if ( true === $return_label ) {
572
-			return $statuses[ $payment->status ];
570
+	if (array_key_exists($payment->status, $statuses)) {
571
+		if (true === $return_label) {
572
+			return $statuses[$payment->status];
573 573
 		} else {
574 574
 			// Account that our 'publish' status is labeled 'Complete'
575 575
 			$post_status = 'publish' == $payment->status ? 'Complete' : $payment->post_status;
576 576
 
577 577
 			// Make sure we're matching cases, since they matter
578
-			return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) );
578
+			return array_search(strtolower($post_status), array_map('strtolower', $statuses));
579 579
 		}
580 580
 	}
581 581
 
@@ -591,17 +591,17 @@  discard block
 block discarded – undo
591 591
  */
592 592
 function give_get_payment_statuses() {
593 593
 	$payment_statuses = array(
594
-		'pending'     => esc_html__( 'Pending', 'give' ),
595
-		'publish'     => esc_html__( 'Complete', 'give' ),
596
-		'refunded'    => esc_html__( 'Refunded', 'give' ),
597
-		'failed'      => esc_html__( 'Failed', 'give' ),
598
-		'cancelled'   => esc_html__( 'Cancelled', 'give' ),
599
-		'abandoned'   => esc_html__( 'Abandoned', 'give' ),
600
-		'preapproval' => esc_html__( 'Pre-Approved', 'give' ),
601
-		'revoked'     => esc_html__( 'Revoked', 'give' )
594
+		'pending'     => esc_html__('Pending', 'give'),
595
+		'publish'     => esc_html__('Complete', 'give'),
596
+		'refunded'    => esc_html__('Refunded', 'give'),
597
+		'failed'      => esc_html__('Failed', 'give'),
598
+		'cancelled'   => esc_html__('Cancelled', 'give'),
599
+		'abandoned'   => esc_html__('Abandoned', 'give'),
600
+		'preapproval' => esc_html__('Pre-Approved', 'give'),
601
+		'revoked'     => esc_html__('Revoked', 'give')
602 602
 	);
603 603
 
604
-	return apply_filters( 'give_payment_statuses', $payment_statuses );
604
+	return apply_filters('give_payment_statuses', $payment_statuses);
605 605
 }
606 606
 
607 607
 /**
@@ -614,10 +614,10 @@  discard block
 block discarded – undo
614 614
  * @return array $payment_status All the available payment statuses.
615 615
  */
616 616
 function give_get_payment_status_keys() {
617
-	$statuses = array_keys( give_get_payment_statuses() );
618
-	asort( $statuses );
617
+	$statuses = array_keys(give_get_payment_statuses());
618
+	asort($statuses);
619 619
 
620
-	return array_values( $statuses );
620
+	return array_values($statuses);
621 621
 }
622 622
 
623 623
 /**
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
  *
633 633
  * @return int $earnings  Earnings
634 634
  */
635
-function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
635
+function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) {
636 636
 
637 637
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead
638 638
 
@@ -643,41 +643,41 @@  discard block
 block discarded – undo
643 643
 		'nopaging'               => true,
644 644
 		'year'                   => $year,
645 645
 		'monthnum'               => $month_num,
646
-		'post_status'            => array( 'publish' ),
646
+		'post_status'            => array('publish'),
647 647
 		'fields'                 => 'ids',
648 648
 		'update_post_term_cache' => false
649 649
 	);
650
-	if ( ! empty( $day ) ) {
650
+	if ( ! empty($day)) {
651 651
 		$args['day'] = $day;
652 652
 	}
653 653
 
654
-	if ( ! empty( $hour ) ) {
654
+	if ( ! empty($hour)) {
655 655
 		$args['hour'] = $hour;
656 656
 	}
657 657
 
658
-	$args = apply_filters( 'give_get_earnings_by_date_args', $args );
659
-	$key  = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 );
658
+	$args = apply_filters('give_get_earnings_by_date_args', $args);
659
+	$key  = 'give_stats_'.substr(md5(serialize($args)), 0, 15);
660 660
 
661
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
661
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
662 662
 		$earnings = false;
663 663
 	} else {
664
-		$earnings = get_transient( $key );
664
+		$earnings = get_transient($key);
665 665
 	}
666 666
 
667
-	if ( false === $earnings ) {
668
-		$sales    = get_posts( $args );
667
+	if (false === $earnings) {
668
+		$sales    = get_posts($args);
669 669
 		$earnings = 0;
670
-		if ( $sales ) {
671
-			$sales = implode( ',', $sales );
670
+		if ($sales) {
671
+			$sales = implode(',', $sales);
672 672
 
673
-			$earnings = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})" );
673
+			$earnings = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})");
674 674
 
675 675
 		}
676 676
 		// Cache the results for one hour
677
-		set_transient( $key, $earnings, HOUR_IN_SECONDS );
677
+		set_transient($key, $earnings, HOUR_IN_SECONDS);
678 678
 	}
679 679
 
680
-	return round( $earnings, 2 );
680
+	return round($earnings, 2);
681 681
 }
682 682
 
683 683
 /**
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
  *
693 693
  * @return int $count     Sales
694 694
  */
695
-function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) {
695
+function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) {
696 696
 
697 697
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead
698 698
 	$args = array(
@@ -700,14 +700,14 @@  discard block
 block discarded – undo
700 700
 		'nopaging'               => true,
701 701
 		'year'                   => $year,
702 702
 		'fields'                 => 'ids',
703
-		'post_status'            => array( 'publish' ),
703
+		'post_status'            => array('publish'),
704 704
 		'update_post_meta_cache' => false,
705 705
 		'update_post_term_cache' => false
706 706
 	);
707 707
 
708
-	$show_free = apply_filters( 'give_sales_by_date_show_free', true, $args );
708
+	$show_free = apply_filters('give_sales_by_date_show_free', true, $args);
709 709
 
710
-	if ( false === $show_free ) {
710
+	if (false === $show_free) {
711 711
 		$args['meta_query'] = array(
712 712
 			array(
713 713
 				'key'     => '_give_payment_total',
@@ -718,33 +718,33 @@  discard block
 block discarded – undo
718 718
 		);
719 719
 	}
720 720
 
721
-	if ( ! empty( $month_num ) ) {
721
+	if ( ! empty($month_num)) {
722 722
 		$args['monthnum'] = $month_num;
723 723
 	}
724 724
 
725
-	if ( ! empty( $day ) ) {
725
+	if ( ! empty($day)) {
726 726
 		$args['day'] = $day;
727 727
 	}
728 728
 
729
-	if ( ! empty( $hour ) ) {
729
+	if ( ! empty($hour)) {
730 730
 		$args['hour'] = $hour;
731 731
 	}
732 732
 
733
-	$args = apply_filters( 'give_get_sales_by_date_args', $args );
733
+	$args = apply_filters('give_get_sales_by_date_args', $args);
734 734
 
735
-	$key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 );
735
+	$key = 'give_stats_'.substr(md5(serialize($args)), 0, 15);
736 736
 
737
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
737
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
738 738
 		$count = false;
739 739
 	} else {
740
-		$count = get_transient( $key );
740
+		$count = get_transient($key);
741 741
 	}
742 742
 
743
-	if ( false === $count ) {
744
-		$sales = new WP_Query( $args );
743
+	if (false === $count) {
744
+		$sales = new WP_Query($args);
745 745
 		$count = (int) $sales->post_count;
746 746
 		// Cache the results for one hour
747
-		set_transient( $key, $count, HOUR_IN_SECONDS );
747
+		set_transient($key, $count, HOUR_IN_SECONDS);
748 748
 	}
749 749
 
750 750
 	return $count;
@@ -759,20 +759,20 @@  discard block
 block discarded – undo
759 759
  *
760 760
  * @return bool            True if complete, false otherwise.
761 761
  */
762
-function give_is_payment_complete( $payment_id ) {
763
-	$payment = new Give_Payment( $payment_id );
762
+function give_is_payment_complete($payment_id) {
763
+	$payment = new Give_Payment($payment_id);
764 764
 
765 765
 	$ret = false;
766 766
 
767
-	if ( $payment->ID > 0 ) {
767
+	if ($payment->ID > 0) {
768 768
 
769
-		if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) {
769
+		if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) {
770 770
 			$ret = true;
771 771
 		}
772 772
 
773 773
 	}
774 774
 
775
-	return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status );
775
+	return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status);
776 776
 }
777 777
 
778 778
 /**
@@ -798,29 +798,29 @@  discard block
 block discarded – undo
798 798
  */
799 799
 function give_get_total_earnings() {
800 800
 
801
-	$total = get_option( 'give_earnings_total', false );
801
+	$total = get_option('give_earnings_total', false);
802 802
 
803 803
 	// If no total stored in DB, use old method of calculating total earnings
804
-	if ( false === $total ) {
804
+	if (false === $total) {
805 805
 
806 806
 		global $wpdb;
807 807
 
808
-		$total = get_transient( 'give_earnings_total' );
808
+		$total = get_transient('give_earnings_total');
809 809
 
810
-		if ( false === $total ) {
810
+		if (false === $total) {
811 811
 
812 812
 			$total = (float) 0;
813 813
 
814
-			$args = apply_filters( 'give_get_total_earnings_args', array(
814
+			$args = apply_filters('give_get_total_earnings_args', array(
815 815
 				'offset' => 0,
816
-				'number' => - 1,
817
-				'status' => array( 'publish' ),
816
+				'number' => -1,
817
+				'status' => array('publish'),
818 818
 				'fields' => 'ids'
819
-			) );
819
+			));
820 820
 
821 821
 
822
-			$payments = give_get_payments( $args );
823
-			if ( $payments ) {
822
+			$payments = give_get_payments($args);
823
+			if ($payments) {
824 824
 
825 825
 				/*
826 826
 				 * If performing a purchase, we need to skip the very last payment in the database, since it calls
@@ -828,30 +828,30 @@  discard block
 block discarded – undo
828 828
 				 * first purchase
829 829
 				 */
830 830
 
831
-				if ( did_action( 'give_update_payment_status' ) ) {
832
-					array_pop( $payments );
831
+				if (did_action('give_update_payment_status')) {
832
+					array_pop($payments);
833 833
 				}
834 834
 
835
-				if ( ! empty( $payments ) ) {
836
-					$payments = implode( ',', $payments );
837
-					$total += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" );
835
+				if ( ! empty($payments)) {
836
+					$payments = implode(',', $payments);
837
+					$total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})");
838 838
 				}
839 839
 
840 840
 			}
841 841
 
842 842
 			// Cache results for 1 day. This cache is cleared automatically when a payment is made
843
-			set_transient( 'give_earnings_total', $total, 86400 );
843
+			set_transient('give_earnings_total', $total, 86400);
844 844
 
845 845
 			// Store the total for the first time
846
-			update_option( 'give_earnings_total', $total );
846
+			update_option('give_earnings_total', $total);
847 847
 		}
848 848
 	}
849 849
 
850
-	if ( $total < 0 ) {
850
+	if ($total < 0) {
851 851
 		$total = 0; // Don't ever show negative earnings
852 852
 	}
853 853
 
854
-	return apply_filters( 'give_total_earnings', round( $total, give_currency_decimal_filter() ) );
854
+	return apply_filters('give_total_earnings', round($total, give_currency_decimal_filter()));
855 855
 }
856 856
 
857 857
 /**
@@ -864,10 +864,10 @@  discard block
 block discarded – undo
864 864
  *
865 865
  * @return float $total  Total earnings.
866 866
  */
867
-function give_increase_total_earnings( $amount = 0 ) {
867
+function give_increase_total_earnings($amount = 0) {
868 868
 	$total = give_get_total_earnings();
869 869
 	$total += $amount;
870
-	update_option( 'give_earnings_total', $total );
870
+	update_option('give_earnings_total', $total);
871 871
 
872 872
 	return $total;
873 873
 }
@@ -881,13 +881,13 @@  discard block
 block discarded – undo
881 881
  *
882 882
  * @return float $total Total earnings
883 883
  */
884
-function give_decrease_total_earnings( $amount = 0 ) {
884
+function give_decrease_total_earnings($amount = 0) {
885 885
 	$total = give_get_total_earnings();
886 886
 	$total -= $amount;
887
-	if ( $total < 0 ) {
887
+	if ($total < 0) {
888 888
 		$total = 0;
889 889
 	}
890
-	update_option( 'give_earnings_total', $total );
890
+	update_option('give_earnings_total', $total);
891 891
 
892 892
 	return $total;
893 893
 }
@@ -903,10 +903,10 @@  discard block
 block discarded – undo
903 903
  *
904 904
  * @return mixed $meta Payment Meta
905 905
  */
906
-function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) {
907
-	$payment = new Give_Payment( $payment_id );
906
+function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) {
907
+	$payment = new Give_Payment($payment_id);
908 908
 
909
-	return $payment->get_meta( $meta_key, $single );
909
+	return $payment->get_meta($meta_key, $single);
910 910
 }
911 911
 
912 912
 /**
@@ -919,10 +919,10 @@  discard block
 block discarded – undo
919 919
  *
920 920
  * @return mixed               Meta ID if successful, false if unsuccessful
921 921
  */
922
-function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) {
923
-	$payment = new Give_Payment( $payment_id );
922
+function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') {
923
+	$payment = new Give_Payment($payment_id);
924 924
 
925
-	return $payment->update_meta( $meta_key, $meta_value, $prev_value );
925
+	return $payment->update_meta($meta_key, $meta_value, $prev_value);
926 926
 }
927 927
 
928 928
 /**
@@ -934,8 +934,8 @@  discard block
 block discarded – undo
934 934
  *
935 935
  * @return array $user_info User Info Meta Values
936 936
  */
937
-function give_get_payment_meta_user_info( $payment_id ) {
938
-	$payment = new Give_Payment( $payment_id );
937
+function give_get_payment_meta_user_info($payment_id) {
938
+	$payment = new Give_Payment($payment_id);
939 939
 
940 940
 	return $payment->user_info;
941 941
 }
@@ -950,8 +950,8 @@  discard block
 block discarded – undo
950 950
  *
951 951
  * @return int $form_id
952 952
  */
953
-function give_get_payment_form_id( $payment_id ) {
954
-	$payment = new Give_Payment( $payment_id );
953
+function give_get_payment_form_id($payment_id) {
954
+	$payment = new Give_Payment($payment_id);
955 955
 
956 956
 	return $payment->form_id;
957 957
 }
@@ -965,8 +965,8 @@  discard block
 block discarded – undo
965 965
  *
966 966
  * @return string $email User Email
967 967
  */
968
-function give_get_payment_user_email( $payment_id ) {
969
-	$payment = new Give_Payment( $payment_id );
968
+function give_get_payment_user_email($payment_id) {
969
+	$payment = new Give_Payment($payment_id);
970 970
 
971 971
 	return $payment->email;
972 972
 }
@@ -980,11 +980,11 @@  discard block
 block discarded – undo
980 980
  *
981 981
  * @return bool            If the payment is associated with a user (false) or not (true)
982 982
  */
983
-function give_is_guest_payment( $payment_id ) {
984
-	$payment_user_id  = give_get_payment_user_id( $payment_id );
985
-	$is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true;
983
+function give_is_guest_payment($payment_id) {
984
+	$payment_user_id  = give_get_payment_user_id($payment_id);
985
+	$is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true;
986 986
 
987
-	return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id );
987
+	return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id);
988 988
 }
989 989
 
990 990
 /**
@@ -996,8 +996,8 @@  discard block
 block discarded – undo
996 996
  *
997 997
  * @return string $user_id User ID
998 998
  */
999
-function give_get_payment_user_id( $payment_id ) {
1000
-	$payment = new Give_Payment( $payment_id );
999
+function give_get_payment_user_id($payment_id) {
1000
+	$payment = new Give_Payment($payment_id);
1001 1001
 
1002 1002
 	return $payment->user_id;
1003 1003
 }
@@ -1011,8 +1011,8 @@  discard block
 block discarded – undo
1011 1011
  *
1012 1012
  * @return string $customer_id Customer ID
1013 1013
  */
1014
-function give_get_payment_customer_id( $payment_id ) {
1015
-	$payment = new Give_Payment( $payment_id );
1014
+function give_get_payment_customer_id($payment_id) {
1015
+	$payment = new Give_Payment($payment_id);
1016 1016
 
1017 1017
 	return $payment->customer_id;
1018 1018
 }
@@ -1026,8 +1026,8 @@  discard block
 block discarded – undo
1026 1026
  *
1027 1027
  * @return string $ip User IP
1028 1028
  */
1029
-function give_get_payment_user_ip( $payment_id ) {
1030
-	$payment = new Give_Payment( $payment_id );
1029
+function give_get_payment_user_ip($payment_id) {
1030
+	$payment = new Give_Payment($payment_id);
1031 1031
 
1032 1032
 	return $payment->ip;
1033 1033
 }
@@ -1041,8 +1041,8 @@  discard block
 block discarded – undo
1041 1041
  *
1042 1042
  * @return string $date The date the payment was completed
1043 1043
  */
1044
-function give_get_payment_completed_date( $payment_id = 0 ) {
1045
-	$payment = new Give_Payment( $payment_id );
1044
+function give_get_payment_completed_date($payment_id = 0) {
1045
+	$payment = new Give_Payment($payment_id);
1046 1046
 
1047 1047
 	return $payment->completed_date;
1048 1048
 }
@@ -1056,8 +1056,8 @@  discard block
 block discarded – undo
1056 1056
  *
1057 1057
  * @return string $gateway Gateway
1058 1058
  */
1059
-function give_get_payment_gateway( $payment_id ) {
1060
-	$payment = new Give_Payment( $payment_id );
1059
+function give_get_payment_gateway($payment_id) {
1060
+	$payment = new Give_Payment($payment_id);
1061 1061
 
1062 1062
 	return $payment->gateway;
1063 1063
 }
@@ -1071,8 +1071,8 @@  discard block
 block discarded – undo
1071 1071
  *
1072 1072
  * @return string $currency The currency code
1073 1073
  */
1074
-function give_get_payment_currency_code( $payment_id = 0 ) {
1075
-	$payment = new Give_Payment( $payment_id );
1074
+function give_get_payment_currency_code($payment_id = 0) {
1075
+	$payment = new Give_Payment($payment_id);
1076 1076
 
1077 1077
 	return $payment->currency;
1078 1078
 }
@@ -1086,10 +1086,10 @@  discard block
 block discarded – undo
1086 1086
  *
1087 1087
  * @return string $currency The currency name
1088 1088
  */
1089
-function give_get_payment_currency( $payment_id = 0 ) {
1090
-	$currency = give_get_payment_currency_code( $payment_id );
1089
+function give_get_payment_currency($payment_id = 0) {
1090
+	$currency = give_get_payment_currency_code($payment_id);
1091 1091
 
1092
-	return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id );
1092
+	return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id);
1093 1093
 }
1094 1094
 
1095 1095
 /**
@@ -1101,8 +1101,8 @@  discard block
 block discarded – undo
1101 1101
  *
1102 1102
  * @return string $key Purchase key
1103 1103
  */
1104
-function give_get_payment_key( $payment_id = 0 ) {
1105
-	$payment = new Give_Payment( $payment_id );
1104
+function give_get_payment_key($payment_id = 0) {
1105
+	$payment = new Give_Payment($payment_id);
1106 1106
 
1107 1107
 	return $payment->key;
1108 1108
 }
@@ -1118,8 +1118,8 @@  discard block
 block discarded – undo
1118 1118
  *
1119 1119
  * @return string $number Payment order number
1120 1120
  */
1121
-function give_get_payment_number( $payment_id = 0 ) {
1122
-	$payment = new Give_Payment( $payment_id );
1121
+function give_get_payment_number($payment_id = 0) {
1122
+	$payment = new Give_Payment($payment_id);
1123 1123
 
1124 1124
 	return $payment->number;
1125 1125
 }
@@ -1133,23 +1133,23 @@  discard block
 block discarded – undo
1133 1133
  *
1134 1134
  * @return string      The formatted payment number
1135 1135
  */
1136
-function give_format_payment_number( $number ) {
1136
+function give_format_payment_number($number) {
1137 1137
 
1138
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1138
+	if ( ! give_get_option('enable_sequential')) {
1139 1139
 		return $number;
1140 1140
 	}
1141 1141
 
1142
-	if ( ! is_numeric( $number ) ) {
1142
+	if ( ! is_numeric($number)) {
1143 1143
 		return $number;
1144 1144
 	}
1145 1145
 
1146
-	$prefix  = give_get_option( 'sequential_prefix' );
1147
-	$number  = absint( $number );
1148
-	$postfix = give_get_option( 'sequential_postfix' );
1146
+	$prefix  = give_get_option('sequential_prefix');
1147
+	$number  = absint($number);
1148
+	$postfix = give_get_option('sequential_postfix');
1149 1149
 
1150
-	$formatted_number = $prefix . $number . $postfix;
1150
+	$formatted_number = $prefix.$number.$postfix;
1151 1151
 
1152
-	return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix );
1152
+	return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix);
1153 1153
 }
1154 1154
 
1155 1155
 /**
@@ -1162,17 +1162,17 @@  discard block
 block discarded – undo
1162 1162
  */
1163 1163
 function give_get_next_payment_number() {
1164 1164
 
1165
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1165
+	if ( ! give_get_option('enable_sequential')) {
1166 1166
 		return false;
1167 1167
 	}
1168 1168
 
1169
-	$number           = get_option( 'give_last_payment_number' );
1170
-	$start            = give_get_option( 'sequential_start', 1 );
1169
+	$number           = get_option('give_last_payment_number');
1170
+	$start            = give_get_option('sequential_start', 1);
1171 1171
 	$increment_number = true;
1172 1172
 
1173
-	if ( false !== $number ) {
1173
+	if (false !== $number) {
1174 1174
 
1175
-		if ( empty( $number ) ) {
1175
+		if (empty($number)) {
1176 1176
 
1177 1177
 			$number           = $start;
1178 1178
 			$increment_number = false;
@@ -1182,24 +1182,24 @@  discard block
 block discarded – undo
1182 1182
 	} else {
1183 1183
 
1184 1184
 		// This case handles the first addition of the new option, as well as if it get's deleted for any reason
1185
-		$payments     = new Give_Payments_Query( array(
1185
+		$payments = new Give_Payments_Query(array(
1186 1186
 			'number'  => 1,
1187 1187
 			'order'   => 'DESC',
1188 1188
 			'orderby' => 'ID',
1189 1189
 			'output'  => 'posts',
1190 1190
 			'fields'  => 'ids'
1191
-		) );
1191
+		));
1192 1192
 		$last_payment = $payments->get_payments();
1193 1193
 
1194
-		if ( ! empty( $last_payment ) ) {
1194
+		if ( ! empty($last_payment)) {
1195 1195
 
1196
-			$number = give_get_payment_number( $last_payment[0] );
1196
+			$number = give_get_payment_number($last_payment[0]);
1197 1197
 
1198 1198
 		}
1199 1199
 
1200
-		if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) {
1200
+		if ( ! empty($number) && $number !== (int) $last_payment[0]) {
1201 1201
 
1202
-			$number = give_remove_payment_prefix_postfix( $number );
1202
+			$number = give_remove_payment_prefix_postfix($number);
1203 1203
 
1204 1204
 		} else {
1205 1205
 
@@ -1209,13 +1209,13 @@  discard block
 block discarded – undo
1209 1209
 
1210 1210
 	}
1211 1211
 
1212
-	$increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number );
1212
+	$increment_number = apply_filters('give_increment_payment_number', $increment_number, $number);
1213 1213
 
1214
-	if ( $increment_number ) {
1215
-		$number ++;
1214
+	if ($increment_number) {
1215
+		$number++;
1216 1216
 	}
1217 1217
 
1218
-	return apply_filters( 'give_get_next_payment_number', $number );
1218
+	return apply_filters('give_get_next_payment_number', $number);
1219 1219
 }
1220 1220
 
1221 1221
 /**
@@ -1227,25 +1227,25 @@  discard block
 block discarded – undo
1227 1227
  *
1228 1228
  * @return string          The new Payment number without prefix and postfix
1229 1229
  */
1230
-function give_remove_payment_prefix_postfix( $number ) {
1230
+function give_remove_payment_prefix_postfix($number) {
1231 1231
 
1232
-	$prefix  = give_get_option( 'sequential_prefix' );
1233
-	$postfix = give_get_option( 'sequential_postfix' );
1232
+	$prefix  = give_get_option('sequential_prefix');
1233
+	$postfix = give_get_option('sequential_postfix');
1234 1234
 
1235 1235
 	// Remove prefix
1236
-	$number = preg_replace( '/' . $prefix . '/', '', $number, 1 );
1236
+	$number = preg_replace('/'.$prefix.'/', '', $number, 1);
1237 1237
 
1238 1238
 	// Remove the postfix
1239
-	$length      = strlen( $number );
1240
-	$postfix_pos = strrpos( $number, $postfix );
1241
-	if ( false !== $postfix_pos ) {
1242
-		$number = substr_replace( $number, '', $postfix_pos, $length );
1239
+	$length      = strlen($number);
1240
+	$postfix_pos = strrpos($number, $postfix);
1241
+	if (false !== $postfix_pos) {
1242
+		$number = substr_replace($number, '', $postfix_pos, $length);
1243 1243
 	}
1244 1244
 
1245 1245
 	// Ensure it's a whole number
1246
-	$number = intval( $number );
1246
+	$number = intval($number);
1247 1247
 
1248
-	return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix );
1248
+	return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix);
1249 1249
 
1250 1250
 }
1251 1251
 
@@ -1261,10 +1261,10 @@  discard block
 block discarded – undo
1261 1261
  *
1262 1262
  * @return string $amount Fully formatted payment amount
1263 1263
  */
1264
-function give_payment_amount( $payment_id = 0 ) {
1265
-	$amount = give_get_payment_amount( $payment_id );
1264
+function give_payment_amount($payment_id = 0) {
1265
+	$amount = give_get_payment_amount($payment_id);
1266 1266
 
1267
-	return give_currency_filter( give_format_amount( $amount ), give_get_payment_currency_code( $payment_id ) );
1267
+	return give_currency_filter(give_format_amount($amount), give_get_payment_currency_code($payment_id));
1268 1268
 }
1269 1269
 
1270 1270
 /**
@@ -1277,11 +1277,11 @@  discard block
 block discarded – undo
1277 1277
  *
1278 1278
  * @return mixed|void
1279 1279
  */
1280
-function give_get_payment_amount( $payment_id ) {
1280
+function give_get_payment_amount($payment_id) {
1281 1281
 
1282
-	$payment = new Give_Payment( $payment_id );
1282
+	$payment = new Give_Payment($payment_id);
1283 1283
 
1284
-	return apply_filters( 'give_payment_amount', floatval( $payment->total ), $payment_id );
1284
+	return apply_filters('give_payment_amount', floatval($payment->total), $payment_id);
1285 1285
 }
1286 1286
 
1287 1287
 /**
@@ -1297,10 +1297,10 @@  discard block
 block discarded – undo
1297 1297
  *
1298 1298
  * @return array Fully formatted payment subtotal
1299 1299
  */
1300
-function give_payment_subtotal( $payment_id = 0 ) {
1301
-	$subtotal = give_get_payment_subtotal( $payment_id );
1300
+function give_payment_subtotal($payment_id = 0) {
1301
+	$subtotal = give_get_payment_subtotal($payment_id);
1302 1302
 
1303
-	return give_currency_filter( give_format_amount( $subtotal ), give_get_payment_currency_code( $payment_id ) );
1303
+	return give_currency_filter(give_format_amount($subtotal), give_get_payment_currency_code($payment_id));
1304 1304
 }
1305 1305
 
1306 1306
 /**
@@ -1314,8 +1314,8 @@  discard block
 block discarded – undo
1314 1314
  *
1315 1315
  * @return float $subtotal Subtotal for payment (non formatted)
1316 1316
  */
1317
-function give_get_payment_subtotal( $payment_id = 0 ) {
1318
-	$payment = new G_Payment( $payment_id );
1317
+function give_get_payment_subtotal($payment_id = 0) {
1318
+	$payment = new G_Payment($payment_id);
1319 1319
 
1320 1320
 	return $payment->subtotal;
1321 1321
 }
@@ -1330,10 +1330,10 @@  discard block
 block discarded – undo
1330 1330
  *
1331 1331
  * @return mixed array if payment fees found, false otherwise
1332 1332
  */
1333
-function give_get_payment_fees( $payment_id = 0, $type = 'all' ) {
1334
-	$payment = new Give_Payment( $payment_id );
1333
+function give_get_payment_fees($payment_id = 0, $type = 'all') {
1334
+	$payment = new Give_Payment($payment_id);
1335 1335
 
1336
-	return $payment->get_fees( $type );
1336
+	return $payment->get_fees($type);
1337 1337
 }
1338 1338
 
1339 1339
 /**
@@ -1345,8 +1345,8 @@  discard block
 block discarded – undo
1345 1345
  *
1346 1346
  * @return string The Transaction ID
1347 1347
  */
1348
-function give_get_payment_transaction_id( $payment_id = 0 ) {
1349
-	$payment = new Give_Payment( $payment_id );
1348
+function give_get_payment_transaction_id($payment_id = 0) {
1349
+	$payment = new Give_Payment($payment_id);
1350 1350
 
1351 1351
 	return $payment->transaction_id;
1352 1352
 }
@@ -1361,15 +1361,15 @@  discard block
 block discarded – undo
1361 1361
  *
1362 1362
  * @return bool|mixed
1363 1363
  */
1364
-function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) {
1364
+function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') {
1365 1365
 
1366
-	if ( empty( $payment_id ) || empty( $transaction_id ) ) {
1366
+	if (empty($payment_id) || empty($transaction_id)) {
1367 1367
 		return false;
1368 1368
 	}
1369 1369
 
1370
-	$transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id );
1370
+	$transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id);
1371 1371
 
1372
-	return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id );
1372
+	return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id);
1373 1373
 }
1374 1374
 
1375 1375
 /**
@@ -1383,12 +1383,12 @@  discard block
 block discarded – undo
1383 1383
  *
1384 1384
  * @return int $purchase Purchase ID
1385 1385
  */
1386
-function give_get_purchase_id_by_key( $key ) {
1386
+function give_get_purchase_id_by_key($key) {
1387 1387
 	global $wpdb;
1388 1388
 
1389
-	$purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key ) );
1389
+	$purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key));
1390 1390
 
1391
-	if ( $purchase != null ) {
1391
+	if ($purchase != null) {
1392 1392
 		return $purchase;
1393 1393
 	}
1394 1394
 
@@ -1407,12 +1407,12 @@  discard block
 block discarded – undo
1407 1407
  *
1408 1408
  * @return int $purchase Purchase ID
1409 1409
  */
1410
-function give_get_purchase_id_by_transaction_id( $key ) {
1410
+function give_get_purchase_id_by_transaction_id($key) {
1411 1411
 	global $wpdb;
1412 1412
 
1413
-	$purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) );
1413
+	$purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key));
1414 1414
 
1415
-	if ( $purchase != null ) {
1415
+	if ($purchase != null) {
1416 1416
 		return $purchase;
1417 1417
 	}
1418 1418
 
@@ -1429,19 +1429,19 @@  discard block
 block discarded – undo
1429 1429
  *
1430 1430
  * @return array $notes Payment Notes
1431 1431
  */
1432
-function give_get_payment_notes( $payment_id = 0, $search = '' ) {
1432
+function give_get_payment_notes($payment_id = 0, $search = '') {
1433 1433
 
1434
-	if ( empty( $payment_id ) && empty( $search ) ) {
1434
+	if (empty($payment_id) && empty($search)) {
1435 1435
 		return false;
1436 1436
 	}
1437 1437
 
1438
-	remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1439
-	remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 );
1438
+	remove_action('pre_get_comments', 'give_hide_payment_notes', 10);
1439
+	remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10);
1440 1440
 
1441
-	$notes = get_comments( array( 'post_id' => $payment_id, 'order' => 'ASC', 'search' => $search ) );
1441
+	$notes = get_comments(array('post_id' => $payment_id, 'order' => 'ASC', 'search' => $search));
1442 1442
 
1443
-	add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1444
-	add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1443
+	add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1444
+	add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1445 1445
 
1446 1446
 	return $notes;
1447 1447
 }
@@ -1457,19 +1457,19 @@  discard block
 block discarded – undo
1457 1457
  *
1458 1458
  * @return int The new note ID
1459 1459
  */
1460
-function give_insert_payment_note( $payment_id = 0, $note = '' ) {
1461
-	if ( empty( $payment_id ) ) {
1460
+function give_insert_payment_note($payment_id = 0, $note = '') {
1461
+	if (empty($payment_id)) {
1462 1462
 		return false;
1463 1463
 	}
1464 1464
 
1465
-	do_action( 'give_pre_insert_payment_note', $payment_id, $note );
1465
+	do_action('give_pre_insert_payment_note', $payment_id, $note);
1466 1466
 
1467
-	$note_id = wp_insert_comment( wp_filter_comment( array(
1467
+	$note_id = wp_insert_comment(wp_filter_comment(array(
1468 1468
 		'comment_post_ID'      => $payment_id,
1469 1469
 		'comment_content'      => $note,
1470 1470
 		'user_id'              => is_admin() ? get_current_user_id() : 0,
1471
-		'comment_date'         => current_time( 'mysql' ),
1472
-		'comment_date_gmt'     => current_time( 'mysql', 1 ),
1471
+		'comment_date'         => current_time('mysql'),
1472
+		'comment_date_gmt'     => current_time('mysql', 1),
1473 1473
 		'comment_approved'     => 1,
1474 1474
 		'comment_parent'       => 0,
1475 1475
 		'comment_author'       => '',
@@ -1478,9 +1478,9 @@  discard block
 block discarded – undo
1478 1478
 		'comment_author_email' => '',
1479 1479
 		'comment_type'         => 'give_payment_note'
1480 1480
 
1481
-	) ) );
1481
+	)));
1482 1482
 
1483
-	do_action( 'give_insert_payment_note', $note_id, $payment_id, $note );
1483
+	do_action('give_insert_payment_note', $note_id, $payment_id, $note);
1484 1484
 
1485 1485
 	return $note_id;
1486 1486
 }
@@ -1495,14 +1495,14 @@  discard block
 block discarded – undo
1495 1495
  *
1496 1496
  * @return bool True on success, false otherwise
1497 1497
  */
1498
-function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) {
1499
-	if ( empty( $comment_id ) ) {
1498
+function give_delete_payment_note($comment_id = 0, $payment_id = 0) {
1499
+	if (empty($comment_id)) {
1500 1500
 		return false;
1501 1501
 	}
1502 1502
 
1503
-	do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id );
1504
-	$ret = wp_delete_comment( $comment_id, true );
1505
-	do_action( 'give_post_delete_payment_note', $comment_id, $payment_id );
1503
+	do_action('give_pre_delete_payment_note', $comment_id, $payment_id);
1504
+	$ret = wp_delete_comment($comment_id, true);
1505
+	do_action('give_post_delete_payment_note', $comment_id, $payment_id);
1506 1506
 
1507 1507
 	return $ret;
1508 1508
 }
@@ -1517,32 +1517,32 @@  discard block
 block discarded – undo
1517 1517
  *
1518 1518
  * @return string
1519 1519
  */
1520
-function give_get_payment_note_html( $note, $payment_id = 0 ) {
1520
+function give_get_payment_note_html($note, $payment_id = 0) {
1521 1521
 
1522
-	if ( is_numeric( $note ) ) {
1523
-		$note = get_comment( $note );
1522
+	if (is_numeric($note)) {
1523
+		$note = get_comment($note);
1524 1524
 	}
1525 1525
 
1526
-	if ( ! empty( $note->user_id ) ) {
1527
-		$user = get_userdata( $note->user_id );
1526
+	if ( ! empty($note->user_id)) {
1527
+		$user = get_userdata($note->user_id);
1528 1528
 		$user = $user->display_name;
1529 1529
 	} else {
1530
-		$user = esc_html__( 'System', 'give' );
1530
+		$user = esc_html__('System', 'give');
1531 1531
 	}
1532 1532
 
1533
-	$date_format = get_option( 'date_format' ) . ', ' . get_option( 'time_format' );
1533
+	$date_format = get_option('date_format').', '.get_option('time_format');
1534 1534
 
1535
-	$delete_note_url = wp_nonce_url( add_query_arg( array(
1535
+	$delete_note_url = wp_nonce_url(add_query_arg(array(
1536 1536
 		'give-action' => 'delete_payment_note',
1537 1537
 		'note_id'     => $note->comment_ID,
1538 1538
 		'payment_id'  => $payment_id
1539
-	) ), 'give_delete_payment_note_' . $note->comment_ID );
1539
+	)), 'give_delete_payment_note_'.$note->comment_ID);
1540 1540
 
1541
-	$note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">';
1541
+	$note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">';
1542 1542
 	$note_html .= '<p>';
1543
-	$note_html .= '<strong>' . $user . '</strong>&nbsp;&ndash;&nbsp;<span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>';
1543
+	$note_html .= '<strong>'.$user.'</strong>&nbsp;&ndash;&nbsp;<span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>';
1544 1544
 	$note_html .= $note->comment_content;
1545
-	$note_html .= '&nbsp;&ndash;&nbsp;<a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" title="' . esc_attr__( 'Delete this payment note', 'give' ) . '">' . esc_html__( 'Delete', 'give' ) . '</a>';
1545
+	$note_html .= '&nbsp;&ndash;&nbsp;<a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" title="'.esc_attr__('Delete this payment note', 'give').'">'.esc_html__('Delete', 'give').'</a>';
1546 1546
 	$note_html .= '</p>';
1547 1547
 	$note_html .= '</div>';
1548 1548
 
@@ -1560,20 +1560,20 @@  discard block
 block discarded – undo
1560 1560
  *
1561 1561
  * @return void
1562 1562
  */
1563
-function give_hide_payment_notes( $query ) {
1563
+function give_hide_payment_notes($query) {
1564 1564
 	global $wp_version;
1565 1565
 
1566
-	if ( version_compare( floatval( $wp_version ), '4.1', '>=' ) ) {
1567
-		$types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array();
1568
-		if ( ! is_array( $types ) ) {
1569
-			$types = array( $types );
1566
+	if (version_compare(floatval($wp_version), '4.1', '>=')) {
1567
+		$types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array();
1568
+		if ( ! is_array($types)) {
1569
+			$types = array($types);
1570 1570
 		}
1571 1571
 		$types[]                           = 'give_payment_note';
1572 1572
 		$query->query_vars['type__not_in'] = $types;
1573 1573
 	}
1574 1574
 }
1575 1575
 
1576
-add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1576
+add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1577 1577
 
1578 1578
 /**
1579 1579
  * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets
@@ -1585,17 +1585,17 @@  discard block
 block discarded – undo
1585 1585
  *
1586 1586
  * @return array $clauses Updated comment clauses
1587 1587
  */
1588
-function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) {
1588
+function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) {
1589 1589
 	global $wpdb, $wp_version;
1590 1590
 
1591
-	if ( version_compare( floatval( $wp_version ), '4.1', '<' ) ) {
1591
+	if (version_compare(floatval($wp_version), '4.1', '<')) {
1592 1592
 		$clauses['where'] .= ' AND comment_type != "give_payment_note"';
1593 1593
 	}
1594 1594
 
1595 1595
 	return $clauses;
1596 1596
 }
1597 1597
 
1598
-add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1598
+add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1599 1599
 
1600 1600
 
1601 1601
 /**
@@ -1608,15 +1608,15 @@  discard block
 block discarded – undo
1608 1608
  *
1609 1609
  * @return array $where
1610 1610
  */
1611
-function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) {
1611
+function give_hide_payment_notes_from_feeds($where, $wp_comment_query) {
1612 1612
 	global $wpdb;
1613 1613
 
1614
-	$where .= $wpdb->prepare( " AND comment_type != %s", 'give_payment_note' );
1614
+	$where .= $wpdb->prepare(" AND comment_type != %s", 'give_payment_note');
1615 1615
 
1616 1616
 	return $where;
1617 1617
 }
1618 1618
 
1619
-add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 );
1619
+add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2);
1620 1620
 
1621 1621
 
1622 1622
 /**
@@ -1630,32 +1630,32 @@  discard block
 block discarded – undo
1630 1630
  *
1631 1631
  * @return array Array of comment counts
1632 1632
  */
1633
-function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) {
1633
+function give_remove_payment_notes_in_comment_counts($stats, $post_id) {
1634 1634
 	global $wpdb, $pagenow;
1635 1635
 
1636
-	if ( 'index.php' != $pagenow ) {
1636
+	if ('index.php' != $pagenow) {
1637 1637
 		return $stats;
1638 1638
 	}
1639 1639
 
1640 1640
 	$post_id = (int) $post_id;
1641 1641
 
1642
-	if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) {
1642
+	if (apply_filters('give_count_payment_notes_in_comments', false)) {
1643 1643
 		return $stats;
1644 1644
 	}
1645 1645
 
1646
-	$stats = wp_cache_get( "comments-{$post_id}", 'counts' );
1646
+	$stats = wp_cache_get("comments-{$post_id}", 'counts');
1647 1647
 
1648
-	if ( false !== $stats ) {
1648
+	if (false !== $stats) {
1649 1649
 		return $stats;
1650 1650
 	}
1651 1651
 
1652 1652
 	$where = 'WHERE comment_type != "give_payment_note"';
1653 1653
 
1654
-	if ( $post_id > 0 ) {
1655
-		$where .= $wpdb->prepare( " AND comment_post_ID = %d", $post_id );
1654
+	if ($post_id > 0) {
1655
+		$where .= $wpdb->prepare(" AND comment_post_ID = %d", $post_id);
1656 1656
 	}
1657 1657
 
1658
-	$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
1658
+	$count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A);
1659 1659
 
1660 1660
 	$total    = 0;
1661 1661
 	$approved = array(
@@ -1665,30 +1665,30 @@  discard block
 block discarded – undo
1665 1665
 		'trash'        => 'trash',
1666 1666
 		'post-trashed' => 'post-trashed'
1667 1667
 	);
1668
-	foreach ( (array) $count as $row ) {
1668
+	foreach ((array) $count as $row) {
1669 1669
 		// Don't count post-trashed toward totals
1670
-		if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) {
1670
+		if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) {
1671 1671
 			$total += $row['num_comments'];
1672 1672
 		}
1673
-		if ( isset( $approved[ $row['comment_approved'] ] ) ) {
1674
-			$stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
1673
+		if (isset($approved[$row['comment_approved']])) {
1674
+			$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
1675 1675
 		}
1676 1676
 	}
1677 1677
 
1678 1678
 	$stats['total_comments'] = $total;
1679
-	foreach ( $approved as $key ) {
1680
-		if ( empty( $stats[ $key ] ) ) {
1681
-			$stats[ $key ] = 0;
1679
+	foreach ($approved as $key) {
1680
+		if (empty($stats[$key])) {
1681
+			$stats[$key] = 0;
1682 1682
 		}
1683 1683
 	}
1684 1684
 
1685 1685
 	$stats = (object) $stats;
1686
-	wp_cache_set( "comments-{$post_id}", $stats, 'counts' );
1686
+	wp_cache_set("comments-{$post_id}", $stats, 'counts');
1687 1687
 
1688 1688
 	return $stats;
1689 1689
 }
1690 1690
 
1691
-add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 );
1691
+add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2);
1692 1692
 
1693 1693
 
1694 1694
 /**
@@ -1701,9 +1701,9 @@  discard block
 block discarded – undo
1701 1701
  *
1702 1702
  * @return string $where Modified where clause
1703 1703
  */
1704
-function give_filter_where_older_than_week( $where = '' ) {
1704
+function give_filter_where_older_than_week($where = '') {
1705 1705
 	// Payments older than one week
1706
-	$start = date( 'Y-m-d', strtotime( '-7 days' ) );
1706
+	$start = date('Y-m-d', strtotime('-7 days'));
1707 1707
 	$where .= " AND post_date <= '{$start}'";
1708 1708
 
1709 1709
 	return $where;
@@ -1722,37 +1722,37 @@  discard block
 block discarded – undo
1722 1722
  *
1723 1723
  * @return string $form_title Returns the full title if $level_title false, otherwise returns the levels title
1724 1724
  */
1725
-function give_get_payment_form_title( $payment_meta, $level_title = false, $separator = '' ) {
1725
+function give_get_payment_form_title($payment_meta, $level_title = false, $separator = '') {
1726 1726
 
1727
-	$form_id    = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0;
1728
-	$form_title = isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : '';
1729
-	$price_id   = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1727
+	$form_id    = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0;
1728
+	$form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : '';
1729
+	$price_id   = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1730 1730
 
1731
-	if ( $level_title == true ) {
1731
+	if ($level_title == true) {
1732 1732
 		$form_title = '';
1733 1733
 	}
1734 1734
 
1735
-	if ( give_has_variable_prices( $form_id ) ) {
1735
+	if (give_has_variable_prices($form_id)) {
1736 1736
 
1737
-		if ( ! empty( $separator ) ) {
1738
-			$form_title .= ' ' . $separator;
1737
+		if ( ! empty($separator)) {
1738
+			$form_title .= ' '.$separator;
1739 1739
 		}
1740 1740
 		$form_title .= ' <span class="donation-level-text-wrap">';
1741 1741
 
1742
-		if ( $price_id == 'custom' ) {
1742
+		if ($price_id == 'custom') {
1743 1743
 
1744
-			$custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true );
1745
-			$form_title .= ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' );
1744
+			$custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true);
1745
+			$form_title .= ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give');
1746 1746
 
1747 1747
 		} else {
1748
-			$form_title .= give_get_price_option_name( $form_id, $price_id );
1748
+			$form_title .= give_get_price_option_name($form_id, $price_id);
1749 1749
 		}
1750 1750
 
1751 1751
 		$form_title .= '</span>';
1752 1752
 
1753 1753
 	}
1754 1754
 
1755
-	return apply_filters( 'give_get_payment_form_title', $form_title, $payment_meta );
1755
+	return apply_filters('give_get_payment_form_title', $form_title, $payment_meta);
1756 1756
 
1757 1757
 }
1758 1758
 
@@ -1766,20 +1766,20 @@  discard block
 block discarded – undo
1766 1766
  *
1767 1767
  * @return string $price_id
1768 1768
  */
1769
-function give_get_price_id( $form_id, $price ) {
1769
+function give_get_price_id($form_id, $price) {
1770 1770
 
1771 1771
 	$price_id = 0;
1772 1772
 
1773
-	if ( give_has_variable_prices( $form_id ) ) {
1773
+	if (give_has_variable_prices($form_id)) {
1774 1774
 
1775
-		$levels = maybe_unserialize( get_post_meta( $form_id, '_give_donation_levels', true ) );
1775
+		$levels = maybe_unserialize(get_post_meta($form_id, '_give_donation_levels', true));
1776 1776
 
1777
-		foreach ( $levels as $level ) {
1777
+		foreach ($levels as $level) {
1778 1778
 
1779
-			$level_amount = (float) give_sanitize_amount( $level['_give_amount'] );
1779
+			$level_amount = (float) give_sanitize_amount($level['_give_amount']);
1780 1780
 
1781 1781
 			//check that this indeed the recurring price
1782
-			if ( $level_amount == $price ) {
1782
+			if ($level_amount == $price) {
1783 1783
 
1784 1784
 				$price_id = $level['_give_id']['level_id'];
1785 1785
 
@@ -1806,10 +1806,10 @@  discard block
 block discarded – undo
1806 1806
  * 
1807 1807
  * @return string/void
1808 1808
  */
1809
-function give_get_form_dropdown( $args = array(), $echo = false ){
1810
-    $form_dropdown_html = Give()->html->forms_dropdown( $args );
1809
+function give_get_form_dropdown($args = array(), $echo = false) {
1810
+    $form_dropdown_html = Give()->html->forms_dropdown($args);
1811 1811
 
1812
-    if( ! $echo ) {
1812
+    if ( ! $echo) {
1813 1813
         return $form_dropdown_html;
1814 1814
     }
1815 1815
 
@@ -1826,39 +1826,39 @@  discard block
 block discarded – undo
1826 1826
  *
1827 1827
  * @return string/void
1828 1828
  */
1829
-function give_get_form_variable_price_dropdown( $args = array(), $echo = false ){
1829
+function give_get_form_variable_price_dropdown($args = array(), $echo = false) {
1830 1830
     
1831 1831
     // Check for give form id.
1832
-    if( empty( $args['id'] ) ) {
1832
+    if (empty($args['id'])) {
1833 1833
         return false;
1834 1834
     }
1835 1835
 
1836 1836
     // Check if form has variable prices or not.
1837
-    if( ! ( $variable_prices = give_has_variable_prices( $args['id'] ) ) ) {
1837
+    if ( ! ($variable_prices = give_has_variable_prices($args['id']))) {
1838 1838
         return false;
1839 1839
     }
1840 1840
     
1841
-    $variable_prices = give_get_variable_prices( absint( $args['id'] ) );
1841
+    $variable_prices = give_get_variable_prices(absint($args['id']));
1842 1842
     $variable_price_options = array();
1843 1843
 
1844 1844
     // Check if multi donation form support custom donation or not.
1845
-    if( give_is_custom_price_mode( absint( $args['id'] ) ) ) {
1846
-        $variable_price_options['custom']  = _x( 'Custom', 'custom donation dropdown item', 'give' );
1845
+    if (give_is_custom_price_mode(absint($args['id']))) {
1846
+        $variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give');
1847 1847
     }
1848 1848
 
1849 1849
     // Get variable price and ID from variable price array.
1850
-    foreach ( $variable_prices as $variable_price ) {
1851
-        $variable_price_options[ $variable_price['_give_id']['level_id'] ] =  $variable_price['_give_text'];
1850
+    foreach ($variable_prices as $variable_price) {
1851
+        $variable_price_options[$variable_price['_give_id']['level_id']] = $variable_price['_give_text'];
1852 1852
     }
1853 1853
 
1854 1854
 
1855 1855
     // Update options.
1856
-    $args = array_merge( $args, array( 'options' => $variable_price_options ) );
1856
+    $args = array_merge($args, array('options' => $variable_price_options));
1857 1857
 
1858 1858
     // Generate select html.
1859
-    $form_dropdown_html = Give()->html->select( $args );
1859
+    $form_dropdown_html = Give()->html->select($args);
1860 1860
 
1861
-    if( ! $echo ) {
1861
+    if ( ! $echo) {
1862 1862
         return $form_dropdown_html;
1863 1863
     }
1864 1864
 
Please login to merge, or discard this patch.
includes/class-give-gravatars.php 1 patch
Spacing   +96 added lines, -96 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
 
@@ -64,50 +64,50 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return bool If the gravatar exists or not
66 66
 	 */
67
-	public function validate_gravatar( $id_or_email ) {
67
+	public function validate_gravatar($id_or_email) {
68 68
 		//id or email code borrowed from wp-includes/pluggable.php
69 69
 		$email = '';
70
-		if ( is_numeric( $id_or_email ) ) {
70
+		if (is_numeric($id_or_email)) {
71 71
 			$id   = (int) $id_or_email;
72
-			$user = get_userdata( $id );
73
-			if ( $user ) {
72
+			$user = get_userdata($id);
73
+			if ($user) {
74 74
 				$email = $user->user_email;
75 75
 			}
76
-		} elseif ( is_object( $id_or_email ) ) {
76
+		} elseif (is_object($id_or_email)) {
77 77
 			// No avatar for pingbacks or trackbacks
78
-			$allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
79
-			if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) {
78
+			$allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment'));
79
+			if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) {
80 80
 				return false;
81 81
 			}
82 82
 
83
-			if ( ! empty( $id_or_email->user_id ) ) {
83
+			if ( ! empty($id_or_email->user_id)) {
84 84
 				$id   = (int) $id_or_email->user_id;
85
-				$user = get_userdata( $id );
86
-				if ( $user ) {
85
+				$user = get_userdata($id);
86
+				if ($user) {
87 87
 					$email = $user->user_email;
88 88
 				}
89
-			} elseif ( ! empty( $id_or_email->comment_author_email ) ) {
89
+			} elseif ( ! empty($id_or_email->comment_author_email)) {
90 90
 				$email = $id_or_email->comment_author_email;
91 91
 			}
92 92
 		} else {
93 93
 			$email = $id_or_email;
94 94
 		}
95 95
 
96
-		$hashkey = md5( strtolower( trim( $email ) ) );
97
-		$uri     = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404';
96
+		$hashkey = md5(strtolower(trim($email)));
97
+		$uri     = 'http://www.gravatar.com/avatar/'.$hashkey.'?d=404';
98 98
 
99
-		$data = wp_cache_get( $hashkey );
100
-		if ( false === $data ) {
101
-			$response = wp_remote_head( $uri );
102
-			if ( is_wp_error( $response ) ) {
99
+		$data = wp_cache_get($hashkey);
100
+		if (false === $data) {
101
+			$response = wp_remote_head($uri);
102
+			if (is_wp_error($response)) {
103 103
 				$data = 'not200';
104 104
 			} else {
105 105
 				$data = $response['response']['code'];
106 106
 			}
107
-			wp_cache_set( $hashkey, $data, $group = '', $expire = 60 * 5 );
107
+			wp_cache_set($hashkey, $data, $group = '', $expire = 60 * 5);
108 108
 
109 109
 		}
110
-		if ( $data == '200' ) {
110
+		if ($data == '200') {
111 111
 			return true;
112 112
 		} else {
113 113
 			return false;
@@ -124,17 +124,17 @@  discard block
 block discarded – undo
124 124
 	 *
125 125
 	 * @return array        IDs if logs, false otherwise
126 126
 	 */
127
-	public function get_log_ids( $form_id = '' ) {
127
+	public function get_log_ids($form_id = '') {
128 128
 
129 129
 		// get Give_Logging class
130 130
 		global $give_logs;
131 131
 
132 132
 		// get log for this form
133
-		$logs = $give_logs->get_logs( $form_id );
133
+		$logs = $give_logs->get_logs($form_id);
134 134
 
135
-		if ( $logs ) {
135
+		if ($logs) {
136 136
 			// make an array with all the donor IDs
137
-			foreach ( $logs as $log ) {
137
+			foreach ($logs as $log) {
138 138
 				$log_ids[] = $log->ID;
139 139
 			}
140 140
 
@@ -155,49 +155,49 @@  discard block
 block discarded – undo
155 155
 	 *
156 156
 	 * @return mixed
157 157
 	 */
158
-	public function get_payment_ids( $form_id = '' ) {
158
+	public function get_payment_ids($form_id = '') {
159 159
 
160 160
 		global $give_options;
161 161
 
162
-		$log_ids = $this->get_log_ids( $form_id );
162
+		$log_ids = $this->get_log_ids($form_id);
163 163
 
164
-		if ( $log_ids ) {
164
+		if ($log_ids) {
165 165
 
166 166
 			$payment_ids = array();
167 167
 
168
-			foreach ( $log_ids as $id ) {
168
+			foreach ($log_ids as $id) {
169 169
 				// get the payment ID for each corresponding log ID
170
-				$payment_ids[] = get_post_meta( $id, '_give_log_payment_id', true );
170
+				$payment_ids[] = get_post_meta($id, '_give_log_payment_id', true);
171 171
 			}
172 172
 
173 173
 			// remove donors who have purchased more than once so we can have unique avatars
174 174
 			$unique_emails = array();
175 175
 
176
-			foreach ( $payment_ids as $key => $id ) {
176
+			foreach ($payment_ids as $key => $id) {
177 177
 
178
-				$email = get_post_meta( $id, '_give_payment_user_email', true );
178
+				$email = get_post_meta($id, '_give_payment_user_email', true);
179 179
 
180
-				if ( isset ( $give_options['give_donators_gravatars_has_gravatar_account'] ) ) {
181
-					if ( ! $this->validate_gravatar( $email ) ) {
180
+				if (isset ($give_options['give_donators_gravatars_has_gravatar_account'])) {
181
+					if ( ! $this->validate_gravatar($email)) {
182 182
 						continue;
183 183
 					}
184 184
 				}
185 185
 
186
-				$unique_emails[ $id ] = get_post_meta( $id, '_give_payment_user_email', true );
186
+				$unique_emails[$id] = get_post_meta($id, '_give_payment_user_email', true);
187 187
 
188 188
 			}
189 189
 
190 190
 			// strip duplicate emails
191
-			$unique_emails = array_unique( $unique_emails );
191
+			$unique_emails = array_unique($unique_emails);
192 192
 
193 193
 			// convert the unique IDs back into simple array
194
-			foreach ( $unique_emails as $id => $email ) {
194
+			foreach ($unique_emails as $id => $email) {
195 195
 				$unique_ids[] = $id;
196 196
 			}
197 197
 
198 198
 			// randomize the payment IDs if enabled
199
-			if ( isset( $give_options['give_donators_gravatars_random_gravatars'] ) ) {
200
-				shuffle( $unique_ids );
199
+			if (isset($give_options['give_donators_gravatars_random_gravatars'])) {
200
+				shuffle($unique_ids);
201 201
 			}
202 202
 
203 203
 			// return our unique IDs
@@ -218,22 +218,22 @@  discard block
 block discarded – undo
218 218
 	 *
219 219
 	 * @return string
220 220
 	 */
221
-	public function gravatars( $form_id = false, $title = '' ) {
221
+	public function gravatars($form_id = false, $title = '') {
222 222
 
223 223
 		// unique $payment_ids 
224
-		$payment_ids = $this->get_payment_ids( $form_id );
224
+		$payment_ids = $this->get_payment_ids($form_id);
225 225
 
226 226
 		global $give_options;
227 227
 
228 228
 		// return if no ID
229
-		if ( ! $form_id ) {
229
+		if ( ! $form_id) {
230 230
 			return;
231 231
 		}
232 232
 
233 233
 		// minimum amount of purchases before showing gravatars
234 234
 		// if the number of items in array is not greater or equal to the number specified, then exit
235
-		if ( isset( $give_options['give_donators_gravatars_min_purchases_required'] ) && '' != $give_options['give_donators_gravatars_min_purchases_required'] ) {
236
-			if ( ! ( count( $payment_ids ) >= $give_options['give_donators_gravatars_min_purchases_required'] ) ) {
235
+		if (isset($give_options['give_donators_gravatars_min_purchases_required']) && '' != $give_options['give_donators_gravatars_min_purchases_required']) {
236
+			if ( ! (count($payment_ids) >= $give_options['give_donators_gravatars_min_purchases_required'])) {
237 237
 				return;
238 238
 			}
239 239
 		}
@@ -244,51 +244,51 @@  discard block
 block discarded – undo
244 244
 		echo '<div id="give-purchase-gravatars">';
245 245
 
246 246
 
247
-		if ( isset ( $title ) ) {
247
+		if (isset ($title)) {
248 248
 
249
-			if ( $title ) {
250
-				echo apply_filters( 'give_donators_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $title ) . '</h3>' );
251
-			} elseif ( isset( $give_options['give_donators_gravatars_heading'] ) ) {
252
-				echo apply_filters( 'give_donators_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $give_options['give_donators_gravatars_heading'] ) . '</h2>' );
249
+			if ($title) {
250
+				echo apply_filters('give_donators_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($title).'</h3>');
251
+			} elseif (isset($give_options['give_donators_gravatars_heading'])) {
252
+				echo apply_filters('give_donators_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($give_options['give_donators_gravatars_heading']).'</h2>');
253 253
 			}
254 254
 
255 255
 		}
256 256
 		echo '<ul class="give-purchase-gravatars-list">';
257 257
 		$i = 0;
258 258
 
259
-		if ( $payment_ids ) {
260
-			foreach ( $payment_ids as $id ) {
259
+		if ($payment_ids) {
260
+			foreach ($payment_ids as $id) {
261 261
 
262 262
 				// Give saves a blank option even when the control is turned off, hence the extra check
263
-				if ( isset( $give_options['give_donators_gravatars_maximum_number'] ) && '' != $give_options['give_donators_gravatars_maximum_number'] && $i == $give_options['give_donators_gravatars_maximum_number'] ) {
263
+				if (isset($give_options['give_donators_gravatars_maximum_number']) && '' != $give_options['give_donators_gravatars_maximum_number'] && $i == $give_options['give_donators_gravatars_maximum_number']) {
264 264
 					continue;
265 265
 				}
266 266
 
267 267
 				// get the payment meta
268
-				$payment_meta = get_post_meta( $id, '_give_payment_meta', true );
268
+				$payment_meta = get_post_meta($id, '_give_payment_meta', true);
269 269
 
270 270
 				// unserialize the payment meta
271
-				$user_info = maybe_unserialize( $payment_meta['user_info'] );
271
+				$user_info = maybe_unserialize($payment_meta['user_info']);
272 272
 
273 273
 				// get donor's first name
274 274
 				$name = $user_info['first_name'];
275 275
 
276 276
 				// get donor's email
277
-				$email = get_post_meta( $id, '_give_payment_user_email', true );
277
+				$email = get_post_meta($id, '_give_payment_user_email', true);
278 278
 
279 279
 				// set gravatar size and provide filter
280
-				$size = isset( $give_options['give_donators_gravatars_gravatar_size'] ) ? apply_filters( 'give_donators_gravatars_gravatar_size', $give_options['give_donators_gravatars_gravatar_size'] ) : '';
280
+				$size = isset($give_options['give_donators_gravatars_gravatar_size']) ? apply_filters('give_donators_gravatars_gravatar_size', $give_options['give_donators_gravatars_gravatar_size']) : '';
281 281
 
282 282
 				// default image
283
-				$default_image = apply_filters( 'give_donators_gravatars_gravatar_default_image', false );
283
+				$default_image = apply_filters('give_donators_gravatars_gravatar_default_image', false);
284 284
 
285 285
 				// assemble output
286 286
 				$output .= '<li>';
287 287
 
288
-				$output .= get_avatar( $email, $size, $default_image, $name );
288
+				$output .= get_avatar($email, $size, $default_image, $name);
289 289
 				$output .= '</li>';
290 290
 
291
-				$i ++;
291
+				$i++;
292 292
 
293 293
 			} // end foreach
294 294
 		}
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 		echo '</ul>';
298 298
 		echo '</div>';
299 299
 
300
-		return apply_filters( 'give_donators_gravatars', ob_get_clean() );
300
+		return apply_filters('give_donators_gravatars', ob_get_clean());
301 301
 	}
302 302
 
303 303
 	/**
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	 * @return void
310 310
 	 */
311 311
 	public function register_widget() {
312
-		register_widget( 'Give_Donators_Gravatars_Widget' );
312
+		register_widget('Give_Donators_Gravatars_Widget');
313 313
 	}
314 314
 
315 315
 	/**
@@ -325,19 +325,19 @@  discard block
 block discarded – undo
325 325
 	 *
326 326
 	 * @todo   Set the ID to get_the_ID() if ID parameter is not passed through. Otherwise it will incorrectly get other gravatars
327 327
 	 */
328
-	public function shortcode( $atts, $content = null ) {
328
+	public function shortcode($atts, $content = null) {
329 329
 
330
-		$atts = shortcode_atts( array(
330
+		$atts = shortcode_atts(array(
331 331
 			'id'    => '',
332 332
 			'title' => ''
333
-		), $atts, 'give_donators_gravatars' );
333
+		), $atts, 'give_donators_gravatars');
334 334
 
335 335
 		// if no ID is passed on single give_forms pages, get the correct ID
336
-		if ( is_singular( 'give_forms' ) ) {
336
+		if (is_singular('give_forms')) {
337 337
 			$id = get_the_ID();
338 338
 		}
339 339
 
340
-		$content = $this->gravatars( $atts['id'], $atts['title'] );
340
+		$content = $this->gravatars($atts['id'], $atts['title']);
341 341
 
342 342
 		return $content;
343 343
 
@@ -353,57 +353,57 @@  discard block
 block discarded – undo
353 353
 	 *
354 354
 	 * @return array           Gravatar settings.
355 355
 	 */
356
-	public function settings( $settings ) {
356
+	public function settings($settings) {
357 357
 
358 358
 		$give_gravatar_settings = array(
359 359
 			array(
360
-				'name' => esc_html__( 'Donator Gravatars', 'give' ),
360
+				'name' => esc_html__('Donator Gravatars', 'give'),
361 361
 				'desc' => '<hr>',
362 362
 				'id'   => 'give_title',
363 363
 				'type' => 'give_title'
364 364
 			),
365 365
 			array(
366
-				'name' => esc_html__( 'Heading', 'give' ),
367
-				'desc' => esc_html__( 'The heading to display above the Gravatars', 'give' ),
366
+				'name' => esc_html__('Heading', 'give'),
367
+				'desc' => esc_html__('The heading to display above the Gravatars', 'give'),
368 368
 				'type' => 'text',
369 369
 				'id'   => 'give_donators_gravatars_heading'
370 370
 			),
371 371
 			array(
372
-				'name'    => esc_html__( 'Gravatar Size', 'give' ),
373
-				'desc'    => esc_html__( 'The size of each Gravatar in pixels (512px maximum)', 'give' ),
372
+				'name'    => esc_html__('Gravatar Size', 'give'),
373
+				'desc'    => esc_html__('The size of each Gravatar in pixels (512px maximum)', 'give'),
374 374
 				'type'    => 'text_small',
375 375
 				'id'      => 'give_donators_gravatars_gravatar_size',
376 376
 				'default' => '64'
377 377
 			),
378 378
 			array(
379
-				'name' => esc_html__( 'Minimum Unique Purchases Required', 'give' ),
379
+				'name' => esc_html__('Minimum Unique Purchases Required', 'give'),
380 380
 				/* translators: %s: form singular label */
381
-				'desc' => sprintf( esc_html__( 'The minimum number of unique purchases a %s must have before the Gravatars are shown. Leave blank for no minimum.', 'give' ), strtolower( give_get_forms_label_singular() ) ),
381
+				'desc' => sprintf(esc_html__('The minimum number of unique purchases a %s must have before the Gravatars are shown. Leave blank for no minimum.', 'give'), strtolower(give_get_forms_label_singular())),
382 382
 				'type' => 'text_small',
383 383
 				'id'   => 'give_donators_gravatars_min_purchases_required',
384 384
 			),
385 385
 			array(
386
-				'name'    => esc_html__( 'Maximum Gravatars To Show', 'give' ),
387
-				'desc'    => esc_html__( 'The maximum number of gravatars to show. Leave blank for no limit.', 'give' ),
386
+				'name'    => esc_html__('Maximum Gravatars To Show', 'give'),
387
+				'desc'    => esc_html__('The maximum number of gravatars to show. Leave blank for no limit.', 'give'),
388 388
 				'type'    => 'text',
389 389
 				'id'      => 'give_donators_gravatars_maximum_number',
390 390
 				'default' => '20',
391 391
 			),
392 392
 			array(
393
-				'name' => esc_html__( 'Gravatar Visibility', 'give' ),
394
-				'desc' => esc_html__( 'Only show donators with a Gravatar account', 'give' ),
393
+				'name' => esc_html__('Gravatar Visibility', 'give'),
394
+				'desc' => esc_html__('Only show donators with a Gravatar account', 'give'),
395 395
 				'id'   => 'give_donators_gravatars_has_gravatar_account',
396 396
 				'type' => 'checkbox',
397 397
 			),
398 398
 			array(
399
-				'name' => esc_html__( 'Randomize Gravatars', 'give' ),
400
-				'desc' => esc_html__( 'Randomize the Gravatars', 'give' ),
399
+				'name' => esc_html__('Randomize Gravatars', 'give'),
400
+				'desc' => esc_html__('Randomize the Gravatars', 'give'),
401 401
 				'id'   => 'give_donators_gravatars_random_gravatars',
402 402
 				'type' => 'checkbox',
403 403
 			),
404 404
 		);
405 405
 
406
-		return array_merge( $settings, $give_gravatar_settings );
406
+		return array_merge($settings, $give_gravatar_settings);
407 407
 	}
408 408
 
409 409
 }
@@ -428,13 +428,13 @@  discard block
 block discarded – undo
428 428
 	 */
429 429
 	public function __construct() {
430 430
 
431
-		$give_label_singular = function_exists( 'give_get_forms_label_singular' ) ? strtolower( give_get_forms_label_singular() ) : null;
431
+		$give_label_singular = function_exists('give_get_forms_label_singular') ? strtolower(give_get_forms_label_singular()) : null;
432 432
 
433 433
 		// widget settings
434 434
 		$widget_ops = array(
435 435
 			'classname'   => 'give-donators-gravatars',
436 436
 			/* translators: 1: form singular label 2: form singular label */
437
-			'description' => sprintf( esc_html__( 'Displays gravatars of people who have donated using your your %1$s. Will only show on the single %2$s page.', 'give' ), $give_label_singular, $give_label_singular )
437
+			'description' => sprintf(esc_html__('Displays gravatars of people who have donated using your your %1$s. Will only show on the single %2$s page.', 'give'), $give_label_singular, $give_label_singular)
438 438
 		);
439 439
 
440 440
 		// widget control settings
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 		// create the widget
448 448
 		parent::__construct(
449 449
 			'give_donators_gravatars_widget',
450
-			esc_html__( 'Give Donators Gravatars', 'give' ),
450
+			esc_html__('Give Donators Gravatars', 'give'),
451 451
 			$widget_ops,
452 452
 			$control_ops
453 453
 		);
@@ -467,30 +467,30 @@  discard block
 block discarded – undo
467 467
 	 *
468 468
 	 * @return void
469 469
 	 */
470
-	public function widget( $args, $instance ) {
470
+	public function widget($args, $instance) {
471 471
 		global $give_options;
472 472
 
473 473
 		//@TODO: Don't extract it!!!
474
-		extract( $args );
474
+		extract($args);
475 475
 
476
-		if ( ! is_singular( 'give_forms' ) ) {
476
+		if ( ! is_singular('give_forms')) {
477 477
 			return;
478 478
 		}
479 479
 
480 480
 		// Variables from widget settings
481
-		$title = apply_filters( 'widget_title', $instance['title'] );
481
+		$title = apply_filters('widget_title', $instance['title']);
482 482
 
483 483
 		// Used by themes. Opens the widget
484 484
 		echo $before_widget;
485 485
 
486 486
 		// Display the widget title
487
-		if ( $title ) {
488
-			echo $before_title . $title . $after_title;
487
+		if ($title) {
488
+			echo $before_title.$title.$after_title;
489 489
 		}
490 490
 
491 491
 		$gravatars = new Give_Donators_Gravatars();
492 492
 
493
-		echo $gravatars->gravatars( get_the_ID(), null ); // remove title
493
+		echo $gravatars->gravatars(get_the_ID(), null); // remove title
494 494
 
495 495
 		// Used by themes. Closes the widget
496 496
 		echo $after_widget;
@@ -510,11 +510,11 @@  discard block
 block discarded – undo
510 510
 	 *
511 511
 	 * @return array Updated settings to save.
512 512
 	 */
513
-	public function update( $new_instance, $old_instance ) {
513
+	public function update($new_instance, $old_instance) {
514 514
 
515 515
 		$instance = $old_instance;
516 516
 
517
-		$instance['title'] = strip_tags( $new_instance['title'] );
517
+		$instance['title'] = strip_tags($new_instance['title']);
518 518
 
519 519
 		return $instance;
520 520
 
@@ -532,19 +532,19 @@  discard block
 block discarded – undo
532 532
 	 *
533 533
 	 * @return void
534 534
 	 */
535
-	public function form( $instance ) {
535
+	public function form($instance) {
536 536
 
537 537
 		// Set up some default widget settings.
538 538
 		$defaults = array(
539 539
 			'title' => '',
540 540
 		);
541 541
 
542
-		$instance = wp_parse_args( (array) $instance, $defaults ); ?>
542
+		$instance = wp_parse_args((array) $instance, $defaults); ?>
543 543
 
544 544
 		<!-- Title -->
545 545
 		<p>
546
-			<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ) ?></label>
547
-			<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $instance['title']; ?>" />
546
+			<label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give') ?></label>
547
+			<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance['title']; ?>" />
548 548
 		</p>
549 549
 
550 550
 		<?php
Please login to merge, or discard this patch.
includes/post-types.php 1 patch
Spacing   +135 added lines, -135 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,40 +23,40 @@  discard block
 block discarded – undo
23 23
 function give_setup_post_types() {
24 24
 
25 25
 	/** Give Forms Post Type */
26
-	$give_forms_singular = give_get_option( 'disable_forms_singular' ) !== 'on' ? true : false;
26
+	$give_forms_singular = give_get_option('disable_forms_singular') !== 'on' ? true : false;
27 27
 
28
-	$give_forms_archives = give_get_option( 'disable_forms_archives' ) !== 'on' ? true : false;
28
+	$give_forms_archives = give_get_option('disable_forms_archives') !== 'on' ? true : false;
29 29
 
30
-	$give_forms_slug = defined( 'GIVE_SLUG' ) ? GIVE_SLUG : 'donations';
30
+	$give_forms_slug = defined('GIVE_SLUG') ? GIVE_SLUG : 'donations';
31 31
 	//support for old 'GIVE_FORMS_SLUG' constant
32
-	if ( defined( 'GIVE_FORMS_SLUG' ) ) {
32
+	if (defined('GIVE_FORMS_SLUG')) {
33 33
 		$give_forms_slug = GIVE_FORMS_SLUG;
34 34
 	}
35 35
 
36
-	$give_forms_rewrite = defined( 'GIVE_DISABLE_FORMS_REWRITE' ) && GIVE_DISABLE_FORMS_REWRITE ? false : array(
36
+	$give_forms_rewrite = defined('GIVE_DISABLE_FORMS_REWRITE') && GIVE_DISABLE_FORMS_REWRITE ? false : array(
37 37
 		'slug'       => $give_forms_slug,
38 38
 		'with_front' => false
39 39
 	);
40 40
 
41
-	$give_forms_labels = apply_filters( 'give_forms_labels', array(
42
-		'name'               => esc_html__( 'Donation %2$s', 'give' ),
41
+	$give_forms_labels = apply_filters('give_forms_labels', array(
42
+		'name'               => esc_html__('Donation %2$s', 'give'),
43 43
 		'singular_name'      => '%1$s',
44
-		'add_new'            => esc_html__( 'Add %1$s', 'give' ),
45
-		'add_new_item'       => esc_html__( 'Add New Donation %1$s', 'give' ),
46
-		'edit_item'          => esc_html__( 'Edit Donation %1$s', 'give' ),
47
-		'new_item'           => esc_html__( 'New %1$s', 'give' ),
48
-		'all_items'          => esc_html__( 'All %2$s', 'give' ),
49
-		'view_item'          => esc_html__( 'View %1$s', 'give' ),
50
-		'search_items'       => esc_html__( 'Search %2$s', 'give' ),
51
-		'not_found'          => esc_html__( 'No %2$s found', 'give' ),
52
-		'not_found_in_trash' => esc_html__( 'No %2$s found in Trash', 'give' ),
44
+		'add_new'            => esc_html__('Add %1$s', 'give'),
45
+		'add_new_item'       => esc_html__('Add New Donation %1$s', 'give'),
46
+		'edit_item'          => esc_html__('Edit Donation %1$s', 'give'),
47
+		'new_item'           => esc_html__('New %1$s', 'give'),
48
+		'all_items'          => esc_html__('All %2$s', 'give'),
49
+		'view_item'          => esc_html__('View %1$s', 'give'),
50
+		'search_items'       => esc_html__('Search %2$s', 'give'),
51
+		'not_found'          => esc_html__('No %2$s found', 'give'),
52
+		'not_found_in_trash' => esc_html__('No %2$s found in Trash', 'give'),
53 53
 		'parent_item_colon'  => '',
54
-		'menu_name'          => apply_filters( 'give_menu_name', esc_html__( 'Donations', 'give' ) ),
55
-		'name_admin_bar'     => apply_filters( 'give_name_admin_bar_name', esc_html__( 'Donation Form', 'give' ) )
56
-	) );
54
+		'menu_name'          => apply_filters('give_menu_name', esc_html__('Donations', 'give')),
55
+		'name_admin_bar'     => apply_filters('give_name_admin_bar_name', esc_html__('Donation Form', 'give'))
56
+	));
57 57
 
58
-	foreach ( $give_forms_labels as $key => $value ) {
59
-		$give_forms_labels[ $key ] = sprintf( $value, give_get_forms_label_singular(), give_get_forms_label_plural() );
58
+	foreach ($give_forms_labels as $key => $value) {
59
+		$give_forms_labels[$key] = sprintf($value, give_get_forms_label_singular(), give_get_forms_label_plural());
60 60
 	}
61 61
 
62 62
 	//Default give_forms supports
@@ -69,14 +69,14 @@  discard block
 block discarded – undo
69 69
 	);
70 70
 
71 71
 	//Has the user disabled the excerpt
72
-	if ( give_get_option( 'disable_forms_excerpt' ) === 'on' ) {
73
-		unset( $give_form_supports[2] );
72
+	if (give_get_option('disable_forms_excerpt') === 'on') {
73
+		unset($give_form_supports[2]);
74 74
 	}
75 75
 
76 76
 	//Has user disabled the featured image?
77
-	if ( give_get_option( 'disable_form_featured_img' ) === 'on' ) {
78
-		unset( $give_form_supports[1] );
79
-		remove_action( 'give_before_single_form_summary', 'give_show_form_images' );
77
+	if (give_get_option('disable_form_featured_img') === 'on') {
78
+		unset($give_form_supports[1]);
79
+		remove_action('give_before_single_form_summary', 'give_show_form_images');
80 80
 	}
81 81
 
82 82
 	$give_forms_args = array(
@@ -92,42 +92,42 @@  discard block
 block discarded – undo
92 92
 		'has_archive'        => $give_forms_archives,
93 93
 		'menu_icon'          => 'dashicons-give',
94 94
 		'hierarchical'       => false,
95
-		'supports'           => apply_filters( 'give_forms_supports', $give_form_supports ),
95
+		'supports'           => apply_filters('give_forms_supports', $give_form_supports),
96 96
 	);
97
-	register_post_type( 'give_forms', apply_filters( 'give_forms_post_type_args', $give_forms_args ) );
97
+	register_post_type('give_forms', apply_filters('give_forms_post_type_args', $give_forms_args));
98 98
 	
99 99
 	/** Payment Post Type */
100 100
 	$payment_labels = array(
101
-		'name'               => _x( 'Donations', 'post type general name', 'give' ),
102
-		'singular_name'      => _x( 'Donation', 'post type singular name', 'give' ),
103
-		'add_new'            => esc_html__( 'Add New', 'give' ),
104
-		'add_new_item'       => esc_html__( 'Add New Donation', 'give' ),
105
-		'edit_item'          => esc_html__( 'Edit Donation', 'give' ),
106
-		'new_item'           => esc_html__( 'New Donation', 'give' ),
107
-		'all_items'          => esc_html__( 'All Donations', 'give' ),
108
-		'view_item'          => esc_html__( 'View Donation', 'give' ),
109
-		'search_items'       => esc_html__( 'Search Donations', 'give' ),
110
-		'not_found'          => esc_html__( 'No Donations found', 'give' ),
111
-		'not_found_in_trash' => esc_html__( 'No Donations found in Trash', 'give' ),
101
+		'name'               => _x('Donations', 'post type general name', 'give'),
102
+		'singular_name'      => _x('Donation', 'post type singular name', 'give'),
103
+		'add_new'            => esc_html__('Add New', 'give'),
104
+		'add_new_item'       => esc_html__('Add New Donation', 'give'),
105
+		'edit_item'          => esc_html__('Edit Donation', 'give'),
106
+		'new_item'           => esc_html__('New Donation', 'give'),
107
+		'all_items'          => esc_html__('All Donations', 'give'),
108
+		'view_item'          => esc_html__('View Donation', 'give'),
109
+		'search_items'       => esc_html__('Search Donations', 'give'),
110
+		'not_found'          => esc_html__('No Donations found', 'give'),
111
+		'not_found_in_trash' => esc_html__('No Donations found in Trash', 'give'),
112 112
 		'parent_item_colon'  => '',
113
-		'menu_name'          => esc_html__( 'Transactions', 'give' )
113
+		'menu_name'          => esc_html__('Transactions', 'give')
114 114
 	);
115 115
 
116 116
 	$payment_args = array(
117
-		'labels'          => apply_filters( 'give_payment_labels', $payment_labels ),
117
+		'labels'          => apply_filters('give_payment_labels', $payment_labels),
118 118
 		'public'          => false,
119 119
 		'query_var'       => false,
120 120
 		'rewrite'         => false,
121 121
 		'map_meta_cap'    => true,
122 122
 		'capability_type' => 'give_payment',
123
-		'supports'        => array( 'title' ),
123
+		'supports'        => array('title'),
124 124
 		'can_export'      => true
125 125
 	);
126
-	register_post_type( 'give_payment', $payment_args );
126
+	register_post_type('give_payment', $payment_args);
127 127
 
128 128
 }
129 129
 
130
-add_action( 'init', 'give_setup_post_types', 1 );
130
+add_action('init', 'give_setup_post_types', 1);
131 131
 
132 132
 
133 133
 /**
@@ -140,32 +140,32 @@  discard block
 block discarded – undo
140 140
  */
141 141
 function give_setup_taxonomies() {
142 142
 
143
-	$slug = defined( 'GIVE_FORMS_SLUG' ) ? GIVE_FORMS_SLUG : 'donations';
143
+	$slug = defined('GIVE_FORMS_SLUG') ? GIVE_FORMS_SLUG : 'donations';
144 144
 
145 145
 	/** Categories */
146 146
 	$category_labels = array(
147 147
 		/* translators: %s: form singular label */
148
-		'name'              => sprintf( _x( '%s Categories', 'taxonomy general name', 'give' ), give_get_forms_label_singular() ),
149
-		'singular_name'     => _x( 'Category', 'taxonomy singular name', 'give' ),
150
-		'search_items'      => esc_html__( 'Search Categories', 'give' ),
151
-		'all_items'         => esc_html__( 'All Categories', 'give' ),
152
-		'parent_item'       => esc_html__( 'Parent Category', 'give' ),
153
-		'parent_item_colon' => esc_html__( 'Parent Category:', 'give' ),
154
-		'edit_item'         => esc_html__( 'Edit Category', 'give' ),
155
-		'update_item'       => esc_html__( 'Update Category', 'give' ),
148
+		'name'              => sprintf(_x('%s Categories', 'taxonomy general name', 'give'), give_get_forms_label_singular()),
149
+		'singular_name'     => _x('Category', 'taxonomy singular name', 'give'),
150
+		'search_items'      => esc_html__('Search Categories', 'give'),
151
+		'all_items'         => esc_html__('All Categories', 'give'),
152
+		'parent_item'       => esc_html__('Parent Category', 'give'),
153
+		'parent_item_colon' => esc_html__('Parent Category:', 'give'),
154
+		'edit_item'         => esc_html__('Edit Category', 'give'),
155
+		'update_item'       => esc_html__('Update Category', 'give'),
156 156
 		/* translators: %s: form singular label */
157
-		'add_new_item'      => sprintf( esc_html__( 'Add New %s Category', 'give' ), give_get_forms_label_singular() ),
158
-		'new_item_name'     => esc_html__( 'New Category Name', 'give' ),
159
-		'menu_name'         => esc_html__( 'Categories', 'give' ),
157
+		'add_new_item'      => sprintf(esc_html__('Add New %s Category', 'give'), give_get_forms_label_singular()),
158
+		'new_item_name'     => esc_html__('New Category Name', 'give'),
159
+		'menu_name'         => esc_html__('Categories', 'give'),
160 160
 	);
161 161
 
162
-	$category_args = apply_filters( 'give_forms_category_args', array(
162
+	$category_args = apply_filters('give_forms_category_args', array(
163 163
 			'hierarchical' => true,
164
-			'labels'       => apply_filters( 'give_forms_category_labels', $category_labels ),
164
+			'labels'       => apply_filters('give_forms_category_labels', $category_labels),
165 165
 			'show_ui'      => true,
166 166
 			'query_var'    => 'give_forms_category',
167 167
 			'rewrite'      => array(
168
-				'slug'         => $slug . '/category',
168
+				'slug'         => $slug.'/category',
169 169
 				'with_front'   => false,
170 170
 				'hierarchical' => true
171 171
 			),
@@ -179,36 +179,36 @@  discard block
 block discarded – undo
179 179
 	);
180 180
 
181 181
 	//Does the user want categories?
182
-	if ( give_get_option( 'enable_categories' ) == 'on' ) {
183
-		register_taxonomy( 'give_forms_category', array( 'give_forms' ), $category_args );
184
-		register_taxonomy_for_object_type( 'give_forms_category', 'give_forms' );
182
+	if (give_get_option('enable_categories') == 'on') {
183
+		register_taxonomy('give_forms_category', array('give_forms'), $category_args);
184
+		register_taxonomy_for_object_type('give_forms_category', 'give_forms');
185 185
 	}
186 186
 
187 187
 
188 188
 	/** Tags */
189 189
 	$tag_labels = array(
190 190
 		/* translators: %s: form singular label */
191
-		'name'                  => sprintf( _x( '%s Tags', 'taxonomy general name', 'give' ), give_get_forms_label_singular() ),
192
-		'singular_name'         => _x( 'Tag', 'taxonomy singular name', 'give' ),
193
-		'search_items'          => esc_html__( 'Search Tags', 'give' ),
194
-		'all_items'             => esc_html__( 'All Tags', 'give' ),
195
-		'parent_item'           => esc_html__( 'Parent Tag', 'give' ),
196
-		'parent_item_colon'     => esc_html__( 'Parent Tag:', 'give' ),
197
-		'edit_item'             => esc_html__( 'Edit Tag', 'give' ),
198
-		'update_item'           => esc_html__( 'Update Tag', 'give' ),
199
-		'add_new_item'          => esc_html__( 'Add New Tag', 'give' ),
200
-		'new_item_name'         => esc_html__( 'New Tag Name', 'give' ),
201
-		'menu_name'             => esc_html__( 'Tags', 'give' ),
191
+		'name'                  => sprintf(_x('%s Tags', 'taxonomy general name', 'give'), give_get_forms_label_singular()),
192
+		'singular_name'         => _x('Tag', 'taxonomy singular name', 'give'),
193
+		'search_items'          => esc_html__('Search Tags', 'give'),
194
+		'all_items'             => esc_html__('All Tags', 'give'),
195
+		'parent_item'           => esc_html__('Parent Tag', 'give'),
196
+		'parent_item_colon'     => esc_html__('Parent Tag:', 'give'),
197
+		'edit_item'             => esc_html__('Edit Tag', 'give'),
198
+		'update_item'           => esc_html__('Update Tag', 'give'),
199
+		'add_new_item'          => esc_html__('Add New Tag', 'give'),
200
+		'new_item_name'         => esc_html__('New Tag Name', 'give'),
201
+		'menu_name'             => esc_html__('Tags', 'give'),
202 202
 		/* translators: %s: form singular label */
203
-		'choose_from_most_used' => sprintf( esc_html__( 'Choose from most used %s tags.', 'give' ), give_get_forms_label_singular() ),
203
+		'choose_from_most_used' => sprintf(esc_html__('Choose from most used %s tags.', 'give'), give_get_forms_label_singular()),
204 204
 	);
205 205
 
206
-	$tag_args = apply_filters( 'give_forms_tag_args', array(
206
+	$tag_args = apply_filters('give_forms_tag_args', array(
207 207
 			'hierarchical' => false,
208
-			'labels'       => apply_filters( 'give_forms_tag_labels', $tag_labels ),
208
+			'labels'       => apply_filters('give_forms_tag_labels', $tag_labels),
209 209
 			'show_ui'      => true,
210 210
 			'query_var'    => 'give_forms_tag',
211
-			'rewrite'      => array( 'slug' => $slug . '/tag', 'with_front' => false, 'hierarchical' => true ),
211
+			'rewrite'      => array('slug' => $slug.'/tag', 'with_front' => false, 'hierarchical' => true),
212 212
 			'capabilities' => array(
213 213
 				'manage_terms' => 'manage_give_form_terms',
214 214
 				'edit_terms'   => 'edit_give_form_terms',
@@ -218,15 +218,15 @@  discard block
 block discarded – undo
218 218
 		)
219 219
 	);
220 220
 
221
-	if ( give_get_option( 'enable_tags' ) == 'on' ) {
222
-		register_taxonomy( 'give_forms_tag', array( 'give_forms' ), $tag_args );
223
-		register_taxonomy_for_object_type( 'give_forms_tag', 'give_forms' );
221
+	if (give_get_option('enable_tags') == 'on') {
222
+		register_taxonomy('give_forms_tag', array('give_forms'), $tag_args);
223
+		register_taxonomy_for_object_type('give_forms_tag', 'give_forms');
224 224
 	}
225 225
 
226 226
 
227 227
 }
228 228
 
229
-add_action( 'init', 'give_setup_taxonomies', 0 );
229
+add_action('init', 'give_setup_taxonomies', 0);
230 230
 
231 231
 
232 232
 /**
@@ -237,11 +237,11 @@  discard block
 block discarded – undo
237 237
  */
238 238
 function give_get_default_form_labels() {
239 239
 	$defaults = array(
240
-		'singular' => esc_html__( 'Form', 'give' ),
241
-		'plural'   => esc_html__( 'Forms', 'give' )
240
+		'singular' => esc_html__('Form', 'give'),
241
+		'plural'   => esc_html__('Forms', 'give')
242 242
 	);
243 243
 
244
-	return apply_filters( 'give_default_form_name', $defaults );
244
+	return apply_filters('give_default_form_name', $defaults);
245 245
 }
246 246
 
247 247
 /**
@@ -253,10 +253,10 @@  discard block
 block discarded – undo
253 253
  *
254 254
  * @return string $defaults['singular'] Singular label
255 255
  */
256
-function give_get_forms_label_singular( $lowercase = false ) {
256
+function give_get_forms_label_singular($lowercase = false) {
257 257
 	$defaults = give_get_default_form_labels();
258 258
 
259
-	return ( $lowercase ) ? strtolower( $defaults['singular'] ) : $defaults['singular'];
259
+	return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular'];
260 260
 }
261 261
 
262 262
 /**
@@ -265,10 +265,10 @@  discard block
 block discarded – undo
265 265
  * @since 1.0
266 266
  * @return string $defaults['plural'] Plural label
267 267
  */
268
-function give_get_forms_label_plural( $lowercase = false ) {
268
+function give_get_forms_label_plural($lowercase = false) {
269 269
 	$defaults = give_get_default_form_labels();
270 270
 
271
-	return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural'];
271
+	return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural'];
272 272
 }
273 273
 
274 274
 /**
@@ -280,12 +280,12 @@  discard block
 block discarded – undo
280 280
  *
281 281
  * @return string $title New placeholder text
282 282
  */
283
-function give_change_default_title( $title ) {
283
+function give_change_default_title($title) {
284 284
 	// If a frontend plugin uses this filter (check extensions before changing this function)
285
-	if ( ! is_admin() ) {
285
+	if ( ! is_admin()) {
286 286
 		$title = sprintf(
287 287
 			/* translators: %s: form singular label */
288
-			esc_html__( 'Enter %s title here', 'give' ),
288
+			esc_html__('Enter %s title here', 'give'),
289 289
 			give_get_forms_label_singular()
290 290
 		);
291 291
 
@@ -294,10 +294,10 @@  discard block
 block discarded – undo
294 294
 
295 295
 	$screen = get_current_screen();
296 296
 
297
-	if ( 'give_forms' == $screen->post_type ) {
297
+	if ('give_forms' == $screen->post_type) {
298 298
 		$title = sprintf(
299 299
 			/* translators: %s: form singular label */
300
-			esc_html__( 'Enter %s title here', 'give' ),
300
+			esc_html__('Enter %s title here', 'give'),
301 301
 			give_get_forms_label_singular()
302 302
 		);
303 303
 	}
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 	return $title;
306 306
 }
307 307
 
308
-add_filter( 'enter_title_here', 'give_change_default_title' );
308
+add_filter('enter_title_here', 'give_change_default_title');
309 309
 
310 310
 /**
311 311
  * Registers Custom Post Statuses which are used by the Payments
@@ -315,50 +315,50 @@  discard block
 block discarded – undo
315 315
  */
316 316
 function give_register_post_type_statuses() {
317 317
 	// Payment Statuses
318
-	register_post_status( 'refunded', array(
319
-		'label'                     => _x( 'Refunded', 'payment status', 'give' ),
318
+	register_post_status('refunded', array(
319
+		'label'                     => _x('Refunded', 'payment status', 'give'),
320 320
 		'public'                    => true,
321 321
 		'exclude_from_search'       => false,
322 322
 		'show_in_admin_all_list'    => true,
323 323
 		'show_in_admin_status_list' => true,
324
-		'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give' )
325
-	) );
326
-	register_post_status( 'failed', array(
327
-		'label'                     => _x( 'Failed', 'payment status', 'give' ),
324
+		'label_count'               => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give')
325
+	));
326
+	register_post_status('failed', array(
327
+		'label'                     => _x('Failed', 'payment status', 'give'),
328 328
 		'public'                    => true,
329 329
 		'exclude_from_search'       => false,
330 330
 		'show_in_admin_all_list'    => true,
331 331
 		'show_in_admin_status_list' => true,
332
-		'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give' )
333
-	) );
334
-	register_post_status( 'revoked', array(
335
-		'label'                     => _x( 'Revoked', 'payment status', 'give' ),
332
+		'label_count'               => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give')
333
+	));
334
+	register_post_status('revoked', array(
335
+		'label'                     => _x('Revoked', 'payment status', 'give'),
336 336
 		'public'                    => true,
337 337
 		'exclude_from_search'       => false,
338 338
 		'show_in_admin_all_list'    => true,
339 339
 		'show_in_admin_status_list' => true,
340
-		'label_count'               => _n_noop( 'Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give' )
341
-	) );
342
-	register_post_status( 'cancelled', array(
343
-		'label'                     => _x( 'Cancelled', 'payment status', 'give' ),
340
+		'label_count'               => _n_noop('Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give')
341
+	));
342
+	register_post_status('cancelled', array(
343
+		'label'                     => _x('Cancelled', 'payment status', 'give'),
344 344
 		'public'                    => true,
345 345
 		'exclude_from_search'       => false,
346 346
 		'show_in_admin_all_list'    => true,
347 347
 		'show_in_admin_status_list' => true,
348
-		'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give' )
349
-	) );
350
-	register_post_status( 'abandoned', array(
351
-		'label'                     => _x( 'Abandoned', 'payment status', 'give' ),
348
+		'label_count'               => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give')
349
+	));
350
+	register_post_status('abandoned', array(
351
+		'label'                     => _x('Abandoned', 'payment status', 'give'),
352 352
 		'public'                    => true,
353 353
 		'exclude_from_search'       => false,
354 354
 		'show_in_admin_all_list'    => true,
355 355
 		'show_in_admin_status_list' => true,
356
-		'label_count'               => _n_noop( 'Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give' )
357
-	) );
356
+		'label_count'               => _n_noop('Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give')
357
+	));
358 358
 
359 359
 }
360 360
 
361
-add_action( 'init', 'give_register_post_type_statuses' );
361
+add_action('init', 'give_register_post_type_statuses');
362 362
 
363 363
 /**
364 364
  * Updated Messages
@@ -371,43 +371,43 @@  discard block
 block discarded – undo
371 371
  *
372 372
  * @return array $messages New post updated messages
373 373
  */
374
-function give_updated_messages( $messages ) {
374
+function give_updated_messages($messages) {
375 375
 	global $post, $post_ID;
376 376
 
377
-	$url1 = '<a href="' . get_permalink( $post_ID ) . '">';
377
+	$url1 = '<a href="'.get_permalink($post_ID).'">';
378 378
 	$url2 = give_get_forms_label_singular();
379 379
 	$url3 = '</a>';
380 380
 
381 381
 	$messages['give_forms'] = array(
382
-		1 => sprintf( __( '%2$s updated. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ),
383
-		4 => sprintf( __( '%2$s updated. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ),
384
-		6 => sprintf( __( '%2$s published. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ),
385
-		7 => sprintf( __( '%2$s saved. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ),
386
-		8 => sprintf( __( '%2$s submitted. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 )
382
+		1 => sprintf(__('%2$s updated. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3),
383
+		4 => sprintf(__('%2$s updated. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3),
384
+		6 => sprintf(__('%2$s published. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3),
385
+		7 => sprintf(__('%2$s saved. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3),
386
+		8 => sprintf(__('%2$s submitted. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3)
387 387
 	);
388 388
 
389 389
 	return $messages;
390 390
 }
391 391
 
392
-add_filter( 'post_updated_messages', 'give_updated_messages' );
392
+add_filter('post_updated_messages', 'give_updated_messages');
393 393
 
394 394
 
395 395
 /**
396 396
  * Setup Post Type Images
397 397
  */
398
-add_action( 'after_setup_theme', 'give_add_thumbnail_support', 10 );
398
+add_action('after_setup_theme', 'give_add_thumbnail_support', 10);
399 399
 
400 400
 /**
401 401
  * Ensure post thumbnail support is turned on
402 402
  */
403 403
 function give_add_thumbnail_support() {
404
-	if ( give_get_option( 'disable_form_featured_img' ) === 'on' ) {
404
+	if (give_get_option('disable_form_featured_img') === 'on') {
405 405
 		return;
406 406
 	}
407
-	if ( ! current_theme_supports( 'post-thumbnails' ) ) {
408
-		add_theme_support( 'post-thumbnails' );
407
+	if ( ! current_theme_supports('post-thumbnails')) {
408
+		add_theme_support('post-thumbnails');
409 409
 	}
410
-	add_post_type_support( 'give_forms', 'thumbnail' );
410
+	add_post_type_support('give_forms', 'thumbnail');
411 411
 }
412 412
 
413 413
 /**
@@ -419,19 +419,19 @@  discard block
 block discarded – undo
419 419
 function give_widgets_init() {
420 420
 
421 421
 	//Single Give Forms (disabled if single turned off in settings)
422
-	if ( give_get_option( 'disable_forms_singular' ) !== 'on' && give_get_option( 'disable_form_sidebar' ) !== 'on' ) {
422
+	if (give_get_option('disable_forms_singular') !== 'on' && give_get_option('disable_form_sidebar') !== 'on') {
423 423
 
424
-		register_sidebar( apply_filters( 'give_forms_single_sidebar', array(
425
-			'name'          => esc_html__( 'Give Single Form Sidebar', 'give' ),
424
+		register_sidebar(apply_filters('give_forms_single_sidebar', array(
425
+			'name'          => esc_html__('Give Single Form Sidebar', 'give'),
426 426
 			'id'            => 'give-forms-sidebar',
427
-			'description'   => esc_html__( 'Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give' ),
427
+			'description'   => esc_html__('Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give'),
428 428
 			'before_widget' => '<div id="%1$s" class="widget %2$s">',
429 429
 			'after_widget'  => '</div>',
430 430
 			'before_title'  => '<h3 class="widgettitle widget-title">',
431 431
 			'after_title'   => '</h3>',
432
-		) ) );
432
+		)));
433 433
 
434 434
 	}
435 435
 }
436 436
 
437
-add_action( 'widgets_init', 'give_widgets_init', 999 );
437
+add_action('widgets_init', 'give_widgets_init', 999);
Please login to merge, or discard this patch.
includes/scripts.php 1 patch
Spacing   +139 added lines, -139 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,94 +26,94 @@  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
-	) );
51
-	$localize_give_ajax     = apply_filters( 'give_global_ajax_vars', array(
50
+	));
51
+	$localize_give_ajax = apply_filters('give_global_ajax_vars', array(
52 52
 		'ajaxurl'         => give_get_ajax_url(),
53
-		'loading'         => esc_html__( 'Loading', 'give' ),
53
+		'loading'         => esc_html__('Loading', 'give'),
54 54
 		// General loading message
55
-		'select_option'   => esc_html__( 'Please select an option', 'give' ),
55
+		'select_option'   => esc_html__('Please select an option', 'give'),
56 56
 		// Variable pricing error with multi-purchase option enabled
57
-		'default_gateway' => give_get_default_gateway( null ),
58
-		'permalinks'      => get_option( 'permalink_structure' ) ? '1' : '0',
57
+		'default_gateway' => give_get_default_gateway(null),
58
+		'permalinks'      => get_option('permalink_structure') ? '1' : '0',
59 59
 		'number_decimals' => give_get_price_decimals()
60
-	) );
60
+	));
61 61
 
62 62
 	//DEBUG is On
63
-	if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
63
+	if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) {
64 64
 
65
-		if ( give_is_cc_verify_enabled() ) {
66
-			wp_register_script( 'give-cc-validator', $js_plugins . 'jquery.payment' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
67
-			wp_enqueue_script( 'give-cc-validator' );
65
+		if (give_is_cc_verify_enabled()) {
66
+			wp_register_script('give-cc-validator', $js_plugins.'jquery.payment'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
67
+			wp_enqueue_script('give-cc-validator');
68 68
 		}
69 69
 
70
-		wp_register_script( 'give-float-labels', $js_plugins . 'float-labels' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
71
-		wp_enqueue_script( 'give-float-labels' );
70
+		wp_register_script('give-float-labels', $js_plugins.'float-labels'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
71
+		wp_enqueue_script('give-float-labels');
72 72
 
73
-		wp_register_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
74
-		wp_enqueue_script( 'give-blockui' );
73
+		wp_register_script('give-blockui', $js_plugins.'jquery.blockUI'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
74
+		wp_enqueue_script('give-blockui');
75 75
 
76
-		wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
77
-		wp_enqueue_script( 'give-qtip' );
76
+		wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
77
+		wp_enqueue_script('give-qtip');
78 78
 
79
-		wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
80
-		wp_enqueue_script( 'give-accounting' );
79
+		wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
80
+		wp_enqueue_script('give-accounting');
81 81
 
82
-		wp_register_script( 'give-magnific', $js_plugins . 'jquery.magnific-popup' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
83
-		wp_enqueue_script( 'give-magnific' );
82
+		wp_register_script('give-magnific', $js_plugins.'jquery.magnific-popup'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
83
+		wp_enqueue_script('give-magnific');
84 84
 
85
-		wp_register_script( 'give-checkout-global', $js_dir . 'give-checkout-global' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
86
-		wp_enqueue_script( 'give-checkout-global' );
85
+		wp_register_script('give-checkout-global', $js_dir.'give-checkout-global'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
86
+		wp_enqueue_script('give-checkout-global');
87 87
 
88 88
 		//General scripts
89
-		wp_register_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
90
-		wp_enqueue_script( 'give-scripts' );
89
+		wp_register_script('give-scripts', $js_dir.'give'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
90
+		wp_enqueue_script('give-scripts');
91 91
 
92 92
 		// Load AJAX scripts, if enabled
93
-		wp_register_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
94
-		wp_enqueue_script( 'give-ajax' );
93
+		wp_register_script('give-ajax', $js_dir.'give-ajax'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
94
+		wp_enqueue_script('give-ajax');
95 95
 
96 96
 		//Localize / Pass AJAX vars from PHP
97
-		wp_localize_script( 'give-checkout-global', 'give_global_vars', $localize_give_checkout );
98
-		wp_localize_script( 'give-ajax', 'give_scripts', $localize_give_ajax );
97
+		wp_localize_script('give-checkout-global', 'give_global_vars', $localize_give_checkout);
98
+		wp_localize_script('give-ajax', 'give_scripts', $localize_give_ajax);
99 99
 
100 100
 
101 101
 	} else {
102 102
 
103 103
 		//DEBUG is OFF (one JS file to rule them all!)
104
-		wp_register_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
105
-		wp_enqueue_script( 'give' );
104
+		wp_register_script('give', $js_dir.'give.all.min.js', array('jquery'), GIVE_VERSION, $scripts_footer);
105
+		wp_enqueue_script('give');
106 106
 
107 107
 		//Localize / Pass AJAX vars from PHP
108
-		wp_localize_script( 'give', 'give_global_vars', $localize_give_checkout );
109
-		wp_localize_script( 'give', 'give_scripts', $localize_give_ajax );
108
+		wp_localize_script('give', 'give_global_vars', $localize_give_checkout);
109
+		wp_localize_script('give', 'give_scripts', $localize_give_ajax);
110 110
 
111 111
 	}
112 112
 
113 113
 
114 114
 }
115 115
 
116
-add_action( 'wp_enqueue_scripts', 'give_load_scripts' );
116
+add_action('wp_enqueue_scripts', 'give_load_scripts');
117 117
 
118 118
 /**
119 119
  * Register styles.
@@ -125,16 +125,16 @@  discard block
 block discarded – undo
125 125
  */
126 126
 function give_register_styles() {
127 127
 
128
-	if ( give_get_option( 'disable_css', false ) ) {
128
+	if (give_get_option('disable_css', false)) {
129 129
 		return;
130 130
 	}
131 131
 
132
-	wp_register_style( 'give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all' );
133
-	wp_enqueue_style( 'give-styles' );
132
+	wp_register_style('give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all');
133
+	wp_enqueue_style('give-styles');
134 134
 
135 135
 }
136 136
 
137
-add_action( 'wp_enqueue_scripts', 'give_register_styles' );
137
+add_action('wp_enqueue_scripts', 'give_register_styles');
138 138
 
139 139
 
140 140
 /**
@@ -146,39 +146,39 @@  discard block
 block discarded – undo
146 146
 function give_get_stylesheet_uri() {
147 147
 
148 148
 	// Use minified libraries if SCRIPT_DEBUG is turned off
149
-	$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
149
+	$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
150 150
 
151
-	$file          = 'give' . $suffix . '.css';
151
+	$file          = 'give'.$suffix.'.css';
152 152
 	$templates_dir = give_get_theme_template_dir_name();
153 153
 
154
-	$child_theme_style_sheet    = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file;
155
-	$child_theme_style_sheet_2  = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give.css';
156
-	$parent_theme_style_sheet   = trailingslashit( get_template_directory() ) . $templates_dir . $file;
157
-	$parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give.css';
158
-	$give_plugin_style_sheet    = trailingslashit( give_get_templates_dir() ) . $file;
154
+	$child_theme_style_sheet    = trailingslashit(get_stylesheet_directory()).$templates_dir.$file;
155
+	$child_theme_style_sheet_2  = trailingslashit(get_stylesheet_directory()).$templates_dir.'give.css';
156
+	$parent_theme_style_sheet   = trailingslashit(get_template_directory()).$templates_dir.$file;
157
+	$parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give.css';
158
+	$give_plugin_style_sheet    = trailingslashit(give_get_templates_dir()).$file;
159 159
 
160 160
 	$uri = false;
161 161
 
162 162
 	// Look in the child theme directory first, followed by the parent theme, followed by the Give core templates directory
163 163
 	// Also look for the min version first, followed by non minified version, even if SCRIPT_DEBUG is not enabled.
164 164
 	// This allows users to copy just give.css to their theme
165
-	if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) {
166
-		if ( ! empty( $nonmin ) ) {
167
-			$uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give.css';
165
+	if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) {
166
+		if ( ! empty($nonmin)) {
167
+			$uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give.css';
168 168
 		} else {
169
-			$uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file;
169
+			$uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file;
170 170
 		}
171
-	} elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) {
172
-		if ( ! empty( $nonmin ) ) {
173
-			$uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give.css';
171
+	} elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) {
172
+		if ( ! empty($nonmin)) {
173
+			$uri = trailingslashit(get_template_directory_uri()).$templates_dir.'give.css';
174 174
 		} else {
175
-			$uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file;
175
+			$uri = trailingslashit(get_template_directory_uri()).$templates_dir.$file;
176 176
 		}
177
-	} elseif ( file_exists( $give_plugin_style_sheet ) || file_exists( $give_plugin_style_sheet ) ) {
178
-		$uri = trailingslashit( give_get_templates_url() ) . $file;
177
+	} elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) {
178
+		$uri = trailingslashit(give_get_templates_url()).$file;
179 179
 	}
180 180
 
181
-	return apply_filters( 'give_get_stylesheet_uri', $uri );
181
+	return apply_filters('give_get_stylesheet_uri', $uri);
182 182
 
183 183
 }
184 184
 
@@ -196,65 +196,65 @@  discard block
 block discarded – undo
196 196
  *
197 197
  * @return void
198 198
  */
199
-function give_load_admin_scripts( $hook ) {
199
+function give_load_admin_scripts($hook) {
200 200
 
201 201
 	global $wp_version, $post, $post_type, $give_options;
202 202
 
203 203
 	//Directories of assets
204
-	$js_dir     = GIVE_PLUGIN_URL . 'assets/js/admin/';
205
-	$js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/';
206
-	$css_dir    = GIVE_PLUGIN_URL . 'assets/css/';
204
+	$js_dir     = GIVE_PLUGIN_URL.'assets/js/admin/';
205
+	$js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/';
206
+	$css_dir    = GIVE_PLUGIN_URL.'assets/css/';
207 207
 
208 208
 	// Use minified libraries if SCRIPT_DEBUG is turned off
209
-	$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
209
+	$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
210 210
 
211 211
 	//Global Admin:
212
-	wp_register_style( 'give-admin-bar-notification', $css_dir . 'adminbar-style.css' );
213
-	wp_enqueue_style( 'give-admin-bar-notification' );
212
+	wp_register_style('give-admin-bar-notification', $css_dir.'adminbar-style.css');
213
+	wp_enqueue_style('give-admin-bar-notification');
214 214
 
215 215
 	//Give Admin Only:
216
-	if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) {
216
+	if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) {
217 217
 		return;
218 218
 	}
219 219
 
220 220
 	//CSS
221
-	wp_register_style( 'jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css' );
222
-	wp_enqueue_style( 'jquery-ui-css' );
223
-	wp_register_style( 'give-admin', $css_dir . 'give-admin' . $suffix . '.css', GIVE_VERSION );
224
-	wp_enqueue_style( 'give-admin' );
225
-	wp_register_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION );
226
-	wp_enqueue_style( 'jquery-chosen' );
227
-	wp_enqueue_style( 'thickbox' );
221
+	wp_register_style('jquery-ui-css', $css_dir.'jquery-ui-fresh'.$suffix.'.css');
222
+	wp_enqueue_style('jquery-ui-css');
223
+	wp_register_style('give-admin', $css_dir.'give-admin'.$suffix.'.css', GIVE_VERSION);
224
+	wp_enqueue_style('give-admin');
225
+	wp_register_style('jquery-chosen', $css_dir.'chosen'.$suffix.'.css', array(), GIVE_VERSION);
226
+	wp_enqueue_style('jquery-chosen');
227
+	wp_enqueue_style('thickbox');
228 228
 
229 229
 	//JS
230
-	wp_register_script( 'jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
231
-	wp_enqueue_script( 'jquery-chosen' );
230
+	wp_register_script('jquery-chosen', $js_plugins.'chosen.jquery'.$suffix.'.js', array('jquery'), GIVE_VERSION);
231
+	wp_enqueue_script('jquery-chosen');
232 232
 
233
-	wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
234
-	wp_enqueue_script( 'give-accounting' );
233
+	wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
234
+	wp_enqueue_script('give-accounting');
235 235
 
236
-	wp_register_script( 'give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
237
-	wp_enqueue_script( 'give-admin-scripts' );
236
+	wp_register_script('give-admin-scripts', $js_dir.'admin-scripts'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
237
+	wp_enqueue_script('give-admin-scripts');
238 238
 
239
-	wp_register_script( 'jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js' );
240
-	wp_enqueue_script( 'jquery-flot' );
239
+	wp_register_script('jquery-flot', $js_plugins.'jquery.flot'.$suffix.'.js');
240
+	wp_enqueue_script('jquery-flot');
241 241
 
242
-	wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
243
-	wp_enqueue_script( 'give-qtip' );
242
+	wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
243
+	wp_enqueue_script('give-qtip');
244 244
 
245
-	wp_enqueue_script( 'jquery-ui-datepicker' );
246
-	wp_enqueue_script( 'thickbox' );
245
+	wp_enqueue_script('jquery-ui-datepicker');
246
+	wp_enqueue_script('thickbox');
247 247
 
248 248
 	// Forms CPT Script.
249
-	if ( $post_type === 'give_forms' ) {
250
-		wp_register_script( 'give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
251
-		wp_enqueue_script( 'give-admin-forms-scripts' );
249
+	if ($post_type === 'give_forms') {
250
+		wp_register_script('give-admin-forms-scripts', $js_dir.'admin-forms'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
251
+		wp_enqueue_script('give-admin-forms-scripts');
252 252
 	}
253 253
 
254 254
 	//Settings Scripts
255
-	if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-settings' ) {
256
-		wp_register_script( 'give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
257
-		wp_enqueue_script( 'give-admin-settings-scripts' );
255
+	if (isset($_GET['page']) && $_GET['page'] == 'give-settings') {
256
+		wp_register_script('give-admin-settings-scripts', $js_dir.'admin-settings'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
257
+		wp_enqueue_script('give-admin-settings-scripts');
258 258
 	}
259 259
 
260 260
 	// Price Separators.
@@ -262,50 +262,50 @@  discard block
 block discarded – undo
262 262
 	$decimal_separator  = give_get_price_decimal_separator();
263 263
 
264 264
 	//Localize strings & variables for JS
265
-	wp_localize_script( 'give-admin-scripts', 'give_vars', array(
266
-		'post_id'                 => isset( $post->ID ) ? $post->ID : null,
265
+	wp_localize_script('give-admin-scripts', 'give_vars', array(
266
+		'post_id'                 => isset($post->ID) ? $post->ID : null,
267 267
 		'give_version'            => GIVE_VERSION,
268 268
 		'thousands_separator'     => $thousand_separator,
269 269
 		'decimal_separator'       => $decimal_separator,
270
-		'quick_edit_warning'      => esc_html__( 'Sorry, not available for variable priced forms.', 'give' ),
271
-		'delete_payment'          => esc_html__( 'Are you sure you wish to delete this payment?', 'give' ),
272
-		'delete_payment_note'     => esc_html__( 'Are you sure you wish to delete this note?', 'give' ),
273
-		'revoke_api_key'          => esc_html__( 'Are you sure you wish to revoke this API key?', 'give' ),
274
-		'regenerate_api_key'      => esc_html__( 'Are you sure you wish to regenerate this API key?', 'give' ),
275
-		'resend_receipt'          => esc_html__( 'Are you sure you wish to resend the donation receipt?', 'give' ),
276
-		'copy_download_link_text' => esc_html__( 'Copy these links to your clipboard and give them to your donor.', 'give' ),
270
+		'quick_edit_warning'      => esc_html__('Sorry, not available for variable priced forms.', 'give'),
271
+		'delete_payment'          => esc_html__('Are you sure you wish to delete this payment?', 'give'),
272
+		'delete_payment_note'     => esc_html__('Are you sure you wish to delete this note?', 'give'),
273
+		'revoke_api_key'          => esc_html__('Are you sure you wish to revoke this API key?', 'give'),
274
+		'regenerate_api_key'      => esc_html__('Are you sure you wish to regenerate this API key?', 'give'),
275
+		'resend_receipt'          => esc_html__('Are you sure you wish to resend the donation receipt?', 'give'),
276
+		'copy_download_link_text' => esc_html__('Copy these links to your clipboard and give them to your donor.', 'give'),
277 277
 		/* translators: %s: form singular label */
278
-		'delete_payment_download' => sprintf( esc_html__( 'Are you sure you wish to delete this %s?', 'give' ), give_get_forms_label_singular() ),
279
-		'one_price_min'           => esc_html__( 'You must have at least one price.', 'give' ),
280
-		'one_file_min'            => esc_html__( 'You must have at least one file.', 'give' ),
281
-		'one_field_min'           => esc_html__( 'You must have at least one field.', 'give' ),
278
+		'delete_payment_download' => sprintf(esc_html__('Are you sure you wish to delete this %s?', 'give'), give_get_forms_label_singular()),
279
+		'one_price_min'           => esc_html__('You must have at least one price.', 'give'),
280
+		'one_file_min'            => esc_html__('You must have at least one file.', 'give'),
281
+		'one_field_min'           => esc_html__('You must have at least one field.', 'give'),
282 282
 		/* translators: %s: form singular label */
283
-		'one_option'              => sprintf( esc_html__( 'Choose a %s', 'give' ), give_get_forms_label_singular() ),
283
+		'one_option'              => sprintf(esc_html__('Choose a %s', 'give'), give_get_forms_label_singular()),
284 284
 		/* translators: %s: form plural label */
285
-		'one_or_more_option'      => sprintf( esc_html__( 'Choose one or more %s', 'give' ), give_get_forms_label_plural() ),
286
-		'numeric_item_price'      => esc_html__( 'Item price must be numeric.', 'give' ),
287
-		'numeric_quantity'        => esc_html__( 'Quantity must be numeric.', 'give' ),
288
-		'currency_sign'           => give_currency_filter( '' ),
289
-		'currency_pos'            => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before',
290
-		'currency_decimals'       => give_currency_decimal_filter( give_get_price_decimals() ),
291
-		'new_media_ui'            => apply_filters( 'give_use_35_media_ui', 1 ),
292
-		'remove_text'             => esc_html__( 'Remove', 'give' ),
285
+		'one_or_more_option'      => sprintf(esc_html__('Choose one or more %s', 'give'), give_get_forms_label_plural()),
286
+		'numeric_item_price'      => esc_html__('Item price must be numeric.', 'give'),
287
+		'numeric_quantity'        => esc_html__('Quantity must be numeric.', 'give'),
288
+		'currency_sign'           => give_currency_filter(''),
289
+		'currency_pos'            => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before',
290
+		'currency_decimals'       => give_currency_decimal_filter(give_get_price_decimals()),
291
+		'new_media_ui'            => apply_filters('give_use_35_media_ui', 1),
292
+		'remove_text'             => esc_html__('Remove', 'give'),
293 293
 		/* translators: %s: form plural label */
294
-		'type_to_search'          => sprintf( esc_html__( 'Type to search %s', 'give' ), give_get_forms_label_plural() ),
295
-		'batch_export_no_class'   => esc_html__( 'You must choose a method.', 'give' ),
296
-		'batch_export_no_reqs'    => esc_html__( 'Required fields not completed.', 'give' ),
297
-		'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' ),
298
-		'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 )
299
-	) );
300
-
301
-	if ( function_exists( 'wp_enqueue_media' ) && version_compare( $wp_version, '3.5', '>=' ) ) {
294
+		'type_to_search'          => sprintf(esc_html__('Type to search %s', 'give'), give_get_forms_label_plural()),
295
+		'batch_export_no_class'   => esc_html__('You must choose a method.', 'give'),
296
+		'batch_export_no_reqs'    => esc_html__('Required fields not completed.', 'give'),
297
+		'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'),
298
+		'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)
299
+	));
300
+
301
+	if (function_exists('wp_enqueue_media') && version_compare($wp_version, '3.5', '>=')) {
302 302
 		//call for new media manager
303 303
 		wp_enqueue_media();
304 304
 	}
305 305
 
306 306
 }
307 307
 
308
-add_action( 'admin_enqueue_scripts', 'give_load_admin_scripts', 100 );
308
+add_action('admin_enqueue_scripts', 'give_load_admin_scripts', 100);
309 309
 
310 310
 /**
311 311
  * Admin Give Icon
@@ -322,14 +322,14 @@  discard block
 block discarded – undo
322 322
 	?>
323 323
 	<style type="text/css" media="screen">
324 324
 
325
-		<?php if( version_compare( $wp_version, '3.8-RC', '>=' ) || version_compare( $wp_version, '3.8', '>=' ) ) { ?>
325
+		<?php if (version_compare($wp_version, '3.8-RC', '>=') || version_compare($wp_version, '3.8', '>=')) { ?>
326 326
 		@font-face {
327 327
 			font-family: 'give-icomoon';
328
-			src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?-ngjl88'; ?>');
329
-			src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?#iefix-ngjl88'?>') format('embedded-opentype'),
330
-			url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.woff?-ngjl88'; ?>') format('woff'),
331
-			url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.ttf?-ngjl88'; ?>') format('truetype'),
332
-			url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.svg?-ngjl88#icomoon'; ?>') format('svg');
328
+			src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?-ngjl88'; ?>');
329
+			src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?#iefix-ngjl88'?>') format('embedded-opentype'),
330
+			url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.woff?-ngjl88'; ?>') format('woff'),
331
+			url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.ttf?-ngjl88'; ?>') format('truetype'),
332
+			url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.svg?-ngjl88#icomoon'; ?>') format('svg');
333 333
 			font-weight: normal;
334 334
 			font-style: normal;
335 335
 		}
@@ -348,4 +348,4 @@  discard block
 block discarded – undo
348 348
 	<?php
349 349
 }
350 350
 
351
-add_action( 'admin_head', 'give_admin_icon' );
351
+add_action('admin_head', 'give_admin_icon');
Please login to merge, or discard this patch.
includes/class-give-stats.php 1 patch
Spacing   +106 added lines, -106 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
 
@@ -85,19 +85,19 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	public function get_predefined_dates() {
87 87
 		$predefined = array(
88
-			'today'        => esc_html__( 'Today', 'give' ),
89
-			'yesterday'    => esc_html__( 'Yesterday', 'give' ),
90
-			'this_week'    => esc_html__( 'This Week', 'give' ),
91
-			'last_week'    => esc_html__( 'Last Week', 'give' ),
92
-			'this_month'   => esc_html__( 'This Month', 'give' ),
93
-			'last_month'   => esc_html__( 'Last Month', 'give' ),
94
-			'this_quarter' => esc_html__( 'This Quarter', 'give' ),
95
-			'last_quarter' => esc_html__( 'Last Quarter', 'give' ),
96
-			'this_year'    => esc_html__( 'This Year', 'give' ),
97
-			'last_year'    => esc_html__( 'Last Year', 'give' )
88
+			'today'        => esc_html__('Today', 'give'),
89
+			'yesterday'    => esc_html__('Yesterday', 'give'),
90
+			'this_week'    => esc_html__('This Week', 'give'),
91
+			'last_week'    => esc_html__('Last Week', 'give'),
92
+			'this_month'   => esc_html__('This Month', 'give'),
93
+			'last_month'   => esc_html__('Last Month', 'give'),
94
+			'this_quarter' => esc_html__('This Quarter', 'give'),
95
+			'last_quarter' => esc_html__('Last Quarter', 'give'),
96
+			'this_year'    => esc_html__('This Year', 'give'),
97
+			'last_year'    => esc_html__('Last Year', 'give')
98 98
 		);
99 99
 
100
-		return apply_filters( 'give_stats_predefined_dates', $predefined );
100
+		return apply_filters('give_stats_predefined_dates', $predefined);
101 101
 	}
102 102
 
103 103
 	/**
@@ -113,18 +113,18 @@  discard block
 block discarded – undo
113 113
 	 *
114 114
 	 * @return void
115 115
 	 */
116
-	public function setup_dates( $_start_date = 'this_month', $_end_date = false ) {
116
+	public function setup_dates($_start_date = 'this_month', $_end_date = false) {
117 117
 
118
-		if ( empty( $_start_date ) ) {
118
+		if (empty($_start_date)) {
119 119
 			$_start_date = 'this_month';
120 120
 		}
121 121
 
122
-		if ( empty( $_end_date ) ) {
122
+		if (empty($_end_date)) {
123 123
 			$_end_date = $_start_date;
124 124
 		}
125 125
 
126
-		$this->start_date = $this->convert_date( $_start_date );
127
-		$this->end_date   = $this->convert_date( $_end_date, true );
126
+		$this->start_date = $this->convert_date($_start_date);
127
+		$this->end_date   = $this->convert_date($_end_date, true);
128 128
 	}
129 129
 
130 130
 	/**
@@ -140,26 +140,26 @@  discard block
 block discarded – undo
140 140
 	 *
141 141
 	 * @return array|WP_Error   If the date is invalid, a WP_Error object will be returned.
142 142
 	 */
143
-	public function convert_date( $date, $end_date = false ) {
143
+	public function convert_date($date, $end_date = false) {
144 144
 
145 145
 		$this->timestamp = false;
146 146
 		$second          = $end_date ? 59 : 0;
147 147
 		$minute          = $end_date ? 59 : 0;
148 148
 		$hour            = $end_date ? 23 : 0;
149 149
 		$day             = 1;
150
-		$month           = date( 'n', current_time( 'timestamp' ) );
151
-		$year            = date( 'Y', current_time( 'timestamp' ) );
150
+		$month           = date('n', current_time('timestamp'));
151
+		$year            = date('Y', current_time('timestamp'));
152 152
 
153
-		if ( array_key_exists( $date, $this->get_predefined_dates() ) ) {
153
+		if (array_key_exists($date, $this->get_predefined_dates())) {
154 154
 
155 155
 			// This is a predefined date rate, such as last_week
156
-			switch ( $date ) {
156
+			switch ($date) {
157 157
 
158 158
 				case 'this_month' :
159 159
 
160
-					if ( $end_date ) {
160
+					if ($end_date) {
161 161
 
162
-						$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
162
+						$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
163 163
 						$hour   = 23;
164 164
 						$minute = 59;
165 165
 						$second = 59;
@@ -169,28 +169,28 @@  discard block
 block discarded – undo
169 169
 
170 170
 				case 'last_month' :
171 171
 
172
-					if ( $month == 1 ) {
172
+					if ($month == 1) {
173 173
 
174 174
 						$month = 12;
175
-						$year --;
175
+						$year--;
176 176
 
177 177
 					} else {
178 178
 
179
-						$month --;
179
+						$month--;
180 180
 
181 181
 					}
182 182
 
183
-					if ( $end_date ) {
184
-						$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
183
+					if ($end_date) {
184
+						$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
185 185
 					}
186 186
 
187 187
 					break;
188 188
 
189 189
 				case 'today' :
190 190
 
191
-					$day = date( 'd', current_time( 'timestamp' ) );
191
+					$day = date('d', current_time('timestamp'));
192 192
 
193
-					if ( $end_date ) {
193
+					if ($end_date) {
194 194
 						$hour   = 23;
195 195
 						$minute = 59;
196 196
 						$second = 59;
@@ -200,23 +200,23 @@  discard block
 block discarded – undo
200 200
 
201 201
 				case 'yesterday' :
202 202
 
203
-					$day = date( 'd', current_time( 'timestamp' ) ) - 1;
203
+					$day = date('d', current_time('timestamp')) - 1;
204 204
 
205 205
 					// Check if Today is the first day of the month (meaning subtracting one will get us 0)
206
-					if ( $day < 1 ) {
206
+					if ($day < 1) {
207 207
 
208 208
 						// If current month is 1
209
-						if ( 1 == $month ) {
209
+						if (1 == $month) {
210 210
 
211 211
 							$year -= 1; // Today is January 1, so skip back to last day of December
212 212
 							$month = 12;
213
-							$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
213
+							$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
214 214
 
215 215
 						} else {
216 216
 
217 217
 							// Go back one month and get the last day of the month
218 218
 							$month -= 1;
219
-							$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
219
+							$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
220 220
 
221 221
 						}
222 222
 					}
@@ -225,12 +225,12 @@  discard block
 block discarded – undo
225 225
 
226 226
 				case 'this_week' :
227 227
 
228
-					$days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24;
229
-					$today              = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24;
228
+					$days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24;
229
+					$today              = date('d', current_time('timestamp')) * 60 * 60 * 24;
230 230
 
231
-					if ( $today < $days_to_week_start ) {
231
+					if ($today < $days_to_week_start) {
232 232
 
233
-						if ( $month > 1 ) {
233
+						if ($month > 1) {
234 234
 							$month -= 1;
235 235
 						} else {
236 236
 							$month = 12;
@@ -238,19 +238,19 @@  discard block
 block discarded – undo
238 238
 
239 239
 					}
240 240
 
241
-					if ( ! $end_date ) {
241
+					if ( ! $end_date) {
242 242
 
243 243
 						// Getting the start day
244 244
 
245
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1;
246
-						$day += get_option( 'start_of_week' );
245
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 1;
246
+						$day += get_option('start_of_week');
247 247
 
248 248
 					} else {
249 249
 
250 250
 						// Getting the end day
251 251
 
252
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1;
253
-						$day += get_option( 'start_of_week' ) + 6;
252
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 1;
253
+						$day += get_option('start_of_week') + 6;
254 254
 
255 255
 					}
256 256
 
@@ -258,12 +258,12 @@  discard block
 block discarded – undo
258 258
 
259 259
 				case 'last_week' :
260 260
 
261
-					$days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24;
262
-					$today              = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24;
261
+					$days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24;
262
+					$today              = date('d', current_time('timestamp')) * 60 * 60 * 24;
263 263
 
264
-					if ( $today < $days_to_week_start ) {
264
+					if ($today < $days_to_week_start) {
265 265
 
266
-						if ( $month > 1 ) {
266
+						if ($month > 1) {
267 267
 							$month -= 1;
268 268
 						} else {
269 269
 							$month = 12;
@@ -271,19 +271,19 @@  discard block
 block discarded – undo
271 271
 
272 272
 					}
273 273
 
274
-					if ( ! $end_date ) {
274
+					if ( ! $end_date) {
275 275
 
276 276
 						// Getting the start day
277 277
 
278
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8;
279
-						$day += get_option( 'start_of_week' );
278
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 8;
279
+						$day += get_option('start_of_week');
280 280
 
281 281
 					} else {
282 282
 
283 283
 						// Getting the end day
284 284
 
285
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8;
286
-						$day += get_option( 'start_of_week' ) + 6;
285
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 8;
286
+						$day += get_option('start_of_week') + 6;
287 287
 
288 288
 					}
289 289
 
@@ -291,39 +291,39 @@  discard block
 block discarded – undo
291 291
 
292 292
 				case 'this_quarter' :
293 293
 
294
-					$month_now = date( 'n', current_time( 'timestamp' ) );
294
+					$month_now = date('n', current_time('timestamp'));
295 295
 
296
-					if ( $month_now <= 3 ) {
296
+					if ($month_now <= 3) {
297 297
 
298
-						if ( ! $end_date ) {
298
+						if ( ! $end_date) {
299 299
 							$month = 1;
300 300
 						} else {
301 301
 							$month  = 3;
302
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
302
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
303 303
 							$hour   = 23;
304 304
 							$minute = 59;
305 305
 							$second = 59;
306 306
 						}
307 307
 
308
-					} else if ( $month_now <= 6 ) {
308
+					} else if ($month_now <= 6) {
309 309
 
310
-						if ( ! $end_date ) {
310
+						if ( ! $end_date) {
311 311
 							$month = 4;
312 312
 						} else {
313 313
 							$month  = 6;
314
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
314
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
315 315
 							$hour   = 23;
316 316
 							$minute = 59;
317 317
 							$second = 59;
318 318
 						}
319 319
 
320
-					} else if ( $month_now <= 9 ) {
320
+					} else if ($month_now <= 9) {
321 321
 
322
-						if ( ! $end_date ) {
322
+						if ( ! $end_date) {
323 323
 							$month = 7;
324 324
 						} else {
325 325
 							$month  = 9;
326
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
326
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
327 327
 							$hour   = 23;
328 328
 							$minute = 59;
329 329
 							$second = 59;
@@ -331,11 +331,11 @@  discard block
 block discarded – undo
331 331
 
332 332
 					} else {
333 333
 
334
-						if ( ! $end_date ) {
334
+						if ( ! $end_date) {
335 335
 							$month = 10;
336 336
 						} else {
337 337
 							$month  = 12;
338
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
338
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
339 339
 							$hour   = 23;
340 340
 							$minute = 59;
341 341
 							$second = 59;
@@ -347,40 +347,40 @@  discard block
 block discarded – undo
347 347
 
348 348
 				case 'last_quarter' :
349 349
 
350
-					$month_now = date( 'n', current_time( 'timestamp' ) );
350
+					$month_now = date('n', current_time('timestamp'));
351 351
 
352
-					if ( $month_now <= 3 ) {
352
+					if ($month_now <= 3) {
353 353
 
354
-						if ( ! $end_date ) {
354
+						if ( ! $end_date) {
355 355
 							$month = 10;
356 356
 						} else {
357 357
 							$year -= 1;
358 358
 							$month  = 12;
359
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
359
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
360 360
 							$hour   = 23;
361 361
 							$minute = 59;
362 362
 							$second = 59;
363 363
 						}
364 364
 
365
-					} else if ( $month_now <= 6 ) {
365
+					} else if ($month_now <= 6) {
366 366
 
367
-						if ( ! $end_date ) {
367
+						if ( ! $end_date) {
368 368
 							$month = 1;
369 369
 						} else {
370 370
 							$month  = 3;
371
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
371
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
372 372
 							$hour   = 23;
373 373
 							$minute = 59;
374 374
 							$second = 59;
375 375
 						}
376 376
 
377
-					} else if ( $month_now <= 9 ) {
377
+					} else if ($month_now <= 9) {
378 378
 
379
-						if ( ! $end_date ) {
379
+						if ( ! $end_date) {
380 380
 							$month = 4;
381 381
 						} else {
382 382
 							$month  = 6;
383
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
383
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
384 384
 							$hour   = 23;
385 385
 							$minute = 59;
386 386
 							$second = 59;
@@ -388,11 +388,11 @@  discard block
 block discarded – undo
388 388
 
389 389
 					} else {
390 390
 
391
-						if ( ! $end_date ) {
391
+						if ( ! $end_date) {
392 392
 							$month = 7;
393 393
 						} else {
394 394
 							$month  = 9;
395
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
395
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
396 396
 							$hour   = 23;
397 397
 							$minute = 59;
398 398
 							$second = 59;
@@ -404,11 +404,11 @@  discard block
 block discarded – undo
404 404
 
405 405
 				case 'this_year' :
406 406
 
407
-					if ( ! $end_date ) {
407
+					if ( ! $end_date) {
408 408
 						$month = 1;
409 409
 					} else {
410 410
 						$month  = 12;
411
-						$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
411
+						$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
412 412
 						$hour   = 23;
413 413
 						$minute = 59;
414 414
 						$second = 59;
@@ -419,11 +419,11 @@  discard block
 block discarded – undo
419 419
 				case 'last_year' :
420 420
 
421 421
 					$year -= 1;
422
-					if ( ! $end_date ) {
422
+					if ( ! $end_date) {
423 423
 						$month = 1;
424 424
 					} else {
425 425
 						$month  = 12;
426
-						$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
426
+						$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
427 427
 						$hour   = 23;
428 428
 						$minute = 59;
429 429
 						$second = 59;
@@ -434,30 +434,30 @@  discard block
 block discarded – undo
434 434
 			}
435 435
 
436 436
 
437
-		} else if ( is_numeric( $date ) ) {
437
+		} else if (is_numeric($date)) {
438 438
 
439 439
 			// return $date unchanged since it is a timestamp
440 440
 			$this->timestamp = true;
441 441
 
442
-		} else if ( false !== strtotime( $date ) ) {
442
+		} else if (false !== strtotime($date)) {
443 443
 
444
-			$date  = strtotime( $date, current_time( 'timestamp' ) );
445
-			$year  = date( 'Y', $date );
446
-			$month = date( 'm', $date );
447
-			$day   = date( 'd', $date );
444
+			$date  = strtotime($date, current_time('timestamp'));
445
+			$year  = date('Y', $date);
446
+			$month = date('m', $date);
447
+			$day   = date('d', $date);
448 448
 
449 449
 		} else {
450 450
 
451
-			return new WP_Error( 'invalid_date', esc_html__( 'Improper date provided.', 'give' ) );
451
+			return new WP_Error('invalid_date', esc_html__('Improper date provided.', 'give'));
452 452
 
453 453
 		}
454 454
 
455
-		if ( false === $this->timestamp ) {
455
+		if (false === $this->timestamp) {
456 456
 			// Create an exact timestamp
457
-			$date = mktime( $hour, $minute, $second, $month, $day, $year );
457
+			$date = mktime($hour, $minute, $second, $month, $day, $year);
458 458
 		}
459 459
 
460
-		return apply_filters( 'give_stats_date', $date, $end_date, $this );
460
+		return apply_filters('give_stats_date', $date, $end_date, $this);
461 461
 
462 462
 	}
463 463
 
@@ -473,33 +473,33 @@  discard block
 block discarded – undo
473 473
 	 * 
474 474
 	 * @return string
475 475
 	 */
476
-	public function count_where( $where = '' ) {
476
+	public function count_where($where = '') {
477 477
 		// Only get payments in our date range
478 478
 
479 479
 		$start_where = '';
480 480
 		$end_where   = '';
481 481
 
482
-		if ( $this->start_date ) {
482
+		if ($this->start_date) {
483 483
 
484
-			if ( $this->timestamp ) {
484
+			if ($this->timestamp) {
485 485
 				$format = 'Y-m-d H:i:s';
486 486
 			} else {
487 487
 				$format = 'Y-m-d 00:00:00';
488 488
 			}
489 489
 
490
-			$start_date  = date( $format, $this->start_date );
490
+			$start_date  = date($format, $this->start_date);
491 491
 			$start_where = " AND p.post_date >= '{$start_date}'";
492 492
 		}
493 493
 
494
-		if ( $this->end_date ) {
494
+		if ($this->end_date) {
495 495
 
496
-			if ( $this->timestamp ) {
496
+			if ($this->timestamp) {
497 497
 				$format = 'Y-m-d H:i:s';
498 498
 			} else {
499 499
 				$format = 'Y-m-d 23:59:59';
500 500
 			}
501 501
 
502
-			$end_date = date( $format, $this->end_date );
502
+			$end_date = date($format, $this->end_date);
503 503
 
504 504
 			$end_where = " AND p.post_date <= '{$end_date}'";
505 505
 		}
@@ -521,34 +521,34 @@  discard block
 block discarded – undo
521 521
 	 *
522 522
 	 * @return string
523 523
 	 */
524
-	public function payments_where( $where = '' ) {
524
+	public function payments_where($where = '') {
525 525
 
526 526
 		global $wpdb;
527 527
 
528 528
 		$start_where = '';
529 529
 		$end_where   = '';
530 530
 
531
-		if ( ! is_wp_error( $this->start_date ) ) {
531
+		if ( ! is_wp_error($this->start_date)) {
532 532
 
533
-			if ( $this->timestamp ) {
533
+			if ($this->timestamp) {
534 534
 				$format = 'Y-m-d H:i:s';
535 535
 			} else {
536 536
 				$format = 'Y-m-d 00:00:00';
537 537
 			}
538 538
 
539
-			$start_date  = date( $format, $this->start_date );
539
+			$start_date  = date($format, $this->start_date);
540 540
 			$start_where = " AND $wpdb->posts.post_date >= '{$start_date}'";
541 541
 		}
542 542
 
543
-		if ( ! is_wp_error( $this->end_date ) ) {
543
+		if ( ! is_wp_error($this->end_date)) {
544 544
 
545
-			if ( $this->timestamp ) {
545
+			if ($this->timestamp) {
546 546
 				$format = 'Y-m-d 00:00:00';
547 547
 			} else {
548 548
 				$format = 'Y-m-d 23:59:59';
549 549
 			}
550 550
 
551
-			$end_date = date( $format, $this->end_date );
551
+			$end_date = date($format, $this->end_date);
552 552
 
553 553
 			$end_where = " AND $wpdb->posts.post_date <= '{$end_date}'";
554 554
 		}
Please login to merge, or discard this patch.
includes/emails/template.php 1 patch
Spacing   +101 added lines, -101 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,38 +56,38 @@  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 69
 	$receipt_link = sprintf(
70 70
 		'<a href="%1$s">%2$s</a>',
71
-		esc_url( add_query_arg( array( 'payment_key' => $receipt_id, 'give_action' => 'view_receipt' ), home_url() ) ),
72
-		esc_html__( 'View the receipt in your browser &raquo;', 'give' )
71
+		esc_url(add_query_arg(array('payment_key' => $receipt_id, 'give_action' => 'view_receipt'), home_url())),
72
+		esc_html__('View the receipt in your browser &raquo;', 'give')
73 73
 	);
74 74
 
75 75
 	$user = wp_get_current_user();
76 76
 
77
-	$message = str_replace( '{name}', $user->display_name, $message );
78
-	$message = str_replace( '{fullname}', $user->display_name, $message );
79
-	$message = str_replace( '{username}', $user->user_login, $message );
80
-	$message = str_replace( '{date}', date( get_option( 'date_format' ), current_time( 'timestamp' ) ), $message );
81
-	$message = str_replace( '{price}', $price, $message );
82
-	$message = str_replace( '{donation}', esc_html__( 'Sample Donation Form Title', 'give' ), $message );
83
-	$message = str_replace( '{receipt_id}', $receipt_id, $message );
84
-	$message = str_replace( '{payment_method}', $gateway, $message );
85
-	$message = str_replace( '{sitename}', get_bloginfo( 'name' ), $message );
86
-	$message = str_replace( '{payment_id}', $payment_id, $message );
87
-	$message = str_replace( '{receipt_link}', $receipt_link, $message );
88
-	$message = str_replace( '{pdf_receipt}', '<a href="#">Download Receipt</a>', $message );
89
-
90
-	return wpautop( apply_filters( 'give_email_preview_template_tags', $message ) );
77
+	$message = str_replace('{name}', $user->display_name, $message);
78
+	$message = str_replace('{fullname}', $user->display_name, $message);
79
+	$message = str_replace('{username}', $user->user_login, $message);
80
+	$message = str_replace('{date}', date(get_option('date_format'), current_time('timestamp')), $message);
81
+	$message = str_replace('{price}', $price, $message);
82
+	$message = str_replace('{donation}', esc_html__('Sample Donation Form Title', 'give'), $message);
83
+	$message = str_replace('{receipt_id}', $receipt_id, $message);
84
+	$message = str_replace('{payment_method}', $gateway, $message);
85
+	$message = str_replace('{sitename}', get_bloginfo('name'), $message);
86
+	$message = str_replace('{payment_id}', $payment_id, $message);
87
+	$message = str_replace('{receipt_link}', $receipt_link, $message);
88
+	$message = str_replace('{pdf_receipt}', '<a href="#">Download Receipt</a>', $message);
89
+
90
+	return wpautop(apply_filters('give_email_preview_template_tags', $message));
91 91
 }
92 92
 
93 93
 /**
@@ -99,23 +99,23 @@  discard block
 block discarded – undo
99 99
  * @since  1.0
100 100
  * @return array|bool
101 101
  */
102
-function give_email_template_preview( $array ) {
102
+function give_email_template_preview($array) {
103 103
 
104
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
104
+	if ( ! current_user_can('manage_give_settings')) {
105 105
 		return false;
106 106
 	}
107 107
 	$custom_field = array(
108
-		'name' => esc_html__( 'Preview Email', 'give' ),
109
-		'desc' => esc_html__( 'Click the buttons to preview emails.', 'give' ),
108
+		'name' => esc_html__('Preview Email', 'give'),
109
+		'desc' => esc_html__('Click the buttons to preview emails.', 'give'),
110 110
 		'id'   => 'give_email_preview_buttons',
111 111
 		'type' => 'email_preview_buttons'
112 112
 	);
113 113
 
114
-	return give_settings_array_insert( $array, 'donation_subject', array( $custom_field ) );
114
+	return give_settings_array_insert($array, 'donation_subject', array($custom_field));
115 115
 
116 116
 }
117 117
 
118
-add_filter( 'give_settings_emails', 'give_email_template_preview' );
118
+add_filter('give_settings_emails', 'give_email_template_preview');
119 119
 
120 120
 /**
121 121
  * Output Email Template Preview Buttons.
@@ -127,12 +127,12 @@  discard block
 block discarded – undo
127 127
 function give_email_preview_buttons_callback() {
128 128
 	ob_start();
129 129
 	?>
130
-	<a href="<?php echo esc_url( add_query_arg( array( 'give_action' => 'preview_email' ), home_url() ) ); ?>" class="button-secondary" target="_blank" title="<?php esc_attr_e( 'Donation Receipt Preview', 'give' ); ?> "><?php esc_html_e( 'Preview Donation Receipt', 'give' ); ?></a>
131
-	<a href="<?php echo wp_nonce_url( add_query_arg( array(
130
+	<a href="<?php echo esc_url(add_query_arg(array('give_action' => 'preview_email'), home_url())); ?>" class="button-secondary" target="_blank" title="<?php esc_attr_e('Donation Receipt Preview', 'give'); ?> "><?php esc_html_e('Preview Donation Receipt', 'give'); ?></a>
131
+	<a href="<?php echo wp_nonce_url(add_query_arg(array(
132 132
 		'give_action'  => 'send_test_email',
133 133
 		'give-message' => 'sent-test-email',
134 134
 		'tag'          => 'emails'
135
-	) ), 'give-test-email' ); ?>" title="<?php esc_attr_e( 'This will send a demo donation receipt to the emails listed below.', 'give' ); ?>" class="button-secondary"><?php esc_html_e( 'Send Test Email', 'give' ); ?></a>
135
+	)), 'give-test-email'); ?>" title="<?php esc_attr_e('This will send a demo donation receipt to the emails listed below.', 'give'); ?>" class="button-secondary"><?php esc_html_e('Send Test Email', 'give'); ?></a>
136 136
 	<?php
137 137
 	echo ob_get_clean();
138 138
 }
@@ -145,46 +145,46 @@  discard block
 block discarded – undo
145 145
  */
146 146
 function give_display_email_template_preview() {
147 147
 
148
-	if ( empty( $_GET['give_action'] ) ) {
148
+	if (empty($_GET['give_action'])) {
149 149
 		return;
150 150
 	}
151 151
 
152
-	if ( 'preview_email' !== $_GET['give_action'] ) {
152
+	if ('preview_email' !== $_GET['give_action']) {
153 153
 		return;
154 154
 	}
155 155
 
156
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
156
+	if ( ! current_user_can('manage_give_settings')) {
157 157
 		return;
158 158
 	}
159 159
 
160 160
 
161
-	Give()->emails->heading = esc_html__( 'Donation Receipt', 'give' );
161
+	Give()->emails->heading = esc_html__('Donation Receipt', 'give');
162 162
 
163
-	$payment_id = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : '';
163
+	$payment_id = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : '';
164 164
 
165 165
 	echo give_get_preview_email_header();
166 166
 
167 167
 	//Are we previewing an actual payment?
168
-	if ( ! empty( $payment_id ) ) {
168
+	if ( ! empty($payment_id)) {
169 169
 
170
-		$content = give_get_email_body_content( $payment_id );
170
+		$content = give_get_email_body_content($payment_id);
171 171
 
172
-		$preview_content = give_do_email_tags( $content, $payment_id );
172
+		$preview_content = give_do_email_tags($content, $payment_id);
173 173
 
174 174
 	} else {
175 175
 
176 176
 		//No payment ID, use sample preview content
177
-		$preview_content = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) );
177
+		$preview_content = give_email_preview_template_tags(give_get_email_body_content(0, array()));
178 178
 	}
179 179
 
180 180
 
181
-	echo Give()->emails->build_email( $preview_content );
181
+	echo Give()->emails->build_email($preview_content);
182 182
 
183 183
 	exit;
184 184
 
185 185
 }
186 186
 
187
-add_action( 'init', 'give_display_email_template_preview' );
187
+add_action('init', 'give_display_email_template_preview');
188 188
 
189 189
 /**
190 190
  * Email Template Body.
@@ -196,18 +196,18 @@  discard block
 block discarded – undo
196 196
  *
197 197
  * @return string $email_body Body of the email
198 198
  */
199
-function give_get_email_body_content( $payment_id = 0, $payment_data = array() ) {
199
+function give_get_email_body_content($payment_id = 0, $payment_data = array()) {
200 200
 
201 201
 	$default_email_body = give_get_default_donation_receipt_email();
202 202
 
203
-	$email_content = give_get_option( 'donation_receipt' );
204
-	$email_content = isset( $email_content ) ? stripslashes( $email_content ) : $default_email_body;
203
+	$email_content = give_get_option('donation_receipt');
204
+	$email_content = isset($email_content) ? stripslashes($email_content) : $default_email_body;
205 205
 
206
-	$email_body = wpautop( $email_content );
206
+	$email_body = wpautop($email_content);
207 207
 
208
-	$email_body = apply_filters( 'give_donation_receipt_' . Give()->emails->get_template(), $email_body, $payment_id, $payment_data );
208
+	$email_body = apply_filters('give_donation_receipt_'.Give()->emails->get_template(), $email_body, $payment_id, $payment_data);
209 209
 
210
-	return apply_filters( 'give_donation_receipt', $email_body, $payment_id, $payment_data );
210
+	return apply_filters('give_donation_receipt', $email_body, $payment_id, $payment_data);
211 211
 }
212 212
 
213 213
 /**
@@ -220,37 +220,37 @@  discard block
 block discarded – undo
220 220
  *
221 221
  * @return string $email_body Body of the email
222 222
  */
223
-function give_get_donation_notification_body_content( $payment_id = 0, $payment_data = array() ) {
223
+function give_get_donation_notification_body_content($payment_id = 0, $payment_data = array()) {
224 224
 
225
-	$user_info = maybe_unserialize( $payment_data['user_info'] );
226
-	$email     = give_get_payment_user_email( $payment_id );
225
+	$user_info = maybe_unserialize($payment_data['user_info']);
226
+	$email     = give_get_payment_user_email($payment_id);
227 227
 
228
-	if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) {
229
-		$user_data = get_userdata( $user_info['id'] );
228
+	if (isset($user_info['id']) && $user_info['id'] > 0) {
229
+		$user_data = get_userdata($user_info['id']);
230 230
 		$name      = $user_data->display_name;
231
-	} elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) {
232
-		$name = $user_info['first_name'] . ' ' . $user_info['last_name'];
231
+	} elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) {
232
+		$name = $user_info['first_name'].' '.$user_info['last_name'];
233 233
 	} else {
234 234
 		$name = $email;
235 235
 	}
236 236
 
237
-	$gateway = give_get_gateway_admin_label( get_post_meta( $payment_id, '_give_payment_gateway', true ) );
237
+	$gateway = give_get_gateway_admin_label(get_post_meta($payment_id, '_give_payment_gateway', true));
238 238
 
239
-	$default_email_body = esc_html__( 'Hello', 'give' ) . "\n\n";
240
-	$default_email_body .= esc_html__( 'A donation has been made.', 'give' ) . "\n\n";
239
+	$default_email_body = esc_html__('Hello', 'give')."\n\n";
240
+	$default_email_body .= esc_html__('A donation has been made.', 'give')."\n\n";
241 241
 	/* translators: %s: form plural label */
242
-	$default_email_body .= sprintf( esc_html__( '%s sold:', 'give' ), give_get_forms_label_plural() ) . "\n\n";
243
-	$default_email_body .= esc_html__( 'Donor:', 'give' ) . ' ' . html_entity_decode( $name, ENT_COMPAT, 'UTF-8' ) . "\n";
244
-	$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";
245
-	$default_email_body .= esc_html__( 'Payment Method:', 'give' ) . ' ' . $gateway . "\n\n";
246
-	$default_email_body .= esc_html__( 'Thank you', 'give' );
242
+	$default_email_body .= sprintf(esc_html__('%s sold:', 'give'), give_get_forms_label_plural())."\n\n";
243
+	$default_email_body .= esc_html__('Donor:', 'give').' '.html_entity_decode($name, ENT_COMPAT, 'UTF-8')."\n";
244
+	$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";
245
+	$default_email_body .= esc_html__('Payment Method:', 'give').' '.$gateway."\n\n";
246
+	$default_email_body .= esc_html__('Thank you', 'give');
247 247
 
248
-	$email = give_get_option( 'donation_notification' );
249
-	$email = isset( $email ) ? stripslashes( $email ) : $default_email_body;
248
+	$email = give_get_option('donation_notification');
249
+	$email = isset($email) ? stripslashes($email) : $default_email_body;
250 250
 
251
-	$email_body = give_do_email_tags( $email, $payment_id );
251
+	$email_body = give_do_email_tags($email, $payment_id);
252 252
 
253
-	return apply_filters( 'give_donation_notification', wpautop( $email_body ), $payment_id, $payment_data );
253
+	return apply_filters('give_donation_notification', wpautop($email_body), $payment_id, $payment_data);
254 254
 }
255 255
 
256 256
 /**
@@ -263,34 +263,34 @@  discard block
 block discarded – undo
263 263
  * @since  1.0
264 264
  */
265 265
 function give_render_receipt_in_browser() {
266
-	if ( ! isset( $_GET['payment_key'] ) ) {
267
-		wp_die( esc_html__( 'Missing donation payment key.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
266
+	if ( ! isset($_GET['payment_key'])) {
267
+		wp_die(esc_html__('Missing donation payment key.', 'give'), esc_html__('Error', 'give'), array('response' => 400));
268 268
 	}
269 269
 
270
-	$key = urlencode( $_GET['payment_key'] );
270
+	$key = urlencode($_GET['payment_key']);
271 271
 
272 272
 	ob_start();
273 273
 	//Disallows caching of the page
274
-	header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" );
275
-	header( "Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1
276
-	header( "Cache-Control: post-check=0, pre-check=0", false );
277
-	header( "Pragma: no-cache" ); // HTTP/1.0
278
-	header( "Expires: Sat, 23 Oct 1977 05:00:00 PST" ); // Date in the past
274
+	header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
275
+	header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
276
+	header("Cache-Control: post-check=0, pre-check=0", false);
277
+	header("Pragma: no-cache"); // HTTP/1.0
278
+	header("Expires: Sat, 23 Oct 1977 05:00:00 PST"); // Date in the past
279 279
 	?>
280 280
 	<!DOCTYPE html>
281 281
 	<html lang="en">
282 282
 	<head>
283
-		<?php do_action( 'give_receipt_head' ); ?>
283
+		<?php do_action('give_receipt_head'); ?>
284 284
 	</head>
285
-	<body class="<?php echo apply_filters( 'give_receipt_page_body_class', 'give_receipt_page' ); ?>">
285
+	<body class="<?php echo apply_filters('give_receipt_page_body_class', 'give_receipt_page'); ?>">
286 286
 
287 287
 	<div id="give_receipt_wrapper">
288
-		<?php do_action( 'give_render_receipt_in_browser_before' ); ?>
289
-		<?php echo do_shortcode( '[give_receipt payment_key=' . $key . ']' ); ?>
290
-		<?php do_action( 'give_render_receipt_in_browser_after' ); ?>
288
+		<?php do_action('give_render_receipt_in_browser_before'); ?>
289
+		<?php echo do_shortcode('[give_receipt payment_key='.$key.']'); ?>
290
+		<?php do_action('give_render_receipt_in_browser_after'); ?>
291 291
 	</div>
292 292
 
293
-	<?php do_action( 'give_receipt_footer' ); ?>
293
+	<?php do_action('give_receipt_footer'); ?>
294 294
 	</body>
295 295
 	</html>
296 296
 	<?php
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	die();
299 299
 }
300 300
 
301
-add_action( 'give_view_receipt', 'give_render_receipt_in_browser' );
301
+add_action('give_view_receipt', 'give_render_receipt_in_browser');
302 302
 
303 303
 
304 304
 /**
@@ -313,31 +313,31 @@  discard block
 block discarded – undo
313 313
 
314 314
 	//Payment receipt switcher
315 315
 	$payment_count = give_count_payments()->publish;
316
-	$payment_id    = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : '';
316
+	$payment_id    = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : '';
317 317
 
318
-	if ( $payment_count <= 0 ) {
318
+	if ($payment_count <= 0) {
319 319
 		return false;
320 320
 	}
321 321
 
322 322
 	//Get payments.
323
-	$payments = new Give_Payments_Query( array(
323
+	$payments = new Give_Payments_Query(array(
324 324
 		'number' => 100
325
-	) );
325
+	));
326 326
 	$payments = $payments->get_payments();
327 327
 	$options  = array();
328 328
 
329 329
 	//Provide nice human readable options.
330
-	if ( $payments ) {
330
+	if ($payments) {
331 331
 		$options[0] =
332 332
 			/* translators: %s: transaction singular label */
333
-			esc_html__( '- Select a transaction -', 'give' );
334
-		foreach ( $payments as $payment ) {
333
+			esc_html__('- Select a transaction -', 'give');
334
+		foreach ($payments as $payment) {
335 335
 
336
-			$options[ $payment->ID ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title );
336
+			$options[$payment->ID] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title);
337 337
 
338 338
 		}
339 339
 	} else {
340
-		$options[0] = esc_html__( 'No Transactions Found', 'give' );
340
+		$options[0] = esc_html__('No Transactions Found', 'give');
341 341
 	}
342 342
 
343 343
 	//Start constructing HTML output.
@@ -350,16 +350,16 @@  discard block
 block discarded – undo
350 350
 			        var selected_trans = transactions.options[transactions.selectedIndex];
351 351
 				        console.log(selected_trans);
352 352
 				        if (selected_trans){
353
-				            var url_string = "' . get_bloginfo( 'url' ) . '?give_action=preview_email&preview_id=" + selected_trans.value;
353
+				            var url_string = "' . get_bloginfo('url').'?give_action=preview_email&preview_id=" + selected_trans.value;
354 354
 				                window.location = url_string;
355 355
 				        }
356 356
 				    }
357 357
 			    </script>';
358 358
 
359
-	$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 transaction:', 'give' ) . '</label>';
359
+	$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 transaction:', 'give').'</label>';
360 360
 
361 361
 	//The select field with 100 latest transactions
362
-	$transaction_header .= Give()->html->select( array(
362
+	$transaction_header .= Give()->html->select(array(
363 363
 		'name'             => 'preview_email_payment_id',
364 364
 		'selected'         => $payment_id,
365 365
 		'id'               => 'give_preview_email_payment_id',
@@ -369,12 +369,12 @@  discard block
 block discarded – undo
369 369
 		'select_atts'      => 'onchange="change_preview()">',
370 370
 		'show_option_all'  => false,
371 371
 		'show_option_none' => false
372
-	) );
372
+	));
373 373
 
374 374
 	//Closing tag
375 375
 	$transaction_header .= '</div>';
376 376
 
377
-	return apply_filters( 'give_preview_email_receipt_header', $transaction_header );
377
+	return apply_filters('give_preview_email_receipt_header', $transaction_header);
378 378
 
379 379
 }
380 380
 
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 function give_receipt_head_content() {
389 389
 
390 390
 	//Title.
391
-	$output = '<title>' . esc_html__( 'Donation Receipt', 'give' ) . '</title>';
391
+	$output = '<title>'.esc_html__('Donation Receipt', 'give').'</title>';
392 392
 
393 393
 	//Meta.
394 394
 	$output .= '<meta charset="utf-8"/>
@@ -402,10 +402,10 @@  discard block
 block discarded – undo
402 402
 		<meta name="robots" content="noindex, nofollow"/>';
403 403
 
404 404
 	//CSS
405
-	$output .= '<link rel="stylesheet" href="' . give_get_stylesheet_uri() . '?ver=' . GIVE_VERSION . '">';
405
+	$output .= '<link rel="stylesheet" href="'.give_get_stylesheet_uri().'?ver='.GIVE_VERSION.'">';
406 406
 
407
-	echo apply_filters( 'give_receipt_head_content', $output );
407
+	echo apply_filters('give_receipt_head_content', $output);
408 408
 
409 409
 }
410 410
 
411
-add_action( 'give_receipt_head', 'give_receipt_head_content' );
412 411
\ No newline at end of file
412
+add_action('give_receipt_head', 'give_receipt_head_content');
413 413
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-give-template-loader.php 1 patch
Spacing   +25 added lines, -25 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
 
@@ -38,29 +38,29 @@  discard block
 block discarded – undo
38 38
 		/**
39 39
 		 * Templates
40 40
 		 */
41
-		add_filter( 'template_include', array( __CLASS__, 'template_loader' ) );
41
+		add_filter('template_include', array(__CLASS__, 'template_loader'));
42 42
 
43 43
 		/**
44 44
 		 * Content Wrappers
45 45
 		 */
46
-		add_action( 'give_before_main_content', 'give_output_content_wrapper', 10 );
47
-		add_action( 'give_after_main_content', 'give_output_content_wrapper_end', 10 );
46
+		add_action('give_before_main_content', 'give_output_content_wrapper', 10);
47
+		add_action('give_after_main_content', 'give_output_content_wrapper_end', 10);
48 48
 
49 49
 		/**
50 50
 		 * Entry Summary Classes
51 51
 		 */
52
-		add_filter( 'give_forms_single_summary_classes', array( $this, 'give_set_single_summary_classes' ) );
52
+		add_filter('give_forms_single_summary_classes', array($this, 'give_set_single_summary_classes'));
53 53
 
54 54
 		/**
55 55
 		 * Sidebar
56 56
 		 */
57
-		add_action( 'give_before_single_form_summary', array( $this, 'give_output_sidebar_option' ), 1 );
57
+		add_action('give_before_single_form_summary', array($this, 'give_output_sidebar_option'), 1);
58 58
 
59 59
 		/**
60 60
 		 * Single Forms Summary Box
61 61
 		 */
62
-		add_action( 'give_single_form_summary', 'give_template_single_title', 5 );
63
-		add_action( 'give_single_form_summary', 'give_get_donation_form', 10 );
62
+		add_action('give_single_form_summary', 'give_template_single_title', 5);
63
+		add_action('give_single_form_summary', 'give_get_donation_form', 10);
64 64
 
65 65
 	}
66 66
 
@@ -75,12 +75,12 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @return string $classes List of space separated class names.
77 77
 	 */
78
-	public function give_set_single_summary_classes( $classes ) {
78
+	public function give_set_single_summary_classes($classes) {
79 79
 
80
-		$sidebar_option = give_get_option( 'disable_form_sidebar' );
80
+		$sidebar_option = give_get_option('disable_form_sidebar');
81 81
 
82 82
 		//Add full width class when feature image is disabled AND no widgets are present
83
-		if ( $sidebar_option == 'on' ) {
83
+		if ($sidebar_option == 'on') {
84 84
 			$classes .= ' give-full-width';
85 85
 		}
86 86
 
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	public function give_output_sidebar_option() {
102 102
 
103
-		$sidebar_option = give_get_option( 'disable_form_sidebar' );
103
+		$sidebar_option = give_get_option('disable_form_sidebar');
104 104
 
105 105
 		//Add full width class when feature image is disabled AND no widgets are present
106
-		if ( $sidebar_option !== 'on' ) {
107
-			add_action( 'give_before_single_form_summary', 'give_left_sidebar_pre_wrap', 5 );
108
-			add_action( 'give_before_single_form_summary', 'give_show_form_images', 10 );
109
-			add_action( 'give_before_single_form_summary', 'give_get_forms_sidebar', 20 );
110
-			add_action( 'give_before_single_form_summary', 'give_left_sidebar_post_wrap', 30 );
106
+		if ($sidebar_option !== 'on') {
107
+			add_action('give_before_single_form_summary', 'give_left_sidebar_pre_wrap', 5);
108
+			add_action('give_before_single_form_summary', 'give_show_form_images', 10);
109
+			add_action('give_before_single_form_summary', 'give_get_forms_sidebar', 20);
110
+			add_action('give_before_single_form_summary', 'give_left_sidebar_post_wrap', 30);
111 111
 		}
112 112
 
113 113
 	}
@@ -129,20 +129,20 @@  discard block
 block discarded – undo
129 129
 	 *
130 130
 	 * @return string $template
131 131
 	 */
132
-	public static function template_loader( $template ) {
133
-		$find = array( 'give.php' );
132
+	public static function template_loader($template) {
133
+		$find = array('give.php');
134 134
 		$file = '';
135 135
 
136
-		if ( is_single() && get_post_type() == 'give_forms' ) {
136
+		if (is_single() && get_post_type() == 'give_forms') {
137 137
 			$file   = 'single-give-form.php';
138 138
 			$find[] = $file;
139
-			$find[] = apply_filters( 'give_template_path', 'give/' ) . $file;
139
+			$find[] = apply_filters('give_template_path', 'give/').$file;
140 140
 		}
141 141
 
142
-		if ( $file ) {
143
-			$template = locate_template( array_unique( $find ) );
144
-			if ( ! $template ) {
145
-				$template = GIVE_PLUGIN_DIR . '/templates/' . $file;
142
+		if ($file) {
143
+			$template = locate_template(array_unique($find));
144
+			if ( ! $template) {
145
+				$template = GIVE_PLUGIN_DIR.'/templates/'.$file;
146 146
 			}
147 147
 		}
148 148
 
Please login to merge, or discard this patch.