@@ -232,7 +232,7 @@ |
||
232 | 232 | * @since 1.0 |
233 | 233 | * @access public |
234 | 234 | * |
235 | - * @return bool |
|
235 | + * @return null|boolean |
|
236 | 236 | */ |
237 | 237 | public function check_for_token() { |
238 | 238 |
@@ -10,7 +10,7 @@ discard block |
||
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 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | public function __construct() { |
97 | 97 | |
98 | 98 | // get it started |
99 | - add_action( 'init', array( $this, 'init' ) ); |
|
99 | + add_action('init', array($this, 'init')); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -120,29 +120,29 @@ discard block |
||
120 | 120 | */ |
121 | 121 | if ( |
122 | 122 | is_user_logged_in() |
123 | - || ! give_is_setting_enabled( give_get_option( 'email_access' ) ) |
|
123 | + || ! give_is_setting_enabled(give_get_option('email_access')) |
|
124 | 124 | || is_admin() |
125 | 125 | ) { |
126 | 126 | return; |
127 | 127 | } |
128 | 128 | |
129 | 129 | // Are db columns setup? |
130 | - $is_setup = give_get_option( 'email_access_installed' ); |
|
131 | - if ( empty( $is_setup ) ) { |
|
130 | + $is_setup = give_get_option('email_access_installed'); |
|
131 | + if (empty($is_setup)) { |
|
132 | 132 | $this->create_columns(); |
133 | 133 | } |
134 | 134 | |
135 | 135 | // Timeouts. |
136 | - $this->verify_throttle = apply_filters( 'give_nl_verify_throttle', 300 ); |
|
137 | - $this->token_expiration = apply_filters( 'give_nl_token_expiration', 7200 ); |
|
136 | + $this->verify_throttle = apply_filters('give_nl_verify_throttle', 300); |
|
137 | + $this->token_expiration = apply_filters('give_nl_token_expiration', 7200); |
|
138 | 138 | |
139 | 139 | // Setup login. |
140 | 140 | $this->check_for_token(); |
141 | 141 | |
142 | - if ( $this->token_exists ) { |
|
143 | - add_filter( 'give_can_view_receipt', '__return_true' ); |
|
144 | - add_filter( 'give_user_pending_verification', '__return_false' ); |
|
145 | - add_filter( 'give_get_users_donations_args', array( $this, 'users_donations_args' ) ); |
|
142 | + if ($this->token_exists) { |
|
143 | + add_filter('give_can_view_receipt', '__return_true'); |
|
144 | + add_filter('give_user_pending_verification', '__return_false'); |
|
145 | + add_filter('give_get_users_donations_args', array($this, 'users_donations_args')); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | } |
@@ -157,25 +157,25 @@ discard block |
||
157 | 157 | * |
158 | 158 | * @return bool |
159 | 159 | */ |
160 | - public function can_send_email( $customer_id ) { |
|
160 | + public function can_send_email($customer_id) { |
|
161 | 161 | /* @var WPDB $wpdb */ |
162 | 162 | global $wpdb; |
163 | 163 | |
164 | 164 | // Prevent multiple emails within X minutes |
165 | - $throttle = date( 'Y-m-d H:i:s', time() - $this->verify_throttle ); |
|
165 | + $throttle = date('Y-m-d H:i:s', time() - $this->verify_throttle); |
|
166 | 166 | |
167 | 167 | // Does a user row exist? |
168 | 168 | $exists = (int) $wpdb->get_var( |
169 | - $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id ) |
|
169 | + $wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id) |
|
170 | 170 | ); |
171 | 171 | |
172 | - if ( 0 < $exists ) { |
|
172 | + if (0 < $exists) { |
|
173 | 173 | $row_id = (int) $wpdb->get_var( |
174 | - $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle ) |
|
174 | + $wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle) |
|
175 | 175 | ); |
176 | 176 | |
177 | - if ( $row_id < 1 ) { |
|
178 | - give_set_error( 'give_email_access_attempts_exhausted', __( 'Please wait a few minutes before requesting a new email access link.', 'give' ) ); |
|
177 | + if ($row_id < 1) { |
|
178 | + give_set_error('give_email_access_attempts_exhausted', __('Please wait a few minutes before requesting a new email access link.', 'give')); |
|
179 | 179 | |
180 | 180 | return false; |
181 | 181 | } |
@@ -195,34 +195,34 @@ discard block |
||
195 | 195 | * |
196 | 196 | * @return void |
197 | 197 | */ |
198 | - public function send_email( $customer_id, $email ) { |
|
198 | + public function send_email($customer_id, $email) { |
|
199 | 199 | |
200 | - $verify_key = wp_generate_password( 20, false ); |
|
200 | + $verify_key = wp_generate_password(20, false); |
|
201 | 201 | |
202 | 202 | // Generate a new verify key |
203 | - $this->set_verify_key( $customer_id, $email, $verify_key ); |
|
203 | + $this->set_verify_key($customer_id, $email, $verify_key); |
|
204 | 204 | |
205 | 205 | // Get the donation history page |
206 | - $page_id = give_get_option( 'history_page' ); |
|
206 | + $page_id = give_get_option('history_page'); |
|
207 | 207 | |
208 | - $access_url = add_query_arg( array( |
|
208 | + $access_url = add_query_arg(array( |
|
209 | 209 | 'give_nl' => $verify_key, |
210 | - ), get_permalink( $page_id ) ); |
|
210 | + ), get_permalink($page_id)); |
|
211 | 211 | |
212 | 212 | // Nice subject and message. |
213 | - $subject = apply_filters( 'give_email_access_token_subject', sprintf( __( 'Your Access Link to %s', 'give' ), get_bloginfo( 'name' ) ) ); |
|
213 | + $subject = apply_filters('give_email_access_token_subject', sprintf(__('Your Access Link to %s', 'give'), get_bloginfo('name'))); |
|
214 | 214 | |
215 | - $message = __( '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"; |
|
216 | - $message .= '<a href="' . esc_url( $access_url ) . '" target="_blank">' . __( 'Access Donation Details »', 'give' ) . '</a>' . "\n\n"; |
|
215 | + $message = __('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"; |
|
216 | + $message .= '<a href="'.esc_url($access_url).'" target="_blank">'.__('Access Donation Details »', 'give').'</a>'."\n\n"; |
|
217 | 217 | $message .= "\n\n"; |
218 | - $message .= __( 'Sincerely,', 'give' ) . "\n"; |
|
219 | - $message .= get_bloginfo( 'name' ) . "\n"; |
|
218 | + $message .= __('Sincerely,', 'give')."\n"; |
|
219 | + $message .= get_bloginfo('name')."\n"; |
|
220 | 220 | |
221 | - $message = apply_filters( 'give_email_access_token_message', $message ); |
|
221 | + $message = apply_filters('give_email_access_token_message', $message); |
|
222 | 222 | |
223 | 223 | // Send the email. |
224 | - Give()->emails->__set( 'heading', apply_filters( 'give_email_access_token_heading', __( 'Your Access Link', 'give' ) ) ); |
|
225 | - Give()->emails->send( $email, $subject, $message ); |
|
224 | + Give()->emails->__set('heading', apply_filters('give_email_access_token_heading', __('Your Access Link', 'give'))); |
|
225 | + Give()->emails->send($email, $subject, $message); |
|
226 | 226 | |
227 | 227 | } |
228 | 228 | |
@@ -236,26 +236,26 @@ discard block |
||
236 | 236 | */ |
237 | 237 | public function check_for_token() { |
238 | 238 | |
239 | - $token = isset( $_GET['give_nl'] ) ? $_GET['give_nl'] : ''; |
|
239 | + $token = isset($_GET['give_nl']) ? $_GET['give_nl'] : ''; |
|
240 | 240 | |
241 | 241 | // Check for cookie. |
242 | - if ( empty( $token ) ) { |
|
243 | - $token = isset( $_COOKIE['give_nl'] ) ? $_COOKIE['give_nl'] : ''; |
|
242 | + if (empty($token)) { |
|
243 | + $token = isset($_COOKIE['give_nl']) ? $_COOKIE['give_nl'] : ''; |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | // Must have a token. |
247 | - if ( ! empty( $token ) ) { |
|
247 | + if ( ! empty($token)) { |
|
248 | 248 | |
249 | - if ( ! $this->is_valid_token( $token ) ) { |
|
250 | - if ( ! $this->is_valid_verify_key( $token ) ) { |
|
249 | + if ( ! $this->is_valid_token($token)) { |
|
250 | + if ( ! $this->is_valid_verify_key($token)) { |
|
251 | 251 | return; |
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
255 | 255 | $this->token_exists = true; |
256 | 256 | // Set cookie. |
257 | - $lifetime = current_time( 'timestamp' ) + Give()->session->set_expiration_time(); |
|
258 | - @setcookie( 'give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
257 | + $lifetime = current_time('timestamp') + Give()->session->set_expiration_time(); |
|
258 | + @setcookie('give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
259 | 259 | |
260 | 260 | return true; |
261 | 261 | } |
@@ -271,26 +271,26 @@ discard block |
||
271 | 271 | * |
272 | 272 | * @return bool |
273 | 273 | */ |
274 | - public function is_valid_token( $token ) { |
|
274 | + public function is_valid_token($token) { |
|
275 | 275 | |
276 | 276 | global $wpdb; |
277 | 277 | |
278 | 278 | // Make sure token isn't expired. |
279 | - $expires = date( 'Y-m-d H:i:s', time() - $this->token_expiration ); |
|
279 | + $expires = date('Y-m-d H:i:s', time() - $this->token_expiration); |
|
280 | 280 | |
281 | 281 | $email = $wpdb->get_var( |
282 | - $wpdb->prepare( "SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires ) |
|
282 | + $wpdb->prepare("SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires) |
|
283 | 283 | ); |
284 | 284 | |
285 | - if ( ! empty( $email ) ) { |
|
285 | + if ( ! empty($email)) { |
|
286 | 286 | $this->token_email = $email; |
287 | 287 | $this->token = $token; |
288 | 288 | return true; |
289 | 289 | } |
290 | 290 | |
291 | 291 | // Set error only if email access form isn't being submitted |
292 | - if ( ! isset( $_POST['give_email'] ) && ! isset( $_POST['_wpnonce'] ) ) { |
|
293 | - 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' ) ) ); |
|
292 | + if ( ! isset($_POST['give_email']) && ! isset($_POST['_wpnonce'])) { |
|
293 | + 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'))); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | return false; |
@@ -309,25 +309,25 @@ discard block |
||
309 | 309 | * |
310 | 310 | * @return void |
311 | 311 | */ |
312 | - public function set_verify_key( $customer_id, $email, $verify_key ) { |
|
312 | + public function set_verify_key($customer_id, $email, $verify_key) { |
|
313 | 313 | global $wpdb; |
314 | 314 | |
315 | - $now = date( 'Y-m-d H:i:s' ); |
|
315 | + $now = date('Y-m-d H:i:s'); |
|
316 | 316 | |
317 | 317 | // Insert or update? |
318 | 318 | $row_id = (int) $wpdb->get_var( |
319 | - $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id ) |
|
319 | + $wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id) |
|
320 | 320 | ); |
321 | 321 | |
322 | 322 | // Update. |
323 | - if ( ! empty( $row_id ) ) { |
|
323 | + if ( ! empty($row_id)) { |
|
324 | 324 | $wpdb->query( |
325 | - $wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id ) |
|
325 | + $wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id) |
|
326 | 326 | ); |
327 | 327 | } // Insert. |
328 | 328 | else { |
329 | 329 | $wpdb->query( |
330 | - $wpdb->prepare( "INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now ) |
|
330 | + $wpdb->prepare("INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now) |
|
331 | 331 | ); |
332 | 332 | } |
333 | 333 | } |
@@ -342,21 +342,21 @@ discard block |
||
342 | 342 | * |
343 | 343 | * @return bool |
344 | 344 | */ |
345 | - public function is_valid_verify_key( $token ) { |
|
345 | + public function is_valid_verify_key($token) { |
|
346 | 346 | /* @var WPDB $wpdb */ |
347 | 347 | global $wpdb; |
348 | 348 | |
349 | 349 | // See if the verify_key exists. |
350 | 350 | $row = $wpdb->get_row( |
351 | - $wpdb->prepare( "SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token ) |
|
351 | + $wpdb->prepare("SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token) |
|
352 | 352 | ); |
353 | 353 | |
354 | - $now = date( 'Y-m-d H:i:s' ); |
|
354 | + $now = date('Y-m-d H:i:s'); |
|
355 | 355 | |
356 | 356 | // Set token and remove verify key. |
357 | - if ( ! empty( $row ) ) { |
|
357 | + if ( ! empty($row)) { |
|
358 | 358 | $wpdb->query( |
359 | - $wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id ) |
|
359 | + $wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id) |
|
360 | 360 | ); |
361 | 361 | |
362 | 362 | $this->token_email = $row->email; |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | * |
381 | 381 | * @return mixed |
382 | 382 | */ |
383 | - public function users_donations_args( $args ) { |
|
383 | + public function users_donations_args($args) { |
|
384 | 384 | $args['user'] = $this->token_email; |
385 | 385 | |
386 | 386 | return $args; |
@@ -401,11 +401,11 @@ discard block |
||
401 | 401 | global $wpdb; |
402 | 402 | |
403 | 403 | // Create columns in customers table |
404 | - $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`" ); |
|
404 | + $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`"); |
|
405 | 405 | |
406 | 406 | // Columns added properly |
407 | - if ( $query ) { |
|
408 | - give_update_option( 'email_access_installed', 1 ); |
|
407 | + if ($query) { |
|
408 | + give_update_option('email_access_installed', 1); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | } |
@@ -10,7 +10,7 @@ discard block |
||
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 |
||
26 | 26 | function give_donation_history() { |
27 | 27 | |
28 | 28 | // If payment_key query arg exists, return receipt instead of donation history. |
29 | - if ( isset( $_GET['payment_key'] ) ) { |
|
29 | + if (isset($_GET['payment_key'])) { |
|
30 | 30 | ob_start(); |
31 | - echo give_receipt_shortcode( array() ); |
|
32 | - echo '<a href="' . esc_url( give_get_history_page_uri() ) . '">« ' . esc_html__( 'Return to All Donations', 'give' ) . '</a>'; |
|
31 | + echo give_receipt_shortcode(array()); |
|
32 | + echo '<a href="'.esc_url(give_get_history_page_uri()).'">« '.esc_html__('Return to All Donations', 'give').'</a>'; |
|
33 | 33 | |
34 | 34 | return ob_get_clean(); |
35 | 35 | } |
36 | 36 | |
37 | - $email_access = give_get_option( 'email_access' ); |
|
37 | + $email_access = give_get_option('email_access'); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Determine access |
@@ -44,28 +44,28 @@ discard block |
||
44 | 44 | */ |
45 | 45 | if ( |
46 | 46 | is_user_logged_in() || false !== Give()->session->get_session_expiration() |
47 | - || ( give_is_setting_enabled( $email_access ) && Give()->email_access->token_exists ) |
|
47 | + || (give_is_setting_enabled($email_access) && Give()->email_access->token_exists) |
|
48 | 48 | ) { |
49 | 49 | ob_start(); |
50 | - give_get_template_part( 'history', 'donations' ); |
|
50 | + give_get_template_part('history', 'donations'); |
|
51 | 51 | |
52 | 52 | return ob_get_clean(); |
53 | 53 | |
54 | - } elseif ( give_is_setting_enabled( $email_access ) ) { |
|
54 | + } elseif (give_is_setting_enabled($email_access)) { |
|
55 | 55 | //Is Email-based access enabled? |
56 | 56 | ob_start(); |
57 | - give_get_template_part( 'email', 'login-form' ); |
|
57 | + give_get_template_part('email', 'login-form'); |
|
58 | 58 | |
59 | 59 | return ob_get_clean(); |
60 | 60 | } else { |
61 | 61 | |
62 | - echo apply_filters( 'give_donation_history_nonuser_message', give_output_error( __( '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' ), false ) ); |
|
63 | - echo do_shortcode( '[give_login]' ); |
|
62 | + echo apply_filters('give_donation_history_nonuser_message', give_output_error(__('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'), false)); |
|
63 | + echo do_shortcode('[give_login]'); |
|
64 | 64 | |
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | -add_shortcode( 'donation_history', 'give_donation_history' ); |
|
68 | +add_shortcode('donation_history', 'give_donation_history'); |
|
69 | 69 | |
70 | 70 | /** |
71 | 71 | * Donation Form Shortcode |
@@ -78,29 +78,29 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @return string |
80 | 80 | */ |
81 | -function give_form_shortcode( $atts ) { |
|
82 | - $atts = shortcode_atts( array( |
|
81 | +function give_form_shortcode($atts) { |
|
82 | + $atts = shortcode_atts(array( |
|
83 | 83 | 'id' => '', |
84 | 84 | 'show_title' => true, |
85 | 85 | 'show_goal' => true, |
86 | 86 | 'show_content' => '', |
87 | 87 | 'float_labels' => '', |
88 | 88 | 'display_style' => '', |
89 | - ), $atts, 'give_form' ); |
|
89 | + ), $atts, 'give_form'); |
|
90 | 90 | |
91 | 91 | // Convert string to bool. |
92 | - $atts['show_title'] = filter_var( $atts['show_title'], FILTER_VALIDATE_BOOLEAN ); |
|
93 | - $atts['show_goal'] = filter_var( $atts['show_goal'], FILTER_VALIDATE_BOOLEAN ); |
|
92 | + $atts['show_title'] = filter_var($atts['show_title'], FILTER_VALIDATE_BOOLEAN); |
|
93 | + $atts['show_goal'] = filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN); |
|
94 | 94 | |
95 | 95 | //get the Give Form |
96 | 96 | ob_start(); |
97 | - give_get_donation_form( $atts ); |
|
97 | + give_get_donation_form($atts); |
|
98 | 98 | $final_output = ob_get_clean(); |
99 | 99 | |
100 | - return apply_filters( 'give_donate_form', $final_output, $atts ); |
|
100 | + return apply_filters('give_donate_form', $final_output, $atts); |
|
101 | 101 | } |
102 | 102 | |
103 | -add_shortcode( 'give_form', 'give_form_shortcode' ); |
|
103 | +add_shortcode('give_form', 'give_form_shortcode'); |
|
104 | 104 | |
105 | 105 | /** |
106 | 106 | * Donation Form Goal Shortcode. |
@@ -113,37 +113,37 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return string |
115 | 115 | */ |
116 | -function give_goal_shortcode( $atts ) { |
|
117 | - $atts = shortcode_atts( array( |
|
116 | +function give_goal_shortcode($atts) { |
|
117 | + $atts = shortcode_atts(array( |
|
118 | 118 | 'id' => '', |
119 | 119 | 'show_text' => true, |
120 | 120 | 'show_bar' => true, |
121 | - ), $atts, 'give_goal' ); |
|
121 | + ), $atts, 'give_goal'); |
|
122 | 122 | |
123 | 123 | |
124 | 124 | //get the Give Form. |
125 | 125 | ob_start(); |
126 | 126 | |
127 | 127 | //Sanity check 1: ensure there is an ID Provided. |
128 | - if ( empty( $atts['id'] ) ) { |
|
129 | - give_output_error( esc_html__( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true ); |
|
128 | + if (empty($atts['id'])) { |
|
129 | + give_output_error(esc_html__('The shortcode is missing Donation Form ID attribute.', 'give'), true); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | //Sanity check 2: Check the form even has Goals enabled. |
133 | - if ( ! give_is_setting_enabled( get_post_meta( $atts['id'], '_give_goal_option', true ) ) ) { |
|
133 | + if ( ! give_is_setting_enabled(get_post_meta($atts['id'], '_give_goal_option', true))) { |
|
134 | 134 | |
135 | - give_output_error( esc_html__( 'The form does not have Goals enabled.', 'give' ), true ); |
|
135 | + give_output_error(esc_html__('The form does not have Goals enabled.', 'give'), true); |
|
136 | 136 | } else { |
137 | 137 | //Passed all sanity checks: output Goal. |
138 | - give_show_goal_progress( $atts['id'], $atts ); |
|
138 | + give_show_goal_progress($atts['id'], $atts); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | $final_output = ob_get_clean(); |
142 | 142 | |
143 | - return apply_filters( 'give_goal_shortcode_output', $final_output, $atts ); |
|
143 | + return apply_filters('give_goal_shortcode_output', $final_output, $atts); |
|
144 | 144 | } |
145 | 145 | |
146 | -add_shortcode( 'give_goal', 'give_goal_shortcode' ); |
|
146 | +add_shortcode('give_goal', 'give_goal_shortcode'); |
|
147 | 147 | |
148 | 148 | |
149 | 149 | /** |
@@ -160,22 +160,22 @@ discard block |
||
160 | 160 | * |
161 | 161 | * @return string |
162 | 162 | */ |
163 | -function give_login_form_shortcode( $atts ) { |
|
164 | - $atts = shortcode_atts( array( |
|
163 | +function give_login_form_shortcode($atts) { |
|
164 | + $atts = shortcode_atts(array( |
|
165 | 165 | // Add backward compatibility for redirect attribute. |
166 | 166 | 'redirect' => '', |
167 | 167 | |
168 | 168 | 'login-redirect' => '', |
169 | 169 | 'logout-redirect' => '', |
170 | - ), $atts, 'give_login' ); |
|
170 | + ), $atts, 'give_login'); |
|
171 | 171 | |
172 | 172 | // 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. |
173 | - $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect'] ) ? $atts['redirect'] : '' ); |
|
173 | + $atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : ''); |
|
174 | 174 | |
175 | - return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] ); |
|
175 | + return give_login_form($atts['login-redirect'], $atts['logout-redirect']); |
|
176 | 176 | } |
177 | 177 | |
178 | -add_shortcode( 'give_login', 'give_login_form_shortcode' ); |
|
178 | +add_shortcode('give_login', 'give_login_form_shortcode'); |
|
179 | 179 | |
180 | 180 | /** |
181 | 181 | * Register Shortcode. |
@@ -190,15 +190,15 @@ discard block |
||
190 | 190 | * |
191 | 191 | * @return string |
192 | 192 | */ |
193 | -function give_register_form_shortcode( $atts ) { |
|
194 | - $atts = shortcode_atts( array( |
|
193 | +function give_register_form_shortcode($atts) { |
|
194 | + $atts = shortcode_atts(array( |
|
195 | 195 | 'redirect' => '', |
196 | - ), $atts, 'give_register' ); |
|
196 | + ), $atts, 'give_register'); |
|
197 | 197 | |
198 | - return give_register_form( $atts['redirect'] ); |
|
198 | + return give_register_form($atts['redirect']); |
|
199 | 199 | } |
200 | 200 | |
201 | -add_shortcode( 'give_register', 'give_register_form_shortcode' ); |
|
201 | +add_shortcode('give_register', 'give_register_form_shortcode'); |
|
202 | 202 | |
203 | 203 | /** |
204 | 204 | * Receipt Shortcode. |
@@ -211,12 +211,12 @@ discard block |
||
211 | 211 | * |
212 | 212 | * @return string |
213 | 213 | */ |
214 | -function give_receipt_shortcode( $atts ) { |
|
214 | +function give_receipt_shortcode($atts) { |
|
215 | 215 | |
216 | 216 | global $give_receipt_args, $payment; |
217 | 217 | |
218 | - $give_receipt_args = shortcode_atts( array( |
|
219 | - 'error' => esc_html__( 'You are missing the payment key to view this donation receipt.', 'give' ), |
|
218 | + $give_receipt_args = shortcode_atts(array( |
|
219 | + 'error' => esc_html__('You are missing the payment key to view this donation receipt.', 'give'), |
|
220 | 220 | 'price' => true, |
221 | 221 | 'donor' => true, |
222 | 222 | 'date' => true, |
@@ -225,50 +225,50 @@ discard block |
||
225 | 225 | 'payment_id' => true, |
226 | 226 | 'payment_status' => false, |
227 | 227 | 'status_notice' => true, |
228 | - ), $atts, 'give_receipt' ); |
|
228 | + ), $atts, 'give_receipt'); |
|
229 | 229 | |
230 | 230 | //set $session var |
231 | 231 | $session = give_get_purchase_session(); |
232 | 232 | |
233 | 233 | //set payment key var |
234 | - if ( isset( $_GET['payment_key'] ) ) { |
|
235 | - $payment_key = urldecode( $_GET['payment_key'] ); |
|
236 | - } elseif ( $session ) { |
|
234 | + if (isset($_GET['payment_key'])) { |
|
235 | + $payment_key = urldecode($_GET['payment_key']); |
|
236 | + } elseif ($session) { |
|
237 | 237 | $payment_key = $session['purchase_key']; |
238 | - } elseif ( $give_receipt_args['payment_key'] ) { |
|
238 | + } elseif ($give_receipt_args['payment_key']) { |
|
239 | 239 | $payment_key = $give_receipt_args['payment_key']; |
240 | 240 | } |
241 | 241 | |
242 | - $email_access = give_get_option( 'email_access' ); |
|
242 | + $email_access = give_get_option('email_access'); |
|
243 | 243 | |
244 | 244 | // No payment_key found & Email Access is Turned on: |
245 | - if ( ! isset( $payment_key ) && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
245 | + if ( ! isset($payment_key) && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
246 | 246 | |
247 | 247 | ob_start(); |
248 | 248 | |
249 | - give_get_template_part( 'email-login-form' ); |
|
249 | + give_get_template_part('email-login-form'); |
|
250 | 250 | |
251 | 251 | return ob_get_clean(); |
252 | 252 | |
253 | - } elseif ( ! isset( $payment_key ) ) { |
|
253 | + } elseif ( ! isset($payment_key)) { |
|
254 | 254 | |
255 | - return give_output_error( $give_receipt_args['error'], false, 'error' ); |
|
255 | + return give_output_error($give_receipt_args['error'], false, 'error'); |
|
256 | 256 | |
257 | 257 | } |
258 | 258 | |
259 | - $payment_id = give_get_purchase_id_by_key( $payment_key ); |
|
260 | - $user_can_view = give_can_view_receipt( $payment_key ); |
|
259 | + $payment_id = give_get_purchase_id_by_key($payment_key); |
|
260 | + $user_can_view = give_can_view_receipt($payment_key); |
|
261 | 261 | |
262 | 262 | // Key was provided, but user is logged out. Offer them the ability to login and view the receipt. |
263 | - if ( ! $user_can_view && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
263 | + if ( ! $user_can_view && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
264 | 264 | |
265 | 265 | ob_start(); |
266 | 266 | |
267 | - give_get_template_part( 'email-login-form' ); |
|
267 | + give_get_template_part('email-login-form'); |
|
268 | 268 | |
269 | 269 | return ob_get_clean(); |
270 | 270 | |
271 | - } elseif ( ! $user_can_view ) { |
|
271 | + } elseif ( ! $user_can_view) { |
|
272 | 272 | |
273 | 273 | global $give_login_redirect; |
274 | 274 | |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | |
277 | 277 | ob_start(); |
278 | 278 | |
279 | - give_output_error( apply_filters( 'give_must_be_logged_in_error_message', esc_html__( 'You must be logged in to view this donation receipt.', 'give' ) ) ); |
|
279 | + give_output_error(apply_filters('give_must_be_logged_in_error_message', esc_html__('You must be logged in to view this donation receipt.', 'give'))); |
|
280 | 280 | |
281 | - give_get_template_part( 'shortcode', 'login' ); |
|
281 | + give_get_template_part('shortcode', 'login'); |
|
282 | 282 | |
283 | 283 | $login_form = ob_get_clean(); |
284 | 284 | |
@@ -293,20 +293,20 @@ discard block |
||
293 | 293 | * or if user is logged in and the user can view sensitive shop data. |
294 | 294 | * |
295 | 295 | */ |
296 | - if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) { |
|
297 | - return give_output_error( $give_receipt_args['error'], false, 'error' ); |
|
296 | + if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) { |
|
297 | + return give_output_error($give_receipt_args['error'], false, 'error'); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | ob_start(); |
301 | 301 | |
302 | - give_get_template_part( 'shortcode', 'receipt' ); |
|
302 | + give_get_template_part('shortcode', 'receipt'); |
|
303 | 303 | |
304 | 304 | $display = ob_get_clean(); |
305 | 305 | |
306 | 306 | return $display; |
307 | 307 | } |
308 | 308 | |
309 | -add_shortcode( 'give_receipt', 'give_receipt_shortcode' ); |
|
309 | +add_shortcode('give_receipt', 'give_receipt_shortcode'); |
|
310 | 310 | |
311 | 311 | /** |
312 | 312 | * Profile Editor Shortcode. |
@@ -325,18 +325,18 @@ discard block |
||
325 | 325 | * |
326 | 326 | * @return string Output generated from the profile editor |
327 | 327 | */ |
328 | -function give_profile_editor_shortcode( $atts ) { |
|
328 | +function give_profile_editor_shortcode($atts) { |
|
329 | 329 | |
330 | 330 | ob_start(); |
331 | 331 | |
332 | - give_get_template_part( 'shortcode', 'profile-editor' ); |
|
332 | + give_get_template_part('shortcode', 'profile-editor'); |
|
333 | 333 | |
334 | 334 | $display = ob_get_clean(); |
335 | 335 | |
336 | 336 | return $display; |
337 | 337 | } |
338 | 338 | |
339 | -add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' ); |
|
339 | +add_shortcode('give_profile_editor', 'give_profile_editor_shortcode'); |
|
340 | 340 | |
341 | 341 | /** |
342 | 342 | * Process Profile Updater Form. |
@@ -349,30 +349,30 @@ discard block |
||
349 | 349 | * |
350 | 350 | * @return bool |
351 | 351 | */ |
352 | -function give_process_profile_editor_updates( $data ) { |
|
352 | +function give_process_profile_editor_updates($data) { |
|
353 | 353 | // Profile field change request |
354 | - if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) { |
|
354 | + if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) { |
|
355 | 355 | return false; |
356 | 356 | } |
357 | 357 | |
358 | 358 | // Nonce security |
359 | - if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) { |
|
359 | + if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) { |
|
360 | 360 | return false; |
361 | 361 | } |
362 | 362 | |
363 | 363 | $user_id = get_current_user_id(); |
364 | - $old_user_data = get_userdata( $user_id ); |
|
365 | - |
|
366 | - $display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name; |
|
367 | - $first_name = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name; |
|
368 | - $last_name = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name; |
|
369 | - $email = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email; |
|
370 | - $line1 = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' ); |
|
371 | - $line2 = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' ); |
|
372 | - $city = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' ); |
|
373 | - $state = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' ); |
|
374 | - $zip = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' ); |
|
375 | - $country = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' ); |
|
364 | + $old_user_data = get_userdata($user_id); |
|
365 | + |
|
366 | + $display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name; |
|
367 | + $first_name = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name; |
|
368 | + $last_name = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name; |
|
369 | + $email = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email; |
|
370 | + $line1 = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : ''); |
|
371 | + $line2 = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : ''); |
|
372 | + $city = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : ''); |
|
373 | + $state = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : ''); |
|
374 | + $zip = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : ''); |
|
375 | + $country = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : ''); |
|
376 | 376 | |
377 | 377 | $userdata = array( |
378 | 378 | 'ID' => $user_id, |
@@ -400,46 +400,46 @@ discard block |
||
400 | 400 | * @param int $user_id The ID of the user. |
401 | 401 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
402 | 402 | */ |
403 | - do_action( 'give_pre_update_user_profile', $user_id, $userdata ); |
|
403 | + do_action('give_pre_update_user_profile', $user_id, $userdata); |
|
404 | 404 | |
405 | 405 | // New password |
406 | - if ( ! empty( $data['give_new_user_pass1'] ) ) { |
|
407 | - if ( $data['give_new_user_pass1'] !== $data['give_new_user_pass2'] ) { |
|
408 | - give_set_error( 'password_mismatch', esc_html__( 'The passwords you entered do not match. Please try again.', 'give' ) ); |
|
406 | + if ( ! empty($data['give_new_user_pass1'])) { |
|
407 | + if ($data['give_new_user_pass1'] !== $data['give_new_user_pass2']) { |
|
408 | + give_set_error('password_mismatch', esc_html__('The passwords you entered do not match. Please try again.', 'give')); |
|
409 | 409 | } else { |
410 | 410 | $userdata['user_pass'] = $data['give_new_user_pass1']; |
411 | 411 | } |
412 | 412 | } |
413 | 413 | |
414 | - if ( empty( $email ) ) { |
|
414 | + if (empty($email)) { |
|
415 | 415 | // Make sure email should not be empty. |
416 | - give_set_error( 'email_empty', esc_html__( 'The email you entered is empty.', 'give' ) ); |
|
416 | + give_set_error('email_empty', esc_html__('The email you entered is empty.', 'give')); |
|
417 | 417 | |
418 | - } else if ( ! is_email( $email ) ) { |
|
418 | + } else if ( ! is_email($email)) { |
|
419 | 419 | // Make sure email should be valid. |
420 | - give_set_error( 'email_not_valid', esc_html__( 'The email you entered is not valid. Please use another', 'give' ) ); |
|
420 | + give_set_error('email_not_valid', esc_html__('The email you entered is not valid. Please use another', 'give')); |
|
421 | 421 | |
422 | - } else if ( $email != $old_user_data->user_email ) { |
|
422 | + } else if ($email != $old_user_data->user_email) { |
|
423 | 423 | // Make sure the new email doesn't belong to another user |
424 | - if ( email_exists( $email ) ) { |
|
425 | - give_set_error( 'email_exists', esc_html__( 'The email you entered belongs to another user. Please use another.', 'give' ) ); |
|
424 | + if (email_exists($email)) { |
|
425 | + give_set_error('email_exists', esc_html__('The email you entered belongs to another user. Please use another.', 'give')); |
|
426 | 426 | } |
427 | 427 | } |
428 | 428 | |
429 | 429 | // Check for errors |
430 | 430 | $errors = give_get_errors(); |
431 | 431 | |
432 | - if ( $errors ) { |
|
432 | + if ($errors) { |
|
433 | 433 | // Send back to the profile editor if there are errors |
434 | - wp_redirect( $data['give_redirect'] ); |
|
434 | + wp_redirect($data['give_redirect']); |
|
435 | 435 | give_die(); |
436 | 436 | } |
437 | 437 | |
438 | 438 | // Update the user |
439 | - $meta = update_user_meta( $user_id, '_give_user_address', $address ); |
|
440 | - $updated = wp_update_user( $userdata ); |
|
439 | + $meta = update_user_meta($user_id, '_give_user_address', $address); |
|
440 | + $updated = wp_update_user($userdata); |
|
441 | 441 | |
442 | - if ( $updated ) { |
|
442 | + if ($updated) { |
|
443 | 443 | |
444 | 444 | /** |
445 | 445 | * Fires after updating user profile. |
@@ -449,12 +449,12 @@ discard block |
||
449 | 449 | * @param int $user_id The ID of the user. |
450 | 450 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
451 | 451 | */ |
452 | - do_action( 'give_user_profile_updated', $user_id, $userdata ); |
|
453 | - wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) ); |
|
452 | + do_action('give_user_profile_updated', $user_id, $userdata); |
|
453 | + wp_redirect(add_query_arg('updated', 'true', $data['give_redirect'])); |
|
454 | 454 | give_die(); |
455 | 455 | } |
456 | 456 | |
457 | 457 | return false; |
458 | 458 | } |
459 | 459 | |
460 | -add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' ); |
|
460 | +add_action('give_edit_user_profile', 'give_process_profile_editor_updates'); |