Completed
Pull Request — master (#782)
by
unknown
20:41
created
includes/api/class-give-api-v1.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) exit;
13
+if ( ! defined('ABSPATH')) exit;
14 14
 
15 15
 /**
16 16
  * Give_API_V1 Class
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) exit;
13
+if ( ! defined( 'ABSPATH' ) ) {
14
+	exit;
15
+}
14 16
 
15 17
 /**
16 18
  * Give_API_V1 Class
Please login to merge, or discard this patch.
includes/class-give-template-loader.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
 	public function __construct() {
15 15
 
16
-		add_filter( 'template_include', array( __CLASS__, 'template_loader' ) );
16
+		add_filter('template_include', array(__CLASS__, 'template_loader'));
17 17
 
18 18
 
19 19
 		/**
@@ -28,19 +28,19 @@  discard block
 block discarded – undo
28 28
 		 * @see 3give_output_content_wrapper()
29 29
 		 * @see give_output_content_wrapper_end()
30 30
 		 */
31
-		add_action( 'give_before_main_content', 'give_output_content_wrapper', 10 );
32
-		add_action( 'give_after_main_content', 'give_output_content_wrapper_end', 10 );
31
+		add_action('give_before_main_content', 'give_output_content_wrapper', 10);
32
+		add_action('give_after_main_content', 'give_output_content_wrapper_end', 10);
33 33
 
34 34
 		/**
35 35
 		 * Entry Summary Classes
36 36
 		 */
37
-		add_filter( 'give_forms_single_summary_classes', array( $this, 'give_set_single_summary_classes' ) );
37
+		add_filter('give_forms_single_summary_classes', array($this, 'give_set_single_summary_classes'));
38 38
 
39 39
 
40 40
 		/**
41 41
 		 * Sidebar
42 42
 		 */
43
-		add_action( 'give_before_single_form_summary', array( $this, 'give_output_sidebar_option' ), 1 );
43
+		add_action('give_before_single_form_summary', array($this, 'give_output_sidebar_option'), 1);
44 44
 
45 45
 
46 46
 		/**
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
 		 *
49 49
 		 * @see give_template_single_title()
50 50
 		 */
51
-		add_action( 'give_single_form_summary', 'give_template_single_title', 5 );
52
-		add_action( 'give_single_form_summary', 'give_get_donation_form', 10 );
51
+		add_action('give_single_form_summary', 'give_template_single_title', 5);
52
+		add_action('give_single_form_summary', 'give_get_donation_form', 10);
53 53
 
54 54
 
55 55
 	}
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return string
66 66
 	 */
