Completed
Pull Request — master (#703)
by
unknown
17:23
created
includes/error-tracking.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@
 block discarded – undo
65 65
  *
66 66
  * @since 1.0
67 67
  * @uses  Give_Session::get()
68
- * @return mixed array if errors are present, false if none found
68
+ * @return string array if errors are present, false if none found
69 69
  */
70 70
 function give_get_errors() {
71 71
 	return Give()->session->get( 'give_errors' );
Please login to merge, or discard this patch.
includes/login-register.php 2 patches
Indentation   +24 added lines, -24 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,23 +136,23 @@  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
-        // Before logout give action.
145
-        do_action( 'give_before_user_logout' );
144
+		// Before logout give action.
145
+		do_action( 'give_before_user_logout' );
146 146
 
147
-        // Logout user.
148
-        wp_logout();
147
+		// Logout user.
148
+		wp_logout();
149 149
 
150
-        // After logout give action.
151
-        do_action( 'give_after_user_logout' );
150
+		// After logout give action.
151
+		do_action( 'give_after_user_logout' );
152 152
 
153
-        wp_redirect( $data['give_logout_redirect'] );
154
-        give_die();
155
-    }
153
+		wp_redirect( $data['give_logout_redirect'] );
154
+		give_die();
155
+	}
156 156
 }
157 157
 
158 158
 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', __( 'The password you entered is incorrect', 'give' ) );
111
+				give_set_error('password_incorrect', __('The password you entered is incorrect', 'give'));
112 112
 			}
