@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | ?> |
| 10 | 10 | |
@@ -12,54 +12,54 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | <form method="post" class="text-center card-body"> |
| 14 | 14 | <div class="gp-wizard-payments"> |
| 15 | - <h2 class="gd-settings-title h3 "><?php _e( 'Gateway Setup', 'invoicing' ); ?></h2> |
|
| 16 | - <p><?php _e( 'Below are a few gateways that can be setup in a few seconds.', 'invoicing' ); ?> |
|
| 15 | + <h2 class="gd-settings-title h3 "><?php _e('Gateway Setup', 'invoicing'); ?></h2> |
|
| 16 | + <p><?php _e('Below are a few gateways that can be setup in a few seconds.', 'invoicing'); ?> |
|
| 17 | 17 | <br> |
| 18 | - <?php _e( 'We have 20+ Gateways that can be setup later.', 'invoicing' ); ?> |
|
| 18 | + <?php _e('We have 20+ Gateways that can be setup later.', 'invoicing'); ?> |
|
| 19 | 19 | </p> |
| 20 | 20 | |
| 21 | 21 | <ul class="list-group"> |
| 22 | 22 | |
| 23 | 23 | <li class="list-group-item d-flex justify-content-between align-items-center"> |
| 24 | - <span class="mr-auto"><img src="<?php echo esc_url( WPINV_PLUGIN_URL . 'assets/images/stripe-verified.svg' );?>" class="ml-n2" alt="Stripe"></span> |
|
| 25 | - <?php if ( false === wpinv_get_option( 'stripe_live_connect_account_id' ) ) : ?> |
|
| 24 | + <span class="mr-auto"><img src="<?php echo esc_url(WPINV_PLUGIN_URL . 'assets/images/stripe-verified.svg'); ?>" class="ml-n2" alt="Stripe"></span> |
|
| 25 | + <?php if (false === wpinv_get_option('stripe_live_connect_account_id')) : ?> |
|
| 26 | 26 | <a href="<?php echo wp_nonce_url( |
| 27 | 27 | add_query_arg( |
| 28 | 28 | array( |
| 29 | 29 | 'getpaid-admin-action' => 'connect_gateway', |
| 30 | 30 | 'plugin' => 'stripe', |
| 31 | - 'redirect' => urlencode( add_query_arg( 'step', 'payments' ) ), |
|
| 31 | + 'redirect' => urlencode(add_query_arg('step', 'payments')), |
|
| 32 | 32 | ), |
| 33 | 33 | admin_url() |
| 34 | 34 | ), |
| 35 | 35 | 'getpaid-nonce', |
| 36 | 36 | 'getpaid-nonce' |
| 37 | 37 | ); ?>" |
| 38 | - class="btn btn-sm btn-outline-primary"><?php _e( 'Connect', 'invoicing' ); ?></a> |
|
| 38 | + class="btn btn-sm btn-outline-primary"><?php _e('Connect', 'invoicing'); ?></a> |
|
| 39 | 39 | <?php else: ?> |
| 40 | - <span class="btn btn-sm btn-success"><?php _e( 'Connected', 'invoicing' ); ?></span> |
|
| 40 | + <span class="btn btn-sm btn-success"><?php _e('Connected', 'invoicing'); ?></span> |
|
| 41 | 41 | <?php endif; ?> |
| 42 | 42 | </li> |
| 43 | 43 | |
| 44 | 44 | <li class="list-group-item"> |
| 45 | 45 | <div class="d-flex justify-content-between align-items-center"> |
| 46 | 46 | <span class="mr-auto"> |
| 47 | - <img src="<?php echo esc_url( WPINV_PLUGIN_URL . 'assets/images/pp-logo-150px.webp' );?>" class="" alt="PayPal" height="25"> |
|
| 47 | + <img src="<?php echo esc_url(WPINV_PLUGIN_URL . 'assets/images/pp-logo-150px.webp'); ?>" class="" alt="PayPal" height="25"> |
|
| 48 | 48 | </span> |
| 49 | 49 | <a |
| 50 | 50 | href="#" |
| 51 | 51 | onclick="jQuery('.getpaid-setup-paypal-input').toggleClass('d-none'); return false;" |
| 52 | - class="getpaid-setup-paypal btn btn-sm btn-outline-primary"><?php _e( 'Set-up', 'invoicing' ); ?></a> |
|
| 52 | + class="getpaid-setup-paypal btn btn-sm btn-outline-primary"><?php _e('Set-up', 'invoicing'); ?></a> |
|
| 53 | 53 | </div> |
| 54 | 54 | <div class="mt-4 getpaid-setup-paypal-input d-none"> |
| 55 | - <input type="text" placeholder="<?php esc_attr_e( 'PayPal Email', 'invoicing' ); ?>" name="paypal-email" class="form-control" value="<?php echo esc_attr( wpinv_get_option( 'paypal_email' ) ); ?>"> |
|
| 55 | + <input type="text" placeholder="<?php esc_attr_e('PayPal Email', 'invoicing'); ?>" name="paypal-email" class="form-control" value="<?php echo esc_attr(wpinv_get_option('paypal_email')); ?>"> |
|
| 56 | 56 | </div> |
| 57 | 57 | </li> |
| 58 | 58 | |
| 59 | 59 | <li class="list-group-item d-flex justify-content-between align-items-center"> |
| 60 | - <span class="mr-auto"><?php _e( 'Test Getway', 'invoicing' ); ?></span> |
|
| 60 | + <span class="mr-auto"><?php _e('Test Getway', 'invoicing'); ?></span> |
|
| 61 | 61 | <div class="custom-control custom-switch"> |
| 62 | - <input type="checkbox" name="enable-manual-gateway" class="custom-control-input" id="enable-manual-gateway" <?php checked( wpinv_is_gateway_active( 'manual' ) ); ?>> |
|
| 62 | + <input type="checkbox" name="enable-manual-gateway" class="custom-control-input" id="enable-manual-gateway" <?php checked(wpinv_is_gateway_active('manual')); ?>> |
|
| 63 | 63 | <label class="custom-control-label" for="enable-manual-gateway"></label> |
| 64 | 64 | </div> |
| 65 | 65 | </li> |
@@ -68,10 +68,10 @@ discard block |
||
| 68 | 68 | </div> |
| 69 | 69 | |
| 70 | 70 | <p class="gp-setup-actions step text-center mt-4"> |
| 71 | - <input type="submit" class="btn btn-primary" value="<?php esc_attr_e( 'Continue', 'invoicing' ); ?>" /> |
|
| 71 | + <input type="submit" class="btn btn-primary" value="<?php esc_attr_e('Continue', 'invoicing'); ?>" /> |
|
| 72 | 72 | </p> |
| 73 | 73 | |
| 74 | - <?php getpaid_hidden_field( 'save_step', 1 ); ?> |
|
| 75 | - <?php wp_nonce_field( 'getpaid-setup-wizard', 'getpaid-setup-wizard' ); ?> |
|
| 74 | + <?php getpaid_hidden_field('save_step', 1); ?> |
|
| 75 | + <?php wp_nonce_field('getpaid-setup-wizard', 'getpaid-setup-wizard'); ?> |
|
| 76 | 76 | </form> |
| 77 | 77 | </div> |
@@ -4,78 +4,78 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | ?> |
| 10 | 10 | |
| 11 | 11 | <div class="card shadow-sm my-5"> |
| 12 | 12 | |
| 13 | 13 | <h1 class="h4 card-header bg-white border-bottom-0 pt-4 pb-1"> |
| 14 | - <?php esc_html_e( 'Welcome to the GetPaid Setup Wizard!', 'invoicing' ); ?> |
|
| 14 | + <?php esc_html_e('Welcome to the GetPaid Setup Wizard!', 'invoicing'); ?> |
|
| 15 | 15 | </h1> |
| 16 | 16 | |
| 17 | 17 | <div class="card-body text-muted "> |
| 18 | - <p><?php _e( 'Thank you for choosing GetPaid - The most Powerful Payments Plugin for WordPress', 'invoicing' ); ?></p> |
|
| 18 | + <p><?php _e('Thank you for choosing GetPaid - The most Powerful Payments Plugin for WordPress', 'invoicing'); ?></p> |
|
| 19 | 19 | <hr class="mt-4 pt-3 pb-0" /> |
| 20 | - <p class="small"><?php _e( 'This quick setup wizard will help you <b>configure the basic settings</b>. It’s <b>completely optional</b> and shouldn’t take longer than <b>five minutes</b>.', 'invoicing' ); ?></p> |
|
| 20 | + <p class="small"><?php _e('This quick setup wizard will help you <b>configure the basic settings</b>. It’s <b>completely optional</b> and shouldn’t take longer than <b>five minutes</b>.', 'invoicing'); ?></p> |
|
| 21 | 21 | </div> |
| 22 | 22 | |
| 23 | 23 | <div class="card-footer mb-0 bg-white gp-setup-actions step border-top-0"> |
| 24 | 24 | <a |
| 25 | - href="<?php echo esc_url( $next_url ); ?>" |
|
| 26 | - class="btn btn-primary button-next"><?php esc_html_e( "Let's go!", 'invoicing' ); ?></a> |
|
| 25 | + href="<?php echo esc_url($next_url); ?>" |
|
| 26 | + class="btn btn-primary button-next"><?php esc_html_e("Let's go!", 'invoicing'); ?></a> |
|
| 27 | 27 | <a |
| 28 | - href="<?php echo esc_url( admin_url() ); ?>" |
|
| 29 | - class="btn btn-link d-block mt-2 "><?php esc_html_e( 'Not right now', 'invoicing' ); ?></a> |
|
| 28 | + href="<?php echo esc_url(admin_url()); ?>" |
|
| 29 | + class="btn btn-link d-block mt-2 "><?php esc_html_e('Not right now', 'invoicing'); ?></a> |
|
| 30 | 30 | </div> |
| 31 | 31 | </div> |
| 32 | 32 | |
| 33 | 33 | <div class="card shadow-sm my-5 overflow-hidden"> |
| 34 | 34 | <h1 class="h4 card-header bg-white border-bottom-0 pt-4 pb-1"> |
| 35 | - <?php esc_html_e( 'GetPaid Features & Addons!', 'invoicing' ); ?> |
|
| 35 | + <?php esc_html_e('GetPaid Features & Addons!', 'invoicing'); ?> |
|
| 36 | 36 | </h1> |
| 37 | 37 | |
| 38 | 38 | <div class="card-body text-muted overflow-hidden"> |
| 39 | - <p><?php _e( 'Collect one time & recurring payments online within minutes. No complex setup required.', 'invoicing' ); ?></p> |
|
| 39 | + <p><?php _e('Collect one time & recurring payments online within minutes. No complex setup required.', 'invoicing'); ?></p> |
|
| 40 | 40 | <hr> |
| 41 | 41 | |
| 42 | 42 | <div class="row row-cols-2 text-left"> |
| 43 | 43 | <div class="col mt-3"> |
| 44 | 44 | <div class="media"> |
| 45 | - <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/buy.svg';?>" class="mr-3" alt="..."> |
|
| 45 | + <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/buy.svg'; ?>" class="mr-3" alt="..."> |
|
| 46 | 46 | <div class="media-body"> |
| 47 | - <h6 class="mt-0 font-weight-bold"><?php _e( 'GetPaid via Buy Now Buttons', 'invoicing' );?></h6> |
|
| 48 | - <small><?php _e( 'Sell via buy now buttons anywhere on your site', 'invoicing' );?></small> |
|
| 47 | + <h6 class="mt-0 font-weight-bold"><?php _e('GetPaid via Buy Now Buttons', 'invoicing'); ?></h6> |
|
| 48 | + <small><?php _e('Sell via buy now buttons anywhere on your site', 'invoicing'); ?></small> |
|
| 49 | 49 | </div> |
| 50 | 50 | </div> |
| 51 | 51 | </div> |
| 52 | 52 | |
| 53 | 53 | <div class="col mt-3"> |
| 54 | 54 | <div class="media"> |
| 55 | - <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/report.svg';?>" class="mr-3" alt="..."> |
|
| 55 | + <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/report.svg'; ?>" class="mr-3" alt="..."> |
|
| 56 | 56 | <div class="media-body"> |
| 57 | - <h6 class="mt-0 font-weight-bold"><?php _e( 'GetPaid via payment form', 'invoicing' );?></h6> |
|
| 58 | - <small><?php _e( 'Payment forms are conversion-optimized checkout forms', 'invoicing' );?></small> |
|
| 57 | + <h6 class="mt-0 font-weight-bold"><?php _e('GetPaid via payment form', 'invoicing'); ?></h6> |
|
| 58 | + <small><?php _e('Payment forms are conversion-optimized checkout forms', 'invoicing'); ?></small> |
|
| 59 | 59 | </div> |
| 60 | 60 | </div> |
| 61 | 61 | </div> |
| 62 | 62 | |
| 63 | 63 | <div class="col mt-3"> |
| 64 | 64 | <div class="media"> |
| 65 | - <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/invoices.svg';?>" class="mr-3" alt="..."> |
|
| 65 | + <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/invoices.svg'; ?>" class="mr-3" alt="..."> |
|
| 66 | 66 | <div class="media-body"> |
| 67 | - <h6 class="mt-0 font-weight-bold"><?php _e('GetPaid via Invoice','invoicing');?></h6> |
|
| 68 | - <small><?php _e('Create and send invoices for just about anything from the WordPress dashboard','invoicing');?></small> |
|
| 67 | + <h6 class="mt-0 font-weight-bold"><?php _e('GetPaid via Invoice', 'invoicing'); ?></h6> |
|
| 68 | + <small><?php _e('Create and send invoices for just about anything from the WordPress dashboard', 'invoicing'); ?></small> |
|
| 69 | 69 | </div> |
| 70 | 70 | </div> |
| 71 | 71 | </div> |
| 72 | 72 | |
| 73 | 73 | <div class="col mt-3"> |
| 74 | 74 | <div class="media"> |
| 75 | - <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/payment.svg';?>" class="mr-3" alt="..."> |
|
| 75 | + <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/payment.svg'; ?>" class="mr-3" alt="..."> |
|
| 76 | 76 | <div class="media-body"> |
| 77 | - <h6 class="mt-0 font-weight-bold"><?php _e('Affordable payment gateways','invoicing');?></h6> |
|
| 78 | - <small><?php _e('On average our gateways are over 66% cheaper than our competition','invoicing');?></small> |
|
| 77 | + <h6 class="mt-0 font-weight-bold"><?php _e('Affordable payment gateways', 'invoicing'); ?></h6> |
|
| 78 | + <small><?php _e('On average our gateways are over 66% cheaper than our competition', 'invoicing'); ?></small> |
|
| 79 | 79 | </div> |
| 80 | 80 | </div> |
| 81 | 81 | </div> |
@@ -86,51 +86,51 @@ discard block |
||
| 86 | 86 | <div class="mt-5"> |
| 87 | 87 | <a |
| 88 | 88 | href="https://wpgetpaid.com/features-list/" |
| 89 | - class="btn btn-primary"><?php esc_html_e( 'View All Features!', 'invoicing' ); ?></a> |
|
| 89 | + class="btn btn-primary"><?php esc_html_e('View All Features!', 'invoicing'); ?></a> |
|
| 90 | 90 | </div> |
| 91 | 91 | |
| 92 | 92 | <div class="mt-5 mx-n4 py-4" style="background:#eafaf6;"> |
| 93 | - <h4 class="mt-0 font-weight-bold text-dark mb-4"><?php _e( 'More with Membership!' , 'invoicing' );?></h4> |
|
| 93 | + <h4 class="mt-0 font-weight-bold text-dark mb-4"><?php _e('More with Membership!', 'invoicing'); ?></h4> |
|
| 94 | 94 | <div class="row row-cols-2 text-left px-5"> |
| 95 | 95 | |
| 96 | 96 | <div class="col"> |
| 97 | 97 | <ul class="list-unstyled"> |
| 98 | - <li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'PDF Invoices' , 'invoicing' );?></li> |
|
| 99 | - <li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'Gravity Forms' , 'invoicing' );?></li> |
|
| 100 | - <li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'Contact form 7' , 'invoicing' );?></li> |
|
| 101 | - <li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'AffiliateWP Integration' , 'invoicing' );?></li> |
|
| 98 | + <li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('PDF Invoices', 'invoicing'); ?></li> |
|
| 99 | + <li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('Gravity Forms', 'invoicing'); ?></li> |
|
| 100 | + <li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('Contact form 7', 'invoicing'); ?></li> |
|
| 101 | + <li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('AffiliateWP Integration', 'invoicing'); ?></li> |
|
| 102 | 102 | </ul> |
| 103 | 103 | </div> |
| 104 | 104 | |
| 105 | 105 | <div class="col"> |
| 106 | 106 | <ul class="list-unstyled"> |
| 107 | - <li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'Ninja forms' , 'invoicing' );?></li> |
|
| 108 | - <li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'Digital Downloads' , 'invoicing' );?></li> |
|
| 109 | - <li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'Wallet' , 'invoicing' );?></li> |
|
| 107 | + <li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('Ninja forms', 'invoicing'); ?></li> |
|
| 108 | + <li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('Digital Downloads', 'invoicing'); ?></li> |
|
| 109 | + <li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('Wallet', 'invoicing'); ?></li> |
|
| 110 | 110 | </ul> |
| 111 | 111 | </div> |
| 112 | 112 | </div> |
| 113 | 113 | |
| 114 | - <h5 class="mt-4 font-weight-bold text-dark mb-3"><?php _e('Membership Starts From','invoicing');?></h5> |
|
| 115 | - <h1 class="mt-0 font-weight-bold text-dark mb-4 display-3"><?php esc_html_e( '$49', 'invoicing' ); ?></h1> |
|
| 114 | + <h5 class="mt-4 font-weight-bold text-dark mb-3"><?php _e('Membership Starts From', 'invoicing'); ?></h5> |
|
| 115 | + <h1 class="mt-0 font-weight-bold text-dark mb-4 display-3"><?php esc_html_e('$49', 'invoicing'); ?></h1> |
|
| 116 | 116 | |
| 117 | 117 | <div class="mt-2"> |
| 118 | 118 | <a |
| 119 | 119 | href="https://wpgetpaid.com/downloads/membership/" |
| 120 | - class="btn btn-primary"><?php esc_html_e( 'Buy Membership Now!', 'invoicing' ); ?></a> |
|
| 120 | + class="btn btn-primary"><?php esc_html_e('Buy Membership Now!', 'invoicing'); ?></a> |
|
| 121 | 121 | </div> |
| 122 | 122 | |
| 123 | 123 | </div> |
| 124 | 124 | |
| 125 | 125 | <div class="card-footer mb-0 bg-white gp-setup-actions step border-top-0"> |
| 126 | 126 | <a |
| 127 | - href="<?php echo esc_url( $next_url ); ?>" |
|
| 128 | - class="btn btn-outline-primary button-next"><?php esc_html_e( 'Launch the Setup Wizard!', 'invoicing' ); ?></a> |
|
| 127 | + href="<?php echo esc_url($next_url); ?>" |
|
| 128 | + class="btn btn-outline-primary button-next"><?php esc_html_e('Launch the Setup Wizard!', 'invoicing'); ?></a> |
|
| 129 | 129 | <a |
| 130 | 130 | href="https://docs.wpgetpaid.com/" |
| 131 | - class="btn btn-outline-primary ml-4"><?php esc_html_e( 'Documentation', 'invoicing' ); ?></a> |
|
| 131 | + class="btn btn-outline-primary ml-4"><?php esc_html_e('Documentation', 'invoicing'); ?></a> |
|
| 132 | 132 | <a |
| 133 | - href="<?php echo esc_url( admin_url() ); ?>" |
|
| 134 | - class="btn btn-link d-block mt-2 "><?php esc_html_e( 'Not right now', 'invoicing' ); ?></a> |
|
| 133 | + href="<?php echo esc_url(admin_url()); ?>" |
|
| 134 | + class="btn btn-link d-block mt-2 "><?php esc_html_e('Not right now', 'invoicing'); ?></a> |
|
| 135 | 135 | </div> |
| 136 | 136 | </div> |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Daily maintenance class. |
@@ -15,20 +15,20 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * Class constructor. |
| 17 | 17 | */ |
| 18 | - public function __construct(){ |
|
| 18 | + public function __construct() { |
|
| 19 | 19 | |
| 20 | 20 | // Clear deprecated events. |
| 21 | - add_action( 'wp', array( $this, 'maybe_clear_deprecated_events' ) ); |
|
| 21 | + add_action('wp', array($this, 'maybe_clear_deprecated_events')); |
|
| 22 | 22 | |
| 23 | 23 | // (Maybe) schedule a cron that runs daily. |
| 24 | - add_action( 'wp', array( $this, 'maybe_create_scheduled_event' ) ); |
|
| 24 | + add_action('wp', array($this, 'maybe_create_scheduled_event')); |
|
| 25 | 25 | |
| 26 | 26 | // Fired everyday at 7 a.m (this might vary for sites with few visitors) |
| 27 | - add_action( 'getpaid_daily_maintenance', array( $this, 'log_cron_run' ) ); |
|
| 28 | - add_action( 'getpaid_daily_maintenance', array( $this, 'backwards_compat' ) ); |
|
| 29 | - add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_expire_subscriptions' ) ); |
|
| 30 | - add_action( 'getpaid_daily_maintenance', array( $this, 'check_renewing_subscriptions' ) ); |
|
| 31 | - add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_update_geoip_databases' ) ); |
|
| 27 | + add_action('getpaid_daily_maintenance', array($this, 'log_cron_run')); |
|
| 28 | + add_action('getpaid_daily_maintenance', array($this, 'backwards_compat')); |
|
| 29 | + add_action('getpaid_daily_maintenance', array($this, 'maybe_expire_subscriptions')); |
|
| 30 | + add_action('getpaid_daily_maintenance', array($this, 'check_renewing_subscriptions')); |
|
| 31 | + add_action('getpaid_daily_maintenance', array($this, 'maybe_update_geoip_databases')); |
|
| 32 | 32 | |
| 33 | 33 | } |
| 34 | 34 | |
@@ -38,9 +38,9 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function maybe_create_scheduled_event() { |
| 40 | 40 | |
| 41 | - if ( ! wp_next_scheduled( 'getpaid_daily_maintenance' ) ) { |
|
| 42 | - $timestamp = strtotime( 'tomorrow 07:00:00', current_time( 'timestamp' ) ); |
|
| 43 | - wp_schedule_event( $timestamp, 'daily', 'getpaid_daily_maintenance' ); |
|
| 41 | + if (!wp_next_scheduled('getpaid_daily_maintenance')) { |
|
| 42 | + $timestamp = strtotime('tomorrow 07:00:00', current_time('timestamp')); |
|
| 43 | + wp_schedule_event($timestamp, 'daily', 'getpaid_daily_maintenance'); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | } |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | public function maybe_clear_deprecated_events() { |
| 53 | 53 | |
| 54 | - if ( ! get_option( 'wpinv_cleared_old_events' ) ) { |
|
| 55 | - wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' ); |
|
| 56 | - wp_clear_scheduled_hook( 'wpinv_register_schedule_event_daily' ); |
|
| 57 | - update_option( 'wpinv_cleared_old_events', 1 ); |
|
| 54 | + if (!get_option('wpinv_cleared_old_events')) { |
|
| 55 | + wp_clear_scheduled_hook('wpinv_register_schedule_event_twicedaily'); |
|
| 56 | + wp_clear_scheduled_hook('wpinv_register_schedule_event_daily'); |
|
| 57 | + update_option('wpinv_cleared_old_events', 1); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | */ |
| 66 | 66 | public function backwards_compat() { |
| 67 | - do_action( 'wpinv_register_schedule_event_daily' ); |
|
| 67 | + do_action('wpinv_register_schedule_event_daily'); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -74,29 +74,29 @@ discard block |
||
| 74 | 74 | public function check_renewing_subscriptions() { |
| 75 | 75 | |
| 76 | 76 | // Fetch subscriptions that expire today. |
| 77 | - $args = array( |
|
| 77 | + $args = array( |
|
| 78 | 78 | 'number' => -1, |
| 79 | 79 | 'count_total' => false, |
| 80 | 80 | 'status' => 'trialling active', |
| 81 | 81 | 'date_expires_query' => array( |
| 82 | 82 | array( |
| 83 | - 'year' => date( 'Y', current_time( 'timestamp' ) ), |
|
| 84 | - 'month' => date( 'n', current_time( 'timestamp' ) ), |
|
| 85 | - 'day' => date( 'j', current_time( 'timestamp' ) ), |
|
| 83 | + 'year' => date('Y', current_time('timestamp')), |
|
| 84 | + 'month' => date('n', current_time('timestamp')), |
|
| 85 | + 'day' => date('j', current_time('timestamp')), |
|
| 86 | 86 | 'compare' => '=', |
| 87 | 87 | ), |
| 88 | 88 | ), |
| 89 | 89 | ); |
| 90 | 90 | |
| 91 | - $subscriptions = new GetPaid_Subscriptions_Query( $args ); |
|
| 91 | + $subscriptions = new GetPaid_Subscriptions_Query($args); |
|
| 92 | 92 | |
| 93 | - foreach ( $subscriptions->get_results() as $subscription ) { |
|
| 93 | + foreach ($subscriptions->get_results() as $subscription) { |
|
| 94 | 94 | |
| 95 | 95 | /** @var WPInv_Subscription $subscription */ |
| 96 | - if ( $subscription->is_last_renewal() ) { |
|
| 96 | + if ($subscription->is_last_renewal()) { |
|
| 97 | 97 | $subscription->complete(); |
| 98 | 98 | } else { |
| 99 | - do_action( 'getpaid_should_renew_subscription', $subscription ); |
|
| 99 | + do_action('getpaid_should_renew_subscription', $subscription); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | public function maybe_expire_subscriptions() { |
| 111 | 111 | |
| 112 | 112 | // Fetch expired subscriptions (skips those that expire today). |
| 113 | - $args = array( |
|
| 113 | + $args = array( |
|
| 114 | 114 | 'number' => -1, |
| 115 | 115 | 'count_total' => false, |
| 116 | 116 | 'status' => 'trialling active failing cancelled', |
@@ -120,11 +120,11 @@ discard block |
||
| 120 | 120 | ), |
| 121 | 121 | ); |
| 122 | 122 | |
| 123 | - $subscriptions = new GetPaid_Subscriptions_Query( $args ); |
|
| 123 | + $subscriptions = new GetPaid_Subscriptions_Query($args); |
|
| 124 | 124 | |
| 125 | - foreach ( $subscriptions->get_results() as $subscription ) { |
|
| 126 | - if ( apply_filters( 'getpaid_daily_maintenance_should_expire_subscription', false, $subscription ) ) { |
|
| 127 | - $subscription->set_status( 'expired' ); |
|
| 125 | + foreach ($subscriptions->get_results() as $subscription) { |
|
| 126 | + if (apply_filters('getpaid_daily_maintenance_should_expire_subscription', false, $subscription)) { |
|
| 127 | + $subscription->set_status('expired'); |
|
| 128 | 128 | $subscription->save(); |
| 129 | 129 | } |
| 130 | 130 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | * |
| 137 | 137 | */ |
| 138 | 138 | public function log_cron_run() { |
| 139 | - wpinv_error_log( 'GetPaid Daily Cron', false ); |
|
| 139 | + wpinv_error_log('GetPaid Daily Cron', false); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
@@ -144,11 +144,11 @@ discard block |
||
| 144 | 144 | * |
| 145 | 145 | */ |
| 146 | 146 | public function maybe_update_geoip_databases() { |
| 147 | - $updated = get_transient( 'getpaid_updated_geoip_databases' ); |
|
| 147 | + $updated = get_transient('getpaid_updated_geoip_databases'); |
|
| 148 | 148 | |
| 149 | - if ( false === $updated ) { |
|
| 150 | - set_transient( 'getpaid_updated_geoip_databases', 1, 15 * DAY_IN_SECONDS ); |
|
| 151 | - do_action( 'getpaid_update_geoip_databases' ); |
|
| 149 | + if (false === $updated) { |
|
| 150 | + set_transient('getpaid_updated_geoip_databases', 1, 15 * DAY_IN_SECONDS); |
|
| 151 | + do_action('getpaid_update_geoip_databases'); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * All Invoicing extensions screen related functions can be found here. |
| 6 | 6 | * |
| 7 | 7 | */ |
| 8 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 8 | +if (!defined('ABSPATH')) { |
|
| 9 | 9 | exit; |
| 10 | 10 | } |
| 11 | 11 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * |
| 21 | 21 | * @return array of tabs. |
| 22 | 22 | */ |
| 23 | - public function get_tabs(){ |
|
| 23 | + public function get_tabs() { |
|
| 24 | 24 | $tabs = array( |
| 25 | 25 | 'addons' => __("Addons", "invoicing"), |
| 26 | 26 | 'gateways' => __("Payment Gateways", "invoicing"), |
@@ -38,28 +38,28 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @return array |
| 40 | 40 | */ |
| 41 | - public function get_section_data( $section_id ) { |
|
| 42 | - $section = self::get_tab( $section_id ); |
|
| 41 | + public function get_section_data($section_id) { |
|
| 42 | + $section = self::get_tab($section_id); |
|
| 43 | 43 | $api_url = "https://wpinvoicing.com/edd-api/v2/products/"; |
| 44 | 44 | $section_data = new stdClass(); |
| 45 | 45 | |
| 46 | - if($section_id=='recommended_plugins'){ |
|
| 46 | + if ($section_id == 'recommended_plugins') { |
|
| 47 | 47 | $section_data->products = self::get_recommend_wp_plugins_edd_formatted(); |
| 48 | 48 | } |
| 49 | - elseif ( ! empty( $section ) ) { |
|
| 50 | - if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing |
|
| 49 | + elseif (!empty($section)) { |
|
| 50 | + if (false === ($section_data = get_transient('wpi_addons_section_' . $section_id))) { //@todo restore after testing |
|
| 51 | 51 | //if ( 1==1) { |
| 52 | 52 | |
| 53 | - $query_args = array( 'category' => $section_id, 'number' => 100); |
|
| 54 | - $query_args = apply_filters('wpeu_edd_api_query_args',$query_args,$api_url,$section_id); |
|
| 53 | + $query_args = array('category' => $section_id, 'number' => 100); |
|
| 54 | + $query_args = apply_filters('wpeu_edd_api_query_args', $query_args, $api_url, $section_id); |
|
| 55 | 55 | |
| 56 | - $raw_section = wp_safe_remote_get( esc_url_raw( add_query_arg($query_args ,$api_url) ), array( 'user-agent' => 'Invoicing Addons Page','timeout' => 15, ) ); |
|
| 56 | + $raw_section = wp_safe_remote_get(esc_url_raw(add_query_arg($query_args, $api_url)), array('user-agent' => 'Invoicing Addons Page', 'timeout' => 15,)); |
|
| 57 | 57 | |
| 58 | - if ( ! is_wp_error( $raw_section ) ) { |
|
| 59 | - $section_data = json_decode( wp_remote_retrieve_body( $raw_section ) ); |
|
| 58 | + if (!is_wp_error($raw_section)) { |
|
| 59 | + $section_data = json_decode(wp_remote_retrieve_body($raw_section)); |
|
| 60 | 60 | |
| 61 | - if ( ! empty( $section_data->products ) ) { |
|
| 62 | - set_transient( 'wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS ); |
|
| 61 | + if (!empty($section_data->products)) { |
|
| 62 | + set_transient('wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS); |
|
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -67,21 +67,21 @@ discard block |
||
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | $products = isset($section_data->products) ? $section_data->products : array(); |
| 70 | - if ( 'addons' == $section_id ) { |
|
| 70 | + if ('addons' == $section_id) { |
|
| 71 | 71 | |
| 72 | 72 | $quotes = new stdClass(); |
| 73 | 73 | $quotes->info = new stdClass(); |
| 74 | 74 | $quotes->info->id = ''; |
| 75 | 75 | $quotes->info->slug = 'invoicing-quotes'; |
| 76 | - $quotes->info->title = __( 'Quotes', 'invoicing' ); |
|
| 77 | - $quotes->info->excerpt = __( 'Create quotes and estimates', 'invoicing' ); |
|
| 76 | + $quotes->info->title = __('Quotes', 'invoicing'); |
|
| 77 | + $quotes->info->excerpt = __('Create quotes and estimates', 'invoicing'); |
|
| 78 | 78 | $quotes->info->link = 'https://wordpress.org/plugins/invoicing-quotes/'; |
| 79 | 79 | $quotes->info->thumbnail = 'https://wpgetpaid.com/wp-content/uploads/sites/13/edd/2019/11/Quotes-1-768x384.png'; |
| 80 | 80 | |
| 81 | 81 | $products[] = $quotes; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - return apply_filters( 'wpi_addons_section_data', $products, $section_id ); |
|
| 84 | + return apply_filters('wpi_addons_section_data', $products, $section_id); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | * @param string $theme |
| 93 | 93 | * @param string $plugin |
| 94 | 94 | */ |
| 95 | - public function output_button( $addon ) { |
|
| 96 | - $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
| 95 | + public function output_button($addon) { |
|
| 96 | + $current_tab = empty($_GET['tab']) ? 'addons' : sanitize_title($_GET['tab']); |
|
| 97 | 97 | // $button_text = __('Free','invoicing'); |
| 98 | 98 | // $licensing = false; |
| 99 | 99 | // $installed = false; |
@@ -105,14 +105,14 @@ discard block |
||
| 105 | 105 | // $install_status = 'get'; |
| 106 | 106 | // $onclick = ''; |
| 107 | 107 | |
| 108 | - $wp_org_themes = array('supreme-directory','directory-starter'); |
|
| 108 | + $wp_org_themes = array('supreme-directory', 'directory-starter'); |
|
| 109 | 109 | |
| 110 | 110 | $button_args = array( |
| 111 | - 'type' => ($current_tab == 'addons' || $current_tab =='gateways') ? 'addons' : $current_tab, |
|
| 111 | + 'type' => ($current_tab == 'addons' || $current_tab == 'gateways') ? 'addons' : $current_tab, |
|
| 112 | 112 | 'id' => isset($addon->info->id) ? absint($addon->info->id) : '', |
| 113 | 113 | 'title' => isset($addon->info->title) ? $addon->info->title : '', |
| 114 | - 'button_text' => __('Free','invoicing'), |
|
| 115 | - 'price_text' => __('Free','invoicing'), |
|
| 114 | + 'button_text' => __('Free', 'invoicing'), |
|
| 115 | + 'price_text' => __('Free', 'invoicing'), |
|
| 116 | 116 | 'link' => isset($addon->info->link) ? $addon->info->link : '', // link to product |
| 117 | 117 | 'url' => isset($addon->info->link) ? $addon->info->link : '', // button url |
| 118 | 118 | 'class' => 'button-primary', |
@@ -128,83 +128,83 @@ discard block |
||
| 128 | 128 | 'update_url' => '', |
| 129 | 129 | ); |
| 130 | 130 | |
| 131 | - if( 'invoicing-quotes' == $addon->info->slug || 'getpaid-stripe-payments' == $addon->info->slug || ( $current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug )){ |
|
| 132 | - include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
|
| 133 | - $status = install_plugin_install_status(array("slug"=>$button_args['slug'],"version"=>"")); |
|
| 131 | + if ('invoicing-quotes' == $addon->info->slug || 'getpaid-stripe-payments' == $addon->info->slug || ($current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug)) { |
|
| 132 | + include_once(ABSPATH . 'wp-admin/includes/plugin-install.php'); //for plugins_api.. |
|
| 133 | + $status = install_plugin_install_status(array("slug"=>$button_args['slug'], "version"=>"")); |
|
| 134 | 134 | $button_args['install_status'] = isset($status['status']) ? $status['status'] : 'install'; |
| 135 | 135 | $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
| 136 | - }elseif( ($current_tab == 'addons' || $current_tab =='gateways') && isset($addon->info->id) && $addon->info->id){ |
|
| 137 | - include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
|
| 138 | - if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
|
| 136 | + }elseif (($current_tab == 'addons' || $current_tab == 'gateways') && isset($addon->info->id) && $addon->info->id) { |
|
| 137 | + include_once(ABSPATH . 'wp-admin/includes/plugin-install.php'); //for plugins_api.. |
|
| 138 | + if (!empty($addon->licensing->edd_slug)) {$button_args['slug'] = $addon->licensing->edd_slug; } |
|
| 139 | 139 | $status = self::install_plugin_install_status($addon); |
| 140 | 140 | $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
| 141 | - if(isset($status['status'])){$button_args['install_status'] = $status['status'];} |
|
| 141 | + if (isset($status['status'])) {$button_args['install_status'] = $status['status']; } |
|
| 142 | 142 | $button_args['update_url'] = "https://wpinvoicing.com"; |
| 143 | - }elseif($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) { |
|
| 144 | - if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
|
| 143 | + }elseif ($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) { |
|
| 144 | + if (!empty($addon->licensing->edd_slug)) {$button_args['slug'] = $addon->licensing->edd_slug; } |
|
| 145 | 145 | $button_args['installed'] = self::is_theme_installed($addon); |
| 146 | - if(!in_array($button_args['slug'],$wp_org_themes)){ |
|
| 146 | + if (!in_array($button_args['slug'], $wp_org_themes)) { |
|
| 147 | 147 | $button_args['update_url'] = "https://wpinvoicing.com"; |
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // set price |
| 152 | - if(isset($addon->pricing) && !empty($addon->pricing)){ |
|
| 153 | - if(is_object($addon->pricing)){ |
|
| 154 | - $prices = (Array)$addon->pricing; |
|
| 152 | + if (isset($addon->pricing) && !empty($addon->pricing)) { |
|
| 153 | + if (is_object($addon->pricing)) { |
|
| 154 | + $prices = (Array) $addon->pricing; |
|
| 155 | 155 | $button_args['price'] = reset($prices); |
| 156 | - }elseif(isset($addon->pricing)){ |
|
| 156 | + }elseif (isset($addon->pricing)) { |
|
| 157 | 157 | $button_args['price'] = $addon->pricing; |
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | // set price text |
| 162 | - if( $button_args['price'] && $button_args['price'] != '0.00' ){ |
|
| 163 | - $button_args['price_text'] = sprintf( __('From: $%d', 'invoicing'), $button_args['price']); |
|
| 162 | + if ($button_args['price'] && $button_args['price'] != '0.00') { |
|
| 163 | + $button_args['price_text'] = sprintf(__('From: $%d', 'invoicing'), $button_args['price']); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | |
| 167 | 167 | // set if installed |
| 168 | - if(in_array($button_args['install_status'], array('installed','latest_installed','update_available','newer_installed'))){ |
|
| 168 | + if (in_array($button_args['install_status'], array('installed', 'latest_installed', 'update_available', 'newer_installed'))) { |
|
| 169 | 169 | $button_args['installed'] = true; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | // print_r($button_args); |
| 173 | 173 | // set if active |
| 174 | - if($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')){ |
|
| 175 | - if($button_args['type'] != 'themes'){ |
|
| 174 | + if ($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')) { |
|
| 175 | + if ($button_args['type'] != 'themes') { |
|
| 176 | 176 | $button_args['active'] = is_plugin_active($button_args['file']); |
| 177 | - }else{ |
|
| 177 | + } else { |
|
| 178 | 178 | $button_args['active'] = self::is_theme_active($addon); |
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | // set button text and class |
| 183 | - if($button_args['active']){ |
|
| 184 | - $button_args['button_text'] = __('Active','invoicing'); |
|
| 183 | + if ($button_args['active']) { |
|
| 184 | + $button_args['button_text'] = __('Active', 'invoicing'); |
|
| 185 | 185 | $button_args['class'] = ' button-secondary disabled '; |
| 186 | - }elseif($button_args['installed']){ |
|
| 187 | - $button_args['button_text'] = __('Activate','invoicing'); |
|
| 186 | + }elseif ($button_args['installed']) { |
|
| 187 | + $button_args['button_text'] = __('Activate', 'invoicing'); |
|
| 188 | 188 | |
| 189 | - if($button_args['type'] != 'themes'){ |
|
| 190 | - if ( current_user_can( 'manage_options' ) ) { |
|
| 191 | - $button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin='.$button_args['file']), 'activate-plugin_' . $button_args['file']); |
|
| 192 | - }else{ |
|
| 189 | + if ($button_args['type'] != 'themes') { |
|
| 190 | + if (current_user_can('manage_options')) { |
|
| 191 | + $button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin=' . $button_args['file']), 'activate-plugin_' . $button_args['file']); |
|
| 192 | + } else { |
|
| 193 | 193 | $button_args['url'] = '#'; |
| 194 | 194 | } |
| 195 | - }else{ |
|
| 196 | - if ( current_user_can( 'switch_themes' ) ) { |
|
| 195 | + } else { |
|
| 196 | + if (current_user_can('switch_themes')) { |
|
| 197 | 197 | $button_args['url'] = self::get_theme_activation_url($addon); |
| 198 | - }else{ |
|
| 198 | + } else { |
|
| 199 | 199 | $button_args['url'] = '#'; |
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - }else{ |
|
| 204 | - if($button_args['type'] == 'recommended_plugins'){ |
|
| 205 | - $button_args['button_text'] = __('Install','invoicing'); |
|
| 206 | - }else{ |
|
| 207 | - $button_args['button_text'] = __('Get it','invoicing'); |
|
| 203 | + } else { |
|
| 204 | + if ($button_args['type'] == 'recommended_plugins') { |
|
| 205 | + $button_args['button_text'] = __('Install', 'invoicing'); |
|
| 206 | + } else { |
|
| 207 | + $button_args['button_text'] = __('Get it', 'invoicing'); |
|
| 208 | 208 | |
| 209 | 209 | /*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){ |
| 210 | 210 | $button_args['button_text'] = __('Install','invoicing'); |
@@ -217,45 +217,45 @@ discard block |
||
| 217 | 217 | |
| 218 | 218 | |
| 219 | 219 | // filter the button arguments |
| 220 | - $button_args = apply_filters('edd_api_button_args',$button_args); |
|
| 220 | + $button_args = apply_filters('edd_api_button_args', $button_args); |
|
| 221 | 221 | // print_r($button_args); |
| 222 | 222 | // set price text |
| 223 | - if(isset($button_args['price_text'])){ |
|
| 223 | + if (isset($button_args['price_text'])) { |
|
| 224 | 224 | ?> |
| 225 | 225 | <a |
| 226 | 226 | target="_blank" |
| 227 | 227 | class="addons-price-text" |
| 228 | - href="<?php echo esc_url( $button_args['link'] ); ?>"> |
|
| 229 | - <?php echo esc_html( $button_args['price_text'] ); ?> |
|
| 228 | + href="<?php echo esc_url($button_args['link']); ?>"> |
|
| 229 | + <?php echo esc_html($button_args['price_text']); ?> |
|
| 230 | 230 | </a> |
| 231 | 231 | <?php |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | |
| 235 | 235 | $target = ''; |
| 236 | - if ( ! empty( $button_args['url'] ) ) { |
|
| 236 | + if (!empty($button_args['url'])) { |
|
| 237 | 237 | $target = strpos($button_args['url'], get_site_url()) !== false ? '' : ' target="_blank" '; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | ?> |
| 241 | 241 | <a |
| 242 | - data-licence="<?php echo esc_attr($button_args['license']);?>" |
|
| 243 | - data-licensing="<?php echo $button_args['licensing'] ? 1 : 0;?>" |
|
| 244 | - data-title="<?php echo esc_attr($button_args['title']);?>" |
|
| 245 | - data-type="<?php echo esc_attr($button_args['type']);?>" |
|
| 246 | - data-text-error-message="<?php _e('Something went wrong!','invoicing');?>" |
|
| 247 | - data-text-activate="<?php _e('Activate','invoicing');?>" |
|
| 248 | - data-text-activating="<?php _e('Activating','invoicing');?>" |
|
| 249 | - data-text-deactivate="<?php _e('Deactivate','invoicing');?>" |
|
| 250 | - data-text-installed="<?php _e('Installed','invoicing');?>" |
|
| 251 | - data-text-install="<?php _e('Install','invoicing');?>" |
|
| 252 | - data-text-installing="<?php _e('Installing','invoicing');?>" |
|
| 253 | - data-text-error="<?php _e('Error','invoicing');?>" |
|
| 254 | - <?php if(!empty($button_args['onclick'])){echo " onclick='".$button_args['onclick']."' ";}?> |
|
| 255 | - <?php echo $target;?> |
|
| 256 | - class="addons-button <?php echo esc_attr( $button_args['class'] ); ?>" |
|
| 257 | - href="<?php echo esc_url( $button_args['url'] ); ?>"> |
|
| 258 | - <?php echo esc_html( $button_args['button_text'] ); ?> |
|
| 242 | + data-licence="<?php echo esc_attr($button_args['license']); ?>" |
|
| 243 | + data-licensing="<?php echo $button_args['licensing'] ? 1 : 0; ?>" |
|
| 244 | + data-title="<?php echo esc_attr($button_args['title']); ?>" |
|
| 245 | + data-type="<?php echo esc_attr($button_args['type']); ?>" |
|
| 246 | + data-text-error-message="<?php _e('Something went wrong!', 'invoicing'); ?>" |
|
| 247 | + data-text-activate="<?php _e('Activate', 'invoicing'); ?>" |
|
| 248 | + data-text-activating="<?php _e('Activating', 'invoicing'); ?>" |
|
| 249 | + data-text-deactivate="<?php _e('Deactivate', 'invoicing'); ?>" |
|
| 250 | + data-text-installed="<?php _e('Installed', 'invoicing'); ?>" |
|
| 251 | + data-text-install="<?php _e('Install', 'invoicing'); ?>" |
|
| 252 | + data-text-installing="<?php _e('Installing', 'invoicing'); ?>" |
|
| 253 | + data-text-error="<?php _e('Error', 'invoicing'); ?>" |
|
| 254 | + <?php if (!empty($button_args['onclick'])) {echo " onclick='" . $button_args['onclick'] . "' "; }?> |
|
| 255 | + <?php echo $target; ?> |
|
| 256 | + class="addons-button <?php echo esc_attr($button_args['class']); ?>" |
|
| 257 | + href="<?php echo esc_url($button_args['url']); ?>"> |
|
| 258 | + <?php echo esc_html($button_args['button_text']); ?> |
|
| 259 | 259 | </a> |
| 260 | 260 | <?php |
| 261 | 261 | |
@@ -270,36 +270,36 @@ discard block |
||
| 270 | 270 | $tabs = self::get_tabs(); |
| 271 | 271 | $sections = self::get_sections(); |
| 272 | 272 | $theme = wp_get_theme(); |
| 273 | - $section_keys = array_keys( $sections ); |
|
| 274 | - $current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys ); |
|
| 275 | - $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
| 276 | - include_once( WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php' ); |
|
| 273 | + $section_keys = array_keys($sections); |
|
| 274 | + $current_section = isset($_GET['section']) ? sanitize_text_field($_GET['section']) : current($section_keys); |
|
| 275 | + $current_tab = empty($_GET['tab']) ? 'addons' : sanitize_title($_GET['tab']); |
|
| 276 | + include_once(WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php'); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
| 280 | 280 | * A list of recommended wp.org plugins. |
| 281 | 281 | * @return array |
| 282 | 282 | */ |
| 283 | - public function get_recommend_wp_plugins(){ |
|
| 283 | + public function get_recommend_wp_plugins() { |
|
| 284 | 284 | $plugins = array( |
| 285 | 285 | 'invoicing-quotes' => array( |
| 286 | 286 | 'url' => 'https://wordpress.org/plugins/invoicing-quotes/', |
| 287 | 287 | 'slug' => 'invoicing-quotes', |
| 288 | 288 | 'name' => 'Quotes', |
| 289 | 289 | 'thumbnail' => 'https://ps.w.org/invoicing-quotes/assets/banner-772x250.png', |
| 290 | - 'desc' => __('Allows you to create quotes, send them to clients and convert them to Invoices when accepted by the customer.','invoicing'), |
|
| 290 | + 'desc' => __('Allows you to create quotes, send them to clients and convert them to Invoices when accepted by the customer.', 'invoicing'), |
|
| 291 | 291 | ), |
| 292 | 292 | 'geodirectory' => array( |
| 293 | 293 | 'url' => 'https://wordpress.org/plugins/geodirectory/', |
| 294 | 294 | 'slug' => 'geodirectory', |
| 295 | 295 | 'name' => 'GeoDirectory', |
| 296 | - 'desc' => __('Turn any WordPress theme into a global business directory portal.','invoicing'), |
|
| 296 | + 'desc' => __('Turn any WordPress theme into a global business directory portal.', 'invoicing'), |
|
| 297 | 297 | ), |
| 298 | 298 | 'userswp' => array( |
| 299 | 299 | 'url' => 'https://wordpress.org/plugins/userswp/', |
| 300 | 300 | 'slug' => 'userswp', |
| 301 | 301 | 'name' => 'UsersWP', |
| 302 | - 'desc' => __('Allow frontend user login and registration as well as have slick profile pages.','invoicing'), |
|
| 302 | + 'desc' => __('Allow frontend user login and registration as well as have slick profile pages.', 'invoicing'), |
|
| 303 | 303 | ), |
| 304 | 304 | ); |
| 305 | 305 | |
@@ -12,14 +12,14 @@ discard block |
||
| 12 | 12 | /** |
| 13 | 13 | * Bail if we are not in WP. |
| 14 | 14 | */ |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if (!defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * Only add if the class does not already exist. |
| 21 | 21 | */ |
| 22 | -if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) { |
|
| 22 | +if (!class_exists('WP_Font_Awesome_Settings')) { |
|
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * A Class to be able to change settings for Font Awesome. |
@@ -88,17 +88,17 @@ discard block |
||
| 88 | 88 | * @return WP_Font_Awesome_Settings - Main instance. |
| 89 | 89 | */ |
| 90 | 90 | public static function instance() { |
| 91 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) { |
|
| 91 | + if (!isset(self::$instance) && !(self::$instance instanceof WP_Font_Awesome_Settings)) { |
|
| 92 | 92 | self::$instance = new WP_Font_Awesome_Settings; |
| 93 | 93 | |
| 94 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
| 94 | + add_action('init', array(self::$instance, 'init')); // set settings |
|
| 95 | 95 | |
| 96 | - if ( is_admin() ) { |
|
| 97 | - add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
| 98 | - add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
| 96 | + if (is_admin()) { |
|
| 97 | + add_action('admin_menu', array(self::$instance, 'menu_item')); |
|
| 98 | + add_action('admin_init', array(self::$instance, 'register_settings')); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - do_action( 'wp_font_awesome_settings_loaded' ); |
|
| 101 | + do_action('wp_font_awesome_settings_loaded'); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | return self::$instance; |
@@ -112,30 +112,30 @@ discard block |
||
| 112 | 112 | public function init() { |
| 113 | 113 | $this->settings = $this->get_settings(); |
| 114 | 114 | |
| 115 | - if ( $this->settings['type'] == 'CSS' ) { |
|
| 115 | + if ($this->settings['type'] == 'CSS') { |
|
| 116 | 116 | |
| 117 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) { |
|
| 118 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 ); |
|
| 117 | + if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') { |
|
| 118 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), 5000); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) { |
|
| 122 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 ); |
|
| 121 | + if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') { |
|
| 122 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 5000); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | } else { |
| 126 | 126 | |
| 127 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) { |
|
| 128 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 ); |
|
| 127 | + if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') { |
|
| 128 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 5000); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) { |
|
| 132 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 ); |
|
| 131 | + if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') { |
|
| 132 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 5000); |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // remove font awesome if set to do so |
| 137 | - if ( $this->settings['dequeue'] == '1' ) { |
|
| 138 | - add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 ); |
|
| 137 | + if ($this->settings['dequeue'] == '1') { |
|
| 138 | + add_action('clean_url', array($this, 'remove_font_awesome'), 5000, 3); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | } |
@@ -147,20 +147,20 @@ discard block |
||
| 147 | 147 | // build url |
| 148 | 148 | $url = $this->get_url(); |
| 149 | 149 | |
| 150 | - wp_deregister_style( 'font-awesome' ); // deregister in case its already there |
|
| 151 | - wp_register_style( 'font-awesome', $url, array(), null ); |
|
| 152 | - wp_enqueue_style( 'font-awesome' ); |
|
| 150 | + wp_deregister_style('font-awesome'); // deregister in case its already there |
|
| 151 | + wp_register_style('font-awesome', $url, array(), null); |
|
| 152 | + wp_enqueue_style('font-awesome'); |
|
| 153 | 153 | |
| 154 | 154 | // RTL language support CSS. |
| 155 | - if ( is_rtl() ) { |
|
| 156 | - wp_add_inline_style( 'font-awesome', $this->rtl_inline_css() ); |
|
| 155 | + if (is_rtl()) { |
|
| 156 | + wp_add_inline_style('font-awesome', $this->rtl_inline_css()); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if ( $this->settings['shims'] ) { |
|
| 160 | - $url = $this->get_url( true ); |
|
| 161 | - wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there |
|
| 162 | - wp_register_style( 'font-awesome-shims', $url, array(), null ); |
|
| 163 | - wp_enqueue_style( 'font-awesome-shims' ); |
|
| 159 | + if ($this->settings['shims']) { |
|
| 160 | + $url = $this->get_url(true); |
|
| 161 | + wp_deregister_style('font-awesome-shims'); // deregister in case its already there |
|
| 162 | + wp_register_style('font-awesome-shims', $url, array(), null); |
|
| 163 | + wp_enqueue_style('font-awesome-shims'); |
|
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | |
@@ -172,15 +172,15 @@ discard block |
||
| 172 | 172 | $url = $this->get_url(); |
| 173 | 173 | |
| 174 | 174 | $deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script'; |
| 175 | - call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there |
|
| 176 | - wp_register_script( 'font-awesome', $url, array(), null ); |
|
| 177 | - wp_enqueue_script( 'font-awesome' ); |
|
| 178 | - |
|
| 179 | - if ( $this->settings['shims'] ) { |
|
| 180 | - $url = $this->get_url( true ); |
|
| 181 | - call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there |
|
| 182 | - wp_register_script( 'font-awesome-shims', $url, array(), null ); |
|
| 183 | - wp_enqueue_script( 'font-awesome-shims' ); |
|
| 175 | + call_user_func($deregister_function, 'font-awesome'); // deregister in case its already there |
|
| 176 | + wp_register_script('font-awesome', $url, array(), null); |
|
| 177 | + wp_enqueue_script('font-awesome'); |
|
| 178 | + |
|
| 179 | + if ($this->settings['shims']) { |
|
| 180 | + $url = $this->get_url(true); |
|
| 181 | + call_user_func($deregister_function, 'font-awesome-shims'); // deregister in case its already there |
|
| 182 | + wp_register_script('font-awesome-shims', $url, array(), null); |
|
| 183 | + wp_enqueue_script('font-awesome-shims'); |
|
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | |
@@ -191,16 +191,16 @@ discard block |
||
| 191 | 191 | * |
| 192 | 192 | * @return string The url to the file. |
| 193 | 193 | */ |
| 194 | - public function get_url( $shims = false ) { |
|
| 194 | + public function get_url($shims = false) { |
|
| 195 | 195 | $script = $shims ? 'v4-shims' : 'all'; |
| 196 | 196 | $sub = $this->settings['pro'] ? 'pro' : 'use'; |
| 197 | 197 | $type = $this->settings['type']; |
| 198 | 198 | $version = $this->settings['version']; |
| 199 | - $kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : ''; |
|
| 199 | + $kit_url = $this->settings['kit-url'] ? esc_url($this->settings['kit-url']) : ''; |
|
| 200 | 200 | $url = ''; |
| 201 | 201 | |
| 202 | - if ( $type == 'KIT' && $kit_url ) { |
|
| 203 | - if ( $shims ) { |
|
| 202 | + if ($type == 'KIT' && $kit_url) { |
|
| 203 | + if ($shims) { |
|
| 204 | 204 | // if its a kit then we don't add shims here |
| 205 | 205 | return ''; |
| 206 | 206 | } |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | $url .= "?wpfas=true"; // set our var so our version is not removed |
| 209 | 209 | } else { |
| 210 | 210 | $url .= "https://$sub.fontawesome.com/releases/"; // CDN |
| 211 | - $url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version |
|
| 211 | + $url .= !empty($version) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version |
|
| 212 | 212 | $url .= $type == 'CSS' ? 'css/' : 'js/'; // type |
| 213 | 213 | $url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type |
| 214 | 214 | $url .= "?wpfas=true"; // set our var so our version is not removed |
@@ -228,16 +228,16 @@ discard block |
||
| 228 | 228 | * |
| 229 | 229 | * @return string The filtered url. |
| 230 | 230 | */ |
| 231 | - public function remove_font_awesome( $url, $original_url, $_context ) { |
|
| 231 | + public function remove_font_awesome($url, $original_url, $_context) { |
|
| 232 | 232 | |
| 233 | - if ( $_context == 'display' |
|
| 234 | - && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false ) |
|
| 235 | - && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false ) |
|
| 233 | + if ($_context == 'display' |
|
| 234 | + && (strstr($url, "fontawesome") !== false || strstr($url, "font-awesome") !== false) |
|
| 235 | + && (strstr($url, ".js") !== false || strstr($url, ".css") !== false) |
|
| 236 | 236 | ) {// it's a font-awesome-url (probably) |
| 237 | 237 | |
| 238 | - if ( strstr( $url, "wpfas=true" ) !== false ) { |
|
| 239 | - if ( $this->settings['type'] == 'JS' ) { |
|
| 240 | - if ( $this->settings['js-pseudo'] ) { |
|
| 238 | + if (strstr($url, "wpfas=true") !== false) { |
|
| 239 | + if ($this->settings['type'] == 'JS') { |
|
| 240 | + if ($this->settings['js-pseudo']) { |
|
| 241 | 241 | $url .= "' data-search-pseudo-elements defer='defer"; |
| 242 | 242 | } else { |
| 243 | 243 | $url .= "' defer='defer"; |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | * Register the database settings with WordPress. |
| 257 | 257 | */ |
| 258 | 258 | public function register_settings() { |
| 259 | - register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' ); |
|
| 259 | + register_setting('wp-font-awesome-settings', 'wp-font-awesome-settings'); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | /** |
@@ -265,10 +265,10 @@ discard block |
||
| 265 | 265 | */ |
| 266 | 266 | public function menu_item() { |
| 267 | 267 | $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
| 268 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array( |
|
| 268 | + call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array( |
|
| 269 | 269 | $this, |
| 270 | 270 | 'settings_page' |
| 271 | - ) ); |
|
| 271 | + )); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | /** |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | */ |
| 279 | 279 | public function get_settings() { |
| 280 | 280 | |
| 281 | - $db_settings = get_option( 'wp-font-awesome-settings' ); |
|
| 281 | + $db_settings = get_option('wp-font-awesome-settings'); |
|
| 282 | 282 | |
| 283 | 283 | $defaults = array( |
| 284 | 284 | 'type' => 'CSS', // type to use, CSS or JS or KIT |
@@ -291,14 +291,14 @@ discard block |
||
| 291 | 291 | 'kit-url' => '', // the kit url |
| 292 | 292 | ); |
| 293 | 293 | |
| 294 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
| 294 | + $settings = wp_parse_args($db_settings, $defaults); |
|
| 295 | 295 | |
| 296 | 296 | /** |
| 297 | 297 | * Filter the Font Awesome settings. |
| 298 | 298 | * |
| 299 | 299 | * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
| 300 | 300 | */ |
| 301 | - return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults ); |
|
| 301 | + return $this->settings = apply_filters('wp-font-awesome-settings', $settings, $db_settings, $defaults); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | |
@@ -306,13 +306,13 @@ discard block |
||
| 306 | 306 | * The settings page html output. |
| 307 | 307 | */ |
| 308 | 308 | public function settings_page() { |
| 309 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 310 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) ); |
|
| 309 | + if (!current_user_can('manage_options')) { |
|
| 310 | + wp_die(__('You do not have sufficient permissions to access this page.', 'font-awesome-settings')); |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | // a hidden way to force the update of the version number via api instead of waiting the 48 hours |
| 314 | - if ( isset( $_REQUEST['force-version-check'] ) ) { |
|
| 315 | - $this->get_latest_version( $force_api = true ); |
|
| 314 | + if (isset($_REQUEST['force-version-check'])) { |
|
| 315 | + $this->get_latest_version($force_api = true); |
|
| 316 | 316 | } |
| 317 | 317 | ?> |
| 318 | 318 | <style> |
@@ -332,37 +332,37 @@ discard block |
||
| 332 | 332 | <h1><?php echo $this->name; ?></h1> |
| 333 | 333 | <form method="post" action="options.php"> |
| 334 | 334 | <?php |
| 335 | - settings_fields( 'wp-font-awesome-settings' ); |
|
| 336 | - do_settings_sections( 'wp-font-awesome-settings' ); |
|
| 335 | + settings_fields('wp-font-awesome-settings'); |
|
| 336 | + do_settings_sections('wp-font-awesome-settings'); |
|
| 337 | 337 | $kit_set = $this->settings['type'] == 'KIT' ? 'wpfas-kit-set' : ''; |
| 338 | 338 | ?> |
| 339 | - <table class="form-table wpfas-table-settings <?php echo esc_attr( $kit_set ); ?>"> |
|
| 339 | + <table class="form-table wpfas-table-settings <?php echo esc_attr($kit_set); ?>"> |
|
| 340 | 340 | <tr valign="top"> |
| 341 | 341 | <th scope="row"><label |
| 342 | - for="wpfas-type"><?php _e( 'Type', 'font-awesome-settings' ); ?></label></th> |
|
| 342 | + for="wpfas-type"><?php _e('Type', 'font-awesome-settings'); ?></label></th> |
|
| 343 | 343 | <td> |
| 344 | 344 | <select name="wp-font-awesome-settings[type]" id="wpfas-type" |
| 345 | 345 | onchange="if(this.value=='KIT'){jQuery('.wpfas-table-settings').addClass('wpfas-kit-set');}else{jQuery('.wpfas-table-settings').removeClass('wpfas-kit-set');}"> |
| 346 | 346 | <option |
| 347 | - value="CSS" <?php selected( $this->settings['type'], 'CSS' ); ?>><?php _e( 'CSS (default)', 'font-awesome-settings' ); ?></option> |
|
| 348 | - <option value="JS" <?php selected( $this->settings['type'], 'JS' ); ?>>JS</option> |
|
| 347 | + value="CSS" <?php selected($this->settings['type'], 'CSS'); ?>><?php _e('CSS (default)', 'font-awesome-settings'); ?></option> |
|
| 348 | + <option value="JS" <?php selected($this->settings['type'], 'JS'); ?>>JS</option> |
|
| 349 | 349 | <option |
| 350 | - value="KIT" <?php selected( $this->settings['type'], 'KIT' ); ?>><?php _e( 'Kits (settings managed on fontawesome.com)', 'font-awesome-settings' ); ?></option> |
|
| 350 | + value="KIT" <?php selected($this->settings['type'], 'KIT'); ?>><?php _e('Kits (settings managed on fontawesome.com)', 'font-awesome-settings'); ?></option> |
|
| 351 | 351 | </select> |
| 352 | 352 | </td> |
| 353 | 353 | </tr> |
| 354 | 354 | |
| 355 | 355 | <tr valign="top" class="wpfas-kit-show"> |
| 356 | 356 | <th scope="row"><label |
| 357 | - for="wpfas-kit-url"><?php _e( 'Kit URL', 'font-awesome-settings' ); ?></label></th> |
|
| 357 | + for="wpfas-kit-url"><?php _e('Kit URL', 'font-awesome-settings'); ?></label></th> |
|
| 358 | 358 | <td> |
| 359 | 359 | <input class="regular-text" id="wpfas-kit-url" type="url" |
| 360 | 360 | name="wp-font-awesome-settings[kit-url]" |
| 361 | - value="<?php echo esc_attr( $this->settings['kit-url'] ); ?>" |
|
| 362 | - placeholder="<?php echo 'https://kit.font';echo 'awesome.com/123abc.js'; // this won't pass theme check :(?>"/> |
|
| 361 | + value="<?php echo esc_attr($this->settings['kit-url']); ?>" |
|
| 362 | + placeholder="<?php echo 'https://kit.font'; echo 'awesome.com/123abc.js'; // this won't pass theme check :(?>"/> |
|
| 363 | 363 | <span><?php |
| 364 | 364 | echo sprintf( |
| 365 | - __( 'Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings' ), |
|
| 365 | + __('Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings'), |
|
| 366 | 366 | '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>', |
| 367 | 367 | '</a>' |
| 368 | 368 | ); |
@@ -372,31 +372,31 @@ discard block |
||
| 372 | 372 | |
| 373 | 373 | <tr valign="top" class="wpfas-kit-hide"> |
| 374 | 374 | <th scope="row"><label |
| 375 | - for="wpfas-version"><?php _e( 'Version', 'font-awesome-settings' ); ?></label></th> |
|
| 375 | + for="wpfas-version"><?php _e('Version', 'font-awesome-settings'); ?></label></th> |
|
| 376 | 376 | <td> |
| 377 | 377 | <select name="wp-font-awesome-settings[version]" id="wpfas-version"> |
| 378 | 378 | <option |
| 379 | - value="" <?php selected( $this->settings['version'], '' ); ?>><?php echo sprintf( __( 'Latest - %s (default)', 'font-awesome-settings' ), $this->get_latest_version() ); ?> |
|
| 379 | + value="" <?php selected($this->settings['version'], ''); ?>><?php echo sprintf(__('Latest - %s (default)', 'font-awesome-settings'), $this->get_latest_version()); ?> |
|
| 380 | 380 | </option> |
| 381 | - <option value="5.6.0" <?php selected( $this->settings['version'], '5.6.0' ); ?>> |
|
| 381 | + <option value="5.6.0" <?php selected($this->settings['version'], '5.6.0'); ?>> |
|
| 382 | 382 | 5.6.0 |
| 383 | 383 | </option> |
| 384 | - <option value="5.5.0" <?php selected( $this->settings['version'], '5.5.0' ); ?>> |
|
| 384 | + <option value="5.5.0" <?php selected($this->settings['version'], '5.5.0'); ?>> |
|
| 385 | 385 | 5.5.0 |
| 386 | 386 | </option> |
| 387 | - <option value="5.4.0" <?php selected( $this->settings['version'], '5.4.0' ); ?>> |
|
| 387 | + <option value="5.4.0" <?php selected($this->settings['version'], '5.4.0'); ?>> |
|
| 388 | 388 | 5.4.0 |
| 389 | 389 | </option> |
| 390 | - <option value="5.3.0" <?php selected( $this->settings['version'], '5.3.0' ); ?>> |
|
| 390 | + <option value="5.3.0" <?php selected($this->settings['version'], '5.3.0'); ?>> |
|
| 391 | 391 | 5.3.0 |
| 392 | 392 | </option> |
| 393 | - <option value="5.2.0" <?php selected( $this->settings['version'], '5.2.0' ); ?>> |
|
| 393 | + <option value="5.2.0" <?php selected($this->settings['version'], '5.2.0'); ?>> |
|
| 394 | 394 | 5.2.0 |
| 395 | 395 | </option> |
| 396 | - <option value="5.1.0" <?php selected( $this->settings['version'], '5.1.0' ); ?>> |
|
| 396 | + <option value="5.1.0" <?php selected($this->settings['version'], '5.1.0'); ?>> |
|
| 397 | 397 | 5.1.0 |
| 398 | 398 | </option> |
| 399 | - <option value="4.7.0" <?php selected( $this->settings['version'], '4.7.0' ); ?>> |
|
| 399 | + <option value="4.7.0" <?php selected($this->settings['version'], '4.7.0'); ?>> |
|
| 400 | 400 | 4.7.1 (CSS only) |
| 401 | 401 | </option> |
| 402 | 402 | </select> |
@@ -405,29 +405,29 @@ discard block |
||
| 405 | 405 | |
| 406 | 406 | <tr valign="top"> |
| 407 | 407 | <th scope="row"><label |
| 408 | - for="wpfas-enqueue"><?php _e( 'Enqueue', 'font-awesome-settings' ); ?></label></th> |
|
| 408 | + for="wpfas-enqueue"><?php _e('Enqueue', 'font-awesome-settings'); ?></label></th> |
|
| 409 | 409 | <td> |
| 410 | 410 | <select name="wp-font-awesome-settings[enqueue]" id="wpfas-enqueue"> |
| 411 | 411 | <option |
| 412 | - value="" <?php selected( $this->settings['enqueue'], '' ); ?>><?php _e( 'Frontend + Backend (default)', 'font-awesome-settings' ); ?></option> |
|
| 412 | + value="" <?php selected($this->settings['enqueue'], ''); ?>><?php _e('Frontend + Backend (default)', 'font-awesome-settings'); ?></option> |
|
| 413 | 413 | <option |
| 414 | - value="frontend" <?php selected( $this->settings['enqueue'], 'frontend' ); ?>><?php _e( 'Frontend', 'font-awesome-settings' ); ?></option> |
|
| 414 | + value="frontend" <?php selected($this->settings['enqueue'], 'frontend'); ?>><?php _e('Frontend', 'font-awesome-settings'); ?></option> |
|
| 415 | 415 | <option |
| 416 | - value="backend" <?php selected( $this->settings['enqueue'], 'backend' ); ?>><?php _e( 'Backend', 'font-awesome-settings' ); ?></option> |
|
| 416 | + value="backend" <?php selected($this->settings['enqueue'], 'backend'); ?>><?php _e('Backend', 'font-awesome-settings'); ?></option> |
|
| 417 | 417 | </select> |
| 418 | 418 | </td> |
| 419 | 419 | </tr> |
| 420 | 420 | |
| 421 | 421 | <tr valign="top" class="wpfas-kit-hide"> |
| 422 | 422 | <th scope="row"><label |
| 423 | - for="wpfas-pro"><?php _e( 'Enable pro', 'font-awesome-settings' ); ?></label></th> |
|
| 423 | + for="wpfas-pro"><?php _e('Enable pro', 'font-awesome-settings'); ?></label></th> |
|
| 424 | 424 | <td> |
| 425 | 425 | <input type="hidden" name="wp-font-awesome-settings[pro]" value="0"/> |
| 426 | 426 | <input type="checkbox" name="wp-font-awesome-settings[pro]" |
| 427 | - value="1" <?php checked( $this->settings['pro'], '1' ); ?> id="wpfas-pro"/> |
|
| 427 | + value="1" <?php checked($this->settings['pro'], '1'); ?> id="wpfas-pro"/> |
|
| 428 | 428 | <span><?php |
| 429 | 429 | echo sprintf( |
| 430 | - __( 'Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings' ), |
|
| 430 | + __('Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings'), |
|
| 431 | 431 | '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/pro"><i class="fas fa-external-link-alt"></i>', |
| 432 | 432 | '</a>', |
| 433 | 433 | '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn"><i class="fas fa-external-link-alt"></i>', |
@@ -439,38 +439,38 @@ discard block |
||
| 439 | 439 | |
| 440 | 440 | <tr valign="top" class="wpfas-kit-hide"> |
| 441 | 441 | <th scope="row"><label |
| 442 | - for="wpfas-shims"><?php _e( 'Enable v4 shims compatibility', 'font-awesome-settings' ); ?></label> |
|
| 442 | + for="wpfas-shims"><?php _e('Enable v4 shims compatibility', 'font-awesome-settings'); ?></label> |
|
| 443 | 443 | </th> |
| 444 | 444 | <td> |
| 445 | 445 | <input type="hidden" name="wp-font-awesome-settings[shims]" value="0"/> |
| 446 | 446 | <input type="checkbox" name="wp-font-awesome-settings[shims]" |
| 447 | - value="1" <?php checked( $this->settings['shims'], '1' ); ?> id="wpfas-shims"/> |
|
| 448 | - <span><?php _e( 'This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'font-awesome-settings' ); ?></span> |
|
| 447 | + value="1" <?php checked($this->settings['shims'], '1'); ?> id="wpfas-shims"/> |
|
| 448 | + <span><?php _e('This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'font-awesome-settings'); ?></span> |
|
| 449 | 449 | </td> |
| 450 | 450 | </tr> |
| 451 | 451 | |
| 452 | 452 | <tr valign="top" class="wpfas-kit-hide"> |
| 453 | 453 | <th scope="row"><label |
| 454 | - for="wpfas-js-pseudo"><?php _e( 'Enable JS pseudo elements (not recommended)', 'font-awesome-settings' ); ?></label> |
|
| 454 | + for="wpfas-js-pseudo"><?php _e('Enable JS pseudo elements (not recommended)', 'font-awesome-settings'); ?></label> |
|
| 455 | 455 | </th> |
| 456 | 456 | <td> |
| 457 | 457 | <input type="hidden" name="wp-font-awesome-settings[js-pseudo]" value="0"/> |
| 458 | 458 | <input type="checkbox" name="wp-font-awesome-settings[js-pseudo]" |
| 459 | - value="1" <?php checked( $this->settings['js-pseudo'], '1' ); ?> |
|
| 459 | + value="1" <?php checked($this->settings['js-pseudo'], '1'); ?> |
|
| 460 | 460 | id="wpfas-js-pseudo"/> |
| 461 | - <span><?php _e( 'Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'font-awesome-settings' ); ?></span> |
|
| 461 | + <span><?php _e('Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'font-awesome-settings'); ?></span> |
|
| 462 | 462 | </td> |
| 463 | 463 | </tr> |
| 464 | 464 | |
| 465 | 465 | <tr valign="top"> |
| 466 | 466 | <th scope="row"><label |
| 467 | - for="wpfas-dequeue"><?php _e( 'Dequeue', 'font-awesome-settings' ); ?></label></th> |
|
| 467 | + for="wpfas-dequeue"><?php _e('Dequeue', 'font-awesome-settings'); ?></label></th> |
|
| 468 | 468 | <td> |
| 469 | 469 | <input type="hidden" name="wp-font-awesome-settings[dequeue]" value="0"/> |
| 470 | 470 | <input type="checkbox" name="wp-font-awesome-settings[dequeue]" |
| 471 | - value="1" <?php checked( $this->settings['dequeue'], '1' ); ?> |
|
| 471 | + value="1" <?php checked($this->settings['dequeue'], '1'); ?> |
|
| 472 | 472 | id="wpfas-dequeue"/> |
| 473 | - <span><?php _e( 'This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'font-awesome-settings' ); ?></span> |
|
| 473 | + <span><?php _e('This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'font-awesome-settings'); ?></span> |
|
| 474 | 474 | </td> |
| 475 | 475 | </tr> |
| 476 | 476 | |
@@ -495,12 +495,12 @@ discard block |
||
| 495 | 495 | * |
| 496 | 496 | * @return string Either a valid version number or an empty string. |
| 497 | 497 | */ |
| 498 | - public function validate_version_number( $version ) { |
|
| 498 | + public function validate_version_number($version) { |
|
| 499 | 499 | |
| 500 | - if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) { |
|
| 500 | + if (version_compare($version, '0.0.1', '>=') >= 0) { |
|
| 501 | 501 | // valid |
| 502 | 502 | } else { |
| 503 | - $version = '';// not validated |
|
| 503 | + $version = ''; // not validated |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | return $version; |
@@ -515,19 +515,19 @@ discard block |
||
| 515 | 515 | * @since 1.0.7 |
| 516 | 516 | * @return mixed|string The latest version number found. |
| 517 | 517 | */ |
| 518 | - public function get_latest_version( $force_api = false ) { |
|
| 518 | + public function get_latest_version($force_api = false) { |
|
| 519 | 519 | $latest_version = $this->latest; |
| 520 | 520 | |
| 521 | - $cache = get_transient( 'wp-font-awesome-settings-version' ); |
|
| 521 | + $cache = get_transient('wp-font-awesome-settings-version'); |
|
| 522 | 522 | |
| 523 | - if ( $cache === false || $force_api ) { // its not set |
|
| 523 | + if ($cache === false || $force_api) { // its not set |
|
| 524 | 524 | $api_ver = $this->get_latest_version_from_api(); |
| 525 | - if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) { |
|
| 525 | + if (version_compare($api_ver, $this->latest, '>=') >= 0) { |
|
| 526 | 526 | $latest_version = $api_ver; |
| 527 | - set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS ); |
|
| 527 | + set_transient('wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS); |
|
| 528 | 528 | } |
| 529 | - } elseif ( $this->validate_version_number( $cache ) ) { |
|
| 530 | - if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) { |
|
| 529 | + } elseif ($this->validate_version_number($cache)) { |
|
| 530 | + if (version_compare($cache, $this->latest, '>=') >= 0) { |
|
| 531 | 531 | $latest_version = $cache; |
| 532 | 532 | } |
| 533 | 533 | } |
@@ -543,10 +543,10 @@ discard block |
||
| 543 | 543 | */ |
| 544 | 544 | public function get_latest_version_from_api() { |
| 545 | 545 | $version = "0"; |
| 546 | - $response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" ); |
|
| 547 | - if ( ! is_wp_error( $response ) && is_array( $response ) ) { |
|
| 548 | - $api_response = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
| 549 | - if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) { |
|
| 546 | + $response = wp_remote_get("https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest"); |
|
| 547 | + if (!is_wp_error($response) && is_array($response)) { |
|
| 548 | + $api_response = json_decode(wp_remote_retrieve_body($response), true); |
|
| 549 | + if (isset($api_response['tag_name']) && version_compare($api_response['tag_name'], $this->latest, '>=') >= 0 && empty($api_response['prerelease'])) { |
|
| 550 | 550 | $version = $api_response['tag_name']; |
| 551 | 551 | } |
| 552 | 552 | } |
@@ -7,15 +7,15 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | function wpinv_get_default_country() { |
| 16 | - $country = wpinv_get_option( 'default_country', 'UK' ); |
|
| 16 | + $country = wpinv_get_option('default_country', 'UK'); |
|
| 17 | 17 | |
| 18 | - return apply_filters( 'wpinv_default_country', $country ); |
|
| 18 | + return apply_filters('wpinv_default_country', $country); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -23,8 +23,8 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return string |
| 25 | 25 | */ |
| 26 | -function getpaid_get_ip_country( $ip_address = '' ) { |
|
| 27 | - $country = GetPaid_Geolocation::geolocate_ip( $ip_address, true ); |
|
| 26 | +function getpaid_get_ip_country($ip_address = '') { |
|
| 27 | + $country = GetPaid_Geolocation::geolocate_ip($ip_address, true); |
|
| 28 | 28 | return $country['country']; |
| 29 | 29 | } |
| 30 | 30 | |
@@ -34,59 +34,59 @@ discard block |
||
| 34 | 34 | * @param string $country The country code to sanitize |
| 35 | 35 | * @return array |
| 36 | 36 | */ |
| 37 | -function wpinv_sanitize_country( $country ) { |
|
| 37 | +function wpinv_sanitize_country($country) { |
|
| 38 | 38 | |
| 39 | 39 | // Enure the country is specified |
| 40 | - if ( empty( $country ) ) { |
|
| 40 | + if (empty($country)) { |
|
| 41 | 41 | $country = wpinv_get_default_country(); |
| 42 | 42 | } |
| 43 | - return trim( wpinv_utf8_strtoupper( $country ) ); |
|
| 43 | + return trim(wpinv_utf8_strtoupper($country)); |
|
| 44 | 44 | |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | -function wpinv_is_base_country( $country ) { |
|
| 47 | +function wpinv_is_base_country($country) { |
|
| 48 | 48 | $base_country = wpinv_get_default_country(); |
| 49 | 49 | |
| 50 | - if ( $base_country === 'UK' ) { |
|
| 50 | + if ($base_country === 'UK') { |
|
| 51 | 51 | $base_country = 'GB'; |
| 52 | 52 | } |
| 53 | - if ( $country == 'UK' ) { |
|
| 53 | + if ($country == 'UK') { |
|
| 54 | 54 | $country = 'GB'; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - return ( $country && $country === $base_country ) ? true : false; |
|
| 57 | + return ($country && $country === $base_country) ? true : false; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | -function wpinv_country_name( $country_code = '' ) { |
|
| 60 | +function wpinv_country_name($country_code = '') { |
|
| 61 | 61 | $countries = wpinv_get_country_list(); |
| 62 | 62 | $country_code = $country_code == 'UK' ? 'GB' : $country_code; |
| 63 | - $country = isset( $countries[$country_code] ) ? $countries[$country_code] : $country_code; |
|
| 63 | + $country = isset($countries[$country_code]) ? $countries[$country_code] : $country_code; |
|
| 64 | 64 | |
| 65 | - return apply_filters( 'wpinv_country_name', $country, $country_code ); |
|
| 65 | + return apply_filters('wpinv_country_name', $country, $country_code); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | function wpinv_get_default_state() { |
| 69 | - $state = wpinv_get_option( 'default_state', '' ); |
|
| 69 | + $state = wpinv_get_option('default_state', ''); |
|
| 70 | 70 | |
| 71 | - return apply_filters( 'wpinv_default_state', $state ); |
|
| 71 | + return apply_filters('wpinv_default_state', $state); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | -function wpinv_state_name( $state_code = '', $country_code = '' ) { |
|
| 74 | +function wpinv_state_name($state_code = '', $country_code = '') { |
|
| 75 | 75 | $state = $state_code; |
| 76 | 76 | |
| 77 | - if ( !empty( $country_code ) ) { |
|
| 78 | - $states = wpinv_get_country_states( $country_code ); |
|
| 77 | + if (!empty($country_code)) { |
|
| 78 | + $states = wpinv_get_country_states($country_code); |
|
| 79 | 79 | |
| 80 | - $state = !empty( $states ) && isset( $states[$state_code] ) ? $states[$state_code] : $state; |
|
| 80 | + $state = !empty($states) && isset($states[$state_code]) ? $states[$state_code] : $state; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - return apply_filters( 'wpinv_state_name', $state, $state_code, $country_code ); |
|
| 83 | + return apply_filters('wpinv_state_name', $state, $state_code, $country_code); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | function wpinv_store_address() { |
| 87 | - $address = wpinv_get_option( 'store_address', '' ); |
|
| 87 | + $address = wpinv_get_option('store_address', ''); |
|
| 88 | 88 | |
| 89 | - return apply_filters( 'wpinv_store_address', $address ); |
|
| 89 | + return apply_filters('wpinv_store_address', $address); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -94,24 +94,24 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @param WPInv_Invoice $invoice |
| 96 | 96 | */ |
| 97 | -function getpaid_maybe_add_default_address( &$invoice ) { |
|
| 97 | +function getpaid_maybe_add_default_address(&$invoice) { |
|
| 98 | 98 | |
| 99 | 99 | $user_id = $invoice->get_user_id(); |
| 100 | 100 | |
| 101 | 101 | // Abort if the invoice belongs to no one. |
| 102 | - if ( empty( $user_id ) ) { |
|
| 102 | + if (empty($user_id)) { |
|
| 103 | 103 | return; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | // Fill in defaults whenever necessary. |
| 107 | - foreach ( wpinv_get_user_address( $user_id ) as $key => $value ) { |
|
| 107 | + foreach (wpinv_get_user_address($user_id) as $key => $value) { |
|
| 108 | 108 | |
| 109 | - if ( is_callable( $invoice, "get_$key" ) ) { |
|
| 110 | - $current = call_user_func( array( $invoice, "get_$key" ) ); |
|
| 109 | + if (is_callable($invoice, "get_$key")) { |
|
| 110 | + $current = call_user_func(array($invoice, "get_$key")); |
|
| 111 | 111 | |
| 112 | - if ( empty( $current ) ) { |
|
| 112 | + if (empty($current)) { |
|
| 113 | 113 | $method = "set_$key"; |
| 114 | - $invoice->$method( $value ); |
|
| 114 | + $invoice->$method($value); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | } |
@@ -130,22 +130,22 @@ discard block |
||
| 130 | 130 | $address_fields = apply_filters( |
| 131 | 131 | 'getpaid_user_address_fields', |
| 132 | 132 | array( |
| 133 | - 'first_name' => __( 'First Name', 'invoicing' ), |
|
| 134 | - 'last_name' => __( 'Last Name', 'invoicing' ), |
|
| 135 | - 'address' => __( 'Address', 'invoicing' ), |
|
| 136 | - 'city' => __( 'City', 'invoicing' ), |
|
| 137 | - 'country' => __( 'Country', 'invoicing' ), |
|
| 138 | - 'state' => __( 'State', 'invoicing' ), |
|
| 139 | - 'zip' => __( 'Zip/Postal Code', 'invoicing' ), |
|
| 140 | - 'phone' => __( 'Phone Number', 'invoicing' ), |
|
| 141 | - 'company' => __( 'Company', 'invoicing' ), |
|
| 142 | - 'company_id' => __( 'Company ID', 'invoicing' ), |
|
| 143 | - 'vat_number' => __( 'VAT Number', 'invoicing' ), |
|
| 133 | + 'first_name' => __('First Name', 'invoicing'), |
|
| 134 | + 'last_name' => __('Last Name', 'invoicing'), |
|
| 135 | + 'address' => __('Address', 'invoicing'), |
|
| 136 | + 'city' => __('City', 'invoicing'), |
|
| 137 | + 'country' => __('Country', 'invoicing'), |
|
| 138 | + 'state' => __('State', 'invoicing'), |
|
| 139 | + 'zip' => __('Zip/Postal Code', 'invoicing'), |
|
| 140 | + 'phone' => __('Phone Number', 'invoicing'), |
|
| 141 | + 'company' => __('Company', 'invoicing'), |
|
| 142 | + 'company_id' => __('Company ID', 'invoicing'), |
|
| 143 | + 'vat_number' => __('VAT Number', 'invoicing'), |
|
| 144 | 144 | ) |
| 145 | 145 | ); |
| 146 | 146 | |
| 147 | - if ( ! wpinv_use_taxes() && isset( $address_fields['vat_number'] ) ) { |
|
| 148 | - unset( $address_fields['vat_number'] ); |
|
| 147 | + if (!wpinv_use_taxes() && isset($address_fields['vat_number'])) { |
|
| 148 | + unset($address_fields['vat_number']); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | return $address_fields; |
@@ -156,8 +156,8 @@ discard block |
||
| 156 | 156 | * |
| 157 | 157 | * @return bool |
| 158 | 158 | */ |
| 159 | -function getpaid_is_address_field_whitelisted( $key ) { |
|
| 160 | - return array_key_exists( $key, getpaid_user_address_fields() ); |
|
| 159 | +function getpaid_is_address_field_whitelisted($key) { |
|
| 160 | + return array_key_exists($key, getpaid_user_address_fields()); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
@@ -167,24 +167,24 @@ discard block |
||
| 167 | 167 | * |
| 168 | 168 | * @param WPInv_Invoice $invoice |
| 169 | 169 | */ |
| 170 | -function getpaid_save_invoice_user_address( $invoice ) { |
|
| 170 | +function getpaid_save_invoice_user_address($invoice) { |
|
| 171 | 171 | |
| 172 | 172 | // Retrieve the invoice. |
| 173 | - $invoice = wpinv_get_invoice( $invoice ); |
|
| 173 | + $invoice = wpinv_get_invoice($invoice); |
|
| 174 | 174 | |
| 175 | 175 | // Abort if it does not exist. |
| 176 | - if ( empty( $invoice ) || $invoice->is_renewal() ) { |
|
| 176 | + if (empty($invoice) || $invoice->is_renewal()) { |
|
| 177 | 177 | return; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - foreach ( array_keys( getpaid_user_address_fields() ) as $field ) { |
|
| 180 | + foreach (array_keys(getpaid_user_address_fields()) as $field) { |
|
| 181 | 181 | |
| 182 | - if ( is_callable( array( $invoice, "get_$field" ) ) ) { |
|
| 183 | - $value = call_user_func( array( $invoice, "get_$field" ) ); |
|
| 182 | + if (is_callable(array($invoice, "get_$field"))) { |
|
| 183 | + $value = call_user_func(array($invoice, "get_$field")); |
|
| 184 | 184 | |
| 185 | 185 | // Only save if it is not empty. |
| 186 | - if ( ! empty( $value ) ) { |
|
| 187 | - update_user_meta( $invoice->get_user_id(), '_wpinv_' . $field, $value ); |
|
| 186 | + if (!empty($value)) { |
|
| 187 | + update_user_meta($invoice->get_user_id(), '_wpinv_' . $field, $value); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | } |
| 195 | -add_action( 'getpaid_checkout_invoice_updated', 'getpaid_save_invoice_user_address' ); |
|
| 195 | +add_action('getpaid_checkout_invoice_updated', 'getpaid_save_invoice_user_address'); |
|
| 196 | 196 | |
| 197 | 197 | /** |
| 198 | 198 | * Retrieves a saved user address. |
@@ -201,14 +201,14 @@ discard block |
||
| 201 | 201 | * @param bool $with_default Whether or not we should use the default country and state. |
| 202 | 202 | * @return array |
| 203 | 203 | */ |
| 204 | -function wpinv_get_user_address( $user_id = 0, $with_default = true ) { |
|
| 204 | +function wpinv_get_user_address($user_id = 0, $with_default = true) { |
|
| 205 | 205 | |
| 206 | 206 | // Prepare the user id. |
| 207 | - $user_id = empty( $user_id ) ? get_current_user_id() : $user_id; |
|
| 208 | - $user_info = get_userdata( $user_id ); |
|
| 207 | + $user_id = empty($user_id) ? get_current_user_id() : $user_id; |
|
| 208 | + $user_info = get_userdata($user_id); |
|
| 209 | 209 | |
| 210 | 210 | // Abort if non exists. |
| 211 | - if ( empty( $user_info ) ) { |
|
| 211 | + if (empty($user_info)) { |
|
| 212 | 212 | return array(); |
| 213 | 213 | } |
| 214 | 214 | |
@@ -218,11 +218,11 @@ discard block |
||
| 218 | 218 | 'email' => $user_info->user_email, |
| 219 | 219 | ); |
| 220 | 220 | |
| 221 | - foreach ( array_keys( getpaid_user_address_fields() ) as $field ) { |
|
| 222 | - $address[$field] = getpaid_get_user_address_field( $user_id, $field ); |
|
| 221 | + foreach (array_keys(getpaid_user_address_fields()) as $field) { |
|
| 222 | + $address[$field] = getpaid_get_user_address_field($user_id, $field); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - if ( ! $with_default ) { |
|
| 225 | + if (!$with_default) { |
|
| 226 | 226 | return $address; |
| 227 | 227 | } |
| 228 | 228 | |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | 'country' => wpinv_get_default_country(), |
| 234 | 234 | ); |
| 235 | 235 | |
| 236 | - return getpaid_array_merge_if_empty( $address, $defaults ); |
|
| 236 | + return getpaid_array_merge_if_empty($address, $defaults); |
|
| 237 | 237 | |
| 238 | 238 | } |
| 239 | 239 | |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | * @param string $field The field to use. |
| 245 | 245 | * @return string|null |
| 246 | 246 | */ |
| 247 | -function getpaid_get_user_address_field( $user_id, $field ) { |
|
| 247 | +function getpaid_get_user_address_field($user_id, $field) { |
|
| 248 | 248 | |
| 249 | 249 | $prefixes = array( |
| 250 | 250 | '_wpinv_', |
@@ -252,15 +252,15 @@ discard block |
||
| 252 | 252 | '' |
| 253 | 253 | ); |
| 254 | 254 | |
| 255 | - foreach ( $prefixes as $prefix ) { |
|
| 255 | + foreach ($prefixes as $prefix) { |
|
| 256 | 256 | |
| 257 | 257 | // Meta table. |
| 258 | - $value = get_user_meta( $user_id, $prefix . $field, true ); |
|
| 258 | + $value = get_user_meta($user_id, $prefix . $field, true); |
|
| 259 | 259 | |
| 260 | 260 | // UWP table. |
| 261 | - $value = ( empty( $value ) && function_exists( 'uwp_get_usermeta' ) ) ? uwp_get_usermeta( $user_id, $prefix . $field ) : $value; |
|
| 261 | + $value = (empty($value) && function_exists('uwp_get_usermeta')) ? uwp_get_usermeta($user_id, $prefix . $field) : $value; |
|
| 262 | 262 | |
| 263 | - if ( ! empty( $value ) ) { |
|
| 263 | + if (!empty($value)) { |
|
| 264 | 264 | return $value; |
| 265 | 265 | } |
| 266 | 266 | |
@@ -277,16 +277,16 @@ discard block |
||
| 277 | 277 | * @param string $return What to return. |
| 278 | 278 | * @return array |
| 279 | 279 | */ |
| 280 | -function wpinv_get_continents( $return = 'all' ) { |
|
| 280 | +function wpinv_get_continents($return = 'all') { |
|
| 281 | 281 | |
| 282 | - $continents = wpinv_get_data( 'continents' ); |
|
| 282 | + $continents = wpinv_get_data('continents'); |
|
| 283 | 283 | |
| 284 | - switch( $return ) { |
|
| 284 | + switch ($return) { |
|
| 285 | 285 | case 'name' : |
| 286 | - return wp_list_pluck( $continents, 'name' ); |
|
| 286 | + return wp_list_pluck($continents, 'name'); |
|
| 287 | 287 | break; |
| 288 | 288 | case 'countries' : |
| 289 | - return wp_list_pluck( $continents, 'countries' ); |
|
| 289 | + return wp_list_pluck($continents, 'countries'); |
|
| 290 | 290 | break; |
| 291 | 291 | default : |
| 292 | 292 | return $continents; |
@@ -302,12 +302,12 @@ discard block |
||
| 302 | 302 | * @param string $country Country code. If no code is specified, defaults to the default country. |
| 303 | 303 | * @return string |
| 304 | 304 | */ |
| 305 | -function wpinv_get_continent_code_for_country( $country = false ) { |
|
| 305 | +function wpinv_get_continent_code_for_country($country = false) { |
|
| 306 | 306 | |
| 307 | - $country = wpinv_sanitize_country( $country ); |
|
| 307 | + $country = wpinv_sanitize_country($country); |
|
| 308 | 308 | |
| 309 | - foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) { |
|
| 310 | - if ( false !== array_search( $country, $countries, true ) ) { |
|
| 309 | + foreach (wpinv_get_continents('countries') as $continent_code => $countries) { |
|
| 310 | + if (false !== array_search($country, $countries, true)) { |
|
| 311 | 311 | return $continent_code; |
| 312 | 312 | } |
| 313 | 313 | } |
@@ -323,13 +323,13 @@ discard block |
||
| 323 | 323 | * @param string $country Country code. If no code is specified, defaults to the default country. |
| 324 | 324 | * @return array |
| 325 | 325 | */ |
| 326 | -function wpinv_get_country_calling_code( $country = null) { |
|
| 326 | +function wpinv_get_country_calling_code($country = null) { |
|
| 327 | 327 | |
| 328 | - $country = wpinv_sanitize_country( $country ); |
|
| 329 | - $codes = wpinv_get_data( 'phone-codes' ); |
|
| 330 | - $code = isset( $codes[ $country ] ) ? $codes[ $country ] : ''; |
|
| 328 | + $country = wpinv_sanitize_country($country); |
|
| 329 | + $codes = wpinv_get_data('phone-codes'); |
|
| 330 | + $code = isset($codes[$country]) ? $codes[$country] : ''; |
|
| 331 | 331 | |
| 332 | - if ( is_array( $code ) ) { |
|
| 332 | + if (is_array($code)) { |
|
| 333 | 333 | return $code[0]; |
| 334 | 334 | } |
| 335 | 335 | return $code; |
@@ -342,8 +342,8 @@ discard block |
||
| 342 | 342 | * @param bool $first_empty Whether or not the first item in the list should be empty |
| 343 | 343 | * @return array |
| 344 | 344 | */ |
| 345 | -function wpinv_get_country_list( $first_empty = false ) { |
|
| 346 | - return wpinv_maybe_add_empty_option( apply_filters( 'wpinv_countries', wpinv_get_data( 'countries' ) ), $first_empty ); |
|
| 345 | +function wpinv_get_country_list($first_empty = false) { |
|
| 346 | + return wpinv_maybe_add_empty_option(apply_filters('wpinv_countries', wpinv_get_data('countries')), $first_empty); |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | /** |
@@ -353,22 +353,22 @@ discard block |
||
| 353 | 353 | * @param bool $first_empty Whether or not the first item in the list should be empty |
| 354 | 354 | * @return array |
| 355 | 355 | */ |
| 356 | -function wpinv_get_country_states( $country = null, $first_empty = false ) { |
|
| 356 | +function wpinv_get_country_states($country = null, $first_empty = false) { |
|
| 357 | 357 | |
| 358 | 358 | // Prepare the country. |
| 359 | - $country = wpinv_sanitize_country( $country ); |
|
| 359 | + $country = wpinv_sanitize_country($country); |
|
| 360 | 360 | |
| 361 | 361 | // Fetch all states. |
| 362 | - $all_states = wpinv_get_data( 'states' ); |
|
| 362 | + $all_states = wpinv_get_data('states'); |
|
| 363 | 363 | |
| 364 | 364 | // Fetch the specified country's states. |
| 365 | - $states = isset( $all_states[ $country ] ) ? $all_states[ $country ] : array() ; |
|
| 366 | - $states = apply_filters( "wpinv_{$country}_states", $states ); |
|
| 367 | - $states = apply_filters( 'wpinv_country_states', $states, $country ); |
|
| 365 | + $states = isset($all_states[$country]) ? $all_states[$country] : array(); |
|
| 366 | + $states = apply_filters("wpinv_{$country}_states", $states); |
|
| 367 | + $states = apply_filters('wpinv_country_states', $states, $country); |
|
| 368 | 368 | |
| 369 | - asort( $states ); |
|
| 369 | + asort($states); |
|
| 370 | 370 | |
| 371 | - return wpinv_maybe_add_empty_option( $states, $first_empty ); |
|
| 371 | + return wpinv_maybe_add_empty_option($states, $first_empty); |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | /** |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | * @return array |
| 379 | 379 | */ |
| 380 | 380 | function wpinv_get_us_states_list() { |
| 381 | - return apply_filters( 'wpinv_usa_states', wpinv_get_country_states( 'US' ) ); |
|
| 381 | + return apply_filters('wpinv_usa_states', wpinv_get_country_states('US')); |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | /** |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | * @return array |
| 389 | 389 | */ |
| 390 | 390 | function wpinv_get_canada_states_list() { |
| 391 | - return apply_filters( 'wpinv_canada_provinces', wpinv_get_country_states( 'CA' ) ); |
|
| 391 | + return apply_filters('wpinv_canada_provinces', wpinv_get_country_states('CA')); |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | /** |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | * @return array |
| 399 | 399 | */ |
| 400 | 400 | function wpinv_get_australia_states_list() { |
| 401 | - return apply_filters( 'wpinv_australia_states', wpinv_get_country_states( 'AU' ) ); |
|
| 401 | + return apply_filters('wpinv_australia_states', wpinv_get_country_states('AU')); |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | /** |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | * @return array |
| 409 | 409 | */ |
| 410 | 410 | function wpinv_get_bangladesh_states_list() { |
| 411 | - return apply_filters( 'wpinv_bangladesh_states', wpinv_get_country_states( 'BD' ) ); |
|
| 411 | + return apply_filters('wpinv_bangladesh_states', wpinv_get_country_states('BD')); |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | /** |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | * @return array |
| 419 | 419 | */ |
| 420 | 420 | function wpinv_get_brazil_states_list() { |
| 421 | - return apply_filters( 'wpinv_brazil_states', wpinv_get_country_states( 'BR' ) ); |
|
| 421 | + return apply_filters('wpinv_brazil_states', wpinv_get_country_states('BR')); |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | /** |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | * @return array |
| 429 | 429 | */ |
| 430 | 430 | function wpinv_get_bulgaria_states_list() { |
| 431 | - return apply_filters( 'wpinv_bulgaria_states', wpinv_get_country_states( 'BG' ) ); |
|
| 431 | + return apply_filters('wpinv_bulgaria_states', wpinv_get_country_states('BG')); |
|
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | /** |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | * @return array |
| 439 | 439 | */ |
| 440 | 440 | function wpinv_get_hong_kong_states_list() { |
| 441 | - return apply_filters( 'wpinv_hong_kong_states', wpinv_get_country_states( 'HK' ) ); |
|
| 441 | + return apply_filters('wpinv_hong_kong_states', wpinv_get_country_states('HK')); |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | /** |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | * @return array |
| 449 | 449 | */ |
| 450 | 450 | function wpinv_get_hungary_states_list() { |
| 451 | - return apply_filters( 'wpinv_hungary_states', wpinv_get_country_states( 'HU' ) ); |
|
| 451 | + return apply_filters('wpinv_hungary_states', wpinv_get_country_states('HU')); |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | /** |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | * @return array |
| 459 | 459 | */ |
| 460 | 460 | function wpinv_get_japan_states_list() { |
| 461 | - return apply_filters( 'wpinv_japan_states', wpinv_get_country_states( 'JP' ) ); |
|
| 461 | + return apply_filters('wpinv_japan_states', wpinv_get_country_states('JP')); |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | /** |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | * @return array |
| 469 | 469 | */ |
| 470 | 470 | function wpinv_get_china_states_list() { |
| 471 | - return apply_filters( 'wpinv_china_states', wpinv_get_country_states( 'CN' ) ); |
|
| 471 | + return apply_filters('wpinv_china_states', wpinv_get_country_states('CN')); |
|
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | /** |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | * @return array |
| 479 | 479 | */ |
| 480 | 480 | function wpinv_get_new_zealand_states_list() { |
| 481 | - return apply_filters( 'wpinv_new_zealand_states', wpinv_get_country_states( 'NZ' ) ); |
|
| 481 | + return apply_filters('wpinv_new_zealand_states', wpinv_get_country_states('NZ')); |
|
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | /** |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | * @return array |
| 489 | 489 | */ |
| 490 | 490 | function wpinv_get_peru_states_list() { |
| 491 | - return apply_filters( 'wpinv_peru_states', wpinv_get_country_states( 'PE' ) ); |
|
| 491 | + return apply_filters('wpinv_peru_states', wpinv_get_country_states('PE')); |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | /** |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | * @return array |
| 499 | 499 | */ |
| 500 | 500 | function wpinv_get_indonesia_states_list() { |
| 501 | - return apply_filters( 'wpinv_indonesia_states', wpinv_get_country_states( 'ID' ) ); |
|
| 501 | + return apply_filters('wpinv_indonesia_states', wpinv_get_country_states('ID')); |
|
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | /** |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | * @return array |
| 509 | 509 | */ |
| 510 | 510 | function wpinv_get_india_states_list() { |
| 511 | - return apply_filters( 'wpinv_india_states', wpinv_get_country_states( 'IN' ) ); |
|
| 511 | + return apply_filters('wpinv_india_states', wpinv_get_country_states('IN')); |
|
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | /** |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | * @return array |
| 519 | 519 | */ |
| 520 | 520 | function wpinv_get_iran_states_list() { |
| 521 | - return apply_filters( 'wpinv_iran_states', wpinv_get_country_states( 'IR' ) ); |
|
| 521 | + return apply_filters('wpinv_iran_states', wpinv_get_country_states('IR')); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | /** |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | * @return array |
| 529 | 529 | */ |
| 530 | 530 | function wpinv_get_italy_states_list() { |
| 531 | - return apply_filters( 'wpinv_italy_states', wpinv_get_country_states( 'IT' ) ); |
|
| 531 | + return apply_filters('wpinv_italy_states', wpinv_get_country_states('IT')); |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | /** |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | * @return array |
| 539 | 539 | */ |
| 540 | 540 | function wpinv_get_malaysia_states_list() { |
| 541 | - return apply_filters( 'wpinv_malaysia_states', wpinv_get_country_states( 'MY' ) ); |
|
| 541 | + return apply_filters('wpinv_malaysia_states', wpinv_get_country_states('MY')); |
|
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | /** |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | * @return array |
| 549 | 549 | */ |
| 550 | 550 | function wpinv_get_mexico_states_list() { |
| 551 | - return apply_filters( 'wpinv_mexico_states', wpinv_get_country_states( 'MX' ) ); |
|
| 551 | + return apply_filters('wpinv_mexico_states', wpinv_get_country_states('MX')); |
|
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | /** |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | * @return array |
| 559 | 559 | */ |
| 560 | 560 | function wpinv_get_nepal_states_list() { |
| 561 | - return apply_filters( 'wpinv_nepal_states', wpinv_get_country_states( 'NP' ) ); |
|
| 561 | + return apply_filters('wpinv_nepal_states', wpinv_get_country_states('NP')); |
|
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | /** |
@@ -568,7 +568,7 @@ discard block |
||
| 568 | 568 | * @return array |
| 569 | 569 | */ |
| 570 | 570 | function wpinv_get_south_africa_states_list() { |
| 571 | - return apply_filters( 'wpinv_south_africa_states', wpinv_get_country_states( 'ZA' ) ); |
|
| 571 | + return apply_filters('wpinv_south_africa_states', wpinv_get_country_states('ZA')); |
|
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | /** |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | * @return array |
| 579 | 579 | */ |
| 580 | 580 | function wpinv_get_thailand_states_list() { |
| 581 | - return apply_filters( 'wpinv_thailand_states', wpinv_get_country_states( 'TH' ) ); |
|
| 581 | + return apply_filters('wpinv_thailand_states', wpinv_get_country_states('TH')); |
|
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | /** |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | * @return array |
| 589 | 589 | */ |
| 590 | 590 | function wpinv_get_turkey_states_list() { |
| 591 | - return apply_filters( 'wpinv_turkey_states', wpinv_get_country_states( 'TR' ) ); |
|
| 591 | + return apply_filters('wpinv_turkey_states', wpinv_get_country_states('TR')); |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | /** |
@@ -598,31 +598,31 @@ discard block |
||
| 598 | 598 | * @return array |
| 599 | 599 | */ |
| 600 | 600 | function wpinv_get_spain_states_list() { |
| 601 | - return apply_filters( 'wpinv_spain_states', wpinv_get_country_states( 'ES' ) ); |
|
| 601 | + return apply_filters('wpinv_spain_states', wpinv_get_country_states('ES')); |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | function wpinv_get_states_field() { |
| 605 | - if( empty( $_POST['country'] ) ) { |
|
| 605 | + if (empty($_POST['country'])) { |
|
| 606 | 606 | $_POST['country'] = wpinv_get_default_country(); |
| 607 | 607 | } |
| 608 | - $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
| 608 | + $states = wpinv_get_country_states(sanitize_text_field($_POST['country'])); |
|
| 609 | 609 | |
| 610 | - if( !empty( $states ) ) { |
|
| 611 | - $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
| 610 | + if (!empty($states)) { |
|
| 611 | + $sanitized_field_name = sanitize_text_field($_POST['field_name']); |
|
| 612 | 612 | |
| 613 | - $class = isset( $_POST['class'] ) ? esc_attr( $_POST['class'] ) : ''; |
|
| 613 | + $class = isset($_POST['class']) ? esc_attr($_POST['class']) : ''; |
|
| 614 | 614 | $class .= " $sanitized_field_name getpaid_js_field-state custom-select wpinv-select wpi_select2"; |
| 615 | 615 | |
| 616 | - $args = array( |
|
| 616 | + $args = array( |
|
| 617 | 617 | 'name' => $sanitized_field_name, |
| 618 | 618 | 'id' => $sanitized_field_name, |
| 619 | - 'class' => implode( ' ', array_unique( explode( ' ', $class ) ) ), |
|
| 620 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
| 619 | + 'class' => implode(' ', array_unique(explode(' ', $class))), |
|
| 620 | + 'options' => array_merge(array('' => ''), $states), |
|
| 621 | 621 | 'show_option_all' => false, |
| 622 | 622 | 'show_option_none' => false |
| 623 | 623 | ); |
| 624 | 624 | |
| 625 | - $response = wpinv_html_select( $args ); |
|
| 625 | + $response = wpinv_html_select($args); |
|
| 626 | 626 | |
| 627 | 627 | } else { |
| 628 | 628 | $response = 'nostates'; |
@@ -631,10 +631,10 @@ discard block |
||
| 631 | 631 | return $response; |
| 632 | 632 | } |
| 633 | 633 | |
| 634 | -function wpinv_default_billing_country( $country = '', $user_id = 0 ) { |
|
| 635 | - $country = !empty( $country ) ? $country : wpinv_get_default_country(); |
|
| 634 | +function wpinv_default_billing_country($country = '', $user_id = 0) { |
|
| 635 | + $country = !empty($country) ? $country : wpinv_get_default_country(); |
|
| 636 | 636 | |
| 637 | - return apply_filters( 'wpinv_default_billing_country', $country, $user_id ); |
|
| 637 | + return apply_filters('wpinv_default_billing_country', $country, $user_id); |
|
| 638 | 638 | } |
| 639 | 639 | |
| 640 | 640 | /** |
@@ -646,7 +646,7 @@ discard block |
||
| 646 | 646 | */ |
| 647 | 647 | function wpinv_get_address_formats() { |
| 648 | 648 | |
| 649 | - return apply_filters( 'wpinv_localisation_address_formats', |
|
| 649 | + return apply_filters('wpinv_localisation_address_formats', |
|
| 650 | 650 | array( |
| 651 | 651 | 'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}", |
| 652 | 652 | 'AU' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}", |
@@ -695,9 +695,9 @@ discard block |
||
| 695 | 695 | * @see `wpinv_get_invoice_address_replacements` |
| 696 | 696 | * @return string |
| 697 | 697 | */ |
| 698 | -function wpinv_get_full_address_format( $country = false) { |
|
| 698 | +function wpinv_get_full_address_format($country = false) { |
|
| 699 | 699 | |
| 700 | - if( empty( $country ) ) { |
|
| 700 | + if (empty($country)) { |
|
| 701 | 701 | $country = wpinv_get_default_country(); |
| 702 | 702 | } |
| 703 | 703 | |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | $formats = wpinv_get_address_formats(); |
| 706 | 706 | |
| 707 | 707 | // Get format for the specified country. |
| 708 | - $format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default']; |
|
| 708 | + $format = ($country && isset($formats[$country])) ? $formats[$country] : $formats['default']; |
|
| 709 | 709 | |
| 710 | 710 | /** |
| 711 | 711 | * Filters the address format to use on Invoices. |
@@ -717,7 +717,7 @@ discard block |
||
| 717 | 717 | * @param string $format The address format to use. |
| 718 | 718 | * @param string $country The country who's address format is being retrieved. |
| 719 | 719 | */ |
| 720 | - return apply_filters( 'wpinv_get_full_address_format', $format, $country ); |
|
| 720 | + return apply_filters('wpinv_get_full_address_format', $format, $country); |
|
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | /** |
@@ -728,7 +728,7 @@ discard block |
||
| 728 | 728 | * @param array $billing_details customer's billing details |
| 729 | 729 | * @return array |
| 730 | 730 | */ |
| 731 | -function wpinv_get_invoice_address_replacements( $billing_details ) { |
|
| 731 | +function wpinv_get_invoice_address_replacements($billing_details) { |
|
| 732 | 732 | |
| 733 | 733 | $default_args = array( |
| 734 | 734 | 'address' => '', |
@@ -741,22 +741,22 @@ discard block |
||
| 741 | 741 | 'company' => '', |
| 742 | 742 | ); |
| 743 | 743 | |
| 744 | - $args = map_deep( wp_parse_args( $billing_details, $default_args ), 'trim' ); |
|
| 744 | + $args = map_deep(wp_parse_args($billing_details, $default_args), 'trim'); |
|
| 745 | 745 | $state = $args['state']; |
| 746 | 746 | $country = $args['country']; |
| 747 | 747 | |
| 748 | 748 | // Handle full country name. |
| 749 | - $full_country = empty( $country ) ? $country : wpinv_country_name( $country ); |
|
| 749 | + $full_country = empty($country) ? $country : wpinv_country_name($country); |
|
| 750 | 750 | |
| 751 | 751 | // Handle full state name. |
| 752 | - $full_state = ( $country && $state ) ? wpinv_state_name( $state, $country ) : $state; |
|
| 752 | + $full_state = ($country && $state) ? wpinv_state_name($state, $country) : $state; |
|
| 753 | 753 | |
| 754 | 754 | $args['postcode'] = $args['zip']; |
| 755 | 755 | $args['name'] = $args['first_name'] . ' ' . $args['last_name']; |
| 756 | 756 | $args['state'] = $full_state; |
| 757 | 757 | $args['state_code'] = $state; |
| 758 | 758 | $args['country'] = $full_country; |
| 759 | - $args['country_code']= $country; |
|
| 759 | + $args['country_code'] = $country; |
|
| 760 | 760 | |
| 761 | 761 | /** |
| 762 | 762 | * Filters the address format replacements to use on Invoices. |
@@ -767,14 +767,14 @@ discard block |
||
| 767 | 767 | * @param array $replacements The address replacements to use. |
| 768 | 768 | * @param array $billing_details The billing details to use. |
| 769 | 769 | */ |
| 770 | - $replacements = apply_filters( 'wpinv_get_invoice_address_replacements', $args, $billing_details ); |
|
| 770 | + $replacements = apply_filters('wpinv_get_invoice_address_replacements', $args, $billing_details); |
|
| 771 | 771 | |
| 772 | 772 | $return = array(); |
| 773 | 773 | |
| 774 | - foreach( $replacements as $key => $value ) { |
|
| 775 | - $value = is_scalar( $value ) ? trim( sanitize_text_field( $value ) ) : ''; |
|
| 774 | + foreach ($replacements as $key => $value) { |
|
| 775 | + $value = is_scalar($value) ? trim(sanitize_text_field($value)) : ''; |
|
| 776 | 776 | $return['{{' . $key . '}}'] = $value; |
| 777 | - $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper( $value ); |
|
| 777 | + $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper($value); |
|
| 778 | 778 | } |
| 779 | 779 | |
| 780 | 780 | return $return; |
@@ -788,6 +788,6 @@ discard block |
||
| 788 | 788 | * @since 1.0.14 |
| 789 | 789 | * @return string |
| 790 | 790 | */ |
| 791 | -function wpinv_trim_formatted_address_line( $line ) { |
|
| 792 | - return trim( $line, ', ' ); |
|
| 791 | +function wpinv_trim_formatted_address_line($line) { |
|
| 792 | + return trim($line, ', '); |
|
| 793 | 793 | } |
| 794 | 794 | \ No newline at end of file |
@@ -4,11 +4,11 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 7 | +if (!defined('ABSPATH')) { |
|
| 8 | 8 | exit; // Exit if accessed directly |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | -if ( ! class_exists( 'GetPaid_Admin_Profile', false ) ) : |
|
| 11 | +if (!class_exists('GetPaid_Admin_Profile', false)) : |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * GetPaid_Admin_Profile Class. |
@@ -19,11 +19,11 @@ discard block |
||
| 19 | 19 | * Hook in tabs. |
| 20 | 20 | */ |
| 21 | 21 | public function __construct() { |
| 22 | - add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
| 23 | - add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
| 22 | + add_action('show_user_profile', array($this, 'add_customer_meta_fields'), 100); |
|
| 23 | + add_action('edit_user_profile', array($this, 'add_customer_meta_fields'), 100); |
|
| 24 | 24 | |
| 25 | - add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) ); |
|
| 26 | - add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) ); |
|
| 25 | + add_action('personal_options_update', array($this, 'save_customer_meta_fields')); |
|
| 26 | + add_action('edit_user_profile_update', array($this, 'save_customer_meta_fields')); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -37,54 +37,54 @@ discard block |
||
| 37 | 37 | 'getpaid_customer_meta_fields', |
| 38 | 38 | array( |
| 39 | 39 | 'billing' => array( |
| 40 | - 'title' => __( 'Billing Details (GetPaid)', 'invoicing' ), |
|
| 40 | + 'title' => __('Billing Details (GetPaid)', 'invoicing'), |
|
| 41 | 41 | 'fields' => array( |
| 42 | 42 | '_wpinv_first_name' => array( |
| 43 | - 'label' => __( 'First name', 'invoicing' ), |
|
| 43 | + 'label' => __('First name', 'invoicing'), |
|
| 44 | 44 | 'description' => '', |
| 45 | 45 | ), |
| 46 | 46 | '_wpinv_last_name' => array( |
| 47 | - 'label' => __( 'Last name', 'invoicing' ), |
|
| 47 | + 'label' => __('Last name', 'invoicing'), |
|
| 48 | 48 | 'description' => '', |
| 49 | 49 | ), |
| 50 | 50 | '_wpinv_company' => array( |
| 51 | - 'label' => __( 'Company', 'invoicing' ), |
|
| 51 | + 'label' => __('Company', 'invoicing'), |
|
| 52 | 52 | 'description' => '', |
| 53 | 53 | ), |
| 54 | 54 | '_wpinv_company_id' => array( |
| 55 | - 'label' => __( 'Company ID', 'invoicing' ), |
|
| 55 | + 'label' => __('Company ID', 'invoicing'), |
|
| 56 | 56 | 'description' => '', |
| 57 | 57 | ), |
| 58 | 58 | '_wpinv_address' => array( |
| 59 | - 'label' => __( 'Address', 'invoicing' ), |
|
| 59 | + 'label' => __('Address', 'invoicing'), |
|
| 60 | 60 | 'description' => '', |
| 61 | 61 | ), |
| 62 | 62 | '_wpinv_city' => array( |
| 63 | - 'label' => __( 'City', 'invoicing' ), |
|
| 63 | + 'label' => __('City', 'invoicing'), |
|
| 64 | 64 | 'description' => '', |
| 65 | 65 | ), |
| 66 | 66 | '_wpinv_zip' => array( |
| 67 | - 'label' => __( 'Postcode / ZIP', 'invoicing' ), |
|
| 67 | + 'label' => __('Postcode / ZIP', 'invoicing'), |
|
| 68 | 68 | 'description' => '', |
| 69 | 69 | ), |
| 70 | 70 | '_wpinv_country' => array( |
| 71 | - 'label' => __( 'Country / Region', 'invoicing' ), |
|
| 71 | + 'label' => __('Country / Region', 'invoicing'), |
|
| 72 | 72 | 'description' => '', |
| 73 | 73 | 'class' => 'getpaid_js_field-country', |
| 74 | 74 | 'type' => 'select', |
| 75 | - 'options' => array( '' => __( 'Select a country / region…', 'invoicing' ) ) + wpinv_get_country_list(), |
|
| 75 | + 'options' => array('' => __('Select a country / region…', 'invoicing')) + wpinv_get_country_list(), |
|
| 76 | 76 | ), |
| 77 | 77 | '_wpinv_state' => array( |
| 78 | - 'label' => __( 'State / County', 'invoicing' ), |
|
| 79 | - 'description' => __( 'State / County or state code', 'invoicing' ), |
|
| 78 | + 'label' => __('State / County', 'invoicing'), |
|
| 79 | + 'description' => __('State / County or state code', 'invoicing'), |
|
| 80 | 80 | 'class' => 'getpaid_js_field-state regular-text', |
| 81 | 81 | ), |
| 82 | 82 | '_wpinv_phone' => array( |
| 83 | - 'label' => __( 'Phone', 'invoicing' ), |
|
| 83 | + 'label' => __('Phone', 'invoicing'), |
|
| 84 | 84 | 'description' => '', |
| 85 | 85 | ), |
| 86 | 86 | '_wpinv_vat_number' => array( |
| 87 | - 'label' => __( 'VAT Number', 'invoicing' ), |
|
| 87 | + 'label' => __('VAT Number', 'invoicing'), |
|
| 88 | 88 | 'description' => '', |
| 89 | 89 | ), |
| 90 | 90 | ), |
@@ -99,39 +99,39 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @param WP_User $user |
| 101 | 101 | */ |
| 102 | - public function add_customer_meta_fields( $user ) { |
|
| 102 | + public function add_customer_meta_fields($user) { |
|
| 103 | 103 | |
| 104 | - if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) { |
|
| 104 | + if (!apply_filters('getpaid_current_user_can_edit_customer_meta_fields', current_user_can('manage_options'), $user->ID)) { |
|
| 105 | 105 | return; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | $show_fields = $this->get_customer_meta_fields(); |
| 109 | 109 | |
| 110 | - foreach ( $show_fields as $fieldset_key => $fieldset ) : |
|
| 110 | + foreach ($show_fields as $fieldset_key => $fieldset) : |
|
| 111 | 111 | ?> |
| 112 | 112 | <h2><?php echo $fieldset['title']; ?></h2> |
| 113 | - <table class="form-table" id="<?php echo esc_attr( 'getpaid-fieldset-' . $fieldset_key ); ?>"> |
|
| 114 | - <?php foreach ( $fieldset['fields'] as $key => $field ) : ?> |
|
| 113 | + <table class="form-table" id="<?php echo esc_attr('getpaid-fieldset-' . $fieldset_key); ?>"> |
|
| 114 | + <?php foreach ($fieldset['fields'] as $key => $field) : ?> |
|
| 115 | 115 | <tr> |
| 116 | 116 | <th> |
| 117 | - <label for="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $field['label'] ); ?></label> |
|
| 117 | + <label for="<?php echo esc_attr($key); ?>"><?php echo esc_html($field['label']); ?></label> |
|
| 118 | 118 | </th> |
| 119 | 119 | <td> |
| 120 | - <?php if ( ! empty( $field['type'] ) && 'select' === $field['type'] ) : ?> |
|
| 121 | - <select name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" class="<?php echo esc_attr( $field['class'] ); ?> wpi_select2" style="width: 25em;"> |
|
| 120 | + <?php if (!empty($field['type']) && 'select' === $field['type']) : ?> |
|
| 121 | + <select name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" class="<?php echo esc_attr($field['class']); ?> wpi_select2" style="width: 25em;"> |
|
| 122 | 122 | <?php |
| 123 | - $selected = esc_attr( get_user_meta( $user->ID, $key, true ) ); |
|
| 124 | - foreach ( $field['options'] as $option_key => $option_value ) : |
|
| 123 | + $selected = esc_attr(get_user_meta($user->ID, $key, true)); |
|
| 124 | + foreach ($field['options'] as $option_key => $option_value) : |
|
| 125 | 125 | ?> |
| 126 | - <option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $selected, $option_key, true ); ?>><?php echo esc_html( $option_value ); ?></option> |
|
| 126 | + <option value="<?php echo esc_attr($option_key); ?>" <?php selected($selected, $option_key, true); ?>><?php echo esc_html($option_value); ?></option> |
|
| 127 | 127 | <?php endforeach; ?> |
| 128 | 128 | </select> |
| 129 | - <?php elseif ( ! empty( $field['type'] ) && 'checkbox' === $field['type'] ) : ?> |
|
| 130 | - <input type="checkbox" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="1" class="<?php echo esc_attr( $field['class'] ); ?>" <?php checked( (int) get_user_meta( $user->ID, $key, true ), 1, true ); ?> /> |
|
| 129 | + <?php elseif (!empty($field['type']) && 'checkbox' === $field['type']) : ?> |
|
| 130 | + <input type="checkbox" name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" value="1" class="<?php echo esc_attr($field['class']); ?>" <?php checked((int) get_user_meta($user->ID, $key, true), 1, true); ?> /> |
|
| 131 | 131 | <?php else : ?> |
| 132 | - <input type="text" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $this->get_user_meta( $user->ID, $key ) ); ?>" class="<?php echo ( ! empty( $field['class'] ) ? esc_attr( $field['class'] ) : 'regular-text' ); ?>" /> |
|
| 132 | + <input type="text" name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" value="<?php echo esc_attr($this->get_user_meta($user->ID, $key)); ?>" class="<?php echo (!empty($field['class']) ? esc_attr($field['class']) : 'regular-text'); ?>" /> |
|
| 133 | 133 | <?php endif; ?> |
| 134 | - <p class="description"><?php echo wp_kses_post( $field['description'] ); ?></p> |
|
| 134 | + <p class="description"><?php echo wp_kses_post($field['description']); ?></p> |
|
| 135 | 135 | </td> |
| 136 | 136 | </tr> |
| 137 | 137 | <?php endforeach; ?> |
@@ -145,21 +145,21 @@ discard block |
||
| 145 | 145 | * |
| 146 | 146 | * @param int $user_id User ID of the user being saved |
| 147 | 147 | */ |
| 148 | - public function save_customer_meta_fields( $user_id ) { |
|
| 149 | - if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) { |
|
| 148 | + public function save_customer_meta_fields($user_id) { |
|
| 149 | + if (!apply_filters('getpaid_current_user_can_edit_customer_meta_fields', current_user_can('manage_options'), $user_id)) { |
|
| 150 | 150 | return; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | $save_fields = $this->get_customer_meta_fields(); |
| 154 | 154 | |
| 155 | - foreach ( $save_fields as $fieldset ) { |
|
| 155 | + foreach ($save_fields as $fieldset) { |
|
| 156 | 156 | |
| 157 | - foreach ( $fieldset['fields'] as $key => $field ) { |
|
| 157 | + foreach ($fieldset['fields'] as $key => $field) { |
|
| 158 | 158 | |
| 159 | - if ( isset( $field['type'] ) && 'checkbox' === $field['type'] ) { |
|
| 160 | - update_user_meta( $user_id, $key, isset( $_POST[ $key ] ) ); |
|
| 161 | - } elseif ( isset( $_POST[ $key ] ) ) { |
|
| 162 | - update_user_meta( $user_id, $key, wpinv_clean( $_POST[ $key ] ) ); |
|
| 159 | + if (isset($field['type']) && 'checkbox' === $field['type']) { |
|
| 160 | + update_user_meta($user_id, $key, isset($_POST[$key])); |
|
| 161 | + } elseif (isset($_POST[$key])) { |
|
| 162 | + update_user_meta($user_id, $key, wpinv_clean($_POST[$key])); |
|
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | } |
@@ -173,11 +173,11 @@ discard block |
||
| 173 | 173 | * @param string $key Key for user meta field |
| 174 | 174 | * @return string |
| 175 | 175 | */ |
| 176 | - protected function get_user_meta( $user_id, $key ) { |
|
| 177 | - $value = get_user_meta( $user_id, $key, true ); |
|
| 178 | - $existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' ); |
|
| 179 | - if ( ! $value && in_array( $key, $existing_fields ) ) { |
|
| 180 | - $value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true ); |
|
| 176 | + protected function get_user_meta($user_id, $key) { |
|
| 177 | + $value = get_user_meta($user_id, $key, true); |
|
| 178 | + $existing_fields = array('_wpinv_first_name', '_wpinv_last_name'); |
|
| 179 | + if (!$value && in_array($key, $existing_fields)) { |
|
| 180 | + $value = get_user_meta($user_id, str_replace('_wpinv_', '', $key), true); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | return $value; |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | +if (!defined('ABSPATH')) { |
|
| 4 | 4 | exit; // Exit if accessed directly |
| 5 | 5 | } |
| 6 | 6 | |
@@ -19,12 +19,12 @@ discard block |
||
| 19 | 19 | * |
| 20 | 20 | * @return string |
| 21 | 21 | */ |
| 22 | - public static function name($text,$multiple = false){ |
|
| 22 | + public static function name($text, $multiple = false) { |
|
| 23 | 23 | $output = ''; |
| 24 | 24 | |
| 25 | - if($text){ |
|
| 26 | - $is_multiple = strpos($text, '[') === false && $multiple ? '[]' : ''; |
|
| 27 | - $output = ' name="'.esc_attr($text).$is_multiple.'" '; |
|
| 25 | + if ($text) { |
|
| 26 | + $is_multiple = strpos($text, '[') === false && $multiple ? '[]' : ''; |
|
| 27 | + $output = ' name="' . esc_attr($text) . $is_multiple . '" '; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | return $output; |
@@ -37,11 +37,11 @@ discard block |
||
| 37 | 37 | * |
| 38 | 38 | * @return string The sanitized item. |
| 39 | 39 | */ |
| 40 | - public static function id($text){ |
|
| 40 | + public static function id($text) { |
|
| 41 | 41 | $output = ''; |
| 42 | 42 | |
| 43 | - if($text){ |
|
| 44 | - $output = ' id="'.sanitize_html_class($text).'" '; |
|
| 43 | + if ($text) { |
|
| 44 | + $output = ' id="' . sanitize_html_class($text) . '" '; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | return $output; |
@@ -54,11 +54,11 @@ discard block |
||
| 54 | 54 | * |
| 55 | 55 | * @return string The sanitized item. |
| 56 | 56 | */ |
| 57 | - public static function title($text){ |
|
| 57 | + public static function title($text) { |
|
| 58 | 58 | $output = ''; |
| 59 | 59 | |
| 60 | - if($text){ |
|
| 61 | - $output = ' title="'.esc_attr($text).'" '; |
|
| 60 | + if ($text) { |
|
| 61 | + $output = ' title="' . esc_attr($text) . '" '; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | return $output; |
@@ -71,11 +71,11 @@ discard block |
||
| 71 | 71 | * |
| 72 | 72 | * @return string The sanitized item. |
| 73 | 73 | */ |
| 74 | - public static function value( $text ) { |
|
| 74 | + public static function value($text) { |
|
| 75 | 75 | $output = ''; |
| 76 | 76 | |
| 77 | - if ( $text !== null && $text !== false ) { |
|
| 78 | - $output = ' value="' . esc_attr( wp_unslash( $text ) ) . '" '; |
|
| 77 | + if ($text !== null && $text !== false) { |
|
| 78 | + $output = ' value="' . esc_attr(wp_unslash($text)) . '" '; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | return $output; |
@@ -88,13 +88,13 @@ discard block |
||
| 88 | 88 | * |
| 89 | 89 | * @return string The sanitized item. |
| 90 | 90 | */ |
| 91 | - public static function class_attr($text){ |
|
| 91 | + public static function class_attr($text) { |
|
| 92 | 92 | $output = ''; |
| 93 | 93 | |
| 94 | - if($text){ |
|
| 94 | + if ($text) { |
|
| 95 | 95 | $classes = self::esc_classes($text); |
| 96 | - if(!empty($classes)){ |
|
| 97 | - $output = ' class="'.$classes.'" '; |
|
| 96 | + if (!empty($classes)) { |
|
| 97 | + $output = ' class="' . $classes . '" '; |
|
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
@@ -108,15 +108,15 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @return string |
| 110 | 110 | */ |
| 111 | - public static function esc_classes($text){ |
|
| 111 | + public static function esc_classes($text) { |
|
| 112 | 112 | $output = ''; |
| 113 | 113 | |
| 114 | - if($text){ |
|
| 115 | - $classes = explode(" ",$text); |
|
| 116 | - $classes = array_map("trim",$classes); |
|
| 117 | - $classes = array_map("sanitize_html_class",$classes); |
|
| 118 | - if(!empty($classes)){ |
|
| 119 | - $output = implode(" ",$classes); |
|
| 114 | + if ($text) { |
|
| 115 | + $classes = explode(" ", $text); |
|
| 116 | + $classes = array_map("trim", $classes); |
|
| 117 | + $classes = array_map("sanitize_html_class", $classes); |
|
| 118 | + if (!empty($classes)) { |
|
| 119 | + $output = implode(" ", $classes); |
|
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | |
@@ -129,14 +129,14 @@ discard block |
||
| 129 | 129 | * |
| 130 | 130 | * @return string |
| 131 | 131 | */ |
| 132 | - public static function data_attributes($args){ |
|
| 132 | + public static function data_attributes($args) { |
|
| 133 | 133 | $output = ''; |
| 134 | 134 | |
| 135 | - if(!empty($args)){ |
|
| 135 | + if (!empty($args)) { |
|
| 136 | 136 | |
| 137 | - foreach($args as $key => $val){ |
|
| 138 | - if(substr( $key, 0, 5 ) === "data-"){ |
|
| 139 | - $output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" '; |
|
| 137 | + foreach ($args as $key => $val) { |
|
| 138 | + if (substr($key, 0, 5) === "data-") { |
|
| 139 | + $output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" '; |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | } |
@@ -149,14 +149,14 @@ discard block |
||
| 149 | 149 | * |
| 150 | 150 | * @return string |
| 151 | 151 | */ |
| 152 | - public static function aria_attributes($args){ |
|
| 152 | + public static function aria_attributes($args) { |
|
| 153 | 153 | $output = ''; |
| 154 | 154 | |
| 155 | - if(!empty($args)){ |
|
| 155 | + if (!empty($args)) { |
|
| 156 | 156 | |
| 157 | - foreach($args as $key => $val){ |
|
| 158 | - if(substr( $key, 0, 5 ) === "aria-"){ |
|
| 159 | - $output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" '; |
|
| 157 | + foreach ($args as $key => $val) { |
|
| 158 | + if (substr($key, 0, 5) === "aria-") { |
|
| 159 | + $output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" '; |
|
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | } |
@@ -173,19 +173,19 @@ discard block |
||
| 173 | 173 | * |
| 174 | 174 | * @return string |
| 175 | 175 | */ |
| 176 | - public static function icon($class,$space_after = false, $extra_attributes = array()){ |
|
| 176 | + public static function icon($class, $space_after = false, $extra_attributes = array()) { |
|
| 177 | 177 | $output = ''; |
| 178 | 178 | |
| 179 | - if($class){ |
|
| 179 | + if ($class) { |
|
| 180 | 180 | $classes = self::esc_classes($class); |
| 181 | - if(!empty($classes)){ |
|
| 182 | - $output = '<i class="'.$classes.'" '; |
|
| 181 | + if (!empty($classes)) { |
|
| 182 | + $output = '<i class="' . $classes . '" '; |
|
| 183 | 183 | // extra attributes |
| 184 | - if(!empty($extra_attributes)){ |
|
| 184 | + if (!empty($extra_attributes)) { |
|
| 185 | 185 | $output .= AUI_Component_Helper::extra_attributes($extra_attributes); |
| 186 | 186 | } |
| 187 | 187 | $output .= '></i>'; |
| 188 | - if($space_after){ |
|
| 188 | + if ($space_after) { |
|
| 189 | 189 | $output .= " "; |
| 190 | 190 | } |
| 191 | 191 | } |
@@ -199,17 +199,17 @@ discard block |
||
| 199 | 199 | * |
| 200 | 200 | * @return string |
| 201 | 201 | */ |
| 202 | - public static function extra_attributes($args){ |
|
| 202 | + public static function extra_attributes($args) { |
|
| 203 | 203 | $output = ''; |
| 204 | 204 | |
| 205 | - if(!empty($args)){ |
|
| 205 | + if (!empty($args)) { |
|
| 206 | 206 | |
| 207 | - if( is_array($args) ){ |
|
| 208 | - foreach($args as $key => $val){ |
|
| 209 | - $output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" '; |
|
| 207 | + if (is_array($args)) { |
|
| 208 | + foreach ($args as $key => $val) { |
|
| 209 | + $output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" '; |
|
| 210 | 210 | } |
| 211 | - }else{ |
|
| 212 | - $output .= ' '.$args.' '; |
|
| 211 | + } else { |
|
| 212 | + $output .= ' ' . $args . ' '; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | } |
@@ -222,11 +222,11 @@ discard block |
||
| 222 | 222 | * |
| 223 | 223 | * @return string |
| 224 | 224 | */ |
| 225 | - public static function help_text($text){ |
|
| 225 | + public static function help_text($text) { |
|
| 226 | 226 | $output = ''; |
| 227 | 227 | |
| 228 | - if($text){ |
|
| 229 | - $output .= '<small class="form-text text-muted">'.wp_kses_post($text).'</small>'; |
|
| 228 | + if ($text) { |
|
| 229 | + $output .= '<small class="form-text text-muted">' . wp_kses_post($text) . '</small>'; |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | |
@@ -240,18 +240,18 @@ discard block |
||
| 240 | 240 | * |
| 241 | 241 | * @return string|void |
| 242 | 242 | */ |
| 243 | - public static function element_require( $input ) { |
|
| 243 | + public static function element_require($input) { |
|
| 244 | 244 | |
| 245 | - $input = str_replace( "'", '"', $input );// we only want double quotes |
|
| 245 | + $input = str_replace("'", '"', $input); // we only want double quotes |
|
| 246 | 246 | |
| 247 | - $output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array( |
|
| 247 | + $output = esc_attr(str_replace(array("[%", "%]", "%:checked]"), array( |
|
| 248 | 248 | "jQuery(form).find('[data-argument=\"", |
| 249 | 249 | "\"]').find('input,select,textarea').val()", |
| 250 | 250 | "\"]').find('input:checked').val()", |
| 251 | - ), $input ) ); |
|
| 251 | + ), $input)); |
|
| 252 | 252 | |
| 253 | - if($output){ |
|
| 254 | - $output = ' data-element-require="'.$output.'" '; |
|
| 253 | + if ($output) { |
|
| 254 | + $output = ' data-element-require="' . $output . '" '; |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | return $output; |
@@ -268,13 +268,13 @@ discard block |
||
| 268 | 268 | * @param array $input Input. |
| 269 | 269 | * @return array Array of allowed HTML tags and their allowed attributes. |
| 270 | 270 | */ |
| 271 | - public static function kses_allowed_html( $context = 'post', $input = array() ) { |
|
| 272 | - $allowed_html = wp_kses_allowed_html( $context ); |
|
| 271 | + public static function kses_allowed_html($context = 'post', $input = array()) { |
|
| 272 | + $allowed_html = wp_kses_allowed_html($context); |
|
| 273 | 273 | |
| 274 | - if ( is_array( $allowed_html ) ) { |
|
| 274 | + if (is_array($allowed_html)) { |
|
| 275 | 275 | // <iframe> |
| 276 | - if ( ! isset( $allowed_html['iframe'] ) && $context == 'post' ) { |
|
| 277 | - $allowed_html['iframe'] = array( |
|
| 276 | + if (!isset($allowed_html['iframe']) && $context == 'post') { |
|
| 277 | + $allowed_html['iframe'] = array( |
|
| 278 | 278 | 'class' => true, |
| 279 | 279 | 'id' => true, |
| 280 | 280 | 'src' => true, |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | * @param @param string|array $context The context for which to retrieve tags. |
| 303 | 303 | * @param array $input Input field. |
| 304 | 304 | */ |
| 305 | - return apply_filters( 'ayecode_ui_kses_allowed_html', $allowed_html, $context, $input ); |
|
| 305 | + return apply_filters('ayecode_ui_kses_allowed_html', $allowed_html, $context, $input); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -324,20 +324,20 @@ discard block |
||
| 324 | 324 | * @param array $input Input Field. |
| 325 | 325 | * @return string Filtered content with only allowed HTML elements. |
| 326 | 326 | */ |
| 327 | - public static function _sanitize_html_field( $value, $input = array() ) { |
|
| 328 | - if ( $value === '' ) { |
|
| 327 | + public static function _sanitize_html_field($value, $input = array()) { |
|
| 328 | + if ($value === '') { |
|
| 329 | 329 | return $value; |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - $allowed_html = self::kses_allowed_html( 'post', $input ); |
|
| 332 | + $allowed_html = self::kses_allowed_html('post', $input); |
|
| 333 | 333 | |
| 334 | - if ( ! is_array( $allowed_html ) ) { |
|
| 335 | - $allowed_html = wp_kses_allowed_html( 'post' ); |
|
| 334 | + if (!is_array($allowed_html)) { |
|
| 335 | + $allowed_html = wp_kses_allowed_html('post'); |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - $filtered = trim( wp_unslash( $value ) ); |
|
| 339 | - $filtered = wp_kses( $filtered, $allowed_html ); |
|
| 340 | - $filtered = balanceTags( $filtered ); // Balances tags |
|
| 338 | + $filtered = trim(wp_unslash($value)); |
|
| 339 | + $filtered = wp_kses($filtered, $allowed_html); |
|
| 340 | + $filtered = balanceTags($filtered); // Balances tags |
|
| 341 | 341 | |
| 342 | 342 | return $filtered; |
| 343 | 343 | } |
@@ -351,21 +351,21 @@ discard block |
||
| 351 | 351 | * @param array $input Input Field. |
| 352 | 352 | * @return mixed Stripped value. |
| 353 | 353 | */ |
| 354 | - public static function sanitize_html_field( $value, $input = array() ) { |
|
| 354 | + public static function sanitize_html_field($value, $input = array()) { |
|
| 355 | 355 | $original = $value; |
| 356 | 356 | |
| 357 | - if ( is_array( $value ) ) { |
|
| 358 | - foreach ( $value as $index => $item ) { |
|
| 359 | - $value[ $index ] = self::_sanitize_html_field( $value, $input ); |
|
| 357 | + if (is_array($value)) { |
|
| 358 | + foreach ($value as $index => $item) { |
|
| 359 | + $value[$index] = self::_sanitize_html_field($value, $input); |
|
| 360 | 360 | } |
| 361 | - } elseif ( is_object( $value ) ) { |
|
| 362 | - $object_vars = get_object_vars( $value ); |
|
| 361 | + } elseif (is_object($value)) { |
|
| 362 | + $object_vars = get_object_vars($value); |
|
| 363 | 363 | |
| 364 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
| 365 | - $value->$property_name = self::_sanitize_html_field( $property_value, $input ); |
|
| 364 | + foreach ($object_vars as $property_name => $property_value) { |
|
| 365 | + $value->$property_name = self::_sanitize_html_field($property_value, $input); |
|
| 366 | 366 | } |
| 367 | 367 | } else { |
| 368 | - $value = self::_sanitize_html_field( $value, $input ); |
|
| 368 | + $value = self::_sanitize_html_field($value, $input); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | /** |
@@ -377,6 +377,6 @@ discard block |
||
| 377 | 377 | * @param string|array $value Original content without filter. |
| 378 | 378 | * @param array $input Input Field. |
| 379 | 379 | */ |
| 380 | - return apply_filters( 'ayecode_ui_sanitize_html_field', $value, $original, $input ); |
|
| 380 | + return apply_filters('ayecode_ui_sanitize_html_field', $value, $original, $input); |
|
| 381 | 381 | } |
| 382 | 382 | } |
| 383 | 383 | \ No newline at end of file |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 10 | +if (!defined('ABSPATH')) { |
|
| 11 | 11 | exit; // Exit if accessed directly |
| 12 | 12 | } |
| 13 | 13 | |
@@ -21,27 +21,27 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @param WP_Post $post |
| 23 | 23 | */ |
| 24 | - public static function output( $post ) { |
|
| 24 | + public static function output($post) { |
|
| 25 | 25 | |
| 26 | 26 | // Prepare the item. |
| 27 | - $item = new WPInv_Item( $post ); |
|
| 27 | + $item = new WPInv_Item($post); |
|
| 28 | 28 | |
| 29 | 29 | // Nonce field. |
| 30 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
| 30 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
| 31 | 31 | |
| 32 | 32 | // Set the currency position. |
| 33 | 33 | $position = wpinv_currency_position(); |
| 34 | 34 | |
| 35 | - if ( $position == 'left_space' ) { |
|
| 35 | + if ($position == 'left_space') { |
|
| 36 | 36 | $position = 'left'; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - if ( $position == 'right_space' ) { |
|
| 39 | + if ($position == 'right_space') { |
|
| 40 | 40 | $position = 'right'; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | ?> |
| 44 | - <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr( $item->get_type( 'edit' ) ); ?>" /> |
|
| 44 | + <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr($item->get_type('edit')); ?>" /> |
|
| 45 | 45 | <style> |
| 46 | 46 | #poststuff .input-group-text, |
| 47 | 47 | #poststuff .form-control { |
@@ -55,21 +55,21 @@ discard block |
||
| 55 | 55 | </style> |
| 56 | 56 | <div class='bsui' style='max-width: 600px;padding-top: 10px;'> |
| 57 | 57 | |
| 58 | - <?php do_action( 'wpinv_item_details_metabox_before_price', $item ); ?> |
|
| 58 | + <?php do_action('wpinv_item_details_metabox_before_price', $item); ?> |
|
| 59 | 59 | <div class="form-group row"> |
| 60 | - <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e( 'Item Price', 'invoicing' )?></span></label> |
|
| 60 | + <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e('Item Price', 'invoicing')?></span></label> |
|
| 61 | 61 | <div class="col-sm-8"> |
| 62 | 62 | <div class="row"> |
| 63 | 63 | <div class="col-sm-4 getpaid-price-input"> |
| 64 | 64 | <div class="input-group input-group-sm"> |
| 65 | - <?php if( 'left' == $position ) : ?> |
|
| 65 | + <?php if ('left' == $position) : ?> |
|
| 66 | 66 | <div class="input-group-prepend"> |
| 67 | 67 | <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
| 68 | 68 | </div> |
| 69 | 69 | <?php endif; ?> |
| 70 | - <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_price( 'edit' ) ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control"> |
|
| 70 | + <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_price('edit'))); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control"> |
|
| 71 | 71 | |
| 72 | - <?php if( 'left' != $position ) : ?> |
|
| 72 | + <?php if ('left' != $position) : ?> |
|
| 73 | 73 | <div class="input-group-append"> |
| 74 | 74 | <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
| 75 | 75 | </div> |
@@ -79,10 +79,10 @@ discard block |
||
| 79 | 79 | </div> |
| 80 | 80 | <div class="col-sm-4 wpinv_show_if_recurring"> |
| 81 | 81 | <?php |
| 82 | - _e( 'every' ); |
|
| 82 | + _e('every'); |
|
| 83 | 83 | echo " "; |
| 84 | 84 | ?> |
| 85 | - <input type="number" style="max-width: 60px;" value="<?php echo esc_attr( $item->get_recurring_interval( 'edit' ) ); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" /> |
|
| 85 | + <input type="number" style="max-width: 60px;" value="<?php echo esc_attr($item->get_recurring_interval('edit')); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" /> |
|
| 86 | 86 | </div> |
| 87 | 87 | <div class="col-sm-4 wpinv_show_if_recurring"> |
| 88 | 88 | <?php |
@@ -90,16 +90,16 @@ discard block |
||
| 90 | 90 | array( |
| 91 | 91 | 'id' => 'wpinv_recurring_period', |
| 92 | 92 | 'name' => 'wpinv_recurring_period', |
| 93 | - 'label' => __( 'Period', 'invoicing' ), |
|
| 94 | - 'placeholder' => __( 'Select Period', 'invoicing' ), |
|
| 95 | - 'value' => $item->get_recurring_period( 'edit' ), |
|
| 93 | + 'label' => __('Period', 'invoicing'), |
|
| 94 | + 'placeholder' => __('Select Period', 'invoicing'), |
|
| 95 | + 'value' => $item->get_recurring_period('edit'), |
|
| 96 | 96 | 'select2' => true, |
| 97 | 97 | 'data-allow-clear' => 'false', |
| 98 | 98 | 'options' => array( |
| 99 | - 'D' => __( 'day(s)', 'invoicing' ), |
|
| 100 | - 'W' => __( 'week(s)', 'invoicing' ), |
|
| 101 | - 'M' => __( 'month(s)', 'invoicing' ), |
|
| 102 | - 'Y' => __( 'year(s)', 'invoicing' ), |
|
| 99 | + 'D' => __('day(s)', 'invoicing'), |
|
| 100 | + 'W' => __('week(s)', 'invoicing'), |
|
| 101 | + 'M' => __('month(s)', 'invoicing'), |
|
| 102 | + 'Y' => __('year(s)', 'invoicing'), |
|
| 103 | 103 | ) |
| 104 | 104 | ) |
| 105 | 105 | ); |
@@ -111,9 +111,9 @@ discard block |
||
| 111 | 111 | <?php |
| 112 | 112 | |
| 113 | 113 | // Dynamic pricing. |
| 114 | - if( $item->supports_dynamic_pricing() ) { |
|
| 114 | + if ($item->supports_dynamic_pricing()) { |
|
| 115 | 115 | |
| 116 | - do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item ); |
|
| 116 | + do_action('wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item); |
|
| 117 | 117 | |
| 118 | 118 | // NYP toggle. |
| 119 | 119 | echo aui()->input( |
@@ -121,31 +121,31 @@ discard block |
||
| 121 | 121 | 'id' => 'wpinv_name_your_price', |
| 122 | 122 | 'name' => 'wpinv_name_your_price', |
| 123 | 123 | 'type' => 'checkbox', |
| 124 | - 'label' => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ), |
|
| 124 | + 'label' => apply_filters('wpinv_name_your_price_toggle_text', __('Let customers name their price', 'invoicing')), |
|
| 125 | 125 | 'value' => '1', |
| 126 | 126 | 'checked' => $item->user_can_set_their_price(), |
| 127 | 127 | 'no_wrap' => true, |
| 128 | 128 | ) |
| 129 | 129 | ); |
| 130 | 130 | |
| 131 | - do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item ); |
|
| 131 | + do_action('wpinv_item_details_metabox_dynamic_pricing_checkbox', $item); |
|
| 132 | 132 | |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | // Subscriptions. |
| 136 | - do_action( 'wpinv_item_details_metabox_before_subscription_checkbox', $item ); |
|
| 136 | + do_action('wpinv_item_details_metabox_before_subscription_checkbox', $item); |
|
| 137 | 137 | echo aui()->input( |
| 138 | 138 | array( |
| 139 | 139 | 'id' => 'wpinv_is_recurring', |
| 140 | 140 | 'name' => 'wpinv_is_recurring', |
| 141 | 141 | 'type' => 'checkbox', |
| 142 | - 'label' => apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Charge customers a recurring amount for this item', 'invoicing' ) ), |
|
| 142 | + 'label' => apply_filters('wpinv_is_recurring_toggle_text', __('Charge customers a recurring amount for this item', 'invoicing')), |
|
| 143 | 143 | 'value' => '1', |
| 144 | 144 | 'checked' => $item->is_recurring(), |
| 145 | 145 | 'no_wrap' => true, |
| 146 | 146 | ) |
| 147 | 147 | ); |
| 148 | - do_action( 'wpinv_item_details_metabox_subscription_checkbox', $item ); |
|
| 148 | + do_action('wpinv_item_details_metabox_subscription_checkbox', $item); |
|
| 149 | 149 | |
| 150 | 150 | ?> |
| 151 | 151 | <div class="wpinv_show_if_recurring"> |
@@ -155,30 +155,30 @@ discard block |
||
| 155 | 155 | </div> |
| 156 | 156 | </div> |
| 157 | 157 | <div class="col-sm-1 pt-2 pl-0"> |
| 158 | - <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e( 'Set the subscription price, billing interval and period.', 'invoicing' ); ?>"></span> |
|
| 158 | + <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e('Set the subscription price, billing interval and period.', 'invoicing'); ?>"></span> |
|
| 159 | 159 | </div> |
| 160 | 160 | </div> |
| 161 | - <?php do_action( 'wpinv_item_details_metabox_after_price', $item ); ?> |
|
| 161 | + <?php do_action('wpinv_item_details_metabox_after_price', $item); ?> |
|
| 162 | 162 | |
| 163 | - <?php if( $item->supports_dynamic_pricing() ) : ?> |
|
| 164 | - <?php do_action( 'wpinv_item_details_metabox_before_minimum_price', $item ); ?> |
|
| 163 | + <?php if ($item->supports_dynamic_pricing()) : ?> |
|
| 164 | + <?php do_action('wpinv_item_details_metabox_before_minimum_price', $item); ?> |
|
| 165 | 165 | <div class="wpinv_show_if_dynamic wpinv_minimum_price"> |
| 166 | 166 | |
| 167 | 167 | <div class="form-group row"> |
| 168 | 168 | <label for="wpinv_minimum_price" class="col-sm-3 col-form-label"> |
| 169 | - <?php _e( 'Minimum Price', 'invoicing' );?> |
|
| 169 | + <?php _e('Minimum Price', 'invoicing'); ?> |
|
| 170 | 170 | </label> |
| 171 | 171 | <div class="col-sm-8"> |
| 172 | 172 | <div class="input-group input-group-sm"> |
| 173 | - <?php if( 'left' == $position ) : ?> |
|
| 173 | + <?php if ('left' == $position) : ?> |
|
| 174 | 174 | <div class="input-group-prepend"> |
| 175 | 175 | <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
| 176 | 176 | </div> |
| 177 | 177 | <?php endif; ?> |
| 178 | 178 | |
| 179 | - <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_minimum_price( 'edit' ) ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control"> |
|
| 179 | + <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_minimum_price('edit'))); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control"> |
|
| 180 | 180 | |
| 181 | - <?php if( 'left' != $position ) : ?> |
|
| 181 | + <?php if ('left' != $position) : ?> |
|
| 182 | 182 | <div class="input-group-append"> |
| 183 | 183 | <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
| 184 | 184 | </div> |
@@ -187,45 +187,45 @@ discard block |
||
| 187 | 187 | </div> |
| 188 | 188 | |
| 189 | 189 | <div class="col-sm-1 pt-2 pl-0"> |
| 190 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the minimum amount that users are allowed to set', 'invoicing' ); ?>"></span> |
|
| 190 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the minimum amount that users are allowed to set', 'invoicing'); ?>"></span> |
|
| 191 | 191 | </div> |
| 192 | 192 | </div> |
| 193 | 193 | |
| 194 | 194 | </div> |
| 195 | - <?php do_action( 'wpinv_item_details_metabox_minimum_price', $item ); ?> |
|
| 195 | + <?php do_action('wpinv_item_details_metabox_minimum_price', $item); ?> |
|
| 196 | 196 | <?php endif; ?> |
| 197 | 197 | |
| 198 | - <?php do_action( 'wpinv_item_details_metabox_before_maximum_renewals', $item ); ?> |
|
| 198 | + <?php do_action('wpinv_item_details_metabox_before_maximum_renewals', $item); ?> |
|
| 199 | 199 | <div class="wpinv_show_if_recurring wpinv_maximum_renewals"> |
| 200 | 200 | |
| 201 | 201 | <div class="form-group row"> |
| 202 | 202 | <label for="wpinv_recurring_limit" class="col-sm-3 col-form-label"> |
| 203 | - <?php _e( 'Maximum Renewals', 'invoicing' );?> |
|
| 203 | + <?php _e('Maximum Renewals', 'invoicing'); ?> |
|
| 204 | 204 | </label> |
| 205 | 205 | <div class="col-sm-8"> |
| 206 | - <input type="number" value="<?php echo esc_attr( $item->get_recurring_limit( 'edit' ) ); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" /> |
|
| 206 | + <input type="number" value="<?php echo esc_attr($item->get_recurring_limit('edit')); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" /> |
|
| 207 | 207 | </div> |
| 208 | 208 | <div class="col-sm-1 pt-2 pl-0"> |
| 209 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing' ); ?>"></span> |
|
| 209 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing'); ?>"></span> |
|
| 210 | 210 | </div> |
| 211 | 211 | </div> |
| 212 | 212 | |
| 213 | 213 | </div> |
| 214 | - <?php do_action( 'wpinv_item_details_metabox_maximum_renewals', $item ); ?> |
|
| 214 | + <?php do_action('wpinv_item_details_metabox_maximum_renewals', $item); ?> |
|
| 215 | 215 | |
| 216 | - <?php do_action( 'wpinv_item_details_metabox_before_free_trial', $item ); ?> |
|
| 216 | + <?php do_action('wpinv_item_details_metabox_before_free_trial', $item); ?> |
|
| 217 | 217 | <div class="wpinv_show_if_recurring wpinv_free_trial"> |
| 218 | 218 | |
| 219 | 219 | <div class="form-group row"> |
| 220 | - <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php defined( 'GETPAID_PAID_TRIALS_VERSION' ) ? _e( 'Free/Paid Trial', 'invoicing' ) : _e( 'Free Trial', 'invoicing' )?></label> |
|
| 220 | + <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php defined('GETPAID_PAID_TRIALS_VERSION') ? _e('Free/Paid Trial', 'invoicing') : _e('Free Trial', 'invoicing')?></label> |
|
| 221 | 221 | |
| 222 | 222 | <div class="col-sm-8"> |
| 223 | 223 | <div class="row"> |
| 224 | 224 | <div class="col-sm-6"> |
| 225 | - <?php $value = $item->has_free_trial() ? $item->get_trial_interval( 'edit' ) : 0;?> |
|
| 225 | + <?php $value = $item->has_free_trial() ? $item->get_trial_interval('edit') : 0; ?> |
|
| 226 | 226 | |
| 227 | 227 | <div> |
| 228 | - <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr( $value ); ?>" > |
|
| 228 | + <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr($value); ?>" > |
|
| 229 | 229 | </div> |
| 230 | 230 | </div> |
| 231 | 231 | <div class="col-sm-6"> |
@@ -234,17 +234,17 @@ discard block |
||
| 234 | 234 | array( |
| 235 | 235 | 'id' => 'wpinv_trial_period', |
| 236 | 236 | 'name' => 'wpinv_trial_period', |
| 237 | - 'label' => __( 'Trial Period', 'invoicing' ), |
|
| 238 | - 'placeholder' => __( 'Trial Period', 'invoicing' ), |
|
| 239 | - 'value' => $item->get_trial_period( 'edit' ), |
|
| 237 | + 'label' => __('Trial Period', 'invoicing'), |
|
| 238 | + 'placeholder' => __('Trial Period', 'invoicing'), |
|
| 239 | + 'value' => $item->get_trial_period('edit'), |
|
| 240 | 240 | 'select2' => true, |
| 241 | 241 | 'data-allow-clear' => 'false', |
| 242 | 242 | 'no_wrap' => true, |
| 243 | 243 | 'options' => array( |
| 244 | - 'D' => __( 'day(s)', 'invoicing' ), |
|
| 245 | - 'W' => __( 'week(s)', 'invoicing' ), |
|
| 246 | - 'M' => __( 'month(s)', 'invoicing' ), |
|
| 247 | - 'Y' => __( 'year(s)', 'invoicing' ), |
|
| 244 | + 'D' => __('day(s)', 'invoicing'), |
|
| 245 | + 'W' => __('week(s)', 'invoicing'), |
|
| 246 | + 'M' => __('month(s)', 'invoicing'), |
|
| 247 | + 'Y' => __('year(s)', 'invoicing'), |
|
| 248 | 248 | ) |
| 249 | 249 | ) |
| 250 | 250 | ); |
@@ -255,15 +255,15 @@ discard block |
||
| 255 | 255 | </div> |
| 256 | 256 | |
| 257 | 257 | <div class="col-sm-1 pt-2 pl-0"> |
| 258 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'An optional period of time to wait before charging the first recurring payment.', 'invoicing' ); ?>"></span> |
|
| 258 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('An optional period of time to wait before charging the first recurring payment.', 'invoicing'); ?>"></span> |
|
| 259 | 259 | </div> |
| 260 | 260 | |
| 261 | 261 | </div> |
| 262 | 262 | |
| 263 | 263 | </div> |
| 264 | - <?php do_action( 'wpinv_item_details_metabox__free_trial', $item ); ?> |
|
| 264 | + <?php do_action('wpinv_item_details_metabox__free_trial', $item); ?> |
|
| 265 | 265 | |
| 266 | - <?php do_action( 'wpinv_item_details_metabox_item_details', $item ); ?> |
|
| 266 | + <?php do_action('wpinv_item_details_metabox_item_details', $item); ?> |
|
| 267 | 267 | </div> |
| 268 | 268 | <?php |
| 269 | 269 | |
@@ -274,31 +274,31 @@ discard block |
||
| 274 | 274 | * |
| 275 | 275 | * @param int $post_id |
| 276 | 276 | */ |
| 277 | - public static function save( $post_id ) { |
|
| 277 | + public static function save($post_id) { |
|
| 278 | 278 | |
| 279 | 279 | // Prepare the item. |
| 280 | - $item = new WPInv_Item( $post_id ); |
|
| 280 | + $item = new WPInv_Item($post_id); |
|
| 281 | 281 | |
| 282 | 282 | // Load new data. |
| 283 | 283 | $item->set_props( |
| 284 | 284 | array( |
| 285 | - 'price' => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null, |
|
| 286 | - 'vat_rule' => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null, |
|
| 287 | - 'vat_class' => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null, |
|
| 288 | - 'type' => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null, |
|
| 289 | - 'is_dynamic_pricing' => isset( $_POST['wpinv_name_your_price'] ), |
|
| 290 | - 'minimum_price' => isset( $_POST['wpinv_minimum_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_minimum_price'] ) : null, |
|
| 291 | - 'is_recurring' => isset( $_POST['wpinv_is_recurring'] ), |
|
| 292 | - 'recurring_period' => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null, |
|
| 293 | - 'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1, |
|
| 294 | - 'recurring_limit' => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
| 295 | - 'is_free_trial' => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null, |
|
| 296 | - 'trial_period' => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null, |
|
| 297 | - 'trial_interval' => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
| 285 | + 'price' => isset($_POST['wpinv_item_price']) ? getpaid_standardize_amount($_POST['wpinv_item_price']) : null, |
|
| 286 | + 'vat_rule' => isset($_POST['wpinv_vat_rules']) ? wpinv_clean($_POST['wpinv_vat_rules']) : null, |
|
| 287 | + 'vat_class' => isset($_POST['wpinv_vat_class']) ? wpinv_clean($_POST['wpinv_vat_class']) : null, |
|
| 288 | + 'type' => isset($_POST['wpinv_item_type']) ? wpinv_clean($_POST['wpinv_item_type']) : null, |
|
| 289 | + 'is_dynamic_pricing' => isset($_POST['wpinv_name_your_price']), |
|
| 290 | + 'minimum_price' => isset($_POST['wpinv_minimum_price']) ? getpaid_standardize_amount($_POST['wpinv_minimum_price']) : null, |
|
| 291 | + 'is_recurring' => isset($_POST['wpinv_is_recurring']), |
|
| 292 | + 'recurring_period' => isset($_POST['wpinv_recurring_period']) ? wpinv_clean($_POST['wpinv_recurring_period']) : null, |
|
| 293 | + 'recurring_interval' => isset($_POST['wpinv_recurring_interval']) ? (int) $_POST['wpinv_recurring_interval'] : 1, |
|
| 294 | + 'recurring_limit' => isset($_POST['wpinv_recurring_limit']) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
| 295 | + 'is_free_trial' => isset($_POST['wpinv_trial_interval']) ? (0 != (int) $_POST['wpinv_trial_interval']) : null, |
|
| 296 | + 'trial_period' => isset($_POST['wpinv_trial_period']) ? wpinv_clean($_POST['wpinv_trial_period']) : null, |
|
| 297 | + 'trial_interval' => isset($_POST['wpinv_trial_interval']) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
| 298 | 298 | ) |
| 299 | 299 | ); |
| 300 | 300 | |
| 301 | 301 | $item->save(); |
| 302 | - do_action( 'getpaid_item_metabox_save', $post_id, $item ); |
|
| 302 | + do_action('getpaid_item_metabox_save', $post_id, $item); |
|
| 303 | 303 | } |
| 304 | 304 | } |