Passed
Push — master ( 1a4515...55ed87 )
by Stiofan
02:32 queued 12s
created
includes/abstract-wpinv-privacy.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Abstract privacy class.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * Abstract class that is intended to be extended by
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      *
39 39
      * @param string $name Plugin identifier.
40 40
      */
41
-    public function __construct( $name = '' ) {
41
+    public function __construct($name = '') {
42 42
         $this->name = $name;
43 43
         $this->init();
44 44
     }
@@ -47,22 +47,22 @@  discard block
 block discarded – undo
47 47
      * Hook in events.
48 48
      */
49 49
     protected function init() {
50
-        add_action( 'admin_init', array( $this, 'add_privacy_message' ) );
50
+        add_action('admin_init', array($this, 'add_privacy_message'));
51 51
         // Register data exporters
52
-        add_filter( 'wp_privacy_personal_data_exporters', array( $this, 'register_exporters' ), 10 );
52
+        add_filter('wp_privacy_personal_data_exporters', array($this, 'register_exporters'), 10);
53 53
         // Register data erasers
54
-        add_filter( 'wp_privacy_personal_data_erasers', array( $this, 'register_erasers' ) );
54
+        add_filter('wp_privacy_personal_data_erasers', array($this, 'register_erasers'));
55 55
     }
56 56
 
57 57
     /**
58 58
      * Adds the privacy message on invoicing privacy page.
59 59
      */
60 60
     public function add_privacy_message() {
61
-        if ( function_exists( 'wp_add_privacy_policy_content' ) ) {
61
+        if (function_exists('wp_add_privacy_policy_content')) {
62 62
             $content = $this->get_privacy_message();
63 63
 
64
-            if ( $content ) {
65
-                wp_add_privacy_policy_content( $this->name, $this->get_privacy_message() );
64
+            if ($content) {
65
+                wp_add_privacy_policy_content($this->name, $this->get_privacy_message());
66 66
             }
67 67
         }
68 68
     }
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
      * @param array $exporters List of exporter callbacks.
84 84
      * @return array
85 85
      */
86
-    public function register_exporters( $exporters = array() ) {
87
-        foreach ( $this->exporters as $id => $exporter ) {
88
-            $exporters[ $id ] = $exporter;
86
+    public function register_exporters($exporters = array()) {
87
+        foreach ($this->exporters as $id => $exporter) {
88
+            $exporters[$id] = $exporter;
89 89
         }
90 90
         return $exporters;
91 91
     }
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
      * @param array $erasers List of eraser callbacks.
97 97
      * @return array
98 98
      */
99
-    public function register_erasers( $erasers = array() ) {
100
-        foreach ( $this->erasers as $id => $eraser ) {
101
-            $erasers[ $id ] = $eraser;
99
+    public function register_erasers($erasers = array()) {
100
+        foreach ($this->erasers as $id => $eraser) {
101
+            $erasers[$id] = $eraser;
102 102
         }
103 103
         return $erasers;
104 104
     }
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
      *
113 113
      * @return array
114 114
      */
115
-    public function add_exporter( $id, $name, $callback ) {
116
-        $this->exporters[ $id ] = array(
115
+    public function add_exporter($id, $name, $callback) {
116
+        $this->exporters[$id] = array(
117 117
             'exporter_friendly_name' => $name,
118 118
             'callback'               => $callback,
119 119
         );
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
      *
130 130
      * @return array
131 131
      */
132
-    public function add_eraser( $id, $name, $callback ) {
133
-        $this->erasers[ $id ] = array(
132
+    public function add_eraser($id, $name, $callback) {
133
+        $this->erasers[$id] = array(
134 134
             'eraser_friendly_name' => $name,
135 135
             'callback'             => $callback,
136 136
         );
Please login to merge, or discard this patch.
includes/class-wpinv-privacy.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Privacy/GDPR related functionality which ties into WordPress functionality.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * WPInv_Privacy Class.
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
      * Init - hook into events.
15 15
      */
16 16
     public function __construct() {
17
-        parent::__construct( __( 'Invoicing', 'invoicing' ) );
17
+        parent::__construct(__('Invoicing', 'invoicing'));
18 18
 
19 19
         // Include supporting classes.
20 20
         include_once 'class-wpinv-privacy-exporters.php';
21 21
 
22 22
         // This hook registers Invoicing data exporters.
23
-        $this->add_exporter( 'wpinv-customer-invoices', __( 'Customer Invoices', 'invoicing' ), array( 'WPInv_Privacy_Exporters', 'customer_invoice_data_exporter' ) );
23
+        $this->add_exporter('wpinv-customer-invoices', __('Customer Invoices', 'invoicing'), array('WPInv_Privacy_Exporters', 'customer_invoice_data_exporter'));
24 24
     }
25 25
 
26 26
     /**
@@ -30,28 +30,28 @@  discard block
 block discarded – undo
30 30
      */
31 31
     public function get_privacy_message() {
32 32
 
33
-        $content = '<h2>' . __( 'Invoices and checkout', 'invoicing' ) . '</h2>' .
33
+        $content = '<h2>' . __('Invoices and checkout', 'invoicing') . '</h2>' .
34 34
                    '<div contenteditable="false">' .
35
-                   '<p class="wp-policy-help">' . __( 'Example privacy texts.', 'invoicing' ) . '</p>' .
35
+                   '<p class="wp-policy-help">' . __('Example privacy texts.', 'invoicing') . '</p>' .
36 36
                    '</div>' .
37
-                   '<p>' . __( 'We collect information about you during the checkout process on our site. This information may include, but is not limited to, your name, email address, phone number, address, IP and any other details that might be requested from you for the purpose of processing your payment and retaining your invoice details for legal reasons.', 'invoicing' ) . '</p>' .
38
-                   '<p>' . __( 'Handling this data also allows us to:', 'invoicing' ) . '</p>' .
37
+                   '<p>' . __('We collect information about you during the checkout process on our site. This information may include, but is not limited to, your name, email address, phone number, address, IP and any other details that might be requested from you for the purpose of processing your payment and retaining your invoice details for legal reasons.', 'invoicing') . '</p>' .
38
+                   '<p>' . __('Handling this data also allows us to:', 'invoicing') . '</p>' .
39 39
                    '<ul>' .
40
-                   '<li>' . __( '- Send you important account/order/service information.', 'invoicing' ) . '</li>' .
41
-                   '<li>' . __( '- Estimate taxes based on your location.', 'invoicing' ) . '</li>' .
42
-                   '<li>' . __( '- Respond to your queries or complaints.', 'invoicing' ) . '</li>' .
43
-                   '<li>' . __( '- Process payments and to prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' .
44
-                   '<li>' . __( '- Retain historical payment and invoice history. We do this on the basis of legal obligations.', 'invoicing' ) . '</li>' .
45
-                   '<li>' . __( '- Set up and administer your account, provide technical and/or customer support, and to verify your identity. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' .
40
+                   '<li>' . __('- Send you important account/order/service information.', 'invoicing') . '</li>' .
41
+                   '<li>' . __('- Estimate taxes based on your location.', 'invoicing') . '</li>' .
42
+                   '<li>' . __('- Respond to your queries or complaints.', 'invoicing') . '</li>' .
43
+                   '<li>' . __('- Process payments and to prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', 'invoicing') . '</li>' .
44
+                   '<li>' . __('- Retain historical payment and invoice history. We do this on the basis of legal obligations.', 'invoicing') . '</li>' .
45
+                   '<li>' . __('- Set up and administer your account, provide technical and/or customer support, and to verify your identity. We do this on the basis of our legitimate business interests.', 'invoicing') . '</li>' .
46 46
                    '</ul>' .
47
-                   '<p>' . __( 'In addition to collecting information at checkout we may also use and store your contact details when manually creating invoices for require payments relating to prior contractual agreements or agreed terms.', 'invoicing' ) . '</p>' .
48
-                   '<h2>' . __( 'What we share with others', 'invoicing' ) . '</h2>' .
49
-                   '<p>' . __( 'We share information with third parties who help us provide our payment and invoicing services to you; for example --', 'invoicing' ) . '</p>' .
47
+                   '<p>' . __('In addition to collecting information at checkout we may also use and store your contact details when manually creating invoices for require payments relating to prior contractual agreements or agreed terms.', 'invoicing') . '</p>' .
48
+                   '<h2>' . __('What we share with others', 'invoicing') . '</h2>' .
49
+                   '<p>' . __('We share information with third parties who help us provide our payment and invoicing services to you; for example --', 'invoicing') . '</p>' .
50 50
                    '<div contenteditable="false">' .
51
-                   '<p class="wp-policy-help">' . __( 'In this subsection you should list which third party payment processors you’re using to take payments since these may handle customer data. We’ve included PayPal as an example, but you should remove this if you’re not using PayPal.', 'invoicing' ) . '</p>' .
51
+                   '<p class="wp-policy-help">' . __('In this subsection you should list which third party payment processors you’re using to take payments since these may handle customer data. We’ve included PayPal as an example, but you should remove this if you’re not using PayPal.', 'invoicing') . '</p>' .
52 52
                    '</div>' .
53
-                   '<p>' . __( 'We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'invoicing' ) . '</p>' .
54
-                   '<p>' . __( 'Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'invoicing' ) . '</p>';
53
+                   '<p>' . __('We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'invoicing') . '</p>' .
54
+                   '<p>' . __('Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'invoicing') . '</p>';
55 55
 
56 56
 
57 57
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 //            '</p>' .
63 63
 //            '</div>';
64 64
 
65
-        return apply_filters( 'wpinv_privacy_policy_content', $content );
65
+        return apply_filters('wpinv_privacy_policy_content', $content);
66 66
     }
67 67
 
68 68
 }
Please login to merge, or discard this patch.
includes/class-wpinv-notes.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit; // Exit if accessed directly
4 4
 }
5 5
 
@@ -14,74 +14,74 @@  discard block
 block discarded – undo
14 14
     }
15 15
     
16 16
     public function init() {
17
-        do_action( 'wpinv_class_notes_init', $this );
17
+        do_action('wpinv_class_notes_init', $this);
18 18
     }
19 19
     
20 20
     public function includes() {
21
-        do_action( 'wpinv_class_notes_includes', $this );
21
+        do_action('wpinv_class_notes_includes', $this);
22 22
     }
23 23
     
24 24
     public function actions() {
25 25
         // Secure inovice notes
26
-        add_action( 'pre_get_comments', array( $this, 'set_invoice_note_type' ), 11, 1 );
27
-        add_action( 'comment_feed_where', array( $this, 'wpinv_comment_feed_where' ), 10, 1 );
26
+        add_action('pre_get_comments', array($this, 'set_invoice_note_type'), 11, 1);
27
+        add_action('comment_feed_where', array($this, 'wpinv_comment_feed_where'), 10, 1);
28 28
         
29 29
         // Count comments
30
-        add_filter( 'wp_count_comments', array( $this, 'wp_count_comments' ), 11, 2 );
30
+        add_filter('wp_count_comments', array($this, 'wp_count_comments'), 11, 2);
31 31
         
32 32
         // Delete comments count cache whenever there is a new comment or a comment status changes
33
-        add_action( 'wp_insert_comment', array( $this, 'delete_comments_count_cache' ) );
34
-        add_action( 'wp_set_comment_status', array( $this, 'delete_comments_count_cache' ) );
33
+        add_action('wp_insert_comment', array($this, 'delete_comments_count_cache'));
34
+        add_action('wp_set_comment_status', array($this, 'delete_comments_count_cache'));
35 35
         
36
-        do_action( 'wpinv_class_notes_actions', $this );
36
+        do_action('wpinv_class_notes_actions', $this);
37 37
     }
38 38
         
39
-    public function set_invoice_note_type( $query ) {
40
-        $post_ID        = !empty( $query->query_vars['post_ID'] ) ? $query->query_vars['post_ID'] : $query->query_vars['post_id'];
39
+    public function set_invoice_note_type($query) {
40
+        $post_ID = !empty($query->query_vars['post_ID']) ? $query->query_vars['post_ID'] : $query->query_vars['post_id'];
41 41
         
42
-        if ( $post_ID && in_array(get_post_type( $post_ID ), array($this->invoice_post_type, 'wpi_quote' )) ) {
42
+        if ($post_ID && in_array(get_post_type($post_ID), array($this->invoice_post_type, 'wpi_quote'))) {
43 43
             $query->query_vars['type__in']      = $this->comment_type;
44 44
             $query->query_vars['type__not_in']  = '';
45 45
         } else {        
46
-            if ( isset( $query->query_vars['type__in'] ) && $type_in = $query->query_vars['type__in'] ) {
47
-                if ( is_array( $type_in ) && in_array( $this->comment_type, $type_in ) ) {
48
-                    $key = array_search( $this->comment_type, $type_in );
49
-                    unset( $query->query_vars['type__in'][$key] );
50
-                } else if ( !is_array( $type_in ) && $type_in == $this->comment_type ) {
46
+            if (isset($query->query_vars['type__in']) && $type_in = $query->query_vars['type__in']) {
47
+                if (is_array($type_in) && in_array($this->comment_type, $type_in)) {
48
+                    $key = array_search($this->comment_type, $type_in);
49
+                    unset($query->query_vars['type__in'][$key]);
50
+                } else if (!is_array($type_in) && $type_in == $this->comment_type) {
51 51
                     $query->query_vars['type__in'] = '';
52 52
                 }
53 53
             }
54 54
             
55
-            if ( isset( $query->query_vars['type__not_in'] ) && $type_not_in = $query->query_vars['type__not_in'] ) {
56
-                if ( is_array( $type_not_in ) && !in_array( $this->comment_type, $type_not_in ) ) {
55
+            if (isset($query->query_vars['type__not_in']) && $type_not_in = $query->query_vars['type__not_in']) {
56
+                if (is_array($type_not_in) && !in_array($this->comment_type, $type_not_in)) {
57 57
                     $query->query_vars['type__not_in'][] = $this->comment_type;
58
-                } else if ( !is_array( $type_not_in ) && $type_not_in != $this->comment_type ) {
58
+                } else if (!is_array($type_not_in) && $type_not_in != $this->comment_type) {
59 59
                     $query->query_vars['type__not_in'] = (array)$query->query_vars['type__not_in'];
60 60
                     $query->query_vars['type__not_in'][] = $this->comment_type;
61 61
                 }
62 62
             } else {
63
-                $query->query_vars['type__not_in']  = $this->comment_type;
63
+                $query->query_vars['type__not_in'] = $this->comment_type;
64 64
             }
65 65
         }
66 66
         
67 67
         return $query;
68 68
     }
69 69
     
70
-    public function get_invoice_notes( $invoice_id = 0, $type = '' ) {
70
+    public function get_invoice_notes($invoice_id = 0, $type = '') {
71 71
         $args = array( 
72 72
             'post_id'   => $invoice_id,
73 73
             'orderby'   => 'comment_ID',
74 74
             'order'     => 'ASC',
75 75
         );
76 76
         
77
-        if ( $type == 'customer' ) {
77
+        if ($type == 'customer') {
78 78
             $args['meta_key']   = '_wpi_customer_note';
79 79
             $args['meta_value'] = 1;
80 80
         }
81 81
         
82
-        $args   = apply_filters( 'wpinv_invoice_notes_args', $args, $this, $invoice_id, $type );
82
+        $args = apply_filters('wpinv_invoice_notes_args', $args, $this, $invoice_id, $type);
83 83
         
84
-        return get_comments( $args );
84
+        return get_comments($args);
85 85
     }
86 86
     
87 87
     /**
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      * @return void
93 93
      */
94 94
     public function delete_comments_count_cache() {
95
-        delete_transient( 'wpinv_count_comments' );
95
+        delete_transient('wpinv_count_comments');
96 96
     }
97 97
     
98 98
     /**
@@ -103,16 +103,16 @@  discard block
 block discarded – undo
103 103
      * @param  int    $post_id Post ID.
104 104
      * @return object
105 105
      */
106
-    public function wp_count_comments( $stats, $post_id ) {
106
+    public function wp_count_comments($stats, $post_id) {
107 107
         global $wpdb;
108 108
 
109
-        if ( 0 === $post_id ) {
110
-            $stats = get_transient( 'wpinv_count_comments' );
109
+        if (0 === $post_id) {
110
+            $stats = get_transient('wpinv_count_comments');
111 111
 
112
-            if ( ! $stats ) {
112
+            if (!$stats) {
113 113
                 $stats = array();
114 114
 
115
-                $count = $wpdb->get_results( "SELECT comment_approved, COUNT(*) AS num_comments FROM {$wpdb->comments} WHERE comment_type NOT IN ('" . $this->comment_type . "') GROUP BY comment_approved", ARRAY_A );
115
+                $count = $wpdb->get_results("SELECT comment_approved, COUNT(*) AS num_comments FROM {$wpdb->comments} WHERE comment_type NOT IN ('" . $this->comment_type . "') GROUP BY comment_approved", ARRAY_A);
116 116
 
117 117
                 $total = 0;
118 118
                 $approved = array(
@@ -123,33 +123,33 @@  discard block
 block discarded – undo
123 123
                     'post-trashed' => 'post-trashed',
124 124
                 );
125 125
 
126
-                foreach ( (array) $count as $row ) {
126
+                foreach ((array)$count as $row) {
127 127
                     // Do not count post-trashed toward totals.
128
-                    if ( 'post-trashed' !== $row['comment_approved'] && 'trash' !== $row['comment_approved'] ) {
128
+                    if ('post-trashed' !== $row['comment_approved'] && 'trash' !== $row['comment_approved']) {
129 129
                         $total += $row['num_comments'];
130 130
                     }
131
-                    if ( isset( $approved[ $row['comment_approved'] ] ) ) {
132
-                        $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
131
+                    if (isset($approved[$row['comment_approved']])) {
132
+                        $stats[$approved[$row['comment_approved']]] = $row['num_comments'];
133 133
                     }
134 134
                 }
135 135
 
136 136
                 $stats['total_comments'] = $total;
137 137
                 $stats['all'] = $total;
138
-                foreach ( $approved as $key ) {
139
-                    if ( empty( $stats[ $key ] ) ) {
140
-                        $stats[ $key ] = 0;
138
+                foreach ($approved as $key) {
139
+                    if (empty($stats[$key])) {
140
+                        $stats[$key] = 0;
141 141
                     }
142 142
                 }
143 143
 
144
-                $stats = (object) $stats;
145
-                set_transient( 'wpinv_count_comments', $stats );
144
+                $stats = (object)$stats;
145
+                set_transient('wpinv_count_comments', $stats);
146 146
             }
147 147
         }
148 148
 
149 149
         return $stats;
150 150
     }
151 151
 
152
-    function wpinv_comment_feed_where($where){
153
-        return $where . ( $where ? ' AND ' : '' ) . " comment_type != 'wpinv_note' ";
152
+    function wpinv_comment_feed_where($where) {
153
+        return $where . ($where ? ' AND ' : '') . " comment_type != 'wpinv_note' ";
154 154
     }
155 155
 }
Please login to merge, or discard this patch.
includes/admin/wpinv-upgrade-functions.php 1 patch
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -11,49 +11,49 @@  discard block
 block discarded – undo
11 11
  * @since 1.0.0
12 12
 */
13 13
 function wpinv_automatic_upgrade() {
14
-    $wpi_version = get_option( 'wpinv_version' );
14
+    $wpi_version = get_option('wpinv_version');
15 15
 
16
-    if ( $wpi_version == WPINV_VERSION ) {
16
+    if ($wpi_version == WPINV_VERSION) {
17 17
         return;
18 18
     }
19 19
     
20
-    if ( version_compare( $wpi_version, '0.0.5', '<' ) ) {
20
+    if (version_compare($wpi_version, '0.0.5', '<')) {
21 21
         wpinv_v005_upgrades();
22 22
     }
23 23
     
24
-    if ( version_compare( $wpi_version, '1.0.3', '<' ) ) {
24
+    if (version_compare($wpi_version, '1.0.3', '<')) {
25 25
         wpinv_v110_upgrades();
26 26
     }
27 27
     
28
-    update_option( 'wpinv_version', WPINV_VERSION );
28
+    update_option('wpinv_version', WPINV_VERSION);
29 29
 }
30
-add_action( 'admin_init', 'wpinv_automatic_upgrade' );
30
+add_action('admin_init', 'wpinv_automatic_upgrade');
31 31
 
32 32
 function wpinv_v005_upgrades() {
33 33
     global $wpdb;
34 34
     
35 35
     // Invoices status
36
-    $results = $wpdb->get_results( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
37
-    if ( !empty( $results ) ) {
38
-        $wpdb->query( "UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
36
+    $results = $wpdb->get_results("SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
37
+    if (!empty($results)) {
38
+        $wpdb->query("UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
39 39
         
40 40
         // Clean post cache
41
-        foreach ( $results as $row ) {
42
-            clean_post_cache( $row->ID );
41
+        foreach ($results as $row) {
42
+            clean_post_cache($row->ID);
43 43
         }
44 44
     }
45 45
     
46 46
     // Item meta key changes
47 47
     $query = "SELECT DISTINCT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
48
-    $results = $wpdb->get_results( $query );
48
+    $results = $wpdb->get_results($query);
49 49
     
50
-    if ( !empty( $results ) ) {
51
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
52
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
53
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
50
+    if (!empty($results)) {
51
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )");
52
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'");
53
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'");
54 54
         
55
-        foreach ( $results as $row ) {
56
-            clean_post_cache( $row->post_id );
55
+        foreach ($results as $row) {
56
+            clean_post_cache($row->post_id);
57 57
         }
58 58
     }
59 59
 
@@ -74,79 +74,79 @@  discard block
 block discarded – undo
74 74
 function wpinv_convert_old_subscriptions() {
75 75
     global $wpdb;
76 76
 
77
-    $query = "SELECT ". $wpdb->posts .".ID FROM ". $wpdb->posts ." INNER JOIN ". $wpdb->postmeta ." ON ( ". $wpdb->posts .".ID = ". $wpdb->postmeta .".post_id ) WHERE 1=1  AND ". $wpdb->postmeta .".meta_key = '_wpinv_subscr_status' AND (". $wpdb->postmeta .".meta_value = 'pending' OR ". $wpdb->postmeta .".meta_value = 'active' OR ". $wpdb->postmeta .".meta_value = 'cancelled' OR ". $wpdb->postmeta .".meta_value = 'completed' OR ". $wpdb->postmeta .".meta_value = 'expired' OR ". $wpdb->postmeta .".meta_value = 'trialling' OR ". $wpdb->postmeta .".meta_value = 'failing') AND ". $wpdb->posts .".post_type = 'wpi_invoice' GROUP BY ". $wpdb->posts .".ID ORDER BY ". $wpdb->posts .".ID ASC";
77
+    $query = "SELECT " . $wpdb->posts . ".ID FROM " . $wpdb->posts . " INNER JOIN " . $wpdb->postmeta . " ON ( " . $wpdb->posts . ".ID = " . $wpdb->postmeta . ".post_id ) WHERE 1=1  AND " . $wpdb->postmeta . ".meta_key = '_wpinv_subscr_status' AND (" . $wpdb->postmeta . ".meta_value = 'pending' OR " . $wpdb->postmeta . ".meta_value = 'active' OR " . $wpdb->postmeta . ".meta_value = 'cancelled' OR " . $wpdb->postmeta . ".meta_value = 'completed' OR " . $wpdb->postmeta . ".meta_value = 'expired' OR " . $wpdb->postmeta . ".meta_value = 'trialling' OR " . $wpdb->postmeta . ".meta_value = 'failing') AND " . $wpdb->posts . ".post_type = 'wpi_invoice' GROUP BY " . $wpdb->posts . ".ID ORDER BY " . $wpdb->posts . ".ID ASC";
78 78
 
79
-    $results = $wpdb->get_results( $query );
79
+    $results = $wpdb->get_results($query);
80 80
 
81
-    if ( empty( $results ) ) {
81
+    if (empty($results)) {
82 82
         return;
83 83
     }
84 84
 
85
-    foreach ( $results as $row ) {
86
-        $invoice = new WPInv_Invoice( $row->ID );
85
+    foreach ($results as $row) {
86
+        $invoice = new WPInv_Invoice($row->ID);
87 87
 
88
-        if ( empty( $invoice->ID ) ) {
88
+        if (empty($invoice->ID)) {
89 89
             continue;
90 90
         }
91 91
 
92
-        if ( $invoice->has_status( 'wpi-renewal' ) ) {
92
+        if ($invoice->has_status('wpi-renewal')) {
93 93
             continue;
94 94
         }
95 95
         
96
-        $item = $invoice->get_recurring( true );
96
+        $item = $invoice->get_recurring(true);
97 97
 
98
-        if ( empty( $item ) ) {
98
+        if (empty($item)) {
99 99
             continue;
100 100
         }
101 101
 
102 102
         $is_free_trial          = $invoice->is_free_trial();
103
-        $profile_id             = get_post_meta( $invoice->ID, '_wpinv_subscr_profile_id', true );
104
-        $subscription_status    = get_post_meta( $invoice->ID, '_wpinv_subscr_status', true );
103
+        $profile_id             = get_post_meta($invoice->ID, '_wpinv_subscr_profile_id', true);
104
+        $subscription_status    = get_post_meta($invoice->ID, '_wpinv_subscr_status', true);
105 105
         $transaction_id         = $invoice->get_transaction_id();
106 106
 
107 107
         // Last invoice
108
-        $query          = "SELECT ID, post_date FROM ". $wpdb->posts ." WHERE post_type = 'wpi_invoice' AND post_parent = '" . $invoice->ID . "' ORDER BY ID DESC LIMIT 1";
109
-        $last_payment   = $wpdb->get_row( $query );
108
+        $query          = "SELECT ID, post_date FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_parent = '" . $invoice->ID . "' ORDER BY ID DESC LIMIT 1";
109
+        $last_payment   = $wpdb->get_row($query);
110 110
 
111
-        if ( !empty( $last_payment ) ) {
112
-            $invoice_date       = $last_payment->post_date;
111
+        if (!empty($last_payment)) {
112
+            $invoice_date = $last_payment->post_date;
113 113
             
114
-            $meta_profile_id     = get_post_meta( $last_payment->ID, '_wpinv_subscr_profile_id', true );
115
-            $meta_transaction_id = get_post_meta( $last_payment->ID, '_wpinv_transaction_id', true );
114
+            $meta_profile_id     = get_post_meta($last_payment->ID, '_wpinv_subscr_profile_id', true);
115
+            $meta_transaction_id = get_post_meta($last_payment->ID, '_wpinv_transaction_id', true);
116 116
 
117
-            if ( !empty( $meta_profile_id ) ) {
118
-                $profile_id  = $meta_profile_id;
117
+            if (!empty($meta_profile_id)) {
118
+                $profile_id = $meta_profile_id;
119 119
             }
120 120
 
121
-            if ( !empty( $meta_transaction_id ) ) {
122
-                $transaction_id  = $meta_transaction_id;
121
+            if (!empty($meta_transaction_id)) {
122
+                $transaction_id = $meta_transaction_id;
123 123
             }
124 124
         } else {
125
-            $invoice_date       = $invoice->get_invoice_date( false );
125
+            $invoice_date       = $invoice->get_invoice_date(false);
126 126
         }
127 127
         
128
-        $profile_id             = empty( $profile_id ) ? $invoice->ID : $profile_id;
129
-        $status                 = empty( $subscription_status ) ? 'pending' : $subscription_status;
128
+        $profile_id             = empty($profile_id) ? $invoice->ID : $profile_id;
129
+        $status                 = empty($subscription_status) ? 'pending' : $subscription_status;
130 130
         
131
-        $period                 = $item->get_recurring_period( true );
131
+        $period                 = $item->get_recurring_period(true);
132 132
         $interval               = $item->get_recurring_interval();
133 133
         $bill_times             = (int)$item->get_recurring_limit();
134 134
         $add_period             = $interval . ' ' . $period;
135 135
         $trial_period           = '';
136 136
 
137
-        if ( $invoice->is_free_trial() ) {
138
-            $trial_period       = $item->get_trial_period( true );
137
+        if ($invoice->is_free_trial()) {
138
+            $trial_period       = $item->get_trial_period(true);
139 139
             $free_interval      = $item->get_trial_interval();
140 140
             $trial_period       = $free_interval . ' ' . $trial_period;
141 141
 
142
-            if ( empty( $last_payment ) ) {
142
+            if (empty($last_payment)) {
143 143
                 $add_period     = $trial_period;
144 144
             }
145 145
         }
146 146
 
147
-        $expiration             = date_i18n( 'Y-m-d H:i:s', strtotime( '+' . $add_period  . ' 23:59:59', strtotime( $invoice_date ) ) );
148
-        if ( strtotime( $expiration ) <  strtotime( date_i18n( 'Y-m-d' ) ) ) {
149
-            if ( $status == 'active' || $status == 'trialling' || $status == 'pending' ) {
147
+        $expiration = date_i18n('Y-m-d H:i:s', strtotime('+' . $add_period . ' 23:59:59', strtotime($invoice_date)));
148
+        if (strtotime($expiration) < strtotime(date_i18n('Y-m-d'))) {
149
+            if ($status == 'active' || $status == 'trialling' || $status == 'pending') {
150 150
                 $status = 'expired';
151 151
             }
152 152
         }
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
             'frequency'         => $interval,
160 160
             'period'            => $period,
161 161
             'initial_amount'    => $invoice->get_total(),
162
-            'recurring_amount'  => $invoice->get_recurring_details( 'total' ),
162
+            'recurring_amount'  => $invoice->get_recurring_details('total'),
163 163
             'bill_times'        => $bill_times,
164 164
             'created'           => $invoice_date,
165 165
             'expiration'        => $expiration,
@@ -169,14 +169,14 @@  discard block
 block discarded – undo
169 169
         );
170 170
 
171 171
         $subs_db      = new WPInv_Subscriptions_DB;
172
-        $subs         = $subs_db->get_subscriptions( array( 'parent_payment_id' => $invoice->ID, 'number' => 1 ) );
173
-        $subscription = reset( $subs );
172
+        $subs         = $subs_db->get_subscriptions(array('parent_payment_id' => $invoice->ID, 'number' => 1));
173
+        $subscription = reset($subs);
174 174
 
175
-        if ( empty( $subscription ) || $subscription->id <= 0 ) {
175
+        if (empty($subscription) || $subscription->id <= 0) {
176 176
             $subscription = new WPInv_Subscription();
177
-            $new_sub = $subscription->create( $args );
177
+            $new_sub = $subscription->create($args);
178 178
 
179
-            if ( !empty( $bill_times ) && $new_sub->get_times_billed() >= $bill_times && ( 'active' == $new_sub->status || 'trialling' == $new_sub->status ) ) {
179
+            if (!empty($bill_times) && $new_sub->get_times_billed() >= $bill_times && ('active' == $new_sub->status || 'trialling' == $new_sub->status)) {
180 180
                 $new_sub->complete(); // Mark completed if all times billed
181 181
             }
182 182
         }
@@ -186,20 +186,20 @@  discard block
 block discarded – undo
186 186
 function wpinv_update_new_email_settings() {
187 187
     global $wpinv_options;
188 188
 
189
-    $current_options = get_option( 'wpinv_settings', array() );
189
+    $current_options = get_option('wpinv_settings', array());
190 190
     $options = array(
191
-        'email_new_invoice_body' => __( '<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing' ),
192
-        'email_cancelled_invoice_body' => __( '<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing' ),
193
-        'email_failed_invoice_body' => __( '<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing' ),
194
-        'email_onhold_invoice_body' => __( '<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing' ),
195
-        'email_processing_invoice_body' => __( '<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing' ),
196
-        'email_refunded_invoice_body' => __( '<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing' ),
197
-        'email_user_invoice_body' => __( '<p>Hi {name},</p><p>An invoice has been created for you on {site_title}. To view / pay for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ),
198
-        'email_user_note_body' => __( '<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing' ),
199
-        'email_overdue_body' => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ),
191
+        'email_new_invoice_body' => __('<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing'),
192
+        'email_cancelled_invoice_body' => __('<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing'),
193
+        'email_failed_invoice_body' => __('<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing'),
194
+        'email_onhold_invoice_body' => __('<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing'),
195
+        'email_processing_invoice_body' => __('<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing'),
196
+        'email_refunded_invoice_body' => __('<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing'),
197
+        'email_user_invoice_body' => __('<p>Hi {name},</p><p>An invoice has been created for you on {site_title}. To view / pay for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'),
198
+        'email_user_note_body' => __('<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing'),
199
+        'email_overdue_body' => __('<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'),
200 200
     );
201 201
 
202
-    foreach ($options as $option => $value){
202
+    foreach ($options as $option => $value) {
203 203
         if (!isset($current_options[$option])) {
204 204
             $current_options[$option] = $value;
205 205
         }
@@ -207,5 +207,5 @@  discard block
 block discarded – undo
207 207
 
208 208
     $wpinv_options = $current_options;
209 209
 
210
-    update_option( 'wpinv_settings', $current_options );
210
+    update_option('wpinv_settings', $current_options);
211 211
 }
212 212
\ No newline at end of file
Please login to merge, or discard this patch.
includes/wpinv-subscription.php 1 patch
Spacing   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Exit if accessed directly
4
-if ( ! defined( 'ABSPATH' ) ) {
4
+if (!defined('ABSPATH')) {
5 5
 	exit;
6 6
 }
7 7
 
@@ -38,15 +38,15 @@  discard block
 block discarded – undo
38 38
 	 * @since  1.0.0
39 39
 	 * @return void
40 40
 	 */
41
-	function __construct( $_id_or_object = 0, $_by_profile_id = false ) {
41
+	function __construct($_id_or_object = 0, $_by_profile_id = false) {
42 42
 
43 43
 		$this->subs_db = new WPInv_Subscriptions_DB;
44 44
 
45
-		if( $_by_profile_id ) {
45
+		if ($_by_profile_id) {
46 46
 
47
-			$_sub = $this->subs_db->get_by( 'profile_id', $_id_or_object );
47
+			$_sub = $this->subs_db->get_by('profile_id', $_id_or_object);
48 48
 
49
-			if( empty( $_sub ) ) {
49
+			if (empty($_sub)) {
50 50
 				return false;
51 51
 			}
52 52
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
 		}
56 56
 
57
-		return $this->setup_subscription( $_id_or_object );
57
+		return $this->setup_subscription($_id_or_object);
58 58
 	}
59 59
 
60 60
 	/**
@@ -63,34 +63,34 @@  discard block
 block discarded – undo
63 63
 	 * @since  1.0.0
64 64
 	 * @return void
65 65
 	 */
66
-	private function setup_subscription( $id_or_object = 0 ) {
66
+	private function setup_subscription($id_or_object = 0) {
67 67
 
68
-		if( empty( $id_or_object ) ) {
68
+		if (empty($id_or_object)) {
69 69
 			return false;
70 70
 		}
71 71
 
72
-		if( is_numeric( $id_or_object ) ) {
72
+		if (is_numeric($id_or_object)) {
73 73
 
74
-			$sub = $this->subs_db->get( $id_or_object );
74
+			$sub = $this->subs_db->get($id_or_object);
75 75
 
76
-		} elseif( is_object( $id_or_object ) ) {
76
+		} elseif (is_object($id_or_object)) {
77 77
 
78 78
 			$sub = $id_or_object;
79 79
 
80 80
 		}
81 81
 
82
-		if( empty( $sub ) ) {
82
+		if (empty($sub)) {
83 83
 			return false;
84 84
 		}
85 85
 
86
-		foreach( $sub as $key => $value ) {
86
+		foreach ($sub as $key => $value) {
87 87
 			$this->$key = $value;
88 88
 		}
89 89
 
90
-		$this->customer = get_userdata( $this->customer_id );
91
-		$this->gateway  = wpinv_get_payment_gateway( $this->parent_payment_id );
90
+		$this->customer = get_userdata($this->customer_id);
91
+		$this->gateway  = wpinv_get_payment_gateway($this->parent_payment_id);
92 92
 
93
-		do_action( 'wpinv_recurring_setup_subscription', $this );
93
+		do_action('wpinv_recurring_setup_subscription', $this);
94 94
 
95 95
 		return $this;
96 96
 	}
@@ -100,15 +100,15 @@  discard block
 block discarded – undo
100 100
 	 *
101 101
 	 * @since 1.0.0
102 102
 	 */
103
-	public function __get( $key ) {
103
+	public function __get($key) {
104 104
 
105
-		if( method_exists( $this, 'get_' . $key ) ) {
105
+		if (method_exists($this, 'get_' . $key)) {
106 106
 
107
-			return call_user_func( array( $this, 'get_' . $key ) );
107
+			return call_user_func(array($this, 'get_' . $key));
108 108
 
109 109
 		} else {
110 110
 
111
-			return new WP_Error( 'wpinv-subscription-invalid-property', sprintf( __( 'Can\'t get property %s', 'invoicing' ), $key ) );
111
+			return new WP_Error('wpinv-subscription-invalid-property', sprintf(__('Can\'t get property %s', 'invoicing'), $key));
112 112
 
113 113
 		}
114 114
 
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
 	 * @param  array  $data Array of attributes for a subscription
122 122
 	 * @return mixed  false if data isn't passed and class not instantiated for creation
123 123
 	 */
124
-	public function create( $data = array() ) {
124
+	public function create($data = array()) {
125 125
 
126
-		if ( $this->id != 0 ) {
126
+		if ($this->id != 0) {
127 127
 			return false;
128 128
 		}
129 129
 
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
 			'profile_id'        => '',
143 143
 		);
144 144
 
145
-		$args = wp_parse_args( $data, $defaults );
145
+		$args = wp_parse_args($data, $defaults);
146 146
 
147
-		if( $args['expiration'] && strtotime( 'NOW', current_time( 'timestamp' ) ) > strtotime( $args['expiration'], current_time( 'timestamp' ) ) ) {
147
+		if ($args['expiration'] && strtotime('NOW', current_time('timestamp')) > strtotime($args['expiration'], current_time('timestamp'))) {
148 148
 
149
-			if( 'active' == $args['status'] || 'trialling' == $args['status'] ) {
149
+			if ('active' == $args['status'] || 'trialling' == $args['status']) {
150 150
 
151 151
 				// Force an active subscription to expired if expiration date is in the past
152 152
 				$args['status'] = 'expired';
@@ -154,13 +154,13 @@  discard block
 block discarded – undo
154 154
 			}
155 155
 		}
156 156
 
157
-		do_action( 'wpinv_subscription_pre_create', $args );
157
+		do_action('wpinv_subscription_pre_create', $args);
158 158
 
159
-		$id = $this->subs_db->insert( $args, 'subscription' );
159
+		$id = $this->subs_db->insert($args, 'subscription');
160 160
 
161
-		do_action( 'wpinv_subscription_post_create', $id, $args );
161
+		do_action('wpinv_subscription_post_create', $id, $args);
162 162
 
163
-		return $this->setup_subscription( $id );
163
+		return $this->setup_subscription($id);
164 164
 
165 165
 	}
166 166
 
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
 	 * @param  array $args Array of fields to update
172 172
 	 * @return bool
173 173
 	 */
174
-	public function update( $args = array() ) {
174
+	public function update($args = array()) {
175 175
 
176
-		$ret = $this->subs_db->update( $this->id, $args );
176
+		$ret = $this->subs_db->update($this->id, $args);
177 177
 
178
-		do_action( 'wpinv_recurring_update_subscription', $this->id, $args, $this );
178
+		do_action('wpinv_recurring_update_subscription', $this->id, $args, $this);
179 179
 
180 180
 		return $ret;
181 181
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	 * @return bool
189 189
 	 */
190 190
 	public function delete() {
191
-		return $this->subs_db->delete( $this->id );
191
+		return $this->subs_db->delete($this->id);
192 192
 	}
193 193
 
194 194
     /**
@@ -208,14 +208,14 @@  discard block
 block discarded – undo
208 208
      * @return array
209 209
      */
210 210
     public function get_child_payments() {
211
-        $payments = get_posts( array(
212
-            'post_parent'    => (int) $this->parent_payment_id,
211
+        $payments = get_posts(array(
212
+            'post_parent'    => (int)$this->parent_payment_id,
213 213
             'posts_per_page' => '999',
214
-            'post_status'    => array( 'publish', 'wpi-processing', 'wpi-renewal' ),
214
+            'post_status'    => array('publish', 'wpi-processing', 'wpi-renewal'),
215 215
             'orderby'           => 'ID',
216 216
             'order'             => 'DESC',
217 217
             'post_type'      => 'wpi_invoice'
218
-        ) );
218
+        ));
219 219
 
220 220
         return $payments;
221 221
     }
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
      */
229 229
     public function get_total_payments() {
230 230
         $child_payments = $this->get_child_payments();
231
-        $total_payments = !empty( $child_payments ) ? count( $child_payments ) : 0;
231
+        $total_payments = !empty($child_payments) ? count($child_payments) : 0;
232 232
 
233
-        if ( 'pending' != $this->status ) {
233
+        if ('pending' != $this->status) {
234 234
                 $total_payments++;
235 235
         }
236 236
 
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
     public function get_times_billed() {
247 247
         $times_billed = (int)$this->get_total_payments();
248 248
 
249
-        if ( ! empty( $this->trial_period ) && $times_billed > 0 ) {
249
+        if (!empty($this->trial_period) && $times_billed > 0) {
250 250
             $times_billed--;
251 251
         }
252 252
 
@@ -260,51 +260,51 @@  discard block
 block discarded – undo
260 260
      * @param  array $args Array of values for the payment, including amount and transaction ID
261 261
      * @return bool
262 262
      */
263
-    public function add_payment( $args = array() ) {
264
-        if ( ! $this->parent_payment_id ) {
263
+    public function add_payment($args = array()) {
264
+        if (!$this->parent_payment_id) {
265 265
             return false;
266 266
         }
267 267
 
268
-        $args = wp_parse_args( $args, array(
268
+        $args = wp_parse_args($args, array(
269 269
             'amount'         => '',
270 270
             'transaction_id' => '',
271 271
             'gateway'        => ''
272
-        ) );
272
+        ));
273 273
         
274
-        if ( empty( $args['transaction_id'] ) || $this->payment_exists( $args['transaction_id'] ) ) {
274
+        if (empty($args['transaction_id']) || $this->payment_exists($args['transaction_id'])) {
275 275
             return false;
276 276
         }
277 277
         
278
-        $parent_invoice = wpinv_get_invoice( $this->parent_payment_id );
279
-        if ( empty( $parent_invoice->ID ) ) {
278
+        $parent_invoice = wpinv_get_invoice($this->parent_payment_id);
279
+        if (empty($parent_invoice->ID)) {
280 280
             return false;
281 281
         }
282 282
 
283 283
         $invoice = new WPInv_Invoice();
284
-        $invoice->set( 'post_type', 'wpi_invoice' );
285
-        $invoice->set( 'parent_invoice', $this->parent_payment_id );
286
-        $invoice->set( 'currency', $parent_invoice->get_currency() );
287
-        $invoice->set( 'transaction_id', $args['transaction_id'] );
288
-        $invoice->set( 'key', $parent_invoice->generate_key() );
289
-        $invoice->set( 'ip', $parent_invoice->ip );
290
-        $invoice->set( 'user_id', $parent_invoice->get_user_id() );
291
-        $invoice->set( 'first_name', $parent_invoice->get_first_name() );
292
-        $invoice->set( 'last_name', $parent_invoice->get_last_name() );
293
-        $invoice->set( 'phone', $parent_invoice->phone );
294
-        $invoice->set( 'address', $parent_invoice->address );
295
-        $invoice->set( 'city', $parent_invoice->city );
296
-        $invoice->set( 'country', $parent_invoice->country );
297
-        $invoice->set( 'state', $parent_invoice->state );
298
-        $invoice->set( 'zip', $parent_invoice->zip );
299
-        $invoice->set( 'company', $parent_invoice->company );
300
-        $invoice->set( 'vat_number', $parent_invoice->vat_number );
301
-        $invoice->set( 'vat_rate', $parent_invoice->vat_rate );
302
-        $invoice->set( 'adddress_confirmed', $parent_invoice->adddress_confirmed );
303
-
304
-        if ( empty( $args['gateway'] ) ) {
305
-            $invoice->set( 'gateway', $parent_invoice->get_gateway() );
284
+        $invoice->set('post_type', 'wpi_invoice');
285
+        $invoice->set('parent_invoice', $this->parent_payment_id);
286
+        $invoice->set('currency', $parent_invoice->get_currency());
287
+        $invoice->set('transaction_id', $args['transaction_id']);
288
+        $invoice->set('key', $parent_invoice->generate_key());
289
+        $invoice->set('ip', $parent_invoice->ip);
290
+        $invoice->set('user_id', $parent_invoice->get_user_id());
291
+        $invoice->set('first_name', $parent_invoice->get_first_name());
292
+        $invoice->set('last_name', $parent_invoice->get_last_name());
293
+        $invoice->set('phone', $parent_invoice->phone);
294
+        $invoice->set('address', $parent_invoice->address);
295
+        $invoice->set('city', $parent_invoice->city);
296
+        $invoice->set('country', $parent_invoice->country);
297
+        $invoice->set('state', $parent_invoice->state);
298
+        $invoice->set('zip', $parent_invoice->zip);
299
+        $invoice->set('company', $parent_invoice->company);
300
+        $invoice->set('vat_number', $parent_invoice->vat_number);
301
+        $invoice->set('vat_rate', $parent_invoice->vat_rate);
302
+        $invoice->set('adddress_confirmed', $parent_invoice->adddress_confirmed);
303
+
304
+        if (empty($args['gateway'])) {
305
+            $invoice->set('gateway', $parent_invoice->get_gateway());
306 306
         } else {
307
-            $invoice->set( 'gateway', $args['gateway'] );
307
+            $invoice->set('gateway', $args['gateway']);
308 308
         }
309 309
         
310 310
         $recurring_details = $parent_invoice->get_recurring_details();
@@ -312,11 +312,11 @@  discard block
 block discarded – undo
312 312
         // increase the earnings for each item in the subscription
313 313
         $items = $recurring_details['cart_details'];
314 314
         
315
-        if ( $items ) {        
315
+        if ($items) {        
316 316
             $add_items      = array();
317 317
             $cart_details   = array();
318 318
             
319
-            foreach ( $items as $item ) {
319
+            foreach ($items as $item) {
320 320
                 $add_item             = array();
321 321
                 $add_item['id']       = $item['id'];
322 322
                 $add_item['quantity'] = $item['quantity'];
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
                 break;
327 327
             }
328 328
             
329
-            $invoice->set( 'items', $add_items );
329
+            $invoice->set('items', $add_items);
330 330
             $invoice->cart_details = $cart_details;
331 331
         }
332 332
         
@@ -336,29 +336,29 @@  discard block
 block discarded – undo
336 336
         $tax                = $recurring_details['tax'];
337 337
         $discount           = $recurring_details['discount'];
338 338
         
339
-        if ( $discount > 0 ) {
340
-            $invoice->set( 'discount_code', $parent_invoice->discount_code );
339
+        if ($discount > 0) {
340
+            $invoice->set('discount_code', $parent_invoice->discount_code);
341 341
         }
342 342
         
343
-        $invoice->subtotal = wpinv_round_amount( $subtotal );
344
-        $invoice->tax      = wpinv_round_amount( $tax );
345
-        $invoice->discount = wpinv_round_amount( $discount );
346
-        $invoice->total    = wpinv_round_amount( $total );
343
+        $invoice->subtotal = wpinv_round_amount($subtotal);
344
+        $invoice->tax      = wpinv_round_amount($tax);
345
+        $invoice->discount = wpinv_round_amount($discount);
346
+        $invoice->total    = wpinv_round_amount($total);
347 347
 
348
-        $invoice  = apply_filters( 'wpinv_subscription_add_payment_save', $invoice, $this, $args );
348
+        $invoice = apply_filters('wpinv_subscription_add_payment_save', $invoice, $this, $args);
349 349
 
350 350
         $invoice->save();
351
-        $invoice->update_meta( '_wpinv_subscription_id', $this->id );
351
+        $invoice->update_meta('_wpinv_subscription_id', $this->id);
352 352
         
353
-        if ( !empty( $invoice->ID ) ) {
354
-            wpinv_update_payment_status( $invoice->ID, 'publish' );
353
+        if (!empty($invoice->ID)) {
354
+            wpinv_update_payment_status($invoice->ID, 'publish');
355 355
             sleep(1);
356
-            wpinv_update_payment_status( $invoice->ID, 'wpi-renewal' );
356
+            wpinv_update_payment_status($invoice->ID, 'wpi-renewal');
357 357
             
358
-            $invoice = wpinv_get_invoice( $invoice->ID );
358
+            $invoice = wpinv_get_invoice($invoice->ID);
359 359
 
360
-            do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this );
361
-            do_action( 'wpinv_recurring_record_payment', $invoice->ID, $this->parent_payment_id, $args['amount'], $args['transaction_id'] );
360
+            do_action('wpinv_recurring_add_subscription_payment', $invoice, $this);
361
+            do_action('wpinv_recurring_record_payment', $invoice->ID, $this->parent_payment_id, $args['amount'], $args['transaction_id']);
362 362
             
363 363
             return $invoice->ID;
364 364
         }
@@ -374,12 +374,12 @@  discard block
 block discarded – undo
374 374
 	 */
375 375
 	public function get_transaction_id() {
376 376
 
377
-		if( empty( $this->transaction_id ) ) {
377
+		if (empty($this->transaction_id)) {
378 378
 
379
-			$txn_id = wpinv_get_payment_transaction_id( $this->parent_payment_id );
379
+			$txn_id = wpinv_get_payment_transaction_id($this->parent_payment_id);
380 380
 
381
-			if( ! empty( $txn_id ) && (int) $this->parent_payment_id !== (int) $txn_id ) {
382
-				$this->set_transaction_id( $txn_id );
381
+			if (!empty($txn_id) && (int)$this->parent_payment_id !== (int)$txn_id) {
382
+				$this->set_transaction_id($txn_id);
383 383
 			}
384 384
 
385 385
 		}
@@ -394,8 +394,8 @@  discard block
 block discarded – undo
394 394
 	 * @since  1.0.0.4
395 395
 	 * @return bool
396 396
 	 */
397
-	public function set_transaction_id( $txn_id = '' ) {
398
-		$this->update( array( 'transaction_id' => $txn_id ) );
397
+	public function set_transaction_id($txn_id = '') {
398
+		$this->update(array('transaction_id' => $txn_id));
399 399
 		$this->transaction_id = $txn_id;
400 400
 	}
401 401
 
@@ -411,35 +411,35 @@  discard block
 block discarded – undo
411 411
 
412 412
 
413 413
 		// Determine what date to use as the start for the new expiration calculation
414
-		if( $expires > current_time( 'timestamp' ) && $this->is_active() ) {
414
+		if ($expires > current_time('timestamp') && $this->is_active()) {
415 415
 
416
-			$base_date  = $expires;
416
+			$base_date = $expires;
417 417
 
418 418
 		} else {
419 419
 
420
-			$base_date  = current_time( 'timestamp' );
420
+			$base_date = current_time('timestamp');
421 421
 
422 422
 		}
423 423
 
424
-		$last_day = wpinv_cal_days_in_month( CAL_GREGORIAN, date( 'n', $base_date ), date( 'Y', $base_date ) );
424
+		$last_day = wpinv_cal_days_in_month(CAL_GREGORIAN, date('n', $base_date), date('Y', $base_date));
425 425
 
426 426
 
427 427
 		$frequency = isset($this->frequency) ? $this->frequency : 1;
428
-		$expiration = date( 'Y-m-d H:i:s', strtotime( '+' . $frequency . ' ' . $this->period  . ' 23:59:59', $base_date ) );
428
+		$expiration = date('Y-m-d H:i:s', strtotime('+' . $frequency . ' ' . $this->period . ' 23:59:59', $base_date));
429 429
 
430
-		if( date( 'j', $base_date ) == $last_day && 'day' != $this->period ) {
431
-			$expiration = date( 'Y-m-d H:i:s', strtotime( $expiration . ' +2 days' ) );
430
+		if (date('j', $base_date) == $last_day && 'day' != $this->period) {
431
+			$expiration = date('Y-m-d H:i:s', strtotime($expiration . ' +2 days'));
432 432
 		}
433 433
 
434
-		$expiration  = apply_filters( 'wpinv_subscription_renewal_expiration', $expiration, $this->id, $this );
434
+		$expiration  = apply_filters('wpinv_subscription_renewal_expiration', $expiration, $this->id, $this);
435 435
 
436
-		do_action( 'wpinv_subscription_pre_renew', $this->id, $expiration, $this );
436
+		do_action('wpinv_subscription_pre_renew', $this->id, $expiration, $this);
437 437
 
438 438
 		$this->status = 'active';
439 439
 		$times_billed = $this->get_times_billed();
440 440
 
441 441
 		// Complete subscription if applicable
442
-		if ( $this->bill_times > 0 && $times_billed >= $this->bill_times ) {
442
+		if ($this->bill_times > 0 && $times_billed >= $this->bill_times) {
443 443
 			$this->complete();
444 444
 			$this->status = 'completed';
445 445
 		}
@@ -449,10 +449,10 @@  discard block
 block discarded – undo
449 449
 			'status'     => $this->status,
450 450
 		);
451 451
 
452
-        $this->subs_db->update( $this->id, $args );
452
+        $this->subs_db->update($this->id, $args);
453 453
 
454
-		do_action( 'wpinv_subscription_post_renew', $this->id, $expiration, $this );
455
-		do_action( 'wpinv_recurring_set_subscription_status', $this->id, $this->status, $this );
454
+		do_action('wpinv_subscription_post_renew', $this->id, $expiration, $this);
455
+		do_action('wpinv_recurring_set_subscription_status', $this->id, $this->status, $this);
456 456
 
457 457
 	}
458 458
 
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 	public function complete() {
468 468
 
469 469
 		// Only mark a subscription as complete if it's not already cancelled.
470
-		if ( 'cancelled' === $this->status ) {
470
+		if ('cancelled' === $this->status) {
471 471
 			return;
472 472
 		}
473 473
 
@@ -475,11 +475,11 @@  discard block
 block discarded – undo
475 475
 			'status' => 'completed'
476 476
 		);
477 477
 
478
-		if( $this->subs_db->update( $this->id, $args ) ) {
478
+		if ($this->subs_db->update($this->id, $args)) {
479 479
 
480 480
 			$this->status = 'completed';
481 481
 
482
-			do_action( 'wpinv_subscription_completed', $this->id, $this );
482
+			do_action('wpinv_subscription_completed', $this->id, $this);
483 483
 
484 484
 		}
485 485
 
@@ -494,15 +494,15 @@  discard block
 block discarded – undo
494 494
 	 * @param  $check_expiration bool True if expiration date should be checked with merchant processor before expiring
495 495
 	 * @return void
496 496
 	 */
497
-	public function expire( $check_expiration = false ) {
497
+	public function expire($check_expiration = false) {
498 498
 
499 499
 		$expiration = $this->expiration;
500 500
 
501
-		if( $check_expiration ) {
501
+		if ($check_expiration) {
502 502
 
503 503
 			// check_expiration() updates $this->expiration so compare to $expiration above
504 504
 
505
-			if( $expiration < $this->get_expiration() && current_time( 'timestamp' ) < $this->get_expiration_time() ) {
505
+			if ($expiration < $this->get_expiration() && current_time('timestamp') < $this->get_expiration_time()) {
506 506
 
507 507
 				return false; // Do not mark as expired since real expiration date is in the future
508 508
 			}
@@ -513,11 +513,11 @@  discard block
 block discarded – undo
513 513
 			'status' => 'expired'
514 514
 		);
515 515
 
516
-		if( $this->subs_db->update( $this->id, $args ) ) {
516
+		if ($this->subs_db->update($this->id, $args)) {
517 517
 
518 518
 			$this->status = 'expired';
519 519
 
520
-			do_action( 'wpinv_subscription_expired', $this->id, $this );
520
+			do_action('wpinv_subscription_expired', $this->id, $this);
521 521
 
522 522
 		}
523 523
 
@@ -535,11 +535,11 @@  discard block
 block discarded – undo
535 535
 			'status' => 'failing'
536 536
 		);
537 537
 
538
-		if( $this->subs_db->update( $this->id, $args ) ) {
538
+		if ($this->subs_db->update($this->id, $args)) {
539 539
 
540 540
 			$this->status = 'failing';
541 541
 
542
-			do_action( 'wpinv_subscription_failing', $this->id, $this );
542
+			do_action('wpinv_subscription_failing', $this->id, $this);
543 543
 
544 544
 
545 545
 		}
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
      * @return void
554 554
      */
555 555
     public function cancel() {
556
-        if ( 'cancelled' === $this->status ) {
556
+        if ('cancelled' === $this->status) {
557 557
             return; // Already cancelled
558 558
         }
559 559
 
@@ -561,20 +561,20 @@  discard block
 block discarded – undo
561 561
             'status' => 'cancelled'
562 562
         );
563 563
 
564
-        if ( $this->subs_db->update( $this->id, $args ) ) {
565
-            if ( is_user_logged_in() ) {
566
-                $userdata = get_userdata( get_current_user_id() );
564
+        if ($this->subs_db->update($this->id, $args)) {
565
+            if (is_user_logged_in()) {
566
+                $userdata = get_userdata(get_current_user_id());
567 567
                 $user     = $userdata->display_name;
568 568
             } else {
569
-                $user = __( 'gateway', 'invoicing' );
569
+                $user = __('gateway', 'invoicing');
570 570
             }
571 571
 
572
-            $note = sprintf( __( 'Subscription has been cancelled by %s', 'invoicing' ), $user );
573
-            wpinv_insert_payment_note( $this->parent_payment_id, $note, '', '', true );
572
+            $note = sprintf(__('Subscription has been cancelled by %s', 'invoicing'), $user);
573
+            wpinv_insert_payment_note($this->parent_payment_id, $note, '', '', true);
574 574
 
575 575
             $this->status = 'cancelled';
576 576
 
577
-            do_action( 'wpinv_subscription_cancelled', $this->id, $this );
577
+            do_action('wpinv_subscription_cancelled', $this->id, $this);
578 578
         }
579 579
     }
580 580
 
@@ -589,10 +589,10 @@  discard block
 block discarded – undo
589 589
 	 */
590 590
 	public function can_cancel() {
591 591
         $ret = false;
592
-	    if( $this->gateway === 'manual' || in_array( $this->status, $this->get_cancellable_statuses() ) ) {
592
+	    if ($this->gateway === 'manual' || in_array($this->status, $this->get_cancellable_statuses())) {
593 593
             $ret = true;
594 594
         }
595
-		return apply_filters( 'wpinv_subscription_can_cancel', $ret, $this );
595
+		return apply_filters('wpinv_subscription_can_cancel', $ret, $this);
596 596
 	}
597 597
 
598 598
     /**
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
      * @return      array
604 604
      */
605 605
     public function get_cancellable_statuses() {
606
-        return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) );
606
+        return apply_filters('wpinv_recurring_cancellable_statuses', array('active', 'trialling', 'failing'));
607 607
     }
608 608
 
609 609
 	/**
@@ -614,9 +614,9 @@  discard block
 block discarded – undo
614 614
 	 */
615 615
 	public function get_cancel_url() {
616 616
 
617
-		$url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'cancel_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-cancel' );
617
+		$url = wp_nonce_url(add_query_arg(array('wpinv_action' => 'cancel_subscription', 'sub_id' => $this->id)), 'wpinv-recurring-cancel');
618 618
 
619
-		return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
619
+		return apply_filters('wpinv_subscription_cancel_url', $url, $this);
620 620
 	}
621 621
 
622 622
 	/**
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 	 */
631 631
 	public function can_renew() {
632 632
 
633
-		return apply_filters( 'wpinv_subscription_can_renew', true, $this );
633
+		return apply_filters('wpinv_subscription_can_renew', true, $this);
634 634
 	}
635 635
 
636 636
 	/**
@@ -641,9 +641,9 @@  discard block
 block discarded – undo
641 641
 	 */
642 642
 	public function get_renew_url() {
643 643
 
644
-		$url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'renew_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-renew' );
644
+		$url = wp_nonce_url(add_query_arg(array('wpinv_action' => 'renew_subscription', 'sub_id' => $this->id)), 'wpinv-recurring-renew');
645 645
 
646
-		return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
646
+		return apply_filters('wpinv_subscription_renew_url', $url, $this);
647 647
 	}
648 648
 
649 649
 	/**
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
 	 * @return bool
654 654
 	 */
655 655
 	public function can_update() {
656
-		return apply_filters( 'wpinv_subscription_can_update', false, $this );
656
+		return apply_filters('wpinv_subscription_can_update', false, $this);
657 657
 	}
658 658
 
659 659
 	/**
@@ -664,9 +664,9 @@  discard block
 block discarded – undo
664 664
 	 */
665 665
 	public function get_update_url() {
666 666
 
667
-		$url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->id ) );
667
+		$url = add_query_arg(array('action' => 'update', 'subscription_id' => $this->id));
668 668
 
669
-		return apply_filters( 'wpinv_subscription_update_url', $url, $this );
669
+		return apply_filters('wpinv_subscription_update_url', $url, $this);
670 670
 	}
671 671
 
672 672
 	/**
@@ -679,11 +679,11 @@  discard block
 block discarded – undo
679 679
 
680 680
 		$ret = false;
681 681
 
682
-		if( ! $this->is_expired() && ( $this->status == 'active' || $this->status == 'cancelled' || $this->status == 'trialling' ) ) {
682
+		if (!$this->is_expired() && ($this->status == 'active' || $this->status == 'cancelled' || $this->status == 'trialling')) {
683 683
 			$ret = true;
684 684
 		}
685 685
 
686
-		return apply_filters( 'wpinv_subscription_is_active', $ret, $this->id, $this );
686
+		return apply_filters('wpinv_subscription_is_active', $ret, $this->id, $this);
687 687
 
688 688
 	}
689 689
 
@@ -697,26 +697,26 @@  discard block
 block discarded – undo
697 697
 
698 698
 		$ret = false;
699 699
 
700
-		if ( $this->status == 'expired' ) {
700
+		if ($this->status == 'expired') {
701 701
 
702 702
 			$ret = true;
703 703
 
704
-		} elseif( 'active' === $this->status || 'cancelled' === $this->status || $this->status == 'trialling'  ) {
704
+		} elseif ('active' === $this->status || 'cancelled' === $this->status || $this->status == 'trialling') {
705 705
 
706 706
 			$ret        = false;
707 707
 			$expiration = $this->get_expiration_time();
708 708
 
709
-			if( $expiration && strtotime( 'NOW', current_time( 'timestamp' ) ) > $expiration ) {
709
+			if ($expiration && strtotime('NOW', current_time('timestamp')) > $expiration) {
710 710
 				$ret = true;
711 711
 
712
-				if ( 'active' === $this->status || $this->status == 'trialling'  ) {
712
+				if ('active' === $this->status || $this->status == 'trialling') {
713 713
 					$this->expire();
714 714
 				}
715 715
 			}
716 716
 
717 717
 		}
718 718
 
719
-		return apply_filters( 'wpinv_subscription_is_expired', $ret, $this->id, $this );
719
+		return apply_filters('wpinv_subscription_is_expired', $ret, $this->id, $this);
720 720
 
721 721
 	}
722 722
 
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 	 * @return int
738 738
 	 */
739 739
 	public function get_expiration_time() {
740
-		return strtotime( $this->expiration, current_time( 'timestamp' ) );
740
+		return strtotime($this->expiration, current_time('timestamp'));
741 741
 	}
742 742
 
743 743
 	/**
@@ -761,37 +761,37 @@  discard block
 block discarded – undo
761 761
 	 */
762 762
 	public function get_status_label() {
763 763
 
764
-		switch( $this->get_status() ) {
764
+		switch ($this->get_status()) {
765 765
 			case 'active' :
766
-				$status = __( 'Active', 'invoicing' );
766
+				$status = __('Active', 'invoicing');
767 767
 				break;
768 768
 
769 769
 			case 'cancelled' :
770
-				$status = __( 'Cancelled', 'invoicing' );
770
+				$status = __('Cancelled', 'invoicing');
771 771
 				break;
772 772
 
773 773
 			case 'expired' :
774
-				$status = __( 'Expired', 'invoicing' );
774
+				$status = __('Expired', 'invoicing');
775 775
 				break;
776 776
 
777 777
 			case 'pending' :
778
-				$status = __( 'Pending', 'invoicing' );
778
+				$status = __('Pending', 'invoicing');
779 779
 				break;
780 780
 
781 781
 			case 'failing' :
782
-				$status = __( 'Failing', 'invoicing' );
782
+				$status = __('Failing', 'invoicing');
783 783
 				break;
784 784
 
785 785
 			case 'trialling' :
786
-				$status = __( 'Trialling', 'invoicing' );
786
+				$status = __('Trialling', 'invoicing');
787 787
 				break;
788 788
 
789 789
 			case 'completed' :
790
-				$status = __( 'Completed', 'invoicing' );
790
+				$status = __('Completed', 'invoicing');
791 791
 				break;
792 792
 
793 793
 			default:
794
-				$status = ucfirst( $this->get_status() );
794
+				$status = ucfirst($this->get_status());
795 795
 				break;
796 796
 		}
797 797
 
@@ -806,51 +806,51 @@  discard block
 block discarded – undo
806 806
      */
807 807
     public function get_status_label_html() {
808 808
 
809
-        switch( $get_status = $this->get_status() ) {
809
+        switch ($get_status = $this->get_status()) {
810 810
             case 'active' :
811
-                $status = __( 'Active', 'invoicing' );
811
+                $status = __('Active', 'invoicing');
812 812
                 $class = 'label-info';
813 813
                 break;
814 814
 
815 815
             case 'cancelled' :
816
-                $status = __( 'Cancelled', 'invoicing' );
816
+                $status = __('Cancelled', 'invoicing');
817 817
                 $class = 'label-danger';
818 818
                 break;
819 819
 
820 820
             case 'expired' :
821
-                $status = __( 'Expired', 'invoicing' );
821
+                $status = __('Expired', 'invoicing');
822 822
                 $class = 'label-default';
823 823
                 break;
824 824
 
825 825
             case 'pending' :
826
-                $status = __( 'Pending', 'invoicing' );
826
+                $status = __('Pending', 'invoicing');
827 827
                 $class = 'label-primary';
828 828
                 break;
829 829
 
830 830
             case 'failing' :
831
-                $status = __( 'Failing', 'invoicing' );
831
+                $status = __('Failing', 'invoicing');
832 832
                 $class = 'label-danger';
833 833
                 break;
834 834
 
835 835
             case 'trialling' :
836
-                $status = __( 'Trialling', 'invoicing' );
836
+                $status = __('Trialling', 'invoicing');
837 837
                 $class = 'label-info';
838 838
                 break;
839 839
 
840 840
             case 'completed' :
841
-                $status = __( 'Completed', 'invoicing' );
841
+                $status = __('Completed', 'invoicing');
842 842
                 $class = 'label-success';
843 843
                 break;
844 844
 
845 845
             default:
846
-                $status = ucfirst( $this->get_status() );
846
+                $status = ucfirst($this->get_status());
847 847
                 $class = 'label-default';
848 848
                 break;
849 849
         }
850 850
 
851 851
         $label = '<span class="sub-status label label-sub-' . $get_status . ' ' . $class . '">' . $status . '</span>';
852 852
 
853
-        return apply_filters( 'wpinv_subscription_status_label_html', $label, $get_status, $status );
853
+        return apply_filters('wpinv_subscription_status_label_html', $label, $get_status, $status);
854 854
     }
855 855
 
856 856
     /**
@@ -860,18 +860,18 @@  discard block
 block discarded – undo
860 860
      * @param  string $txn_id The transaction ID from the merchant processor
861 861
      * @return bool
862 862
      */
863
-    public function payment_exists( $txn_id = '' ) {
863
+    public function payment_exists($txn_id = '') {
864 864
         global $wpdb;
865 865
 
866
-        if ( empty( $txn_id ) ) {
866
+        if (empty($txn_id)) {
867 867
             return false;
868 868
         }
869 869
 
870
-        $txn_id = esc_sql( $txn_id );
870
+        $txn_id = esc_sql($txn_id);
871 871
 
872
-        $purchase = $wpdb->get_var( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_transaction_id' AND meta_value = '{$txn_id}' LIMIT 1" );
872
+        $purchase = $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_transaction_id' AND meta_value = '{$txn_id}' LIMIT 1");
873 873
 
874
-        if ( $purchase != null ) {
874
+        if ($purchase != null) {
875 875
             return true;
876 876
         }
877 877
 
Please login to merge, or discard this patch.
includes/gateways/worldpay.php 1 patch
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly
3
-if ( ! defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5
-add_action( 'wpinv_worldpay_cc_form', '__return_false' );
5
+add_action('wpinv_worldpay_cc_form', '__return_false');
6 6
 
7
-function wpinv_process_worldpay_payment( $purchase_data ) {
8
-    if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) {
9
-        wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
7
+function wpinv_process_worldpay_payment($purchase_data) {
8
+    if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) {
9
+        wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
10 10
     }
11 11
     
12 12
     // Collect payment data
@@ -24,132 +24,132 @@  discard block
 block discarded – undo
24 24
     );
25 25
 
26 26
     // Record the pending payment
27
-    $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] );
27
+    $invoice = wpinv_get_invoice($purchase_data['invoice_id']);
28 28
     
29
-    if ( !empty( $invoice ) ) {
29
+    if (!empty($invoice)) {
30 30
         $quantities_enabled = wpinv_item_quantities_enabled();
31 31
         
32
-        $instId     = wpinv_get_option( 'worldpay_instId', false );
32
+        $instId     = wpinv_get_option('worldpay_instId', false);
33 33
         $cartId     = $invoice->get_number();
34
-        $testMode   = wpinv_is_test_mode( 'worldpay' ) ? 100 : 0;
34
+        $testMode   = wpinv_is_test_mode('worldpay') ? 100 : 0;
35 35
         $name       = $invoice->get_user_full_name();
36
-        $address    = wp_strip_all_tags( $invoice->get_address(), true );
36
+        $address    = wp_strip_all_tags($invoice->get_address(), true);
37 37
         $postcode   = $invoice->zip;
38 38
         $tel        = $invoice->phone;
39 39
         $email      = $invoice->get_email();
40 40
         $country    = $invoice->country;
41
-        $amount     = wpinv_sanitize_amount( $invoice->get_total() );
41
+        $amount     = wpinv_sanitize_amount($invoice->get_total());
42 42
         $currency   = wpinv_get_currency();
43 43
         
44 44
         $items      = array();
45
-        foreach ( $invoice->get_cart_details() as $item ) {
45
+        foreach ($invoice->get_cart_details() as $item) {
46 46
             $item_desc  = $item['name'];
47
-            $quantity   = !empty( $item['quantity'] ) && $item['quantity'] > 0 ? $item['quantity'] : 1;
48
-            $item_desc .= ' (' . ( $quantities_enabled ? $quantity . 'x ' : '' ) . wpinv_price( wpinv_format_amount( $item['item_price'] ) ) . ')';
47
+            $quantity   = !empty($item['quantity']) && $item['quantity'] > 0 ? $item['quantity'] : 1;
48
+            $item_desc .= ' (' . ($quantities_enabled ? $quantity . 'x ' : '') . wpinv_price(wpinv_format_amount($item['item_price'])) . ')';
49 49
             
50 50
             $items[] = $item_desc;
51 51
         }
52 52
         
53
-        $desc = implode( ', ', $items );
54
-        if ( wpinv_use_taxes() && $invoice->get_tax() > 0 ) {
55
-            $desc .= ', ' . wp_sprintf( __( 'Tax: %s', 'invoicing' ), $invoice->get_tax( true ) );
53
+        $desc = implode(', ', $items);
54
+        if (wpinv_use_taxes() && $invoice->get_tax() > 0) {
55
+            $desc .= ', ' . wp_sprintf(__('Tax: %s', 'invoicing'), $invoice->get_tax(true));
56 56
         }
57 57
         
58 58
         $extra_params                   = array();
59 59
         $extra_params['MC_description'] = $desc;
60
-        $extra_params['MC_callback']    = wpinv_get_ipn_url( 'worldpay' );
60
+        $extra_params['MC_callback']    = wpinv_get_ipn_url('worldpay');
61 61
         $extra_params['MC_key']         = $invoice->get_key();
62 62
         $extra_params['MC_invoice_id']  = $invoice->ID;
63 63
         $extra_params['address1']       = $address;
64 64
         $extra_params['town']           = $invoice->city;
65 65
         $extra_params['region']         = $invoice->state;
66
-        $extra_params['amountString']   = $invoice->get_total( true );
67
-        $extra_params['countryString']  = wpinv_country_name( $invoice->country );
66
+        $extra_params['amountString']   = $invoice->get_total(true);
67
+        $extra_params['countryString']  = wpinv_country_name($invoice->country);
68 68
         $extra_params['compName']       = $invoice->company;
69 69
         
70
-        $extra_params   = apply_filters( 'wpinv_worldpay_form_extra_parameters', $extra_params, $invoice );
70
+        $extra_params   = apply_filters('wpinv_worldpay_form_extra_parameters', $extra_params, $invoice);
71 71
         
72
-        $redirect_text  = __( 'Redirecting to Worldpay site, click on button if not redirected.', 'invoicing' );
73
-        $redirect_text  = apply_filters( 'wpinv_worldpay_redirect_text', $redirect_text, $invoice );
72
+        $redirect_text  = __('Redirecting to Worldpay site, click on button if not redirected.', 'invoicing');
73
+        $redirect_text  = apply_filters('wpinv_worldpay_redirect_text', $redirect_text, $invoice);
74 74
         
75 75
         // Empty the shopping cart
76 76
         wpinv_empty_cart();
77 77
         ?>
78 78
 <div class="wpi-worldpay-form" style="padding:20px;font-family:arial,sans-serif;text-align:center;color:#555">
79
-<?php do_action( 'wpinv_worldpay_form_before', $invoice ); ?>
80
-<h3><?php echo $redirect_text ;?></h3>
79
+<?php do_action('wpinv_worldpay_form_before', $invoice); ?>
80
+<h3><?php echo $redirect_text; ?></h3>
81 81
 <form action="<?php echo wpinv_get_worldpay_redirect(); ?>" name="wpi_worldpay_form" method="POST">
82
-    <input type="hidden" value="<?php echo $amount;?>" name="amount">
83
-    <input type="hidden" value="<?php echo esc_attr( $cartId );?>" name="cartId">
84
-    <input type="hidden" value="<?php echo $currency;?>" name="currency">
85
-    <input type="hidden" value="<?php echo $instId;?>" name="instId">
86
-    <input type="hidden" value="<?php echo $testMode;?>" name="testMode">
87
-    <input type="hidden" value="<?php echo esc_attr( $name );?>" name="name">
88
-    <input type="hidden" value="<?php echo esc_attr( $address );?>" name="address">
89
-    <input type="hidden" value="<?php echo esc_attr( $postcode );?>" name="postcode">
90
-    <input type="hidden" value="<?php echo esc_attr( $tel );?>" name="tel">
91
-    <input type="hidden" value="<?php echo esc_attr( $email );?>" name="email">
92
-    <input type="hidden" value="<?php echo esc_attr( $country );?>" name="country">
93
-    <input type="hidden" value="<?php echo esc_attr( $desc );?>" name="desc">
94
-    <?php foreach ( $extra_params as $param => $value ) { ?>
95
-        <?php if ( !empty( $value !== false ) ) { ?>
96
-    <input type="hidden" value="<?php echo esc_attr( $value );?>" name="<?php echo esc_attr( $param );?>">
82
+    <input type="hidden" value="<?php echo $amount; ?>" name="amount">
83
+    <input type="hidden" value="<?php echo esc_attr($cartId); ?>" name="cartId">
84
+    <input type="hidden" value="<?php echo $currency; ?>" name="currency">
85
+    <input type="hidden" value="<?php echo $instId; ?>" name="instId">
86
+    <input type="hidden" value="<?php echo $testMode; ?>" name="testMode">
87
+    <input type="hidden" value="<?php echo esc_attr($name); ?>" name="name">
88
+    <input type="hidden" value="<?php echo esc_attr($address); ?>" name="address">
89
+    <input type="hidden" value="<?php echo esc_attr($postcode); ?>" name="postcode">
90
+    <input type="hidden" value="<?php echo esc_attr($tel); ?>" name="tel">
91
+    <input type="hidden" value="<?php echo esc_attr($email); ?>" name="email">
92
+    <input type="hidden" value="<?php echo esc_attr($country); ?>" name="country">
93
+    <input type="hidden" value="<?php echo esc_attr($desc); ?>" name="desc">
94
+    <?php foreach ($extra_params as $param => $value) { ?>
95
+        <?php if (!empty($value !== false)) { ?>
96
+    <input type="hidden" value="<?php echo esc_attr($value); ?>" name="<?php echo esc_attr($param); ?>">
97 97
         <?php } ?>
98 98
     <?php } ?>
99
-    <?php do_action( 'wpinv_worldpay_form_parameters', $invoice ); ?>
100
-    <input type="submit" name="wpi_worldpay_submit" value="<?php esc_attr_e( 'Pay by Credit Card / Debit Card (WorldPay)', 'invoicing' ) ;?>">
99
+    <?php do_action('wpinv_worldpay_form_parameters', $invoice); ?>
100
+    <input type="submit" name="wpi_worldpay_submit" value="<?php esc_attr_e('Pay by Credit Card / Debit Card (WorldPay)', 'invoicing'); ?>">
101 101
 </form>
102 102
 <script type="text/javascript">document.wpi_worldpay_form.submit();</script>
103
-<?php do_action( 'wpinv_worldpay_form_after', $invoice ); ?>
103
+<?php do_action('wpinv_worldpay_form_after', $invoice); ?>
104 104
 </div>
105 105
         <?php
106 106
     } else {
107
-        wpinv_record_gateway_error( __( 'Payment Error', 'invoicing' ), sprintf( __( 'Payment creation failed while processing a worldpay payment. Payment data: %s', 'invoicing' ), json_encode( $payment_data ) ), $invoice );
107
+        wpinv_record_gateway_error(__('Payment Error', 'invoicing'), sprintf(__('Payment creation failed while processing a worldpay payment. Payment data: %s', 'invoicing'), json_encode($payment_data)), $invoice);
108 108
         // If errors are present, send the user back to the purchase page so they can be corrected
109
-        wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] );
109
+        wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']);
110 110
     }
111 111
 }
112
-add_action( 'wpinv_gateway_worldpay', 'wpinv_process_worldpay_payment' );
112
+add_action('wpinv_gateway_worldpay', 'wpinv_process_worldpay_payment');
113 113
 
114 114
 function wpinv_get_worldpay_redirect() {
115
-    $redirect = wpinv_is_test_mode( 'worldpay' ) ? 'https://secure-test.worldpay.com/wcc/purchase' : 'https://secure.worldpay.com/wcc/purchase';
115
+    $redirect = wpinv_is_test_mode('worldpay') ? 'https://secure-test.worldpay.com/wcc/purchase' : 'https://secure.worldpay.com/wcc/purchase';
116 116
     
117
-    return apply_filters( 'wpinv_worldpay_redirect', $redirect );
117
+    return apply_filters('wpinv_worldpay_redirect', $redirect);
118 118
 }
119 119
 
120 120
 function wpinv_process_worldpay_ipn() {
121
-    $request = wpinv_get_post_data( 'post' );
121
+    $request = wpinv_get_post_data('post');
122 122
     
123
-    if ( !empty( $request['cartId'] ) && !empty( $request['transStatus'] ) && !empty( $request['installation'] ) && isset( $request['testMode'] ) && isset( $request['MC_invoice_id'] ) && isset( $request['MC_key'] ) ) {
123
+    if (!empty($request['cartId']) && !empty($request['transStatus']) && !empty($request['installation']) && isset($request['testMode']) && isset($request['MC_invoice_id']) && isset($request['MC_key'])) {
124 124
         $invoice_id = $request['MC_invoice_id'];
125 125
         
126
-        if ( $invoice_id == wpinv_get_invoice_id_by_key( $request['MC_key'] ) && $invoice = wpinv_get_invoice( $invoice_id ) ) {
127
-            if ( $request['transStatus'] == 'Y' ) {                
128
-                wpinv_update_payment_status( $invoice_id, 'publish' );
129
-                wpinv_set_payment_transaction_id( $invoice_id, $request['transId'] );
130
-                wpinv_insert_payment_note( $invoice_id, sprintf( __( 'Worldpay Transaction ID: %s', 'invoicing' ), $request['transId'] ) );
126
+        if ($invoice_id == wpinv_get_invoice_id_by_key($request['MC_key']) && $invoice = wpinv_get_invoice($invoice_id)) {
127
+            if ($request['transStatus'] == 'Y') {                
128
+                wpinv_update_payment_status($invoice_id, 'publish');
129
+                wpinv_set_payment_transaction_id($invoice_id, $request['transId']);
130
+                wpinv_insert_payment_note($invoice_id, sprintf(__('Worldpay Transaction ID: %s', 'invoicing'), $request['transId']));
131 131
                 return;
132
-            } else if ( $request['transStatus'] == 'C' ) {
133
-                wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
134
-                wpinv_insert_payment_note( $invoice_id, __( 'Payment transaction failed while processing Worldpay payment, kindly check IPN log.', 'invoicing' ) );
132
+            } else if ($request['transStatus'] == 'C') {
133
+                wpinv_update_payment_status($invoice_id, 'wpi-failed');
134
+                wpinv_insert_payment_note($invoice_id, __('Payment transaction failed while processing Worldpay payment, kindly check IPN log.', 'invoicing'));
135 135
                 
136
-                wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Payment transaction failed while processing Worldpay payment. IPN data: %s', 'invoicing' ), json_encode( $request ) ), $invoice_id );
136
+                wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Payment transaction failed while processing Worldpay payment. IPN data: %s', 'invoicing'), json_encode($request)), $invoice_id);
137 137
                 return;
138 138
             }
139 139
         }
140 140
     }
141 141
     return;
142 142
 }
143
-add_action( 'wpinv_verify_worldpay_ipn', 'wpinv_process_worldpay_ipn' );
143
+add_action('wpinv_verify_worldpay_ipn', 'wpinv_process_worldpay_ipn');
144 144
 
145 145
 function wpinv_is_worldpay_valid_for_use() {
146
-    return in_array( wpinv_get_currency(), apply_filters( 'wpinv_worldpay_supported_currencies', array( 'AUD', 'ARS', 'CAD', 'CHF', 'DKK', 'EUR', 'HKD', 'MYR', 'GBP', 'NZD', 'NOK', 'SGD', 'LKR', 'SEK', 'TRY', 'USD', 'ZAR' )));
146
+    return in_array(wpinv_get_currency(), apply_filters('wpinv_worldpay_supported_currencies', array('AUD', 'ARS', 'CAD', 'CHF', 'DKK', 'EUR', 'HKD', 'MYR', 'GBP', 'NZD', 'NOK', 'SGD', 'LKR', 'SEK', 'TRY', 'USD', 'ZAR')));
147 147
 }
148 148
 
149
-function wpinv_check_worldpay_currency_support( $gateway_list ) {
150
-    if ( isset( $gateway_list['worldpay'] ) && ! wpinv_is_worldpay_valid_for_use() ) {
151
-        unset( $gateway_list['worldpay'] );
149
+function wpinv_check_worldpay_currency_support($gateway_list) {
150
+    if (isset($gateway_list['worldpay']) && !wpinv_is_worldpay_valid_for_use()) {
151
+        unset($gateway_list['worldpay']);
152 152
     }
153 153
     return $gateway_list;
154 154
 }
155
-add_filter( 'wpinv_enabled_payment_gateways', 'wpinv_check_worldpay_currency_support', 10, 1 );
156 155
\ No newline at end of file
156
+add_filter('wpinv_enabled_payment_gateways', 'wpinv_check_worldpay_currency_support', 10, 1);
157 157
\ No newline at end of file
Please login to merge, or discard this patch.
includes/wpinv-helper-functions.php 1 patch
Spacing   +380 added lines, -380 removed lines patch added patch discarded remove patch
@@ -7,132 +7,132 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 function wpinv_item_quantities_enabled() {
15
-    $ret = wpinv_get_option( 'item_quantities', true );
15
+    $ret = wpinv_get_option('item_quantities', true);
16 16
 
17
-    return (bool) apply_filters( 'wpinv_item_quantities_enabled', $ret );
17
+    return (bool)apply_filters('wpinv_item_quantities_enabled', $ret);
18 18
 }
19 19
 
20 20
 function wpinv_get_ip() {
21 21
     $ip = '127.0.0.1';
22 22
 
23
-    if ( !empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
24
-        $ip = sanitize_text_field( $_SERVER['HTTP_CLIENT_IP'] );
25
-    } elseif ( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
26
-        $ip = sanitize_text_field( $_SERVER['HTTP_X_FORWARDED_FOR'] );
27
-    } elseif( !empty( $_SERVER['REMOTE_ADDR'] ) ) {
28
-        $ip = sanitize_text_field( $_SERVER['REMOTE_ADDR'] );
23
+    if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
24
+        $ip = sanitize_text_field($_SERVER['HTTP_CLIENT_IP']);
25
+    } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
26
+        $ip = sanitize_text_field($_SERVER['HTTP_X_FORWARDED_FOR']);
27
+    } elseif (!empty($_SERVER['REMOTE_ADDR'])) {
28
+        $ip = sanitize_text_field($_SERVER['REMOTE_ADDR']);
29 29
     }
30 30
 
31
-    return apply_filters( 'wpinv_get_ip', $ip );
31
+    return apply_filters('wpinv_get_ip', $ip);
32 32
 }
33 33
 
34 34
 function wpinv_get_user_agent() {
35
-    if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
36
-        $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] );
35
+    if (!empty($_SERVER['HTTP_USER_AGENT'])) {
36
+        $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']);
37 37
     } else {
38 38
         $user_agent = '';
39 39
     }
40 40
 
41
-    return apply_filters( 'wpinv_get_user_agent', $user_agent );
41
+    return apply_filters('wpinv_get_user_agent', $user_agent);
42 42
 }
43 43
 
44
-function wpinv_sanitize_amount( $amount, $decimals = NULL ) {
44
+function wpinv_sanitize_amount($amount, $decimals = NULL) {
45 45
     $is_negative   = false;
46 46
     $thousands_sep = wpinv_thousands_separator();
47 47
     $decimal_sep   = wpinv_decimal_separator();
48
-    if ( $decimals === NULL ) {
48
+    if ($decimals === NULL) {
49 49
         $decimals = wpinv_decimals();
50 50
     }
51 51
 
52 52
     // Sanitize the amount
53
-    if ( $decimal_sep == ',' && false !== ( $found = strpos( $amount, $decimal_sep ) ) ) {
54
-        if ( ( $thousands_sep == '.' || $thousands_sep == ' ' ) && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
55
-            $amount = str_replace( $thousands_sep, '', $amount );
56
-        } elseif( empty( $thousands_sep ) && false !== ( $found = strpos( $amount, '.' ) ) ) {
57
-            $amount = str_replace( '.', '', $amount );
53
+    if ($decimal_sep == ',' && false !== ($found = strpos($amount, $decimal_sep))) {
54
+        if (($thousands_sep == '.' || $thousands_sep == ' ') && false !== ($found = strpos($amount, $thousands_sep))) {
55
+            $amount = str_replace($thousands_sep, '', $amount);
56
+        } elseif (empty($thousands_sep) && false !== ($found = strpos($amount, '.'))) {
57
+            $amount = str_replace('.', '', $amount);
58 58
         }
59 59
 
60
-        $amount = str_replace( $decimal_sep, '.', $amount );
61
-    } elseif( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
62
-        $amount = str_replace( $thousands_sep, '', $amount );
60
+        $amount = str_replace($decimal_sep, '.', $amount);
61
+    } elseif ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) {
62
+        $amount = str_replace($thousands_sep, '', $amount);
63 63
     }
64 64
 
65
-    if( $amount < 0 ) {
65
+    if ($amount < 0) {
66 66
         $is_negative = true;
67 67
     }
68 68
 
69
-    $amount   = preg_replace( '/[^0-9\.]/', '', $amount );
69
+    $amount   = preg_replace('/[^0-9\.]/', '', $amount);
70 70
 
71
-    $decimals = apply_filters( 'wpinv_sanitize_amount_decimals', absint( $decimals ), $amount );
72
-    $amount   = number_format( (double) $amount, absint( $decimals ), '.', '' );
71
+    $decimals = apply_filters('wpinv_sanitize_amount_decimals', absint($decimals), $amount);
72
+    $amount   = number_format((double)$amount, absint($decimals), '.', '');
73 73
 
74
-    if( $is_negative ) {
74
+    if ($is_negative) {
75 75
         $amount *= -1;
76 76
     }
77 77
 
78
-    return apply_filters( 'wpinv_sanitize_amount', $amount, $decimals );
78
+    return apply_filters('wpinv_sanitize_amount', $amount, $decimals);
79 79
 }
80
-add_filter( 'wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1 );
80
+add_filter('wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1);
81 81
 
82
-function wpinv_round_amount( $amount, $decimals = NULL ) {
83
-    if ( $decimals === NULL ) {
82
+function wpinv_round_amount($amount, $decimals = NULL) {
83
+    if ($decimals === NULL) {
84 84
         $decimals = wpinv_decimals();
85 85
     }
86 86
     
87
-    $amount = round( (double)$amount, wpinv_currency_decimal_filter( absint( $decimals ) ) );
87
+    $amount = round((double)$amount, wpinv_currency_decimal_filter(absint($decimals)));
88 88
 
89
-    return apply_filters( 'wpinv_round_amount', $amount, $decimals );
89
+    return apply_filters('wpinv_round_amount', $amount, $decimals);
90 90
 }
91 91
 
92
-function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
92
+function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) {
93 93
     global $post;
94 94
 
95 95
     $invoice_statuses = array(
96
-        'wpi-pending' => __( 'Pending Payment', 'invoicing' ),
97
-        'publish' => __( 'Paid', 'invoicing'),
98
-        'wpi-processing' => __( 'Processing', 'invoicing' ),
99
-        'wpi-onhold' => __( 'On Hold', 'invoicing' ),
100
-        'wpi-refunded' => __( 'Refunded', 'invoicing' ),
101
-        'wpi-cancelled' => __( 'Cancelled', 'invoicing' ),
102
-        'wpi-failed' => __( 'Failed', 'invoicing' ),
103
-        'wpi-renewal' => __( 'Renewal Payment', 'invoicing' )
96
+        'wpi-pending' => __('Pending Payment', 'invoicing'),
97
+        'publish' => __('Paid', 'invoicing'),
98
+        'wpi-processing' => __('Processing', 'invoicing'),
99
+        'wpi-onhold' => __('On Hold', 'invoicing'),
100
+        'wpi-refunded' => __('Refunded', 'invoicing'),
101
+        'wpi-cancelled' => __('Cancelled', 'invoicing'),
102
+        'wpi-failed' => __('Failed', 'invoicing'),
103
+        'wpi-renewal' => __('Renewal Payment', 'invoicing')
104 104
     );
105 105
 
106
-    if ( $draft ) {
107
-        $invoice_statuses['draft'] = __( 'Draft', 'invoicing' );
106
+    if ($draft) {
107
+        $invoice_statuses['draft'] = __('Draft', 'invoicing');
108 108
     }
109 109
 
110
-    if ( $trashed ) {
111
-        $invoice_statuses['trash'] = __( 'Trash', 'invoicing' );
110
+    if ($trashed) {
111
+        $invoice_statuses['trash'] = __('Trash', 'invoicing');
112 112
     }
113 113
 
114
-    return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
114
+    return apply_filters('wpinv_statuses', $invoice_statuses, $invoice);
115 115
 }
116 116
 
117
-function wpinv_status_nicename( $status ) {
118
-    $statuses = wpinv_get_invoice_statuses( true, true );
119
-    $status   = isset( $statuses[$status] ) ? $statuses[$status] : __( $status, 'invoicing' );
117
+function wpinv_status_nicename($status) {
118
+    $statuses = wpinv_get_invoice_statuses(true, true);
119
+    $status   = isset($statuses[$status]) ? $statuses[$status] : __($status, 'invoicing');
120 120
 
121 121
     return $status;
122 122
 }
123 123
 
124 124
 function wpinv_get_currency() {
125
-    $currency = wpinv_get_option( 'currency', 'USD' );
125
+    $currency = wpinv_get_option('currency', 'USD');
126 126
     
127
-    return apply_filters( 'wpinv_currency', $currency );
127
+    return apply_filters('wpinv_currency', $currency);
128 128
 }
129 129
 
130
-function wpinv_currency_symbol( $currency = '' ) {
131
-    if ( empty( $currency ) ) {
130
+function wpinv_currency_symbol($currency = '') {
131
+    if (empty($currency)) {
132 132
         $currency = wpinv_get_currency();
133 133
     }
134 134
     
135
-    $symbols = apply_filters( 'wpinv_currency_symbols', array(
135
+    $symbols = apply_filters('wpinv_currency_symbols', array(
136 136
         'AED' => '&#x62f;.&#x625;',
137 137
         'AFN' => '&#x60b;',
138 138
         'ALL' => 'L',
@@ -295,209 +295,209 @@  discard block
 block discarded – undo
295 295
         'YER' => '&#xfdfc;',
296 296
         'ZAR' => '&#82;',
297 297
         'ZMW' => 'ZK',
298
-    ) );
298
+    ));
299 299
 
300
-    $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency;
300
+    $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency;
301 301
 
302
-    return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency );
302
+    return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency);
303 303
 }
304 304
 
305 305
 function wpinv_currency_position() {
306
-    $position = wpinv_get_option( 'currency_position', 'left' );
306
+    $position = wpinv_get_option('currency_position', 'left');
307 307
     
308
-    return apply_filters( 'wpinv_currency_position', $position );
308
+    return apply_filters('wpinv_currency_position', $position);
309 309
 }
310 310
 
311 311
 function wpinv_thousands_separator() {
312
-    $thousand_sep = wpinv_get_option( 'thousands_separator', ',' );
312
+    $thousand_sep = wpinv_get_option('thousands_separator', ',');
313 313
     
314
-    return apply_filters( 'wpinv_thousands_separator', $thousand_sep );
314
+    return apply_filters('wpinv_thousands_separator', $thousand_sep);
315 315
 }
316 316
 
317 317
 function wpinv_decimal_separator() {
318
-    $decimal_sep = wpinv_get_option( 'decimal_separator', '.' );
318
+    $decimal_sep = wpinv_get_option('decimal_separator', '.');
319 319
     
320
-    return apply_filters( 'wpinv_decimal_separator', $decimal_sep );
320
+    return apply_filters('wpinv_decimal_separator', $decimal_sep);
321 321
 }
322 322
 
323 323
 function wpinv_decimals() {
324
-    $decimals = apply_filters( 'wpinv_decimals', wpinv_get_option( 'decimals', 2 ) );
324
+    $decimals = apply_filters('wpinv_decimals', wpinv_get_option('decimals', 2));
325 325
     
326
-    return absint( $decimals );
326
+    return absint($decimals);
327 327
 }
328 328
 
329 329
 function wpinv_get_currencies() {
330 330
     $currencies = array(
331
-        'USD' => __( 'US Dollar', 'invoicing' ),
332
-        'EUR' => __( 'Euro', 'invoicing' ),
333
-        'GBP' => __( 'Pound Sterling', 'invoicing' ),
334
-        'AED' => __( 'United Arab Emirates', 'invoicing' ),
335
-        'AFN' => __( 'Afghan Afghani', 'invoicing' ),
336
-        'ALL' => __( 'Albanian Lek', 'invoicing' ),
337
-        'AMD' => __( 'Armenian Dram', 'invoicing' ),
338
-        'ANG' => __( 'Netherlands Antillean Guilder', 'invoicing' ),
339
-        'AOA' => __( 'Angolan Kwanza', 'invoicing' ),
340
-        'ARS' => __( 'Argentine Peso', 'invoicing' ),
341
-        'AUD' => __( 'Australian Dollar', 'invoicing' ),
342
-        'AWG' => __( 'Aruban Florin', 'invoicing' ),
343
-        'AZN' => __( 'Azerbaijani Manat', 'invoicing' ),
344
-        'BAM' => __( 'Bosnia and Herzegovina Convertible Marka', 'invoicing' ),
345
-        'BBD' => __( 'Barbadian Dollar', 'invoicing' ),
346
-        'BDT' => __( 'Bangladeshi Taka', 'invoicing' ),
347
-        'BGN' => __( 'Bulgarian Lev', 'invoicing' ),
348
-        'BHD' => __( 'Bahraini Dinar', 'invoicing' ),
349
-        'BIF' => __( 'Burundian Franc', 'invoicing' ),
350
-        'BMD' => __( 'Bermudian Dollar', 'invoicing' ),
351
-        'BND' => __( 'Brunei Dollar', 'invoicing' ),
352
-        'BOB' => __( 'Bolivian Boliviano', 'invoicing' ),
353
-        'BRL' => __( 'Brazilian Real', 'invoicing' ),
354
-        'BSD' => __( 'Bahamian Dollar', 'invoicing' ),
355
-        'BTC' => __( 'Bitcoin', 'invoicing' ),
356
-        'BTN' => __( 'Bhutanese Ngultrum', 'invoicing' ),
357
-        'BWP' => __( 'Botswana Pula', 'invoicing' ),
358
-        'BYN' => __( 'Belarusian Ruble', 'invoicing' ),
359
-        'BZD' => __( 'Belize Dollar', 'invoicing' ),
360
-        'CAD' => __( 'Canadian Dollar', 'invoicing' ),
361
-        'CDF' => __( 'Congolese Franc', 'invoicing' ),
362
-        'CHF' => __( 'Swiss Franc', 'invoicing' ),
363
-        'CLP' => __( 'Chilean Peso', 'invoicing' ),
364
-        'CNY' => __( 'Chinese Yuan', 'invoicing' ),
365
-        'COP' => __( 'Colombian Peso', 'invoicing' ),
366
-        'CRC' => __( 'Costa Rican Colon', 'invoicing' ),
367
-        'CUC' => __( 'Cuban Convertible Peso', 'invoicing' ),
368
-        'CUP' => __( 'Cuban Peso', 'invoicing' ),
369
-        'CVE' => __( 'Cape Verdean escudo', 'invoicing' ),
370
-        'CZK' => __( 'Czech Koruna', 'invoicing' ),
371
-        'DJF' => __( 'Djiboutian Franc', 'invoicing' ),
372
-        'DKK' => __( 'Danish Krone', 'invoicing' ),
373
-        'DOP' => __( 'Dominican Peso', 'invoicing' ),
374
-        'DZD' => __( 'Algerian Dinar', 'invoicing' ),
375
-        'EGP' => __( 'Egyptian Pound', 'invoicing' ),
376
-        'ERN' => __( 'Eritrean Nakfa', 'invoicing' ),
377
-        'ETB' => __( 'Ethiopian Irr', 'invoicing' ),
378
-        'FJD' => __( 'Fijian Dollar', 'invoicing' ),
379
-        'FKP' => __( 'Falkland Islands Pound', 'invoicing' ),
380
-        'GEL' => __( 'Georgian Lari', 'invoicing' ),
381
-        'GGP' => __( 'Guernsey Pound', 'invoicing' ),
382
-        'GHS' => __( 'Ghana Cedi', 'invoicing' ),
383
-        'GIP' => __( 'Gibraltar Pound', 'invoicing' ),
384
-        'GMD' => __( 'Gambian Dalasi', 'invoicing' ),
385
-        'GNF' => __( 'Guinean Franc', 'invoicing' ),
386
-        'GTQ' => __( 'Guatemalan Quetzal', 'invoicing' ),
387
-        'GYD' => __( 'Guyanese Dollar', 'invoicing' ),
388
-        'HKD' => __( 'Hong Kong Dollar', 'invoicing' ),
389
-        'HNL' => __( 'Honduran Lempira', 'invoicing' ),
390
-        'HRK' => __( 'Croatian Kuna', 'invoicing' ),
391
-        'HTG' => __( 'Haitian Gourde', 'invoicing' ),
392
-        'HUF' => __( 'Hungarian Forint', 'invoicing' ),
393
-        'IDR' => __( 'Indonesian Rupiah', 'invoicing' ),
394
-        'ILS' => __( 'Israeli New Shekel', 'invoicing' ),
395
-        'IMP' => __( 'Manx Pound', 'invoicing' ),
396
-        'INR' => __( 'Indian Rupee', 'invoicing' ),
397
-        'IQD' => __( 'Iraqi Dinar', 'invoicing' ),
398
-        'IRR' => __( 'Iranian Rial', 'invoicing' ),
399
-        'IRT' => __( 'Iranian Toman', 'invoicing' ),
400
-        'ISK' => __( 'Icelandic Krona', 'invoicing' ),
401
-        'JEP' => __( 'Jersey Pound', 'invoicing' ),
402
-        'JMD' => __( 'Jamaican Dollar', 'invoicing' ),
403
-        'JOD' => __( 'Jordanian Dinar', 'invoicing' ),
404
-        'JPY' => __( 'Japanese Yen', 'invoicing' ),
405
-        'KES' => __( 'Kenyan Shilling', 'invoicing' ),
406
-        'KGS' => __( 'Kyrgyzstani Som', 'invoicing' ),
407
-        'KHR' => __( 'Cambodian Riel', 'invoicing' ),
408
-        'KMF' => __( 'Comorian Franc', 'invoicing' ),
409
-        'KPW' => __( 'North Korean Won', 'invoicing' ),
410
-        'KRW' => __( 'South Korean Won', 'invoicing' ),
411
-        'KWD' => __( 'Kuwaiti Dinar', 'invoicing' ),
412
-        'KYD' => __( 'Cayman Islands Dollar', 'invoicing' ),
413
-        'KZT' => __( 'Kazakhstani Tenge', 'invoicing' ),
414
-        'LAK' => __( 'Lao Kip', 'invoicing' ),
415
-        'LBP' => __( 'Lebanese Pound', 'invoicing' ),
416
-        'LKR' => __( 'Sri Lankan Rupee', 'invoicing' ),
417
-        'LRD' => __( 'Liberian Dollar', 'invoicing' ),
418
-        'LSL' => __( 'Lesotho Loti', 'invoicing' ),
419
-        'LYD' => __( 'Libyan Dinar', 'invoicing' ),
420
-        'MAD' => __( 'Moroccan Dirham', 'invoicing' ),
421
-        'MDL' => __( 'Moldovan Leu', 'invoicing' ),
422
-        'MGA' => __( 'Malagasy Ariary', 'invoicing' ),
423
-        'MKD' => __( 'Macedonian Denar', 'invoicing' ),
424
-        'MMK' => __( 'Burmese Kyat', 'invoicing' ),
425
-        'MNT' => __( 'Mongolian Tughrik', 'invoicing' ),
426
-        'MOP' => __( 'Macanese Pataca', 'invoicing' ),
427
-        'MRO' => __( 'Mauritanian Ouguiya', 'invoicing' ),
428
-        'MUR' => __( 'Mauritian Rupee', 'invoicing' ),
429
-        'MVR' => __( 'Maldivian Rufiyaa', 'invoicing' ),
430
-        'MWK' => __( 'Malawian Kwacha', 'invoicing' ),
431
-        'MXN' => __( 'Mexican Peso', 'invoicing' ),
432
-        'MYR' => __( 'Malaysian Ringgit', 'invoicing' ),
433
-        'MZN' => __( 'Mozambican Metical', 'invoicing' ),
434
-        'NAD' => __( 'Namibian Dollar', 'invoicing' ),
435
-        'NGN' => __( 'Nigerian Naira', 'invoicing' ),
436
-        'NIO' => __( 'Nicaraguan Cordoba', 'invoicing' ),
437
-        'NOK' => __( 'Norwegian Krone', 'invoicing' ),
438
-        'NPR' => __( 'Nepalese Rupee', 'invoicing' ),
439
-        'NZD' => __( 'New Zealand Dollar', 'invoicing' ),
440
-        'OMR' => __( 'Omani Rial', 'invoicing' ),
441
-        'PAB' => __( 'Panamanian Balboa', 'invoicing' ),
442
-        'PEN' => __( 'Peruvian Nuevo Sol', 'invoicing' ),
443
-        'PGK' => __( 'Papua New Guinean Kina', 'invoicing' ),
444
-        'PHP' => __( 'Philippine Peso', 'invoicing' ),
445
-        'PKR' => __( 'Pakistani Rupee', 'invoicing' ),
446
-        'PLN' => __( 'Polish Zloty', 'invoicing' ),
447
-        'PRB' => __( 'Transnistrian Ruble', 'invoicing' ),
448
-        'PYG' => __( 'Paraguayan Guarani', 'invoicing' ),
449
-        'QAR' => __( 'Qatari Riyal', 'invoicing' ),
450
-        'RON' => __( 'Romanian Leu', 'invoicing' ),
451
-        'RSD' => __( 'Serbian Dinar', 'invoicing' ),
452
-        'RUB' => __( 'Russian Ruble', 'invoicing' ),
453
-        'RWF' => __( 'Rwandan Franc', 'invoicing' ),
454
-        'SAR' => __( 'Saudi Riyal', 'invoicing' ),
455
-        'SBD' => __( 'Solomon Islands Dollar', 'invoicing' ),
456
-        'SCR' => __( 'Seychellois Rupee', 'invoicing' ),
457
-        'SDG' => __( 'Sudanese Pound', 'invoicing' ),
458
-        'SEK' => __( 'Swedish Krona', 'invoicing' ),
459
-        'SGD' => __( 'Singapore Dollar', 'invoicing' ),
460
-        'SHP' => __( 'Saint Helena Pound', 'invoicing' ),
461
-        'SLL' => __( 'Sierra Leonean Leone', 'invoicing' ),
462
-        'SOS' => __( 'Somali Shilling', 'invoicing' ),
463
-        'SRD' => __( 'Surinamese Dollar', 'invoicing' ),
464
-        'SSP' => __( 'South Sudanese Pound', 'invoicing' ),
465
-        'STD' => __( 'Sao Tomean Dobra', 'invoicing' ),
466
-        'SYP' => __( 'Syrian Pound', 'invoicing' ),
467
-        'SZL' => __( 'Swazi Lilangeni', 'invoicing' ),
468
-        'THB' => __( 'Thai Baht', 'invoicing' ),
469
-        'TJS' => __( 'Tajikistani Somoni', 'invoicing' ),
470
-        'TMT' => __( 'Turkmenistan Manat', 'invoicing' ),
471
-        'TND' => __( 'Tunisian Dinar', 'invoicing' ),
472
-        'TOP' => __( 'Tongan Pa&#x2bb;anga', 'invoicing' ),
473
-        'TRY' => __( 'Turkish Lira', 'invoicing' ),
474
-        'TTD' => __( 'Trinidad and Tobago Dollar', 'invoicing' ),
475
-        'TWD' => __( 'New Taiwan Dollar', 'invoicing' ),
476
-        'TZS' => __( 'Tanzanian Shilling', 'invoicing' ),
477
-        'UAH' => __( 'Ukrainian Hryvnia', 'invoicing' ),
478
-        'UGX' => __( 'Ugandan Shilling', 'invoicing' ),
479
-        'UYU' => __( 'Uruguayan Peso', 'invoicing' ),
480
-        'UZS' => __( 'Uzbekistani Som', 'invoicing' ),
481
-        'VEF' => __( 'Venezuelan Bol&iacute;var', 'invoicing' ),
482
-        'VND' => __( 'Vietnamese Dong', 'invoicing' ),
483
-        'VUV' => __( 'Vanuatu Vatu', 'invoicing' ),
484
-        'WST' => __( 'Samoan Tala', 'invoicing' ),
485
-        'XAF' => __( 'Central African CFA Franc', 'invoicing' ),
486
-        'XCD' => __( 'East Caribbean Dollar', 'invoicing' ),
487
-        'XOF' => __( 'West African CFA Franc', 'invoicing' ),
488
-        'XPF' => __( 'CFP Franc', 'invoicing' ),
489
-        'YER' => __( 'Yemeni Rial', 'invoicing' ),
490
-        'ZAR' => __( 'South African Rand', 'invoicing' ),
491
-        'ZMW' => __( 'Zambian Kwacha', 'invoicing' ),
331
+        'USD' => __('US Dollar', 'invoicing'),
332
+        'EUR' => __('Euro', 'invoicing'),
333
+        'GBP' => __('Pound Sterling', 'invoicing'),
334
+        'AED' => __('United Arab Emirates', 'invoicing'),
335
+        'AFN' => __('Afghan Afghani', 'invoicing'),
336
+        'ALL' => __('Albanian Lek', 'invoicing'),
337
+        'AMD' => __('Armenian Dram', 'invoicing'),
338
+        'ANG' => __('Netherlands Antillean Guilder', 'invoicing'),
339
+        'AOA' => __('Angolan Kwanza', 'invoicing'),
340
+        'ARS' => __('Argentine Peso', 'invoicing'),
341
+        'AUD' => __('Australian Dollar', 'invoicing'),
342
+        'AWG' => __('Aruban Florin', 'invoicing'),
343
+        'AZN' => __('Azerbaijani Manat', 'invoicing'),
344
+        'BAM' => __('Bosnia and Herzegovina Convertible Marka', 'invoicing'),
345
+        'BBD' => __('Barbadian Dollar', 'invoicing'),
346
+        'BDT' => __('Bangladeshi Taka', 'invoicing'),
347
+        'BGN' => __('Bulgarian Lev', 'invoicing'),
348
+        'BHD' => __('Bahraini Dinar', 'invoicing'),
349
+        'BIF' => __('Burundian Franc', 'invoicing'),
350
+        'BMD' => __('Bermudian Dollar', 'invoicing'),
351
+        'BND' => __('Brunei Dollar', 'invoicing'),
352
+        'BOB' => __('Bolivian Boliviano', 'invoicing'),
353
+        'BRL' => __('Brazilian Real', 'invoicing'),
354
+        'BSD' => __('Bahamian Dollar', 'invoicing'),
355
+        'BTC' => __('Bitcoin', 'invoicing'),
356
+        'BTN' => __('Bhutanese Ngultrum', 'invoicing'),
357
+        'BWP' => __('Botswana Pula', 'invoicing'),
358
+        'BYN' => __('Belarusian Ruble', 'invoicing'),
359
+        'BZD' => __('Belize Dollar', 'invoicing'),
360
+        'CAD' => __('Canadian Dollar', 'invoicing'),
361
+        'CDF' => __('Congolese Franc', 'invoicing'),
362
+        'CHF' => __('Swiss Franc', 'invoicing'),
363
+        'CLP' => __('Chilean Peso', 'invoicing'),
364
+        'CNY' => __('Chinese Yuan', 'invoicing'),
365
+        'COP' => __('Colombian Peso', 'invoicing'),
366
+        'CRC' => __('Costa Rican Colon', 'invoicing'),
367
+        'CUC' => __('Cuban Convertible Peso', 'invoicing'),
368
+        'CUP' => __('Cuban Peso', 'invoicing'),
369
+        'CVE' => __('Cape Verdean escudo', 'invoicing'),
370
+        'CZK' => __('Czech Koruna', 'invoicing'),
371
+        'DJF' => __('Djiboutian Franc', 'invoicing'),
372
+        'DKK' => __('Danish Krone', 'invoicing'),
373
+        'DOP' => __('Dominican Peso', 'invoicing'),
374
+        'DZD' => __('Algerian Dinar', 'invoicing'),
375
+        'EGP' => __('Egyptian Pound', 'invoicing'),
376
+        'ERN' => __('Eritrean Nakfa', 'invoicing'),
377
+        'ETB' => __('Ethiopian Irr', 'invoicing'),
378
+        'FJD' => __('Fijian Dollar', 'invoicing'),
379
+        'FKP' => __('Falkland Islands Pound', 'invoicing'),
380
+        'GEL' => __('Georgian Lari', 'invoicing'),
381
+        'GGP' => __('Guernsey Pound', 'invoicing'),
382
+        'GHS' => __('Ghana Cedi', 'invoicing'),
383
+        'GIP' => __('Gibraltar Pound', 'invoicing'),
384
+        'GMD' => __('Gambian Dalasi', 'invoicing'),
385
+        'GNF' => __('Guinean Franc', 'invoicing'),
386
+        'GTQ' => __('Guatemalan Quetzal', 'invoicing'),
387
+        'GYD' => __('Guyanese Dollar', 'invoicing'),
388
+        'HKD' => __('Hong Kong Dollar', 'invoicing'),
389
+        'HNL' => __('Honduran Lempira', 'invoicing'),
390
+        'HRK' => __('Croatian Kuna', 'invoicing'),
391
+        'HTG' => __('Haitian Gourde', 'invoicing'),
392
+        'HUF' => __('Hungarian Forint', 'invoicing'),
393
+        'IDR' => __('Indonesian Rupiah', 'invoicing'),
394
+        'ILS' => __('Israeli New Shekel', 'invoicing'),
395
+        'IMP' => __('Manx Pound', 'invoicing'),
396
+        'INR' => __('Indian Rupee', 'invoicing'),
397
+        'IQD' => __('Iraqi Dinar', 'invoicing'),
398
+        'IRR' => __('Iranian Rial', 'invoicing'),
399
+        'IRT' => __('Iranian Toman', 'invoicing'),
400
+        'ISK' => __('Icelandic Krona', 'invoicing'),
401
+        'JEP' => __('Jersey Pound', 'invoicing'),
402
+        'JMD' => __('Jamaican Dollar', 'invoicing'),
403
+        'JOD' => __('Jordanian Dinar', 'invoicing'),
404
+        'JPY' => __('Japanese Yen', 'invoicing'),
405
+        'KES' => __('Kenyan Shilling', 'invoicing'),
406
+        'KGS' => __('Kyrgyzstani Som', 'invoicing'),
407
+        'KHR' => __('Cambodian Riel', 'invoicing'),
408
+        'KMF' => __('Comorian Franc', 'invoicing'),
409
+        'KPW' => __('North Korean Won', 'invoicing'),
410
+        'KRW' => __('South Korean Won', 'invoicing'),
411
+        'KWD' => __('Kuwaiti Dinar', 'invoicing'),
412
+        'KYD' => __('Cayman Islands Dollar', 'invoicing'),
413
+        'KZT' => __('Kazakhstani Tenge', 'invoicing'),
414
+        'LAK' => __('Lao Kip', 'invoicing'),
415
+        'LBP' => __('Lebanese Pound', 'invoicing'),
416
+        'LKR' => __('Sri Lankan Rupee', 'invoicing'),
417
+        'LRD' => __('Liberian Dollar', 'invoicing'),
418
+        'LSL' => __('Lesotho Loti', 'invoicing'),
419
+        'LYD' => __('Libyan Dinar', 'invoicing'),
420
+        'MAD' => __('Moroccan Dirham', 'invoicing'),
421
+        'MDL' => __('Moldovan Leu', 'invoicing'),
422
+        'MGA' => __('Malagasy Ariary', 'invoicing'),
423
+        'MKD' => __('Macedonian Denar', 'invoicing'),
424
+        'MMK' => __('Burmese Kyat', 'invoicing'),
425
+        'MNT' => __('Mongolian Tughrik', 'invoicing'),
426
+        'MOP' => __('Macanese Pataca', 'invoicing'),
427
+        'MRO' => __('Mauritanian Ouguiya', 'invoicing'),
428
+        'MUR' => __('Mauritian Rupee', 'invoicing'),
429
+        'MVR' => __('Maldivian Rufiyaa', 'invoicing'),
430
+        'MWK' => __('Malawian Kwacha', 'invoicing'),
431
+        'MXN' => __('Mexican Peso', 'invoicing'),
432
+        'MYR' => __('Malaysian Ringgit', 'invoicing'),
433
+        'MZN' => __('Mozambican Metical', 'invoicing'),
434
+        'NAD' => __('Namibian Dollar', 'invoicing'),
435
+        'NGN' => __('Nigerian Naira', 'invoicing'),
436
+        'NIO' => __('Nicaraguan Cordoba', 'invoicing'),
437
+        'NOK' => __('Norwegian Krone', 'invoicing'),
438
+        'NPR' => __('Nepalese Rupee', 'invoicing'),
439
+        'NZD' => __('New Zealand Dollar', 'invoicing'),
440
+        'OMR' => __('Omani Rial', 'invoicing'),
441
+        'PAB' => __('Panamanian Balboa', 'invoicing'),
442
+        'PEN' => __('Peruvian Nuevo Sol', 'invoicing'),
443
+        'PGK' => __('Papua New Guinean Kina', 'invoicing'),
444
+        'PHP' => __('Philippine Peso', 'invoicing'),
445
+        'PKR' => __('Pakistani Rupee', 'invoicing'),
446
+        'PLN' => __('Polish Zloty', 'invoicing'),
447
+        'PRB' => __('Transnistrian Ruble', 'invoicing'),
448
+        'PYG' => __('Paraguayan Guarani', 'invoicing'),
449
+        'QAR' => __('Qatari Riyal', 'invoicing'),
450
+        'RON' => __('Romanian Leu', 'invoicing'),
451
+        'RSD' => __('Serbian Dinar', 'invoicing'),
452
+        'RUB' => __('Russian Ruble', 'invoicing'),
453
+        'RWF' => __('Rwandan Franc', 'invoicing'),
454
+        'SAR' => __('Saudi Riyal', 'invoicing'),
455
+        'SBD' => __('Solomon Islands Dollar', 'invoicing'),
456
+        'SCR' => __('Seychellois Rupee', 'invoicing'),
457
+        'SDG' => __('Sudanese Pound', 'invoicing'),
458
+        'SEK' => __('Swedish Krona', 'invoicing'),
459
+        'SGD' => __('Singapore Dollar', 'invoicing'),
460
+        'SHP' => __('Saint Helena Pound', 'invoicing'),
461
+        'SLL' => __('Sierra Leonean Leone', 'invoicing'),
462
+        'SOS' => __('Somali Shilling', 'invoicing'),
463
+        'SRD' => __('Surinamese Dollar', 'invoicing'),
464
+        'SSP' => __('South Sudanese Pound', 'invoicing'),
465
+        'STD' => __('Sao Tomean Dobra', 'invoicing'),
466
+        'SYP' => __('Syrian Pound', 'invoicing'),
467
+        'SZL' => __('Swazi Lilangeni', 'invoicing'),
468
+        'THB' => __('Thai Baht', 'invoicing'),
469
+        'TJS' => __('Tajikistani Somoni', 'invoicing'),
470
+        'TMT' => __('Turkmenistan Manat', 'invoicing'),
471
+        'TND' => __('Tunisian Dinar', 'invoicing'),
472
+        'TOP' => __('Tongan Pa&#x2bb;anga', 'invoicing'),
473
+        'TRY' => __('Turkish Lira', 'invoicing'),
474
+        'TTD' => __('Trinidad and Tobago Dollar', 'invoicing'),
475
+        'TWD' => __('New Taiwan Dollar', 'invoicing'),
476
+        'TZS' => __('Tanzanian Shilling', 'invoicing'),
477
+        'UAH' => __('Ukrainian Hryvnia', 'invoicing'),
478
+        'UGX' => __('Ugandan Shilling', 'invoicing'),
479
+        'UYU' => __('Uruguayan Peso', 'invoicing'),
480
+        'UZS' => __('Uzbekistani Som', 'invoicing'),
481
+        'VEF' => __('Venezuelan Bol&iacute;var', 'invoicing'),
482
+        'VND' => __('Vietnamese Dong', 'invoicing'),
483
+        'VUV' => __('Vanuatu Vatu', 'invoicing'),
484
+        'WST' => __('Samoan Tala', 'invoicing'),
485
+        'XAF' => __('Central African CFA Franc', 'invoicing'),
486
+        'XCD' => __('East Caribbean Dollar', 'invoicing'),
487
+        'XOF' => __('West African CFA Franc', 'invoicing'),
488
+        'XPF' => __('CFP Franc', 'invoicing'),
489
+        'YER' => __('Yemeni Rial', 'invoicing'),
490
+        'ZAR' => __('South African Rand', 'invoicing'),
491
+        'ZMW' => __('Zambian Kwacha', 'invoicing'),
492 492
     );
493 493
     
494 494
     //asort( $currencies ); // this
495 495
 
496
-    return apply_filters( 'wpinv_currencies', $currencies );
496
+    return apply_filters('wpinv_currencies', $currencies);
497 497
 }
498 498
 
499
-function wpinv_price( $amount = '', $currency = '' ) {
500
-    if( empty( $currency ) ) {
499
+function wpinv_price($amount = '', $currency = '') {
500
+    if (empty($currency)) {
501 501
         $currency = wpinv_get_currency();
502 502
     }
503 503
 
@@ -505,14 +505,14 @@  discard block
 block discarded – undo
505 505
 
506 506
     $negative = $amount < 0;
507 507
 
508
-    if ( $negative ) {
509
-        $amount = substr( $amount, 1 );
508
+    if ($negative) {
509
+        $amount = substr($amount, 1);
510 510
     }
511 511
 
512
-    $symbol = wpinv_currency_symbol( $currency );
512
+    $symbol = wpinv_currency_symbol($currency);
513 513
 
514
-    if ( $position == 'left' || $position == 'left_space' ) {
515
-        switch ( $currency ) {
514
+    if ($position == 'left' || $position == 'left_space') {
515
+        switch ($currency) {
516 516
             case "GBP" :
517 517
             case "BRL" :
518 518
             case "EUR" :
@@ -524,15 +524,15 @@  discard block
 block discarded – undo
524 524
             case "NZD" :
525 525
             case "SGD" :
526 526
             case "JPY" :
527
-                $price = $position == 'left_space' ? $symbol . ' ' .  $amount : $symbol . $amount;
527
+                $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount;
528 528
                 break;
529 529
             default :
530 530
                 //$price = $currency . ' ' . $amount;
531
-                $price = $position == 'left_space' ? $symbol . ' ' .  $amount : $symbol . $amount;
531
+                $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount;
532 532
                 break;
533 533
         }
534 534
     } else {
535
-        switch ( $currency ) {
535
+        switch ($currency) {
536 536
             case "GBP" :
537 537
             case "BRL" :
538 538
             case "EUR" :
@@ -543,83 +543,83 @@  discard block
 block discarded – undo
543 543
             case "MXN" :
544 544
             case "SGD" :
545 545
             case "JPY" :
546
-                $price = $position == 'right_space' ? $amount . ' ' .  $symbol : $amount . $symbol;
546
+                $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol;
547 547
                 break;
548 548
             default :
549 549
                 //$price = $amount . ' ' . $currency;
550
-                $price = $position == 'right_space' ? $amount . ' ' .  $symbol : $amount . $symbol;
550
+                $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol;
551 551
                 break;
552 552
         }
553 553
     }
554 554
     
555
-    if ( $negative ) {
555
+    if ($negative) {
556 556
         $price = '-' . $price;
557 557
     }
558 558
     
559
-    $price = apply_filters( 'wpinv_' . strtolower( $currency ) . '_currency_filter_' . $position, $price, $currency, $amount );
559
+    $price = apply_filters('wpinv_' . strtolower($currency) . '_currency_filter_' . $position, $price, $currency, $amount);
560 560
 
561 561
     return $price;
562 562
 }
563 563
 
564
-function wpinv_format_amount( $amount, $decimals = NULL, $calculate = false ) {
564
+function wpinv_format_amount($amount, $decimals = NULL, $calculate = false) {
565 565
     $thousands_sep = wpinv_thousands_separator();
566 566
     $decimal_sep   = wpinv_decimal_separator();
567 567
 
568
-    if ( $decimals === NULL ) {
568
+    if ($decimals === NULL) {
569 569
         $decimals = wpinv_decimals();
570 570
     }
571 571
 
572
-    if ( $decimal_sep == ',' && false !== ( $sep_found = strpos( $amount, $decimal_sep ) ) ) {
573
-        $whole = substr( $amount, 0, $sep_found );
574
-        $part = substr( $amount, $sep_found + 1, ( strlen( $amount ) - 1 ) );
572
+    if ($decimal_sep == ',' && false !== ($sep_found = strpos($amount, $decimal_sep))) {
573
+        $whole = substr($amount, 0, $sep_found);
574
+        $part = substr($amount, $sep_found + 1, (strlen($amount) - 1));
575 575
         $amount = $whole . '.' . $part;
576 576
     }
577 577
 
578
-    if ( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
579
-        $amount = str_replace( ',', '', $amount );
578
+    if ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) {
579
+        $amount = str_replace(',', '', $amount);
580 580
     }
581 581
 
582
-    if ( $thousands_sep == ' ' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
583
-        $amount = str_replace( ' ', '', $amount );
582
+    if ($thousands_sep == ' ' && false !== ($found = strpos($amount, $thousands_sep))) {
583
+        $amount = str_replace(' ', '', $amount);
584 584
     }
585 585
 
586
-    if ( empty( $amount ) ) {
586
+    if (empty($amount)) {
587 587
         $amount = 0;
588 588
     }
589 589
     
590
-    $decimals  = apply_filters( 'wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate );
591
-    $formatted = number_format( (float)$amount, $decimals, $decimal_sep, $thousands_sep );
590
+    $decimals  = apply_filters('wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate);
591
+    $formatted = number_format((float)$amount, $decimals, $decimal_sep, $thousands_sep);
592 592
     
593
-    if ( $calculate ) {
594
-        if ( $thousands_sep === "," ) {
595
-            $formatted = str_replace( ",", "", $formatted );
593
+    if ($calculate) {
594
+        if ($thousands_sep === ",") {
595
+            $formatted = str_replace(",", "", $formatted);
596 596
         }
597 597
         
598
-        if ( $decimal_sep === "," ) {
599
-            $formatted = str_replace( ",", ".", $formatted );
598
+        if ($decimal_sep === ",") {
599
+            $formatted = str_replace(",", ".", $formatted);
600 600
         }
601 601
     }
602 602
 
603
-    return apply_filters( 'wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate );
603
+    return apply_filters('wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate);
604 604
 }
605
-add_filter( 'wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1 );
605
+add_filter('wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1);
606 606
 
607
-function wpinv_sanitize_key( $key ) {
607
+function wpinv_sanitize_key($key) {
608 608
     $raw_key = $key;
609
-    $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
609
+    $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key);
610 610
 
611
-    return apply_filters( 'wpinv_sanitize_key', $key, $raw_key );
611
+    return apply_filters('wpinv_sanitize_key', $key, $raw_key);
612 612
 }
613 613
 
614
-function wpinv_get_file_extension( $str ) {
615
-    $parts = explode( '.', $str );
616
-    return end( $parts );
614
+function wpinv_get_file_extension($str) {
615
+    $parts = explode('.', $str);
616
+    return end($parts);
617 617
 }
618 618
 
619
-function wpinv_string_is_image_url( $str ) {
620
-    $ext = wpinv_get_file_extension( $str );
619
+function wpinv_string_is_image_url($str) {
620
+    $ext = wpinv_get_file_extension($str);
621 621
 
622
-    switch ( strtolower( $ext ) ) {
622
+    switch (strtolower($ext)) {
623 623
         case 'jpeg';
624 624
         case 'jpg';
625 625
             $return = true;
@@ -635,32 +635,32 @@  discard block
 block discarded – undo
635 635
             break;
636 636
     }
637 637
 
638
-    return (bool)apply_filters( 'wpinv_string_is_image', $return, $str );
638
+    return (bool)apply_filters('wpinv_string_is_image', $return, $str);
639 639
 }
640 640
 
641
-function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) {
642
-    $should_log = apply_filters( 'wpinv_log_errors', WP_DEBUG );
641
+function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) {
642
+    $should_log = apply_filters('wpinv_log_errors', WP_DEBUG);
643 643
     
644
-    if ( true === $should_log ) {
644
+    if (true === $should_log) {
645 645
         $label = '';
646
-        if ( $file && $file !== '' ) {
647
-            $label .= basename( $file ) . ( $line ? '(' . $line . ')' : '' );
646
+        if ($file && $file !== '') {
647
+            $label .= basename($file) . ($line ? '(' . $line . ')' : '');
648 648
         }
649 649
         
650
-        if ( $title && $title !== '' ) {
650
+        if ($title && $title !== '') {
651 651
             $label = $label !== '' ? $label . ' ' : '';
652 652
             $label .= $title . ' ';
653 653
         }
654 654
         
655
-        $label = $label !== '' ? trim( $label ) . ' : ' : '';
655
+        $label = $label !== '' ? trim($label) . ' : ' : '';
656 656
         
657
-        if ( is_array( $log ) || is_object( $log ) ) {
658
-            error_log( $label . print_r( $log, true ) );
657
+        if (is_array($log) || is_object($log)) {
658
+            error_log($label . print_r($log, true));
659 659
         } else {
660
-            error_log( $label . $log );
660
+            error_log($label . $log);
661 661
         }
662 662
         
663
-        if ( $exit ) {
663
+        if ($exit) {
664 664
             exit;
665 665
         }
666 666
     }
@@ -668,65 +668,65 @@  discard block
 block discarded – undo
668 668
 
669 669
 function wpinv_is_ajax_disabled() {
670 670
     $retval = false;
671
-    return apply_filters( 'wpinv_is_ajax_disabled', $retval );
671
+    return apply_filters('wpinv_is_ajax_disabled', $retval);
672 672
 }
673 673
 
674
-function wpinv_get_current_page_url( $nocache = false ) {
674
+function wpinv_get_current_page_url($nocache = false) {
675 675
     global $wp;
676 676
 
677
-    if ( get_option( 'permalink_structure' ) ) {
678
-        $base = trailingslashit( home_url( $wp->request ) );
677
+    if (get_option('permalink_structure')) {
678
+        $base = trailingslashit(home_url($wp->request));
679 679
     } else {
680
-        $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) );
681
-        $base = remove_query_arg( array( 'post_type', 'name' ), $base );
680
+        $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request)));
681
+        $base = remove_query_arg(array('post_type', 'name'), $base);
682 682
     }
683 683
 
684 684
     $scheme = is_ssl() ? 'https' : 'http';
685
-    $uri    = set_url_scheme( $base, $scheme );
685
+    $uri    = set_url_scheme($base, $scheme);
686 686
 
687
-    if ( is_front_page() ) {
688
-        $uri = home_url( '/' );
689
-    } elseif ( wpinv_is_checkout( array(), false ) ) {
687
+    if (is_front_page()) {
688
+        $uri = home_url('/');
689
+    } elseif (wpinv_is_checkout(array(), false)) {
690 690
         $uri = wpinv_get_checkout_uri();
691 691
     }
692 692
 
693
-    $uri = apply_filters( 'wpinv_get_current_page_url', $uri );
693
+    $uri = apply_filters('wpinv_get_current_page_url', $uri);
694 694
 
695
-    if ( $nocache ) {
696
-        $uri = wpinv_add_cache_busting( $uri );
695
+    if ($nocache) {
696
+        $uri = wpinv_add_cache_busting($uri);
697 697
     }
698 698
 
699 699
     return $uri;
700 700
 }
701 701
 
702 702
 function wpinv_get_php_arg_separator_output() {
703
-	return ini_get( 'arg_separator.output' );
703
+	return ini_get('arg_separator.output');
704 704
 }
705 705
 
706
-function wpinv_rgb_from_hex( $color ) {
707
-    $color = str_replace( '#', '', $color );
706
+function wpinv_rgb_from_hex($color) {
707
+    $color = str_replace('#', '', $color);
708 708
     // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF"
709
-    $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color );
709
+    $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color);
710 710
 
711 711
     $rgb      = array();
712
-    $rgb['R'] = hexdec( $color{0}.$color{1} );
713
-    $rgb['G'] = hexdec( $color{2}.$color{3} );
714
-    $rgb['B'] = hexdec( $color{4}.$color{5} );
712
+    $rgb['R'] = hexdec($color{0} . $color{1} );
713
+    $rgb['G'] = hexdec($color{2} . $color{3} );
714
+    $rgb['B'] = hexdec($color{4} . $color{5} );
715 715
 
716 716
     return $rgb;
717 717
 }
718 718
 
719
-function wpinv_hex_darker( $color, $factor = 30 ) {
720
-    $base  = wpinv_rgb_from_hex( $color );
719
+function wpinv_hex_darker($color, $factor = 30) {
720
+    $base  = wpinv_rgb_from_hex($color);
721 721
     $color = '#';
722 722
 
723
-    foreach ( $base as $k => $v ) {
723
+    foreach ($base as $k => $v) {
724 724
         $amount      = $v / 100;
725
-        $amount      = round( $amount * $factor );
725
+        $amount      = round($amount * $factor);
726 726
         $new_decimal = $v - $amount;
727 727
 
728
-        $new_hex_component = dechex( $new_decimal );
729
-        if ( strlen( $new_hex_component ) < 2 ) {
728
+        $new_hex_component = dechex($new_decimal);
729
+        if (strlen($new_hex_component) < 2) {
730 730
             $new_hex_component = "0" . $new_hex_component;
731 731
         }
732 732
         $color .= $new_hex_component;
@@ -735,18 +735,18 @@  discard block
 block discarded – undo
735 735
     return $color;
736 736
 }
737 737
 
738
-function wpinv_hex_lighter( $color, $factor = 30 ) {
739
-    $base  = wpinv_rgb_from_hex( $color );
738
+function wpinv_hex_lighter($color, $factor = 30) {
739
+    $base  = wpinv_rgb_from_hex($color);
740 740
     $color = '#';
741 741
 
742
-    foreach ( $base as $k => $v ) {
742
+    foreach ($base as $k => $v) {
743 743
         $amount      = 255 - $v;
744 744
         $amount      = $amount / 100;
745
-        $amount      = round( $amount * $factor );
745
+        $amount      = round($amount * $factor);
746 746
         $new_decimal = $v + $amount;
747 747
 
748
-        $new_hex_component = dechex( $new_decimal );
749
-        if ( strlen( $new_hex_component ) < 2 ) {
748
+        $new_hex_component = dechex($new_decimal);
749
+        if (strlen($new_hex_component) < 2) {
750 750
             $new_hex_component = "0" . $new_hex_component;
751 751
         }
752 752
         $color .= $new_hex_component;
@@ -755,22 +755,22 @@  discard block
 block discarded – undo
755 755
     return $color;
756 756
 }
757 757
 
758
-function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) {
759
-    $hex = str_replace( '#', '', $color );
758
+function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') {
759
+    $hex = str_replace('#', '', $color);
760 760
 
761
-    $c_r = hexdec( substr( $hex, 0, 2 ) );
762
-    $c_g = hexdec( substr( $hex, 2, 2 ) );
763
-    $c_b = hexdec( substr( $hex, 4, 2 ) );
761
+    $c_r = hexdec(substr($hex, 0, 2));
762
+    $c_g = hexdec(substr($hex, 2, 2));
763
+    $c_b = hexdec(substr($hex, 4, 2));
764 764
 
765
-    $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
765
+    $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000;
766 766
 
767 767
     return $brightness > 155 ? $dark : $light;
768 768
 }
769 769
 
770
-function wpinv_format_hex( $hex ) {
771
-    $hex = trim( str_replace( '#', '', $hex ) );
770
+function wpinv_format_hex($hex) {
771
+    $hex = trim(str_replace('#', '', $hex));
772 772
 
773
-    if ( strlen( $hex ) == 3 ) {
773
+    if (strlen($hex) == 3) {
774 774
         $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
775 775
     }
776 776
 
@@ -790,12 +790,12 @@  discard block
 block discarded – undo
790 790
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
791 791
  * @return string
792 792
  */
793
-function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) {
794
-    if ( function_exists( 'mb_strimwidth' ) ) {
795
-        return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding );
793
+function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') {
794
+    if (function_exists('mb_strimwidth')) {
795
+        return mb_strimwidth($str, $start, $width, $trimmaker, $encoding);
796 796
     }
797 797
     
798
-    return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker;
798
+    return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker;
799 799
 }
800 800
 
801 801
 /**
@@ -807,28 +807,28 @@  discard block
 block discarded – undo
807 807
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
808 808
  * @return int Returns the number of characters in string.
809 809
  */
810
-function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) {
811
-    if ( function_exists( 'mb_strlen' ) ) {
812
-        return mb_strlen( $str, $encoding );
810
+function wpinv_utf8_strlen($str, $encoding = 'UTF-8') {
811
+    if (function_exists('mb_strlen')) {
812
+        return mb_strlen($str, $encoding);
813 813
     }
814 814
         
815
-    return strlen( $str );
815
+    return strlen($str);
816 816
 }
817 817
 
818
-function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) {
819
-    if ( function_exists( 'mb_strtolower' ) ) {
820
-        return mb_strtolower( $str, $encoding );
818
+function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') {
819
+    if (function_exists('mb_strtolower')) {
820
+        return mb_strtolower($str, $encoding);
821 821
     }
822 822
     
823
-    return strtolower( $str );
823
+    return strtolower($str);
824 824
 }
825 825
 
826
-function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) {
827
-    if ( function_exists( 'mb_strtoupper' ) ) {
828
-        return mb_strtoupper( $str, $encoding );
826
+function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') {
827
+    if (function_exists('mb_strtoupper')) {
828
+        return mb_strtoupper($str, $encoding);
829 829
     }
830 830
     
831
-    return strtoupper( $str );
831
+    return strtoupper($str);
832 832
 }
833 833
 
834 834
 /**
@@ -842,12 +842,12 @@  discard block
 block discarded – undo
842 842
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
843 843
  * @return int Returns the position of the first occurrence of search in the string.
844 844
  */
845
-function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
846
-    if ( function_exists( 'mb_strpos' ) ) {
847
-        return mb_strpos( $str, $find, $offset, $encoding );
845
+function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
846
+    if (function_exists('mb_strpos')) {
847
+        return mb_strpos($str, $find, $offset, $encoding);
848 848
     }
849 849
         
850
-    return strpos( $str, $find, $offset );
850
+    return strpos($str, $find, $offset);
851 851
 }
852 852
 
853 853
 /**
@@ -861,12 +861,12 @@  discard block
 block discarded – undo
861 861
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
862 862
  * @return int Returns the position of the last occurrence of search.
863 863
  */
864
-function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
865
-    if ( function_exists( 'mb_strrpos' ) ) {
866
-        return mb_strrpos( $str, $find, $offset, $encoding );
864
+function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
865
+    if (function_exists('mb_strrpos')) {
866
+        return mb_strrpos($str, $find, $offset, $encoding);
867 867
     }
868 868
         
869
-    return strrpos( $str, $find, $offset );
869
+    return strrpos($str, $find, $offset);
870 870
 }
871 871
 
872 872
 /**
@@ -881,16 +881,16 @@  discard block
 block discarded – undo
881 881
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
882 882
  * @return string
883 883
  */
884
-function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) {
885
-    if ( function_exists( 'mb_substr' ) ) {
886
-        if ( $length === null ) {
887
-            return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding );
884
+function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') {
885
+    if (function_exists('mb_substr')) {
886
+        if ($length === null) {
887
+            return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding);
888 888
         } else {
889
-            return mb_substr( $str, $start, $length, $encoding );
889
+            return mb_substr($str, $start, $length, $encoding);
890 890
         }
891 891
     }
892 892
         
893
-    return substr( $str, $start, $length );
893
+    return substr($str, $start, $length);
894 894
 }
895 895
 
896 896
 /**
@@ -902,48 +902,48 @@  discard block
 block discarded – undo
902 902
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
903 903
  * @return string The width of string.
904 904
  */
905
-function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) {
906
-    if ( function_exists( 'mb_strwidth' ) ) {
907
-        return mb_strwidth( $str, $encoding );
905
+function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') {
906
+    if (function_exists('mb_strwidth')) {
907
+        return mb_strwidth($str, $encoding);
908 908
     }
909 909
     
910
-    return wpinv_utf8_strlen( $str, $encoding );
910
+    return wpinv_utf8_strlen($str, $encoding);
911 911
 }
912 912
 
913
-function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) {
914
-    if ( function_exists( 'mb_strlen' ) ) {
915
-        $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding );
913
+function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') {
914
+    if (function_exists('mb_strlen')) {
915
+        $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding);
916 916
         $str_end = "";
917 917
         
918
-        if ( $lower_str_end ) {
919
-            $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding );
918
+        if ($lower_str_end) {
919
+            $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding);
920 920
         } else {
921
-            $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding );
921
+            $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding);
922 922
         }
923 923
 
924 924
         return $first_letter . $str_end;
925 925
     }
926 926
     
927
-    return ucfirst( $str );
927
+    return ucfirst($str);
928 928
 }
929 929
 
930
-function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) {
931
-    if ( function_exists( 'mb_convert_case' ) ) {
932
-        return mb_convert_case( $str, MB_CASE_TITLE, $encoding );
930
+function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') {
931
+    if (function_exists('mb_convert_case')) {
932
+        return mb_convert_case($str, MB_CASE_TITLE, $encoding);
933 933
     }
934 934
     
935
-    return ucwords( $str );
935
+    return ucwords($str);
936 936
 }
937 937
 
938
-function wpinv_period_in_days( $period, $unit ) {
939
-    $period = absint( $period );
938
+function wpinv_period_in_days($period, $unit) {
939
+    $period = absint($period);
940 940
     
941
-    if ( $period > 0 ) {
942
-        if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) {
941
+    if ($period > 0) {
942
+        if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) {
943 943
             $period = $period * 7;
944
-        } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) {
944
+        } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) {
945 945
             $period = $period * 30;
946
-        } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) {
946
+        } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) {
947 947
             $period = $period * 365;
948 948
         }
949 949
     }
@@ -951,12 +951,12 @@  discard block
 block discarded – undo
951 951
     return $period;
952 952
 }
953 953
 
954
-function wpinv_cal_days_in_month( $calendar, $month, $year ) {
955
-    if ( function_exists( 'cal_days_in_month' ) ) {
956
-        return cal_days_in_month( $calendar, $month, $year );
954
+function wpinv_cal_days_in_month($calendar, $month, $year) {
955
+    if (function_exists('cal_days_in_month')) {
956
+        return cal_days_in_month($calendar, $month, $year);
957 957
     }
958 958
 
959 959
     // Fallback in case the calendar extension is not loaded in PHP
960 960
     // Only supports Gregorian calendar
961
-    return date( 't', mktime( 0, 0, 0, $month, 1, $year ) );
961
+    return date('t', mktime(0, 0, 0, $month, 1, $year));
962 962
 }
Please login to merge, or discard this patch.
includes/wpinv-tax-functions.php 1 patch
Spacing   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -1,121 +1,121 @@  discard block
 block discarded – undo
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
 function wpinv_use_taxes() {
8
-    $ret = wpinv_get_option( 'enable_taxes', false );
8
+    $ret = wpinv_get_option('enable_taxes', false);
9 9
     
10
-    return (bool) apply_filters( 'wpinv_use_taxes', $ret );
10
+    return (bool)apply_filters('wpinv_use_taxes', $ret);
11 11
 }
12 12
 
13 13
 function wpinv_get_tax_rates() {
14
-    $rates = get_option( 'wpinv_tax_rates', array() );
14
+    $rates = get_option('wpinv_tax_rates', array());
15 15
     
16
-    return apply_filters( 'wpinv_get_tax_rates', $rates );
16
+    return apply_filters('wpinv_get_tax_rates', $rates);
17 17
 }
18 18
 
19
-function wpinv_get_tax_rate( $country = false, $state = false, $item_id = 0 ) {
19
+function wpinv_get_tax_rate($country = false, $state = false, $item_id = 0) {
20 20
     global $wpinv_euvat, $wpi_tax_rates, $wpi_userID;
21
-    $wpi_tax_rates = !empty( $wpi_tax_rates ) ? $wpi_tax_rates : array();
21
+    $wpi_tax_rates = !empty($wpi_tax_rates) ? $wpi_tax_rates : array();
22 22
     
23
-    if ( !empty( $wpi_tax_rates ) && !empty( $item_id ) && isset( $wpi_tax_rates[$item_id] ) ) {
23
+    if (!empty($wpi_tax_rates) && !empty($item_id) && isset($wpi_tax_rates[$item_id])) {
24 24
         return $wpi_tax_rates[$item_id];
25 25
     }
26 26
     
27
-    if ( !$wpinv_euvat->item_is_taxable( $item_id, $country, $state ) ) {
27
+    if (!$wpinv_euvat->item_is_taxable($item_id, $country, $state)) {
28 28
         $wpi_tax_rates[$item_id] = 0;
29 29
         return 0;
30 30
     }
31 31
     
32 32
     $is_global = false;
33
-    if ( $item_id == 'global' ) {
33
+    if ($item_id == 'global') {
34 34
         $is_global = true;
35 35
         $item_id = 0;
36 36
     }
37 37
     
38
-    $rate           = (float)wpinv_get_option( 'tax_rate', 0 );
39
-    $user_address   = wpinv_get_user_address( $wpi_userID );
38
+    $rate           = (float)wpinv_get_option('tax_rate', 0);
39
+    $user_address   = wpinv_get_user_address($wpi_userID);
40 40
     
41
-    if( empty( $country ) ) {
42
-        if( !empty( $_POST['wpinv_country'] ) ) {
41
+    if (empty($country)) {
42
+        if (!empty($_POST['wpinv_country'])) {
43 43
             $country = $_POST['wpinv_country'];
44
-        } elseif( !empty( $_POST['wpinv_country'] ) ) {
44
+        } elseif (!empty($_POST['wpinv_country'])) {
45 45
             $country = $_POST['wpinv_country'];
46
-        } elseif( !empty( $_POST['country'] ) ) {
46
+        } elseif (!empty($_POST['country'])) {
47 47
             $country = $_POST['country'];
48
-        } elseif( is_user_logged_in() && !empty( $user_address ) ) {
48
+        } elseif (is_user_logged_in() && !empty($user_address)) {
49 49
             $country = $user_address['country'];
50 50
         }
51
-        $country = !empty( $country ) ? $country : wpinv_get_default_country();
51
+        $country = !empty($country) ? $country : wpinv_get_default_country();
52 52
     }
53 53
 
54
-    if( empty( $state ) ) {
55
-        if( !empty( $_POST['wpinv_state'] ) ) {
54
+    if (empty($state)) {
55
+        if (!empty($_POST['wpinv_state'])) {
56 56
             $state = $_POST['wpinv_state'];
57
-        } elseif( !empty( $_POST['wpinv_state'] ) ) {
57
+        } elseif (!empty($_POST['wpinv_state'])) {
58 58
             $state = $_POST['wpinv_state'];
59
-        } elseif( !empty( $_POST['state'] ) ) {
59
+        } elseif (!empty($_POST['state'])) {
60 60
             $state = $_POST['state'];
61
-        } elseif( is_user_logged_in() && !empty( $user_address ) ) {
61
+        } elseif (is_user_logged_in() && !empty($user_address)) {
62 62
             $state = $user_address['state'];
63 63
         }
64
-        $state = !empty( $state ) ? $state : wpinv_get_default_state();
64
+        $state = !empty($state) ? $state : wpinv_get_default_state();
65 65
     }
66 66
     
67
-    if( !empty( $country ) ) {
68
-        $tax_rates   = wpinv_get_tax_rates();
67
+    if (!empty($country)) {
68
+        $tax_rates = wpinv_get_tax_rates();
69 69
 
70
-        if( !empty( $tax_rates ) ) {
70
+        if (!empty($tax_rates)) {
71 71
             // Locate the tax rate for this country / state, if it exists
72
-            foreach( $tax_rates as $key => $tax_rate ) {
73
-                if( $country != $tax_rate['country'] )
72
+            foreach ($tax_rates as $key => $tax_rate) {
73
+                if ($country != $tax_rate['country'])
74 74
                     continue;
75 75
 
76
-                if( !empty( $tax_rate['global'] ) ) {
77
-                    if( !empty( $tax_rate['rate'] ) ) {
78
-                        $rate = number_format( $tax_rate['rate'], 4 );
76
+                if (!empty($tax_rate['global'])) {
77
+                    if (!empty($tax_rate['rate'])) {
78
+                        $rate = number_format($tax_rate['rate'], 4);
79 79
                     }
80 80
                 } else {
81 81
 
82
-                    if( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) )
82
+                    if (empty($tax_rate['state']) || strtolower($state) != strtolower($tax_rate['state']))
83 83
                         continue;
84 84
 
85 85
                     $state_rate = $tax_rate['rate'];
86
-                    if( 0 !== $state_rate || !empty( $state_rate ) ) {
87
-                        $rate = number_format( $state_rate, 4 );
86
+                    if (0 !== $state_rate || !empty($state_rate)) {
87
+                        $rate = number_format($state_rate, 4);
88 88
                     }
89 89
                 }
90 90
             }
91 91
         }
92 92
     }
93 93
     
94
-    $rate = apply_filters( 'wpinv_tax_rate', $rate, $country, $state, $item_id );
94
+    $rate = apply_filters('wpinv_tax_rate', $rate, $country, $state, $item_id);
95 95
     
96
-    if ( !empty( $item_id ) ) {
96
+    if (!empty($item_id)) {
97 97
         $wpi_tax_rates[$item_id] = $rate;
98
-    } else if ( $is_global ) {
98
+    } else if ($is_global) {
99 99
         $wpi_tax_rates['global'] = $rate;
100 100
     }
101 101
     
102 102
     return $rate;
103 103
 }
104 104
 
105
-function wpinv_get_formatted_tax_rate( $country = false, $state = false, $item_id ) {
106
-    $rate = wpinv_get_tax_rate( $country, $state, $item_id );
107
-    $rate = round( $rate, 4 );
105
+function wpinv_get_formatted_tax_rate($country = false, $state = false, $item_id) {
106
+    $rate = wpinv_get_tax_rate($country, $state, $item_id);
107
+    $rate = round($rate, 4);
108 108
     $formatted = $rate .= '%';
109
-    return apply_filters( 'wpinv_formatted_tax_rate', $formatted, $rate, $country, $state, $item_id );
109
+    return apply_filters('wpinv_formatted_tax_rate', $formatted, $rate, $country, $state, $item_id);
110 110
 }
111 111
 
112
-function wpinv_calculate_tax( $amount = 0, $country = false, $state = false, $item_id = 0 ) {
113
-    $rate = wpinv_get_tax_rate( $country, $state, $item_id );
112
+function wpinv_calculate_tax($amount = 0, $country = false, $state = false, $item_id = 0) {
113
+    $rate = wpinv_get_tax_rate($country, $state, $item_id);
114 114
     $tax  = 0.00;
115 115
 
116
-    if ( wpinv_use_taxes() ) {        
117
-        if ( wpinv_prices_include_tax() ) {
118
-            $pre_tax = ( $amount / ( ( 1 + $rate ) * 0.01 ) );
116
+    if (wpinv_use_taxes()) {        
117
+        if (wpinv_prices_include_tax()) {
118
+            $pre_tax = ($amount / ((1 + $rate) * 0.01));
119 119
             $tax     = $amount - $pre_tax;
120 120
         } else {
121 121
             $tax = $amount * $rate * 0.01;
@@ -123,46 +123,46 @@  discard block
 block discarded – undo
123 123
 
124 124
     }
125 125
 
126
-    return apply_filters( 'wpinv_taxed_amount', $tax, $rate, $country, $state, $item_id );
126
+    return apply_filters('wpinv_taxed_amount', $tax, $rate, $country, $state, $item_id);
127 127
 }
128 128
 
129 129
 function wpinv_prices_include_tax() {
130 130
     return false; // TODO
131
-    $ret = ( wpinv_get_option( 'prices_include_tax', false ) == 'yes' && wpinv_use_taxes() );
131
+    $ret = (wpinv_get_option('prices_include_tax', false) == 'yes' && wpinv_use_taxes());
132 132
 
133
-    return apply_filters( 'wpinv_prices_include_tax', $ret );
133
+    return apply_filters('wpinv_prices_include_tax', $ret);
134 134
 }
135 135
 
136
-function wpinv_sales_tax_for_year( $year = null ) {
137
-    return wpinv_price( wpinv_format_amount( wpinv_get_sales_tax_for_year( $year ) ) );
136
+function wpinv_sales_tax_for_year($year = null) {
137
+    return wpinv_price(wpinv_format_amount(wpinv_get_sales_tax_for_year($year)));
138 138
 }
139 139
 
140
-function wpinv_get_sales_tax_for_year( $year = null ) {
140
+function wpinv_get_sales_tax_for_year($year = null) {
141 141
     global $wpdb;
142 142
 
143 143
     // Start at zero
144 144
     $tax = 0;
145 145
 
146
-    if ( ! empty( $year ) ) {
146
+    if (!empty($year)) {
147 147
         $args = array(
148 148
             'post_type'      => 'wpi_invoice',
149
-            'post_status'    => array( 'publish' ),
149
+            'post_status'    => array('publish'),
150 150
             'posts_per_page' => -1,
151 151
             'year'           => $year,
152 152
             'fields'         => 'ids'
153 153
         );
154 154
 
155
-        $payments    = get_posts( $args );
156
-        $payment_ids = implode( ',', $payments );
155
+        $payments    = get_posts($args);
156
+        $payment_ids = implode(',', $payments);
157 157
 
158
-        if ( count( $payments ) > 0 ) {
158
+        if (count($payments) > 0) {
159 159
             $sql = "SELECT SUM( meta_value ) FROM $wpdb->postmeta WHERE meta_key = '_wpinv_tax' AND post_id IN( $payment_ids )";
160
-            $tax = $wpdb->get_var( $sql );
160
+            $tax = $wpdb->get_var($sql);
161 161
         }
162 162
 
163 163
     }
164 164
 
165
-    return apply_filters( 'wpinv_get_sales_tax_for_year', $tax, $year );
165
+    return apply_filters('wpinv_get_sales_tax_for_year', $tax, $year);
166 166
 }
167 167
 
168 168
 function wpinv_is_cart_taxed() {
@@ -171,33 +171,33 @@  discard block
 block discarded – undo
171 171
 
172 172
 function wpinv_prices_show_tax_on_checkout() {
173 173
     return false; // TODO
174
-    $ret = ( wpinv_get_option( 'checkout_include_tax', false ) == 'yes' && wpinv_use_taxes() );
174
+    $ret = (wpinv_get_option('checkout_include_tax', false) == 'yes' && wpinv_use_taxes());
175 175
 
176
-    return apply_filters( 'wpinv_taxes_on_prices_on_checkout', $ret );
176
+    return apply_filters('wpinv_taxes_on_prices_on_checkout', $ret);
177 177
 }
178 178
 
179 179
 function wpinv_display_tax_rate() {
180
-    $ret = wpinv_use_taxes() && wpinv_get_option( 'display_tax_rate', false );
180
+    $ret = wpinv_use_taxes() && wpinv_get_option('display_tax_rate', false);
181 181
 
182
-    return apply_filters( 'wpinv_display_tax_rate', $ret );
182
+    return apply_filters('wpinv_display_tax_rate', $ret);
183 183
 }
184 184
 
185 185
 function wpinv_cart_needs_tax_address_fields() {
186
-    if( !wpinv_is_cart_taxed() )
186
+    if (!wpinv_is_cart_taxed())
187 187
         return false;
188 188
 
189
-    return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' );
189
+    return !did_action('wpinv_after_cc_fields', 'wpinv_default_cc_address_fields');
190 190
 }
191 191
 
192
-function wpinv_item_is_tax_exclusive( $item_id = 0 ) {
193
-    $ret = (bool)get_post_meta( $item_id, '_wpinv_tax_exclusive', false );
194
-    return apply_filters( 'wpinv_is_tax_exclusive', $ret, $item_id );
192
+function wpinv_item_is_tax_exclusive($item_id = 0) {
193
+    $ret = (bool)get_post_meta($item_id, '_wpinv_tax_exclusive', false);
194
+    return apply_filters('wpinv_is_tax_exclusive', $ret, $item_id);
195 195
 }
196 196
 
197
-function wpinv_currency_decimal_filter( $decimals = 2 ) {
197
+function wpinv_currency_decimal_filter($decimals = 2) {
198 198
     $currency = wpinv_get_currency();
199 199
 
200
-    switch ( $currency ) {
200
+    switch ($currency) {
201 201
         case 'RIAL' :
202 202
         case 'JPY' :
203 203
         case 'TWD' :
@@ -206,48 +206,48 @@  discard block
 block discarded – undo
206 206
             break;
207 207
     }
208 208
 
209
-    return apply_filters( 'wpinv_currency_decimal_count', $decimals, $currency );
209
+    return apply_filters('wpinv_currency_decimal_count', $decimals, $currency);
210 210
 }
211 211
 
212 212
 function wpinv_tax_amount() {
213 213
     $output = 0.00;
214 214
     
215
-    return apply_filters( 'wpinv_tax_amount', $output );
215
+    return apply_filters('wpinv_tax_amount', $output);
216 216
 }
217 217
 
218 218
 function wpinv_recalculated_tax() {
219
-    define( 'WPINV_RECALCTAX', true );
219
+    define('WPINV_RECALCTAX', true);
220 220
 }
221
-add_action( 'wp_ajax_wpinv_recalculate_tax', 'wpinv_recalculated_tax', 1 );
221
+add_action('wp_ajax_wpinv_recalculate_tax', 'wpinv_recalculated_tax', 1);
222 222
 
223
-function wpinv_recalculate_tax( $return = false ) {
223
+function wpinv_recalculate_tax($return = false) {
224 224
     $invoice_id = (int)wpinv_get_invoice_cart_id();
225
-    if ( empty( $invoice_id ) ) {
225
+    if (empty($invoice_id)) {
226 226
         return false;
227 227
     }
228 228
     
229
-    $invoice = wpinv_get_invoice_cart( $invoice_id );
229
+    $invoice = wpinv_get_invoice_cart($invoice_id);
230 230
 
231
-    if ( empty( $invoice ) ) {
231
+    if (empty($invoice)) {
232 232
         return false;
233 233
     }
234 234
 
235
-    if ( empty( $_POST['country'] ) ) {
235
+    if (empty($_POST['country'])) {
236 236
         $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
237 237
     }
238 238
         
239 239
     $invoice->country = sanitize_text_field($_POST['country']);
240
-    $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
240
+    $invoice->set('country', sanitize_text_field($_POST['country']));
241 241
     if (isset($_POST['state'])) {
242 242
         $invoice->state = sanitize_text_field($_POST['state']);
243
-        $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
243
+        $invoice->set('state', sanitize_text_field($_POST['state']));
244 244
     }
245 245
 
246 246
     $invoice->cart_details  = wpinv_get_cart_content_details();
247 247
     
248
-    $subtotal               = wpinv_get_cart_subtotal( $invoice->cart_details );
249
-    $tax                    = wpinv_get_cart_tax( $invoice->cart_details );
250
-    $total                  = wpinv_get_cart_total( $invoice->cart_details );
248
+    $subtotal               = wpinv_get_cart_subtotal($invoice->cart_details);
249
+    $tax                    = wpinv_get_cart_tax($invoice->cart_details);
250
+    $total                  = wpinv_get_cart_total($invoice->cart_details);
251 251
 
252 252
     $invoice->tax           = $tax;
253 253
     $invoice->subtotal      = $subtotal;
@@ -255,61 +255,61 @@  discard block
 block discarded – undo
255 255
 
256 256
     $invoice->save();
257 257
     
258
-    if ( $invoice->is_free_trial() ) {
258
+    if ($invoice->is_free_trial()) {
259 259
         $total = 0;
260 260
     }
261 261
     
262 262
     $response = array(
263
-        'total'        => html_entity_decode( wpinv_price( wpinv_format_amount( $total ) ), ENT_COMPAT, 'UTF-8' ),
263
+        'total'        => html_entity_decode(wpinv_price(wpinv_format_amount($total)), ENT_COMPAT, 'UTF-8'),
264 264
         'total_raw'    => $total,
265
-        'free'         => !( (float)$total > 0 ) && $invoice->is_free() ? true : false,
266
-        'html'         => wpinv_checkout_cart( $invoice->cart_details, false ),
265
+        'free'         => !((float)$total > 0) && $invoice->is_free() ? true : false,
266
+        'html'         => wpinv_checkout_cart($invoice->cart_details, false),
267 267
     );
268 268
     
269
-    if ( $return ) {
269
+    if ($return) {
270 270
         return $response;
271 271
     }
272 272
 
273
-    wp_send_json( $response );
273
+    wp_send_json($response);
274 274
 }
275
-add_action( 'wp_ajax_wpinv_recalculate_tax', 'wpinv_recalculate_tax' );
276
-add_action( 'wp_ajax_nopriv_wpinv_recalculate_tax', 'wpinv_recalculate_tax' );
275
+add_action('wp_ajax_wpinv_recalculate_tax', 'wpinv_recalculate_tax');
276
+add_action('wp_ajax_nopriv_wpinv_recalculate_tax', 'wpinv_recalculate_tax');
277 277
 
278 278
 // VAT Settings
279
-function wpinv_vat_rate_add_callback( $args ) {
279
+function wpinv_vat_rate_add_callback($args) {
280 280
     ?>
281
-    <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" />&nbsp;&nbsp;<i style="display:none;" class="fa fa-refresh fa-spin"></i></p>
281
+    <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" />&nbsp;&nbsp;<i style="display:none;" class="fa fa-refresh fa-spin"></i></p>
282 282
     <?php
283 283
 }
284 284
 
285
-function wpinv_vat_rate_delete_callback( $args ) {
285
+function wpinv_vat_rate_delete_callback($args) {
286 286
     global $wpinv_euvat;
287 287
     
288 288
     $vat_classes = $wpinv_euvat->get_rate_classes();
289
-    $vat_class = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : '';
290
-    if ( isset( $vat_classes[$vat_class] ) ) {
289
+    $vat_class = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : '';
290
+    if (isset($vat_classes[$vat_class])) {
291 291
     ?>
292
-    <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" />&nbsp;&nbsp;<i style="display:none;" class="fa fa-refresh fa-spin"></i></p>
292
+    <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" />&nbsp;&nbsp;<i style="display:none;" class="fa fa-refresh fa-spin"></i></p>
293 293
     <?php
294 294
     }
295 295
 }
296 296
 
297
-function wpinv_vat_rates_callback( $args ) {
297
+function wpinv_vat_rates_callback($args) {
298 298
     global $wpinv_euvat;
299 299
     
300 300
     $vat_classes    = $wpinv_euvat->get_rate_classes();
301
-    $vat_class      = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : '_standard';
301
+    $vat_class      = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : '_standard';
302 302
     
303 303
     $eu_states      = $wpinv_euvat->get_eu_states();
304 304
     $countries      = wpinv_get_country_list();
305 305
     $vat_groups     = $wpinv_euvat->get_vat_groups();
306
-    $rates          = $wpinv_euvat->get_vat_rates( $vat_class );
306
+    $rates          = $wpinv_euvat->get_vat_rates($vat_class);
307 307
     ob_start();
308 308
 ?>
309 309
 </td><tr>
310 310
     <td colspan="2" class="wpinv_vat_tdbox">
311
-    <input type="hidden" name="wpi_vat_class" value="<?php echo $vat_class;?>" />
312
-    <p><?php echo ( isset( $args['desc'] ) ? $args['desc'] : '' ); ?></p>
311
+    <input type="hidden" name="wpi_vat_class" value="<?php echo $vat_class; ?>" />
312
+    <p><?php echo (isset($args['desc']) ? $args['desc'] : ''); ?></p>
313 313
     <table id="wpinv_vat_rates" class="wp-list-table widefat fixed posts">
314 314
         <colgroup>
315 315
             <col width="50px" />
@@ -321,43 +321,43 @@  discard block
 block discarded – undo
321 321
         </colgroup>
322 322
         <thead>
323 323
             <tr>
324
-                <th scope="col" colspan="2" class="wpinv_vat_country_name"><?php _e( 'Country', 'invoicing' ); ?></th>
325
-                <th scope="col" class="wpinv_vat_global" title="<?php esc_attr_e( 'Apply rate to whole country', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th>
326
-                <th scope="col" class="wpinv_vat_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> 
327
-                <th scope="col" class="wpinv_vat_name"><?php _e( 'VAT Name', 'invoicing' ); ?></th>
328
-                <th scope="col" class="wpinv_vat_group"><?php _e( 'Tax Group', 'invoicing' ); ?></th>
324
+                <th scope="col" colspan="2" class="wpinv_vat_country_name"><?php _e('Country', 'invoicing'); ?></th>
325
+                <th scope="col" class="wpinv_vat_global" title="<?php esc_attr_e('Apply rate to whole country', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th>
326
+                <th scope="col" class="wpinv_vat_rate"><?php _e('Rate %', 'invoicing'); ?></th> 
327
+                <th scope="col" class="wpinv_vat_name"><?php _e('VAT Name', 'invoicing'); ?></th>
328
+                <th scope="col" class="wpinv_vat_group"><?php _e('Tax Group', 'invoicing'); ?></th>
329 329
             </tr>
330 330
         </thead>
331 331
         <tbody>
332
-        <?php if( !empty( $eu_states ) ) { ?>
332
+        <?php if (!empty($eu_states)) { ?>
333 333
         <?php 
334
-        foreach ( $eu_states as $state ) { 
335
-            $country_name = isset( $countries[$state] ) ? $countries[$state] : '';
334
+        foreach ($eu_states as $state) { 
335
+            $country_name = isset($countries[$state]) ? $countries[$state] : '';
336 336
             
337 337
             // Filter the rate for each country
338
-            $country_rate = array_filter( $rates, function( $rate ) use( $state ) { return $rate['country'] === $state; } );
338
+            $country_rate = array_filter($rates, function($rate) use($state) { return $rate['country'] === $state; } );
339 339
             
340 340
             // If one does not exist create a default
341
-            $country_rate = is_array( $country_rate ) && count( $country_rate ) > 0 ? reset( $country_rate ) : array();
341
+            $country_rate = is_array($country_rate) && count($country_rate) > 0 ? reset($country_rate) : array();
342 342
             
343
-            $vat_global = isset( $country_rate['global'] ) ? !empty( $country_rate['global'] ) : true;
344
-            $vat_rate = isset( $country_rate['rate'] ) ? $country_rate['rate'] : '';
345
-            $vat_name = !empty( $country_rate['name'] ) ? esc_attr( stripslashes( $country_rate['name'] ) ) : '';
346
-            $vat_group = !empty( $country_rate['group'] ) ? $country_rate['group'] : ( $vat_class === '_standard' ? 'standard' : 'reduced' );
343
+            $vat_global = isset($country_rate['global']) ? !empty($country_rate['global']) : true;
344
+            $vat_rate = isset($country_rate['rate']) ? $country_rate['rate'] : '';
345
+            $vat_name = !empty($country_rate['name']) ? esc_attr(stripslashes($country_rate['name'])) : '';
346
+            $vat_group = !empty($country_rate['group']) ? $country_rate['group'] : ($vat_class === '_standard' ? 'standard' : 'reduced');
347 347
         ?>
348 348
         <tr>
349 349
             <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>
350 350
             <td class="wpinv_vat_country_name"><?php echo $country_name; ?></td>
351 351
             <td class="wpinv_vat_global">
352
-                <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" />
353
-                <label for="tax_rates[<?php echo $state;?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
354
-                <input type="hidden" name="vat_rates[<?php echo $state;?>][global]" value="1" checked="checked" />
352
+                <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" />
353
+                <label for="tax_rates[<?php echo $state; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
354
+                <input type="hidden" name="vat_rates[<?php echo $state; ?>][global]" value="1" checked="checked" />
355 355
             </td>
356
-            <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>
357
-            <td class="wpinv_vat_name"><input type="text" class="regular-text" name="vat_rates[<?php echo $state;?>][name]" value="<?php echo $vat_name; ?>" /></td>
356
+            <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>
357
+            <td class="wpinv_vat_name"><input type="text" class="regular-text" name="vat_rates[<?php echo $state; ?>][name]" value="<?php echo $vat_name; ?>" /></td>
358 358
             <td class="wpinv_vat_group">
359 359
             <?php
360
-            echo wpinv_html_select( array(
360
+            echo wpinv_html_select(array(
361 361
                                         'name'             => 'vat_rates[' . $state . '][group]',
362 362
                                         'selected'         => $vat_group,
363 363
                                         'id'               => 'vat_rates[' . $state . '][group]',
@@ -366,14 +366,14 @@  discard block
 block discarded – undo
366 366
                                         'multiple'         => false,
367 367
                                         'show_option_all'  => false,
368 368
                                         'show_option_none' => false
369
-                                    ) );
369
+                                    ));
370 370
             ?>
371 371
             </td>
372 372
         </tr>
373 373
         <?php } ?>
374 374
         <tr>
375 375
             <td colspan="6" style="background-color:#fafafa;">
376
-                <span><input id="wpi_vat_get_rates_group" type="button" class="button-secondary" value="<?php esc_attr_e( 'Update EU VAT Rates', 'invoicing' ); ?>" />&nbsp;&nbsp;<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>
376
+                <span><input id="wpi_vat_get_rates_group" type="button" class="button-secondary" value="<?php esc_attr_e('Update EU VAT Rates', 'invoicing'); ?>" />&nbsp;&nbsp;<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>
377 377
             </td>
378 378
         </tr>
379 379
         <?php } ?>
@@ -385,35 +385,35 @@  discard block
 block discarded – undo
385 385
     echo $content;
386 386
 }
387 387
 
388
-function wpinv_vat_number_callback( $args ) {
388
+function wpinv_vat_number_callback($args) {
389 389
     global $wpinv_euvat;
390 390
     
391 391
     $vat_number     = $wpinv_euvat->get_vat_number();
392 392
     $vat_valid      = $wpinv_euvat->is_vat_validated();
393 393
 
394
-    $size           = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular';
395
-    $validated_text = $vat_valid ? __( 'VAT number validated', 'invoicing' ) : __( 'VAT number not validated', 'invoicing' );
394
+    $size           = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
395
+    $validated_text = $vat_valid ? __('VAT number validated', 'invoicing') : __('VAT number not validated', 'invoicing');
396 396
     $disabled       = $vat_valid ? 'disabled="disabled"' : " ";
397 397
     
398
-    $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 ) ) . '"/>';
399
-    $html .= '<span>&nbsp;<input type="button" id="wpinv_vat_validate" class="wpinv_validate_vat_button button-secondary" ' . $disabled . ' value="' . esc_attr__( 'Validate VAT Number', 'invoicing' ) . '" /></span>';
398
+    $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)) . '"/>';
399
+    $html .= '<span>&nbsp;<input type="button" id="wpinv_vat_validate" class="wpinv_validate_vat_button button-secondary" ' . $disabled . ' value="' . esc_attr__('Validate VAT Number', 'invoicing') . '" /></span>';
400 400
     $html .= '<span class="wpinv-vat-stat wpinv-vat-stat-' . (int)$vat_valid . '"><i class="fa"></i> <font>' . $validated_text . '</font></span>';
401
-    $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>';
402
-    $html .= '<input type="hidden" name="_wpi_nonce" value="' . wp_create_nonce( 'vat_validation' ) . '">';
401
+    $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>';
402
+    $html .= '<input type="hidden" name="_wpi_nonce" value="' . wp_create_nonce('vat_validation') . '">';
403 403
 
404 404
     echo $html;
405 405
 }
406 406
 
407
-function wpinv_eu_fallback_rate_callback( $args ) {
407
+function wpinv_eu_fallback_rate_callback($args) {
408 408
     global $wpinv_options;
409 409
 
410
-    $value = isset( $wpinv_options[$args['id']] ) ? $wpinv_options[ $args['id'] ] : ( isset( $args['std'] ) ? $args['std'] : '' );
411
-    $size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'small';
410
+    $value = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : (isset($args['std']) ? $args['std'] : '');
411
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'small';
412 412
     
413
-    $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 ) ) . '" />';
414
-    $html .= '<span>&nbsp;<input id="wpi_add_eu_states" type="button" class="button-secondary" value="' . esc_attr__( 'Add EU Member States', 'invoicing' ) . '" /></span>';
415
-    $html .= '<span>&nbsp;<input id="wpi_remove_eu_states" type="button" class="button-secondary" value="' . esc_attr__( 'Remove EU Member States', 'invoicing' ) . '" /></span>';
416
-    $html .= '<span>&nbsp;<input id="wpi_vat_get_rates" type="button" class="button-secondary" value="' . esc_attr__( 'Update EU VAT Rates', 'invoicing' ) . '" />&nbsp;&nbsp;<i style="display:none" class="fa fa-refresh fa-spin"></i></span>';
413
+    $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)) . '" />';
414
+    $html .= '<span>&nbsp;<input id="wpi_add_eu_states" type="button" class="button-secondary" value="' . esc_attr__('Add EU Member States', 'invoicing') . '" /></span>';
415
+    $html .= '<span>&nbsp;<input id="wpi_remove_eu_states" type="button" class="button-secondary" value="' . esc_attr__('Remove EU Member States', 'invoicing') . '" /></span>';
416
+    $html .= '<span>&nbsp;<input id="wpi_vat_get_rates" type="button" class="button-secondary" value="' . esc_attr__('Update EU VAT Rates', 'invoicing') . '" />&nbsp;&nbsp;<i style="display:none" class="fa fa-refresh fa-spin"></i></span>';
417 417
     $html .= '<p><label for="wpinv_settings_' . $args['section'] . '_' . $args['id'] . '">' . $args['desc'] . '</label></p>';
418 418
     echo $html;
419 419
     ?>
@@ -421,36 +421,36 @@  discard block
 block discarded – undo
421 421
     <?php
422 422
 }
423 423
 
424
-function wpinv_vat_ip_lookup_callback( $args ) {
424
+function wpinv_vat_ip_lookup_callback($args) {
425 425
     global $wpinv_options, $wpinv_euvat;
426 426
 
427
-    $value =  isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ]  : ( isset( $args['std'] ) ? $args['std'] : 'default' );
427
+    $value = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : (isset($args['std']) ? $args['std'] : 'default');
428 428
     
429 429
     $options = array();
430
-    if ( function_exists( 'geoip_country_code_by_name' ) ) {
431
-        $options['geoip'] = __( 'PHP GeoIP extension', 'invoicing' );
430
+    if (function_exists('geoip_country_code_by_name')) {
431
+        $options['geoip'] = __('PHP GeoIP extension', 'invoicing');
432 432
     }
433 433
     
434 434
     $geoip2_database = $wpinv_euvat->geoip2_country_dbfile();
435 435
     
436
-    if ( !function_exists( 'bcadd' ) ) {
437
-        $geoip2_message = __( 'GeoIP2 service requires the BC Math PHP extension, it is not loaded in your version of PHP!', 'invoicing' );
436
+    if (!function_exists('bcadd')) {
437
+        $geoip2_message = __('GeoIP2 service requires the BC Math PHP extension, it is not loaded in your version of PHP!', 'invoicing');
438 438
     } else {
439
-        $geoip2_message = ini_get('safe_mode') ? __( 'GeoIP2 is not supported with PHP safe mode enabled!', 'invoicing' ) : '';
439
+        $geoip2_message = ini_get('safe_mode') ? __('GeoIP2 is not supported with PHP safe mode enabled!', 'invoicing') : '';
440 440
     }
441 441
     
442
-    if ( $geoip2_database !== false && empty( $geoip2_message ) ) {
443
-        $options['geoip2'] = __( 'GeoIP2 Database', 'invoicing' );
442
+    if ($geoip2_database !== false && empty($geoip2_message)) {
443
+        $options['geoip2'] = __('GeoIP2 Database', 'invoicing');
444 444
     }
445 445
     
446
-    if ( function_exists( 'simplexml_load_file' ) ) {
447
-        $options['geoplugin'] = __( 'geoPlugin Web Service', 'invoicing' );
446
+    if (function_exists('simplexml_load_file')) {
447
+        $options['geoplugin'] = __('geoPlugin Web Service', 'invoicing');
448 448
     }
449 449
     
450
-    $options['site']    = __( 'Use default country', 'invoicing' );
451
-    $options['default'] = __( 'Auto', 'invoicing' );
450
+    $options['site']    = __('Use default country', 'invoicing');
451
+    $options['default'] = __('Auto', 'invoicing');
452 452
 
453
-    $html = wpinv_html_select( array(
453
+    $html = wpinv_html_select(array(
454 454
         'name'             => "wpinv_settings[{$args['id']}]",
455 455
         'selected'         => $value,
456 456
         'id'               => "wpinv_settings[{$args['id']}]",
@@ -462,23 +462,23 @@  discard block
 block discarded – undo
462 462
     ));
463 463
     
464 464
     $desc = '<label for="wpinv_settings[' . $args['id'] . ']">';
465
-    $desc .= __( 'Select the option Invoicing should use to determine the country from the IP address of the user.', 'invoicing' );
465
+    $desc .= __('Select the option Invoicing should use to determine the country from the IP address of the user.', 'invoicing');
466 466
     $desc .= '<p>';
467
-    if ( empty( $geoip2_message ) ) {
468
-        if ( $geoip2_database ) {
467
+    if (empty($geoip2_message)) {
468
+        if ($geoip2_database) {
469 469
             $last_updated = '';
470
-            if ( $time_updated = wpinv_get_option( 'wpinv_geoip2_date_updated' ) ) {
471
-                $date_updated = date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $time_updated );
472
-                $last_updated = '<br>' . sprintf( __( 'The GeoIP2 database was last updated on: <b>%s</b>', 'invoicing' ), $date_updated );
470
+            if ($time_updated = wpinv_get_option('wpinv_geoip2_date_updated')) {
471
+                $date_updated = date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $time_updated);
472
+                $last_updated = '<br>' . sprintf(__('The GeoIP2 database was last updated on: <b>%s</b>', 'invoicing'), $date_updated);
473 473
             }
474
-            $desc .= __(  'GeoIP2 database exists:', 'invoicing' ) . $last_updated . '&nbsp;<input type="button" id="wpi_geoip2" action="update" class="wpinv-refresh-geoip2-btn button-secondary" value="' . __( 'Update GeoIP2 database now (~55MB)', 'invoicing' ) . '"></input>';
474
+            $desc .= __('GeoIP2 database exists:', 'invoicing') . $last_updated . '&nbsp;<input type="button" id="wpi_geoip2" action="update" class="wpinv-refresh-geoip2-btn button-secondary" value="' . __('Update GeoIP2 database now (~55MB)', 'invoicing') . '"></input>';
475 475
         } else {
476
-            $desc .= __( 'GeoIP2 database does not exist:', 'invoicing' ) . '&nbsp;<input type="button" id="wpi_geoip2" action="download" class="wpinv-download-geoip2-btn button-secondary" value="' . __( 'Download GeoIP2 database now', 'invoicing' ) . ' (~53MB)"></input><br>' . __(  'After downloading the GeoIP2 database the GeoIP2 lookup option will show.', 'invoicing' );
476
+            $desc .= __('GeoIP2 database does not exist:', 'invoicing') . '&nbsp;<input type="button" id="wpi_geoip2" action="download" class="wpinv-download-geoip2-btn button-secondary" value="' . __('Download GeoIP2 database now', 'invoicing') . ' (~53MB)"></input><br>' . __('After downloading the GeoIP2 database the GeoIP2 lookup option will show.', 'invoicing');
477 477
         }
478 478
     } else {
479 479
         $desc .= $geoip2_message;
480 480
     }
481
-    $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>';
481
+    $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>';
482 482
     $desc .= '</label>';
483 483
     
484 484
     $html .= $desc;
Please login to merge, or discard this patch.
includes/wpinv-post-types.php 1 patch
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -7,44 +7,44 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14
-add_action( 'init', 'wpinv_register_post_types', 1 );
14
+add_action('init', 'wpinv_register_post_types', 1);
15 15
 function wpinv_register_post_types() {    
16 16
     $labels = array(
17
-        'name'               => _x( 'Invoices', 'post type general name', 'invoicing' ),
18
-        'singular_name'      => _x( 'Invoice', 'post type singular name', 'invoicing' ),
19
-        'menu_name'          => _x( 'Invoices', 'admin menu', 'invoicing' ),
20
-        'name_admin_bar'     => _x( 'Invoice', 'add new on admin bar', 'invoicing' ),
21
-        'add_new'            => _x( 'Add New', 'book', 'invoicing' ),
22
-        'add_new_item'       => __( 'Add New Invoice', 'invoicing' ),
23
-        'new_item'           => __( 'New Invoice', 'invoicing' ),
24
-        'edit_item'          => __( 'Edit Invoice', 'invoicing' ),
25
-        'view_item'          => __( 'View Invoice', 'invoicing' ),
26
-        'all_items'          => __( 'Invoices', 'invoicing' ),
27
-        'search_items'       => __( 'Search Invoices', 'invoicing' ),
28
-        'parent_item_colon'  => __( 'Parent Invoices:', 'invoicing' ),
29
-        'not_found'          => __( 'No invoices found.', 'invoicing' ),
30
-        'not_found_in_trash' => __( 'No invoices found in trash.', 'invoicing' )
17
+        'name'               => _x('Invoices', 'post type general name', 'invoicing'),
18
+        'singular_name'      => _x('Invoice', 'post type singular name', 'invoicing'),
19
+        'menu_name'          => _x('Invoices', 'admin menu', 'invoicing'),
20
+        'name_admin_bar'     => _x('Invoice', 'add new on admin bar', 'invoicing'),
21
+        'add_new'            => _x('Add New', 'book', 'invoicing'),
22
+        'add_new_item'       => __('Add New Invoice', 'invoicing'),
23
+        'new_item'           => __('New Invoice', 'invoicing'),
24
+        'edit_item'          => __('Edit Invoice', 'invoicing'),
25
+        'view_item'          => __('View Invoice', 'invoicing'),
26
+        'all_items'          => __('Invoices', 'invoicing'),
27
+        'search_items'       => __('Search Invoices', 'invoicing'),
28
+        'parent_item_colon'  => __('Parent Invoices:', 'invoicing'),
29
+        'not_found'          => __('No invoices found.', 'invoicing'),
30
+        'not_found_in_trash' => __('No invoices found in trash.', 'invoicing')
31 31
     );
32
-    $labels = apply_filters( 'wpinv_labels', $labels );
32
+    $labels = apply_filters('wpinv_labels', $labels);
33 33
     
34 34
     $menu_icon = WPINV_PLUGIN_URL . '/assets/images/favicon.ico';
35
-    $menu_icon = apply_filters( 'wpinv_menu_icon_invoice', $menu_icon );
35
+    $menu_icon = apply_filters('wpinv_menu_icon_invoice', $menu_icon);
36 36
 
37 37
     $cap_type = 'wpi_invoice';
38 38
     $args = array(
39 39
         'labels'             => $labels,
40
-        'description'        => __( 'This is where invoices are stored.', 'invoicing' ),
40
+        'description'        => __('This is where invoices are stored.', 'invoicing'),
41 41
         'public'             => true,
42 42
         'can_export'         => true,
43 43
         '_builtin'           => false,
44 44
         'publicly_queryable' => true,
45 45
         'exclude_from_search'=> true,
46 46
         'show_ui'            => true,
47
-        'show_in_menu'       => current_user_can( 'manage_invoicing' ) ? 'wpinv' : true,
47
+        'show_in_menu'       => current_user_can('manage_invoicing') ? 'wpinv' : true,
48 48
         'show_in_nav_menus'  => false,
49 49
         'query_var'          => false,
50 50
         'rewrite'            => true,
@@ -69,39 +69,39 @@  discard block
 block discarded – undo
69 69
         'has_archive'        => false,
70 70
         'hierarchical'       => false,
71 71
         'menu_position'      => null,
72
-        'supports'           => array( 'title', 'author' ),
72
+        'supports'           => array('title', 'author'),
73 73
         'menu_icon'          => 'dashicons-media-spreadsheet',
74 74
     );
75 75
             
76
-    $args = apply_filters( 'wpinv_register_post_type_invoice', $args );
76
+    $args = apply_filters('wpinv_register_post_type_invoice', $args);
77 77
     
78
-    register_post_type( 'wpi_invoice', $args );
78
+    register_post_type('wpi_invoice', $args);
79 79
     
80 80
     $items_labels = array(
81
-        'name'               => _x( 'Items', 'post type general name', 'invoicing' ),
82
-        'singular_name'      => _x( 'Item', 'post type singular name', 'invoicing' ),
83
-        'menu_name'          => _x( 'Items', 'admin menu', 'invoicing' ),
84
-        'add_new'            => _x( 'Add New', 'wpi_item', 'invoicing' ),
85
-        'add_new_item'       => __( 'Add New Item', 'invoicing' ),
86
-        'new_item'           => __( 'New Item', 'invoicing' ),
87
-        'edit_item'          => __( 'Edit Item', 'invoicing' ),
88
-        'view_item'          => __( 'View Item', 'invoicing' ),
89
-        'all_items'          => __( 'Items', 'invoicing' ),
90
-        'search_items'       => __( 'Search Items', 'invoicing' ),
81
+        'name'               => _x('Items', 'post type general name', 'invoicing'),
82
+        'singular_name'      => _x('Item', 'post type singular name', 'invoicing'),
83
+        'menu_name'          => _x('Items', 'admin menu', 'invoicing'),
84
+        'add_new'            => _x('Add New', 'wpi_item', 'invoicing'),
85
+        'add_new_item'       => __('Add New Item', 'invoicing'),
86
+        'new_item'           => __('New Item', 'invoicing'),
87
+        'edit_item'          => __('Edit Item', 'invoicing'),
88
+        'view_item'          => __('View Item', 'invoicing'),
89
+        'all_items'          => __('Items', 'invoicing'),
90
+        'search_items'       => __('Search Items', 'invoicing'),
91 91
         'parent_item_colon'  => '',
92
-        'not_found'          => __( 'No items found.', 'invoicing' ),
93
-        'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' )
92
+        'not_found'          => __('No items found.', 'invoicing'),
93
+        'not_found_in_trash' => __('No items found in trash.', 'invoicing')
94 94
     );
95
-    $items_labels = apply_filters( 'wpinv_items_labels', $items_labels );
95
+    $items_labels = apply_filters('wpinv_items_labels', $items_labels);
96 96
 
97 97
     $cap_type = 'wpi_item';
98 98
     $invoice_item_args = array(
99 99
         'labels'                => $items_labels,
100 100
         'public'                => false,
101 101
         'show_ui'               => true,
102
-        'show_in_menu'          => current_user_can( 'manage_invoicing' ) ? 'wpinv' : false,
102
+        'show_in_menu'          => current_user_can('manage_invoicing') ? 'wpinv' : false,
103 103
         'show_in_nav_menus'     => false,
104
-        'supports'              => array( 'title', 'excerpt' ),
104
+        'supports'              => array('title', 'excerpt'),
105 105
         'register_meta_box_cb'  => 'wpinv_register_item_meta_boxes',
106 106
         'rewrite'               => false,
107 107
         'query_var'             => false,
@@ -125,40 +125,40 @@  discard block
 block discarded – undo
125 125
         ),
126 126
         'can_export'            => true,
127 127
     );
128
-    $invoice_item_args = apply_filters( 'wpinv_register_post_type_invoice_item', $invoice_item_args );
128
+    $invoice_item_args = apply_filters('wpinv_register_post_type_invoice_item', $invoice_item_args);
129 129
 
130
-    register_post_type( 'wpi_item', $invoice_item_args );
130
+    register_post_type('wpi_item', $invoice_item_args);
131 131
     
132 132
     $labels = array(
133
-        'name'               => _x( 'Discounts', 'post type general name', 'invoicing' ),
134
-        'singular_name'      => _x( 'Discount', 'post type singular name', 'invoicing' ),
135
-        'menu_name'          => _x( 'Discounts', 'admin menu', 'invoicing' ),
136
-        'name_admin_bar'     => _x( 'Discount', 'add new on admin bar', 'invoicing' ),
137
-        'add_new'            => _x( 'Add New', 'book', 'invoicing' ),
138
-        'add_new_item'       => __( 'Add New Discount', 'invoicing' ),
139
-        'new_item'           => __( 'New Discount', 'invoicing' ),
140
-        'edit_item'          => __( 'Edit Discount', 'invoicing' ),
141
-        'view_item'          => __( 'View Discount', 'invoicing' ),
142
-        'all_items'          => __( 'Discounts', 'invoicing' ),
143
-        'search_items'       => __( 'Search Discounts', 'invoicing' ),
144
-        'parent_item_colon'  => __( 'Parent Discounts:', 'invoicing' ),
145
-        'not_found'          => __( 'No discounts found.', 'invoicing' ),
146
-        'not_found_in_trash' => __( 'No discounts found in trash.', 'invoicing' )
133
+        'name'               => _x('Discounts', 'post type general name', 'invoicing'),
134
+        'singular_name'      => _x('Discount', 'post type singular name', 'invoicing'),
135
+        'menu_name'          => _x('Discounts', 'admin menu', 'invoicing'),
136
+        'name_admin_bar'     => _x('Discount', 'add new on admin bar', 'invoicing'),
137
+        'add_new'            => _x('Add New', 'book', 'invoicing'),
138
+        'add_new_item'       => __('Add New Discount', 'invoicing'),
139
+        'new_item'           => __('New Discount', 'invoicing'),
140
+        'edit_item'          => __('Edit Discount', 'invoicing'),
141
+        'view_item'          => __('View Discount', 'invoicing'),
142
+        'all_items'          => __('Discounts', 'invoicing'),
143
+        'search_items'       => __('Search Discounts', 'invoicing'),
144
+        'parent_item_colon'  => __('Parent Discounts:', 'invoicing'),
145
+        'not_found'          => __('No discounts found.', 'invoicing'),
146
+        'not_found_in_trash' => __('No discounts found in trash.', 'invoicing')
147 147
     );
148
-    $labels = apply_filters( 'wpinv_discounts_labels', $labels );
148
+    $labels = apply_filters('wpinv_discounts_labels', $labels);
149 149
 
150 150
     $cap_type = 'wpi_discount';
151 151
     
152 152
     $args = array(
153 153
         'labels'             => $labels,
154
-        'description'        => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ),
154
+        'description'        => __('This is where you can add new discounts that users can use in invoices.', 'invoicing'),
155 155
         'public'             => false,
156 156
         'can_export'         => true,
157 157
         '_builtin'           => false,
158 158
         'publicly_queryable' => false,
159 159
         'exclude_from_search'=> true,
160 160
         'show_ui'            => true,
161
-        'show_in_menu'       => current_user_can( 'manage_invoicing' ) ? 'wpinv' : false,
161
+        'show_in_menu'       => current_user_can('manage_invoicing') ? 'wpinv' : false,
162 162
         'query_var'          => false,
163 163
         'rewrite'            => false,
164 164
         'capability_type'    => $cap_type,
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
         ),
182 182
         'has_archive'        => false,
183 183
         'hierarchical'       => false,
184
-        'supports'           => array( 'title', 'excerpt' ),
184
+        'supports'           => array('title', 'excerpt'),
185 185
         'register_meta_box_cb'  => 'wpinv_register_discount_meta_boxes',
186 186
         'show_in_nav_menus'  => false,
187 187
         'show_in_admin_bar'  => true,
@@ -189,107 +189,107 @@  discard block
 block discarded – undo
189 189
         'menu_position'      => null,
190 190
     );
191 191
             
192
-    $args = apply_filters( 'wpinv_register_post_type_discount', $args );
192
+    $args = apply_filters('wpinv_register_post_type_discount', $args);
193 193
     
194
-    register_post_type( 'wpi_discount', $args );
194
+    register_post_type('wpi_discount', $args);
195 195
 }
196 196
 
197 197
 function wpinv_get_default_labels() {
198 198
     $defaults = array(
199
-       'singular' => __( 'Invoice', 'invoicing' ),
200
-       'plural'   => __( 'Invoices', 'invoicing' )
199
+       'singular' => __('Invoice', 'invoicing'),
200
+       'plural'   => __('Invoices', 'invoicing')
201 201
     );
202 202
     
203
-    return apply_filters( 'wpinv_default_invoices_name', $defaults );
203
+    return apply_filters('wpinv_default_invoices_name', $defaults);
204 204
 }
205 205
 
206
-function wpinv_get_label_singular( $lowercase = false ) {
206
+function wpinv_get_label_singular($lowercase = false) {
207 207
     $defaults = wpinv_get_default_labels();
208 208
     
209
-    return ($lowercase) ? strtolower( $defaults['singular'] ) : $defaults['singular'];
209
+    return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular'];
210 210
 }
211 211
 
212
-function wpinv_get_label_plural( $lowercase = false ) {
212
+function wpinv_get_label_plural($lowercase = false) {
213 213
     $defaults = wpinv_get_default_labels();
214 214
     
215
-    return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural'];
215
+    return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural'];
216 216
 }
217 217
 
218
-function wpinv_change_default_title( $title ) {
219
-     if ( !is_admin() ) {
218
+function wpinv_change_default_title($title) {
219
+     if (!is_admin()) {
220 220
         $label = wpinv_get_label_singular();
221
-        $title = sprintf( __( 'Enter %s name here', 'invoicing' ), $label );
221
+        $title = sprintf(__('Enter %s name here', 'invoicing'), $label);
222 222
         return $title;
223 223
      }
224 224
 
225 225
      $screen = get_current_screen();
226 226
 
227
-     if ( 'wpi_invoice' == $screen->post_type ) {
227
+     if ('wpi_invoice' == $screen->post_type) {
228 228
         $label = wpinv_get_label_singular();
229
-        $title = sprintf( __( 'Enter %s name here', 'invoicing' ), $label );
229
+        $title = sprintf(__('Enter %s name here', 'invoicing'), $label);
230 230
      }
231 231
 
232 232
      return $title;
233 233
 }
234
-add_filter( 'enter_title_here', 'wpinv_change_default_title' );
234
+add_filter('enter_title_here', 'wpinv_change_default_title');
235 235
 
236 236
 function wpinv_register_post_status() {
237
-    register_post_status( 'wpi-pending', array(
238
-        'label'                     => _x( 'Pending', 'Invoice status', 'invoicing' ),
237
+    register_post_status('wpi-pending', array(
238
+        'label'                     => _x('Pending', 'Invoice status', 'invoicing'),
239 239
         'public'                    => true,
240 240
         'exclude_from_search'       => true,
241 241
         'show_in_admin_all_list'    => true,
242 242
         'show_in_admin_status_list' => true,
243
-        'label_count'               => _n_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>', 'invoicing' )
244
-    ) );
245
-    register_post_status( 'wpi-processing', array(
246
-        'label'                     => _x( 'Processing', 'Invoice status', 'invoicing' ),
243
+        'label_count'               => _n_noop('Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>', 'invoicing')
244
+    ));
245
+    register_post_status('wpi-processing', array(
246
+        'label'                     => _x('Processing', 'Invoice status', 'invoicing'),
247 247
         'public'                    => true,
248 248
         'exclude_from_search'       => true,
249 249
         'show_in_admin_all_list'    => true,
250 250
         'show_in_admin_status_list' => true,
251
-        'label_count'               => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' )
252
-    ) );
253
-    register_post_status( 'wpi-onhold', array(
254
-        'label'                     => _x( 'On Hold', 'Invoice status', 'invoicing' ),
251
+        'label_count'               => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing')
252
+    ));
253
+    register_post_status('wpi-onhold', array(
254
+        'label'                     => _x('On Hold', 'Invoice status', 'invoicing'),
255 255
         'public'                    => true,
256 256
         'exclude_from_search'       => true,
257 257
         'show_in_admin_all_list'    => true,
258 258
         'show_in_admin_status_list' => true,
259
-        'label_count'               => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' )
260
-    ) );
261
-    register_post_status( 'wpi-cancelled', array(
262
-        'label'                     => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
259
+        'label_count'               => _n_noop('On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing')
260
+    ));
261
+    register_post_status('wpi-cancelled', array(
262
+        'label'                     => _x('Cancelled', 'Invoice status', 'invoicing'),
263 263
         'public'                    => true,
264 264
         'exclude_from_search'       => true,
265 265
         'show_in_admin_all_list'    => true,
266 266
         'show_in_admin_status_list' => true,
267
-        'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' )
268
-    ) );
269
-    register_post_status( 'wpi-refunded', array(
270
-        'label'                     => _x( 'Refunded', 'Invoice status', 'invoicing' ),
267
+        'label_count'               => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing')
268
+    ));
269
+    register_post_status('wpi-refunded', array(
270
+        'label'                     => _x('Refunded', 'Invoice status', 'invoicing'),
271 271
         'public'                    => true,
272 272
         'exclude_from_search'       => true,
273 273
         'show_in_admin_all_list'    => true,
274 274
         'show_in_admin_status_list' => true,
275
-        'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' )
276
-    ) );
277
-    register_post_status( 'wpi-failed', array(
278
-        'label'                     => _x( 'Failed', 'Invoice status', 'invoicing' ),
275
+        'label_count'               => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing')
276
+    ));
277
+    register_post_status('wpi-failed', array(
278
+        'label'                     => _x('Failed', 'Invoice status', 'invoicing'),
279 279
         'public'                    => true,
280 280
         'exclude_from_search'       => true,
281 281
         'show_in_admin_all_list'    => true,
282 282
         'show_in_admin_status_list' => true,
283
-        'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' )
284
-    ) );
285
-    register_post_status( 'wpi-renewal', array(
286
-        'label'                     => _x( 'Renewal', 'Invoice status', 'invoicing' ),
283
+        'label_count'               => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing')
284
+    ));
285
+    register_post_status('wpi-renewal', array(
286
+        'label'                     => _x('Renewal', 'Invoice status', 'invoicing'),
287 287
         'public'                    => true,
288 288
         'exclude_from_search'       => true,
289 289
         'show_in_admin_all_list'    => true,
290 290
         'show_in_admin_status_list' => true,
291
-        'label_count'               => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' )
292
-    ) );
291
+        'label_count'               => _n_noop('Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing')
292
+    ));
293 293
 }
294
-add_action( 'init', 'wpinv_register_post_status', 10 );
294
+add_action('init', 'wpinv_register_post_status', 10);
295 295
 
Please login to merge, or discard this patch.