@@ -694,7 +694,7 @@ |
||
694 | 694 | if( |
695 | 695 | empty( $this->license ) |
696 | 696 | && ! $this->__is_notice_dismissed( 'general' ) |
697 | - && empty( $showed_invalid_message ) |
|
697 | + && empty( $showed_invalid_message ) |
|
698 | 698 | ) { |
699 | 699 | $messages['general'] = sprintf( |
700 | 700 | __( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ), |
@@ -10,11 +10,11 @@ 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 | |
17 | -if ( ! class_exists( 'Give_License' ) ) : |
|
17 | +if ( ! class_exists('Give_License')) : |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Give_License Class |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @var string |
105 | 105 | */ |
106 | - private $api_url = 'https://givewp.com/edd-sl-api/'; |
|
106 | + private $api_url = 'https://givewp.com/edd-sl-api/'; |
|
107 | 107 | |
108 | 108 | /** |
109 | 109 | * Account URL |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @var null|string |
115 | 115 | */ |
116 | - private $account_url = 'https://givewp.com/my-account/'; |
|
116 | + private $account_url = 'https://givewp.com/my-account/'; |
|
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Ccheckout URL |
@@ -142,19 +142,19 @@ discard block |
||
142 | 142 | * @param string $_checkout_url |
143 | 143 | * @param string $_account_url |
144 | 144 | */ |
145 | - public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null ) { |
|
145 | + public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null) { |
|
146 | 146 | $give_options = give_get_settings(); |
147 | 147 | |
148 | 148 | $this->file = $_file; |
149 | 149 | $this->item_name = $_item_name; |
150 | - $this->item_shortname = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) ); |
|
150 | + $this->item_shortname = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name))); |
|
151 | 151 | $this->version = $_version; |
152 | - $this->license = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : ''; |
|
153 | - $this->license_data = get_option( $this->item_shortname . '_license_active' ); |
|
152 | + $this->license = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : ''; |
|
153 | + $this->license_data = get_option($this->item_shortname.'_license_active'); |
|
154 | 154 | $this->author = $_author; |
155 | - $this->api_url = is_null( $_api_url ) ? $this->api_url : $_api_url; |
|
156 | - $this->checkout_url = is_null( $_checkout_url ) ? $this->checkout_url : $_checkout_url; |
|
157 | - $this->account_url = is_null( $_account_url ) ? $this->account_url : $_account_url; |
|
155 | + $this->api_url = is_null($_api_url) ? $this->api_url : $_api_url; |
|
156 | + $this->checkout_url = is_null($_checkout_url) ? $this->checkout_url : $_checkout_url; |
|
157 | + $this->account_url = is_null($_account_url) ? $this->account_url : $_account_url; |
|
158 | 158 | |
159 | 159 | // Setup hooks |
160 | 160 | $this->includes(); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @return void |
174 | 174 | */ |
175 | 175 | private function includes() { |
176 | - if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
176 | + if ( ! class_exists('EDD_SL_Plugin_Updater')) { |
|
177 | 177 | require_once 'admin/EDD_SL_Plugin_Updater.php'; |
178 | 178 | } |
179 | 179 | } |
@@ -191,26 +191,26 @@ discard block |
||
191 | 191 | private function hooks() { |
192 | 192 | |
193 | 193 | // Register settings |
194 | - add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 ); |
|
194 | + add_filter('give_settings_licenses', array($this, 'settings'), 1); |
|
195 | 195 | |
196 | 196 | // Activate license key on settings save |
197 | - add_action( 'admin_init', array( $this, 'activate_license' ) ); |
|
197 | + add_action('admin_init', array($this, 'activate_license')); |
|
198 | 198 | |
199 | 199 | // Deactivate license key |
200 | - add_action( 'admin_init', array( $this, 'deactivate_license' ) ); |
|
200 | + add_action('admin_init', array($this, 'deactivate_license')); |
|
201 | 201 | |
202 | 202 | // Updater |
203 | - add_action( 'admin_init', array( $this, 'auto_updater' ), 0 ); |
|
203 | + add_action('admin_init', array($this, 'auto_updater'), 0); |
|
204 | 204 | |
205 | - add_action( 'admin_notices', array( $this, 'notices' ) ); |
|
205 | + add_action('admin_notices', array($this, 'notices')); |
|
206 | 206 | |
207 | 207 | // Check license weekly. |
208 | - add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_license_check' ) ); |
|
209 | - add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_license_check' ) ); |
|
208 | + add_action('give_weekly_scheduled_events', array($this, 'weekly_license_check')); |
|
209 | + add_action('give_validate_license_when_site_migrated', array($this, 'weekly_license_check')); |
|
210 | 210 | |
211 | 211 | // Check subscription weekly. |
212 | - add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_subscription_check' ) ); |
|
213 | - add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_subscription_check' ) ); |
|
212 | + add_action('give_weekly_scheduled_events', array($this, 'weekly_subscription_check')); |
|
213 | + add_action('give_validate_license_when_site_migrated', array($this, 'weekly_subscription_check')); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public function auto_updater() { |
225 | 225 | |
226 | - if ( ! $this->is_valid_license() ) { |
|
226 | + if ( ! $this->is_valid_license()) { |
|
227 | 227 | return false; |
228 | 228 | } |
229 | 229 | |
@@ -252,16 +252,16 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @return array License settings. |
254 | 254 | */ |
255 | - public function settings( $settings ) { |
|
255 | + public function settings($settings) { |
|
256 | 256 | |
257 | 257 | $give_license_settings = array( |
258 | 258 | array( |
259 | 259 | 'name' => $this->item_name, |
260 | - 'id' => $this->item_shortname . '_license_key', |
|
260 | + 'id' => $this->item_shortname.'_license_key', |
|
261 | 261 | 'desc' => '', |
262 | 262 | 'type' => 'license_key', |
263 | 263 | 'options' => array( |
264 | - 'license' => get_option( $this->item_shortname . '_license_active' ), |
|
264 | + 'license' => get_option($this->item_shortname.'_license_active'), |
|
265 | 265 | 'shortname' => $this->item_shortname, |
266 | 266 | 'item_name' => $this->item_name, |
267 | 267 | 'api_url' => $this->api_url, |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | ) |
273 | 273 | ); |
274 | 274 | |
275 | - return array_merge( $settings, $give_license_settings ); |
|
275 | + return array_merge($settings, $give_license_settings); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -287,18 +287,18 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @return array License settings content. |
289 | 289 | */ |
290 | - public function license_settings_content( $settings ) { |
|
290 | + public function license_settings_content($settings) { |
|
291 | 291 | |
292 | 292 | $give_license_settings = array( |
293 | 293 | array( |
294 | - 'name' => esc_html__( 'Add-on Licenses', 'give' ), |
|
294 | + 'name' => esc_html__('Add-on Licenses', 'give'), |
|
295 | 295 | 'desc' => '<hr>', |
296 | 296 | 'type' => 'give_title', |
297 | 297 | 'id' => 'give_title' |
298 | 298 | ), |
299 | 299 | ); |
300 | 300 | |
301 | - return array_merge( $settings, $give_license_settings ); |
|
301 | + return array_merge($settings, $give_license_settings); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
@@ -313,37 +313,37 @@ discard block |
||
313 | 313 | */ |
314 | 314 | public function activate_license() { |
315 | 315 | // Bailout: Check if license key set of not. |
316 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
316 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
317 | 317 | return; |
318 | 318 | } |
319 | 319 | |
320 | 320 | // Security check. |
321 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
321 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
322 | 322 | |
323 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
323 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
324 | 324 | |
325 | 325 | } |
326 | 326 | |
327 | 327 | // Check if user have correct permissions. |
328 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
328 | + if ( ! current_user_can('manage_give_settings')) { |
|
329 | 329 | return; |
330 | 330 | } |
331 | 331 | |
332 | 332 | // Allow third party addon developers to handle license activation. |
333 | - if( $this->__is_third_party_addon() ){ |
|
334 | - do_action( 'give_activate_license', $this ); |
|
333 | + if ($this->__is_third_party_addon()) { |
|
334 | + do_action('give_activate_license', $this); |
|
335 | 335 | return; |
336 | 336 | } |
337 | 337 | |
338 | 338 | // Delete previous license setting if a empty license key submitted. |
339 | - if ( empty( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
340 | - delete_option( $this->item_shortname . '_license_active' ); |
|
339 | + if (empty($_POST[$this->item_shortname.'_license_key'])) { |
|
340 | + delete_option($this->item_shortname.'_license_active'); |
|
341 | 341 | return; |
342 | 342 | } |
343 | 343 | |
344 | 344 | // Do not simultaneously activate any addon if user want to deactivate any addon. |
345 | - foreach ( $_POST as $key => $value ) { |
|
346 | - if ( false !== strpos( $key, 'license_key_deactivate' ) ) { |
|
345 | + foreach ($_POST as $key => $value) { |
|
346 | + if (false !== strpos($key, 'license_key_deactivate')) { |
|
347 | 347 | // Don't activate a key when deactivating a different key |
348 | 348 | return; |
349 | 349 | } |
@@ -351,15 +351,15 @@ discard block |
||
351 | 351 | |
352 | 352 | |
353 | 353 | // Check if plugin previously installed. |
354 | - if ( $this->is_valid_license() ) { |
|
354 | + if ($this->is_valid_license()) { |
|
355 | 355 | return; |
356 | 356 | } |
357 | 357 | |
358 | 358 | // Get license key. |
359 | - $license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] ); |
|
359 | + $license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']); |
|
360 | 360 | |
361 | 361 | // Bailout. |
362 | - if( empty( $license ) ) { |
|
362 | + if (empty($license)) { |
|
363 | 363 | return; |
364 | 364 | } |
365 | 365 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | $api_params = array( |
371 | 371 | 'edd_action' => 'activate_license', //never change from "edd_" to "give_"! |
372 | 372 | 'license' => $license, |
373 | - 'item_name' => urlencode( $this->item_name ), |
|
373 | + 'item_name' => urlencode($this->item_name), |
|
374 | 374 | 'url' => home_url() |
375 | 375 | ); |
376 | 376 | |
@@ -385,16 +385,16 @@ discard block |
||
385 | 385 | ); |
386 | 386 | |
387 | 387 | // Make sure there are no errors |
388 | - if ( is_wp_error( $response ) ) { |
|
388 | + if (is_wp_error($response)) { |
|
389 | 389 | return; |
390 | 390 | } |
391 | 391 | |
392 | 392 | // Tell WordPress to look for updates |
393 | - set_site_transient( 'update_plugins', null ); |
|
393 | + set_site_transient('update_plugins', null); |
|
394 | 394 | |
395 | 395 | // Decode license data |
396 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
397 | - update_option( $this->item_shortname . '_license_active', $license_data ); |
|
396 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
397 | + update_option($this->item_shortname.'_license_active', $license_data); |
|
398 | 398 | |
399 | 399 | // Check subscription for license key and store this to db (if any). |
400 | 400 | $this->__single_subscription_check(); |
@@ -412,34 +412,34 @@ discard block |
||
412 | 412 | */ |
413 | 413 | public function deactivate_license() { |
414 | 414 | |
415 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
415 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
416 | 416 | return; |
417 | 417 | } |
418 | 418 | |
419 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
419 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
420 | 420 | |
421 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
421 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
422 | 422 | |
423 | 423 | } |
424 | 424 | |
425 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
425 | + if ( ! current_user_can('manage_give_settings')) { |
|
426 | 426 | return; |
427 | 427 | } |
428 | 428 | |
429 | 429 | // Allow third party add-on developers to handle license deactivation. |
430 | - if( $this->__is_third_party_addon() ){ |
|
431 | - do_action( 'give_deactivate_license', $this ); |
|
430 | + if ($this->__is_third_party_addon()) { |
|
431 | + do_action('give_deactivate_license', $this); |
|
432 | 432 | return; |
433 | 433 | } |
434 | 434 | |
435 | 435 | // Run on deactivate button press |
436 | - if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) { |
|
436 | + if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) { |
|
437 | 437 | |
438 | 438 | // Data to send to the API |
439 | 439 | $api_params = array( |
440 | 440 | 'edd_action' => 'deactivate_license', //never change from "edd_" to "give_"! |
441 | 441 | 'license' => $this->license, |
442 | - 'item_name' => urlencode( $this->item_name ), |
|
442 | + 'item_name' => urlencode($this->item_name), |
|
443 | 443 | 'url' => home_url() |
444 | 444 | ); |
445 | 445 | |
@@ -454,15 +454,15 @@ discard block |
||
454 | 454 | ); |
455 | 455 | |
456 | 456 | // Make sure there are no errors |
457 | - if ( is_wp_error( $response ) ) { |
|
457 | + if (is_wp_error($response)) { |
|
458 | 458 | return; |
459 | 459 | } |
460 | 460 | |
461 | 461 | // Decode the license data |
462 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
462 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
463 | 463 | |
464 | 464 | // Remove license data. |
465 | - delete_option( $this->item_shortname . '_license_active' ); |
|
465 | + delete_option($this->item_shortname.'_license_active'); |
|
466 | 466 | |
467 | 467 | // Remove license key from subscriptions if exist. |
468 | 468 | $this->__remove_license_key_from_subscriptions(); |
@@ -479,18 +479,18 @@ discard block |
||
479 | 479 | */ |
480 | 480 | public function weekly_license_check() { |
481 | 481 | |
482 | - if( ! empty( $_POST['give_settings'] ) ) { |
|
482 | + if ( ! empty($_POST['give_settings'])) { |
|
483 | 483 | // Don't fire when saving settings |
484 | 484 | return false; |
485 | 485 | } |
486 | 486 | |
487 | - if( empty( $this->license ) ) { |
|
487 | + if (empty($this->license)) { |
|
488 | 488 | return false; |
489 | 489 | } |
490 | 490 | |
491 | 491 | // Allow third party add-on developers to handle their license check. |
492 | - if( $this->__is_third_party_addon() ){ |
|
493 | - do_action( 'give_weekly_license_check', $this ); |
|
492 | + if ($this->__is_third_party_addon()) { |
|
493 | + do_action('give_weekly_license_check', $this); |
|
494 | 494 | return false; |
495 | 495 | } |
496 | 496 | |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | $api_params = array( |
499 | 499 | 'edd_action'=> 'check_license', |
500 | 500 | 'license' => $this->license, |
501 | - 'item_name' => urlencode( $this->item_name ), |
|
501 | + 'item_name' => urlencode($this->item_name), |
|
502 | 502 | 'url' => home_url() |
503 | 503 | ); |
504 | 504 | |
@@ -513,12 +513,12 @@ discard block |
||
513 | 513 | ); |
514 | 514 | |
515 | 515 | // Make sure the response came back okay. |
516 | - if ( is_wp_error( $response ) ) { |
|
516 | + if (is_wp_error($response)) { |
|
517 | 517 | return false; |
518 | 518 | } |
519 | 519 | |
520 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
521 | - update_option( $this->item_shortname . '_license_active', $license_data ); |
|
520 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
521 | + update_option($this->item_shortname.'_license_active', $license_data); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | /** |
@@ -531,24 +531,24 @@ discard block |
||
531 | 531 | */ |
532 | 532 | public function weekly_subscription_check() { |
533 | 533 | |
534 | - if( ! empty( $_POST['give_settings'] ) ) { |
|
534 | + if ( ! empty($_POST['give_settings'])) { |
|
535 | 535 | // Don't fire when saving settings |
536 | 536 | return false; |
537 | 537 | } |
538 | 538 | |
539 | 539 | // Remove old subscription data. |
540 | - if( absint( get_option( '_give_subscriptions_edit_last', true ) ) < current_time( 'timestamp' , 1 ) ){ |
|
541 | - delete_option( 'give_subscriptions' ); |
|
542 | - update_option( '_give_subscriptions_edit_last', strtotime( '+ 1 day', current_time( 'timestamp' , 1 ) ) ); |
|
540 | + if (absint(get_option('_give_subscriptions_edit_last', true)) < current_time('timestamp', 1)) { |
|
541 | + delete_option('give_subscriptions'); |
|
542 | + update_option('_give_subscriptions_edit_last', strtotime('+ 1 day', current_time('timestamp', 1))); |
|
543 | 543 | } |
544 | 544 | |
545 | - if( empty( $this->license ) ) { |
|
545 | + if (empty($this->license)) { |
|
546 | 546 | return false; |
547 | 547 | } |
548 | 548 | |
549 | 549 | // Allow third party add-on developers to handle their subscription check. |
550 | - if( $this->__is_third_party_addon() ){ |
|
551 | - do_action( 'give_weekly_subscription_check', $this ); |
|
550 | + if ($this->__is_third_party_addon()) { |
|
551 | + do_action('give_weekly_subscription_check', $this); |
|
552 | 552 | return false; |
553 | 553 | } |
554 | 554 | |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | // This is a custom feature to check subscriptions. |
563 | 563 | 'edd_action'=> 'check_subscription', |
564 | 564 | 'license' => $this->license, |
565 | - 'item_name' => urlencode( $this->item_name ), |
|
565 | + 'item_name' => urlencode($this->item_name), |
|
566 | 566 | 'url' => home_url() |
567 | 567 | ); |
568 | 568 | |
@@ -577,27 +577,27 @@ discard block |
||
577 | 577 | ); |
578 | 578 | |
579 | 579 | // Make sure the response came back okay. |
580 | - if ( is_wp_error( $response ) ) { |
|
580 | + if (is_wp_error($response)) { |
|
581 | 581 | return false; |
582 | 582 | } |
583 | 583 | |
584 | - $subscription_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
584 | + $subscription_data = json_decode(wp_remote_retrieve_body($response), true); |
|
585 | 585 | |
586 | - if( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) { |
|
587 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
586 | + if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) { |
|
587 | + $subscriptions = get_option('give_subscriptions', array()); |
|
588 | 588 | |
589 | 589 | // Update subscription data only if subscription does not exist already. |
590 | - if( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) { |
|
591 | - $subscriptions[ $subscription_data['id'] ] = $subscription_data; |
|
592 | - $subscriptions[ $subscription_data['id'] ]['licenses'] = array(); |
|
590 | + if ( ! array_key_exists($subscription_data['id'], $subscriptions)) { |
|
591 | + $subscriptions[$subscription_data['id']] = $subscription_data; |
|
592 | + $subscriptions[$subscription_data['id']]['licenses'] = array(); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | // Store licenses for subscription. |
596 | - if( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) { |
|
597 | - $subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license; |
|
596 | + if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) { |
|
597 | + $subscriptions[$subscription_data['id']]['licenses'][] = $this->license; |
|
598 | 598 | } |
599 | 599 | |
600 | - update_option( 'give_subscriptions', $subscriptions ); |
|
600 | + update_option('give_subscriptions', $subscriptions); |
|
601 | 601 | } |
602 | 602 | } |
603 | 603 | |
@@ -611,11 +611,11 @@ discard block |
||
611 | 611 | */ |
612 | 612 | private function __single_subscription_check() { |
613 | 613 | // Do not fire if license key is not set. |
614 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
614 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
615 | 615 | return false; |
616 | 616 | } |
617 | 617 | |
618 | - if( empty( $this->license ) ) { |
|
618 | + if (empty($this->license)) { |
|
619 | 619 | return false; |
620 | 620 | } |
621 | 621 | |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | // This is a custom feature to check subscriptions. |
627 | 627 | 'edd_action'=> 'check_subscription', |
628 | 628 | 'license' => $this->license, |
629 | - 'item_name' => urlencode( $this->item_name ), |
|
629 | + 'item_name' => urlencode($this->item_name), |
|
630 | 630 | 'url' => home_url() |
631 | 631 | ); |
632 | 632 | |
@@ -641,27 +641,27 @@ discard block |
||
641 | 641 | ); |
642 | 642 | |
643 | 643 | // Make sure the response came back okay. |
644 | - if ( is_wp_error( $response ) ) { |
|
644 | + if (is_wp_error($response)) { |
|
645 | 645 | return false; |
646 | 646 | } |
647 | 647 | |
648 | - $subscription_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
648 | + $subscription_data = json_decode(wp_remote_retrieve_body($response), true); |
|
649 | 649 | |
650 | - if( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) { |
|
651 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
650 | + if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) { |
|
651 | + $subscriptions = get_option('give_subscriptions', array()); |
|
652 | 652 | |
653 | 653 | // Update subscription data only if subscription does not exist already. |
654 | - if( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) { |
|
655 | - $subscriptions[ $subscription_data['id'] ] = $subscription_data; |
|
656 | - $subscriptions[ $subscription_data['id'] ]['licenses'] = array(); |
|
654 | + if ( ! array_key_exists($subscription_data['id'], $subscriptions)) { |
|
655 | + $subscriptions[$subscription_data['id']] = $subscription_data; |
|
656 | + $subscriptions[$subscription_data['id']]['licenses'] = array(); |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | // Store licenses for subscription. |
660 | - if( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) { |
|
661 | - $subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license; |
|
660 | + if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) { |
|
661 | + $subscriptions[$subscription_data['id']]['licenses'][] = $this->license; |
|
662 | 662 | } |
663 | 663 | |
664 | - update_option( 'give_subscriptions', $subscriptions ); |
|
664 | + update_option('give_subscriptions', $subscriptions); |
|
665 | 665 | } |
666 | 666 | } |
667 | 667 | |
@@ -674,12 +674,12 @@ discard block |
||
674 | 674 | * @return void |
675 | 675 | */ |
676 | 676 | public function notices() { |
677 | - if( ! current_user_can( 'manage_give_settings' ) ) { |
|
677 | + if ( ! current_user_can('manage_give_settings')) { |
|
678 | 678 | return; |
679 | 679 | } |
680 | 680 | |
681 | 681 | // Do not show licenses notices on license tab. |
682 | - if( 'licenses' === give_get_current_setting_tab() ) { |
|
682 | + if ('licenses' === give_get_current_setting_tab()) { |
|
683 | 683 | return; |
684 | 684 | } |
685 | 685 | |
@@ -688,93 +688,93 @@ discard block |
||
688 | 688 | static $addon_license_key_in_subscriptions; |
689 | 689 | |
690 | 690 | // Set default value. |
691 | - $addon_license_key_in_subscriptions = ! empty( $addon_license_key_in_subscriptions ) ? $addon_license_key_in_subscriptions : array(); |
|
691 | + $addon_license_key_in_subscriptions = ! empty($addon_license_key_in_subscriptions) ? $addon_license_key_in_subscriptions : array(); |
|
692 | 692 | $messages = array(); |
693 | 693 | |
694 | - if( |
|
695 | - empty( $this->license ) |
|
696 | - && ! $this->__is_notice_dismissed( 'general' ) |
|
697 | - && empty( $showed_invalid_message ) |
|
694 | + if ( |
|
695 | + empty($this->license) |
|
696 | + && ! $this->__is_notice_dismissed('general') |
|
697 | + && empty($showed_invalid_message) |
|
698 | 698 | ) { |
699 | 699 | $messages['general'] = sprintf( |
700 | - __( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ), |
|
701 | - admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) |
|
700 | + __('You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'), |
|
701 | + admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses') |
|
702 | 702 | ); |
703 | 703 | $showed_invalid_message = true; |
704 | 704 | |
705 | 705 | } |
706 | 706 | |
707 | 707 | // Get subscriptions. |
708 | - $subscriptions = get_option( 'give_subscriptions' ); |
|
708 | + $subscriptions = get_option('give_subscriptions'); |
|
709 | 709 | |
710 | 710 | // Show subscription messages. |
711 | - if( ! empty( $subscriptions ) && ! $showed_subscriptions_message ) { |
|
711 | + if ( ! empty($subscriptions) && ! $showed_subscriptions_message) { |
|
712 | 712 | |
713 | - foreach ( $subscriptions as $subscription ) { |
|
713 | + foreach ($subscriptions as $subscription) { |
|
714 | 714 | // Subscription expires timestamp. |
715 | - $subscription_expires = strtotime( $subscription['expires'] ); |
|
715 | + $subscription_expires = strtotime($subscription['expires']); |
|
716 | 716 | |
717 | 717 | // Start showing subscriptions message before one week of renewal date. |
718 | - if( strtotime( '- 7 days', $subscription_expires ) > current_time( 'timestamp', 1 ) ) { |
|
718 | + if (strtotime('- 7 days', $subscription_expires) > current_time('timestamp', 1)) { |
|
719 | 719 | continue; |
720 | 720 | } |
721 | 721 | |
722 | 722 | // Check if subscription message already exist in messages. |
723 | - if( array_key_exists( $subscription['id'], $messages ) ) { |
|
723 | + if (array_key_exists($subscription['id'], $messages)) { |
|
724 | 724 | continue; |
725 | 725 | } |
726 | 726 | |
727 | - if( ( ! $this->__is_notice_dismissed( $subscription['id'] ) && 'active' !== $subscription['status'] ) ) { |
|
727 | + if (( ! $this->__is_notice_dismissed($subscription['id']) && 'active' !== $subscription['status'])) { |
|
728 | 728 | |
729 | - if( strtotime( $subscription['expires'] ) < current_time( 'timestamp', 1 ) ) {// Check if license already expired. |
|
729 | + if (strtotime($subscription['expires']) < current_time('timestamp', 1)) {// Check if license already expired. |
|
730 | 730 | $messages[$subscription['id']] = sprintf( |
731 | - __( 'Your Give add-on license expired for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ), |
|
732 | - urldecode( $subscription['invoice_url'] ), |
|
731 | + __('Your Give add-on license expired for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give'), |
|
732 | + urldecode($subscription['invoice_url']), |
|
733 | 733 | $subscription['payment_id'], |
734 | 734 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
735 | - esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
|
735 | + esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'])) |
|
736 | 736 | ); |
737 | - }else{ |
|
737 | + } else { |
|
738 | 738 | $messages[$subscription['id']] = sprintf( |
739 | - __( 'Your Give add-on license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ), |
|
740 | - human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ), |
|
741 | - urldecode( $subscription['invoice_url'] ), |
|
739 | + __('Your Give add-on license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give'), |
|
740 | + human_time_diff(current_time('timestamp', 1), strtotime($subscription['expires'])), |
|
741 | + urldecode($subscription['invoice_url']), |
|
742 | 742 | $subscription['payment_id'], |
743 | 743 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
744 | - esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
|
744 | + esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'])) |
|
745 | 745 | ); |
746 | 746 | } |
747 | 747 | } |
748 | 748 | |
749 | 749 | // Stop validation for these license keys. |
750 | - $addon_license_key_in_subscriptions = array_merge( $addon_license_key_in_subscriptions, $subscription['licenses'] ); |
|
750 | + $addon_license_key_in_subscriptions = array_merge($addon_license_key_in_subscriptions, $subscription['licenses']); |
|
751 | 751 | } |
752 | 752 | $showed_subscriptions_message = true; |
753 | 753 | } |
754 | 754 | |
755 | 755 | // Show non subscription addon messages. |
756 | - if( |
|
757 | - ! in_array( $this->license, $addon_license_key_in_subscriptions ) |
|
758 | - && ! $this->__is_notice_dismissed( 'general' ) |
|
756 | + if ( |
|
757 | + ! in_array($this->license, $addon_license_key_in_subscriptions) |
|
758 | + && ! $this->__is_notice_dismissed('general') |
|
759 | 759 | && ! $this->is_valid_license() |
760 | - && empty( $showed_invalid_message ) |
|
760 | + && empty($showed_invalid_message) |
|
761 | 761 | ) { |
762 | 762 | |
763 | 763 | $messages['general'] = sprintf( |
764 | - __( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ), |
|
765 | - admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) |
|
764 | + __('You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'), |
|
765 | + admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses') |
|
766 | 766 | ); |
767 | 767 | $showed_invalid_message = true; |
768 | 768 | |
769 | 769 | } |
770 | 770 | |
771 | 771 | // Print messages. |
772 | - if( ! empty( $messages ) ) { |
|
773 | - foreach( $messages as $notice_id => $message ) { |
|
772 | + if ( ! empty($messages)) { |
|
773 | + foreach ($messages as $notice_id => $message) { |
|
774 | 774 | |
775 | 775 | echo sprintf( |
776 | 776 | '<div class="notice notice-error is-dismissible give-license-notice" data-dismiss-notice-shortly="%1$s"><p>%2$s</p></div>', |
777 | - esc_url( add_query_arg( '_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'] ) ), |
|
777 | + esc_url(add_query_arg('_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'])), |
|
778 | 778 | $message |
779 | 779 | ); |
780 | 780 | } |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | * @return bool |
791 | 791 | */ |
792 | 792 | public function is_valid_license() { |
793 | - if( apply_filters( 'give_is_valid_license' , ( is_object( $this->license_data ) && ! empty( $this->license_data ) && property_exists( $this->license_data, 'license' )&& 'valid' === $this->license_data->license ) ) ) { |
|
793 | + if (apply_filters('give_is_valid_license', (is_object($this->license_data) && ! empty($this->license_data) && property_exists($this->license_data, 'license') && 'valid' === $this->license_data->license))) { |
|
794 | 794 | return true; |
795 | 795 | } |
796 | 796 | |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | * @return bool |
807 | 807 | */ |
808 | 808 | private function __is_third_party_addon() { |
809 | - return ( false === strpos( $this->api_url, 'givewp.com/' ) ); |
|
809 | + return (false === strpos($this->api_url, 'givewp.com/')); |
|
810 | 810 | } |
811 | 811 | |
812 | 812 | /** |
@@ -820,26 +820,26 @@ discard block |
||
820 | 820 | * |
821 | 821 | * @return void|bool |
822 | 822 | */ |
823 | - private function __remove_license_key_from_subscriptions(){ |
|
824 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
823 | + private function __remove_license_key_from_subscriptions() { |
|
824 | + $subscriptions = get_option('give_subscriptions', array()); |
|
825 | 825 | |
826 | 826 | // Bailout. |
827 | - if( empty( $this->license ) ) { |
|
827 | + if (empty($this->license)) { |
|
828 | 828 | return false; |
829 | 829 | } |
830 | 830 | |
831 | - if( ! empty( $subscriptions ) ) { |
|
832 | - foreach ( $subscriptions as $subscription_id => $subscription ) { |
|
833 | - $license_index = array_search( $this->license, $subscription['licenses'] ); |
|
834 | - if( false !== $license_index ) { |
|
831 | + if ( ! empty($subscriptions)) { |
|
832 | + foreach ($subscriptions as $subscription_id => $subscription) { |
|
833 | + $license_index = array_search($this->license, $subscription['licenses']); |
|
834 | + if (false !== $license_index) { |
|
835 | 835 | // Remove license key. |
836 | - unset( $subscriptions[ $subscription_id ]['licenses'][$license_index] ); |
|
836 | + unset($subscriptions[$subscription_id]['licenses'][$license_index]); |
|
837 | 837 | |
838 | 838 | // Rearrange license keys. |
839 | - $subscriptions[ $subscription_id ]['licenses'] = array_values( $subscriptions[ $subscription_id ]['licenses'] ); |
|
839 | + $subscriptions[$subscription_id]['licenses'] = array_values($subscriptions[$subscription_id]['licenses']); |
|
840 | 840 | |
841 | 841 | // Update subscription information. |
842 | - update_option( 'give_subscriptions', $subscriptions ); |
|
842 | + update_option('give_subscriptions', $subscriptions); |
|
843 | 843 | break; |
844 | 844 | } |
845 | 845 | } |
@@ -854,7 +854,7 @@ discard block |
||
854 | 854 | * |
855 | 855 | * @return void |
856 | 856 | */ |
857 | - private function __remove_license_notices_show_blocker(){ |
|
857 | + private function __remove_license_notices_show_blocker() { |
|
858 | 858 | global $wpdb; |
859 | 859 | |
860 | 860 | // Delete permanent notice blocker. |
@@ -892,21 +892,21 @@ discard block |
||
892 | 892 | * |
893 | 893 | * @return bool |
894 | 894 | */ |
895 | - private function __is_notice_dismissed( $notice_id ){ |
|
895 | + private function __is_notice_dismissed($notice_id) { |
|
896 | 896 | $current_user = wp_get_current_user(); |
897 | 897 | $is_notice_dismissed = false; |
898 | 898 | |
899 | 899 | // Ge is notice dismissed permanently. |
900 | - $already_dismiss_notices = ( $already_dismiss_notices = get_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', true ) ) |
|
900 | + $already_dismiss_notices = ($already_dismiss_notices = get_user_meta($current_user->ID, '_give_hide_license_notices_permanently', true)) |
|
901 | 901 | ? $already_dismiss_notices |
902 | 902 | : array(); |
903 | 903 | |
904 | 904 | |
905 | - if( |
|
906 | - in_array( $notice_id, $already_dismiss_notices ) |
|
907 | - || Give_Cache::get( "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}", true ) |
|
905 | + if ( |
|
906 | + in_array($notice_id, $already_dismiss_notices) |
|
907 | + || Give_Cache::get("_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}", true) |
|
908 | 908 | ) { |
909 | - $is_notice_dismissed = true; |
|
909 | + $is_notice_dismissed = true; |
|
910 | 910 | } |
911 | 911 | |
912 | 912 | return $is_notice_dismissed; |
@@ -734,7 +734,7 @@ |
||
734 | 734 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
735 | 735 | esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
736 | 736 | ); |
737 | - }else{ |
|
737 | + } else{ |
|
738 | 738 | $messages[$subscription['id']] = sprintf( |
739 | 739 | __( 'Your Give add-on license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ), |
740 | 740 | human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ), |
@@ -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 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @return string |
22 | 22 | */ |
23 | 23 | function give_get_templates_dir() { |
24 | - return GIVE_PLUGIN_DIR . 'templates'; |
|
24 | + return GIVE_PLUGIN_DIR.'templates'; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @return string |
32 | 32 | */ |
33 | 33 | function give_get_templates_url() { |
34 | - return GIVE_PLUGIN_URL . 'templates'; |
|
34 | + return GIVE_PLUGIN_URL.'templates'; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -44,23 +44,23 @@ discard block |
||
44 | 44 | * @param string $template_path Template file path. Default is empty. |
45 | 45 | * @param string $default_path Default path. Default is empty. |
46 | 46 | */ |
47 | -function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
48 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
49 | - extract( $args ); |
|
47 | +function give_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
48 | + if ( ! empty($args) && is_array($args)) { |
|
49 | + extract($args); |
|
50 | 50 | } |
51 | 51 | |
52 | - $template_names = array( $template_name . '.php' ); |
|
52 | + $template_names = array($template_name.'.php'); |
|
53 | 53 | |
54 | - $located = give_locate_template( $template_names, $template_path, $default_path ); |
|
54 | + $located = give_locate_template($template_names, $template_path, $default_path); |
|
55 | 55 | |
56 | - if ( ! file_exists( $located ) ) { |
|
56 | + if ( ! file_exists($located)) { |
|
57 | 57 | /* translators: %s: the template */ |
58 | - give_output_error( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true ); |
|
58 | + give_output_error(sprintf(__('The %s template was not found.', 'give'), $located), true); |
|
59 | 59 | return; |
60 | 60 | } |
61 | 61 | |
62 | 62 | // Allow 3rd party plugin filter template file from their plugin. |
63 | - $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
63 | + $located = apply_filters('give_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Fires in give template, before the file is included. |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * @param string $located Template file filter by 3rd party plugin. |
75 | 75 | * @param array $args Passed arguments. |
76 | 76 | */ |
77 | - do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
77 | + do_action('give_before_template_part', $template_name, $template_path, $located, $args); |
|
78 | 78 | |
79 | - include( $located ); |
|
79 | + include($located); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Fires in give template, after the file is included. |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param string $located Template file filter by 3rd party plugin. |
91 | 91 | * @param array $args Passed arguments. |
92 | 92 | */ |
93 | - do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
93 | + do_action('give_after_template_part', $template_name, $template_path, $located, $args); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @return string |
108 | 108 | */ |
109 | -function give_get_template_part( $slug, $name = null, $load = true ) { |
|
109 | +function give_get_template_part($slug, $name = null, $load = true) { |
|
110 | 110 | |
111 | 111 | /** |
112 | 112 | * Fires in give template part, before the template part is retrieved. |
@@ -118,20 +118,20 @@ discard block |
||
118 | 118 | * @param string $slug Template part file slug {slug}.php. |
119 | 119 | * @param string $name Template part file name {slug}-{name}.php. |
120 | 120 | */ |
121 | - do_action( "get_template_part_{$slug}", $slug, $name ); |
|
121 | + do_action("get_template_part_{$slug}", $slug, $name); |
|
122 | 122 | |
123 | 123 | // Setup possible parts |
124 | 124 | $templates = array(); |
125 | - if ( isset( $name ) ) { |
|
126 | - $templates[] = $slug . '-' . $name . '.php'; |
|
125 | + if (isset($name)) { |
|
126 | + $templates[] = $slug.'-'.$name.'.php'; |
|
127 | 127 | } |
128 | - $templates[] = $slug . '.php'; |
|
128 | + $templates[] = $slug.'.php'; |
|
129 | 129 | |
130 | 130 | // Allow template parts to be filtered |
131 | - $templates = apply_filters( 'give_get_template_part', $templates, $slug, $name ); |
|
131 | + $templates = apply_filters('give_get_template_part', $templates, $slug, $name); |
|
132 | 132 | |
133 | 133 | // Return the part that is found |
134 | - return give_locate_template( $templates, $load, false ); |
|
134 | + return give_locate_template($templates, $load, false); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -152,37 +152,37 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return string The template filename if one is located. |
154 | 154 | */ |
155 | -function give_locate_template( $template_names, $load = false, $require_once = true ) { |
|
155 | +function give_locate_template($template_names, $load = false, $require_once = true) { |
|
156 | 156 | // No file found yet |
157 | 157 | $located = false; |
158 | 158 | |
159 | 159 | // Try to find a template file |
160 | - foreach ( (array) $template_names as $template_name ) { |
|
160 | + foreach ((array) $template_names as $template_name) { |
|
161 | 161 | |
162 | 162 | // Continue if template is empty |
163 | - if ( empty( $template_name ) ) { |
|
163 | + if (empty($template_name)) { |
|
164 | 164 | continue; |
165 | 165 | } |
166 | 166 | |
167 | 167 | // Trim off any slashes from the template name |
168 | - $template_name = ltrim( $template_name, '/' ); |
|
168 | + $template_name = ltrim($template_name, '/'); |
|
169 | 169 | |
170 | 170 | // try locating this template file by looping through the template paths |
171 | - foreach ( give_get_theme_template_paths() as $template_path ) { |
|
171 | + foreach (give_get_theme_template_paths() as $template_path) { |
|
172 | 172 | |
173 | - if ( file_exists( $template_path . $template_name ) ) { |
|
174 | - $located = $template_path . $template_name; |
|
173 | + if (file_exists($template_path.$template_name)) { |
|
174 | + $located = $template_path.$template_name; |
|
175 | 175 | break; |
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
179 | - if ( $located ) { |
|
179 | + if ($located) { |
|
180 | 180 | break; |
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | - if ( ( true == $load ) && ! empty( $located ) ) { |
|
185 | - load_template( $located, $require_once ); |
|
184 | + if ((true == $load) && ! empty($located)) { |
|
185 | + load_template($located, $require_once); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | return $located; |
@@ -199,17 +199,17 @@ discard block |
||
199 | 199 | $template_dir = give_get_theme_template_dir_name(); |
200 | 200 | |
201 | 201 | $file_paths = array( |
202 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
203 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
202 | + 1 => trailingslashit(get_stylesheet_directory()).$template_dir, |
|
203 | + 10 => trailingslashit(get_template_directory()).$template_dir, |
|
204 | 204 | 100 => give_get_templates_dir() |
205 | 205 | ); |
206 | 206 | |
207 | - $file_paths = apply_filters( 'give_template_paths', $file_paths ); |
|
207 | + $file_paths = apply_filters('give_template_paths', $file_paths); |
|
208 | 208 | |
209 | 209 | // sort the file paths based on priority |
210 | - ksort( $file_paths, SORT_NUMERIC ); |
|
210 | + ksort($file_paths, SORT_NUMERIC); |
|
211 | 211 | |
212 | - return array_map( 'trailingslashit', $file_paths ); |
|
212 | + return array_map('trailingslashit', $file_paths); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @return string |
222 | 222 | */ |
223 | 223 | function give_get_theme_template_dir_name() { |
224 | - return trailingslashit( apply_filters( 'give_templates_dir', 'give' ) ); |
|
224 | + return trailingslashit(apply_filters('give_templates_dir', 'give')); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -231,10 +231,10 @@ discard block |
||
231 | 231 | * @return void |
232 | 232 | */ |
233 | 233 | function give_version_in_header() { |
234 | - echo '<meta name="generator" content="Give v' . GIVE_VERSION . '" />' . "\n"; |
|
234 | + echo '<meta name="generator" content="Give v'.GIVE_VERSION.'" />'."\n"; |
|
235 | 235 | } |
236 | 236 | |
237 | -add_action( 'wp_head', 'give_version_in_header' ); |
|
237 | +add_action('wp_head', 'give_version_in_header'); |
|
238 | 238 | |
239 | 239 | /** |
240 | 240 | * Determines if we're currently on the Donations History page. |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | */ |
245 | 245 | function give_is_donation_history_page() { |
246 | 246 | |
247 | - $ret = is_page( give_get_option( 'history_page' ) ); |
|
247 | + $ret = is_page(give_get_option('history_page')); |
|
248 | 248 | |
249 | - return apply_filters( 'give_is_donation_history_page', $ret ); |
|
249 | + return apply_filters('give_is_donation_history_page', $ret); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -258,25 +258,25 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @return array Modified array of classes |
260 | 260 | */ |
261 | -function give_add_body_classes( $class ) { |
|
261 | +function give_add_body_classes($class) { |
|
262 | 262 | $classes = (array) $class; |
263 | 263 | |
264 | - if ( give_is_success_page() ) { |
|
264 | + if (give_is_success_page()) { |
|
265 | 265 | $classes[] = 'give-success'; |
266 | 266 | $classes[] = 'give-page'; |
267 | 267 | } |
268 | 268 | |
269 | - if ( give_is_failed_transaction_page() ) { |
|
269 | + if (give_is_failed_transaction_page()) { |
|
270 | 270 | $classes[] = 'give-failed-transaction'; |
271 | 271 | $classes[] = 'give-page'; |
272 | 272 | } |
273 | 273 | |
274 | - if ( give_is_donation_history_page() ) { |
|
274 | + if (give_is_donation_history_page()) { |
|
275 | 275 | $classes[] = 'give-donation-history'; |
276 | 276 | $classes[] = 'give-page'; |
277 | 277 | } |
278 | 278 | |
279 | - if ( give_is_test_mode() ) { |
|
279 | + if (give_is_test_mode()) { |
|
280 | 280 | $classes[] = 'give-test-mode'; |
281 | 281 | $classes[] = 'give-page'; |
282 | 282 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | //Theme-specific Classes used to prevent conflicts via CSS |
285 | 285 | $current_theme = wp_get_theme(); |
286 | 286 | |
287 | - switch ( $current_theme->template ) { |
|
287 | + switch ($current_theme->template) { |
|
288 | 288 | |
289 | 289 | case 'Divi': |
290 | 290 | $classes[] = 'give-divi'; |
@@ -298,10 +298,10 @@ discard block |
||
298 | 298 | |
299 | 299 | } |
300 | 300 | |
301 | - return array_unique( $classes ); |
|
301 | + return array_unique($classes); |
|
302 | 302 | } |
303 | 303 | |
304 | -add_filter( 'body_class', 'give_add_body_classes' ); |
|
304 | +add_filter('body_class', 'give_add_body_classes'); |
|
305 | 305 | |
306 | 306 | |
307 | 307 | /** |
@@ -317,22 +317,22 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @return array |
319 | 319 | */ |
320 | -function give_add_post_class( $classes, $class = '', $post_id = '' ) { |
|
321 | - if ( ! $post_id || 'give_forms' !== get_post_type( $post_id ) ) { |
|
320 | +function give_add_post_class($classes, $class = '', $post_id = '') { |
|
321 | + if ( ! $post_id || 'give_forms' !== get_post_type($post_id)) { |
|
322 | 322 | return $classes; |
323 | 323 | } |
324 | 324 | |
325 | 325 | //@TODO: Add classes for custom taxonomy and form configurations (multi vs single donations, etc). |
326 | 326 | |
327 | - if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) { |
|
328 | - unset( $classes[ $key ] ); |
|
327 | + if (false !== ($key = array_search('hentry', $classes))) { |
|
328 | + unset($classes[$key]); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | return $classes; |
332 | 332 | } |
333 | 333 | |
334 | 334 | |
335 | -add_filter( 'post_class', 'give_add_post_class', 20, 3 ); |
|
335 | +add_filter('post_class', 'give_add_post_class', 20, 3); |
|
336 | 336 | |
337 | 337 | /** |
338 | 338 | * Get the placeholder image URL for forms etc |
@@ -342,74 +342,74 @@ discard block |
||
342 | 342 | */ |
343 | 343 | function give_get_placeholder_img_src() { |
344 | 344 | |
345 | - $placeholder_url = '//placehold.it/600x600&text=' . urlencode( esc_attr__( 'Give Placeholder Image', 'give' ) ); |
|
345 | + $placeholder_url = '//placehold.it/600x600&text='.urlencode(esc_attr__('Give Placeholder Image', 'give')); |
|
346 | 346 | |
347 | - return apply_filters( 'give_placeholder_img_src', $placeholder_url ); |
|
347 | + return apply_filters('give_placeholder_img_src', $placeholder_url); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | |
351 | 351 | /** |
352 | 352 | * Global |
353 | 353 | */ |
354 | -if ( ! function_exists( 'give_output_content_wrapper' ) ) { |
|
354 | +if ( ! function_exists('give_output_content_wrapper')) { |
|
355 | 355 | |
356 | 356 | /** |
357 | 357 | * Output the start of the page wrapper. |
358 | 358 | */ |
359 | 359 | function give_output_content_wrapper() { |
360 | - give_get_template_part( 'global/wrapper-start' ); |
|
360 | + give_get_template_part('global/wrapper-start'); |
|
361 | 361 | } |
362 | 362 | } |
363 | -if ( ! function_exists( 'give_output_content_wrapper_end' ) ) { |
|
363 | +if ( ! function_exists('give_output_content_wrapper_end')) { |
|
364 | 364 | |
365 | 365 | /** |
366 | 366 | * Output the end of the page wrapper. |
367 | 367 | */ |
368 | 368 | function give_output_content_wrapper_end() { |
369 | - give_get_template_part( 'global/wrapper-end' ); |
|
369 | + give_get_template_part('global/wrapper-end'); |
|
370 | 370 | } |
371 | 371 | } |
372 | 372 | |
373 | 373 | /** |
374 | 374 | * Single Give Form |
375 | 375 | */ |
376 | -if ( ! function_exists( 'give_left_sidebar_pre_wrap' ) ) { |
|
376 | +if ( ! function_exists('give_left_sidebar_pre_wrap')) { |
|
377 | 377 | function give_left_sidebar_pre_wrap() { |
378 | - echo apply_filters( 'give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">' ); |
|
378 | + echo apply_filters('give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">'); |
|
379 | 379 | } |
380 | 380 | } |
381 | 381 | |
382 | -if ( ! function_exists( 'give_left_sidebar_post_wrap' ) ) { |
|
382 | +if ( ! function_exists('give_left_sidebar_post_wrap')) { |
|
383 | 383 | function give_left_sidebar_post_wrap() { |
384 | - echo apply_filters( 'give_left_sidebar_post_wrap', '</div>' ); |
|
384 | + echo apply_filters('give_left_sidebar_post_wrap', '</div>'); |
|
385 | 385 | } |
386 | 386 | } |
387 | 387 | |
388 | -if ( ! function_exists( 'give_get_forms_sidebar' ) ) { |
|
388 | +if ( ! function_exists('give_get_forms_sidebar')) { |
|
389 | 389 | function give_get_forms_sidebar() { |
390 | - give_get_template_part( 'single-give-form/sidebar' ); |
|
390 | + give_get_template_part('single-give-form/sidebar'); |
|
391 | 391 | } |
392 | 392 | } |
393 | 393 | |
394 | -if ( ! function_exists( 'give_show_form_images' ) ) { |
|
394 | +if ( ! function_exists('give_show_form_images')) { |
|
395 | 395 | |
396 | 396 | /** |
397 | 397 | * Output the donation form featured image. |
398 | 398 | */ |
399 | 399 | function give_show_form_images() { |
400 | - if ( give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) { |
|
401 | - give_get_template_part( 'single-give-form/featured-image' ); |
|
400 | + if (give_is_setting_enabled(give_get_option('form_featured_img'))) { |
|
401 | + give_get_template_part('single-give-form/featured-image'); |
|
402 | 402 | } |
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
406 | -if ( ! function_exists( 'give_template_single_title' ) ) { |
|
406 | +if ( ! function_exists('give_template_single_title')) { |
|
407 | 407 | |
408 | 408 | /** |
409 | 409 | * Output the form title. |
410 | 410 | */ |
411 | 411 | function give_template_single_title() { |
412 | - give_get_template_part( 'single-give-form/title' ); |
|
412 | + give_get_template_part('single-give-form/title'); |
|
413 | 413 | } |
414 | 414 | } |
415 | 415 | |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | * Conditional Functions |
418 | 418 | */ |
419 | 419 | |
420 | -if ( ! function_exists( 'is_give_form' ) ) { |
|
420 | +if ( ! function_exists('is_give_form')) { |
|
421 | 421 | |
422 | 422 | /** |
423 | 423 | * is_give_form |
@@ -429,11 +429,11 @@ discard block |
||
429 | 429 | * @return bool |
430 | 430 | */ |
431 | 431 | function is_give_form() { |
432 | - return is_singular( array( 'give_form' ) ); |
|
432 | + return is_singular(array('give_form')); |
|
433 | 433 | } |
434 | 434 | } |
435 | 435 | |
436 | -if ( ! function_exists( 'is_give_category' ) ) { |
|
436 | +if ( ! function_exists('is_give_category')) { |
|
437 | 437 | |
438 | 438 | /** |
439 | 439 | * is_give_category |
@@ -448,12 +448,12 @@ discard block |
||
448 | 448 | * |
449 | 449 | * @return bool |
450 | 450 | */ |
451 | - function is_give_category( $term = '' ) { |
|
452 | - return is_tax( 'give_forms_category', $term ); |
|
451 | + function is_give_category($term = '') { |
|
452 | + return is_tax('give_forms_category', $term); |
|
453 | 453 | } |
454 | 454 | } |
455 | 455 | |
456 | -if ( ! function_exists( 'is_give_tag' ) ) { |
|
456 | +if ( ! function_exists('is_give_tag')) { |
|
457 | 457 | |
458 | 458 | /** |
459 | 459 | * is_give_tag |
@@ -468,12 +468,12 @@ discard block |
||
468 | 468 | * |
469 | 469 | * @return bool |
470 | 470 | */ |
471 | - function is_give_tag( $term = '' ) { |
|
472 | - return is_tax( 'give_forms_tag', $term ); |
|
471 | + function is_give_tag($term = '') { |
|
472 | + return is_tax('give_forms_tag', $term); |
|
473 | 473 | } |
474 | 474 | } |
475 | 475 | |
476 | -if ( ! function_exists( 'is_give_taxonomy' ) ) { |
|
476 | +if ( ! function_exists('is_give_taxonomy')) { |
|
477 | 477 | |
478 | 478 | /** |
479 | 479 | * is_give_taxonomy |
@@ -485,6 +485,6 @@ discard block |
||
485 | 485 | * @return bool |
486 | 486 | */ |
487 | 487 | function is_give_taxonomy() { |
488 | - return is_tax( get_object_taxonomies( 'give_form' ) ); |
|
488 | + return is_tax(get_object_taxonomies('give_form')); |
|
489 | 489 | } |
490 | 490 | } |
@@ -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,30 +44,30 @@ 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 | |
61 | 61 | } else { |
62 | 62 | |
63 | - $output = 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 ) ); |
|
64 | - $output .= do_shortcode( '[give_login]' ); |
|
63 | + $output = 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)); |
|
64 | + $output .= do_shortcode('[give_login]'); |
|
65 | 65 | |
66 | 66 | return $output; |
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | -add_shortcode( 'donation_history', 'give_donation_history' ); |
|
70 | +add_shortcode('donation_history', 'give_donation_history'); |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Donation Form Shortcode |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return string |
82 | 82 | */ |
83 | -function give_form_shortcode( $atts ) { |
|
84 | - $atts = shortcode_atts( array( |
|
83 | +function give_form_shortcode($atts) { |
|
84 | + $atts = shortcode_atts(array( |
|
85 | 85 | 'id' => '', |
86 | 86 | 'show_title' => true, |
87 | 87 | 'show_goal' => true, |
@@ -89,21 +89,21 @@ discard block |
||
89 | 89 | 'float_labels' => '', |
90 | 90 | 'display_style' => '', |
91 | 91 | 'continue_button_title' => '', |
92 | - ), $atts, 'give_form' ); |
|
92 | + ), $atts, 'give_form'); |
|
93 | 93 | |
94 | 94 | // Convert string to bool. |
95 | - $atts['show_title'] = filter_var( $atts['show_title'], FILTER_VALIDATE_BOOLEAN ); |
|
96 | - $atts['show_goal'] = filter_var( $atts['show_goal'], FILTER_VALIDATE_BOOLEAN ); |
|
95 | + $atts['show_title'] = filter_var($atts['show_title'], FILTER_VALIDATE_BOOLEAN); |
|
96 | + $atts['show_goal'] = filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN); |
|
97 | 97 | |
98 | 98 | //get the Give Form |
99 | 99 | ob_start(); |
100 | - give_get_donation_form( $atts ); |
|
100 | + give_get_donation_form($atts); |
|
101 | 101 | $final_output = ob_get_clean(); |
102 | 102 | |
103 | - return apply_filters( 'give_donate_form', $final_output, $atts ); |
|
103 | + return apply_filters('give_donate_form', $final_output, $atts); |
|
104 | 104 | } |
105 | 105 | |
106 | -add_shortcode( 'give_form', 'give_form_shortcode' ); |
|
106 | +add_shortcode('give_form', 'give_form_shortcode'); |
|
107 | 107 | |
108 | 108 | /** |
109 | 109 | * Donation Form Goal Shortcode. |
@@ -116,37 +116,37 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @return string |
118 | 118 | */ |
119 | -function give_goal_shortcode( $atts ) { |
|
120 | - $atts = shortcode_atts( array( |
|
119 | +function give_goal_shortcode($atts) { |
|
120 | + $atts = shortcode_atts(array( |
|
121 | 121 | 'id' => '', |
122 | 122 | 'show_text' => true, |
123 | 123 | 'show_bar' => true, |
124 | - ), $atts, 'give_goal' ); |
|
124 | + ), $atts, 'give_goal'); |
|
125 | 125 | |
126 | 126 | |
127 | 127 | //get the Give Form. |
128 | 128 | ob_start(); |
129 | 129 | |
130 | 130 | //Sanity check 1: ensure there is an ID Provided. |
131 | - if ( empty( $atts['id'] ) ) { |
|
132 | - give_output_error( esc_html__( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true ); |
|
131 | + if (empty($atts['id'])) { |
|
132 | + give_output_error(esc_html__('The shortcode is missing Donation Form ID attribute.', 'give'), true); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | //Sanity check 2: Check the form even has Goals enabled. |
136 | - if ( ! give_is_setting_enabled( get_post_meta( $atts['id'], '_give_goal_option', true ) ) ) { |
|
136 | + if ( ! give_is_setting_enabled(get_post_meta($atts['id'], '_give_goal_option', true))) { |
|
137 | 137 | |
138 | - give_output_error( esc_html__( 'The form does not have Goals enabled.', 'give' ), true ); |
|
138 | + give_output_error(esc_html__('The form does not have Goals enabled.', 'give'), true); |
|
139 | 139 | } else { |
140 | 140 | //Passed all sanity checks: output Goal. |
141 | - give_show_goal_progress( $atts['id'], $atts ); |
|
141 | + give_show_goal_progress($atts['id'], $atts); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | $final_output = ob_get_clean(); |
145 | 145 | |
146 | - return apply_filters( 'give_goal_shortcode_output', $final_output, $atts ); |
|
146 | + return apply_filters('give_goal_shortcode_output', $final_output, $atts); |
|
147 | 147 | } |
148 | 148 | |
149 | -add_shortcode( 'give_goal', 'give_goal_shortcode' ); |
|
149 | +add_shortcode('give_goal', 'give_goal_shortcode'); |
|
150 | 150 | |
151 | 151 | |
152 | 152 | /** |
@@ -163,22 +163,22 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return string |
165 | 165 | */ |
166 | -function give_login_form_shortcode( $atts ) { |
|
167 | - $atts = shortcode_atts( array( |
|
166 | +function give_login_form_shortcode($atts) { |
|
167 | + $atts = shortcode_atts(array( |
|
168 | 168 | // Add backward compatibility for redirect attribute. |
169 | 169 | 'redirect' => '', |
170 | 170 | |
171 | 171 | 'login-redirect' => '', |
172 | 172 | 'logout-redirect' => '', |
173 | - ), $atts, 'give_login' ); |
|
173 | + ), $atts, 'give_login'); |
|
174 | 174 | |
175 | 175 | // 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. |
176 | - $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect'] ) ? $atts['redirect'] : '' ); |
|
176 | + $atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : ''); |
|
177 | 177 | |
178 | - return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] ); |
|
178 | + return give_login_form($atts['login-redirect'], $atts['logout-redirect']); |
|
179 | 179 | } |
180 | 180 | |
181 | -add_shortcode( 'give_login', 'give_login_form_shortcode' ); |
|
181 | +add_shortcode('give_login', 'give_login_form_shortcode'); |
|
182 | 182 | |
183 | 183 | /** |
184 | 184 | * Register Shortcode. |
@@ -193,15 +193,15 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @return string |
195 | 195 | */ |
196 | -function give_register_form_shortcode( $atts ) { |
|
197 | - $atts = shortcode_atts( array( |
|
196 | +function give_register_form_shortcode($atts) { |
|
197 | + $atts = shortcode_atts(array( |
|
198 | 198 | 'redirect' => '', |
199 | - ), $atts, 'give_register' ); |
|
199 | + ), $atts, 'give_register'); |
|
200 | 200 | |
201 | - return give_register_form( $atts['redirect'] ); |
|
201 | + return give_register_form($atts['redirect']); |
|
202 | 202 | } |
203 | 203 | |
204 | -add_shortcode( 'give_register', 'give_register_form_shortcode' ); |
|
204 | +add_shortcode('give_register', 'give_register_form_shortcode'); |
|
205 | 205 | |
206 | 206 | /** |
207 | 207 | * Receipt Shortcode. |
@@ -214,12 +214,12 @@ discard block |
||
214 | 214 | * |
215 | 215 | * @return string |
216 | 216 | */ |
217 | -function give_receipt_shortcode( $atts ) { |
|
217 | +function give_receipt_shortcode($atts) { |
|
218 | 218 | |
219 | 219 | global $give_receipt_args, $payment; |
220 | 220 | |
221 | - $give_receipt_args = shortcode_atts( array( |
|
222 | - 'error' => esc_html__( 'You are missing the payment key to view this donation receipt.', 'give' ), |
|
221 | + $give_receipt_args = shortcode_atts(array( |
|
222 | + 'error' => esc_html__('You are missing the payment key to view this donation receipt.', 'give'), |
|
223 | 223 | 'price' => true, |
224 | 224 | 'donor' => true, |
225 | 225 | 'date' => true, |
@@ -228,50 +228,50 @@ discard block |
||
228 | 228 | 'payment_id' => true, |
229 | 229 | 'payment_status' => false, |
230 | 230 | 'status_notice' => true, |
231 | - ), $atts, 'give_receipt' ); |
|
231 | + ), $atts, 'give_receipt'); |
|
232 | 232 | |
233 | 233 | //set $session var |
234 | 234 | $session = give_get_purchase_session(); |
235 | 235 | |
236 | 236 | //set payment key var |
237 | - if ( isset( $_GET['payment_key'] ) ) { |
|
238 | - $payment_key = urldecode( $_GET['payment_key'] ); |
|
239 | - } elseif ( $session ) { |
|
237 | + if (isset($_GET['payment_key'])) { |
|
238 | + $payment_key = urldecode($_GET['payment_key']); |
|
239 | + } elseif ($session) { |
|
240 | 240 | $payment_key = $session['purchase_key']; |
241 | - } elseif ( $give_receipt_args['payment_key'] ) { |
|
241 | + } elseif ($give_receipt_args['payment_key']) { |
|
242 | 242 | $payment_key = $give_receipt_args['payment_key']; |
243 | 243 | } |
244 | 244 | |
245 | - $email_access = give_get_option( 'email_access' ); |
|
245 | + $email_access = give_get_option('email_access'); |
|
246 | 246 | |
247 | 247 | // No payment_key found & Email Access is Turned on: |
248 | - if ( ! isset( $payment_key ) && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
248 | + if ( ! isset($payment_key) && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
249 | 249 | |
250 | 250 | ob_start(); |
251 | 251 | |
252 | - give_get_template_part( 'email-login-form' ); |
|
252 | + give_get_template_part('email-login-form'); |
|
253 | 253 | |
254 | 254 | return ob_get_clean(); |
255 | 255 | |
256 | - } elseif ( ! isset( $payment_key ) ) { |
|
256 | + } elseif ( ! isset($payment_key)) { |
|
257 | 257 | |
258 | - return give_output_error( $give_receipt_args['error'], false, 'error' ); |
|
258 | + return give_output_error($give_receipt_args['error'], false, 'error'); |
|
259 | 259 | |
260 | 260 | } |
261 | 261 | |
262 | - $payment_id = give_get_purchase_id_by_key( $payment_key ); |
|
263 | - $user_can_view = give_can_view_receipt( $payment_key ); |
|
262 | + $payment_id = give_get_purchase_id_by_key($payment_key); |
|
263 | + $user_can_view = give_can_view_receipt($payment_key); |
|
264 | 264 | |
265 | 265 | // Key was provided, but user is logged out. Offer them the ability to login and view the receipt. |
266 | - if ( ! $user_can_view && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
266 | + if ( ! $user_can_view && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
267 | 267 | |
268 | 268 | ob_start(); |
269 | 269 | |
270 | - give_get_template_part( 'email-login-form' ); |
|
270 | + give_get_template_part('email-login-form'); |
|
271 | 271 | |
272 | 272 | return ob_get_clean(); |
273 | 273 | |
274 | - } elseif ( ! $user_can_view ) { |
|
274 | + } elseif ( ! $user_can_view) { |
|
275 | 275 | |
276 | 276 | global $give_login_redirect; |
277 | 277 | |
@@ -279,9 +279,9 @@ discard block |
||
279 | 279 | |
280 | 280 | ob_start(); |
281 | 281 | |
282 | - 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' ) ) ); |
|
282 | + 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'))); |
|
283 | 283 | |
284 | - give_get_template_part( 'shortcode', 'login' ); |
|
284 | + give_get_template_part('shortcode', 'login'); |
|
285 | 285 | |
286 | 286 | $login_form = ob_get_clean(); |
287 | 287 | |
@@ -296,20 +296,20 @@ discard block |
||
296 | 296 | * or if user is logged in and the user can view sensitive shop data. |
297 | 297 | * |
298 | 298 | */ |
299 | - if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) { |
|
300 | - return give_output_error( $give_receipt_args['error'], false, 'error' ); |
|
299 | + if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) { |
|
300 | + return give_output_error($give_receipt_args['error'], false, 'error'); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | ob_start(); |
304 | 304 | |
305 | - give_get_template_part( 'shortcode', 'receipt' ); |
|
305 | + give_get_template_part('shortcode', 'receipt'); |
|
306 | 306 | |
307 | 307 | $display = ob_get_clean(); |
308 | 308 | |
309 | 309 | return $display; |
310 | 310 | } |
311 | 311 | |
312 | -add_shortcode( 'give_receipt', 'give_receipt_shortcode' ); |
|
312 | +add_shortcode('give_receipt', 'give_receipt_shortcode'); |
|
313 | 313 | |
314 | 314 | /** |
315 | 315 | * Profile Editor Shortcode. |
@@ -328,18 +328,18 @@ discard block |
||
328 | 328 | * |
329 | 329 | * @return string Output generated from the profile editor |
330 | 330 | */ |
331 | -function give_profile_editor_shortcode( $atts ) { |
|
331 | +function give_profile_editor_shortcode($atts) { |
|
332 | 332 | |
333 | 333 | ob_start(); |
334 | 334 | |
335 | - give_get_template_part( 'shortcode', 'profile-editor' ); |
|
335 | + give_get_template_part('shortcode', 'profile-editor'); |
|
336 | 336 | |
337 | 337 | $display = ob_get_clean(); |
338 | 338 | |
339 | 339 | return $display; |
340 | 340 | } |
341 | 341 | |
342 | -add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' ); |
|
342 | +add_shortcode('give_profile_editor', 'give_profile_editor_shortcode'); |
|
343 | 343 | |
344 | 344 | /** |
345 | 345 | * Process Profile Updater Form. |
@@ -352,30 +352,30 @@ discard block |
||
352 | 352 | * |
353 | 353 | * @return bool |
354 | 354 | */ |
355 | -function give_process_profile_editor_updates( $data ) { |
|
355 | +function give_process_profile_editor_updates($data) { |
|
356 | 356 | // Profile field change request |
357 | - if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) { |
|
357 | + if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) { |
|
358 | 358 | return false; |
359 | 359 | } |
360 | 360 | |
361 | 361 | // Nonce security |
362 | - if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) { |
|
362 | + if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) { |
|
363 | 363 | return false; |
364 | 364 | } |
365 | 365 | |
366 | 366 | $user_id = get_current_user_id(); |
367 | - $old_user_data = get_userdata( $user_id ); |
|
368 | - |
|
369 | - $display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name; |
|
370 | - $first_name = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name; |
|
371 | - $last_name = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name; |
|
372 | - $email = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email; |
|
373 | - $line1 = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' ); |
|
374 | - $line2 = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' ); |
|
375 | - $city = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' ); |
|
376 | - $state = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' ); |
|
377 | - $zip = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' ); |
|
378 | - $country = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' ); |
|
367 | + $old_user_data = get_userdata($user_id); |
|
368 | + |
|
369 | + $display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name; |
|
370 | + $first_name = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name; |
|
371 | + $last_name = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name; |
|
372 | + $email = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email; |
|
373 | + $line1 = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : ''); |
|
374 | + $line2 = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : ''); |
|
375 | + $city = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : ''); |
|
376 | + $state = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : ''); |
|
377 | + $zip = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : ''); |
|
378 | + $country = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : ''); |
|
379 | 379 | |
380 | 380 | $userdata = array( |
381 | 381 | 'ID' => $user_id, |
@@ -403,46 +403,46 @@ discard block |
||
403 | 403 | * @param int $user_id The ID of the user. |
404 | 404 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
405 | 405 | */ |
406 | - do_action( 'give_pre_update_user_profile', $user_id, $userdata ); |
|
406 | + do_action('give_pre_update_user_profile', $user_id, $userdata); |
|
407 | 407 | |
408 | 408 | // New password |
409 | - if ( ! empty( $data['give_new_user_pass1'] ) ) { |
|
410 | - if ( $data['give_new_user_pass1'] !== $data['give_new_user_pass2'] ) { |
|
411 | - give_set_error( 'password_mismatch', esc_html__( 'The passwords you entered do not match. Please try again.', 'give' ) ); |
|
409 | + if ( ! empty($data['give_new_user_pass1'])) { |
|
410 | + if ($data['give_new_user_pass1'] !== $data['give_new_user_pass2']) { |
|
411 | + give_set_error('password_mismatch', esc_html__('The passwords you entered do not match. Please try again.', 'give')); |
|
412 | 412 | } else { |
413 | 413 | $userdata['user_pass'] = $data['give_new_user_pass1']; |
414 | 414 | } |
415 | 415 | } |
416 | 416 | |
417 | - if ( empty( $email ) ) { |
|
417 | + if (empty($email)) { |
|
418 | 418 | // Make sure email should not be empty. |
419 | - give_set_error( 'email_empty', esc_html__( 'The email you entered is empty.', 'give' ) ); |
|
419 | + give_set_error('email_empty', esc_html__('The email you entered is empty.', 'give')); |
|
420 | 420 | |
421 | - } else if ( ! is_email( $email ) ) { |
|
421 | + } else if ( ! is_email($email)) { |
|
422 | 422 | // Make sure email should be valid. |
423 | - give_set_error( 'email_not_valid', esc_html__( 'The email you entered is not valid. Please use another', 'give' ) ); |
|
423 | + give_set_error('email_not_valid', esc_html__('The email you entered is not valid. Please use another', 'give')); |
|
424 | 424 | |
425 | - } else if ( $email != $old_user_data->user_email ) { |
|
425 | + } else if ($email != $old_user_data->user_email) { |
|
426 | 426 | // Make sure the new email doesn't belong to another user |
427 | - if ( email_exists( $email ) ) { |
|
428 | - give_set_error( 'email_exists', esc_html__( 'The email you entered belongs to another user. Please use another.', 'give' ) ); |
|
427 | + if (email_exists($email)) { |
|
428 | + give_set_error('email_exists', esc_html__('The email you entered belongs to another user. Please use another.', 'give')); |
|
429 | 429 | } |
430 | 430 | } |
431 | 431 | |
432 | 432 | // Check for errors |
433 | 433 | $errors = give_get_errors(); |
434 | 434 | |
435 | - if ( $errors ) { |
|
435 | + if ($errors) { |
|
436 | 436 | // Send back to the profile editor if there are errors |
437 | - wp_redirect( $data['give_redirect'] ); |
|
437 | + wp_redirect($data['give_redirect']); |
|
438 | 438 | give_die(); |
439 | 439 | } |
440 | 440 | |
441 | 441 | // Update the user |
442 | - $meta = update_user_meta( $user_id, '_give_user_address', $address ); |
|
443 | - $updated = wp_update_user( $userdata ); |
|
442 | + $meta = update_user_meta($user_id, '_give_user_address', $address); |
|
443 | + $updated = wp_update_user($userdata); |
|
444 | 444 | |
445 | - if ( $updated ) { |
|
445 | + if ($updated) { |
|
446 | 446 | |
447 | 447 | /** |
448 | 448 | * Fires after updating user profile. |
@@ -452,12 +452,12 @@ discard block |
||
452 | 452 | * @param int $user_id The ID of the user. |
453 | 453 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
454 | 454 | */ |
455 | - do_action( 'give_user_profile_updated', $user_id, $userdata ); |
|
456 | - wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) ); |
|
455 | + do_action('give_user_profile_updated', $user_id, $userdata); |
|
456 | + wp_redirect(add_query_arg('updated', 'true', $data['give_redirect'])); |
|
457 | 457 | give_die(); |
458 | 458 | } |
459 | 459 | |
460 | 460 | return false; |
461 | 461 | } |
462 | 462 | |
463 | -add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' ); |
|
463 | +add_action('give_edit_user_profile', 'give_process_profile_editor_updates'); |