@@ -42,7 +42,7 @@ |
||
42 | 42 | case version_compare( $give_version, '1.7', '<' ) : |
43 | 43 | give_v17_upgrades(); |
44 | 44 | $did_upgrade = true; |
45 | - break; |
|
45 | + break; |
|
46 | 46 | |
47 | 47 | case version_compare( $give_version, '1.8', '<' ) : |
48 | 48 | give_v18_upgrades(); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -25,37 +25,37 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_do_automatic_upgrades() { |
27 | 27 | $did_upgrade = false; |
28 | - $give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) ); |
|
28 | + $give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version')); |
|
29 | 29 | |
30 | - if ( ! $give_version ) { |
|
30 | + if ( ! $give_version) { |
|
31 | 31 | // 1.0 is the first version to use this option so we must add it. |
32 | 32 | $give_version = '1.0'; |
33 | 33 | } |
34 | 34 | |
35 | - switch ( true ) { |
|
35 | + switch (true) { |
|
36 | 36 | |
37 | - case version_compare( $give_version, '1.6', '<' ) : |
|
37 | + case version_compare($give_version, '1.6', '<') : |
|
38 | 38 | give_v16_upgrades(); |
39 | 39 | $did_upgrade = true; |
40 | 40 | break; |
41 | 41 | |
42 | - case version_compare( $give_version, '1.7', '<' ) : |
|
42 | + case version_compare($give_version, '1.7', '<') : |
|
43 | 43 | give_v17_upgrades(); |
44 | 44 | $did_upgrade = true; |
45 | 45 | break; |
46 | 46 | |
47 | - case version_compare( $give_version, '1.8', '<' ) : |
|
47 | + case version_compare($give_version, '1.8', '<') : |
|
48 | 48 | give_v18_upgrades(); |
49 | 49 | $did_upgrade = true; |
50 | 50 | } |
51 | 51 | |
52 | - if ( $did_upgrade ) { |
|
53 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
52 | + if ($did_upgrade) { |
|
53 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | -add_action( 'admin_init', 'give_do_automatic_upgrades' ); |
|
58 | -add_action( 'give_upgrades', 'give_do_automatic_upgrades' ); |
|
57 | +add_action('admin_init', 'give_do_automatic_upgrades'); |
|
58 | +add_action('give_upgrades', 'give_do_automatic_upgrades'); |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Display Upgrade Notices |
@@ -65,18 +65,18 @@ discard block |
||
65 | 65 | */ |
66 | 66 | function give_show_upgrade_notices() { |
67 | 67 | // Don't show notices on the upgrades page. |
68 | - if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-upgrades' ) { |
|
68 | + if (isset($_GET['page']) && $_GET['page'] == 'give-upgrades') { |
|
69 | 69 | return; |
70 | 70 | } |
71 | 71 | |
72 | - $give_version = get_option( 'give_version' ); |
|
72 | + $give_version = get_option('give_version'); |
|
73 | 73 | |
74 | - if ( ! $give_version ) { |
|
74 | + if ( ! $give_version) { |
|
75 | 75 | // 1.0 is the first version to use this option so we must add it. |
76 | 76 | $give_version = '1.0'; |
77 | 77 | } |
78 | 78 | |
79 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
79 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
80 | 80 | |
81 | 81 | /* |
82 | 82 | * NOTICE: |
@@ -87,31 +87,31 @@ discard block |
||
87 | 87 | */ |
88 | 88 | |
89 | 89 | // v1.3.2 Upgrades |
90 | - if ( version_compare( $give_version, '1.3.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) { |
|
90 | + if (version_compare($give_version, '1.3.2', '<') || ! give_has_upgrade_completed('upgrade_give_payment_customer_id')) { |
|
91 | 91 | printf( |
92 | 92 | /* translators: %s: upgrade URL */ |
93 | - '<div class="updated"><p>' . __( 'Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>', |
|
94 | - esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id' ) ) |
|
93 | + '<div class="updated"><p>'.__('Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>', |
|
94 | + esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id')) |
|
95 | 95 | ); |
96 | 96 | } |
97 | 97 | |
98 | 98 | // v1.3.4 Upgrades //ensure the user has gone through 1.3.4. |
99 | - if ( version_compare( $give_version, '1.3.4', '<' ) || ( ! give_has_upgrade_completed( 'upgrade_give_offline_status' ) && give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) ) { |
|
99 | + if (version_compare($give_version, '1.3.4', '<') || ( ! give_has_upgrade_completed('upgrade_give_offline_status') && give_has_upgrade_completed('upgrade_give_payment_customer_id'))) { |
|
100 | 100 | printf( |
101 | 101 | /* translators: %s: upgrade URL */ |
102 | - '<div class="updated"><p>' . __( 'Give needs to upgrade the donations database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>', |
|
103 | - esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status' ) ) |
|
102 | + '<div class="updated"><p>'.__('Give needs to upgrade the donations database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>', |
|
103 | + esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status')) |
|
104 | 104 | ); |
105 | 105 | } |
106 | 106 | |
107 | 107 | // Check if we have a stalled upgrade. |
108 | 108 | $resume_upgrade = give_maybe_resume_upgrade(); |
109 | - if ( ! empty( $resume_upgrade ) ) { |
|
110 | - $resume_url = add_query_arg( $resume_upgrade, admin_url( 'index.php' ) ); |
|
109 | + if ( ! empty($resume_upgrade)) { |
|
110 | + $resume_url = add_query_arg($resume_upgrade, admin_url('index.php')); |
|
111 | 111 | echo Give_Notices::notice_html( |
112 | 112 | sprintf( |
113 | - __( 'Give needs to complete a database upgrade that was previously started, click <a href="%s">here</a> to resume the upgrade.', 'give' ), |
|
114 | - esc_url( $resume_url ) |
|
113 | + __('Give needs to complete a database upgrade that was previously started, click <a href="%s">here</a> to resume the upgrade.', 'give'), |
|
114 | + esc_url($resume_url) |
|
115 | 115 | ) |
116 | 116 | ); |
117 | 117 | |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | } |
120 | 120 | |
121 | 121 | // v1.8 form metadata upgrades. |
122 | - if ( version_compare( $give_version, '1.8', '<' ) || ! give_has_upgrade_completed( 'v18_upgrades_form_metadata' ) ) { |
|
122 | + if (version_compare($give_version, '1.8', '<') || ! give_has_upgrade_completed('v18_upgrades_form_metadata')) { |
|
123 | 123 | echo Give_Notices::notice_html( |
124 | 124 | sprintf( |
125 | - esc_html__( 'Give needs to upgrade the form database, click %1$shere%2$s to start the upgrade.', 'give' ), |
|
126 | - '<a class="give-upgrade-link" href="' . esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=give_v18_upgrades_form_metadata' ) ) . '">', |
|
125 | + esc_html__('Give needs to upgrade the form database, click %1$shere%2$s to start the upgrade.', 'give'), |
|
126 | + '<a class="give-upgrade-link" href="'.esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=give_v18_upgrades_form_metadata')).'">', |
|
127 | 127 | '</a>' |
128 | 128 | ) |
129 | 129 | ); |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | <?php |
152 | 152 | } |
153 | 153 | |
154 | -add_action( 'admin_notices', 'give_show_upgrade_notices' ); |
|
154 | +add_action('admin_notices', 'give_show_upgrade_notices'); |
|
155 | 155 | |
156 | 156 | /** |
157 | 157 | * Triggers all upgrade functions |
@@ -163,29 +163,29 @@ discard block |
||
163 | 163 | */ |
164 | 164 | function give_trigger_upgrades() { |
165 | 165 | |
166 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
167 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
166 | + if ( ! current_user_can('manage_give_settings')) { |
|
167 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
168 | 168 | 'response' => 403, |
169 | - ) ); |
|
169 | + )); |
|
170 | 170 | } |
171 | 171 | |
172 | - $give_version = get_option( 'give_version' ); |
|
172 | + $give_version = get_option('give_version'); |
|
173 | 173 | |
174 | - if ( ! $give_version ) { |
|
174 | + if ( ! $give_version) { |
|
175 | 175 | // 1.0 is the first version to use this option so we must add it. |
176 | 176 | $give_version = '1.0'; |
177 | - add_option( 'give_version', $give_version ); |
|
177 | + add_option('give_version', $give_version); |
|
178 | 178 | } |
179 | 179 | |
180 | - update_option( 'give_version', GIVE_VERSION ); |
|
181 | - delete_option( 'give_doing_upgrade' ); |
|
180 | + update_option('give_version', GIVE_VERSION); |
|
181 | + delete_option('give_doing_upgrade'); |
|
182 | 182 | |
183 | - if ( DOING_AJAX ) { |
|
184 | - die( 'complete' ); |
|
183 | + if (DOING_AJAX) { |
|
184 | + die('complete'); |
|
185 | 185 | } // End if(). |
186 | 186 | } |
187 | 187 | |
188 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
188 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
189 | 189 | |
190 | 190 | /** |
191 | 191 | * Check if the upgrade routine has been run for a specific action |
@@ -196,15 +196,15 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return bool If the action has been added to the completed actions array |
198 | 198 | */ |
199 | -function give_has_upgrade_completed( $upgrade_action = '' ) { |
|
199 | +function give_has_upgrade_completed($upgrade_action = '') { |
|
200 | 200 | |
201 | - if ( empty( $upgrade_action ) ) { |
|
201 | + if (empty($upgrade_action)) { |
|
202 | 202 | return false; |
203 | 203 | } |
204 | 204 | |
205 | 205 | $completed_upgrades = give_get_completed_upgrades(); |
206 | 206 | |
207 | - return in_array( $upgrade_action, $completed_upgrades ); |
|
207 | + return in_array($upgrade_action, $completed_upgrades); |
|
208 | 208 | |
209 | 209 | } |
210 | 210 | |
@@ -216,8 +216,8 @@ discard block |
||
216 | 216 | * @return mixed When nothing to resume returns false, otherwise starts the upgrade where it left off |
217 | 217 | */ |
218 | 218 | function give_maybe_resume_upgrade() { |
219 | - $doing_upgrade = get_option( 'give_doing_upgrade', false ); |
|
220 | - if ( empty( $doing_upgrade ) ) { |
|
219 | + $doing_upgrade = get_option('give_doing_upgrade', false); |
|
220 | + if (empty($doing_upgrade)) { |
|
221 | 221 | return false; |
222 | 222 | } |
223 | 223 | |
@@ -233,9 +233,9 @@ discard block |
||
233 | 233 | * |
234 | 234 | * @return bool If the function was successfully added |
235 | 235 | */ |
236 | -function give_set_upgrade_complete( $upgrade_action = '' ) { |
|
236 | +function give_set_upgrade_complete($upgrade_action = '') { |
|
237 | 237 | |
238 | - if ( empty( $upgrade_action ) ) { |
|
238 | + if (empty($upgrade_action)) { |
|
239 | 239 | return false; |
240 | 240 | } |
241 | 241 | |
@@ -243,9 +243,9 @@ discard block |
||
243 | 243 | $completed_upgrades[] = $upgrade_action; |
244 | 244 | |
245 | 245 | // Remove any blanks, and only show uniques. |
246 | - $completed_upgrades = array_unique( array_values( $completed_upgrades ) ); |
|
246 | + $completed_upgrades = array_unique(array_values($completed_upgrades)); |
|
247 | 247 | |
248 | - return update_option( 'give_completed_upgrades', $completed_upgrades ); |
|
248 | + return update_option('give_completed_upgrades', $completed_upgrades); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | */ |
257 | 257 | function give_get_completed_upgrades() { |
258 | 258 | |
259 | - $completed_upgrades = get_option( 'give_completed_upgrades' ); |
|
259 | + $completed_upgrades = get_option('give_completed_upgrades'); |
|
260 | 260 | |
261 | - if ( false === $completed_upgrades ) { |
|
261 | + if (false === $completed_upgrades) { |
|
262 | 262 | $completed_upgrades = array(); |
263 | 263 | } |
264 | 264 | |
@@ -275,31 +275,31 @@ discard block |
||
275 | 275 | */ |
276 | 276 | function give_v132_upgrade_give_payment_customer_id() { |
277 | 277 | global $wpdb; |
278 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
279 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
278 | + if ( ! current_user_can('manage_give_settings')) { |
|
279 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
280 | 280 | 'response' => 403, |
281 | - ) ); |
|
281 | + )); |
|
282 | 282 | } |
283 | 283 | |
284 | - ignore_user_abort( true ); |
|
284 | + ignore_user_abort(true); |
|
285 | 285 | |
286 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
287 | - @set_time_limit( 0 ); |
|
286 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
287 | + @set_time_limit(0); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | // UPDATE DB METAKEYS. |
291 | 291 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
292 | - $query = $wpdb->query( $sql ); |
|
292 | + $query = $wpdb->query($sql); |
|
293 | 293 | |
294 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
295 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
296 | - delete_option( 'give_doing_upgrade' ); |
|
297 | - wp_redirect( admin_url() ); |
|
294 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
295 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
296 | + delete_option('give_doing_upgrade'); |
|
297 | + wp_redirect(admin_url()); |
|
298 | 298 | exit; |
299 | 299 | |
300 | 300 | } |
301 | 301 | |
302 | -add_action( 'give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id' ); |
|
302 | +add_action('give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id'); |
|
303 | 303 | |
304 | 304 | /** |
305 | 305 | * Upgrades the Offline Status |
@@ -312,16 +312,16 @@ discard block |
||
312 | 312 | |
313 | 313 | global $wpdb; |
314 | 314 | |
315 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
316 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
315 | + if ( ! current_user_can('manage_give_settings')) { |
|
316 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
317 | 317 | 'response' => 403, |
318 | - ) ); |
|
318 | + )); |
|
319 | 319 | } |
320 | 320 | |
321 | - ignore_user_abort( true ); |
|
321 | + ignore_user_abort(true); |
|
322 | 322 | |
323 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
324 | - @set_time_limit( 0 ); |
|
323 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
324 | + @set_time_limit(0); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | // Get abandoned offline payments. |
@@ -331,31 +331,31 @@ discard block |
||
331 | 331 | $where .= "AND ( p.post_status = 'abandoned' )"; |
332 | 332 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
333 | 333 | |
334 | - $sql = $select . $join . $where; |
|
335 | - $found_payments = $wpdb->get_col( $sql ); |
|
334 | + $sql = $select.$join.$where; |
|
335 | + $found_payments = $wpdb->get_col($sql); |
|
336 | 336 | |
337 | - foreach ( $found_payments as $payment ) { |
|
337 | + foreach ($found_payments as $payment) { |
|
338 | 338 | |
339 | 339 | // Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves. |
340 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
340 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
341 | 341 | |
342 | 342 | // 1450124863 = 12/10/2015 20:42:25. |
343 | - if ( $modified_time >= 1450124863 ) { |
|
343 | + if ($modified_time >= 1450124863) { |
|
344 | 344 | |
345 | - give_update_payment_status( $payment, 'pending' ); |
|
345 | + give_update_payment_status($payment, 'pending'); |
|
346 | 346 | |
347 | 347 | } |
348 | 348 | } |
349 | 349 | |
350 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
351 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
352 | - delete_option( 'give_doing_upgrade' ); |
|
353 | - wp_redirect( admin_url() ); |
|
350 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
351 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
352 | + delete_option('give_doing_upgrade'); |
|
353 | + wp_redirect(admin_url()); |
|
354 | 354 | exit; |
355 | 355 | |
356 | 356 | } |
357 | 357 | |
358 | -add_action( 'give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status' ); |
|
358 | +add_action('give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status'); |
|
359 | 359 | |
360 | 360 | /** |
361 | 361 | * Cleanup User Roles |
@@ -366,17 +366,17 @@ discard block |
||
366 | 366 | */ |
367 | 367 | function give_v152_cleanup_users() { |
368 | 368 | |
369 | - $give_version = get_option( 'give_version' ); |
|
369 | + $give_version = get_option('give_version'); |
|
370 | 370 | |
371 | - if ( ! $give_version ) { |
|
371 | + if ( ! $give_version) { |
|
372 | 372 | // 1.0 is the first version to use this option so we must add it. |
373 | 373 | $give_version = '1.0'; |
374 | 374 | } |
375 | 375 | |
376 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
376 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
377 | 377 | |
378 | 378 | // v1.5.2 Upgrades |
379 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
379 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
380 | 380 | |
381 | 381 | // Delete all caps with "ss". |
382 | 382 | // Also delete all unused "campaign" roles. |
@@ -423,9 +423,9 @@ discard block |
||
423 | 423 | ); |
424 | 424 | |
425 | 425 | global $wp_roles; |
426 | - foreach ( $delete_caps as $cap ) { |
|
427 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
428 | - $wp_roles->remove_cap( $role, $cap ); |
|
426 | + foreach ($delete_caps as $cap) { |
|
427 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
428 | + $wp_roles->remove_cap($role, $cap); |
|
429 | 429 | } |
430 | 430 | } |
431 | 431 | |
@@ -435,15 +435,15 @@ discard block |
||
435 | 435 | $roles->add_caps(); |
436 | 436 | |
437 | 437 | // The Update Ran. |
438 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
439 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
440 | - delete_option( 'give_doing_upgrade' ); |
|
438 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
439 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
440 | + delete_option('give_doing_upgrade'); |
|
441 | 441 | |
442 | 442 | }// End if(). |
443 | 443 | |
444 | 444 | } |
445 | 445 | |
446 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
446 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
447 | 447 | |
448 | 448 | /** |
449 | 449 | * 1.6 Upgrade routine to create the customer meta table. |
@@ -483,53 +483,53 @@ discard block |
||
483 | 483 | |
484 | 484 | // Get addons license key. |
485 | 485 | $addons = array(); |
486 | - foreach ( $give_options as $key => $value ) { |
|
487 | - if ( false !== strpos( $key, '_license_key' ) ) { |
|
488 | - $addons[ $key ] = $value; |
|
486 | + foreach ($give_options as $key => $value) { |
|
487 | + if (false !== strpos($key, '_license_key')) { |
|
488 | + $addons[$key] = $value; |
|
489 | 489 | } |
490 | 490 | } |
491 | 491 | |
492 | 492 | // Bailout: We do not have any addon license data to upgrade. |
493 | - if ( empty( $addons ) ) { |
|
493 | + if (empty($addons)) { |
|
494 | 494 | return false; |
495 | 495 | } |
496 | 496 | |
497 | - foreach ( $addons as $key => $addon_license ) { |
|
497 | + foreach ($addons as $key => $addon_license) { |
|
498 | 498 | |
499 | 499 | // Get addon shortname. |
500 | - $shortname = str_replace( '_license_key', '', $key ); |
|
500 | + $shortname = str_replace('_license_key', '', $key); |
|
501 | 501 | |
502 | 502 | // Addon license option name. |
503 | - $addon_license_option_name = $shortname . '_license_active'; |
|
503 | + $addon_license_option_name = $shortname.'_license_active'; |
|
504 | 504 | |
505 | 505 | // bailout if license is empty. |
506 | - if ( empty( $addon_license ) ) { |
|
507 | - delete_option( $addon_license_option_name ); |
|
506 | + if (empty($addon_license)) { |
|
507 | + delete_option($addon_license_option_name); |
|
508 | 508 | continue; |
509 | 509 | } |
510 | 510 | |
511 | 511 | // Get addon name. |
512 | 512 | $addon_name = array(); |
513 | - $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) ); |
|
514 | - foreach ( $addon_name_parts as $name_part ) { |
|
513 | + $addon_name_parts = explode('_', str_replace('give_', '', $shortname)); |
|
514 | + foreach ($addon_name_parts as $name_part) { |
|
515 | 515 | |
516 | 516 | // Fix addon name |
517 | - switch ( $name_part ) { |
|
517 | + switch ($name_part) { |
|
518 | 518 | case 'authorizenet' : |
519 | 519 | $name_part = 'authorize.net'; |
520 | 520 | break; |
521 | 521 | } |
522 | 522 | |
523 | - $addon_name[] = ucfirst( $name_part ); |
|
523 | + $addon_name[] = ucfirst($name_part); |
|
524 | 524 | } |
525 | 525 | |
526 | - $addon_name = implode( ' ', $addon_name ); |
|
526 | + $addon_name = implode(' ', $addon_name); |
|
527 | 527 | |
528 | 528 | // Data to send to the API |
529 | 529 | $api_params = array( |
530 | 530 | 'edd_action' => 'activate_license', // never change from "edd_" to "give_"! |
531 | 531 | 'license' => $addon_license, |
532 | - 'item_name' => urlencode( $addon_name ), |
|
532 | + 'item_name' => urlencode($addon_name), |
|
533 | 533 | 'url' => home_url(), |
534 | 534 | ); |
535 | 535 | |
@@ -544,17 +544,17 @@ discard block |
||
544 | 544 | ); |
545 | 545 | |
546 | 546 | // Make sure there are no errors. |
547 | - if ( is_wp_error( $response ) ) { |
|
548 | - delete_option( $addon_license_option_name ); |
|
547 | + if (is_wp_error($response)) { |
|
548 | + delete_option($addon_license_option_name); |
|
549 | 549 | continue; |
550 | 550 | } |
551 | 551 | |
552 | 552 | // Tell WordPress to look for updates. |
553 | - set_site_transient( 'update_plugins', null ); |
|
553 | + set_site_transient('update_plugins', null); |
|
554 | 554 | |
555 | 555 | // Decode license data. |
556 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
557 | - update_option( $addon_license_option_name, $license_data ); |
|
556 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
557 | + update_option($addon_license_option_name, $license_data); |
|
558 | 558 | }// End foreach(). |
559 | 559 | } |
560 | 560 | |
@@ -584,9 +584,9 @@ discard block |
||
584 | 584 | ); |
585 | 585 | |
586 | 586 | global $wp_roles; |
587 | - foreach ( $delete_caps as $cap ) { |
|
588 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
589 | - $wp_roles->remove_cap( $role, $cap ); |
|
587 | + foreach ($delete_caps as $cap) { |
|
588 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
589 | + $wp_roles->remove_cap($role, $cap); |
|
590 | 590 | } |
591 | 591 | } |
592 | 592 | |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | function give_v18_upgrades_core_setting() { |
621 | 621 | // Core settings which changes from checkbox to radio. |
622 | 622 | $core_setting_names = array_merge( |
623 | - array_keys( give_v18_renamed_core_settings() ), |
|
623 | + array_keys(give_v18_renamed_core_settings()), |
|
624 | 624 | array( |
625 | 625 | 'uninstall_on_delete', |
626 | 626 | 'scripts_footer', |
@@ -632,48 +632,48 @@ discard block |
||
632 | 632 | ); |
633 | 633 | |
634 | 634 | // Bailout: If not any setting define. |
635 | - if ( $give_settings = get_option( 'give_settings' ) ) { |
|
635 | + if ($give_settings = get_option('give_settings')) { |
|
636 | 636 | |
637 | 637 | $setting_changed = false; |
638 | 638 | |
639 | 639 | // Loop: check each setting field. |
640 | - foreach ( $core_setting_names as $setting_name ) { |
|
640 | + foreach ($core_setting_names as $setting_name) { |
|
641 | 641 | // New setting name. |
642 | - $new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name ); |
|
642 | + $new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name); |
|
643 | 643 | |
644 | 644 | // Continue: If setting already set. |
645 | 645 | if ( |
646 | - array_key_exists( $new_setting_name, $give_settings ) |
|
647 | - && in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) ) |
|
646 | + array_key_exists($new_setting_name, $give_settings) |
|
647 | + && in_array($give_settings[$new_setting_name], array('enabled', 'disabled')) |
|
648 | 648 | ) { |
649 | 649 | continue; |
650 | 650 | } |
651 | 651 | |
652 | 652 | // Set checkbox value to radio value. |
653 | - $give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' ); |
|
653 | + $give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled'); |
|
654 | 654 | |
655 | 655 | // @see https://github.com/WordImpress/Give/issues/1063 |
656 | - if ( false !== strpos( $setting_name, 'disable_' ) ) { |
|
656 | + if (false !== strpos($setting_name, 'disable_')) { |
|
657 | 657 | |
658 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' ); |
|
659 | - } elseif ( false !== strpos( $setting_name, 'enable_' ) ) { |
|
658 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled'); |
|
659 | + } elseif (false !== strpos($setting_name, 'enable_')) { |
|
660 | 660 | |
661 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' ); |
|
661 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled'); |
|
662 | 662 | } |
663 | 663 | |
664 | 664 | // Tell bot to update core setting to db. |
665 | - if ( ! $setting_changed ) { |
|
665 | + if ( ! $setting_changed) { |
|
666 | 666 | $setting_changed = true; |
667 | 667 | } |
668 | 668 | } |
669 | 669 | |
670 | 670 | // Update setting only if they changed. |
671 | - if ( $setting_changed ) { |
|
672 | - update_option( 'give_settings', $give_settings ); |
|
671 | + if ($setting_changed) { |
|
672 | + update_option('give_settings', $give_settings); |
|
673 | 673 | } |
674 | 674 | }// End if(). |
675 | 675 | |
676 | - give_set_upgrade_complete( 'v18_upgrades_core_setting' ); |
|
676 | + give_set_upgrade_complete('v18_upgrades_core_setting'); |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | /** |
@@ -683,22 +683,22 @@ discard block |
||
683 | 683 | * @return void |
684 | 684 | */ |
685 | 685 | function give_v18_upgrades_form_metadata() { |
686 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
687 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
686 | + if ( ! current_user_can('manage_give_settings')) { |
|
687 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
688 | 688 | 'response' => 403, |
689 | - ) ); |
|
689 | + )); |
|
690 | 690 | } |
691 | 691 | |
692 | - ignore_user_abort( true ); |
|
692 | + ignore_user_abort(true); |
|
693 | 693 | |
694 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
695 | - @set_time_limit( 0 ); |
|
694 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
695 | + @set_time_limit(0); |
|
696 | 696 | } |
697 | 697 | |
698 | - $step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1; |
|
698 | + $step = isset($_GET['step']) ? absint($_GET['step']) : 1; |
|
699 | 699 | |
700 | 700 | // form query |
701 | - $forms = new WP_Query( array( |
|
701 | + $forms = new WP_Query(array( |
|
702 | 702 | 'paged' => $step, |
703 | 703 | 'status' => 'any', |
704 | 704 | 'order' => 'ASC', |
@@ -708,27 +708,27 @@ discard block |
||
708 | 708 | ); |
709 | 709 | |
710 | 710 | |
711 | - if ( $forms->have_posts() ) { |
|
712 | - while ( $forms->have_posts() ) { |
|
711 | + if ($forms->have_posts()) { |
|
712 | + while ($forms->have_posts()) { |
|
713 | 713 | $forms->the_post(); |
714 | 714 | |
715 | 715 | // Form content. |
716 | 716 | // Note in version 1.8 display content setting split into display content and content placement setting. |
717 | 717 | // You can delete _give_content_option in future |
718 | - $show_content = get_post_meta( get_the_ID(), '_give_content_option', true ); |
|
719 | - if ( $show_content && ! get_post_meta( get_the_ID(), '_give_display_content', true ) ) { |
|
720 | - $field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' ); |
|
721 | - update_post_meta( get_the_ID(), '_give_display_content', $field_value ); |
|
718 | + $show_content = get_post_meta(get_the_ID(), '_give_content_option', true); |
|
719 | + if ($show_content && ! get_post_meta(get_the_ID(), '_give_display_content', true)) { |
|
720 | + $field_value = ('none' !== $show_content ? 'enabled' : 'disabled'); |
|
721 | + update_post_meta(get_the_ID(), '_give_display_content', $field_value); |
|
722 | 722 | |
723 | - $field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' ); |
|
724 | - update_post_meta( get_the_ID(), '_give_content_placement', $field_value ); |
|
723 | + $field_value = ('none' !== $show_content ? $show_content : 'give_pre_form'); |
|
724 | + update_post_meta(get_the_ID(), '_give_content_placement', $field_value); |
|
725 | 725 | } |
726 | 726 | |
727 | 727 | // "Disable" Guest Donation. Checkbox |
728 | 728 | // See: https://github.com/WordImpress/Give/issues/1470 |
729 | - $guest_donation = get_post_meta( get_the_ID(), '_give_logged_in_only', true ); |
|
730 | - $guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' ); |
|
731 | - update_post_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval ); |
|
729 | + $guest_donation = get_post_meta(get_the_ID(), '_give_logged_in_only', true); |
|
730 | + $guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled'); |
|
731 | + update_post_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval); |
|
732 | 732 | |
733 | 733 | // Convert yes/no setting field to enabled/disabled. |
734 | 734 | $form_radio_settings = array( |
@@ -751,15 +751,15 @@ discard block |
||
751 | 751 | '_give_offline_donation_enable_billing_fields_single', |
752 | 752 | ); |
753 | 753 | |
754 | - foreach ( $form_radio_settings as $meta_key ) { |
|
754 | + foreach ($form_radio_settings as $meta_key) { |
|
755 | 755 | // Get value. |
756 | - $field_value = get_post_meta( get_the_ID(), $meta_key, true ); |
|
756 | + $field_value = get_post_meta(get_the_ID(), $meta_key, true); |
|
757 | 757 | |
758 | 758 | // Convert meta value only if it is in yes/no/none. |
759 | - if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) { |
|
759 | + if (in_array($field_value, array('yes', 'on', 'no', 'none'))) { |
|
760 | 760 | |
761 | - $field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' ); |
|
762 | - update_post_meta( get_the_ID(), $meta_key, $field_value ); |
|
761 | + $field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled'); |
|
762 | + update_post_meta(get_the_ID(), $meta_key, $field_value); |
|
763 | 763 | } |
764 | 764 | } |
765 | 765 | }// End while(). |
@@ -767,28 +767,28 @@ discard block |
||
767 | 767 | wp_reset_postdata(); |
768 | 768 | |
769 | 769 | // Forms found so upgrade them |
770 | - $step ++; |
|
771 | - $redirect = add_query_arg( array( |
|
770 | + $step++; |
|
771 | + $redirect = add_query_arg(array( |
|
772 | 772 | 'page' => 'give-upgrades', |
773 | 773 | 'give-upgrade' => 'give_v18_upgrades_form_metadata', |
774 | 774 | 'step' => $step, |
775 | - ), admin_url( 'index.php' ) ); |
|
776 | - wp_redirect( $redirect ); |
|
775 | + ), admin_url('index.php')); |
|
776 | + wp_redirect($redirect); |
|
777 | 777 | exit(); |
778 | 778 | |
779 | 779 | } else { |
780 | 780 | // No more forms found, finish up. |
781 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
782 | - delete_option( 'give_doing_upgrade' ); |
|
783 | - give_set_upgrade_complete( 'v18_upgrades_form_metadata' ); |
|
781 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
782 | + delete_option('give_doing_upgrade'); |
|
783 | + give_set_upgrade_complete('v18_upgrades_form_metadata'); |
|
784 | 784 | |
785 | 785 | |
786 | - wp_redirect( admin_url() ); |
|
786 | + wp_redirect(admin_url()); |
|
787 | 787 | exit; |
788 | 788 | } |
789 | 789 | } |
790 | 790 | |
791 | -add_action( 'give_give_v18_upgrades_form_metadata', 'give_v18_upgrades_form_metadata' ); |
|
791 | +add_action('give_give_v18_upgrades_form_metadata', 'give_v18_upgrades_form_metadata'); |
|
792 | 792 | |
793 | 793 | /** |
794 | 794 | * Get list of core setting renamed in version 1.8. |
@@ -9,13 +9,13 @@ discard block |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | // Exit if accessed directly. |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
16 | 16 | // Load WP_List_Table if not loaded. |
17 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
18 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
17 | +if ( ! class_exists('WP_List_Table')) { |
|
18 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function __construct() { |
46 | 46 | // Set parent defaults. |
47 | - parent::__construct( array( |
|
48 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records. |
|
49 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records. |
|
47 | + parent::__construct(array( |
|
48 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records. |
|
49 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records. |
|
50 | 50 | 'ajax' => false // Does this table support ajax?. |
51 | - ) ); |
|
51 | + )); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -62,19 +62,19 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return string Column Name. |
64 | 64 | */ |
65 | - public function column_default( $item, $column_name ) { |
|
65 | + public function column_default($item, $column_name) { |
|
66 | 66 | |
67 | - switch ( $column_name ) { |
|
67 | + switch ($column_name) { |
|
68 | 68 | case 'ID' : |
69 | 69 | return $item['ID_label']; |
70 | 70 | case 'payment_id' : |
71 | - return empty( $item['payment_id'] ) ? esc_html__( 'n/a', 'give' ) : sprintf( "<a href=\"%s\" target=\"_blank\">{$item['payment_id']}</a>", get_edit_post_link( $item['payment_id'] ) ); |
|
71 | + return empty($item['payment_id']) ? esc_html__('n/a', 'give') : sprintf("<a href=\"%s\" target=\"_blank\">{$item['payment_id']}</a>", get_edit_post_link($item['payment_id'])); |
|
72 | 72 | case 'gateway' : |
73 | - return empty( $item['gateway'] ) ? esc_html__( 'n/a', 'give' ) : $item['gateway']; |
|
73 | + return empty($item['gateway']) ? esc_html__('n/a', 'give') : $item['gateway']; |
|
74 | 74 | case 'error' : |
75 | - return get_the_title( $item['ID'] ) ? get_the_title( $item['ID'] ) : esc_html__( 'Payment Error', 'give' ); |
|
75 | + return get_the_title($item['ID']) ? get_the_title($item['ID']) : esc_html__('Payment Error', 'give'); |
|
76 | 76 | default: |
77 | - return $item[ $column_name ]; |
|
77 | + return $item[$column_name]; |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -88,27 +88,27 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return void |
90 | 90 | */ |
91 | - public function column_message( $item ) { ?> |
|
92 | - <a href="#TB_inline?width=640&inlineId=log-message-<?php echo $item['ID']; ?>" class="thickbox give-error-log-details-link button button-small" data-tooltip="<?php esc_attr_e( 'View Log Message', 'give' ); ?>"><span class="dashicons dashicons-visibility"></span></a> |
|
91 | + public function column_message($item) { ?> |
|
92 | + <a href="#TB_inline?width=640&inlineId=log-message-<?php echo $item['ID']; ?>" class="thickbox give-error-log-details-link button button-small" data-tooltip="<?php esc_attr_e('View Log Message', 'give'); ?>"><span class="dashicons dashicons-visibility"></span></a> |
|
93 | 93 | <div id="log-message-<?php echo $item['ID']; ?>" style="display:none;"> |
94 | 94 | <?php |
95 | 95 | |
96 | - $log_message = get_post_field( 'post_content', $item['ID'] ); |
|
96 | + $log_message = get_post_field('post_content', $item['ID']); |
|
97 | 97 | |
98 | - $serialized = strpos( $log_message, '{"' ); |
|
98 | + $serialized = strpos($log_message, '{"'); |
|
99 | 99 | |
100 | 100 | // Check to see if the log message contains serialized information |
101 | - if ( $serialized !== false ) { |
|
102 | - $length = strlen( $log_message ) - $serialized; |
|
103 | - $intro = substr( $log_message, 0, - $length ); |
|
104 | - $data = substr( $log_message, $serialized, strlen( $log_message ) - 1 ); |
|
101 | + if ($serialized !== false) { |
|
102 | + $length = strlen($log_message) - $serialized; |
|
103 | + $intro = substr($log_message, 0, - $length); |
|
104 | + $data = substr($log_message, $serialized, strlen($log_message) - 1); |
|
105 | 105 | |
106 | - echo wpautop( $intro ); |
|
107 | - echo wpautop( '<strong>' . esc_html__( 'Log data:', 'give' ) . '</strong>' ); |
|
108 | - echo '<div style="word-wrap: break-word;">' . wpautop( $data ) . '</div>'; |
|
106 | + echo wpautop($intro); |
|
107 | + echo wpautop('<strong>'.esc_html__('Log data:', 'give').'</strong>'); |
|
108 | + echo '<div style="word-wrap: break-word;">'.wpautop($data).'</div>'; |
|
109 | 109 | } else { |
110 | 110 | // No serialized data found |
111 | - echo wpautop( $log_message ); |
|
111 | + echo wpautop($log_message); |
|
112 | 112 | } |
113 | 113 | ?> |
114 | 114 | </div> |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function get_columns() { |
126 | 126 | $columns = array( |
127 | - 'ID' => esc_html__( 'Log ID', 'give' ), |
|
128 | - 'error' => esc_html__( 'Error', 'give' ), |
|
129 | - 'gateway' => esc_html__( 'Gateway', 'give' ), |
|
130 | - 'payment_id' => esc_html__( 'Donation ID', 'give' ), |
|
131 | - 'date' => esc_html__( 'Date', 'give' ), |
|
132 | - 'message' => esc_html__( 'Details', 'give' ) |
|
127 | + 'ID' => esc_html__('Log ID', 'give'), |
|
128 | + 'error' => esc_html__('Error', 'give'), |
|
129 | + 'gateway' => esc_html__('Gateway', 'give'), |
|
130 | + 'payment_id' => esc_html__('Donation ID', 'give'), |
|
131 | + 'date' => esc_html__('Date', 'give'), |
|
132 | + 'message' => esc_html__('Details', 'give') |
|
133 | 133 | ); |
134 | 134 | |
135 | 135 | return $columns; |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @return int Current page number |
144 | 144 | */ |
145 | 145 | public function get_paged() { |
146 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
146 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @since 1.0 |
154 | 154 | * @return void |
155 | 155 | */ |
156 | - public function bulk_actions( $which = '' ) { |
|
156 | + public function bulk_actions($which = '') { |
|
157 | 157 | give_log_views(); |
158 | 158 | } |
159 | 159 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | |
172 | 172 | // Prevent the queries from getting cached. |
173 | 173 | // Without this there are occasional memory issues for some installs. |
174 | - wp_suspend_cache_addition( true ); |
|
174 | + wp_suspend_cache_addition(true); |
|
175 | 175 | |
176 | 176 | $logs_data = array(); |
177 | 177 | $paged = $this->get_paged(); |
@@ -180,17 +180,17 @@ discard block |
||
180 | 180 | 'paged' => $paged |
181 | 181 | ); |
182 | 182 | |
183 | - $logs = $give_logs->get_connected_logs( $log_query ); |
|
183 | + $logs = $give_logs->get_connected_logs($log_query); |
|
184 | 184 | |
185 | - if ( $logs ) { |
|
186 | - foreach ( $logs as $log ) { |
|
185 | + if ($logs) { |
|
186 | + foreach ($logs as $log) { |
|
187 | 187 | |
188 | 188 | $logs_data[] = array( |
189 | 189 | 'ID' => $log->ID, |
190 | - 'ID_label' => '<span class=\'give-item-label give-item-label-gray\'>' . $log->ID . '</span>', |
|
190 | + 'ID_label' => '<span class=\'give-item-label give-item-label-gray\'>'.$log->ID.'</span>', |
|
191 | 191 | 'payment_id' => $log->post_parent, |
192 | 192 | 'error' => 'error', |
193 | - 'gateway' => give_get_payment_gateway( $log->post_parent ), |
|
193 | + 'gateway' => give_get_payment_gateway($log->post_parent), |
|
194 | 194 | 'date' => $log->post_date |
195 | 195 | ); |
196 | 196 | } |
@@ -212,19 +212,19 @@ discard block |
||
212 | 212 | * |
213 | 213 | * @param string $which |
214 | 214 | */ |
215 | - protected function display_tablenav( $which ) { |
|
216 | - if ( 'top' === $which ) { |
|
217 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
215 | + protected function display_tablenav($which) { |
|
216 | + if ('top' === $which) { |
|
217 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
218 | 218 | } |
219 | 219 | ?> |
220 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
220 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
221 | 221 | |
222 | 222 | <div class="alignleft actions bulkactions"> |
223 | - <?php $this->bulk_actions( $which ); ?> |
|
223 | + <?php $this->bulk_actions($which); ?> |
|
224 | 224 | </div> |
225 | 225 | <?php |
226 | - $this->extra_tablenav( $which ); |
|
227 | - $this->pagination( $which ); |
|
226 | + $this->extra_tablenav($which); |
|
227 | + $this->pagination($which); |
|
228 | 228 | ?> |
229 | 229 | |
230 | 230 | <br class="clear"/> |
@@ -251,14 +251,14 @@ discard block |
||
251 | 251 | $columns = $this->get_columns(); |
252 | 252 | $hidden = array(); // No hidden columns |
253 | 253 | $sortable = $this->get_sortable_columns(); |
254 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
254 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
255 | 255 | $this->items = $this->get_logs(); |
256 | - $total_items = $give_logs->get_log_count( 0, 'gateway_error' ); |
|
256 | + $total_items = $give_logs->get_log_count(0, 'gateway_error'); |
|
257 | 257 | |
258 | - $this->set_pagination_args( array( |
|
258 | + $this->set_pagination_args(array( |
|
259 | 259 | 'total_items' => $total_items, |
260 | 260 | 'per_page' => $this->per_page, |
261 | - 'total_pages' => ceil( $total_items / $this->per_page ) |
|
261 | + 'total_pages' => ceil($total_items / $this->per_page) |
|
262 | 262 | ) |
263 | 263 | ); |
264 | 264 | } |
@@ -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 | |
@@ -25,25 +25,25 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_load_scripts() { |
27 | 27 | |
28 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/frontend/'; |
|
29 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
30 | - $scripts_footer = ( give_is_setting_enabled( give_get_option( 'scripts_footer' ) ) ) ? true : false; |
|
28 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/frontend/'; |
|
29 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
30 | + $scripts_footer = (give_is_setting_enabled(give_get_option('scripts_footer'))) ? true : false; |
|
31 | 31 | |
32 | 32 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
33 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
33 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
34 | 34 | |
35 | 35 | // Localize / PHP to AJAX vars. |
36 | - $localize_give_vars = apply_filters( 'give_global_script_vars', array( |
|
36 | + $localize_give_vars = apply_filters('give_global_script_vars', array( |
|
37 | 37 | 'ajaxurl' => give_get_ajax_url(), |
38 | - 'checkout_nonce' => wp_create_nonce( 'give_checkout_nonce' ), |
|
39 | - 'currency_sign' => give_currency_filter( '' ), |
|
38 | + 'checkout_nonce' => wp_create_nonce('give_checkout_nonce'), |
|
39 | + 'currency_sign' => give_currency_filter(''), |
|
40 | 40 | 'currency_pos' => give_get_currency_position(), |
41 | 41 | 'thousands_separator' => give_get_price_thousand_separator(), |
42 | 42 | 'decimal_separator' => give_get_price_decimal_separator(), |
43 | - 'no_gateway' => __( 'Please select a payment method.', 'give' ), |
|
44 | - 'bad_minimum' => __( 'The minimum donation amount for this form is', 'give' ), |
|
45 | - 'general_loading' => __( 'Loading...', 'give' ), |
|
46 | - 'purchase_loading' => __( 'Please Wait...', 'give' ), |
|
43 | + 'no_gateway' => __('Please select a payment method.', 'give'), |
|
44 | + 'bad_minimum' => __('The minimum donation amount for this form is', 'give'), |
|
45 | + 'general_loading' => __('Loading...', 'give'), |
|
46 | + 'purchase_loading' => __('Please Wait...', 'give'), |
|
47 | 47 | 'number_decimals' => give_get_price_decimals(), |
48 | 48 | 'give_version' => GIVE_VERSION, |
49 | 49 | 'magnific_options' => apply_filters( |
@@ -57,81 +57,81 @@ discard block |
||
57 | 57 | 'give_form_translation_js', |
58 | 58 | array( |
59 | 59 | // Field name Validation message. |
60 | - 'payment-mode' => __( 'Please select payment mode.', 'give' ), |
|
61 | - 'give_first' => __( 'Please enter your first name.', 'give' ), |
|
62 | - 'give_email' => __( 'Please enter a valid email address.', 'give' ), |
|
63 | - 'give_user_login' => __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ), |
|
64 | - 'give_user_pass' => __( 'Enter a password.', 'give' ), |
|
65 | - 'give_user_pass_confirm' => __( 'Enter the password confirmation.', 'give' ), |
|
66 | - 'give_agree_to_terms' => __( 'You must agree to the terms and conditions.', 'give' ), |
|
60 | + 'payment-mode' => __('Please select payment mode.', 'give'), |
|
61 | + 'give_first' => __('Please enter your first name.', 'give'), |
|
62 | + 'give_email' => __('Please enter a valid email address.', 'give'), |
|
63 | + 'give_user_login' => __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'), |
|
64 | + 'give_user_pass' => __('Enter a password.', 'give'), |
|
65 | + 'give_user_pass_confirm' => __('Enter the password confirmation.', 'give'), |
|
66 | + 'give_agree_to_terms' => __('You must agree to the terms and conditions.', 'give'), |
|
67 | 67 | ) |
68 | 68 | ), |
69 | - ) ); |
|
69 | + )); |
|
70 | 70 | |
71 | - $localize_give_ajax = apply_filters( 'give_global_ajax_vars', array( |
|
71 | + $localize_give_ajax = apply_filters('give_global_ajax_vars', array( |
|
72 | 72 | 'ajaxurl' => give_get_ajax_url(), |
73 | - 'loading' => __( 'Loading', 'give' ), |
|
73 | + 'loading' => __('Loading', 'give'), |
|
74 | 74 | // General loading message. |
75 | - 'select_option' => __( 'Please select an option', 'give' ), |
|
75 | + 'select_option' => __('Please select an option', 'give'), |
|
76 | 76 | // Variable pricing error with multi-donation option enabled. |
77 | - 'default_gateway' => give_get_default_gateway( null ), |
|
78 | - 'permalinks' => get_option( 'permalink_structure' ) ? '1' : '0', |
|
77 | + 'default_gateway' => give_get_default_gateway(null), |
|
78 | + 'permalinks' => get_option('permalink_structure') ? '1' : '0', |
|
79 | 79 | 'number_decimals' => give_get_price_decimals(), |
80 | - ) ); |
|
80 | + )); |
|
81 | 81 | |
82 | 82 | // DEBUG is On. |
83 | - if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { |
|
83 | + if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) { |
|
84 | 84 | |
85 | - if ( give_is_cc_verify_enabled() ) { |
|
86 | - wp_register_script( 'give-cc-validator', $js_plugins . 'jquery.payment' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
87 | - wp_enqueue_script( 'give-cc-validator' ); |
|
85 | + if (give_is_cc_verify_enabled()) { |
|
86 | + wp_register_script('give-cc-validator', $js_plugins.'jquery.payment'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
87 | + wp_enqueue_script('give-cc-validator'); |
|
88 | 88 | } |
89 | 89 | |
90 | - wp_register_script( 'give-float-labels', $js_plugins . 'float-labels' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
91 | - wp_enqueue_script( 'give-float-labels' ); |
|
90 | + wp_register_script('give-float-labels', $js_plugins.'float-labels'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
91 | + wp_enqueue_script('give-float-labels'); |
|
92 | 92 | |
93 | - wp_register_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
94 | - wp_enqueue_script( 'give-blockui' ); |
|
93 | + wp_register_script('give-blockui', $js_plugins.'jquery.blockUI'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
94 | + wp_enqueue_script('give-blockui'); |
|
95 | 95 | |
96 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
97 | - wp_enqueue_script( 'give-qtip' ); |
|
96 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
97 | + wp_enqueue_script('give-qtip'); |
|
98 | 98 | |
99 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
100 | - wp_enqueue_script( 'give-accounting' ); |
|
99 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
100 | + wp_enqueue_script('give-accounting'); |
|
101 | 101 | |
102 | - wp_register_script( 'give-magnific', $js_plugins . 'jquery.magnific-popup' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
103 | - wp_enqueue_script( 'give-magnific' ); |
|
102 | + wp_register_script('give-magnific', $js_plugins.'jquery.magnific-popup'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
103 | + wp_enqueue_script('give-magnific'); |
|
104 | 104 | |
105 | - wp_register_script( 'give-checkout-global', $js_dir . 'give-checkout-global' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
106 | - wp_enqueue_script( 'give-checkout-global' ); |
|
105 | + wp_register_script('give-checkout-global', $js_dir.'give-checkout-global'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
106 | + wp_enqueue_script('give-checkout-global'); |
|
107 | 107 | |
108 | 108 | // General scripts. |
109 | - wp_register_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
110 | - wp_enqueue_script( 'give-scripts' ); |
|
109 | + wp_register_script('give-scripts', $js_dir.'give'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
110 | + wp_enqueue_script('give-scripts'); |
|
111 | 111 | |
112 | 112 | // Load AJAX scripts, if enabled. |
113 | - wp_register_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
114 | - wp_enqueue_script( 'give-ajax' ); |
|
113 | + wp_register_script('give-ajax', $js_dir.'give-ajax'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
114 | + wp_enqueue_script('give-ajax'); |
|
115 | 115 | |
116 | 116 | // Localize / Pass AJAX vars from PHP, |
117 | - wp_localize_script( 'give-checkout-global', 'give_global_vars', $localize_give_vars ); |
|
118 | - wp_localize_script( 'give-ajax', 'give_scripts', $localize_give_ajax ); |
|
117 | + wp_localize_script('give-checkout-global', 'give_global_vars', $localize_give_vars); |
|
118 | + wp_localize_script('give-ajax', 'give_scripts', $localize_give_ajax); |
|
119 | 119 | |
120 | 120 | } else { |
121 | 121 | |
122 | 122 | // DEBUG is OFF (one JS file to rule them all!). |
123 | - wp_register_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
124 | - wp_enqueue_script( 'give' ); |
|
123 | + wp_register_script('give', $js_dir.'give.all.min.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
124 | + wp_enqueue_script('give'); |
|
125 | 125 | |
126 | 126 | // Localize / Pass AJAX vars from PHP. |
127 | - wp_localize_script( 'give', 'give_global_vars', $localize_give_vars ); |
|
128 | - wp_localize_script( 'give', 'give_scripts', $localize_give_ajax ); |
|
127 | + wp_localize_script('give', 'give_global_vars', $localize_give_vars); |
|
128 | + wp_localize_script('give', 'give_scripts', $localize_give_ajax); |
|
129 | 129 | |
130 | 130 | } |
131 | 131 | |
132 | 132 | } |
133 | 133 | |
134 | -add_action( 'wp_enqueue_scripts', 'give_load_scripts' ); |
|
134 | +add_action('wp_enqueue_scripts', 'give_load_scripts'); |
|
135 | 135 | |
136 | 136 | /** |
137 | 137 | * Register styles. |
@@ -144,16 +144,16 @@ discard block |
||
144 | 144 | */ |
145 | 145 | function give_register_styles() { |
146 | 146 | |
147 | - if ( ! give_is_setting_enabled( give_get_option( 'css' ) ) ) { |
|
147 | + if ( ! give_is_setting_enabled(give_get_option('css'))) { |
|
148 | 148 | return; |
149 | 149 | } |
150 | 150 | |
151 | - wp_register_style( 'give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all' ); |
|
152 | - wp_enqueue_style( 'give-styles' ); |
|
151 | + wp_register_style('give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all'); |
|
152 | + wp_enqueue_style('give-styles'); |
|
153 | 153 | |
154 | 154 | } |
155 | 155 | |
156 | -add_action( 'wp_enqueue_scripts', 'give_register_styles' ); |
|
156 | +add_action('wp_enqueue_scripts', 'give_register_styles'); |
|
157 | 157 | |
158 | 158 | |
159 | 159 | /** |
@@ -166,19 +166,19 @@ discard block |
||
166 | 166 | function give_get_stylesheet_uri() { |
167 | 167 | |
168 | 168 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
169 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
169 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
170 | 170 | |
171 | 171 | // LTR or RTL files. |
172 | - $direction = ( is_rtl() ) ? '-rtl' : ''; |
|
172 | + $direction = (is_rtl()) ? '-rtl' : ''; |
|
173 | 173 | |
174 | - $file = 'give' . $direction . $suffix . '.css'; |
|
174 | + $file = 'give'.$direction.$suffix.'.css'; |
|
175 | 175 | $templates_dir = give_get_theme_template_dir_name(); |
176 | 176 | |
177 | - $child_theme_style_sheet = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file; |
|
178 | - $child_theme_style_sheet_2 = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give' . $direction . '.css'; |
|
179 | - $parent_theme_style_sheet = trailingslashit( get_template_directory() ) . $templates_dir . $file; |
|
180 | - $parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give' . $direction . '.css'; |
|
181 | - $give_plugin_style_sheet = trailingslashit( give_get_templates_dir() ) . $file; |
|
177 | + $child_theme_style_sheet = trailingslashit(get_stylesheet_directory()).$templates_dir.$file; |
|
178 | + $child_theme_style_sheet_2 = trailingslashit(get_stylesheet_directory()).$templates_dir.'give'.$direction.'.css'; |
|
179 | + $parent_theme_style_sheet = trailingslashit(get_template_directory()).$templates_dir.$file; |
|
180 | + $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give'.$direction.'.css'; |
|
181 | + $give_plugin_style_sheet = trailingslashit(give_get_templates_dir()).$file; |
|
182 | 182 | |
183 | 183 | $uri = false; |
184 | 184 | |
@@ -188,23 +188,23 @@ discard block |
||
188 | 188 | * followed by non minified version, even if SCRIPT_DEBUG is not enabled. |
189 | 189 | * This allows users to copy just give.css to their theme. |
190 | 190 | */ |
191 | - if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) { |
|
192 | - if ( ! empty( $nonmin ) ) { |
|
193 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give' . $direction . '.css'; |
|
191 | + if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) { |
|
192 | + if ( ! empty($nonmin)) { |
|
193 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give'.$direction.'.css'; |
|
194 | 194 | } else { |
195 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file; |
|
195 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file; |
|
196 | 196 | } |
197 | - } elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) { |
|
198 | - if ( ! empty( $nonmin ) ) { |
|
199 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give' . $direction . '.css'; |
|
197 | + } elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) { |
|
198 | + if ( ! empty($nonmin)) { |
|
199 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.'give'.$direction.'.css'; |
|
200 | 200 | } else { |
201 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file; |
|
201 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.$file; |
|
202 | 202 | } |
203 | - } elseif ( file_exists( $give_plugin_style_sheet ) || file_exists( $give_plugin_style_sheet ) ) { |
|
204 | - $uri = trailingslashit( give_get_templates_url() ) . $file; |
|
203 | + } elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) { |
|
204 | + $uri = trailingslashit(give_get_templates_url()).$file; |
|
205 | 205 | } |
206 | 206 | |
207 | - return apply_filters( 'give_get_stylesheet_uri', $uri ); |
|
207 | + return apply_filters('give_get_stylesheet_uri', $uri); |
|
208 | 208 | |
209 | 209 | } |
210 | 210 | |
@@ -221,73 +221,73 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @return void |
223 | 223 | */ |
224 | -function give_load_admin_scripts( $hook ) { |
|
224 | +function give_load_admin_scripts($hook) { |
|
225 | 225 | |
226 | 226 | global $post, $post_type; |
227 | 227 | |
228 | 228 | $give_options = give_get_settings(); |
229 | 229 | |
230 | 230 | // Directories of assets. |
231 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
232 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
233 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
231 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
232 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
233 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
234 | 234 | |
235 | 235 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
236 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
236 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
237 | 237 | |
238 | 238 | // LTR or RTL files. |
239 | - $direction = ( is_rtl() ) ? '-rtl' : ''; |
|
239 | + $direction = (is_rtl()) ? '-rtl' : ''; |
|
240 | 240 | |
241 | 241 | // Global Admin. |
242 | - wp_register_style( 'give-admin-bar-notification', $css_dir . 'adminbar-style.css' ); |
|
243 | - wp_enqueue_style( 'give-admin-bar-notification' ); |
|
242 | + wp_register_style('give-admin-bar-notification', $css_dir.'adminbar-style.css'); |
|
243 | + wp_enqueue_style('give-admin-bar-notification'); |
|
244 | 244 | |
245 | 245 | // Give Admin Only. |
246 | - if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) { |
|
246 | + if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) { |
|
247 | 247 | return; |
248 | 248 | } |
249 | 249 | |
250 | 250 | // CSS. |
251 | - wp_register_style( 'jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css' ); |
|
252 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
253 | - wp_register_style( 'give-admin', $css_dir . 'give-admin' . $direction . $suffix . '.css', array(), GIVE_VERSION ); |
|
254 | - wp_enqueue_style( 'give-admin' ); |
|
255 | - wp_register_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION ); |
|
256 | - wp_enqueue_style( 'jquery-chosen' ); |
|
257 | - wp_enqueue_style( 'thickbox' ); |
|
251 | + wp_register_style('jquery-ui-css', $css_dir.'jquery-ui-fresh'.$suffix.'.css'); |
|
252 | + wp_enqueue_style('jquery-ui-css'); |
|
253 | + wp_register_style('give-admin', $css_dir.'give-admin'.$direction.$suffix.'.css', array(), GIVE_VERSION); |
|
254 | + wp_enqueue_style('give-admin'); |
|
255 | + wp_register_style('jquery-chosen', $css_dir.'chosen'.$suffix.'.css', array(), GIVE_VERSION); |
|
256 | + wp_enqueue_style('jquery-chosen'); |
|
257 | + wp_enqueue_style('thickbox'); |
|
258 | 258 | |
259 | 259 | // JS. |
260 | - wp_register_script( 'jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
261 | - wp_enqueue_script( 'jquery-chosen' ); |
|
260 | + wp_register_script('jquery-chosen', $js_plugins.'chosen.jquery'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
261 | + wp_enqueue_script('jquery-chosen'); |
|
262 | 262 | |
263 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
264 | - wp_enqueue_script( 'give-accounting' ); |
|
263 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
264 | + wp_enqueue_script('give-accounting'); |
|
265 | 265 | |
266 | - wp_register_script( 'give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
267 | - wp_enqueue_script( 'give-admin-scripts' ); |
|
266 | + wp_register_script('give-admin-scripts', $js_dir.'admin-scripts'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
267 | + wp_enqueue_script('give-admin-scripts'); |
|
268 | 268 | |
269 | - wp_register_script( 'jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js' ); |
|
270 | - wp_enqueue_script( 'jquery-flot' ); |
|
269 | + wp_register_script('jquery-flot', $js_plugins.'jquery.flot'.$suffix.'.js'); |
|
270 | + wp_enqueue_script('jquery-flot'); |
|
271 | 271 | |
272 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
273 | - wp_enqueue_script( 'give-qtip' ); |
|
272 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
273 | + wp_enqueue_script('give-qtip'); |
|
274 | 274 | |
275 | - wp_register_script( 'give-repeatable-fields', $js_plugins . 'repeatable-fields' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
276 | - wp_enqueue_script( 'give-repeatable-fields' ); |
|
275 | + wp_register_script('give-repeatable-fields', $js_plugins.'repeatable-fields'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
276 | + wp_enqueue_script('give-repeatable-fields'); |
|
277 | 277 | |
278 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
279 | - wp_enqueue_script( 'thickbox' ); |
|
278 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
279 | + wp_enqueue_script('thickbox'); |
|
280 | 280 | |
281 | 281 | // Forms CPT Script. |
282 | - if ( $post_type === 'give_forms' ) { |
|
283 | - wp_register_script( 'give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
284 | - wp_enqueue_script( 'give-admin-forms-scripts' ); |
|
282 | + if ($post_type === 'give_forms') { |
|
283 | + wp_register_script('give-admin-forms-scripts', $js_dir.'admin-forms'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
284 | + wp_enqueue_script('give-admin-forms-scripts'); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | // Settings Scripts. |
288 | - if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-settings' ) { |
|
289 | - wp_register_script( 'give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
290 | - wp_enqueue_script( 'give-admin-settings-scripts' ); |
|
288 | + if (isset($_GET['page']) && $_GET['page'] == 'give-settings') { |
|
289 | + wp_register_script('give-admin-settings-scripts', $js_dir.'admin-settings'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
290 | + wp_enqueue_script('give-admin-settings-scripts'); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | // Price Separators. |
@@ -295,60 +295,60 @@ discard block |
||
295 | 295 | $decimal_separator = give_get_price_decimal_separator(); |
296 | 296 | |
297 | 297 | // Localize strings & variables for JS. |
298 | - wp_localize_script( 'give-admin-scripts', 'give_vars', array( |
|
299 | - 'post_id' => isset( $post->ID ) ? $post->ID : null, |
|
298 | + wp_localize_script('give-admin-scripts', 'give_vars', array( |
|
299 | + 'post_id' => isset($post->ID) ? $post->ID : null, |
|
300 | 300 | 'give_version' => GIVE_VERSION, |
301 | 301 | 'thousands_separator' => $thousand_separator, |
302 | 302 | 'decimal_separator' => $decimal_separator, |
303 | - 'quick_edit_warning' => __( 'Not available for variable priced forms.', 'give' ), |
|
304 | - 'delete_payment' => __( 'Are you sure you wish to delete this payment?', 'give' ), |
|
305 | - 'delete_payment_note' => __( 'Are you sure you wish to delete this note?', 'give' ), |
|
306 | - 'revoke_api_key' => __( 'Are you sure you wish to revoke this API key?', 'give' ), |
|
307 | - 'regenerate_api_key' => __( 'Are you sure you wish to regenerate this API key?', 'give' ), |
|
308 | - 'resend_receipt' => __( 'Are you sure you wish to resend the donation receipt?', 'give' ), |
|
309 | - 'logo' => __( 'Logo', 'give' ), |
|
310 | - 'use_this_image' => __( 'Use this image', 'give' ), |
|
311 | - 'one_option' => __( 'Choose a form', 'give' ), |
|
312 | - 'one_or_more_option' => __( 'Choose one or more forms', 'give' ), |
|
313 | - 'currency_sign' => give_currency_filter( '' ), |
|
314 | - 'currency_pos' => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before', |
|
315 | - 'currency_decimals' => give_currency_decimal_filter( give_get_price_decimals() ), |
|
316 | - 'batch_export_no_class' => __( 'You must choose a method.', 'give' ), |
|
317 | - 'batch_export_no_reqs' => __( 'Required fields not completed.', 'give' ), |
|
318 | - 'reset_stats_warn' => __( 'Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give' ), |
|
319 | - 'price_format_guide' => sprintf( __( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator ), |
|
303 | + 'quick_edit_warning' => __('Not available for variable priced forms.', 'give'), |
|
304 | + 'delete_payment' => __('Are you sure you wish to delete this payment?', 'give'), |
|
305 | + 'delete_payment_note' => __('Are you sure you wish to delete this note?', 'give'), |
|
306 | + 'revoke_api_key' => __('Are you sure you wish to revoke this API key?', 'give'), |
|
307 | + 'regenerate_api_key' => __('Are you sure you wish to regenerate this API key?', 'give'), |
|
308 | + 'resend_receipt' => __('Are you sure you wish to resend the donation receipt?', 'give'), |
|
309 | + 'logo' => __('Logo', 'give'), |
|
310 | + 'use_this_image' => __('Use this image', 'give'), |
|
311 | + 'one_option' => __('Choose a form', 'give'), |
|
312 | + 'one_or_more_option' => __('Choose one or more forms', 'give'), |
|
313 | + 'currency_sign' => give_currency_filter(''), |
|
314 | + 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', |
|
315 | + 'currency_decimals' => give_currency_decimal_filter(give_get_price_decimals()), |
|
316 | + 'batch_export_no_class' => __('You must choose a method.', 'give'), |
|
317 | + 'batch_export_no_reqs' => __('Required fields not completed.', 'give'), |
|
318 | + 'reset_stats_warn' => __('Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give'), |
|
319 | + 'price_format_guide' => sprintf(__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator), |
|
320 | 320 | /* translators : %s: Donation form options metabox */ |
321 | - 'confirm_before_remove_row_text' => __( 'Do you want to delete this level?', 'give' ), |
|
322 | - 'matched_success_failure_page' => __( 'You cannot set the success and failed pages to the same page', 'give' ), |
|
323 | - 'dismiss_notice_text' => __( 'Dismiss this notice.', 'give' ), |
|
321 | + 'confirm_before_remove_row_text' => __('Do you want to delete this level?', 'give'), |
|
322 | + 'matched_success_failure_page' => __('You cannot set the success and failed pages to the same page', 'give'), |
|
323 | + 'dismiss_notice_text' => __('Dismiss this notice.', 'give'), |
|
324 | 324 | 'bulk_action' => array( |
325 | 325 | 'delete' => array( |
326 | - 'zero_payment_selected' => __( 'You must choose at least one or more payments to delete.', 'give' ), |
|
327 | - 'delete_payment' => __( 'Are you sure you want to permanently delete this donation?', 'give' ), |
|
328 | - 'delete_payments' => __( 'Are you sure you want to permanently delete the selected {payment_count} donations?', 'give' ), |
|
326 | + 'zero_payment_selected' => __('You must choose at least one or more payments to delete.', 'give'), |
|
327 | + 'delete_payment' => __('Are you sure you want to permanently delete this donation?', 'give'), |
|
328 | + 'delete_payments' => __('Are you sure you want to permanently delete the selected {payment_count} donations?', 'give'), |
|
329 | 329 | ), |
330 | 330 | 'resend_receipt' => array( |
331 | - 'zero_recipient_selected' => __( 'You must choose at least one or more recipients to resend the email receipt.', 'give' ), |
|
332 | - 'resend_receipt' => __( 'Are you sure you want to resend the email receipt to this recipient?', 'give' ), |
|
333 | - 'resend_receipts' => __( 'Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give' ), |
|
331 | + 'zero_recipient_selected' => __('You must choose at least one or more recipients to resend the email receipt.', 'give'), |
|
332 | + 'resend_receipt' => __('Are you sure you want to resend the email receipt to this recipient?', 'give'), |
|
333 | + 'resend_receipts' => __('Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give'), |
|
334 | 334 | ), |
335 | 335 | ), |
336 | - 'upgrade_confirmation' => __( 'Please make sure to create a database backup before initiating the upgrade.', 'give' ), |
|
336 | + 'upgrade_confirmation' => __('Please make sure to create a database backup before initiating the upgrade.', 'give'), |
|
337 | 337 | 'metabox_fields' => array( |
338 | 338 | 'media' => array( |
339 | - 'button_title' => esc_html__( 'Choose Attachment', 'give' ), |
|
339 | + 'button_title' => esc_html__('Choose Attachment', 'give'), |
|
340 | 340 | ) |
341 | 341 | ) |
342 | - ) ); |
|
342 | + )); |
|
343 | 343 | |
344 | - if ( function_exists( 'wp_enqueue_media' ) && version_compare( get_bloginfo( 'version' ), '3.5', '>=' ) ) { |
|
344 | + if (function_exists('wp_enqueue_media') && version_compare(get_bloginfo('version'), '3.5', '>=')) { |
|
345 | 345 | // call for new media manager. |
346 | 346 | wp_enqueue_media(); |
347 | 347 | } |
348 | 348 | |
349 | 349 | } |
350 | 350 | |
351 | -add_action( 'admin_enqueue_scripts', 'give_load_admin_scripts', 100 ); |
|
351 | +add_action('admin_enqueue_scripts', 'give_load_admin_scripts', 100); |
|
352 | 352 | |
353 | 353 | /** |
354 | 354 | * Admin Give Icon |
@@ -363,13 +363,13 @@ discard block |
||
363 | 363 | ?> |
364 | 364 | <style type="text/css" media="screen"> |
365 | 365 | |
366 | - <?php if ( version_compare( get_bloginfo( 'version' ), '3.8-RC', '>=' ) || version_compare( get_bloginfo( 'version' ), '3.8', '>=' ) ) { ?> |
|
366 | + <?php if (version_compare(get_bloginfo('version'), '3.8-RC', '>=') || version_compare(get_bloginfo('version'), '3.8', '>=')) { ?> |
|
367 | 367 | @font-face { |
368 | 368 | font-family: 'give-icomoon'; |
369 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?ngjl88'; ?>'); |
|
370 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), |
|
371 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), |
|
372 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); |
|
369 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?ngjl88'; ?>'); |
|
370 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), |
|
371 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), |
|
372 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); |
|
373 | 373 | font-weight: normal; |
374 | 374 | font-style: normal; |
375 | 375 | } |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | <?php |
389 | 389 | } |
390 | 390 | |
391 | -add_action( 'admin_head', 'give_admin_icon' ); |
|
391 | +add_action('admin_head', 'give_admin_icon'); |
|
392 | 392 | |
393 | 393 | /** |
394 | 394 | * Admin js code |
@@ -418,4 +418,4 @@ discard block |
||
418 | 418 | <?php |
419 | 419 | } |
420 | 420 | |
421 | -add_action( 'admin_head', 'give_admin_hide_notice_shortly_js' ); |
|
421 | +add_action('admin_head', 'give_admin_hide_notice_shortly_js'); |
@@ -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'); |