Completed
Pull Request — master (#893)
by Rami
20:06
created
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'                     => __( 'Refunded', 'give' ),
318
+	register_post_status('refunded', array(
319
+		'label'                     => __('Refunded', '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'                     => __( 'Failed', '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'                     => __('Failed', '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'                     => __( 'Revoked', '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'                     => __('Revoked', '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'                     => __( 'Cancelled', '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'                     => __('Cancelled', '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'                     => __( 'Abandoned', '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'                     => __('Abandoned', '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/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__( 'Show only donators with a Gravatar account.', 'give' ),
393
+				'name' => esc_html__('Gravatar Visibility', 'give'),
394
+				'desc' => esc_html__('Show only 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/shortcodes.php 1 patch
Spacing   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,28 +25,28 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_donation_history() {
27 27
 
28
-	$email_access = give_get_option( 'email_access' );
28
+	$email_access = give_get_option('email_access');
29 29
 
30 30
 	//Is user logged in? Does a session exist? Does an email-access token exist?
31
-	if ( is_user_logged_in() || Give()->session->get_session_expiration() !== false || ( $email_access == 'on' && Give()->email_access->token_exists ) ) {
31
+	if (is_user_logged_in() || Give()->session->get_session_expiration() !== false || ($email_access == 'on' && Give()->email_access->token_exists)) {
32 32
 		ob_start();
33
-		give_get_template_part( 'history', 'donations' );
33
+		give_get_template_part('history', 'donations');
34 34
 
35 35
 		return ob_get_clean();
36 36
 	} //Is Email-based access enabled?
37
-	elseif ( $email_access == 'on' ) {
37
+	elseif ($email_access == 'on') {
38 38
 
39 39
 		ob_start();
40
-		give_get_template_part( 'email', 'login-form' );
40
+		give_get_template_part('email', 'login-form');
41 41
 
42 42
 		return ob_get_clean();
43 43
 	} else {
44
-		$message = esc_html__( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' );
45
-		echo apply_filters( 'give_donation_history_nonuser_message', give_output_error( $message, false ), $message );
44
+		$message = esc_html__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give');
45
+		echo apply_filters('give_donation_history_nonuser_message', give_output_error($message, false), $message);
46 46
 	}
47 47
 }
48 48
 
49
-add_shortcode( 'donation_history', 'give_donation_history' );
49
+add_shortcode('donation_history', 'give_donation_history');
50 50
 
51 51
 /**
52 52
  * Donation Form Shortcode
@@ -60,53 +60,53 @@  discard block
 block discarded – undo
60 60
  *
61 61
  * @return string
62 62
  */
63
-function give_form_shortcode( $atts, $content = null ) {
64
-	$atts = shortcode_atts( array(
63
+function give_form_shortcode($atts, $content = null) {
64
+	$atts = shortcode_atts(array(
65 65
 		'id'            => '',
66 66
 		'show_title'    => true,
67 67
 		'show_goal'     => true,
68 68
 		'show_content'  => '',
69 69
 		'float_labels'  => '',
70 70
 		'display_style' => '',
71
-	), $atts, 'give_form' );
71
+	), $atts, 'give_form');
72 72
 
73
-	foreach ( $atts as $key => $value ) {
73
+	foreach ($atts as $key => $value) {
74 74
 		//convert shortcode_atts values to booleans
75
-		if ( $key == 'show_title' ) {
76
-			$atts[ $key ] = filter_var( $atts[ $key ], FILTER_VALIDATE_BOOLEAN );
77
-		} elseif ( $key == 'show_goal' ) {
78
-			$atts[ $key ] = filter_var( $atts[ $key ], FILTER_VALIDATE_BOOLEAN );
75
+		if ($key == 'show_title') {
76
+			$atts[$key] = filter_var($atts[$key], FILTER_VALIDATE_BOOLEAN);
77
+		} elseif ($key == 'show_goal') {
78
+			$atts[$key] = filter_var($atts[$key], FILTER_VALIDATE_BOOLEAN);
79 79
 		}
80 80
 
81 81
 		//validate show_content value
82
-		if ( $key == 'show_content' ) {
83
-			if ( ! in_array( $value, array( 'none', 'above', 'below' ) ) ) {
84
-				$atts[ $key ] = '';
85
-			} else if ( $value == 'above' ) {
86
-				$atts[ $key ] = 'give_pre_form';
87
-			} else if ( $value == 'below' ) {
88
-				$atts[ $key ] = 'give_post_form';
82
+		if ($key == 'show_content') {
83
+			if ( ! in_array($value, array('none', 'above', 'below'))) {
84
+				$atts[$key] = '';
85
+			} else if ($value == 'above') {
86
+				$atts[$key] = 'give_pre_form';
87
+			} else if ($value == 'below') {
88
+				$atts[$key] = 'give_post_form';
89 89
 			}
90 90
 		}
91 91
 
92 92
 		//validate display_style and float_labels value
93
-		if ( ( $key == 'display_style' && ! in_array( $value, array( 'onpage', 'reveal', 'modal' ) ) )
94
-		     || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) )
93
+		if (($key == 'display_style' && ! in_array($value, array('onpage', 'reveal', 'modal')))
94
+		     || ($key == 'float_labels' && ! in_array($value, array('enabled', 'disabled')))
95 95
 		) {
96 96
 
97
-			$atts[ $key ] = '';
97
+			$atts[$key] = '';
98 98
 		}
99 99
 	}
100 100
 
101 101
 	//get the Give Form
102 102
 	ob_start();
103
-	give_get_donation_form( $atts );
103
+	give_get_donation_form($atts);
104 104
 	$final_output = ob_get_clean();
105 105
 
106
-	return apply_filters( 'give_donate_form', $final_output, $atts );
106
+	return apply_filters('give_donate_form', $final_output, $atts);
107 107
 }
108 108
 
109
-add_shortcode( 'give_form', 'give_form_shortcode' );
109
+add_shortcode('give_form', 'give_form_shortcode');
110 110
 
111 111
 /**
112 112
  * Donation Form Goal Shortcode.
@@ -120,37 +120,37 @@  discard block
 block discarded – undo
120 120
  *
121 121
  * @return string
122 122
  */
123
-function give_goal_shortcode( $atts, $content = null ) {
124
-	$atts = shortcode_atts( array(
123
+function give_goal_shortcode($atts, $content = null) {
124
+	$atts = shortcode_atts(array(
125 125
 		'id'        => '',
126 126
 		'show_text' => true,
127 127
 		'show_bar'  => true,
128
-	), $atts, 'give_goal' );
128
+	), $atts, 'give_goal');
129 129
 
130 130
 
131 131
 	//get the Give Form.
132 132
 	ob_start();
133 133
 
134 134
 	//Sanity check 1: ensure there is an ID Provided.
135
-	if ( empty( $atts['id'] ) ) {
136
-		give_output_error( esc_html__( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true );
135
+	if (empty($atts['id'])) {
136
+		give_output_error(esc_html__('The shortcode is missing Donation Form ID attribute.', 'give'), true);
137 137
 	}
138 138
 
139 139
 	//Sanity check 2: Check the form even has Goals enabled.
140
-	$goal_option = get_post_meta( $atts['id'], '_give_goal_option', true );
141
-	if ( empty( $goal_option ) || $goal_option !== 'yes' ) {
142
-		give_output_error( esc_html__( 'The form does not have Goals enabled.', 'give' ), true );
140
+	$goal_option = get_post_meta($atts['id'], '_give_goal_option', true);
141
+	if (empty($goal_option) || $goal_option !== 'yes') {
142
+		give_output_error(esc_html__('The form does not have Goals enabled.', 'give'), true);
143 143
 	} else {
144 144
 		//Passed all sanity checks: output Goal.
145
-		give_show_goal_progress( $atts['id'], $atts );
145
+		give_show_goal_progress($atts['id'], $atts);
146 146
 	}
147 147
 
148 148
 	$final_output = ob_get_clean();
149 149
 
150
-	return apply_filters( 'give_goal_shortcode_output', $final_output, $atts );
150
+	return apply_filters('give_goal_shortcode_output', $final_output, $atts);
151 151
 }
152 152
 
153
-add_shortcode( 'give_goal', 'give_goal_shortcode' );
153
+add_shortcode('give_goal', 'give_goal_shortcode');
154 154
 
155 155
 
156 156
 /**
@@ -167,22 +167,22 @@  discard block
 block discarded – undo
167 167
  * @uses  give_login_form()
168 168
  * @return string
169 169
  */
170
-function give_login_form_shortcode( $atts, $content = null ) {
171
-	$atts = shortcode_atts( array(
170
+function give_login_form_shortcode($atts, $content = null) {
171
+	$atts = shortcode_atts(array(
172 172
         // Add backward compatibility for redirect attribute.
173 173
         'redirect'          => '',
174 174
 
175 175
 		'login-redirect'    => '',
176 176
 		'logout-redirect'   => '',
177
-	), $atts, 'give_login' );
177
+	), $atts, 'give_login');
178 178
 
179 179
     // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute.
180
-    $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect' ] ) ? $atts['redirect'] : '' );
180
+    $atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : '');
181 181
 
182
-	return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] );
182
+	return give_login_form($atts['login-redirect'], $atts['logout-redirect']);
183 183
 }
184 184
 
185
-add_shortcode( 'give_login', 'give_login_form_shortcode' );
185
+add_shortcode('give_login', 'give_login_form_shortcode');
186 186
 
187 187
 /**
188 188
  * Register Shortcode.
@@ -197,15 +197,15 @@  discard block
 block discarded – undo
197 197
  * @uses  give_register_form()
198 198
  * @return string
199 199
  */
200
-function give_register_form_shortcode( $atts, $content = null ) {
201
-	$atts = shortcode_atts( array(
200
+function give_register_form_shortcode($atts, $content = null) {
201
+	$atts = shortcode_atts(array(
202 202
 		'redirect' => '',
203
-	), $atts, 'give_register' );
203
+	), $atts, 'give_register');
204 204
 
205
-	return give_register_form( $atts['redirect'] );
205
+	return give_register_form($atts['redirect']);
206 206
 }
207 207
 
208
-add_shortcode( 'give_register', 'give_register_form_shortcode' );
208
+add_shortcode('give_register', 'give_register_form_shortcode');
209 209
 
210 210
 
211 211
 /**
@@ -220,62 +220,62 @@  discard block
 block discarded – undo
220 220
  *
221 221
  * @return string
222 222
  */
223
-function give_receipt_shortcode( $atts, $content = null ) {
223
+function give_receipt_shortcode($atts, $content = null) {
224 224
 
225 225
 	global $give_receipt_args, $payment;
226 226
 
227
-	$give_receipt_args = shortcode_atts( array(
228
-		'error'          => esc_html__( 'You are missing the payment key to view this donation receipt.', 'give' ),
227
+	$give_receipt_args = shortcode_atts(array(
228
+		'error'          => esc_html__('You are missing the payment key to view this donation receipt.', 'give'),
229 229
 		'price'          => true,
230 230
 		'donor'          => true,
231 231
 		'date'           => true,
232 232
 		'payment_key'    => false,
233 233
 		'payment_method' => true,
234 234
 		'payment_id'     => true
235
-	), $atts, 'give_receipt' );
235
+	), $atts, 'give_receipt');
236 236
 
237 237
 	//set $session var
238 238
 	$session = give_get_purchase_session();
239 239
 
240 240
 	//set payment key var
241
-	if ( isset( $_GET['payment_key'] ) ) {
242
-		$payment_key = urldecode( $_GET['payment_key'] );
243
-	} elseif ( $session ) {
241
+	if (isset($_GET['payment_key'])) {
242
+		$payment_key = urldecode($_GET['payment_key']);
243
+	} elseif ($session) {
244 244
 		$payment_key = $session['purchase_key'];
245
-	} elseif ( $give_receipt_args['payment_key'] ) {
245
+	} elseif ($give_receipt_args['payment_key']) {
246 246
 		$payment_key = $give_receipt_args['payment_key'];
247 247
 	}
248 248
 
249
-	$email_access = give_get_option( 'email_access' );
249
+	$email_access = give_get_option('email_access');
250 250
 
251 251
 	// No payment_key found & Email Access is Turned on:
252
-	if ( ! isset( $payment_key ) && $email_access == 'on' && ! Give()->email_access->token_exists ) {
252
+	if ( ! isset($payment_key) && $email_access == 'on' && ! Give()->email_access->token_exists) {
253 253
 
254 254
 		ob_start();
255 255
 
256
-		give_get_template_part( 'email-login-form' );
256
+		give_get_template_part('email-login-form');
257 257
 
258 258
 		return ob_get_clean();
259 259
 
260
-	} elseif ( ! isset( $payment_key ) ) {
260
+	} elseif ( ! isset($payment_key)) {
261 261
 
262
-		return give_output_error( $give_receipt_args['error'], false, 'error' );
262
+		return give_output_error($give_receipt_args['error'], false, 'error');
263 263
 
264 264
 	}
265 265
 
266
-	$payment_id    = give_get_purchase_id_by_key( $payment_key );
267
-	$user_can_view = give_can_view_receipt( $payment_key );
266
+	$payment_id    = give_get_purchase_id_by_key($payment_key);
267
+	$user_can_view = give_can_view_receipt($payment_key);
268 268
 
269 269
 	// Key was provided, but user is logged out. Offer them the ability to login and view the receipt.
270
-	if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists ) {
270
+	if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists) {
271 271
 
272 272
 		ob_start();
273 273
 
274
-		give_get_template_part( 'email-login-form' );
274
+		give_get_template_part('email-login-form');
275 275
 
276 276
 		return ob_get_clean();
277 277
 
278
-	} elseif ( ! $user_can_view ) {
278
+	} elseif ( ! $user_can_view) {
279 279
 
280 280
 		global $give_login_redirect;
281 281
 
@@ -283,9 +283,9 @@  discard block
 block discarded – undo
283 283
 
284 284
 		ob_start();
285 285
 
286
-		give_output_error( apply_filters( 'give_must_be_logged_in_error_message', esc_html__( 'You must be logged in to view this donation payment receipt.', 'give' ) ) );
286
+		give_output_error(apply_filters('give_must_be_logged_in_error_message', esc_html__('You must be logged in to view this donation payment receipt.', 'give')));
287 287
 
288
-		give_get_template_part( 'shortcode', 'login' );
288
+		give_get_template_part('shortcode', 'login');
289 289
 
290 290
 		$login_form = ob_get_clean();
291 291
 
@@ -300,13 +300,13 @@  discard block
 block discarded – undo
300 300
 	 * or if user is logged in and the user can view sensitive shop data.
301 301
 	 *
302 302
 	 */
303
-	if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) {
304
-		return give_output_error( $give_receipt_args['error'], false, 'error' );
303
+	if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) {
304
+		return give_output_error($give_receipt_args['error'], false, 'error');
305 305
 	}
306 306
 
307 307
 	ob_start();
308 308
 
309
-	give_get_template_part( 'shortcode', 'receipt' );
309
+	give_get_template_part('shortcode', 'receipt');
310 310
 
311 311
 	$display = ob_get_clean();
312 312
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 
316 316
 }
317 317
 
318
-add_shortcode( 'give_receipt', 'give_receipt_shortcode' );
318
+add_shortcode('give_receipt', 'give_receipt_shortcode');
319 319
 
320 320
 /**
321 321
  * Profile Editor Shortcode.
@@ -335,18 +335,18 @@  discard block
 block discarded – undo
335 335
  *
336 336
  * @return string Output generated from the profile editor
337 337
  */
338
-function give_profile_editor_shortcode( $atts, $content = null ) {
338
+function give_profile_editor_shortcode($atts, $content = null) {
339 339
 
340 340
 	ob_start();
341 341
 
342
-	give_get_template_part( 'shortcode', 'profile-editor' );
342
+	give_get_template_part('shortcode', 'profile-editor');
343 343
 
344 344
 	$display = ob_get_clean();
345 345
 
346 346
 	return $display;
347 347
 }
348 348
 
349
-add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' );
349
+add_shortcode('give_profile_editor', 'give_profile_editor_shortcode');
350 350
 
351 351
 /**
352 352
  * Process Profile Updater Form.
@@ -359,30 +359,30 @@  discard block
 block discarded – undo
359 359
  *
360 360
  * @return bool
361 361
  */
362
-function give_process_profile_editor_updates( $data ) {
362
+function give_process_profile_editor_updates($data) {
363 363
 	// Profile field change request
364
-	if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) {
364
+	if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) {
365 365
 		return false;
366 366
 	}
367 367
 
368 368
 	// Nonce security
369
-	if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) {
369
+	if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) {
370 370
 		return false;
371 371
 	}
372 372
 
373 373
 	$user_id       = get_current_user_id();
374
-	$old_user_data = get_userdata( $user_id );
375
-
376
-	$display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name;
377
-	$first_name   = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name;
378
-	$last_name    = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name;
379
-	$email        = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email;
380
-	$line1        = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' );
381
-	$line2        = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' );
382
-	$city         = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' );
383
-	$state        = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' );
384
-	$zip          = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' );
385
-	$country      = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' );
374
+	$old_user_data = get_userdata($user_id);
375
+
376
+	$display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name;
377
+	$first_name   = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name;
378
+	$last_name    = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name;
379
+	$email        = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email;
380
+	$line1        = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : '');
381
+	$line2        = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : '');
382
+	$city         = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : '');
383
+	$state        = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : '');
384
+	$zip          = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : '');
385
+	$country      = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : '');
386 386
 
387 387
 	$userdata = array(
388 388
 		'ID'           => $user_id,
@@ -410,38 +410,38 @@  discard block
 block discarded – undo
410 410
 	 * @param int   $user_id  The ID of the user.
411 411
 	 * @param array $userdata User info, including ID, first name, last name, display name and email.
412 412
 	 */
413
-	do_action( 'give_pre_update_user_profile', $user_id, $userdata );
413
+	do_action('give_pre_update_user_profile', $user_id, $userdata);
414 414
 
415 415
 	// New password
416
-	if ( ! empty( $data['give_new_user_pass1'] ) ) {
417
-		if ( $data['give_new_user_pass1'] !== $data['give_new_user_pass2'] ) {
418
-			give_set_error( 'password_mismatch', esc_html__( 'The passwords you entered do not match. Please try again.', 'give' ) );
416
+	if ( ! empty($data['give_new_user_pass1'])) {
417
+		if ($data['give_new_user_pass1'] !== $data['give_new_user_pass2']) {
418
+			give_set_error('password_mismatch', esc_html__('The passwords you entered do not match. Please try again.', 'give'));
419 419
 		} else {
420 420
 			$userdata['user_pass'] = $data['give_new_user_pass1'];
421 421
 		}
422 422
 	}
423 423
 
424 424
 	// Make sure the new email doesn't belong to another user
425
-	if ( $email != $old_user_data->user_email ) {
426
-		if ( email_exists( $email ) ) {
427
-			give_set_error( 'email_exists', esc_html__( 'The email you entered belongs to another user. Please use another.', 'give' ) );
425
+	if ($email != $old_user_data->user_email) {
426
+		if (email_exists($email)) {
427
+			give_set_error('email_exists', esc_html__('The email you entered belongs to another user. Please use another.', 'give'));
428 428
 		}
429 429
 	}
430 430
 
431 431
 	// Check for errors
432 432
 	$errors = give_get_errors();
433 433
 
434
-	if ( $errors ) {
434
+	if ($errors) {
435 435
 		// Send back to the profile editor if there are errors
436
-		wp_redirect( $data['give_redirect'] );
436
+		wp_redirect($data['give_redirect']);
437 437
 		give_die();
438 438
 	}
439 439
 
440 440
 	// Update the user
441
-	$meta    = update_user_meta( $user_id, '_give_user_address', $address );
442
-	$updated = wp_update_user( $userdata );
441
+	$meta    = update_user_meta($user_id, '_give_user_address', $address);
442
+	$updated = wp_update_user($userdata);
443 443
 
444
-	if ( $updated ) {
444
+	if ($updated) {
445 445
 
446 446
 		/**
447 447
 		 * Fires after updating user profile.
@@ -451,13 +451,13 @@  discard block
 block discarded – undo
451 451
 		 * @param int   $user_id  The ID of the user.
452 452
 		 * @param array $userdata User info, including ID, first name, last name, display name and email.
453 453
 		 */
454
-		do_action( 'give_user_profile_updated', $user_id, $userdata );
455
-		wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) );
454
+		do_action('give_user_profile_updated', $user_id, $userdata);
455
+		wp_redirect(add_query_arg('updated', 'true', $data['give_redirect']));
456 456
 		give_die();
457 457
 	}
458 458
 
459 459
 	return false;
460 460
 }
461 461
 
462
-add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' );
462
+add_action('give_edit_user_profile', 'give_process_profile_editor_updates');
463 463
 
Please login to merge, or discard this patch.
includes/class-give-html-elements.php 1 patch
Spacing   +140 added lines, -140 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
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @return string       Transactions dropdown.
37 37
 	 */
38
-	public function transactions_dropdown( $args = array() ) {
38
+	public function transactions_dropdown($args = array()) {
39 39
 
40 40
 		$defaults = array(
41 41
 			'name'        => 'transactions',
@@ -45,34 +45,34 @@  discard block
 block discarded – undo
45 45
 			'selected'    => 0,
46 46
 			'chosen'      => false,
47 47
 			'number'      => 30,
48
-			'placeholder' => esc_html__( 'Select a transaction', 'give' )
48
+			'placeholder' => esc_html__('Select a transaction', 'give')
49 49
 		);
50 50
 
51
-		$args = wp_parse_args( $args, $defaults );
51
+		$args = wp_parse_args($args, $defaults);
52 52
 
53 53
 
54
-		$payments = new Give_Payments_Query( array(
54
+		$payments = new Give_Payments_Query(array(
55 55
 			'number' => $args['number']
56
-		) );
56
+		));
57 57
 
58 58
 		$payments = $payments->get_payments();
59 59
 
60 60
 		$options = array();
61 61
 
62 62
 		//Provide nice human readable options.
63
-		if ( $payments ) {
64
-			$options[0] = esc_html__( 'Select a transaction', 'give' );
65
-			foreach ( $payments as $payment ) {
63
+		if ($payments) {
64
+			$options[0] = esc_html__('Select a transaction', 'give');
65
+			foreach ($payments as $payment) {
66 66
 
67
-				$options[ absint( $payment->ID ) ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title);
67
+				$options[absint($payment->ID)] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title);
68 68
 
69 69
 			}
70 70
 		} else {
71
-			$options[0] = esc_html__( 'No transactions found.', 'give' );
71
+			$options[0] = esc_html__('No transactions found.', 'give');
72 72
 		}
73 73
 
74 74
 
75
-		$output = $this->select( array(
75
+		$output = $this->select(array(
76 76
 			'name'             => $args['name'],
77 77
 			'selected'         => $args['selected'],
78 78
 			'id'               => $args['id'],
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 			'select_atts'      => $args['select_atts'],
85 85
 			'show_option_all'  => false,
86 86
 			'show_option_none' => false
87
-		) );
87
+		));
88 88
 
89 89
 		return $output;
90 90
 	}
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 *
102 102
 	 * @return string      Give forms dropdown.
103 103
 	 */
104
-	public function forms_dropdown( $args = array() ) {
104
+	public function forms_dropdown($args = array()) {
105 105
 
106 106
 		$defaults = array(
107 107
 			'name'        => 'forms',
@@ -113,49 +113,49 @@  discard block
 block discarded – undo
113 113
 			'number'      => 30,
114 114
 			'placeholder' => sprintf(
115 115
 				/* translators: %s: form singular label */
116
-				esc_attr__( 'Select a %s', 'give' ),
116
+				esc_attr__('Select a %s', 'give'),
117 117
 				give_get_forms_label_singular()
118 118
 			)
119 119
 		);
120 120
 
121
-		$args = wp_parse_args( $args, $defaults );
121
+		$args = wp_parse_args($args, $defaults);
122 122
 
123
-		$forms = get_posts( array(
123
+		$forms = get_posts(array(
124 124
 			'post_type'      => 'give_forms',
125 125
 			'orderby'        => 'title',
126 126
 			'order'          => 'ASC',
127 127
 			'posts_per_page' => $args['number']
128
-		) );
128
+		));
129 129
 
130 130
 		$options = array();
131 131
 
132
-		if ( $forms ) {
132
+		if ($forms) {
133 133
 			$options[0] = sprintf(
134 134
 				/* translators: %s: form singular label */
135
-				esc_html__( 'Select a %s', 'give' ),
135
+				esc_html__('Select a %s', 'give'),
136 136
 				give_get_forms_label_singular()
137 137
 			);
138
-			foreach ( $forms as $form ) {
139
-				$options[ absint( $form->ID ) ] = esc_html( $form->post_title );
138
+			foreach ($forms as $form) {
139
+				$options[absint($form->ID)] = esc_html($form->post_title);
140 140
 			}
141 141
 		} else {
142
-			$options[0] = esc_html__( 'No donation forms found.', 'give' );
142
+			$options[0] = esc_html__('No donation forms found.', 'give');
143 143
 		}
144 144
 
145 145
 		// This ensures that any selected forms are included in the drop down
146
-		if ( is_array( $args['selected'] ) ) {
147
-			foreach ( $args['selected'] as $item ) {
148
-				if ( ! in_array( $item, $options ) ) {
149
-					$options[ $item ] = get_the_title( $item );
146
+		if (is_array($args['selected'])) {
147
+			foreach ($args['selected'] as $item) {
148
+				if ( ! in_array($item, $options)) {
149
+					$options[$item] = get_the_title($item);
150 150
 				}
151 151
 			}
152
-		} elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) {
153
-			if ( ! in_array( $args['selected'], $options ) ) {
154
-				$options[ $args['selected'] ] = get_the_title( $args['selected'] );
152
+		} elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
153
+			if ( ! in_array($args['selected'], $options)) {
154
+				$options[$args['selected']] = get_the_title($args['selected']);
155 155
 			}
156 156
 		}
157 157
 
158
-		$output = $this->select( array(
158
+		$output = $this->select(array(
159 159
 			'name'             => $args['name'],
160 160
 			'selected'         => $args['selected'],
161 161
 			'id'               => $args['id'],
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 			'placeholder'      => $args['placeholder'],
167 167
 			'show_option_all'  => false,
168 168
 			'show_option_none' => false
169
-		) );
169
+		));
170 170
 
171 171
 		return $output;
172 172
 	}
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	 *
184 184
 	 * @return string      Donors dropdown.
185 185
 	 */
186
-	public function donor_dropdown( $args = array() ) {
186
+	public function donor_dropdown($args = array()) {
187 187
 
188 188
 		$defaults = array(
189 189
 			'name'        => 'customers',
@@ -192,38 +192,38 @@  discard block
 block discarded – undo
192 192
 			'multiple'    => false,
193 193
 			'selected'    => 0,
194 194
 			'chosen'      => true,
195
-			'placeholder' => esc_attr__( 'Select a Donor', 'give' ),
195
+			'placeholder' => esc_attr__('Select a Donor', 'give'),
196 196
 			'number'      => 30
197 197
 		);
198 198
 
199
-		$args = wp_parse_args( $args, $defaults );
199
+		$args = wp_parse_args($args, $defaults);
200 200
 
201
-		$customers = Give()->customers->get_customers( array(
201
+		$customers = Give()->customers->get_customers(array(
202 202
 			'number' => $args['number']
203
-		) );
203
+		));
204 204
 
205 205
 		$options = array();
206 206
 
207
-		if ( $customers ) {
208
-			$options[0] = esc_html__( 'No donor attached', 'give' );
209
-			foreach ( $customers as $customer ) {
210
-				$options[ absint( $customer->id ) ] = esc_html( $customer->name . ' (' . $customer->email . ')' );
207
+		if ($customers) {
208
+			$options[0] = esc_html__('No donor attached', 'give');
209
+			foreach ($customers as $customer) {
210
+				$options[absint($customer->id)] = esc_html($customer->name.' ('.$customer->email.')');
211 211
 			}
212 212
 		} else {
213
-			$options[0] = esc_html__( 'No donors found.', 'give' );
213
+			$options[0] = esc_html__('No donors found.', 'give');
214 214
 		}
215 215
 
216
-		if ( ! empty( $args['selected'] ) ) {
216
+		if ( ! empty($args['selected'])) {
217 217
 
218 218
 			// If a selected customer has been specified, we need to ensure it's in the initial list of customers displayed.
219 219
 
220
-			if ( ! array_key_exists( $args['selected'], $options ) ) {
220
+			if ( ! array_key_exists($args['selected'], $options)) {
221 221
 
222
-				$customer = new Give_Customer( $args['selected'] );
222
+				$customer = new Give_Customer($args['selected']);
223 223
 
224
-				if ( $customer ) {
224
+				if ($customer) {
225 225
 
226
-					$options[ absint( $args['selected'] ) ] = esc_html( $customer->name . ' (' . $customer->email . ')' );
226
+					$options[absint($args['selected'])] = esc_html($customer->name.' ('.$customer->email.')');
227 227
 
228 228
 				}
229 229
 
@@ -231,17 +231,17 @@  discard block
 block discarded – undo
231 231
 
232 232
 		}
233 233
 
234
-		$output = $this->select( array(
234
+		$output = $this->select(array(
235 235
 			'name'             => $args['name'],
236 236
 			'selected'         => $args['selected'],
237 237
 			'id'               => $args['id'],
238
-			'class'            => $args['class'] . ' give-customer-select',
238
+			'class'            => $args['class'].' give-customer-select',
239 239
 			'options'          => $options,
240 240
 			'multiple'         => $args['multiple'],
241 241
 			'chosen'           => $args['chosen'],
242 242
 			'show_option_all'  => false,
243 243
 			'show_option_none' => false
244
-		) );
244
+		));
245 245
 
246 246
 		return $output;
247 247
 	}
@@ -259,21 +259,21 @@  discard block
 block discarded – undo
259 259
 	 *
260 260
 	 * @return string           Categories dropdown.
261 261
 	 */
262
-	public function category_dropdown( $name = 'give_forms_categories', $selected = 0 ) {
263
-		$categories = get_terms( 'give_forms_category', apply_filters( 'give_forms_category_dropdown', array() ) );
262
+	public function category_dropdown($name = 'give_forms_categories', $selected = 0) {
263
+		$categories = get_terms('give_forms_category', apply_filters('give_forms_category_dropdown', array()));
264 264
 		$options    = array();
265 265
 
266
-		foreach ( $categories as $category ) {
267
-			$options[ absint( $category->term_id ) ] = esc_html( $category->name );
266
+		foreach ($categories as $category) {
267
+			$options[absint($category->term_id)] = esc_html($category->name);
268 268
 		}
269 269
 
270
-		$output = $this->select( array(
270
+		$output = $this->select(array(
271 271
 			'name'             => $name,
272 272
 			'selected'         => $selected,
273 273
 			'options'          => $options,
274
-			'show_option_all'  => esc_html__( 'All Categories', 'give' ),
274
+			'show_option_all'  => esc_html__('All Categories', 'give'),
275 275
 			'show_option_none' => false
276
-		) );
276
+		));
277 277
 
278 278
 		return $output;
279 279
 	}
@@ -293,25 +293,25 @@  discard block
 block discarded – undo
293 293
 	 *
294 294
 	 * @return string               Years dropdown.
295 295
 	 */
296
-	public function year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
297
-		$current    = date( 'Y' );
298
-		$start_year = $current - absint( $years_before );
299
-		$end_year   = $current + absint( $years_after );
300
-		$selected   = empty( $selected ) ? date( 'Y' ) : $selected;
296
+	public function year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) {
297
+		$current    = date('Y');
298
+		$start_year = $current - absint($years_before);
299
+		$end_year   = $current + absint($years_after);
300
+		$selected   = empty($selected) ? date('Y') : $selected;
301 301
 		$options    = array();
302 302
 
303
-		while ( $start_year <= $end_year ) {
304
-			$options[ absint( $start_year ) ] = $start_year;
305
-			$start_year ++;
303
+		while ($start_year <= $end_year) {
304
+			$options[absint($start_year)] = $start_year;
305
+			$start_year++;
306 306
 		}
307 307
 
308
-		$output = $this->select( array(
308
+		$output = $this->select(array(
309 309
 			'name'             => $name,
310 310
 			'selected'         => $selected,
311 311
 			'options'          => $options,
312 312
 			'show_option_all'  => false,
313 313
 			'show_option_none' => false
314
-		) );
314
+		));
315 315
 
316 316
 		return $output;
317 317
 	}
@@ -329,23 +329,23 @@  discard block
 block discarded – undo
329 329
 	 *
330 330
 	 * @return string           Months dropdown.
331 331
 	 */
332
-	public function month_dropdown( $name = 'month', $selected = 0 ) {
332
+	public function month_dropdown($name = 'month', $selected = 0) {
333 333
 		$month    = 1;
334 334
 		$options  = array();
335
-		$selected = empty( $selected ) ? date( 'n' ) : $selected;
335
+		$selected = empty($selected) ? date('n') : $selected;
336 336
 
337
-		while ( $month <= 12 ) {
338
-			$options[ absint( $month ) ] = give_month_num_to_name( $month );
339
-			$month ++;
337
+		while ($month <= 12) {
338
+			$options[absint($month)] = give_month_num_to_name($month);
339
+			$month++;
340 340
 		}
341 341
 
342
-		$output = $this->select( array(
342
+		$output = $this->select(array(
343 343
 			'name'             => $name,
344 344
 			'selected'         => $selected,
345 345
 			'options'          => $options,
346 346
 			'show_option_all'  => false,
347 347
 			'show_option_none' => false
348
-		) );
348
+		));
349 349
 
350 350
 		return $output;
351 351
 	}
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 	 *
363 363
 	 * @return string      The dropdown.
364 364
 	 */
365
-	public function select( $args = array() ) {
365
+	public function select($args = array()) {
366 366
 		$defaults = array(
367 367
 			'options'          => array(),
368 368
 			'name'             => null,
@@ -373,60 +373,60 @@  discard block
 block discarded – undo
373 373
 			'placeholder'      => null,
374 374
 			'multiple'         => false,
375 375
 			'select_atts'      => false,
376
-			'show_option_all'  => esc_html__( 'All', 'give' ),
377
-			'show_option_none' => esc_html__( 'None', 'give' )
376
+			'show_option_all'  => esc_html__('All', 'give'),
377
+			'show_option_none' => esc_html__('None', 'give')
378 378
 		);
379 379
 
380
-		$args = wp_parse_args( $args, $defaults );
380
+		$args = wp_parse_args($args, $defaults);
381 381
 
382
-		if ( $args['multiple'] ) {
382
+		if ($args['multiple']) {
383 383
 			$multiple = ' MULTIPLE';
384 384
 		} else {
385 385
 			$multiple = '';
386 386
 		}
387 387
 
388
-		if ( $args['chosen'] ) {
388
+		if ($args['chosen']) {
389 389
 			$args['class'] .= ' give-select-chosen';
390 390
 		}
391 391
 
392
-		if ( $args['placeholder'] ) {
392
+		if ($args['placeholder']) {
393 393
 			$placeholder = $args['placeholder'];
394 394
 		} else {
395 395
 			$placeholder = '';
396 396
 		}
397 397
 
398 398
 
399
-		$output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( sanitize_key( str_replace( '-', '_', $args['id'] ) ) ) . '" class="give-select ' . esc_attr( $args['class'] ) . '"' . $multiple . ' ' . $args['select_atts'] . ' data-placeholder="' . $placeholder . '">';
399
+		$output = '<select name="'.esc_attr($args['name']).'" id="'.esc_attr(sanitize_key(str_replace('-', '_', $args['id']))).'" class="give-select '.esc_attr($args['class']).'"'.$multiple.' '.$args['select_atts'].' data-placeholder="'.$placeholder.'">';
400 400
 
401
-		if ( $args['show_option_all'] ) {
402
-			if ( $args['multiple'] ) {
403
-				$selected = selected( true, in_array( 0, $args['selected'] ), false );
401
+		if ($args['show_option_all']) {
402
+			if ($args['multiple']) {
403
+				$selected = selected(true, in_array(0, $args['selected']), false);
404 404
 			} else {
405
-				$selected = selected( $args['selected'], 0, false );
405
+				$selected = selected($args['selected'], 0, false);
406 406
 			}
407
-			$output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
407
+			$output .= '<option value="all"'.$selected.'>'.esc_html($args['show_option_all']).'</option>';
408 408
 		}
409 409
 
410
-		if ( ! empty( $args['options'] ) ) {
410
+		if ( ! empty($args['options'])) {
411 411
 
412
-			if ( $args['show_option_none'] ) {
413
-				if ( $args['multiple'] ) {
414
-					$selected = selected( true, in_array( - 1, $args['selected'] ), false );
412
+			if ($args['show_option_none']) {
413
+				if ($args['multiple']) {
414
+					$selected = selected(true, in_array( -1, $args['selected'] ), false);
415 415
 				} else {
416
-					$selected = selected( $args['selected'], - 1, false );
416
+					$selected = selected($args['selected'], - 1, false);
417 417
 				}
418
-				$output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
418
+				$output .= '<option value="-1"'.$selected.'>'.esc_html($args['show_option_none']).'</option>';
419 419
 			}
420 420
 
421
-			foreach ( $args['options'] as $key => $option ) {
421
+			foreach ($args['options'] as $key => $option) {
422 422
 
423
-				if ( $args['multiple'] && is_array( $args['selected'] ) ) {
424
-					$selected = selected( true, in_array( $key, $args['selected'] ), false );
423
+				if ($args['multiple'] && is_array($args['selected'])) {
424
+					$selected = selected(true, in_array($key, $args['selected']), false);
425 425
 				} else {
426
-					$selected = selected( $args['selected'], $key, false );
426
+					$selected = selected($args['selected'], $key, false);
427 427
 				}
428 428
 
429
-				$output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
429
+				$output .= '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option).'</option>';
430 430
 			}
431 431
 		}
432 432
 
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 	 *
448 448
 	 * @return string      The checkbox.
449 449
 	 */
450
-	public function checkbox( $args = array() ) {
450
+	public function checkbox($args = array()) {
451 451
 		$defaults = array(
452 452
 			'name'    => null,
453 453
 			'current' => null,
@@ -458,16 +458,16 @@  discard block
 block discarded – undo
458 458
 			)
459 459
 		);
460 460
 
461
-		$args = wp_parse_args( $args, $defaults );
461
+		$args = wp_parse_args($args, $defaults);
462 462
 
463 463
 		$options = '';
464
-		if ( ! empty( $args['options']['disabled'] ) ) {
464
+		if ( ! empty($args['options']['disabled'])) {
465 465
 			$options .= ' disabled="disabled"';
466
-		} elseif ( ! empty( $args['options']['readonly'] ) ) {
466
+		} elseif ( ! empty($args['options']['readonly'])) {
467 467
 			$options .= ' readonly';
468 468
 		}
469 469
 
470
-		$output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />';
470
+		$output = '<input type="checkbox"'.$options.' name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].' '.esc_attr($args['name']).'" '.checked(1, $args['current'], false).' />';
471 471
 
472 472
 		return $output;
473 473
 	}
@@ -484,22 +484,22 @@  discard block
 block discarded – undo
484 484
 	 *
485 485
 	 * @return string      The text field.
486 486
 	 */
487
-	public function text( $args = array() ) {
487
+	public function text($args = array()) {
488 488
 		// Backwards compatibility
489
-		if ( func_num_args() > 1 ) {
489
+		if (func_num_args() > 1) {
490 490
 			$args = func_get_args();
491 491
 
492 492
 			$name  = $args[0];
493
-			$value = isset( $args[1] ) ? $args[1] : '';
494
-			$label = isset( $args[2] ) ? $args[2] : '';
495
-			$desc  = isset( $args[3] ) ? $args[3] : '';
493
+			$value = isset($args[1]) ? $args[1] : '';
494
+			$label = isset($args[2]) ? $args[2] : '';
495
+			$desc  = isset($args[3]) ? $args[3] : '';
496 496
 		}
497 497
 
498 498
 		$defaults = array(
499
-			'name'         => isset( $name ) ? $name : 'text',
500
-			'value'        => isset( $value ) ? $value : null,
501
-			'label'        => isset( $label ) ? $label : null,
502
-			'desc'         => isset( $desc ) ? $desc : null,
499
+			'name'         => isset($name) ? $name : 'text',
500
+			'value'        => isset($value) ? $value : null,
501
+			'label'        => isset($label) ? $label : null,
502
+			'desc'         => isset($desc) ? $desc : null,
503 503
 			'placeholder'  => '',
504 504
 			'class'        => 'regular-text',
505 505
 			'disabled'     => false,
@@ -507,29 +507,29 @@  discard block
 block discarded – undo
507 507
 			'data'         => false
508 508
 		);
509 509
 
510
-		$args = wp_parse_args( $args, $defaults );
510
+		$args = wp_parse_args($args, $defaults);
511 511
 
512 512
 		$disabled = '';
513
-		if ( $args['disabled'] ) {
513
+		if ($args['disabled']) {
514 514
 			$disabled = ' disabled="disabled"';
515 515
 		}
516 516
 
517 517
 		$data = '';
518
-		if ( ! empty( $args['data'] ) ) {
519
-			foreach ( $args['data'] as $key => $value ) {
520
-				$data .= 'data-' . $key . '="' . $value . '" ';
518
+		if ( ! empty($args['data'])) {
519
+			foreach ($args['data'] as $key => $value) {
520
+				$data .= 'data-'.$key.'="'.$value.'" ';
521 521
 			}
522 522
 		}
523 523
 
524
-		$output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">';
524
+		$output = '<span id="give-'.sanitize_key($args['name']).'-wrap">';
525 525
 
526
-		$output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
526
+		$output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>';
527 527
 
528
-		if ( ! empty( $args['desc'] ) ) {
529
-			$output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>';
528
+		if ( ! empty($args['desc'])) {
529
+			$output .= '<span class="give-description">'.esc_html($args['desc']).'</span>';
530 530
 		}
531 531
 
532
-		$output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $args['class'] . '" ' . $data . '' . $disabled . '/>';
532
+		$output .= '<input type="text" name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" autocomplete="'.esc_attr($args['autocomplete']).'" value="'.esc_attr($args['value']).'" placeholder="'.esc_attr($args['placeholder']).'" class="'.$args['class'].'" '.$data.''.$disabled.'/>';
533 533
 
534 534
 		$output .= '</span>';
535 535
 
@@ -548,15 +548,15 @@  discard block
 block discarded – undo
548 548
 	 *
549 549
 	 * @return string      The date picker.
550 550
 	 */
551
-	public function date_field( $args = array() ) {
551
+	public function date_field($args = array()) {
552 552
 
553
-		if ( empty( $args['class'] ) ) {
553
+		if (empty($args['class'])) {
554 554
 			$args['class'] = 'give_datepicker';
555
-		} elseif ( ! strpos( $args['class'], 'give_datepicker' ) ) {
555
+		} elseif ( ! strpos($args['class'], 'give_datepicker')) {
556 556
 			$args['class'] .= ' give_datepicker';
557 557
 		}
558 558
 
559
-		return $this->text( $args );
559
+		return $this->text($args);
560 560
 	}
561 561
 
562 562
 	/**
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 	 *
572 572
 	 * @return string      The textarea.
573 573
 	 */
574
-	public function textarea( $args = array() ) {
574
+	public function textarea($args = array()) {
575 575
 		$defaults = array(
576 576
 			'name'     => 'textarea',
577 577
 			'value'    => null,
@@ -581,21 +581,21 @@  discard block
 block discarded – undo
581 581
 			'disabled' => false
582 582
 		);
583 583
 
584
-		$args = wp_parse_args( $args, $defaults );
584
+		$args = wp_parse_args($args, $defaults);
585 585
 
586 586
 		$disabled = '';
587
-		if ( $args['disabled'] ) {
587
+		if ($args['disabled']) {
588 588
 			$disabled = ' disabled="disabled"';
589 589
 		}
590 590
 
591
-		$output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">';
591
+		$output = '<span id="give-'.sanitize_key($args['name']).'-wrap">';
592 592
 
593
-		$output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
593
+		$output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>';
594 594
 
595
-		$output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
595
+		$output .= '<textarea name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].'"'.$disabled.'>'.esc_attr($args['value']).'</textarea>';
596 596
 
597
-		if ( ! empty( $args['desc'] ) ) {
598
-			$output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>';
597
+		if ( ! empty($args['desc'])) {
598
+			$output .= '<span class="give-description">'.esc_html($args['desc']).'</span>';
599 599
 		}
600 600
 
601 601
 		$output .= '</span>';
@@ -615,12 +615,12 @@  discard block
 block discarded – undo
615 615
 	 *
616 616
 	 * @return string      The text field with ajax search.
617 617
 	 */
618
-	public function ajax_user_search( $args = array() ) {
618
+	public function ajax_user_search($args = array()) {
619 619
 
620 620
 		$defaults = array(
621 621
 			'name'         => 'user_id',
622 622
 			'value'        => null,
623
-			'placeholder'  => esc_attr__( 'Enter username', 'give' ),
623
+			'placeholder'  => esc_attr__('Enter username', 'give'),
624 624
 			'label'        => null,
625 625
 			'desc'         => null,
626 626
 			'class'        => '',
@@ -629,13 +629,13 @@  discard block
 block discarded – undo
629 629
 			'data'         => false
630 630
 		);
631 631
 
632
-		$args = wp_parse_args( $args, $defaults );
632
+		$args = wp_parse_args($args, $defaults);
633 633
 
634
-		$args['class'] = 'give-ajax-user-search ' . $args['class'];
634
+		$args['class'] = 'give-ajax-user-search '.$args['class'];
635 635
 
636 636
 		$output = '<span class="give_user_search_wrap">';
637
-		$output .= $this->text( $args );
638
-		$output .= '<span class="give_user_search_results hidden"><a class="give-ajax-user-cancel" aria-label="' . esc_attr__( 'Cancel', 'give' ) . '" href="#">x</a><span></span></span>';
637
+		$output .= $this->text($args);
638
+		$output .= '<span class="give_user_search_results hidden"><a class="give-ajax-user-cancel" aria-label="'.esc_attr__('Cancel', 'give').'" href="#">x</a><span></span></span>';
639 639
 		$output .= '</span>';
640 640
 
641 641
 		return $output;
Please login to merge, or discard this patch.
includes/template-functions.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -45,22 +45,22 @@  discard block
 block discarded – undo
45 45
  * @param string $default_path  Default path. Default is empty.
46 46
  */
47 47
 function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
48
-    if ( ! empty( $args ) && is_array( $args ) ) {
49
-        extract( $args );
50
-    }
48
+	if ( ! empty( $args ) && is_array( $args ) ) {
49
+		extract( $args );
50
+	}
51 51
 
52
-    $template_names = array( $template_name . '.php' );
52
+	$template_names = array( $template_name . '.php' );
53 53
 
54
-    $located = give_locate_template( $template_names, $template_path, $default_path );
54
+	$located = give_locate_template( $template_names, $template_path, $default_path );
55 55
 
56
-    if ( ! file_exists( $located ) ) {
56
+	if ( ! file_exists( $located ) ) {
57 57
 		/* translators: %s: the template */
58
-        give_output_error( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true );
59
-        return;
60
-    }
58
+		give_output_error( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true );
59
+		return;
60
+	}
61 61
 
62
-    // Allow 3rd party plugin filter template file from their plugin.
63
-    $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path );
62
+	// Allow 3rd party plugin filter template file from their plugin.
63
+	$located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path );
64 64
 
65 65
 	/**
66 66
 	 * Fires in give template, before the file is included.
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 	 * @param string $located       Template file filter by 3rd party plugin.
75 75
 	 * @param array  $args          Passed arguments.
76 76
 	 */
77
-    do_action( 'give_before_template_part', $template_name, $template_path, $located, $args );
77
+	do_action( 'give_before_template_part', $template_name, $template_path, $located, $args );
78 78
 
79
-    include( $located );
79
+	include( $located );
80 80
 
81 81
 	/**
82 82
 	 * Fires in give template, after the file is included.
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 * @param string $located       Template file filter by 3rd party plugin.
91 91
 	 * @param array  $args          Passed arguments.
92 92
 	 */
93
-    do_action( 'give_after_template_part', $template_name, $template_path, $located, $args );
93
+	do_action( 'give_after_template_part', $template_name, $template_path, $located, $args );
94 94
 }
95 95
 
96 96
 /**
Please login to merge, or discard this patch.
Spacing   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  * @return string
22 22
  */
23 23
 function give_get_templates_dir() {
24
-	return GIVE_PLUGIN_DIR . 'templates';
24
+	return GIVE_PLUGIN_DIR.'templates';
25 25
 }
26 26
 
27 27
 /**
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
  * @return string
32 32
  */
33 33
 function give_get_templates_url() {
34
-	return GIVE_PLUGIN_URL . 'templates';
34
+	return GIVE_PLUGIN_URL.'templates';
35 35
 }
36 36
 
37 37
 /**
@@ -44,23 +44,23 @@  discard block
 block discarded – undo
44 44
  * @param string $template_path Template file path. Default is empty.
45 45
  * @param string $default_path  Default path. Default is empty.
46 46
  */
47
-function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
48
-    if ( ! empty( $args ) && is_array( $args ) ) {
49
-        extract( $args );
47
+function give_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
48
+    if ( ! empty($args) && is_array($args)) {
49
+        extract($args);
50 50
     }
51 51
 
52
-    $template_names = array( $template_name . '.php' );
52
+    $template_names = array($template_name.'.php');
53 53
 
54
-    $located = give_locate_template( $template_names, $template_path, $default_path );
54
+    $located = give_locate_template($template_names, $template_path, $default_path);
55 55
 
56
-    if ( ! file_exists( $located ) ) {
56
+    if ( ! file_exists($located)) {
57 57
 		/* translators: %s: the template */
58
-        give_output_error( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true );
58
+        give_output_error(sprintf(__('The %s template was not found.', 'give'), $located), true);
59 59
         return;
60 60
     }
61 61
 
62 62
     // Allow 3rd party plugin filter template file from their plugin.
63
-    $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path );
63
+    $located = apply_filters('give_get_template', $located, $template_name, $args, $template_path, $default_path);
64 64
 
65 65
 	/**
66 66
 	 * Fires in give template, before the file is included.
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 	 * @param string $located       Template file filter by 3rd party plugin.
75 75
 	 * @param array  $args          Passed arguments.
76 76
 	 */
77
-    do_action( 'give_before_template_part', $template_name, $template_path, $located, $args );
77
+    do_action('give_before_template_part', $template_name, $template_path, $located, $args);
78 78
 
79
-    include( $located );
79
+    include($located);
80 80
 
81 81
 	/**
82 82
 	 * Fires in give template, after the file is included.
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 * @param string $located       Template file filter by 3rd party plugin.
91 91
 	 * @param array  $args          Passed arguments.
92 92
 	 */
93
-    do_action( 'give_after_template_part', $template_name, $template_path, $located, $args );
93
+    do_action('give_after_template_part', $template_name, $template_path, $located, $args);
94 94
 }
95 95
 
96 96
 /**
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
  *
107 107
  * @return string 
108 108
  */
109
-function give_get_template_part( $slug, $name = null, $load = true ) {
109
+function give_get_template_part($slug, $name = null, $load = true) {
110 110
 
111 111
 	/**
112 112
 	 * Fires in give template part, before the template part is retrieved.
@@ -118,20 +118,20 @@  discard block
 block discarded – undo
118 118
 	 * @param string $slug Template part file slug {slug}.php.
119 119
 	 * @param string $name Template part file name {slug}-{name}.php.
120 120
 	 */
121
-	do_action( 'get_template_part_' . $slug, $slug, $name );
121
+	do_action('get_template_part_'.$slug, $slug, $name);
122 122
 
123 123
 	// Setup possible parts
124 124
 	$templates = array();
125
-	if ( isset( $name ) ) {
126
-		$templates[] = $slug . '-' . $name . '.php';
125
+	if (isset($name)) {
126
+		$templates[] = $slug.'-'.$name.'.php';
127 127
 	}
128
-	$templates[] = $slug . '.php';
128
+	$templates[] = $slug.'.php';
129 129
 
130 130
 	// Allow template parts to be filtered
131
-	$templates = apply_filters( 'give_get_template_part', $templates, $slug, $name );
131
+	$templates = apply_filters('give_get_template_part', $templates, $slug, $name);
132 132
 
133 133
 	// Return the part that is found
134
-	return give_locate_template( $templates, $load, false );
134
+	return give_locate_template($templates, $load, false);
135 135
 }
136 136
 
137 137
 /**
@@ -152,37 +152,37 @@  discard block
 block discarded – undo
152 152
  *
153 153
  * @return string The template filename if one is located.
154 154
  */
155
-function give_locate_template( $template_names, $load = false, $require_once = true ) {
155
+function give_locate_template($template_names, $load = false, $require_once = true) {
156 156
 	// No file found yet
157 157
 	$located = false;
158 158
 
159 159
 	// Try to find a template file
160
-	foreach ( (array) $template_names as $template_name ) {
160
+	foreach ((array) $template_names as $template_name) {
161 161
 
162 162
 		// Continue if template is empty
163
-		if ( empty( $template_name ) ) {
163
+		if (empty($template_name)) {
164 164
 			continue;
165 165
 		}
166 166
 
167 167
 		// Trim off any slashes from the template name
168
-		$template_name = ltrim( $template_name, '/' );
168
+		$template_name = ltrim($template_name, '/');
169 169
 
170 170
 		// try locating this template file by looping through the template paths
171
-		foreach ( give_get_theme_template_paths() as $template_path ) {
171
+		foreach (give_get_theme_template_paths() as $template_path) {
172 172
 
173
-			if ( file_exists( $template_path . $template_name ) ) {
174
-				$located = $template_path . $template_name;
173
+			if (file_exists($template_path.$template_name)) {
174
+				$located = $template_path.$template_name;
175 175
 				break;
176 176
 			}
177 177
 		}
178 178
 
179
-		if ( $located ) {
179
+		if ($located) {
180 180
 			break;
181 181
 		}
182 182
 	}
183 183
 
184
-	if ( ( true == $load ) && ! empty( $located ) ) {
185
-		load_template( $located, $require_once );
184
+	if ((true == $load) && ! empty($located)) {
185
+		load_template($located, $require_once);
186 186
 	}
187 187
 
188 188
 	return $located;
@@ -199,17 +199,17 @@  discard block
 block discarded – undo
199 199
 	$template_dir = give_get_theme_template_dir_name();
200 200
 
201 201
 	$file_paths = array(
202
-		1   => trailingslashit( get_stylesheet_directory() ) . $template_dir,
203
-		10  => trailingslashit( get_template_directory() ) . $template_dir,
202
+		1   => trailingslashit(get_stylesheet_directory()).$template_dir,
203
+		10  => trailingslashit(get_template_directory()).$template_dir,
204 204
 		100 => give_get_templates_dir()
205 205
 	);
206 206
 
207
-	$file_paths = apply_filters( 'give_template_paths', $file_paths );
207
+	$file_paths = apply_filters('give_template_paths', $file_paths);
208 208
 
209 209
 	// sort the file paths based on priority
210
-	ksort( $file_paths, SORT_NUMERIC );
210
+	ksort($file_paths, SORT_NUMERIC);
211 211
 
212
-	return array_map( 'trailingslashit', $file_paths );
212
+	return array_map('trailingslashit', $file_paths);
213 213
 }
214 214
 
215 215
 /**
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
  * @return string
222 222
  */
223 223
 function give_get_theme_template_dir_name() {
224
-	return trailingslashit( apply_filters( 'give_templates_dir', 'give' ) );
224
+	return trailingslashit(apply_filters('give_templates_dir', 'give'));
225 225
 }
226 226
 
227 227
 /**
@@ -231,10 +231,10 @@  discard block
 block discarded – undo
231 231
  * @return void
232 232
  */
233 233
 function give_version_in_header() {
234
-	echo '<meta name="generator" content="Give v' . GIVE_VERSION . '" />' . "\n";
234
+	echo '<meta name="generator" content="Give v'.GIVE_VERSION.'" />'."\n";
235 235
 }
236 236
 
237
-add_action( 'wp_head', 'give_version_in_header' );
237
+add_action('wp_head', 'give_version_in_header');
238 238
 
239 239
 /**
240 240
  * Determines if we're currently on the Donations History page.
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
  */
245 245
 function give_is_donation_history_page() {
246 246
 
247
-	$ret = is_page( give_get_option( 'history_page' ) );
247
+	$ret = is_page(give_get_option('history_page'));
248 248
 
249
-	return apply_filters( 'give_is_donation_history_page', $ret );
249
+	return apply_filters('give_is_donation_history_page', $ret);
250 250
 }
251 251
 
252 252
 /**
@@ -258,25 +258,25 @@  discard block
 block discarded – undo
258 258
  *
259 259
  * @return array Modified array of classes
260 260
  */
261
-function give_add_body_classes( $class ) {
261
+function give_add_body_classes($class) {
262 262
 	$classes = (array) $class;
263 263
 
264
-	if ( give_is_success_page() ) {
264
+	if (give_is_success_page()) {
265 265
 		$classes[] = 'give-success';
266 266
 		$classes[] = 'give-page';
267 267
 	}
268 268
 
269
-	if ( give_is_failed_transaction_page() ) {
269
+	if (give_is_failed_transaction_page()) {
270 270
 		$classes[] = 'give-failed-transaction';
271 271
 		$classes[] = 'give-page';
272 272
 	}
273 273
 
274
-	if ( give_is_donation_history_page() ) {
274
+	if (give_is_donation_history_page()) {
275 275
 		$classes[] = 'give-donation-history';
276 276
 		$classes[] = 'give-page';
277 277
 	}
278 278
 
279
-	if ( give_is_test_mode() ) {
279
+	if (give_is_test_mode()) {
280 280
 		$classes[] = 'give-test-mode';
281 281
 		$classes[] = 'give-page';
282 282
 	}
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	//Theme-specific Classes used to prevent conflicts via CSS
285 285
 	$current_theme = wp_get_theme();
286 286
 
287
-	switch ( $current_theme->template ) {
287
+	switch ($current_theme->template) {
288 288
 
289 289
 		case 'Divi':
290 290
 			$classes[] = 'give-divi';
@@ -298,10 +298,10 @@  discard block
 block discarded – undo
298 298
 
299 299
 	}
300 300
 
301
-	return array_unique( $classes );
301
+	return array_unique($classes);
302 302
 }
303 303
 
304
-add_filter( 'body_class', 'give_add_body_classes' );
304
+add_filter('body_class', 'give_add_body_classes');
305 305
 
306 306
 
307 307
 /**
@@ -317,22 +317,22 @@  discard block
 block discarded – undo
317 317
  *
318 318
  * @return array
319 319
  */
320
-function give_add_post_class( $classes, $class = '', $post_id = '' ) {
321
-	if ( ! $post_id || 'give_forms' !== get_post_type( $post_id ) ) {
320
+function give_add_post_class($classes, $class = '', $post_id = '') {
321
+	if ( ! $post_id || 'give_forms' !== get_post_type($post_id)) {
322 322
 		return $classes;
323 323
 	}
324 324
 
325 325
 	//@TODO: Add classes for custom taxonomy and form configurations (multi vs single donations, etc).
326 326
 
327
-	if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) {
328
-		unset( $classes[ $key ] );
327
+	if (false !== ($key = array_search('hentry', $classes))) {
328
+		unset($classes[$key]);
329 329
 	}
330 330
 
331 331
 	return $classes;
332 332
 }
333 333
 
334 334
 
335
-add_filter( 'post_class', 'give_add_post_class', 20, 3 );
335
+add_filter('post_class', 'give_add_post_class', 20, 3);
336 336
 
337 337
 /**
338 338
  * Get the placeholder image URL for forms etc
@@ -342,85 +342,85 @@  discard block
 block discarded – undo
342 342
  */
343 343
 function give_get_placeholder_img_src() {
344 344
 
345
-	$placeholder_url = '//placehold.it/600x600&text=' . urlencode( esc_attr__( 'Give Placeholder Image', 'give' ) );
345
+	$placeholder_url = '//placehold.it/600x600&text='.urlencode(esc_attr__('Give Placeholder Image', 'give'));
346 346
 
347
-	return apply_filters( 'give_placeholder_img_src', $placeholder_url );
347
+	return apply_filters('give_placeholder_img_src', $placeholder_url);
348 348
 }
349 349
 
350 350
 
351 351
 /**
352 352
  * Global
353 353
  */
354
-if ( ! function_exists( 'give_output_content_wrapper' ) ) {
354
+if ( ! function_exists('give_output_content_wrapper')) {
355 355
 
356 356
 	/**
357 357
 	 * Output the start of the page wrapper.
358 358
 	 */
359 359
 	function give_output_content_wrapper() {
360
-		give_get_template_part( 'global/wrapper-start' );
360
+		give_get_template_part('global/wrapper-start');
361 361
 	}
362 362
 }
363
-if ( ! function_exists( 'give_output_content_wrapper_end' ) ) {
363
+if ( ! function_exists('give_output_content_wrapper_end')) {
364 364
 
365 365
 	/**
366 366
 	 * Output the end of the page wrapper.
367 367
 	 */
368 368
 	function give_output_content_wrapper_end() {
369
-		give_get_template_part( 'global/wrapper-end' );
369
+		give_get_template_part('global/wrapper-end');
370 370
 	}
371 371
 }
372 372
 
373 373
 /**
374 374
  * Single Give Form
375 375
  */
376
-if ( ! function_exists( 'give_left_sidebar_pre_wrap' ) ) {
376
+if ( ! function_exists('give_left_sidebar_pre_wrap')) {
377 377
 	function give_left_sidebar_pre_wrap() {
378
-		echo apply_filters( 'give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">' );
378
+		echo apply_filters('give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">');
379 379
 	}
380 380
 }
381 381
 
382
-if ( ! function_exists( 'give_left_sidebar_post_wrap' ) ) {
382
+if ( ! function_exists('give_left_sidebar_post_wrap')) {
383 383
 	function give_left_sidebar_post_wrap() {
384
-		echo apply_filters( 'give_left_sidebar_post_wrap', '</div>' );
384
+		echo apply_filters('give_left_sidebar_post_wrap', '</div>');
385 385
 	}
386 386
 }
387 387
 
388
-if ( ! function_exists( 'give_get_forms_sidebar' ) ) {
388
+if ( ! function_exists('give_get_forms_sidebar')) {
389 389
 	function give_get_forms_sidebar() {
390
-		give_get_template_part( 'single-give-form/sidebar' );
390
+		give_get_template_part('single-give-form/sidebar');
391 391
 	}
392 392
 }
393 393
 
394
-if ( ! function_exists( 'give_show_form_images' ) ) {
394
+if ( ! function_exists('give_show_form_images')) {
395 395
 
396 396
 	/**
397 397
 	 * Output the product image before the single product summary.
398 398
 	 */
399 399
 	function give_show_form_images() {
400
-		$featured_image_option = give_get_option( 'disable_form_featured_img' );
401
-		if ( $featured_image_option !== 'on' ) {
402
-			give_get_template_part( 'single-give-form/featured-image' );
400
+		$featured_image_option = give_get_option('disable_form_featured_img');
401
+		if ($featured_image_option !== 'on') {
402
+			give_get_template_part('single-give-form/featured-image');
403 403
 		}
404 404
 	}
405 405
 }
406 406
 
407
-if ( ! function_exists( 'give_template_single_title' ) ) {
407
+if ( ! function_exists('give_template_single_title')) {
408 408
 
409 409
 	/**
410 410
 	 * Output the product title.
411 411
 	 */
412 412
 	function give_template_single_title() {
413
-		give_get_template_part( 'single-give-form/title' );
413
+		give_get_template_part('single-give-form/title');
414 414
 	}
415 415
 }
416 416
 
417
-if ( ! function_exists( 'give_show_avatars' ) ) {
417
+if ( ! function_exists('give_show_avatars')) {
418 418
 
419 419
 	/**
420 420
 	 * Output the product title.
421 421
 	 */
422 422
 	function give_show_avatars() {
423
-		echo do_shortcode( '[give_donators_gravatars]' );
423
+		echo do_shortcode('[give_donators_gravatars]');
424 424
 	}
425 425
 }
426 426
 
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
  * Conditional Functions
429 429
  */
430 430
 
431
-if ( ! function_exists( 'is_give_form' ) ) {
431
+if ( ! function_exists('is_give_form')) {
432 432
 
433 433
 	/**
434 434
 	 * is_give_form
@@ -440,11 +440,11 @@  discard block
 block discarded – undo
440 440
 	 * @return bool
441 441
 	 */
442 442
 	function is_give_form() {
443
-		return is_singular( array( 'give_form' ) );
443
+		return is_singular(array('give_form'));
444 444
 	}
445 445
 }
446 446
 
447
-if ( ! function_exists( 'is_give_category' ) ) {
447
+if ( ! function_exists('is_give_category')) {
448 448
 
449 449
 	/**
450 450
 	 * is_give_category
@@ -459,12 +459,12 @@  discard block
 block discarded – undo
459 459
 	 *
460 460
 	 * @return bool
461 461
 	 */
462
-	function is_give_category( $term = '' ) {
463
-		return is_tax( 'give_forms_category', $term );
462
+	function is_give_category($term = '') {
463
+		return is_tax('give_forms_category', $term);
464 464
 	}
465 465
 }
466 466
 
467
-if ( ! function_exists( 'is_give_tag' ) ) {
467
+if ( ! function_exists('is_give_tag')) {
468 468
 
469 469
 	/**
470 470
 	 * is_give_tag
@@ -479,12 +479,12 @@  discard block
 block discarded – undo
479 479
 	 *
480 480
 	 * @return bool
481 481
 	 */
482
-	function is_give_tag( $term = '' ) {
483
-		return is_tax( 'give_forms_tag', $term );
482
+	function is_give_tag($term = '') {
483
+		return is_tax('give_forms_tag', $term);
484 484
 	}
485 485
 }
486 486
 
487
-if ( ! function_exists( 'is_give_taxonomy' ) ) {
487
+if ( ! function_exists('is_give_taxonomy')) {
488 488
 
489 489
 	/**
490 490
 	 * is_give_taxonomy
@@ -496,6 +496,6 @@  discard block
 block discarded – undo
496 496
 	 * @return bool
497 497
 	 */
498 498
 	function is_give_taxonomy() {
499
-		return is_tax( get_object_taxonomies( 'give_form' ) );
499
+		return is_tax(get_object_taxonomies('give_form'));
500 500
 	}
501 501
 }
Please login to merge, or discard this patch.
includes/class-give-email-access.php 1 patch
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	public function __construct() {
99 99
 
100 100
 		// get it started
101
-		add_action( 'init', array( $this, 'init' ) );
101
+		add_action('init', array($this, 'init'));
102 102
 	}
103 103
 
104 104
 	/**
@@ -113,30 +113,30 @@  discard block
 block discarded – undo
113 113
 	 */
114 114
 	public function init() {
115 115
 
116
-		$is_enabled = give_get_option( 'email_access' );
116
+		$is_enabled = give_get_option('email_access');
117 117
 
118 118
 		//Non-logged in users only
119
-		if ( is_user_logged_in() || $is_enabled !== 'on' || is_admin() ) {
119
+		if (is_user_logged_in() || $is_enabled !== 'on' || is_admin()) {
120 120
 			return;
121 121
 		}
122 122
 
123 123
 		//Are db columns setup?
124
-		$is_setup = give_get_option( 'email_access_installed' );
125
-		if ( empty( $is_setup ) ) {
124
+		$is_setup = give_get_option('email_access_installed');
125
+		if (empty($is_setup)) {
126 126
 			$this->create_columns();
127 127
 		}
128 128
 
129 129
 		// Timeouts
130
-		$this->verify_throttle  = apply_filters( 'give_nl_verify_throttle', 300 );
131
-		$this->token_expiration = apply_filters( 'give_nl_token_expiration', 7200 );
130
+		$this->verify_throttle  = apply_filters('give_nl_verify_throttle', 300);
131
+		$this->token_expiration = apply_filters('give_nl_token_expiration', 7200);
132 132
 
133 133
 		// Setup login
134 134
 		$this->check_for_token();
135 135
 
136
-		if ( $this->token_exists ) {
137
-			add_filter( 'give_can_view_receipt', '__return_true' );
138
-			add_filter( 'give_user_pending_verification', '__return_false' );
139
-			add_filter( 'give_get_users_purchases_args', array( $this, 'users_purchases_args' ) );
136
+		if ($this->token_exists) {
137
+			add_filter('give_can_view_receipt', '__return_true');
138
+			add_filter('give_user_pending_verification', '__return_false');
139
+			add_filter('give_get_users_purchases_args', array($this, 'users_purchases_args'));
140 140
 		}
141 141
 	}
142 142
 
@@ -150,25 +150,25 @@  discard block
 block discarded – undo
150 150
 	 *
151 151
 	 * @return bool
152 152
 	 */
153
-	public function can_send_email( $customer_id ) {
153
+	public function can_send_email($customer_id) {
154 154
 		/* @var WPDB $wpdb */
155 155
 		global $wpdb;
156 156
 
157 157
 		// Prevent multiple emails within X minutes
158
-		$throttle = date( 'Y-m-d H:i:s', time() - $this->verify_throttle );
158
+		$throttle = date('Y-m-d H:i:s', time() - $this->verify_throttle);
159 159
 
160 160
 		// Does a user row exist?
161 161
 		$exists = (int) $wpdb->get_var(
162
-			$wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id )
162
+			$wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id)
163 163
 		);
164 164
 
165
-		if ( 0 < $exists ) {
165
+		if (0 < $exists) {
166 166
 			$row_id = (int) $wpdb->get_var(
167
-				$wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle )
167
+				$wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle)
168 168
 			);
169 169
 
170
-			if ( $row_id < 1 ) {
171
-				give_set_error( 'give_email_access_attempts_exhausted', esc_html__( 'Please wait a few minutes before requesting a new email access link.', 'give' ) );
170
+			if ($row_id < 1) {
171
+				give_set_error('give_email_access_attempts_exhausted', esc_html__('Please wait a few minutes before requesting a new email access link.', 'give'));
172 172
 
173 173
 				return false;
174 174
 			}
@@ -188,34 +188,34 @@  discard block
 block discarded – undo
188 188
 	 *
189 189
 	 * @return void
190 190
 	 */
191
-	public function send_email( $customer_id, $email ) {
191
+	public function send_email($customer_id, $email) {
192 192
 
193
-		$verify_key = wp_generate_password( 20, false );
193
+		$verify_key = wp_generate_password(20, false);
194 194
 
195 195
 		// Generate a new verify key
196
-		$this->set_verify_key( $customer_id, $email, $verify_key );
196
+		$this->set_verify_key($customer_id, $email, $verify_key);
197 197
 
198 198
 		// Get the purchase history URL
199
-		$page_id = give_get_option( 'history_page' );
199
+		$page_id = give_get_option('history_page');
200 200
 
201
-		$access_url = add_query_arg( array(
201
+		$access_url = add_query_arg(array(
202 202
 			'give_nl' => $verify_key,
203
-		), get_permalink( $page_id ) );
203
+		), get_permalink($page_id));
204 204
 
205 205
 		//Nice subject and message
206
-		$subject = apply_filters( 'give_email_access_token_subject', sprintf( esc_html__( 'Your Access Link to %s', 'give' ), get_bloginfo( 'name' ) ) );
206
+		$subject = apply_filters('give_email_access_token_subject', sprintf(esc_html__('Your Access Link to %s', 'give'), get_bloginfo('name')));
207 207
 
208
-		$message  = esc_html__( 'You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give' ) . "\n\n";
209
-		$message .= '<a href="' . esc_url( $access_url ) . '" target="_blank">' . esc_html__( 'Access My Donation Details &raquo;', 'give' ) . '</a>' . "\n\n";
208
+		$message  = esc_html__('You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give')."\n\n";
209
+		$message .= '<a href="'.esc_url($access_url).'" target="_blank">'.esc_html__('Access My Donation Details &raquo;', 'give').'</a>'."\n\n";
210 210
 		$message .= "\n\n";
211
-		$message .= esc_html__( 'Sincerely,', 'give' ) . "\n";
212
-		$message .= get_bloginfo( 'name' ) . "\n";
211
+		$message .= esc_html__('Sincerely,', 'give')."\n";
212
+		$message .= get_bloginfo('name')."\n";
213 213
 
214
-		$message = apply_filters( 'give_email_access_token_message', $message );
214
+		$message = apply_filters('give_email_access_token_message', $message);
215 215
 
216 216
 		// Send the email
217
-		Give()->emails->__set( 'heading', apply_filters( 'give_email_access_token_heading', esc_html__( 'Your Access Link', 'give' ) ) );
218
-		Give()->emails->send( $email, $subject, $message );
217
+		Give()->emails->__set('heading', apply_filters('give_email_access_token_heading', esc_html__('Your Access Link', 'give')));
218
+		Give()->emails->send($email, $subject, $message);
219 219
 
220 220
 	}
221 221
 
@@ -229,24 +229,24 @@  discard block
 block discarded – undo
229 229
 	 */
230 230
 	public function check_for_token() {
231 231
 
232
-		$token = isset( $_GET['give_nl'] ) ? $_GET['give_nl'] : '';
232
+		$token = isset($_GET['give_nl']) ? $_GET['give_nl'] : '';
233 233
 
234 234
 		// Check for cookie
235
-		if ( empty( $token ) ) {
236
-			$token = isset( $_COOKIE['give_nl'] ) ? $_COOKIE['give_nl'] : '';
235
+		if (empty($token)) {
236
+			$token = isset($_COOKIE['give_nl']) ? $_COOKIE['give_nl'] : '';
237 237
 		}
238 238
 
239
-		if ( ! empty( $token ) ) {
240
-			if ( ! $this->is_valid_token( $token ) ) {
241
-				if ( ! $this->is_valid_verify_key( $token ) ) {
239
+		if ( ! empty($token)) {
240
+			if ( ! $this->is_valid_token($token)) {
241
+				if ( ! $this->is_valid_verify_key($token)) {
242 242
 					return;
243 243
 				}
244 244
 			}
245 245
 
246 246
 			$this->token_exists = true;
247 247
 			// Set cookie
248
-			$lifetime = current_time( 'timestamp' ) + Give()->session->set_expiration_time();
249
-			@setcookie( 'give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false );
248
+			$lifetime = current_time('timestamp') + Give()->session->set_expiration_time();
249
+			@setcookie('give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false);
250 250
 		}
251 251
 	}
252 252
 
@@ -260,18 +260,18 @@  discard block
 block discarded – undo
260 260
 	 *
261 261
 	 * @return bool
262 262
 	 */
263
-	public function is_valid_token( $token ) {
263
+	public function is_valid_token($token) {
264 264
 
265 265
 		global $wpdb;
266 266
 
267 267
 		// Make sure token isn't expired
268
-		$expires = date( 'Y-m-d H:i:s', time() - $this->token_expiration );
268
+		$expires = date('Y-m-d H:i:s', time() - $this->token_expiration);
269 269
 
270 270
 		$email = $wpdb->get_var(
271
-			$wpdb->prepare( "SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires )
271
+			$wpdb->prepare("SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires)
272 272
 		);
273 273
 
274
-		if ( ! empty( $email ) ) {
274
+		if ( ! empty($email)) {
275 275
 			$this->token_email = $email;
276 276
 			$this->token       = $token;
277 277
 
@@ -279,8 +279,8 @@  discard block
 block discarded – undo
279 279
 		}
280 280
 
281 281
 		//Set error only if email access form isn't being submitted
282
-		if ( ! isset( $_POST['give_email'] ) && ! isset( $_POST['_wpnonce'] ) ) {
283
-			give_set_error( 'give_email_token_expired', apply_filters( 'give_email_token_expired_message', 'Your access token has expired. Please request a new one below:', 'give' ) );
282
+		if ( ! isset($_POST['give_email']) && ! isset($_POST['_wpnonce'])) {
283
+			give_set_error('give_email_token_expired', apply_filters('give_email_token_expired_message', 'Your access token has expired. Please request a new one below:', 'give'));
284 284
 		}
285 285
 
286 286
 
@@ -300,25 +300,25 @@  discard block
 block discarded – undo
300 300
 	 *
301 301
 	 * @return void
302 302
 	 */
303
-	public function set_verify_key( $customer_id, $email, $verify_key ) {
303
+	public function set_verify_key($customer_id, $email, $verify_key) {
304 304
 		global $wpdb;
305 305
 
306
-		$now = date( 'Y-m-d H:i:s' );
306
+		$now = date('Y-m-d H:i:s');
307 307
 
308 308
 		// Insert or update?
309 309
 		$row_id = (int) $wpdb->get_var(
310
-			$wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id )
310
+			$wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id)
311 311
 		);
312 312
 
313 313
 		// Update
314
-		if ( ! empty( $row_id ) ) {
314
+		if ( ! empty($row_id)) {
315 315
 			$wpdb->query(
316
-				$wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id )
316
+				$wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id)
317 317
 			);
318 318
 		} // Insert
319 319
 		else {
320 320
 			$wpdb->query(
321
-				$wpdb->prepare( "INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now )
321
+				$wpdb->prepare("INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now)
322 322
 			);
323 323
 		}
324 324
 	}
@@ -333,21 +333,21 @@  discard block
 block discarded – undo
333 333
 	 *
334 334
 	 * @return bool
335 335
 	 */
336
-	public function is_valid_verify_key( $token ) {
336
+	public function is_valid_verify_key($token) {
337 337
         /* @var WPDB $wpdb */
338 338
 		global $wpdb;
339 339
 
340 340
 		// See if the verify_key exists
341 341
 		$row = $wpdb->get_row(
342
-			$wpdb->prepare( "SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token )
342
+			$wpdb->prepare("SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token)
343 343
 		);
344 344
 
345
-		$now = date( 'Y-m-d H:i:s' );
345
+		$now = date('Y-m-d H:i:s');
346 346
 
347 347
 		// Set token
348
-		if ( ! empty( $row ) ) {
348
+		if ( ! empty($row)) {
349 349
 			$wpdb->query(
350
-				$wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id )
350
+				$wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id)
351 351
 			);
352 352
 
353 353
 			$this->token_email = $row->email;
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 	 *
372 372
 	 * @return mixed
373 373
 	 */
374
-	public function users_purchases_args( $args ) {
374
+	public function users_purchases_args($args) {
375 375
 		$args['user'] = $this->token_email;
376 376
 
377 377
 		return $args;
@@ -392,11 +392,11 @@  discard block
 block discarded – undo
392 392
 		global $wpdb;
393 393
 
394 394
 		//Create columns in customers table
395
-		$query = $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`" );
395
+		$query = $wpdb->query("ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`");
396 396
 
397 397
 		//Columns added properly
398
-		if ( $query ) {
399
-			give_update_option( 'email_access_installed', 1 );
398
+		if ($query) {
399
+			give_update_option('email_access_installed', 1);
400 400
 		}
401 401
 
402 402
 	}
Please login to merge, or discard this patch.
includes/misc-functions.php 1 patch
Spacing   +170 added lines, -170 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
 	$ret = give_get_option('test_mode', false);
27 27
 
28
-	return (bool) apply_filters( 'give_is_test_mode', $ret );
28
+	return (bool) apply_filters('give_is_test_mode', $ret);
29 29
 
30 30
 }
31 31
 
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
  */
38 38
 function give_get_currency() {
39 39
 
40
-	$currency = give_get_option( 'currency', 'USD' );
40
+	$currency = give_get_option('currency', 'USD');
41 41
 
42
-	return apply_filters( 'give_currency', $currency );
42
+	return apply_filters('give_currency', $currency);
43 43
 }
44 44
 
45 45
 /**
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
  */
52 52
 function give_get_currency_position() {
53 53
 
54
-	$currency_pos = give_get_option( 'currency_position', 'before' );
54
+	$currency_pos = give_get_option('currency_position', 'before');
55 55
 
56
-	return apply_filters( 'give_currency_position', $currency_pos );
56
+	return apply_filters('give_currency_position', $currency_pos);
57 57
 }
58 58
 
59 59
 
@@ -66,39 +66,39 @@  discard block
 block discarded – undo
66 66
 
67 67
 function give_get_currencies() {
68 68
 	$currencies = array(
69
-		'USD'  => esc_html__( 'US Dollars ($)', 'give' ),
70
-		'EUR'  => esc_html__( 'Euros (€)', 'give' ),
71
-		'GBP'  => esc_html__( 'Pounds Sterling (£)', 'give' ),
72
-		'AUD'  => esc_html__( 'Australian Dollars ($)', 'give' ),
73
-		'BRL'  => esc_html__( 'Brazilian Real (R$)', 'give' ),
74
-		'CAD'  => esc_html__( 'Canadian Dollars ($)', 'give' ),
75
-		'CZK'  => esc_html__( 'Czech Koruna (Kč)', 'give' ),
76
-		'DKK'  => esc_html__( 'Danish Krone (kr)', 'give' ),
77
-		'HKD'  => esc_html__( 'Hong Kong Dollar ($)', 'give' ),
78
-		'HUF'  => esc_html__( 'Hungarian Forint (Ft)', 'give' ),
79
-		'ILS'  => esc_html__( 'Israeli Shekel (₪)', 'give' ),
80
-		'JPY'  => esc_html__( 'Japanese Yen (¥)', 'give' ),
81
-		'MYR'  => esc_html__( 'Malaysian Ringgits (RM)', 'give' ),
82
-		'MXN'  => esc_html__( 'Mexican Peso ($)', 'give' ),
83
-		'MAD'  => esc_html__( 'Moroccan Dirham (&#x2e;&#x62f;&#x2e;&#x645;)', 'give' ),
84
-		'NZD'  => esc_html__( 'New Zealand Dollar ($)', 'give' ),
85
-		'NOK'  => esc_html__( 'Norwegian Krone (Kr.)', 'give' ),
86
-		'PHP'  => esc_html__( 'Philippine Pesos (₱)', 'give' ),
87
-		'PLN'  => esc_html__( 'Polish Zloty (zł)', 'give' ),
88
-		'SGD'  => esc_html__( 'Singapore Dollar ($)', 'give' ),
89
-		'KRW'  => esc_html__( 'South Korean Won (₩)', 'give' ),
90
-		'ZAR'  => esc_html__( 'South African Rand (R)', 'give' ),
91
-		'SEK'  => esc_html__( 'Swedish Krona (kr)', 'give' ),
92
-		'CHF'  => esc_html__( 'Swiss Franc (CHF)', 'give' ),
93
-		'TWD'  => esc_html__( 'Taiwan New Dollars (NT$)', 'give' ),
94
-		'THB'  => esc_html__( 'Thai Baht (฿)', 'give' ),
95
-		'INR'  => esc_html__( 'Indian Rupee (₹)', 'give' ),
96
-		'TRY'  => esc_html__( 'Turkish Lira (₺)', 'give' ),
97
-		'RIAL' => esc_html__( 'Iranian Rial (﷼)', 'give' ),
98
-		'RUB'  => esc_html__( 'Russian Rubles (руб)', 'give' )
69
+		'USD'  => esc_html__('US Dollars ($)', 'give'),
70
+		'EUR'  => esc_html__('Euros (€)', 'give'),
71
+		'GBP'  => esc_html__('Pounds Sterling (£)', 'give'),
72
+		'AUD'  => esc_html__('Australian Dollars ($)', 'give'),
73
+		'BRL'  => esc_html__('Brazilian Real (R$)', 'give'),
74
+		'CAD'  => esc_html__('Canadian Dollars ($)', 'give'),
75
+		'CZK'  => esc_html__('Czech Koruna (Kč)', 'give'),
76
+		'DKK'  => esc_html__('Danish Krone (kr)', 'give'),
77
+		'HKD'  => esc_html__('Hong Kong Dollar ($)', 'give'),
78
+		'HUF'  => esc_html__('Hungarian Forint (Ft)', 'give'),
79
+		'ILS'  => esc_html__('Israeli Shekel (₪)', 'give'),
80
+		'JPY'  => esc_html__('Japanese Yen (¥)', 'give'),
81
+		'MYR'  => esc_html__('Malaysian Ringgits (RM)', 'give'),
82
+		'MXN'  => esc_html__('Mexican Peso ($)', 'give'),
83
+		'MAD'  => esc_html__('Moroccan Dirham (&#x2e;&#x62f;&#x2e;&#x645;)', 'give'),
84
+		'NZD'  => esc_html__('New Zealand Dollar ($)', 'give'),
85
+		'NOK'  => esc_html__('Norwegian Krone (Kr.)', 'give'),
86
+		'PHP'  => esc_html__('Philippine Pesos (₱)', 'give'),
87
+		'PLN'  => esc_html__('Polish Zloty (zł)', 'give'),
88
+		'SGD'  => esc_html__('Singapore Dollar ($)', 'give'),
89
+		'KRW'  => esc_html__('South Korean Won (₩)', 'give'),
90
+		'ZAR'  => esc_html__('South African Rand (R)', 'give'),
91
+		'SEK'  => esc_html__('Swedish Krona (kr)', 'give'),
92
+		'CHF'  => esc_html__('Swiss Franc (CHF)', 'give'),
93
+		'TWD'  => esc_html__('Taiwan New Dollars (NT$)', 'give'),
94
+		'THB'  => esc_html__('Thai Baht (฿)', 'give'),
95
+		'INR'  => esc_html__('Indian Rupee (₹)', 'give'),
96
+		'TRY'  => esc_html__('Turkish Lira (₺)', 'give'),
97
+		'RIAL' => esc_html__('Iranian Rial (﷼)', 'give'),
98
+		'RUB'  => esc_html__('Russian Rubles (руб)', 'give')
99 99
 	);
100 100
 
101
-	return apply_filters( 'give_currencies', $currencies );
101
+	return apply_filters('give_currencies', $currencies);
102 102
 }
103 103
 
104 104
 
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
  *
114 114
  * @return string           The symbol to use for the currency
115 115
  */
116
-function give_currency_symbol( $currency = '' ) {
116
+function give_currency_symbol($currency = '') {
117 117
 
118
-	if ( empty( $currency ) ) {
118
+	if (empty($currency)) {
119 119
 		$currency = give_get_currency();
120 120
 	}
121
-	switch ( $currency ) :
121
+	switch ($currency) :
122 122
 		case 'GBP' :
123 123
 			$symbol = '£';
124 124
 			break;
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	endswitch;
198 198
 
199 199
 
200
-	return apply_filters( 'give_currency_symbol', $symbol, $currency );
200
+	return apply_filters('give_currency_symbol', $symbol, $currency);
201 201
 }
202 202
 
203 203
 
@@ -209,13 +209,13 @@  discard block
 block discarded – undo
209 209
  */
210 210
 function give_get_current_page_url() {
211 211
 
212
-	if ( is_front_page() ) {
213
-		$current_url = home_url( '/' );
212
+	if (is_front_page()) {
213
+		$current_url = home_url('/');
214 214
 	} else {
215
-		$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . untrailingslashit( $_SERVER['REQUEST_URI'] ) );
215
+		$current_url = set_url_scheme('http://'.$_SERVER['HTTP_HOST'].untrailingslashit($_SERVER['REQUEST_URI']));
216 216
 	}
217 217
 
218
-	return apply_filters( 'give_get_current_page_url', esc_url( $current_url ) );
218
+	return apply_filters('give_get_current_page_url', esc_url($current_url));
219 219
 }
220 220
 
221 221
 
@@ -236,15 +236,15 @@  discard block
 block discarded – undo
236 236
 	 */
237 237
 	$gateways = give_get_enabled_payment_gateways();
238 238
 
239
-	if ( count( $gateways ) == 1 && ! isset( $gateways['paypal'] ) && ! isset( $gateways['manual'] ) ) {
239
+	if (count($gateways) == 1 && ! isset($gateways['paypal']) && ! isset($gateways['manual'])) {
240 240
 		$ret = true;
241
-	} else if ( count( $gateways ) == 1 ) {
241
+	} else if (count($gateways) == 1) {
242 242
 		$ret = false;
243
-	} else if ( count( $gateways ) == 2 && isset( $gateways['paypal'] ) && isset( $gateways['manual'] ) ) {
243
+	} else if (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) {
244 244
 		$ret = false;
245 245
 	}
246 246
 
247
-	return (bool) apply_filters( 'give_verify_credit_cards', $ret );
247
+	return (bool) apply_filters('give_verify_credit_cards', $ret);
248 248
 }
249 249
 
250 250
 /**
@@ -256,26 +256,26 @@  discard block
 block discarded – undo
256 256
 function give_get_timezone_id() {
257 257
 
258 258
 	// if site timezone string exists, return it
259
-	if ( $timezone = get_option( 'timezone_string' ) ) {
259
+	if ($timezone = get_option('timezone_string')) {
260 260
 		return $timezone;
261 261
 	}
262 262
 
263 263
 	// get UTC offset, if it isn't set return UTC
264
-	if ( ! ( $utc_offset = 3600 * get_option( 'gmt_offset', 0 ) ) ) {
264
+	if ( ! ($utc_offset = 3600 * get_option('gmt_offset', 0))) {
265 265
 		return 'UTC';
266 266
 	}
267 267
 
268 268
 	// attempt to guess the timezone string from the UTC offset
269
-	$timezone = timezone_name_from_abbr( '', $utc_offset );
269
+	$timezone = timezone_name_from_abbr('', $utc_offset);
270 270
 
271 271
 	// last try, guess timezone string manually
272
-	if ( $timezone === false ) {
272
+	if ($timezone === false) {
273 273
 
274
-		$is_dst = date( 'I' );
274
+		$is_dst = date('I');
275 275
 
276
-		foreach ( timezone_abbreviations_list() as $abbr ) {
277
-			foreach ( $abbr as $city ) {
278
-				if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) {
276
+		foreach (timezone_abbreviations_list() as $abbr) {
277
+			foreach ($abbr as $city) {
278
+				if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) {
279 279
 					return $city['timezone_id'];
280 280
 				}
281 281
 			}
@@ -299,17 +299,17 @@  discard block
 block discarded – undo
299 299
 
300 300
 	$ip = '127.0.0.1';
301 301
 
302
-	if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
302
+	if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) {
303 303
 		//check ip from share internet
304 304
 		$ip = $_SERVER['HTTP_CLIENT_IP'];
305
-	} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
305
+	} elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
306 306
 		//to check ip is pass from proxy
307 307
 		$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
308
-	} elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) {
308
+	} elseif ( ! empty($_SERVER['REMOTE_ADDR'])) {
309 309
 		$ip = $_SERVER['REMOTE_ADDR'];
310 310
 	}
311 311
 
312
-	return apply_filters( 'give_get_ip', $ip );
312
+	return apply_filters('give_get_ip', $ip);
313 313
 }
314 314
 
315 315
 
@@ -324,9 +324,9 @@  discard block
 block discarded – undo
324 324
  *
325 325
  * @uses  Give()->session->set()
326 326
  */
327
-function give_set_purchase_session( $purchase_data = array() ) {
328
-	Give()->session->set( 'give_purchase', $purchase_data );
329
-	Give()->session->set( 'give_email', $purchase_data['user_email'] );
327
+function give_set_purchase_session($purchase_data = array()) {
328
+	Give()->session->set('give_purchase', $purchase_data);
329
+	Give()->session->set('give_email', $purchase_data['user_email']);
330 330
 }
331 331
 
332 332
 /**
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
  * @return mixed array | false
341 341
  */
342 342
 function give_get_purchase_session() {
343
-	return Give()->session->get( 'give_purchase' );
343
+	return Give()->session->get('give_purchase');
344 344
 }
345 345
 
346 346
 /**
@@ -355,14 +355,14 @@  discard block
 block discarded – undo
355 355
  *
356 356
  * @return string
357 357
  */
358
-function give_get_purchase_summary( $purchase_data, $email = true ) {
358
+function give_get_purchase_summary($purchase_data, $email = true) {
359 359
 	$summary = '';
360 360
 
361
-	if ( $email ) {
362
-		$summary .= $purchase_data['user_email'] . ' - ';
361
+	if ($email) {
362
+		$summary .= $purchase_data['user_email'].' - ';
363 363
 	}
364 364
 
365
-	$summary .= get_the_title( $purchase_data['post_data']['give-form-id'] );
365
+	$summary .= get_the_title($purchase_data['post_data']['give-form-id']);
366 366
 
367 367
 	return $summary;
368 368
 }
@@ -379,31 +379,31 @@  discard block
 block discarded – undo
379 379
 function give_get_host() {
380 380
 	$host = false;
381 381
 
382
-	if ( defined( 'WPE_APIKEY' ) ) {
382
+	if (defined('WPE_APIKEY')) {
383 383
 		$host = 'WP Engine';
384
-	} elseif ( defined( 'PAGELYBIN' ) ) {
384
+	} elseif (defined('PAGELYBIN')) {
385 385
 		$host = 'Pagely';
386
-	} elseif ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
386
+	} elseif (DB_HOST == 'localhost:/tmp/mysql5.sock') {
387 387
 		$host = 'ICDSoft';
388
-	} elseif ( DB_HOST == 'mysqlv5' ) {
388
+	} elseif (DB_HOST == 'mysqlv5') {
389 389
 		$host = 'NetworkSolutions';
390
-	} elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
390
+	} elseif (strpos(DB_HOST, 'ipagemysql.com') !== false) {
391 391
 		$host = 'iPage';
392
-	} elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
392
+	} elseif (strpos(DB_HOST, 'ipowermysql.com') !== false) {
393 393
 		$host = 'IPower';
394
-	} elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
394
+	} elseif (strpos(DB_HOST, '.gridserver.com') !== false) {
395 395
 		$host = 'MediaTemple Grid';
396
-	} elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) {
396
+	} elseif (strpos(DB_HOST, '.pair.com') !== false) {
397 397
 		$host = 'pair Networks';
398
-	} elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
398
+	} elseif (strpos(DB_HOST, '.stabletransit.com') !== false) {
399 399
 		$host = 'Rackspace Cloud';
400
-	} elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
400
+	} elseif (strpos(DB_HOST, '.sysfix.eu') !== false) {
401 401
 		$host = 'SysFix.eu Power Hosting';
402
-	} elseif ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
402
+	} elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) {
403 403
 		$host = 'Flywheel';
404 404
 	} else {
405 405
 		// Adding a general fallback for data gathering
406
-		$host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME'];
406
+		$host = 'DBH: '.DB_HOST.', SRV: '.$_SERVER['SERVER_NAME'];
407 407
 	}
408 408
 
409 409
 	return $host;
@@ -419,67 +419,67 @@  discard block
 block discarded – undo
419 419
  *
420 420
  * @return bool true if host matches, false if not
421 421
  */
422
-function give_is_host( $host = false ) {
422
+function give_is_host($host = false) {
423 423
 
424 424
 	$return = false;
425 425
 
426
-	if ( $host ) {
427
-		$host = str_replace( ' ', '', strtolower( $host ) );
426
+	if ($host) {
427
+		$host = str_replace(' ', '', strtolower($host));
428 428
 
429
-		switch ( $host ) {
429
+		switch ($host) {
430 430
 			case 'wpengine':
431
-				if ( defined( 'WPE_APIKEY' ) ) {
431
+				if (defined('WPE_APIKEY')) {
432 432
 					$return = true;
433 433
 				}
434 434
 				break;
435 435
 			case 'pagely':
436
-				if ( defined( 'PAGELYBIN' ) ) {
436
+				if (defined('PAGELYBIN')) {
437 437
 					$return = true;
438 438
 				}
439 439
 				break;
440 440
 			case 'icdsoft':
441
-				if ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
441
+				if (DB_HOST == 'localhost:/tmp/mysql5.sock') {
442 442
 					$return = true;
443 443
 				}
444 444
 				break;
445 445
 			case 'networksolutions':
446
-				if ( DB_HOST == 'mysqlv5' ) {
446
+				if (DB_HOST == 'mysqlv5') {
447 447
 					$return = true;
448 448
 				}
449 449
 				break;
450 450
 			case 'ipage':
451
-				if ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
451
+				if (strpos(DB_HOST, 'ipagemysql.com') !== false) {
452 452
 					$return = true;
453 453
 				}
454 454
 				break;
455 455
 			case 'ipower':
456
-				if ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
456
+				if (strpos(DB_HOST, 'ipowermysql.com') !== false) {
457 457
 					$return = true;
458 458
 				}
459 459
 				break;
460 460
 			case 'mediatemplegrid':
461
-				if ( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
461
+				if (strpos(DB_HOST, '.gridserver.com') !== false) {
462 462
 					$return = true;
463 463
 				}
464 464
 				break;
465 465
 			case 'pairnetworks':
466
-				if ( strpos( DB_HOST, '.pair.com' ) !== false ) {
466
+				if (strpos(DB_HOST, '.pair.com') !== false) {
467 467
 					$return = true;
468 468
 				}
469 469
 				break;
470 470
 			case 'rackspacecloud':
471
-				if ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
471
+				if (strpos(DB_HOST, '.stabletransit.com') !== false) {
472 472
 					$return = true;
473 473
 				}
474 474
 				break;
475 475
 			case 'sysfix.eu':
476 476
 			case 'sysfix.eupowerhosting':
477
-				if ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
477
+				if (strpos(DB_HOST, '.sysfix.eu') !== false) {
478 478
 					$return = true;
479 479
 				}
480 480
 				break;
481 481
 			case 'flywheel':
482
-				if ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
482
+				if (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) {
483 483
 					$return = true;
484 484
 				}
485 485
 				break;
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
  * @param string $replacement Optional. The function that should have been called.
513 513
  * @param array  $backtrace   Optional. Contains stack backtrace of deprecated function.
514 514
  */
515
-function _give_deprecated_function( $function, $version, $replacement = null, $backtrace = null ) {
515
+function _give_deprecated_function($function, $version, $replacement = null, $backtrace = null) {
516 516
 
517 517
 	/**
518 518
 	 * Fires while give deprecated function call occurs.
@@ -525,19 +525,19 @@  discard block
 block discarded – undo
525 525
 	 * @param string $replacement Optional. The function that should have been called.
526 526
 	 * @param string $version     The plugin version that deprecated the function.
527 527
 	 */
528
-	do_action( 'give_deprecated_function_run', $function, $replacement, $version );
528
+	do_action('give_deprecated_function_run', $function, $replacement, $version);
529 529
 
530
-	$show_errors = current_user_can( 'manage_options' );
530
+	$show_errors = current_user_can('manage_options');
531 531
 
532 532
 	// Allow plugin to filter the output error trigger
533
-	if ( WP_DEBUG && apply_filters( 'give_deprecated_function_trigger_error', $show_errors ) ) {
534
-		if ( ! is_null( $replacement ) ) {
535
-			trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give' ), $function, $version, $replacement ) );
536
-			trigger_error( print_r( $backtrace, 1 ) ); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
533
+	if (WP_DEBUG && apply_filters('give_deprecated_function_trigger_error', $show_errors)) {
534
+		if ( ! is_null($replacement)) {
535
+			trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give'), $function, $version, $replacement));
536
+			trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
537 537
 			// Alternatively we could dump this to a file.
538 538
 		} else {
539
-			trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give' ), $function, $version ) );
540
-			trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
539
+			trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give'), $function, $version));
540
+			trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
541 541
 			// Alternatively we could dump this to a file.
542 542
 		}
543 543
 	}
@@ -551,8 +551,8 @@  discard block
 block discarded – undo
551 551
  * @return string $post_id
552 552
  */
553 553
 function give_get_admin_post_id() {
554
-	$post_id = isset( $_GET['post'] ) ? $_GET['post'] : null;
555
-	if ( ! $post_id && isset( $_POST['post_id'] ) ) {
554
+	$post_id = isset($_GET['post']) ? $_GET['post'] : null;
555
+	if ( ! $post_id && isset($_POST['post_id'])) {
556 556
 		$post_id = $_POST['post_id'];
557 557
 	}
558 558
 
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
  * @return string Arg separator output
567 567
  */
568 568
 function give_get_php_arg_separator_output() {
569
-	return ini_get( 'arg_separator.output' );
569
+	return ini_get('arg_separator.output');
570 570
 }
571 571
 
572 572
 
@@ -581,10 +581,10 @@  discard block
 block discarded – undo
581 581
  *
582 582
  * @return string Short month name
583 583
  */
584
-function give_month_num_to_name( $n ) {
585
-	$timestamp = mktime( 0, 0, 0, $n, 1, 2005 );
584
+function give_month_num_to_name($n) {
585
+	$timestamp = mktime(0, 0, 0, $n, 1, 2005);
586 586
 
587
-	return date_i18n( "M", $timestamp );
587
+	return date_i18n("M", $timestamp);
588 588
 }
589 589
 
590 590
 
@@ -597,10 +597,10 @@  discard block
 block discarded – undo
597 597
  *
598 598
  * @return bool Whether or not function is disabled.
599 599
  */
600
-function give_is_func_disabled( $function ) {
601
-	$disabled = explode( ',', ini_get( 'disable_functions' ) );
600
+function give_is_func_disabled($function) {
601
+	$disabled = explode(',', ini_get('disable_functions'));
602 602
 
603
-	return in_array( $function, $disabled );
603
+	return in_array($function, $disabled);
604 604
 }
605 605
 
606 606
 
@@ -615,23 +615,23 @@  discard block
 block discarded – undo
615 615
 
616 616
 		<form action="//givewp.us3.list-manage.com/subscribe/post?u=3ccb75d68bda4381e2f45794c&amp;id=12a081aa13" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
617 617
 			<div class="give-newsletter-confirmation">
618
-				<p><?php esc_html_e( 'Thanks for Subscribing!', 'give' ); ?> :)</p>
618
+				<p><?php esc_html_e('Thanks for Subscribing!', 'give'); ?> :)</p>
619 619
 			</div>
620 620
 
621 621
 			<table class="form-table give-newsletter-form">
622 622
 				<tr valign="middle">
623 623
 					<td>
624
-						<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL" placeholder="<?php esc_attr_e( 'Email Address (required)', 'give' ); ?>">
624
+						<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL" placeholder="<?php esc_attr_e('Email Address (required)', 'give'); ?>">
625 625
 					</td>
626 626
 
627 627
 					<td scope="row">
628
-						<input type="text" value="" placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" name="FNAME" class="" id="mce-FNAME"></td>
628
+						<input type="text" value="" placeholder="<?php esc_attr_e('First Name', 'give'); ?>" name="FNAME" class="" id="mce-FNAME"></td>
629 629
 
630 630
 					<td scope="row">
631
-						<input type="text" value="" placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" name="LNAME" class="" id="mce-LNAME"></td>
631
+						<input type="text" value="" placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" name="LNAME" class="" id="mce-LNAME"></td>
632 632
 
633 633
 					<td scope="row">
634
-						<input type="submit" value="<?php esc_attr_e( 'Subscribe', 'give' ); ?>" name="subscribe" id="mc-embedded-subscribe" class="button">
634
+						<input type="submit" value="<?php esc_attr_e('Subscribe', 'give'); ?>" name="subscribe" id="mc-embedded-subscribe" class="button">
635 635
 					</td>
636 636
 				</tr>
637 637
 			</table>
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
 		<a href="https://twitter.com/givewp" class="twitter-follow-button" data-show-count="false"><?php
692 692
 			printf(
693 693
 				/* translators: %s: Give twitter user @givewp */
694
-				esc_html_e( 'Follow %s', 'give' ),
694
+				esc_html_e('Follow %s', 'give'),
695 695
 				'@givewp'
696 696
 			);
697 697
 		?></a>
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
  *
721 721
  * @return mixed
722 722
  */
723
-function give_svg_icons( $icon ) {
723
+function give_svg_icons($icon) {
724 724
 
725 725
 	// Store your SVGs in an associative array
726 726
 	$svgs = array(
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 	);
733 733
 
734 734
 	// Return the chosen icon's SVG string
735
-	return $svgs[ $icon ];
735
+	return $svgs[$icon];
736 736
 }
737 737
 
738 738
 /**
@@ -744,15 +744,15 @@  discard block
 block discarded – undo
744 744
  *
745 745
  * @return mixed
746 746
  */
747
-function modify_nav_menu_meta_box_object( $post_type ) {
748
-	if ( isset( $post_type->name ) && $post_type->name == 'give_forms' ) {
749
-		$post_type->labels->name = esc_html__( 'Donation Forms', 'give' );
747
+function modify_nav_menu_meta_box_object($post_type) {
748
+	if (isset($post_type->name) && $post_type->name == 'give_forms') {
749
+		$post_type->labels->name = esc_html__('Donation Forms', 'give');
750 750
 	}
751 751
 
752 752
 	return $post_type;
753 753
 }
754 754
 
755
-add_filter( 'nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object' );
755
+add_filter('nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object');
756 756
 
757 757
 
758 758
 /**
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
  * @license    http://opensource.org/licenses/MIT MIT
766 766
  */
767 767
 
768
-if ( ! function_exists( 'array_column' ) ) {
768
+if ( ! function_exists('array_column')) {
769 769
 	/**
770 770
 	 * Returns the values from a single column of the input array, identified by
771 771
 	 * the $columnKey.
@@ -784,56 +784,56 @@  discard block
 block discarded – undo
784 784
 	 *
785 785
 	 * @return array
786 786
 	 */
787
-	function array_column( $input = null, $columnKey = null, $indexKey = null ) {
787
+	function array_column($input = null, $columnKey = null, $indexKey = null) {
788 788
 		// Using func_get_args() in order to check for proper number of
789 789
 		// parameters and trigger errors exactly as the built-in array_column()
790 790
 		// does in PHP 5.5.
791 791
 		$argc   = func_num_args();
792 792
 		$params = func_get_args();
793 793
 
794
-		if ( $argc < 2 ) {
795
-			trigger_error( "array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING );
794
+		if ($argc < 2) {
795
+			trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING);
796 796
 
797 797
 			return null;
798 798
 		}
799 799
 
800
-		if ( ! is_array( $params[0] ) ) {
800
+		if ( ! is_array($params[0])) {
801 801
 			trigger_error(
802
-				'array_column() expects parameter 1 to be array, ' . gettype( $params[0] ) . ' given',
802
+				'array_column() expects parameter 1 to be array, '.gettype($params[0]).' given',
803 803
 				E_USER_WARNING
804 804
 			);
805 805
 
806 806
 			return null;
807 807
 		}
808 808
 
809
-		if ( ! is_int( $params[1] )
810
-		     && ! is_float( $params[1] )
811
-		     && ! is_string( $params[1] )
809
+		if ( ! is_int($params[1])
810
+		     && ! is_float($params[1])
811
+		     && ! is_string($params[1])
812 812
 		     && $params[1] !== null
813
-		     && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) )
813
+		     && ! (is_object($params[1]) && method_exists($params[1], '__toString'))
814 814
 		) {
815
-			trigger_error( 'array_column(): The column key should be either a string or an integer', E_USER_WARNING );
815
+			trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING);
816 816
 
817 817
 			return false;
818 818
 		}
819 819
 
820
-		if ( isset( $params[2] )
821
-		     && ! is_int( $params[2] )
822
-		     && ! is_float( $params[2] )
823
-		     && ! is_string( $params[2] )
824
-		     && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) )
820
+		if (isset($params[2])
821
+		     && ! is_int($params[2])
822
+		     && ! is_float($params[2])
823
+		     && ! is_string($params[2])
824
+		     && ! (is_object($params[2]) && method_exists($params[2], '__toString'))
825 825
 		) {
826
-			trigger_error( 'array_column(): The index key should be either a string or an integer', E_USER_WARNING );
826
+			trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING);
827 827
 
828 828
 			return false;
829 829
 		}
830 830
 
831 831
 		$paramsInput     = $params[0];
832
-		$paramsColumnKey = ( $params[1] !== null ) ? (string) $params[1] : null;
832
+		$paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null;
833 833
 
834 834
 		$paramsIndexKey = null;
835
-		if ( isset( $params[2] ) ) {
836
-			if ( is_float( $params[2] ) || is_int( $params[2] ) ) {
835
+		if (isset($params[2])) {
836
+			if (is_float($params[2]) || is_int($params[2])) {
837 837
 				$paramsIndexKey = (int) $params[2];
838 838
 			} else {
839 839
 				$paramsIndexKey = (string) $params[2];
@@ -842,26 +842,26 @@  discard block
 block discarded – undo
842 842
 
843 843
 		$resultArray = array();
844 844
 
845
-		foreach ( $paramsInput as $row ) {
845
+		foreach ($paramsInput as $row) {
846 846
 			$key    = $value = null;
847 847
 			$keySet = $valueSet = false;
848 848
 
849
-			if ( $paramsIndexKey !== null && array_key_exists( $paramsIndexKey, $row ) ) {
849
+			if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) {
850 850
 				$keySet = true;
851
-				$key    = (string) $row[ $paramsIndexKey ];
851
+				$key    = (string) $row[$paramsIndexKey];
852 852
 			}
853 853
 
854
-			if ( $paramsColumnKey === null ) {
854
+			if ($paramsColumnKey === null) {
855 855
 				$valueSet = true;
856 856
 				$value    = $row;
857
-			} elseif ( is_array( $row ) && array_key_exists( $paramsColumnKey, $row ) ) {
857
+			} elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) {
858 858
 				$valueSet = true;
859
-				$value    = $row[ $paramsColumnKey ];
859
+				$value    = $row[$paramsColumnKey];
860 860
 			}
861 861
 
862
-			if ( $valueSet ) {
863
-				if ( $keySet ) {
864
-					$resultArray[ $key ] = $value;
862
+			if ($valueSet) {
863
+				if ($keySet) {
864
+					$resultArray[$key] = $value;
865 865
 				} else {
866 866
 					$resultArray[] = $value;
867 867
 				}
@@ -883,40 +883,40 @@  discard block
 block discarded – undo
883 883
  *
884 884
  * @return bool Whether the receipt is visible or not.
885 885
  */
886
-function give_can_view_receipt( $payment_key = '' ) {
886
+function give_can_view_receipt($payment_key = '') {
887 887
 
888 888
 	$return = false;
889 889
 
890
-	if ( empty( $payment_key ) ) {
890
+	if (empty($payment_key)) {
891 891
 		return $return;
892 892
 	}
893 893
 
894 894
 	global $give_receipt_args;
895 895
 
896
-	$give_receipt_args['id'] = give_get_purchase_id_by_key( $payment_key );
896
+	$give_receipt_args['id'] = give_get_purchase_id_by_key($payment_key);
897 897
 
898
-	$user_id = (int) give_get_payment_user_id( $give_receipt_args['id'] );
898
+	$user_id = (int) give_get_payment_user_id($give_receipt_args['id']);
899 899
 
900
-	$payment_meta = give_get_payment_meta( $give_receipt_args['id'] );
900
+	$payment_meta = give_get_payment_meta($give_receipt_args['id']);
901 901
 
902
-	if ( is_user_logged_in() ) {
903
-		if ( $user_id === (int) get_current_user_id() ) {
902
+	if (is_user_logged_in()) {
903
+		if ($user_id === (int) get_current_user_id()) {
904 904
 			$return = true;
905
-		} elseif ( wp_get_current_user()->user_email === give_get_payment_user_email( $give_receipt_args['id'] ) ) {
905
+		} elseif (wp_get_current_user()->user_email === give_get_payment_user_email($give_receipt_args['id'])) {
906 906
 			$return = true;
907
-		} elseif ( current_user_can( 'view_give_sensitive_data' ) ) {
907
+		} elseif (current_user_can('view_give_sensitive_data')) {
908 908
 			$return = true;
909 909
 		}
910 910
 	}
911 911
 
912 912
 	$session = give_get_purchase_session();
913
-	if ( ! empty( $session ) && ! is_user_logged_in() ) {
914
-		if ( $session['purchase_key'] === $payment_meta['key'] ) {
913
+	if ( ! empty($session) && ! is_user_logged_in()) {
914
+		if ($session['purchase_key'] === $payment_meta['key']) {
915 915
 			$return = true;
916 916
 		}
917 917
 	}
918 918
 
919
-	return (bool) apply_filters( 'give_can_view_receipt', $return, $payment_key );
919
+	return (bool) apply_filters('give_can_view_receipt', $return, $payment_key);
920 920
 
921 921
 }
922 922
 
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
  *
926 926
  * Fallback in case the calendar extension is not loaded in PHP; Only supports Gregorian calendar
927 927
  */
928
-if ( ! function_exists( 'cal_days_in_month' ) ) {
928
+if ( ! function_exists('cal_days_in_month')) {
929 929
 	/**
930 930
 	 * cal_days_in_month
931 931
 	 *
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
 	 *
936 936
 	 * @return bool|string
937 937
 	 */
938
-	function cal_days_in_month( $calendar, $month, $year ) {
939
-		return date( 't', mktime( 0, 0, 0, $month, 1, $year ) );
938
+	function cal_days_in_month($calendar, $month, $year) {
939
+		return date('t', mktime(0, 0, 0, $month, 1, $year));
940 940
 	}
941 941
 }
Please login to merge, or discard this patch.
includes/process-purchase.php 1 patch
Spacing   +250 added lines, -250 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
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @since 1.0
32 32
 	 */
33
-	do_action( 'give_pre_process_purchase' );
33
+	do_action('give_pre_process_purchase');
34 34
 
35 35
 	// Validate the form $_POST data
36 36
 	$valid_data = give_purchase_form_validate_fields();
@@ -45,26 +45,26 @@  discard block
 block discarded – undo
45 45
 	 * @param bool|array $valid_data Validate fields.
46 46
 	 * @param array      $_POST      Array of variables passed via the HTTP POST.
47 47
 	 */
48
-	do_action( 'give_checkout_error_checks', $valid_data, $_POST );
48
+	do_action('give_checkout_error_checks', $valid_data, $_POST);
49 49
 
50
-	$is_ajax = isset( $_POST['give_ajax'] );
50
+	$is_ajax = isset($_POST['give_ajax']);
51 51
 
52 52
 	// Process the login form
53
-	if ( isset( $_POST['give_login_submit'] ) ) {
53
+	if (isset($_POST['give_login_submit'])) {
54 54
 		give_process_form_login();
55 55
 	}
56 56
 
57 57
 	// Validate the user
58
-	$user = give_get_purchase_form_user( $valid_data );
58
+	$user = give_get_purchase_form_user($valid_data);
59 59
 
60
-	if ( false === $valid_data || give_get_errors() || ! $user ) {
61
-		if ( $is_ajax ) {
60
+	if (false === $valid_data || give_get_errors() || ! $user) {
61
+		if ($is_ajax) {
62 62
 			/**
63 63
 			 * Fires when AJAX sends back errors from the purchase form.
64 64
 			 *
65 65
 			 * @since 1.0
66 66
 			 */
67
-			do_action( 'give_ajax_checkout_errors' );
67
+			do_action('give_ajax_checkout_errors');
68 68
 			give_die();
69 69
 		} else {
70 70
 			return false;
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
 	}
73 73
 
74 74
 	//If AJAX send back success to proceed with form submission
75
-	if ( $is_ajax ) {
75
+	if ($is_ajax) {
76 76
 		echo 'success';
77 77
 		give_die();
78 78
 	}
79 79
 
80 80
 	//After AJAX: Setup session if not using php_sessions
81
-	if ( ! Give()->session->use_php_sessions() ) {
81
+	if ( ! Give()->session->use_php_sessions()) {
82 82
 		//Double-check that set_cookie is publicly accessible;
83 83
 		// we're using a slightly modified class-wp-sessions.php
84
-		$session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' );
85
-		if ( $session_reflection->isPublic() ) {
84
+		$session_reflection = new ReflectionMethod('WP_Session', 'set_cookie');
85
+		if ($session_reflection->isPublic()) {
86 86
 			// Manually set the cookie.
87 87
 			Give()->session->init()->set_cookie();
88 88
 		}
@@ -97,18 +97,18 @@  discard block
 block discarded – undo
97 97
 		'address'    => $user['address']
98 98
 	);
99 99
 
100
-	$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
100
+	$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
101 101
 
102
-	$price        = isset( $_POST['give-amount'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00';
103
-	$purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );
102
+	$price        = isset($_POST['give-amount']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00';
103
+	$purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true)));
104 104
 
105 105
 	// Setup purchase information
106 106
 	$purchase_data = array(
107 107
 		'price'        => $price,
108 108
 		'purchase_key' => $purchase_key,
109 109
 		'user_email'   => $user['user_email'],
110
-		'date'         => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
111
-		'user_info'    => stripslashes_deep( $user_info ),
110
+		'date'         => date('Y-m-d H:i:s', current_time('timestamp')),
111
+		'user_info'    => stripslashes_deep($user_info),
112 112
 		'post_data'    => $_POST,
113 113
 		'gateway'      => $valid_data['gateway'],
114 114
 		'card_info'    => $valid_data['cc_info']
@@ -128,37 +128,37 @@  discard block
 block discarded – undo
128 128
 	 * @param array      $user_info  Array containing basic user information.
129 129
 	 * @param bool|array $valid_data Validate fields.
130 130
 	 */
131
-	do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data );
131
+	do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data);
132 132
 
133 133
 	//Sanity check for price
134
-	if ( ! $purchase_data['price'] ) {
134
+	if ( ! $purchase_data['price']) {
135 135
 		// Revert to manual
136 136
 		$purchase_data['gateway'] = 'manual';
137 137
 		$_POST['give-gateway']    = 'manual';
138 138
 	}
139 139
 
140 140
 	// Allow the purchase data to be modified before it is sent to the gateway
141
-	$purchase_data = apply_filters( 'give_purchase_data_before_gateway', $purchase_data, $valid_data );
141
+	$purchase_data = apply_filters('give_purchase_data_before_gateway', $purchase_data, $valid_data);
142 142
 
143 143
 	// Setup the data we're storing in the purchase session
144 144
 	$session_data = $purchase_data;
145 145
 
146 146
 	// Make sure credit card numbers are never stored in sessions
147
-	unset( $session_data['card_info']['card_number'] );
148
-	unset( $session_data['post_data']['card_number'] );
147
+	unset($session_data['card_info']['card_number']);
148
+	unset($session_data['post_data']['card_number']);
149 149
 
150 150
 	// Used for showing data to non logged-in users after purchase, and for other plugins needing purchase data.
151
-	give_set_purchase_session( $session_data );
151
+	give_set_purchase_session($session_data);
152 152
 
153 153
 	// Send info to the gateway for payment processing
154
-	give_send_to_gateway( $purchase_data['gateway'], $purchase_data );
154
+	give_send_to_gateway($purchase_data['gateway'], $purchase_data);
155 155
 	give_die();
156 156
 
157 157
 }
158 158
 
159
-add_action( 'give_purchase', 'give_process_purchase_form' );
160
-add_action( 'wp_ajax_give_process_checkout', 'give_process_purchase_form' );
161
-add_action( 'wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form' );
159
+add_action('give_purchase', 'give_process_purchase_form');
160
+add_action('wp_ajax_give_process_checkout', 'give_process_purchase_form');
161
+add_action('wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form');
162 162
 
163 163
 /**
164 164
  * Process the checkout login form
@@ -169,37 +169,37 @@  discard block
 block discarded – undo
169 169
  */
170 170
 function give_process_form_login() {
171 171
 
172
-	$is_ajax = isset( $_POST['give_ajax'] );
172
+	$is_ajax = isset($_POST['give_ajax']);
173 173
 
174 174
 	$user_data = give_purchase_form_validate_user_login();
175 175
 
176
-	if ( give_get_errors() || $user_data['user_id'] < 1 ) {
177
-		if ( $is_ajax ) {
176
+	if (give_get_errors() || $user_data['user_id'] < 1) {
177
+		if ($is_ajax) {
178 178
 			/**
179 179
 			 * Fires when AJAX sends back errors from the purchase form.
180 180
 			 *
181 181
 			 * @since 1.0
182 182
 			 */
183
-			do_action( 'give_ajax_checkout_errors' );
183
+			do_action('give_ajax_checkout_errors');
184 184
 			give_die();
185 185
 		} else {
186
-			wp_redirect( $_SERVER['HTTP_REFERER'] );
186
+			wp_redirect($_SERVER['HTTP_REFERER']);
187 187
 			exit;
188 188
 		}
189 189
 	}
190 190
 
191
-	give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] );
191
+	give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']);
192 192
 
193
-	if ( $is_ajax ) {
193
+	if ($is_ajax) {
194 194
 		echo 'success';
195 195
 		give_die();
196 196
 	} else {
197
-		wp_redirect( $_SERVER['HTTP_REFERER'] );
197
+		wp_redirect($_SERVER['HTTP_REFERER']);
198 198
 	}
199 199
 }
200 200
 
201
-add_action( 'wp_ajax_give_process_checkout_login', 'give_process_form_login' );
202
-add_action( 'wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login' );
201
+add_action('wp_ajax_give_process_checkout_login', 'give_process_form_login');
202
+add_action('wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login');
203 203
 
204 204
 /**
205 205
  * Purchase Form Validate Fields
@@ -211,45 +211,45 @@  discard block
 block discarded – undo
211 211
 function give_purchase_form_validate_fields() {
212 212
 
213 213
 	// Check if there is $_POST
214
-	if ( empty( $_POST ) ) {
214
+	if (empty($_POST)) {
215 215
 		return false;
216 216
 	}
217 217
 
218
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
218
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
219 219
 
220 220
 	// Start an array to collect valid data
221 221
 	$valid_data = array(
222 222
 		'gateway'          => give_purchase_form_validate_gateway(), // Gateway fallback (amount is validated here)
223
-		'need_new_user'    => false,     // New user flag
224
-		'need_user_login'  => false,     // Login user flag
225
-		'logged_user_data' => array(),   // Logged user collected data
226
-		'new_user_data'    => array(),   // New user collected data
227
-		'login_user_data'  => array(),   // Login user collected data
228
-		'guest_user_data'  => array(),   // Guest user collected data
223
+		'need_new_user'    => false, // New user flag
224
+		'need_user_login'  => false, // Login user flag
225
+		'logged_user_data' => array(), // Logged user collected data
226
+		'new_user_data'    => array(), // New user collected data
227
+		'login_user_data'  => array(), // Login user collected data
228
+		'guest_user_data'  => array(), // Guest user collected data
229 229
 		'cc_info'          => give_purchase_form_validate_cc()    // Credit card info
230 230
 	);
231 231
 
232 232
 	//Validate Honeypot First
233
-	if ( ! empty( $_POST['give-honeypot'] ) ) {
234
-		give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) );
233
+	if ( ! empty($_POST['give-honeypot'])) {
234
+		give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give'));
235 235
 	}
236 236
 
237 237
 	// Validate agree to terms
238
-	$terms_option = get_post_meta( $form_id, '_give_terms_option', true );
239
-	if ( isset( $terms_option ) && $terms_option === 'yes' ) {
238
+	$terms_option = get_post_meta($form_id, '_give_terms_option', true);
239
+	if (isset($terms_option) && $terms_option === 'yes') {
240 240
 		give_purchase_form_validate_agree_to_terms();
241 241
 	}
242 242
 
243
-	if ( is_user_logged_in() ) {
243
+	if (is_user_logged_in()) {
244 244
 		// Collect logged in user data
245 245
 		$valid_data['logged_in_user'] = give_purchase_form_validate_logged_in_user();
246
-	} else if ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) {
246
+	} else if (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') {
247 247
 		// Set new user registration as required
248 248
 		$valid_data['need_new_user'] = true;
249 249
 		// Validate new user data
250 250
 		$valid_data['new_user_data'] = give_purchase_form_validate_new_user();
251 251
 		// Check if login validation is needed
252
-	} else if ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) {
252
+	} else if (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') {
253 253
 		// Set user login as required
254 254
 		$valid_data['need_user_login'] = true;
255 255
 		// Validate users login info
@@ -274,41 +274,41 @@  discard block
 block discarded – undo
274 274
  */
275 275
 function give_purchase_form_validate_gateway() {
276 276
 
277
-	$form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
278
-	$amount  = isset( $_REQUEST['give-amount'] ) ? give_sanitize_amount( $_REQUEST['give-amount'] ) : 0;
279
-	$gateway = give_get_default_gateway( $form_id );
277
+	$form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
278
+	$amount  = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0;
279
+	$gateway = give_get_default_gateway($form_id);
280 280
 
281 281
 	// Check if a gateway value is present
282
-	if ( ! empty( $_REQUEST['give-gateway'] ) ) {
282
+	if ( ! empty($_REQUEST['give-gateway'])) {
283 283
 
284
-		$gateway = sanitize_text_field( $_REQUEST['give-gateway'] );
284
+		$gateway = sanitize_text_field($_REQUEST['give-gateway']);
285 285
 
286 286
 		//Is amount being donated in LIVE mode 0.00? If so, error:
287
-		if ( $amount == 0 && ! give_is_test_mode() ) {
287
+		if ($amount == 0 && ! give_is_test_mode()) {
288 288
 
289
-			give_set_error( 'invalid_donation_amount', esc_html__( 'Please insert a valid donation amount.', 'give' ) );
289
+			give_set_error('invalid_donation_amount', esc_html__('Please insert a valid donation amount.', 'give'));
290 290
 
291 291
 		} //Check for a minimum custom amount
292
-		elseif ( ! give_verify_minimum_price() ) {
292
+		elseif ( ! give_verify_minimum_price()) {
293 293
 
294 294
 			give_set_error(
295 295
 				'invalid_donation_minimum',
296 296
 				sprintf(
297 297
 					/* translators: %s: minimum donation amount */
298
-					esc_html__( 'This form has a minimum donation amount of %s.', 'give' ),
299
-					give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) )
298
+					esc_html__('This form has a minimum donation amount of %s.', 'give'),
299
+					give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id)))
300 300
 				)
301 301
 			);
302 302
 
303 303
 		} //Is this test mode zero donation? Let it through but set to manual gateway
304
-		elseif ( $amount == 0 && give_is_test_mode() ) {
304
+		elseif ($amount == 0 && give_is_test_mode()) {
305 305
 
306 306
 			$gateway = 'manual';
307 307
 
308 308
 		} //Check if this gateway is active
309
-		elseif ( ! give_is_gateway_active( $gateway ) ) {
309
+		elseif ( ! give_is_gateway_active($gateway)) {
310 310
 
311
-			give_set_error( 'invalid_gateway', esc_html__( 'The selected payment gateway is not enabled.', 'give' ) );
311
+			give_set_error('invalid_gateway', esc_html__('The selected payment gateway is not enabled.', 'give'));
312 312
 
313 313
 		}
314 314
 
@@ -327,23 +327,23 @@  discard block
 block discarded – undo
327 327
  */
328 328
 function give_verify_minimum_price() {
329 329
 
330
-	$amount          = give_sanitize_amount( $_REQUEST['give-amount'] );
331
-	$form_id         = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
332
-	$price_id        = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : 0;
333
-	$variable_prices = give_has_variable_prices( $form_id );
330
+	$amount          = give_sanitize_amount($_REQUEST['give-amount']);
331
+	$form_id         = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
332
+	$price_id        = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : 0;
333
+	$variable_prices = give_has_variable_prices($form_id);
334 334
 
335
-	if ( $variable_prices && ! empty( $price_id ) ) {
335
+	if ($variable_prices && ! empty($price_id)) {
336 336
 
337
-		$price_level_amount = give_get_price_option_amount( $form_id, $price_id );
337
+		$price_level_amount = give_get_price_option_amount($form_id, $price_id);
338 338
 
339
-		if ( $price_level_amount == $amount ) {
339
+		if ($price_level_amount == $amount) {
340 340
 			return true;
341 341
 		}
342 342
 	}
343 343
 
344
-	$minimum = give_get_form_minimum_price( $form_id );
344
+	$minimum = give_get_form_minimum_price($form_id);
345 345
 
346
-	if ( $minimum > $amount ) {
346
+	if ($minimum > $amount) {
347 347
 		return false;
348 348
 	}
349 349
 
@@ -359,9 +359,9 @@  discard block
 block discarded – undo
359 359
  */
360 360
 function give_purchase_form_validate_agree_to_terms() {
361 361
 	// Validate agree to terms
362
-	if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) {
362
+	if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) {
363 363
 		// User did not agree
364
-		give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', esc_html__( 'You must agree to the terms of use.', 'give' ) ) );
364
+		give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', esc_html__('You must agree to the terms of use.', 'give')));
365 365
 	}
366 366
 }
367 367
 
@@ -375,47 +375,47 @@  discard block
 block discarded – undo
375 375
  *
376 376
  * @return      array
377 377
  */
378
-function give_purchase_form_required_fields( $form_id ) {
378
+function give_purchase_form_required_fields($form_id) {
379 379
 
380
-	$payment_mode = give_get_chosen_gateway( $form_id );
380
+	$payment_mode = give_get_chosen_gateway($form_id);
381 381
 
382 382
 	$required_fields = array(
383 383
 		'give_email' => array(
384 384
 			'error_id'      => 'invalid_email',
385
-			'error_message' => esc_html__( 'Please enter a valid email address.', 'give' )
385
+			'error_message' => esc_html__('Please enter a valid email address.', 'give')
386 386
 		),
387 387
 		'give_first' => array(
388 388
 			'error_id'      => 'invalid_first_name',
389
-			'error_message' => esc_html__( 'Please enter your first name.', 'give' )
389
+			'error_message' => esc_html__('Please enter your first name.', 'give')
390 390
 		)
391 391
 	);
392 392
 
393
-	$require_address = give_require_billing_address( $payment_mode );
393
+	$require_address = give_require_billing_address($payment_mode);
394 394
 
395
-	if ( $require_address ) {
396
-		$required_fields['card_address']    = array(
395
+	if ($require_address) {
396
+		$required_fields['card_address'] = array(
397 397
 			'error_id'      => 'invalid_card_address',
398
-			'error_message' => esc_html__( 'Please enter your primary billing address.', 'give' )
398
+			'error_message' => esc_html__('Please enter your primary billing address.', 'give')
399 399
 		);
400
-		$required_fields['card_zip']        = array(
400
+		$required_fields['card_zip'] = array(
401 401
 			'error_id'      => 'invalid_zip_code',
402
-			'error_message' => esc_html__( 'Please enter your zip / postal code.', 'give' )
402
+			'error_message' => esc_html__('Please enter your zip / postal code.', 'give')
403 403
 		);
404
-		$required_fields['card_city']       = array(
404
+		$required_fields['card_city'] = array(
405 405
 			'error_id'      => 'invalid_city',
406
-			'error_message' => esc_html__( 'Please enter your billing city.', 'give' )
406
+			'error_message' => esc_html__('Please enter your billing city.', 'give')
407 407
 		);
408 408
 		$required_fields['billing_country'] = array(
409 409
 			'error_id'      => 'invalid_country',
410
-			'error_message' => esc_html__( 'Please select your billing country.', 'give' )
410
+			'error_message' => esc_html__('Please select your billing country.', 'give')
411 411
 		);
412
-		$required_fields['card_state']      = array(
412
+		$required_fields['card_state'] = array(
413 413
 			'error_id'      => 'invalid_state',
414
-			'error_message' => esc_html__( 'Please enter billing state / province.', 'give' )
414
+			'error_message' => esc_html__('Please enter billing state / province.', 'give')
415 415
 		);
416 416
 	}
417 417
 
418
-	return apply_filters( 'give_purchase_form_required_fields', $required_fields, $form_id );
418
+	return apply_filters('give_purchase_form_required_fields', $required_fields, $form_id);
419 419
 
420 420
 }
421 421
 
@@ -428,16 +428,16 @@  discard block
 block discarded – undo
428 428
  *
429 429
  * @return mixed|void
430 430
  */
431
-function give_require_billing_address( $payment_mode ) {
431
+function give_require_billing_address($payment_mode) {
432 432
 
433 433
 	$return = false;
434 434
 
435
-	if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) {
435
+	if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) {
436 436
 		$return = true;
437 437
 	}
438 438
 
439 439
 	// Let payment gateways and other extensions determine if address fields should be required
440
-	return apply_filters( 'give_require_billing_address', $return );
440
+	return apply_filters('give_require_billing_address', $return);
441 441
 
442 442
 }
443 443
 
@@ -451,43 +451,43 @@  discard block
 block discarded – undo
451 451
 function give_purchase_form_validate_logged_in_user() {
452 452
 	global $user_ID;
453 453
 
454
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
454
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
455 455
 
456 456
 	// Start empty array to collect valid user data
457 457
 	$valid_user_data = array(
458 458
 		// Assume there will be errors
459
-		'user_id' => - 1
459
+		'user_id' => -1
460 460
 	);
461 461
 
462 462
 	// Verify there is a user_ID
463
-	if ( $user_ID > 0 ) {
463
+	if ($user_ID > 0) {
464 464
 		// Get the logged in user data
465
-		$user_data = get_userdata( $user_ID );
465
+		$user_data = get_userdata($user_ID);
466 466
 
467 467
 		// Loop through required fields and show error messages
468
-		foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) {
469
-			if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
470
-				give_set_error( $value['error_id'], $value['error_message'] );
468
+		foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) {
469
+			if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) {
470
+				give_set_error($value['error_id'], $value['error_message']);
471 471
 			}
472 472
 		}
473 473
 
474 474
 		// Verify data
475
-		if ( $user_data ) {
475
+		if ($user_data) {
476 476
 			// Collected logged in user data
477 477
 			$valid_user_data = array(
478 478
 				'user_id'    => $user_ID,
479
-				'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email,
480
-				'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name,
481
-				'user_last'  => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name,
479
+				'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email,
480
+				'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name,
481
+				'user_last'  => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name,
482 482
 			);
483 483
 
484
-			if ( ! is_email( $valid_user_data['user_email'] ) ) {
485
-				give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
484
+			if ( ! is_email($valid_user_data['user_email'])) {
485
+				give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
486 486
 			}
487 487
 
488 488
 		} else {
489 489
 			// Set invalid user error
490
-			give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) );
490
+			give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give'));
491 491
 		}
492 492
 	}
493 493
 
@@ -505,90 +505,90 @@  discard block
 block discarded – undo
505 505
 function give_purchase_form_validate_new_user() {
506 506
 
507 507
 	$registering_new_user = false;
508
-	$form_id              = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
508
+	$form_id              = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
509 509
 
510 510
 	// Start an empty array to collect valid user data
511 511
 	$valid_user_data = array(
512 512
 		// Assume there will be errors
513
-		'user_id'    => - 1,
513
+		'user_id'    => -1,
514 514
 		// Get first name
515
-		'user_first' => isset( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : '',
515
+		'user_first' => isset($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : '',
516 516
 		// Get last name
517
-		'user_last'  => isset( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : '',
517
+		'user_last'  => isset($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : '',
518 518
 	);
519 519
 
520 520
 	// Check the new user's credentials against existing ones
521
-	$user_login   = isset( $_POST['give_user_login'] ) ? trim( $_POST['give_user_login'] ) : false;
522
-	$user_email   = isset( $_POST['give_email'] ) ? trim( $_POST['give_email'] ) : false;
523
-	$user_pass    = isset( $_POST['give_user_pass'] ) ? trim( $_POST['give_user_pass'] ) : false;
524
-	$pass_confirm = isset( $_POST['give_user_pass_confirm'] ) ? trim( $_POST['give_user_pass_confirm'] ) : false;
521
+	$user_login   = isset($_POST['give_user_login']) ? trim($_POST['give_user_login']) : false;
522
+	$user_email   = isset($_POST['give_email']) ? trim($_POST['give_email']) : false;
523
+	$user_pass    = isset($_POST['give_user_pass']) ? trim($_POST['give_user_pass']) : false;
524
+	$pass_confirm = isset($_POST['give_user_pass_confirm']) ? trim($_POST['give_user_pass_confirm']) : false;
525 525
 
526 526
 	// Loop through required fields and show error messages
527
-	foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) {
528
-		if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
529
-			give_set_error( $value['error_id'], $value['error_message'] );
527
+	foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) {
528
+		if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) {
529
+			give_set_error($value['error_id'], $value['error_message']);
530 530
 		}
531 531
 	}
532 532
 
533 533
 	// Check if we have an username to register
534
-	if ( $user_login && strlen( $user_login ) > 0 ) {
534
+	if ($user_login && strlen($user_login) > 0) {
535 535
 		$registering_new_user = true;
536 536
 
537 537
 		// We have an user name, check if it already exists
538
-		if ( username_exists( $user_login ) ) {
538
+		if (username_exists($user_login)) {
539 539
 			// Username already registered
540
-			give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) );
540
+			give_set_error('username_unavailable', esc_html__('Username already taken.', 'give'));
541 541
 			// Check if it's valid
542
-		} else if ( ! give_validate_username( $user_login ) ) {
542
+		} else if ( ! give_validate_username($user_login)) {
543 543
 			// Invalid username
544
-			if ( is_multisite() ) {
545
-				give_set_error( 'username_invalid', esc_html__( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) );
544
+			if (is_multisite()) {
545
+				give_set_error('username_invalid', esc_html__('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'));
546 546
 			} else {
547
-				give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) );
547
+				give_set_error('username_invalid', esc_html__('Invalid username.', 'give'));
548 548
 			}
549 549
 		} else {
550 550
 			// All the checks have run and it's good to go
551 551
 			$valid_user_data['user_login'] = $user_login;
552 552
 		}
553
-	} elseif ( give_logged_in_only( $form_id ) ) {
554
-		give_set_error( 'registration_required', esc_html__( 'You must register or login to complete your donation.', 'give' ) );
553
+	} elseif (give_logged_in_only($form_id)) {
554
+		give_set_error('registration_required', esc_html__('You must register or login to complete your donation.', 'give'));
555 555
 	}
556 556
 
557 557
 	// Check if we have an email to verify
558
-	if ( $user_email && strlen( $user_email ) > 0 ) {
558
+	if ($user_email && strlen($user_email) > 0) {
559 559
 		// Validate email
560
-		if ( ! is_email( $user_email ) ) {
561
-			give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
560
+		if ( ! is_email($user_email)) {
561
+			give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
562 562
 			// Check if email exists
563
-		} else if ( email_exists( $user_email ) && $registering_new_user ) {
564
-			give_set_error( 'email_used', esc_html__( 'The email already active for another user.', 'give' ) );
563
+		} else if (email_exists($user_email) && $registering_new_user) {
564
+			give_set_error('email_used', esc_html__('The email already active for another user.', 'give'));
565 565
 		} else {
566 566
 			// All the checks have run and it's good to go
567 567
 			$valid_user_data['user_email'] = $user_email;
568 568
 		}
569 569
 	} else {
570 570
 		// No email
571
-		give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) );
571
+		give_set_error('email_empty', esc_html__('Enter an email.', 'give'));
572 572
 	}
573 573
 
574 574
 	// Check password
575
-	if ( $user_pass && $pass_confirm ) {
575
+	if ($user_pass && $pass_confirm) {
576 576
 		// Verify confirmation matches
577
-		if ( $user_pass != $pass_confirm ) {
577
+		if ($user_pass != $pass_confirm) {
578 578
 			// Passwords do not match
579
-			give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) );
579
+			give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give'));
580 580
 		} else {
581 581
 			// All is good to go
582 582
 			$valid_user_data['user_pass'] = $user_pass;
583 583
 		}
584 584
 	} else {
585 585
 		// Password or confirmation missing
586
-		if ( ! $user_pass && $registering_new_user ) {
586
+		if ( ! $user_pass && $registering_new_user) {
587 587
 			// The password is invalid
588
-			give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) );
589
-		} else if ( ! $pass_confirm && $registering_new_user ) {
588
+			give_set_error('password_empty', esc_html__('Enter a password.', 'give'));
589
+		} else if ( ! $pass_confirm && $registering_new_user) {
590 590
 			// Confirmation password is invalid
591
-			give_set_error( 'confirmation_empty', esc_html__( 'Enter the password confirmation.', 'give' ) );
591
+			give_set_error('confirmation_empty', esc_html__('Enter the password confirmation.', 'give'));
592 592
 		}
593 593
 	}
594 594
 
@@ -607,36 +607,36 @@  discard block
 block discarded – undo
607 607
 	// Start an array to collect valid user data
608 608
 	$valid_user_data = array(
609 609
 		// Assume there will be errors
610
-		'user_id' => - 1
610
+		'user_id' => -1
611 611
 	);
612 612
 
613 613
 	// Username
614
-	if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) {
615
-		give_set_error( 'must_log_in', esc_html__( 'You must register or login to complete your donation.', 'give' ) );
614
+	if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') {
615
+		give_set_error('must_log_in', esc_html__('You must register or login to complete your donation.', 'give'));
616 616
 
617 617
 		return $valid_user_data;
618 618
 	}
619 619
 
620 620
 	// Get the user by login
621
-	$user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) );
621
+	$user_data = get_user_by('login', strip_tags($_POST['give_user_login']));
622 622
 
623 623
 	// Check if user exists
624
-	if ( $user_data ) {
624
+	if ($user_data) {
625 625
 		// Get password
626
-		$user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false;
626
+		$user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false;
627 627
 
628 628
 		// Check user_pass
629
-		if ( $user_pass ) {
629
+		if ($user_pass) {
630 630
 			// Check if password is valid
631
-			if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) {
631
+			if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) {
632 632
 				// Incorrect password
633 633
 				give_set_error(
634 634
 					'password_incorrect',
635 635
 					sprintf(
636 636
 						'%1$s <a href="%2$s">%3$s</a>',
637
-						esc_html__( 'The password you entered is incorrect.', 'give' ),
638
-						wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ),
639
-						esc_html__( 'Reset Password', 'give' )
637
+						esc_html__('The password you entered is incorrect.', 'give'),
638
+						wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"),
639
+						esc_html__('Reset Password', 'give')
640 640
 					)
641 641
 				);
642 642
 				// All is correct
@@ -653,11 +653,11 @@  discard block
 block discarded – undo
653 653
 			}
654 654
 		} else {
655 655
 			// Empty password
656
-			give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) );
656
+			give_set_error('password_empty', esc_html__('Enter a password.', 'give'));
657 657
 		}
658 658
 	} else {
659 659
 		// no username
660
-		give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) );
660
+		give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give'));
661 661
 	}
662 662
 
663 663
 	return $valid_user_data;
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
  */
673 673
 function give_purchase_form_validate_guest_user() {
674 674
 
675
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
675
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
676 676
 
677 677
 	// Start an array to collect valid user data
678 678
 	$valid_user_data = array(
@@ -681,32 +681,32 @@  discard block
 block discarded – undo
681 681
 	);
682 682
 
683 683
 	// Show error message if user must be logged in
684
-	if ( give_logged_in_only( $form_id ) ) {
685
-		give_set_error( 'logged_in_only', esc_html__( 'You must be logged in to donate.', 'give' ) );
684
+	if (give_logged_in_only($form_id)) {
685
+		give_set_error('logged_in_only', esc_html__('You must be logged in to donate.', 'give'));
686 686
 	}
687 687
 
688 688
 	// Get the guest email
689
-	$guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false;
689
+	$guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false;
690 690
 
691 691
 	// Check email
692
-	if ( $guest_email && strlen( $guest_email ) > 0 ) {
692
+	if ($guest_email && strlen($guest_email) > 0) {
693 693
 		// Validate email
694
-		if ( ! is_email( $guest_email ) ) {
694
+		if ( ! is_email($guest_email)) {
695 695
 			// Invalid email
696
-			give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
696
+			give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
697 697
 		} else {
698 698
 			// All is good to go
699 699
 			$valid_user_data['user_email'] = $guest_email;
700 700
 		}
701 701
 	} else {
702 702
 		// No email
703
-		give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) );
703
+		give_set_error('email_empty', esc_html__('Enter an email.', 'give'));
704 704
 	}
705 705
 
706 706
 	// Loop through required fields and show error messages
707
-	foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) {
708
-		if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
709
-			give_set_error( $value['error_id'], $value['error_message'] );
707
+	foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) {
708
+		if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) {
709
+			give_set_error($value['error_id'], $value['error_message']);
710 710
 		}
711 711
 	}
712 712
 
@@ -722,36 +722,36 @@  discard block
 block discarded – undo
722 722
  * @since   1.0
723 723
  * @return  integer
724 724
  */
725
-function give_register_and_login_new_user( $user_data = array() ) {
725
+function give_register_and_login_new_user($user_data = array()) {
726 726
 	// Verify the array
727
-	if ( empty( $user_data ) ) {
728
-		return - 1;
727
+	if (empty($user_data)) {
728
+		return -1;
729 729
 	}
730 730
 
731
-	if ( give_get_errors() ) {
732
-		return - 1;
731
+	if (give_get_errors()) {
732
+		return -1;
733 733
 	}
734 734
 
735
-	$user_args = apply_filters( 'give_insert_user_args', array(
736
-		'user_login'      => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '',
737
-		'user_pass'       => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '',
738
-		'user_email'      => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '',
739
-		'first_name'      => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '',
740
-		'last_name'       => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '',
741
-		'user_registered' => date( 'Y-m-d H:i:s' ),
742
-		'role'            => get_option( 'default_role' )
743
-	), $user_data );
735
+	$user_args = apply_filters('give_insert_user_args', array(
736
+		'user_login'      => isset($user_data['user_login']) ? $user_data['user_login'] : '',
737
+		'user_pass'       => isset($user_data['user_pass']) ? $user_data['user_pass'] : '',
738
+		'user_email'      => isset($user_data['user_email']) ? $user_data['user_email'] : '',
739
+		'first_name'      => isset($user_data['user_first']) ? $user_data['user_first'] : '',
740
+		'last_name'       => isset($user_data['user_last']) ? $user_data['user_last'] : '',
741
+		'user_registered' => date('Y-m-d H:i:s'),
742
+		'role'            => get_option('default_role')
743
+	), $user_data);
744 744
 
745 745
 	// Insert new user
746
-	$user_id = wp_insert_user( $user_args );
746
+	$user_id = wp_insert_user($user_args);
747 747
 
748 748
 	// Validate inserted user
749
-	if ( is_wp_error( $user_id ) ) {
750
-		return - 1;
749
+	if (is_wp_error($user_id)) {
750
+		return -1;
751 751
 	}
752 752
 
753 753
 	// Allow themes and plugins to filter the user data
754
-	$user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args );
754
+	$user_data = apply_filters('give_insert_user_data', $user_data, $user_args);
755 755
 
756 756
 	/**
757 757
 	 * Fires after inserting user.
@@ -761,10 +761,10 @@  discard block
 block discarded – undo
761 761
 	 * @param int   $user_id   User id.
762 762
 	 * @param array $user_data Array containing user data.
763 763
 	 */
764
-	do_action( 'give_insert_user', $user_id, $user_data );
764
+	do_action('give_insert_user', $user_id, $user_data);
765 765
 
766 766
 	// Login new user
767
-	give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] );
767
+	give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']);
768 768
 
769 769
 	// Return user id
770 770
 	return $user_id;
@@ -779,27 +779,27 @@  discard block
 block discarded – undo
779 779
  * @since   1.0
780 780
  * @return  array
781 781
  */
782
-function give_get_purchase_form_user( $valid_data = array() ) {
782
+function give_get_purchase_form_user($valid_data = array()) {
783 783
 
784 784
 	// Initialize user
785 785
 	$user    = false;
786
-	$is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
786
+	$is_ajax = defined('DOING_AJAX') && DOING_AJAX;
787 787
 
788
-	if ( $is_ajax ) {
788
+	if ($is_ajax) {
789 789
 		// Do not create or login the user during the ajax submission (check for errors only)
790 790
 		return true;
791
-	} else if ( is_user_logged_in() ) {
791
+	} else if (is_user_logged_in()) {
792 792
 		// Set the valid user as the logged in collected data
793 793
 		$user = $valid_data['logged_in_user'];
794
-	} else if ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) {
794
+	} else if ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) {
795 795
 		// New user registration
796
-		if ( $valid_data['need_new_user'] === true ) {
796
+		if ($valid_data['need_new_user'] === true) {
797 797
 			// Set user
798 798
 			$user = $valid_data['new_user_data'];
799 799
 			// Register and login new user
800
-			$user['user_id'] = give_register_and_login_new_user( $user );
800
+			$user['user_id'] = give_register_and_login_new_user($user);
801 801
 			// User login
802
-		} else if ( $valid_data['need_user_login'] === true && ! $is_ajax ) {
802
+		} else if ($valid_data['need_user_login'] === true && ! $is_ajax) {
803 803
 
804 804
 			/*
805 805
 			 * The login form is now processed in the give_process_purchase_login() function.
@@ -814,48 +814,48 @@  discard block
 block discarded – undo
814 814
 			// Set user
815 815
 			$user = $valid_data['login_user_data'];
816 816
 			// Login user
817
-			give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] );
817
+			give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']);
818 818
 		}
819 819
 	}
820 820
 
821 821
 	// Check guest checkout
822
-	if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) {
822
+	if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) {
823 823
 		// Set user
824 824
 		$user = $valid_data['guest_user_data'];
825 825
 	}
826 826
 
827 827
 	// Verify we have an user
828
-	if ( false === $user || empty( $user ) ) {
828
+	if (false === $user || empty($user)) {
829 829
 		// Return false
830 830
 		return false;
831 831
 	}
832 832
 
833 833
 	// Get user first name
834
-	if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) {
835
-		$user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : '';
834
+	if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) {
835
+		$user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : '';
836 836
 	}
837 837
 
838 838
 	// Get user last name
839
-	if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) {
840
-		$user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : '';
839
+	if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) {
840
+		$user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : '';
841 841
 	}
842 842
 
843 843
 	// Get the user's billing address details
844 844
 	$user['address']            = array();
845
-	$user['address']['line1']   = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false;
846
-	$user['address']['line2']   = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false;
847
-	$user['address']['city']    = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false;
848
-	$user['address']['state']   = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false;
849
-	$user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false;
850
-	$user['address']['zip']     = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false;
851
-
852
-	if ( empty( $user['address']['country'] ) ) {
845
+	$user['address']['line1']   = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false;
846
+	$user['address']['line2']   = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false;
847
+	$user['address']['city']    = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false;
848
+	$user['address']['state']   = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false;
849
+	$user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false;
850
+	$user['address']['zip']     = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false;
851
+
852
+	if (empty($user['address']['country'])) {
853 853
 		$user['address'] = false;
854 854
 	} // Country will always be set if address fields are present
855 855
 
856
-	if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) {
856
+	if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) {
857 857
 		// Store the address in the user's meta so the donation form can be pre-populated with it on return purchases
858
-		update_user_meta( $user['user_id'], '_give_user_address', $user['address'] );
858
+		update_user_meta($user['user_id'], '_give_user_address', $user['address']);
859 859
 	}
860 860
 
861 861
 	// Return valid user
@@ -874,16 +874,16 @@  discard block
 block discarded – undo
874 874
 	$card_data = give_get_purchase_cc_info();
875 875
 
876 876
 	// Validate the card zip
877
-	if ( ! empty( $card_data['card_zip'] ) ) {
878
-		if ( ! give_purchase_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) {
879
-			give_set_error( 'invalid_cc_zip', esc_html__( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) );
877
+	if ( ! empty($card_data['card_zip'])) {
878
+		if ( ! give_purchase_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) {
879
+			give_set_error('invalid_cc_zip', esc_html__('The zip / postal code you entered for your billing address is invalid.', 'give'));
880 880
 		}
881 881
 	}
882 882
 
883 883
 	//Ensure no spaces
884
-	if ( ! empty( $card_data['card_number'] ) ) {
885
-		$card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); //no "+" signs
886
-		$card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces
884
+	if ( ! empty($card_data['card_number'])) {
885
+		$card_data['card_number'] = str_replace('+', '', $card_data['card_number']); //no "+" signs
886
+		$card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces
887 887
 	}
888 888
 
889 889
 	// This should validate card numbers at some point too
@@ -899,17 +899,17 @@  discard block
 block discarded – undo
899 899
  */
900 900
 function give_get_purchase_cc_info() {
901 901
 	$cc_info                   = array();
902
-	$cc_info['card_name']      = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : '';
903
-	$cc_info['card_number']    = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : '';
904
-	$cc_info['card_cvc']       = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : '';
905
-	$cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : '';
906
-	$cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : '';
907
-	$cc_info['card_address']   = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : '';
908
-	$cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : '';
909
-	$cc_info['card_city']      = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : '';
910
-	$cc_info['card_state']     = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : '';
911
-	$cc_info['card_country']   = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : '';
912
-	$cc_info['card_zip']       = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : '';
902
+	$cc_info['card_name']      = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : '';
903
+	$cc_info['card_number']    = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : '';
904
+	$cc_info['card_cvc']       = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : '';
905
+	$cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : '';
906
+	$cc_info['card_exp_year']  = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : '';
907
+	$cc_info['card_address']   = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : '';
908
+	$cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : '';
909
+	$cc_info['card_city']      = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : '';
910
+	$cc_info['card_state']     = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : '';
911
+	$cc_info['card_country']   = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : '';
912
+	$cc_info['card_zip']       = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : '';
913 913
 
914 914
 	// Return cc info
915 915
 	return $cc_info;
@@ -925,14 +925,14 @@  discard block
 block discarded – undo
925 925
  *
926 926
  * @return bool|mixed|void
927 927
  */
928
-function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) {
928
+function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') {
929 929
 	$ret = false;
930 930
 
931
-	if ( empty( $zip ) || empty( $country_code ) ) {
931
+	if (empty($zip) || empty($country_code)) {
932 932
 		return $ret;
933 933
 	}
934 934
 
935
-	$country_code = strtoupper( $country_code );
935
+	$country_code = strtoupper($country_code);
936 936
 
937 937
 	$zip_regex = array(
938 938
 		"AD" => "AD\d{3}",
@@ -1092,11 +1092,11 @@  discard block
 block discarded – undo
1092 1092
 		"ZM" => "\d{5}"
1093 1093
 	);
1094 1094
 
1095
-	if ( ! isset ( $zip_regex[ $country_code ] ) || preg_match( "/" . $zip_regex[ $country_code ] . "/i", $zip ) ) {
1095
+	if ( ! isset ($zip_regex[$country_code]) || preg_match("/".$zip_regex[$country_code]."/i", $zip)) {
1096 1096
 		$ret = true;
1097 1097
 	}
1098 1098
 
1099
-	return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code );
1099
+	return apply_filters('give_is_zip_valid', $ret, $zip, $country_code);
1100 1100
 }
1101 1101
 
1102 1102
 
@@ -1110,37 +1110,37 @@  discard block
 block discarded – undo
1110 1110
  *
1111 1111
  * @return bool
1112 1112
  */
1113
-function give_validate_multi_donation_form_level(  $valid_data, $data ) {
1113
+function give_validate_multi_donation_form_level($valid_data, $data) {
1114 1114
     /* @var Give_Donate_Form $form*/
1115
-    $form = new Give_Donate_Form( $data['give-form-id'] );
1115
+    $form = new Give_Donate_Form($data['give-form-id']);
1116 1116
 
1117 1117
     $donation_level_matched = false;
1118 1118
 
1119
-    if( $form->is_multi_type_donation_form() ) {
1119
+    if ($form->is_multi_type_donation_form()) {
1120 1120
 
1121 1121
         // Bailout.
1122
-        if( ! ( $variable_prices = $form->get_prices() ) ) {
1122
+        if ( ! ($variable_prices = $form->get_prices())) {
1123 1123
             return false;
1124 1124
         }
1125 1125
 
1126 1126
         // Sanitize donation amount.
1127
-        $data['give-amount'] = give_sanitize_amount( $data['give-amount'] );
1127
+        $data['give-amount'] = give_sanitize_amount($data['give-amount']);
1128 1128
 
1129 1129
         // Get number of decimals.
1130 1130
         $default_decimals = give_get_price_decimals();
1131 1131
 
1132
-        if( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ){
1132
+        if ($data['give-amount'] === give_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']), $default_decimals)) {
1133 1133
             return true;
1134 1134
         }
1135 1135
 
1136 1136
         
1137 1137
         // Find correct donation level from all donation levels.
1138
-        foreach ( $variable_prices as $variable_price ) {
1138
+        foreach ($variable_prices as $variable_price) {
1139 1139
             // Sanitize level amount.
1140
-            $variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals );
1140
+            $variable_price['_give_amount'] = give_sanitize_amount($variable_price['_give_amount'], $default_decimals);
1141 1141
 
1142 1142
             // Set first match donation level ID.
1143
-            if( $data['give-amount'] === $variable_price['_give_amount'] ) {
1143
+            if ($data['give-amount'] === $variable_price['_give_amount']) {
1144 1144
                 $_POST['give-price-id'] = $variable_price['_give_id']['level_id'];
1145 1145
                 $donation_level_matched = true;
1146 1146
                 break;
@@ -1149,20 +1149,20 @@  discard block
 block discarded – undo
1149 1149
 
1150 1150
         // If donation amount is not find in donation levels then check if form has custom donation feature enable or not.
1151 1151
         // If yes then set price id to custom if amount is greater then custom minimum amount (if any).
1152
-        if(
1152
+        if (
1153 1153
             ! $donation_level_matched
1154
-            && ( 'yes' === get_post_meta( $data['give-form-id'], '_give_custom_amount', true ) )
1154
+            && ('yes' === get_post_meta($data['give-form-id'], '_give_custom_amount', true))
1155 1155
         ) {
1156 1156
             // Sanitize custom minimum amount.
1157
-            $custom_minimum_amount = give_sanitize_amount( get_post_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals );
1157
+            $custom_minimum_amount = give_sanitize_amount(get_post_meta($data['give-form-id'], '_give_custom_amount_minimum', true), $default_decimals);
1158 1158
 
1159
-            if( $data['give-amount'] >= $custom_minimum_amount ) {
1159
+            if ($data['give-amount'] >= $custom_minimum_amount) {
1160 1160
                 $_POST['give-price-id'] = 'custom';
1161
-                $donation_level_matched  = true;
1161
+                $donation_level_matched = true;
1162 1162
             }
1163 1163
         }
1164 1164
     }
1165 1165
 
1166
-    return ( $donation_level_matched ? true : false );
1166
+    return ($donation_level_matched ? true : false);
1167 1167
 }
1168
-add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 );
1169 1168
\ No newline at end of file
1169
+add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2);
1170 1170
\ No newline at end of file
Please login to merge, or discard this patch.
includes/login-register.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -33,20 +33,20 @@  discard block
 block discarded – undo
33 33
 		$login_redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url());
34 34
 	}
35 35
 
36
-    if ( empty( $logout_redirect ) ) {
37
-        $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() );
38
-    }
36
+	if ( empty( $logout_redirect ) ) {
37
+		$logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() );
38
+	}
39 39
 
40 40
 
41
-    // Add user_logout action to logout url.
42
-    $logout_redirect = add_query_arg(
43
-        array(
44
-            'give_action'       => 'user_logout',
45
-            'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ),
46
-            'give_logout_redirect' => urlencode( $logout_redirect )
47
-        ),
48
-        home_url('/')
49
-    );
41
+	// Add user_logout action to logout url.
42
+	$logout_redirect = add_query_arg(
43
+		array(
44
+			'give_action'       => 'user_logout',
45
+			'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ),
46
+			'give_logout_redirect' => urlencode( $logout_redirect )
47
+		),
48
+		home_url('/')
49
+	);
50 50
 
51 51
 	$give_login_redirect = $login_redirect;
52 52
 	$give_logout_redirect = $logout_redirect;
@@ -136,31 +136,31 @@  discard block
 block discarded – undo
136 136
  * @return void
137 137
  */
138 138
 function give_process_user_logout( $data ) {
139
-    if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) {
139
+	if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) {
140 140
 
141
-        // Prevent occurring of any custom action on wp_logout.
142
-        remove_all_actions( 'wp_logout' );
141
+		// Prevent occurring of any custom action on wp_logout.
142
+		remove_all_actions( 'wp_logout' );
143 143
 
144 144
 		/**
145 145
 		 * Fires before processing user logout.
146 146
 		 *
147 147
 		 * @since 1.0
148 148
 		 */
149
-        do_action( 'give_before_user_logout' );
149
+		do_action( 'give_before_user_logout' );
150 150
 
151
-        // Logout user.
152
-        wp_logout();
151
+		// Logout user.
152
+		wp_logout();
153 153
 
154 154
 		/**
155 155
 		 * Fires after processing user logout.
156 156
 		 *
157 157
 		 * @since 1.0
158 158
 		 */
159
-        do_action( 'give_after_user_logout' );
159
+		do_action( 'give_after_user_logout' );
160 160
 
161
-        wp_redirect( $data['give_logout_redirect'] );
162
-        give_die();
163
-    }
161
+		wp_redirect( $data['give_logout_redirect'] );
162
+		give_die();
163
+	}
164 164
 }
165 165
 
166 166
 add_action( 'give_user_logout', 'give_process_user_logout' );
Please login to merge, or discard this patch.
Spacing   +71 added lines, -71 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,15 +26,15 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @return string Login form
28 28
  */
29
-function give_login_form( $login_redirect = '', $logout_redirect = '' ) {
30
-	global $give_login_redirect, $give_logout_redirect;;
29
+function give_login_form($login_redirect = '', $logout_redirect = '') {
30
+	global $give_login_redirect, $give_logout_redirect; ;
31 31
 
32
-	if ( empty( $login_redirect ) ) {
32
+	if (empty($login_redirect)) {
33 33
 		$login_redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url());
34 34
 	}
35 35
 
36
-    if ( empty( $logout_redirect ) ) {
37
-        $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() );
36
+    if (empty($logout_redirect)) {
37
+        $logout_redirect = add_query_arg('give-logout-success', 'true', give_get_current_page_url());
38 38
     }
39 39
 
40 40
 
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
     $logout_redirect = add_query_arg(
43 43
         array(
44 44
             'give_action'       => 'user_logout',
45
-            'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ),
46
-            'give_logout_redirect' => urlencode( $logout_redirect )
45
+            'give_logout_nonce' => wp_create_nonce('give-logout-nonce'),
46
+            'give_logout_redirect' => urlencode($logout_redirect)
47 47
         ),
48 48
         home_url('/')
49 49
     );
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 
54 54
 	ob_start();
55 55
 
56
-	give_get_template_part( 'shortcode', 'login' );
56
+	give_get_template_part('shortcode', 'login');
57 57
 
58
-	return apply_filters( 'give_login_form', ob_get_clean() );
58
+	return apply_filters('give_login_form', ob_get_clean());
59 59
 }
60 60
 
61 61
 /**
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
69 69
  *
70 70
  * @return string Register form
71 71
  */
72
-function give_register_form( $redirect = '' ) {
72
+function give_register_form($redirect = '') {
73 73
 	global $give_options, $give_register_redirect;
74 74
 
75
-	if ( empty( $redirect ) ) {
75
+	if (empty($redirect)) {
76 76
 		$redirect = give_get_current_page_url();
77 77
 	}
78 78
 
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 
81 81
 	ob_start();
82 82
 
83
-	if ( ! is_user_logged_in() ) {
84
-		give_get_template_part( 'shortcode', 'register' );
83
+	if ( ! is_user_logged_in()) {
84
+		give_get_template_part('shortcode', 'register');
85 85
 	}
86 86
 
87
-	return apply_filters( 'give_register_form', ob_get_clean() );
87
+	return apply_filters('give_register_form', ob_get_clean());
88 88
 }
89 89
 
90 90
 /**
@@ -96,34 +96,34 @@  discard block
 block discarded – undo
96 96
  *
97 97
  * @return void
98 98
  */
99
-function give_process_login_form( $data ) {
100
-	if ( wp_verify_nonce( $data['give_login_nonce'], 'give-login-nonce' ) ) {
101
-		$user_data = get_user_by( 'login', $data['give_user_login'] );
102
-		if ( ! $user_data ) {
103
-			$user_data = get_user_by( 'email', $data['give_user_login'] );
99
+function give_process_login_form($data) {
100
+	if (wp_verify_nonce($data['give_login_nonce'], 'give-login-nonce')) {
101
+		$user_data = get_user_by('login', $data['give_user_login']);
102
+		if ( ! $user_data) {
103
+			$user_data = get_user_by('email', $data['give_user_login']);
104 104
 		}
105
-		if ( $user_data ) {
105
+		if ($user_data) {
106 106
 			$user_ID    = $user_data->ID;
107 107
 			$user_email = $user_data->user_email;
108
-			if ( wp_check_password( $data['give_user_pass'], $user_data->user_pass, $user_data->ID ) ) {
109
-				give_log_user_in( $user_data->ID, $data['give_user_login'], $data['give_user_pass'] );
108
+			if (wp_check_password($data['give_user_pass'], $user_data->user_pass, $user_data->ID)) {
109
+				give_log_user_in($user_data->ID, $data['give_user_login'], $data['give_user_pass']);
110 110
 			} else {
111
-				give_set_error( 'password_incorrect', esc_html__( 'The password you entered is incorrect.', 'give' ) );
111
+				give_set_error('password_incorrect', esc_html__('The password you entered is incorrect.', 'give'));
112 112
 			}
113 113
 		} else {
114
-			give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) );
114
+			give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give'));
115 115
 		}
116 116
 		// Check for errors and redirect if none present
117 117
 		$errors = give_get_errors();
118
-		if ( ! $errors ) {
119
-			$redirect = apply_filters( 'give_login_redirect', $data['give_login_redirect'], $user_ID );
120
-			wp_redirect( $redirect );
118
+		if ( ! $errors) {
119
+			$redirect = apply_filters('give_login_redirect', $data['give_login_redirect'], $user_ID);
120
+			wp_redirect($redirect);
121 121
 			give_die();
122 122
 		}
123 123
 	}
124 124
 }
125 125
 
126
-add_action( 'give_user_login', 'give_process_login_form' );
126
+add_action('give_user_login', 'give_process_login_form');
127 127
 
128 128
 
129 129
 /**
@@ -135,18 +135,18 @@  discard block
 block discarded – undo
135 135
  *
136 136
  * @return void
137 137
  */
138
-function give_process_user_logout( $data ) {
139
-    if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) {
138
+function give_process_user_logout($data) {
139
+    if (wp_verify_nonce($data['give_logout_nonce'], 'give-logout-nonce') && is_user_logged_in()) {
140 140
 
141 141
         // Prevent occurring of any custom action on wp_logout.
142
-        remove_all_actions( 'wp_logout' );
142
+        remove_all_actions('wp_logout');
143 143
 
144 144
 		/**
145 145
 		 * Fires before processing user logout.
146 146
 		 *
147 147
 		 * @since 1.0
148 148
 		 */
149
-        do_action( 'give_before_user_logout' );
149
+        do_action('give_before_user_logout');
150 150
 
151 151
         // Logout user.
152 152
         wp_logout();
@@ -156,14 +156,14 @@  discard block
 block discarded – undo
156 156
 		 *
157 157
 		 * @since 1.0
158 158
 		 */
159
-        do_action( 'give_after_user_logout' );
159
+        do_action('give_after_user_logout');
160 160
 
161
-        wp_redirect( $data['give_logout_redirect'] );
161
+        wp_redirect($data['give_logout_redirect']);
162 162
         give_die();
163 163
     }
164 164
 }
165 165
 
166
-add_action( 'give_user_logout', 'give_process_user_logout' );
166
+add_action('give_user_logout', 'give_process_user_logout');
167 167
 
168 168
 /**
169 169
  * Log User In
@@ -176,13 +176,13 @@  discard block
 block discarded – undo
176 176
  *
177 177
  * @return void
178 178
  */
179
-function give_log_user_in( $user_id, $user_login, $user_pass ) {
180
-	if ( $user_id < 1 ) {
179
+function give_log_user_in($user_id, $user_login, $user_pass) {
180
+	if ($user_id < 1) {
181 181
 		return;
182 182
 	}
183 183
 
184
-	wp_set_auth_cookie( $user_id );
185
-	wp_set_current_user( $user_id, $user_login );
184
+	wp_set_auth_cookie($user_id);
185
+	wp_set_current_user($user_id, $user_login);
186 186
 
187 187
 	/**
188 188
 	 * Fires after the user has successfully logged in.
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 * @param string  $user_login Username.
193 193
 	 * @param WP_User $$user      WP_User object of the logged-in user.
194 194
 	 */
195
-	do_action( 'wp_login', $user_login, get_userdata( $user_id ) );
195
+	do_action('wp_login', $user_login, get_userdata($user_id));
196 196
 
197 197
 	/**
198 198
 	 * Fires after give user has successfully logged in.
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 * @param string $user_login Username.
204 204
 	 * @param string $user_pass  User password.
205 205
 	 */
206
-	do_action( 'give_log_user_in', $user_id, $user_login, $user_pass );
206
+	do_action('give_log_user_in', $user_id, $user_login, $user_pass);
207 207
 }
208 208
 
209 209
 
@@ -216,13 +216,13 @@  discard block
 block discarded – undo
216 216
  *
217 217
  * @return void
218 218
  */
219
-function give_process_register_form( $data ) {
219
+function give_process_register_form($data) {
220 220
 
221
-	if ( is_user_logged_in() ) {
221
+	if (is_user_logged_in()) {
222 222
 		return;
223 223
 	}
224 224
 
225
-	if ( empty( $_POST['give_register_submit'] ) ) {
225
+	if (empty($_POST['give_register_submit'])) {
226 226
 		return;
227 227
 	}
228 228
 
@@ -231,38 +231,38 @@  discard block
 block discarded – undo
231 231
 	 *
232 232
 	 * @since 1.0
233 233
 	 */
234
-	do_action( 'give_pre_process_register_form' );
234
+	do_action('give_pre_process_register_form');
235 235
 
236
-	if ( empty( $data['give_user_login'] ) ) {
237
-		give_set_error( 'empty_username', esc_html__( 'Invalid username.', 'give' ) );
236
+	if (empty($data['give_user_login'])) {
237
+		give_set_error('empty_username', esc_html__('Invalid username.', 'give'));
238 238
 	}
239 239
 
240
-	if ( username_exists( $data['give_user_login'] ) ) {
241
-		give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) );
240
+	if (username_exists($data['give_user_login'])) {
241
+		give_set_error('username_unavailable', esc_html__('Username already taken.', 'give'));
242 242
 	}
243 243
 
244
-	if ( ! validate_username( $data['give_user_login'] ) ) {
245
-		give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) );
244
+	if ( ! validate_username($data['give_user_login'])) {
245
+		give_set_error('username_invalid', esc_html__('Invalid username.', 'give'));
246 246
 	}
247 247
 
248
-	if ( email_exists( $data['give_user_email'] ) ) {
249
-		give_set_error( 'email_unavailable', esc_html__( 'Email address already taken.', 'give' ) );
248
+	if (email_exists($data['give_user_email'])) {
249
+		give_set_error('email_unavailable', esc_html__('Email address already taken.', 'give'));
250 250
 	}
251 251
 
252
-	if ( empty( $data['give_user_email'] ) || ! is_email( $data['give_user_email'] ) ) {
253
-		give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
252
+	if (empty($data['give_user_email']) || ! is_email($data['give_user_email'])) {
253
+		give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
254 254
 	}
255 255
 
256
-	if ( ! empty( $data['give_payment_email'] ) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email( $data['give_payment_email'] ) ) {
257
-		give_set_error( 'payment_email_invalid', esc_html__( 'Invalid payment email.', 'give' ) );
256
+	if ( ! empty($data['give_payment_email']) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email($data['give_payment_email'])) {
257
+		give_set_error('payment_email_invalid', esc_html__('Invalid payment email.', 'give'));
258 258
 	}
259 259
 
260
-	if ( empty( $_POST['give_user_pass'] ) ) {
261
-		give_set_error( 'empty_password', esc_html__( 'Please enter a password.', 'give' ) );
260
+	if (empty($_POST['give_user_pass'])) {
261
+		give_set_error('empty_password', esc_html__('Please enter a password.', 'give'));
262 262
 	}
263 263
 
264
-	if ( ( ! empty( $_POST['give_user_pass'] ) && empty( $_POST['give_user_pass2'] ) ) || ( $_POST['give_user_pass'] !== $_POST['give_user_pass2'] ) ) {
265
-		give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) );
264
+	if (( ! empty($_POST['give_user_pass']) && empty($_POST['give_user_pass2'])) || ($_POST['give_user_pass'] !== $_POST['give_user_pass2'])) {
265
+		give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give'));
266 266
 	}
267 267
 
268 268
 	/**
@@ -270,26 +270,26 @@  discard block
 block discarded – undo
270 270
 	 *
271 271
 	 * @since 1.0
272 272
 	 */
273
-	do_action( 'give_process_register_form' );
273
+	do_action('give_process_register_form');
274 274
 
275 275
 	// Check for errors and redirect if none present
276 276
 	$errors = give_get_errors();
277 277
 
278
-	if ( empty( $errors ) ) {
278
+	if (empty($errors)) {
279 279
 
280
-		$redirect = apply_filters( 'give_register_redirect', $data['give_redirect'] );
280
+		$redirect = apply_filters('give_register_redirect', $data['give_redirect']);
281 281
 
282
-		give_register_and_login_new_user( array(
282
+		give_register_and_login_new_user(array(
283 283
 			'user_login'      => $data['give_user_login'],
284 284
 			'user_pass'       => $data['give_user_pass'],
285 285
 			'user_email'      => $data['give_user_email'],
286
-			'user_registered' => date( 'Y-m-d H:i:s' ),
287
-			'role'            => get_option( 'default_role' )
288
-		) );
286
+			'user_registered' => date('Y-m-d H:i:s'),
287
+			'role'            => get_option('default_role')
288
+		));
289 289
 
290
-		wp_redirect( $redirect );
290
+		wp_redirect($redirect);
291 291
 		give_die();
292 292
 	}
293 293
 }
294 294
 
295
-add_action( 'give_user_register', 'give_process_register_form' );
296 295
\ No newline at end of file
296
+add_action('give_user_register', 'give_process_register_form');
297 297
\ No newline at end of file
Please login to merge, or discard this patch.