@@ -1,10 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | -$email_footer = apply_filters( 'wpinv_email_footer_text', wpinv_get_option( 'email_footer_text' ) ); |
|
| 7 | -$email_footer = $email_footer ? wpautop( wp_kses_post( wptexturize( $email_footer ) ) ) : ''; |
|
| 6 | +$email_footer = apply_filters('wpinv_email_footer_text', wpinv_get_option('email_footer_text')); |
|
| 7 | +$email_footer = $email_footer ? wpautop(wp_kses_post(wptexturize($email_footer))) : ''; |
|
| 8 | 8 | ?> |
| 9 | 9 | </div> |
| 10 | 10 | </td> |
@@ -1,7 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if ( !defined('ABSPATH') ) { |
|
| 4 | 4 | die('-1'); |
| 5 | +} |
|
| 5 | 6 | |
| 6 | 7 | $email_footer = apply_filters( 'wpinv_email_footer_text', wpinv_get_option( 'email_footer_text' ) ); |
| 7 | 8 | $email_footer = $email_footer ? wpautop( wp_kses_post( wptexturize( $email_footer ) ) ) : ''; |
@@ -1,16 +1,16 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | -if ( !isset( $email_heading ) ) { |
|
| 6 | +if (!isset($email_heading)) { |
|
| 7 | 7 | global $email_heading; |
| 8 | 8 | } |
| 9 | 9 | ?> |
| 10 | 10 | <!DOCTYPE html> |
| 11 | 11 | <html dir="<?php echo is_rtl() ? 'rtl' : 'ltr'?>"> |
| 12 | 12 | <head> |
| 13 | - <meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo( 'charset' ); ?>" /> |
|
| 13 | + <meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo('charset'); ?>" /> |
|
| 14 | 14 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 15 | 15 | <meta name="robots" content="noindex,nofollow"> |
| 16 | 16 | <title><?php echo wpinv_get_blogname(); ?></title> |
@@ -22,13 +22,13 @@ discard block |
||
| 22 | 22 | <td align="center" valign="top"> |
| 23 | 23 | <div id="template_header_image"> |
| 24 | 24 | <?php |
| 25 | - if ( $img = wpinv_get_option( 'email_header_image' ) ) { |
|
| 26 | - echo '<p style="margin-top:0;"><img style="max-width:100%" src="' . esc_url( $img ) . '" alt="' . esc_attr( wpinv_get_blogname() ) . '" /></p>'; |
|
| 25 | + if ($img = wpinv_get_option('email_header_image')) { |
|
| 26 | + echo '<p style="margin-top:0;"><img style="max-width:100%" src="' . esc_url($img) . '" alt="' . esc_attr(wpinv_get_blogname()) . '" /></p>'; |
|
| 27 | 27 | } |
| 28 | 28 | ?> |
| 29 | 29 | </div> |
| 30 | 30 | <table border="0" cellpadding="0" cellspacing="0" width="100%" id="template_container"> |
| 31 | - <?php if ( !empty( $email_heading ) ) { ?> |
|
| 31 | + <?php if (!empty($email_heading)) { ?> |
|
| 32 | 32 | <tr> |
| 33 | 33 | <td align="center" valign="top"> |
| 34 | 34 | <!-- Header --> |
@@ -1,7 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if ( !defined('ABSPATH') ) { |
|
| 4 | 4 | die('-1'); |
| 5 | +} |
|
| 5 | 6 | |
| 6 | 7 | if ( !isset( $email_heading ) ) { |
| 7 | 8 | global $email_heading; |
@@ -1,7 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if ( !defined('ABSPATH') ) { |
|
| 4 | 4 | die('-1'); |
| 5 | +} |
|
| 5 | 6 | |
| 6 | 7 | // Load colours |
| 7 | 8 | $bg = wpinv_get_option( 'email_background_color', '#f5f5f5' ); |
@@ -1,25 +1,25 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | 6 | // Load colours |
| 7 | -$bg = wpinv_get_option( 'email_background_color', '#f5f5f5' ); |
|
| 8 | -$body = wpinv_get_option( 'email_body_background_color', '#fdfdfd' ); |
|
| 9 | -$base = wpinv_get_option( 'email_base_color', '#557da2' ); |
|
| 10 | -$base_text = wpinv_light_or_dark( $base, '#202020', '#ffffff' ); |
|
| 11 | -$text = wpinv_get_option( 'email_text_color', '#505050' ); |
|
| 7 | +$bg = wpinv_get_option('email_background_color', '#f5f5f5'); |
|
| 8 | +$body = wpinv_get_option('email_body_background_color', '#fdfdfd'); |
|
| 9 | +$base = wpinv_get_option('email_base_color', '#557da2'); |
|
| 10 | +$base_text = wpinv_light_or_dark($base, '#202020', '#ffffff'); |
|
| 11 | +$text = wpinv_get_option('email_text_color', '#505050'); |
|
| 12 | 12 | |
| 13 | -$bg_darker_10 = wpinv_hex_darker( $bg, 10 ); |
|
| 14 | -$body_darker_10 = wpinv_hex_darker( $body, 10 ); |
|
| 15 | -$base_lighter_20 = wpinv_hex_lighter( $base, 20 ); |
|
| 16 | -$base_lighter_40 = wpinv_hex_lighter( $base, 40 ); |
|
| 17 | -$text_lighter_20 = wpinv_hex_lighter( $text, 20 ); |
|
| 13 | +$bg_darker_10 = wpinv_hex_darker($bg, 10); |
|
| 14 | +$body_darker_10 = wpinv_hex_darker($body, 10); |
|
| 15 | +$base_lighter_20 = wpinv_hex_lighter($base, 20); |
|
| 16 | +$base_lighter_40 = wpinv_hex_lighter($base, 40); |
|
| 17 | +$text_lighter_20 = wpinv_hex_lighter($text, 20); |
|
| 18 | 18 | |
| 19 | 19 | // !important; is a gmail hack to prevent styles being stripped if it doesn't like something. |
| 20 | 20 | ?> |
| 21 | 21 | #wrapper { |
| 22 | - background-color: <?php echo esc_attr( $bg ); ?>; |
|
| 22 | + background-color: <?php echo esc_attr($bg); ?>; |
|
| 23 | 23 | margin: 0; |
| 24 | 24 | -webkit-text-size-adjust: none !important; |
| 25 | 25 | padding: 3%; |
@@ -40,15 +40,15 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | #template_container { |
| 42 | 42 | box-shadow: 0 1px 4px rgba(0,0,0,0.1) !important; |
| 43 | - background-color: <?php echo esc_attr( $body ); ?>; |
|
| 44 | - border: 1px solid <?php echo esc_attr( $bg_darker_10 ); ?>; |
|
| 43 | + background-color: <?php echo esc_attr($body); ?>; |
|
| 44 | + border: 1px solid <?php echo esc_attr($bg_darker_10); ?>; |
|
| 45 | 45 | border-radius: 3px !important; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | #template_header { |
| 49 | - background-color: <?php echo esc_attr( $base ); ?>; |
|
| 49 | + background-color: <?php echo esc_attr($base); ?>; |
|
| 50 | 50 | border-radius: 3px 3px 0 0 !important; |
| 51 | - color: <?php echo esc_attr( $base_text ); ?>; |
|
| 51 | + color: <?php echo esc_attr($base_text); ?>; |
|
| 52 | 52 | border-bottom: 0; |
| 53 | 53 | font-weight: bold; |
| 54 | 54 | line-height: 100%; |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | #template_header h1 { |
| 64 | - color: <?php echo esc_attr( $base_text ); ?>; |
|
| 64 | + color: <?php echo esc_attr($base_text); ?>; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | #template_footer td { |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | #template_footer #credit { |
| 74 | 74 | border:0; |
| 75 | - color: <?php echo esc_attr( $base_lighter_40 ); ?>; |
|
| 75 | + color: <?php echo esc_attr($base_lighter_40); ?>; |
|
| 76 | 76 | font-family: Arial; |
| 77 | 77 | font-size:12px; |
| 78 | 78 | line-height:125%; |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | #body_content { |
| 84 | - background-color: <?php echo esc_attr( $body ); ?>; |
|
| 84 | + background-color: <?php echo esc_attr($body); ?>; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | #body_content table td { |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | #body_content_inner { |
| 104 | - color: <?php echo esc_attr( $text_lighter_20 ); ?>; |
|
| 104 | + color: <?php echo esc_attr($text_lighter_20); ?>; |
|
| 105 | 105 | font-family: Arial,Helvetica,sans-serif; |
| 106 | 106 | font-size: 14px; |
| 107 | 107 | line-height: 150%; |
@@ -109,17 +109,17 @@ discard block |
||
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | .td { |
| 112 | - color: <?php echo esc_attr( $text_lighter_20 ); ?>; |
|
| 113 | - border: 1px solid <?php echo esc_attr( $body_darker_10 ); ?>; |
|
| 112 | + color: <?php echo esc_attr($text_lighter_20); ?>; |
|
| 113 | + border: 1px solid <?php echo esc_attr($body_darker_10); ?>; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | .text { |
| 117 | - color: <?php echo esc_attr( $text ); ?>; |
|
| 117 | + color: <?php echo esc_attr($text); ?>; |
|
| 118 | 118 | font-family: Arial,Helvetica,sans-serif; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | .link { |
| 122 | - color: <?php echo esc_attr( $base ); ?>; |
|
| 122 | + color: <?php echo esc_attr($base); ?>; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | #header_wrapper { |
@@ -128,19 +128,19 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | h1 { |
| 131 | - color: <?php echo esc_attr( $base ); ?>; |
|
| 131 | + color: <?php echo esc_attr($base); ?>; |
|
| 132 | 132 | font-family: Arial,Helvetica,sans-serif; |
| 133 | 133 | font-size: 30px; |
| 134 | 134 | font-weight: 300; |
| 135 | 135 | line-height: 150%; |
| 136 | 136 | margin: 0; |
| 137 | 137 | text-align: <?php echo is_rtl() ? 'right' : 'left'; ?>; |
| 138 | - text-shadow: 0 1px 0 <?php echo esc_attr( $base_lighter_20 ); ?>; |
|
| 138 | + text-shadow: 0 1px 0 <?php echo esc_attr($base_lighter_20); ?>; |
|
| 139 | 139 | -webkit-font-smoothing: antialiased; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | h2 { |
| 143 | - color: <?php echo esc_attr( $base ); ?>; |
|
| 143 | + color: <?php echo esc_attr($base); ?>; |
|
| 144 | 144 | display: block; |
| 145 | 145 | font-family: Arial,Helvetica,sans-serif; |
| 146 | 146 | font-size: 18px; |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | h3 { |
| 154 | - color: <?php echo esc_attr( $base ); ?>; |
|
| 154 | + color: <?php echo esc_attr($base); ?>; |
|
| 155 | 155 | display: block; |
| 156 | 156 | font-family: Arial,Helvetica,sans-serif; |
| 157 | 157 | font-size: 16px; |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | a { |
| 165 | - color: <?php echo esc_attr( $base ); ?>; |
|
| 165 | + color: <?php echo esc_attr($base); ?>; |
|
| 166 | 166 | font-weight: normal; |
| 167 | 167 | text-decoration: underline; |
| 168 | 168 | } |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | .table-bordered { |
| 183 | - border: 1px solid <?php echo esc_attr( $body_darker_10 ); ?>; |
|
| 183 | + border: 1px solid <?php echo esc_attr($body_darker_10); ?>; |
|
| 184 | 184 | border-collapse: collapse; |
| 185 | 185 | border-spacing: 0; |
| 186 | 186 | width: 100%; |
@@ -188,8 +188,8 @@ discard block |
||
| 188 | 188 | |
| 189 | 189 | .table-bordered th, |
| 190 | 190 | .table-bordered td { |
| 191 | - border: 1px solid <?php echo esc_attr( $body_darker_10 ); ?>; |
|
| 192 | - color: <?php echo esc_attr( $text_lighter_20 ); ?>; |
|
| 191 | + border: 1px solid <?php echo esc_attr($body_darker_10); ?>; |
|
| 192 | + color: <?php echo esc_attr($text_lighter_20); ?>; |
|
| 193 | 193 | font-size: 14px; |
| 194 | 194 | } |
| 195 | 195 | .small { |
@@ -288,9 +288,9 @@ discard block |
||
| 288 | 288 | text-decoration: none; |
| 289 | 289 | } |
| 290 | 290 | .btn-default { |
| 291 | - color: <?php echo esc_attr( $base_text ); ?>; |
|
| 292 | - background-color: <?php echo esc_attr( $base ); ?>; |
|
| 293 | - border-color: <?php echo esc_attr( $base ); ?>; |
|
| 291 | + color: <?php echo esc_attr($base_text); ?>; |
|
| 292 | + background-color: <?php echo esc_attr($base); ?>; |
|
| 293 | + border-color: <?php echo esc_attr($base); ?>; |
|
| 294 | 294 | } |
| 295 | 295 | .btn-primary { |
| 296 | 296 | color: #fff; |
@@ -1,7 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if ( !defined('ABSPATH') ) { |
|
| 4 | 4 | die('-1'); |
| 5 | +} |
|
| 5 | 6 | |
| 6 | 7 | do_action( 'wpinv_email_before_billing_details', $invoice ); ?> |
| 7 | 8 | <div id="wpinv-email-billing"> |
@@ -1,41 +1,41 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | -do_action( 'wpinv_email_before_billing_details', $invoice ); ?> |
|
| 6 | +do_action('wpinv_email_before_billing_details', $invoice); ?> |
|
| 7 | 7 | <div id="wpinv-email-billing"> |
| 8 | - <h3 class="wpinv-address-t"><?php echo apply_filters( 'wpinv_email_billing_title', __( 'Billing Details', 'invoicing' ) ); ?></h3> |
|
| 8 | + <h3 class="wpinv-address-t"><?php echo apply_filters('wpinv_email_billing_title', __('Billing Details', 'invoicing')); ?></h3> |
|
| 9 | 9 | |
| 10 | 10 | <table class="table table-bordered table-sm wpi-billing-details"> |
| 11 | 11 | <tbody> |
| 12 | - <?php do_action( 'wpinv_email_billing_fields_first', $invoice ); ?> |
|
| 12 | + <?php do_action('wpinv_email_billing_fields_first', $invoice); ?> |
|
| 13 | 13 | <tr class="wpi-receipt-name"> |
| 14 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
| 15 | - <td><?php if ( $sent_to_admin && $invoice->get_user_id() ) { ?><a href="<?php echo esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), self_admin_url( 'user-edit.php' ) ) ) ;?>"><?php echo esc_html( $invoice->get_user_full_name() ); ?></a><?php } else { echo esc_html( $invoice->get_user_full_name() ); } ?></td> |
|
| 14 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
| 15 | + <td><?php if ($sent_to_admin && $invoice->get_user_id()) { ?><a href="<?php echo esc_url(add_query_arg('user_id', $invoice->get_user_id(), self_admin_url('user-edit.php'))); ?>"><?php echo esc_html($invoice->get_user_full_name()); ?></a><?php } else { echo esc_html($invoice->get_user_full_name()); } ?></td> |
|
| 16 | 16 | </tr> |
| 17 | 17 | <tr class="wpi-receipt-email"> |
| 18 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
| 19 | - <td><?php echo $invoice->get_email() ;?></td> |
|
| 18 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
| 19 | + <td><?php echo $invoice->get_email(); ?></td> |
|
| 20 | 20 | </tr> |
| 21 | - <?php if ( $invoice->get_company() ) { ?> |
|
| 21 | + <?php if ($invoice->get_company()) { ?> |
|
| 22 | 22 | <tr class="wpi-receipt-company"> |
| 23 | - <th class="text-left"><?php _e( 'Company', 'invoicing' ); ?></th> |
|
| 24 | - <td><?php echo esc_html( $invoice->get_company() ) ;?></td> |
|
| 23 | + <th class="text-left"><?php _e('Company', 'invoicing'); ?></th> |
|
| 24 | + <td><?php echo esc_html($invoice->get_company()); ?></td> |
|
| 25 | 25 | </tr> |
| 26 | 26 | <?php } ?> |
| 27 | 27 | <tr class="wpi-receipt-address"> |
| 28 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
| 29 | - <td><?php echo wpinv_get_invoice_address_markup( $invoice->get_user_info() ) ;?></td> |
|
| 28 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
| 29 | + <td><?php echo wpinv_get_invoice_address_markup($invoice->get_user_info()); ?></td> |
|
| 30 | 30 | </tr> |
| 31 | - <?php if ( $invoice->get_phone() ) { ?> |
|
| 31 | + <?php if ($invoice->get_phone()) { ?> |
|
| 32 | 32 | <tr class="wpi-receipt-phone"> |
| 33 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
| 34 | - <td><?php echo esc_html( $invoice->phone ) ;?></td> |
|
| 33 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
| 34 | + <td><?php echo esc_html($invoice->phone); ?></td> |
|
| 35 | 35 | </tr> |
| 36 | 36 | <?php } ?> |
| 37 | - <?php do_action( 'wpinv_email_billing_fields_last', $invoice ); ?> |
|
| 37 | + <?php do_action('wpinv_email_billing_fields_last', $invoice); ?> |
|
| 38 | 38 | </tbody> |
| 39 | 39 | </table> |
| 40 | 40 | </div> |
| 41 | -<?php do_action( 'wpinv_email_after_billing_details', $invoice ); ?> |
|
| 42 | 41 | \ No newline at end of file |
| 42 | +<?php do_action('wpinv_email_after_billing_details', $invoice); ?> |
|
| 43 | 43 | \ No newline at end of file |
@@ -1,7 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if ( !defined('ABSPATH') ) { |
|
| 4 | 4 | die('-1'); |
| 5 | +} |
|
| 5 | 6 | |
| 6 | 7 | global $wpinv_euvat; |
| 7 | 8 | |
@@ -1,68 +1,68 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | 6 | global $wpinv_euvat; |
| 7 | 7 | |
| 8 | -$sent_to_admin = !empty( $sent_to_admin ) ? true : false; |
|
| 9 | -$invoice_url = $invoice->get_view_url( true ); |
|
| 8 | +$sent_to_admin = !empty($sent_to_admin) ? true : false; |
|
| 9 | +$invoice_url = $invoice->get_view_url(true); |
|
| 10 | 10 | $use_taxes = wpinv_use_taxes(); |
| 11 | 11 | $vat_name = getpaid_tax()->get_vat_name(); |
| 12 | 12 | |
| 13 | -do_action( 'wpinv_email_before_invoice_details', $invoice, $sent_to_admin ); ?> |
|
| 13 | +do_action('wpinv_email_before_invoice_details', $invoice, $sent_to_admin); ?> |
|
| 14 | 14 | <div id="wpinv-email-details"> |
| 15 | - <h3 class="wpinv-details-t"><?php echo apply_filters( 'wpinv_email_details_title', __( 'Invoice Details', 'invoicing' ), $invoice ); ?></h3> |
|
| 15 | + <h3 class="wpinv-details-t"><?php echo apply_filters('wpinv_email_details_title', __('Invoice Details', 'invoicing'), $invoice); ?></h3> |
|
| 16 | 16 | <table class="table table-bordered table-sm"> |
| 17 | - <?php if ( $invoice_number = $invoice->get_number() ) { ?> |
|
| 17 | + <?php if ($invoice_number = $invoice->get_number()) { ?> |
|
| 18 | 18 | <tr> |
| 19 | - <td><?php echo apply_filters( 'wpinv_invoice_number_label', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></td> |
|
| 20 | - <td><a href="<?php echo esc_url( $invoice_url ) ;?>"><?php echo $invoice_number; ?></a></td> |
|
| 19 | + <td><?php echo apply_filters('wpinv_invoice_number_label', __('Invoice Number', 'invoicing'), $invoice); ?></td> |
|
| 20 | + <td><a href="<?php echo esc_url($invoice_url); ?>"><?php echo $invoice_number; ?></a></td> |
|
| 21 | 21 | </tr> |
| 22 | 22 | <?php } ?> |
| 23 | 23 | <tr> |
| 24 | - <td><?php echo apply_filters( 'wpinv_invoice_status_title', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></td> |
|
| 25 | - <td><?php echo $invoice->get_status( true ); ?></td> |
|
| 24 | + <td><?php echo apply_filters('wpinv_invoice_status_title', __('Invoice Status', 'invoicing'), $invoice); ?></td> |
|
| 25 | + <td><?php echo $invoice->get_status(true); ?></td> |
|
| 26 | 26 | </tr> |
| 27 | - <?php if ( $invoice->is_renewal() ) { ?> |
|
| 27 | + <?php if ($invoice->is_renewal()) { ?> |
|
| 28 | 28 | <tr> |
| 29 | - <td><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Parent Invoice', 'invoicing' ), $invoice ); ?></td> |
|
| 30 | - <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td> |
|
| 29 | + <td><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Parent Invoice', 'invoicing'), $invoice); ?></td> |
|
| 30 | + <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td> |
|
| 31 | 31 | </tr> |
| 32 | 32 | <?php } ?> |
| 33 | - <?php if ( ( $gateway_title = $invoice->get_gateway_title() ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?> |
|
| 34 | - <td><?php echo apply_filters( 'wpinv_invoice_payment_method_label', __( 'Payment Method', 'invoicing' ), $invoice ); ?></td> |
|
| 33 | + <?php if (($gateway_title = $invoice->get_gateway_title()) && ($invoice->is_paid() || $invoice->is_refunded())) { ?> |
|
| 34 | + <td><?php echo apply_filters('wpinv_invoice_payment_method_label', __('Payment Method', 'invoicing'), $invoice); ?></td> |
|
| 35 | 35 | <td><?php echo $gateway_title; ?></td> |
| 36 | 36 | <?php } ?> |
| 37 | - <?php if ( $invoice_date = $invoice->get_invoice_date( false ) ) { ?> |
|
| 37 | + <?php if ($invoice_date = $invoice->get_invoice_date(false)) { ?> |
|
| 38 | 38 | <tr> |
| 39 | - <td><?php echo apply_filters( 'wpinv_invoice_date_label', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></td> |
|
| 40 | - <td><?php echo wp_sprintf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $invoice_date ) ), $invoice->get_invoice_date() ); ?></td> |
|
| 39 | + <td><?php echo apply_filters('wpinv_invoice_date_label', __('Invoice Date', 'invoicing'), $invoice); ?></td> |
|
| 40 | + <td><?php echo wp_sprintf('<time datetime="%s">%s</time>', date_i18n('c', strtotime($invoice_date)), $invoice->get_invoice_date()); ?></td> |
|
| 41 | 41 | </tr> |
| 42 | 42 | <?php } ?> |
| 43 | - <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date() ) ) { ?> |
|
| 43 | + <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date())) { ?> |
|
| 44 | 44 | <tr> |
| 45 | - <td><?php echo apply_filters( 'wpinv_invoice_due_date_label', __( 'Due Date', 'invoicing' ), $invoice ); ?></td> |
|
| 46 | - <td><?php echo wp_sprintf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $due_date ) ), $invoice->get_due_date( true ) ); ?></td> |
|
| 45 | + <td><?php echo apply_filters('wpinv_invoice_due_date_label', __('Due Date', 'invoicing'), $invoice); ?></td> |
|
| 46 | + <td><?php echo wp_sprintf('<time datetime="%s">%s</time>', date_i18n('c', strtotime($due_date)), $invoice->get_due_date(true)); ?></td> |
|
| 47 | 47 | </tr> |
| 48 | 48 | <?php } ?> |
| 49 | - <?php do_action( 'wpinv_email_invoice_details_after_due_date', $invoice->ID ); ?> |
|
| 50 | - <?php if ( empty( $sent_to_admin ) && ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) ) { ?> |
|
| 49 | + <?php do_action('wpinv_email_invoice_details_after_due_date', $invoice->ID); ?> |
|
| 50 | + <?php if (empty($sent_to_admin) && ($owner_vat_number = $wpinv_euvat->get_vat_number())) { ?> |
|
| 51 | 51 | <tr> |
| 52 | - <td><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></td> |
|
| 52 | + <td><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></td> |
|
| 53 | 53 | <td><?php echo $owner_vat_number; ?></td> |
| 54 | 54 | </tr> |
| 55 | 55 | <?php } ?> |
| 56 | - <?php if ( $use_taxes && ( $user_vat_number = $invoice->vat_number ) ) { ?> |
|
| 56 | + <?php if ($use_taxes && ($user_vat_number = $invoice->vat_number)) { ?> |
|
| 57 | 57 | <tr> |
| 58 | - <td><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></td> |
|
| 58 | + <td><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></td> |
|
| 59 | 59 | <td><?php echo $user_vat_number; ?></td> |
| 60 | 60 | </tr> |
| 61 | 61 | <?php } ?> |
| 62 | 62 | <tr class="table-active"> |
| 63 | - <td><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></td> |
|
| 64 | - <td><strong><?php echo $invoice->get_total( true ); ?></strong></td> |
|
| 63 | + <td><strong><?php _e('Total Amount', 'invoicing') ?></strong></td> |
|
| 64 | + <td><strong><?php echo $invoice->get_total(true); ?></strong></td> |
|
| 65 | 65 | </tr> |
| 66 | 66 | </table> |
| 67 | 67 | </div> |
| 68 | -<?php do_action( 'wpinv_email_after_invoice_details', $invoice, $sent_to_admin ); ?> |
|
| 69 | 68 | \ No newline at end of file |
| 69 | +<?php do_action('wpinv_email_after_invoice_details', $invoice, $sent_to_admin); ?> |
|
| 70 | 70 | \ No newline at end of file |
@@ -196,8 +196,9 @@ |
||
| 196 | 196 | foreach ( $types as $name => $type ) { |
| 197 | 197 | echo '<option value="' . esc_attr( $name ) . '"'; |
| 198 | 198 | |
| 199 | - if ( isset( $_GET['discount_type'] ) ) |
|
| 200 | - selected( $name, $_GET['discount_type'] ); |
|
| 199 | + if ( isset( $_GET['discount_type'] ) ) { |
|
| 200 | + selected( $name, $_GET['discount_type'] ); |
|
| 201 | + } |
|
| 201 | 202 | |
| 202 | 203 | echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
| 203 | 204 | } |
@@ -1,16 +1,16 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // MUST have WordPress. |
| 3 | -if ( !defined( 'WPINC' ) ) { |
|
| 4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 3 | +if (!defined('WPINC')) { |
|
| 4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | -add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' ); |
|
| 8 | -function wpinv_discount_custom_column( $column ) { |
|
| 7 | +add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column'); |
|
| 8 | +function wpinv_discount_custom_column($column) { |
|
| 9 | 9 | global $post; |
| 10 | 10 | |
| 11 | - $discount = new WPInv_Discount( $post ); |
|
| 11 | + $discount = new WPInv_Discount($post); |
|
| 12 | 12 | |
| 13 | - switch ( $column ) { |
|
| 13 | + switch ($column) { |
|
| 14 | 14 | case 'code' : |
| 15 | 15 | echo $discount->get_code(); |
| 16 | 16 | break; |
@@ -21,38 +21,38 @@ discard block |
||
| 21 | 21 | echo $discount->get_usage(); |
| 22 | 22 | break; |
| 23 | 23 | case 'start_date' : |
| 24 | - echo getpaid_format_date_value( $discount->get_start_date() ); |
|
| 24 | + echo getpaid_format_date_value($discount->get_start_date()); |
|
| 25 | 25 | break; |
| 26 | 26 | case 'expiry_date' : |
| 27 | - echo getpaid_format_date_value( $discount->get_expiration_date(), __( 'Never', 'invoicing' ) ); |
|
| 27 | + echo getpaid_format_date_value($discount->get_expiration_date(), __('Never', 'invoicing')); |
|
| 28 | 28 | break; |
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | -add_filter( 'post_row_actions', 'wpinv_post_row_actions', 9999, 2 ); |
|
| 33 | -function wpinv_post_row_actions( $actions, $post ) { |
|
| 34 | - $post_type = !empty( $post->post_type ) ? $post->post_type : ''; |
|
| 32 | +add_filter('post_row_actions', 'wpinv_post_row_actions', 9999, 2); |
|
| 33 | +function wpinv_post_row_actions($actions, $post) { |
|
| 34 | + $post_type = !empty($post->post_type) ? $post->post_type : ''; |
|
| 35 | 35 | |
| 36 | - if ( $post_type == 'wpi_invoice' ) { |
|
| 36 | + if ($post_type == 'wpi_invoice') { |
|
| 37 | 37 | $actions = array(); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - if ( $post_type == 'wpi_discount' ) { |
|
| 41 | - $actions = wpinv_discount_row_actions( $post, $actions ); |
|
| 40 | + if ($post_type == 'wpi_discount') { |
|
| 41 | + $actions = wpinv_discount_row_actions($post, $actions); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | return $actions; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | -function wpinv_discount_row_actions( $discount, $row_actions ) { |
|
| 48 | - $row_actions = array(); |
|
| 49 | - $edit_link = get_edit_post_link( $discount->ID ); |
|
| 50 | - $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>'; |
|
| 47 | +function wpinv_discount_row_actions($discount, $row_actions) { |
|
| 48 | + $row_actions = array(); |
|
| 49 | + $edit_link = get_edit_post_link($discount->ID); |
|
| 50 | + $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>'; |
|
| 51 | 51 | |
| 52 | - if( in_array( strtolower( $discount->post_status ), array( 'publish' ) ) ) { |
|
| 53 | - $row_actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'deactivate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Deactivate', 'invoicing' ) . '</a>'; |
|
| 54 | - } elseif( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) ) { |
|
| 55 | - $row_actions['activate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'activate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Activate', 'invoicing' ) . '</a>'; |
|
| 52 | + if (in_array(strtolower($discount->post_status), array('publish'))) { |
|
| 53 | + $row_actions['deactivate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'deactivate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Deactivate', 'invoicing') . '</a>'; |
|
| 54 | + } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) { |
|
| 55 | + $row_actions['activate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'activate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Activate', 'invoicing') . '</a>'; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | $delete_url = esc_url( |
@@ -66,110 +66,110 @@ discard block |
||
| 66 | 66 | 'wpinv_discount_nonce' |
| 67 | 67 | ) |
| 68 | 68 | ); |
| 69 | - $row_actions['delete'] = '<a href="' . $delete_url . '">' . __( 'Delete', 'invoicing' ) . '</a>'; |
|
| 69 | + $row_actions['delete'] = '<a href="' . $delete_url . '">' . __('Delete', 'invoicing') . '</a>'; |
|
| 70 | 70 | |
| 71 | - $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount ); |
|
| 71 | + $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount); |
|
| 72 | 72 | |
| 73 | 73 | return $row_actions; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | -add_filter( 'list_table_primary_column', 'wpinv_table_primary_column', 10, 2 ); |
|
| 77 | -function wpinv_table_primary_column( $default, $screen_id ) { |
|
| 78 | - if ( 'edit-wpi_invoice' === $screen_id ) { |
|
| 76 | +add_filter('list_table_primary_column', 'wpinv_table_primary_column', 10, 2); |
|
| 77 | +function wpinv_table_primary_column($default, $screen_id) { |
|
| 78 | + if ('edit-wpi_invoice' === $screen_id) { |
|
| 79 | 79 | return 'name'; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | return $default; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | -function wpinv_discount_bulk_actions( $actions, $display = false ) { |
|
| 86 | - if ( !$display ) { |
|
| 85 | +function wpinv_discount_bulk_actions($actions, $display = false) { |
|
| 86 | + if (!$display) { |
|
| 87 | 87 | return array(); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | $actions = array( |
| 91 | - 'activate' => __( 'Activate', 'invoicing' ), |
|
| 92 | - 'deactivate' => __( 'Deactivate', 'invoicing' ), |
|
| 93 | - 'delete' => __( 'Delete', 'invoicing' ), |
|
| 91 | + 'activate' => __('Activate', 'invoicing'), |
|
| 92 | + 'deactivate' => __('Deactivate', 'invoicing'), |
|
| 93 | + 'delete' => __('Delete', 'invoicing'), |
|
| 94 | 94 | ); |
| 95 | 95 | $two = ''; |
| 96 | 96 | $which = 'top'; |
| 97 | 97 | echo '</div><div class="alignleft actions bulkactions">'; |
| 98 | - echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>'; |
|
| 99 | - echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">"; |
|
| 100 | - echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>"; |
|
| 98 | + echo '<label for="bulk-action-selector-' . esc_attr($which) . '" class="screen-reader-text">' . __('Select bulk action') . '</label>'; |
|
| 99 | + echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr($which) . "\">"; |
|
| 100 | + echo '<option value="-1">' . __('Bulk Actions') . "</option>"; |
|
| 101 | 101 | |
| 102 | - foreach ( $actions as $name => $title ) { |
|
| 102 | + foreach ($actions as $name => $title) { |
|
| 103 | 103 | $class = 'edit' === $name ? ' class="hide-if-no-js"' : ''; |
| 104 | 104 | |
| 105 | 105 | echo "" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>"; |
| 106 | 106 | } |
| 107 | 107 | echo "</select>"; |
| 108 | 108 | |
| 109 | - submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) ); |
|
| 109 | + submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two")); |
|
| 110 | 110 | |
| 111 | 111 | echo '</div><div class="alignleft actions">'; |
| 112 | 112 | } |
| 113 | -add_filter( 'bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10 ); |
|
| 113 | +add_filter('bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10); |
|
| 114 | 114 | |
| 115 | -function wpinv_disable_months_dropdown( $disable, $post_type ) { |
|
| 116 | - if ( $post_type == 'wpi_discount' ) { |
|
| 115 | +function wpinv_disable_months_dropdown($disable, $post_type) { |
|
| 116 | + if ($post_type == 'wpi_discount') { |
|
| 117 | 117 | $disable = true; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | return $disable; |
| 121 | 121 | } |
| 122 | -add_filter( 'disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2 ); |
|
| 122 | +add_filter('disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2); |
|
| 123 | 123 | |
| 124 | 124 | function wpinv_restrict_manage_posts() { |
| 125 | 125 | global $typenow; |
| 126 | 126 | |
| 127 | - if( 'wpi_discount' == $typenow ) { |
|
| 127 | + if ('wpi_discount' == $typenow) { |
|
| 128 | 128 | wpinv_discount_filters(); |
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | -add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 ); |
|
| 131 | +add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10); |
|
| 132 | 132 | |
| 133 | 133 | function wpinv_discount_filters() { |
| 134 | - wpinv_discount_bulk_actions( array(), true ); |
|
| 134 | + wpinv_discount_bulk_actions(array(), true); |
|
| 135 | 135 | |
| 136 | 136 | ?> |
| 137 | 137 | <select name="discount_type" id="dropdown_wpinv_discount_type"> |
| 138 | - <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option> |
|
| 138 | + <option value=""><?php _e('Show all types', 'invoicing'); ?></option> |
|
| 139 | 139 | <?php |
| 140 | 140 | $types = wpinv_get_discount_types(); |
| 141 | 141 | |
| 142 | - foreach ( $types as $name => $type ) { |
|
| 143 | - echo '<option value="' . esc_attr( $name ) . '"'; |
|
| 142 | + foreach ($types as $name => $type) { |
|
| 143 | + echo '<option value="' . esc_attr($name) . '"'; |
|
| 144 | 144 | |
| 145 | - if ( isset( $_GET['discount_type'] ) ) |
|
| 146 | - selected( $name, $_GET['discount_type'] ); |
|
| 145 | + if (isset($_GET['discount_type'])) |
|
| 146 | + selected($name, $_GET['discount_type']); |
|
| 147 | 147 | |
| 148 | - echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
|
| 148 | + echo '>' . esc_html__($type, 'invoicing') . '</option>'; |
|
| 149 | 149 | } |
| 150 | 150 | ?> |
| 151 | 151 | </select> |
| 152 | 152 | <?php |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | -function wpinv_request( $vars ) { |
|
| 155 | +function wpinv_request($vars) { |
|
| 156 | 156 | global $typenow, $wp_query, $wp_post_statuses; |
| 157 | 157 | |
| 158 | - if ( 'wpi_invoice' === $typenow ) { |
|
| 159 | - if ( !isset( $vars['post_status'] ) ) { |
|
| 158 | + if ('wpi_invoice' === $typenow) { |
|
| 159 | + if (!isset($vars['post_status'])) { |
|
| 160 | 160 | $post_statuses = wpinv_get_invoice_statuses(); |
| 161 | 161 | |
| 162 | - foreach ( $post_statuses as $status => $value ) { |
|
| 163 | - if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) { |
|
| 164 | - unset( $post_statuses[ $status ] ); |
|
| 162 | + foreach ($post_statuses as $status => $value) { |
|
| 163 | + if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) { |
|
| 164 | + unset($post_statuses[$status]); |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - $vars['post_status'] = array_keys( $post_statuses ); |
|
| 168 | + $vars['post_status'] = array_keys($post_statuses); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - if ( isset( $vars['orderby'] ) ) { |
|
| 172 | - if ( 'amount' == $vars['orderby'] ) { |
|
| 171 | + if (isset($vars['orderby'])) { |
|
| 172 | + if ('amount' == $vars['orderby']) { |
|
| 173 | 173 | $vars = array_merge( |
| 174 | 174 | $vars, |
| 175 | 175 | array( |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | 'orderby' => 'meta_value_num' |
| 178 | 178 | ) |
| 179 | 179 | ); |
| 180 | - } else if ( 'customer' == $vars['orderby'] ) { |
|
| 180 | + } else if ('customer' == $vars['orderby']) { |
|
| 181 | 181 | $vars = array_merge( |
| 182 | 182 | $vars, |
| 183 | 183 | array( |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | 'orderby' => 'meta_value' |
| 186 | 186 | ) |
| 187 | 187 | ); |
| 188 | - } else if ( 'number' == $vars['orderby'] ) { |
|
| 188 | + } else if ('number' == $vars['orderby']) { |
|
| 189 | 189 | $vars = array_merge( |
| 190 | 190 | $vars, |
| 191 | 191 | array( |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | 'orderby' => 'meta_value' |
| 194 | 194 | ) |
| 195 | 195 | ); |
| 196 | - } else if ( 'payment_date' == $vars['orderby'] ) { |
|
| 196 | + } else if ('payment_date' == $vars['orderby']) { |
|
| 197 | 197 | $vars = array_merge( |
| 198 | 198 | $vars, |
| 199 | 199 | array( |
@@ -203,73 +203,73 @@ discard block |
||
| 203 | 203 | ); |
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | - } else if ( 'wpi_discount' == $typenow ) { |
|
| 207 | - $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
| 206 | + } else if ('wpi_discount' == $typenow) { |
|
| 207 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
| 208 | 208 | // Filter vat rule type |
| 209 | - if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) { |
|
| 209 | + if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') { |
|
| 210 | 210 | $meta_query[] = array( |
| 211 | 211 | 'key' => '_wpi_discount_type', |
| 212 | - 'value' => sanitize_text_field( $_GET['discount_type'] ), |
|
| 212 | + 'value' => sanitize_text_field($_GET['discount_type']), |
|
| 213 | 213 | 'compare' => '=' |
| 214 | 214 | ); |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | - if ( !empty( $meta_query ) ) { |
|
| 217 | + if (!empty($meta_query)) { |
|
| 218 | 218 | $vars['meta_query'] = $meta_query; |
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | return $vars; |
| 223 | 223 | } |
| 224 | -add_filter( 'request', 'wpinv_request' ); |
|
| 224 | +add_filter('request', 'wpinv_request'); |
|
| 225 | 225 | |
| 226 | -function wpinv_item_type_class( $classes, $class, $post_id ) { |
|
| 226 | +function wpinv_item_type_class($classes, $class, $post_id) { |
|
| 227 | 227 | global $pagenow, $typenow; |
| 228 | 228 | |
| 229 | - if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow ) { |
|
| 230 | - if ( $type = get_post_meta( $post_id, '_wpinv_type', true ) ) { |
|
| 231 | - $classes[] = 'wpi-type-' . sanitize_html_class( $type ); |
|
| 229 | + if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow) { |
|
| 230 | + if ($type = get_post_meta($post_id, '_wpinv_type', true)) { |
|
| 231 | + $classes[] = 'wpi-type-' . sanitize_html_class($type); |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - if ( !wpinv_item_is_editable( $post_id ) ) { |
|
| 234 | + if (!wpinv_item_is_editable($post_id)) { |
|
| 235 | 235 | $classes[] = 'wpi-editable-n'; |
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | return $classes; |
| 239 | 239 | } |
| 240 | -add_filter( 'post_class', 'wpinv_item_type_class', 10, 3 ); |
|
| 240 | +add_filter('post_class', 'wpinv_item_type_class', 10, 3); |
|
| 241 | 241 | |
| 242 | 242 | function wpinv_check_quick_edit() { |
| 243 | 243 | global $pagenow, $current_screen, $wpinv_item_screen; |
| 244 | 244 | |
| 245 | - if ( $pagenow == 'edit.php' && !empty( $current_screen->post_type ) ) { |
|
| 246 | - if ( empty( $wpinv_item_screen ) ) { |
|
| 247 | - if ( $current_screen->post_type == 'wpi_item' ) { |
|
| 245 | + if ($pagenow == 'edit.php' && !empty($current_screen->post_type)) { |
|
| 246 | + if (empty($wpinv_item_screen)) { |
|
| 247 | + if ($current_screen->post_type == 'wpi_item') { |
|
| 248 | 248 | $wpinv_item_screen = 'y'; |
| 249 | 249 | } else { |
| 250 | 250 | $wpinv_item_screen = 'n'; |
| 251 | 251 | } |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - if ( $wpinv_item_screen == 'y' && $pagenow == 'edit.php' ) { |
|
| 255 | - add_filter( 'post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 ); |
|
| 256 | - add_filter( 'page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 ); |
|
| 254 | + if ($wpinv_item_screen == 'y' && $pagenow == 'edit.php') { |
|
| 255 | + add_filter('post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2); |
|
| 256 | + add_filter('page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2); |
|
| 257 | 257 | } |
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | -add_action( 'admin_head', 'wpinv_check_quick_edit', 10 ); |
|
| 260 | +add_action('admin_head', 'wpinv_check_quick_edit', 10); |
|
| 261 | 261 | |
| 262 | -function wpinv_item_disable_quick_edit( $actions = array(), $row = null ) { |
|
| 263 | - if ( isset( $actions['inline hide-if-no-js'] ) ) { |
|
| 264 | - unset( $actions['inline hide-if-no-js'] ); |
|
| 262 | +function wpinv_item_disable_quick_edit($actions = array(), $row = null) { |
|
| 263 | + if (isset($actions['inline hide-if-no-js'])) { |
|
| 264 | + unset($actions['inline hide-if-no-js']); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - if ( !empty( $row->post_type ) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable( $row ) ) { |
|
| 268 | - if ( isset( $actions['trash'] ) ) { |
|
| 269 | - unset( $actions['trash'] ); |
|
| 267 | + if (!empty($row->post_type) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable($row)) { |
|
| 268 | + if (isset($actions['trash'])) { |
|
| 269 | + unset($actions['trash']); |
|
| 270 | 270 | } |
| 271 | - if ( isset( $actions['delete'] ) ) { |
|
| 272 | - unset( $actions['delete'] ); |
|
| 271 | + if (isset($actions['delete'])) { |
|
| 272 | + unset($actions['delete']); |
|
| 273 | 273 | } |
| 274 | 274 | } |
| 275 | 275 | |
@@ -286,19 +286,19 @@ discard block |
||
| 286 | 286 | * @param int $post_parent (default: 0) Parent for the new page |
| 287 | 287 | * @return int page ID |
| 288 | 288 | */ |
| 289 | -function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) { |
|
| 289 | +function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) { |
|
| 290 | 290 | global $wpdb; |
| 291 | 291 | |
| 292 | - $option_value = wpinv_get_option( $option ); |
|
| 292 | + $option_value = wpinv_get_option($option); |
|
| 293 | 293 | |
| 294 | - if ( $option_value > 0 && ( $page_object = get_post( $option_value ) ) ) { |
|
| 295 | - if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) { |
|
| 294 | + if ($option_value > 0 && ($page_object = get_post($option_value))) { |
|
| 295 | + if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) { |
|
| 296 | 296 | // Valid page is already in place |
| 297 | 297 | return $page_object->ID; |
| 298 | 298 | } |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - if(!empty($post_parent)){ |
|
| 301 | + if (!empty($post_parent)) { |
|
| 302 | 302 | $page = get_page_by_path($post_parent); |
| 303 | 303 | if ($page) { |
| 304 | 304 | $post_parent = $page->ID; |
@@ -307,40 +307,40 @@ discard block |
||
| 307 | 307 | } |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - if ( strlen( $page_content ) > 0 ) { |
|
| 310 | + if (strlen($page_content) > 0) { |
|
| 311 | 311 | // Search for an existing page with the specified page content (typically a shortcode) |
| 312 | - $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); |
|
| 312 | + $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%")); |
|
| 313 | 313 | } else { |
| 314 | 314 | // Search for an existing page with the specified page slug |
| 315 | - $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug ) ); |
|
| 315 | + $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug)); |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content ); |
|
| 318 | + $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content); |
|
| 319 | 319 | |
| 320 | - if ( $valid_page_found ) { |
|
| 321 | - if ( $option ) { |
|
| 322 | - wpinv_update_option( $option, $valid_page_found ); |
|
| 320 | + if ($valid_page_found) { |
|
| 321 | + if ($option) { |
|
| 322 | + wpinv_update_option($option, $valid_page_found); |
|
| 323 | 323 | } |
| 324 | 324 | return $valid_page_found; |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | // Search for a matching valid trashed page |
| 328 | - if ( strlen( $page_content ) > 0 ) { |
|
| 328 | + if (strlen($page_content) > 0) { |
|
| 329 | 329 | // Search for an existing page with the specified page content (typically a shortcode) |
| 330 | - $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); |
|
| 330 | + $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%")); |
|
| 331 | 331 | } else { |
| 332 | 332 | // Search for an existing page with the specified page slug |
| 333 | - $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) ); |
|
| 333 | + $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug)); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | - if ( $trashed_page_found ) { |
|
| 336 | + if ($trashed_page_found) { |
|
| 337 | 337 | $page_id = $trashed_page_found; |
| 338 | 338 | $page_data = array( |
| 339 | 339 | 'ID' => $page_id, |
| 340 | 340 | 'post_status' => 'publish', |
| 341 | 341 | 'post_parent' => $post_parent, |
| 342 | 342 | ); |
| 343 | - wp_update_post( $page_data ); |
|
| 343 | + wp_update_post($page_data); |
|
| 344 | 344 | } else { |
| 345 | 345 | $page_data = array( |
| 346 | 346 | 'post_status' => 'publish', |
@@ -352,11 +352,11 @@ discard block |
||
| 352 | 352 | 'post_parent' => $post_parent, |
| 353 | 353 | 'comment_status' => 'closed', |
| 354 | 354 | ); |
| 355 | - $page_id = wp_insert_post( $page_data ); |
|
| 355 | + $page_id = wp_insert_post($page_data); |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | - if ( $option ) { |
|
| 359 | - wpinv_update_option( $option, (int)$page_id ); |
|
| 358 | + if ($option) { |
|
| 359 | + wpinv_update_option($option, (int) $page_id); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | return $page_id; |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) { |
| 311 | 311 | if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){ |
| 312 | 312 | $enabled_gateway = wpinv_get_default_gateway(); |
| 313 | - }else{ |
|
| 313 | + } else{ |
|
| 314 | 314 | $enabled_gateway = $gateways[0]; |
| 315 | 315 | } |
| 316 | 316 | |
@@ -336,8 +336,9 @@ discard block |
||
| 336 | 336 | |
| 337 | 337 | $payments = new WP_Query( $args ); |
| 338 | 338 | |
| 339 | - if( $payments ) |
|
| 340 | - $ret = $payments->post_count; |
|
| 339 | + if( $payments ) { |
|
| 340 | + $ret = $payments->post_count; |
|
| 341 | + } |
|
| 341 | 342 | return $ret; |
| 342 | 343 | } |
| 343 | 344 | |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | * Contains gateway functions. |
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | -defined( 'ABSPATH' ) || exit; |
|
| 6 | +defined('ABSPATH') || exit; |
|
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * Returns an array of payment gateways. |
@@ -11,141 +11,141 @@ discard block |
||
| 11 | 11 | * @return array |
| 12 | 12 | */ |
| 13 | 13 | function wpinv_get_payment_gateways() { |
| 14 | - return apply_filters( 'wpinv_payment_gateways', array() ); |
|
| 14 | + return apply_filters('wpinv_payment_gateways', array()); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | -function wpinv_payment_gateway_titles( $all_gateways ) { |
|
| 17 | +function wpinv_payment_gateway_titles($all_gateways) { |
|
| 18 | 18 | global $wpinv_options; |
| 19 | 19 | |
| 20 | 20 | $gateways = array(); |
| 21 | - foreach ( $all_gateways as $key => $gateway ) { |
|
| 22 | - if ( !empty( $wpinv_options[$key . '_title'] ) ) { |
|
| 23 | - $all_gateways[$key]['checkout_label'] = __( $wpinv_options[$key . '_title'], 'invoicing' ); |
|
| 21 | + foreach ($all_gateways as $key => $gateway) { |
|
| 22 | + if (!empty($wpinv_options[$key . '_title'])) { |
|
| 23 | + $all_gateways[$key]['checkout_label'] = __($wpinv_options[$key . '_title'], 'invoicing'); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - $gateways[$key] = isset( $wpinv_options[$key . '_ordering'] ) ? $wpinv_options[$key . '_ordering'] : ( isset( $gateway['ordering'] ) ? $gateway['ordering'] : '' ); |
|
| 26 | + $gateways[$key] = isset($wpinv_options[$key . '_ordering']) ? $wpinv_options[$key . '_ordering'] : (isset($gateway['ordering']) ? $gateway['ordering'] : ''); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - asort( $gateways ); |
|
| 29 | + asort($gateways); |
|
| 30 | 30 | |
| 31 | - foreach ( $gateways as $gateway => $key ) { |
|
| 31 | + foreach ($gateways as $gateway => $key) { |
|
| 32 | 32 | $gateways[$gateway] = $all_gateways[$gateway]; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | return $gateways; |
| 36 | 36 | } |
| 37 | -add_filter( 'wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1 ); |
|
| 37 | +add_filter('wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1); |
|
| 38 | 38 | |
| 39 | -function wpinv_get_enabled_payment_gateways( $sort = false ) { |
|
| 39 | +function wpinv_get_enabled_payment_gateways($sort = false) { |
|
| 40 | 40 | $gateways = wpinv_get_payment_gateways(); |
| 41 | - $enabled = wpinv_get_option( 'gateways', false ); |
|
| 41 | + $enabled = wpinv_get_option('gateways', false); |
|
| 42 | 42 | |
| 43 | 43 | $gateway_list = array(); |
| 44 | 44 | |
| 45 | - foreach ( $gateways as $key => $gateway ) { |
|
| 46 | - if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) { |
|
| 47 | - $gateway_list[ $key ] = $gateway; |
|
| 45 | + foreach ($gateways as $key => $gateway) { |
|
| 46 | + if (isset($enabled[$key]) && $enabled[$key] == 1) { |
|
| 47 | + $gateway_list[$key] = $gateway; |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - if ( true === $sort ) { |
|
| 52 | - uasort( $gateway_list, 'wpinv_sort_gateway_order' ); |
|
| 51 | + if (true === $sort) { |
|
| 52 | + uasort($gateway_list, 'wpinv_sort_gateway_order'); |
|
| 53 | 53 | |
| 54 | 54 | // Reorder our gateways so the default is first |
| 55 | 55 | $default_gateway_id = wpinv_get_default_gateway(); |
| 56 | 56 | |
| 57 | - if ( wpinv_is_gateway_active( $default_gateway_id ) ) { |
|
| 58 | - $default_gateway = array( $default_gateway_id => $gateway_list[ $default_gateway_id ] ); |
|
| 59 | - unset( $gateway_list[ $default_gateway_id ] ); |
|
| 57 | + if (wpinv_is_gateway_active($default_gateway_id)) { |
|
| 58 | + $default_gateway = array($default_gateway_id => $gateway_list[$default_gateway_id]); |
|
| 59 | + unset($gateway_list[$default_gateway_id]); |
|
| 60 | 60 | |
| 61 | - $gateway_list = array_merge( $default_gateway, $gateway_list ); |
|
| 61 | + $gateway_list = array_merge($default_gateway, $gateway_list); |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - return apply_filters( 'wpinv_enabled_payment_gateways', $gateway_list ); |
|
| 65 | + return apply_filters('wpinv_enabled_payment_gateways', $gateway_list); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | -function wpinv_sort_gateway_order( $a, $b ) { |
|
| 68 | +function wpinv_sort_gateway_order($a, $b) { |
|
| 69 | 69 | return $a['ordering'] - $b['ordering']; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | -function wpinv_is_gateway_active( $gateway ) { |
|
| 72 | +function wpinv_is_gateway_active($gateway) { |
|
| 73 | 73 | $gateways = wpinv_get_enabled_payment_gateways(); |
| 74 | 74 | |
| 75 | - $ret = is_array($gateways) && $gateway ? array_key_exists( $gateway, $gateways ) : false; |
|
| 75 | + $ret = is_array($gateways) && $gateway ? array_key_exists($gateway, $gateways) : false; |
|
| 76 | 76 | |
| 77 | - return apply_filters( 'wpinv_is_gateway_active', $ret, $gateway, $gateways ); |
|
| 77 | + return apply_filters('wpinv_is_gateway_active', $ret, $gateway, $gateways); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | function wpinv_get_default_gateway() { |
| 81 | - $default = wpinv_get_option( 'default_gateway', 'paypal' ); |
|
| 81 | + $default = wpinv_get_option('default_gateway', 'paypal'); |
|
| 82 | 82 | |
| 83 | - if ( !wpinv_is_gateway_active( $default ) ) { |
|
| 83 | + if (!wpinv_is_gateway_active($default)) { |
|
| 84 | 84 | $gateways = wpinv_get_enabled_payment_gateways(); |
| 85 | - $gateways = array_keys( $gateways ); |
|
| 86 | - $default = reset( $gateways ); |
|
| 85 | + $gateways = array_keys($gateways); |
|
| 86 | + $default = reset($gateways); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - return apply_filters( 'wpinv_default_gateway', $default ); |
|
| 89 | + return apply_filters('wpinv_default_gateway', $default); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | -function wpinv_get_gateway_admin_label( $gateway ) { |
|
| 92 | +function wpinv_get_gateway_admin_label($gateway) { |
|
| 93 | 93 | $gateways = wpinv_get_payment_gateways(); |
| 94 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway; |
|
| 95 | - $payment = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false; |
|
| 94 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway; |
|
| 95 | + $payment = isset($_GET['id']) ? absint($_GET['id']) : false; |
|
| 96 | 96 | |
| 97 | - if( $gateway == 'manual' && $payment ) { |
|
| 98 | - if( !( (float)wpinv_payment_total( $payment ) > 0 ) ) { |
|
| 99 | - $label = __( 'Free Purchase', 'invoicing' ); |
|
| 97 | + if ($gateway == 'manual' && $payment) { |
|
| 98 | + if (!((float) wpinv_payment_total($payment) > 0)) { |
|
| 99 | + $label = __('Free Purchase', 'invoicing'); |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - return apply_filters( 'wpinv_gateway_admin_label', $label, $gateway ); |
|
| 103 | + return apply_filters('wpinv_gateway_admin_label', $label, $gateway); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | -function wpinv_get_gateway_description( $gateway ) { |
|
| 106 | +function wpinv_get_gateway_description($gateway) { |
|
| 107 | 107 | global $wpinv_options; |
| 108 | 108 | |
| 109 | - $description = ! empty( $wpinv_options[$gateway . '_desc'] ) ? $wpinv_options[$gateway . '_desc'] : ''; |
|
| 109 | + $description = !empty($wpinv_options[$gateway . '_desc']) ? $wpinv_options[$gateway . '_desc'] : ''; |
|
| 110 | 110 | |
| 111 | - return apply_filters( 'wpinv_gateway_description', $description, $gateway ); |
|
| 111 | + return apply_filters('wpinv_gateway_description', $description, $gateway); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | -function wpinv_get_gateway_button_label( $gateway ) { |
|
| 115 | - return apply_filters( 'wpinv_gateway_' . $gateway . '_button_label', '' ); |
|
| 114 | +function wpinv_get_gateway_button_label($gateway) { |
|
| 115 | + return apply_filters('wpinv_gateway_' . $gateway . '_button_label', ''); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | -function wpinv_get_gateway_checkout_label( $gateway ) { |
|
| 118 | +function wpinv_get_gateway_checkout_label($gateway) { |
|
| 119 | 119 | $gateways = wpinv_get_payment_gateways(); |
| 120 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway; |
|
| 120 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway; |
|
| 121 | 121 | |
| 122 | - if ( $gateway == 'none' ) { |
|
| 123 | - $label = __( 'None', 'invoicing' ); |
|
| 122 | + if ($gateway == 'none') { |
|
| 123 | + $label = __('None', 'invoicing'); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - return apply_filters( 'wpinv_gateway_checkout_label', ucfirst( $label ), $gateway ); |
|
| 126 | + return apply_filters('wpinv_gateway_checkout_label', ucfirst($label), $gateway); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | -function wpinv_settings_sections_gateways( $settings ) { |
|
| 129 | +function wpinv_settings_sections_gateways($settings) { |
|
| 130 | 130 | $gateways = wpinv_get_payment_gateways(); |
| 131 | 131 | |
| 132 | 132 | if (!empty($gateways)) { |
| 133 | - foreach ($gateways as $key => $gateway) { |
|
| 133 | + foreach ($gateways as $key => $gateway) { |
|
| 134 | 134 | $settings[$key] = $gateway['admin_label']; |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | return $settings; |
| 139 | 139 | } |
| 140 | -add_filter( 'wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1 ); |
|
| 140 | +add_filter('wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1); |
|
| 141 | 141 | |
| 142 | 142 | /** |
| 143 | 143 | * Adds GateWay settings. |
| 144 | 144 | */ |
| 145 | -function wpinv_settings_gateways( $settings ) { |
|
| 145 | +function wpinv_settings_gateways($settings) { |
|
| 146 | 146 | |
| 147 | 147 | // Loop through each gateway. |
| 148 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
| 148 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
| 149 | 149 | |
| 150 | 150 | $gateway_settings = array( |
| 151 | 151 | |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | "{$key}_header" => array( |
| 154 | 154 | |
| 155 | 155 | 'id' => "{$key}_gateway_header", |
| 156 | - 'name' => '<h3>' . wp_sprintf( __( '%s Settings', 'invoicing' ), $gateway['admin_label'] ) . '</h3>', |
|
| 156 | + 'name' => '<h3>' . wp_sprintf(__('%s Settings', 'invoicing'), $gateway['admin_label']) . '</h3>', |
|
| 157 | 157 | 'custom' => $key, |
| 158 | 158 | 'type' => 'gateway_header', |
| 159 | 159 | |
@@ -162,56 +162,56 @@ discard block |
||
| 162 | 162 | // Activate/Deactivate a gateway. |
| 163 | 163 | "{$key}_active" => array( |
| 164 | 164 | 'id' => $key . '_active', |
| 165 | - 'name' => __( 'Activate', 'invoicing' ), |
|
| 166 | - 'desc' => wp_sprintf( __( 'Enable %s', 'invoicing' ), $gateway['admin_label'] ), |
|
| 165 | + 'name' => __('Activate', 'invoicing'), |
|
| 166 | + 'desc' => wp_sprintf(__('Enable %s', 'invoicing'), $gateway['admin_label']), |
|
| 167 | 167 | 'type' => 'checkbox', |
| 168 | 168 | ), |
| 169 | 169 | |
| 170 | 170 | // Activate/Deactivate sandbox. |
| 171 | 171 | "{$key}_sandbox" => array( |
| 172 | 172 | 'id' => $key . '_sandbox', |
| 173 | - 'name' => __( 'Sandbox', 'invoicing' ), |
|
| 174 | - 'desc' => __( 'Enable sandbox to test payments', 'invoicing' ), |
|
| 173 | + 'name' => __('Sandbox', 'invoicing'), |
|
| 174 | + 'desc' => __('Enable sandbox to test payments', 'invoicing'), |
|
| 175 | 175 | 'type' => 'checkbox', |
| 176 | 176 | ), |
| 177 | 177 | |
| 178 | 178 | // Checkout title. |
| 179 | 179 | "{$key}_title" => array( |
| 180 | 180 | 'id' => $key . '_title', |
| 181 | - 'name' => __( 'Checkout Title', 'invoicing' ), |
|
| 182 | - 'std' => isset( $gateway['checkout_label'] ) ? $gateway['checkout_label'] : '', |
|
| 181 | + 'name' => __('Checkout Title', 'invoicing'), |
|
| 182 | + 'std' => isset($gateway['checkout_label']) ? $gateway['checkout_label'] : '', |
|
| 183 | 183 | 'type' => 'text', |
| 184 | 184 | ), |
| 185 | 185 | |
| 186 | 186 | // Checkout description. |
| 187 | 187 | "{$key}_desc" => array( |
| 188 | 188 | 'id' => $key . '_desc', |
| 189 | - 'name' => __( 'Checkout Description', 'invoicing' ), |
|
| 190 | - 'std' => apply_filters( "getpaid_default_{$key}_checkout_description", '' ), |
|
| 189 | + 'name' => __('Checkout Description', 'invoicing'), |
|
| 190 | + 'std' => apply_filters("getpaid_default_{$key}_checkout_description", ''), |
|
| 191 | 191 | 'type' => 'text', |
| 192 | 192 | ), |
| 193 | 193 | |
| 194 | 194 | // Checkout order. |
| 195 | 195 | "{$key}_ordering" => array( |
| 196 | 196 | 'id' => $key . '_ordering', |
| 197 | - 'name' => __( 'Priority', 'invoicing' ), |
|
| 198 | - 'std' => apply_filters( "getpaid_default_{$key}_checkout_description", '' ), |
|
| 197 | + 'name' => __('Priority', 'invoicing'), |
|
| 198 | + 'std' => apply_filters("getpaid_default_{$key}_checkout_description", ''), |
|
| 199 | 199 | 'type' => 'number', |
| 200 | 200 | 'step' => '1', |
| 201 | 201 | 'min' => '-100000', |
| 202 | 202 | 'max' => '100000', |
| 203 | - 'std' => isset( $gateway['ordering'] ) ? $gateway['ordering'] : '10', |
|
| 203 | + 'std' => isset($gateway['ordering']) ? $gateway['ordering'] : '10', |
|
| 204 | 204 | ), |
| 205 | 205 | |
| 206 | 206 | ); |
| 207 | 207 | |
| 208 | 208 | // Maybe remove the sandbox. |
| 209 | - if ( ! apply_filters( "wpinv_{$key}_supports_sandbox", false ) ) { |
|
| 210 | - unset( $gateway_settings["{$key}_sandbox"] ); |
|
| 209 | + if (!apply_filters("wpinv_{$key}_supports_sandbox", false)) { |
|
| 210 | + unset($gateway_settings["{$key}_sandbox"]); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - $gateway_settings = apply_filters( 'wpinv_gateway_settings', $gateway_settings, $key, $gateway ); |
|
| 214 | - $gateway_settings = apply_filters( 'wpinv_gateway_settings_' . $key, $gateway_settings, $gateway ); |
|
| 213 | + $gateway_settings = apply_filters('wpinv_gateway_settings', $gateway_settings, $key, $gateway); |
|
| 214 | + $gateway_settings = apply_filters('wpinv_gateway_settings_' . $key, $gateway_settings, $gateway); |
|
| 215 | 215 | |
| 216 | 216 | $settings[$key] = $gateway_settings; |
| 217 | 217 | } |
@@ -219,57 +219,57 @@ discard block |
||
| 219 | 219 | return $settings; |
| 220 | 220 | |
| 221 | 221 | } |
| 222 | -add_filter( 'wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1 ); |
|
| 222 | +add_filter('wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1); |
|
| 223 | 223 | |
| 224 | -function wpinv_gateway_header_callback( $args ) { |
|
| 225 | - echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr( $args['custom'] ) . '" />'; |
|
| 224 | +function wpinv_gateway_header_callback($args) { |
|
| 225 | + echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr($args['custom']) . '" />'; |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | -function wpinv_get_gateway_supports( $gateway ) { |
|
| 228 | +function wpinv_get_gateway_supports($gateway) { |
|
| 229 | 229 | $gateways = wpinv_get_enabled_payment_gateways(); |
| 230 | - $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array(); |
|
| 231 | - return apply_filters( 'wpinv_gateway_supports', $supports, $gateway ); |
|
| 230 | + $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array(); |
|
| 231 | + return apply_filters('wpinv_gateway_supports', $supports, $gateway); |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | -function wpinv_get_chosen_gateway( $invoice_id = 0 ) { |
|
| 235 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
| 234 | +function wpinv_get_chosen_gateway($invoice_id = 0) { |
|
| 235 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
| 236 | 236 | |
| 237 | 237 | $chosen = false; |
| 238 | - if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) { |
|
| 238 | + if ($invoice_id > 0 && $invoice = wpinv_get_invoice($invoice_id)) { |
|
| 239 | 239 | $chosen = $invoice->get_gateway(); |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - $chosen = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen; |
|
| 242 | + $chosen = isset($_REQUEST['payment-mode']) ? sanitize_text_field($_REQUEST['payment-mode']) : $chosen; |
|
| 243 | 243 | |
| 244 | - if ( false !== $chosen ) { |
|
| 245 | - $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen ); |
|
| 244 | + if (false !== $chosen) { |
|
| 245 | + $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - if ( ! empty ( $chosen ) ) { |
|
| 249 | - $enabled_gateway = urldecode( $chosen ); |
|
| 250 | - } else if ( !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) { |
|
| 248 | + if (!empty ($chosen)) { |
|
| 249 | + $enabled_gateway = urldecode($chosen); |
|
| 250 | + } else if (!empty($invoice) && (float) $invoice->get_subtotal() <= 0) { |
|
| 251 | 251 | $enabled_gateway = 'manual'; |
| 252 | 252 | } else { |
| 253 | 253 | $enabled_gateway = wpinv_get_default_gateway(); |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) { |
|
| 257 | - if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){ |
|
| 256 | + if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) { |
|
| 257 | + if (wpinv_is_gateway_active(wpinv_get_default_gateway())) { |
|
| 258 | 258 | $enabled_gateway = wpinv_get_default_gateway(); |
| 259 | - }else{ |
|
| 259 | + } else { |
|
| 260 | 260 | $enabled_gateway = $gateways[0]; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway ); |
|
| 265 | + return apply_filters('wpinv_chosen_gateway', $enabled_gateway); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | -function wpinv_record_gateway_error( $title = '', $message = '', $parent = 0 ) { |
|
| 269 | - return wpinv_error_log( $message, $title ); |
|
| 268 | +function wpinv_record_gateway_error($title = '', $message = '', $parent = 0) { |
|
| 269 | + return wpinv_error_log($message, $title); |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | -function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
| 272 | +function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
| 273 | 273 | $ret = 0; |
| 274 | 274 | $args = array( |
| 275 | 275 | 'meta_key' => '_wpinv_gateway', |
@@ -280,48 +280,48 @@ discard block |
||
| 280 | 280 | 'fields' => 'ids' |
| 281 | 281 | ); |
| 282 | 282 | |
| 283 | - $payments = new WP_Query( $args ); |
|
| 283 | + $payments = new WP_Query($args); |
|
| 284 | 284 | |
| 285 | - if( $payments ) |
|
| 285 | + if ($payments) |
|
| 286 | 286 | $ret = $payments->post_count; |
| 287 | 287 | return $ret; |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | -function wpinv_settings_update_gateways( $input ) { |
|
| 290 | +function wpinv_settings_update_gateways($input) { |
|
| 291 | 291 | global $wpinv_options; |
| 292 | 292 | |
| 293 | - if ( !empty( $input['save_gateway'] ) ) { |
|
| 294 | - $gateways = wpinv_get_option( 'gateways', false ); |
|
| 293 | + if (!empty($input['save_gateway'])) { |
|
| 294 | + $gateways = wpinv_get_option('gateways', false); |
|
| 295 | 295 | $gateways = !empty($gateways) ? $gateways : array(); |
| 296 | 296 | $gateway = $input['save_gateway']; |
| 297 | 297 | |
| 298 | - if ( !empty( $input[$gateway . '_active'] ) ) { |
|
| 298 | + if (!empty($input[$gateway . '_active'])) { |
|
| 299 | 299 | $gateways[$gateway] = 1; |
| 300 | 300 | } else { |
| 301 | - if ( isset( $gateways[$gateway] ) ) { |
|
| 302 | - unset( $gateways[$gateway] ); |
|
| 301 | + if (isset($gateways[$gateway])) { |
|
| 302 | + unset($gateways[$gateway]); |
|
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | $input['gateways'] = $gateways; |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | - if ( !empty( $input['default_gateway'] ) ) { |
|
| 309 | + if (!empty($input['default_gateway'])) { |
|
| 310 | 310 | $gateways = wpinv_get_payment_gateways(); |
| 311 | 311 | |
| 312 | - foreach ( $gateways as $key => $gateway ) { |
|
| 313 | - $active = 0; |
|
| 314 | - if ( !empty( $input['gateways'] ) && !empty( $input['gateways'][$key] ) ) { |
|
| 312 | + foreach ($gateways as $key => $gateway) { |
|
| 313 | + $active = 0; |
|
| 314 | + if (!empty($input['gateways']) && !empty($input['gateways'][$key])) { |
|
| 315 | 315 | $active = 1; |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | $input[$key . '_active'] = $active; |
| 319 | 319 | |
| 320 | - if ( empty( $wpinv_options[$key . '_title'] ) ) { |
|
| 320 | + if (empty($wpinv_options[$key . '_title'])) { |
|
| 321 | 321 | $input[$key . '_title'] = $gateway['checkout_label']; |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - if ( !isset( $wpinv_options[$key . '_ordering'] ) && isset( $gateway['ordering'] ) ) { |
|
| 324 | + if (!isset($wpinv_options[$key . '_ordering']) && isset($gateway['ordering'])) { |
|
| 325 | 325 | $input[$key . '_ordering'] = $gateway['ordering']; |
| 326 | 326 | } |
| 327 | 327 | } |
@@ -329,27 +329,27 @@ discard block |
||
| 329 | 329 | |
| 330 | 330 | return $input; |
| 331 | 331 | } |
| 332 | -add_filter( 'wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1 ); |
|
| 332 | +add_filter('wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1); |
|
| 333 | 333 | |
| 334 | 334 | // PayPal Standard settings |
| 335 | -function wpinv_gateway_settings_paypal( $setting ) { |
|
| 336 | - $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing' ); |
|
| 337 | - $setting['paypal_desc']['std'] = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' ); |
|
| 335 | +function wpinv_gateway_settings_paypal($setting) { |
|
| 336 | + $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __('( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing'); |
|
| 337 | + $setting['paypal_desc']['std'] = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing'); |
|
| 338 | 338 | |
| 339 | 339 | $setting['paypal_sandbox'] = array( |
| 340 | 340 | 'type' => 'checkbox', |
| 341 | 341 | 'id' => 'paypal_sandbox', |
| 342 | - 'name' => __( 'PayPal Sandbox', 'invoicing' ), |
|
| 343 | - 'desc' => __( 'PayPal sandbox can be used to test payments.', 'invoicing' ), |
|
| 342 | + 'name' => __('PayPal Sandbox', 'invoicing'), |
|
| 343 | + 'desc' => __('PayPal sandbox can be used to test payments.', 'invoicing'), |
|
| 344 | 344 | 'std' => 1 |
| 345 | 345 | ); |
| 346 | 346 | |
| 347 | 347 | $setting['paypal_email'] = array( |
| 348 | 348 | 'type' => 'text', |
| 349 | 349 | 'id' => 'paypal_email', |
| 350 | - 'name' => __( 'PayPal Email', 'invoicing' ), |
|
| 351 | - 'desc' => __( 'Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing' ), |
|
| 352 | - 'std' => __( '[email protected]', 'invoicing' ), |
|
| 350 | + 'name' => __('PayPal Email', 'invoicing'), |
|
| 351 | + 'desc' => __('Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing'), |
|
| 352 | + 'std' => __('[email protected]', 'invoicing'), |
|
| 353 | 353 | ); |
| 354 | 354 | /* |
| 355 | 355 | $setting['paypal_ipn_url'] = array( |
@@ -363,18 +363,18 @@ discard block |
||
| 363 | 363 | |
| 364 | 364 | return $setting; |
| 365 | 365 | } |
| 366 | -add_filter( 'wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1 ); |
|
| 366 | +add_filter('wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1); |
|
| 367 | 367 | |
| 368 | 368 | /** |
| 369 | 369 | * Displays the ipn url field. |
| 370 | 370 | */ |
| 371 | -function wpinv_ipn_url_callback( $args ) { |
|
| 372 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 371 | +function wpinv_ipn_url_callback($args) { |
|
| 372 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 373 | 373 | |
| 374 | 374 | $attrs = $args['readonly'] ? ' readonly' : ''; |
| 375 | 375 | |
| 376 | - $html = '<input class="regular-text" type="text" ' . $attrs . ' value="' . esc_attr( $args['std'] ) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" onClick="this.select()">'; |
|
| 377 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>'; |
|
| 376 | + $html = '<input class="regular-text" type="text" ' . $attrs . ' value="' . esc_attr($args['std']) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" onClick="this.select()">'; |
|
| 377 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>'; |
|
| 378 | 378 | |
| 379 | 379 | echo $html; |
| 380 | 380 | } |
@@ -386,9 +386,9 @@ discard block |
||
| 386 | 386 | * |
| 387 | 387 | * @return bool |
| 388 | 388 | */ |
| 389 | -function wpinv_is_test_mode( $gateway = '' ) { |
|
| 390 | - $sandbox = empty( $gateway ) ? false : wpinv_get_option( "{$gateway}_sandbox", false ); |
|
| 391 | - return apply_filters( 'wpinv_is_test_mode', $sandbox, $gateway ); |
|
| 389 | +function wpinv_is_test_mode($gateway = '') { |
|
| 390 | + $sandbox = empty($gateway) ? false : wpinv_get_option("{$gateway}_sandbox", false); |
|
| 391 | + return apply_filters('wpinv_is_test_mode', $sandbox, $gateway); |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | /** |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | * |
| 400 | 400 | * @return string |
| 401 | 401 | */ |
| 402 | -function wpinv_get_ipn_url( $gateway = false, $args = array() ) { |
|
| 402 | +function wpinv_get_ipn_url($gateway = false, $args = array()) { |
|
| 403 | 403 | $args = wp_parse_args( |
| 404 | 404 | array( |
| 405 | 405 | 'wpi-listener' => 'IPN', |
@@ -408,37 +408,37 @@ discard block |
||
| 408 | 408 | $args |
| 409 | 409 | ); |
| 410 | 410 | |
| 411 | - return apply_filters( 'wpinv_ipn_url', add_query_arg( $args, home_url( 'index.php' ) ), $gateway, $args ); |
|
| 411 | + return apply_filters('wpinv_ipn_url', add_query_arg($args, home_url('index.php')), $gateway, $args); |
|
| 412 | 412 | |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | /** |
| 416 | 416 | * Retrieves request data with slashes removed slashes. |
| 417 | 417 | */ |
| 418 | -function wpinv_get_post_data( $method = 'request' ) { |
|
| 418 | +function wpinv_get_post_data($method = 'request') { |
|
| 419 | 419 | |
| 420 | - if ( $method == 'post' ) { |
|
| 421 | - return wp_unslash( $_POST ); |
|
| 420 | + if ($method == 'post') { |
|
| 421 | + return wp_unslash($_POST); |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | - if ( $method == 'get' ) { |
|
| 425 | - return wp_unslash( $_GET ); |
|
| 424 | + if ($method == 'get') { |
|
| 425 | + return wp_unslash($_GET); |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - return wp_unslash( $_REQUEST ); |
|
| 428 | + return wp_unslash($_REQUEST); |
|
| 429 | 429 | |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | /** |
| 433 | 433 | * Checks if a given gateway supports subscription payments. |
| 434 | 434 | */ |
| 435 | -function wpinv_gateway_support_subscription( $gateway ) { |
|
| 435 | +function wpinv_gateway_support_subscription($gateway) { |
|
| 436 | 436 | $supports = false; |
| 437 | 437 | |
| 438 | - if ( wpinv_is_gateway_active( $gateway ) ) { |
|
| 439 | - $supports = apply_filters( 'wpinv_' . $gateway . '_support_subscription', $supports ); |
|
| 438 | + if (wpinv_is_gateway_active($gateway)) { |
|
| 439 | + $supports = apply_filters('wpinv_' . $gateway . '_support_subscription', $supports); |
|
| 440 | 440 | |
| 441 | - $supports = apply_filters( 'getapid_gateway_supports_subscription', $supports, $gateway ); |
|
| 441 | + $supports = apply_filters('getapid_gateway_supports_subscription', $supports, $gateway); |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | return $supports; |
@@ -450,14 +450,14 @@ discard block |
||
| 450 | 450 | * @param array $gateways an array of gateways. |
| 451 | 451 | * @param GetPaid_Payment_Form $form payment form. |
| 452 | 452 | */ |
| 453 | -function wpinv_payment_gateways_on_cart( $gateways, $form ) { |
|
| 453 | +function wpinv_payment_gateways_on_cart($gateways, $form) { |
|
| 454 | 454 | |
| 455 | - if ( $form->is_recurring() ) { |
|
| 455 | + if ($form->is_recurring()) { |
|
| 456 | 456 | |
| 457 | - foreach ( array_keys( $gateways ) as $gateway ) { |
|
| 457 | + foreach (array_keys($gateways) as $gateway) { |
|
| 458 | 458 | |
| 459 | - if ( ! wpinv_gateway_support_subscription( $gateway ) ) { |
|
| 460 | - unset( $gateways[$gateway] ); |
|
| 459 | + if (!wpinv_gateway_support_subscription($gateway)) { |
|
| 460 | + unset($gateways[$gateway]); |
|
| 461 | 461 | } |
| 462 | 462 | |
| 463 | 463 | } |
@@ -466,4 +466,4 @@ discard block |
||
| 466 | 466 | |
| 467 | 467 | return $gateways; |
| 468 | 468 | } |
| 469 | -add_filter( 'getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2 ); |
|
| 469 | +add_filter('getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2); |
|
@@ -70,8 +70,9 @@ discard block |
||
| 70 | 70 | if( !empty( $tax_rates ) ) { |
| 71 | 71 | // Locate the tax rate for this country / state, if it exists |
| 72 | 72 | foreach( $tax_rates as $key => $tax_rate ) { |
| 73 | - if( $country != $tax_rate['country'] ) |
|
| 74 | - continue; |
|
| 73 | + if( $country != $tax_rate['country'] ) { |
|
| 74 | + continue; |
|
| 75 | + } |
|
| 75 | 76 | |
| 76 | 77 | if( !empty( $tax_rate['global'] ) ) { |
| 77 | 78 | if( !empty( $tax_rate['rate'] ) ) { |
@@ -79,8 +80,9 @@ discard block |
||
| 79 | 80 | } |
| 80 | 81 | } else { |
| 81 | 82 | |
| 82 | - if( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) ) |
|
| 83 | - continue; |
|
| 83 | + if( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) ) { |
|
| 84 | + continue; |
|
| 85 | + } |
|
| 84 | 86 | |
| 85 | 87 | $state_rate = $tax_rate['rate']; |
| 86 | 88 | if( 0 !== $state_rate || !empty( $state_rate ) ) { |
@@ -183,8 +185,9 @@ discard block |
||
| 183 | 185 | } |
| 184 | 186 | |
| 185 | 187 | function wpinv_cart_needs_tax_address_fields() { |
| 186 | - if( !wpinv_is_cart_taxed() ) |
|
| 187 | - return false; |
|
| 188 | + if( !wpinv_is_cart_taxed() ) { |
|
| 189 | + return false; |
|
| 190 | + } |
|
| 188 | 191 | |
| 189 | 192 | return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' ); |
| 190 | 193 | } |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // MUST have WordPress. |
| 3 | -if ( !defined( 'WPINC' ) ) { |
|
| 4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 3 | +if (!defined('WPINC')) { |
|
| 4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | /** |
@@ -18,8 +18,8 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | * @return bool |
| 20 | 20 | */ |
| 21 | -function getpaid_is_eu_state( $country ) { |
|
| 22 | - return WPInv_EUVat::is_eu_state( $country ); |
|
| 21 | +function getpaid_is_eu_state($country) { |
|
| 22 | + return WPInv_EUVat::is_eu_state($country); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -27,8 +27,8 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | * @return bool |
| 29 | 29 | */ |
| 30 | -function getpaid_is_gst_country( $country ) { |
|
| 31 | - return WPInv_EUVat::is_gst_country( $country ); |
|
| 30 | +function getpaid_is_gst_country($country) { |
|
| 31 | + return WPInv_EUVat::is_gst_country($country); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -42,117 +42,117 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | function wpinv_use_taxes() { |
| 45 | - $ret = wpinv_get_option( 'enable_taxes', false ); |
|
| 45 | + $ret = wpinv_get_option('enable_taxes', false); |
|
| 46 | 46 | |
| 47 | - return (bool) apply_filters( 'wpinv_use_taxes', $ret ); |
|
| 47 | + return (bool) apply_filters('wpinv_use_taxes', $ret); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | function wpinv_get_tax_rates() { |
| 51 | - $rates = get_option( 'wpinv_tax_rates', array() ); |
|
| 51 | + $rates = get_option('wpinv_tax_rates', array()); |
|
| 52 | 52 | |
| 53 | - return apply_filters( 'wpinv_get_tax_rates', $rates ); |
|
| 53 | + return apply_filters('wpinv_get_tax_rates', $rates); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | -function wpinv_get_tax_rate( $country = false, $state = false, $item_id = 0 ) { |
|
| 56 | +function wpinv_get_tax_rate($country = false, $state = false, $item_id = 0) { |
|
| 57 | 57 | global $wpinv_euvat, $wpi_tax_rates, $wpi_userID; |
| 58 | - $wpi_tax_rates = !empty( $wpi_tax_rates ) ? $wpi_tax_rates : array(); |
|
| 58 | + $wpi_tax_rates = !empty($wpi_tax_rates) ? $wpi_tax_rates : array(); |
|
| 59 | 59 | |
| 60 | - if ( !empty( $wpi_tax_rates ) && !empty( $item_id ) && isset( $wpi_tax_rates[$item_id] ) ) { |
|
| 60 | + if (!empty($wpi_tax_rates) && !empty($item_id) && isset($wpi_tax_rates[$item_id])) { |
|
| 61 | 61 | return $wpi_tax_rates[$item_id]; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - if ( !$wpinv_euvat->item_is_taxable( $item_id, $country, $state ) ) { |
|
| 64 | + if (!$wpinv_euvat->item_is_taxable($item_id, $country, $state)) { |
|
| 65 | 65 | $wpi_tax_rates[$item_id] = 0; |
| 66 | 66 | return 0; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | $is_global = false; |
| 70 | - if ( $item_id == 'global' ) { |
|
| 70 | + if ($item_id == 'global') { |
|
| 71 | 71 | $is_global = true; |
| 72 | 72 | $item_id = 0; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - $rate = (float)wpinv_get_option( 'tax_rate', 0 ); |
|
| 76 | - $user_address = wpinv_get_user_address( $wpi_userID ); |
|
| 75 | + $rate = (float) wpinv_get_option('tax_rate', 0); |
|
| 76 | + $user_address = wpinv_get_user_address($wpi_userID); |
|
| 77 | 77 | |
| 78 | - if( empty( $country ) ) { |
|
| 79 | - if( !empty( $_POST['wpinv_country'] ) ) { |
|
| 78 | + if (empty($country)) { |
|
| 79 | + if (!empty($_POST['wpinv_country'])) { |
|
| 80 | 80 | $country = $_POST['wpinv_country']; |
| 81 | - } elseif( !empty( $_POST['wpinv_country'] ) ) { |
|
| 81 | + } elseif (!empty($_POST['wpinv_country'])) { |
|
| 82 | 82 | $country = $_POST['wpinv_country']; |
| 83 | - } elseif( !empty( $_POST['country'] ) ) { |
|
| 83 | + } elseif (!empty($_POST['country'])) { |
|
| 84 | 84 | $country = $_POST['country']; |
| 85 | - } elseif( is_user_logged_in() && !empty( $user_address ) ) { |
|
| 85 | + } elseif (is_user_logged_in() && !empty($user_address)) { |
|
| 86 | 86 | $country = $user_address['country']; |
| 87 | 87 | } |
| 88 | - $country = !empty( $country ) ? $country : wpinv_get_default_country(); |
|
| 88 | + $country = !empty($country) ? $country : wpinv_get_default_country(); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - if( empty( $state ) ) { |
|
| 92 | - if( !empty( $_POST['wpinv_state'] ) ) { |
|
| 91 | + if (empty($state)) { |
|
| 92 | + if (!empty($_POST['wpinv_state'])) { |
|
| 93 | 93 | $state = $_POST['wpinv_state']; |
| 94 | - } elseif( !empty( $_POST['wpinv_state'] ) ) { |
|
| 94 | + } elseif (!empty($_POST['wpinv_state'])) { |
|
| 95 | 95 | $state = $_POST['wpinv_state']; |
| 96 | - } elseif( !empty( $_POST['state'] ) ) { |
|
| 96 | + } elseif (!empty($_POST['state'])) { |
|
| 97 | 97 | $state = $_POST['state']; |
| 98 | - } elseif( is_user_logged_in() && !empty( $user_address ) ) { |
|
| 98 | + } elseif (is_user_logged_in() && !empty($user_address)) { |
|
| 99 | 99 | $state = $user_address['state']; |
| 100 | 100 | } |
| 101 | - $state = !empty( $state ) ? $state : wpinv_get_default_state(); |
|
| 101 | + $state = !empty($state) ? $state : wpinv_get_default_state(); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - if( !empty( $country ) ) { |
|
| 105 | - $tax_rates = wpinv_get_tax_rates(); |
|
| 104 | + if (!empty($country)) { |
|
| 105 | + $tax_rates = wpinv_get_tax_rates(); |
|
| 106 | 106 | |
| 107 | - if( !empty( $tax_rates ) ) { |
|
| 107 | + if (!empty($tax_rates)) { |
|
| 108 | 108 | // Locate the tax rate for this country / state, if it exists |
| 109 | - foreach( $tax_rates as $key => $tax_rate ) { |
|
| 110 | - if( $country != $tax_rate['country'] ) |
|
| 109 | + foreach ($tax_rates as $key => $tax_rate) { |
|
| 110 | + if ($country != $tax_rate['country']) |
|
| 111 | 111 | continue; |
| 112 | 112 | |
| 113 | - if( !empty( $tax_rate['global'] ) ) { |
|
| 114 | - if( !empty( $tax_rate['rate'] ) ) { |
|
| 115 | - $rate = number_format( $tax_rate['rate'], 4 ); |
|
| 113 | + if (!empty($tax_rate['global'])) { |
|
| 114 | + if (!empty($tax_rate['rate'])) { |
|
| 115 | + $rate = number_format($tax_rate['rate'], 4); |
|
| 116 | 116 | } |
| 117 | 117 | } else { |
| 118 | 118 | |
| 119 | - if( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) ) |
|
| 119 | + if (empty($tax_rate['state']) || strtolower($state) != strtolower($tax_rate['state'])) |
|
| 120 | 120 | continue; |
| 121 | 121 | |
| 122 | 122 | $state_rate = $tax_rate['rate']; |
| 123 | - if( 0 !== $state_rate || !empty( $state_rate ) ) { |
|
| 124 | - $rate = number_format( $state_rate, 4 ); |
|
| 123 | + if (0 !== $state_rate || !empty($state_rate)) { |
|
| 124 | + $rate = number_format($state_rate, 4); |
|
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - $rate = apply_filters( 'wpinv_tax_rate', $rate, $country, $state, $item_id ); |
|
| 131 | + $rate = apply_filters('wpinv_tax_rate', $rate, $country, $state, $item_id); |
|
| 132 | 132 | |
| 133 | - if ( !empty( $item_id ) ) { |
|
| 133 | + if (!empty($item_id)) { |
|
| 134 | 134 | $wpi_tax_rates[$item_id] = $rate; |
| 135 | - } else if ( $is_global ) { |
|
| 135 | + } else if ($is_global) { |
|
| 136 | 136 | $wpi_tax_rates['global'] = $rate; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | return $rate; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | -function wpinv_get_formatted_tax_rate( $country = false, $state = false, $item_id ) { |
|
| 143 | - $rate = wpinv_get_tax_rate( $country, $state, $item_id ); |
|
| 144 | - $rate = round( $rate, 4 ); |
|
| 142 | +function wpinv_get_formatted_tax_rate($country = false, $state = false, $item_id) { |
|
| 143 | + $rate = wpinv_get_tax_rate($country, $state, $item_id); |
|
| 144 | + $rate = round($rate, 4); |
|
| 145 | 145 | $formatted = $rate .= '%'; |
| 146 | - return apply_filters( 'wpinv_formatted_tax_rate', $formatted, $rate, $country, $state, $item_id ); |
|
| 146 | + return apply_filters('wpinv_formatted_tax_rate', $formatted, $rate, $country, $state, $item_id); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | -function wpinv_calculate_tax( $amount = 0, $country = false, $state = false, $item_id = 0 ) { |
|
| 150 | - $rate = wpinv_get_tax_rate( $country, $state, $item_id ); |
|
| 149 | +function wpinv_calculate_tax($amount = 0, $country = false, $state = false, $item_id = 0) { |
|
| 150 | + $rate = wpinv_get_tax_rate($country, $state, $item_id); |
|
| 151 | 151 | $tax = 0.00; |
| 152 | 152 | |
| 153 | - if ( wpinv_use_taxes() ) { |
|
| 154 | - if ( wpinv_prices_include_tax() ) { |
|
| 155 | - $pre_tax = ( $amount / ( ( 1 + $rate ) * 0.01 ) ); |
|
| 153 | + if (wpinv_use_taxes()) { |
|
| 154 | + if (wpinv_prices_include_tax()) { |
|
| 155 | + $pre_tax = ($amount / ((1 + $rate) * 0.01)); |
|
| 156 | 156 | $tax = $amount - $pre_tax; |
| 157 | 157 | } else { |
| 158 | 158 | $tax = $amount * $rate * 0.01; |
@@ -160,46 +160,46 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - return apply_filters( 'wpinv_taxed_amount', $tax, $rate, $country, $state, $item_id ); |
|
| 163 | + return apply_filters('wpinv_taxed_amount', $tax, $rate, $country, $state, $item_id); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | function wpinv_prices_include_tax() { |
| 167 | 167 | return false; // TODO |
| 168 | - $ret = ( wpinv_get_option( 'prices_include_tax', false ) == 'yes' && wpinv_use_taxes() ); |
|
| 168 | + $ret = (wpinv_get_option('prices_include_tax', false) == 'yes' && wpinv_use_taxes()); |
|
| 169 | 169 | |
| 170 | - return apply_filters( 'wpinv_prices_include_tax', $ret ); |
|
| 170 | + return apply_filters('wpinv_prices_include_tax', $ret); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | -function wpinv_sales_tax_for_year( $year = null ) { |
|
| 174 | - return wpinv_price( wpinv_format_amount( wpinv_get_sales_tax_for_year( $year ) ) ); |
|
| 173 | +function wpinv_sales_tax_for_year($year = null) { |
|
| 174 | + return wpinv_price(wpinv_format_amount(wpinv_get_sales_tax_for_year($year))); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | -function wpinv_get_sales_tax_for_year( $year = null ) { |
|
| 177 | +function wpinv_get_sales_tax_for_year($year = null) { |
|
| 178 | 178 | global $wpdb; |
| 179 | 179 | |
| 180 | 180 | // Start at zero |
| 181 | 181 | $tax = 0; |
| 182 | 182 | |
| 183 | - if ( ! empty( $year ) ) { |
|
| 183 | + if (!empty($year)) { |
|
| 184 | 184 | $args = array( |
| 185 | 185 | 'post_type' => 'wpi_invoice', |
| 186 | - 'post_status' => array( 'publish' ), |
|
| 186 | + 'post_status' => array('publish'), |
|
| 187 | 187 | 'posts_per_page' => -1, |
| 188 | 188 | 'year' => $year, |
| 189 | 189 | 'fields' => 'ids' |
| 190 | 190 | ); |
| 191 | 191 | |
| 192 | - $payments = get_posts( $args ); |
|
| 193 | - $payment_ids = implode( ',', $payments ); |
|
| 192 | + $payments = get_posts($args); |
|
| 193 | + $payment_ids = implode(',', $payments); |
|
| 194 | 194 | |
| 195 | - if ( count( $payments ) > 0 ) { |
|
| 195 | + if (count($payments) > 0) { |
|
| 196 | 196 | $sql = "SELECT SUM( meta_value ) FROM $wpdb->postmeta WHERE meta_key = '_wpinv_tax' AND post_id IN( $payment_ids )"; |
| 197 | - $tax = $wpdb->get_var( $sql ); |
|
| 197 | + $tax = $wpdb->get_var($sql); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - return apply_filters( 'wpinv_get_sales_tax_for_year', $tax, $year ); |
|
| 202 | + return apply_filters('wpinv_get_sales_tax_for_year', $tax, $year); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | function wpinv_is_cart_taxed() { |
@@ -208,33 +208,33 @@ discard block |
||
| 208 | 208 | |
| 209 | 209 | function wpinv_prices_show_tax_on_checkout() { |
| 210 | 210 | return false; // TODO |
| 211 | - $ret = ( wpinv_get_option( 'checkout_include_tax', false ) == 'yes' && wpinv_use_taxes() ); |
|
| 211 | + $ret = (wpinv_get_option('checkout_include_tax', false) == 'yes' && wpinv_use_taxes()); |
|
| 212 | 212 | |
| 213 | - return apply_filters( 'wpinv_taxes_on_prices_on_checkout', $ret ); |
|
| 213 | + return apply_filters('wpinv_taxes_on_prices_on_checkout', $ret); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | function wpinv_display_tax_rate() { |
| 217 | - $ret = wpinv_use_taxes() && wpinv_get_option( 'display_tax_rate', false ); |
|
| 217 | + $ret = wpinv_use_taxes() && wpinv_get_option('display_tax_rate', false); |
|
| 218 | 218 | |
| 219 | - return apply_filters( 'wpinv_display_tax_rate', $ret ); |
|
| 219 | + return apply_filters('wpinv_display_tax_rate', $ret); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | function wpinv_cart_needs_tax_address_fields() { |
| 223 | - if( !wpinv_is_cart_taxed() ) |
|
| 223 | + if (!wpinv_is_cart_taxed()) |
|
| 224 | 224 | return false; |
| 225 | 225 | |
| 226 | - return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' ); |
|
| 226 | + return !did_action('wpinv_after_cc_fields', 'wpinv_default_cc_address_fields'); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | -function wpinv_item_is_tax_exclusive( $item_id = 0 ) { |
|
| 230 | - $ret = (bool)get_post_meta( $item_id, '_wpinv_tax_exclusive', false ); |
|
| 231 | - return apply_filters( 'wpinv_is_tax_exclusive', $ret, $item_id ); |
|
| 229 | +function wpinv_item_is_tax_exclusive($item_id = 0) { |
|
| 230 | + $ret = (bool) get_post_meta($item_id, '_wpinv_tax_exclusive', false); |
|
| 231 | + return apply_filters('wpinv_is_tax_exclusive', $ret, $item_id); |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | -function wpinv_currency_decimal_filter( $decimals = 2 ) { |
|
| 234 | +function wpinv_currency_decimal_filter($decimals = 2) { |
|
| 235 | 235 | $currency = wpinv_get_currency(); |
| 236 | 236 | |
| 237 | - switch ( $currency ) { |
|
| 237 | + switch ($currency) { |
|
| 238 | 238 | case 'RIAL' : |
| 239 | 239 | case 'JPY' : |
| 240 | 240 | case 'TWD' : |
@@ -243,50 +243,50 @@ discard block |
||
| 243 | 243 | break; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - return apply_filters( 'wpinv_currency_decimal_count', $decimals, $currency ); |
|
| 246 | + return apply_filters('wpinv_currency_decimal_count', $decimals, $currency); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | function wpinv_tax_amount() { |
| 250 | 250 | $output = 0.00; |
| 251 | 251 | |
| 252 | - return apply_filters( 'wpinv_tax_amount', $output ); |
|
| 252 | + return apply_filters('wpinv_tax_amount', $output); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | // VAT Settings |
| 256 | -function wpinv_vat_rate_add_callback( $args ) { |
|
| 256 | +function wpinv_vat_rate_add_callback($args) { |
|
| 257 | 257 | ?> |
| 258 | - <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_add" type="button" value="<?php esc_attr_e( 'Add', 'invoicing' );?>" class="button button-primary" /> <i style="display:none;" class="fa fa-refresh fa-spin"></i></p> |
|
| 258 | + <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_add" type="button" value="<?php esc_attr_e('Add', 'invoicing'); ?>" class="button button-primary" /> <i style="display:none;" class="fa fa-refresh fa-spin"></i></p> |
|
| 259 | 259 | <?php |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | -function wpinv_vat_rate_delete_callback( $args ) { |
|
| 262 | +function wpinv_vat_rate_delete_callback($args) { |
|
| 263 | 263 | global $wpinv_euvat; |
| 264 | 264 | |
| 265 | 265 | $vat_classes = $wpinv_euvat->get_rate_classes(); |
| 266 | - $vat_class = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : ''; |
|
| 267 | - if ( isset( $vat_classes[$vat_class] ) ) { |
|
| 266 | + $vat_class = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : ''; |
|
| 267 | + if (isset($vat_classes[$vat_class])) { |
|
| 268 | 268 | ?> |
| 269 | - <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_delete" type="button" value="<?php echo wp_sprintf( esc_attr__( 'Delete class "%s"', 'invoicing' ), $vat_classes[$vat_class] );?>" class="button button-primary" /> <i style="display:none;" class="fa fa-refresh fa-spin"></i></p> |
|
| 269 | + <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_delete" type="button" value="<?php echo wp_sprintf(esc_attr__('Delete class "%s"', 'invoicing'), $vat_classes[$vat_class]); ?>" class="button button-primary" /> <i style="display:none;" class="fa fa-refresh fa-spin"></i></p> |
|
| 270 | 270 | <?php |
| 271 | 271 | } |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | -function wpinv_vat_rates_callback( $args ) { |
|
| 274 | +function wpinv_vat_rates_callback($args) { |
|
| 275 | 275 | global $wpinv_euvat; |
| 276 | 276 | |
| 277 | 277 | $vat_classes = $wpinv_euvat->get_rate_classes(); |
| 278 | - $vat_class = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : '_standard'; |
|
| 278 | + $vat_class = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : '_standard'; |
|
| 279 | 279 | |
| 280 | 280 | $eu_states = $wpinv_euvat->get_eu_states(); |
| 281 | 281 | $countries = wpinv_get_country_list(); |
| 282 | 282 | $vat_groups = $wpinv_euvat->get_vat_groups(); |
| 283 | - $rates = $wpinv_euvat->get_vat_rates( $vat_class ); |
|
| 283 | + $rates = $wpinv_euvat->get_vat_rates($vat_class); |
|
| 284 | 284 | ob_start(); |
| 285 | 285 | ?> |
| 286 | 286 | </td><tr> |
| 287 | 287 | <td colspan="2" class="wpinv_vat_tdbox"> |
| 288 | - <input type="hidden" name="wpi_vat_class" value="<?php echo $vat_class;?>" /> |
|
| 289 | - <p><?php echo ( isset( $args['desc'] ) ? $args['desc'] : '' ); ?></p> |
|
| 288 | + <input type="hidden" name="wpi_vat_class" value="<?php echo $vat_class; ?>" /> |
|
| 289 | + <p><?php echo (isset($args['desc']) ? $args['desc'] : ''); ?></p> |
|
| 290 | 290 | <table id="wpinv_vat_rates" class="wp-list-table widefat fixed posts"> |
| 291 | 291 | <colgroup> |
| 292 | 292 | <col width="50px" /> |
@@ -298,43 +298,43 @@ discard block |
||
| 298 | 298 | </colgroup> |
| 299 | 299 | <thead> |
| 300 | 300 | <tr> |
| 301 | - <th scope="col" colspan="2" class="wpinv_vat_country_name"><?php _e( 'Country', 'invoicing' ); ?></th> |
|
| 302 | - <th scope="col" class="wpinv_vat_global" title="<?php esc_attr_e( 'Apply rate to whole country', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th> |
|
| 303 | - <th scope="col" class="wpinv_vat_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> |
|
| 304 | - <th scope="col" class="wpinv_vat_name"><?php _e( 'VAT Name', 'invoicing' ); ?></th> |
|
| 305 | - <th scope="col" class="wpinv_vat_group"><?php _e( 'Tax Group', 'invoicing' ); ?></th> |
|
| 301 | + <th scope="col" colspan="2" class="wpinv_vat_country_name"><?php _e('Country', 'invoicing'); ?></th> |
|
| 302 | + <th scope="col" class="wpinv_vat_global" title="<?php esc_attr_e('Apply rate to whole country', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th> |
|
| 303 | + <th scope="col" class="wpinv_vat_rate"><?php _e('Rate %', 'invoicing'); ?></th> |
|
| 304 | + <th scope="col" class="wpinv_vat_name"><?php _e('VAT Name', 'invoicing'); ?></th> |
|
| 305 | + <th scope="col" class="wpinv_vat_group"><?php _e('Tax Group', 'invoicing'); ?></th> |
|
| 306 | 306 | </tr> |
| 307 | 307 | </thead> |
| 308 | 308 | <tbody> |
| 309 | - <?php if( !empty( $eu_states ) ) { ?> |
|
| 309 | + <?php if (!empty($eu_states)) { ?> |
|
| 310 | 310 | <?php |
| 311 | - foreach ( $eu_states as $state ) { |
|
| 312 | - $country_name = isset( $countries[$state] ) ? $countries[$state] : ''; |
|
| 311 | + foreach ($eu_states as $state) { |
|
| 312 | + $country_name = isset($countries[$state]) ? $countries[$state] : ''; |
|
| 313 | 313 | |
| 314 | 314 | // Filter the rate for each country |
| 315 | - $country_rate = array_filter( $rates, function( $rate ) use( $state ) { return $rate['country'] === $state; } ); |
|
| 315 | + $country_rate = array_filter($rates, function($rate) use($state) { return $rate['country'] === $state; } ); |
|
| 316 | 316 | |
| 317 | 317 | // If one does not exist create a default |
| 318 | - $country_rate = is_array( $country_rate ) && count( $country_rate ) > 0 ? reset( $country_rate ) : array(); |
|
| 318 | + $country_rate = is_array($country_rate) && count($country_rate) > 0 ? reset($country_rate) : array(); |
|
| 319 | 319 | |
| 320 | - $vat_global = isset( $country_rate['global'] ) ? !empty( $country_rate['global'] ) : true; |
|
| 321 | - $vat_rate = isset( $country_rate['rate'] ) ? $country_rate['rate'] : ''; |
|
| 322 | - $vat_name = !empty( $country_rate['name'] ) ? esc_attr( stripslashes( $country_rate['name'] ) ) : ''; |
|
| 323 | - $vat_group = !empty( $country_rate['group'] ) ? $country_rate['group'] : ( $vat_class === '_standard' ? 'standard' : 'reduced' ); |
|
| 320 | + $vat_global = isset($country_rate['global']) ? !empty($country_rate['global']) : true; |
|
| 321 | + $vat_rate = isset($country_rate['rate']) ? $country_rate['rate'] : ''; |
|
| 322 | + $vat_name = !empty($country_rate['name']) ? esc_attr(stripslashes($country_rate['name'])) : ''; |
|
| 323 | + $vat_group = !empty($country_rate['group']) ? $country_rate['group'] : ($vat_class === '_standard' ? 'standard' : 'reduced'); |
|
| 324 | 324 | ?> |
| 325 | 325 | <tr> |
| 326 | 326 | <td class="wpinv_vat_country"><?php echo $state; ?><input type="hidden" name="vat_rates[<?php echo $state; ?>][country]" value="<?php echo $state; ?>" /><input type="hidden" name="vat_rates[<?php echo $state; ?>][state]" value="" /></td> |
| 327 | 327 | <td class="wpinv_vat_country_name"><?php echo $country_name; ?></td> |
| 328 | 328 | <td class="wpinv_vat_global"> |
| 329 | - <input type="checkbox" name="vat_rates[<?php echo $state;?>][global]" id="vat_rates[<?php echo $state;?>][global]" value="1" <?php checked( true, $vat_global );?> disabled="disabled" /> |
|
| 330 | - <label for="tax_rates[<?php echo $state;?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
| 331 | - <input type="hidden" name="vat_rates[<?php echo $state;?>][global]" value="1" checked="checked" /> |
|
| 329 | + <input type="checkbox" name="vat_rates[<?php echo $state; ?>][global]" id="vat_rates[<?php echo $state; ?>][global]" value="1" <?php checked(true, $vat_global); ?> disabled="disabled" /> |
|
| 330 | + <label for="tax_rates[<?php echo $state; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
| 331 | + <input type="hidden" name="vat_rates[<?php echo $state; ?>][global]" value="1" checked="checked" /> |
|
| 332 | 332 | </td> |
| 333 | - <td class="wpinv_vat_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="vat_rates[<?php echo $state;?>][rate]" value="<?php echo $vat_rate; ?>" /></td> |
|
| 334 | - <td class="wpinv_vat_name"><input type="text" class="regular-text" name="vat_rates[<?php echo $state;?>][name]" value="<?php echo $vat_name; ?>" /></td> |
|
| 333 | + <td class="wpinv_vat_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="vat_rates[<?php echo $state; ?>][rate]" value="<?php echo $vat_rate; ?>" /></td> |
|
| 334 | + <td class="wpinv_vat_name"><input type="text" class="regular-text" name="vat_rates[<?php echo $state; ?>][name]" value="<?php echo $vat_name; ?>" /></td> |
|
| 335 | 335 | <td class="wpinv_vat_group"> |
| 336 | 336 | <?php |
| 337 | - echo wpinv_html_select( array( |
|
| 337 | + echo wpinv_html_select(array( |
|
| 338 | 338 | 'name' => 'vat_rates[' . $state . '][group]', |
| 339 | 339 | 'selected' => $vat_group, |
| 340 | 340 | 'id' => 'vat_rates[' . $state . '][group]', |
@@ -343,14 +343,14 @@ discard block |
||
| 343 | 343 | 'multiple' => false, |
| 344 | 344 | 'show_option_all' => false, |
| 345 | 345 | 'show_option_none' => false |
| 346 | - ) ); |
|
| 346 | + )); |
|
| 347 | 347 | ?> |
| 348 | 348 | </td> |
| 349 | 349 | </tr> |
| 350 | 350 | <?php } ?> |
| 351 | 351 | <tr> |
| 352 | 352 | <td colspan="6" style="background-color:#fafafa;"> |
| 353 | - <span><input id="wpi_vat_get_rates_group" type="button" class="button-secondary" value="<?php esc_attr_e( 'Update EU VAT Rates', 'invoicing' ); ?>" /> <i style="display:none" class="fa fa-refresh fa-spin"></i></span><span id="wpinv-rates-error-wrap" class="wpinv_errors" style="display:none;"></span> |
|
| 353 | + <span><input id="wpi_vat_get_rates_group" type="button" class="button-secondary" value="<?php esc_attr_e('Update EU VAT Rates', 'invoicing'); ?>" /> <i style="display:none" class="fa fa-refresh fa-spin"></i></span><span id="wpinv-rates-error-wrap" class="wpinv_errors" style="display:none;"></span> |
|
| 354 | 354 | </td> |
| 355 | 355 | </tr> |
| 356 | 356 | <?php } ?> |
@@ -362,35 +362,35 @@ discard block |
||
| 362 | 362 | echo $content; |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | -function wpinv_vat_number_callback( $args ) { |
|
| 365 | +function wpinv_vat_number_callback($args) { |
|
| 366 | 366 | global $wpinv_euvat; |
| 367 | 367 | |
| 368 | 368 | $vat_number = $wpinv_euvat->get_vat_number(); |
| 369 | 369 | $vat_valid = $wpinv_euvat->is_vat_validated(); |
| 370 | 370 | |
| 371 | - $size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 372 | - $validated_text = $vat_valid ? __( 'VAT number validated', 'invoicing' ) : __( 'VAT number not validated', 'invoicing' ); |
|
| 371 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 372 | + $validated_text = $vat_valid ? __('VAT number validated', 'invoicing') : __('VAT number not validated', 'invoicing'); |
|
| 373 | 373 | $disabled = $vat_valid ? 'disabled="disabled"' : " "; |
| 374 | 374 | |
| 375 | - $html = '<input type="text" class="' . $size . '-text" id="wpinv_settings[' . $args['id'] . ']" name="wpinv_settings[' . $args['id'] . ']" placeholder="GB123456789" value="' . esc_attr( stripslashes( $vat_number ) ) . '"/>'; |
|
| 376 | - $html .= '<span> <input type="button" id="wpinv_vat_validate" class="wpinv_validate_vat_button button-secondary" ' . $disabled . ' value="' . esc_attr__( 'Validate VAT Number', 'invoicing' ) . '" /></span>'; |
|
| 377 | - $html .= '<span class="wpinv-vat-stat wpinv-vat-stat-' . (int)$vat_valid . '"><i class="fa"></i> <font>' . $validated_text . '</font></span>'; |
|
| 378 | - $html .= '<label for="wpinv_settings[' . $args['id'] . ']">' . '<p>' . __( 'Enter your VAT number including country identifier, eg: GB123456789 (Settings must be saved after validation)', 'invoicing' ).'</p>' . '</label>'; |
|
| 379 | - $html .= '<input type="hidden" name="_wpi_nonce" value="' . wp_create_nonce( 'vat_validation' ) . '">'; |
|
| 375 | + $html = '<input type="text" class="' . $size . '-text" id="wpinv_settings[' . $args['id'] . ']" name="wpinv_settings[' . $args['id'] . ']" placeholder="GB123456789" value="' . esc_attr(stripslashes($vat_number)) . '"/>'; |
|
| 376 | + $html .= '<span> <input type="button" id="wpinv_vat_validate" class="wpinv_validate_vat_button button-secondary" ' . $disabled . ' value="' . esc_attr__('Validate VAT Number', 'invoicing') . '" /></span>'; |
|
| 377 | + $html .= '<span class="wpinv-vat-stat wpinv-vat-stat-' . (int) $vat_valid . '"><i class="fa"></i> <font>' . $validated_text . '</font></span>'; |
|
| 378 | + $html .= '<label for="wpinv_settings[' . $args['id'] . ']">' . '<p>' . __('Enter your VAT number including country identifier, eg: GB123456789 (Settings must be saved after validation)', 'invoicing') . '</p>' . '</label>'; |
|
| 379 | + $html .= '<input type="hidden" name="_wpi_nonce" value="' . wp_create_nonce('vat_validation') . '">'; |
|
| 380 | 380 | |
| 381 | 381 | echo $html; |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | -function wpinv_eu_fallback_rate_callback( $args ) { |
|
| 384 | +function wpinv_eu_fallback_rate_callback($args) { |
|
| 385 | 385 | global $wpinv_options; |
| 386 | 386 | |
| 387 | - $value = isset( $wpinv_options[$args['id']] ) ? $wpinv_options[ $args['id'] ] : ( isset( $args['std'] ) ? $args['std'] : '' ); |
|
| 388 | - $size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'small'; |
|
| 387 | + $value = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : (isset($args['std']) ? $args['std'] : ''); |
|
| 388 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'small'; |
|
| 389 | 389 | |
| 390 | - $html = '<input type="number" min="0" max="99" step="any" class="' . $size . '-text" id="wpinv_settings_' . $args['section'] . '_' . $args['id'] . '" name="wpinv_settings[' . $args['id'] . ']" value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
| 391 | - $html .= '<span> <input id="wpi_add_eu_states" type="button" class="button-secondary" value="' . esc_attr__( 'Add EU Member States', 'invoicing' ) . '" /></span>'; |
|
| 392 | - $html .= '<span> <input id="wpi_remove_eu_states" type="button" class="button-secondary" value="' . esc_attr__( 'Remove EU Member States', 'invoicing' ) . '" /></span>'; |
|
| 393 | - $html .= '<span> <input id="wpi_vat_get_rates" type="button" class="button-secondary" value="' . esc_attr__( 'Update EU VAT Rates', 'invoicing' ) . '" /> <i style="display:none" class="fa fa-refresh fa-spin"></i></span>'; |
|
| 390 | + $html = '<input type="number" min="0" max="99" step="any" class="' . $size . '-text" id="wpinv_settings_' . $args['section'] . '_' . $args['id'] . '" name="wpinv_settings[' . $args['id'] . ']" value="' . esc_attr(stripslashes($value)) . '" />'; |
|
| 391 | + $html .= '<span> <input id="wpi_add_eu_states" type="button" class="button-secondary" value="' . esc_attr__('Add EU Member States', 'invoicing') . '" /></span>'; |
|
| 392 | + $html .= '<span> <input id="wpi_remove_eu_states" type="button" class="button-secondary" value="' . esc_attr__('Remove EU Member States', 'invoicing') . '" /></span>'; |
|
| 393 | + $html .= '<span> <input id="wpi_vat_get_rates" type="button" class="button-secondary" value="' . esc_attr__('Update EU VAT Rates', 'invoicing') . '" /> <i style="display:none" class="fa fa-refresh fa-spin"></i></span>'; |
|
| 394 | 394 | $html .= '<p><label for="wpinv_settings_' . $args['section'] . '_' . $args['id'] . '">' . $args['desc'] . '</label></p>'; |
| 395 | 395 | echo $html; |
| 396 | 396 | ?> |
@@ -398,36 +398,36 @@ discard block |
||
| 398 | 398 | <?php |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | -function wpinv_vat_ip_lookup_callback( $args ) { |
|
| 401 | +function wpinv_vat_ip_lookup_callback($args) { |
|
| 402 | 402 | global $wpinv_options, $wpinv_euvat; |
| 403 | 403 | |
| 404 | - $value = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : ( isset( $args['std'] ) ? $args['std'] : 'default' ); |
|
| 404 | + $value = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : (isset($args['std']) ? $args['std'] : 'default'); |
|
| 405 | 405 | |
| 406 | 406 | $options = array(); |
| 407 | - if ( function_exists( 'geoip_country_code_by_name' ) ) { |
|
| 408 | - $options['geoip'] = __( 'PHP GeoIP extension', 'invoicing' ); |
|
| 407 | + if (function_exists('geoip_country_code_by_name')) { |
|
| 408 | + $options['geoip'] = __('PHP GeoIP extension', 'invoicing'); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | $geoip2_database = $wpinv_euvat->geoip2_country_dbfile(); |
| 412 | 412 | |
| 413 | - if ( !function_exists( 'bcadd' ) ) { |
|
| 414 | - $geoip2_message = __( 'GeoIP2 service requires the BC Math PHP extension, it is not loaded in your version of PHP!', 'invoicing' ); |
|
| 413 | + if (!function_exists('bcadd')) { |
|
| 414 | + $geoip2_message = __('GeoIP2 service requires the BC Math PHP extension, it is not loaded in your version of PHP!', 'invoicing'); |
|
| 415 | 415 | } else { |
| 416 | - $geoip2_message = ini_get('safe_mode') ? __( 'GeoIP2 is not supported with PHP safe mode enabled!', 'invoicing' ) : ''; |
|
| 416 | + $geoip2_message = ini_get('safe_mode') ? __('GeoIP2 is not supported with PHP safe mode enabled!', 'invoicing') : ''; |
|
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - if ( $geoip2_database !== false && empty( $geoip2_message ) ) { |
|
| 420 | - $options['geoip2'] = __( 'GeoIP2 Database', 'invoicing' ); |
|
| 419 | + if ($geoip2_database !== false && empty($geoip2_message)) { |
|
| 420 | + $options['geoip2'] = __('GeoIP2 Database', 'invoicing'); |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - if ( function_exists( 'simplexml_load_file' ) ) { |
|
| 424 | - $options['geoplugin'] = __( 'geoPlugin Web Service', 'invoicing' ); |
|
| 423 | + if (function_exists('simplexml_load_file')) { |
|
| 424 | + $options['geoplugin'] = __('geoPlugin Web Service', 'invoicing'); |
|
| 425 | 425 | } |
| 426 | 426 | |
| 427 | - $options['site'] = __( 'Use default country', 'invoicing' ); |
|
| 428 | - $options['default'] = __( 'Auto', 'invoicing' ); |
|
| 427 | + $options['site'] = __('Use default country', 'invoicing'); |
|
| 428 | + $options['default'] = __('Auto', 'invoicing'); |
|
| 429 | 429 | |
| 430 | - $html = wpinv_html_select( array( |
|
| 430 | + $html = wpinv_html_select(array( |
|
| 431 | 431 | 'name' => "wpinv_settings[{$args['id']}]", |
| 432 | 432 | 'selected' => $value, |
| 433 | 433 | 'id' => "wpinv_settings[{$args['id']}]", |
@@ -439,23 +439,23 @@ discard block |
||
| 439 | 439 | )); |
| 440 | 440 | |
| 441 | 441 | $desc = '<label for="wpinv_settings[' . $args['id'] . ']">'; |
| 442 | - $desc .= __( 'Select the option Invoicing should use to determine the country from the IP address of the user.', 'invoicing' ); |
|
| 442 | + $desc .= __('Select the option Invoicing should use to determine the country from the IP address of the user.', 'invoicing'); |
|
| 443 | 443 | $desc .= '<p>'; |
| 444 | - if ( empty( $geoip2_message ) ) { |
|
| 445 | - if ( $geoip2_database ) { |
|
| 444 | + if (empty($geoip2_message)) { |
|
| 445 | + if ($geoip2_database) { |
|
| 446 | 446 | $last_updated = ''; |
| 447 | - if ( $time_updated = wpinv_get_option( 'wpinv_geoip2_date_updated' ) ) { |
|
| 448 | - $date_updated = date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $time_updated ); |
|
| 449 | - $last_updated = '<br>' . sprintf( __( 'The GeoIP2 database was last updated on: <b>%s</b>', 'invoicing' ), $date_updated ); |
|
| 447 | + if ($time_updated = wpinv_get_option('wpinv_geoip2_date_updated')) { |
|
| 448 | + $date_updated = date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $time_updated); |
|
| 449 | + $last_updated = '<br>' . sprintf(__('The GeoIP2 database was last updated on: <b>%s</b>', 'invoicing'), $date_updated); |
|
| 450 | 450 | } |
| 451 | - $desc .= __( 'GeoIP2 database exists:', 'invoicing' ) . $last_updated . ' <input type="button" id="wpi_geoip2" action="update" class="wpinv-refresh-geoip2-btn button-secondary" value="' . __( 'Update GeoIP2 database now (~30MB)', 'invoicing' ) . '"></input>'; |
|
| 451 | + $desc .= __('GeoIP2 database exists:', 'invoicing') . $last_updated . ' <input type="button" id="wpi_geoip2" action="update" class="wpinv-refresh-geoip2-btn button-secondary" value="' . __('Update GeoIP2 database now (~30MB)', 'invoicing') . '"></input>'; |
|
| 452 | 452 | } else { |
| 453 | - $desc .= __( 'GeoIP2 database does not exist:', 'invoicing' ) . ' <input type="button" id="wpi_geoip2" action="download" class="wpinv-download-geoip2-btn button-secondary" value="' . __( 'Download GeoIP2 database now', 'invoicing' ) . ' (~30MB)"></input><br>' . __( 'After downloading the GeoIP2 database the GeoIP2 lookup option will show.', 'invoicing' ); |
|
| 453 | + $desc .= __('GeoIP2 database does not exist:', 'invoicing') . ' <input type="button" id="wpi_geoip2" action="download" class="wpinv-download-geoip2-btn button-secondary" value="' . __('Download GeoIP2 database now', 'invoicing') . ' (~30MB)"></input><br>' . __('After downloading the GeoIP2 database the GeoIP2 lookup option will show.', 'invoicing'); |
|
| 454 | 454 | } |
| 455 | 455 | } else { |
| 456 | 456 | $desc .= $geoip2_message; |
| 457 | 457 | } |
| 458 | - $desc .= '</p><p>'. __( 'geoPlugin is a great free service please consider supporting them: ', 'invoicing' ) . ' <a href="http://www.geoplugin.com/" target="_blank">GeoPlugin.com</a></p>'; |
|
| 458 | + $desc .= '</p><p>' . __('geoPlugin is a great free service please consider supporting them: ', 'invoicing') . ' <a href="http://www.geoplugin.com/" target="_blank">GeoPlugin.com</a></p>'; |
|
| 459 | 459 | $desc .= '</label>'; |
| 460 | 460 | |
| 461 | 461 | $html .= $desc; |
@@ -471,39 +471,39 @@ discard block |
||
| 471 | 471 | * |
| 472 | 472 | * @param string|bool|null $vat_rule |
| 473 | 473 | */ |
| 474 | -function getpaid_filter_vat_rule( $vat_rule ) { |
|
| 474 | +function getpaid_filter_vat_rule($vat_rule) { |
|
| 475 | 475 | |
| 476 | - if ( empty( $vat_rule ) ) { |
|
| 476 | + if (empty($vat_rule)) { |
|
| 477 | 477 | return getpaid_tax()->allow_vat_rules() ? 'digital' : 'physical'; |
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | return $vat_rule; |
| 481 | 481 | } |
| 482 | -add_filter( 'wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule' ); |
|
| 482 | +add_filter('wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule'); |
|
| 483 | 483 | |
| 484 | 484 | /** |
| 485 | 485 | * Filters the VAT class to ensure that each item has a VAT class. |
| 486 | 486 | * |
| 487 | 487 | * @param string|bool|null $vat_rule |
| 488 | 488 | */ |
| 489 | -function getpaid_filter_vat_class( $vat_class ) { |
|
| 490 | - return empty( $vat_class ) ? '_standard' : $vat_class; |
|
| 489 | +function getpaid_filter_vat_class($vat_class) { |
|
| 490 | + return empty($vat_class) ? '_standard' : $vat_class; |
|
| 491 | 491 | } |
| 492 | -add_filter( 'wpinv_get_item_vat_class', 'getpaid_filter_vat_class' ); |
|
| 492 | +add_filter('wpinv_get_item_vat_class', 'getpaid_filter_vat_class'); |
|
| 493 | 493 | |
| 494 | 494 | /** |
| 495 | 495 | * Returns the ip address location url. |
| 496 | 496 | * |
| 497 | 497 | */ |
| 498 | -function getpaid_ip_location_url( $ip_address ) { |
|
| 498 | +function getpaid_ip_location_url($ip_address) { |
|
| 499 | 499 | |
| 500 | 500 | return add_query_arg( |
| 501 | 501 | array( |
| 502 | 502 | 'action' => 'wpinv_ip_geolocation', |
| 503 | 503 | 'ip' => $ip_address, |
| 504 | - '_wpnonce' => wp_create_nonce( 'getpaid-ip-location' ) |
|
| 504 | + '_wpnonce' => wp_create_nonce('getpaid-ip-location') |
|
| 505 | 505 | ), |
| 506 | - admin_url( 'admin-ajax.php' ) |
|
| 506 | + admin_url('admin-ajax.php') |
|
| 507 | 507 | ); |
| 508 | 508 | |
| 509 | 509 | } |
@@ -513,59 +513,59 @@ discard block |
||
| 513 | 513 | * |
| 514 | 514 | * @return array|bool |
| 515 | 515 | */ |
| 516 | -function getpaid_geolocate_ip_address( $ip_address ) { |
|
| 516 | +function getpaid_geolocate_ip_address($ip_address) { |
|
| 517 | 517 | |
| 518 | 518 | // Do we have an ip address? |
| 519 | - if ( empty( $ip_address ) ) { |
|
| 519 | + if (empty($ip_address)) { |
|
| 520 | 520 | return false; |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | 523 | /** |
| 524 | 524 | * Retrieve ip address using max mind. |
| 525 | 525 | */ |
| 526 | - if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = getpaid_tax()->geoip2_city_record( $ip_address ) ) { |
|
| 526 | + if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = getpaid_tax()->geoip2_city_record($ip_address)) { |
|
| 527 | 527 | |
| 528 | 528 | try { |
| 529 | 529 | $iso = $geoip2_city->country->isoCode; |
| 530 | 530 | $country = $geoip2_city->country->name; |
| 531 | - $region = ! empty( $geoip2_city->subdivisions ) && ! empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : ''; |
|
| 531 | + $region = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : ''; |
|
| 532 | 532 | $city = $geoip2_city->city->name; |
| 533 | 533 | $longitude = $geoip2_city->location->longitude; |
| 534 | 534 | $latitude = $geoip2_city->location->latitude; |
| 535 | - $credit = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' ); |
|
| 536 | - } catch( Exception $e ) { |
|
| 537 | - wpinv_error_log( $e->getMessage(), 'MaxMind Exception', __FILE__, __LINE__ ); |
|
| 535 | + $credit = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing'); |
|
| 536 | + } catch (Exception $e) { |
|
| 537 | + wpinv_error_log($e->getMessage(), 'MaxMind Exception', __FILE__, __LINE__); |
|
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | // If that fails, GeoLocate using GeoPlugin. |
| 543 | - if ( ( empty( $iso ) || empty( $longitude ) || empty( $latitude ) ) && function_exists( 'simplexml_load_file' ) ) { |
|
| 543 | + if ((empty($iso) || empty($longitude) || empty($latitude)) && function_exists('simplexml_load_file')) { |
|
| 544 | 544 | |
| 545 | 545 | try { |
| 546 | - $url = esc_url( add_query_arg( 'ip', urlencode( $ip_address ), 'http://www.geoplugin.net/xml.gp' ) ); |
|
| 547 | - $load_xml = simplexml_load_file( $url ); |
|
| 546 | + $url = esc_url(add_query_arg('ip', urlencode($ip_address), 'http://www.geoplugin.net/xml.gp')); |
|
| 547 | + $load_xml = simplexml_load_file($url); |
|
| 548 | 548 | |
| 549 | - if ( ! empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && ! empty( $load_xml->geoplugin_latitude ) && ! empty( $load_xml->geoplugin_longitude ) ) { |
|
| 549 | + if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) { |
|
| 550 | 550 | $iso = $load_xml->geoplugin_countryCode; |
| 551 | 551 | $country = $load_xml->geoplugin_countryName; |
| 552 | - $region = ! empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : ''; |
|
| 553 | - $city = ! empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : ''; |
|
| 552 | + $region = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : ''; |
|
| 553 | + $city = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : ''; |
|
| 554 | 554 | $longitude = $load_xml->geoplugin_longitude; |
| 555 | 555 | $latitude = $load_xml->geoplugin_latitude; |
| 556 | 556 | $credit = $load_xml->geoplugin_credit; |
| 557 | - $credit = __( 'Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing' ) . '<br>' . $load_xml->geoplugin_credit; |
|
| 557 | + $credit = __('Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing') . '<br>' . $load_xml->geoplugin_credit; |
|
| 558 | 558 | } |
| 559 | - } catch( Exception $e ) { |
|
| 560 | - wpinv_error_log( $e->getMessage(), 'GeoPlugin Exception', __FILE__, __LINE__ ); |
|
| 559 | + } catch (Exception $e) { |
|
| 560 | + wpinv_error_log($e->getMessage(), 'GeoPlugin Exception', __FILE__, __LINE__); |
|
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | } |
| 564 | 564 | |
| 565 | - if ( empty( $iso ) ) { |
|
| 565 | + if (empty($iso)) { |
|
| 566 | 566 | return false; |
| 567 | 567 | } |
| 568 | 568 | |
| 569 | - return compact( 'iso', 'country', 'region', 'city', 'longitude', 'latitude', 'credit' ); |
|
| 569 | + return compact('iso', 'country', 'region', 'city', 'longitude', 'latitude', 'credit'); |
|
| 570 | 570 | |
| 571 | 571 | } |
@@ -130,7 +130,6 @@ |
||
| 130 | 130 | private function mostSpecificSubdivision() |
| 131 | 131 | { |
| 132 | 132 | return empty($this->subdivisions) ? |
| 133 | - new \GeoIp2\Record\Subdivision(array(), $this->locales) : |
|
| 134 | - end($this->subdivisions); |
|
| 133 | + new \GeoIp2\Record\Subdivision(array(), $this->locales) : end($this->subdivisions); |
|
| 135 | 134 | } |
| 136 | 135 | } |