113 113
 		} else {
114
-			give_set_error( 'username_incorrect', __( 'The username you entered does not exist', 'give' ) );
114
+			give_set_error('username_incorrect', __('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,27 +135,27 @@  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
         // Before logout give action.
145
-        do_action( 'give_before_user_logout' );
145
+        do_action('give_before_user_logout');
146 146
 
147 147
         // Logout user.
148 148
         wp_logout();
149 149
 
150 150
         // After logout give action.
151
-        do_action( 'give_after_user_logout' );
151
+        do_action('give_after_user_logout');
152 152
 
153
-        wp_redirect( $data['give_logout_redirect'] );
153
+        wp_redirect($data['give_logout_redirect']);
154 154
         give_die();
155 155
     }
156 156
 }
157 157
 
158
-add_action( 'give_user_logout', 'give_process_user_logout' );
158
+add_action('give_user_logout', 'give_process_user_logout');
159 159
 
160 160
 /**
161 161
  * Log User In
@@ -168,15 +168,15 @@  discard block
 block discarded – undo
168 168
  *
169 169
  * @return void
170 170
  */
171
-function give_log_user_in( $user_id, $user_login, $user_pass ) {
172
-	if ( $user_id < 1 ) {
171
+function give_log_user_in($user_id, $user_login, $user_pass) {
172
+	if ($user_id < 1) {
173 173
 		return;
174 174
 	}
175 175
 
176
-	wp_set_auth_cookie( $user_id );
177
-	wp_set_current_user( $user_id, $user_login );
178
-	do_action( 'wp_login', $user_login, get_userdata( $user_id ) );
179
-	do_action( 'give_log_user_in', $user_id, $user_login, $user_pass );
176
+	wp_set_auth_cookie($user_id);
177
+	wp_set_current_user($user_id, $user_login);
178
+	do_action('wp_login', $user_login, get_userdata($user_id));
179
+	do_action('give_log_user_in', $user_id, $user_login, $user_pass);
180 180
 }
181 181
 
182 182
 
@@ -189,70 +189,70 @@  discard block
 block discarded – undo
189 189
  *
190 190
  * @return void
191 191
  */
192
-function give_process_register_form( $data ) {
192
+function give_process_register_form($data) {
193 193
 
194
-	if ( is_user_logged_in() ) {
194
+	if (is_user_logged_in()) {
195 195
 		return;
196 196
 	}
197 197
 
198
-	if ( empty( $_POST['give_register_submit'] ) ) {
198
+	if (empty($_POST['give_register_submit'])) {
199 199
 		return;
200 200
 	}
201 201
 
202
-	do_action( 'give_pre_process_register_form' );
202
+	do_action('give_pre_process_register_form');
203 203
 
204
-	if ( empty( $data['give_user_login'] ) ) {
205
-		give_set_error( 'empty_username', __( 'Invalid username', 'give' ) );
204
+	if (empty($data['give_user_login'])) {
205
+		give_set_error('empty_username', __('Invalid username', 'give'));
206 206
 	}
207 207
 
208
-	if ( username_exists( $data['give_user_login'] ) ) {
209
-		give_set_error( 'username_unavailable', __( 'Username already taken', 'give' ) );
208
+	if (username_exists($data['give_user_login'])) {
209
+		give_set_error('username_unavailable', __('Username already taken', 'give'));
210 210
 	}
211 211
 
212
-	if ( ! validate_username( $data['give_user_login'] ) ) {
213
-		give_set_error( 'username_invalid', __( 'Invalid username', 'give' ) );
212
+	if ( ! validate_username($data['give_user_login'])) {
213
+		give_set_error('username_invalid', __('Invalid username', 'give'));
214 214
 	}
215 215
 
216
-	if ( email_exists( $data['give_user_email'] ) ) {
217
-		give_set_error( 'email_unavailable', __( 'Email address already taken', 'give' ) );
216
+	if (email_exists($data['give_user_email'])) {
217
+		give_set_error('email_unavailable', __('Email address already taken', 'give'));
218 218
 	}
219 219
 
220
-	if ( empty( $data['give_user_email'] ) || ! is_email( $data['give_user_email'] ) ) {
221
-		give_set_error( 'email_invalid', __( 'Invalid email', 'give' ) );
220
+	if (empty($data['give_user_email']) || ! is_email($data['give_user_email'])) {
221
+		give_set_error('email_invalid', __('Invalid email', 'give'));
222 222
 	}
223 223
 
224
-	if ( ! empty( $data['give_payment_email'] ) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email( $data['give_payment_email'] ) ) {
225
-		give_set_error( 'payment_email_invalid', __( 'Invalid payment email', 'give' ) );
224
+	if ( ! empty($data['give_payment_email']) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email($data['give_payment_email'])) {
225
+		give_set_error('payment_email_invalid', __('Invalid payment email', 'give'));
226 226
 	}
227 227
 
228
-	if ( empty( $_POST['give_user_pass'] ) ) {
229
-		give_set_error( 'empty_password', __( 'Please enter a password', 'give' ) );
228
+	if (empty($_POST['give_user_pass'])) {
229
+		give_set_error('empty_password', __('Please enter a password', 'give'));
230 230
 	}
231 231
 
232
-	if ( ( ! empty( $_POST['give_user_pass'] ) && empty( $_POST['give_user_pass2'] ) ) || ( $_POST['give_user_pass'] !== $_POST['give_user_pass2'] ) ) {
233
-		give_set_error( 'password_mismatch', __( 'Passwords do not match', 'give' ) );
232
+	if (( ! empty($_POST['give_user_pass']) && empty($_POST['give_user_pass2'])) || ($_POST['give_user_pass'] !== $_POST['give_user_pass2'])) {
233
+		give_set_error('password_mismatch', __('Passwords do not match', 'give'));
234 234
 	}
235 235
 
236
-	do_action( 'give_process_register_form' );
236
+	do_action('give_process_register_form');
237 237
 
238 238
 	// Check for errors and redirect if none present
239 239
 	$errors = give_get_errors();
240 240
 
241
-	if ( empty( $errors ) ) {
241
+	if (empty($errors)) {
242 242
 
243
-		$redirect = apply_filters( 'give_register_redirect', $data['give_redirect'] );
243
+		$redirect = apply_filters('give_register_redirect', $data['give_redirect']);
244 244
 
245
-		give_register_and_login_new_user( array(
245
+		give_register_and_login_new_user(array(
246 246
 			'user_login'      => $data['give_user_login'],
247 247
 			'user_pass'       => $data['give_user_pass'],
248 248
 			'user_email'      => $data['give_user_email'],
249
-			'user_registered' => date( 'Y-m-d H:i:s' ),
250
-			'role'            => get_option( 'default_role' )
251
-		) );
249
+			'user_registered' => date('Y-m-d H:i:s'),
250
+			'role'            => get_option('default_role')
251
+		));
252 252
 
253
-		wp_redirect( $redirect );
253
+		wp_redirect($redirect);
254 254
 		give_die();
255 255
 	}
256 256
 }
257 257
 
258
-add_action( 'give_user_register', 'give_process_register_form' );
259 258
\ No newline at end of file
259
+add_action('give_user_register', 'give_process_register_form');
260 260
\ No newline at end of file
Please login to merge, or discard this patch.
includes/api/class-give-api.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1437,7 +1437,7 @@  discard block
 block discarded – undo
1437 1437
 	 * Determines whether results should be displayed in XML or JSON
1438 1438
 	 *
1439 1439
 	 * @since 1.1
1440
-     * @access public
1440
+	 * @access public
1441 1441
 	 *
1442 1442
 	 * @return mixed|void
1443 1443
 	 */
@@ -1455,7 +1455,7 @@  discard block
 block discarded – undo
1455 1455
 	 *
1456 1456
 	 * @access private
1457 1457
 	 * @since  1.1
1458
-     *
1458
+	 *
1459 1459
 	 * @global Give_Logging $give_logs
1460 1460
 	 * @global WP_Query     $wp_query
1461 1461
 	 *
@@ -1468,15 +1468,15 @@  discard block
 block discarded – undo
1468 1468
 			return;
1469 1469
 		}
1470 1470
 
1471
-        /**
1472
-         * @var Give_Logging $give_logs
1473
-         */
1471
+		/**
1472
+		 * @var Give_Logging $give_logs
1473
+		 */
1474 1474
 		global $give_logs;
1475 1475
 
1476
-        /**
1477
-         * @var WP_Query $wp_query
1478
-         */
1479
-        global $wp_query;
1476
+		/**
1477
+		 * @var WP_Query $wp_query
1478
+		 */
1479
+		global $wp_query;
1480 1480
 
1481 1481
 		$query = array(
1482 1482
 			'give-api'    => $wp_query->query_vars['give-api'],
@@ -1534,9 +1534,9 @@  discard block
 block discarded – undo
1534 1534
 	 * @param int $status_code
1535 1535
 	 */
1536 1536
 	public function output( $status_code = 200 ) {
1537
-        /**
1538
-         * @var WP_Query $wp_query
1539
-         */
1537
+		/**
1538
+		 * @var WP_Query $wp_query
1539
+		 */
1540 1540
 		global $wp_query;
1541 1541
 
1542 1542
 		$format = $this->get_output_format();
Please login to merge, or discard this patch.
includes/admin/shortcodes/shortcode-give-login.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -42,16 +42,16 @@
 block discarded – undo
42 42
 				'minWidth' => 320,
43 43
 				'tooltip'  => __( 'Enter an URL here to redirect to after login.', 'give' ),
44 44
 			),
45
-            array(
46
-                'type' => 'container',
47
-                'html' => sprintf( '<p class="no-margin">%s</p>', __( 'Logout Redirect URL (optional):', 'give' ) ),
48
-            ),
49
-            array(
50
-                'type'     => 'textbox',
51
-                'name'     => 'logout-redirect',
52
-                'minWidth' => 320,
53
-                'tooltip'  => __( 'Enter an URL here to redirect to after logout.', 'give' ),
54
-            ),
45
+			array(
46
+				'type' => 'container',
47
+				'html' => sprintf( '<p class="no-margin">%s</p>', __( 'Logout Redirect URL (optional):', 'give' ) ),
48
+			),
49
+			array(
50
+				'type'     => 'textbox',
51
+				'name'     => 'logout-redirect',
52
+				'minWidth' => 320,
53
+				'tooltip'  => __( 'Enter an URL here to redirect to after logout.', 'give' ),
54
+			),
55 55
 		);
56 56
 	}
57 57
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  * @since       1.3.0
10 10
  */
11 11
 
12
-defined( 'ABSPATH' ) or exit;
12
+defined('ABSPATH') or exit;
13 13
 
14 14
 class Give_Shortcode_Login extends Give_Shortcode_Generator {
15 15
 
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
 	 */
19 19
 	public function __construct() {
20 20
 
21
-		$this->shortcode['title'] = __( 'Login', 'give' );
22
-		$this->shortcode['label'] = __( 'Login', 'give' );
21
+		$this->shortcode['title'] = __('Login', 'give');
22
+		$this->shortcode['label'] = __('Login', 'give');
23 23
 
24
-		parent::__construct( 'give_login' );
24
+		parent::__construct('give_login');
25 25
 	}
26 26
 
27 27
 	/**
@@ -34,23 +34,23 @@  discard block
 block discarded – undo
34 34
 		return array(
35 35
 			array(
36 36
 				'type' => 'container',
37
-				'html' => sprintf( '<p class="no-margin">%s</p>', __( 'Login Redirect URL (optional):', 'give' ) ),
37
+				'html' => sprintf('<p class="no-margin">%s</p>', __('Login Redirect URL (optional):', 'give')),
38 38
 			),
39 39
 			array(
40 40
 				'type'     => 'textbox',
41 41
 				'name'     => 'login-redirect',
42 42
 				'minWidth' => 320,
43
-				'tooltip'  => __( 'Enter an URL here to redirect to after login.', 'give' ),
43
+				'tooltip'  => __('Enter an URL here to redirect to after login.', 'give'),
44 44
 			),
45 45
             array(
46 46
                 'type' => 'container',
47
-                'html' => sprintf( '<p class="no-margin">%s</p>', __( 'Logout Redirect URL (optional):', 'give' ) ),
47
+                'html' => sprintf('<p class="no-margin">%s</p>', __('Logout Redirect URL (optional):', 'give')),
48 48
             ),
49 49
             array(
50 50
                 'type'     => 'textbox',
51 51
                 'name'     => 'logout-redirect',
52 52
                 'minWidth' => 320,
53
-                'tooltip'  => __( 'Enter an URL here to redirect to after logout.', 'give' ),
53
+                'tooltip'  => __('Enter an URL here to redirect to after logout.', 'give'),
54 54
             ),
55 55
 		);
56 56
 	}
Please login to merge, or discard this patch.
includes/shortcodes.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
 		//validate display_style and float_labels value
93 93
 		if ( ( $key == 'display_style' && ! in_array( $value, array( 'onpage', 'reveal', 'modal' ) ) )
94
-		     || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) )
94
+			 || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) )
95 95
 		) {
96 96
 
97 97
 			$atts[ $key ] = '';
@@ -169,15 +169,15 @@  discard block
 block discarded – undo
169 169
  */
170 170
 function give_login_form_shortcode( $atts, $content = null ) {
171 171
 	$atts = shortcode_atts( array(
172
-        // Add backward compatibility for redirect attribute.
173
-        'redirect'          => '',
172
+		// Add backward compatibility for redirect attribute.
173
+		'redirect'          => '',
174 174
 
175 175
 		'login-redirect'    => '',
176 176
 		'logout-redirect'   => '',
177 177
 	), $atts, 'give_login' );
178 178
 
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'] : '' );
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'] : '' );
181 181
 
182 182
 	return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] );
183 183
 }
Please login to merge, or discard this 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 = __( '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 = __('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( __( 'Error: No Donation form ID for the shortcode provided.', 'give' ), true );
135
+	if (empty($atts['id'])) {
136
+		give_output_error(__('Error: No Donation form ID for the shortcode provided.', 'give'), true);
137 137
 	}
138 138
 
139 139
 	//Sanity check 2: Check that this form even has Goals enabled
140
-	$goal_option = get_post_meta( $atts['id'], '_give_goal_option', true );
141
-	if ( empty( $goal_option ) || $goal_option !== 'yes' ) {
142
-		give_output_error( __( 'Error: This form does not have Goals enabled.', 'give' ), true );
140
+	$goal_option = get_post_meta($atts['id'], '_give_goal_option', true);
141
+	if (empty($goal_option) || $goal_option !== 'yes') {
142
+		give_output_error(__('Error: This form does not have Goals enabled.', 'give'), true);
143 143
 	} else {
144 144
 		//Passed all sanity checks: output Goal
145
-		give_show_goal_progress( $atts['id'], $atts );
145
+		give_show_goal_progress($atts['id'], $atts);
146 146
 	}
147 147
 
148 148
 	$final_output = ob_get_clean();
149 149
 
150
-	return apply_filters( 'give_goal_shortcode_output', $final_output, $atts );
150
+	return apply_filters('give_goal_shortcode_output', $final_output, $atts);
151 151
 }
152 152
 
153
-add_shortcode( 'give_goal', 'give_goal_shortcode' );
153
+add_shortcode('give_goal', 'give_goal_shortcode');
154 154
 
155 155
 
156 156
 /**
@@ -167,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__( 'Sorry, you are missing the payment key to view this donation receipt.', 'give' ),
227
+	$give_receipt_args = shortcode_atts(array(
228
+		'error'          => esc_html__('Sorry, 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
 
@@ -302,13 +302,13 @@  discard block
 block discarded – undo
302 302
 	 * Or if user is logged in and the user can view sensitive shop data
303 303
 	 *
304 304
 	 */
305
-	if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) {
306
-		return give_output_error( $give_receipt_args['error'], false, 'error' );
305
+	if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) {
306
+		return give_output_error($give_receipt_args['error'], false, 'error');
307 307
 	}
308 308
 
309 309
 	ob_start();
310 310
 
311
-	give_get_template_part( 'shortcode', 'receipt' );
311
+	give_get_template_part('shortcode', 'receipt');
312 312
 
313 313
 	$display = ob_get_clean();
314 314
 
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 
318 318
 }
319 319
 
320
-add_shortcode( 'give_receipt', 'give_receipt_shortcode' );
320
+add_shortcode('give_receipt', 'give_receipt_shortcode');
321 321
 
322 322
 /**
323 323
  * Profile Editor Shortcode
@@ -337,18 +337,18 @@  discard block
 block discarded – undo
337 337
  *
338 338
  * @return string Output generated from the profile editor
339 339
  */
340
-function give_profile_editor_shortcode( $atts, $content = null ) {
340
+function give_profile_editor_shortcode($atts, $content = null) {
341 341
 
342 342
 	ob_start();
343 343
 
344
-	give_get_template_part( 'shortcode', 'profile-editor' );
344
+	give_get_template_part('shortcode', 'profile-editor');
345 345
 
346 346
 	$display = ob_get_clean();
347 347
 
348 348
 	return $display;
349 349
 }
350 350
 
351
-add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' );
351
+add_shortcode('give_profile_editor', 'give_profile_editor_shortcode');
352 352
 
353 353
 /**
354 354
  * Process Profile Updater Form
@@ -361,30 +361,30 @@  discard block
 block discarded – undo
361 361
  *
362 362
  * @return false
363 363
  */
364
-function give_process_profile_editor_updates( $data ) {
364
+function give_process_profile_editor_updates($data) {
365 365
 	// Profile field change request
366
-	if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) {
366
+	if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) {
367 367
 		return false;
368 368
 	}
369 369
 
370 370
 	// Nonce security
371
-	if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) {
371
+	if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) {
372 372
 		return false;
373 373
 	}
374 374
 
375 375
 	$user_id       = get_current_user_id();
376
-	$old_user_data = get_userdata( $user_id );
377
-
378
-	$display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name;
379
-	$first_name   = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name;
380
-	$last_name    = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name;
381
-	$email        = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email;
382
-	$line1        = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' );
383
-	$line2        = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' );
384
-	$city         = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' );
385
-	$state        = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' );
386
-	$zip          = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' );
387
-	$country      = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' );
376
+	$old_user_data = get_userdata($user_id);
377
+
378
+	$display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name;
379
+	$first_name   = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name;
380
+	$last_name    = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name;
381
+	$email        = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email;
382
+	$line1        = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : '');
383
+	$line2        = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : '');
384
+	$city         = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : '');
385
+	$state        = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : '');
386
+	$zip          = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : '');
387
+	$country      = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : '');
388 388
 
389 389
 	$userdata = array(
390 390
 		'ID'           => $user_id,
@@ -404,45 +404,45 @@  discard block
 block discarded – undo
404 404
 		'country' => $country
405 405
 	);
406 406
 
407
-	do_action( 'give_pre_update_user_profile', $user_id, $userdata );
407
+	do_action('give_pre_update_user_profile', $user_id, $userdata);
408 408
 
409 409
 	// New password
410
-	if ( ! empty( $data['give_new_user_pass1'] ) ) {
411
-		if ( $data['give_new_user_pass1'] !== $data['give_new_user_pass2'] ) {
412
-			give_set_error( 'password_mismatch', __( 'The passwords you entered do not match. Please try again.', 'give' ) );
410
+	if ( ! empty($data['give_new_user_pass1'])) {
411
+		if ($data['give_new_user_pass1'] !== $data['give_new_user_pass2']) {
412
+			give_set_error('password_mismatch', __('The passwords you entered do not match. Please try again.', 'give'));
413 413
 		} else {
414 414
 			$userdata['user_pass'] = $data['give_new_user_pass1'];
415 415
 		}
416 416
 	}
417 417
 
418 418
 	// Make sure the new email doesn't belong to another user
419
-	if ( $email != $old_user_data->user_email ) {
420
-		if ( email_exists( $email ) ) {
421
-			give_set_error( 'email_exists', __( 'The email you entered belongs to another user. Please use another.', 'give' ) );
419
+	if ($email != $old_user_data->user_email) {
420
+		if (email_exists($email)) {
421
+			give_set_error('email_exists', __('The email you entered belongs to another user. Please use another.', 'give'));
422 422
 		}
423 423
 	}
424 424
 
425 425
 	// Check for errors
426 426
 	$errors = give_get_errors();
427 427
 
428
-	if ( $errors ) {
428
+	if ($errors) {
429 429
 		// Send back to the profile editor if there are errors
430
-		wp_redirect( $data['give_redirect'] );
430
+		wp_redirect($data['give_redirect']);
431 431
 		give_die();
432 432
 	}
433 433
 
434 434
 	// Update the user
435
-	$meta    = update_user_meta( $user_id, '_give_user_address', $address );
436
-	$updated = wp_update_user( $userdata );
435
+	$meta    = update_user_meta($user_id, '_give_user_address', $address);
436
+	$updated = wp_update_user($userdata);
437 437
 
438
-	if ( $updated ) {
439
-		do_action( 'give_user_profile_updated', $user_id, $userdata );
440
-		wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) );
438
+	if ($updated) {
439
+		do_action('give_user_profile_updated', $user_id, $userdata);
440
+		wp_redirect(add_query_arg('updated', 'true', $data['give_redirect']));
441 441
 		give_die();
442 442
 	}
443 443
 
444 444
 	return false;
445 445
 }
446 446
 
447
-add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' );
447
+add_action('give_edit_user_profile', 'give_process_profile_editor_updates');
448 448
 
Please login to merge, or discard this patch.