67
-	public function give_set_single_summary_classes( $classes ) {
67
+	public function give_set_single_summary_classes($classes) {
68 68
 
69
-		$sidebar_option = give_get_option( 'disable_form_sidebar' );
69
+		$sidebar_option = give_get_option('disable_form_sidebar');
70 70
 
71 71
 		//Add full width class when feature image is disabled AND no widgets are present
72
-		if ( $sidebar_option == 'on' ) {
72
+		if ($sidebar_option == 'on') {
73 73
 			$classes .= ' give-full-width';
74 74
 		}
75 75
 
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 */
88 88
 	public function give_output_sidebar_option() {
89
-		$sidebar_option = give_get_option( 'disable_form_sidebar' );
89
+		$sidebar_option = give_get_option('disable_form_sidebar');
90 90
 		//Add full width class when feature image is disabled AND no widgets are present
91
-		if ( $sidebar_option !== 'on' ) {
92
-			add_action( 'give_before_single_form_summary', 'give_left_sidebar_pre_wrap', 5 );
93
-			add_action( 'give_before_single_form_summary', 'give_show_form_images', 10 );
94
-			add_action( 'give_before_single_form_summary', 'give_get_forms_sidebar', 20 );
95
-			add_action( 'give_before_single_form_summary', 'give_left_sidebar_post_wrap', 30 );
91
+		if ($sidebar_option !== 'on') {
92
+			add_action('give_before_single_form_summary', 'give_left_sidebar_pre_wrap', 5);
93
+			add_action('give_before_single_form_summary', 'give_show_form_images', 10);
94
+			add_action('give_before_single_form_summary', 'give_get_forms_sidebar', 20);
95
+			add_action('give_before_single_form_summary', 'give_left_sidebar_post_wrap', 30);
96 96
 		}
97 97
 
98 98
 	}
@@ -114,22 +114,22 @@  discard block
 block discarded – undo
114 114
 	 *
115 115
 	 * @return string
116 116
 	 */
117
-	public static function template_loader( $template ) {
118
-		$find = array( 'give.php' );
117
+	public static function template_loader($template) {
118
+		$find = array('give.php');
119 119
 		$file = '';
120 120
 
121
-		if ( is_single() && get_post_type() == 'give_forms' ) {
121
+		if (is_single() && get_post_type() == 'give_forms') {
122 122
 
123 123
 			$file   = 'single-give-form.php';
124 124
 			$find[] = $file;
125
-			$find[] = apply_filters( 'give_template_path', 'give/' ) . $file;
125
+			$find[] = apply_filters('give_template_path', 'give/').$file;
126 126
 
127 127
 		}
128 128
 
129
-		if ( $file ) {
130
-			$template = locate_template( array_unique( $find ) );
131
-			if ( ! $template ) {
132
-				$template = GIVE_PLUGIN_DIR . '/templates/' . $file;
129
+		if ($file) {
130
+			$template = locate_template(array_unique($find));
131
+			if ( ! $template) {
132
+				$template = GIVE_PLUGIN_DIR.'/templates/'.$file;
133 133
 			}
134 134
 		}
135 135
 
Please login to merge, or discard this patch.
includes/gateways/functions.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -97,10 +97,10 @@
 block discarded – undo
97 97
 
98 98
 	//Single Form settings varies compared to the Global default settings
99 99
 	if ( ! empty( $form_default ) &&
100
-	     $form_id !== null &&
101
-	     $default !== $form_default &&
102
-	     $form_default !== 'global' &&
103
-	     give_is_gateway_active( $form_default )
100
+		 $form_id !== null &&
101
+		 $default !== $form_default &&
102
+		 $form_default !== 'global' &&
103
+		 give_is_gateway_active( $form_default )
104 104
 	) {
105 105
 		$default = $form_default;
106 106
 	}
Please login to merge, or discard this patch.
Spacing   +75 added lines, -75 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
 
@@ -24,17 +24,17 @@  discard block
 block discarded – undo
24 24
 	// Default, built-in gateways
25 25
 	$gateways = array(
26 26
 		'paypal' => array(
27
-			'admin_label'    => esc_html__( 'PayPal Standard', 'give' ),
28
-			'checkout_label' => esc_html__( 'PayPal', 'give' ),
29
-			'supports'       => array( 'buy_now' )
27
+			'admin_label'    => esc_html__('PayPal Standard', 'give'),
28
+			'checkout_label' => esc_html__('PayPal', 'give'),
29
+			'supports'       => array('buy_now')
30 30
 		),
31 31
 		'manual' => array(
32
-			'admin_label'    => esc_html__( 'Test Payment', 'give' ),
33
-			'checkout_label' => esc_html__( 'Test Payment', 'give' )
32
+			'admin_label'    => esc_html__('Test Payment', 'give'),
33
+			'checkout_label' => esc_html__('Test Payment', 'give')
34 34
 		),
35 35
 	);
36 36
 
37
-	return apply_filters( 'give_payment_gateways', $gateways );
37
+	return apply_filters('give_payment_gateways', $gateways);
38 38
 
39 39
 }
40 40
 
@@ -48,20 +48,20 @@  discard block
 block discarded – undo
48 48
 
49 49
 	$gateways = give_get_payment_gateways();
50 50
 
51
-	$enabled = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' );
51
+	$enabled = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways');
52 52
 
53 53
 	$gateway_list = array();
54 54
 
55
-	foreach ( $gateways as $key => $gateway ) {
56
-		if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) {
57
-			$gateway_list[ $key ] = $gateway;
55
+	foreach ($gateways as $key => $gateway) {
56
+		if (isset($enabled[$key]) && $enabled[$key] == 1) {
57
+			$gateway_list[$key] = $gateway;
58 58
 		}
59 59
 	}
60 60
 
61 61
 	// Set order of payment gateway in list.
62
-	$gateway_list = give_get_ordered_payment_gateways( $gateway_list );
62
+	$gateway_list = give_get_ordered_payment_gateways($gateway_list);
63 63
 
64
-	return apply_filters( 'give_enabled_payment_gateways', $gateway_list );
64
+	return apply_filters('give_enabled_payment_gateways', $gateway_list);
65 65
 }
66 66
 
67 67
 /**
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
  *
74 74
  * @return boolean true if enabled, false otherwise
75 75
  */
76
-function give_is_gateway_active( $gateway ) {
76
+function give_is_gateway_active($gateway) {
77 77
 	$gateways = give_get_enabled_payment_gateways();
78 78
 
79
-	$ret = array_key_exists( $gateway, $gateways );
79
+	$ret = array_key_exists($gateway, $gateways);
80 80
 
81
-	return apply_filters( 'give_is_gateway_active', $ret, $gateway, $gateways );
81
+	return apply_filters('give_is_gateway_active', $ret, $gateway, $gateways);
82 82
 }
83 83
 
84 84
 /**
@@ -91,24 +91,24 @@  discard block
 block discarded – undo
91 91
  *
92 92
  * @return string Gateway ID
93 93
  */
94
-function give_get_default_gateway( $form_id ) {
94
+function give_get_default_gateway($form_id) {
95 95
 
96 96
 	global $give_options;
97 97
 
98
-	$default      = isset( $give_options['default_gateway'] ) && give_is_gateway_active( $give_options['default_gateway'] ) ? $give_options['default_gateway'] : 'paypal';
99
-	$form_default = get_post_meta( $form_id, '_give_default_gateway', true );
98
+	$default      = isset($give_options['default_gateway']) && give_is_gateway_active($give_options['default_gateway']) ? $give_options['default_gateway'] : 'paypal';
99
+	$form_default = get_post_meta($form_id, '_give_default_gateway', true);
100 100
 
101 101
 	//Single Form settings varies compared to the Global default settings
102
-	if ( ! empty( $form_default ) &&
102
+	if ( ! empty($form_default) &&
103 103
 	     $form_id !== null &&
104 104
 	     $default !== $form_default &&
105 105
 	     $form_default !== 'global' &&
106
-	     give_is_gateway_active( $form_default )
106
+	     give_is_gateway_active($form_default)
107 107
 	) {
108 108
 		$default = $form_default;
109 109
 	}
110 110
 
111
-	return apply_filters( 'give_default_gateway', $default );
111
+	return apply_filters('give_default_gateway', $default);
112 112
 }
113 113
 
114 114
 /**
@@ -120,18 +120,18 @@  discard block
 block discarded – undo
120 120
  *
121 121
  * @return string Gateway admin label
122 122
  */
123
-function give_get_gateway_admin_label( $gateway ) {
123
+function give_get_gateway_admin_label($gateway) {
124 124
 	$gateways = give_get_enabled_payment_gateways();
125
-	$label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway;
126
-	$payment  = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false;
125
+	$label    = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway;
126
+	$payment  = isset($_GET['id']) ? absint($_GET['id']) : false;
127 127
 
128
-	if ( $gateway == 'manual' && $payment ) {
129
-		if ( give_get_payment_amount( $payment ) == 0 ) {
130
-			$label = esc_html__( 'Test Donation', 'give' );
128
+	if ($gateway == 'manual' && $payment) {
129
+		if (give_get_payment_amount($payment) == 0) {
130
+			$label = esc_html__('Test Donation', 'give');
131 131
 		}
132 132
 	}
133 133
 
134
-	return apply_filters( 'give_gateway_admin_label', $label, $gateway );
134
+	return apply_filters('give_gateway_admin_label', $label, $gateway);
135 135
 }
136 136
 
137 137
 /**
@@ -143,15 +143,15 @@  discard block
 block discarded – undo
143 143
  *
144 144
  * @return string Checkout label for the gateway
145 145
  */
146
-function give_get_gateway_checkout_label( $gateway ) {
146
+function give_get_gateway_checkout_label($gateway) {
147 147
 	$gateways = give_get_enabled_payment_gateways();
148
-	$label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway;
148
+	$label    = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway;
149 149
 
150
-	if ( $gateway == 'manual' ) {
151
-		$label = esc_html__( 'Test Donation', 'give' );
150
+	if ($gateway == 'manual') {
151
+		$label = esc_html__('Test Donation', 'give');
152 152
 	}
153 153
 
154
-	return apply_filters( 'give_gateway_checkout_label', $label, $gateway );
154
+	return apply_filters('give_gateway_checkout_label', $label, $gateway);
155 155
 }
156 156
 
157 157
 /**
@@ -163,11 +163,11 @@  discard block
 block discarded – undo
163 163
  *
164 164
  * @return array Options the gateway supports
165 165
  */
166
-function give_get_gateway_supports( $gateway ) {
166
+function give_get_gateway_supports($gateway) {
167 167
 	$gateways = give_get_enabled_payment_gateways();
168
-	$supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array();
168
+	$supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array();
169 169
 
170
-	return apply_filters( 'give_gateway_supports', $supports, $gateway );
170
+	return apply_filters('give_gateway_supports', $supports, $gateway);
171 171
 }
172 172
 
173 173
 /**
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
  *
180 180
  * @return bool
181 181
  */
182
-function give_gateway_supports_buy_now( $gateway ) {
183
-	$supports = give_get_gateway_supports( $gateway );
184
-	$ret      = in_array( 'buy_now', $supports );
182
+function give_gateway_supports_buy_now($gateway) {
183
+	$supports = give_get_gateway_supports($gateway);
184
+	$ret      = in_array('buy_now', $supports);
185 185
 
186
-	return apply_filters( 'give_gateway_supports_buy_now', $ret, $gateway );
186
+	return apply_filters('give_gateway_supports_buy_now', $ret, $gateway);
187 187
 }
188 188
 
189 189
 /**
@@ -196,16 +196,16 @@  discard block
 block discarded – undo
196 196
 	$gateways = give_get_enabled_payment_gateways();
197 197
 	$ret      = false;
198 198
 
199
-	if ( $gateways ) {
200
-		foreach ( $gateways as $gateway_id => $gateway ) {
201
-			if ( give_gateway_supports_buy_now( $gateway_id ) ) {
199
+	if ($gateways) {
200
+		foreach ($gateways as $gateway_id => $gateway) {
201
+			if (give_gateway_supports_buy_now($gateway_id)) {
202 202
 				$ret = true;
203 203
 				break;
204 204
 			}
205 205
 		}
206 206
 	}
207 207
 
208
-	return apply_filters( 'give_give_supports_buy_now', $ret );
208
+	return apply_filters('give_give_supports_buy_now', $ret);
209 209
 }
210 210
 
211 211
 /**
@@ -218,12 +218,12 @@  discard block
 block discarded – undo
218 218
  *
219 219
  * @return void
220 220
  */
221
-function give_send_to_gateway( $gateway, $payment_data ) {
221
+function give_send_to_gateway($gateway, $payment_data) {
222 222
 
223
-	$payment_data['gateway_nonce'] = wp_create_nonce( 'give-gateway' );
223
+	$payment_data['gateway_nonce'] = wp_create_nonce('give-gateway');
224 224
 
225 225
 	// $gateway must match the ID used when registering the gateway
226
-	do_action( 'give_gateway_' . $gateway, $payment_data );
226
+	do_action('give_gateway_'.$gateway, $payment_data);
227 227
 }
228 228
 
229 229
 
@@ -240,32 +240,32 @@  discard block
 block discarded – undo
240 240
  *
241 241
  * @return string $enabled_gateway The slug of the gateway
242 242
  */
243
-function give_get_chosen_gateway( $form_id ) {
243
+function give_get_chosen_gateway($form_id) {
244 244
 	$gateways        = give_get_enabled_payment_gateways();
245
-	$request_form_id = isset( $_REQUEST['give_form_id'] ) ? $_REQUEST['give_form_id'] : 0;
246
-	if ( empty( $request_form_id ) ) {
247
-		$request_form_id = isset( $_REQUEST['form-id'] ) ? $_REQUEST['form-id'] : 0;
245
+	$request_form_id = isset($_REQUEST['give_form_id']) ? $_REQUEST['give_form_id'] : 0;
246
+	if (empty($request_form_id)) {
247
+		$request_form_id = isset($_REQUEST['form-id']) ? $_REQUEST['form-id'] : 0;
248 248
 	}
249
-	$chosen          = give_get_default_gateway( $form_id );
249
+	$chosen          = give_get_default_gateway($form_id);
250 250
 	$enabled_gateway = '';
251 251
 
252 252
 	//Take into account request Form ID args
253
-	if ( ! empty( $request_form_id ) && $form_id == $request_form_id ) {
253
+	if ( ! empty($request_form_id) && $form_id == $request_form_id) {
254 254
 		$chosen = $_REQUEST['payment-mode'];
255 255
 	}
256 256
 
257
-	if ( $chosen ) {
258
-		$enabled_gateway = urldecode( $chosen );
259
-	} else if ( count( $gateways ) >= 1 && ! $chosen ) {
260
-		foreach ( $gateways as $gateway_id => $gateway ):
257
+	if ($chosen) {
258
+		$enabled_gateway = urldecode($chosen);
259
+	} else if (count($gateways) >= 1 && ! $chosen) {
260
+		foreach ($gateways as $gateway_id => $gateway):
261 261
 			$enabled_gateway = $gateway_id;
262 262
 		endforeach;
263 263
 	} else {
264
-		$enabled_gateway = give_get_default_gateway( $form_id );
264
+		$enabled_gateway = give_get_default_gateway($form_id);
265 265
 	}
266 266
 
267 267
 
268
-	return apply_filters( 'give_chosen_gateway', $enabled_gateway );
268
+	return apply_filters('give_chosen_gateway', $enabled_gateway);
269 269
 }
270 270
 
271 271
 /**
@@ -282,8 +282,8 @@  discard block
 block discarded – undo
282 282
  *
283 283
  * @return int ID of the new log entry
284 284
  */
285
-function give_record_gateway_error( $title = '', $message = '', $parent = 0 ) {
286
-	return give_record_log( $title, $message, $parent, 'gateway_error' );
285
+function give_record_gateway_error($title = '', $message = '', $parent = 0) {
286
+	return give_record_log($title, $message, $parent, 'gateway_error');
287 287
 }
288 288
 
289 289
 /**
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
  *
297 297
  * @return int
298 298
  */
299
-function give_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) {
299
+function give_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') {
300 300
 
301 301
 	$ret  = 0;
302 302
 	$args = array(
@@ -308,9 +308,9 @@  discard block
 block discarded – undo
308 308
 		'fields'      => 'ids'
309 309
 	);
310 310
 
311
-	$payments = new WP_Query( $args );
311
+	$payments = new WP_Query($args);
312 312
 
313
-	if ( $payments ) {
313
+	if ($payments) {
314 314
 		$ret = $payments->post_count;
315 315
 	}
316 316
 
@@ -327,27 +327,27 @@  discard block
 block discarded – undo
327 327
  *
328 328
  * @return array $gateways All the available gateways
329 329
  */
330
-function give_get_ordered_payment_gateways( $gateways ) {
330
+function give_get_ordered_payment_gateways($gateways) {
331 331
 
332 332
 	//  Get gateways setting.
333
-	$gateways_setting = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' );
333
+	$gateways_setting = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways');
334 334
 
335 335
 	// Return from here if we do not have gateways setting.
336
-	if ( empty( $gateways_setting ) ) {
336
+	if (empty($gateways_setting)) {
337 337
 		return $gateways;
338 338
 	}
339 339
 
340 340
 	// Reverse array to order payment gateways.
341
-	$gateways_setting = array_reverse( $gateways_setting );
341
+	$gateways_setting = array_reverse($gateways_setting);
342 342
 
343 343
 	// Reorder gateways array
344
-	foreach ( $gateways_setting as $gateway_key => $value ) {
344
+	foreach ($gateways_setting as $gateway_key => $value) {
345 345
 
346
-		$new_gateway_value = isset( $gateways[ $gateway_key ] ) ? $gateways[ $gateway_key ] : '';
347
-		unset( $gateways[ $gateway_key ] );
346
+		$new_gateway_value = isset($gateways[$gateway_key]) ? $gateways[$gateway_key] : '';
347
+		unset($gateways[$gateway_key]);
348 348
 
349
-		if(!empty($new_gateway_value)) {
350
-			$gateways = array_merge( array( $gateway_key => $new_gateway_value ), $gateways );
349
+		if ( ! empty($new_gateway_value)) {
350
+			$gateways = array_merge(array($gateway_key => $new_gateway_value), $gateways);
351 351
 		}
352 352
 	}
353 353
 
@@ -358,5 +358,5 @@  discard block
 block discarded – undo
358 358
 	 *
359 359
 	 * @param array $gateways All the available gateways
360 360
 	 */
361
-	return apply_filters( 'give_payment_gateways_order', $gateways );
361
+	return apply_filters('give_payment_gateways_order', $gateways);
362 362
 }
Please login to merge, or discard this patch.
includes/price-functions.php 1 patch
Spacing   +15 added lines, -15 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,13 +23,13 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return bool true if has variable prices, false otherwise
25 25
  */
26
-function give_has_variable_prices( $form_id = 0 ) {
26
+function give_has_variable_prices($form_id = 0) {
27 27
 
28
-	if ( empty( $form_id ) ) {
28
+	if (empty($form_id)) {
29 29
 		return false;
30 30
 	}
31 31
 
32
-	$form = new Give_Donate_Form( $form_id );
32
+	$form = new Give_Donate_Form($form_id);
33 33
 
34 34
 	return $form->has_variable_prices();
35 35
 }
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
  *
45 45
  * @return array Variable prices
46 46
  */
47
-function give_get_variable_prices( $form_id = 0 ) {
47
+function give_get_variable_prices($form_id = 0) {
48 48
 
49
-	if ( empty( $form_id ) ) {
49
+	if (empty($form_id)) {
50 50
 		return false;
51 51
 	}
52 52
 
53
-	$form = new Give_Donate_Form( $form_id );
53
+	$form = new Give_Donate_Form($form_id);
54 54
 
55 55
 	return $form->prices;
56 56
 
@@ -67,13 +67,13 @@  discard block
 block discarded – undo
67 67
  *
68 68
  * @return string $default_price
69 69
  */
70
-function give_get_default_multilevel_amount( $form_id ) {
70
+function give_get_default_multilevel_amount($form_id) {
71 71
 	$default_price = '1.00';
72
-	$prices        = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id );
72
+	$prices        = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id);
73 73
 
74
-	foreach ( $prices as $price ) {
74
+	foreach ($prices as $price) {
75 75
 
76
-		if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) {
76
+		if (isset($price['_give_default']) && $price['_give_default'] === 'default') {
77 77
 			$default_price = $price['_give_amount'];
78 78
 		}
79 79
 
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
  * @return string $default_price
95 95
  * @since      1.0
96 96
  */
97
-function give_get_default_form_amount( $form_id ) {
97
+function give_get_default_form_amount($form_id) {
98 98
 
99
-	if ( give_has_variable_prices( $form_id ) ) {
99
+	if (give_has_variable_prices($form_id)) {
100 100
 
101
-		$default_amount = give_get_default_multilevel_amount( $form_id );
101
+		$default_amount = give_get_default_multilevel_amount($form_id);
102 102
 
103 103
 	} else {
104 104
 
105
-		$default_amount = get_post_meta( $form_id, '_give_set_price', true );
105
+		$default_amount = get_post_meta($form_id, '_give_set_price', true);
106 106
 
107 107
 	}
108 108
 
Please login to merge, or discard this patch.
includes/shortcodes.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@
 block discarded – undo
79 79
 
80 80
 		//validate display_style and float_labels value
81 81
 		if ( ( $key == 'display_style' && ! in_array( $value, array( 'onpage', 'reveal', 'modal' ) ) )
82
-		     || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) )
82
+			 || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) )
83 83
 		) {
84 84
 
85 85
 			$atts[ $key ] = '';
Please login to merge, or discard this patch.
Spacing   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,28 +25,28 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_donation_history() {
27 27
 
28
-	$email_access = give_get_option( 'email_access' );
28
+	$email_access = give_get_option('email_access');
29 29
 
30 30
 	//Is user logged in? Does a session exist? Does an email-access token exist?
31
-	if ( is_user_logged_in() || Give()->session->get_session_expiration() !== false || ( $email_access == 'on' && Give()->email_access->token_exists ) ) {
31
+	if (is_user_logged_in() || Give()->session->get_session_expiration() !== false || ($email_access == 'on' && Give()->email_access->token_exists)) {
32 32
 		ob_start();
33
-		give_get_template_part( 'history', 'donations' );
33
+		give_get_template_part('history', 'donations');
34 34
 
35 35
 		return ob_get_clean();
36 36
 	} //Is Email-based access enabled?
37
-	elseif ( $email_access == 'on' ) {
37
+	elseif ($email_access == 'on') {
38 38
 
39 39
 		ob_start();
40
-		give_get_template_part( 'email', 'login-form' );
40
+		give_get_template_part('email', 'login-form');
41 41
 
42 42
 		return ob_get_clean();
43 43
 	} else {
44
-		$message = esc_html__( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' );
45
-		echo apply_filters( 'give_donation_history_nonuser_message', give_output_error( $message, false ), $message );
44
+		$message = esc_html__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give');
45
+		echo apply_filters('give_donation_history_nonuser_message', give_output_error($message, false), $message);
46 46
 	}
47 47
 }
48 48
 
49
-add_shortcode( 'donation_history', 'give_donation_history' );
49
+add_shortcode('donation_history', 'give_donation_history');
50 50
 
51 51
 /**
52 52
  * Donation Form Shortcode
@@ -60,53 +60,53 @@  discard block
 block discarded – undo
60 60
  *
61 61
  * @return string
62 62
  */
63
-function give_form_shortcode( $atts, $content = null ) {
64
-	$atts = shortcode_atts( array(
63
+function give_form_shortcode($atts, $content = null) {
64
+	$atts = shortcode_atts(array(
65 65
 		'id'            => '',
66 66
 		'show_title'    => true,
67 67
 		'show_goal'     => true,
68 68
 		'show_content'  => '',
69 69
 		'float_labels'  => '',
70 70
 		'display_style' => '',
71
-	), $atts, 'give_form' );
71
+	), $atts, 'give_form');
72 72
 
73
-	foreach ( $atts as $key => $value ) {
73
+	foreach ($atts as $key => $value) {
74 74
 		//convert shortcode_atts values to booleans
75
-		if ( $key == 'show_title' ) {
76
-			$atts[ $key ] = filter_var( $atts[ $key ], FILTER_VALIDATE_BOOLEAN );
77
-		} elseif ( $key == 'show_goal' ) {
78
-			$atts[ $key ] = filter_var( $atts[ $key ], FILTER_VALIDATE_BOOLEAN );
75
+		if ($key == 'show_title') {
76
+			$atts[$key] = filter_var($atts[$key], FILTER_VALIDATE_BOOLEAN);
77
+		} elseif ($key == 'show_goal') {
78
+			$atts[$key] = filter_var($atts[$key], FILTER_VALIDATE_BOOLEAN);
79 79
 		}
80 80
 
81 81
 		//validate show_content value
82
-		if ( $key == 'show_content' ) {
83
-			if ( ! in_array( $value, array( 'none', 'above', 'below' ) ) ) {
84
-				$atts[ $key ] = '';
85
-			} else if ( $value == 'above' ) {
86
-				$atts[ $key ] = 'give_pre_form';
87
-			} else if ( $value == 'below' ) {
88
-				$atts[ $key ] = 'give_post_form';
82
+		if ($key == 'show_content') {
83
+			if ( ! in_array($value, array('none', 'above', 'below'))) {
84
+				$atts[$key] = '';
85
+			} else if ($value == 'above') {
86
+				$atts[$key] = 'give_pre_form';
87
+			} else if ($value == 'below') {
88
+				$atts[$key] = 'give_post_form';
89 89
 			}
90 90
 		}
91 91
 
92 92
 		//validate display_style and float_labels value
93
-		if ( ( $key == 'display_style' && ! in_array( $value, array( 'onpage', 'reveal', 'modal' ) ) )
94
-		     || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) )
93
+		if (($key == 'display_style' && ! in_array($value, array('onpage', 'reveal', 'modal')))
94
+		     || ($key == 'float_labels' && ! in_array($value, array('enabled', 'disabled')))
95 95
 		) {
96 96
 
97
-			$atts[ $key ] = '';
97
+			$atts[$key] = '';
98 98
 		}
99 99
 	}
100 100
 
101 101
 	//get the Give Form
102 102
 	ob_start();
103
-	give_get_donation_form( $atts );
103
+	give_get_donation_form($atts);
104 104
 	$final_output = ob_get_clean();
105 105
 
106
-	return apply_filters( 'give_donate_form', $final_output, $atts );
106
+	return apply_filters('give_donate_form', $final_output, $atts);
107 107
 }
108 108
 
109
-add_shortcode( 'give_form', 'give_form_shortcode' );
109
+add_shortcode('give_form', 'give_form_shortcode');
110 110
 
111 111
 /**
112 112
  * Donation Form Goal Shortcode
@@ -120,37 +120,37 @@  discard block
 block discarded – undo
120 120
  *
121 121
  * @return string
122 122
  */
123
-function give_goal_shortcode( $atts, $content = null ) {
124
-	$atts = shortcode_atts( array(
123
+function give_goal_shortcode($atts, $content = null) {
124
+	$atts = shortcode_atts(array(
125 125
 		'id'        => '',
126 126
 		'show_text' => true,
127 127
 		'show_bar'  => true,
128
-	), $atts, 'give_goal' );
128
+	), $atts, 'give_goal');
129 129
 
130 130
 
131 131
 	//get the Give Form
132 132
 	ob_start();
133 133
 
134 134
 	//Sanity check 1: ensure there is an ID Provided
135
-	if ( empty( $atts['id'] ) ) {
136
-		give_output_error( esc_html__( 'Error: No Donation form ID for the shortcode provided.', 'give' ), true );
135
+	if (empty($atts['id'])) {
136
+		give_output_error(esc_html__('Error: No Donation form ID for the shortcode provided.', 'give'), true);
137 137
 	}
138 138
 
139 139
 	//Sanity check 2: Check that this form even has Goals enabled
140
-	$goal_option = get_post_meta( $atts['id'], '_give_goal_option', true );
141
-	if ( empty( $goal_option ) || $goal_option !== 'yes' ) {
142
-		give_output_error( esc_html__( 'Error: This form does not have Goals enabled.', 'give' ), true );
140
+	$goal_option = get_post_meta($atts['id'], '_give_goal_option', true);
141
+	if (empty($goal_option) || $goal_option !== 'yes') {
142
+		give_output_error(esc_html__('Error: This form does not have Goals enabled.', 'give'), true);
143 143
 	} else {
144 144
 		//Passed all sanity checks: output Goal
145
-		give_show_goal_progress( $atts['id'], $atts );
145
+		give_show_goal_progress($atts['id'], $atts);
146 146
 	}
147 147
 
148 148
 	$final_output = ob_get_clean();
149 149
 
150
-	return apply_filters( 'give_goal_shortcode_output', $final_output, $atts );
150
+	return apply_filters('give_goal_shortcode_output', $final_output, $atts);
151 151
 }
152 152
 
153
-add_shortcode( 'give_goal', 'give_goal_shortcode' );
153
+add_shortcode('give_goal', 'give_goal_shortcode');
154 154
 
155 155
 
156 156
 /**
@@ -167,15 +167,15 @@  discard block
 block discarded – undo
167 167
  * @uses  give_login_form()
168 168
  * @return string
169 169
  */
170
-function give_login_form_shortcode( $atts, $content = null ) {
171
-	$atts = shortcode_atts( array(
170
+function give_login_form_shortcode($atts, $content = null) {
171
+	$atts = shortcode_atts(array(
172 172
 		'redirect' => '',
173
-	), $atts, 'give_login' );
173
+	), $atts, 'give_login');
174 174
 
175
-	return give_login_form( $atts['redirect'] );
175
+	return give_login_form($atts['redirect']);
176 176
 }
177 177
 
178
-add_shortcode( 'give_login', 'give_login_form_shortcode' );
178
+add_shortcode('give_login', 'give_login_form_shortcode');
179 179
 
180 180
 /**
181 181
  * Register Shortcode
@@ -190,15 +190,15 @@  discard block
 block discarded – undo
190 190
  * @uses  give_register_form()
191 191
  * @return string
192 192
  */
193
-function give_register_form_shortcode( $atts, $content = null ) {
194
-	$atts = shortcode_atts( array(
193
+function give_register_form_shortcode($atts, $content = null) {
194
+	$atts = shortcode_atts(array(
195 195
 		'redirect' => '',
196
-	), $atts, 'give_register' );
196
+	), $atts, 'give_register');
197 197
 
198
-	return give_register_form( $atts['redirect'] );
198
+	return give_register_form($atts['redirect']);
199 199
 }
200 200
 
201
-add_shortcode( 'give_register', 'give_register_form_shortcode' );
201
+add_shortcode('give_register', 'give_register_form_shortcode');
202 202
 
203 203
 
204 204
 /**
@@ -213,62 +213,62 @@  discard block
 block discarded – undo
213 213
  *
214 214
  * @return string
215 215
  */
216
-function give_receipt_shortcode( $atts, $content = null ) {
216
+function give_receipt_shortcode($atts, $content = null) {
217 217
 
218 218
 	global $give_receipt_args, $payment;
219 219
 
220
-	$give_receipt_args = shortcode_atts( array(
221
-		'error'          => esc_html__( 'Sorry, you are missing the payment key to view this donation receipt.', 'give' ),
220
+	$give_receipt_args = shortcode_atts(array(
221
+		'error'          => esc_html__('Sorry, you are missing the payment key to view this donation receipt.', 'give'),
222 222
 		'price'          => true,
223 223
 		'donor'          => true,
224 224
 		'date'           => true,
225 225
 		'payment_key'    => false,
226 226
 		'payment_method' => true,
227 227
 		'payment_id'     => true
228
-	), $atts, 'give_receipt' );
228
+	), $atts, 'give_receipt');
229 229
 
230 230
 	//set $session var
231 231
 	$session = give_get_purchase_session();
232 232
 
233 233
 	//set payment key var
234
-	if ( isset( $_GET['payment_key'] ) ) {
235
-		$payment_key = urldecode( $_GET['payment_key'] );
236
-	} elseif ( $session ) {
234
+	if (isset($_GET['payment_key'])) {
235
+		$payment_key = urldecode($_GET['payment_key']);
236
+	} elseif ($session) {
237 237
 		$payment_key = $session['purchase_key'];
238
-	} elseif ( $give_receipt_args['payment_key'] ) {
238
+	} elseif ($give_receipt_args['payment_key']) {
239 239
 		$payment_key = $give_receipt_args['payment_key'];
240 240
 	}
241 241
 
242
-	$email_access = give_get_option( 'email_access' );
242
+	$email_access = give_get_option('email_access');
243 243
 
244 244
 	// No payment_key found & Email Access is Turned on:
245
-	if ( ! isset( $payment_key ) && $email_access == 'on' && ! Give()->email_access->token_exists ) {
245
+	if ( ! isset($payment_key) && $email_access == 'on' && ! Give()->email_access->token_exists) {
246 246
 
247 247
 		ob_start();
248 248
 
249
-		give_get_template_part( 'email-login-form' );
249
+		give_get_template_part('email-login-form');
250 250
 
251 251
 		return ob_get_clean();
252 252
 
253
-	} elseif ( ! isset( $payment_key ) ) {
253
+	} elseif ( ! isset($payment_key)) {
254 254
 
255
-		return give_output_error( $give_receipt_args['error'], false, 'error' );
255
+		return give_output_error($give_receipt_args['error'], false, 'error');
256 256
 
257 257
 	}
258 258
 
259
-	$payment_id    = give_get_purchase_id_by_key( $payment_key );
260
-	$user_can_view = give_can_view_receipt( $payment_key );
259
+	$payment_id    = give_get_purchase_id_by_key($payment_key);
260
+	$user_can_view = give_can_view_receipt($payment_key);
261 261
 
262 262
 	// Key was provided, but user is logged out. Offer them the ability to login and view the receipt
263
-	if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists ) {
263
+	if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists) {
264 264
 
265 265
 		ob_start();
266 266
 
267
-		give_get_template_part( 'email-login-form' );
267
+		give_get_template_part('email-login-form');
268 268
 
269 269
 		return ob_get_clean();
270 270
 
271
-	} elseif ( ! $user_can_view ) {
271
+	} elseif ( ! $user_can_view) {
272 272
 
273 273
 		global $give_login_redirect;
274 274
 
@@ -276,9 +276,9 @@  discard block
 block discarded – undo
276 276
 
277 277
 		ob_start();
278 278
 
279
-		give_output_error( apply_filters( 'give_must_be_logged_in_error_message', esc_html__( 'You must be logged in to view this donation payment receipt.', 'give' ) ) );
279
+		give_output_error(apply_filters('give_must_be_logged_in_error_message', esc_html__('You must be logged in to view this donation payment receipt.', 'give')));
280 280
 
281
-		give_get_template_part( 'shortcode', 'login' );
281
+		give_get_template_part('shortcode', 'login');
282 282
 
283 283
 		$login_form = ob_get_clean();
284 284
 
@@ -295,13 +295,13 @@  discard block
 block discarded – undo
295 295
 	 * Or if user is logged in and the user can view sensitive shop data
296 296
 	 *
297 297
 	 */
298
-	if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) {
299
-		return give_output_error( $give_receipt_args['error'], false, 'error' );
298
+	if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) {
299
+		return give_output_error($give_receipt_args['error'], false, 'error');
300 300
 	}
301 301
 
302 302
 	ob_start();
303 303
 
304
-	give_get_template_part( 'shortcode', 'receipt' );
304
+	give_get_template_part('shortcode', 'receipt');
305 305
 
306 306
 	$display = ob_get_clean();
307 307
 
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 
311 311
 }
312 312
 
313
-add_shortcode( 'give_receipt', 'give_receipt_shortcode' );
313
+add_shortcode('give_receipt', 'give_receipt_shortcode');
314 314
 
315 315
 /**
316 316
  * Profile Editor Shortcode
@@ -330,18 +330,18 @@  discard block
 block discarded – undo
330 330
  *
331 331
  * @return string Output generated from the profile editor
332 332
  */
333
-function give_profile_editor_shortcode( $atts, $content = null ) {
333
+function give_profile_editor_shortcode($atts, $content = null) {
334 334
 
335 335
 	ob_start();
336 336
 
337
-	give_get_template_part( 'shortcode', 'profile-editor' );
337
+	give_get_template_part('shortcode', 'profile-editor');
338 338
 
339 339
 	$display = ob_get_clean();
340 340
 
341 341
 	return $display;
342 342
 }
343 343
 
344
-add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' );
344
+add_shortcode('give_profile_editor', 'give_profile_editor_shortcode');
345 345
 
346 346
 /**
347 347
  * Process Profile Updater Form
@@ -354,30 +354,30 @@  discard block
 block discarded – undo
354 354
  *
355 355
  * @return false
356 356
  */
357
-function give_process_profile_editor_updates( $data ) {
357
+function give_process_profile_editor_updates($data) {
358 358
 	// Profile field change request
359
-	if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) {
359
+	if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) {
360 360
 		return false;
361 361
 	}
362 362
 
363 363
 	// Nonce security
364
-	if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) {
364
+	if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) {
365 365
 		return false;
366 366
 	}
367 367
 
368 368
 	$user_id       = get_current_user_id();
369
-	$old_user_data = get_userdata( $user_id );
370
-
371
-	$display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name;
372
-	$first_name   = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name;
373
-	$last_name    = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name;
374
-	$email        = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email;
375
-	$line1        = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' );
376
-	$line2        = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' );
377
-	$city         = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' );
378
-	$state        = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' );
379
-	$zip          = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' );
380
-	$country      = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' );
369
+	$old_user_data = get_userdata($user_id);
370
+
371
+	$display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name;
372
+	$first_name   = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name;
373
+	$last_name    = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name;
374
+	$email        = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email;
375
+	$line1        = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : '');
376
+	$line2        = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : '');
377
+	$city         = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : '');
378
+	$state        = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : '');
379
+	$zip          = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : '');
380
+	$country      = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : '');
381 381
 
382 382
 	$userdata = array(
383 383
 		'ID'           => $user_id,
@@ -397,45 +397,45 @@  discard block
 block discarded – undo
397 397
 		'country' => $country
398 398
 	);
399 399
 
400
-	do_action( 'give_pre_update_user_profile', $user_id, $userdata );
400
+	do_action('give_pre_update_user_profile', $user_id, $userdata);
401 401
 
402 402
 	// New password
403
-	if ( ! empty( $data['give_new_user_pass1'] ) ) {
404
-		if ( $data['give_new_user_pass1'] !== $data['give_new_user_pass2'] ) {
405
-			give_set_error( 'password_mismatch', esc_html__( 'The passwords you entered do not match. Please try again.', 'give' ) );
403
+	if ( ! empty($data['give_new_user_pass1'])) {
404
+		if ($data['give_new_user_pass1'] !== $data['give_new_user_pass2']) {
405
+			give_set_error('password_mismatch', esc_html__('The passwords you entered do not match. Please try again.', 'give'));
406 406
 		} else {
407 407
 			$userdata['user_pass'] = $data['give_new_user_pass1'];
408 408
 		}
409 409
 	}
410 410
 
411 411
 	// Make sure the new email doesn't belong to another user
412
-	if ( $email != $old_user_data->user_email ) {
413
-		if ( email_exists( $email ) ) {
414
-			give_set_error( 'email_exists', esc_html__( 'The email you entered belongs to another user. Please use another.', 'give' ) );
412
+	if ($email != $old_user_data->user_email) {
413
+		if (email_exists($email)) {
414
+			give_set_error('email_exists', esc_html__('The email you entered belongs to another user. Please use another.', 'give'));
415 415
 		}
416 416
 	}
417 417
 
418 418
 	// Check for errors
419 419
 	$errors = give_get_errors();
420 420
 
421
-	if ( $errors ) {
421
+	if ($errors) {
422 422
 		// Send back to the profile editor if there are errors
423
-		wp_redirect( $data['give_redirect'] );
423
+		wp_redirect($data['give_redirect']);
424 424
 		give_die();
425 425
 	}
426 426
 
427 427
 	// Update the user
428
-	$meta    = update_user_meta( $user_id, '_give_user_address', $address );
429
-	$updated = wp_update_user( $userdata );
428
+	$meta    = update_user_meta($user_id, '_give_user_address', $address);
429
+	$updated = wp_update_user($userdata);
430 430
 
431
-	if ( $updated ) {
432
-		do_action( 'give_user_profile_updated', $user_id, $userdata );
433
-		wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) );
431
+	if ($updated) {
432
+		do_action('give_user_profile_updated', $user_id, $userdata);
433
+		wp_redirect(add_query_arg('updated', 'true', $data['give_redirect']));
434 434
 		give_die();
435 435
 	}
436 436
 
437 437
 	return false;
438 438
 }
439 439
 
440
-add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' );
440
+add_action('give_edit_user_profile', 'give_process_profile_editor_updates');
441 441
 
Please login to merge, or discard this patch.
uninstall.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -10,83 +10,83 @@
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
13
+if ( ! defined('WP_UNINSTALL_PLUGIN')) {
14 14
 	exit;
15 15
 }
16 16
 
17 17
 // Load Give file
18
-include_once( 'give.php' );
18
+include_once('give.php');
19 19
 
20 20
 global $wpdb, $wp_roles;
21 21
 
22 22
 
23
-if ( give_get_option( 'uninstall_on_delete' ) === 'on' ) {
23
+if (give_get_option('uninstall_on_delete') === 'on') {
24 24
 
25 25
 	// Delete All the Custom Post Types
26
-	$give_taxonomies = array( 'form_category', 'form_tag', 'give_log_type', );
27
-	$give_post_types = array( 'give_forms', 'give_payment', 'give_log' );
28
-	foreach ( $give_post_types as $post_type ) {
26
+	$give_taxonomies = array('form_category', 'form_tag', 'give_log_type',);
27
+	$give_post_types = array('give_forms', 'give_payment', 'give_log');
28
+	foreach ($give_post_types as $post_type) {
29 29
 
30
-		$give_taxonomies = array_merge( $give_taxonomies, get_object_taxonomies( $post_type ) );
31
-		$items           = get_posts( array(
30
+		$give_taxonomies = array_merge($give_taxonomies, get_object_taxonomies($post_type));
31
+		$items           = get_posts(array(
32 32
 			'post_type'   => $post_type,
33 33
 			'post_status' => 'any',
34
-			'numberposts' => - 1,
34
+			'numberposts' => -1,
35 35
 			'fields'      => 'ids'
36
-		) );
36
+		));
37 37
 
38
-		if ( $items ) {
39
-			foreach ( $items as $item ) {
40
-				wp_delete_post( $item, true );
38
+		if ($items) {
39
+			foreach ($items as $item) {
40
+				wp_delete_post($item, true);
41 41
 			}
42 42
 		}
43 43
 	}
44 44
 
45 45
 	// Delete All the Terms & Taxonomies
46
-	foreach ( array_unique( array_filter( $give_taxonomies ) ) as $taxonomy ) {
46
+	foreach (array_unique(array_filter($give_taxonomies)) as $taxonomy) {
47 47
 
48
-		$terms = $wpdb->get_results( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy ) );
48
+		$terms = $wpdb->get_results($wpdb->prepare("SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy));
49 49
 
50 50
 		// Delete Terms
51
-		if ( $terms ) {
52
-			foreach ( $terms as $term ) {
53
-				$wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $term->term_taxonomy_id ) );
54
-				$wpdb->delete( $wpdb->terms, array( 'term_id' => $term->term_id ) );
51
+		if ($terms) {
52
+			foreach ($terms as $term) {
53
+				$wpdb->delete($wpdb->term_taxonomy, array('term_taxonomy_id' => $term->term_taxonomy_id));
54
+				$wpdb->delete($wpdb->terms, array('term_id' => $term->term_id));
55 55
 			}
56 56
 		}
57 57
 
58 58
 		// Delete Taxonomies
59
-		$wpdb->delete( $wpdb->term_taxonomy, array( 'taxonomy' => $taxonomy ), array( '%s' ) );
59
+		$wpdb->delete($wpdb->term_taxonomy, array('taxonomy' => $taxonomy), array('%s'));
60 60
 	}
61 61
 
62 62
 	// Delete the Plugin Pages
63
-	$give_created_pages = array( 'success_page', 'failure_page', 'history_page' );
64
-	foreach ( $give_created_pages as $p ) {
65
-		$page = give_get_option( $p, false );
66
-		if ( $page ) {
67
-			wp_delete_post( $page, true );
63
+	$give_created_pages = array('success_page', 'failure_page', 'history_page');
64
+	foreach ($give_created_pages as $p) {
65
+		$page = give_get_option($p, false);
66
+		if ($page) {
67
+			wp_delete_post($page, true);
68 68
 		}
69 69
 	}
70 70
 
71 71
 	// Delete all the Plugin Options
72
-	delete_option( 'give_settings' );
73
-	delete_option( 'give_version' );
72
+	delete_option('give_settings');
73
+	delete_option('give_version');
74 74
 
75 75
 	// Delete Capabilities
76 76
 	Give()->roles->remove_caps();
77 77
 
78 78
 	// Delete the Roles
79
-	$give_roles = array( 'give_manager', 'give_accountant', 'give_worker' );
80
-	foreach ( $give_roles as $role ) {
81
-		remove_role( $role );
79
+	$give_roles = array('give_manager', 'give_accountant', 'give_worker');
80
+	foreach ($give_roles as $role) {
81
+		remove_role($role);
82 82
 	}
83 83
 
84 84
 	// Remove all database tables
85
-	$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "give_donors" );
86
-	$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "give_customers" );
85
+	$wpdb->query("DROP TABLE IF EXISTS ".$wpdb->prefix."give_donors");
86
+	$wpdb->query("DROP TABLE IF EXISTS ".$wpdb->prefix."give_customers");
87 87
 
88 88
 	// Cleanup Cron Events
89
-	wp_clear_scheduled_hook( 'give_daily_scheduled_events' );
90
-	wp_clear_scheduled_hook( 'give_daily_cron' );
91
-	wp_clear_scheduled_hook( 'give_weekly_cron' );
89
+	wp_clear_scheduled_hook('give_daily_scheduled_events');
90
+	wp_clear_scheduled_hook('give_daily_cron');
91
+	wp_clear_scheduled_hook('give_weekly_cron');
92 92
 }
Please login to merge, or discard this patch.
includes/formatting.php 3 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -142,8 +142,10 @@
 block discarded – undo
142 142
 
143 143
 	if ( is_front_page() ) :
144 144
 		$page_url = home_url();
145
-	else :
145
+	else {
146
+		:
146 147
 		$page_url = 'http';
148
+	}
147 149
 
148 150
 		if ( isset( $_SERVER["HTTPS"] ) && $_SERVER["HTTPS"] == "on" ) {
149 151
 			$page_url .= "s";
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@
 block discarded – undo
119 119
  * @param $field_args
120 120
  * @param $field
121 121
  *
122
- * @return bool
122
+ * @return false|null
123 123
  */
124 124
 function give_format_admin_multilevel_amount( $field_args, $field ) {
125 125
 
Please login to merge, or discard this patch.
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,37 +25,37 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * @return string $amount Newly sanitized amount
27 27
  */
28
-function give_sanitize_amount( $amount ) {
28
+function give_sanitize_amount($amount) {
29 29
 	$is_negative   = false;
30
-	$thousands_sep = give_get_option( 'thousands_separator', ',' );
31
-	$decimal_sep   = give_get_option( 'decimal_separator', '.' );
30
+	$thousands_sep = give_get_option('thousands_separator', ',');
31
+	$decimal_sep   = give_get_option('decimal_separator', '.');
32 32
 
33 33
 	// Sanitize the amount
34
-	if ( $decimal_sep == ',' && false !== ( $found = strpos( $amount, $decimal_sep ) ) ) {
35
-		if ( ( $thousands_sep == '.' || $thousands_sep == ' ' ) && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
36
-			$amount = str_replace( $thousands_sep, '', $amount );
37
-		} elseif ( empty( $thousands_sep ) && false !== ( $found = strpos( $amount, '.' ) ) ) {
38
-			$amount = str_replace( '.', '', $amount );
34
+	if ($decimal_sep == ',' && false !== ($found = strpos($amount, $decimal_sep))) {
35
+		if (($thousands_sep == '.' || $thousands_sep == ' ') && false !== ($found = strpos($amount, $thousands_sep))) {
36
+			$amount = str_replace($thousands_sep, '', $amount);
37
+		} elseif (empty($thousands_sep) && false !== ($found = strpos($amount, '.'))) {
38
+			$amount = str_replace('.', '', $amount);
39 39
 		}
40 40
 
41
-		$amount = str_replace( $decimal_sep, '.', $amount );
42
-	} elseif ( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
43
-		$amount = str_replace( $thousands_sep, '', $amount );
41
+		$amount = str_replace($decimal_sep, '.', $amount);
42
+	} elseif ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) {
43
+		$amount = str_replace($thousands_sep, '', $amount);
44 44
 	}
45 45
 
46
-	if ( $amount < 0 ) {
46
+	if ($amount < 0) {
47 47
 		$is_negative = true;
48 48
 	}
49 49
 
50
-	$amount   = preg_replace( '/[^0-9\.]/', '', $amount );
51
-	$decimals = apply_filters( 'give_sanitize_amount_decimals', 2, $amount );
52
-	$amount   = number_format( (double) $amount, $decimals, '.', '' );
50
+	$amount   = preg_replace('/[^0-9\.]/', '', $amount);
51
+	$decimals = apply_filters('give_sanitize_amount_decimals', 2, $amount);
52
+	$amount   = number_format((double) $amount, $decimals, '.', '');
53 53
 
54
-	if ( $is_negative ) {
54
+	if ($is_negative) {
55 55
 		$amount *= - 1;
56 56
 	}
57 57
 
58
-	return apply_filters( 'give_sanitize_amount', $amount );
58
+	return apply_filters('give_sanitize_amount', $amount);
59 59
 }
60 60
 
61 61
 /**
@@ -68,47 +68,47 @@  discard block
 block discarded – undo
68 68
  *
69 69
  * @return string $amount Newly formatted amount or Price Not Available
70 70
  */
71
-function give_format_amount( $amount, $decimals = true ) {
71
+function give_format_amount($amount, $decimals = true) {
72 72
 
73
-	$thousands_sep = give_get_option( 'thousands_separator', ',' );
74
-	$decimal_sep   = give_get_option( 'decimal_separator', '.' );
73
+	$thousands_sep = give_get_option('thousands_separator', ',');
74
+	$decimal_sep   = give_get_option('decimal_separator', '.');
75 75
 
76 76
 	// Format the amount
77
-	if ( $decimal_sep == ',' && false !== ( $sep_found = strpos( $amount, $decimal_sep ) ) ) {
78
-		$whole  = substr( $amount, 0, $sep_found );
79
-		$part   = substr( $amount, $sep_found + 1, ( strlen( $amount ) - 1 ) );
80
-		$amount = $whole . '.' . $part;
77
+	if ($decimal_sep == ',' && false !== ($sep_found = strpos($amount, $decimal_sep))) {
78
+		$whole  = substr($amount, 0, $sep_found);
79
+		$part   = substr($amount, $sep_found + 1, (strlen($amount) - 1));
80
+		$amount = $whole.'.'.$part;
81 81
 	}
82 82
 
83 83
 	// Strip , from the amount (if set as the thousands separator)
84
-	if ( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
85
-		$amount = str_replace( ',', '', $amount );
84
+	if ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) {
85
+		$amount = str_replace(',', '', $amount);
86 86
 	}
87 87
 
88 88
 	// Strip . from the amount (if set as the thousands separator) AND , set to decimal separator
89
-	if ( $thousands_sep == '.' && $decimal_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
90
-		$amount      = explode( '.', $amount );
91
-		$array_count = count( $amount );
92
-		if ( $decimals == true ) {
93
-			unset( $amount[ $array_count - 1 ] );
89
+	if ($thousands_sep == '.' && $decimal_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) {
90
+		$amount      = explode('.', $amount);
91
+		$array_count = count($amount);
92
+		if ($decimals == true) {
93
+			unset($amount[$array_count - 1]);
94 94
 		}
95
-		$amount = implode( '', $amount );
95
+		$amount = implode('', $amount);
96 96
 	}
97 97
 
98 98
 	// Strip ' ' from the amount (if set as the thousands separator)
99
-	if ( $thousands_sep == ' ' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
100
-		$amount = str_replace( ' ', '', $amount );
99
+	if ($thousands_sep == ' ' && false !== ($found = strpos($amount, $thousands_sep))) {
100
+		$amount = str_replace(' ', '', $amount);
101 101
 	}
102 102
 
103
-	if ( empty( $amount ) ) {
103
+	if (empty($amount)) {
104 104
 		$amount = 0;
105 105
 	}
106 106
 
107
-	$decimals = apply_filters( 'give_format_amount_decimals', $decimals ? 2 : 0, $amount );
107
+	$decimals = apply_filters('give_format_amount_decimals', $decimals ? 2 : 0, $amount);
108 108
 
109
-	$formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep );
109
+	$formatted = number_format($amount, $decimals, $decimal_sep, $thousands_sep);
110 110
 
111
-	return apply_filters( 'give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep );
111
+	return apply_filters('give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep);
112 112
 }
113 113
 
114 114
 /**
@@ -121,13 +121,13 @@  discard block
 block discarded – undo
121 121
  *
122 122
  * @return bool
123 123
  */
124
-function give_format_admin_multilevel_amount( $field_args, $field ) {
124
+function give_format_admin_multilevel_amount($field_args, $field) {
125 125
 
126
-	if ( empty( $field->value ) ) {
126
+	if (empty($field->value)) {
127 127
 		return false;
128 128
 	}
129 129
 
130
-	$field->value = give_format_amount( $field->value );
130
+	$field->value = give_format_amount($field->value);
131 131
 
132 132
 }
133 133
 
@@ -141,24 +141,24 @@  discard block
 block discarded – undo
141 141
  *
142 142
  * @return mixed|string|void
143 143
  */
144
-function give_currency_filter( $price = '', $currency = '' ) {
144
+function give_currency_filter($price = '', $currency = '') {
145 145
 
146
-	if ( empty( $currency ) ) {
146
+	if (empty($currency)) {
147 147
 		$currency = give_get_currency();
148 148
 	}
149 149
 
150
-	$position = give_get_option( 'currency_position', 'before' );
150
+	$position = give_get_option('currency_position', 'before');
151 151
 
152 152
 	$negative = $price < 0;
153 153
 
154
-	if ( $negative ) {
155
-		$price = substr( $price, 1 ); // Remove proceeding "-" -
154
+	if ($negative) {
155
+		$price = substr($price, 1); // Remove proceeding "-" -
156 156
 	}
157 157
 
158
-	$symbol = give_currency_symbol( $currency );
158
+	$symbol = give_currency_symbol($currency);
159 159
 
160
-	if ( $position == 'before' ):
161
-		switch ( $currency ):
160
+	if ($position == 'before'):
161
+		switch ($currency):
162 162
 			case 'GBP' :
163 163
 			case 'BRL' :
164 164
 			case 'EUR' :
@@ -184,18 +184,18 @@  discard block
 block discarded – undo
184 184
 			case 'DKK' :
185 185
 			case 'HUF' :
186 186
 			case 'ILS' :
187
-				$formatted = $symbol . $price;
187
+				$formatted = $symbol.$price;
188 188
 				break;
189 189
 			case 'NOK' :
190
-				$formatted = $symbol . ' ' . $price;
190
+				$formatted = $symbol.' '.$price;
191 191
 				break;
192 192
 			default :
193
-				$formatted = $currency . ' ' . $price;
193
+				$formatted = $currency.' '.$price;
194 194
 				break;
195 195
 		endswitch;
196
-		$formatted = apply_filters( 'give_' . strtolower( $currency ) . '_currency_filter_before', $formatted, $currency, $price );
196
+		$formatted = apply_filters('give_'.strtolower($currency).'_currency_filter_before', $formatted, $currency, $price);
197 197
 	else :
198
-		switch ( $currency ) :
198
+		switch ($currency) :
199 199
 			case 'GBP' :
200 200
 			case 'BRL' :
201 201
 			case 'EUR' :
@@ -220,18 +220,18 @@  discard block
 block discarded – undo
220 220
 			case 'HUF' :
221 221
 			case 'MYR' :
222 222
 			case 'ILS' :
223
-				$formatted = $price . $symbol;
223
+				$formatted = $price.$symbol;
224 224
 				break;
225 225
 			default :
226
-				$formatted = $price . ' ' . $currency;
226
+				$formatted = $price.' '.$currency;
227 227
 				break;
228 228
 		endswitch;
229
-		$formatted = apply_filters( 'give_' . strtolower( $currency ) . '_currency_filter_after', $formatted, $currency, $price );
229
+		$formatted = apply_filters('give_'.strtolower($currency).'_currency_filter_after', $formatted, $currency, $price);
230 230
 	endif;
231 231
 
232
-	if ( $negative ) {
232
+	if ($negative) {
233 233
 		// Prepend the mins sign before the currency sign
234
-		$formatted = '-' . $formatted;
234
+		$formatted = '-'.$formatted;
235 235
 	}
236 236
 
237 237
 	return $formatted;
@@ -246,11 +246,11 @@  discard block
 block discarded – undo
246 246
  *
247 247
  * @return int $decimals
248 248
  */
249
-function give_currency_decimal_filter( $decimals = 2 ) {
249
+function give_currency_decimal_filter($decimals = 2) {
250 250
 
251 251
 	$currency = give_get_currency();
252 252
 
253
-	switch ( $currency ) {
253
+	switch ($currency) {
254 254
 		case 'RIAL' :
255 255
 		case 'JPY' :
256 256
 		case 'TWD' :
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
 			break;
261 261
 	}
262 262
 
263
-	return apply_filters( 'give_currency_decimal_count', $decimals, $currency );
263
+	return apply_filters('give_currency_decimal_count', $decimals, $currency);
264 264
 }
265 265
 
266
-add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' );
267
-add_filter( 'give_format_amount_decimals', 'give_currency_decimal_filter' );
268 266
\ No newline at end of file
267
+add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter');
268
+add_filter('give_format_amount_decimals', 'give_currency_decimal_filter');
269 269
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/shortcodes/class-shortcode-button.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -117,8 +117,8 @@
 block discarded – undo
117 117
 		$shortcode_button_pages = array( 'post.php', 'page.php', 'post-new.php', 'post-edit.php' );
118 118
 		// Only run in admin post/page creation and edit screens
119 119
 		if ( in_array( $pagenow, $shortcode_button_pages )
120
-		     && apply_filters( 'give_shortcode_button_condition', true )
121
-		     && ! empty( self::$shortcodes )
120
+			 && apply_filters( 'give_shortcode_button_condition', true )
121
+			 && ! empty( self::$shortcodes )
122 122
 		) {
123 123
 
124 124
 			$shortcodes = array();
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @since       1.3.0
12 12
  */
13 13
 
14
-defined( 'ABSPATH' ) or exit;
14
+defined('ABSPATH') or exit;
15 15
 
16 16
 /**
17 17
  * Class Give_Shortcode_Button
@@ -30,16 +30,16 @@  discard block
 block discarded – undo
30 30
 	 */
31 31
 	public function __construct() {
32 32
 
33
-		if ( is_admin() ) {
34
-			add_filter( 'mce_external_plugins', array( $this, 'mce_external_plugins' ), 15 );
33
+		if (is_admin()) {
34
+			add_filter('mce_external_plugins', array($this, 'mce_external_plugins'), 15);
35 35
 
36
-			add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_assets' ) );
37
-			add_action( 'admin_enqueue_scripts', array( $this, 'admin_localize_scripts' ), 13 );
38
-			add_action( 'media_buttons', array( $this, 'shortcode_button' ) );
36
+			add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_assets'));
37
+			add_action('admin_enqueue_scripts', array($this, 'admin_localize_scripts'), 13);
38
+			add_action('media_buttons', array($this, 'shortcode_button'));
39 39
 		}
40 40
 
41
-		add_action( "wp_ajax_give_shortcode", array( $this, 'shortcode_ajax' ) );
42
-		add_action( "wp_ajax_nopriv_give_shortcode", array( $this, 'shortcode_ajax' ) );
41
+		add_action("wp_ajax_give_shortcode", array($this, 'shortcode_ajax'));
42
+		add_action("wp_ajax_nopriv_give_shortcode", array($this, 'shortcode_ajax'));
43 43
 	}
44 44
 
45 45
 	/**
@@ -51,13 +51,13 @@  discard block
 block discarded – undo
51 51
 	 *
52 52
 	 * @since 1.0
53 53
 	 */
54
-	public function mce_external_plugins( $plugin_array ) {
54
+	public function mce_external_plugins($plugin_array) {
55 55
 
56
-		if ( current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) ) {
56
+		if (current_user_can('edit_posts') && current_user_can('edit_pages')) {
57 57
 
58
-			$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
58
+			$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
59 59
 
60
-			$plugin_array['give_shortcode'] = GIVE_PLUGIN_URL . 'assets/js/admin/tinymce/mce-plugin' . $suffix . '.js';
60
+			$plugin_array['give_shortcode'] = GIVE_PLUGIN_URL.'assets/js/admin/tinymce/mce-plugin'.$suffix.'.js';
61 61
 		}
62 62
 
63 63
 		return $plugin_array;
@@ -72,12 +72,12 @@  discard block
 block discarded – undo
72 72
 	 */
73 73
 	public function admin_enqueue_assets() {
74 74
 
75
-		$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
75
+		$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
76 76
 
77 77
 		wp_enqueue_script(
78 78
 			'give_shortcode',
79
-			GIVE_PLUGIN_URL . 'assets/js/admin/admin-shortcodes' . $suffix . '.js',
80
-			array( 'jquery' ),
79
+			GIVE_PLUGIN_URL.'assets/js/admin/admin-shortcodes'.$suffix.'.js',
80
+			array('jquery'),
81 81
 			GIVE_VERSION,
82 82
 			true
83 83
 		);
@@ -92,17 +92,17 @@  discard block
 block discarded – undo
92 92
 	 */
93 93
 	public function admin_localize_scripts() {
94 94
 
95
-		if ( ! empty( self::$shortcodes ) ) {
95
+		if ( ! empty(self::$shortcodes)) {
96 96
 
97 97
 			$variables = array();
98 98
 
99
-			foreach ( self::$shortcodes as $shortcode => $values ) {
100
-				if ( ! empty( $values['required'] ) ) {
101
-					$variables[ $shortcode ] = $values['required'];
99
+			foreach (self::$shortcodes as $shortcode => $values) {
100
+				if ( ! empty($values['required'])) {
101
+					$variables[$shortcode] = $values['required'];
102 102
 				}
103 103
 			}
104 104
 
105
-			wp_localize_script( 'give_shortcode', 'scShortcodes', $variables );
105
+			wp_localize_script('give_shortcode', 'scShortcodes', $variables);
106 106
 		}
107 107
 	}
108 108
 
@@ -117,24 +117,24 @@  discard block
 block discarded – undo
117 117
 
118 118
 		global $pagenow, $wp_version;
119 119
 
120
-		$shortcode_button_pages = array( 'post.php', 'page.php', 'post-new.php', 'post-edit.php' );
120
+		$shortcode_button_pages = array('post.php', 'page.php', 'post-new.php', 'post-edit.php');
121 121
 		// Only run in admin post/page creation and edit screens
122
-		if ( in_array( $pagenow, $shortcode_button_pages )
123
-		     && apply_filters( 'give_shortcode_button_condition', true )
124
-		     && ! empty( self::$shortcodes )
122
+		if (in_array($pagenow, $shortcode_button_pages)
123
+		     && apply_filters('give_shortcode_button_condition', true)
124
+		     && ! empty(self::$shortcodes)
125 125
 		) {
126 126
 
127 127
 			$shortcodes = array();
128 128
 
129
-			foreach ( self::$shortcodes as $shortcode => $values ) {
129
+			foreach (self::$shortcodes as $shortcode => $values) {
130 130
 				/**
131 131
 				 * Filters the condition for including the current shortcode
132 132
 				 *
133 133
 				 * @since 1.0
134 134
 				 */
135
-				if ( apply_filters( sanitize_title( $shortcode ) . '_condition', true ) ) {
135
+				if (apply_filters(sanitize_title($shortcode).'_condition', true)) {
136 136
 
137
-					$shortcodes[ $shortcode ] = sprintf(
137
+					$shortcodes[$shortcode] = sprintf(
138 138
 						'<div class="sc-shortcode mce-menu-item give-shortcode-item-%1$s" data-shortcode="%s">%s</div>',
139 139
 						$shortcode,
140 140
 						$values['label'],
@@ -143,37 +143,37 @@  discard block
 block discarded – undo
143 143
 				}
144 144
 			}
145 145
 
146
-			if ( ! empty( $shortcodes ) ) {
146
+			if ( ! empty($shortcodes)) {
147 147
 
148 148
 				// check current WP version
149
-				$img = ( version_compare( $wp_version, '3.5', '<' ) )
150
-					? '<img src="' . GIVE_PLUGIN_URL . 'assets/images/give-media.png" />'
151
-					: '<span class="wp-media-buttons-icon" id="give-media-button" style="background-image: url(' . give_svg_icons( 'give_grey' ) . ');"></span>';
149
+				$img = (version_compare($wp_version, '3.5', '<'))
150
+					? '<img src="'.GIVE_PLUGIN_URL.'assets/images/give-media.png" />'
151
+					: '<span class="wp-media-buttons-icon" id="give-media-button" style="background-image: url('.give_svg_icons('give_grey').');"></span>';
152 152
 
153
-				reset( $shortcodes );
153
+				reset($shortcodes);
154 154
 
155
-				if ( count( $shortcodes ) == 1 ) {
155
+				if (count($shortcodes) == 1) {
156 156
 
157
-					$shortcode = key( $shortcodes );
157
+					$shortcode = key($shortcodes);
158 158
 
159 159
 					printf(
160 160
 						'<button class="button sc-shortcode" data-shortcode="%s">%s</button>',
161 161
 						$shortcode,
162
-						sprintf( '%s %s %s',
162
+						sprintf('%s %s %s',
163 163
 							$img,
164
-							esc_html__( 'Insert', 'give' ),
165
-							self::$shortcodes[ $shortcode ]['label']
164
+							esc_html__('Insert', 'give'),
165
+							self::$shortcodes[$shortcode]['label']
166 166
 						)
167 167
 					);
168 168
 				} else {
169 169
 					printf(
170
-						'<div class="sc-wrap">' .
171
-						'<button class="button sc-button">%s %s</button>' .
172
-						'<div class="sc-menu mce-menu">%s</div>' .
170
+						'<div class="sc-wrap">'.
171
+						'<button class="button sc-button">%s %s</button>'.
172
+						'<div class="sc-menu mce-menu">%s</div>'.
173 173
 						'</div>',
174 174
 						$img,
175
-						esc_html__( 'Give Shortcodes', 'give' ),
176
-						implode( '', array_values( $shortcodes ) )
175
+						esc_html__('Give Shortcodes', 'give'),
176
+						implode('', array_values($shortcodes))
177 177
 					);
178 178
 				}
179 179
 			}
@@ -189,15 +189,15 @@  discard block
 block discarded – undo
189 189
 	 */
190 190
 	public function shortcode_ajax() {
191 191
 
192
-		$shortcode = isset( $_POST['shortcode'] ) ? $_POST['shortcode'] : false;
192
+		$shortcode = isset($_POST['shortcode']) ? $_POST['shortcode'] : false;
193 193
 		$response  = false;
194 194
 
195
-		if ( $shortcode && array_key_exists( $shortcode, self::$shortcodes ) ) {
195
+		if ($shortcode && array_key_exists($shortcode, self::$shortcodes)) {
196 196
 
197
-			$data = self::$shortcodes[ $shortcode ];
197
+			$data = self::$shortcodes[$shortcode];
198 198
 
199
-			if ( ! empty( $data['errors'] ) ) {
200
-				$data['btn_okay'] = array( esc_html__( 'Okay', 'give' ) );
199
+			if ( ! empty($data['errors'])) {
200
+				$data['btn_okay'] = array(esc_html__('Okay', 'give'));
201 201
 			}
202 202
 
203 203
 			$response = array(
@@ -209,10 +209,10 @@  discard block
 block discarded – undo
209 209
 			);
210 210
 		} else {
211 211
 			// todo: handle error
212
-			error_log( print_r( 'AJAX error!', 1 ) );
212
+			error_log(print_r('AJAX error!', 1));
213 213
 		}
214 214
 
215
-		wp_send_json( $response );
215
+		wp_send_json($response);
216 216
 	}
217 217
 }
218 218
 
Please login to merge, or discard this patch.
includes/class-give-roles.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -71,9 +71,9 @@
 block discarded – undo
71 71
 		) );
72 72
 
73 73
 		add_role( 'give_accountant', __( 'Give Accountant', 'give' ), array(
74
-		    'read'                   => true,
75
-		    'edit_posts'             => false,
76
-		    'delete_posts'           => false
74
+			'read'                   => true,
75
+			'edit_posts'             => false,
76
+			'delete_posts'           => false
77 77
 		) );
78 78
 
79 79
 		add_role( 'give_worker', __( 'Give Worker', 'give' ), array(
Please login to merge, or discard this patch.
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	public function __construct() {
30 30
 
31
-		add_filter( 'give_map_meta_cap', array( $this, 'meta_caps' ), 10, 4 );
31
+		add_filter('give_map_meta_cap', array($this, 'meta_caps'), 10, 4);
32 32
 	}
33 33
 
34 34
 	/**
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 * @return void
40 40
 	 */
41 41
 	public function add_roles() {
42
-		add_role( 'give_manager', esc_html__( 'Give Manager', 'give' ), array(
42
+		add_role('give_manager', esc_html__('Give Manager', 'give'), array(
43 43
 			'read'                   => true,
44 44
 			'edit_posts'             => true,
45 45
 			'delete_posts'           => true,
@@ -68,20 +68,20 @@  discard block
 block discarded – undo
68 68
 			'publish_posts'          => true,
69 69
 			'read_private_pages'     => true,
70 70
 			'read_private_posts'     => true
71
-		) );
71
+		));
72 72
 
73
-		add_role( 'give_accountant', esc_html__( 'Give Accountant', 'give' ), array(
73
+		add_role('give_accountant', esc_html__('Give Accountant', 'give'), array(
74 74
 		    'read'                   => true,
75 75
 		    'edit_posts'             => false,
76 76
 		    'delete_posts'           => false
77
-		) );
77
+		));
78 78
 
79
-		add_role( 'give_worker', esc_html__( 'Give Worker', 'give' ), array(
79
+		add_role('give_worker', esc_html__('Give Worker', 'give'), array(
80 80
 			'read'                   => true,
81 81
 			'edit_posts'             => false,
82 82
 			'upload_files'           => true,
83 83
 			'delete_posts'           => false
84
-		) );
84
+		));
85 85
 
86 86
 	}
87 87
 
@@ -96,38 +96,38 @@  discard block
 block discarded – undo
96 96
 	public function add_caps() {
97 97
 		global $wp_roles;
98 98
 
99
-		if ( class_exists('WP_Roles') ) {
100
-			if ( ! isset( $wp_roles ) ) {
99
+		if (class_exists('WP_Roles')) {
100
+			if ( ! isset($wp_roles)) {
101 101
 				$wp_roles = new WP_Roles();
102 102
 			}
103 103
 		}
104 104
 
105
-		if ( is_object( $wp_roles ) ) {
106
-			$wp_roles->add_cap( 'give_manager', 'view_give_reports' );
107
-			$wp_roles->add_cap( 'give_manager', 'view_give_sensitive_data' );
108
-			$wp_roles->add_cap( 'give_manager', 'export_give_reports' );
109
-			$wp_roles->add_cap( 'give_manager', 'manage_give_settings' );
105
+		if (is_object($wp_roles)) {
106
+			$wp_roles->add_cap('give_manager', 'view_give_reports');
107
+			$wp_roles->add_cap('give_manager', 'view_give_sensitive_data');
108
+			$wp_roles->add_cap('give_manager', 'export_give_reports');
109
+			$wp_roles->add_cap('give_manager', 'manage_give_settings');
110 110
 
111
-			$wp_roles->add_cap( 'administrator', 'view_give_reports' );
112
-			$wp_roles->add_cap( 'administrator', 'view_give_sensitive_data' );
113
-			$wp_roles->add_cap( 'administrator', 'export_give_reports' );
114
-			$wp_roles->add_cap( 'administrator', 'manage_give_settings' );
111
+			$wp_roles->add_cap('administrator', 'view_give_reports');
112
+			$wp_roles->add_cap('administrator', 'view_give_sensitive_data');
113
+			$wp_roles->add_cap('administrator', 'export_give_reports');
114
+			$wp_roles->add_cap('administrator', 'manage_give_settings');
115 115
 
116 116
 			// Add the main post type capabilities
117 117
 			$capabilities = $this->get_core_caps();
118
-			foreach ( $capabilities as $cap_group ) {
119
-				foreach ( $cap_group as $cap ) {
120
-					$wp_roles->add_cap( 'administrator', $cap );
121
-					$wp_roles->add_cap( 'give_manager', $cap );
122
-					$wp_roles->add_cap( 'give_worker', $cap );
118
+			foreach ($capabilities as $cap_group) {
119
+				foreach ($cap_group as $cap) {
120
+					$wp_roles->add_cap('administrator', $cap);
121
+					$wp_roles->add_cap('give_manager', $cap);
122
+					$wp_roles->add_cap('give_worker', $cap);
123 123
 				}
124 124
 			}
125 125
 
126
-			$wp_roles->add_cap( 'give_accountant', 'edit_give_forms' );
127
-			$wp_roles->add_cap( 'give_accountant', 'read_private_give_forms' );
128
-			$wp_roles->add_cap( 'give_accountant', 'view_give_reports' );
129
-			$wp_roles->add_cap( 'give_accountant', 'export_give_reports' );
130
-			$wp_roles->add_cap( 'give_accountant', 'edit_give_payments' );
126
+			$wp_roles->add_cap('give_accountant', 'edit_give_forms');
127
+			$wp_roles->add_cap('give_accountant', 'read_private_give_forms');
128
+			$wp_roles->add_cap('give_accountant', 'view_give_reports');
129
+			$wp_roles->add_cap('give_accountant', 'export_give_reports');
130
+			$wp_roles->add_cap('give_accountant', 'edit_give_payments');
131 131
 
132 132
 		}
133 133
 	}
@@ -142,10 +142,10 @@  discard block
 block discarded – undo
142 142
 	public function get_core_caps() {
143 143
 		$capabilities = array();
144 144
 
145
-		$capability_types = array( 'give_form', 'give_payment' );
145
+		$capability_types = array('give_form', 'give_payment');
146 146
 
147
-		foreach ( $capability_types as $capability_type ) {
148
-			$capabilities[ $capability_type ] = array(
147
+		foreach ($capability_types as $capability_type) {
148
+			$capabilities[$capability_type] = array(
149 149
 				// Post type
150 150
 				"edit_{$capability_type}",
151 151
 				"read_{$capability_type}",
@@ -182,22 +182,22 @@  discard block
 block discarded – undo
182 182
 	 * @since  1.0
183 183
 	 * @return array $caps
184 184
 	 */
185
-	public function meta_caps( $caps, $cap, $user_id, $args ) {
185
+	public function meta_caps($caps, $cap, $user_id, $args) {
186 186
 
187
-		switch( $cap ) {
187
+		switch ($cap) {
188 188
 
189 189
 			case 'view_give_forms_stats' :
190 190
 				
191
-				if( empty( $args[0] ) ) {
191
+				if (empty($args[0])) {
192 192
 					break;
193 193
 				}
194 194
 				
195
-				$form = get_post( $args[0] );
196
-				if ( empty( $form ) ) {
195
+				$form = get_post($args[0]);
196
+				if (empty($form)) {
197 197
 					break;
198 198
 				}
199 199
 
200
-				if( user_can( $user_id, 'view_give_reports' ) || $user_id == $form->post_author ) {
200
+				if (user_can($user_id, 'view_give_reports') || $user_id == $form->post_author) {
201 201
 					$caps = array();
202 202
 				}
203 203
 
@@ -219,41 +219,41 @@  discard block
 block discarded – undo
219 219
 		
220 220
 		global $wp_roles;
221 221
 
222
-		if ( class_exists( 'WP_Roles' ) ) {
223
-			if ( ! isset( $wp_roles ) ) {
222
+		if (class_exists('WP_Roles')) {
223
+			if ( ! isset($wp_roles)) {
224 224
 				$wp_roles = new WP_Roles();
225 225
 			}
226 226
 		}
227 227
 
228
-		if ( is_object( $wp_roles ) ) {
228
+		if (is_object($wp_roles)) {
229 229
 			/** Give Manager Capabilities */
230
-			$wp_roles->remove_cap( 'give_manager', 'view_give_reports' );
231
-			$wp_roles->remove_cap( 'give_manager', 'view_give_sensitive_data' );
232
-			$wp_roles->remove_cap( 'give_manager', 'export_give_reports' );
233
-			$wp_roles->remove_cap( 'give_manager', 'manage_give_settings' );
230
+			$wp_roles->remove_cap('give_manager', 'view_give_reports');
231
+			$wp_roles->remove_cap('give_manager', 'view_give_sensitive_data');
232
+			$wp_roles->remove_cap('give_manager', 'export_give_reports');
233
+			$wp_roles->remove_cap('give_manager', 'manage_give_settings');
234 234
 
235 235
 			/** Site Administrator Capabilities */
236
-			$wp_roles->remove_cap( 'administrator', 'view_give_reports' );
237
-			$wp_roles->remove_cap( 'administrator', 'view_give_sensitive_data' );
238
-			$wp_roles->remove_cap( 'administrator', 'export_give_reports' );
239
-			$wp_roles->remove_cap( 'administrator', 'manage_give_settings' );
236
+			$wp_roles->remove_cap('administrator', 'view_give_reports');
237
+			$wp_roles->remove_cap('administrator', 'view_give_sensitive_data');
238
+			$wp_roles->remove_cap('administrator', 'export_give_reports');
239
+			$wp_roles->remove_cap('administrator', 'manage_give_settings');
240 240
 
241 241
 			/** Remove the Main Post Type Capabilities */
242 242
 			$capabilities = $this->get_core_caps();
243 243
 
244
-			foreach ( $capabilities as $cap_group ) {
245
-				foreach ( $cap_group as $cap ) {
246
-					$wp_roles->remove_cap( 'give_manager', $cap );
247
-					$wp_roles->remove_cap( 'administrator', $cap );
248
-					$wp_roles->remove_cap( 'give_worker', $cap );
244
+			foreach ($capabilities as $cap_group) {
245
+				foreach ($cap_group as $cap) {
246
+					$wp_roles->remove_cap('give_manager', $cap);
247
+					$wp_roles->remove_cap('administrator', $cap);
248
+					$wp_roles->remove_cap('give_worker', $cap);
249 249
 				}
250 250
 			}
251 251
 
252 252
 			/** Give Accountant Capabilities */
253
-			$wp_roles->remove_cap( 'give_accountant', 'edit_give_forms' );
254
-			$wp_roles->remove_cap( 'give_accountant', 'read_private_give_forms' );
255
-			$wp_roles->remove_cap( 'give_accountant', 'view_give_reports' );
256
-			$wp_roles->remove_cap( 'give_accountant', 'export_give_reports' );
253
+			$wp_roles->remove_cap('give_accountant', 'edit_give_forms');
254
+			$wp_roles->remove_cap('give_accountant', 'read_private_give_forms');
255
+			$wp_roles->remove_cap('give_accountant', 'view_give_reports');
256
+			$wp_roles->remove_cap('give_accountant', 'export_give_reports');
257 257
 
258 258
 		}
259 259
 	}
Please login to merge, or discard this patch.