Completed
Push — master ( 87ad6d...31f474 )
by Kiran
31s queued 25s
created
includes/admin/class-getpaid-anonymization-logs.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,12 +34,12 @@
 block discarded – undo
34 34
         // Prepare pagination
35 35
         $pagination = paginate_links(
36 36
             array(
37
-				'base'      => add_query_arg( 'paged', '%#%' ),
38
-				'format'    => '',
39
-				'prev_text' => __( '«', 'invoicing' ),
40
-				'next_text' => __( '»', 'invoicing' ),
41
-				'total'     => ceil( $total_logs / $per_page ),
42
-				'current'   => $page,
37
+                'base'      => add_query_arg( 'paged', '%#%' ),
38
+                'format'    => '',
39
+                'prev_text' => __( '«', 'invoicing' ),
40
+                'next_text' => __( '»', 'invoicing' ),
41
+                'total'     => ceil( $total_logs / $per_page ),
42
+                'current'   => $page,
43 43
             )
44 44
         );
45 45
 
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @since 2.8.22
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 /**
13 13
  * GetPaid_Anonymization_Logs Class
@@ -19,89 +19,89 @@  discard block
 block discarded – undo
19 19
      */
20 20
     public function display_logs() {
21 21
         // Check user capabilities
22
-        if ( ! current_user_can( 'manage_options' ) ) {
22
+        if (!current_user_can('manage_options')) {
23 23
             return;
24 24
         }
25 25
 
26 26
         // Get current page number
27
-        $page = isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
27
+        $page = isset($_GET['paged']) ? absint($_GET['paged']) : 1;
28 28
         $per_page = 20;
29 29
 
30 30
         // Fetch logs
31
-        $logs = $this->get_logs( $page, $per_page );
31
+        $logs = $this->get_logs($page, $per_page);
32 32
         $total_logs = $this->get_total_logs();
33 33
 
34 34
         // Prepare pagination
35 35
         $pagination = paginate_links(
36 36
             array(
37
-				'base'      => add_query_arg( 'paged', '%#%' ),
37
+				'base'      => add_query_arg('paged', '%#%'),
38 38
 				'format'    => '',
39
-				'prev_text' => __( '«', 'invoicing' ),
40
-				'next_text' => __( '»', 'invoicing' ),
41
-				'total'     => ceil( $total_logs / $per_page ),
39
+				'prev_text' => __('«', 'invoicing'),
40
+				'next_text' => __('»', 'invoicing'),
41
+				'total'     => ceil($total_logs / $per_page),
42 42
 				'current'   => $page,
43 43
             )
44 44
         );
45 45
 
46 46
         ?>
47 47
         <div class="wrap getpaid-anonymization-logs">
48
-            <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
48
+            <h1><?php echo esc_html(get_admin_page_title()); ?></h1>
49 49
             <div class="tablenav top">
50 50
                 <div class="alignleft actions">
51 51
                     <form method="get">
52 52
                         <input type="hidden" name="page" value="wpinv-anonymization-logs">
53
-                        <label for="filter-by-date" class="screen-reader-text"><?php _e( 'Filter by date', 'invoicing' ); ?></label>
53
+                        <label for="filter-by-date" class="screen-reader-text"><?php _e('Filter by date', 'invoicing'); ?></label>
54 54
                         <select name="m" id="filter-by-date">
55
-                            <option value="0"><?php _e( 'All dates', 'invoicing' ); ?></option>
55
+                            <option value="0"><?php _e('All dates', 'invoicing'); ?></option>
56 56
                             <?php
57 57
                             $months = $this->get_log_months();
58
-                            foreach ( $months as $month ) {
59
-                                $selected = ( isset( $_GET['m'] ) && $_GET['m'] == $month->month ) ? ' selected="selected"' : '';
60
-                                echo '<option value="' . esc_attr( $month->month ) . '"' . $selected . '>' . esc_html( $month->month_name . ' ' . $month->year ) . '</option>';
58
+                            foreach ($months as $month) {
59
+                                $selected = (isset($_GET['m']) && $_GET['m'] == $month->month) ? ' selected="selected"' : '';
60
+                                echo '<option value="' . esc_attr($month->month) . '"' . $selected . '>' . esc_html($month->month_name . ' ' . $month->year) . '</option>';
61 61
                             }
62 62
                             ?>
63 63
                         </select>
64
-                        <?php submit_button( __( 'Filter', 'invoicing' ), '', 'filter_action', false ); ?>
64
+                        <?php submit_button(__('Filter', 'invoicing'), '', 'filter_action', false); ?>
65 65
                     </form>
66 66
                 </div>
67 67
             </div>
68 68
             <table class="wp-list-table widefat fixed striped">
69 69
                 <thead>
70 70
                     <tr>
71
-                        <th><?php _e( 'Log ID', 'invoicing' ); ?></th>
72
-                        <th><?php _e( 'User', 'invoicing' ); ?></th>
73
-                        <th><?php _e( 'Action', 'invoicing' ); ?></th>
74
-                        <th><?php _e( 'Date', 'invoicing' ); ?></th>
75
-                        <th><?php _e( 'Details', 'invoicing' ); ?></th>
71
+                        <th><?php _e('Log ID', 'invoicing'); ?></th>
72
+                        <th><?php _e('User', 'invoicing'); ?></th>
73
+                        <th><?php _e('Action', 'invoicing'); ?></th>
74
+                        <th><?php _e('Date', 'invoicing'); ?></th>
75
+                        <th><?php _e('Details', 'invoicing'); ?></th>
76 76
                     </tr>
77 77
                 </thead>
78 78
                 <tbody>
79
-                    <?php if ( empty( $logs ) ) : ?>
79
+                    <?php if (empty($logs)) : ?>
80 80
                         <tr>
81
-                            <td colspan="5"><?php _e( 'No anonymization logs found.', 'invoicing' ); ?></td>
81
+                            <td colspan="5"><?php _e('No anonymization logs found.', 'invoicing'); ?></td>
82 82
                         </tr>
83 83
                     <?php else : ?>
84 84
                         <?php
85
-                        foreach ( $logs as $log ) :
86
-                            $additional_info = json_decode( $log->additional_info, true );
85
+                        foreach ($logs as $log) :
86
+                            $additional_info = json_decode($log->additional_info, true);
87 87
                         ?>
88 88
                             <tr>
89
-                                <td><?php echo esc_html( $log->log_id ); ?></td>
89
+                                <td><?php echo esc_html($log->log_id); ?></td>
90 90
                                 <td>
91 91
                                     <?php
92
-                                    $user_edit_link = get_edit_user_link( $log->user_id );
93
-                                    if ( $user_edit_link ) {
94
-                                        echo '<a href="' . esc_url( $user_edit_link ) . '">' . esc_html( $log->user_id ) . '</a>';
92
+                                    $user_edit_link = get_edit_user_link($log->user_id);
93
+                                    if ($user_edit_link) {
94
+                                        echo '<a href="' . esc_url($user_edit_link) . '">' . esc_html($log->user_id) . '</a>';
95 95
                                     } else {
96
-                                        echo esc_html( $log->user_id );
96
+                                        echo esc_html($log->user_id);
97 97
                                     }
98 98
                                     ?>
99 99
                                 </td>
100
-                                <td><?php echo esc_html( ucfirst( $log->action ) ); ?></td>
101
-                                <td><?php echo esc_html( get_date_from_gmt( $log->timestamp, 'F j, Y g:i a' ) ); ?></td>
100
+                                <td><?php echo esc_html(ucfirst($log->action)); ?></td>
101
+                                <td><?php echo esc_html(get_date_from_gmt($log->timestamp, 'F j, Y g:i a')); ?></td>
102 102
                                 <td>
103 103
                                     <button class="button-link toggle-details" type="button" aria-expanded="false">
104
-                                        <span class="screen-reader-text"><?php _e( 'Show more details', 'invoicing' ); ?></span>
104
+                                        <span class="screen-reader-text"><?php _e('Show more details', 'invoicing'); ?></span>
105 105
                                         <span class="dashicons dashicons-arrow-down-alt2"></span>
106 106
                                     </button>
107 107
                                 </td>
@@ -112,19 +112,19 @@  discard block
 block discarded – undo
112 112
                                         <table class="widefat fixed">
113 113
                                             <tbody>
114 114
                                                 <tr>
115
-                                                    <th><?php _e( 'Data Type', 'invoicing' ); ?></th>
116
-                                                    <td><?php echo esc_html( $log->data_type ); ?></td>
115
+                                                    <th><?php _e('Data Type', 'invoicing'); ?></th>
116
+                                                    <td><?php echo esc_html($log->data_type); ?></td>
117 117
                                                 </tr>
118
-                                                <?php if ( is_array( $additional_info ) ) : ?>
118
+                                                <?php if (is_array($additional_info)) : ?>
119 119
                                                     <tr>
120
-                                                        <th><?php _e( 'Additional Information', 'invoicing' ); ?></th>
120
+                                                        <th><?php _e('Additional Information', 'invoicing'); ?></th>
121 121
                                                         <td>
122 122
                                                             <table class="widefat fixed">
123 123
                                                                 <tbody>
124
-                                                                    <?php foreach ( $additional_info as $key => $value ) : ?>
124
+                                                                    <?php foreach ($additional_info as $key => $value) : ?>
125 125
                                                                         <tr>
126
-                                                                            <th><?php echo esc_html( $key ); ?></th>
127
-                                                                            <td><?php echo esc_html( $value ); ?></td>
126
+                                                                            <th><?php echo esc_html($key); ?></th>
127
+                                                                            <td><?php echo esc_html($value); ?></td>
128 128
                                                                         </tr>
129 129
                                                                     <?php endforeach; ?>
130 130
                                                                 </tbody>
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
                     <?php endif; ?>
142 142
                 </tbody>
143 143
             </table>
144
-            <?php if ( $pagination ) : ?>
144
+            <?php if ($pagination) : ?>
145 145
                 <div class="tablenav bottom">
146 146
                     <div class="tablenav-pages">
147 147
                         <?php echo $pagination; ?>
@@ -159,10 +159,10 @@  discard block
 block discarded – undo
159 159
      * @param int $per_page Number of logs per page
160 160
      * @return array
161 161
      */
162
-    private function get_logs( $page, $per_page ) {
162
+    private function get_logs($page, $per_page) {
163 163
         global $wpdb;
164 164
         $table_name = $wpdb->prefix . 'getpaid_anonymization_logs';
165
-        $offset = ( $page - 1 ) * $per_page;
165
+        $offset = ($page - 1) * $per_page;
166 166
 
167 167
         $query = $wpdb->prepare(
168 168
             "SELECT * FROM $table_name ORDER BY timestamp DESC LIMIT %d OFFSET %d",
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
             $offset
171 171
         );
172 172
 
173
-        return $wpdb->get_results( $query );
173
+        return $wpdb->get_results($query);
174 174
     }
175 175
 
176 176
     /**
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
     private function get_total_logs() {
182 182
         global $wpdb;
183 183
         $table_name = $wpdb->prefix . 'getpaid_anonymization_logs';
184
-        return $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" );
184
+        return $wpdb->get_var("SELECT COUNT(*) FROM $table_name");
185 185
     }
186 186
 
187 187
     /**
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -80,10 +80,12 @@
 block discarded – undo
80 80
                         <tr>
81 81
                             <td colspan="5"><?php _e( 'No anonymization logs found.', 'invoicing' ); ?></td>
82 82
                         </tr>
83
-                    <?php else : ?>
83
+                    <?php else {
84
+    : ?>
84 85
                         <?php
85 86
                         foreach ( $logs as $log ) :
86 87
                             $additional_info = json_decode( $log->additional_info, true );
88
+}
87 89
                         ?>
88 90
                             <tr>
89 91
                                 <td><?php echo esc_html( $log->log_id ); ?></td>
Please login to merge, or discard this patch.
includes/class-wpinv-data-retention.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -291,18 +291,18 @@
 block discarded – undo
291 291
 
292 292
         $user_meta_data = array(
293 293
             'nickname',
294
-			'description',
295
-			'rich_editing',
296
-			'syntax_highlighting',
297
-			'comment_shortcuts',
294
+            'description',
295
+            'rich_editing',
296
+            'syntax_highlighting',
297
+            'comment_shortcuts',
298 298
             'admin_color',
299
-			'use_ssl',
300
-			'show_admin_bar_front',
301
-			'locale',
302
-			'wp_capabilities',
299
+            'use_ssl',
300
+            'show_admin_bar_front',
301
+            'locale',
302
+            'wp_capabilities',
303 303
             'wp_user_level',
304
-			'dismissed_wp_pointers',
305
-			'show_welcome_panel',
304
+            'dismissed_wp_pointers',
305
+            'show_welcome_panel',
306 306
         );
307 307
 
308 308
         /**
Please login to merge, or discard this patch.
Spacing   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @since   2.8.22
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * WPInv_Data_Retention Class.
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
      * Class constructor.
36 36
      */
37 37
     public function __construct() {
38
-        add_filter( 'wpinv_settings_misc', array( $this, 'add_data_retention_settings' ) );
38
+        add_filter('wpinv_settings_misc', array($this, 'add_data_retention_settings'));
39 39
 
40
-        add_action( 'wpmu_delete_user', array( $this, 'maybe_handle_user_deletion' ), 1 );
41
-        add_action( 'delete_user', array( $this, 'maybe_handle_user_deletion' ), 1 );
42
-        add_filter( 'wp_privacy_personal_data_erasure_request', array( $this, 'handle_erasure_request' ), 10, 2 );
40
+        add_action('wpmu_delete_user', array($this, 'maybe_handle_user_deletion'), 1);
41
+        add_action('delete_user', array($this, 'maybe_handle_user_deletion'), 1);
42
+        add_filter('wp_privacy_personal_data_erasure_request', array($this, 'handle_erasure_request'), 10, 2);
43 43
 
44
-        add_action( 'getpaid_daily_maintenance', array( $this, 'perform_data_retention_cleanup' ) );
44
+        add_action('getpaid_daily_maintenance', array($this, 'perform_data_retention_cleanup'));
45 45
     }
46 46
 
47 47
     /**
@@ -50,43 +50,43 @@  discard block
 block discarded – undo
50 50
      * @param array $misc_settings Existing misc settings.
51 51
      * @return array Updated misc settings.
52 52
      */
53
-    public function add_data_retention_settings( $misc_settings ) {
53
+    public function add_data_retention_settings($misc_settings) {
54 54
         $misc_settings['data_retention'] = array(
55 55
             'id'   => 'data_retention',
56
-            'name' => '<h3>' . __( 'Data Retention', 'invoicing' ) . '</h3>',
56
+            'name' => '<h3>' . __('Data Retention', 'invoicing') . '</h3>',
57 57
             'type' => 'header',
58 58
         );
59 59
 
60 60
         $misc_settings['data_retention_method'] = array(
61 61
             'id'      => 'data_retention_method',
62
-            'name'    => __( 'Data Handling', 'invoicing' ),
63
-            'desc'    => __( 'Choose how to handle user data when deletion is required.', 'invoicing' ),
62
+            'name'    => __('Data Handling', 'invoicing'),
63
+            'desc'    => __('Choose how to handle user data when deletion is required.', 'invoicing'),
64 64
             'type'    => 'select',
65 65
             'options' => array(
66
-                'anonymize' => __( 'Anonymize data', 'invoicing' ),
67
-                'delete'    => __( 'Delete data without anonymization', 'invoicing' ),
66
+                'anonymize' => __('Anonymize data', 'invoicing'),
67
+                'delete'    => __('Delete data without anonymization', 'invoicing'),
68 68
             ),
69 69
             'std'     => 'anonymize',
70
-            'tooltip' => __( 'Anonymization replaces personal data with non-identifiable information. Direct deletion removes all data permanently.', 'invoicing' ),
70
+            'tooltip' => __('Anonymization replaces personal data with non-identifiable information. Direct deletion removes all data permanently.', 'invoicing'),
71 71
         );
72 72
 
73 73
         $misc_settings['data_retention_period'] = array(
74 74
             'id'      => 'data_retention_period',
75
-            'name'    => __( 'Retention Period', 'invoicing' ),
76
-            'desc'    => __( 'Specify how long to retain customer data after processing.', 'invoicing' ),
75
+            'name'    => __('Retention Period', 'invoicing'),
76
+            'desc'    => __('Specify how long to retain customer data after processing.', 'invoicing'),
77 77
             'type'    => 'select',
78 78
             'options' => array(
79
-                'never' => __( 'Never delete (retain indefinitely)', 'invoicing' ),
80
-                '30'    => __( '30 days', 'invoicing' ),
81
-                '90'    => __( '90 days', 'invoicing' ),
82
-                '180'   => __( '6 months', 'invoicing' ),
83
-                '365'   => __( '1 year', 'invoicing' ),
84
-                '730'   => __( '2 years', 'invoicing' ),
85
-                '1825'  => __( '5 years', 'invoicing' ),
86
-                '3650'  => __( '10 years', 'invoicing' ),
79
+                'never' => __('Never delete (retain indefinitely)', 'invoicing'),
80
+                '30'    => __('30 days', 'invoicing'),
81
+                '90'    => __('90 days', 'invoicing'),
82
+                '180'   => __('6 months', 'invoicing'),
83
+                '365'   => __('1 year', 'invoicing'),
84
+                '730'   => __('2 years', 'invoicing'),
85
+                '1825'  => __('5 years', 'invoicing'),
86
+                '3650'  => __('10 years', 'invoicing'),
87 87
             ),
88 88
             'std'     => '3650',
89
-            'tooltip' => __( 'Choose how long to keep processed customer data before final action. This helps balance data minimization with business needs.', 'invoicing' ),
89
+            'tooltip' => __('Choose how long to keep processed customer data before final action. This helps balance data minimization with business needs.', 'invoicing'),
90 90
         );
91 91
 
92 92
         return $misc_settings;
@@ -97,15 +97,15 @@  discard block
 block discarded – undo
97 97
      *
98 98
      * @param int $user_id The ID of the user being deleted.
99 99
      */
100
-    public function maybe_handle_user_deletion( $user_id ) {
101
-        if ( ! $this->handle_user_deletion ) {
100
+    public function maybe_handle_user_deletion($user_id) {
101
+        if (!$this->handle_user_deletion) {
102 102
             return;
103 103
         }
104 104
 
105
-        if ( current_user_can( 'manage_options' ) ) {
106
-            $this->handle_admin_user_deletion( $user_id );
105
+        if (current_user_can('manage_options')) {
106
+            $this->handle_admin_user_deletion($user_id);
107 107
         } else {
108
-            $this->handle_self_account_deletion( $user_id );
108
+            $this->handle_self_account_deletion($user_id);
109 109
         }
110 110
     }
111 111
 
@@ -115,19 +115,19 @@  discard block
 block discarded – undo
115 115
      * @since 2.8.22
116 116
      * @param int $user_id The ID of the user being deleted.
117 117
      */
118
-    public function handle_admin_user_deletion( $user_id ) {
119
-        if ( $this->has_active_subscriptions( $user_id ) ) {
120
-            $this->prevent_user_deletion( $user_id, 'active_subscriptions' );
118
+    public function handle_admin_user_deletion($user_id) {
119
+        if ($this->has_active_subscriptions($user_id)) {
120
+            $this->prevent_user_deletion($user_id, 'active_subscriptions');
121 121
             return;
122 122
         }
123 123
 
124
-        if ( $this->has_paid_invoices( $user_id ) ) {
125
-            $retention_method = wpinv_get_option( 'data_retention_method', 'anonymize' );
126
-            if ( 'anonymize' === $retention_method ) {
127
-                $this->anonymize_user_data( $user_id );
128
-                $this->prevent_user_deletion( $user_id, 'paid_invoices' );
124
+        if ($this->has_paid_invoices($user_id)) {
125
+            $retention_method = wpinv_get_option('data_retention_method', 'anonymize');
126
+            if ('anonymize' === $retention_method) {
127
+                $this->anonymize_user_data($user_id);
128
+                $this->prevent_user_deletion($user_id, 'paid_invoices');
129 129
             } else {
130
-                $this->delete_user_data( $user_id );
130
+                $this->delete_user_data($user_id);
131 131
             }
132 132
         }
133 133
     }
@@ -138,19 +138,19 @@  discard block
 block discarded – undo
138 138
      * @since 2.8.22
139 139
      * @param int $user_id The ID of the user being deleted.
140 140
      */
141
-    public function handle_self_account_deletion( $user_id ) {
142
-        $this->cancel_active_subscriptions( $user_id );
141
+    public function handle_self_account_deletion($user_id) {
142
+        $this->cancel_active_subscriptions($user_id);
143 143
 
144
-        if ( $this->has_paid_invoices( $user_id ) ) {
145
-            $retention_method = wpinv_get_option( 'data_retention_method', 'anonymize' );
144
+        if ($this->has_paid_invoices($user_id)) {
145
+            $retention_method = wpinv_get_option('data_retention_method', 'anonymize');
146 146
 
147
-            if ( 'anonymize' === $retention_method ) {
148
-                $user = get_userdata( $user_id );
147
+            if ('anonymize' === $retention_method) {
148
+                $user = get_userdata($user_id);
149 149
 
150
-                $this->anonymize_user_data( $user_id );
150
+                $this->anonymize_user_data($user_id);
151 151
 
152
-                $message = apply_filters( 'uwp_get_account_deletion_message', '', $user );
153
-                do_action( 'uwp_send_account_deletion_emails', $user, $message );
152
+                $message = apply_filters('uwp_get_account_deletion_message', '', $user);
153
+                do_action('uwp_send_account_deletion_emails', $user, $message);
154 154
 
155 155
                 $this->end_user_session();
156 156
             }
@@ -164,15 +164,15 @@  discard block
 block discarded – undo
164 164
      * @param int $user_id The ID of the user being checked.
165 165
      * @return bool True if user has active subscriptions, false otherwise.
166 166
      */
167
-    private function has_active_subscriptions( $user_id ) {
167
+    private function has_active_subscriptions($user_id) {
168 168
         $subscriptions = getpaid_get_subscriptions(
169 169
             array(
170
-                'customer_in' => array( (int) $user_id ),
170
+                'customer_in' => array((int) $user_id),
171 171
                 'status'      => 'active',
172 172
             )
173 173
         );
174 174
 
175
-        return ! empty( $subscriptions );
175
+        return !empty($subscriptions);
176 176
     }
177 177
 
178 178
     /**
@@ -181,15 +181,15 @@  discard block
 block discarded – undo
181 181
      * @since 2.8.22
182 182
      * @param int $user_id The ID of the user.
183 183
      */
184
-    private function cancel_active_subscriptions( $user_id ) {
184
+    private function cancel_active_subscriptions($user_id) {
185 185
         $subscriptions = getpaid_get_subscriptions(
186 186
             array(
187
-                'customer_in' => array( (int) $user_id ),
187
+                'customer_in' => array((int) $user_id),
188 188
                 'status'      => 'active',
189 189
             )
190 190
         );
191 191
 
192
-        foreach ( $subscriptions as $subscription ) {
192
+        foreach ($subscriptions as $subscription) {
193 193
             $subscription->cancel();
194 194
         }
195 195
     }
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
      * @param int $user_id The ID of the user being checked.
202 202
      * @return bool True if user has paid invoices, false otherwise.
203 203
      */
204
-    private function has_paid_invoices( $user_id ) {
204
+    private function has_paid_invoices($user_id) {
205 205
         $invoices = wpinv_get_invoices(
206 206
             array(
207 207
                 'user'   => (int) $user_id,
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
             )
210 210
         );
211 211
 
212
-        return ! empty( $invoices->total );
212
+        return !empty($invoices->total);
213 213
     }
214 214
 
215 215
     /**
@@ -219,24 +219,24 @@  discard block
 block discarded – undo
219 219
      * @param int    $user_id The ID of the user being deleted.
220 220
      * @param string $reason  The reason for preventing deletion.
221 221
      */
222
-    private function prevent_user_deletion( $user_id, $reason ) {
223
-        $user = get_userdata( $user_id );
222
+    private function prevent_user_deletion($user_id, $reason) {
223
+        $user = get_userdata($user_id);
224 224
 
225
-        if ( 'active_subscriptions' === $reason ) {
225
+        if ('active_subscriptions' === $reason) {
226 226
             $this->error_message = sprintf(
227 227
                 /* translators: %s: user login */
228
-                esc_html__( 'User deletion for %s has been halted. All active subscriptions should be cancelled first.', 'invoicing' ),
228
+                esc_html__('User deletion for %s has been halted. All active subscriptions should be cancelled first.', 'invoicing'),
229 229
                 $user->user_login
230 230
             );
231 231
         } else {
232 232
             $this->error_message = sprintf(
233 233
                 /* translators: %s: user login */
234
-                esc_html__( 'User deletion for %s has been halted due to paid invoices. Data will be anonymized instead.', 'invoicing' ),
234
+                esc_html__('User deletion for %s has been halted due to paid invoices. Data will be anonymized instead.', 'invoicing'),
235 235
                 $user->user_login
236 236
             );
237 237
         }
238 238
 
239
-        wp_die( $this->error_message, esc_html__( 'User Deletion Halted', 'invoicing' ), array( 'response' => 403 ) );
239
+        wp_die($this->error_message, esc_html__('User Deletion Halted', 'invoicing'), array('response' => 403));
240 240
     }
241 241
 
242 242
     /**
@@ -246,17 +246,17 @@  discard block
 block discarded – undo
246 246
      * @param int $user_id The ID of the user to anonymize.
247 247
      * @return bool True on success, false on failure.
248 248
      */
249
-    private function anonymize_user_data( $user_id ) {
249
+    private function anonymize_user_data($user_id) {
250 250
         global $wpdb;
251 251
 
252
-        $user = get_userdata( $user_id );
253
-        if ( ! $user ) {
252
+        $user = get_userdata($user_id);
253
+        if (!$user) {
254 254
             return false;
255 255
         }
256 256
 
257 257
         $table_name    = $wpdb->prefix . 'getpaid_customers';
258
-        $deletion_date = gmdate( 'Y-m-d', strtotime( '+10 years' ) );
259
-        $hashed_email  = $this->hash_email( $user->user_email );
258
+        $deletion_date = gmdate('Y-m-d', strtotime('+10 years'));
259
+        $hashed_email  = $this->hash_email($user->user_email);
260 260
 
261 261
         $updated = $wpdb->update(
262 262
             $table_name,
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
                 'email_cc'      => $hashed_email,
268 268
                 'phone'         => '',
269 269
             ),
270
-            array( 'user_id' => (int) $user->ID )
270
+            array('user_id' => (int) $user->ID)
271 271
         );
272 272
 
273
-        if ( false === $updated ) {
273
+        if (false === $updated) {
274 274
             return false;
275 275
         }
276 276
 
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
          * @since 2.8.22
288 288
          * @param int $user_id The ID of the user being anonymized.
289 289
          */
290
-        do_action( 'wpinv_anonymize_user_meta_data', $user->ID );
290
+        do_action('wpinv_anonymize_user_meta_data', $user->ID);
291 291
 
292 292
         $user_meta_data = array(
293 293
             'nickname',
@@ -312,13 +312,13 @@  discard block
 block discarded – undo
312 312
          * @param array $user_meta_data The meta fields to be anonymized.
313 313
          * @param int   $user_id          The ID of the user being anonymized.
314 314
          */
315
-        $user_meta_data = apply_filters( 'wpinv_user_meta_data_to_anonymize', $user_meta_data, $user->ID );
315
+        $user_meta_data = apply_filters('wpinv_user_meta_data_to_anonymize', $user_meta_data, $user->ID);
316 316
 
317
-        foreach ( $user_meta_data as $meta_key ) {
318
-            delete_user_meta( $user->ID, $meta_key );
317
+        foreach ($user_meta_data as $meta_key) {
318
+            delete_user_meta($user->ID, $meta_key);
319 319
         }
320 320
 
321
-        return $this->ensure_invoice_anonymization( $user->ID, 'anonymize' );
321
+        return $this->ensure_invoice_anonymization($user->ID, 'anonymize');
322 322
     }
323 323
 
324 324
     /**
@@ -327,15 +327,15 @@  discard block
 block discarded – undo
327 327
      * @param int $user_id The ID of the user to delete.
328 328
      * @return bool True on success, false on failure.
329 329
      */
330
-    private function delete_user_data( $user_id ) {
330
+    private function delete_user_data($user_id) {
331 331
         // Delete associated invoices.
332
-        $this->ensure_invoice_anonymization( $user_id, 'delete' );
332
+        $this->ensure_invoice_anonymization($user_id, 'delete');
333 333
 
334 334
         // Delete the user.
335
-        if ( is_multisite() ) {
336
-            wpmu_delete_user( $user_id );
335
+        if (is_multisite()) {
336
+            wpmu_delete_user($user_id);
337 337
         } else {
338
-            wp_delete_user( $user_id );
338
+            wp_delete_user($user_id);
339 339
         }
340 340
 
341 341
         /**
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
          * @since 2.8.22
345 345
          * @param int $user_id The ID of the user being deleted.
346 346
          */
347
-        do_action( 'wpinv_delete_user_data', $user_id );
347
+        do_action('wpinv_delete_user_data', $user_id);
348 348
 
349 349
         return true;
350 350
     }
@@ -357,8 +357,8 @@  discard block
 block discarded – undo
357 357
      * @param string $action  The action to perform (anonymize or delete).
358 358
      * @return bool True on success, false on failure.
359 359
      */
360
-    public function ensure_invoice_anonymization( $user_id, $action = 'anonymize' ) {
361
-        $invoices = wpinv_get_invoices( array( 'user' => $user_id ) );
360
+    public function ensure_invoice_anonymization($user_id, $action = 'anonymize') {
361
+        $invoices = wpinv_get_invoices(array('user' => $user_id));
362 362
 
363 363
         /**
364 364
          * Filters the invoice meta fields to be anonymized.
@@ -367,22 +367,22 @@  discard block
 block discarded – undo
367 367
          * @param array $inv_meta_data The meta fields to be anonymized.
368 368
          * @param int   $user_id         The ID of the user being processed.
369 369
          */
370
-        $inv_meta_data = apply_filters( 'wpinv_invoice_meta_data_to_anonymize', array(), $user_id );
370
+        $inv_meta_data = apply_filters('wpinv_invoice_meta_data_to_anonymize', array(), $user_id);
371 371
 
372
-        foreach ( $invoices->invoices as $invoice ) {
373
-            foreach ( $inv_meta_data as $meta_key ) {
374
-                delete_post_meta( $invoice->get_id(), $meta_key );
372
+        foreach ($invoices->invoices as $invoice) {
373
+            foreach ($inv_meta_data as $meta_key) {
374
+                delete_post_meta($invoice->get_id(), $meta_key);
375 375
             }
376 376
 
377
-            if ( 'anonymize' === $action ) {
378
-                $hashed_inv_email    = $this->hash_email( $invoice->get_email() );
379
-                $hashed_inv_email_cc = $this->hash_email( $invoice->get_email_cc() );
377
+            if ('anonymize' === $action) {
378
+                $hashed_inv_email    = $this->hash_email($invoice->get_email());
379
+                $hashed_inv_email_cc = $this->hash_email($invoice->get_email_cc());
380 380
 
381
-                $invoice->set_email( $hashed_inv_email );
382
-                $invoice->set_email_cc( $hashed_inv_email_cc );
383
-                $invoice->set_phone( '' );
384
-                $invoice->set_ip( $this->anonymize_data( $invoice->get_ip() ) );
385
-                $invoice->set_is_anonymized( 1 );
381
+                $invoice->set_email($hashed_inv_email);
382
+                $invoice->set_email_cc($hashed_inv_email_cc);
383
+                $invoice->set_phone('');
384
+                $invoice->set_ip($this->anonymize_data($invoice->get_ip()));
385
+                $invoice->set_is_anonymized(1);
386 386
 
387 387
                 /**
388 388
                  * Fires when anonymizing additional invoice data.
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
                  * @param WPInv_Invoice $invoice The invoice being anonymized.
392 392
                  * @param string        $action  The action being performed (anonymize or delete).
393 393
                  */
394
-                do_action( 'wpinv_anonymize_invoice_data', $invoice, $action );
394
+                do_action('wpinv_anonymize_invoice_data', $invoice, $action);
395 395
 
396 396
                 $invoice->save();
397 397
             } else {
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
             }
400 400
         }
401 401
 
402
-        return $this->log_deletion_action( $user_id, $invoices->invoices, $action );
402
+        return $this->log_deletion_action($user_id, $invoices->invoices, $action);
403 403
     }
404 404
 
405 405
     /**
@@ -411,11 +411,11 @@  discard block
 block discarded – undo
411 411
      * @param string $action   The action being performed (anonymize or delete).
412 412
      * @return bool True on success, false on failure.
413 413
      */
414
-    private function log_deletion_action( $user_id, $invoices, $action ) {
414
+    private function log_deletion_action($user_id, $invoices, $action) {
415 415
         global $wpdb;
416 416
 
417 417
         $table_name = $wpdb->prefix . 'getpaid_anonymization_logs';
418
-        $user_data  = get_userdata( $user_id );
418
+        $user_data  = get_userdata($user_id);
419 419
 
420 420
         $additional_info = array(
421 421
             'Username'      => $user_data ? $user_data->user_login : 'N/A',
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
             'First Name'    => $user_data ? $user_data->first_name : 'N/A',
425 425
             'Last Name'     => $user_data ? $user_data->last_name : 'N/A',
426 426
             'Registered'    => $user_data ? $user_data->user_registered : 'N/A',
427
-            'invoice_count' => count( $invoices ),
427
+            'invoice_count' => count($invoices),
428 428
         );
429 429
 
430 430
 
@@ -437,43 +437,43 @@  discard block
 block discarded – undo
437 437
          * @param array  $invoices        The invoices being processed.
438 438
          * @param string $action          The action being performed (anonymize or delete).
439 439
          */
440
-        $additional_info = apply_filters( 'wpinv_anonymization_log_additional_info', $additional_info, $user_id, $invoices, $action );
440
+        $additional_info = apply_filters('wpinv_anonymization_log_additional_info', $additional_info, $user_id, $invoices, $action);
441 441
 
442 442
         $data = array(
443 443
             'user_id'         => $user_id,
444
-            'action'          => sanitize_text_field( $action ),
444
+            'action'          => sanitize_text_field($action),
445 445
             'data_type'       => 'User Invoices',
446
-            'timestamp'       => current_time( 'mysql' ),
447
-            'additional_info' => wp_json_encode( $additional_info ),
446
+            'timestamp'       => current_time('mysql'),
447
+            'additional_info' => wp_json_encode($additional_info),
448 448
         );
449 449
 
450 450
         $format = array(
451
-            '%d',  // user_id
452
-            '%s',  // action
453
-            '%s',  // data_type
454
-            '%s',  // timestamp
455
-            '%s',  // additional_info
451
+            '%d', // user_id
452
+            '%s', // action
453
+            '%s', // data_type
454
+            '%s', // timestamp
455
+            '%s', // additional_info
456 456
         );
457 457
 
458
-        if ( ! empty( $user_id ) && ! empty( $action ) ) {
458
+        if (!empty($user_id) && !empty($action)) {
459 459
             $result = $wpdb->update(
460 460
                 $table_name,
461 461
                 $data,
462 462
                 array(
463 463
                     'user_id' => (int) $user_id,
464
-                    'action'  => sanitize_text_field( $action ),
464
+                    'action'  => sanitize_text_field($action),
465 465
                 ),
466 466
                 $format,
467
-                array( '%d', '%s' )
467
+                array('%d', '%s')
468 468
             );
469 469
 
470
-            if ( false === $result ) {
470
+            if (false === $result) {
471 471
                 // If update fails, try to insert.
472
-                $result = $wpdb->insert( $table_name, $data, $format );
472
+                $result = $wpdb->insert($table_name, $data, $format);
473 473
             }
474 474
 
475
-            if ( false === $result ) {
476
-                wpinv_error_log( sprintf( 'Failed to log anonymization action for user ID: %d. Error: %s', $user_id, $wpdb->last_error ) );
475
+            if (false === $result) {
476
+                wpinv_error_log(sprintf('Failed to log anonymization action for user ID: %d. Error: %s', $user_id, $wpdb->last_error));
477 477
                 return false;
478 478
             }
479 479
         }
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
          * @param string $action   The action being performed (anonymize or delete).
488 488
          * @param array  $data     The data that was inserted into the log.
489 489
          */
490
-        do_action( 'wpinv_after_log_deletion_action', $user_id, $invoices, $action, $data );
490
+        do_action('wpinv_after_log_deletion_action', $user_id, $invoices, $action, $data);
491 491
 
492 492
         return true;
493 493
     }
@@ -500,20 +500,20 @@  discard block
 block discarded – undo
500 500
      * @param int   $user_id  The ID of the user being erased.
501 501
      * @return array The modified response.
502 502
      */
503
-    public function handle_erasure_request( $response, $user_id ) {
504
-        if ( $this->has_active_subscriptions( $user_id ) ) {
505
-            $response['messages'][]    = esc_html__( 'User has active subscriptions. Data cannot be erased at this time.', 'invoicing' );
503
+    public function handle_erasure_request($response, $user_id) {
504
+        if ($this->has_active_subscriptions($user_id)) {
505
+            $response['messages'][]    = esc_html__('User has active subscriptions. Data cannot be erased at this time.', 'invoicing');
506 506
             $response['items_removed'] = false;
507
-        } elseif ( $this->has_paid_invoices( $user_id ) ) {
508
-            $retention_method = wpinv_get_option( 'data_retention_method', 'anonymize' );
509
-            if ( 'anonymize' === $retention_method ) {
510
-                $this->anonymize_user_data( $user_id );
511
-                $response['messages'][]     = esc_html__( 'User data has been anonymized due to existing paid invoices.', 'invoicing' );
507
+        } elseif ($this->has_paid_invoices($user_id)) {
508
+            $retention_method = wpinv_get_option('data_retention_method', 'anonymize');
509
+            if ('anonymize' === $retention_method) {
510
+                $this->anonymize_user_data($user_id);
511
+                $response['messages'][]     = esc_html__('User data has been anonymized due to existing paid invoices.', 'invoicing');
512 512
                 $response['items_removed']  = false;
513 513
                 $response['items_retained'] = true;
514 514
             } else {
515
-                $this->delete_user_data( $user_id );
516
-                $response['messages'][]     = esc_html__( 'User data has been deleted.', 'invoicing' );
515
+                $this->delete_user_data($user_id);
516
+                $response['messages'][]     = esc_html__('User data has been deleted.', 'invoicing');
517 517
                 $response['items_removed']  = true;
518 518
                 $response['items_retained'] = false;
519 519
             }
@@ -529,18 +529,18 @@  discard block
 block discarded – undo
529 529
      * @param string $email The email to hash.
530 530
      * @return string The hashed email.
531 531
      */
532
-    private function hash_email( $email ) {
532
+    private function hash_email($email) {
533 533
         $site_url = get_site_url();
534
-        $domain   = wp_parse_url( $site_url, PHP_URL_HOST );
534
+        $domain   = wp_parse_url($site_url, PHP_URL_HOST);
535 535
 
536
-        if ( empty( $domain ) ) {
536
+        if (empty($domain)) {
537 537
             return $email;
538 538
         }
539 539
 
540
-        $clean_email     = sanitize_email( strtolower( trim( $email ) ) );
541
-        $hash            = wp_hash( $clean_email );
542
-        $hash            = substr( $hash, 0, 20 );
543
-        $anonymized_email = sprintf( '%s@%s', $hash, $domain );
540
+        $clean_email     = sanitize_email(strtolower(trim($email)));
541
+        $hash            = wp_hash($clean_email);
542
+        $hash            = substr($hash, 0, 20);
543
+        $anonymized_email = sprintf('%s@%s', $hash, $domain);
544 544
 
545 545
         /**
546 546
          * Filters the anonymized email before returning.
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
          * @param string $anonymized_email The anonymized email address.
550 550
          * @param string $email            The original email address.
551 551
          */
552
-        return apply_filters( 'wpinv_anonymized_email', $anonymized_email, $email );
552
+        return apply_filters('wpinv_anonymized_email', $anonymized_email, $email);
553 553
     }
554 554
 
555 555
     /**
@@ -559,12 +559,12 @@  discard block
 block discarded – undo
559 559
      * @param string $data The data to anonymize.
560 560
      * @return string The anonymized data.
561 561
      */
562
-    private function anonymize_data( $data ) {
563
-        if ( empty( $data ) ) {
562
+    private function anonymize_data($data) {
563
+        if (empty($data)) {
564 564
             return '';
565 565
         }
566 566
 
567
-        return wp_privacy_anonymize_data( 'text', $data );
567
+        return wp_privacy_anonymize_data('text', $data);
568 568
     }
569 569
 
570 570
     /**
@@ -578,17 +578,17 @@  discard block
 block discarded – undo
578 578
     public function perform_data_retention_cleanup() {
579 579
         global $wpdb;
580 580
 
581
-        $retention_period = wpinv_get_option( 'data_retention_period', '3650' );
581
+        $retention_period = wpinv_get_option('data_retention_period', '3650');
582 582
 
583 583
         // If retention period is set to 'never', exit the function.
584
-        if ( 'never' === $retention_period ) {
584
+        if ('never' === $retention_period) {
585 585
             return;
586 586
         }
587 587
 
588 588
         $customers_table = $wpdb->prefix . 'getpaid_customers';
589 589
 
590 590
         // Calculate the cutoff date for data retention.
591
-        $cutoff_date = gmdate( 'Y-m-d', strtotime( "-$retention_period days" ) );
591
+        $cutoff_date = gmdate('Y-m-d', strtotime("-$retention_period days"));
592 592
 
593 593
         $expired_records = $wpdb->get_results(
594 594
             $wpdb->prepare(
@@ -603,18 +603,18 @@  discard block
 block discarded – undo
603 603
          * @since 2.8.22
604 604
          * @param array $expired_records Array of customer records to be processed.
605 605
          */
606
-        do_action( 'getpaid_data_retention_before_cleanup', $expired_records );
606
+        do_action('getpaid_data_retention_before_cleanup', $expired_records);
607 607
 
608
-        if ( ! empty( $expired_records ) ) {
608
+        if (!empty($expired_records)) {
609 609
             // Disable our custom user deletion handling.
610 610
             $this->handle_user_deletion = false;
611 611
 
612
-            foreach ( $expired_records as $record ) {
612
+            foreach ($expired_records as $record) {
613 613
                 // Delete associated invoices.
614
-                $this->ensure_invoice_anonymization( (int) $record->user_id, 'delete' );
614
+                $this->ensure_invoice_anonymization((int) $record->user_id, 'delete');
615 615
 
616 616
                 // Delete the user.
617
-                wp_delete_user( (int) $record->user_id );
617
+                wp_delete_user((int) $record->user_id);
618 618
 
619 619
                 /**
620 620
                  * Fires after processing each expired record during cleanup.
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
                  * @since 2.8.22
623 623
                  * @param object $record The customer record being processed.
624 624
                  */
625
-                do_action( 'getpaid_data_retention_process_record', $record );
625
+                do_action('getpaid_data_retention_process_record', $record);
626 626
             }
627 627
 
628 628
             // Re-enable our custom user deletion handling.
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
              * @since 2.8.22
635 635
              * @param array $expired_records Array of customer records that were processed.
636 636
              */
637
-            do_action( 'getpaid_data_retention_after_cleanup', $expired_records );
637
+            do_action('getpaid_data_retention_after_cleanup', $expired_records);
638 638
         }
639 639
 
640 640
         /**
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
          * @param int $retention_period The current retention period in years.
645 645
          * @param string $cutoff_date The cutoff date used for identifying expired records.
646 646
          */
647
-        do_action( 'getpaid_data_retention_cleanup_complete', $retention_period, $cutoff_date );
647
+        do_action('getpaid_data_retention_cleanup_complete', $retention_period, $cutoff_date);
648 648
     }
649 649
 
650 650
     /**
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
 
658 658
         // Redirect after deletion.
659 659
         $redirect_page = home_url();
660
-        wp_safe_redirect( $redirect_page );
660
+        wp_safe_redirect($redirect_page);
661 661
         exit();
662 662
     }
663 663
 }
664 664
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wpinv.php 2 patches
Indentation   +616 added lines, -616 removed lines patch added patch discarded remove patch
@@ -14,620 +14,620 @@
 block discarded – undo
14 14
  */
15 15
 class WPInv_Plugin {
16 16
 
17
-	/**
18
-	 * GetPaid version.
19
-	 *
20
-	 * @var string
21
-	 */
22
-	public $version;
23
-
24
-	/**
25
-	 * Data container.
26
-	 *
27
-	 * @var array
28
-	 */
29
-	protected $data = array();
30
-
31
-	/**
32
-	 * Form elements instance.
33
-	 *
34
-	 * @var WPInv_Payment_Form_Elements
35
-	 */
36
-	public $form_elements;
37
-
38
-	/**
39
-	 * @var array An array of payment gateways.
40
-	 */
41
-	public $gateways;
42
-
43
-	/**
44
-	 * Class constructor.
45
-	 */
46
-	public function __construct() {
47
-		$this->define_constants();
48
-		$this->includes();
49
-		$this->init_hooks();
50
-		$this->set_properties();
51
-	}
52
-
53
-	/**
54
-	 * Sets a custom data property.
55
-	 *
56
-	 * @param string $prop The prop to set.
57
-	 * @param mixed $value The value to retrieve.
58
-	 */
59
-	public function set( $prop, $value ) {
60
-		$this->data[ $prop ] = $value;
61
-	}
62
-
63
-	/**
64
-	 * Gets a custom data property.
65
-	 *
66
-	 * @param string $prop The prop to set.
67
-	 * @return mixed The value.
68
-	 */
69
-	public function get( $prop ) {
70
-		if ( isset( $this->data[ $prop ] ) ) {
71
-			return $this->data[ $prop ];
72
-		}
73
-
74
-		return null;
75
-	}
76
-
77
-	/**
78
-	 * Define class properties.
79
-	 */
80
-	public function set_properties() {
81
-		// Sessions.
82
-		$this->set( 'session', new WPInv_Session_Handler() );
83
-		$GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
84
-		$GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility.
85
-
86
-		// Init other objects.
87
-		$this->set( 'notes', new WPInv_Notes() );
88
-		$this->set( 'api', new WPInv_API() );
89
-		$this->set( 'post_types', new GetPaid_Post_Types() );
90
-		$this->set( 'template', new GetPaid_Template() );
91
-		$this->set( 'admin', new GetPaid_Admin() );
92
-		$this->set( 'subscriptions', new WPInv_Subscriptions() );
93
-		$this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
94
-		$this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
95
-		$this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
96
-		$this->set( 'payment_forms', new GetPaid_Payment_Forms() );
97
-		$this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() );
98
-		$this->set( 'data_retention', new WPInv_Data_Retention() );
99
-	}
100
-
101
-	 /**
102
-	 * Define plugin constants.
103
-	 */
104
-	public function define_constants() {
105
-		define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
106
-		define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
107
-		$this->version = WPINV_VERSION;
108
-	}
109
-
110
-	/**
111
-	 * Hook into actions and filters.
112
-	 *
113
-	 * @since 1.0.19
114
-	 */
115
-	protected function init_hooks() {
116
-		/* Internationalize the text strings used. */
117
-		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
118
-
119
-		// Init the plugin after WordPress inits.
120
-		add_action( 'init', array( $this, 'init' ), 1 );
121
-		add_action( 'init', array( $this, 'maybe_process_ipn' ), 100 );
122
-		add_action( 'init', array( $this, 'wpinv_actions' ) );
123
-		add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
124
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
125
-		add_action( 'wp_footer', array( $this, 'wp_footer' ) );
126
-		add_action( 'wp_head', array( $this, 'wp_head' ) );
127
-		add_action( 'widgets_init', array( $this, 'register_widgets' ) );
128
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
129
-		add_filter( 'the_seo_framework_sitemap_supported_post_types', array( $this, 'exclude_invoicing_post_types' ) );
130
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
131
-
132
-		add_filter( 'query_vars', array( $this, 'custom_query_vars' ) );
133
-		add_action( 'init', array( $this, 'add_rewrite_rule' ), 10, 0 );
134
-		add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 );
135
-
136
-		// Fires after registering actions.
137
-		do_action( 'wpinv_actions', $this );
138
-		do_action( 'getpaid_actions', $this );
139
-	}
140
-
141
-	public function plugins_loaded() {
142
-		/* Internationalize the text strings used. */
143
-		$this->load_textdomain();
144
-
145
-		do_action( 'wpinv_loaded' );
146
-
147
-		// Fix oxygen page builder conflict
148
-		if ( function_exists( 'ct_css_output' ) ) {
149
-			wpinv_oxygen_fix_conflict();
150
-		}
151
-	}
152
-
153
-	/**
154
-	 * Load Localisation files.
155
-	 *
156
-	 * Note: the first-loaded translation file overrides any following ones if the same translation is present.
157
-	 *
158
-	 * Locales found in:
159
-	 *      - WP_LANG_DIR/plugins/invoicing-LOCALE.mo
160
-	 *      - WP_PLUGIN_DIR/invoicing/languages/invoicing-LOCALE.mo
161
-	 *
162
-	 * @since 1.0.0
163
-	 */
164
-	public function load_textdomain() {
165
-		// Determines the current locale.
166
-		if ( function_exists( 'determine_locale' ) ) {
167
-			$locale = determine_locale();
168
-		} else if ( function_exists( 'get_user_locale' ) ) {
169
-			$locale = get_user_locale();
170
-		} else {
171
-			$locale = get_locale();
172
-		}
173
-
174
-		/**
175
-		 * Filter the locale to use for translations.
176
-		 */
177
-		$locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
178
-
179
-		unload_textdomain( 'invoicing', true );
180
-		load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
181
-		load_plugin_textdomain( 'invoicing', false, plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/' );
182
-	}
183
-
184
-	/**
185
-	 * Include required core files used in admin and on the frontend.
186
-	 */
187
-	public function includes() {
188
-		// Start with the settings.
189
-		require_once WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php';
190
-
191
-		// Packages/libraries.
192
-		require_once WPINV_PLUGIN_DIR . 'vendor/autoload.php';
193
-		require_once WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php';
194
-
195
-		// Load functions.
196
-		require_once WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php';
197
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php';
198
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php';
199
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php';
200
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php';
201
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php';
202
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php';
203
-		require_once WPINV_PLUGIN_DIR . 'includes/invoice-functions.php';
204
-		require_once WPINV_PLUGIN_DIR . 'includes/subscription-functions.php';
205
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php';
206
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php';
207
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php';
208
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php';
209
-		require_once WPINV_PLUGIN_DIR . 'includes/user-functions.php';
210
-		require_once WPINV_PLUGIN_DIR . 'includes/error-functions.php';
211
-
212
-		// Register autoloader.
213
-		try {
214
-			spl_autoload_register( array( $this, 'autoload' ), true );
215
-		} catch ( Exception $e ) {
216
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
217
-		}
218
-
219
-		require_once WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php';
220
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php';
221
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php';
222
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php';
223
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php';
224
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php';
225
-		require_once WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php';
226
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php';
227
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php';
228
-		require_once WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php';
229
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php';
230
-		require_once WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php';
231
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php';
232
-		require_once WPINV_PLUGIN_DIR . 'widgets/checkout.php';
233
-		require_once WPINV_PLUGIN_DIR . 'widgets/invoice-history.php';
234
-		require_once WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php';
235
-		require_once WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php';
236
-		require_once WPINV_PLUGIN_DIR . 'widgets/subscriptions.php';
237
-		require_once WPINV_PLUGIN_DIR . 'widgets/buy-item.php';
238
-		require_once WPINV_PLUGIN_DIR . 'widgets/getpaid.php';
239
-		require_once WPINV_PLUGIN_DIR . 'widgets/invoice.php';
240
-		require_once WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php';
241
-
242
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
243
-			GetPaid_Post_Types_Admin::init();
244
-
245
-			require_once WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php';
246
-			require_once WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php';
247
-			require_once WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php';
248
-			require_once WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php';
249
-			require_once WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php';
250
-			require_once WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php';
251
-			// load the user class only on the users.php page
252
-			global $pagenow;
253
-			if ( $pagenow == 'users.php' ) {
254
-				new WPInv_Admin_Users();
255
-			}
256
-		}
257
-
258
-		// Register cli commands
259
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
260
-			require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php';
261
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
262
-		}
263
-	}
264
-
265
-	/**
266
-	 * Class autoloader
267
-	 *
268
-	 * @param       string $class_name The name of the class to load.
269
-	 * @access      public
270
-	 * @since       1.0.19
271
-	 * @return      void
272
-	 */
273
-	public function autoload( $class_name ) {
274
-		// Normalize the class name...
275
-		$class_name  = strtolower( $class_name );
276
-
277
-		// ... and make sure it is our class.
278
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
279
-			return;
280
-		}
281
-
282
-		// Next, prepare the file name from the class.
283
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
284
-
285
-		// Base path of the classes.
286
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
287
-
288
-		// And an array of possible locations in order of importance.
289
-		$locations = array(
290
-			"$plugin_path/includes",
291
-			"$plugin_path/includes/data-stores",
292
-			"$plugin_path/includes/gateways",
293
-			"$plugin_path/includes/payments",
294
-			"$plugin_path/includes/geolocation",
295
-			"$plugin_path/includes/reports",
296
-			"$plugin_path/includes/api",
297
-			"$plugin_path/includes/admin",
298
-			"$plugin_path/includes/admin/meta-boxes",
299
-		);
300
-
301
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
302
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
303
-				include trailingslashit( $location ) . $file_name;
304
-				break;
305
-			}
306
-		}
307
-	}
308
-
309
-	/**
310
-	 * Inits hooks etc.
311
-	 */
312
-	public function init() {
313
-		// Fires before getpaid inits.
314
-		do_action( 'before_getpaid_init', $this );
315
-
316
-		// Maybe upgrade.
317
-		$this->maybe_upgrade_database();
318
-
319
-		// Load default gateways.
320
-		$gateways = apply_filters(
321
-			'getpaid_default_gateways',
322
-			array(
323
-				'manual'        => 'GetPaid_Manual_Gateway',
324
-				'paypal'        => 'GetPaid_Paypal_Gateway',
325
-				'worldpay'      => 'GetPaid_Worldpay_Gateway',
326
-				'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
327
-				'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
328
-			)
329
-		);
330
-
331
-		foreach ( $gateways as $id => $class ) {
332
-			$this->gateways[ $id ] = new $class();
333
-		}
334
-
335
-		if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) {
336
-			GetPaid_Installer::rename_gateways_label();
337
-			update_option( 'wpinv_renamed_gateways', 'yes' );
338
-		}
339
-
340
-		// Fires after getpaid inits.
341
-		do_action( 'getpaid_init', $this );
342
-	}
343
-
344
-	/**
345
-	 * Checks if this is an IPN request and processes it.
346
-	 */
347
-	public function maybe_process_ipn() {
348
-		// Ensure that this is an IPN request.
349
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
350
-			return;
351
-		}
352
-
353
-		$gateway = sanitize_text_field( $_GET['wpi-gateway'] );
354
-
355
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
356
-		do_action( "wpinv_verify_{$gateway}_ipn" );
357
-		exit;
358
-	}
359
-
360
-	public function enqueue_scripts() {
361
-		// Fires before adding scripts.
362
-		do_action( 'getpaid_enqueue_scripts' );
363
-
364
-		$localize                         = array();
365
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
366
-		$localize['thousands']            = wpinv_thousands_separator();
367
-		$localize['decimals']             = wpinv_decimal_separator();
368
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
369
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
370
-		$localize['UseTaxes']             = wpinv_use_taxes();
371
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
372
-		$localize['loading']              = __( 'Loading...', 'invoicing' );
373
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
374
-		$localize['recaptchaSettings']    = getpaid_get_recaptcha_settings();
375
-
376
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
377
-
378
-		// reCaptcha.
379
-		if ( getpaid_is_recaptcha_enabled() && ( $recaptcha_js = getpaid_recaptcha_api_url() ) ) {
380
-			wp_enqueue_script( 'recaptcha', $recaptcha_js, array(), null, true ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
381
-		}
382
-
383
-		wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.min.js', array( 'jquery' ), WPINV_VERSION, true );
384
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
385
-	}
386
-
387
-	public function wpinv_actions() {
388
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
389
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
390
-		}
391
-
392
-		if ( defined( 'WP_ALL_IMPORT_ROOT_DIR' ) ) {
393
-			include plugin_dir_path( __FILE__ ) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php';
394
-		}
395
-	}
396
-
397
-	/**
398
-	 * Fires an action after verifying that a user can fire them.
399
-	 *
400
-	 * Note: If the action is on an invoice, subscription etc, esure that the
401
-	 * current user owns the invoice/subscription.
402
-	 */
403
-	public function maybe_do_authenticated_action() {
404
-		if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
405
-			$key  = sanitize_key( $_REQUEST['getpaid-action'] );
406
-			$data = wp_unslash( $_REQUEST );
407
-
408
-			if ( is_user_logged_in() ) {
409
-				do_action( "getpaid_authenticated_action_$key", $data );
410
-			}
411
-
412
-			do_action( "getpaid_unauthenticated_action_$key", $data );
413
-		}
414
-	}
415
-
416
-	public function pre_get_posts( $wp_query ) {
417
-		if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
418
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
419
-		}
420
-
421
-		return $wp_query;
422
-	}
423
-
424
-	/**
425
-	 * Register widgets
426
-	 *
427
-	 */
428
-	public function register_widgets() {
429
-		global $pagenow;
430
-
431
-		// Currently, UX Builder does not work particulaly well with SuperDuper.
432
-		// So we disable our widgets when editing a page with UX Builder.
433
-		if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) {
434
-			return;
435
-		}
436
-
437
-		$block_widget_init_screens = function_exists( 'sd_pagenow_exclude' ) ? sd_pagenow_exclude() : array();
438
-
439
-		if ( is_admin() && $pagenow && in_array( $pagenow, $block_widget_init_screens ) ) {
440
-			// don't initiate in these conditions.
441
-		} else {
442
-			// Only load allowed widgets.
443
-			$exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array();
444
-			$widgets = apply_filters(
445
-				'getpaid_widget_classes',
446
-				array(
447
-					'WPInv_Checkout_Widget',
448
-					'WPInv_History_Widget',
449
-					'WPInv_Receipt_Widget',
450
-					'WPInv_Subscriptions_Widget',
451
-					'WPInv_Buy_Item_Widget',
452
-					'WPInv_Messages_Widget',
453
-					'WPInv_GetPaid_Widget',
454
-					'WPInv_Invoice_Widget',
455
-				)
456
-			);
457
-
458
-			// For each widget...
459
-			foreach ( $widgets as $widget ) {
460
-				// Abort early if it is excluded for this page.
461
-				if ( in_array( $widget, $exclude ) ) {
462
-					continue;
463
-				}
464
-
465
-				// SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it.
466
-				if ( is_subclass_of( $widget, 'WP_Widget' ) ) {
467
-					register_widget( $widget );
468
-				} else {
469
-					new $widget();
470
-				}
471
-			}
472
-		}
473
-	}
474
-
475
-	/**
476
-	 * Upgrades the database.
477
-	 *
478
-	 * @since 2.0.2
479
-	 */
480
-	public function maybe_upgrade_database() {
481
-		// Ensure the database tables are up to date.
482
-		GetPaid_Installer::maybe_create_db_tables();
483
-
484
-		$wpi_version = get_option( 'wpinv_version', 0 );
485
-
486
-		if ( $wpi_version == WPINV_VERSION ) {
487
-			return;
488
-		}
489
-
490
-		$installer = new GetPaid_Installer();
491
-
492
-		if ( empty( $wpi_version ) ) {
493
-			return $installer->upgrade_db( 0 );
494
-		}
495
-
496
-		$upgrades  = array(
497
-			'0.0.5' => '004',
498
-			'1.0.3' => '102',
499
-			'2.0.0' => '118',
500
-			'2.8.0' => '279',
501
-		);
502
-
503
-		foreach ( $upgrades as $key => $method ) {
504
-			if ( version_compare( $wpi_version, $key, '<' ) ) {
505
-				return $installer->upgrade_db( $method );
506
-			}
507
-		}
508
-	}
509
-
510
-	/**
511
-	 * Flushes the permalinks if needed.
512
-	 *
513
-	 * @since 2.0.8
514
-	 */
515
-	public function maybe_flush_permalinks() {
516
-		$flush = get_option( 'wpinv_flush_permalinks', 0 );
517
-
518
-		if ( ! empty( $flush ) ) {
519
-			flush_rewrite_rules();
520
-			delete_option( 'wpinv_flush_permalinks' );
521
-		}
522
-	}
523
-
524
-	/**
525
-	 * Remove our pages from yoast sitemaps.
526
-	 *
527
-	 * @since 1.0.19
528
-	 * @param int[] $excluded_posts_ids
529
-	 */
530
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ) {
531
-		// Ensure that we have an array.
532
-		if ( ! is_array( $excluded_posts_ids ) ) {
533
-			$excluded_posts_ids = array();
534
-		}
535
-
536
-		// Prepare our pages.
537
-		$our_pages = array();
538
-
539
-		// Checkout page.
540
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
541
-
542
-		// Success page.
543
-		$our_pages[] = wpinv_get_option( 'success_page', false );
544
-
545
-		// Failure page.
546
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
547
-
548
-		// History page.
549
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
550
-
551
-		// Subscriptions page.
552
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
553
-
554
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
555
-
556
-		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
557
-
558
-		return array_unique( $excluded_posts_ids );
559
-	}
560
-
561
-	/**
562
-	 * Remove our pages from yoast sitemaps.
563
-	 *
564
-	 * @since 1.0.19
565
-	 * @param string[] $post_types
566
-	 */
567
-	public function exclude_invoicing_post_types( $post_types ) {
568
-		// Ensure that we have an array.
569
-		if ( ! is_array( $post_types ) ) {
570
-			$post_types = array();
571
-		}
572
-
573
-		// Remove our post types.
574
-		return array_diff( $post_types, array_keys( getpaid_get_invoice_post_types() ) );
575
-	}
576
-
577
-	/**
578
-	 * Displays additional footer code.
579
-	 *
580
-	 * @since 2.0.0
581
-	 */
582
-	public function wp_footer() {
583
-		wpinv_get_template( 'frontend-footer.php' );
584
-	}
585
-
586
-	/**
587
-	 * Displays additional header code.
588
-	 *
589
-	 * @since 2.0.0
590
-	 */
591
-	public function wp_head() {
592
-		wpinv_get_template( 'frontend-head.php' );
593
-	}
594
-
595
-	/**
596
-	 * Custom query vars.
597
-	 *
598
-	 */
599
-	public function custom_query_vars( $vars ) {
600
-		$vars[] = 'getpaid-ipn';
601
-		return $vars;
602
-	}
603
-
604
-	/**
605
-	 * Add rewrite tags and rules.
606
-	 *
607
-	 */
608
-	public function add_rewrite_rule() {
609
-		$tag = 'getpaid-ipn';
610
-		add_rewrite_tag( "%$tag%", '([^&]+)' );
611
-		add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top' );
612
-	}
613
-
614
-	/**
615
-	 * Processes non-query string ipns.
616
-	 *
617
-	 */
618
-	public function maybe_process_new_ipn( $query ) {
619
-		if ( is_admin() || ! $query->is_main_query() ) {
620
-			return;
621
-		}
622
-
623
-		$gateway = get_query_var( 'getpaid-ipn' );
624
-
625
-		if ( ! empty( $gateway ) ) {
626
-			$gateway = sanitize_text_field( $gateway );
627
-			nocache_headers();
628
-			do_action( 'wpinv_verify_payment_ipn', $gateway );
629
-			do_action( "wpinv_verify_{$gateway}_ipn" );
630
-			exit;
631
-		}
632
-	}
17
+    /**
18
+     * GetPaid version.
19
+     *
20
+     * @var string
21
+     */
22
+    public $version;
23
+
24
+    /**
25
+     * Data container.
26
+     *
27
+     * @var array
28
+     */
29
+    protected $data = array();
30
+
31
+    /**
32
+     * Form elements instance.
33
+     *
34
+     * @var WPInv_Payment_Form_Elements
35
+     */
36
+    public $form_elements;
37
+
38
+    /**
39
+     * @var array An array of payment gateways.
40
+     */
41
+    public $gateways;
42
+
43
+    /**
44
+     * Class constructor.
45
+     */
46
+    public function __construct() {
47
+        $this->define_constants();
48
+        $this->includes();
49
+        $this->init_hooks();
50
+        $this->set_properties();
51
+    }
52
+
53
+    /**
54
+     * Sets a custom data property.
55
+     *
56
+     * @param string $prop The prop to set.
57
+     * @param mixed $value The value to retrieve.
58
+     */
59
+    public function set( $prop, $value ) {
60
+        $this->data[ $prop ] = $value;
61
+    }
62
+
63
+    /**
64
+     * Gets a custom data property.
65
+     *
66
+     * @param string $prop The prop to set.
67
+     * @return mixed The value.
68
+     */
69
+    public function get( $prop ) {
70
+        if ( isset( $this->data[ $prop ] ) ) {
71
+            return $this->data[ $prop ];
72
+        }
73
+
74
+        return null;
75
+    }
76
+
77
+    /**
78
+     * Define class properties.
79
+     */
80
+    public function set_properties() {
81
+        // Sessions.
82
+        $this->set( 'session', new WPInv_Session_Handler() );
83
+        $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
84
+        $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility.
85
+
86
+        // Init other objects.
87
+        $this->set( 'notes', new WPInv_Notes() );
88
+        $this->set( 'api', new WPInv_API() );
89
+        $this->set( 'post_types', new GetPaid_Post_Types() );
90
+        $this->set( 'template', new GetPaid_Template() );
91
+        $this->set( 'admin', new GetPaid_Admin() );
92
+        $this->set( 'subscriptions', new WPInv_Subscriptions() );
93
+        $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
94
+        $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
95
+        $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
96
+        $this->set( 'payment_forms', new GetPaid_Payment_Forms() );
97
+        $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() );
98
+        $this->set( 'data_retention', new WPInv_Data_Retention() );
99
+    }
100
+
101
+        /**
102
+         * Define plugin constants.
103
+         */
104
+    public function define_constants() {
105
+        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
106
+        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
107
+        $this->version = WPINV_VERSION;
108
+    }
109
+
110
+    /**
111
+     * Hook into actions and filters.
112
+     *
113
+     * @since 1.0.19
114
+     */
115
+    protected function init_hooks() {
116
+        /* Internationalize the text strings used. */
117
+        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
118
+
119
+        // Init the plugin after WordPress inits.
120
+        add_action( 'init', array( $this, 'init' ), 1 );
121
+        add_action( 'init', array( $this, 'maybe_process_ipn' ), 100 );
122
+        add_action( 'init', array( $this, 'wpinv_actions' ) );
123
+        add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
124
+        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
125
+        add_action( 'wp_footer', array( $this, 'wp_footer' ) );
126
+        add_action( 'wp_head', array( $this, 'wp_head' ) );
127
+        add_action( 'widgets_init', array( $this, 'register_widgets' ) );
128
+        add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
129
+        add_filter( 'the_seo_framework_sitemap_supported_post_types', array( $this, 'exclude_invoicing_post_types' ) );
130
+        add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
131
+
132
+        add_filter( 'query_vars', array( $this, 'custom_query_vars' ) );
133
+        add_action( 'init', array( $this, 'add_rewrite_rule' ), 10, 0 );
134
+        add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 );
135
+
136
+        // Fires after registering actions.
137
+        do_action( 'wpinv_actions', $this );
138
+        do_action( 'getpaid_actions', $this );
139
+    }
140
+
141
+    public function plugins_loaded() {
142
+        /* Internationalize the text strings used. */
143
+        $this->load_textdomain();
144
+
145
+        do_action( 'wpinv_loaded' );
146
+
147
+        // Fix oxygen page builder conflict
148
+        if ( function_exists( 'ct_css_output' ) ) {
149
+            wpinv_oxygen_fix_conflict();
150
+        }
151
+    }
152
+
153
+    /**
154
+     * Load Localisation files.
155
+     *
156
+     * Note: the first-loaded translation file overrides any following ones if the same translation is present.
157
+     *
158
+     * Locales found in:
159
+     *      - WP_LANG_DIR/plugins/invoicing-LOCALE.mo
160
+     *      - WP_PLUGIN_DIR/invoicing/languages/invoicing-LOCALE.mo
161
+     *
162
+     * @since 1.0.0
163
+     */
164
+    public function load_textdomain() {
165
+        // Determines the current locale.
166
+        if ( function_exists( 'determine_locale' ) ) {
167
+            $locale = determine_locale();
168
+        } else if ( function_exists( 'get_user_locale' ) ) {
169
+            $locale = get_user_locale();
170
+        } else {
171
+            $locale = get_locale();
172
+        }
173
+
174
+        /**
175
+         * Filter the locale to use for translations.
176
+         */
177
+        $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
178
+
179
+        unload_textdomain( 'invoicing', true );
180
+        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
181
+        load_plugin_textdomain( 'invoicing', false, plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/' );
182
+    }
183
+
184
+    /**
185
+     * Include required core files used in admin and on the frontend.
186
+     */
187
+    public function includes() {
188
+        // Start with the settings.
189
+        require_once WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php';
190
+
191
+        // Packages/libraries.
192
+        require_once WPINV_PLUGIN_DIR . 'vendor/autoload.php';
193
+        require_once WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php';
194
+
195
+        // Load functions.
196
+        require_once WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php';
197
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php';
198
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php';
199
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php';
200
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php';
201
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php';
202
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php';
203
+        require_once WPINV_PLUGIN_DIR . 'includes/invoice-functions.php';
204
+        require_once WPINV_PLUGIN_DIR . 'includes/subscription-functions.php';
205
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php';
206
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php';
207
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php';
208
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php';
209
+        require_once WPINV_PLUGIN_DIR . 'includes/user-functions.php';
210
+        require_once WPINV_PLUGIN_DIR . 'includes/error-functions.php';
211
+
212
+        // Register autoloader.
213
+        try {
214
+            spl_autoload_register( array( $this, 'autoload' ), true );
215
+        } catch ( Exception $e ) {
216
+            wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
217
+        }
218
+
219
+        require_once WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php';
220
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php';
221
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php';
222
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php';
223
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php';
224
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php';
225
+        require_once WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php';
226
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php';
227
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php';
228
+        require_once WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php';
229
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php';
230
+        require_once WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php';
231
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php';
232
+        require_once WPINV_PLUGIN_DIR . 'widgets/checkout.php';
233
+        require_once WPINV_PLUGIN_DIR . 'widgets/invoice-history.php';
234
+        require_once WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php';
235
+        require_once WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php';
236
+        require_once WPINV_PLUGIN_DIR . 'widgets/subscriptions.php';
237
+        require_once WPINV_PLUGIN_DIR . 'widgets/buy-item.php';
238
+        require_once WPINV_PLUGIN_DIR . 'widgets/getpaid.php';
239
+        require_once WPINV_PLUGIN_DIR . 'widgets/invoice.php';
240
+        require_once WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php';
241
+
242
+        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
243
+            GetPaid_Post_Types_Admin::init();
244
+
245
+            require_once WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php';
246
+            require_once WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php';
247
+            require_once WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php';
248
+            require_once WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php';
249
+            require_once WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php';
250
+            require_once WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php';
251
+            // load the user class only on the users.php page
252
+            global $pagenow;
253
+            if ( $pagenow == 'users.php' ) {
254
+                new WPInv_Admin_Users();
255
+            }
256
+        }
257
+
258
+        // Register cli commands
259
+        if ( defined( 'WP_CLI' ) && WP_CLI ) {
260
+            require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php';
261
+            WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
262
+        }
263
+    }
264
+
265
+    /**
266
+     * Class autoloader
267
+     *
268
+     * @param       string $class_name The name of the class to load.
269
+     * @access      public
270
+     * @since       1.0.19
271
+     * @return      void
272
+     */
273
+    public function autoload( $class_name ) {
274
+        // Normalize the class name...
275
+        $class_name  = strtolower( $class_name );
276
+
277
+        // ... and make sure it is our class.
278
+        if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
279
+            return;
280
+        }
281
+
282
+        // Next, prepare the file name from the class.
283
+        $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
284
+
285
+        // Base path of the classes.
286
+        $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
287
+
288
+        // And an array of possible locations in order of importance.
289
+        $locations = array(
290
+            "$plugin_path/includes",
291
+            "$plugin_path/includes/data-stores",
292
+            "$plugin_path/includes/gateways",
293
+            "$plugin_path/includes/payments",
294
+            "$plugin_path/includes/geolocation",
295
+            "$plugin_path/includes/reports",
296
+            "$plugin_path/includes/api",
297
+            "$plugin_path/includes/admin",
298
+            "$plugin_path/includes/admin/meta-boxes",
299
+        );
300
+
301
+        foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
302
+            if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
303
+                include trailingslashit( $location ) . $file_name;
304
+                break;
305
+            }
306
+        }
307
+    }
308
+
309
+    /**
310
+     * Inits hooks etc.
311
+     */
312
+    public function init() {
313
+        // Fires before getpaid inits.
314
+        do_action( 'before_getpaid_init', $this );
315
+
316
+        // Maybe upgrade.
317
+        $this->maybe_upgrade_database();
318
+
319
+        // Load default gateways.
320
+        $gateways = apply_filters(
321
+            'getpaid_default_gateways',
322
+            array(
323
+                'manual'        => 'GetPaid_Manual_Gateway',
324
+                'paypal'        => 'GetPaid_Paypal_Gateway',
325
+                'worldpay'      => 'GetPaid_Worldpay_Gateway',
326
+                'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
327
+                'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
328
+            )
329
+        );
330
+
331
+        foreach ( $gateways as $id => $class ) {
332
+            $this->gateways[ $id ] = new $class();
333
+        }
334
+
335
+        if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) {
336
+            GetPaid_Installer::rename_gateways_label();
337
+            update_option( 'wpinv_renamed_gateways', 'yes' );
338
+        }
339
+
340
+        // Fires after getpaid inits.
341
+        do_action( 'getpaid_init', $this );
342
+    }
343
+
344
+    /**
345
+     * Checks if this is an IPN request and processes it.
346
+     */
347
+    public function maybe_process_ipn() {
348
+        // Ensure that this is an IPN request.
349
+        if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
350
+            return;
351
+        }
352
+
353
+        $gateway = sanitize_text_field( $_GET['wpi-gateway'] );
354
+
355
+        do_action( 'wpinv_verify_payment_ipn', $gateway );
356
+        do_action( "wpinv_verify_{$gateway}_ipn" );
357
+        exit;
358
+    }
359
+
360
+    public function enqueue_scripts() {
361
+        // Fires before adding scripts.
362
+        do_action( 'getpaid_enqueue_scripts' );
363
+
364
+        $localize                         = array();
365
+        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
366
+        $localize['thousands']            = wpinv_thousands_separator();
367
+        $localize['decimals']             = wpinv_decimal_separator();
368
+        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
369
+        $localize['txtComplete']          = __( 'Continue', 'invoicing' );
370
+        $localize['UseTaxes']             = wpinv_use_taxes();
371
+        $localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
372
+        $localize['loading']              = __( 'Loading...', 'invoicing' );
373
+        $localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
374
+        $localize['recaptchaSettings']    = getpaid_get_recaptcha_settings();
375
+
376
+        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
377
+
378
+        // reCaptcha.
379
+        if ( getpaid_is_recaptcha_enabled() && ( $recaptcha_js = getpaid_recaptcha_api_url() ) ) {
380
+            wp_enqueue_script( 'recaptcha', $recaptcha_js, array(), null, true ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
381
+        }
382
+
383
+        wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.min.js', array( 'jquery' ), WPINV_VERSION, true );
384
+        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
385
+    }
386
+
387
+    public function wpinv_actions() {
388
+        if ( isset( $_REQUEST['wpi_action'] ) ) {
389
+            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
390
+        }
391
+
392
+        if ( defined( 'WP_ALL_IMPORT_ROOT_DIR' ) ) {
393
+            include plugin_dir_path( __FILE__ ) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php';
394
+        }
395
+    }
396
+
397
+    /**
398
+     * Fires an action after verifying that a user can fire them.
399
+     *
400
+     * Note: If the action is on an invoice, subscription etc, esure that the
401
+     * current user owns the invoice/subscription.
402
+     */
403
+    public function maybe_do_authenticated_action() {
404
+        if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
405
+            $key  = sanitize_key( $_REQUEST['getpaid-action'] );
406
+            $data = wp_unslash( $_REQUEST );
407
+
408
+            if ( is_user_logged_in() ) {
409
+                do_action( "getpaid_authenticated_action_$key", $data );
410
+            }
411
+
412
+            do_action( "getpaid_unauthenticated_action_$key", $data );
413
+        }
414
+    }
415
+
416
+    public function pre_get_posts( $wp_query ) {
417
+        if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
418
+            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
419
+        }
420
+
421
+        return $wp_query;
422
+    }
423
+
424
+    /**
425
+     * Register widgets
426
+     *
427
+     */
428
+    public function register_widgets() {
429
+        global $pagenow;
430
+
431
+        // Currently, UX Builder does not work particulaly well with SuperDuper.
432
+        // So we disable our widgets when editing a page with UX Builder.
433
+        if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) {
434
+            return;
435
+        }
436
+
437
+        $block_widget_init_screens = function_exists( 'sd_pagenow_exclude' ) ? sd_pagenow_exclude() : array();
438
+
439
+        if ( is_admin() && $pagenow && in_array( $pagenow, $block_widget_init_screens ) ) {
440
+            // don't initiate in these conditions.
441
+        } else {
442
+            // Only load allowed widgets.
443
+            $exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array();
444
+            $widgets = apply_filters(
445
+                'getpaid_widget_classes',
446
+                array(
447
+                    'WPInv_Checkout_Widget',
448
+                    'WPInv_History_Widget',
449
+                    'WPInv_Receipt_Widget',
450
+                    'WPInv_Subscriptions_Widget',
451
+                    'WPInv_Buy_Item_Widget',
452
+                    'WPInv_Messages_Widget',
453
+                    'WPInv_GetPaid_Widget',
454
+                    'WPInv_Invoice_Widget',
455
+                )
456
+            );
457
+
458
+            // For each widget...
459
+            foreach ( $widgets as $widget ) {
460
+                // Abort early if it is excluded for this page.
461
+                if ( in_array( $widget, $exclude ) ) {
462
+                    continue;
463
+                }
464
+
465
+                // SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it.
466
+                if ( is_subclass_of( $widget, 'WP_Widget' ) ) {
467
+                    register_widget( $widget );
468
+                } else {
469
+                    new $widget();
470
+                }
471
+            }
472
+        }
473
+    }
474
+
475
+    /**
476
+     * Upgrades the database.
477
+     *
478
+     * @since 2.0.2
479
+     */
480
+    public function maybe_upgrade_database() {
481
+        // Ensure the database tables are up to date.
482
+        GetPaid_Installer::maybe_create_db_tables();
483
+
484
+        $wpi_version = get_option( 'wpinv_version', 0 );
485
+
486
+        if ( $wpi_version == WPINV_VERSION ) {
487
+            return;
488
+        }
489
+
490
+        $installer = new GetPaid_Installer();
491
+
492
+        if ( empty( $wpi_version ) ) {
493
+            return $installer->upgrade_db( 0 );
494
+        }
495
+
496
+        $upgrades  = array(
497
+            '0.0.5' => '004',
498
+            '1.0.3' => '102',
499
+            '2.0.0' => '118',
500
+            '2.8.0' => '279',
501
+        );
502
+
503
+        foreach ( $upgrades as $key => $method ) {
504
+            if ( version_compare( $wpi_version, $key, '<' ) ) {
505
+                return $installer->upgrade_db( $method );
506
+            }
507
+        }
508
+    }
509
+
510
+    /**
511
+     * Flushes the permalinks if needed.
512
+     *
513
+     * @since 2.0.8
514
+     */
515
+    public function maybe_flush_permalinks() {
516
+        $flush = get_option( 'wpinv_flush_permalinks', 0 );
517
+
518
+        if ( ! empty( $flush ) ) {
519
+            flush_rewrite_rules();
520
+            delete_option( 'wpinv_flush_permalinks' );
521
+        }
522
+    }
523
+
524
+    /**
525
+     * Remove our pages from yoast sitemaps.
526
+     *
527
+     * @since 1.0.19
528
+     * @param int[] $excluded_posts_ids
529
+     */
530
+    public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ) {
531
+        // Ensure that we have an array.
532
+        if ( ! is_array( $excluded_posts_ids ) ) {
533
+            $excluded_posts_ids = array();
534
+        }
535
+
536
+        // Prepare our pages.
537
+        $our_pages = array();
538
+
539
+        // Checkout page.
540
+        $our_pages[] = wpinv_get_option( 'checkout_page', false );
541
+
542
+        // Success page.
543
+        $our_pages[] = wpinv_get_option( 'success_page', false );
544
+
545
+        // Failure page.
546
+        $our_pages[] = wpinv_get_option( 'failure_page', false );
547
+
548
+        // History page.
549
+        $our_pages[] = wpinv_get_option( 'invoice_history_page', false );
550
+
551
+        // Subscriptions page.
552
+        $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
553
+
554
+        $our_pages   = array_map( 'intval', array_filter( $our_pages ) );
555
+
556
+        $excluded_posts_ids = $excluded_posts_ids + $our_pages;
557
+
558
+        return array_unique( $excluded_posts_ids );
559
+    }
560
+
561
+    /**
562
+     * Remove our pages from yoast sitemaps.
563
+     *
564
+     * @since 1.0.19
565
+     * @param string[] $post_types
566
+     */
567
+    public function exclude_invoicing_post_types( $post_types ) {
568
+        // Ensure that we have an array.
569
+        if ( ! is_array( $post_types ) ) {
570
+            $post_types = array();
571
+        }
572
+
573
+        // Remove our post types.
574
+        return array_diff( $post_types, array_keys( getpaid_get_invoice_post_types() ) );
575
+    }
576
+
577
+    /**
578
+     * Displays additional footer code.
579
+     *
580
+     * @since 2.0.0
581
+     */
582
+    public function wp_footer() {
583
+        wpinv_get_template( 'frontend-footer.php' );
584
+    }
585
+
586
+    /**
587
+     * Displays additional header code.
588
+     *
589
+     * @since 2.0.0
590
+     */
591
+    public function wp_head() {
592
+        wpinv_get_template( 'frontend-head.php' );
593
+    }
594
+
595
+    /**
596
+     * Custom query vars.
597
+     *
598
+     */
599
+    public function custom_query_vars( $vars ) {
600
+        $vars[] = 'getpaid-ipn';
601
+        return $vars;
602
+    }
603
+
604
+    /**
605
+     * Add rewrite tags and rules.
606
+     *
607
+     */
608
+    public function add_rewrite_rule() {
609
+        $tag = 'getpaid-ipn';
610
+        add_rewrite_tag( "%$tag%", '([^&]+)' );
611
+        add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top' );
612
+    }
613
+
614
+    /**
615
+     * Processes non-query string ipns.
616
+     *
617
+     */
618
+    public function maybe_process_new_ipn( $query ) {
619
+        if ( is_admin() || ! $query->is_main_query() ) {
620
+            return;
621
+        }
622
+
623
+        $gateway = get_query_var( 'getpaid-ipn' );
624
+
625
+        if ( ! empty( $gateway ) ) {
626
+            $gateway = sanitize_text_field( $gateway );
627
+            nocache_headers();
628
+            do_action( 'wpinv_verify_payment_ipn', $gateway );
629
+            do_action( "wpinv_verify_{$gateway}_ipn" );
630
+            exit;
631
+        }
632
+    }
633 633
 }
Please login to merge, or discard this patch.
Spacing   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @since   1.0.0
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Main Invoicing class.
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	 * @param string $prop The prop to set.
57 57
 	 * @param mixed $value The value to retrieve.
58 58
 	 */
59
-	public function set( $prop, $value ) {
60
-		$this->data[ $prop ] = $value;
59
+	public function set($prop, $value) {
60
+		$this->data[$prop] = $value;
61 61
 	}
62 62
 
63 63
 	/**
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 	 * @param string $prop The prop to set.
67 67
 	 * @return mixed The value.
68 68
 	 */
69
-	public function get( $prop ) {
70
-		if ( isset( $this->data[ $prop ] ) ) {
71
-			return $this->data[ $prop ];
69
+	public function get($prop) {
70
+		if (isset($this->data[$prop])) {
71
+			return $this->data[$prop];
72 72
 		}
73 73
 
74 74
 		return null;
@@ -79,31 +79,31 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	public function set_properties() {
81 81
 		// Sessions.
82
-		$this->set( 'session', new WPInv_Session_Handler() );
83
-		$GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
82
+		$this->set('session', new WPInv_Session_Handler());
83
+		$GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility.
84 84
 		$GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility.
85 85
 
86 86
 		// Init other objects.
87
-		$this->set( 'notes', new WPInv_Notes() );
88
-		$this->set( 'api', new WPInv_API() );
89
-		$this->set( 'post_types', new GetPaid_Post_Types() );
90
-		$this->set( 'template', new GetPaid_Template() );
91
-		$this->set( 'admin', new GetPaid_Admin() );
92
-		$this->set( 'subscriptions', new WPInv_Subscriptions() );
93
-		$this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
94
-		$this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
95
-		$this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
96
-		$this->set( 'payment_forms', new GetPaid_Payment_Forms() );
97
-		$this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() );
98
-		$this->set( 'data_retention', new WPInv_Data_Retention() );
87
+		$this->set('notes', new WPInv_Notes());
88
+		$this->set('api', new WPInv_API());
89
+		$this->set('post_types', new GetPaid_Post_Types());
90
+		$this->set('template', new GetPaid_Template());
91
+		$this->set('admin', new GetPaid_Admin());
92
+		$this->set('subscriptions', new WPInv_Subscriptions());
93
+		$this->set('invoice_emails', new GetPaid_Invoice_Notification_Emails());
94
+		$this->set('subscription_emails', new GetPaid_Subscription_Notification_Emails());
95
+		$this->set('daily_maintenace', new GetPaid_Daily_Maintenance());
96
+		$this->set('payment_forms', new GetPaid_Payment_Forms());
97
+		$this->set('maxmind', new GetPaid_MaxMind_Geolocation());
98
+		$this->set('data_retention', new WPInv_Data_Retention());
99 99
 	}
100 100
 
101 101
 	 /**
102 102
 	 * Define plugin constants.
103 103
 	 */
104 104
 	public function define_constants() {
105
-		define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
106
-		define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
105
+		define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
106
+		define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
107 107
 		$this->version = WPINV_VERSION;
108 108
 	}
109 109
 
@@ -114,38 +114,38 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	protected function init_hooks() {
116 116
 		/* Internationalize the text strings used. */
117
-		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
117
+		add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
118 118
 
119 119
 		// Init the plugin after WordPress inits.
120
-		add_action( 'init', array( $this, 'init' ), 1 );
121
-		add_action( 'init', array( $this, 'maybe_process_ipn' ), 100 );
122
-		add_action( 'init', array( $this, 'wpinv_actions' ) );
123
-		add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
124
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
125
-		add_action( 'wp_footer', array( $this, 'wp_footer' ) );
126
-		add_action( 'wp_head', array( $this, 'wp_head' ) );
127
-		add_action( 'widgets_init', array( $this, 'register_widgets' ) );
128
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
129
-		add_filter( 'the_seo_framework_sitemap_supported_post_types', array( $this, 'exclude_invoicing_post_types' ) );
130
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
131
-
132
-		add_filter( 'query_vars', array( $this, 'custom_query_vars' ) );
133
-		add_action( 'init', array( $this, 'add_rewrite_rule' ), 10, 0 );
134
-		add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 );
120
+		add_action('init', array($this, 'init'), 1);
121
+		add_action('init', array($this, 'maybe_process_ipn'), 100);
122
+		add_action('init', array($this, 'wpinv_actions'));
123
+		add_action('init', array($this, 'maybe_do_authenticated_action'), 100);
124
+		add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 11);
125
+		add_action('wp_footer', array($this, 'wp_footer'));
126
+		add_action('wp_head', array($this, 'wp_head'));
127
+		add_action('widgets_init', array($this, 'register_widgets'));
128
+		add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids'));
129
+		add_filter('the_seo_framework_sitemap_supported_post_types', array($this, 'exclude_invoicing_post_types'));
130
+		add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
131
+
132
+		add_filter('query_vars', array($this, 'custom_query_vars'));
133
+		add_action('init', array($this, 'add_rewrite_rule'), 10, 0);
134
+		add_action('pre_get_posts', array($this, 'maybe_process_new_ipn'), 1);
135 135
 
136 136
 		// Fires after registering actions.
137
-		do_action( 'wpinv_actions', $this );
138
-		do_action( 'getpaid_actions', $this );
137
+		do_action('wpinv_actions', $this);
138
+		do_action('getpaid_actions', $this);
139 139
 	}
140 140
 
141 141
 	public function plugins_loaded() {
142 142
 		/* Internationalize the text strings used. */
143 143
 		$this->load_textdomain();
144 144
 
145
-		do_action( 'wpinv_loaded' );
145
+		do_action('wpinv_loaded');
146 146
 
147 147
 		// Fix oxygen page builder conflict
148
-		if ( function_exists( 'ct_css_output' ) ) {
148
+		if (function_exists('ct_css_output')) {
149 149
 			wpinv_oxygen_fix_conflict();
150 150
 		}
151 151
 	}
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
 	 */
164 164
 	public function load_textdomain() {
165 165
 		// Determines the current locale.
166
-		if ( function_exists( 'determine_locale' ) ) {
166
+		if (function_exists('determine_locale')) {
167 167
 			$locale = determine_locale();
168
-		} else if ( function_exists( 'get_user_locale' ) ) {
168
+		} else if (function_exists('get_user_locale')) {
169 169
 			$locale = get_user_locale();
170 170
 		} else {
171 171
 			$locale = get_locale();
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
 		/**
175 175
 		 * Filter the locale to use for translations.
176 176
 		 */
177
-		$locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
177
+		$locale = apply_filters('plugin_locale', $locale, 'invoicing');
178 178
 
179
-		unload_textdomain( 'invoicing', true );
180
-		load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
181
-		load_plugin_textdomain( 'invoicing', false, plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/' );
179
+		unload_textdomain('invoicing', true);
180
+		load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
181
+		load_plugin_textdomain('invoicing', false, plugin_basename(dirname(WPINV_PLUGIN_FILE)) . '/languages/');
182 182
 	}
183 183
 
184 184
 	/**
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
 
212 212
 		// Register autoloader.
213 213
 		try {
214
-			spl_autoload_register( array( $this, 'autoload' ), true );
215
-		} catch ( Exception $e ) {
216
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
214
+			spl_autoload_register(array($this, 'autoload'), true);
215
+		} catch (Exception $e) {
216
+			wpinv_error_log($e->getMessage(), '', __FILE__, 149, true);
217 217
 		}
218 218
 
219 219
 		require_once WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php';
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 		require_once WPINV_PLUGIN_DIR . 'widgets/invoice.php';
240 240
 		require_once WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php';
241 241
 
242
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
242
+		if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
243 243
 			GetPaid_Post_Types_Admin::init();
244 244
 
245 245
 			require_once WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php';
@@ -250,15 +250,15 @@  discard block
 block discarded – undo
250 250
 			require_once WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php';
251 251
 			// load the user class only on the users.php page
252 252
 			global $pagenow;
253
-			if ( $pagenow == 'users.php' ) {
253
+			if ($pagenow == 'users.php') {
254 254
 				new WPInv_Admin_Users();
255 255
 			}
256 256
 		}
257 257
 
258 258
 		// Register cli commands
259
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
259
+		if (defined('WP_CLI') && WP_CLI) {
260 260
 			require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php';
261
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
261
+			WP_CLI::add_command('invoicing', 'WPInv_CLI');
262 262
 		}
263 263
 	}
264 264
 
@@ -270,20 +270,20 @@  discard block
 block discarded – undo
270 270
 	 * @since       1.0.19
271 271
 	 * @return      void
272 272
 	 */
273
-	public function autoload( $class_name ) {
273
+	public function autoload($class_name) {
274 274
 		// Normalize the class name...
275
-		$class_name  = strtolower( $class_name );
275
+		$class_name = strtolower($class_name);
276 276
 
277 277
 		// ... and make sure it is our class.
278
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
278
+		if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) {
279 279
 			return;
280 280
 		}
281 281
 
282 282
 		// Next, prepare the file name from the class.
283
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
283
+		$file_name = 'class-' . str_replace('_', '-', $class_name) . '.php';
284 284
 
285 285
 		// Base path of the classes.
286
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
286
+		$plugin_path = untrailingslashit(WPINV_PLUGIN_DIR);
287 287
 
288 288
 		// And an array of possible locations in order of importance.
289 289
 		$locations = array(
@@ -298,9 +298,9 @@  discard block
 block discarded – undo
298 298
 			"$plugin_path/includes/admin/meta-boxes",
299 299
 		);
300 300
 
301
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
302
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
303
-				include trailingslashit( $location ) . $file_name;
301
+		foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) {
302
+			if (file_exists(trailingslashit($location) . $file_name)) {
303
+				include trailingslashit($location) . $file_name;
304 304
 				break;
305 305
 			}
306 306
 		}
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 	 */
312 312
 	public function init() {
313 313
 		// Fires before getpaid inits.
314
-		do_action( 'before_getpaid_init', $this );
314
+		do_action('before_getpaid_init', $this);
315 315
 
316 316
 		// Maybe upgrade.
317 317
 		$this->maybe_upgrade_database();
@@ -328,17 +328,17 @@  discard block
 block discarded – undo
328 328
 			)
329 329
 		);
330 330
 
331
-		foreach ( $gateways as $id => $class ) {
332
-			$this->gateways[ $id ] = new $class();
331
+		foreach ($gateways as $id => $class) {
332
+			$this->gateways[$id] = new $class();
333 333
 		}
334 334
 
335
-		if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) {
335
+		if ('yes' != get_option('wpinv_renamed_gateways')) {
336 336
 			GetPaid_Installer::rename_gateways_label();
337
-			update_option( 'wpinv_renamed_gateways', 'yes' );
337
+			update_option('wpinv_renamed_gateways', 'yes');
338 338
 		}
339 339
 
340 340
 		// Fires after getpaid inits.
341
-		do_action( 'getpaid_init', $this );
341
+		do_action('getpaid_init', $this);
342 342
 	}
343 343
 
344 344
 	/**
@@ -346,51 +346,51 @@  discard block
 block discarded – undo
346 346
 	 */
347 347
 	public function maybe_process_ipn() {
348 348
 		// Ensure that this is an IPN request.
349
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
349
+		if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) {
350 350
 			return;
351 351
 		}
352 352
 
353
-		$gateway = sanitize_text_field( $_GET['wpi-gateway'] );
353
+		$gateway = sanitize_text_field($_GET['wpi-gateway']);
354 354
 
355
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
356
-		do_action( "wpinv_verify_{$gateway}_ipn" );
355
+		do_action('wpinv_verify_payment_ipn', $gateway);
356
+		do_action("wpinv_verify_{$gateway}_ipn");
357 357
 		exit;
358 358
 	}
359 359
 
360 360
 	public function enqueue_scripts() {
361 361
 		// Fires before adding scripts.
362
-		do_action( 'getpaid_enqueue_scripts' );
362
+		do_action('getpaid_enqueue_scripts');
363 363
 
364 364
 		$localize                         = array();
365
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
365
+		$localize['ajax_url']             = admin_url('admin-ajax.php');
366 366
 		$localize['thousands']            = wpinv_thousands_separator();
367 367
 		$localize['decimals']             = wpinv_decimal_separator();
368
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
369
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
368
+		$localize['nonce']                = wp_create_nonce('wpinv-nonce');
369
+		$localize['txtComplete']          = __('Continue', 'invoicing');
370 370
 		$localize['UseTaxes']             = wpinv_use_taxes();
371
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
372
-		$localize['loading']              = __( 'Loading...', 'invoicing' );
373
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
371
+		$localize['formNonce']            = wp_create_nonce('getpaid_form_nonce');
372
+		$localize['loading']              = __('Loading...', 'invoicing');
373
+		$localize['connectionError']      = __('Could not establish a connection to the server.', 'invoicing');
374 374
 		$localize['recaptchaSettings']    = getpaid_get_recaptcha_settings();
375 375
 
376
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
376
+		$localize = apply_filters('wpinv_front_js_localize', $localize);
377 377
 
378 378
 		// reCaptcha.
379
-		if ( getpaid_is_recaptcha_enabled() && ( $recaptcha_js = getpaid_recaptcha_api_url() ) ) {
380
-			wp_enqueue_script( 'recaptcha', $recaptcha_js, array(), null, true ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
379
+		if (getpaid_is_recaptcha_enabled() && ($recaptcha_js = getpaid_recaptcha_api_url())) {
380
+			wp_enqueue_script('recaptcha', $recaptcha_js, array(), null, true); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
381 381
 		}
382 382
 
383
-		wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.min.js', array( 'jquery' ), WPINV_VERSION, true );
384
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
383
+		wp_enqueue_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.min.js', array('jquery'), WPINV_VERSION, true);
384
+		wp_localize_script('wpinv-front-script', 'WPInv', $localize);
385 385
 	}
386 386
 
387 387
 	public function wpinv_actions() {
388
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
389
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
388
+		if (isset($_REQUEST['wpi_action'])) {
389
+			do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
390 390
 		}
391 391
 
392
-		if ( defined( 'WP_ALL_IMPORT_ROOT_DIR' ) ) {
393
-			include plugin_dir_path( __FILE__ ) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php';
392
+		if (defined('WP_ALL_IMPORT_ROOT_DIR')) {
393
+			include plugin_dir_path(__FILE__) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php';
394 394
 		}
395 395
 	}
396 396
 
@@ -401,21 +401,21 @@  discard block
 block discarded – undo
401 401
 	 * current user owns the invoice/subscription.
402 402
 	 */
403 403
 	public function maybe_do_authenticated_action() {
404
-		if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
405
-			$key  = sanitize_key( $_REQUEST['getpaid-action'] );
406
-			$data = wp_unslash( $_REQUEST );
404
+		if (isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
405
+			$key  = sanitize_key($_REQUEST['getpaid-action']);
406
+			$data = wp_unslash($_REQUEST);
407 407
 
408
-			if ( is_user_logged_in() ) {
409
-				do_action( "getpaid_authenticated_action_$key", $data );
408
+			if (is_user_logged_in()) {
409
+				do_action("getpaid_authenticated_action_$key", $data);
410 410
 			}
411 411
 
412
-			do_action( "getpaid_unauthenticated_action_$key", $data );
412
+			do_action("getpaid_unauthenticated_action_$key", $data);
413 413
 		}
414 414
 	}
415 415
 
416
-	public function pre_get_posts( $wp_query ) {
417
-		if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
418
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
416
+	public function pre_get_posts($wp_query) {
417
+		if (!is_admin() && !empty($wp_query->query_vars['post_type']) && getpaid_is_invoice_post_type($wp_query->query_vars['post_type']) && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
418
+			$wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses(false, false, $wp_query->query_vars['post_type']));
419 419
 		}
420 420
 
421 421
 		return $wp_query;
@@ -430,17 +430,17 @@  discard block
 block discarded – undo
430 430
 
431 431
 		// Currently, UX Builder does not work particulaly well with SuperDuper.
432 432
 		// So we disable our widgets when editing a page with UX Builder.
433
-		if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) {
433
+		if (function_exists('ux_builder_is_active') && ux_builder_is_active()) {
434 434
 			return;
435 435
 		}
436 436
 
437
-		$block_widget_init_screens = function_exists( 'sd_pagenow_exclude' ) ? sd_pagenow_exclude() : array();
437
+		$block_widget_init_screens = function_exists('sd_pagenow_exclude') ? sd_pagenow_exclude() : array();
438 438
 
439
-		if ( is_admin() && $pagenow && in_array( $pagenow, $block_widget_init_screens ) ) {
439
+		if (is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) {
440 440
 			// don't initiate in these conditions.
441 441
 		} else {
442 442
 			// Only load allowed widgets.
443
-			$exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array();
443
+			$exclude = function_exists('sd_widget_exclude') ? sd_widget_exclude() : array();
444 444
 			$widgets = apply_filters(
445 445
 				'getpaid_widget_classes',
446 446
 				array(
@@ -456,15 +456,15 @@  discard block
 block discarded – undo
456 456
 			);
457 457
 
458 458
 			// For each widget...
459
-			foreach ( $widgets as $widget ) {
459
+			foreach ($widgets as $widget) {
460 460
 				// Abort early if it is excluded for this page.
461
-				if ( in_array( $widget, $exclude ) ) {
461
+				if (in_array($widget, $exclude)) {
462 462
 					continue;
463 463
 				}
464 464
 
465 465
 				// SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it.
466
-				if ( is_subclass_of( $widget, 'WP_Widget' ) ) {
467
-					register_widget( $widget );
466
+				if (is_subclass_of($widget, 'WP_Widget')) {
467
+					register_widget($widget);
468 468
 				} else {
469 469
 					new $widget();
470 470
 				}
@@ -481,28 +481,28 @@  discard block
 block discarded – undo
481 481
 		// Ensure the database tables are up to date.
482 482
 		GetPaid_Installer::maybe_create_db_tables();
483 483
 
484
-		$wpi_version = get_option( 'wpinv_version', 0 );
484
+		$wpi_version = get_option('wpinv_version', 0);
485 485
 
486
-		if ( $wpi_version == WPINV_VERSION ) {
486
+		if ($wpi_version == WPINV_VERSION) {
487 487
 			return;
488 488
 		}
489 489
 
490 490
 		$installer = new GetPaid_Installer();
491 491
 
492
-		if ( empty( $wpi_version ) ) {
493
-			return $installer->upgrade_db( 0 );
492
+		if (empty($wpi_version)) {
493
+			return $installer->upgrade_db(0);
494 494
 		}
495 495
 
496
-		$upgrades  = array(
496
+		$upgrades = array(
497 497
 			'0.0.5' => '004',
498 498
 			'1.0.3' => '102',
499 499
 			'2.0.0' => '118',
500 500
 			'2.8.0' => '279',
501 501
 		);
502 502
 
503
-		foreach ( $upgrades as $key => $method ) {
504
-			if ( version_compare( $wpi_version, $key, '<' ) ) {
505
-				return $installer->upgrade_db( $method );
503
+		foreach ($upgrades as $key => $method) {
504
+			if (version_compare($wpi_version, $key, '<')) {
505
+				return $installer->upgrade_db($method);
506 506
 			}
507 507
 		}
508 508
 	}
@@ -513,11 +513,11 @@  discard block
 block discarded – undo
513 513
 	 * @since 2.0.8
514 514
 	 */
515 515
 	public function maybe_flush_permalinks() {
516
-		$flush = get_option( 'wpinv_flush_permalinks', 0 );
516
+		$flush = get_option('wpinv_flush_permalinks', 0);
517 517
 
518
-		if ( ! empty( $flush ) ) {
518
+		if (!empty($flush)) {
519 519
 			flush_rewrite_rules();
520
-			delete_option( 'wpinv_flush_permalinks' );
520
+			delete_option('wpinv_flush_permalinks');
521 521
 		}
522 522
 	}
523 523
 
@@ -527,9 +527,9 @@  discard block
 block discarded – undo
527 527
 	 * @since 1.0.19
528 528
 	 * @param int[] $excluded_posts_ids
529 529
 	 */
530
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ) {
530
+	public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) {
531 531
 		// Ensure that we have an array.
532
-		if ( ! is_array( $excluded_posts_ids ) ) {
532
+		if (!is_array($excluded_posts_ids)) {
533 533
 			$excluded_posts_ids = array();
534 534
 		}
535 535
 
@@ -537,25 +537,25 @@  discard block
 block discarded – undo
537 537
 		$our_pages = array();
538 538
 
539 539
 		// Checkout page.
540
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
540
+		$our_pages[] = wpinv_get_option('checkout_page', false);
541 541
 
542 542
 		// Success page.
543
-		$our_pages[] = wpinv_get_option( 'success_page', false );
543
+		$our_pages[] = wpinv_get_option('success_page', false);
544 544
 
545 545
 		// Failure page.
546
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
546
+		$our_pages[] = wpinv_get_option('failure_page', false);
547 547
 
548 548
 		// History page.
549
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
549
+		$our_pages[] = wpinv_get_option('invoice_history_page', false);
550 550
 
551 551
 		// Subscriptions page.
552
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
552
+		$our_pages[] = wpinv_get_option('invoice_subscription_page', false);
553 553
 
554
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
554
+		$our_pages   = array_map('intval', array_filter($our_pages));
555 555
 
556 556
 		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
557 557
 
558
-		return array_unique( $excluded_posts_ids );
558
+		return array_unique($excluded_posts_ids);
559 559
 	}
560 560
 
561 561
 	/**
@@ -564,14 +564,14 @@  discard block
 block discarded – undo
564 564
 	 * @since 1.0.19
565 565
 	 * @param string[] $post_types
566 566
 	 */
567
-	public function exclude_invoicing_post_types( $post_types ) {
567
+	public function exclude_invoicing_post_types($post_types) {
568 568
 		// Ensure that we have an array.
569
-		if ( ! is_array( $post_types ) ) {
569
+		if (!is_array($post_types)) {
570 570
 			$post_types = array();
571 571
 		}
572 572
 
573 573
 		// Remove our post types.
574
-		return array_diff( $post_types, array_keys( getpaid_get_invoice_post_types() ) );
574
+		return array_diff($post_types, array_keys(getpaid_get_invoice_post_types()));
575 575
 	}
576 576
 
577 577
 	/**
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
 	 * @since 2.0.0
581 581
 	 */
582 582
 	public function wp_footer() {
583
-		wpinv_get_template( 'frontend-footer.php' );
583
+		wpinv_get_template('frontend-footer.php');
584 584
 	}
585 585
 
586 586
 	/**
@@ -589,14 +589,14 @@  discard block
 block discarded – undo
589 589
 	 * @since 2.0.0
590 590
 	 */
591 591
 	public function wp_head() {
592
-		wpinv_get_template( 'frontend-head.php' );
592
+		wpinv_get_template('frontend-head.php');
593 593
 	}
594 594
 
595 595
 	/**
596 596
 	 * Custom query vars.
597 597
 	 *
598 598
 	 */
599
-	public function custom_query_vars( $vars ) {
599
+	public function custom_query_vars($vars) {
600 600
 		$vars[] = 'getpaid-ipn';
601 601
 		return $vars;
602 602
 	}
@@ -607,26 +607,26 @@  discard block
 block discarded – undo
607 607
 	 */
608 608
 	public function add_rewrite_rule() {
609 609
 		$tag = 'getpaid-ipn';
610
-		add_rewrite_tag( "%$tag%", '([^&]+)' );
611
-		add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top' );
610
+		add_rewrite_tag("%$tag%", '([^&]+)');
611
+		add_rewrite_rule("^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top');
612 612
 	}
613 613
 
614 614
 	/**
615 615
 	 * Processes non-query string ipns.
616 616
 	 *
617 617
 	 */
618
-	public function maybe_process_new_ipn( $query ) {
619
-		if ( is_admin() || ! $query->is_main_query() ) {
618
+	public function maybe_process_new_ipn($query) {
619
+		if (is_admin() || !$query->is_main_query()) {
620 620
 			return;
621 621
 		}
622 622
 
623
-		$gateway = get_query_var( 'getpaid-ipn' );
623
+		$gateway = get_query_var('getpaid-ipn');
624 624
 
625
-		if ( ! empty( $gateway ) ) {
626
-			$gateway = sanitize_text_field( $gateway );
625
+		if (!empty($gateway)) {
626
+			$gateway = sanitize_text_field($gateway);
627 627
 			nocache_headers();
628
-			do_action( 'wpinv_verify_payment_ipn', $gateway );
629
-			do_action( "wpinv_verify_{$gateway}_ipn" );
628
+			do_action('wpinv_verify_payment_ipn', $gateway);
629
+			do_action("wpinv_verify_{$gateway}_ipn");
630 630
 			exit;
631 631
 		}
632 632
 	}
Please login to merge, or discard this patch.
includes/admin/class-wpinv-admin-menus.php 1 patch
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Setup menus in WP admin.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * WC_Admin_Menus Class.
@@ -13,15 +13,15 @@  discard block
 block discarded – undo
13 13
      * Hook in tabs.
14 14
      */
15 15
     public function __construct() {
16
-        add_action( 'admin_head', array( $this, 'set_admin_menu_class' ) );
17
-        add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 );
18
-        add_action( 'admin_menu', array( $this, 'add_customers_menu' ), 18 );
19
-        add_action( 'admin_menu', array( $this, 'add_subscriptions_menu' ), 40 );
20
-        add_action( 'admin_menu', array( $this, 'add_addons_menu' ), 100 );
21
-        add_action( 'admin_menu', array( $this, 'add_settings_menu' ), 60 );
22
-        add_action( 'admin_menu', array( $this, 'add_anonymization_logs_menu' ), 40 );
23
-        add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 );
24
-        add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) );
16
+        add_action('admin_head', array($this, 'set_admin_menu_class'));
17
+        add_action('admin_menu', array($this, 'admin_menu'), 10);
18
+        add_action('admin_menu', array($this, 'add_customers_menu'), 18);
19
+        add_action('admin_menu', array($this, 'add_subscriptions_menu'), 40);
20
+        add_action('admin_menu', array($this, 'add_addons_menu'), 100);
21
+        add_action('admin_menu', array($this, 'add_settings_menu'), 60);
22
+        add_action('admin_menu', array($this, 'add_anonymization_logs_menu'), 40);
23
+        add_action('admin_menu', array($this, 'remove_admin_submenus'), 10);
24
+        add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes'));
25 25
     }
26 26
 
27 27
     /**
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	public function set_admin_menu_class() {
31 31
 		global $current_screen, $parent_file, $submenu_file;
32 32
 
33
-        if ( ! empty( $current_screen->id ) && in_array( $current_screen->id, array( 'wpi_discount', 'wpi_payment_form', 'wpi_invoice' ) ) ) {
33
+        if (!empty($current_screen->id) && in_array($current_screen->id, array('wpi_discount', 'wpi_payment_form', 'wpi_invoice'))) {
34 34
 			$parent_file = 'wpinv';
35 35
 			$submenu_file = 'edit.php?post_type=' . $current_screen->id;
36 36
         }
@@ -39,14 +39,14 @@  discard block
 block discarded – undo
39 39
 
40 40
     public function admin_menu() {
41 41
 
42
-        $capability = apply_filters( 'invoicing_capability', wpinv_get_capability() );
42
+        $capability = apply_filters('invoicing_capability', wpinv_get_capability());
43 43
         add_menu_page(
44
-            __( 'GetPaid', 'invoicing' ),
45
-            __( 'GetPaid', 'invoicing' ),
44
+            __('GetPaid', 'invoicing'),
45
+            __('GetPaid', 'invoicing'),
46 46
             $capability,
47 47
             'wpinv',
48 48
             null,
49
-            'data:image/svg+xml;base64,' . base64_encode( file_get_contents( WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg' ) ),
49
+            'data:image/svg+xml;base64,' . base64_encode(file_get_contents(WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg')),
50 50
             '54.123460'
51 51
         );
52 52
 
@@ -58,11 +58,11 @@  discard block
 block discarded – undo
58 58
     public function add_customers_menu() {
59 59
         add_submenu_page(
60 60
             'wpinv',
61
-            __( 'Customers', 'invoicing' ),
62
-            __( 'Customers', 'invoicing' ),
61
+            __('Customers', 'invoicing'),
62
+            __('Customers', 'invoicing'),
63 63
             wpinv_get_capability(),
64 64
             'wpinv-customers',
65
-            array( $this, 'customers_page' )
65
+            array($this, 'customers_page')
66 66
         );
67 67
     }
68 68
 
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
     public function add_subscriptions_menu() {
73 73
         add_submenu_page(
74 74
             'wpinv',
75
-            __( 'Subscriptions', 'invoicing' ),
76
-            __( 'Subscriptions', 'invoicing' ),
75
+            __('Subscriptions', 'invoicing'),
76
+            __('Subscriptions', 'invoicing'),
77 77
             wpinv_get_capability(),
78 78
             'wpinv-subscriptions',
79 79
             'wpinv_subscriptions_page'
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
                     width: 120px;
96 96
                 }
97 97
             </style>
98
-            <h1><?php echo esc_html( __( 'Customers', 'invoicing' ) ); ?>&nbsp;<a href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'download_customers' ), 'getpaid-nonce', 'getpaid-nonce' ) ); ?>" class="page-title-action"><?php esc_html_e( 'Export', 'invoicing' ); ?></a></h1>
99
-            <form method="get" style="overflow: auto; width: 100%" action=<?php echo esc_url( add_query_arg( array() ) ); ?>>
98
+            <h1><?php echo esc_html(__('Customers', 'invoicing')); ?>&nbsp;<a href="<?php echo esc_url(wp_nonce_url(add_query_arg('getpaid-admin-action', 'download_customers'), 'getpaid-nonce', 'getpaid-nonce')); ?>" class="page-title-action"><?php esc_html_e('Export', 'invoicing'); ?></a></h1>
99
+            <form method="get" style="overflow: auto; width: 100%" action=<?php echo esc_url(add_query_arg(array())); ?>>
100 100
                 <input type="hidden" name="page" value="wpinv-customers" />
101 101
                 <?php
102 102
                     $table = new WPInv_Customers_Table();
103 103
                     $table->prepare_items();
104
-                    $table->search_box( __( 'Search Customers', 'invoicing' ), 'search-customers' );
104
+                    $table->search_box(__('Search Customers', 'invoicing'), 'search-customers');
105 105
                     $table->display();
106 106
                 ?>
107 107
             </form>
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
     public function add_settings_menu() {
116 116
         add_submenu_page(
117 117
             'wpinv',
118
-            __( 'Invoice Settings', 'invoicing' ),
119
-            __( 'Settings', 'invoicing' ),
120
-            apply_filters( 'invoicing_capability', wpinv_get_capability() ),
118
+            __('Invoice Settings', 'invoicing'),
119
+            __('Settings', 'invoicing'),
120
+            apply_filters('invoicing_capability', wpinv_get_capability()),
121 121
             'wpinv-settings',
122
-            array( $this, 'options_page' )
122
+            array($this, 'options_page')
123 123
         );
124 124
     }
125 125
 
@@ -131,26 +131,26 @@  discard block
 block discarded – undo
131 131
     public function add_anonymization_logs_menu() {
132 132
         $anonymization_logs_page = new GetPaid_Anonymization_Logs();
133 133
         add_management_page(
134
-            __( 'Anonymization Logs', 'invoicing' ),
135
-            __( 'Anonymization Logs', 'invoicing' ),
134
+            __('Anonymization Logs', 'invoicing'),
135
+            __('Anonymization Logs', 'invoicing'),
136 136
             'manage_options',
137 137
             'wpinv-anonymization-logs',
138
-            array( $anonymization_logs_page, 'display_logs' )
138
+            array($anonymization_logs_page, 'display_logs')
139 139
         );
140 140
     }
141 141
 
142 142
     public function add_addons_menu() {
143
-        if ( ! apply_filters( 'wpi_show_addons_page', true ) ) {
143
+        if (!apply_filters('wpi_show_addons_page', true)) {
144 144
             return;
145 145
         }
146 146
 
147 147
         add_submenu_page(
148 148
             'wpinv',
149
-            __( 'Invoicing extensions', 'invoicing' ),
150
-            __( 'Extensions', 'invoicing' ),
149
+            __('Invoicing extensions', 'invoicing'),
150
+            __('Extensions', 'invoicing'),
151 151
             'manage_options',
152 152
             'wpi-addons',
153
-            array( $this, 'addons_page' )
153
+            array($this, 'addons_page')
154 154
         );
155 155
     }
156 156
 
@@ -161,29 +161,29 @@  discard block
 block discarded – undo
161 161
 
162 162
     function options_page() {
163 163
 
164
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
164
+        if (!wpinv_current_user_can_manage_invoicing()) {
165 165
             return;
166 166
         }
167 167
 
168 168
         $settings_tabs = wpinv_get_settings_tabs();
169
-        $settings_tabs = empty( $settings_tabs ) ? array() : $settings_tabs;
170
-        $active_tab    = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general';
171
-        $sections      = wpinv_get_settings_tab_sections( $active_tab );
169
+        $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs;
170
+        $active_tab    = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general';
171
+        $sections      = wpinv_get_settings_tab_sections($active_tab);
172 172
         $key           = 'main';
173 173
 
174
-        if ( is_array( $sections ) ) {
175
-            $key = key( $sections );
174
+        if (is_array($sections)) {
175
+            $key = key($sections);
176 176
         }
177 177
 
178 178
         add_thickbox();
179 179
 
180
-        $registered_sections = wpinv_get_settings_tab_sections( $active_tab );
181
-        $section             = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? sanitize_text_field( $_GET['section'] ) : $key;
180
+        $registered_sections = wpinv_get_settings_tab_sections($active_tab);
181
+        $section             = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? sanitize_text_field($_GET['section']) : $key;
182 182
         ?>
183 183
         <div class="wrap">
184 184
             <h1 class="nav-tab-wrapper">
185 185
                 <?php
186
-                foreach ( wpinv_get_settings_tabs() as $tab_id => $tab_name ) {
186
+                foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) {
187 187
                     $tab_url = add_query_arg(
188 188
                         array(
189 189
 							'settings-updated' => false,
@@ -193,23 +193,23 @@  discard block
 block discarded – undo
193 193
                     );
194 194
 
195 195
                     // Remove the section from the tabs so we always end up at the main section
196
-                    $tab_url = remove_query_arg( 'section', $tab_url );
197
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
196
+                    $tab_url = remove_query_arg('section', $tab_url);
197
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
198 198
 
199 199
                     $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
200 200
 
201
-                    echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab ' . esc_attr( $active ) . '">';
202
-                    echo esc_html( $tab_name );
201
+                    echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab ' . esc_attr($active) . '">';
202
+                    echo esc_html($tab_name);
203 203
                     echo '</a>';
204 204
                 }
205 205
                 ?>
206 206
             </h1>
207 207
             <?php
208
-            $number_of_sections = count( $sections );
208
+            $number_of_sections = count($sections);
209 209
             $number = 0;
210
-            if ( $number_of_sections > 1 ) {
210
+            if ($number_of_sections > 1) {
211 211
                 echo '<div><ul class="subsubsub">';
212
-                foreach ( $sections as $section_id => $section_name ) {
212
+                foreach ($sections as $section_id => $section_name) {
213 213
                     echo '<li>';
214 214
                     $number++;
215 215
                     $tab_url = add_query_arg(
@@ -218,16 +218,16 @@  discard block
 block discarded – undo
218 218
 							'tab'              => $active_tab,
219 219
 							'section'          => $section_id,
220 220
                         ),
221
-                        admin_url( 'admin.php?page=wpinv-settings' )
221
+                        admin_url('admin.php?page=wpinv-settings')
222 222
                     );
223
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
223
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
224 224
                     $class = '';
225
-                    if ( $section == $section_id ) {
225
+                    if ($section == $section_id) {
226 226
                         $class = 'current';
227 227
                     }
228
-                    echo '<a class="' . esc_attr( $class ) . '" href="' . esc_url( $tab_url ) . '">' . esc_html( $section_name ) . '</a>';
228
+                    echo '<a class="' . esc_attr($class) . '" href="' . esc_url($tab_url) . '">' . esc_html($section_name) . '</a>';
229 229
 
230
-                    if ( $number != $number_of_sections ) {
230
+                    if ($number != $number_of_sections) {
231 231
                         echo ' | ';
232 232
                     }
233 233
                     echo '</li>';
@@ -239,20 +239,20 @@  discard block
 block discarded – undo
239 239
                 <form method="post" action="options.php">
240 240
                     <table class="form-tablex">
241 241
                         <?php
242
-                        settings_fields( 'wpinv_settings' );
242
+                        settings_fields('wpinv_settings');
243 243
 
244
-                        if ( 'main' === $section ) {
245
-                            do_action( 'wpinv_settings_tab_top', $active_tab );
244
+                        if ('main' === $section) {
245
+                            do_action('wpinv_settings_tab_top', $active_tab);
246 246
                         }
247 247
 
248
-                        do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section );
249
-                        do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section );
250
-                        do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section );
251
-                        do_action( 'getpaid_settings_tab_bottom', $active_tab, $section );
248
+                        do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section);
249
+                        do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section);
250
+                        do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section);
251
+                        do_action('getpaid_settings_tab_bottom', $active_tab, $section);
252 252
 
253 253
                         // For backwards compatibility
254
-                        if ( 'main' === $section ) {
255
-                            do_action( 'wpinv_settings_tab_bottom', $active_tab );
254
+                        if ('main' === $section) {
255
+                            do_action('wpinv_settings_tab_bottom', $active_tab);
256 256
                         }
257 257
                         ?>
258 258
                     </table>
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
     }
265 265
 
266 266
     public function remove_admin_submenus() {
267
-        remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' );
267
+        remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice');
268 268
     }
269 269
 
270 270
     /**
@@ -274,8 +274,8 @@  discard block
 block discarded – undo
274 274
 
275 275
         add_meta_box(
276 276
             'wpinv_endpoints_nav_link',
277
-            __( 'GetPaid endpoints', 'invoicing' ),
278
-            array( $this, 'nav_menu_links' ),
277
+            __('GetPaid endpoints', 'invoicing'),
278
+            array($this, 'nav_menu_links'),
279 279
             'nav-menus',
280 280
             'side',
281 281
             'low'
@@ -290,12 +290,12 @@  discard block
 block discarded – undo
290 290
         $endpoints = $this->get_menu_items();
291 291
         ?>
292 292
         <div id="invoicing-endpoints" class="posttypediv">
293
-            <?php if ( ! empty( $endpoints['pages'] ) ) : ?>
293
+            <?php if (!empty($endpoints['pages'])) : ?>
294 294
                 <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active">
295 295
                     <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear">
296 296
                         <?php
297
-                            $walker = new Walker_Nav_Menu_Checklist( array() );
298
-                            echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $endpoints['pages'] ), 0, (object) array( 'walker' => $walker ) );
297
+                            $walker = new Walker_Nav_Menu_Checklist(array());
298
+                            echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object) array('walker' => $walker));
299 299
                         ?>
300 300
                     </ul>
301 301
                 </div>
@@ -304,11 +304,11 @@  discard block
 block discarded – undo
304 304
             <p class="button-controls wp-clearfix" data-items-type="invoicing-endpoints">
305 305
                 <span class="list-controls hide-if-no-js">
306 306
                     <input type="checkbox" id="invoicing-endpoints-tab" class="select-all">
307
-                    <label for="invoicing-endpoints-tab"><?php esc_html_e( 'Select all', 'invoicing' ); ?></label>
307
+                    <label for="invoicing-endpoints-tab"><?php esc_html_e('Select all', 'invoicing'); ?></label>
308 308
                 </span>
309 309
 
310 310
                 <span class="add-to-menu">
311
-                    <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'invoicing' ); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints">
311
+                    <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'invoicing'); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints">
312 312
                     <span class="spinner"></span>
313 313
                 </span>
314 314
             </p>
@@ -326,18 +326,18 @@  discard block
 block discarded – undo
326 326
 
327 327
         $pages = array(
328 328
             array(
329
-                'id'    => wpinv_get_option( 'invoice_history_page' ),
330
-                'label' => __( 'My Invoices', 'invoicing' ),
329
+                'id'    => wpinv_get_option('invoice_history_page'),
330
+                'label' => __('My Invoices', 'invoicing'),
331 331
             ),
332 332
             array(
333
-                'id'    => wpinv_get_option( 'invoice_subscription_page' ),
334
-                'label' => __( 'My Subscriptions', 'invoicing' ),
333
+                'id'    => wpinv_get_option('invoice_subscription_page'),
334
+                'label' => __('My Subscriptions', 'invoicing'),
335 335
             ),
336 336
         );
337 337
 
338
-        foreach ( apply_filters( 'getpaid_menu_pages', $pages ) as $page ) {
338
+        foreach (apply_filters('getpaid_menu_pages', $pages) as $page) {
339 339
 
340
-            if ( (int) $page['id'] > 0 ) {
340
+            if ((int) $page['id'] > 0) {
341 341
 
342 342
                 $item                   = new stdClass();
343 343
                 $item->object_id        = (int) $page['id'];
@@ -345,11 +345,11 @@  discard block
 block discarded – undo
345 345
                 $item->object           = 'page';
346 346
                 $item->menu_item_parent = 0;
347 347
                 $item->type             = 'post_type';
348
-                $item->title            = esc_html( $page['label'] );
349
-                $item->url              = get_permalink( (int) $page['id'] );
348
+                $item->title            = esc_html($page['label']);
349
+                $item->url              = get_permalink((int) $page['id']);
350 350
                 $item->target           = '';
351 351
                 $item->attr_title       = '';
352
-                $item->classes          = array( 'wpinv-menu-item' );
352
+                $item->classes          = array('wpinv-menu-item');
353 353
                 $item->xfn              = '';
354 354
 
355 355
                 $items['pages'][]       = $item;
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
             }
358 358
 }
359 359
 
360
-        return apply_filters( 'wpinv_menu_items', $items );
360
+        return apply_filters('wpinv_menu_items', $items);
361 361
     }
362 362
 
363 363
 }
Please login to merge, or discard this patch.
includes/admin/class-getpaid-installer.php 2 patches
Indentation   +496 added lines, -496 removed lines patch added patch discarded remove patch
@@ -20,411 +20,411 @@  discard block
 block discarded – undo
20 20
  */
21 21
 class GetPaid_Installer {
22 22
 
23
-	private static $schema = null;
24
-	private static $schema_version = null;
25
-
26
-	/**
27
-	 * Upgrades the install.
28
-	 *
29
-	 * @param string $upgrade_from The current invoicing version.
30
-	 */
31
-	public function upgrade_db( $upgrade_from ) {
32
-
33
-		// Save the current invoicing version.
34
-		update_option( 'wpinv_version', WPINV_VERSION );
35
-
36
-		// Setup the invoice Custom Post Type.
37
-		GetPaid_Post_Types::register_post_types();
38
-
39
-		// Clear the permalinks
40
-		flush_rewrite_rules();
41
-
42
-		// Maybe create new/missing pages.
43
-		$this->create_pages();
44
-
45
-		// Maybe re(add) admin capabilities.
46
-		$this->add_capabilities();
47
-
48
-		// Maybe create the default payment form.
49
-		wpinv_get_default_payment_form();
50
-
51
-		// Create any missing database tables.
52
-		$method = "upgrade_from_$upgrade_from";
53
-
54
-		$installed = get_option( 'gepaid_installed_on' );
55
-
56
-		if ( empty( $installed ) ) {
57
-			update_option( 'gepaid_installed_on', time() );
58
-		}
59
-
60
-		if ( method_exists( $this, $method ) ) {
61
-			$this->$method();
62
-		}
63
-
64
-	}
65
-
66
-	/**
67
-	 * Do a fresh install.
68
-	 *
69
-	 */
70
-	public function upgrade_from_0() {
71
-
72
-		// Save default tax rates.
73
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
74
-	}
75
-
76
-	/**
77
-	 * Upgrade to 0.0.5
78
-	 *
79
-	 */
80
-	public function upgrade_from_004() {
81
-		global $wpdb;
82
-
83
-		// Invoices.
84
-		$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' )" );
85
-		if ( ! empty( $results ) ) {
86
-			$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' )" );
87
-
88
-			// Clean post cache
89
-			foreach ( $results as $row ) {
90
-				clean_post_cache( $row->ID );
91
-			}
92
-		}
93
-
94
-		// Item meta key changes
95
-		$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' )";
96
-		$results = $wpdb->get_results( $query );
97
-
98
-		if ( ! empty( $results ) ) {
99
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
100
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
101
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
102
-
103
-			foreach ( $results as $row ) {
104
-				clean_post_cache( $row->post_id );
105
-			}
106
-		}
107
-
108
-		$this->upgrade_from_118();
109
-	}
110
-
111
-	/**
112
-	 * Upgrade to version 2.0.0.
113
-	 *
114
-	 */
115
-	public function upgrade_from_118() {
116
-		$this->migrate_old_invoices();
117
-		$this->upgrade_from_279();
118
-	}
119
-
120
-	/**
121
-	 * Upgrade to version 2.0.0.
122
-	 *
123
-	 */
124
-	public function upgrade_from_279() {
125
-		self::migrate_old_customers();
126
-	}
127
-
128
-	/**
129
-	 * Give administrators the capability to manage GetPaid.
130
-	 *
131
-	 */
132
-	public function add_capabilities() {
133
-		$GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' );
134
-	}
135
-
136
-	/**
137
-	 * Retreives GetPaid pages.
138
-	 *
139
-	 */
140
-	public static function get_pages() {
141
-
142
-		return apply_filters(
143
-			'wpinv_create_pages',
144
-			array(
145
-
146
-				// Checkout page.
147
-				'checkout_page'             => array(
148
-					'name'    => _x( 'gp-checkout', 'Page slug', 'invoicing' ),
149
-					'title'   => _x( 'Checkout', 'Page title', 'invoicing' ),
150
-					'content' => '
23
+    private static $schema = null;
24
+    private static $schema_version = null;
25
+
26
+    /**
27
+     * Upgrades the install.
28
+     *
29
+     * @param string $upgrade_from The current invoicing version.
30
+     */
31
+    public function upgrade_db( $upgrade_from ) {
32
+
33
+        // Save the current invoicing version.
34
+        update_option( 'wpinv_version', WPINV_VERSION );
35
+
36
+        // Setup the invoice Custom Post Type.
37
+        GetPaid_Post_Types::register_post_types();
38
+
39
+        // Clear the permalinks
40
+        flush_rewrite_rules();
41
+
42
+        // Maybe create new/missing pages.
43
+        $this->create_pages();
44
+
45
+        // Maybe re(add) admin capabilities.
46
+        $this->add_capabilities();
47
+
48
+        // Maybe create the default payment form.
49
+        wpinv_get_default_payment_form();
50
+
51
+        // Create any missing database tables.
52
+        $method = "upgrade_from_$upgrade_from";
53
+
54
+        $installed = get_option( 'gepaid_installed_on' );
55
+
56
+        if ( empty( $installed ) ) {
57
+            update_option( 'gepaid_installed_on', time() );
58
+        }
59
+
60
+        if ( method_exists( $this, $method ) ) {
61
+            $this->$method();
62
+        }
63
+
64
+    }
65
+
66
+    /**
67
+     * Do a fresh install.
68
+     *
69
+     */
70
+    public function upgrade_from_0() {
71
+
72
+        // Save default tax rates.
73
+        update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
74
+    }
75
+
76
+    /**
77
+     * Upgrade to 0.0.5
78
+     *
79
+     */
80
+    public function upgrade_from_004() {
81
+        global $wpdb;
82
+
83
+        // Invoices.
84
+        $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' )" );
85
+        if ( ! empty( $results ) ) {
86
+            $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' )" );
87
+
88
+            // Clean post cache
89
+            foreach ( $results as $row ) {
90
+                clean_post_cache( $row->ID );
91
+            }
92
+        }
93
+
94
+        // Item meta key changes
95
+        $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' )";
96
+        $results = $wpdb->get_results( $query );
97
+
98
+        if ( ! empty( $results ) ) {
99
+            $wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
100
+            $wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
101
+            $wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
102
+
103
+            foreach ( $results as $row ) {
104
+                clean_post_cache( $row->post_id );
105
+            }
106
+        }
107
+
108
+        $this->upgrade_from_118();
109
+    }
110
+
111
+    /**
112
+     * Upgrade to version 2.0.0.
113
+     *
114
+     */
115
+    public function upgrade_from_118() {
116
+        $this->migrate_old_invoices();
117
+        $this->upgrade_from_279();
118
+    }
119
+
120
+    /**
121
+     * Upgrade to version 2.0.0.
122
+     *
123
+     */
124
+    public function upgrade_from_279() {
125
+        self::migrate_old_customers();
126
+    }
127
+
128
+    /**
129
+     * Give administrators the capability to manage GetPaid.
130
+     *
131
+     */
132
+    public function add_capabilities() {
133
+        $GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' );
134
+    }
135
+
136
+    /**
137
+     * Retreives GetPaid pages.
138
+     *
139
+     */
140
+    public static function get_pages() {
141
+
142
+        return apply_filters(
143
+            'wpinv_create_pages',
144
+            array(
145
+
146
+                // Checkout page.
147
+                'checkout_page'             => array(
148
+                    'name'    => _x( 'gp-checkout', 'Page slug', 'invoicing' ),
149
+                    'title'   => _x( 'Checkout', 'Page title', 'invoicing' ),
150
+                    'content' => '
151 151
 						<!-- wp:shortcode -->
152 152
 						[wpinv_checkout]
153 153
 						<!-- /wp:shortcode -->
154 154
 					',
155
-					'parent'  => '',
156
-				),
157
-
158
-				// Invoice history page.
159
-				'invoice_history_page'      => array(
160
-					'name'    => _x( 'gp-invoices', 'Page slug', 'invoicing' ),
161
-					'title'   => _x( 'My Invoices', 'Page title', 'invoicing' ),
162
-					'content' => '
155
+                    'parent'  => '',
156
+                ),
157
+
158
+                // Invoice history page.
159
+                'invoice_history_page'      => array(
160
+                    'name'    => _x( 'gp-invoices', 'Page slug', 'invoicing' ),
161
+                    'title'   => _x( 'My Invoices', 'Page title', 'invoicing' ),
162
+                    'content' => '
163 163
 					<!-- wp:shortcode -->
164 164
 					[wpinv_history]
165 165
 					<!-- /wp:shortcode -->
166 166
 				',
167
-					'parent'  => '',
168
-				),
169
-
170
-				// Success page content.
171
-				'success_page'              => array(
172
-					'name'    => _x( 'gp-receipt', 'Page slug', 'invoicing' ),
173
-					'title'   => _x( 'Payment Confirmation', 'Page title', 'invoicing' ),
174
-					'content' => '
167
+                    'parent'  => '',
168
+                ),
169
+
170
+                // Success page content.
171
+                'success_page'              => array(
172
+                    'name'    => _x( 'gp-receipt', 'Page slug', 'invoicing' ),
173
+                    'title'   => _x( 'Payment Confirmation', 'Page title', 'invoicing' ),
174
+                    'content' => '
175 175
 					<!-- wp:shortcode -->
176 176
 					[wpinv_receipt]
177 177
 					<!-- /wp:shortcode -->
178 178
 				',
179
-					'parent'  => 'gp-checkout',
180
-				),
181
-
182
-				// Failure page content.
183
-				'failure_page'              => array(
184
-					'name'    => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ),
185
-					'title'   => _x( 'Transaction Failed', 'Page title', 'invoicing' ),
186
-					'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ),
187
-					'parent'  => 'gp-checkout',
188
-				),
189
-
190
-				// Subscriptions history page.
191
-				'invoice_subscription_page' => array(
192
-					'name'    => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ),
193
-					'title'   => _x( 'My Subscriptions', 'Page title', 'invoicing' ),
194
-					'content' => '
179
+                    'parent'  => 'gp-checkout',
180
+                ),
181
+
182
+                // Failure page content.
183
+                'failure_page'              => array(
184
+                    'name'    => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ),
185
+                    'title'   => _x( 'Transaction Failed', 'Page title', 'invoicing' ),
186
+                    'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ),
187
+                    'parent'  => 'gp-checkout',
188
+                ),
189
+
190
+                // Subscriptions history page.
191
+                'invoice_subscription_page' => array(
192
+                    'name'    => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ),
193
+                    'title'   => _x( 'My Subscriptions', 'Page title', 'invoicing' ),
194
+                    'content' => '
195 195
 					<!-- wp:shortcode -->
196 196
 					[wpinv_subscriptions]
197 197
 					<!-- /wp:shortcode -->
198 198
 				',
199
-					'parent'  => '',
200
-				),
201
-
202
-			)
203
-		);
204
-
205
-	}
206
-
207
-	/**
208
-	 * Re-create GetPaid pages.
209
-	 *
210
-	 */
211
-	public function create_pages() {
212
-
213
-		foreach ( self::get_pages() as $key => $page ) {
214
-			wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] );
215
-		}
216
-
217
-	}
218
-
219
-	/**
220
-	 * Migrates old invoices to new invoices.
221
-	 *
222
-	 */
223
-	public function migrate_old_invoices() {
224
-		global $wpdb;
225
-
226
-		$invoices_table      = $wpdb->prefix . 'getpaid_invoices';
227
-		$invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items';
228
-		$migrated            = $wpdb->get_col( "SELECT post_id FROM $invoices_table" );
229
-		$invoices            = array_unique(
230
-			get_posts(
231
-				array(
232
-					'post_type'      => array( 'wpi_invoice', 'wpi_quote' ),
233
-					'posts_per_page' => -1,
234
-					'fields'         => 'ids',
235
-					'post_status'    => array_keys( get_post_stati() ),
236
-					'exclude'        => (array) $migrated,
237
-				)
238
-			)
239
-		);
240
-
241
-		// Abort if we do not have any invoices.
242
-		if ( empty( $invoices ) ) {
243
-			return;
244
-		}
245
-
246
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php';
247
-
248
-		$invoice_rows = array();
249
-		foreach ( $invoices as $invoice ) {
250
-
251
-			$invoice = new WPInv_Legacy_Invoice( $invoice );
252
-
253
-			if ( empty( $invoice->ID ) ) {
254
-				return;
255
-			}
256
-
257
-			$fields = array(
258
-				'post_id'            => $invoice->ID,
259
-				'number'             => $invoice->get_number(),
260
-				'key'                => $invoice->get_key(),
261
-				'type'               => str_replace( 'wpi_', '', $invoice->post_type ),
262
-				'mode'               => $invoice->mode,
263
-				'user_ip'            => $invoice->get_ip(),
264
-				'first_name'         => $invoice->get_first_name(),
265
-				'last_name'          => $invoice->get_last_name(),
266
-				'address'            => $invoice->get_address(),
267
-				'city'               => $invoice->city,
268
-				'state'              => $invoice->state,
269
-				'country'            => $invoice->country,
270
-				'zip'                => $invoice->zip,
271
-				'adddress_confirmed' => (int) $invoice->adddress_confirmed,
272
-				'gateway'            => $invoice->get_gateway(),
273
-				'transaction_id'     => $invoice->get_transaction_id(),
274
-				'currency'           => $invoice->get_currency(),
275
-				'subtotal'           => $invoice->get_subtotal(),
276
-				'tax'                => $invoice->get_tax(),
277
-				'fees_total'         => $invoice->get_fees_total(),
278
-				'total'              => $invoice->get_total(),
279
-				'discount'           => $invoice->get_discount(),
280
-				'discount_code'      => $invoice->get_discount_code(),
281
-				'disable_taxes'      => $invoice->disable_taxes,
282
-				'due_date'           => $invoice->get_due_date(),
283
-				'completed_date'     => $invoice->get_completed_date(),
284
-				'company'            => $invoice->company,
285
-				'vat_number'         => $invoice->vat_number,
286
-				'vat_rate'           => $invoice->vat_rate,
287
-				'custom_meta'        => $invoice->payment_meta,
288
-			);
289
-
290
-			foreach ( $fields as $key => $val ) {
291
-				if ( is_null( $val ) ) {
292
-					$val = '';
293
-				}
294
-				$val = maybe_serialize( $val );
295
-				$fields[ $key ] = $wpdb->prepare( '%s', $val );
296
-			}
297
-
298
-			$fields = implode( ', ', $fields );
299
-			$invoice_rows[] = "($fields)";
300
-
301
-			$item_rows    = array();
302
-			$item_columns = array();
303
-			foreach ( $invoice->get_cart_details() as $details ) {
304
-				$fields = array(
305
-					'post_id'          => $invoice->ID,
306
-					'item_id'          => $details['id'],
307
-					'item_name'        => $details['name'],
308
-					'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'],
309
-					'vat_rate'         => $details['vat_rate'],
310
-					'vat_class'        => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'],
311
-					'tax'              => $details['tax'],
312
-					'item_price'       => $details['item_price'],
313
-					'custom_price'     => $details['custom_price'],
314
-					'quantity'         => $details['quantity'],
315
-					'discount'         => $details['discount'],
316
-					'subtotal'         => $details['subtotal'],
317
-					'price'            => $details['price'],
318
-					'meta'             => $details['meta'],
319
-					'fees'             => $details['fees'],
320
-				);
321
-
322
-				$item_columns = array_keys( $fields );
323
-
324
-				foreach ( $fields as $key => $val ) {
325
-					if ( is_null( $val ) ) {
326
-						$val = '';
327
-					}
328
-					$val = maybe_serialize( $val );
329
-					$fields[ $key ] = $wpdb->prepare( '%s', $val );
330
-				}
331
-
332
-				$fields = implode( ', ', $fields );
333
-				$item_rows[] = "($fields)";
334
-			}
335
-
336
-			$item_rows    = implode( ', ', $item_rows );
337
-			$item_columns = implode( ', ', $item_columns );
338
-			$wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" );
339
-		}
340
-
341
-		if ( empty( $invoice_rows ) ) {
342
-			return;
343
-		}
344
-
345
-		$invoice_rows = implode( ', ', $invoice_rows );
346
-		$wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" );
347
-
348
-	}
349
-
350
-	/**
351
-	 * Migrates old customers to new table.
352
-	 *
353
-	 */
354
-	public static function migrate_old_customers() {
355
-		global $wpdb;
356
-
357
-		// Fetch post_id from $wpdb->prefix . 'getpaid_invoices' where customer_id = 0 or null.
358
-		$invoice_ids = $wpdb->get_col( "SELECT post_id FROM {$wpdb->prefix}getpaid_invoices WHERE customer_id = 0 OR customer_id IS NULL" );
359
-
360
-		foreach ( $invoice_ids as $invoice_id ) {
361
-			$invoice = wpinv_get_invoice( $invoice_id );
362
-
363
-			if ( empty( $invoice ) ) {
364
-				continue;
365
-			}
366
-
367
-			// Fetch customer from the user ID.
368
-			$user_id = $invoice->get_user_id();
369
-
370
-			if ( empty( $user_id ) ) {
371
-				continue;
372
-			}
373
-
374
-			$customer = getpaid_get_customer_by_user_id( $user_id );
375
-
376
-			// Create if not exists.
377
-			if ( empty( $customer ) ) {
378
-				$customer = new GetPaid_Customer( 0 );
379
-				$customer->clone_user( $user_id );
380
-				$customer->save();
381
-			}
382
-
383
-			$invoice->set_customer_id( $customer->get_id() );
384
-			$invoice->save();
385
-		}
386
-
387
-	}
388
-
389
-	/**
390
-	 * Migrates old invoices to new invoices.
391
-	 *
392
-	 */
393
-	public static function rename_gateways_label() {
394
-		global $wpdb;
395
-
396
-		foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) {
397
-
398
-			$wpdb->update(
399
-				$wpdb->prefix . 'getpaid_invoices',
400
-				array( 'gateway' => $gateway ),
401
-				array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ),
402
-				'%s',
403
-				'%s'
404
-			);
405
-
406
-		}
407
-	}
408
-
409
-	/**
410
-	 * Returns the DB schema.
411
-	 *
412
-	 */
413
-	public static function get_db_schema() {
414
-		global $wpdb;
415
-
416
-		if ( ! empty( self::$schema ) ) {
417
-			return self::$schema;
418
-		}
199
+                    'parent'  => '',
200
+                ),
201
+
202
+            )
203
+        );
204
+
205
+    }
206
+
207
+    /**
208
+     * Re-create GetPaid pages.
209
+     *
210
+     */
211
+    public function create_pages() {
212
+
213
+        foreach ( self::get_pages() as $key => $page ) {
214
+            wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] );
215
+        }
216
+
217
+    }
218
+
219
+    /**
220
+     * Migrates old invoices to new invoices.
221
+     *
222
+     */
223
+    public function migrate_old_invoices() {
224
+        global $wpdb;
225
+
226
+        $invoices_table      = $wpdb->prefix . 'getpaid_invoices';
227
+        $invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items';
228
+        $migrated            = $wpdb->get_col( "SELECT post_id FROM $invoices_table" );
229
+        $invoices            = array_unique(
230
+            get_posts(
231
+                array(
232
+                    'post_type'      => array( 'wpi_invoice', 'wpi_quote' ),
233
+                    'posts_per_page' => -1,
234
+                    'fields'         => 'ids',
235
+                    'post_status'    => array_keys( get_post_stati() ),
236
+                    'exclude'        => (array) $migrated,
237
+                )
238
+            )
239
+        );
240
+
241
+        // Abort if we do not have any invoices.
242
+        if ( empty( $invoices ) ) {
243
+            return;
244
+        }
245
+
246
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php';
247
+
248
+        $invoice_rows = array();
249
+        foreach ( $invoices as $invoice ) {
250
+
251
+            $invoice = new WPInv_Legacy_Invoice( $invoice );
252
+
253
+            if ( empty( $invoice->ID ) ) {
254
+                return;
255
+            }
256
+
257
+            $fields = array(
258
+                'post_id'            => $invoice->ID,
259
+                'number'             => $invoice->get_number(),
260
+                'key'                => $invoice->get_key(),
261
+                'type'               => str_replace( 'wpi_', '', $invoice->post_type ),
262
+                'mode'               => $invoice->mode,
263
+                'user_ip'            => $invoice->get_ip(),
264
+                'first_name'         => $invoice->get_first_name(),
265
+                'last_name'          => $invoice->get_last_name(),
266
+                'address'            => $invoice->get_address(),
267
+                'city'               => $invoice->city,
268
+                'state'              => $invoice->state,
269
+                'country'            => $invoice->country,
270
+                'zip'                => $invoice->zip,
271
+                'adddress_confirmed' => (int) $invoice->adddress_confirmed,
272
+                'gateway'            => $invoice->get_gateway(),
273
+                'transaction_id'     => $invoice->get_transaction_id(),
274
+                'currency'           => $invoice->get_currency(),
275
+                'subtotal'           => $invoice->get_subtotal(),
276
+                'tax'                => $invoice->get_tax(),
277
+                'fees_total'         => $invoice->get_fees_total(),
278
+                'total'              => $invoice->get_total(),
279
+                'discount'           => $invoice->get_discount(),
280
+                'discount_code'      => $invoice->get_discount_code(),
281
+                'disable_taxes'      => $invoice->disable_taxes,
282
+                'due_date'           => $invoice->get_due_date(),
283
+                'completed_date'     => $invoice->get_completed_date(),
284
+                'company'            => $invoice->company,
285
+                'vat_number'         => $invoice->vat_number,
286
+                'vat_rate'           => $invoice->vat_rate,
287
+                'custom_meta'        => $invoice->payment_meta,
288
+            );
289
+
290
+            foreach ( $fields as $key => $val ) {
291
+                if ( is_null( $val ) ) {
292
+                    $val = '';
293
+                }
294
+                $val = maybe_serialize( $val );
295
+                $fields[ $key ] = $wpdb->prepare( '%s', $val );
296
+            }
297
+
298
+            $fields = implode( ', ', $fields );
299
+            $invoice_rows[] = "($fields)";
300
+
301
+            $item_rows    = array();
302
+            $item_columns = array();
303
+            foreach ( $invoice->get_cart_details() as $details ) {
304
+                $fields = array(
305
+                    'post_id'          => $invoice->ID,
306
+                    'item_id'          => $details['id'],
307
+                    'item_name'        => $details['name'],
308
+                    'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'],
309
+                    'vat_rate'         => $details['vat_rate'],
310
+                    'vat_class'        => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'],
311
+                    'tax'              => $details['tax'],
312
+                    'item_price'       => $details['item_price'],
313
+                    'custom_price'     => $details['custom_price'],
314
+                    'quantity'         => $details['quantity'],
315
+                    'discount'         => $details['discount'],
316
+                    'subtotal'         => $details['subtotal'],
317
+                    'price'            => $details['price'],
318
+                    'meta'             => $details['meta'],
319
+                    'fees'             => $details['fees'],
320
+                );
321
+
322
+                $item_columns = array_keys( $fields );
323
+
324
+                foreach ( $fields as $key => $val ) {
325
+                    if ( is_null( $val ) ) {
326
+                        $val = '';
327
+                    }
328
+                    $val = maybe_serialize( $val );
329
+                    $fields[ $key ] = $wpdb->prepare( '%s', $val );
330
+                }
331
+
332
+                $fields = implode( ', ', $fields );
333
+                $item_rows[] = "($fields)";
334
+            }
335
+
336
+            $item_rows    = implode( ', ', $item_rows );
337
+            $item_columns = implode( ', ', $item_columns );
338
+            $wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" );
339
+        }
340
+
341
+        if ( empty( $invoice_rows ) ) {
342
+            return;
343
+        }
344
+
345
+        $invoice_rows = implode( ', ', $invoice_rows );
346
+        $wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" );
347
+
348
+    }
349
+
350
+    /**
351
+     * Migrates old customers to new table.
352
+     *
353
+     */
354
+    public static function migrate_old_customers() {
355
+        global $wpdb;
356
+
357
+        // Fetch post_id from $wpdb->prefix . 'getpaid_invoices' where customer_id = 0 or null.
358
+        $invoice_ids = $wpdb->get_col( "SELECT post_id FROM {$wpdb->prefix}getpaid_invoices WHERE customer_id = 0 OR customer_id IS NULL" );
359
+
360
+        foreach ( $invoice_ids as $invoice_id ) {
361
+            $invoice = wpinv_get_invoice( $invoice_id );
362
+
363
+            if ( empty( $invoice ) ) {
364
+                continue;
365
+            }
366
+
367
+            // Fetch customer from the user ID.
368
+            $user_id = $invoice->get_user_id();
369
+
370
+            if ( empty( $user_id ) ) {
371
+                continue;
372
+            }
373
+
374
+            $customer = getpaid_get_customer_by_user_id( $user_id );
375
+
376
+            // Create if not exists.
377
+            if ( empty( $customer ) ) {
378
+                $customer = new GetPaid_Customer( 0 );
379
+                $customer->clone_user( $user_id );
380
+                $customer->save();
381
+            }
382
+
383
+            $invoice->set_customer_id( $customer->get_id() );
384
+            $invoice->save();
385
+        }
386
+
387
+    }
388
+
389
+    /**
390
+     * Migrates old invoices to new invoices.
391
+     *
392
+     */
393
+    public static function rename_gateways_label() {
394
+        global $wpdb;
395
+
396
+        foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) {
397
+
398
+            $wpdb->update(
399
+                $wpdb->prefix . 'getpaid_invoices',
400
+                array( 'gateway' => $gateway ),
401
+                array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ),
402
+                '%s',
403
+                '%s'
404
+            );
405
+
406
+        }
407
+    }
408
+
409
+    /**
410
+     * Returns the DB schema.
411
+     *
412
+     */
413
+    public static function get_db_schema() {
414
+        global $wpdb;
415
+
416
+        if ( ! empty( self::$schema ) ) {
417
+            return self::$schema;
418
+        }
419 419
 
420
-		require_once ABSPATH . 'wp-admin/includes/upgrade.php';
420
+        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
421 421
 
422
-		$charset_collate = $wpdb->get_charset_collate();
422
+        $charset_collate = $wpdb->get_charset_collate();
423 423
 
424
-		$schema = array();
424
+        $schema = array();
425 425
 
426
-		// Subscriptions.
427
-		$schema['subscriptions'] = "CREATE TABLE {$wpdb->prefix}wpinv_subscriptions (
426
+        // Subscriptions.
427
+        $schema['subscriptions'] = "CREATE TABLE {$wpdb->prefix}wpinv_subscriptions (
428 428
 			id bigint(20) unsigned NOT NULL auto_increment,
429 429
 			customer_id bigint(20) NOT NULL,
430 430
 			frequency int(11) NOT NULL DEFAULT '1',
@@ -447,8 +447,8 @@  discard block
 block discarded – undo
447 447
 			KEY customer_and_status (customer_id, status)
448 448
 		  ) $charset_collate;";
449 449
 
450
-		// Invoices.
451
-		$schema['invoices'] = "CREATE TABLE {$wpdb->prefix}getpaid_invoices (
450
+        // Invoices.
451
+        $schema['invoices'] = "CREATE TABLE {$wpdb->prefix}getpaid_invoices (
452 452
 			post_id BIGINT(20) NOT NULL,
453 453
 			customer_id BIGINT(20) NOT NULL DEFAULT 0,
454 454
             `number` VARCHAR(100),
@@ -486,8 +486,8 @@  discard block
 block discarded – undo
486 486
 			KEY invoice_key (invoice_key)
487 487
 		  ) $charset_collate;";
488 488
 
489
-		// Invoice items.
490
-		$schema['items'] = "CREATE TABLE {$wpdb->prefix}getpaid_invoice_items (
489
+        // Invoice items.
490
+        $schema['items'] = "CREATE TABLE {$wpdb->prefix}getpaid_invoice_items (
491 491
 			ID BIGINT(20) NOT NULL AUTO_INCREMENT,
492 492
             post_id BIGINT(20) NOT NULL,
493 493
             item_id BIGINT(20) NOT NULL,
@@ -509,8 +509,8 @@  discard block
 block discarded – undo
509 509
 			KEY post_id (post_id)
510 510
 		  ) $charset_collate;";
511 511
 
512
-		// Customers.
513
-		$schema['customers'] = "CREATE TABLE {$wpdb->prefix}getpaid_customers (
512
+        // Customers.
513
+        $schema['customers'] = "CREATE TABLE {$wpdb->prefix}getpaid_customers (
514 514
 			id BIGINT(20) NOT NULL AUTO_INCREMENT,
515 515
 			user_id BIGINT(20) NOT NULL,
516 516
 			email VARCHAR(100) NOT NULL,
@@ -520,38 +520,38 @@  discard block
 block discarded – undo
520 520
 			purchase_count BIGINT(20) NOT NULL DEFAULT 0,
521 521
 			";
522 522
 
523
-		// Add address fields.
524
-		foreach ( array_keys( getpaid_user_address_fields( true ) ) as $field ) {
525
-			// Skip id, user_id and email.
526
-			if ( in_array( $field, array( 'id', 'user_id', 'email', 'purchase_value', 'purchase_count', 'date_created', 'date_modified', 'uuid' ), true ) ) {
527
-				continue;
528
-			}
529
-
530
-			$field   = sanitize_key( $field );
531
-			$length  = 100;
532
-			$default = '';
533
-
534
-			// Country.
535
-			if ( 'country' === $field ) {
536
-				$length  = 2;
537
-				$default = wpinv_get_default_country();
538
-			}
539
-
540
-			// State.
541
-			if ( 'state' === $field ) {
542
-				$default = wpinv_get_default_state();
543
-			}
544
-
545
-			// Phone, zip.
546
-			if ( in_array( $field, array( 'phone', 'zip' ), true ) ) {
547
-				$length = 20;
548
-			}
549
-
550
-			$schema['customers'] .= "`$field` VARCHAR($length) NOT NULL DEFAULT '$default',
523
+        // Add address fields.
524
+        foreach ( array_keys( getpaid_user_address_fields( true ) ) as $field ) {
525
+            // Skip id, user_id and email.
526
+            if ( in_array( $field, array( 'id', 'user_id', 'email', 'purchase_value', 'purchase_count', 'date_created', 'date_modified', 'uuid' ), true ) ) {
527
+                continue;
528
+            }
529
+
530
+            $field   = sanitize_key( $field );
531
+            $length  = 100;
532
+            $default = '';
533
+
534
+            // Country.
535
+            if ( 'country' === $field ) {
536
+                $length  = 2;
537
+                $default = wpinv_get_default_country();
538
+            }
539
+
540
+            // State.
541
+            if ( 'state' === $field ) {
542
+                $default = wpinv_get_default_state();
543
+            }
544
+
545
+            // Phone, zip.
546
+            if ( in_array( $field, array( 'phone', 'zip' ), true ) ) {
547
+                $length = 20;
548
+            }
549
+
550
+            $schema['customers'] .= "`$field` VARCHAR($length) NOT NULL DEFAULT '$default',
551 551
 			";
552
-		}
552
+        }
553 553
 
554
-		$schema['customers'] .= "date_created DATETIME NOT NULL,
554
+        $schema['customers'] .= "date_created DATETIME NOT NULL,
555 555
 			date_modified DATETIME NOT NULL,
556 556
 			uuid VARCHAR(100) NOT NULL,
557 557
 			is_anonymized INT(2) NOT NULL DEFAULT 0,
@@ -561,8 +561,8 @@  discard block
 block discarded – undo
561 561
 			KEY email (email)
562 562
 		  ) $charset_collate;";
563 563
 
564
-		// Customer meta.
565
-		$schema['customer_meta'] = "CREATE TABLE {$wpdb->prefix}getpaid_customer_meta (
564
+        // Customer meta.
565
+        $schema['customer_meta'] = "CREATE TABLE {$wpdb->prefix}getpaid_customer_meta (
566 566
 			meta_id BIGINT(20) NOT NULL AUTO_INCREMENT,
567 567
 			customer_id BIGINT(20) NOT NULL,
568 568
 			meta_key VARCHAR(255) NOT NULL,
@@ -572,8 +572,8 @@  discard block
 block discarded – undo
572 572
 			KEY meta_key (meta_key(191))
573 573
 		  ) $charset_collate;";
574 574
 
575
-		// Anonymization Logs.
576
-		$schema['anonymization_logs'] = "CREATE TABLE {$wpdb->prefix}getpaid_anonymization_logs (
575
+        // Anonymization Logs.
576
+        $schema['anonymization_logs'] = "CREATE TABLE {$wpdb->prefix}getpaid_anonymization_logs (
577 577
 			log_id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
578 578
 			user_id BIGINT(20) UNSIGNED NOT NULL,
579 579
 			action VARCHAR(50) NOT NULL,
@@ -587,75 +587,75 @@  discard block
 block discarded – undo
587 587
 			KEY timestamp (timestamp)
588 588
 		) $charset_collate;";
589 589
 
590
-		// Filter.
591
-		$schema = apply_filters( 'getpaid_db_schema', $schema );
592
-
593
-		self::$schema         = implode( "\n", array_values( $schema ) );
594
-		self::$schema_version = md5( sanitize_key( self::$schema ) );
595
-
596
-		return self::$schema;
597
-	}
598
-
599
-	/**
600
-	 * Returns the DB schema version.
601
-	 *
602
-	 */
603
-	public static function get_db_schema_version() {
604
-		if ( ! empty( self::$schema_version ) ) {
605
-			return self::$schema_version;
606
-		}
607
-
608
-		self::get_db_schema();
609
-
610
-		return self::$schema_version;
611
-	}
612
-
613
-	/**
614
-	 * Checks if the db schema is up to date.
615
-	 *
616
-	 * @return bool
617
-	 */
618
-	public static function is_db_schema_up_to_date() {
619
-		return self::get_db_schema_version() === get_option( 'getpaid_db_schema' );
620
-	}
621
-
622
-	/**
623
-	 * Set up the database tables which the plugin needs to function.
624
-	 */
625
-	public static function create_db_tables() {
626
-		global $wpdb;
627
-
628
-		$wpdb->hide_errors();
629
-
630
-		require_once ABSPATH . 'wp-admin/includes/upgrade.php';
631
-
632
-		$schema = self::get_db_schema();
633
-
634
-		// If invoices table exists, rename key to invoice_key.
635
-		$invoices_table = "{$wpdb->prefix}getpaid_invoices";
636
-
637
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) === $invoices_table ) {
638
-			$fields = $wpdb->get_results( "SHOW COLUMNS FROM {$wpdb->prefix}getpaid_invoices" );
639
-
640
-			foreach ( $fields as $field ) {
641
-				if ( 'key' === $field->Field ) {
642
-					$wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoices CHANGE `key` `invoice_key` VARCHAR(100)" );
643
-					break;
644
-				}
645
-			}
646
-		}
647
-
648
-		dbDelta( $schema );
649
-		wp_cache_flush();
650
-		update_option( 'getpaid_db_schema', self::get_db_schema_version() );
651
-	}
652
-
653
-	/**
654
-	 * Creates tables if schema is not up to date.
655
-	 */
656
-	public static function maybe_create_db_tables() {
657
-		if ( ! self::is_db_schema_up_to_date() ) {
658
-			self::create_db_tables();
659
-		}
660
-	}
590
+        // Filter.
591
+        $schema = apply_filters( 'getpaid_db_schema', $schema );
592
+
593
+        self::$schema         = implode( "\n", array_values( $schema ) );
594
+        self::$schema_version = md5( sanitize_key( self::$schema ) );
595
+
596
+        return self::$schema;
597
+    }
598
+
599
+    /**
600
+     * Returns the DB schema version.
601
+     *
602
+     */
603
+    public static function get_db_schema_version() {
604
+        if ( ! empty( self::$schema_version ) ) {
605
+            return self::$schema_version;
606
+        }
607
+
608
+        self::get_db_schema();
609
+
610
+        return self::$schema_version;
611
+    }
612
+
613
+    /**
614
+     * Checks if the db schema is up to date.
615
+     *
616
+     * @return bool
617
+     */
618
+    public static function is_db_schema_up_to_date() {
619
+        return self::get_db_schema_version() === get_option( 'getpaid_db_schema' );
620
+    }
621
+
622
+    /**
623
+     * Set up the database tables which the plugin needs to function.
624
+     */
625
+    public static function create_db_tables() {
626
+        global $wpdb;
627
+
628
+        $wpdb->hide_errors();
629
+
630
+        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
631
+
632
+        $schema = self::get_db_schema();
633
+
634
+        // If invoices table exists, rename key to invoice_key.
635
+        $invoices_table = "{$wpdb->prefix}getpaid_invoices";
636
+
637
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) === $invoices_table ) {
638
+            $fields = $wpdb->get_results( "SHOW COLUMNS FROM {$wpdb->prefix}getpaid_invoices" );
639
+
640
+            foreach ( $fields as $field ) {
641
+                if ( 'key' === $field->Field ) {
642
+                    $wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoices CHANGE `key` `invoice_key` VARCHAR(100)" );
643
+                    break;
644
+                }
645
+            }
646
+        }
647
+
648
+        dbDelta( $schema );
649
+        wp_cache_flush();
650
+        update_option( 'getpaid_db_schema', self::get_db_schema_version() );
651
+    }
652
+
653
+    /**
654
+     * Creates tables if schema is not up to date.
655
+     */
656
+    public static function maybe_create_db_tables() {
657
+        if ( ! self::is_db_schema_up_to_date() ) {
658
+            self::create_db_tables();
659
+        }
660
+    }
661 661
 }
Please login to merge, or discard this patch.
Spacing   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @since   2.0.2
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * The main installer/updater class.
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
28 28
 	 *
29 29
 	 * @param string $upgrade_from The current invoicing version.
30 30
 	 */
31
-	public function upgrade_db( $upgrade_from ) {
31
+	public function upgrade_db($upgrade_from) {
32 32
 
33 33
 		// Save the current invoicing version.
34
-		update_option( 'wpinv_version', WPINV_VERSION );
34
+		update_option('wpinv_version', WPINV_VERSION);
35 35
 
36 36
 		// Setup the invoice Custom Post Type.
37 37
 		GetPaid_Post_Types::register_post_types();
@@ -51,13 +51,13 @@  discard block
 block discarded – undo
51 51
 		// Create any missing database tables.
52 52
 		$method = "upgrade_from_$upgrade_from";
53 53
 
54
-		$installed = get_option( 'gepaid_installed_on' );
54
+		$installed = get_option('gepaid_installed_on');
55 55
 
56
-		if ( empty( $installed ) ) {
57
-			update_option( 'gepaid_installed_on', time() );
56
+		if (empty($installed)) {
57
+			update_option('gepaid_installed_on', time());
58 58
 		}
59 59
 
60
-		if ( method_exists( $this, $method ) ) {
60
+		if (method_exists($this, $method)) {
61 61
 			$this->$method();
62 62
 		}
63 63
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	public function upgrade_from_0() {
71 71
 
72 72
 		// Save default tax rates.
73
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
73
+		update_option('wpinv_tax_rates', wpinv_get_data('tax-rates'));
74 74
 	}
75 75
 
76 76
 	/**
@@ -81,27 +81,27 @@  discard block
 block discarded – undo
81 81
 		global $wpdb;
82 82
 
83 83
 		// Invoices.
84
-		$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' )" );
85
-		if ( ! empty( $results ) ) {
86
-			$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' )" );
84
+		$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' )");
85
+		if (!empty($results)) {
86
+			$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' )");
87 87
 
88 88
 			// Clean post cache
89
-			foreach ( $results as $row ) {
90
-				clean_post_cache( $row->ID );
89
+			foreach ($results as $row) {
90
+				clean_post_cache($row->ID);
91 91
 			}
92 92
 		}
93 93
 
94 94
 		// Item meta key changes
95 95
 		$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' )";
96
-		$results = $wpdb->get_results( $query );
96
+		$results = $wpdb->get_results($query);
97 97
 
98
-		if ( ! empty( $results ) ) {
99
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
100
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
101
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
98
+		if (!empty($results)) {
99
+			$wpdb->query('UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )");
100
+			$wpdb->query('UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'");
101
+			$wpdb->query('UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'");
102 102
 
103
-			foreach ( $results as $row ) {
104
-				clean_post_cache( $row->post_id );
103
+			foreach ($results as $row) {
104
+				clean_post_cache($row->post_id);
105 105
 			}
106 106
 		}
107 107
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 *
131 131
 	 */
132 132
 	public function add_capabilities() {
133
-		$GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' );
133
+		$GLOBALS['wp_roles']->add_cap('administrator', 'manage_invoicing');
134 134
 	}
135 135
 
136 136
 	/**
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
 
146 146
 				// Checkout page.
147 147
 				'checkout_page'             => array(
148
-					'name'    => _x( 'gp-checkout', 'Page slug', 'invoicing' ),
149
-					'title'   => _x( 'Checkout', 'Page title', 'invoicing' ),
148
+					'name'    => _x('gp-checkout', 'Page slug', 'invoicing'),
149
+					'title'   => _x('Checkout', 'Page title', 'invoicing'),
150 150
 					'content' => '
151 151
 						<!-- wp:shortcode -->
152 152
 						[wpinv_checkout]
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
 
158 158
 				// Invoice history page.
159 159
 				'invoice_history_page'      => array(
160
-					'name'    => _x( 'gp-invoices', 'Page slug', 'invoicing' ),
161
-					'title'   => _x( 'My Invoices', 'Page title', 'invoicing' ),
160
+					'name'    => _x('gp-invoices', 'Page slug', 'invoicing'),
161
+					'title'   => _x('My Invoices', 'Page title', 'invoicing'),
162 162
 					'content' => '
163 163
 					<!-- wp:shortcode -->
164 164
 					[wpinv_history]
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
 
170 170
 				// Success page content.
171 171
 				'success_page'              => array(
172
-					'name'    => _x( 'gp-receipt', 'Page slug', 'invoicing' ),
173
-					'title'   => _x( 'Payment Confirmation', 'Page title', 'invoicing' ),
172
+					'name'    => _x('gp-receipt', 'Page slug', 'invoicing'),
173
+					'title'   => _x('Payment Confirmation', 'Page title', 'invoicing'),
174 174
 					'content' => '
175 175
 					<!-- wp:shortcode -->
176 176
 					[wpinv_receipt]
@@ -181,16 +181,16 @@  discard block
 block discarded – undo
181 181
 
182 182
 				// Failure page content.
183 183
 				'failure_page'              => array(
184
-					'name'    => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ),
185
-					'title'   => _x( 'Transaction Failed', 'Page title', 'invoicing' ),
186
-					'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ),
184
+					'name'    => _x('gp-transaction-failed', 'Page slug', 'invoicing'),
185
+					'title'   => _x('Transaction Failed', 'Page title', 'invoicing'),
186
+					'content' => __('Your transaction failed, please try again or contact site support.', 'invoicing'),
187 187
 					'parent'  => 'gp-checkout',
188 188
 				),
189 189
 
190 190
 				// Subscriptions history page.
191 191
 				'invoice_subscription_page' => array(
192
-					'name'    => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ),
193
-					'title'   => _x( 'My Subscriptions', 'Page title', 'invoicing' ),
192
+					'name'    => _x('gp-subscriptions', 'Page slug', 'invoicing'),
193
+					'title'   => _x('My Subscriptions', 'Page title', 'invoicing'),
194 194
 					'content' => '
195 195
 					<!-- wp:shortcode -->
196 196
 					[wpinv_subscriptions]
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
 	 */
211 211
 	public function create_pages() {
212 212
 
213
-		foreach ( self::get_pages() as $key => $page ) {
214
-			wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] );
213
+		foreach (self::get_pages() as $key => $page) {
214
+			wpinv_create_page(esc_sql($page['name']), $key, $page['title'], $page['content'], $page['parent']);
215 215
 		}
216 216
 
217 217
 	}
@@ -225,32 +225,32 @@  discard block
 block discarded – undo
225 225
 
226 226
 		$invoices_table      = $wpdb->prefix . 'getpaid_invoices';
227 227
 		$invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items';
228
-		$migrated            = $wpdb->get_col( "SELECT post_id FROM $invoices_table" );
228
+		$migrated            = $wpdb->get_col("SELECT post_id FROM $invoices_table");
229 229
 		$invoices            = array_unique(
230 230
 			get_posts(
231 231
 				array(
232
-					'post_type'      => array( 'wpi_invoice', 'wpi_quote' ),
232
+					'post_type'      => array('wpi_invoice', 'wpi_quote'),
233 233
 					'posts_per_page' => -1,
234 234
 					'fields'         => 'ids',
235
-					'post_status'    => array_keys( get_post_stati() ),
235
+					'post_status'    => array_keys(get_post_stati()),
236 236
 					'exclude'        => (array) $migrated,
237 237
 				)
238 238
 			)
239 239
 		);
240 240
 
241 241
 		// Abort if we do not have any invoices.
242
-		if ( empty( $invoices ) ) {
242
+		if (empty($invoices)) {
243 243
 			return;
244 244
 		}
245 245
 
246 246
 		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php';
247 247
 
248 248
 		$invoice_rows = array();
249
-		foreach ( $invoices as $invoice ) {
249
+		foreach ($invoices as $invoice) {
250 250
 
251
-			$invoice = new WPInv_Legacy_Invoice( $invoice );
251
+			$invoice = new WPInv_Legacy_Invoice($invoice);
252 252
 
253
-			if ( empty( $invoice->ID ) ) {
253
+			if (empty($invoice->ID)) {
254 254
 				return;
255 255
 			}
256 256
 
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 				'post_id'            => $invoice->ID,
259 259
 				'number'             => $invoice->get_number(),
260 260
 				'key'                => $invoice->get_key(),
261
-				'type'               => str_replace( 'wpi_', '', $invoice->post_type ),
261
+				'type'               => str_replace('wpi_', '', $invoice->post_type),
262 262
 				'mode'               => $invoice->mode,
263 263
 				'user_ip'            => $invoice->get_ip(),
264 264
 				'first_name'         => $invoice->get_first_name(),
@@ -287,27 +287,27 @@  discard block
 block discarded – undo
287 287
 				'custom_meta'        => $invoice->payment_meta,
288 288
 			);
289 289
 
290
-			foreach ( $fields as $key => $val ) {
291
-				if ( is_null( $val ) ) {
290
+			foreach ($fields as $key => $val) {
291
+				if (is_null($val)) {
292 292
 					$val = '';
293 293
 				}
294
-				$val = maybe_serialize( $val );
295
-				$fields[ $key ] = $wpdb->prepare( '%s', $val );
294
+				$val = maybe_serialize($val);
295
+				$fields[$key] = $wpdb->prepare('%s', $val);
296 296
 			}
297 297
 
298
-			$fields = implode( ', ', $fields );
298
+			$fields = implode(', ', $fields);
299 299
 			$invoice_rows[] = "($fields)";
300 300
 
301 301
 			$item_rows    = array();
302 302
 			$item_columns = array();
303
-			foreach ( $invoice->get_cart_details() as $details ) {
303
+			foreach ($invoice->get_cart_details() as $details) {
304 304
 				$fields = array(
305 305
 					'post_id'          => $invoice->ID,
306 306
 					'item_id'          => $details['id'],
307 307
 					'item_name'        => $details['name'],
308
-					'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'],
308
+					'item_description' => empty($details['meta']['description']) ? '' : $details['meta']['description'],
309 309
 					'vat_rate'         => $details['vat_rate'],
310
-					'vat_class'        => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'],
310
+					'vat_class'        => empty($details['vat_class']) ? '_standard' : $details['vat_class'],
311 311
 					'tax'              => $details['tax'],
312 312
 					'item_price'       => $details['item_price'],
313 313
 					'custom_price'     => $details['custom_price'],
@@ -319,31 +319,31 @@  discard block
 block discarded – undo
319 319
 					'fees'             => $details['fees'],
320 320
 				);
321 321
 
322
-				$item_columns = array_keys( $fields );
322
+				$item_columns = array_keys($fields);
323 323
 
324
-				foreach ( $fields as $key => $val ) {
325
-					if ( is_null( $val ) ) {
324
+				foreach ($fields as $key => $val) {
325
+					if (is_null($val)) {
326 326
 						$val = '';
327 327
 					}
328
-					$val = maybe_serialize( $val );
329
-					$fields[ $key ] = $wpdb->prepare( '%s', $val );
328
+					$val = maybe_serialize($val);
329
+					$fields[$key] = $wpdb->prepare('%s', $val);
330 330
 				}
331 331
 
332
-				$fields = implode( ', ', $fields );
332
+				$fields = implode(', ', $fields);
333 333
 				$item_rows[] = "($fields)";
334 334
 			}
335 335
 
336
-			$item_rows    = implode( ', ', $item_rows );
337
-			$item_columns = implode( ', ', $item_columns );
338
-			$wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" );
336
+			$item_rows    = implode(', ', $item_rows);
337
+			$item_columns = implode(', ', $item_columns);
338
+			$wpdb->query("INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows");
339 339
 		}
340 340
 
341
-		if ( empty( $invoice_rows ) ) {
341
+		if (empty($invoice_rows)) {
342 342
 			return;
343 343
 		}
344 344
 
345
-		$invoice_rows = implode( ', ', $invoice_rows );
346
-		$wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" );
345
+		$invoice_rows = implode(', ', $invoice_rows);
346
+		$wpdb->query("INSERT INTO $invoices_table VALUES $invoice_rows");
347 347
 
348 348
 	}
349 349
 
@@ -355,32 +355,32 @@  discard block
 block discarded – undo
355 355
 		global $wpdb;
356 356
 
357 357
 		// Fetch post_id from $wpdb->prefix . 'getpaid_invoices' where customer_id = 0 or null.
358
-		$invoice_ids = $wpdb->get_col( "SELECT post_id FROM {$wpdb->prefix}getpaid_invoices WHERE customer_id = 0 OR customer_id IS NULL" );
358
+		$invoice_ids = $wpdb->get_col("SELECT post_id FROM {$wpdb->prefix}getpaid_invoices WHERE customer_id = 0 OR customer_id IS NULL");
359 359
 
360
-		foreach ( $invoice_ids as $invoice_id ) {
361
-			$invoice = wpinv_get_invoice( $invoice_id );
360
+		foreach ($invoice_ids as $invoice_id) {
361
+			$invoice = wpinv_get_invoice($invoice_id);
362 362
 
363
-			if ( empty( $invoice ) ) {
363
+			if (empty($invoice)) {
364 364
 				continue;
365 365
 			}
366 366
 
367 367
 			// Fetch customer from the user ID.
368 368
 			$user_id = $invoice->get_user_id();
369 369
 
370
-			if ( empty( $user_id ) ) {
370
+			if (empty($user_id)) {
371 371
 				continue;
372 372
 			}
373 373
 
374
-			$customer = getpaid_get_customer_by_user_id( $user_id );
374
+			$customer = getpaid_get_customer_by_user_id($user_id);
375 375
 
376 376
 			// Create if not exists.
377
-			if ( empty( $customer ) ) {
378
-				$customer = new GetPaid_Customer( 0 );
379
-				$customer->clone_user( $user_id );
377
+			if (empty($customer)) {
378
+				$customer = new GetPaid_Customer(0);
379
+				$customer->clone_user($user_id);
380 380
 				$customer->save();
381 381
 			}
382 382
 
383
-			$invoice->set_customer_id( $customer->get_id() );
383
+			$invoice->set_customer_id($customer->get_id());
384 384
 			$invoice->save();
385 385
 		}
386 386
 
@@ -393,12 +393,12 @@  discard block
 block discarded – undo
393 393
 	public static function rename_gateways_label() {
394 394
 		global $wpdb;
395 395
 
396
-		foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) {
396
+		foreach (array_keys(wpinv_get_payment_gateways()) as $gateway) {
397 397
 
398 398
 			$wpdb->update(
399 399
 				$wpdb->prefix . 'getpaid_invoices',
400
-				array( 'gateway' => $gateway ),
401
-				array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ),
400
+				array('gateway' => $gateway),
401
+				array('gateway' => wpinv_get_gateway_admin_label($gateway)),
402 402
 				'%s',
403 403
 				'%s'
404 404
 			);
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
 	public static function get_db_schema() {
414 414
 		global $wpdb;
415 415
 
416
-		if ( ! empty( self::$schema ) ) {
416
+		if (!empty(self::$schema)) {
417 417
 			return self::$schema;
418 418
 		}
419 419
 
@@ -521,29 +521,29 @@  discard block
 block discarded – undo
521 521
 			";
522 522
 
523 523
 		// Add address fields.
524
-		foreach ( array_keys( getpaid_user_address_fields( true ) ) as $field ) {
524
+		foreach (array_keys(getpaid_user_address_fields(true)) as $field) {
525 525
 			// Skip id, user_id and email.
526
-			if ( in_array( $field, array( 'id', 'user_id', 'email', 'purchase_value', 'purchase_count', 'date_created', 'date_modified', 'uuid' ), true ) ) {
526
+			if (in_array($field, array('id', 'user_id', 'email', 'purchase_value', 'purchase_count', 'date_created', 'date_modified', 'uuid'), true)) {
527 527
 				continue;
528 528
 			}
529 529
 
530
-			$field   = sanitize_key( $field );
530
+			$field   = sanitize_key($field);
531 531
 			$length  = 100;
532 532
 			$default = '';
533 533
 
534 534
 			// Country.
535
-			if ( 'country' === $field ) {
535
+			if ('country' === $field) {
536 536
 				$length  = 2;
537 537
 				$default = wpinv_get_default_country();
538 538
 			}
539 539
 
540 540
 			// State.
541
-			if ( 'state' === $field ) {
541
+			if ('state' === $field) {
542 542
 				$default = wpinv_get_default_state();
543 543
 			}
544 544
 
545 545
 			// Phone, zip.
546
-			if ( in_array( $field, array( 'phone', 'zip' ), true ) ) {
546
+			if (in_array($field, array('phone', 'zip'), true)) {
547 547
 				$length = 20;
548 548
 			}
549 549
 
@@ -588,10 +588,10 @@  discard block
 block discarded – undo
588 588
 		) $charset_collate;";
589 589
 
590 590
 		// Filter.
591
-		$schema = apply_filters( 'getpaid_db_schema', $schema );
591
+		$schema = apply_filters('getpaid_db_schema', $schema);
592 592
 
593
-		self::$schema         = implode( "\n", array_values( $schema ) );
594
-		self::$schema_version = md5( sanitize_key( self::$schema ) );
593
+		self::$schema         = implode("\n", array_values($schema));
594
+		self::$schema_version = md5(sanitize_key(self::$schema));
595 595
 
596 596
 		return self::$schema;
597 597
 	}
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 	 *
602 602
 	 */
603 603
 	public static function get_db_schema_version() {
604
-		if ( ! empty( self::$schema_version ) ) {
604
+		if (!empty(self::$schema_version)) {
605 605
 			return self::$schema_version;
606 606
 		}
607 607
 
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 	 * @return bool
617 617
 	 */
618 618
 	public static function is_db_schema_up_to_date() {
619
-		return self::get_db_schema_version() === get_option( 'getpaid_db_schema' );
619
+		return self::get_db_schema_version() === get_option('getpaid_db_schema');
620 620
 	}
621 621
 
622 622
 	/**
@@ -634,27 +634,27 @@  discard block
 block discarded – undo
634 634
 		// If invoices table exists, rename key to invoice_key.
635 635
 		$invoices_table = "{$wpdb->prefix}getpaid_invoices";
636 636
 
637
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) === $invoices_table ) {
638
-			$fields = $wpdb->get_results( "SHOW COLUMNS FROM {$wpdb->prefix}getpaid_invoices" );
637
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'") === $invoices_table) {
638
+			$fields = $wpdb->get_results("SHOW COLUMNS FROM {$wpdb->prefix}getpaid_invoices");
639 639
 
640
-			foreach ( $fields as $field ) {
641
-				if ( 'key' === $field->Field ) {
642
-					$wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoices CHANGE `key` `invoice_key` VARCHAR(100)" );
640
+			foreach ($fields as $field) {
641
+				if ('key' === $field->Field) {
642
+					$wpdb->query("ALTER TABLE {$wpdb->prefix}getpaid_invoices CHANGE `key` `invoice_key` VARCHAR(100)");
643 643
 					break;
644 644
 				}
645 645
 			}
646 646
 		}
647 647
 
648
-		dbDelta( $schema );
648
+		dbDelta($schema);
649 649
 		wp_cache_flush();
650
-		update_option( 'getpaid_db_schema', self::get_db_schema_version() );
650
+		update_option('getpaid_db_schema', self::get_db_schema_version());
651 651
 	}
652 652
 
653 653
 	/**
654 654
 	 * Creates tables if schema is not up to date.
655 655
 	 */
656 656
 	public static function maybe_create_db_tables() {
657
-		if ( ! self::is_db_schema_up_to_date() ) {
657
+		if (!self::is_db_schema_up_to_date()) {
658 658
 			self::create_db_tables();
659 659
 		}
660 660
 	}
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 2 patches
Indentation   +2759 added lines, -2759 removed lines patch added patch discarded remove patch
@@ -14,31 +14,31 @@  discard block
 block discarded – undo
14 14
 class WPInv_Invoice extends GetPaid_Data {
15 15
 
16 16
     /**
17
-	 * Which data store to load.
18
-	 *
19
-	 * @var string
20
-	 */
17
+     * Which data store to load.
18
+     *
19
+     * @var string
20
+     */
21 21
     protected $data_store_name = 'invoice';
22 22
 
23 23
     /**
24
-	 * This is the name of this object type.
25
-	 *
26
-	 * @var string
27
-	 */
24
+     * This is the name of this object type.
25
+     *
26
+     * @var string
27
+     */
28 28
     protected $object_type = 'invoice';
29 29
 
30 30
     /**
31
-	 * Item Data array. This is the core item data exposed in APIs.
32
-	 *
33
-	 * @since 1.0.19
34
-	 * @var array
35
-	 */
36
-	protected $data = array(
37
-		'parent_id'              => 0,
38
-		'customer_id'            => 0,
39
-		'status'                 => 'wpi-pending',
40
-		'version'                => '',
41
-		'date_created'           => null,
31
+     * Item Data array. This is the core item data exposed in APIs.
32
+     *
33
+     * @since 1.0.19
34
+     * @var array
35
+     */
36
+    protected $data = array(
37
+        'parent_id'              => 0,
38
+        'customer_id'            => 0,
39
+        'status'                 => 'wpi-pending',
40
+        'version'                => '',
41
+        'date_created'           => null,
42 42
         'date_modified'          => null,
43 43
         'due_date'               => null,
44 44
         'completed_date'         => null,
@@ -61,17 +61,17 @@  discard block
 block discarded – undo
61 61
         'state'                  => null,
62 62
         'zip'                    => null,
63 63
         'company'                => null,
64
-		'company_id'             => null,
64
+        'company_id'             => null,
65 65
         'vat_number'             => null,
66 66
         'vat_rate'               => null,
67 67
         'address'                => null,
68 68
         'address_confirmed'      => false,
69 69
         'shipping'               => null,
70
-		'subtotal'               => 0,
70
+        'subtotal'               => 0,
71 71
         'total_discount'         => 0,
72 72
         'total_tax'              => 0,
73
-		'total_fees'             => 0,
74
-		'total'                  => 0,
73
+        'total_fees'             => 0,
74
+        'total'                  => 0,
75 75
         'fees'                   => array(),
76 76
         'discounts'              => array(),
77 77
         'taxes'                  => array(),
@@ -83,23 +83,23 @@  discard block
 block discarded – undo
83 83
         'transaction_id'         => '',
84 84
         'currency'               => '',
85 85
         'disable_taxes'          => false,
86
-		'subscription_id'        => null,
87
-		'remote_subscription_id' => null,
88
-		'is_anonymized'          => false,
89
-		'is_viewed'              => false,
90
-		'email_cc'               => '',
91
-		'template'               => 'quantity', // hours, amount only
92
-		'created_via'            => null,
86
+        'subscription_id'        => null,
87
+        'remote_subscription_id' => null,
88
+        'is_anonymized'          => false,
89
+        'is_viewed'              => false,
90
+        'email_cc'               => '',
91
+        'template'               => 'quantity', // hours, amount only
92
+        'created_via'            => null,
93 93
     );
94 94
 
95 95
     /**
96
-	 * Stores meta in cache for future reads.
97
-	 *
98
-	 * A group must be set to to enable caching.
99
-	 *
100
-	 * @var string
101
-	 */
102
-	protected $cache_group = 'getpaid_invoices';
96
+     * Stores meta in cache for future reads.
97
+     *
98
+     * A group must be set to to enable caching.
99
+     *
100
+     * @var string
101
+     */
102
+    protected $cache_group = 'getpaid_invoices';
103 103
 
104 104
     /**
105 105
      * Stores a reference to the original WP_Post object
@@ -113,122 +113,122 @@  discard block
 block discarded – undo
113 113
      *
114 114
      * @var int
115 115
      */
116
-	protected $recurring_item = null;
116
+    protected $recurring_item = null;
117 117
 
118
-	/**
118
+    /**
119 119
      * Stores an array of item totals.
120
-	 *
121
-	 * e.g $totals['discount'] = array(
122
-	 *      'initial'   => 10,
123
-	 *      'recurring' => 10,
124
-	 * )
120
+     *
121
+     * e.g $totals['discount'] = array(
122
+     *      'initial'   => 10,
123
+     *      'recurring' => 10,
124
+     * )
125 125
      *
126 126
      * @var array
127 127
      */
128
-	protected $totals = array();
128
+    protected $totals = array();
129 129
 
130
-	/**
130
+    /**
131 131
      * Tax rate.
132
-	 *
132
+     *
133 133
      * @var float
134 134
      */
135
-	protected $tax_rate = 0;
135
+    protected $tax_rate = 0;
136 136
 
137
-	/**
138
-	 * Stores the status transition information.
139
-	 *
140
-	 * @since 1.0.19
141
-	 * @var bool|array
142
-	 */
143
-	protected $status_transition = false;
137
+    /**
138
+     * Stores the status transition information.
139
+     *
140
+     * @since 1.0.19
141
+     * @var bool|array
142
+     */
143
+    protected $status_transition = false;
144 144
 
145 145
     /**
146
-	 * Get the invoice if ID is passed, otherwise the invoice is new and empty.
147
-	 *
148
-	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
149
-	 */
146
+     * Get the invoice if ID is passed, otherwise the invoice is new and empty.
147
+     *
148
+     * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
149
+     */
150 150
     public function __construct( $invoice = 0 ) {
151 151
 
152 152
         parent::__construct( $invoice );
153 153
 
154
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
155
-			$this->set_id( (int) $invoice );
156
-		} elseif ( $invoice instanceof self ) {
157
-			$this->set_id( $invoice->get_id() );
158
-		} elseif ( ! empty( $invoice->ID ) ) {
159
-			$this->set_id( $invoice->ID );
160
-		} elseif ( is_array( $invoice ) ) {
161
-			$this->set_props( $invoice );
162
-
163
-			if ( isset( $invoice['ID'] ) ) {
164
-				$this->set_id( $invoice['ID'] );
165
-			}
154
+        if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
155
+            $this->set_id( (int) $invoice );
156
+        } elseif ( $invoice instanceof self ) {
157
+            $this->set_id( $invoice->get_id() );
158
+        } elseif ( ! empty( $invoice->ID ) ) {
159
+            $this->set_id( $invoice->ID );
160
+        } elseif ( is_array( $invoice ) ) {
161
+            $this->set_props( $invoice );
162
+
163
+            if ( isset( $invoice['ID'] ) ) {
164
+                $this->set_id( $invoice['ID'] );
165
+            }
166 166
 } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
167
-			$this->set_id( $invoice_id );
168
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
169
-			$this->set_id( $invoice_id );
170
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
171
-			$this->set_id( $invoice_id );
172
-		} else {
173
-			$this->set_object_read( true );
174
-		}
167
+            $this->set_id( $invoice_id );
168
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
169
+            $this->set_id( $invoice_id );
170
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
171
+            $this->set_id( $invoice_id );
172
+        } else {
173
+            $this->set_object_read( true );
174
+        }
175 175
 
176 176
         // Load the datastore.
177
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
177
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
178 178
 
179
-		if ( $this->get_id() > 0 ) {
179
+        if ( $this->get_id() > 0 ) {
180 180
             $this->post = get_post( $this->get_id() );
181 181
             $this->ID   = $this->get_id();
182
-			$this->data_store->read( $this );
182
+            $this->data_store->read( $this );
183 183
         }
184 184
 
185 185
     }
186 186
 
187 187
     /**
188
-	 * Given an invoice key/number, it returns its id.
189
-	 *
190
-	 *
191
-	 * @static
192
-	 * @param string $value The invoice key or number
193
-	 * @param string $field Either key, transaction_id or number.
194
-	 * @since 1.0.15
195
-	 * @return int
196
-	 */
197
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
188
+     * Given an invoice key/number, it returns its id.
189
+     *
190
+     *
191
+     * @static
192
+     * @param string $value The invoice key or number
193
+     * @param string $field Either key, transaction_id or number.
194
+     * @since 1.0.15
195
+     * @return int
196
+     */
197
+    public static function get_invoice_id_by_field( $value, $field = 'key' ) {
198 198
         global $wpdb;
199 199
 
200
-		// Trim the value.
201
-		$value = trim( $value );
200
+        // Trim the value.
201
+        $value = trim( $value );
202 202
 
203
-		if ( empty( $value ) ) {
204
-			return 0;
205
-		}
203
+        if ( empty( $value ) ) {
204
+            return 0;
205
+        }
206 206
 
207 207
         // Valid fields.
208 208
         $fields = array( 'key', 'number', 'transaction_id' );
209 209
 
210
-		// Ensure a field has been passed.
211
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
212
-			return 0;
213
-		}
210
+        // Ensure a field has been passed.
211
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
212
+            return 0;
213
+        }
214 214
 
215
-		// Maybe retrieve from the cache.
216
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
217
-		if ( false !== $invoice_id ) {
218
-			return $invoice_id;
219
-		}
215
+        // Maybe retrieve from the cache.
216
+        $invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
217
+        if ( false !== $invoice_id ) {
218
+            return $invoice_id;
219
+        }
220 220
 
221 221
         // Fetch from the db.
222 222
         $table       = $wpdb->prefix . 'getpaid_invoices';
223
-		$db_field    = 'key' === $field ? 'invoice_key' : $field;
223
+        $db_field    = 'key' === $field ? 'invoice_key' : $field;
224 224
         $invoice_id  = (int) $wpdb->get_var(
225 225
             $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$db_field`=%s LIMIT 1", $value )
226 226
         );
227 227
 
228
-		// Update the cache with our data
229
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
228
+        // Update the cache with our data
229
+        wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
230 230
 
231
-		return $invoice_id;
231
+        return $invoice_id;
232 232
     }
233 233
 
234 234
     /**
@@ -254,83 +254,83 @@  discard block
 block discarded – undo
254 254
     */
255 255
 
256 256
     /**
257
-	 * Get parent invoice ID.
258
-	 *
259
-	 * @since 1.0.19
260
-	 * @param  string $context View or edit context.
261
-	 * @return int
262
-	 */
263
-	public function get_parent_id( $context = 'view' ) {
264
-		return (int) $this->get_prop( 'parent_id', $context );
257
+     * Get parent invoice ID.
258
+     *
259
+     * @since 1.0.19
260
+     * @param  string $context View or edit context.
261
+     * @return int
262
+     */
263
+    public function get_parent_id( $context = 'view' ) {
264
+        return (int) $this->get_prop( 'parent_id', $context );
265 265
     }
266 266
 
267 267
     /**
268
-	 * Get parent invoice.
269
-	 *
270
-	 * @since 1.0.19
271
-	 * @return WPInv_Invoice
272
-	 */
268
+     * Get parent invoice.
269
+     *
270
+     * @since 1.0.19
271
+     * @return WPInv_Invoice
272
+     */
273 273
     public function get_parent_payment() {
274 274
         return new WPInv_Invoice( $this->get_parent_id() );
275 275
     }
276 276
 
277 277
     /**
278
-	 * Alias for self::get_parent_payment().
279
-	 *
280
-	 * @since 1.0.19
281
-	 * @return WPInv_Invoice
282
-	 */
278
+     * Alias for self::get_parent_payment().
279
+     *
280
+     * @since 1.0.19
281
+     * @return WPInv_Invoice
282
+     */
283 283
     public function get_parent() {
284 284
         return $this->get_parent_payment();
285 285
     }
286 286
 
287 287
     /**
288
-	 * Get invoice status.
289
-	 *
290
-	 * @since 1.0.19
291
-	 * @param  string $context View or edit context.
292
-	 * @return string
293
-	 */
294
-	public function get_status( $context = 'view' ) {
295
-		return $this->get_prop( 'status', $context );
296
-	}
288
+     * Get invoice status.
289
+     *
290
+     * @since 1.0.19
291
+     * @param  string $context View or edit context.
292
+     * @return string
293
+     */
294
+    public function get_status( $context = 'view' ) {
295
+        return $this->get_prop( 'status', $context );
296
+    }
297 297
 
298
-	/**
299
-	 * Retrieves an array of possible invoice statuses.
300
-	 *
301
-	 * @since 1.0.19
302
-	 * @return array
303
-	 */
304
-	public function get_all_statuses() {
305
-		return wpinv_get_invoice_statuses( true, true, $this );
298
+    /**
299
+     * Retrieves an array of possible invoice statuses.
300
+     *
301
+     * @since 1.0.19
302
+     * @return array
303
+     */
304
+    public function get_all_statuses() {
305
+        return wpinv_get_invoice_statuses( true, true, $this );
306 306
     }
307 307
 
308 308
     /**
309
-	 * Get invoice status nice name.
310
-	 *
311
-	 * @since 1.0.19
312
-	 * @return string
313
-	 */
309
+     * Get invoice status nice name.
310
+     *
311
+     * @since 1.0.19
312
+     * @return string
313
+     */
314 314
     public function get_status_nicename() {
315
-		$statuses = $this->get_all_statuses();
315
+        $statuses = $this->get_all_statuses();
316 316
 
317 317
         $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
318 318
 
319 319
         return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
320 320
     }
321 321
 
322
-	/**
323
-	 * Retrieves the invoice status class
324
-	 *
325
-	 * @since  1.0.19
326
-	 * @return string
327
-	 */
328
-	public function get_status_class() {
329
-		$statuses = getpaid_get_invoice_status_classes();
330
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'bg-dark text-white';
331
-	}
322
+    /**
323
+     * Retrieves the invoice status class
324
+     *
325
+     * @since  1.0.19
326
+     * @return string
327
+     */
328
+    public function get_status_class() {
329
+        $statuses = getpaid_get_invoice_status_classes();
330
+        return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'bg-dark text-white';
331
+    }
332 332
 
333
-	/**
333
+    /**
334 334
      * Retrieves the invoice status label html
335 335
      *
336 336
      * @since  1.0.0
@@ -338,263 +338,263 @@  discard block
 block discarded – undo
338 338
      */
339 339
     public function get_status_label_html() {
340 340
 
341
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
342
-		$status       = sanitize_html_class( $this->get_status() );
343
-		$class        = esc_attr( $this->get_status_class() );
344
-
345
-		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
346
-	}
347
-
348
-    /**
349
-	 * Get plugin version when the invoice was created.
350
-	 *
351
-	 * @since 1.0.19
352
-	 * @param  string $context View or edit context.
353
-	 * @return string
354
-	 */
355
-	public function get_version( $context = 'view' ) {
356
-		return $this->get_prop( 'version', $context );
357
-	}
358
-
359
-	/**
360
-	 * @deprecated
361
-	 */
362
-	public function get_invoice_date( $format = true ) {
363
-		$date      = getpaid_format_date( $this->get_date_completed() );
364
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
365
-		$formatted = getpaid_format_date( $date );
366
-
367
-		if ( $format ) {
368
-			return $formatted;
369
-		}
370
-
371
-		return empty( $formatted ) ? '' : $date;
372
-
373
-    }
374
-
375
-    /**
376
-	 * Get date when the invoice was created.
377
-	 *
378
-	 * @since 1.0.19
379
-	 * @param  string $context View or edit context.
380
-	 * @return string
381
-	 */
382
-	public function get_date_created( $context = 'view' ) {
383
-		return $this->get_prop( 'date_created', $context );
384
-	}
385
-
386
-	/**
387
-	 * Alias for self::get_date_created().
388
-	 *
389
-	 * @since 1.0.19
390
-	 * @param  string $context View or edit context.
391
-	 * @return string
392
-	 */
393
-	public function get_created_date( $context = 'view' ) {
394
-		return $this->get_date_created( $context );
395
-    }
396
-
397
-    /**
398
-	 * Get GMT date when the invoice was created.
399
-	 *
400
-	 * @since 1.0.19
401
-	 * @param  string $context View or edit context.
402
-	 * @return string
403
-	 */
404
-	public function get_date_created_gmt( $context = 'view' ) {
341
+        $status_label = sanitize_text_field( $this->get_status_nicename() );
342
+        $status       = sanitize_html_class( $this->get_status() );
343
+        $class        = esc_attr( $this->get_status_class() );
344
+
345
+        return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
346
+    }
347
+
348
+    /**
349
+     * Get plugin version when the invoice was created.
350
+     *
351
+     * @since 1.0.19
352
+     * @param  string $context View or edit context.
353
+     * @return string
354
+     */
355
+    public function get_version( $context = 'view' ) {
356
+        return $this->get_prop( 'version', $context );
357
+    }
358
+
359
+    /**
360
+     * @deprecated
361
+     */
362
+    public function get_invoice_date( $format = true ) {
363
+        $date      = getpaid_format_date( $this->get_date_completed() );
364
+        $date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
365
+        $formatted = getpaid_format_date( $date );
366
+
367
+        if ( $format ) {
368
+            return $formatted;
369
+        }
370
+
371
+        return empty( $formatted ) ? '' : $date;
372
+
373
+    }
374
+
375
+    /**
376
+     * Get date when the invoice was created.
377
+     *
378
+     * @since 1.0.19
379
+     * @param  string $context View or edit context.
380
+     * @return string
381
+     */
382
+    public function get_date_created( $context = 'view' ) {
383
+        return $this->get_prop( 'date_created', $context );
384
+    }
385
+
386
+    /**
387
+     * Alias for self::get_date_created().
388
+     *
389
+     * @since 1.0.19
390
+     * @param  string $context View or edit context.
391
+     * @return string
392
+     */
393
+    public function get_created_date( $context = 'view' ) {
394
+        return $this->get_date_created( $context );
395
+    }
396
+
397
+    /**
398
+     * Get GMT date when the invoice was created.
399
+     *
400
+     * @since 1.0.19
401
+     * @param  string $context View or edit context.
402
+     * @return string
403
+     */
404
+    public function get_date_created_gmt( $context = 'view' ) {
405 405
         $date = $this->get_date_created( $context );
406 406
 
407 407
         if ( $date ) {
408 408
             $date = get_gmt_from_date( $date );
409 409
         }
410
-		return $date;
411
-    }
412
-
413
-    /**
414
-	 * Get date when the invoice was last modified.
415
-	 *
416
-	 * @since 1.0.19
417
-	 * @param  string $context View or edit context.
418
-	 * @return string
419
-	 */
420
-	public function get_date_modified( $context = 'view' ) {
421
-		return $this->get_prop( 'date_modified', $context );
422
-	}
423
-
424
-	/**
425
-	 * Alias for self::get_date_modified().
426
-	 *
427
-	 * @since 1.0.19
428
-	 * @param  string $context View or edit context.
429
-	 * @return string
430
-	 */
431
-	public function get_modified_date( $context = 'view' ) {
432
-		return $this->get_date_modified( $context );
433
-    }
434
-
435
-    /**
436
-	 * Get GMT date when the invoice was last modified.
437
-	 *
438
-	 * @since 1.0.19
439
-	 * @param  string $context View or edit context.
440
-	 * @return string
441
-	 */
442
-	public function get_date_modified_gmt( $context = 'view' ) {
410
+        return $date;
411
+    }
412
+
413
+    /**
414
+     * Get date when the invoice was last modified.
415
+     *
416
+     * @since 1.0.19
417
+     * @param  string $context View or edit context.
418
+     * @return string
419
+     */
420
+    public function get_date_modified( $context = 'view' ) {
421
+        return $this->get_prop( 'date_modified', $context );
422
+    }
423
+
424
+    /**
425
+     * Alias for self::get_date_modified().
426
+     *
427
+     * @since 1.0.19
428
+     * @param  string $context View or edit context.
429
+     * @return string
430
+     */
431
+    public function get_modified_date( $context = 'view' ) {
432
+        return $this->get_date_modified( $context );
433
+    }
434
+
435
+    /**
436
+     * Get GMT date when the invoice was last modified.
437
+     *
438
+     * @since 1.0.19
439
+     * @param  string $context View or edit context.
440
+     * @return string
441
+     */
442
+    public function get_date_modified_gmt( $context = 'view' ) {
443 443
         $date = $this->get_date_modified( $context );
444 444
 
445 445
         if ( $date ) {
446 446
             $date = get_gmt_from_date( $date );
447 447
         }
448
-		return $date;
448
+        return $date;
449 449
     }
450 450
 
451 451
     /**
452
-	 * Get the invoice due date.
453
-	 *
454
-	 * @since 1.0.19
455
-	 * @param  string $context View or edit context.
456
-	 * @return string
457
-	 */
458
-	public function get_due_date( $context = 'view' ) {
459
-		return $this->get_prop( 'due_date', $context );
452
+     * Get the invoice due date.
453
+     *
454
+     * @since 1.0.19
455
+     * @param  string $context View or edit context.
456
+     * @return string
457
+     */
458
+    public function get_due_date( $context = 'view' ) {
459
+        return $this->get_prop( 'due_date', $context );
460 460
     }
461 461
 
462 462
     /**
463
-	 * Alias for self::get_due_date().
464
-	 *
465
-	 * @since 1.0.19
466
-	 * @param  string $context View or edit context.
467
-	 * @return string
468
-	 */
469
-	public function get_date_due( $context = 'view' ) {
470
-		return $this->get_due_date( $context );
463
+     * Alias for self::get_due_date().
464
+     *
465
+     * @since 1.0.19
466
+     * @param  string $context View or edit context.
467
+     * @return string
468
+     */
469
+    public function get_date_due( $context = 'view' ) {
470
+        return $this->get_due_date( $context );
471 471
     }
472 472
 
473 473
     /**
474
-	 * Get the invoice GMT due date.
475
-	 *
476
-	 * @since 1.0.19
477
-	 * @param  string $context View or edit context.
478
-	 * @return string
479
-	 */
480
-	public function get_due_date_gmt( $context = 'view' ) {
474
+     * Get the invoice GMT due date.
475
+     *
476
+     * @since 1.0.19
477
+     * @param  string $context View or edit context.
478
+     * @return string
479
+     */
480
+    public function get_due_date_gmt( $context = 'view' ) {
481 481
         $date = $this->get_due_date( $context );
482 482
 
483 483
         if ( $date ) {
484 484
             $date = get_gmt_from_date( $date );
485 485
         }
486
-		return $date;
486
+        return $date;
487 487
     }
488 488
 
489 489
     /**
490
-	 * Alias for self::get_due_date_gmt().
491
-	 *
492
-	 * @since 1.0.19
493
-	 * @param  string $context View or edit context.
494
-	 * @return string
495
-	 */
496
-	public function get_gmt_date_due( $context = 'view' ) {
497
-		return $this->get_due_date_gmt( $context );
490
+     * Alias for self::get_due_date_gmt().
491
+     *
492
+     * @since 1.0.19
493
+     * @param  string $context View or edit context.
494
+     * @return string
495
+     */
496
+    public function get_gmt_date_due( $context = 'view' ) {
497
+        return $this->get_due_date_gmt( $context );
498 498
     }
499 499
 
500 500
     /**
501
-	 * Get date when the invoice was completed.
502
-	 *
503
-	 * @since 1.0.19
504
-	 * @param  string $context View or edit context.
505
-	 * @return string
506
-	 */
507
-	public function get_completed_date( $context = 'view' ) {
508
-		return $this->get_prop( 'completed_date', $context );
501
+     * Get date when the invoice was completed.
502
+     *
503
+     * @since 1.0.19
504
+     * @param  string $context View or edit context.
505
+     * @return string
506
+     */
507
+    public function get_completed_date( $context = 'view' ) {
508
+        return $this->get_prop( 'completed_date', $context );
509 509
     }
510 510
 
511 511
     /**
512
-	 * Alias for self::get_completed_date().
513
-	 *
514
-	 * @since 1.0.19
515
-	 * @param  string $context View or edit context.
516
-	 * @return string
517
-	 */
518
-	public function get_date_completed( $context = 'view' ) {
519
-		return $this->get_completed_date( $context );
512
+     * Alias for self::get_completed_date().
513
+     *
514
+     * @since 1.0.19
515
+     * @param  string $context View or edit context.
516
+     * @return string
517
+     */
518
+    public function get_date_completed( $context = 'view' ) {
519
+        return $this->get_completed_date( $context );
520 520
     }
521 521
 
522 522
     /**
523
-	 * Get GMT date when the invoice was was completed.
524
-	 *
525
-	 * @since 1.0.19
526
-	 * @param  string $context View or edit context.
527
-	 * @return string
528
-	 */
529
-	public function get_completed_date_gmt( $context = 'view' ) {
523
+     * Get GMT date when the invoice was was completed.
524
+     *
525
+     * @since 1.0.19
526
+     * @param  string $context View or edit context.
527
+     * @return string
528
+     */
529
+    public function get_completed_date_gmt( $context = 'view' ) {
530 530
         $date = $this->get_completed_date( $context );
531 531
 
532 532
         if ( $date ) {
533 533
             $date = get_gmt_from_date( $date );
534 534
         }
535
-		return $date;
535
+        return $date;
536 536
     }
537 537
 
538 538
     /**
539
-	 * Alias for self::get_completed_date_gmt().
540
-	 *
541
-	 * @since 1.0.19
542
-	 * @param  string $context View or edit context.
543
-	 * @return string
544
-	 */
545
-	public function get_gmt_completed_date( $context = 'view' ) {
546
-		return $this->get_completed_date_gmt( $context );
539
+     * Alias for self::get_completed_date_gmt().
540
+     *
541
+     * @since 1.0.19
542
+     * @param  string $context View or edit context.
543
+     * @return string
544
+     */
545
+    public function get_gmt_completed_date( $context = 'view' ) {
546
+        return $this->get_completed_date_gmt( $context );
547 547
     }
548 548
 
549 549
     /**
550
-	 * Get the invoice number.
551
-	 *
552
-	 * @since 1.0.19
553
-	 * @param  string $context View or edit context.
554
-	 * @return string
555
-	 */
556
-	public function get_number( $context = 'view' ) {
557
-		$number = $this->get_prop( 'number', $context );
550
+     * Get the invoice number.
551
+     *
552
+     * @since 1.0.19
553
+     * @param  string $context View or edit context.
554
+     * @return string
555
+     */
556
+    public function get_number( $context = 'view' ) {
557
+        $number = $this->get_prop( 'number', $context );
558 558
 
559
-		if ( empty( $number ) ) {
560
-			$number = $this->generate_number();
561
-			$this->set_number( $this->generate_number() );
562
-		}
559
+        if ( empty( $number ) ) {
560
+            $number = $this->generate_number();
561
+            $this->set_number( $this->generate_number() );
562
+        }
563 563
 
564
-		return $number;
564
+        return $number;
565 565
     }
566 566
 
567
-	/**
568
-	 * Set the invoice number.
569
-	 *
570
-	 * @since 1.0.19
571
-	 */
572
-	public function maybe_set_number() {
567
+    /**
568
+     * Set the invoice number.
569
+     *
570
+     * @since 1.0.19
571
+     */
572
+    public function maybe_set_number() {
573 573
         $number = $this->get_number();
574 574
 
575 575
         if ( empty( $number ) || $this->get_id() == $number ) {
576
-			$this->set_number( $this->generate_number() );
576
+            $this->set_number( $this->generate_number() );
577 577
         }
578 578
 
579
-	}
579
+    }
580 580
 
581 581
     /**
582
-	 * Get the invoice key.
583
-	 *
584
-	 * @since 1.0.19
585
-	 * @param  string $context View or edit context.
586
-	 * @return string
587
-	 */
588
-	public function get_key( $context = 'view' ) {
582
+     * Get the invoice key.
583
+     *
584
+     * @since 1.0.19
585
+     * @param  string $context View or edit context.
586
+     * @return string
587
+     */
588
+    public function get_key( $context = 'view' ) {
589 589
         return $this->get_prop( 'key', $context );
590
-	}
591
-
592
-	/**
593
-	 * Set the invoice key.
594
-	 *
595
-	 * @since 1.0.19
596
-	 */
597
-	public function maybe_set_key() {
590
+    }
591
+
592
+    /**
593
+     * Set the invoice key.
594
+     *
595
+     * @since 1.0.19
596
+     */
597
+    public function maybe_set_key() {
598 598
         $key = $this->get_key();
599 599
 
600 600
         if ( empty( $key ) ) {
@@ -605,140 +605,140 @@  discard block
 block discarded – undo
605 605
     }
606 606
 
607 607
     /**
608
-	 * Get the invoice type.
609
-	 *
610
-	 * @since 1.0.19
611
-	 * @param  string $context View or edit context.
612
-	 * @return string
613
-	 */
614
-	public function get_type( $context = 'view' ) {
608
+     * Get the invoice type.
609
+     *
610
+     * @since 1.0.19
611
+     * @param  string $context View or edit context.
612
+     * @return string
613
+     */
614
+    public function get_type( $context = 'view' ) {
615 615
         return $this->get_prop( 'type', $context );
616
-	}
617
-
618
-	/**
619
-	 * Returns the post type name.
620
-	 *
621
-	 * @since 1.0.19
622
-	 * @return string
623
-	 */
624
-	public function get_invoice_quote_type() {
616
+    }
617
+
618
+    /**
619
+     * Returns the post type name.
620
+     *
621
+     * @since 1.0.19
622
+     * @return string
623
+     */
624
+    public function get_invoice_quote_type() {
625 625
         return getpaid_get_post_type_label( $this->get_post_type(), false );
626 626
     }
627 627
 
628 628
     /**
629
-	 * Get the invoice post type label.
630
-	 *
631
-	 * @since 1.0.19
632
-	 * @param  string $context View or edit context.
633
-	 * @return string
634
-	 */
635
-	public function get_label( $context = 'view' ) {
629
+     * Get the invoice post type label.
630
+     *
631
+     * @since 1.0.19
632
+     * @param  string $context View or edit context.
633
+     * @return string
634
+     */
635
+    public function get_label( $context = 'view' ) {
636 636
         return getpaid_get_post_type_label( $this->get_post_type( $context ), false );
637
-	}
638
-
639
-	/**
640
-	 * Get the invoice post type.
641
-	 *
642
-	 * @since 1.0.19
643
-	 * @param  string $context View or edit context.
644
-	 * @return string
645
-	 */
646
-	public function get_post_type( $context = 'view' ) {
637
+    }
638
+
639
+    /**
640
+     * Get the invoice post type.
641
+     *
642
+     * @since 1.0.19
643
+     * @param  string $context View or edit context.
644
+     * @return string
645
+     */
646
+    public function get_post_type( $context = 'view' ) {
647 647
         return $this->get_prop( 'post_type', $context );
648 648
     }
649 649
 
650 650
     /**
651
-	 * Get the invoice mode.
652
-	 *
653
-	 * @since 1.0.19
654
-	 * @param  string $context View or edit context.
655
-	 * @return string
656
-	 */
657
-	public function get_mode( $context = 'view' ) {
651
+     * Get the invoice mode.
652
+     *
653
+     * @since 1.0.19
654
+     * @param  string $context View or edit context.
655
+     * @return string
656
+     */
657
+    public function get_mode( $context = 'view' ) {
658 658
         return $this->get_prop( 'mode', $context );
659 659
     }
660 660
 
661 661
     /**
662
-	 * Get the invoice path.
663
-	 *
664
-	 * @since 1.0.19
665
-	 * @param  string $context View or edit context.
666
-	 * @return string
667
-	 */
668
-	public function get_path( $context = 'view' ) {
662
+     * Get the invoice path.
663
+     *
664
+     * @since 1.0.19
665
+     * @param  string $context View or edit context.
666
+     * @return string
667
+     */
668
+    public function get_path( $context = 'view' ) {
669 669
         $path   = $this->get_prop( 'path', $context );
670
-		$prefix = $this->get_type();
670
+        $prefix = $this->get_type();
671 671
 
672
-		if ( 0 !== strpos( $path, $prefix ) ) {
673
-			$path = sanitize_title( $prefix . '-' . $this->get_id() );
674
-			$this->set_path( $path );
675
-		}
672
+        if ( 0 !== strpos( $path, $prefix ) ) {
673
+            $path = sanitize_title( $prefix . '-' . $this->get_id() );
674
+            $this->set_path( $path );
675
+        }
676 676
 
677
-		return $path;
677
+        return $path;
678 678
     }
679 679
 
680 680
     /**
681
-	 * Get the invoice name/title.
682
-	 *
683
-	 * @since 1.0.19
684
-	 * @param  string $context View or edit context.
685
-	 * @return string
686
-	 */
687
-	public function get_name( $context = 'view' ) {
681
+     * Get the invoice name/title.
682
+     *
683
+     * @since 1.0.19
684
+     * @param  string $context View or edit context.
685
+     * @return string
686
+     */
687
+    public function get_name( $context = 'view' ) {
688 688
         return $this->get_prop( 'title', $context );
689 689
     }
690 690
 
691 691
     /**
692
-	 * Alias of self::get_name().
693
-	 *
694
-	 * @since 1.0.19
695
-	 * @param  string $context View or edit context.
696
-	 * @return string
697
-	 */
698
-	public function get_title( $context = 'view' ) {
699
-		return $this->get_name( $context );
692
+     * Alias of self::get_name().
693
+     *
694
+     * @since 1.0.19
695
+     * @param  string $context View or edit context.
696
+     * @return string
697
+     */
698
+    public function get_title( $context = 'view' ) {
699
+        return $this->get_name( $context );
700 700
     }
701 701
 
702 702
     /**
703
-	 * Get the invoice description.
704
-	 *
705
-	 * @since 1.0.19
706
-	 * @param  string $context View or edit context.
707
-	 * @return string
708
-	 */
709
-	public function get_description( $context = 'view' ) {
710
-		return $this->get_prop( 'description', $context );
703
+     * Get the invoice description.
704
+     *
705
+     * @since 1.0.19
706
+     * @param  string $context View or edit context.
707
+     * @return string
708
+     */
709
+    public function get_description( $context = 'view' ) {
710
+        return $this->get_prop( 'description', $context );
711 711
     }
712 712
 
713 713
     /**
714
-	 * Alias of self::get_description().
715
-	 *
716
-	 * @since 1.0.19
717
-	 * @param  string $context View or edit context.
718
-	 * @return string
719
-	 */
720
-	public function get_excerpt( $context = 'view' ) {
721
-		return $this->get_description( $context );
714
+     * Alias of self::get_description().
715
+     *
716
+     * @since 1.0.19
717
+     * @param  string $context View or edit context.
718
+     * @return string
719
+     */
720
+    public function get_excerpt( $context = 'view' ) {
721
+        return $this->get_description( $context );
722 722
     }
723 723
 
724 724
     /**
725
-	 * Alias of self::get_description().
726
-	 *
727
-	 * @since 1.0.19
728
-	 * @param  string $context View or edit context.
729
-	 * @return string
730
-	 */
731
-	public function get_summary( $context = 'view' ) {
732
-		return $this->get_description( $context );
725
+     * Alias of self::get_description().
726
+     *
727
+     * @since 1.0.19
728
+     * @param  string $context View or edit context.
729
+     * @return string
730
+     */
731
+    public function get_summary( $context = 'view' ) {
732
+        return $this->get_description( $context );
733 733
     }
734 734
 
735 735
     /**
736
-	 * Returns the user info.
737
-	 *
738
-	 * @since 1.0.19
736
+     * Returns the user info.
737
+     *
738
+     * @since 1.0.19
739 739
      * @param  string $context View or edit context.
740
-	 * @return array
741
-	 */
740
+     * @return array
741
+     */
742 742
     public function get_user_info( $context = 'view' ) {
743 743
 
744 744
         $user_info = array(
@@ -753,683 +753,683 @@  discard block
 block discarded – undo
753 753
             'state'      => $this->get_state( $context ),
754 754
             'zip'        => $this->get_zip( $context ),
755 755
             'company'    => $this->get_company( $context ),
756
-			'company_id' => $this->get_company_id( $context ),
756
+            'company_id' => $this->get_company_id( $context ),
757 757
             'vat_number' => $this->get_vat_number( $context ),
758 758
             'discount'   => $this->get_discount_code( $context ),
759
-		);
759
+        );
760 760
 
761
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
761
+        return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
762 762
 
763 763
     }
764 764
 
765 765
     /**
766
-	 * Get the user id.
767
-	 *
768
-	 * @since 1.0.19
769
-	 * @param  string $context View or edit context.
770
-	 * @return int
771
-	 */
772
-	public function get_author( $context = 'view' ) {
773
-		return (int) $this->get_prop( 'author', $context );
766
+     * Get the user id.
767
+     *
768
+     * @since 1.0.19
769
+     * @param  string $context View or edit context.
770
+     * @return int
771
+     */
772
+    public function get_author( $context = 'view' ) {
773
+        return (int) $this->get_prop( 'author', $context );
774 774
     }
775 775
 
776 776
     /**
777
-	 * Alias of self::get_author().
778
-	 *
779
-	 * @since 1.0.19
780
-	 * @param  string $context View or edit context.
781
-	 * @return int
782
-	 */
783
-	public function get_user_id( $context = 'view' ) {
784
-		return $this->get_author( $context );
777
+     * Alias of self::get_author().
778
+     *
779
+     * @since 1.0.19
780
+     * @param  string $context View or edit context.
781
+     * @return int
782
+     */
783
+    public function get_user_id( $context = 'view' ) {
784
+        return $this->get_author( $context );
785 785
     }
786 786
 
787
-     /**
788
-	 * Get customer ID.
789
-	 *
790
-	 * @since 1.0.19
791
-	 * @param  string $context View or edit context.
792
-	 * @return int
793
-	 */
794
-	public function get_customer_id( $context = 'view' ) {
795
-		return (int) $this->get_prop( 'customer_id', $context );
787
+        /**
788
+         * Get customer ID.
789
+         *
790
+         * @since 1.0.19
791
+         * @param  string $context View or edit context.
792
+         * @return int
793
+         */
794
+    public function get_customer_id( $context = 'view' ) {
795
+        return (int) $this->get_prop( 'customer_id', $context );
796 796
     }
797 797
 
798 798
     /**
799
-	 * Get the customer's ip.
800
-	 *
801
-	 * @since 1.0.19
802
-	 * @param  string $context View or edit context.
803
-	 * @return string
804
-	 */
805
-	public function get_ip( $context = 'view' ) {
806
-		return $this->get_prop( 'user_ip', $context );
799
+     * Get the customer's ip.
800
+     *
801
+     * @since 1.0.19
802
+     * @param  string $context View or edit context.
803
+     * @return string
804
+     */
805
+    public function get_ip( $context = 'view' ) {
806
+        return $this->get_prop( 'user_ip', $context );
807 807
     }
808 808
 
809 809
     /**
810
-	 * Alias of self::get_ip().
811
-	 *
812
-	 * @since 1.0.19
813
-	 * @param  string $context View or edit context.
814
-	 * @return string
815
-	 */
816
-	public function get_user_ip( $context = 'view' ) {
817
-		return $this->get_ip( $context );
810
+     * Alias of self::get_ip().
811
+     *
812
+     * @since 1.0.19
813
+     * @param  string $context View or edit context.
814
+     * @return string
815
+     */
816
+    public function get_user_ip( $context = 'view' ) {
817
+        return $this->get_ip( $context );
818 818
     }
819 819
 
820
-     /**
821
-	 * Alias of self::get_ip().
822
-	 *
823
-	 * @since 1.0.19
824
-	 * @param  string $context View or edit context.
825
-	 * @return string
826
-	 */
827
-	public function get_customer_ip( $context = 'view' ) {
828
-		return $this->get_ip( $context );
820
+        /**
821
+         * Alias of self::get_ip().
822
+         *
823
+         * @since 1.0.19
824
+         * @param  string $context View or edit context.
825
+         * @return string
826
+         */
827
+    public function get_customer_ip( $context = 'view' ) {
828
+        return $this->get_ip( $context );
829 829
     }
830 830
 
831 831
     /**
832
-	 * Get the customer's first name.
833
-	 *
834
-	 * @since 1.0.19
835
-	 * @param  string $context View or edit context.
836
-	 * @return string
837
-	 */
838
-	public function get_first_name( $context = 'view' ) {
839
-		return $this->get_prop( 'first_name', $context );
832
+     * Get the customer's first name.
833
+     *
834
+     * @since 1.0.19
835
+     * @param  string $context View or edit context.
836
+     * @return string
837
+     */
838
+    public function get_first_name( $context = 'view' ) {
839
+        return $this->get_prop( 'first_name', $context );
840 840
     }
841 841
 
842 842
     /**
843
-	 * Alias of self::get_first_name().
844
-	 *
845
-	 * @since 1.0.19
846
-	 * @param  string $context View or edit context.
847
-	 * @return string
848
-	 */
849
-	public function get_user_first_name( $context = 'view' ) {
850
-		return $this->get_first_name( $context );
843
+     * Alias of self::get_first_name().
844
+     *
845
+     * @since 1.0.19
846
+     * @param  string $context View or edit context.
847
+     * @return string
848
+     */
849
+    public function get_user_first_name( $context = 'view' ) {
850
+        return $this->get_first_name( $context );
851 851
     }
852 852
 
853
-     /**
854
-	 * Alias of self::get_first_name().
855
-	 *
856
-	 * @since 1.0.19
857
-	 * @param  string $context View or edit context.
858
-	 * @return string
859
-	 */
860
-	public function get_customer_first_name( $context = 'view' ) {
861
-		return $this->get_first_name( $context );
853
+        /**
854
+         * Alias of self::get_first_name().
855
+         *
856
+         * @since 1.0.19
857
+         * @param  string $context View or edit context.
858
+         * @return string
859
+         */
860
+    public function get_customer_first_name( $context = 'view' ) {
861
+        return $this->get_first_name( $context );
862 862
     }
863 863
 
864 864
     /**
865
-	 * Get the customer's last name.
866
-	 *
867
-	 * @since 1.0.19
868
-	 * @param  string $context View or edit context.
869
-	 * @return string
870
-	 */
871
-	public function get_last_name( $context = 'view' ) {
872
-		return $this->get_prop( 'last_name', $context );
865
+     * Get the customer's last name.
866
+     *
867
+     * @since 1.0.19
868
+     * @param  string $context View or edit context.
869
+     * @return string
870
+     */
871
+    public function get_last_name( $context = 'view' ) {
872
+        return $this->get_prop( 'last_name', $context );
873 873
     }
874 874
 
875 875
     /**
876
-	 * Alias of self::get_last_name().
877
-	 *
878
-	 * @since 1.0.19
879
-	 * @param  string $context View or edit context.
880
-	 * @return string
881
-	 */
882
-	public function get_user_last_name( $context = 'view' ) {
883
-		return $this->get_last_name( $context );
876
+     * Alias of self::get_last_name().
877
+     *
878
+     * @since 1.0.19
879
+     * @param  string $context View or edit context.
880
+     * @return string
881
+     */
882
+    public function get_user_last_name( $context = 'view' ) {
883
+        return $this->get_last_name( $context );
884 884
     }
885 885
 
886 886
     /**
887
-	 * Alias of self::get_last_name().
888
-	 *
889
-	 * @since 1.0.19
890
-	 * @param  string $context View or edit context.
891
-	 * @return string
892
-	 */
893
-	public function get_customer_last_name( $context = 'view' ) {
894
-		return $this->get_last_name( $context );
887
+     * Alias of self::get_last_name().
888
+     *
889
+     * @since 1.0.19
890
+     * @param  string $context View or edit context.
891
+     * @return string
892
+     */
893
+    public function get_customer_last_name( $context = 'view' ) {
894
+        return $this->get_last_name( $context );
895 895
     }
896 896
 
897 897
     /**
898
-	 * Get the customer's full name.
899
-	 *
900
-	 * @since 1.0.19
901
-	 * @param  string $context View or edit context.
902
-	 * @return string
903
-	 */
904
-	public function get_full_name( $context = 'view' ) {
905
-		$name = trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
898
+     * Get the customer's full name.
899
+     *
900
+     * @since 1.0.19
901
+     * @param  string $context View or edit context.
902
+     * @return string
903
+     */
904
+    public function get_full_name( $context = 'view' ) {
905
+        $name = trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
906 906
 
907
-		if ( ! $name ) {
908
-			$user = get_userdata( $this->get_author( $context ) );
907
+        if ( ! $name ) {
908
+            $user = get_userdata( $this->get_author( $context ) );
909 909
 
910
-			if ( $user ) {
911
-				$name = $user->display_name;
912
-			}
913
-		}
910
+            if ( $user ) {
911
+                $name = $user->display_name;
912
+            }
913
+        }
914 914
 
915
-		if ( ! $name ) {
916
-			$name = $this->get_email( $context );
917
-		}
915
+        if ( ! $name ) {
916
+            $name = $this->get_email( $context );
917
+        }
918 918
 
919
-		return apply_filters( 'wpinv_invoice_user_full_name', $name, $this );
919
+        return apply_filters( 'wpinv_invoice_user_full_name', $name, $this );
920 920
     }
921 921
 
922 922
     /**
923
-	 * Alias of self::get_full_name().
924
-	 *
925
-	 * @since 1.0.19
926
-	 * @param  string $context View or edit context.
927
-	 * @return string
928
-	 */
929
-	public function get_user_full_name( $context = 'view' ) {
930
-		return $this->get_full_name( $context );
931
-    }
923
+     * Alias of self::get_full_name().
924
+     *
925
+     * @since 1.0.19
926
+     * @param  string $context View or edit context.
927
+     * @return string
928
+     */
929
+    public function get_user_full_name( $context = 'view' ) {
930
+        return $this->get_full_name( $context );
931
+    }
932
+
933
+    /**
934
+     * Alias of self::get_full_name().
935
+     *
936
+     * @since 1.0.19
937
+     * @param  string $context View or edit context.
938
+     * @return string
939
+     */
940
+    public function get_customer_full_name( $context = 'view' ) {
941
+        return $this->get_full_name( $context );
942
+    }
943
+
944
+    /**
945
+     * Get the customer's phone number.
946
+     *
947
+     * @since 1.0.19
948
+     * @param  string $context View or edit context.
949
+     * @return string
950
+     */
951
+    public function get_phone( $context = 'view' ) {
952
+        return $this->get_prop( 'phone', $context );
953
+    }
954
+
955
+    /**
956
+     * Alias of self::get_phone().
957
+     *
958
+     * @since 1.0.19
959
+     * @param  string $context View or edit context.
960
+     * @return string
961
+     */
962
+    public function get_phone_number( $context = 'view' ) {
963
+        return $this->get_phone( $context );
964
+    }
965
+
966
+    /**
967
+     * Alias of self::get_phone().
968
+     *
969
+     * @since 1.0.19
970
+     * @param  string $context View or edit context.
971
+     * @return string
972
+     */
973
+    public function get_user_phone( $context = 'view' ) {
974
+        return $this->get_phone( $context );
975
+    }
976
+
977
+    /**
978
+     * Alias of self::get_phone().
979
+     *
980
+     * @since 1.0.19
981
+     * @param  string $context View or edit context.
982
+     * @return string
983
+     */
984
+    public function get_customer_phone( $context = 'view' ) {
985
+        return $this->get_phone( $context );
986
+    }
987
+
988
+    /**
989
+     * Get the customer's email address.
990
+     *
991
+     * @since 1.0.19
992
+     * @param  string $context View or edit context.
993
+     * @return string
994
+     */
995
+    public function get_email( $context = 'view' ) {
996
+        return $this->get_prop( 'email', $context );
997
+    }
932 998
 
933 999
     /**
934
-	 * Alias of self::get_full_name().
935
-	 *
936
-	 * @since 1.0.19
937
-	 * @param  string $context View or edit context.
938
-	 * @return string
939
-	 */
940
-	public function get_customer_full_name( $context = 'view' ) {
941
-		return $this->get_full_name( $context );
1000
+     * Alias of self::get_email().
1001
+     *
1002
+     * @since 1.0.19
1003
+     * @param  string $context View or edit context.
1004
+     * @return string
1005
+     */
1006
+    public function get_email_address( $context = 'view' ) {
1007
+        return $this->get_email( $context );
1008
+    }
1009
+
1010
+    /**
1011
+     * Alias of self::get_email().
1012
+     *
1013
+     * @since 1.0.19
1014
+     * @param  string $context View or edit context.
1015
+     * @return string
1016
+     */
1017
+    public function get_user_email( $context = 'view' ) {
1018
+        return $this->get_email( $context );
942 1019
     }
943 1020
 
944 1021
     /**
945
-	 * Get the customer's phone number.
946
-	 *
947
-	 * @since 1.0.19
948
-	 * @param  string $context View or edit context.
949
-	 * @return string
950
-	 */
951
-	public function get_phone( $context = 'view' ) {
952
-		return $this->get_prop( 'phone', $context );
1022
+     * Alias of self::get_email().
1023
+     *
1024
+     * @since 1.0.19
1025
+     * @param  string $context View or edit context.
1026
+     * @return string
1027
+     */
1028
+    public function get_customer_email( $context = 'view' ) {
1029
+        return $this->get_email( $context );
953 1030
     }
954 1031
 
955 1032
     /**
956
-	 * Alias of self::get_phone().
957
-	 *
958
-	 * @since 1.0.19
959
-	 * @param  string $context View or edit context.
960
-	 * @return string
961
-	 */
962
-	public function get_phone_number( $context = 'view' ) {
963
-		return $this->get_phone( $context );
1033
+     * Get the customer's country.
1034
+     *
1035
+     * @since 1.0.19
1036
+     * @param  string $context View or edit context.
1037
+     * @return string
1038
+     */
1039
+    public function get_country( $context = 'view' ) {
1040
+        $country = $this->get_prop( 'country', $context );
1041
+        return empty( $country ) ? wpinv_get_default_country() : $country;
964 1042
     }
965 1043
 
966 1044
     /**
967
-	 * Alias of self::get_phone().
968
-	 *
969
-	 * @since 1.0.19
970
-	 * @param  string $context View or edit context.
971
-	 * @return string
972
-	 */
973
-	public function get_user_phone( $context = 'view' ) {
974
-		return $this->get_phone( $context );
1045
+     * Alias of self::get_country().
1046
+     *
1047
+     * @since 1.0.19
1048
+     * @param  string $context View or edit context.
1049
+     * @return string
1050
+     */
1051
+    public function get_user_country( $context = 'view' ) {
1052
+        return $this->get_country( $context );
975 1053
     }
976 1054
 
977 1055
     /**
978
-	 * Alias of self::get_phone().
979
-	 *
980
-	 * @since 1.0.19
981
-	 * @param  string $context View or edit context.
982
-	 * @return string
983
-	 */
984
-	public function get_customer_phone( $context = 'view' ) {
985
-		return $this->get_phone( $context );
1056
+     * Alias of self::get_country().
1057
+     *
1058
+     * @since 1.0.19
1059
+     * @param  string $context View or edit context.
1060
+     * @return string
1061
+     */
1062
+    public function get_customer_country( $context = 'view' ) {
1063
+        return $this->get_country( $context );
1064
+    }
1065
+
1066
+    /**
1067
+     * Get the customer's state.
1068
+     *
1069
+     * @since 1.0.19
1070
+     * @param  string $context View or edit context.
1071
+     * @return string
1072
+     */
1073
+    public function get_state( $context = 'view' ) {
1074
+        $state = $this->get_prop( 'state', $context );
1075
+        return empty( $state ) ? wpinv_get_default_state() : $state;
1076
+    }
1077
+
1078
+    /**
1079
+     * Alias of self::get_state().
1080
+     *
1081
+     * @since 1.0.19
1082
+     * @param  string $context View or edit context.
1083
+     * @return string
1084
+     */
1085
+    public function get_user_state( $context = 'view' ) {
1086
+        return $this->get_state( $context );
1087
+    }
1088
+
1089
+    /**
1090
+     * Alias of self::get_state().
1091
+     *
1092
+     * @since 1.0.19
1093
+     * @param  string $context View or edit context.
1094
+     * @return string
1095
+     */
1096
+    public function get_customer_state( $context = 'view' ) {
1097
+        return $this->get_state( $context );
986 1098
     }
987 1099
 
988 1100
     /**
989
-	 * Get the customer's email address.
990
-	 *
991
-	 * @since 1.0.19
992
-	 * @param  string $context View or edit context.
993
-	 * @return string
994
-	 */
995
-	public function get_email( $context = 'view' ) {
996
-		return $this->get_prop( 'email', $context );
1101
+     * Get the customer's city.
1102
+     *
1103
+     * @since 1.0.19
1104
+     * @param  string $context View or edit context.
1105
+     * @return string
1106
+     */
1107
+    public function get_city( $context = 'view' ) {
1108
+        return $this->get_prop( 'city', $context );
997 1109
     }
998 1110
 
999 1111
     /**
1000
-	 * Alias of self::get_email().
1001
-	 *
1002
-	 * @since 1.0.19
1003
-	 * @param  string $context View or edit context.
1004
-	 * @return string
1005
-	 */
1006
-	public function get_email_address( $context = 'view' ) {
1007
-		return $this->get_email( $context );
1112
+     * Alias of self::get_city().
1113
+     *
1114
+     * @since 1.0.19
1115
+     * @param  string $context View or edit context.
1116
+     * @return string
1117
+     */
1118
+    public function get_user_city( $context = 'view' ) {
1119
+        return $this->get_city( $context );
1008 1120
     }
1009 1121
 
1010 1122
     /**
1011
-	 * Alias of self::get_email().
1012
-	 *
1013
-	 * @since 1.0.19
1014
-	 * @param  string $context View or edit context.
1015
-	 * @return string
1016
-	 */
1017
-	public function get_user_email( $context = 'view' ) {
1018
-		return $this->get_email( $context );
1123
+     * Alias of self::get_city().
1124
+     *
1125
+     * @since 1.0.19
1126
+     * @param  string $context View or edit context.
1127
+     * @return string
1128
+     */
1129
+    public function get_customer_city( $context = 'view' ) {
1130
+        return $this->get_city( $context );
1019 1131
     }
1020 1132
 
1021 1133
     /**
1022
-	 * Alias of self::get_email().
1023
-	 *
1024
-	 * @since 1.0.19
1025
-	 * @param  string $context View or edit context.
1026
-	 * @return string
1027
-	 */
1028
-	public function get_customer_email( $context = 'view' ) {
1029
-		return $this->get_email( $context );
1134
+     * Get the customer's zip.
1135
+     *
1136
+     * @since 1.0.19
1137
+     * @param  string $context View or edit context.
1138
+     * @return string
1139
+     */
1140
+    public function get_zip( $context = 'view' ) {
1141
+        return $this->get_prop( 'zip', $context );
1030 1142
     }
1031 1143
 
1032 1144
     /**
1033
-	 * Get the customer's country.
1034
-	 *
1035
-	 * @since 1.0.19
1036
-	 * @param  string $context View or edit context.
1037
-	 * @return string
1038
-	 */
1039
-	public function get_country( $context = 'view' ) {
1040
-		$country = $this->get_prop( 'country', $context );
1041
-		return empty( $country ) ? wpinv_get_default_country() : $country;
1145
+     * Alias of self::get_zip().
1146
+     *
1147
+     * @since 1.0.19
1148
+     * @param  string $context View or edit context.
1149
+     * @return string
1150
+     */
1151
+    public function get_user_zip( $context = 'view' ) {
1152
+        return $this->get_zip( $context );
1042 1153
     }
1043 1154
 
1044 1155
     /**
1045
-	 * Alias of self::get_country().
1046
-	 *
1047
-	 * @since 1.0.19
1048
-	 * @param  string $context View or edit context.
1049
-	 * @return string
1050
-	 */
1051
-	public function get_user_country( $context = 'view' ) {
1052
-		return $this->get_country( $context );
1156
+     * Alias of self::get_zip().
1157
+     *
1158
+     * @since 1.0.19
1159
+     * @param  string $context View or edit context.
1160
+     * @return string
1161
+     */
1162
+    public function get_customer_zip( $context = 'view' ) {
1163
+        return $this->get_zip( $context );
1053 1164
     }
1054 1165
 
1055 1166
     /**
1056
-	 * Alias of self::get_country().
1057
-	 *
1058
-	 * @since 1.0.19
1059
-	 * @param  string $context View or edit context.
1060
-	 * @return string
1061
-	 */
1062
-	public function get_customer_country( $context = 'view' ) {
1063
-		return $this->get_country( $context );
1167
+     * Get the customer's company.
1168
+     *
1169
+     * @since 1.0.19
1170
+     * @param  string $context View or edit context.
1171
+     * @return string
1172
+     */
1173
+    public function get_company( $context = 'view' ) {
1174
+        return $this->get_prop( 'company', $context );
1064 1175
     }
1065 1176
 
1066 1177
     /**
1067
-	 * Get the customer's state.
1068
-	 *
1069
-	 * @since 1.0.19
1070
-	 * @param  string $context View or edit context.
1071
-	 * @return string
1072
-	 */
1073
-	public function get_state( $context = 'view' ) {
1074
-		$state = $this->get_prop( 'state', $context );
1075
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1178
+     * Alias of self::get_company().
1179
+     *
1180
+     * @since 1.0.19
1181
+     * @param  string $context View or edit context.
1182
+     * @return string
1183
+     */
1184
+    public function get_user_company( $context = 'view' ) {
1185
+        return $this->get_company( $context );
1076 1186
     }
1077 1187
 
1078 1188
     /**
1079
-	 * Alias of self::get_state().
1080
-	 *
1081
-	 * @since 1.0.19
1082
-	 * @param  string $context View or edit context.
1083
-	 * @return string
1084
-	 */
1085
-	public function get_user_state( $context = 'view' ) {
1086
-		return $this->get_state( $context );
1189
+     * Alias of self::get_company().
1190
+     *
1191
+     * @since 1.0.19
1192
+     * @param  string $context View or edit context.
1193
+     * @return string
1194
+     */
1195
+    public function get_customer_company( $context = 'view' ) {
1196
+        return $this->get_company( $context );
1087 1197
     }
1088 1198
 
1089 1199
     /**
1090
-	 * Alias of self::get_state().
1091
-	 *
1092
-	 * @since 1.0.19
1093
-	 * @param  string $context View or edit context.
1094
-	 * @return string
1095
-	 */
1096
-	public function get_customer_state( $context = 'view' ) {
1097
-		return $this->get_state( $context );
1200
+     * Get the customer's company id.
1201
+     *
1202
+     * @since 1.0.19
1203
+     * @param  string $context View or edit context.
1204
+     * @return string
1205
+     */
1206
+    public function get_company_id( $context = 'view' ) {
1207
+        return $this->get_prop( 'company_id', $context );
1098 1208
     }
1099 1209
 
1100 1210
     /**
1101
-	 * Get the customer's city.
1102
-	 *
1103
-	 * @since 1.0.19
1104
-	 * @param  string $context View or edit context.
1105
-	 * @return string
1106
-	 */
1107
-	public function get_city( $context = 'view' ) {
1108
-		return $this->get_prop( 'city', $context );
1211
+     * Get the customer's vat number.
1212
+     *
1213
+     * @since 1.0.19
1214
+     * @param  string $context View or edit context.
1215
+     * @return string
1216
+     */
1217
+    public function get_vat_number( $context = 'view' ) {
1218
+        return $this->get_prop( 'vat_number', $context );
1109 1219
     }
1110 1220
 
1111 1221
     /**
1112
-	 * Alias of self::get_city().
1113
-	 *
1114
-	 * @since 1.0.19
1115
-	 * @param  string $context View or edit context.
1116
-	 * @return string
1117
-	 */
1118
-	public function get_user_city( $context = 'view' ) {
1119
-		return $this->get_city( $context );
1222
+     * Alias of self::get_vat_number().
1223
+     *
1224
+     * @since 1.0.19
1225
+     * @param  string $context View or edit context.
1226
+     * @return string
1227
+     */
1228
+    public function get_user_vat_number( $context = 'view' ) {
1229
+        return $this->get_vat_number( $context );
1120 1230
     }
1121 1231
 
1122 1232
     /**
1123
-	 * Alias of self::get_city().
1124
-	 *
1125
-	 * @since 1.0.19
1126
-	 * @param  string $context View or edit context.
1127
-	 * @return string
1128
-	 */
1129
-	public function get_customer_city( $context = 'view' ) {
1130
-		return $this->get_city( $context );
1233
+     * Alias of self::get_vat_number().
1234
+     *
1235
+     * @since 1.0.19
1236
+     * @param  string $context View or edit context.
1237
+     * @return string
1238
+     */
1239
+    public function get_customer_vat_number( $context = 'view' ) {
1240
+        return $this->get_vat_number( $context );
1131 1241
     }
1132 1242
 
1133 1243
     /**
1134
-	 * Get the customer's zip.
1135
-	 *
1136
-	 * @since 1.0.19
1137
-	 * @param  string $context View or edit context.
1138
-	 * @return string
1139
-	 */
1140
-	public function get_zip( $context = 'view' ) {
1141
-		return $this->get_prop( 'zip', $context );
1244
+     * Get the customer's vat rate.
1245
+     *
1246
+     * @since 1.0.19
1247
+     * @param  string $context View or edit context.
1248
+     * @return string
1249
+     */
1250
+    public function get_vat_rate( $context = 'view' ) {
1251
+        return $this->get_prop( 'vat_rate', $context );
1142 1252
     }
1143 1253
 
1144 1254
     /**
1145
-	 * Alias of self::get_zip().
1146
-	 *
1147
-	 * @since 1.0.19
1148
-	 * @param  string $context View or edit context.
1149
-	 * @return string
1150
-	 */
1151
-	public function get_user_zip( $context = 'view' ) {
1152
-		return $this->get_zip( $context );
1255
+     * Alias of self::get_vat_rate().
1256
+     *
1257
+     * @since 1.0.19
1258
+     * @param  string $context View or edit context.
1259
+     * @return string
1260
+     */
1261
+    public function get_user_vat_rate( $context = 'view' ) {
1262
+        return $this->get_vat_rate( $context );
1153 1263
     }
1154 1264
 
1155 1265
     /**
1156
-	 * Alias of self::get_zip().
1157
-	 *
1158
-	 * @since 1.0.19
1159
-	 * @param  string $context View or edit context.
1160
-	 * @return string
1161
-	 */
1162
-	public function get_customer_zip( $context = 'view' ) {
1163
-		return $this->get_zip( $context );
1266
+     * Alias of self::get_vat_rate().
1267
+     *
1268
+     * @since 1.0.19
1269
+     * @param  string $context View or edit context.
1270
+     * @return string
1271
+     */
1272
+    public function get_customer_vat_rate( $context = 'view' ) {
1273
+        return $this->get_vat_rate( $context );
1164 1274
     }
1165 1275
 
1166 1276
     /**
1167
-	 * Get the customer's company.
1168
-	 *
1169
-	 * @since 1.0.19
1170
-	 * @param  string $context View or edit context.
1171
-	 * @return string
1172
-	 */
1173
-	public function get_company( $context = 'view' ) {
1174
-		return $this->get_prop( 'company', $context );
1277
+     * Get the customer's address.
1278
+     *
1279
+     * @since 1.0.19
1280
+     * @param  string $context View or edit context.
1281
+     * @return string
1282
+     */
1283
+    public function get_address( $context = 'view' ) {
1284
+        return $this->get_prop( 'address', $context );
1175 1285
     }
1176 1286
 
1177 1287
     /**
1178
-	 * Alias of self::get_company().
1179
-	 *
1180
-	 * @since 1.0.19
1181
-	 * @param  string $context View or edit context.
1182
-	 * @return string
1183
-	 */
1184
-	public function get_user_company( $context = 'view' ) {
1185
-		return $this->get_company( $context );
1288
+     * Alias of self::get_address().
1289
+     *
1290
+     * @since 1.0.19
1291
+     * @param  string $context View or edit context.
1292
+     * @return string
1293
+     */
1294
+    public function get_user_address( $context = 'view' ) {
1295
+        return $this->get_address( $context );
1186 1296
     }
1187 1297
 
1188 1298
     /**
1189
-	 * Alias of self::get_company().
1190
-	 *
1191
-	 * @since 1.0.19
1192
-	 * @param  string $context View or edit context.
1193
-	 * @return string
1194
-	 */
1195
-	public function get_customer_company( $context = 'view' ) {
1196
-		return $this->get_company( $context );
1299
+     * Alias of self::get_address().
1300
+     *
1301
+     * @since 1.0.19
1302
+     * @param  string $context View or edit context.
1303
+     * @return string
1304
+     */
1305
+    public function get_customer_address( $context = 'view' ) {
1306
+        return $this->get_address( $context );
1197 1307
     }
1198 1308
 
1199
-	/**
1200
-	 * Get the customer's company id.
1201
-	 *
1202
-	 * @since 1.0.19
1203
-	 * @param  string $context View or edit context.
1204
-	 * @return string
1205
-	 */
1206
-	public function get_company_id( $context = 'view' ) {
1207
-		return $this->get_prop( 'company_id', $context );
1309
+    /**
1310
+     * Get whether the customer has viewed the invoice or not.
1311
+     *
1312
+     * @since 1.0.19
1313
+     * @param  string $context View or edit context.
1314
+     * @return bool
1315
+     */
1316
+    public function get_is_viewed( $context = 'view' ) {
1317
+        return (bool) $this->get_prop( 'is_viewed', $context );
1208 1318
     }
1209 1319
 
1210 1320
     /**
1211
-	 * Get the customer's vat number.
1212
-	 *
1213
-	 * @since 1.0.19
1214
-	 * @param  string $context View or edit context.
1215
-	 * @return string
1216
-	 */
1217
-	public function get_vat_number( $context = 'view' ) {
1218
-		return $this->get_prop( 'vat_number', $context );
1321
+     * Get other recipients for invoice communications.
1322
+     *
1323
+     * @since 1.0.19
1324
+     * @param  string $context View or edit context.
1325
+     * @return bool
1326
+     */
1327
+    public function get_email_cc( $context = 'view' ) {
1328
+        return $this->get_prop( 'email_cc', $context );
1219 1329
     }
1220 1330
 
1221 1331
     /**
1222
-	 * Alias of self::get_vat_number().
1223
-	 *
1224
-	 * @since 1.0.19
1225
-	 * @param  string $context View or edit context.
1226
-	 * @return string
1227
-	 */
1228
-	public function get_user_vat_number( $context = 'view' ) {
1229
-		return $this->get_vat_number( $context );
1332
+     * Get invoice template.
1333
+     *
1334
+     * @since 1.0.19
1335
+     * @param  string $context View or edit context.
1336
+     * @return bool
1337
+     */
1338
+    public function get_template( $context = 'view' ) {
1339
+        return $this->get_prop( 'template', $context );
1230 1340
     }
1231 1341
 
1232 1342
     /**
1233
-	 * Alias of self::get_vat_number().
1234
-	 *
1235
-	 * @since 1.0.19
1236
-	 * @param  string $context View or edit context.
1237
-	 * @return string
1238
-	 */
1239
-	public function get_customer_vat_number( $context = 'view' ) {
1240
-		return $this->get_vat_number( $context );
1343
+     * Get invoice source.
1344
+     *
1345
+     * @since 1.0.19
1346
+     * @param  string $context View or edit context.
1347
+     * @return bool
1348
+     */
1349
+    public function get_created_via( $context = 'view' ) {
1350
+        return $this->get_prop( 'created_via', $context );
1241 1351
     }
1242 1352
 
1243
-    /**
1244
-	 * Get the customer's vat rate.
1245
-	 *
1246
-	 * @since 1.0.19
1247
-	 * @param  string $context View or edit context.
1248
-	 * @return string
1249
-	 */
1250
-	public function get_vat_rate( $context = 'view' ) {
1251
-		return $this->get_prop( 'vat_rate', $context );
1252
-    }
1253
-
1254
-    /**
1255
-	 * Alias of self::get_vat_rate().
1256
-	 *
1257
-	 * @since 1.0.19
1258
-	 * @param  string $context View or edit context.
1259
-	 * @return string
1260
-	 */
1261
-	public function get_user_vat_rate( $context = 'view' ) {
1262
-		return $this->get_vat_rate( $context );
1263
-    }
1264
-
1265
-    /**
1266
-	 * Alias of self::get_vat_rate().
1267
-	 *
1268
-	 * @since 1.0.19
1269
-	 * @param  string $context View or edit context.
1270
-	 * @return string
1271
-	 */
1272
-	public function get_customer_vat_rate( $context = 'view' ) {
1273
-		return $this->get_vat_rate( $context );
1274
-    }
1275
-
1276
-    /**
1277
-	 * Get the customer's address.
1278
-	 *
1279
-	 * @since 1.0.19
1280
-	 * @param  string $context View or edit context.
1281
-	 * @return string
1282
-	 */
1283
-	public function get_address( $context = 'view' ) {
1284
-		return $this->get_prop( 'address', $context );
1285
-    }
1286
-
1287
-    /**
1288
-	 * Alias of self::get_address().
1289
-	 *
1290
-	 * @since 1.0.19
1291
-	 * @param  string $context View or edit context.
1292
-	 * @return string
1293
-	 */
1294
-	public function get_user_address( $context = 'view' ) {
1295
-		return $this->get_address( $context );
1296
-    }
1297
-
1298
-    /**
1299
-	 * Alias of self::get_address().
1300
-	 *
1301
-	 * @since 1.0.19
1302
-	 * @param  string $context View or edit context.
1303
-	 * @return string
1304
-	 */
1305
-	public function get_customer_address( $context = 'view' ) {
1306
-		return $this->get_address( $context );
1307
-    }
1308
-
1309
-    /**
1310
-	 * Get whether the customer has viewed the invoice or not.
1311
-	 *
1312
-	 * @since 1.0.19
1313
-	 * @param  string $context View or edit context.
1314
-	 * @return bool
1315
-	 */
1316
-	public function get_is_viewed( $context = 'view' ) {
1317
-		return (bool) $this->get_prop( 'is_viewed', $context );
1318
-	}
1319
-
1320
-	/**
1321
-	 * Get other recipients for invoice communications.
1322
-	 *
1323
-	 * @since 1.0.19
1324
-	 * @param  string $context View or edit context.
1325
-	 * @return bool
1326
-	 */
1327
-	public function get_email_cc( $context = 'view' ) {
1328
-		return $this->get_prop( 'email_cc', $context );
1329
-	}
1330
-
1331
-	/**
1332
-	 * Get invoice template.
1333
-	 *
1334
-	 * @since 1.0.19
1335
-	 * @param  string $context View or edit context.
1336
-	 * @return bool
1337
-	 */
1338
-	public function get_template( $context = 'view' ) {
1339
-		return $this->get_prop( 'template', $context );
1340
-	}
1341
-
1342
-	/**
1343
-	 * Get invoice source.
1344
-	 *
1345
-	 * @since 1.0.19
1346
-	 * @param  string $context View or edit context.
1347
-	 * @return bool
1348
-	 */
1349
-	public function get_created_via( $context = 'view' ) {
1350
-		return $this->get_prop( 'created_via', $context );
1351
-	}
1352
-
1353
-	/**
1354
-	 * Get whether the customer has confirmed their address.
1355
-	 *
1356
-	 * @since 1.0.19
1357
-	 * @param  string $context View or edit context.
1358
-	 * @return bool
1359
-	 */
1360
-	public function get_address_confirmed( $context = 'view' ) {
1361
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1362
-    }
1363
-
1364
-    /**
1365
-	 * Alias of self::get_address_confirmed().
1366
-	 *
1367
-	 * @since 1.0.19
1368
-	 * @param  string $context View or edit context.
1369
-	 * @return bool
1370
-	 */
1371
-	public function get_user_address_confirmed( $context = 'view' ) {
1372
-		return $this->get_address_confirmed( $context );
1373
-    }
1374
-
1375
-    /**
1376
-	 * Alias of self::get_address().
1377
-	 *
1378
-	 * @since 1.0.19
1379
-	 * @param  string $context View or edit context.
1380
-	 * @return bool
1381
-	 */
1382
-	public function get_customer_address_confirmed( $context = 'view' ) {
1383
-		return $this->get_address_confirmed( $context );
1384
-    }
1385
-
1386
-	/**
1387
-	 * Get the shipping address.
1388
-	 *
1389
-	 * @since 1.0.19
1390
-	 * @return array|false
1391
-	 */
1392
-	public function get_shipping_address() {
1393
-
1394
-		$shipping_address = get_post_meta( $this->get_id(), 'shipping_address', true );
1395
-		return is_array( $shipping_address ) ? $shipping_address : false;
1396
-    }
1397
-
1398
-	/**
1399
-	 * Check if the invoice has a shipping address.
1400
-	 */
1401
-	public function has_shipping_address() {
1402
-		return false !== $this->get_shipping_address();
1403
-    }
1404
-
1405
-	/**
1406
-	 * Get the shipping amount.
1407
-	 *
1408
-	 * @since 1.0.19
1409
-	 * @param  string $context View or edit context.
1410
-	 * @return float
1411
-	 */
1412
-	public function get_shipping( $context = 'view' ) {
1413
-
1414
-		if ( $context = 'view' ) {
1415
-			return floatval( $this->get_prop( 'shipping', $context ) );
1416
-		}
1417
-
1418
-		return $this->get_prop( 'shipping', $context );
1419
-    }
1420
-
1421
-	public function has_shipping() {
1422
-		return defined( 'GETPAID_SHIPPING_CALCULATOR_VERSION' ) && $this->get_prop( 'shipping', 'edit' );
1423
-    }
1424
-
1425
-    /**
1426
-	 * Get the invoice subtotal.
1427
-	 *
1428
-	 * @since 1.0.19
1429
-	 * @param  string $context View or edit context.
1430
-	 * @return float
1431
-	 */
1432
-	public function get_subtotal( $context = 'view' ) {
1353
+    /**
1354
+     * Get whether the customer has confirmed their address.
1355
+     *
1356
+     * @since 1.0.19
1357
+     * @param  string $context View or edit context.
1358
+     * @return bool
1359
+     */
1360
+    public function get_address_confirmed( $context = 'view' ) {
1361
+        return (bool) $this->get_prop( 'address_confirmed', $context );
1362
+    }
1363
+
1364
+    /**
1365
+     * Alias of self::get_address_confirmed().
1366
+     *
1367
+     * @since 1.0.19
1368
+     * @param  string $context View or edit context.
1369
+     * @return bool
1370
+     */
1371
+    public function get_user_address_confirmed( $context = 'view' ) {
1372
+        return $this->get_address_confirmed( $context );
1373
+    }
1374
+
1375
+    /**
1376
+     * Alias of self::get_address().
1377
+     *
1378
+     * @since 1.0.19
1379
+     * @param  string $context View or edit context.
1380
+     * @return bool
1381
+     */
1382
+    public function get_customer_address_confirmed( $context = 'view' ) {
1383
+        return $this->get_address_confirmed( $context );
1384
+    }
1385
+
1386
+    /**
1387
+     * Get the shipping address.
1388
+     *
1389
+     * @since 1.0.19
1390
+     * @return array|false
1391
+     */
1392
+    public function get_shipping_address() {
1393
+
1394
+        $shipping_address = get_post_meta( $this->get_id(), 'shipping_address', true );
1395
+        return is_array( $shipping_address ) ? $shipping_address : false;
1396
+    }
1397
+
1398
+    /**
1399
+     * Check if the invoice has a shipping address.
1400
+     */
1401
+    public function has_shipping_address() {
1402
+        return false !== $this->get_shipping_address();
1403
+    }
1404
+
1405
+    /**
1406
+     * Get the shipping amount.
1407
+     *
1408
+     * @since 1.0.19
1409
+     * @param  string $context View or edit context.
1410
+     * @return float
1411
+     */
1412
+    public function get_shipping( $context = 'view' ) {
1413
+
1414
+        if ( $context = 'view' ) {
1415
+            return floatval( $this->get_prop( 'shipping', $context ) );
1416
+        }
1417
+
1418
+        return $this->get_prop( 'shipping', $context );
1419
+    }
1420
+
1421
+    public function has_shipping() {
1422
+        return defined( 'GETPAID_SHIPPING_CALCULATOR_VERSION' ) && $this->get_prop( 'shipping', 'edit' );
1423
+    }
1424
+
1425
+    /**
1426
+     * Get the invoice subtotal.
1427
+     *
1428
+     * @since 1.0.19
1429
+     * @param  string $context View or edit context.
1430
+     * @return float
1431
+     */
1432
+    public function get_subtotal( $context = 'view' ) {
1433 1433
         $subtotal = (float) $this->get_prop( 'subtotal', $context );
1434 1434
 
1435 1435
         // Backwards compatibility.
@@ -1441,198 +1441,198 @@  discard block
 block discarded – undo
1441 1441
     }
1442 1442
 
1443 1443
     /**
1444
-	 * Get the invoice discount total.
1445
-	 *
1446
-	 * @since 1.0.19
1447
-	 * @param  string $context View or edit context.
1448
-	 * @return float
1449
-	 */
1450
-	public function get_total_discount( $context = 'view' ) {
1451
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1444
+     * Get the invoice discount total.
1445
+     *
1446
+     * @since 1.0.19
1447
+     * @param  string $context View or edit context.
1448
+     * @return float
1449
+     */
1450
+    public function get_total_discount( $context = 'view' ) {
1451
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1452 1452
     }
1453 1453
 
1454 1454
     /**
1455
-	 * Get the invoice tax total.
1456
-	 *
1457
-	 * @since 1.0.19
1458
-	 * @param  string $context View or edit context.
1459
-	 * @return float
1460
-	 */
1461
-	public function get_total_tax( $context = 'view' ) {
1462
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1463
-	}
1455
+     * Get the invoice tax total.
1456
+     *
1457
+     * @since 1.0.19
1458
+     * @param  string $context View or edit context.
1459
+     * @return float
1460
+     */
1461
+    public function get_total_tax( $context = 'view' ) {
1462
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1463
+    }
1464 1464
 
1465
-	/**
1466
-	 * @deprecated
1467
-	 */
1468
-	public function get_final_tax( $currency = false ) {
1469
-		$tax = $this->get_total_tax();
1465
+    /**
1466
+     * @deprecated
1467
+     */
1468
+    public function get_final_tax( $currency = false ) {
1469
+        $tax = $this->get_total_tax();
1470 1470
 
1471 1471
         if ( $currency ) {
1472
-			return wpinv_price( $tax, $this->get_currency() );
1472
+            return wpinv_price( $tax, $this->get_currency() );
1473 1473
         }
1474 1474
 
1475 1475
         return $tax;
1476 1476
     }
1477 1477
 
1478 1478
     /**
1479
-	 * Get the invoice fees total.
1480
-	 *
1481
-	 * @since 1.0.19
1482
-	 * @param  string $context View or edit context.
1483
-	 * @return float
1484
-	 */
1485
-	public function get_total_fees( $context = 'view' ) {
1486
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1479
+     * Get the invoice fees total.
1480
+     *
1481
+     * @since 1.0.19
1482
+     * @param  string $context View or edit context.
1483
+     * @return float
1484
+     */
1485
+    public function get_total_fees( $context = 'view' ) {
1486
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1487
+    }
1488
+
1489
+    /**
1490
+     * Alias for self::get_total_fees().
1491
+     *
1492
+     * @since 1.0.19
1493
+     * @param  string $context View or edit context.
1494
+     * @return float
1495
+     */
1496
+    public function get_fees_total( $context = 'view' ) {
1497
+        return $this->get_total_fees( $context );
1487 1498
     }
1488 1499
 
1489 1500
     /**
1490
-	 * Alias for self::get_total_fees().
1491
-	 *
1492
-	 * @since 1.0.19
1493
-	 * @param  string $context View or edit context.
1494
-	 * @return float
1495
-	 */
1496
-	public function get_fees_total( $context = 'view' ) {
1497
-		return $this->get_total_fees( $context );
1501
+     * Get the invoice total.
1502
+     *
1503
+     * @since 1.0.19
1504
+     * @return float
1505
+     */
1506
+    public function get_total( $context = 'view' ) {
1507
+        $total = $this->get_prop( 'total', $context );
1508
+
1509
+        if ( $this->has_shipping() && $context == 'view' ) {
1510
+            $total = $this->get_prop( 'total', $context ) + $this->get_shipping( $context );
1511
+        }
1512
+
1513
+        return wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1498 1514
     }
1499 1515
 
1500 1516
     /**
1501
-	 * Get the invoice total.
1502
-	 *
1503
-	 * @since 1.0.19
1517
+     * Retrieves the non-recurring total of items.
1518
+     *
1519
+     * @since 2.3.0
1504 1520
      * @return float
1505
-	 */
1506
-	public function get_total( $context = 'view' ) {
1507
-		$total = $this->get_prop( 'total', $context );
1508
-
1509
-		if ( $this->has_shipping() && $context == 'view' ) {
1510
-			$total = $this->get_prop( 'total', $context ) + $this->get_shipping( $context );
1511
-		}
1512
-
1513
-		return wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1514
-	}
1515
-
1516
-	/**
1517
-	 * Retrieves the non-recurring total of items.
1518
-	 *
1519
-	 * @since 2.3.0
1520
-	 * @return float
1521
-	 */
1522
-	public function get_non_recurring_total() {
1523
-
1524
-		$subtotal = 0;
1525
-		foreach ( $this->get_items() as $item ) {
1526
-			if ( ! $item->is_recurring() ) {
1527
-				$subtotal += $item->get_sub_total();
1528
-			}
1529
-		}
1530
-
1531
-		foreach ( $this->get_fees() as $fee ) {
1532
-			if ( empty( $fee['recurring_fee'] ) ) {
1533
-				$subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1534
-			}
1535
-		}
1536
-
1537
-		$subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1521
+     */
1522
+    public function get_non_recurring_total() {
1523
+
1524
+        $subtotal = 0;
1525
+        foreach ( $this->get_items() as $item ) {
1526
+            if ( ! $item->is_recurring() ) {
1527
+                $subtotal += $item->get_sub_total();
1528
+            }
1529
+        }
1530
+
1531
+        foreach ( $this->get_fees() as $fee ) {
1532
+            if ( empty( $fee['recurring_fee'] ) ) {
1533
+                $subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1534
+            }
1535
+        }
1536
+
1537
+        $subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1538 1538
         return apply_filters( 'wpinv_get_non_recurring_invoice_total', $subtotal, $this );
1539 1539
 
1540 1540
     }
1541 1541
 
1542
-	/**
1543
-	 * Get the invoice totals.
1544
-	 *
1545
-	 * @since 1.0.19
1542
+    /**
1543
+     * Get the invoice totals.
1544
+     *
1545
+     * @since 1.0.19
1546 1546
      * @return array
1547
-	 */
1548
-	public function get_totals() {
1549
-		return $this->totals;
1547
+     */
1548
+    public function get_totals() {
1549
+        return $this->totals;
1550 1550
     }
1551 1551
 
1552 1552
     /**
1553
-	 * Get the initial invoice total.
1554
-	 *
1555
-	 * @since 1.0.19
1553
+     * Get the initial invoice total.
1554
+     *
1555
+     * @since 1.0.19
1556 1556
      * @param  string $context View or edit context.
1557 1557
      * @return float
1558
-	 */
1558
+     */
1559 1559
     public function get_initial_total() {
1560 1560
 
1561
-		if ( empty( $this->totals ) ) {
1562
-			$this->recalculate_total();
1563
-		}
1561
+        if ( empty( $this->totals ) ) {
1562
+            $this->recalculate_total();
1563
+        }
1564 1564
 
1565
-		$tax      = $this->totals['tax']['initial'];
1566
-		$fee      = $this->totals['fee']['initial'];
1567
-		$discount = $this->totals['discount']['initial'];
1568
-		$subtotal = $this->totals['subtotal']['initial'];
1569
-		$total    = $tax + $fee - $discount + $subtotal;
1565
+        $tax      = $this->totals['tax']['initial'];
1566
+        $fee      = $this->totals['fee']['initial'];
1567
+        $discount = $this->totals['discount']['initial'];
1568
+        $subtotal = $this->totals['subtotal']['initial'];
1569
+        $total    = $tax + $fee - $discount + $subtotal;
1570 1570
 
1571
-		if ( 0 > $total ) {
1572
-			$total = 0;
1573
-		}
1571
+        if ( 0 > $total ) {
1572
+            $total = 0;
1573
+        }
1574 1574
 
1575
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1575
+        $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1576 1576
         return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1577
-	}
1577
+    }
1578 1578
 
1579
-	/**
1580
-	 * Get the recurring invoice total.
1581
-	 *
1582
-	 * @since 1.0.19
1579
+    /**
1580
+     * Get the recurring invoice total.
1581
+     *
1582
+     * @since 1.0.19
1583 1583
      * @param  string $context View or edit context.
1584 1584
      * @return float
1585
-	 */
1585
+     */
1586 1586
     public function get_recurring_total() {
1587 1587
 
1588
-		if ( empty( $this->totals ) ) {
1589
-			$this->recalculate_total();
1590
-		}
1588
+        if ( empty( $this->totals ) ) {
1589
+            $this->recalculate_total();
1590
+        }
1591 1591
 
1592
-		$tax      = $this->totals['tax']['recurring'];
1593
-		$fee      = $this->totals['fee']['recurring'];
1594
-		$discount = $this->totals['discount']['recurring'];
1595
-		$subtotal = $this->totals['subtotal']['recurring'];
1596
-		$total    = $tax + $fee - $discount + $subtotal;
1592
+        $tax      = $this->totals['tax']['recurring'];
1593
+        $fee      = $this->totals['fee']['recurring'];
1594
+        $discount = $this->totals['discount']['recurring'];
1595
+        $subtotal = $this->totals['subtotal']['recurring'];
1596
+        $total    = $tax + $fee - $discount + $subtotal;
1597 1597
 
1598
-		if ( 0 > $total ) {
1599
-			$total = 0;
1600
-		}
1598
+        if ( 0 > $total ) {
1599
+            $total = 0;
1600
+        }
1601 1601
 
1602
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1602
+        $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1603 1603
         return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1604
-	}
1604
+    }
1605 1605
 
1606
-	/**
1607
-	 * Returns recurring payment details.
1608
-	 *
1609
-	 * @since 1.0.19
1606
+    /**
1607
+     * Returns recurring payment details.
1608
+     *
1609
+     * @since 1.0.19
1610 1610
      * @param  string $field Optionally provide a field to return.
1611
-	 * @param string $currency Whether to include the currency.
1611
+     * @param string $currency Whether to include the currency.
1612 1612
      * @return float|string
1613
-	 */
1613
+     */
1614 1614
     public function get_recurring_details( $field = '', $currency = false ) {
1615 1615
 
1616
-		// Maybe recalculate totals.
1617
-		if ( empty( $this->totals ) ) {
1618
-			$this->recalculate_total();
1619
-		}
1616
+        // Maybe recalculate totals.
1617
+        if ( empty( $this->totals ) ) {
1618
+            $this->recalculate_total();
1619
+        }
1620 1620
 
1621
-		// Prepare recurring totals.
1621
+        // Prepare recurring totals.
1622 1622
         $data = apply_filters(
1623
-			'wpinv_get_invoice_recurring_details',
1624
-			array(
1625
-				'cart_details' => $this->get_cart_details(),
1626
-				'subtotal'     => $this->totals['subtotal']['recurring'],
1627
-				'discount'     => $this->totals['discount']['recurring'],
1628
-				'tax'          => $this->totals['tax']['recurring'],
1629
-				'fee'          => $this->totals['fee']['recurring'],
1630
-				'total'        => $this->get_recurring_total(),
1631
-			),
1632
-			$this,
1633
-			$field,
1634
-			$currency
1635
-		);
1623
+            'wpinv_get_invoice_recurring_details',
1624
+            array(
1625
+                'cart_details' => $this->get_cart_details(),
1626
+                'subtotal'     => $this->totals['subtotal']['recurring'],
1627
+                'discount'     => $this->totals['discount']['recurring'],
1628
+                'tax'          => $this->totals['tax']['recurring'],
1629
+                'fee'          => $this->totals['fee']['recurring'],
1630
+                'total'        => $this->get_recurring_total(),
1631
+            ),
1632
+            $this,
1633
+            $field,
1634
+            $currency
1635
+        );
1636 1636
 
1637 1637
         if ( isset( $data[ $field ] ) ) {
1638 1638
             return ( $currency ? wpinv_price( $data[ $field ], $this->get_currency() ) : $data[ $field ] );
@@ -1642,166 +1642,166 @@  discard block
 block discarded – undo
1642 1642
     }
1643 1643
 
1644 1644
     /**
1645
-	 * Get the invoice fees.
1646
-	 *
1647
-	 * @since 1.0.19
1648
-	 * @param  string $context View or edit context.
1649
-	 * @return array
1650
-	 */
1651
-	public function get_fees( $context = 'view' ) {
1652
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1645
+     * Get the invoice fees.
1646
+     *
1647
+     * @since 1.0.19
1648
+     * @param  string $context View or edit context.
1649
+     * @return array
1650
+     */
1651
+    public function get_fees( $context = 'view' ) {
1652
+        return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1653 1653
     }
1654 1654
 
1655 1655
     /**
1656
-	 * Get the invoice discounts.
1657
-	 *
1658
-	 * @since 1.0.19
1659
-	 * @param  string $context View or edit context.
1660
-	 * @return array
1661
-	 */
1662
-	public function get_discounts( $context = 'view' ) {
1663
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1656
+     * Get the invoice discounts.
1657
+     *
1658
+     * @since 1.0.19
1659
+     * @param  string $context View or edit context.
1660
+     * @return array
1661
+     */
1662
+    public function get_discounts( $context = 'view' ) {
1663
+        return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1664 1664
     }
1665 1665
 
1666 1666
     /**
1667
-	 * Get the invoice taxes.
1668
-	 *
1669
-	 * @since 1.0.19
1670
-	 * @param  string $context View or edit context.
1671
-	 * @return array
1672
-	 */
1673
-	public function get_taxes( $context = 'view' ) {
1674
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1667
+     * Get the invoice taxes.
1668
+     *
1669
+     * @since 1.0.19
1670
+     * @param  string $context View or edit context.
1671
+     * @return array
1672
+     */
1673
+    public function get_taxes( $context = 'view' ) {
1674
+        return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1675 1675
     }
1676 1676
 
1677 1677
     /**
1678
-	 * Get the invoice items.
1679
-	 *
1680
-	 * @since 1.0.19
1681
-	 * @param  string $context View or edit context.
1682
-	 * @return GetPaid_Form_Item[]
1683
-	 */
1684
-	public function get_items( $context = 'view' ) {
1678
+     * Get the invoice items.
1679
+     *
1680
+     * @since 1.0.19
1681
+     * @param  string $context View or edit context.
1682
+     * @return GetPaid_Form_Item[]
1683
+     */
1684
+    public function get_items( $context = 'view' ) {
1685 1685
         return $this->get_prop( 'items', $context );
1686
-	}
1686
+    }
1687 1687
 
1688
-	/**
1689
-	 * Get the invoice item ids.
1690
-	 *
1691
-	 * @since 1.0.19
1692
-	 * @return string
1693
-	 */
1694
-	public function get_item_ids() {
1695
-		return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1688
+    /**
1689
+     * Get the invoice item ids.
1690
+     *
1691
+     * @since 1.0.19
1692
+     * @return string
1693
+     */
1694
+    public function get_item_ids() {
1695
+        return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1696 1696
     }
1697 1697
 
1698 1698
     /**
1699
-	 * Get the invoice's payment form.
1700
-	 *
1701
-	 * @since 1.0.19
1702
-	 * @param  string $context View or edit context.
1703
-	 * @return int
1704
-	 */
1705
-	public function get_payment_form( $context = 'view' ) {
1706
-		return intval( $this->get_prop( 'payment_form', $context ) );
1699
+     * Get the invoice's payment form.
1700
+     *
1701
+     * @since 1.0.19
1702
+     * @param  string $context View or edit context.
1703
+     * @return int
1704
+     */
1705
+    public function get_payment_form( $context = 'view' ) {
1706
+        return intval( $this->get_prop( 'payment_form', $context ) );
1707 1707
     }
1708 1708
 
1709 1709
     /**
1710
-	 * Get the invoice's submission id.
1711
-	 *
1712
-	 * @since 1.0.19
1713
-	 * @param  string $context View or edit context.
1714
-	 * @return string
1715
-	 */
1716
-	public function get_submission_id( $context = 'view' ) {
1717
-		return $this->get_prop( 'submission_id', $context );
1710
+     * Get the invoice's submission id.
1711
+     *
1712
+     * @since 1.0.19
1713
+     * @param  string $context View or edit context.
1714
+     * @return string
1715
+     */
1716
+    public function get_submission_id( $context = 'view' ) {
1717
+        return $this->get_prop( 'submission_id', $context );
1718 1718
     }
1719 1719
 
1720 1720
     /**
1721
-	 * Get the invoice's discount code.
1722
-	 *
1723
-	 * @since 1.0.19
1724
-	 * @param  string $context View or edit context.
1725
-	 * @return string
1726
-	 */
1727
-	public function get_discount_code( $context = 'view' ) {
1728
-		return $this->get_prop( 'discount_code', $context );
1721
+     * Get the invoice's discount code.
1722
+     *
1723
+     * @since 1.0.19
1724
+     * @param  string $context View or edit context.
1725
+     * @return string
1726
+     */
1727
+    public function get_discount_code( $context = 'view' ) {
1728
+        return $this->get_prop( 'discount_code', $context );
1729 1729
     }
1730 1730
 
1731 1731
     /**
1732
-	 * Get the invoice's gateway.
1733
-	 *
1734
-	 * @since 1.0.19
1735
-	 * @param  string $context View or edit context.
1736
-	 * @return string
1737
-	 */
1738
-	public function get_gateway( $context = 'view' ) {
1739
-		return $this->get_prop( 'gateway', $context );
1732
+     * Get the invoice's gateway.
1733
+     *
1734
+     * @since 1.0.19
1735
+     * @param  string $context View or edit context.
1736
+     * @return string
1737
+     */
1738
+    public function get_gateway( $context = 'view' ) {
1739
+        return $this->get_prop( 'gateway', $context );
1740 1740
     }
1741 1741
 
1742 1742
     /**
1743
-	 * Get the invoice's gateway display title.
1744
-	 *
1745
-	 * @since 1.0.19
1746
-	 * @return string
1747
-	 */
1743
+     * Get the invoice's gateway display title.
1744
+     *
1745
+     * @since 1.0.19
1746
+     * @return string
1747
+     */
1748 1748
     public function get_gateway_title() {
1749 1749
         $title = wpinv_get_gateway_checkout_label( $this->get_gateway() );
1750 1750
         return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1751 1751
     }
1752 1752
 
1753 1753
     /**
1754
-	 * Get the invoice's transaction id.
1755
-	 *
1756
-	 * @since 1.0.19
1757
-	 * @param  string $context View or edit context.
1758
-	 * @return string
1759
-	 */
1760
-	public function get_transaction_id( $context = 'view' ) {
1761
-		return $this->get_prop( 'transaction_id', $context );
1754
+     * Get the invoice's transaction id.
1755
+     *
1756
+     * @since 1.0.19
1757
+     * @param  string $context View or edit context.
1758
+     * @return string
1759
+     */
1760
+    public function get_transaction_id( $context = 'view' ) {
1761
+        return $this->get_prop( 'transaction_id', $context );
1762 1762
     }
1763 1763
 
1764 1764
     /**
1765
-	 * Get the invoice's currency.
1766
-	 *
1767
-	 * @since 1.0.19
1768
-	 * @param  string $context View or edit context.
1769
-	 * @return string
1770
-	 */
1771
-	public function get_currency( $context = 'view' ) {
1765
+     * Get the invoice's currency.
1766
+     *
1767
+     * @since 1.0.19
1768
+     * @param  string $context View or edit context.
1769
+     * @return string
1770
+     */
1771
+    public function get_currency( $context = 'view' ) {
1772 1772
         $currency = $this->get_prop( 'currency', $context );
1773 1773
         return empty( $currency ) ? wpinv_get_currency() : $currency;
1774 1774
     }
1775 1775
 
1776 1776
     /**
1777
-	 * Checks if we are charging taxes for this invoice.
1778
-	 *
1779
-	 * @since 1.0.19
1780
-	 * @param  string $context View or edit context.
1781
-	 * @return bool
1782
-	 */
1783
-	public function get_disable_taxes( $context = 'view' ) {
1777
+     * Checks if we are charging taxes for this invoice.
1778
+     *
1779
+     * @since 1.0.19
1780
+     * @param  string $context View or edit context.
1781
+     * @return bool
1782
+     */
1783
+    public function get_disable_taxes( $context = 'view' ) {
1784 1784
         return (bool) $this->get_prop( 'disable_taxes', $context );
1785 1785
     }
1786 1786
 
1787 1787
     /**
1788
-	 * Retrieves the subscription id for an invoice.
1789
-	 *
1790
-	 * @since 1.0.19
1791
-	 * @param  string $context View or edit context.
1792
-	 * @return int
1793
-	 */
1788
+     * Retrieves the subscription id for an invoice.
1789
+     *
1790
+     * @since 1.0.19
1791
+     * @param  string $context View or edit context.
1792
+     * @return int
1793
+     */
1794 1794
     public function get_subscription_id( $context = 'view' ) {
1795
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1796
-	}
1797
-
1798
-	/**
1799
-	 * Retrieves the remote subscription id for an invoice.
1800
-	 *
1801
-	 * @since 1.0.19
1802
-	 * @param  string $context View or edit context.
1803
-	 * @return int
1804
-	 */
1795
+        return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1796
+    }
1797
+
1798
+    /**
1799
+     * Retrieves the remote subscription id for an invoice.
1800
+     *
1801
+     * @since 1.0.19
1802
+     * @param  string $context View or edit context.
1803
+     * @return int
1804
+     */
1805 1805
     public function get_remote_subscription_id( $context = 'view' ) {
1806 1806
         $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1807 1807
 
@@ -1813,24 +1813,24 @@  discard block
 block discarded – undo
1813 1813
         return $subscription_id;
1814 1814
     }
1815 1815
 
1816
-	/**
1817
-	 * Get the invoice's _anonymize status.
1818
-	 *
1819
-	 * @since 2.8.22
1820
-	 * @param  string $context View or edit context.
1821
-	 * @return string
1822
-	 */
1823
-	public function get_is_anonymized( $context = 'view' ) {
1824
-		return (bool) $this->get_prop( 'is_anonymized', $context );
1816
+    /**
1817
+     * Get the invoice's _anonymize status.
1818
+     *
1819
+     * @since 2.8.22
1820
+     * @param  string $context View or edit context.
1821
+     * @return string
1822
+     */
1823
+    public function get_is_anonymized( $context = 'view' ) {
1824
+        return (bool) $this->get_prop( 'is_anonymized', $context );
1825 1825
     }
1826 1826
 
1827 1827
     /**
1828
-	 * Retrieves the payment meta for an invoice.
1829
-	 *
1830
-	 * @since 1.0.19
1831
-	 * @param  string $context View or edit context.
1832
-	 * @return array
1833
-	 */
1828
+     * Retrieves the payment meta for an invoice.
1829
+     *
1830
+     * @since 1.0.19
1831
+     * @param  string $context View or edit context.
1832
+     * @return array
1833
+     */
1834 1834
     public function get_payment_meta( $context = 'view' ) {
1835 1835
 
1836 1836
         return array(
@@ -1850,31 +1850,31 @@  discard block
 block discarded – undo
1850 1850
     }
1851 1851
 
1852 1852
     /**
1853
-	 * Retrieves the cart details for an invoice.
1854
-	 *
1855
-	 * @since 1.0.19
1856
-	 * @return array
1857
-	 */
1853
+     * Retrieves the cart details for an invoice.
1854
+     *
1855
+     * @since 1.0.19
1856
+     * @return array
1857
+     */
1858 1858
     public function get_cart_details() {
1859 1859
         $items        = $this->get_items();
1860 1860
         $cart_details = array();
1861 1861
 
1862 1862
         foreach ( $items as $item ) {
1863
-			$item->invoice_id = $this->get_id();
1863
+            $item->invoice_id = $this->get_id();
1864 1864
             $cart_details[]   = $item->prepare_data_for_saving();
1865 1865
         }
1866 1866
 
1867 1867
         return $cart_details;
1868
-	}
1868
+    }
1869 1869
 
1870
-	/**
1871
-	 * Retrieves the recurring item.
1872
-	 *
1873
-	 * @return null|GetPaid_Form_Item|int
1874
-	 */
1875
-	public function get_recurring( $object = false ) {
1870
+    /**
1871
+     * Retrieves the recurring item.
1872
+     *
1873
+     * @return null|GetPaid_Form_Item|int
1874
+     */
1875
+    public function get_recurring( $object = false ) {
1876 1876
 
1877
-		// Are we returning an object?
1877
+        // Are we returning an object?
1878 1878
         if ( $object ) {
1879 1879
             return $this->get_item( $this->recurring_item );
1880 1880
         }
@@ -1882,130 +1882,130 @@  discard block
 block discarded – undo
1882 1882
         return $this->recurring_item;
1883 1883
     }
1884 1884
 
1885
-	/**
1886
-	 * Retrieves the subscription name.
1887
-	 *
1888
-	 * @since 1.0.19
1889
-	 * @return string
1890
-	 */
1891
-	public function get_subscription_name() {
1885
+    /**
1886
+     * Retrieves the subscription name.
1887
+     *
1888
+     * @since 1.0.19
1889
+     * @return string
1890
+     */
1891
+    public function get_subscription_name() {
1892 1892
 
1893
-		// Retrieve the recurring name
1893
+        // Retrieve the recurring name
1894 1894
         $item = $this->get_recurring( true );
1895 1895
 
1896
-		// Abort if it does not exist.
1896
+        // Abort if it does not exist.
1897 1897
         if ( empty( $item ) ) {
1898 1898
             return '';
1899 1899
         }
1900 1900
 
1901
-		// Return the item name.
1901
+        // Return the item name.
1902 1902
         return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1903
-	}
1904
-
1905
-	/**
1906
-	 * Retrieves the view url.
1907
-	 *
1908
-	 * @since 1.0.19
1909
-	 * @return string
1910
-	 */
1911
-	public function get_view_url() {
1903
+    }
1904
+
1905
+    /**
1906
+     * Retrieves the view url.
1907
+     *
1908
+     * @since 1.0.19
1909
+     * @return string
1910
+     */
1911
+    public function get_view_url() {
1912 1912
         $invoice_url = get_permalink( $this->get_id() );
1913
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1913
+        $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1914 1914
         return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1915
-	}
1915
+    }
1916 1916
 
1917
-	/**
1918
-	 * Retrieves the payment url.
1919
-	 *
1920
-	 * @since 1.0.19
1921
-	 * @return string
1922
-	 */
1923
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1917
+    /**
1918
+     * Retrieves the payment url.
1919
+     *
1920
+     * @since 1.0.19
1921
+     * @return string
1922
+     */
1923
+    public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1924 1924
 
1925
-		// Retrieve the checkout url.
1925
+        // Retrieve the checkout url.
1926 1926
         $pay_url = wpinv_get_checkout_uri();
1927 1927
 
1928
-		// Maybe force ssl.
1928
+        // Maybe force ssl.
1929 1929
         if ( is_ssl() ) {
1930 1930
             $pay_url = str_replace( 'http:', 'https:', $pay_url );
1931 1931
         }
1932 1932
 
1933
-		// Add the invoice key.
1934
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1933
+        // Add the invoice key.
1934
+        $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1935 1935
 
1936
-		// (Maybe?) add a secret
1936
+        // (Maybe?) add a secret
1937 1937
         if ( $secret ) {
1938 1938
             $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1939 1939
         }
1940 1940
 
1941 1941
         return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1942
-	}
1942
+    }
1943 1943
 
1944
-	/**
1945
-	 * Retrieves the receipt url.
1946
-	 *
1947
-	 * @since 1.0.19
1948
-	 * @return string
1949
-	 */
1950
-	public function get_receipt_url() {
1944
+    /**
1945
+     * Retrieves the receipt url.
1946
+     *
1947
+     * @since 1.0.19
1948
+     * @return string
1949
+     */
1950
+    public function get_receipt_url() {
1951 1951
 
1952
-		// Retrieve the checkout url.
1952
+        // Retrieve the checkout url.
1953 1953
         $receipt_url = wpinv_get_success_page_uri();
1954 1954
 
1955
-		// Maybe force ssl.
1955
+        // Maybe force ssl.
1956 1956
         if ( is_ssl() ) {
1957 1957
             $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1958 1958
         }
1959 1959
 
1960
-		// Add the invoice key.
1961
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1960
+        // Add the invoice key.
1961
+        $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1962 1962
 
1963 1963
         return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1964
-	}
1965
-
1966
-	/**
1967
-	 * Retrieves the remote transaction url.
1968
-	 *
1969
-	 * @since 1.6.0
1970
-	 * @return string
1971
-	 */
1972
-	public function get_transaction_url() {
1973
-		return apply_filters( 'getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this );
1974
-	}
1975
-
1976
-	/**
1977
-	 * Retrieves the default status.
1978
-	 *
1979
-	 * @since 1.0.19
1980
-	 * @return string
1981
-	 */
1982
-	public function get_default_status() {
1983
-
1984
-		$type   = $this->get_type();
1985
-		$status = "wpi-$type-pending";
1986
-		return str_replace( '-invoice', '', $status );
1987
-
1988
-	}
1989
-
1990
-    /**
1991
-	 * Magic method for accessing invoice properties.
1992
-	 *
1993
-	 * @since 1.0.15
1994
-	 * @access public
1995
-	 *
1996
-	 * @param string $key Discount data to retrieve
1997
-	 * @param  string $context View or edit context.
1998
-	 * @return mixed Value of the given invoice property (if set).
1999
-	 */
2000
-	public function get( $key, $context = 'view' ) {
2001
-		$method = "get_$key";
2002
-
2003
-		if ( is_callable( array( $this, $method ) ) ) {
2004
-			return $this->$method( $context );
2005
-		}
1964
+    }
1965
+
1966
+    /**
1967
+     * Retrieves the remote transaction url.
1968
+     *
1969
+     * @since 1.6.0
1970
+     * @return string
1971
+     */
1972
+    public function get_transaction_url() {
1973
+        return apply_filters( 'getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this );
1974
+    }
1975
+
1976
+    /**
1977
+     * Retrieves the default status.
1978
+     *
1979
+     * @since 1.0.19
1980
+     * @return string
1981
+     */
1982
+    public function get_default_status() {
1983
+
1984
+        $type   = $this->get_type();
1985
+        $status = "wpi-$type-pending";
1986
+        return str_replace( '-invoice', '', $status );
1987
+
1988
+    }
1989
+
1990
+    /**
1991
+     * Magic method for accessing invoice properties.
1992
+     *
1993
+     * @since 1.0.15
1994
+     * @access public
1995
+     *
1996
+     * @param string $key Discount data to retrieve
1997
+     * @param  string $context View or edit context.
1998
+     * @return mixed Value of the given invoice property (if set).
1999
+     */
2000
+    public function get( $key, $context = 'view' ) {
2001
+        $method = "get_$key";
2002
+
2003
+        if ( is_callable( array( $this, $method ) ) ) {
2004
+            return $this->$method( $context );
2005
+        }
2006 2006
 
2007 2007
         return $this->get_prop( $key, $context );
2008
-	}
2008
+    }
2009 2009
 
2010 2010
     /*
2011 2011
 	|--------------------------------------------------------------------------
@@ -2018,129 +2018,129 @@  discard block
 block discarded – undo
2018 2018
     */
2019 2019
 
2020 2020
     /**
2021
-	 * Magic method for setting invoice properties.
2022
-	 *
2023
-	 * @since 1.0.19
2024
-	 * @access public
2025
-	 *
2026
-	 * @param string $key Discount data to retrieve
2027
-	 * @param  mixed $value new value.
2028
-	 * @return mixed Value of the given invoice property (if set).
2029
-	 */
2030
-	public function set( $key, $value ) {
2021
+     * Magic method for setting invoice properties.
2022
+     *
2023
+     * @since 1.0.19
2024
+     * @access public
2025
+     *
2026
+     * @param string $key Discount data to retrieve
2027
+     * @param  mixed $value new value.
2028
+     * @return mixed Value of the given invoice property (if set).
2029
+     */
2030
+    public function set( $key, $value ) {
2031 2031
 
2032 2032
         $setter = "set_$key";
2033 2033
         if ( is_callable( array( $this, $setter ) ) ) {
2034 2034
             $this->{$setter}( $value );
2035 2035
         }
2036 2036
 
2037
-	}
2038
-
2039
-	/**
2040
-	 * Sets item status.
2041
-	 *
2042
-	 * @since 1.0.19
2043
-	 * @param string $new_status    New status.
2044
-	 * @param string $note          Optional note to add.
2045
-	 * @param bool   $manual_update Is this a manual status change?.
2046
-	 * @return array details of change.
2047
-	 */
2048
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
2049
-		$old_status = $this->get_status();
2050
-
2051
-		$statuses = $this->get_all_statuses();
2052
-
2053
-		if ( isset( $statuses['draft'] ) ) {
2054
-			unset( $statuses['draft'] );
2055
-		}
2056
-
2057
-		$this->set_prop( 'status', $new_status );
2058
-
2059
-		// If setting the status, ensure it's set to a valid status.
2060
-		if ( true === $this->object_read ) {
2061
-
2062
-			// Only allow valid new status.
2063
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
2064
-				$new_status = $this->get_default_status();
2065
-			}
2066
-
2067
-			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
2068
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
2069
-				$old_status = $this->get_default_status();
2070
-			}
2071
-
2072
-			// Paid - Renewal (i.e when duplicating a parent invoice )
2073
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
2074
-				$old_status = 'wpi-pending';
2075
-			}
2076
-
2077
-			if ( $old_status !== $new_status ) {
2078
-				$this->status_transition = array(
2079
-					'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
2080
-					'to'     => $new_status,
2081
-					'note'   => $note,
2082
-					'manual' => (bool) $manual_update,
2083
-				);
2084
-
2085
-				if ( $manual_update ) {
2086
-					do_action( 'getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status );
2087
-				}
2088
-
2089
-				$this->maybe_set_date_paid();
2090
-
2091
-			}
2092
-		}
2093
-
2094
-		return array(
2095
-			'from' => $old_status,
2096
-			'to'   => $new_status,
2097
-		);
2098
-	}
2099
-
2100
-	/**
2101
-	 * Maybe set date paid.
2102
-	 *
2103
-	 * Sets the date paid variable when transitioning to the payment complete
2104
-	 * order status.
2105
-	 *
2106
-	 * @since 1.0.19
2107
-	 */
2108
-	public function maybe_set_date_paid() {
2109
-
2110
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2111
-			$this->set_date_completed( current_time( 'mysql' ) );
2112
-		}
2113
-	}
2114
-
2115
-    /**
2116
-	 * Set parent invoice ID.
2117
-	 *
2118
-	 * @since 1.0.19
2119
-	 */
2120
-	public function set_parent_id( $value ) {
2121
-		if ( $value && ( $value === $this->get_id() ) ) {
2122
-			return;
2123
-		}
2124
-		$this->set_prop( 'parent_id', absint( $value ) );
2125
-    }
2126
-
2127
-    /**
2128
-	 * Set plugin version when the invoice was created.
2129
-	 *
2130
-	 * @since 1.0.19
2131
-	 */
2132
-	public function set_version( $value ) {
2133
-		$this->set_prop( 'version', $value );
2134
-    }
2135
-
2136
-    /**
2137
-	 * Set date when the invoice was created.
2138
-	 *
2139
-	 * @since 1.0.19
2140
-	 * @param string $value Value to set.
2037
+    }
2038
+
2039
+    /**
2040
+     * Sets item status.
2041
+     *
2042
+     * @since 1.0.19
2043
+     * @param string $new_status    New status.
2044
+     * @param string $note          Optional note to add.
2045
+     * @param bool   $manual_update Is this a manual status change?.
2046
+     * @return array details of change.
2047
+     */
2048
+    public function set_status( $new_status, $note = '', $manual_update = false ) {
2049
+        $old_status = $this->get_status();
2050
+
2051
+        $statuses = $this->get_all_statuses();
2052
+
2053
+        if ( isset( $statuses['draft'] ) ) {
2054
+            unset( $statuses['draft'] );
2055
+        }
2056
+
2057
+        $this->set_prop( 'status', $new_status );
2058
+
2059
+        // If setting the status, ensure it's set to a valid status.
2060
+        if ( true === $this->object_read ) {
2061
+
2062
+            // Only allow valid new status.
2063
+            if ( ! array_key_exists( $new_status, $statuses ) ) {
2064
+                $new_status = $this->get_default_status();
2065
+            }
2066
+
2067
+            // If the old status is set but unknown (e.g. draft) assume its pending for action usage.
2068
+            if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
2069
+                $old_status = $this->get_default_status();
2070
+            }
2071
+
2072
+            // Paid - Renewal (i.e when duplicating a parent invoice )
2073
+            if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
2074
+                $old_status = 'wpi-pending';
2075
+            }
2076
+
2077
+            if ( $old_status !== $new_status ) {
2078
+                $this->status_transition = array(
2079
+                    'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
2080
+                    'to'     => $new_status,
2081
+                    'note'   => $note,
2082
+                    'manual' => (bool) $manual_update,
2083
+                );
2084
+
2085
+                if ( $manual_update ) {
2086
+                    do_action( 'getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status );
2087
+                }
2088
+
2089
+                $this->maybe_set_date_paid();
2090
+
2091
+            }
2092
+        }
2093
+
2094
+        return array(
2095
+            'from' => $old_status,
2096
+            'to'   => $new_status,
2097
+        );
2098
+    }
2099
+
2100
+    /**
2101
+     * Maybe set date paid.
2102
+     *
2103
+     * Sets the date paid variable when transitioning to the payment complete
2104
+     * order status.
2105
+     *
2106
+     * @since 1.0.19
2107
+     */
2108
+    public function maybe_set_date_paid() {
2109
+
2110
+        if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2111
+            $this->set_date_completed( current_time( 'mysql' ) );
2112
+        }
2113
+    }
2114
+
2115
+    /**
2116
+     * Set parent invoice ID.
2117
+     *
2118
+     * @since 1.0.19
2119
+     */
2120
+    public function set_parent_id( $value ) {
2121
+        if ( $value && ( $value === $this->get_id() ) ) {
2122
+            return;
2123
+        }
2124
+        $this->set_prop( 'parent_id', absint( $value ) );
2125
+    }
2126
+
2127
+    /**
2128
+     * Set plugin version when the invoice was created.
2129
+     *
2130
+     * @since 1.0.19
2131
+     */
2132
+    public function set_version( $value ) {
2133
+        $this->set_prop( 'version', $value );
2134
+    }
2135
+
2136
+    /**
2137
+     * Set date when the invoice was created.
2138
+     *
2139
+     * @since 1.0.19
2140
+     * @param string $value Value to set.
2141 2141
      * @return bool Whether or not the date was set.
2142
-	 */
2143
-	public function set_date_created( $value ) {
2142
+     */
2143
+    public function set_date_created( $value ) {
2144 2144
         $date = strtotime( $value );
2145 2145
 
2146 2146
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2148,19 +2148,19 @@  discard block
 block discarded – undo
2148 2148
             return true;
2149 2149
         }
2150 2150
 
2151
-		$this->set_prop( 'date_created', '' );
2152
-		return false;
2151
+        $this->set_prop( 'date_created', '' );
2152
+        return false;
2153 2153
 
2154 2154
     }
2155 2155
 
2156 2156
     /**
2157
-	 * Set date invoice due date.
2158
-	 *
2159
-	 * @since 1.0.19
2160
-	 * @param string $value Value to set.
2157
+     * Set date invoice due date.
2158
+     *
2159
+     * @since 1.0.19
2160
+     * @param string $value Value to set.
2161 2161
      * @return bool Whether or not the date was set.
2162
-	 */
2163
-	public function set_due_date( $value ) {
2162
+     */
2163
+    public function set_due_date( $value ) {
2164 2164
         $date = strtotime( $value );
2165 2165
 
2166 2166
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2168,29 +2168,29 @@  discard block
 block discarded – undo
2168 2168
             return true;
2169 2169
         }
2170 2170
 
2171
-		$this->set_prop( 'due_date', '' );
2171
+        $this->set_prop( 'due_date', '' );
2172 2172
         return false;
2173 2173
 
2174 2174
     }
2175 2175
 
2176 2176
     /**
2177
-	 * Alias of self::set_due_date().
2178
-	 *
2179
-	 * @since 1.0.19
2180
-	 * @param  string $value New name.
2181
-	 */
2182
-	public function set_date_due( $value ) {
2183
-		$this->set_due_date( $value );
2177
+     * Alias of self::set_due_date().
2178
+     *
2179
+     * @since 1.0.19
2180
+     * @param  string $value New name.
2181
+     */
2182
+    public function set_date_due( $value ) {
2183
+        $this->set_due_date( $value );
2184 2184
     }
2185 2185
 
2186 2186
     /**
2187
-	 * Set date invoice was completed.
2188
-	 *
2189
-	 * @since 1.0.19
2190
-	 * @param string $value Value to set.
2187
+     * Set date invoice was completed.
2188
+     *
2189
+     * @since 1.0.19
2190
+     * @param string $value Value to set.
2191 2191
      * @return bool Whether or not the date was set.
2192
-	 */
2193
-	public function set_completed_date( $value ) {
2192
+     */
2193
+    public function set_completed_date( $value ) {
2194 2194
         $date = strtotime( $value );
2195 2195
 
2196 2196
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2198,29 +2198,29 @@  discard block
 block discarded – undo
2198 2198
             return true;
2199 2199
         }
2200 2200
 
2201
-		$this->set_prop( 'completed_date', '' );
2201
+        $this->set_prop( 'completed_date', '' );
2202 2202
         return false;
2203 2203
 
2204 2204
     }
2205 2205
 
2206 2206
     /**
2207
-	 * Alias of self::set_completed_date().
2208
-	 *
2209
-	 * @since 1.0.19
2210
-	 * @param  string $value New name.
2211
-	 */
2212
-	public function set_date_completed( $value ) {
2213
-		$this->set_completed_date( $value );
2207
+     * Alias of self::set_completed_date().
2208
+     *
2209
+     * @since 1.0.19
2210
+     * @param  string $value New name.
2211
+     */
2212
+    public function set_date_completed( $value ) {
2213
+        $this->set_completed_date( $value );
2214 2214
     }
2215 2215
 
2216 2216
     /**
2217
-	 * Set date when the invoice was last modified.
2218
-	 *
2219
-	 * @since 1.0.19
2220
-	 * @param string $value Value to set.
2217
+     * Set date when the invoice was last modified.
2218
+     *
2219
+     * @since 1.0.19
2220
+     * @param string $value Value to set.
2221 2221
      * @return bool Whether or not the date was set.
2222
-	 */
2223
-	public function set_date_modified( $value ) {
2222
+     */
2223
+    public function set_date_modified( $value ) {
2224 2224
         $date = strtotime( $value );
2225 2225
 
2226 2226
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2228,813 +2228,813 @@  discard block
 block discarded – undo
2228 2228
             return true;
2229 2229
         }
2230 2230
 
2231
-		$this->set_prop( 'date_modified', '' );
2231
+        $this->set_prop( 'date_modified', '' );
2232 2232
         return false;
2233 2233
 
2234 2234
     }
2235 2235
 
2236 2236
     /**
2237
-	 * Set the invoice number.
2238
-	 *
2239
-	 * @since 1.0.19
2240
-	 * @param  string $value New number.
2241
-	 */
2242
-	public function set_number( $value ) {
2237
+     * Set the invoice number.
2238
+     *
2239
+     * @since 1.0.19
2240
+     * @param  string $value New number.
2241
+     */
2242
+    public function set_number( $value ) {
2243 2243
         $number = sanitize_text_field( $value );
2244
-		$this->set_prop( 'number', $number );
2244
+        $this->set_prop( 'number', $number );
2245 2245
     }
2246 2246
 
2247 2247
     /**
2248
-	 * Set the invoice type.
2249
-	 *
2250
-	 * @since 1.0.19
2251
-	 * @param  string $value Type.
2252
-	 */
2253
-	public function set_type( $value ) {
2248
+     * Set the invoice type.
2249
+     *
2250
+     * @since 1.0.19
2251
+     * @param  string $value Type.
2252
+     */
2253
+    public function set_type( $value ) {
2254 2254
         $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2255
-		$this->set_prop( 'type', $type );
2256
-	}
2255
+        $this->set_prop( 'type', $type );
2256
+    }
2257 2257
 
2258 2258
     /**
2259
-	 * Set the invoice post type.
2260
-	 *
2261
-	 * @since 1.0.19
2262
-	 * @param  string $value Post type.
2263
-	 */
2264
-	public function set_post_type( $value ) {
2259
+     * Set the invoice post type.
2260
+     *
2261
+     * @since 1.0.19
2262
+     * @param  string $value Post type.
2263
+     */
2264
+    public function set_post_type( $value ) {
2265 2265
         if ( getpaid_is_invoice_post_type( $value ) ) {
2266
-			$this->set_type( $value );
2266
+            $this->set_type( $value );
2267 2267
             $this->set_prop( 'post_type', $value );
2268 2268
         }
2269 2269
     }
2270 2270
 
2271 2271
     /**
2272
-	 * Set the invoice key.
2273
-	 *
2274
-	 * @since 1.0.19
2275
-	 * @param  string $value New key.
2276
-	 */
2277
-	public function set_key( $value ) {
2272
+     * Set the invoice key.
2273
+     *
2274
+     * @since 1.0.19
2275
+     * @param  string $value New key.
2276
+     */
2277
+    public function set_key( $value ) {
2278 2278
         $key = sanitize_text_field( $value );
2279
-		$this->set_prop( 'key', $key );
2279
+        $this->set_prop( 'key', $key );
2280 2280
     }
2281 2281
 
2282 2282
     /**
2283
-	 * Set the invoice mode.
2284
-	 *
2285
-	 * @since 1.0.19
2286
-	 * @param  string $value mode.
2287
-	 */
2288
-	public function set_mode( $value ) {
2283
+     * Set the invoice mode.
2284
+     *
2285
+     * @since 1.0.19
2286
+     * @param  string $value mode.
2287
+     */
2288
+    public function set_mode( $value ) {
2289 2289
         if ( in_array( $value, array( 'live', 'test' ) ) ) {
2290 2290
             $this->set_prop( 'mode', $value );
2291 2291
         }
2292 2292
     }
2293 2293
 
2294 2294
     /**
2295
-	 * Set the invoice path.
2296
-	 *
2297
-	 * @since 1.0.19
2298
-	 * @param  string $value path.
2299
-	 */
2300
-	public function set_path( $value ) {
2295
+     * Set the invoice path.
2296
+     *
2297
+     * @since 1.0.19
2298
+     * @param  string $value path.
2299
+     */
2300
+    public function set_path( $value ) {
2301 2301
         $this->set_prop( 'path', $value );
2302 2302
     }
2303 2303
 
2304 2304
     /**
2305
-	 * Set the invoice name.
2306
-	 *
2307
-	 * @since 1.0.19
2308
-	 * @param  string $value New name.
2309
-	 */
2310
-	public function set_name( $value ) {
2305
+     * Set the invoice name.
2306
+     *
2307
+     * @since 1.0.19
2308
+     * @param  string $value New name.
2309
+     */
2310
+    public function set_name( $value ) {
2311 2311
         $name = sanitize_text_field( $value );
2312
-		$this->set_prop( 'name', $name );
2312
+        $this->set_prop( 'name', $name );
2313 2313
     }
2314 2314
 
2315 2315
     /**
2316
-	 * Alias of self::set_name().
2317
-	 *
2318
-	 * @since 1.0.19
2319
-	 * @param  string $value New name.
2320
-	 */
2321
-	public function set_title( $value ) {
2322
-		$this->set_name( $value );
2316
+     * Alias of self::set_name().
2317
+     *
2318
+     * @since 1.0.19
2319
+     * @param  string $value New name.
2320
+     */
2321
+    public function set_title( $value ) {
2322
+        $this->set_name( $value );
2323 2323
     }
2324 2324
 
2325 2325
     /**
2326
-	 * Set the invoice description.
2327
-	 *
2328
-	 * @since 1.0.19
2329
-	 * @param  string $value New description.
2330
-	 */
2331
-	public function set_description( $value ) {
2326
+     * Set the invoice description.
2327
+     *
2328
+     * @since 1.0.19
2329
+     * @param  string $value New description.
2330
+     */
2331
+    public function set_description( $value ) {
2332 2332
         $description = wp_kses_post( $value );
2333
-		$this->set_prop( 'description', $description );
2333
+        $this->set_prop( 'description', $description );
2334
+    }
2335
+
2336
+    /**
2337
+     * Alias of self::set_description().
2338
+     *
2339
+     * @since 1.0.19
2340
+     * @param  string $value New description.
2341
+     */
2342
+    public function set_excerpt( $value ) {
2343
+        $this->set_description( $value );
2344
+    }
2345
+
2346
+    /**
2347
+     * Alias of self::set_description().
2348
+     *
2349
+     * @since 1.0.19
2350
+     * @param  string $value New description.
2351
+     */
2352
+    public function set_summary( $value ) {
2353
+        $this->set_description( $value );
2354
+    }
2355
+
2356
+    /**
2357
+     * Set the receiver of the invoice.
2358
+     *
2359
+     * @since 1.0.19
2360
+     * @param  int $value New author.
2361
+     */
2362
+    public function set_author( $value ) {
2363
+        $user = get_user_by( 'id', (int) $value );
2364
+
2365
+        if ( $user && $user->ID ) {
2366
+            $this->set_prop( 'author', $user->ID );
2367
+            $this->set_prop( 'email', $user->user_email );
2368
+        }
2369
+
2370
+    }
2371
+
2372
+    /**
2373
+     * Alias of self::set_author().
2374
+     *
2375
+     * @since 1.0.19
2376
+     * @param  int $value New user id.
2377
+     */
2378
+    public function set_user_id( $value ) {
2379
+        $this->set_author( $value );
2380
+    }
2381
+
2382
+    /**
2383
+     * Sets the customer ID.
2384
+     *
2385
+     * @since 1.0.19
2386
+     * @param  int $value New user id.
2387
+     */
2388
+    public function set_customer_id( $value ) {
2389
+        $this->set_prop( 'customer_id', (int) $value );
2390
+    }
2391
+
2392
+    /**
2393
+     * Set the customer's ip.
2394
+     *
2395
+     * @since 1.0.19
2396
+     * @param  string $value ip address.
2397
+     */
2398
+    public function set_ip( $value ) {
2399
+        $this->set_prop( 'ip', $value );
2400
+    }
2401
+
2402
+    /**
2403
+     * Alias of self::set_ip().
2404
+     *
2405
+     * @since 1.0.19
2406
+     * @param  string $value ip address.
2407
+     */
2408
+    public function set_user_ip( $value ) {
2409
+        $this->set_ip( $value );
2410
+    }
2411
+
2412
+    /**
2413
+     * Set the customer's first name.
2414
+     *
2415
+     * @since 1.0.19
2416
+     * @param  string $value first name.
2417
+     */
2418
+    public function set_first_name( $value ) {
2419
+        $this->set_prop( 'first_name', $value );
2420
+    }
2421
+
2422
+    /**
2423
+     * Alias of self::set_first_name().
2424
+     *
2425
+     * @since 1.0.19
2426
+     * @param  string $value first name.
2427
+     */
2428
+    public function set_user_first_name( $value ) {
2429
+        $this->set_first_name( $value );
2430
+    }
2431
+
2432
+    /**
2433
+     * Alias of self::set_first_name().
2434
+     *
2435
+     * @since 1.0.19
2436
+     * @param  string $value first name.
2437
+     */
2438
+    public function set_customer_first_name( $value ) {
2439
+        $this->set_first_name( $value );
2440
+    }
2441
+
2442
+    /**
2443
+     * Set the customer's last name.
2444
+     *
2445
+     * @since 1.0.19
2446
+     * @param  string $value last name.
2447
+     */
2448
+    public function set_last_name( $value ) {
2449
+        $this->set_prop( 'last_name', $value );
2450
+    }
2451
+
2452
+    /**
2453
+     * Alias of self::set_last_name().
2454
+     *
2455
+     * @since 1.0.19
2456
+     * @param  string $value last name.
2457
+     */
2458
+    public function set_user_last_name( $value ) {
2459
+        $this->set_last_name( $value );
2460
+    }
2461
+
2462
+    /**
2463
+     * Alias of self::set_last_name().
2464
+     *
2465
+     * @since 1.0.19
2466
+     * @param  string $value last name.
2467
+     */
2468
+    public function set_customer_last_name( $value ) {
2469
+        $this->set_last_name( $value );
2334 2470
     }
2335 2471
 
2336 2472
     /**
2337
-	 * Alias of self::set_description().
2338
-	 *
2339
-	 * @since 1.0.19
2340
-	 * @param  string $value New description.
2341
-	 */
2342
-	public function set_excerpt( $value ) {
2343
-		$this->set_description( $value );
2473
+     * Set the customer's phone number.
2474
+     *
2475
+     * @since 1.0.19
2476
+     * @param  string $value phone.
2477
+     */
2478
+    public function set_phone( $value ) {
2479
+        $this->set_prop( 'phone', $value );
2480
+    }
2481
+
2482
+    /**
2483
+     * Alias of self::set_phone().
2484
+     *
2485
+     * @since 1.0.19
2486
+     * @param  string $value phone.
2487
+     */
2488
+    public function set_user_phone( $value ) {
2489
+        $this->set_phone( $value );
2344 2490
     }
2345 2491
 
2346 2492
     /**
2347
-	 * Alias of self::set_description().
2348
-	 *
2349
-	 * @since 1.0.19
2350
-	 * @param  string $value New description.
2351
-	 */
2352
-	public function set_summary( $value ) {
2353
-		$this->set_description( $value );
2493
+     * Alias of self::set_phone().
2494
+     *
2495
+     * @since 1.0.19
2496
+     * @param  string $value phone.
2497
+     */
2498
+    public function set_customer_phone( $value ) {
2499
+        $this->set_phone( $value );
2354 2500
     }
2355 2501
 
2356 2502
     /**
2357
-	 * Set the receiver of the invoice.
2358
-	 *
2359
-	 * @since 1.0.19
2360
-	 * @param  int $value New author.
2361
-	 */
2362
-	public function set_author( $value ) {
2363
-		$user = get_user_by( 'id', (int) $value );
2503
+     * Alias of self::set_phone().
2504
+     *
2505
+     * @since 1.0.19
2506
+     * @param  string $value phone.
2507
+     */
2508
+    public function set_phone_number( $value ) {
2509
+        $this->set_phone( $value );
2510
+    }
2364 2511
 
2365
-		if ( $user && $user->ID ) {
2366
-			$this->set_prop( 'author', $user->ID );
2367
-			$this->set_prop( 'email', $user->user_email );
2368
-		}
2512
+    /**
2513
+     * Set the customer's email address.
2514
+     *
2515
+     * @since 1.0.19
2516
+     * @param  string $value email address.
2517
+     */
2518
+    public function set_email( $value ) {
2519
+        $this->set_prop( 'email', $value );
2520
+    }
2369 2521
 
2522
+    /**
2523
+     * Alias of self::set_email().
2524
+     *
2525
+     * @since 1.0.19
2526
+     * @param  string $value email address.
2527
+     */
2528
+    public function set_user_email( $value ) {
2529
+        $this->set_email( $value );
2370 2530
     }
2371 2531
 
2372 2532
     /**
2373
-	 * Alias of self::set_author().
2374
-	 *
2375
-	 * @since 1.0.19
2376
-	 * @param  int $value New user id.
2377
-	 */
2378
-	public function set_user_id( $value ) {
2379
-		$this->set_author( $value );
2533
+     * Alias of self::set_email().
2534
+     *
2535
+     * @since 1.0.19
2536
+     * @param  string $value email address.
2537
+     */
2538
+    public function set_email_address( $value ) {
2539
+        $this->set_email( $value );
2380 2540
     }
2381 2541
 
2382 2542
     /**
2383
-	 * Sets the customer ID.
2384
-	 *
2385
-	 * @since 1.0.19
2386
-	 * @param  int $value New user id.
2387
-	 */
2388
-	public function set_customer_id( $value ) {
2389
-		$this->set_prop( 'customer_id', (int) $value );
2543
+     * Alias of self::set_email().
2544
+     *
2545
+     * @since 1.0.19
2546
+     * @param  string $value email address.
2547
+     */
2548
+    public function set_customer_email( $value ) {
2549
+        $this->set_email( $value );
2390 2550
     }
2391 2551
 
2392 2552
     /**
2393
-	 * Set the customer's ip.
2394
-	 *
2395
-	 * @since 1.0.19
2396
-	 * @param  string $value ip address.
2397
-	 */
2398
-	public function set_ip( $value ) {
2399
-		$this->set_prop( 'ip', $value );
2553
+     * Set the customer's country.
2554
+     *
2555
+     * @since 1.0.19
2556
+     * @param  string $value country.
2557
+     */
2558
+    public function set_country( $value ) {
2559
+        $this->set_prop( 'country', $value );
2400 2560
     }
2401 2561
 
2402 2562
     /**
2403
-	 * Alias of self::set_ip().
2404
-	 *
2405
-	 * @since 1.0.19
2406
-	 * @param  string $value ip address.
2407
-	 */
2408
-	public function set_user_ip( $value ) {
2409
-		$this->set_ip( $value );
2563
+     * Alias of self::set_country().
2564
+     *
2565
+     * @since 1.0.19
2566
+     * @param  string $value country.
2567
+     */
2568
+    public function set_user_country( $value ) {
2569
+        $this->set_country( $value );
2410 2570
     }
2411 2571
 
2412 2572
     /**
2413
-	 * Set the customer's first name.
2414
-	 *
2415
-	 * @since 1.0.19
2416
-	 * @param  string $value first name.
2417
-	 */
2418
-	public function set_first_name( $value ) {
2419
-		$this->set_prop( 'first_name', $value );
2573
+     * Alias of self::set_country().
2574
+     *
2575
+     * @since 1.0.19
2576
+     * @param  string $value country.
2577
+     */
2578
+    public function set_customer_country( $value ) {
2579
+        $this->set_country( $value );
2420 2580
     }
2421 2581
 
2422 2582
     /**
2423
-	 * Alias of self::set_first_name().
2424
-	 *
2425
-	 * @since 1.0.19
2426
-	 * @param  string $value first name.
2427
-	 */
2428
-	public function set_user_first_name( $value ) {
2429
-		$this->set_first_name( $value );
2583
+     * Set the customer's state.
2584
+     *
2585
+     * @since 1.0.19
2586
+     * @param  string $value state.
2587
+     */
2588
+    public function set_state( $value ) {
2589
+        $this->set_prop( 'state', $value );
2430 2590
     }
2431 2591
 
2432 2592
     /**
2433
-	 * Alias of self::set_first_name().
2434
-	 *
2435
-	 * @since 1.0.19
2436
-	 * @param  string $value first name.
2437
-	 */
2438
-	public function set_customer_first_name( $value ) {
2439
-		$this->set_first_name( $value );
2593
+     * Alias of self::set_state().
2594
+     *
2595
+     * @since 1.0.19
2596
+     * @param  string $value state.
2597
+     */
2598
+    public function set_user_state( $value ) {
2599
+        $this->set_state( $value );
2440 2600
     }
2441 2601
 
2442 2602
     /**
2443
-	 * Set the customer's last name.
2444
-	 *
2445
-	 * @since 1.0.19
2446
-	 * @param  string $value last name.
2447
-	 */
2448
-	public function set_last_name( $value ) {
2449
-		$this->set_prop( 'last_name', $value );
2603
+     * Alias of self::set_state().
2604
+     *
2605
+     * @since 1.0.19
2606
+     * @param  string $value state.
2607
+     */
2608
+    public function set_customer_state( $value ) {
2609
+        $this->set_state( $value );
2450 2610
     }
2451 2611
 
2452 2612
     /**
2453
-	 * Alias of self::set_last_name().
2454
-	 *
2455
-	 * @since 1.0.19
2456
-	 * @param  string $value last name.
2457
-	 */
2458
-	public function set_user_last_name( $value ) {
2459
-		$this->set_last_name( $value );
2613
+     * Set the customer's city.
2614
+     *
2615
+     * @since 1.0.19
2616
+     * @param  string $value city.
2617
+     */
2618
+    public function set_city( $value ) {
2619
+        $this->set_prop( 'city', $value );
2460 2620
     }
2461 2621
 
2462 2622
     /**
2463
-	 * Alias of self::set_last_name().
2464
-	 *
2465
-	 * @since 1.0.19
2466
-	 * @param  string $value last name.
2467
-	 */
2468
-	public function set_customer_last_name( $value ) {
2469
-		$this->set_last_name( $value );
2623
+     * Alias of self::set_city().
2624
+     *
2625
+     * @since 1.0.19
2626
+     * @param  string $value city.
2627
+     */
2628
+    public function set_user_city( $value ) {
2629
+        $this->set_city( $value );
2470 2630
     }
2471 2631
 
2472 2632
     /**
2473
-	 * Set the customer's phone number.
2474
-	 *
2475
-	 * @since 1.0.19
2476
-	 * @param  string $value phone.
2477
-	 */
2478
-	public function set_phone( $value ) {
2479
-		$this->set_prop( 'phone', $value );
2633
+     * Alias of self::set_city().
2634
+     *
2635
+     * @since 1.0.19
2636
+     * @param  string $value city.
2637
+     */
2638
+    public function set_customer_city( $value ) {
2639
+        $this->set_city( $value );
2480 2640
     }
2481 2641
 
2482 2642
     /**
2483
-	 * Alias of self::set_phone().
2484
-	 *
2485
-	 * @since 1.0.19
2486
-	 * @param  string $value phone.
2487
-	 */
2488
-	public function set_user_phone( $value ) {
2489
-		$this->set_phone( $value );
2643
+     * Set the customer's zip code.
2644
+     *
2645
+     * @since 1.0.19
2646
+     * @param  string $value zip.
2647
+     */
2648
+    public function set_zip( $value ) {
2649
+        $this->set_prop( 'zip', $value );
2490 2650
     }
2491 2651
 
2492 2652
     /**
2493
-	 * Alias of self::set_phone().
2494
-	 *
2495
-	 * @since 1.0.19
2496
-	 * @param  string $value phone.
2497
-	 */
2498
-	public function set_customer_phone( $value ) {
2499
-		$this->set_phone( $value );
2653
+     * Alias of self::set_zip().
2654
+     *
2655
+     * @since 1.0.19
2656
+     * @param  string $value zip.
2657
+     */
2658
+    public function set_user_zip( $value ) {
2659
+        $this->set_zip( $value );
2500 2660
     }
2501 2661
 
2502 2662
     /**
2503
-	 * Alias of self::set_phone().
2504
-	 *
2505
-	 * @since 1.0.19
2506
-	 * @param  string $value phone.
2507
-	 */
2508
-	public function set_phone_number( $value ) {
2509
-		$this->set_phone( $value );
2663
+     * Alias of self::set_zip().
2664
+     *
2665
+     * @since 1.0.19
2666
+     * @param  string $value zip.
2667
+     */
2668
+    public function set_customer_zip( $value ) {
2669
+        $this->set_zip( $value );
2510 2670
     }
2511 2671
 
2512 2672
     /**
2513
-	 * Set the customer's email address.
2514
-	 *
2515
-	 * @since 1.0.19
2516
-	 * @param  string $value email address.
2517
-	 */
2518
-	public function set_email( $value ) {
2519
-		$this->set_prop( 'email', $value );
2673
+     * Set the customer's company.
2674
+     *
2675
+     * @since 1.0.19
2676
+     * @param  string $value company.
2677
+     */
2678
+    public function set_company( $value ) {
2679
+        $this->set_prop( 'company', $value );
2520 2680
     }
2521 2681
 
2522 2682
     /**
2523
-	 * Alias of self::set_email().
2524
-	 *
2525
-	 * @since 1.0.19
2526
-	 * @param  string $value email address.
2527
-	 */
2528
-	public function set_user_email( $value ) {
2529
-		$this->set_email( $value );
2683
+     * Alias of self::set_company().
2684
+     *
2685
+     * @since 1.0.19
2686
+     * @param  string $value company.
2687
+     */
2688
+    public function set_user_company( $value ) {
2689
+        $this->set_company( $value );
2530 2690
     }
2531 2691
 
2532 2692
     /**
2533
-	 * Alias of self::set_email().
2534
-	 *
2535
-	 * @since 1.0.19
2536
-	 * @param  string $value email address.
2537
-	 */
2538
-	public function set_email_address( $value ) {
2539
-		$this->set_email( $value );
2693
+     * Alias of self::set_company().
2694
+     *
2695
+     * @since 1.0.19
2696
+     * @param  string $value company.
2697
+     */
2698
+    public function set_customer_company( $value ) {
2699
+        $this->set_company( $value );
2540 2700
     }
2541 2701
 
2542 2702
     /**
2543
-	 * Alias of self::set_email().
2544
-	 *
2545
-	 * @since 1.0.19
2546
-	 * @param  string $value email address.
2547
-	 */
2548
-	public function set_customer_email( $value ) {
2549
-		$this->set_email( $value );
2703
+     * Set the customer's company id.
2704
+     *
2705
+     * @since 1.0.19
2706
+     * @param  string $value company id.
2707
+     */
2708
+    public function set_company_id( $value ) {
2709
+        $this->set_prop( 'company_id', $value );
2550 2710
     }
2551 2711
 
2552 2712
     /**
2553
-	 * Set the customer's country.
2554
-	 *
2555
-	 * @since 1.0.19
2556
-	 * @param  string $value country.
2557
-	 */
2558
-	public function set_country( $value ) {
2559
-		$this->set_prop( 'country', $value );
2713
+     * Set the customer's var number.
2714
+     *
2715
+     * @since 1.0.19
2716
+     * @param  string $value var number.
2717
+     */
2718
+    public function set_vat_number( $value ) {
2719
+        $this->set_prop( 'vat_number', $value );
2560 2720
     }
2561 2721
 
2562 2722
     /**
2563
-	 * Alias of self::set_country().
2564
-	 *
2565
-	 * @since 1.0.19
2566
-	 * @param  string $value country.
2567
-	 */
2568
-	public function set_user_country( $value ) {
2569
-		$this->set_country( $value );
2723
+     * Alias of self::set_vat_number().
2724
+     *
2725
+     * @since 1.0.19
2726
+     * @param  string $value var number.
2727
+     */
2728
+    public function set_user_vat_number( $value ) {
2729
+        $this->set_vat_number( $value );
2570 2730
     }
2571 2731
 
2572 2732
     /**
2573
-	 * Alias of self::set_country().
2574
-	 *
2575
-	 * @since 1.0.19
2576
-	 * @param  string $value country.
2577
-	 */
2578
-	public function set_customer_country( $value ) {
2579
-		$this->set_country( $value );
2733
+     * Alias of self::set_vat_number().
2734
+     *
2735
+     * @since 1.0.19
2736
+     * @param  string $value var number.
2737
+     */
2738
+    public function set_customer_vat_number( $value ) {
2739
+        $this->set_vat_number( $value );
2580 2740
     }
2581 2741
 
2582 2742
     /**
2583
-	 * Set the customer's state.
2584
-	 *
2585
-	 * @since 1.0.19
2586
-	 * @param  string $value state.
2587
-	 */
2588
-	public function set_state( $value ) {
2589
-		$this->set_prop( 'state', $value );
2743
+     * Set the customer's vat rate.
2744
+     *
2745
+     * @since 1.0.19
2746
+     * @param  string $value var rate.
2747
+     */
2748
+    public function set_vat_rate( $value ) {
2749
+        $this->set_prop( 'vat_rate', $value );
2590 2750
     }
2591 2751
 
2592 2752
     /**
2593
-	 * Alias of self::set_state().
2594
-	 *
2595
-	 * @since 1.0.19
2596
-	 * @param  string $value state.
2597
-	 */
2598
-	public function set_user_state( $value ) {
2599
-		$this->set_state( $value );
2753
+     * Alias of self::set_vat_rate().
2754
+     *
2755
+     * @since 1.0.19
2756
+     * @param  string $value var number.
2757
+     */
2758
+    public function set_user_vat_rate( $value ) {
2759
+        $this->set_vat_rate( $value );
2600 2760
     }
2601 2761
 
2602 2762
     /**
2603
-	 * Alias of self::set_state().
2604
-	 *
2605
-	 * @since 1.0.19
2606
-	 * @param  string $value state.
2607
-	 */
2608
-	public function set_customer_state( $value ) {
2609
-		$this->set_state( $value );
2763
+     * Alias of self::set_vat_rate().
2764
+     *
2765
+     * @since 1.0.19
2766
+     * @param  string $value var number.
2767
+     */
2768
+    public function set_customer_vat_rate( $value ) {
2769
+        $this->set_vat_rate( $value );
2610 2770
     }
2611 2771
 
2612 2772
     /**
2613
-	 * Set the customer's city.
2614
-	 *
2615
-	 * @since 1.0.19
2616
-	 * @param  string $value city.
2617
-	 */
2618
-	public function set_city( $value ) {
2619
-		$this->set_prop( 'city', $value );
2773
+     * Set the customer's address.
2774
+     *
2775
+     * @since 1.0.19
2776
+     * @param  string $value address.
2777
+     */
2778
+    public function set_address( $value ) {
2779
+        $this->set_prop( 'address', $value );
2620 2780
     }
2621 2781
 
2622 2782
     /**
2623
-	 * Alias of self::set_city().
2624
-	 *
2625
-	 * @since 1.0.19
2626
-	 * @param  string $value city.
2627
-	 */
2628
-	public function set_user_city( $value ) {
2629
-		$this->set_city( $value );
2783
+     * Alias of self::set_address().
2784
+     *
2785
+     * @since 1.0.19
2786
+     * @param  string $value address.
2787
+     */
2788
+    public function set_user_address( $value ) {
2789
+        $this->set_address( $value );
2630 2790
     }
2631 2791
 
2632 2792
     /**
2633
-	 * Alias of self::set_city().
2634
-	 *
2635
-	 * @since 1.0.19
2636
-	 * @param  string $value city.
2637
-	 */
2638
-	public function set_customer_city( $value ) {
2639
-		$this->set_city( $value );
2793
+     * Alias of self::set_address().
2794
+     *
2795
+     * @since 1.0.19
2796
+     * @param  string $value address.
2797
+     */
2798
+    public function set_customer_address( $value ) {
2799
+        $this->set_address( $value );
2640 2800
     }
2641 2801
 
2642 2802
     /**
2643
-	 * Set the customer's zip code.
2644
-	 *
2645
-	 * @since 1.0.19
2646
-	 * @param  string $value zip.
2647
-	 */
2648
-	public function set_zip( $value ) {
2649
-		$this->set_prop( 'zip', $value );
2803
+     * Set whether the customer has viewed the invoice or not.
2804
+     *
2805
+     * @since 1.0.19
2806
+     * @param  int|bool $value confirmed.
2807
+     */
2808
+    public function set_is_viewed( $value ) {
2809
+        $this->set_prop( 'is_viewed', $value );
2650 2810
     }
2651 2811
 
2652 2812
     /**
2653
-	 * Alias of self::set_zip().
2654
-	 *
2655
-	 * @since 1.0.19
2656
-	 * @param  string $value zip.
2657
-	 */
2658
-	public function set_user_zip( $value ) {
2659
-		$this->set_zip( $value );
2813
+     * Set extra email recipients.
2814
+     *
2815
+     * @since 1.0.19
2816
+     * @param  string $value email recipients.
2817
+     */
2818
+    public function set_email_cc( $value ) {
2819
+        $this->set_prop( 'email_cc', $value );
2660 2820
     }
2661 2821
 
2662 2822
     /**
2663
-	 * Alias of self::set_zip().
2664
-	 *
2665
-	 * @since 1.0.19
2666
-	 * @param  string $value zip.
2667
-	 */
2668
-	public function set_customer_zip( $value ) {
2669
-		$this->set_zip( $value );
2823
+     * Set the invoice template.
2824
+     *
2825
+     * @since 1.0.19
2826
+     * @param  string $value template.
2827
+     */
2828
+    public function set_template( $value ) {
2829
+        if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2830
+            $this->set_prop( 'template', $value );
2831
+        }
2670 2832
     }
2671 2833
 
2672 2834
     /**
2673
-	 * Set the customer's company.
2674
-	 *
2675
-	 * @since 1.0.19
2676
-	 * @param  string $value company.
2677
-	 */
2678
-	public function set_company( $value ) {
2679
-		$this->set_prop( 'company', $value );
2835
+     * Set the invoice source.
2836
+     *
2837
+     * @since 1.0.19
2838
+     * @param  string $value source.
2839
+     * @deprecated
2840
+     */
2841
+    public function created_via( $value ) {
2842
+        $this->set_created_via( sanitize_text_field( $value ) );
2680 2843
     }
2681 2844
 
2682 2845
     /**
2683
-	 * Alias of self::set_company().
2684
-	 *
2685
-	 * @since 1.0.19
2686
-	 * @param  string $value company.
2687
-	 */
2688
-	public function set_user_company( $value ) {
2689
-		$this->set_company( $value );
2846
+     * Set the invoice source.
2847
+     *
2848
+     * @since 1.0.19
2849
+     * @param  string $value source.
2850
+     */
2851
+    public function set_created_via( $value ) {
2852
+        $this->set_prop( 'created_via', sanitize_text_field( $value ) );
2690 2853
     }
2691 2854
 
2692 2855
     /**
2693
-	 * Alias of self::set_company().
2694
-	 *
2695
-	 * @since 1.0.19
2696
-	 * @param  string $value company.
2697
-	 */
2698
-	public function set_customer_company( $value ) {
2699
-		$this->set_company( $value );
2700
-    }
2701
-
2702
-	/**
2703
-	 * Set the customer's company id.
2704
-	 *
2705
-	 * @since 1.0.19
2706
-	 * @param  string $value company id.
2707
-	 */
2708
-	public function set_company_id( $value ) {
2709
-		$this->set_prop( 'company_id', $value );
2856
+     * Set the customer's address confirmed status.
2857
+     *
2858
+     * @since 1.0.19
2859
+     * @param  int|bool $value confirmed.
2860
+     */
2861
+    public function set_address_confirmed( $value ) {
2862
+        $this->set_prop( 'address_confirmed', $value );
2710 2863
     }
2711 2864
 
2712 2865
     /**
2713
-	 * Set the customer's var number.
2714
-	 *
2715
-	 * @since 1.0.19
2716
-	 * @param  string $value var number.
2717
-	 */
2718
-	public function set_vat_number( $value ) {
2719
-		$this->set_prop( 'vat_number', $value );
2866
+     * Alias of self::set_address_confirmed().
2867
+     *
2868
+     * @since 1.0.19
2869
+     * @param  int|bool $value confirmed.
2870
+     */
2871
+    public function set_user_address_confirmed( $value ) {
2872
+        $this->set_address_confirmed( $value );
2720 2873
     }
2721 2874
 
2722 2875
     /**
2723
-	 * Alias of self::set_vat_number().
2724
-	 *
2725
-	 * @since 1.0.19
2726
-	 * @param  string $value var number.
2727
-	 */
2728
-	public function set_user_vat_number( $value ) {
2729
-		$this->set_vat_number( $value );
2876
+     * Alias of self::set_address_confirmed().
2877
+     *
2878
+     * @since 1.0.19
2879
+     * @param  int|bool $value confirmed.
2880
+     */
2881
+    public function set_customer_address_confirmed( $value ) {
2882
+        $this->set_address_confirmed( $value );
2730 2883
     }
2731 2884
 
2732 2885
     /**
2733
-	 * Alias of self::set_vat_number().
2734
-	 *
2735
-	 * @since 1.0.19
2736
-	 * @param  string $value var number.
2737
-	 */
2738
-	public function set_customer_vat_number( $value ) {
2739
-		$this->set_vat_number( $value );
2886
+     * Set the shipping fee
2887
+     *
2888
+     * @since 1.0.19
2889
+     * @param  float $value shipping amount.
2890
+     */
2891
+    public function set_shipping( $value ) {
2892
+
2893
+        if ( ! is_numeric( $value ) ) {
2894
+            return $this->set_prop( 'shipping', null );
2895
+        }
2896
+
2897
+        $this->set_prop( 'shipping', max( 0, floatval( $value ) ) );
2740 2898
     }
2741 2899
 
2742 2900
     /**
2743
-	 * Set the customer's vat rate.
2744
-	 *
2745
-	 * @since 1.0.19
2746
-	 * @param  string $value var rate.
2747
-	 */
2748
-	public function set_vat_rate( $value ) {
2749
-		$this->set_prop( 'vat_rate', $value );
2901
+     * Set the invoice sub total.
2902
+     *
2903
+     * @since 1.0.19
2904
+     * @param  float $value sub total.
2905
+     */
2906
+    public function set_subtotal( $value ) {
2907
+        $this->set_prop( 'subtotal', max( 0, $value ) );
2750 2908
     }
2751 2909
 
2752
-    /**
2753
-	 * Alias of self::set_vat_rate().
2754
-	 *
2755
-	 * @since 1.0.19
2756
-	 * @param  string $value var number.
2757
-	 */
2758
-	public function set_user_vat_rate( $value ) {
2759
-		$this->set_vat_rate( $value );
2760
-    }
2761
-
2762
-    /**
2763
-	 * Alias of self::set_vat_rate().
2764
-	 *
2765
-	 * @since 1.0.19
2766
-	 * @param  string $value var number.
2767
-	 */
2768
-	public function set_customer_vat_rate( $value ) {
2769
-		$this->set_vat_rate( $value );
2770
-    }
2771
-
2772
-    /**
2773
-	 * Set the customer's address.
2774
-	 *
2775
-	 * @since 1.0.19
2776
-	 * @param  string $value address.
2777
-	 */
2778
-	public function set_address( $value ) {
2779
-		$this->set_prop( 'address', $value );
2780
-    }
2781
-
2782
-    /**
2783
-	 * Alias of self::set_address().
2784
-	 *
2785
-	 * @since 1.0.19
2786
-	 * @param  string $value address.
2787
-	 */
2788
-	public function set_user_address( $value ) {
2789
-		$this->set_address( $value );
2790
-    }
2791
-
2792
-    /**
2793
-	 * Alias of self::set_address().
2794
-	 *
2795
-	 * @since 1.0.19
2796
-	 * @param  string $value address.
2797
-	 */
2798
-	public function set_customer_address( $value ) {
2799
-		$this->set_address( $value );
2800
-    }
2801
-
2802
-    /**
2803
-	 * Set whether the customer has viewed the invoice or not.
2804
-	 *
2805
-	 * @since 1.0.19
2806
-	 * @param  int|bool $value confirmed.
2807
-	 */
2808
-	public function set_is_viewed( $value ) {
2809
-		$this->set_prop( 'is_viewed', $value );
2810
-	}
2811
-
2812
-	/**
2813
-	 * Set extra email recipients.
2814
-	 *
2815
-	 * @since 1.0.19
2816
-	 * @param  string $value email recipients.
2817
-	 */
2818
-	public function set_email_cc( $value ) {
2819
-		$this->set_prop( 'email_cc', $value );
2820
-	}
2821
-
2822
-	/**
2823
-	 * Set the invoice template.
2824
-	 *
2825
-	 * @since 1.0.19
2826
-	 * @param  string $value template.
2827
-	 */
2828
-	public function set_template( $value ) {
2829
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2830
-			$this->set_prop( 'template', $value );
2831
-		}
2832
-	}
2833
-
2834
-	/**
2835
-	 * Set the invoice source.
2836
-	 *
2837
-	 * @since 1.0.19
2838
-	 * @param  string $value source.
2839
-	 * @deprecated
2840
-	 */
2841
-	public function created_via( $value ) {
2842
-		$this->set_created_via( sanitize_text_field( $value ) );
2843
-	}
2844
-
2845
-	/**
2846
-	 * Set the invoice source.
2847
-	 *
2848
-	 * @since 1.0.19
2849
-	 * @param  string $value source.
2850
-	 */
2851
-	public function set_created_via( $value ) {
2852
-		$this->set_prop( 'created_via', sanitize_text_field( $value ) );
2853
-	}
2854
-
2855
-	/**
2856
-	 * Set the customer's address confirmed status.
2857
-	 *
2858
-	 * @since 1.0.19
2859
-	 * @param  int|bool $value confirmed.
2860
-	 */
2861
-	public function set_address_confirmed( $value ) {
2862
-		$this->set_prop( 'address_confirmed', $value );
2863
-    }
2864
-
2865
-    /**
2866
-	 * Alias of self::set_address_confirmed().
2867
-	 *
2868
-	 * @since 1.0.19
2869
-	 * @param  int|bool $value confirmed.
2870
-	 */
2871
-	public function set_user_address_confirmed( $value ) {
2872
-		$this->set_address_confirmed( $value );
2873
-    }
2874
-
2875
-    /**
2876
-	 * Alias of self::set_address_confirmed().
2877
-	 *
2878
-	 * @since 1.0.19
2879
-	 * @param  int|bool $value confirmed.
2880
-	 */
2881
-	public function set_customer_address_confirmed( $value ) {
2882
-		$this->set_address_confirmed( $value );
2883
-    }
2884
-
2885
-    /**
2886
-	 * Set the shipping fee
2887
-	 *
2888
-	 * @since 1.0.19
2889
-	 * @param  float $value shipping amount.
2890
-	 */
2891
-	public function set_shipping( $value ) {
2892
-
2893
-		if ( ! is_numeric( $value ) ) {
2894
-			return $this->set_prop( 'shipping', null );
2895
-		}
2896
-
2897
-		$this->set_prop( 'shipping', max( 0, floatval( $value ) ) );
2898
-	}
2899
-
2900
-	/**
2901
-	 * Set the invoice sub total.
2902
-	 *
2903
-	 * @since 1.0.19
2904
-	 * @param  float $value sub total.
2905
-	 */
2906
-	public function set_subtotal( $value ) {
2907
-		$this->set_prop( 'subtotal', max( 0, $value ) );
2908
-	}
2909
-
2910
-	/**
2911
-	 * Set the invoice total.
2912
-	 *
2913
-	 * @since 1.0.19
2914
-	 * @param  float $value sub total.
2915
-	 */
2916
-	public function set_total( $value ) {
2917
-		$this->set_prop( 'total', max( 0, $value ) );
2910
+    /**
2911
+     * Set the invoice total.
2912
+     *
2913
+     * @since 1.0.19
2914
+     * @param  float $value sub total.
2915
+     */
2916
+    public function set_total( $value ) {
2917
+        $this->set_prop( 'total', max( 0, $value ) );
2918 2918
     }
2919 2919
 
2920 2920
     /**
2921
-	 * Set the invoice discount amount.
2922
-	 *
2923
-	 * @since 1.0.19
2924
-	 * @param  float $value discount total.
2925
-	 */
2926
-	public function set_total_discount( $value ) {
2927
-		$this->set_prop( 'total_discount', max( 0, $value ) );
2921
+     * Set the invoice discount amount.
2922
+     *
2923
+     * @since 1.0.19
2924
+     * @param  float $value discount total.
2925
+     */
2926
+    public function set_total_discount( $value ) {
2927
+        $this->set_prop( 'total_discount', max( 0, $value ) );
2928 2928
     }
2929 2929
 
2930 2930
     /**
2931
-	 * Alias of self::set_total_discount().
2932
-	 *
2933
-	 * @since 1.0.19
2934
-	 * @param  float $value discount total.
2935
-	 */
2936
-	public function set_discount( $value ) {
2937
-		$this->set_total_discount( $value );
2931
+     * Alias of self::set_total_discount().
2932
+     *
2933
+     * @since 1.0.19
2934
+     * @param  float $value discount total.
2935
+     */
2936
+    public function set_discount( $value ) {
2937
+        $this->set_total_discount( $value );
2938 2938
     }
2939 2939
 
2940 2940
     /**
2941
-	 * Set the invoice tax amount.
2942
-	 *
2943
-	 * @since 1.0.19
2944
-	 * @param  float $value tax total.
2945
-	 */
2946
-	public function set_total_tax( $value ) {
2947
-		$this->set_prop( 'total_tax', max( 0, $value ) );
2941
+     * Set the invoice tax amount.
2942
+     *
2943
+     * @since 1.0.19
2944
+     * @param  float $value tax total.
2945
+     */
2946
+    public function set_total_tax( $value ) {
2947
+        $this->set_prop( 'total_tax', max( 0, $value ) );
2948 2948
     }
2949 2949
 
2950 2950
     /**
2951
-	 * Alias of self::set_total_tax().
2952
-	 *
2953
-	 * @since 1.0.19
2954
-	 * @param  float $value tax total.
2955
-	 */
2956
-	public function set_tax_total( $value ) {
2957
-		$this->set_total_tax( $value );
2951
+     * Alias of self::set_total_tax().
2952
+     *
2953
+     * @since 1.0.19
2954
+     * @param  float $value tax total.
2955
+     */
2956
+    public function set_tax_total( $value ) {
2957
+        $this->set_total_tax( $value );
2958 2958
     }
2959 2959
 
2960 2960
     /**
2961
-	 * Set the invoice fees amount.
2962
-	 *
2963
-	 * @since 1.0.19
2964
-	 * @param  float $value fees total.
2965
-	 */
2966
-	public function set_total_fees( $value ) {
2967
-		$this->set_prop( 'total_fees', max( 0, $value ) );
2961
+     * Set the invoice fees amount.
2962
+     *
2963
+     * @since 1.0.19
2964
+     * @param  float $value fees total.
2965
+     */
2966
+    public function set_total_fees( $value ) {
2967
+        $this->set_prop( 'total_fees', max( 0, $value ) );
2968 2968
     }
2969 2969
 
2970 2970
     /**
2971
-	 * Alias of self::set_total_fees().
2972
-	 *
2973
-	 * @since 1.0.19
2974
-	 * @param  float $value fees total.
2975
-	 */
2976
-	public function set_fees_total( $value ) {
2977
-		$this->set_total_fees( $value );
2971
+     * Alias of self::set_total_fees().
2972
+     *
2973
+     * @since 1.0.19
2974
+     * @param  float $value fees total.
2975
+     */
2976
+    public function set_fees_total( $value ) {
2977
+        $this->set_total_fees( $value );
2978 2978
     }
2979 2979
 
2980 2980
     /**
2981
-	 * Set the invoice fees.
2982
-	 *
2983
-	 * @since 1.0.19
2984
-	 * @param  array $value fees.
2985
-	 */
2986
-	public function set_fees( $value ) {
2981
+     * Set the invoice fees.
2982
+     *
2983
+     * @since 1.0.19
2984
+     * @param  array $value fees.
2985
+     */
2986
+    public function set_fees( $value ) {
2987 2987
 
2988
-		if ( ! is_array( $value ) ) {
2989
-			$value = array();
2990
-		}
2988
+        if ( ! is_array( $value ) ) {
2989
+            $value = array();
2990
+        }
2991 2991
 
2992
-		$this->set_prop( 'fees', $value );
2992
+        $this->set_prop( 'fees', $value );
2993 2993
 
2994 2994
     }
2995 2995
 
2996 2996
     /**
2997
-	 * Set the invoice taxes.
2998
-	 *
2999
-	 * @since 1.0.19
3000
-	 * @param  array $value taxes.
3001
-	 */
3002
-	public function set_taxes( $value ) {
2997
+     * Set the invoice taxes.
2998
+     *
2999
+     * @since 1.0.19
3000
+     * @param  array $value taxes.
3001
+     */
3002
+    public function set_taxes( $value ) {
3003 3003
 
3004
-		if ( ! is_array( $value ) ) {
3005
-			$value = array();
3006
-		}
3004
+        if ( ! is_array( $value ) ) {
3005
+            $value = array();
3006
+        }
3007 3007
 
3008
-		$this->set_prop( 'taxes', $value );
3008
+        $this->set_prop( 'taxes', $value );
3009 3009
 
3010 3010
     }
3011 3011
 
3012 3012
     /**
3013
-	 * Set the invoice discounts.
3014
-	 *
3015
-	 * @since 1.0.19
3016
-	 * @param  array $value discounts.
3017
-	 */
3018
-	public function set_discounts( $value ) {
3013
+     * Set the invoice discounts.
3014
+     *
3015
+     * @since 1.0.19
3016
+     * @param  array $value discounts.
3017
+     */
3018
+    public function set_discounts( $value ) {
3019 3019
 
3020
-		if ( ! is_array( $value ) ) {
3021
-			$value = array();
3022
-		}
3020
+        if ( ! is_array( $value ) ) {
3021
+            $value = array();
3022
+        }
3023 3023
 
3024
-		$this->set_prop( 'discounts', $value );
3024
+        $this->set_prop( 'discounts', $value );
3025 3025
     }
3026 3026
 
3027 3027
     /**
3028
-	 * Set the invoice items.
3029
-	 *
3030
-	 * @since 1.0.19
3031
-	 * @param  GetPaid_Form_Item[] $value items.
3032
-	 */
3033
-	public function set_items( $value ) {
3028
+     * Set the invoice items.
3029
+     *
3030
+     * @since 1.0.19
3031
+     * @param  GetPaid_Form_Item[] $value items.
3032
+     */
3033
+    public function set_items( $value ) {
3034 3034
 
3035 3035
         // Remove existing items.
3036 3036
         $this->set_prop( 'items', array() );
3037
-		$this->recurring_item = null;
3037
+        $this->recurring_item = null;
3038 3038
 
3039 3039
         // Ensure that we have an array.
3040 3040
         if ( ! is_array( $value ) ) {
@@ -3048,105 +3048,105 @@  discard block
 block discarded – undo
3048 3048
     }
3049 3049
 
3050 3050
     /**
3051
-	 * Set the payment form.
3052
-	 *
3053
-	 * @since 1.0.19
3054
-	 * @param  int $value payment form.
3055
-	 */
3056
-	public function set_payment_form( $value ) {
3057
-		$this->set_prop( 'payment_form', $value );
3051
+     * Set the payment form.
3052
+     *
3053
+     * @since 1.0.19
3054
+     * @param  int $value payment form.
3055
+     */
3056
+    public function set_payment_form( $value ) {
3057
+        $this->set_prop( 'payment_form', $value );
3058 3058
     }
3059 3059
 
3060 3060
     /**
3061
-	 * Set the submission id.
3062
-	 *
3063
-	 * @since 1.0.19
3064
-	 * @param  string $value submission id.
3065
-	 */
3066
-	public function set_submission_id( $value ) {
3067
-		$this->set_prop( 'submission_id', $value );
3061
+     * Set the submission id.
3062
+     *
3063
+     * @since 1.0.19
3064
+     * @param  string $value submission id.
3065
+     */
3066
+    public function set_submission_id( $value ) {
3067
+        $this->set_prop( 'submission_id', $value );
3068 3068
     }
3069 3069
 
3070 3070
     /**
3071
-	 * Set the discount code.
3072
-	 *
3073
-	 * @since 1.0.19
3074
-	 * @param  string $value discount code.
3075
-	 */
3076
-	public function set_discount_code( $value ) {
3077
-		$this->set_prop( 'discount_code', sanitize_text_field( $value ) );
3071
+     * Set the discount code.
3072
+     *
3073
+     * @since 1.0.19
3074
+     * @param  string $value discount code.
3075
+     */
3076
+    public function set_discount_code( $value ) {
3077
+        $this->set_prop( 'discount_code', sanitize_text_field( $value ) );
3078 3078
     }
3079 3079
 
3080 3080
     /**
3081
-	 * Set the gateway.
3082
-	 *
3083
-	 * @since 1.0.19
3084
-	 * @param  string $value gateway.
3085
-	 */
3086
-	public function set_gateway( $value ) {
3087
-		$this->set_prop( 'gateway', $value );
3081
+     * Set the gateway.
3082
+     *
3083
+     * @since 1.0.19
3084
+     * @param  string $value gateway.
3085
+     */
3086
+    public function set_gateway( $value ) {
3087
+        $this->set_prop( 'gateway', $value );
3088 3088
     }
3089 3089
 
3090 3090
     /**
3091
-	 * Set the transaction id.
3092
-	 *
3093
-	 * @since 1.0.19
3094
-	 * @param  string $value transaction id.
3095
-	 */
3096
-	public function set_transaction_id( $value ) {
3097
-		if ( ! empty( $value ) ) {
3098
-			$this->set_prop( 'transaction_id', $value );
3099
-		}
3091
+     * Set the transaction id.
3092
+     *
3093
+     * @since 1.0.19
3094
+     * @param  string $value transaction id.
3095
+     */
3096
+    public function set_transaction_id( $value ) {
3097
+        if ( ! empty( $value ) ) {
3098
+            $this->set_prop( 'transaction_id', $value );
3099
+        }
3100 3100
     }
3101 3101
 
3102 3102
     /**
3103
-	 * Set the currency id.
3104
-	 *
3105
-	 * @since 1.0.19
3106
-	 * @param  string $value currency id.
3107
-	 */
3108
-	public function set_currency( $value ) {
3109
-		$this->set_prop( 'currency', $value );
3103
+     * Set the currency id.
3104
+     *
3105
+     * @since 1.0.19
3106
+     * @param  string $value currency id.
3107
+     */
3108
+    public function set_currency( $value ) {
3109
+        $this->set_prop( 'currency', $value );
3110 3110
     }
3111 3111
 
3112
-	/**
3113
-	 * Set whether to disable taxes.
3114
-	 *
3115
-	 * @since 1.0.19
3116
-	 * @param  bool $value value.
3117
-	 */
3118
-	public function set_disable_taxes( $value ) {
3119
-		$this->set_prop( 'disable_taxes', (bool) $value );
3120
-	}
3112
+    /**
3113
+     * Set whether to disable taxes.
3114
+     *
3115
+     * @since 1.0.19
3116
+     * @param  bool $value value.
3117
+     */
3118
+    public function set_disable_taxes( $value ) {
3119
+        $this->set_prop( 'disable_taxes', (bool) $value );
3120
+    }
3121 3121
 
3122 3122
     /**
3123
-	 * Set the subscription id.
3124
-	 *
3125
-	 * @since 1.0.19
3126
-	 * @param  string $value subscription id.
3127
-	 */
3128
-	public function set_subscription_id( $value ) {
3129
-		$this->set_prop( 'subscription_id', $value );
3130
-	}
3123
+     * Set the subscription id.
3124
+     *
3125
+     * @since 1.0.19
3126
+     * @param  string $value subscription id.
3127
+     */
3128
+    public function set_subscription_id( $value ) {
3129
+        $this->set_prop( 'subscription_id', $value );
3130
+    }
3131 3131
 
3132
-	/**
3133
-	 * Set the remote subscription id.
3134
-	 *
3135
-	 * @since 1.0.19
3136
-	 * @param  string $value subscription id.
3137
-	 */
3138
-	public function set_remote_subscription_id( $value ) {
3139
-		$this->set_prop( 'remote_subscription_id', $value );
3132
+    /**
3133
+     * Set the remote subscription id.
3134
+     *
3135
+     * @since 1.0.19
3136
+     * @param  string $value subscription id.
3137
+     */
3138
+    public function set_remote_subscription_id( $value ) {
3139
+        $this->set_prop( 'remote_subscription_id', $value );
3140 3140
     }
3141 3141
 
3142
-	/**
3143
-	 * Set the invoice anonymize status.
3144
-	 *
3145
-	 * @since 2.8.22
3146
-	 * @param  bool $is_anonymized is anonymized.
3147
-	 */
3148
-	public function set_is_anonymized( $is_anonymized ) {
3149
-		$this->set_prop( 'is_anonymized', (bool) $is_anonymized );
3142
+    /**
3143
+     * Set the invoice anonymize status.
3144
+     *
3145
+     * @since 2.8.22
3146
+     * @param  bool $is_anonymized is anonymized.
3147
+     */
3148
+    public function set_is_anonymized( $is_anonymized ) {
3149
+        $this->set_prop( 'is_anonymized', (bool) $is_anonymized );
3150 3150
     }
3151 3151
 
3152 3152
     /*
@@ -3185,24 +3185,24 @@  discard block
 block discarded – undo
3185 3185
      */
3186 3186
     public function is_taxable() {
3187 3187
         return ! $this->get_disable_taxes();
3188
-	}
3188
+    }
3189 3189
 
3190
-	/**
3191
-	 * @deprecated
3192
-	 */
3193
-	public function has_vat() {
3190
+    /**
3191
+     * @deprecated
3192
+     */
3193
+    public function has_vat() {
3194 3194
         return $this->is_taxable();
3195
-	}
3195
+    }
3196 3196
 
3197
-	/**
3198
-	 * Checks to see if the invoice requires payment.
3199
-	 */
3200
-	public function is_free() {
3197
+    /**
3198
+     * Checks to see if the invoice requires payment.
3199
+     */
3200
+    public function is_free() {
3201 3201
         $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
3202 3202
 
3203
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3204
-			$is_free = false;
3205
-		}
3203
+        if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3204
+            $is_free = false;
3205
+        }
3206 3206
 
3207 3207
         return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
3208 3208
     }
@@ -3213,46 +3213,46 @@  discard block
 block discarded – undo
3213 3213
     public function is_paid() {
3214 3214
         $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
3215 3215
         return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
3216
-	}
3216
+    }
3217 3217
 
3218
-	/**
3218
+    /**
3219 3219
      * Checks if the invoice needs payment.
3220 3220
      */
3221
-	public function needs_payment() {
3222
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3221
+    public function needs_payment() {
3222
+        $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3223 3223
         return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
3224 3224
     }
3225 3225
 
3226
-	/**
3226
+    /**
3227 3227
      * Checks if the invoice is refunded.
3228 3228
      */
3229
-	public function is_refunded() {
3229
+    public function is_refunded() {
3230 3230
         $is_refunded = $this->has_status( 'wpi-refunded' );
3231 3231
         return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
3232
-	}
3232
+    }
3233 3233
 
3234
-	/**
3234
+    /**
3235 3235
      * Checks if the invoice is held.
3236 3236
      */
3237
-	public function is_held() {
3237
+    public function is_held() {
3238 3238
         $is_held = $this->has_status( 'wpi-onhold' );
3239 3239
         return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3240
-	}
3240
+    }
3241 3241
 
3242
-	/**
3242
+    /**
3243 3243
      * Checks if the invoice is due.
3244 3244
      */
3245
-	public function is_due() {
3246
-		$due_date = $this->get_due_date();
3247
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3248
-	}
3245
+    public function is_due() {
3246
+        $due_date = $this->get_due_date();
3247
+        return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3248
+    }
3249 3249
 
3250
-	/**
3250
+    /**
3251 3251
      * Checks if the invoice is draft.
3252 3252
      */
3253
-	public function is_draft() {
3253
+    public function is_draft() {
3254 3254
         return $this->has_status( 'draft, auto-draft' );
3255
-	}
3255
+    }
3256 3256
 
3257 3257
     /**
3258 3258
      * Checks if the invoice has a given status.
@@ -3260,9 +3260,9 @@  discard block
 block discarded – undo
3260 3260
     public function has_status( $status ) {
3261 3261
         $status = wpinv_parse_list( $status );
3262 3262
         return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3263
-	}
3263
+    }
3264 3264
 
3265
-	/**
3265
+    /**
3266 3266
      * Checks if the invoice is of a given type.
3267 3267
      */
3268 3268
     public function is_type( $type ) {
@@ -3285,25 +3285,25 @@  discard block
 block discarded – undo
3285 3285
      */
3286 3286
     public function has_free_trial() {
3287 3287
         return $this->is_recurring() && 0 == $this->get_initial_total();
3288
-	}
3288
+    }
3289 3289
 
3290
-	/**
3290
+    /**
3291 3291
      * @deprecated
3292 3292
      */
3293 3293
     public function is_free_trial() {
3294 3294
         return $this->has_free_trial();
3295 3295
     }
3296 3296
 
3297
-	/**
3297
+    /**
3298 3298
      * Check if the initial payment if 0.
3299 3299
      *
3300 3300
      */
3301
-	public function is_initial_free() {
3301
+    public function is_initial_free() {
3302 3302
         $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3303 3303
         return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3304 3304
     }
3305 3305
 
3306
-	/**
3306
+    /**
3307 3307
      * Check if the recurring item has a free trial.
3308 3308
      *
3309 3309
      */
@@ -3316,16 +3316,16 @@  discard block
 block discarded – undo
3316 3316
 
3317 3317
         $item = $this->get_recurring( true );
3318 3318
         return $item->has_free_trial();
3319
-	}
3319
+    }
3320 3320
 
3321
-	/**
3321
+    /**
3322 3322
      * Check if the free trial is a result of a discount.
3323 3323
      */
3324 3324
     public function is_free_trial_from_discount() {
3325
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3326
-	}
3325
+        return $this->has_free_trial() && ! $this->item_has_free_trial();
3326
+    }
3327 3327
 
3328
-	/**
3328
+    /**
3329 3329
      * Checks if this is an anonymized invoice.
3330 3330
      *
3331 3331
      * @since 2.8.22
@@ -3334,12 +3334,12 @@  discard block
 block discarded – undo
3334 3334
         return true === (bool) $this->get_is_anonymized();
3335 3335
     }
3336 3336
 
3337
-	/**
3337
+    /**
3338 3338
      * @deprecated
3339 3339
      */
3340 3340
     public function discount_first_payment_only() {
3341 3341
 
3342
-		$discount = wpinv_get_discount_obj( $this->get_discount_code() );
3342
+        $discount = wpinv_get_discount_obj( $this->get_discount_code() );
3343 3343
         if ( ! $discount->exists() || ! $this->is_recurring() ) {
3344 3344
             return true;
3345 3345
         }
@@ -3364,146 +3364,146 @@  discard block
 block discarded – undo
3364 3364
      */
3365 3365
     public function add_item( $item ) {
3366 3366
 
3367
-		if ( is_array( $item ) ) {
3368
-			$item = $this->process_array_item( $item );
3369
-		}
3367
+        if ( is_array( $item ) ) {
3368
+            $item = $this->process_array_item( $item );
3369
+        }
3370 3370
 
3371
-		if ( is_numeric( $item ) ) {
3372
-			$item = new GetPaid_Form_Item( $item );
3373
-		}
3371
+        if ( is_numeric( $item ) ) {
3372
+            $item = new GetPaid_Form_Item( $item );
3373
+        }
3374 3374
 
3375 3375
         // Make sure that it is available for purchase.
3376
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3377
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3376
+        if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3377
+            return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3378 3378
         }
3379 3379
 
3380 3380
         // Do we have a recurring item?
3381
-		if ( $item->is_recurring() ) {
3382
-			$this->recurring_item = $item->get_id();
3381
+        if ( $item->is_recurring() ) {
3382
+            $this->recurring_item = $item->get_id();
3383 3383
         }
3384 3384
 
3385 3385
         // Invoice id.
3386 3386
         $item->invoice_id = (int) $this->get_id();
3387 3387
 
3388
-		// Remove duplicates.
3389
-		$this->remove_item( $item->get_id() );
3388
+        // Remove duplicates.
3389
+        $this->remove_item( $item->get_id() );
3390 3390
 
3391
-		if ( 0 == $item->get_quantity() ) {
3392
-			return;
3393
-		}
3391
+        if ( 0 == $item->get_quantity() ) {
3392
+            return;
3393
+        }
3394 3394
 
3395
-		// Retrieve all items.
3395
+        // Retrieve all items.
3396 3396
         $items   = $this->get_items();
3397 3397
 
3398
-		// Add new item.
3398
+        // Add new item.
3399 3399
         $items[] = $item;
3400 3400
 
3401 3401
         $this->set_prop( 'items', $items );
3402 3402
 
3403
-		return true;
3404
-	}
3403
+        return true;
3404
+    }
3405 3405
 
3406
-	/**
3407
-	 * Converts an array to an item.
3408
-	 *
3409
-	 * @since 1.0.19
3410
-	 * @return GetPaid_Form_Item
3411
-	 */
3412
-	protected function process_array_item( $array ) {
3406
+    /**
3407
+     * Converts an array to an item.
3408
+     *
3409
+     * @since 1.0.19
3410
+     * @return GetPaid_Form_Item
3411
+     */
3412
+    protected function process_array_item( $array ) {
3413 3413
 
3414
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3415
-		$item    = new GetPaid_Form_Item( $item_id );
3414
+        $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3415
+        $item    = new GetPaid_Form_Item( $item_id );
3416 3416
 
3417
-		// Set item data.
3418
-		foreach ( array( 'name', 'price', 'description' ) as $key ) {
3419
-			if ( isset( $array[ "item_$key" ] ) ) {
3420
-				$method = "set_$key";
3421
-				$item->$method( $array[ "item_$key" ] );
3422
-			}
3423
-		}
3417
+        // Set item data.
3418
+        foreach ( array( 'name', 'price', 'description' ) as $key ) {
3419
+            if ( isset( $array[ "item_$key" ] ) ) {
3420
+                $method = "set_$key";
3421
+                $item->$method( $array[ "item_$key" ] );
3422
+            }
3423
+        }
3424 3424
 
3425
-		if ( isset( $array['quantity'] ) ) {
3426
-			$item->set_quantity( $array['quantity'] );
3427
-		}
3425
+        if ( isset( $array['quantity'] ) ) {
3426
+            $item->set_quantity( $array['quantity'] );
3427
+        }
3428 3428
 
3429
-		// Set item meta.
3430
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3431
-			$item->set_item_meta( $array['meta'] );
3432
-		}
3429
+        // Set item meta.
3430
+        if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3431
+            $item->set_item_meta( $array['meta'] );
3432
+        }
3433 3433
 
3434
-		return $item;
3434
+        return $item;
3435 3435
 
3436
-	}
3436
+    }
3437 3437
 
3438 3438
     /**
3439
-	 * Retrieves a specific item.
3440
-	 *
3441
-	 * @since 1.0.19
3442
-	 * @return GetPaid_Form_Item|null
3443
-	 */
3444
-	public function get_item( $item_id ) {
3439
+     * Retrieves a specific item.
3440
+     *
3441
+     * @since 1.0.19
3442
+     * @return GetPaid_Form_Item|null
3443
+     */
3444
+    public function get_item( $item_id ) {
3445 3445
 
3446
-		foreach ( $this->get_items() as $item ) {
3447
-			if ( (int) $item_id == $item->get_id() ) {
3448
-				return $item;
3449
-			}
3450
-		}
3446
+        foreach ( $this->get_items() as $item ) {
3447
+            if ( (int) $item_id == $item->get_id() ) {
3448
+                return $item;
3449
+            }
3450
+        }
3451 3451
 
3452
-		return null;
3452
+        return null;
3453 3453
     }
3454 3454
 
3455 3455
     /**
3456
-	 * Removes a specific item.
3457
-	 *
3458
-	 * @since 1.0.19
3459
-	 */
3460
-	public function remove_item( $item_id ) {
3461
-		$items   = $this->get_items();
3462
-		$item_id = (int) $item_id;
3456
+     * Removes a specific item.
3457
+     *
3458
+     * @since 1.0.19
3459
+     */
3460
+    public function remove_item( $item_id ) {
3461
+        $items   = $this->get_items();
3462
+        $item_id = (int) $item_id;
3463 3463
 
3464
-		foreach ( $items as $index => $item ) {
3465
-			if ( (int) $item_id == $item->get_id() ) {
3466
-				unset( $items[ $index ] );
3467
-				$this->set_prop( 'items', $items );
3464
+        foreach ( $items as $index => $item ) {
3465
+            if ( (int) $item_id == $item->get_id() ) {
3466
+                unset( $items[ $index ] );
3467
+                $this->set_prop( 'items', $items );
3468 3468
 
3469
-				if ( $item_id == $this->recurring_item ) {
3470
-					$this->recurring_item = null;
3471
-				}
3469
+                if ( $item_id == $this->recurring_item ) {
3470
+                    $this->recurring_item = null;
3471
+                }
3472 3472
 }
3473
-		}
3473
+        }
3474 3474
 
3475 3475
     }
3476 3476
 
3477 3477
     /**
3478
-	 * Adds a fee to the invoice.
3479
-	 *
3480
-	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3481
-	 * @since 1.0.19
3482
-	 */
3478
+     * Adds a fee to the invoice.
3479
+     *
3480
+     * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3481
+     * @since 1.0.19
3482
+     */
3483 3483
     public function add_fee( $fee ) {
3484 3484
 
3485
-		$fees                 = $this->get_fees();
3486
-		$fees[ $fee['name'] ] = $fee;
3487
-		$this->set_prop( 'fees', $fees );
3485
+        $fees                 = $this->get_fees();
3486
+        $fees[ $fee['name'] ] = $fee;
3487
+        $this->set_prop( 'fees', $fees );
3488 3488
 
3489 3489
     }
3490 3490
 
3491 3491
     /**
3492
-	 * Retrieves a specific fee.
3493
-	 *
3494
-	 * @since 1.0.19
3495
-	 */
3496
-	public function get_fee( $fee ) {
3492
+     * Retrieves a specific fee.
3493
+     *
3494
+     * @since 1.0.19
3495
+     */
3496
+    public function get_fee( $fee ) {
3497 3497
         $fees = $this->get_fees();
3498
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3498
+        return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3499 3499
     }
3500 3500
 
3501 3501
     /**
3502
-	 * Removes a specific fee.
3503
-	 *
3504
-	 * @since 1.0.19
3505
-	 */
3506
-	public function remove_fee( $fee ) {
3502
+     * Removes a specific fee.
3503
+     *
3504
+     * @since 1.0.19
3505
+     */
3506
+    public function remove_fee( $fee ) {
3507 3507
         $fees = $this->get_fees();
3508 3508
         if ( isset( $fees[ $fee ] ) ) {
3509 3509
             unset( $fees[ $fee ] );
@@ -3511,55 +3511,55 @@  discard block
 block discarded – undo
3511 3511
         }
3512 3512
     }
3513 3513
 
3514
-	/**
3515
-	 * Adds a discount to the invoice.
3516
-	 *
3517
-	 * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3518
-	 * @since 1.0.19
3519
-	 */
3520
-	public function add_discount( $discount ) {
3514
+    /**
3515
+     * Adds a discount to the invoice.
3516
+     *
3517
+     * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3518
+     * @since 1.0.19
3519
+     */
3520
+    public function add_discount( $discount ) {
3521 3521
 
3522
-		$discounts = $this->get_discounts();
3523
-		$discounts[ $discount['name'] ] = $discount;
3524
-		$this->set_prop( 'discounts', $discounts );
3522
+        $discounts = $this->get_discounts();
3523
+        $discounts[ $discount['name'] ] = $discount;
3524
+        $this->set_prop( 'discounts', $discounts );
3525 3525
 
3526
-	}
3526
+    }
3527 3527
 
3528 3528
     /**
3529
-	 * Retrieves a specific discount.
3530
-	 *
3531
-	 * @since 1.0.19
3532
-	 * @return float
3533
-	 */
3534
-	public function get_discount( $discount = false ) {
3529
+     * Retrieves a specific discount.
3530
+     *
3531
+     * @since 1.0.19
3532
+     * @return float
3533
+     */
3534
+    public function get_discount( $discount = false ) {
3535 3535
 
3536
-		// Backwards compatibility.
3537
-		if ( empty( $discount ) ) {
3538
-			return $this->get_total_discount();
3539
-		}
3536
+        // Backwards compatibility.
3537
+        if ( empty( $discount ) ) {
3538
+            return $this->get_total_discount();
3539
+        }
3540 3540
 
3541 3541
         $discounts = $this->get_discounts();
3542
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3542
+        return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3543 3543
     }
3544 3544
 
3545 3545
     /**
3546
-	 * Removes a specific discount.
3547
-	 *
3548
-	 * @since 1.0.19
3549
-	 */
3550
-	public function remove_discount( $discount ) {
3546
+     * Removes a specific discount.
3547
+     *
3548
+     * @since 1.0.19
3549
+     */
3550
+    public function remove_discount( $discount ) {
3551 3551
         $discounts = $this->get_discounts();
3552 3552
         if ( isset( $discounts[ $discount ] ) ) {
3553 3553
             unset( $discounts[ $discount ] );
3554 3554
             $this->set_prop( 'discounts', $discounts );
3555 3555
         }
3556 3556
 
3557
-		if ( 'discount_code' == $discount ) {
3558
-			foreach ( $this->get_items() as $item ) {
3559
-				$item->item_discount           = 0;
3560
-				$item->recurring_item_discount = 0;
3561
-			}
3562
-		}
3557
+        if ( 'discount_code' == $discount ) {
3558
+            foreach ( $this->get_items() as $item ) {
3559
+                $item->item_discount           = 0;
3560
+                $item->recurring_item_discount = 0;
3561
+            }
3562
+        }
3563 3563
 
3564 3564
     }
3565 3565
 
@@ -3572,116 +3572,116 @@  discard block
 block discarded – undo
3572 3572
         if ( $this->is_taxable() ) {
3573 3573
 
3574 3574
             $taxes                 = $this->get_taxes();
3575
-			$taxes[ $tax['name'] ] = $tax;
3576
-			$this->set_prop( 'taxes', $tax );
3575
+            $taxes[ $tax['name'] ] = $tax;
3576
+            $this->set_prop( 'taxes', $tax );
3577 3577
 
3578 3578
         }
3579 3579
     }
3580 3580
 
3581 3581
     /**
3582
-	 * Retrieves a specific tax.
3583
-	 *
3584
-	 * @since 1.0.19
3585
-	 */
3586
-	public function get_tax( $tax = null ) {
3582
+     * Retrieves a specific tax.
3583
+     *
3584
+     * @since 1.0.19
3585
+     */
3586
+    public function get_tax( $tax = null ) {
3587 3587
 
3588
-		// Backwards compatibility.
3589
-		if ( empty( $tax ) ) {
3590
-			return $this->get_total_tax();
3591
-		}
3588
+        // Backwards compatibility.
3589
+        if ( empty( $tax ) ) {
3590
+            return $this->get_total_tax();
3591
+        }
3592 3592
 
3593 3593
         $taxes = $this->get_taxes();
3594
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3594
+        return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3595 3595
     }
3596 3596
 
3597
-	public function get_tax_total_by_name( $name ) {
3598
-		if ( $name && 0 === strpos( $name, 'tax__' ) ) {
3599
-			$name = str_replace( 'tax__', '', $name );
3600
-		}
3597
+    public function get_tax_total_by_name( $name ) {
3598
+        if ( $name && 0 === strpos( $name, 'tax__' ) ) {
3599
+            $name = str_replace( 'tax__', '', $name );
3600
+        }
3601 3601
 
3602
-		if ( empty( $name ) ) {
3603
-			return 0;
3604
-		}
3602
+        if ( empty( $name ) ) {
3603
+            return 0;
3604
+        }
3605 3605
 
3606
-		$tax = $this->get_tax( $name );
3606
+        $tax = $this->get_tax( $name );
3607 3607
 
3608
-		if ( empty( $tax ) ) {
3609
-			return 0;
3610
-		}
3608
+        if ( empty( $tax ) ) {
3609
+            return 0;
3610
+        }
3611 3611
 
3612 3612
         return $this->is_renewal() ? $tax['recurring_tax'] : $tax['initial_tax'];
3613 3613
     }
3614 3614
 
3615
-	/**
3616
-	 * Get tax item name.
3617
-	 *
3618
-	 * @since 2.8.8
3619
-	 */
3620
-	public function get_tax_item_name( $tax_key, $tax_item, $suffix = '' ) {
3621
-		$tax_name = _x( 'Tax', 'Tax name', 'invoicing' );
3615
+    /**
3616
+     * Get tax item name.
3617
+     *
3618
+     * @since 2.8.8
3619
+     */
3620
+    public function get_tax_item_name( $tax_key, $tax_item, $suffix = '' ) {
3621
+        $tax_name = _x( 'Tax', 'Tax name', 'invoicing' );
3622 3622
 
3623
-		if ( ! empty( $tax_item ) && is_array( $tax_item ) && ! empty( $tax_item['name'] ) ) {
3624
-			$tax_name = __( $tax_item['name'], 'invoicing' );
3625
-		}
3623
+        if ( ! empty( $tax_item ) && is_array( $tax_item ) && ! empty( $tax_item['name'] ) ) {
3624
+            $tax_name = __( $tax_item['name'], 'invoicing' );
3625
+        }
3626 3626
 
3627
-		if ( $suffix ) {
3628
-			$tax_name .= $suffix;
3629
-		}
3627
+        if ( $suffix ) {
3628
+            $tax_name .= $suffix;
3629
+        }
3630 3630
 
3631
-		return apply_filters( 'wpinv_invoice_get_tax_name', $tax_name, $this, $tax_key, $tax_item, $suffix );
3632
-	}
3631
+        return apply_filters( 'wpinv_invoice_get_tax_name', $tax_name, $this, $tax_key, $tax_item, $suffix );
3632
+    }
3633 3633
 
3634
-	/**
3635
-	 * Get tax item amount.
3636
-	 *
3637
-	 * @since 2.8.8
3638
-	 */
3639
-	public function get_tax_item_amount( $tax_key, $tax_item, $with_currency = false ) {
3640
-		$tax_amount = $this->get_tax_total_by_name( $tax_key );
3634
+    /**
3635
+     * Get tax item amount.
3636
+     *
3637
+     * @since 2.8.8
3638
+     */
3639
+    public function get_tax_item_amount( $tax_key, $tax_item, $with_currency = false ) {
3640
+        $tax_amount = $this->get_tax_total_by_name( $tax_key );
3641 3641
 
3642
-		if ( $with_currency ) {
3643
-			$tax_amount = wpinv_price( $tax_amount, $this->get_currency() );
3644
-		}
3642
+        if ( $with_currency ) {
3643
+            $tax_amount = wpinv_price( $tax_amount, $this->get_currency() );
3644
+        }
3645 3645
 
3646
-		return apply_filters( 'wpinv_invoice_get_tax_amount', $tax_amount, $this, $tax_item, $with_currency );
3647
-	}
3646
+        return apply_filters( 'wpinv_invoice_get_tax_amount', $tax_amount, $this, $tax_item, $with_currency );
3647
+    }
3648 3648
 
3649
-	public function get_item_tax_name( $percentage = true, $sep = ' + ' ) {
3650
-		$taxes = $this->get_taxes();
3649
+    public function get_item_tax_name( $percentage = true, $sep = ' + ' ) {
3650
+        $taxes = $this->get_taxes();
3651 3651
 
3652
-		if ( ! empty( $taxes ) && is_array( $taxes ) && count( $taxes ) == 1 && wpinv_display_individual_tax_rates() ) {
3653
-			$names = array();
3652
+        if ( ! empty( $taxes ) && is_array( $taxes ) && count( $taxes ) == 1 && wpinv_display_individual_tax_rates() ) {
3653
+            $names = array();
3654 3654
 
3655
-			foreach ( $taxes as $key => $tax ) {
3656
-				if ( ! empty( $tax ) && ! empty( $tax['name'] ) ) {
3657
-					$name = __( $tax['name'], 'invoicing' );
3655
+            foreach ( $taxes as $key => $tax ) {
3656
+                if ( ! empty( $tax ) && ! empty( $tax['name'] ) ) {
3657
+                    $name = __( $tax['name'], 'invoicing' );
3658 3658
 
3659
-					$names[] = $name;
3660
-				}
3661
-			}
3659
+                    $names[] = $name;
3660
+                }
3661
+            }
3662 3662
 
3663
-			if ( ! empty( $names ) ) {
3664
-				$names = array_unique( $names );
3663
+            if ( ! empty( $names ) ) {
3664
+                $names = array_unique( $names );
3665 3665
 
3666
-				$tax_name = implode( $sep, $names );
3667
-			}
3666
+                $tax_name = implode( $sep, $names );
3667
+            }
3668 3668
 
3669
-			if ( $percentage ) {
3670
-				$tax_name = wp_sprintf( _x( '%s (%%)', 'Tax name with %. Ex: Tax (%)', 'invoicing' ), $tax_name );
3671
-			}
3672
-		} else {
3673
-			$tax_name = $percentage ? __( 'Tax (%)', 'invoicing' ) : _x( 'Tax', 'Tax name', 'invoicing' );
3674
-		}
3669
+            if ( $percentage ) {
3670
+                $tax_name = wp_sprintf( _x( '%s (%%)', 'Tax name with %. Ex: Tax (%)', 'invoicing' ), $tax_name );
3671
+            }
3672
+        } else {
3673
+            $tax_name = $percentage ? __( 'Tax (%)', 'invoicing' ) : _x( 'Tax', 'Tax name', 'invoicing' );
3674
+        }
3675 3675
 
3676
-		return apply_filters( 'wpinv_invoice_get_item_tax_name', $tax_name, $this, $percentage, $sep );
3677
-	}
3676
+        return apply_filters( 'wpinv_invoice_get_item_tax_name', $tax_name, $this, $percentage, $sep );
3677
+    }
3678 3678
 
3679 3679
     /**
3680
-	 * Removes a specific tax.
3681
-	 *
3682
-	 * @since 1.0.19
3683
-	 */
3684
-	public function remove_tax( $tax ) {
3680
+     * Removes a specific tax.
3681
+     *
3682
+     * @since 1.0.19
3683
+     */
3684
+    public function remove_tax( $tax ) {
3685 3685
         $taxes = $this->get_taxes();
3686 3686
         if ( isset( $taxes[ $tax ] ) ) {
3687 3687
             unset( $taxes[ $tax ] );
@@ -3690,193 +3690,193 @@  discard block
 block discarded – undo
3690 3690
     }
3691 3691
 
3692 3692
     /**
3693
-	 * Recalculates the invoice subtotal.
3694
-	 *
3695
-	 * @since 1.0.19
3696
-	 * @return float The recalculated subtotal
3697
-	 */
3698
-	public function recalculate_subtotal() {
3693
+     * Recalculates the invoice subtotal.
3694
+     *
3695
+     * @since 1.0.19
3696
+     * @return float The recalculated subtotal
3697
+     */
3698
+    public function recalculate_subtotal() {
3699 3699
         $items     = $this->get_items();
3700
-		$subtotal  = 0;
3701
-		$recurring = 0;
3700
+        $subtotal  = 0;
3701
+        $recurring = 0;
3702 3702
 
3703 3703
         foreach ( $items as $item ) {
3704
-			$subtotal  += $item->get_sub_total( 'edit' );
3705
-			$recurring += $item->get_recurring_sub_total( 'edit' );
3704
+            $subtotal  += $item->get_sub_total( 'edit' );
3705
+            $recurring += $item->get_recurring_sub_total( 'edit' );
3706 3706
         }
3707 3707
 
3708
-		if ( wpinv_prices_include_tax() ) {
3709
-			$subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3710
-			$recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3711
-		}
3708
+        if ( wpinv_prices_include_tax() ) {
3709
+            $subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3710
+            $recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3711
+        }
3712 3712
 
3713
-		$current = $this->is_renewal() ? $recurring : $subtotal;
3714
-		$this->set_subtotal( $current );
3713
+        $current = $this->is_renewal() ? $recurring : $subtotal;
3714
+        $this->set_subtotal( $current );
3715 3715
 
3716
-		$this->totals['subtotal'] = array(
3717
-			'initial'   => $subtotal,
3718
-			'recurring' => $recurring,
3719
-		);
3716
+        $this->totals['subtotal'] = array(
3717
+            'initial'   => $subtotal,
3718
+            'recurring' => $recurring,
3719
+        );
3720 3720
 
3721 3721
         return $current;
3722 3722
     }
3723 3723
 
3724 3724
     /**
3725
-	 * Recalculates the invoice discount total.
3726
-	 *
3727
-	 * @since 1.0.19
3728
-	 * @return float The recalculated discount
3729
-	 */
3730
-	public function recalculate_total_discount() {
3731
-		// Fix renewal invoice amount when tax + recurring discount applied.
3732
-		if ( $this->is_renewal() && $this->get_discount_code() ) {
3733
-			// Maybe recalculate discount (Pre-GetPaid Fix).
3734
-			$discount = new WPInv_Discount( $this->get_discount_code() );
3735
-
3736
-			if ( $discount->exists() && $discount->is_recurring() ) {
3737
-				getpaid_calculate_invoice_discount( $this, $discount );
3738
-			}
3739
-		}
3725
+     * Recalculates the invoice discount total.
3726
+     *
3727
+     * @since 1.0.19
3728
+     * @return float The recalculated discount
3729
+     */
3730
+    public function recalculate_total_discount() {
3731
+        // Fix renewal invoice amount when tax + recurring discount applied.
3732
+        if ( $this->is_renewal() && $this->get_discount_code() ) {
3733
+            // Maybe recalculate discount (Pre-GetPaid Fix).
3734
+            $discount = new WPInv_Discount( $this->get_discount_code() );
3735
+
3736
+            if ( $discount->exists() && $discount->is_recurring() ) {
3737
+                getpaid_calculate_invoice_discount( $this, $discount );
3738
+            }
3739
+        }
3740 3740
 
3741
-		$discounts = $this->get_discounts();
3742
-		$discount  = 0;
3743
-		$recurring = 0;
3741
+        $discounts = $this->get_discounts();
3742
+        $discount  = 0;
3743
+        $recurring = 0;
3744 3744
 
3745 3745
         foreach ( $discounts as $data ) {
3746
-			$discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3747
-			$recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3748
-		}
3746
+            $discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3747
+            $recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3748
+        }
3749 3749
 
3750
-		$current = $this->is_renewal() ? $recurring : $discount;
3750
+        $current = $this->is_renewal() ? $recurring : $discount;
3751 3751
 
3752
-		$this->set_total_discount( $current );
3752
+        $this->set_total_discount( $current );
3753 3753
 
3754
-		$this->totals['discount'] = array(
3755
-			'initial'   => $discount,
3756
-			'recurring' => $recurring,
3757
-		);
3754
+        $this->totals['discount'] = array(
3755
+            'initial'   => $discount,
3756
+            'recurring' => $recurring,
3757
+        );
3758 3758
 
3759
-		return $current;
3759
+        return $current;
3760 3760
 
3761 3761
     }
3762 3762
 
3763 3763
     /**
3764
-	 * Recalculates the invoice tax total.
3765
-	 *
3766
-	 * @since 1.0.19
3767
-	 * @return float The recalculated tax
3768
-	 */
3769
-	public function recalculate_total_tax() {
3764
+     * Recalculates the invoice tax total.
3765
+     *
3766
+     * @since 1.0.19
3767
+     * @return float The recalculated tax
3768
+     */
3769
+    public function recalculate_total_tax() {
3770 3770
 
3771
-		// Maybe disable taxes.
3772
-		$vat_number = $this->get_vat_number();
3773
-		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3771
+        // Maybe disable taxes.
3772
+        $vat_number = $this->get_vat_number();
3773
+        $skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3774 3774
 
3775
-		if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' === wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3776
-			$skip_tax = false;
3777
-		}
3775
+        if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' === wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3776
+            $skip_tax = false;
3777
+        }
3778 3778
 
3779
-		if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax ) {
3779
+        if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax ) {
3780 3780
 
3781
-			$this->totals['tax'] = array(
3782
-				'initial'   => 0,
3783
-				'recurring' => 0,
3784
-			);
3781
+            $this->totals['tax'] = array(
3782
+                'initial'   => 0,
3783
+                'recurring' => 0,
3784
+            );
3785 3785
 
3786
-			$this->tax_rate = 0;
3786
+            $this->tax_rate = 0;
3787 3787
 
3788
-			$this->set_taxes( array() );
3789
-			$current = 0;
3790
-		} else {
3788
+            $this->set_taxes( array() );
3789
+            $current = 0;
3790
+        } else {
3791 3791
 
3792
-			$item_taxes = array();
3792
+            $item_taxes = array();
3793 3793
 
3794
-			foreach ( $this->get_items() as $item ) {
3795
-				$rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3796
-				$rates    = getpaid_filter_item_tax_rates( $item, $rates );
3797
-				$taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3798
-				$r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3799
-				foreach ( $taxes as $name => $amount ) {
3800
-					$recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3801
-					$tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3794
+            foreach ( $this->get_items() as $item ) {
3795
+                $rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3796
+                $rates    = getpaid_filter_item_tax_rates( $item, $rates );
3797
+                $taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3798
+                $r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3799
+                foreach ( $taxes as $name => $amount ) {
3800
+                    $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3801
+                    $tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3802 3802
 
3803
-					if ( ! isset( $item_taxes[ $name ] ) ) {
3804
-						$item_taxes[ $name ] = $tax;
3805
-						continue;
3806
-					}
3803
+                    if ( ! isset( $item_taxes[ $name ] ) ) {
3804
+                        $item_taxes[ $name ] = $tax;
3805
+                        continue;
3806
+                    }
3807 3807
 
3808
-					$item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3809
-					$item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3808
+                    $item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3809
+                    $item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3810 3810
 
3811
-				}
3812
-			}
3811
+                }
3812
+            }
3813 3813
 
3814
-			$this->set_taxes( $item_taxes );
3814
+            $this->set_taxes( $item_taxes );
3815 3815
 
3816
-			$initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3817
-			$recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3816
+            $initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3817
+            $recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3818 3818
 
3819
-			$current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3819
+            $current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3820 3820
 
3821
-			$this->totals['tax'] = array(
3822
-				'initial'   => $initial_tax,
3823
-				'recurring' => $recurring_tax,
3824
-			);
3821
+            $this->totals['tax'] = array(
3822
+                'initial'   => $initial_tax,
3823
+                'recurring' => $recurring_tax,
3824
+            );
3825 3825
 
3826
-		}
3826
+        }
3827 3827
 
3828
-		$this->set_total_tax( $current );
3828
+        $this->set_total_tax( $current );
3829 3829
 
3830
-		return $current;
3830
+        return $current;
3831 3831
 
3832 3832
     }
3833 3833
 
3834 3834
     /**
3835
-	 * Recalculates the invoice fees total.
3836
-	 *
3837
-	 * @since 1.0.19
3838
-	 * @return float The recalculated fee
3839
-	 */
3840
-	public function recalculate_total_fees() {
3841
-		$fees      = $this->get_fees();
3842
-		$fee       = 0;
3843
-		$recurring = 0;
3835
+     * Recalculates the invoice fees total.
3836
+     *
3837
+     * @since 1.0.19
3838
+     * @return float The recalculated fee
3839
+     */
3840
+    public function recalculate_total_fees() {
3841
+        $fees      = $this->get_fees();
3842
+        $fee       = 0;
3843
+        $recurring = 0;
3844 3844
 
3845 3845
         foreach ( $fees as $data ) {
3846
-			$fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3847
-			$recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3848
-		}
3846
+            $fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3847
+            $recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3848
+        }
3849 3849
 
3850
-		$current = $this->is_renewal() ? $recurring : $fee;
3851
-		$this->set_total_fees( $current );
3850
+        $current = $this->is_renewal() ? $recurring : $fee;
3851
+        $this->set_total_fees( $current );
3852 3852
 
3853
-		$this->totals['fee'] = array(
3854
-			'initial'   => $fee,
3855
-			'recurring' => $recurring,
3856
-		);
3853
+        $this->totals['fee'] = array(
3854
+            'initial'   => $fee,
3855
+            'recurring' => $recurring,
3856
+        );
3857 3857
 
3858 3858
         $this->set_total_fees( $fee );
3859 3859
         return $current;
3860 3860
     }
3861 3861
 
3862 3862
     /**
3863
-	 * Recalculates the invoice total.
3864
-	 *
3865
-	 * @since 1.0.19
3863
+     * Recalculates the invoice total.
3864
+     *
3865
+     * @since 1.0.19
3866 3866
      * @return float The invoice total
3867
-	 */
3868
-	public function recalculate_total() {
3867
+     */
3868
+    public function recalculate_total() {
3869 3869
         $this->recalculate_total_fees();
3870 3870
         $this->recalculate_total_discount();
3871
-		$this->recalculate_total_tax();
3872
-		$this->recalculate_subtotal();
3873
-		$this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) );
3874
-		return $this->get_total();
3875
-	}
3876
-
3877
-	/**
3878
-	 * @deprecated
3879
-	 */
3871
+        $this->recalculate_total_tax();
3872
+        $this->recalculate_subtotal();
3873
+        $this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) );
3874
+        return $this->get_total();
3875
+    }
3876
+
3877
+    /**
3878
+     * @deprecated
3879
+     */
3880 3880
     public function recalculate_totals() {
3881 3881
         $this->recalculate_total();
3882 3882
         $this->save( true );
@@ -3890,22 +3890,22 @@  discard block
 block discarded – undo
3890 3890
         return $this->get_data();
3891 3891
     }
3892 3892
 
3893
-	/**
3893
+    /**
3894 3894
      * Adds a system note to an invoice.
3895 3895
      *
3896 3896
      * @param string $note The note being added.
3897
-	 * @return int|false The new note's ID on success, false on failure.
3897
+     * @return int|false The new note's ID on success, false on failure.
3898 3898
      *
3899 3899
      */
3900 3900
     public function add_system_note( $note ) {
3901
-		return $this->add_note( $note, false, false, true );
3902
-	}
3901
+        return $this->add_note( $note, false, false, true );
3902
+    }
3903 3903
 
3904 3904
     /**
3905 3905
      * Adds a note to an invoice.
3906 3906
      *
3907 3907
      * @param string $note The note being added.
3908
-	 * @return int|false The new note's ID on success, false on failure.
3908
+     * @return int|false The new note's ID on success, false on failure.
3909 3909
      *
3910 3910
      */
3911 3911
     public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
@@ -3915,21 +3915,21 @@  discard block
 block discarded – undo
3915 3915
             return false;
3916 3916
         }
3917 3917
 
3918
-		$author       = 'System';
3919
-		$author_email = '[email protected]';
3918
+        $author       = 'System';
3919
+        $author_email = '[email protected]';
3920 3920
 
3921
-		// If this is an admin comment or it has been added by the user.
3922
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3923
-			$user         = get_user_by( 'id', get_current_user_id() );
3921
+        // If this is an admin comment or it has been added by the user.
3922
+        if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3923
+            $user         = get_user_by( 'id', get_current_user_id() );
3924 3924
             $author       = $user->display_name;
3925 3925
             $author_email = $user->user_email;
3926
-		}
3926
+        }
3927 3927
 
3928
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3928
+        return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3929 3929
 
3930
-	}
3930
+    }
3931 3931
 
3932
-	/**
3932
+    /**
3933 3933
      * Generates a unique key for the invoice.
3934 3934
      */
3935 3935
     public function generate_key( $string = '' ) {
@@ -3949,113 +3949,113 @@  discard block
 block discarded – undo
3949 3949
             $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3950 3950
         }
3951 3951
 
3952
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3953
-
3954
-	}
3955
-
3956
-	/**
3957
-	 * Handle the status transition.
3958
-	 */
3959
-	protected function status_transition() {
3960
-		$status_transition = $this->status_transition;
3961
-
3962
-		// Reset status transition variable.
3963
-		$this->status_transition = false;
3964
-
3965
-		if ( $status_transition ) {
3966
-			try {
3967
-
3968
-				// Fire a hook for the status change.
3969
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3970
-
3971
-				// @deprecated this is deprecated and will be removed in the future.
3972
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3973
-
3974
-				if ( ! empty( $status_transition['from'] ) ) {
3975
-
3976
-					/* translators: 1: old invoice status 2: new invoice status */
3977
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) );
3978
-
3979
-					// Fire another hook.
3980
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3981
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3952
+        return wpinv_format_invoice_number( $number, $this->get_post_type() );
3982 3953
 
3983
-					// @deprecated this is deprecated and will be removed in the future.
3984
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3985
-
3986
-					// Note the transition occurred.
3987
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3988
-
3989
-					// Work out if this was for a payment, and trigger a payment_status hook instead.
3990
-					if (
3991
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'pending', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3992
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3993
-					) {
3994
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3995
-					}
3996
-
3997
-					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3998
-					if (
3999
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
4000
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'pending', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
4001
-					) {
4002
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
4003
-					}
4004
-				} else {
4005
-					/* translators: %s: new invoice status */
4006
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) );
4007
-
4008
-					// Note the transition occurred.
4009
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3954
+    }
4010 3955
 
4011
-				}
4012
-			} catch ( Exception $e ) {
4013
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
4014
-			}
4015
-		}
4016
-	}
3956
+    /**
3957
+     * Handle the status transition.
3958
+     */
3959
+    protected function status_transition() {
3960
+        $status_transition = $this->status_transition;
3961
+
3962
+        // Reset status transition variable.
3963
+        $this->status_transition = false;
3964
+
3965
+        if ( $status_transition ) {
3966
+            try {
3967
+
3968
+                // Fire a hook for the status change.
3969
+                do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3970
+
3971
+                // @deprecated this is deprecated and will be removed in the future.
3972
+                do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3973
+
3974
+                if ( ! empty( $status_transition['from'] ) ) {
3975
+
3976
+                    /* translators: 1: old invoice status 2: new invoice status */
3977
+                    $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) );
3978
+
3979
+                    // Fire another hook.
3980
+                    do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3981
+                    do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3982
+
3983
+                    // @deprecated this is deprecated and will be removed in the future.
3984
+                    do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3985
+
3986
+                    // Note the transition occurred.
3987
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3988
+
3989
+                    // Work out if this was for a payment, and trigger a payment_status hook instead.
3990
+                    if (
3991
+                        in_array( $status_transition['from'], array( 'wpi-cancelled', 'pending', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3992
+                        && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3993
+                    ) {
3994
+                        do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3995
+                    }
3996
+
3997
+                    // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3998
+                    if (
3999
+                        in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
4000
+                        && in_array( $status_transition['to'], array( 'wpi-cancelled', 'pending', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
4001
+                    ) {
4002
+                        do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
4003
+                    }
4004
+                } else {
4005
+                    /* translators: %s: new invoice status */
4006
+                    $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) );
4007
+
4008
+                    // Note the transition occurred.
4009
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
4010
+
4011
+                }
4012
+            } catch ( Exception $e ) {
4013
+                $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
4014
+            }
4015
+        }
4016
+    }
4017 4017
 
4018
-	/**
4019
-	 * Updates an invoice status.
4020
-	 */
4021
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
4018
+    /**
4019
+     * Updates an invoice status.
4020
+     */
4021
+    public function update_status( $new_status = false, $note = '', $manual = false ) {
4022 4022
 
4023
-		// Fires before updating a status.
4024
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
4023
+        // Fires before updating a status.
4024
+        do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
4025 4025
 
4026
-		// Update the status.
4027
-		$this->set_status( $new_status, $note, $manual );
4026
+        // Update the status.
4027
+        $this->set_status( $new_status, $note, $manual );
4028 4028
 
4029
-		// Save the order.
4030
-		return $this->save();
4029
+        // Save the order.
4030
+        return $this->save();
4031 4031
 
4032
-	}
4032
+    }
4033 4033
 
4034
-	/**
4035
-	 * @deprecated
4036
-	 */
4037
-	public function refresh_item_ids() {
4034
+    /**
4035
+     * @deprecated
4036
+     */
4037
+    public function refresh_item_ids() {
4038 4038
         $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) );
4039 4039
         update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
4040
-	}
4040
+    }
4041 4041
 
4042
-	/**
4043
-	 * @deprecated
4044
-	 */
4045
-	public function update_items( $temp = false ) {
4042
+    /**
4043
+     * @deprecated
4044
+     */
4045
+    public function update_items( $temp = false ) {
4046 4046
 
4047
-		$this->set_items( $this->get_items() );
4047
+        $this->set_items( $this->get_items() );
4048 4048
 
4049
-		if ( ! $temp ) {
4050
-			$this->save();
4051
-		}
4049
+        if ( ! $temp ) {
4050
+            $this->save();
4051
+        }
4052 4052
 
4053 4053
         return $this;
4054
-	}
4054
+    }
4055 4055
 
4056
-	/**
4057
-	 * @deprecated
4058
-	 */
4056
+    /**
4057
+     * @deprecated
4058
+     */
4059 4059
     public function validate_discount() {
4060 4060
 
4061 4061
         $discount_code = $this->get_discount_code();
@@ -4071,101 +4071,101 @@  discard block
 block discarded – undo
4071 4071
 
4072 4072
     }
4073 4073
 
4074
-	/**
4075
-	 * Refunds an invoice.
4076
-	 */
4074
+    /**
4075
+     * Refunds an invoice.
4076
+     */
4077 4077
     public function refund() {
4078
-		$this->set_status( 'wpi-refunded' );
4078
+        $this->set_status( 'wpi-refunded' );
4079 4079
         $this->save();
4080
-	}
4080
+    }
4081 4081
 
4082
-	/**
4083
-	 * Marks an invoice as paid.
4084
-	 *
4085
-	 * @param string $transaction_id
4086
-	 */
4082
+    /**
4083
+     * Marks an invoice as paid.
4084
+     *
4085
+     * @param string $transaction_id
4086
+     */
4087 4087
     public function mark_paid( $transaction_id = null, $note = '' ) {
4088 4088
 
4089
-		// Set the transaction id.
4090
-		if ( empty( $transaction_id ) ) {
4091
-			$transaction_id = $this->generate_key( 'trans_' );
4092
-		}
4089
+        // Set the transaction id.
4090
+        if ( empty( $transaction_id ) ) {
4091
+            $transaction_id = $this->generate_key( 'trans_' );
4092
+        }
4093 4093
 
4094
-		if ( ! $this->get_transaction_id() ) {
4095
-			$this->set_transaction_id( $transaction_id );
4096
-		}
4094
+        if ( ! $this->get_transaction_id() ) {
4095
+            $this->set_transaction_id( $transaction_id );
4096
+        }
4097 4097
 
4098
-		if ( $this->is_paid() && 'wpi-processing' !== $this->get_status() ) {
4099
-			return $this->save();
4100
-		}
4098
+        if ( $this->is_paid() && 'wpi-processing' !== $this->get_status() ) {
4099
+            return $this->save();
4100
+        }
4101 4101
 
4102
-		// Set the completed date.
4103
-		$this->set_date_completed( current_time( 'mysql' ) );
4102
+        // Set the completed date.
4103
+        $this->set_date_completed( current_time( 'mysql' ) );
4104 4104
 
4105
-		// Set the new status.
4106
-		$gateway = sanitize_text_field( $this->get_gateway_title() );
4107
-		if ( $this->is_renewal() || ! $this->is_parent() ) {
4105
+        // Set the new status.
4106
+        $gateway = sanitize_text_field( $this->get_gateway_title() );
4107
+        if ( $this->is_renewal() || ! $this->is_parent() ) {
4108 4108
 
4109
-			$_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
4110
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
4109
+            $_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
4110
+            $_note = $_note . empty( $note ) ? '' : " ($note)";
4111 4111
 
4112
-			if ( 'none' == $this->get_gateway() ) {
4113
-				$_note = $note;
4114
-			}
4112
+            if ( 'none' == $this->get_gateway() ) {
4113
+                $_note = $note;
4114
+            }
4115 4115
 
4116
-			$this->set_status( 'wpi-renewal', $_note );
4116
+            $this->set_status( 'wpi-renewal', $_note );
4117 4117
 
4118
-		} else {
4118
+        } else {
4119 4119
 
4120
-			$_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
4121
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
4120
+            $_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
4121
+            $_note = $_note . empty( $note ) ? '' : " ($note)";
4122 4122
 
4123
-			if ( 'none' == $this->get_gateway() ) {
4124
-				$_note = $note;
4125
-			}
4123
+            if ( 'none' == $this->get_gateway() ) {
4124
+                $_note = $note;
4125
+            }
4126 4126
 
4127
-			$this->set_status( 'publish', $_note );
4127
+            $this->set_status( 'publish', $_note );
4128 4128
 
4129
-		}
4129
+        }
4130 4130
 
4131
-		// Set checkout mode.
4132
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
4133
-		$this->set_mode( $mode );
4131
+        // Set checkout mode.
4132
+        $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
4133
+        $this->set_mode( $mode );
4134 4134
 
4135
-		// Save the invoice.
4135
+        // Save the invoice.
4136 4136
         $this->save();
4137
-	}
4138
-
4139
-	/**
4140
-	 * Save data to the database.
4141
-	 *
4142
-	 * @since 1.0.19
4143
-	 * @return int invoice ID
4144
-	 */
4145
-	public function save() {
4146
-		$this->maybe_set_date_paid();
4147
-		$this->maybe_set_key();
4148
-		parent::save();
4149
-		$this->clear_cache();
4150
-		$this->status_transition();
4151
-		return $this->get_id();
4152
-	}
4153
-
4154
-	/**
4137
+    }
4138
+
4139
+    /**
4140
+     * Save data to the database.
4141
+     *
4142
+     * @since 1.0.19
4143
+     * @return int invoice ID
4144
+     */
4145
+    public function save() {
4146
+        $this->maybe_set_date_paid();
4147
+        $this->maybe_set_key();
4148
+        parent::save();
4149
+        $this->clear_cache();
4150
+        $this->status_transition();
4151
+        return $this->get_id();
4152
+    }
4153
+
4154
+    /**
4155 4155
      * Clears the subscription's cache.
4156 4156
      */
4157 4157
     public function clear_cache() {
4158
-		if ( $this->get_key() ) {
4159
-			wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
4160
-		}
4161
-
4162
-		if ( $this->get_number() ) {
4163
-			wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
4164
-		}
4165
-
4166
-		if ( $this->get_transaction_id() ) {
4167
-			wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
4168
-		}
4169
-	}
4158
+        if ( $this->get_key() ) {
4159
+            wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
4160
+        }
4161
+
4162
+        if ( $this->get_number() ) {
4163
+            wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
4164
+        }
4165
+
4166
+        if ( $this->get_transaction_id() ) {
4167
+            wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
4168
+        }
4169
+    }
4170 4170
 
4171 4171
 }
Please login to merge, or discard this patch.
Spacing   +854 added lines, -854 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Invoice class.
@@ -147,39 +147,39 @@  discard block
 block discarded – undo
147 147
 	 *
148 148
 	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
149 149
 	 */
150
-    public function __construct( $invoice = 0 ) {
150
+    public function __construct($invoice = 0) {
151 151
 
152
-        parent::__construct( $invoice );
152
+        parent::__construct($invoice);
153 153
 
154
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
155
-			$this->set_id( (int) $invoice );
156
-		} elseif ( $invoice instanceof self ) {
157
-			$this->set_id( $invoice->get_id() );
158
-		} elseif ( ! empty( $invoice->ID ) ) {
159
-			$this->set_id( $invoice->ID );
160
-		} elseif ( is_array( $invoice ) ) {
161
-			$this->set_props( $invoice );
154
+		if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type((int) $invoice))) {
155
+			$this->set_id((int) $invoice);
156
+		} elseif ($invoice instanceof self) {
157
+			$this->set_id($invoice->get_id());
158
+		} elseif (!empty($invoice->ID)) {
159
+			$this->set_id($invoice->ID);
160
+		} elseif (is_array($invoice)) {
161
+			$this->set_props($invoice);
162 162
 
163
-			if ( isset( $invoice['ID'] ) ) {
164
-				$this->set_id( $invoice['ID'] );
163
+			if (isset($invoice['ID'])) {
164
+				$this->set_id($invoice['ID']);
165 165
 			}
166
-} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
167
-			$this->set_id( $invoice_id );
168
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
169
-			$this->set_id( $invoice_id );
170
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
171
-			$this->set_id( $invoice_id );
166
+} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) {
167
+			$this->set_id($invoice_id);
168
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) {
169
+			$this->set_id($invoice_id);
170
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) {
171
+			$this->set_id($invoice_id);
172 172
 		} else {
173
-			$this->set_object_read( true );
173
+			$this->set_object_read(true);
174 174
 		}
175 175
 
176 176
         // Load the datastore.
177
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
177
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
178 178
 
179
-		if ( $this->get_id() > 0 ) {
180
-            $this->post = get_post( $this->get_id() );
179
+		if ($this->get_id() > 0) {
180
+            $this->post = get_post($this->get_id());
181 181
             $this->ID   = $this->get_id();
182
-			$this->data_store->read( $this );
182
+			$this->data_store->read($this);
183 183
         }
184 184
 
185 185
     }
@@ -194,39 +194,39 @@  discard block
 block discarded – undo
194 194
 	 * @since 1.0.15
195 195
 	 * @return int
196 196
 	 */
197
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
197
+	public static function get_invoice_id_by_field($value, $field = 'key') {
198 198
         global $wpdb;
199 199
 
200 200
 		// Trim the value.
201
-		$value = trim( $value );
201
+		$value = trim($value);
202 202
 
203
-		if ( empty( $value ) ) {
203
+		if (empty($value)) {
204 204
 			return 0;
205 205
 		}
206 206
 
207 207
         // Valid fields.
208
-        $fields = array( 'key', 'number', 'transaction_id' );
208
+        $fields = array('key', 'number', 'transaction_id');
209 209
 
210 210
 		// Ensure a field has been passed.
211
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
211
+		if (empty($field) || !in_array($field, $fields)) {
212 212
 			return 0;
213 213
 		}
214 214
 
215 215
 		// Maybe retrieve from the cache.
216
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
217
-		if ( false !== $invoice_id ) {
216
+		$invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids");
217
+		if (false !== $invoice_id) {
218 218
 			return $invoice_id;
219 219
 		}
220 220
 
221 221
         // Fetch from the db.
222 222
         $table       = $wpdb->prefix . 'getpaid_invoices';
223
-		$db_field    = 'key' === $field ? 'invoice_key' : $field;
223
+		$db_field = 'key' === $field ? 'invoice_key' : $field;
224 224
         $invoice_id  = (int) $wpdb->get_var(
225
-            $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$db_field`=%s LIMIT 1", $value )
225
+            $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$db_field`=%s LIMIT 1", $value)
226 226
         );
227 227
 
228 228
 		// Update the cache with our data
229
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
229
+		wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids");
230 230
 
231 231
 		return $invoice_id;
232 232
     }
@@ -234,8 +234,8 @@  discard block
 block discarded – undo
234 234
     /**
235 235
      * Checks if an invoice key is set.
236 236
      */
237
-    public function _isset( $key ) {
238
-        return isset( $this->data[ $key ] ) || method_exists( $this, "get_$key" );
237
+    public function _isset($key) {
238
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
239 239
     }
240 240
 
241 241
     /*
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
 	 * @param  string $context View or edit context.
261 261
 	 * @return int
262 262
 	 */
263
-	public function get_parent_id( $context = 'view' ) {
264
-		return (int) $this->get_prop( 'parent_id', $context );
263
+	public function get_parent_id($context = 'view') {
264
+		return (int) $this->get_prop('parent_id', $context);
265 265
     }
266 266
 
267 267
     /**
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 * @return WPInv_Invoice
272 272
 	 */
273 273
     public function get_parent_payment() {
274
-        return new WPInv_Invoice( $this->get_parent_id() );
274
+        return new WPInv_Invoice($this->get_parent_id());
275 275
     }
276 276
 
277 277
     /**
@@ -291,8 +291,8 @@  discard block
 block discarded – undo
291 291
 	 * @param  string $context View or edit context.
292 292
 	 * @return string
293 293
 	 */
294
-	public function get_status( $context = 'view' ) {
295
-		return $this->get_prop( 'status', $context );
294
+	public function get_status($context = 'view') {
295
+		return $this->get_prop('status', $context);
296 296
 	}
297 297
 
298 298
 	/**
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 	 * @return array
303 303
 	 */
304 304
 	public function get_all_statuses() {
305
-		return wpinv_get_invoice_statuses( true, true, $this );
305
+		return wpinv_get_invoice_statuses(true, true, $this);
306 306
     }
307 307
 
308 308
     /**
@@ -314,9 +314,9 @@  discard block
 block discarded – undo
314 314
     public function get_status_nicename() {
315 315
 		$statuses = $this->get_all_statuses();
316 316
 
317
-        $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
317
+        $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status();
318 318
 
319
-        return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
319
+        return apply_filters('wpinv_get_invoice_status_nicename', $status, $this);
320 320
     }
321 321
 
322 322
 	/**
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 	 */
328 328
 	public function get_status_class() {
329 329
 		$statuses = getpaid_get_invoice_status_classes();
330
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'bg-dark text-white';
330
+		return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'bg-dark text-white';
331 331
 	}
332 332
 
333 333
 	/**
@@ -338,9 +338,9 @@  discard block
 block discarded – undo
338 338
      */
339 339
     public function get_status_label_html() {
340 340
 
341
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
342
-		$status       = sanitize_html_class( $this->get_status() );
343
-		$class        = esc_attr( $this->get_status_class() );
341
+		$status_label = sanitize_text_field($this->get_status_nicename());
342
+		$status       = sanitize_html_class($this->get_status());
343
+		$class        = esc_attr($this->get_status_class());
344 344
 
345 345
 		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
346 346
 	}
@@ -352,23 +352,23 @@  discard block
 block discarded – undo
352 352
 	 * @param  string $context View or edit context.
353 353
 	 * @return string
354 354
 	 */
355
-	public function get_version( $context = 'view' ) {
356
-		return $this->get_prop( 'version', $context );
355
+	public function get_version($context = 'view') {
356
+		return $this->get_prop('version', $context);
357 357
 	}
358 358
 
359 359
 	/**
360 360
 	 * @deprecated
361 361
 	 */
362
-	public function get_invoice_date( $format = true ) {
363
-		$date      = getpaid_format_date( $this->get_date_completed() );
364
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
365
-		$formatted = getpaid_format_date( $date );
362
+	public function get_invoice_date($format = true) {
363
+		$date      = getpaid_format_date($this->get_date_completed());
364
+		$date      = empty($date) ? $this->get_date_created() : $this->get_date_completed();
365
+		$formatted = getpaid_format_date($date);
366 366
 
367
-		if ( $format ) {
367
+		if ($format) {
368 368
 			return $formatted;
369 369
 		}
370 370
 
371
-		return empty( $formatted ) ? '' : $date;
371
+		return empty($formatted) ? '' : $date;
372 372
 
373 373
     }
374 374
 
@@ -379,8 +379,8 @@  discard block
 block discarded – undo
379 379
 	 * @param  string $context View or edit context.
380 380
 	 * @return string
381 381
 	 */
382
-	public function get_date_created( $context = 'view' ) {
383
-		return $this->get_prop( 'date_created', $context );
382
+	public function get_date_created($context = 'view') {
383
+		return $this->get_prop('date_created', $context);
384 384
 	}
385 385
 
386 386
 	/**
@@ -390,8 +390,8 @@  discard block
 block discarded – undo
390 390
 	 * @param  string $context View or edit context.
391 391
 	 * @return string
392 392
 	 */
393
-	public function get_created_date( $context = 'view' ) {
394
-		return $this->get_date_created( $context );
393
+	public function get_created_date($context = 'view') {
394
+		return $this->get_date_created($context);
395 395
     }
396 396
 
397 397
     /**
@@ -401,11 +401,11 @@  discard block
 block discarded – undo
401 401
 	 * @param  string $context View or edit context.
402 402
 	 * @return string
403 403
 	 */
404
-	public function get_date_created_gmt( $context = 'view' ) {
405
-        $date = $this->get_date_created( $context );
404
+	public function get_date_created_gmt($context = 'view') {
405
+        $date = $this->get_date_created($context);
406 406
 
407
-        if ( $date ) {
408
-            $date = get_gmt_from_date( $date );
407
+        if ($date) {
408
+            $date = get_gmt_from_date($date);
409 409
         }
410 410
 		return $date;
411 411
     }
@@ -417,8 +417,8 @@  discard block
 block discarded – undo
417 417
 	 * @param  string $context View or edit context.
418 418
 	 * @return string
419 419
 	 */
420
-	public function get_date_modified( $context = 'view' ) {
421
-		return $this->get_prop( 'date_modified', $context );
420
+	public function get_date_modified($context = 'view') {
421
+		return $this->get_prop('date_modified', $context);
422 422
 	}
423 423
 
424 424
 	/**
@@ -428,8 +428,8 @@  discard block
 block discarded – undo
428 428
 	 * @param  string $context View or edit context.
429 429
 	 * @return string
430 430
 	 */
431
-	public function get_modified_date( $context = 'view' ) {
432
-		return $this->get_date_modified( $context );
431
+	public function get_modified_date($context = 'view') {
432
+		return $this->get_date_modified($context);
433 433
     }
434 434
 
435 435
     /**
@@ -439,11 +439,11 @@  discard block
 block discarded – undo
439 439
 	 * @param  string $context View or edit context.
440 440
 	 * @return string
441 441
 	 */
442
-	public function get_date_modified_gmt( $context = 'view' ) {
443
-        $date = $this->get_date_modified( $context );
442
+	public function get_date_modified_gmt($context = 'view') {
443
+        $date = $this->get_date_modified($context);
444 444
 
445
-        if ( $date ) {
446
-            $date = get_gmt_from_date( $date );
445
+        if ($date) {
446
+            $date = get_gmt_from_date($date);
447 447
         }
448 448
 		return $date;
449 449
     }
@@ -455,8 +455,8 @@  discard block
 block discarded – undo
455 455
 	 * @param  string $context View or edit context.
456 456
 	 * @return string
457 457
 	 */
458
-	public function get_due_date( $context = 'view' ) {
459
-		return $this->get_prop( 'due_date', $context );
458
+	public function get_due_date($context = 'view') {
459
+		return $this->get_prop('due_date', $context);
460 460
     }
461 461
 
462 462
     /**
@@ -466,8 +466,8 @@  discard block
 block discarded – undo
466 466
 	 * @param  string $context View or edit context.
467 467
 	 * @return string
468 468
 	 */
469
-	public function get_date_due( $context = 'view' ) {
470
-		return $this->get_due_date( $context );
469
+	public function get_date_due($context = 'view') {
470
+		return $this->get_due_date($context);
471 471
     }
472 472
 
473 473
     /**
@@ -477,11 +477,11 @@  discard block
 block discarded – undo
477 477
 	 * @param  string $context View or edit context.
478 478
 	 * @return string
479 479
 	 */
480
-	public function get_due_date_gmt( $context = 'view' ) {
481
-        $date = $this->get_due_date( $context );
480
+	public function get_due_date_gmt($context = 'view') {
481
+        $date = $this->get_due_date($context);
482 482
 
483
-        if ( $date ) {
484
-            $date = get_gmt_from_date( $date );
483
+        if ($date) {
484
+            $date = get_gmt_from_date($date);
485 485
         }
486 486
 		return $date;
487 487
     }
@@ -493,8 +493,8 @@  discard block
 block discarded – undo
493 493
 	 * @param  string $context View or edit context.
494 494
 	 * @return string
495 495
 	 */
496
-	public function get_gmt_date_due( $context = 'view' ) {
497
-		return $this->get_due_date_gmt( $context );
496
+	public function get_gmt_date_due($context = 'view') {
497
+		return $this->get_due_date_gmt($context);
498 498
     }
499 499
 
500 500
     /**
@@ -504,8 +504,8 @@  discard block
 block discarded – undo
504 504
 	 * @param  string $context View or edit context.
505 505
 	 * @return string
506 506
 	 */
507
-	public function get_completed_date( $context = 'view' ) {
508
-		return $this->get_prop( 'completed_date', $context );
507
+	public function get_completed_date($context = 'view') {
508
+		return $this->get_prop('completed_date', $context);
509 509
     }
510 510
 
511 511
     /**
@@ -515,8 +515,8 @@  discard block
 block discarded – undo
515 515
 	 * @param  string $context View or edit context.
516 516
 	 * @return string
517 517
 	 */
518
-	public function get_date_completed( $context = 'view' ) {
519
-		return $this->get_completed_date( $context );
518
+	public function get_date_completed($context = 'view') {
519
+		return $this->get_completed_date($context);
520 520
     }
521 521
 
522 522
     /**
@@ -526,11 +526,11 @@  discard block
 block discarded – undo
526 526
 	 * @param  string $context View or edit context.
527 527
 	 * @return string
528 528
 	 */
529
-	public function get_completed_date_gmt( $context = 'view' ) {
530
-        $date = $this->get_completed_date( $context );
529
+	public function get_completed_date_gmt($context = 'view') {
530
+        $date = $this->get_completed_date($context);
531 531
 
532
-        if ( $date ) {
533
-            $date = get_gmt_from_date( $date );
532
+        if ($date) {
533
+            $date = get_gmt_from_date($date);
534 534
         }
535 535
 		return $date;
536 536
     }
@@ -542,8 +542,8 @@  discard block
 block discarded – undo
542 542
 	 * @param  string $context View or edit context.
543 543
 	 * @return string
544 544
 	 */
545
-	public function get_gmt_completed_date( $context = 'view' ) {
546
-		return $this->get_completed_date_gmt( $context );
545
+	public function get_gmt_completed_date($context = 'view') {
546
+		return $this->get_completed_date_gmt($context);
547 547
     }
548 548
 
549 549
     /**
@@ -553,12 +553,12 @@  discard block
 block discarded – undo
553 553
 	 * @param  string $context View or edit context.
554 554
 	 * @return string
555 555
 	 */
556
-	public function get_number( $context = 'view' ) {
557
-		$number = $this->get_prop( 'number', $context );
556
+	public function get_number($context = 'view') {
557
+		$number = $this->get_prop('number', $context);
558 558
 
559
-		if ( empty( $number ) ) {
559
+		if (empty($number)) {
560 560
 			$number = $this->generate_number();
561
-			$this->set_number( $this->generate_number() );
561
+			$this->set_number($this->generate_number());
562 562
 		}
563 563
 
564 564
 		return $number;
@@ -572,8 +572,8 @@  discard block
 block discarded – undo
572 572
 	public function maybe_set_number() {
573 573
         $number = $this->get_number();
574 574
 
575
-        if ( empty( $number ) || $this->get_id() == $number ) {
576
-			$this->set_number( $this->generate_number() );
575
+        if (empty($number) || $this->get_id() == $number) {
576
+			$this->set_number($this->generate_number());
577 577
         }
578 578
 
579 579
 	}
@@ -585,8 +585,8 @@  discard block
 block discarded – undo
585 585
 	 * @param  string $context View or edit context.
586 586
 	 * @return string
587 587
 	 */
588
-	public function get_key( $context = 'view' ) {
589
-        return $this->get_prop( 'key', $context );
588
+	public function get_key($context = 'view') {
589
+        return $this->get_prop('key', $context);
590 590
 	}
591 591
 
592 592
 	/**
@@ -597,9 +597,9 @@  discard block
 block discarded – undo
597 597
 	public function maybe_set_key() {
598 598
         $key = $this->get_key();
599 599
 
600
-        if ( empty( $key ) ) {
601
-            $key = $this->generate_key( $this->get_type() . '_' );
602
-            $this->set_key( $key );
600
+        if (empty($key)) {
601
+            $key = $this->generate_key($this->get_type() . '_');
602
+            $this->set_key($key);
603 603
         }
604 604
 
605 605
     }
@@ -611,8 +611,8 @@  discard block
 block discarded – undo
611 611
 	 * @param  string $context View or edit context.
612 612
 	 * @return string
613 613
 	 */
614
-	public function get_type( $context = 'view' ) {
615
-        return $this->get_prop( 'type', $context );
614
+	public function get_type($context = 'view') {
615
+        return $this->get_prop('type', $context);
616 616
 	}
617 617
 
618 618
 	/**
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 	 * @return string
623 623
 	 */
624 624
 	public function get_invoice_quote_type() {
625
-        return getpaid_get_post_type_label( $this->get_post_type(), false );
625
+        return getpaid_get_post_type_label($this->get_post_type(), false);
626 626
     }
627 627
 
628 628
     /**
@@ -632,8 +632,8 @@  discard block
 block discarded – undo
632 632
 	 * @param  string $context View or edit context.
633 633
 	 * @return string
634 634
 	 */
635
-	public function get_label( $context = 'view' ) {
636
-        return getpaid_get_post_type_label( $this->get_post_type( $context ), false );
635
+	public function get_label($context = 'view') {
636
+        return getpaid_get_post_type_label($this->get_post_type($context), false);
637 637
 	}
638 638
 
639 639
 	/**
@@ -643,8 +643,8 @@  discard block
 block discarded – undo
643 643
 	 * @param  string $context View or edit context.
644 644
 	 * @return string
645 645
 	 */
646
-	public function get_post_type( $context = 'view' ) {
647
-        return $this->get_prop( 'post_type', $context );
646
+	public function get_post_type($context = 'view') {
647
+        return $this->get_prop('post_type', $context);
648 648
     }
649 649
 
650 650
     /**
@@ -654,8 +654,8 @@  discard block
 block discarded – undo
654 654
 	 * @param  string $context View or edit context.
655 655
 	 * @return string
656 656
 	 */
657
-	public function get_mode( $context = 'view' ) {
658
-        return $this->get_prop( 'mode', $context );
657
+	public function get_mode($context = 'view') {
658
+        return $this->get_prop('mode', $context);
659 659
     }
660 660
 
661 661
     /**
@@ -665,13 +665,13 @@  discard block
 block discarded – undo
665 665
 	 * @param  string $context View or edit context.
666 666
 	 * @return string
667 667
 	 */
668
-	public function get_path( $context = 'view' ) {
669
-        $path   = $this->get_prop( 'path', $context );
668
+	public function get_path($context = 'view') {
669
+        $path = $this->get_prop('path', $context);
670 670
 		$prefix = $this->get_type();
671 671
 
672
-		if ( 0 !== strpos( $path, $prefix ) ) {
673
-			$path = sanitize_title( $prefix . '-' . $this->get_id() );
674
-			$this->set_path( $path );
672
+		if (0 !== strpos($path, $prefix)) {
673
+			$path = sanitize_title($prefix . '-' . $this->get_id());
674
+			$this->set_path($path);
675 675
 		}
676 676
 
677 677
 		return $path;
@@ -684,8 +684,8 @@  discard block
 block discarded – undo
684 684
 	 * @param  string $context View or edit context.
685 685
 	 * @return string
686 686
 	 */
687
-	public function get_name( $context = 'view' ) {
688
-        return $this->get_prop( 'title', $context );
687
+	public function get_name($context = 'view') {
688
+        return $this->get_prop('title', $context);
689 689
     }
690 690
 
691 691
     /**
@@ -695,8 +695,8 @@  discard block
 block discarded – undo
695 695
 	 * @param  string $context View or edit context.
696 696
 	 * @return string
697 697
 	 */
698
-	public function get_title( $context = 'view' ) {
699
-		return $this->get_name( $context );
698
+	public function get_title($context = 'view') {
699
+		return $this->get_name($context);
700 700
     }
701 701
 
702 702
     /**
@@ -706,8 +706,8 @@  discard block
 block discarded – undo
706 706
 	 * @param  string $context View or edit context.
707 707
 	 * @return string
708 708
 	 */
709
-	public function get_description( $context = 'view' ) {
710
-		return $this->get_prop( 'description', $context );
709
+	public function get_description($context = 'view') {
710
+		return $this->get_prop('description', $context);
711 711
     }
712 712
 
713 713
     /**
@@ -717,8 +717,8 @@  discard block
 block discarded – undo
717 717
 	 * @param  string $context View or edit context.
718 718
 	 * @return string
719 719
 	 */
720
-	public function get_excerpt( $context = 'view' ) {
721
-		return $this->get_description( $context );
720
+	public function get_excerpt($context = 'view') {
721
+		return $this->get_description($context);
722 722
     }
723 723
 
724 724
     /**
@@ -728,8 +728,8 @@  discard block
 block discarded – undo
728 728
 	 * @param  string $context View or edit context.
729 729
 	 * @return string
730 730
 	 */
731
-	public function get_summary( $context = 'view' ) {
732
-		return $this->get_description( $context );
731
+	public function get_summary($context = 'view') {
732
+		return $this->get_description($context);
733 733
     }
734 734
 
735 735
     /**
@@ -739,26 +739,26 @@  discard block
 block discarded – undo
739 739
      * @param  string $context View or edit context.
740 740
 	 * @return array
741 741
 	 */
742
-    public function get_user_info( $context = 'view' ) {
742
+    public function get_user_info($context = 'view') {
743 743
 
744 744
         $user_info = array(
745
-            'user_id'    => $this->get_user_id( $context ),
746
-            'email'      => $this->get_email( $context ),
747
-            'first_name' => $this->get_first_name( $context ),
748
-            'last_name'  => $this->get_last_name( $context ),
749
-            'address'    => $this->get_address( $context ),
750
-            'phone'      => $this->get_phone( $context ),
751
-            'city'       => $this->get_city( $context ),
752
-            'country'    => $this->get_country( $context ),
753
-            'state'      => $this->get_state( $context ),
754
-            'zip'        => $this->get_zip( $context ),
755
-            'company'    => $this->get_company( $context ),
756
-			'company_id' => $this->get_company_id( $context ),
757
-            'vat_number' => $this->get_vat_number( $context ),
758
-            'discount'   => $this->get_discount_code( $context ),
745
+            'user_id'    => $this->get_user_id($context),
746
+            'email'      => $this->get_email($context),
747
+            'first_name' => $this->get_first_name($context),
748
+            'last_name'  => $this->get_last_name($context),
749
+            'address'    => $this->get_address($context),
750
+            'phone'      => $this->get_phone($context),
751
+            'city'       => $this->get_city($context),
752
+            'country'    => $this->get_country($context),
753
+            'state'      => $this->get_state($context),
754
+            'zip'        => $this->get_zip($context),
755
+            'company'    => $this->get_company($context),
756
+			'company_id' => $this->get_company_id($context),
757
+            'vat_number' => $this->get_vat_number($context),
758
+            'discount'   => $this->get_discount_code($context),
759 759
 		);
760 760
 
761
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
761
+		return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this);
762 762
 
763 763
     }
764 764
 
@@ -769,8 +769,8 @@  discard block
 block discarded – undo
769 769
 	 * @param  string $context View or edit context.
770 770
 	 * @return int
771 771
 	 */
772
-	public function get_author( $context = 'view' ) {
773
-		return (int) $this->get_prop( 'author', $context );
772
+	public function get_author($context = 'view') {
773
+		return (int) $this->get_prop('author', $context);
774 774
     }
775 775
 
776 776
     /**
@@ -780,8 +780,8 @@  discard block
 block discarded – undo
780 780
 	 * @param  string $context View or edit context.
781 781
 	 * @return int
782 782
 	 */
783
-	public function get_user_id( $context = 'view' ) {
784
-		return $this->get_author( $context );
783
+	public function get_user_id($context = 'view') {
784
+		return $this->get_author($context);
785 785
     }
786 786
 
787 787
      /**
@@ -791,8 +791,8 @@  discard block
 block discarded – undo
791 791
 	 * @param  string $context View or edit context.
792 792
 	 * @return int
793 793
 	 */
794
-	public function get_customer_id( $context = 'view' ) {
795
-		return (int) $this->get_prop( 'customer_id', $context );
794
+	public function get_customer_id($context = 'view') {
795
+		return (int) $this->get_prop('customer_id', $context);
796 796
     }
797 797
 
798 798
     /**
@@ -802,8 +802,8 @@  discard block
 block discarded – undo
802 802
 	 * @param  string $context View or edit context.
803 803
 	 * @return string
804 804
 	 */
805
-	public function get_ip( $context = 'view' ) {
806
-		return $this->get_prop( 'user_ip', $context );
805
+	public function get_ip($context = 'view') {
806
+		return $this->get_prop('user_ip', $context);
807 807
     }
808 808
 
809 809
     /**
@@ -813,8 +813,8 @@  discard block
 block discarded – undo
813 813
 	 * @param  string $context View or edit context.
814 814
 	 * @return string
815 815
 	 */
816
-	public function get_user_ip( $context = 'view' ) {
817
-		return $this->get_ip( $context );
816
+	public function get_user_ip($context = 'view') {
817
+		return $this->get_ip($context);
818 818
     }
819 819
 
820 820
      /**
@@ -824,8 +824,8 @@  discard block
 block discarded – undo
824 824
 	 * @param  string $context View or edit context.
825 825
 	 * @return string
826 826
 	 */
827
-	public function get_customer_ip( $context = 'view' ) {
828
-		return $this->get_ip( $context );
827
+	public function get_customer_ip($context = 'view') {
828
+		return $this->get_ip($context);
829 829
     }
830 830
 
831 831
     /**
@@ -835,8 +835,8 @@  discard block
 block discarded – undo
835 835
 	 * @param  string $context View or edit context.
836 836
 	 * @return string
837 837
 	 */
838
-	public function get_first_name( $context = 'view' ) {
839
-		return $this->get_prop( 'first_name', $context );
838
+	public function get_first_name($context = 'view') {
839
+		return $this->get_prop('first_name', $context);
840 840
     }
841 841
 
842 842
     /**
@@ -846,8 +846,8 @@  discard block
 block discarded – undo
846 846
 	 * @param  string $context View or edit context.
847 847
 	 * @return string
848 848
 	 */
849
-	public function get_user_first_name( $context = 'view' ) {
850
-		return $this->get_first_name( $context );
849
+	public function get_user_first_name($context = 'view') {
850
+		return $this->get_first_name($context);
851 851
     }
852 852
 
853 853
      /**
@@ -857,8 +857,8 @@  discard block
 block discarded – undo
857 857
 	 * @param  string $context View or edit context.
858 858
 	 * @return string
859 859
 	 */
860
-	public function get_customer_first_name( $context = 'view' ) {
861
-		return $this->get_first_name( $context );
860
+	public function get_customer_first_name($context = 'view') {
861
+		return $this->get_first_name($context);
862 862
     }
863 863
 
864 864
     /**
@@ -868,8 +868,8 @@  discard block
 block discarded – undo
868 868
 	 * @param  string $context View or edit context.
869 869
 	 * @return string
870 870
 	 */
871
-	public function get_last_name( $context = 'view' ) {
872
-		return $this->get_prop( 'last_name', $context );
871
+	public function get_last_name($context = 'view') {
872
+		return $this->get_prop('last_name', $context);
873 873
     }
874 874
 
875 875
     /**
@@ -879,8 +879,8 @@  discard block
 block discarded – undo
879 879
 	 * @param  string $context View or edit context.
880 880
 	 * @return string
881 881
 	 */
882
-	public function get_user_last_name( $context = 'view' ) {
883
-		return $this->get_last_name( $context );
882
+	public function get_user_last_name($context = 'view') {
883
+		return $this->get_last_name($context);
884 884
     }
885 885
 
886 886
     /**
@@ -890,8 +890,8 @@  discard block
 block discarded – undo
890 890
 	 * @param  string $context View or edit context.
891 891
 	 * @return string
892 892
 	 */
893
-	public function get_customer_last_name( $context = 'view' ) {
894
-		return $this->get_last_name( $context );
893
+	public function get_customer_last_name($context = 'view') {
894
+		return $this->get_last_name($context);
895 895
     }
896 896
 
897 897
     /**
@@ -901,22 +901,22 @@  discard block
 block discarded – undo
901 901
 	 * @param  string $context View or edit context.
902 902
 	 * @return string
903 903
 	 */
904
-	public function get_full_name( $context = 'view' ) {
905
-		$name = trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
904
+	public function get_full_name($context = 'view') {
905
+		$name = trim($this->get_first_name($context) . ' ' . $this->get_last_name($context));
906 906
 
907
-		if ( ! $name ) {
908
-			$user = get_userdata( $this->get_author( $context ) );
907
+		if (!$name) {
908
+			$user = get_userdata($this->get_author($context));
909 909
 
910
-			if ( $user ) {
910
+			if ($user) {
911 911
 				$name = $user->display_name;
912 912
 			}
913 913
 		}
914 914
 
915
-		if ( ! $name ) {
916
-			$name = $this->get_email( $context );
915
+		if (!$name) {
916
+			$name = $this->get_email($context);
917 917
 		}
918 918
 
919
-		return apply_filters( 'wpinv_invoice_user_full_name', $name, $this );
919
+		return apply_filters('wpinv_invoice_user_full_name', $name, $this);
920 920
     }
921 921
 
922 922
     /**
@@ -926,8 +926,8 @@  discard block
 block discarded – undo
926 926
 	 * @param  string $context View or edit context.
927 927
 	 * @return string
928 928
 	 */
929
-	public function get_user_full_name( $context = 'view' ) {
930
-		return $this->get_full_name( $context );
929
+	public function get_user_full_name($context = 'view') {
930
+		return $this->get_full_name($context);
931 931
     }
932 932
 
933 933
     /**
@@ -937,8 +937,8 @@  discard block
 block discarded – undo
937 937
 	 * @param  string $context View or edit context.
938 938
 	 * @return string
939 939
 	 */
940
-	public function get_customer_full_name( $context = 'view' ) {
941
-		return $this->get_full_name( $context );
940
+	public function get_customer_full_name($context = 'view') {
941
+		return $this->get_full_name($context);
942 942
     }
943 943
 
944 944
     /**
@@ -948,8 +948,8 @@  discard block
 block discarded – undo
948 948
 	 * @param  string $context View or edit context.
949 949
 	 * @return string
950 950
 	 */
951
-	public function get_phone( $context = 'view' ) {
952
-		return $this->get_prop( 'phone', $context );
951
+	public function get_phone($context = 'view') {
952
+		return $this->get_prop('phone', $context);
953 953
     }
954 954
 
955 955
     /**
@@ -959,8 +959,8 @@  discard block
 block discarded – undo
959 959
 	 * @param  string $context View or edit context.
960 960
 	 * @return string
961 961
 	 */
962
-	public function get_phone_number( $context = 'view' ) {
963
-		return $this->get_phone( $context );
962
+	public function get_phone_number($context = 'view') {
963
+		return $this->get_phone($context);
964 964
     }
965 965
 
966 966
     /**
@@ -970,8 +970,8 @@  discard block
 block discarded – undo
970 970
 	 * @param  string $context View or edit context.
971 971
 	 * @return string
972 972
 	 */
973
-	public function get_user_phone( $context = 'view' ) {
974
-		return $this->get_phone( $context );
973
+	public function get_user_phone($context = 'view') {
974
+		return $this->get_phone($context);
975 975
     }
976 976
 
977 977
     /**
@@ -981,8 +981,8 @@  discard block
 block discarded – undo
981 981
 	 * @param  string $context View or edit context.
982 982
 	 * @return string
983 983
 	 */
984
-	public function get_customer_phone( $context = 'view' ) {
985
-		return $this->get_phone( $context );
984
+	public function get_customer_phone($context = 'view') {
985
+		return $this->get_phone($context);
986 986
     }
987 987
 
988 988
     /**
@@ -992,8 +992,8 @@  discard block
 block discarded – undo
992 992
 	 * @param  string $context View or edit context.
993 993
 	 * @return string
994 994
 	 */
995
-	public function get_email( $context = 'view' ) {
996
-		return $this->get_prop( 'email', $context );
995
+	public function get_email($context = 'view') {
996
+		return $this->get_prop('email', $context);
997 997
     }
998 998
 
999 999
     /**
@@ -1003,8 +1003,8 @@  discard block
 block discarded – undo
1003 1003
 	 * @param  string $context View or edit context.
1004 1004
 	 * @return string
1005 1005
 	 */
1006
-	public function get_email_address( $context = 'view' ) {
1007
-		return $this->get_email( $context );
1006
+	public function get_email_address($context = 'view') {
1007
+		return $this->get_email($context);
1008 1008
     }
1009 1009
 
1010 1010
     /**
@@ -1014,8 +1014,8 @@  discard block
 block discarded – undo
1014 1014
 	 * @param  string $context View or edit context.
1015 1015
 	 * @return string
1016 1016
 	 */
1017
-	public function get_user_email( $context = 'view' ) {
1018
-		return $this->get_email( $context );
1017
+	public function get_user_email($context = 'view') {
1018
+		return $this->get_email($context);
1019 1019
     }
1020 1020
 
1021 1021
     /**
@@ -1025,8 +1025,8 @@  discard block
 block discarded – undo
1025 1025
 	 * @param  string $context View or edit context.
1026 1026
 	 * @return string
1027 1027
 	 */
1028
-	public function get_customer_email( $context = 'view' ) {
1029
-		return $this->get_email( $context );
1028
+	public function get_customer_email($context = 'view') {
1029
+		return $this->get_email($context);
1030 1030
     }
1031 1031
 
1032 1032
     /**
@@ -1036,9 +1036,9 @@  discard block
 block discarded – undo
1036 1036
 	 * @param  string $context View or edit context.
1037 1037
 	 * @return string
1038 1038
 	 */
1039
-	public function get_country( $context = 'view' ) {
1040
-		$country = $this->get_prop( 'country', $context );
1041
-		return empty( $country ) ? wpinv_get_default_country() : $country;
1039
+	public function get_country($context = 'view') {
1040
+		$country = $this->get_prop('country', $context);
1041
+		return empty($country) ? wpinv_get_default_country() : $country;
1042 1042
     }
1043 1043
 
1044 1044
     /**
@@ -1048,8 +1048,8 @@  discard block
 block discarded – undo
1048 1048
 	 * @param  string $context View or edit context.
1049 1049
 	 * @return string
1050 1050
 	 */
1051
-	public function get_user_country( $context = 'view' ) {
1052
-		return $this->get_country( $context );
1051
+	public function get_user_country($context = 'view') {
1052
+		return $this->get_country($context);
1053 1053
     }
1054 1054
 
1055 1055
     /**
@@ -1059,8 +1059,8 @@  discard block
 block discarded – undo
1059 1059
 	 * @param  string $context View or edit context.
1060 1060
 	 * @return string
1061 1061
 	 */
1062
-	public function get_customer_country( $context = 'view' ) {
1063
-		return $this->get_country( $context );
1062
+	public function get_customer_country($context = 'view') {
1063
+		return $this->get_country($context);
1064 1064
     }
1065 1065
 
1066 1066
     /**
@@ -1070,9 +1070,9 @@  discard block
 block discarded – undo
1070 1070
 	 * @param  string $context View or edit context.
1071 1071
 	 * @return string
1072 1072
 	 */
1073
-	public function get_state( $context = 'view' ) {
1074
-		$state = $this->get_prop( 'state', $context );
1075
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1073
+	public function get_state($context = 'view') {
1074
+		$state = $this->get_prop('state', $context);
1075
+		return empty($state) ? wpinv_get_default_state() : $state;
1076 1076
     }
1077 1077
 
1078 1078
     /**
@@ -1082,8 +1082,8 @@  discard block
 block discarded – undo
1082 1082
 	 * @param  string $context View or edit context.
1083 1083
 	 * @return string
1084 1084
 	 */
1085
-	public function get_user_state( $context = 'view' ) {
1086
-		return $this->get_state( $context );
1085
+	public function get_user_state($context = 'view') {
1086
+		return $this->get_state($context);
1087 1087
     }
1088 1088
 
1089 1089
     /**
@@ -1093,8 +1093,8 @@  discard block
 block discarded – undo
1093 1093
 	 * @param  string $context View or edit context.
1094 1094
 	 * @return string
1095 1095
 	 */
1096
-	public function get_customer_state( $context = 'view' ) {
1097
-		return $this->get_state( $context );
1096
+	public function get_customer_state($context = 'view') {
1097
+		return $this->get_state($context);
1098 1098
     }
1099 1099
 
1100 1100
     /**
@@ -1104,8 +1104,8 @@  discard block
 block discarded – undo
1104 1104
 	 * @param  string $context View or edit context.
1105 1105
 	 * @return string
1106 1106
 	 */
1107
-	public function get_city( $context = 'view' ) {
1108
-		return $this->get_prop( 'city', $context );
1107
+	public function get_city($context = 'view') {
1108
+		return $this->get_prop('city', $context);
1109 1109
     }
1110 1110
 
1111 1111
     /**
@@ -1115,8 +1115,8 @@  discard block
 block discarded – undo
1115 1115
 	 * @param  string $context View or edit context.
1116 1116
 	 * @return string
1117 1117
 	 */
1118
-	public function get_user_city( $context = 'view' ) {
1119
-		return $this->get_city( $context );
1118
+	public function get_user_city($context = 'view') {
1119
+		return $this->get_city($context);
1120 1120
     }
1121 1121
 
1122 1122
     /**
@@ -1126,8 +1126,8 @@  discard block
 block discarded – undo
1126 1126
 	 * @param  string $context View or edit context.
1127 1127
 	 * @return string
1128 1128
 	 */
1129
-	public function get_customer_city( $context = 'view' ) {
1130
-		return $this->get_city( $context );
1129
+	public function get_customer_city($context = 'view') {
1130
+		return $this->get_city($context);
1131 1131
     }
1132 1132
 
1133 1133
     /**
@@ -1137,8 +1137,8 @@  discard block
 block discarded – undo
1137 1137
 	 * @param  string $context View or edit context.
1138 1138
 	 * @return string
1139 1139
 	 */
1140
-	public function get_zip( $context = 'view' ) {
1141
-		return $this->get_prop( 'zip', $context );
1140
+	public function get_zip($context = 'view') {
1141
+		return $this->get_prop('zip', $context);
1142 1142
     }
1143 1143
 
1144 1144
     /**
@@ -1148,8 +1148,8 @@  discard block
 block discarded – undo
1148 1148
 	 * @param  string $context View or edit context.
1149 1149
 	 * @return string
1150 1150
 	 */
1151
-	public function get_user_zip( $context = 'view' ) {
1152
-		return $this->get_zip( $context );
1151
+	public function get_user_zip($context = 'view') {
1152
+		return $this->get_zip($context);
1153 1153
     }
1154 1154
 
1155 1155
     /**
@@ -1159,8 +1159,8 @@  discard block
 block discarded – undo
1159 1159
 	 * @param  string $context View or edit context.
1160 1160
 	 * @return string
1161 1161
 	 */
1162
-	public function get_customer_zip( $context = 'view' ) {
1163
-		return $this->get_zip( $context );
1162
+	public function get_customer_zip($context = 'view') {
1163
+		return $this->get_zip($context);
1164 1164
     }
1165 1165
 
1166 1166
     /**
@@ -1170,8 +1170,8 @@  discard block
 block discarded – undo
1170 1170
 	 * @param  string $context View or edit context.
1171 1171
 	 * @return string
1172 1172
 	 */
1173
-	public function get_company( $context = 'view' ) {
1174
-		return $this->get_prop( 'company', $context );
1173
+	public function get_company($context = 'view') {
1174
+		return $this->get_prop('company', $context);
1175 1175
     }
1176 1176
 
1177 1177
     /**
@@ -1181,8 +1181,8 @@  discard block
 block discarded – undo
1181 1181
 	 * @param  string $context View or edit context.
1182 1182
 	 * @return string
1183 1183
 	 */
1184
-	public function get_user_company( $context = 'view' ) {
1185
-		return $this->get_company( $context );
1184
+	public function get_user_company($context = 'view') {
1185
+		return $this->get_company($context);
1186 1186
     }
1187 1187
 
1188 1188
     /**
@@ -1192,8 +1192,8 @@  discard block
 block discarded – undo
1192 1192
 	 * @param  string $context View or edit context.
1193 1193
 	 * @return string
1194 1194
 	 */
1195
-	public function get_customer_company( $context = 'view' ) {
1196
-		return $this->get_company( $context );
1195
+	public function get_customer_company($context = 'view') {
1196
+		return $this->get_company($context);
1197 1197
     }
1198 1198
 
1199 1199
 	/**
@@ -1203,8 +1203,8 @@  discard block
 block discarded – undo
1203 1203
 	 * @param  string $context View or edit context.
1204 1204
 	 * @return string
1205 1205
 	 */
1206
-	public function get_company_id( $context = 'view' ) {
1207
-		return $this->get_prop( 'company_id', $context );
1206
+	public function get_company_id($context = 'view') {
1207
+		return $this->get_prop('company_id', $context);
1208 1208
     }
1209 1209
 
1210 1210
     /**
@@ -1214,8 +1214,8 @@  discard block
 block discarded – undo
1214 1214
 	 * @param  string $context View or edit context.
1215 1215
 	 * @return string
1216 1216
 	 */
1217
-	public function get_vat_number( $context = 'view' ) {
1218
-		return $this->get_prop( 'vat_number', $context );
1217
+	public function get_vat_number($context = 'view') {
1218
+		return $this->get_prop('vat_number', $context);
1219 1219
     }
1220 1220
 
1221 1221
     /**
@@ -1225,8 +1225,8 @@  discard block
 block discarded – undo
1225 1225
 	 * @param  string $context View or edit context.
1226 1226
 	 * @return string
1227 1227
 	 */
1228
-	public function get_user_vat_number( $context = 'view' ) {
1229
-		return $this->get_vat_number( $context );
1228
+	public function get_user_vat_number($context = 'view') {
1229
+		return $this->get_vat_number($context);
1230 1230
     }
1231 1231
 
1232 1232
     /**
@@ -1236,8 +1236,8 @@  discard block
 block discarded – undo
1236 1236
 	 * @param  string $context View or edit context.
1237 1237
 	 * @return string
1238 1238
 	 */
1239
-	public function get_customer_vat_number( $context = 'view' ) {
1240
-		return $this->get_vat_number( $context );
1239
+	public function get_customer_vat_number($context = 'view') {
1240
+		return $this->get_vat_number($context);
1241 1241
     }
1242 1242
 
1243 1243
     /**
@@ -1247,8 +1247,8 @@  discard block
 block discarded – undo
1247 1247
 	 * @param  string $context View or edit context.
1248 1248
 	 * @return string
1249 1249
 	 */
1250
-	public function get_vat_rate( $context = 'view' ) {
1251
-		return $this->get_prop( 'vat_rate', $context );
1250
+	public function get_vat_rate($context = 'view') {
1251
+		return $this->get_prop('vat_rate', $context);
1252 1252
     }
1253 1253
 
1254 1254
     /**
@@ -1258,8 +1258,8 @@  discard block
 block discarded – undo
1258 1258
 	 * @param  string $context View or edit context.
1259 1259
 	 * @return string
1260 1260
 	 */
1261
-	public function get_user_vat_rate( $context = 'view' ) {
1262
-		return $this->get_vat_rate( $context );
1261
+	public function get_user_vat_rate($context = 'view') {
1262
+		return $this->get_vat_rate($context);
1263 1263
     }
1264 1264
 
1265 1265
     /**
@@ -1269,8 +1269,8 @@  discard block
 block discarded – undo
1269 1269
 	 * @param  string $context View or edit context.
1270 1270
 	 * @return string
1271 1271
 	 */
1272
-	public function get_customer_vat_rate( $context = 'view' ) {
1273
-		return $this->get_vat_rate( $context );
1272
+	public function get_customer_vat_rate($context = 'view') {
1273
+		return $this->get_vat_rate($context);
1274 1274
     }
1275 1275
 
1276 1276
     /**
@@ -1280,8 +1280,8 @@  discard block
 block discarded – undo
1280 1280
 	 * @param  string $context View or edit context.
1281 1281
 	 * @return string
1282 1282
 	 */
1283
-	public function get_address( $context = 'view' ) {
1284
-		return $this->get_prop( 'address', $context );
1283
+	public function get_address($context = 'view') {
1284
+		return $this->get_prop('address', $context);
1285 1285
     }
1286 1286
 
1287 1287
     /**
@@ -1291,8 +1291,8 @@  discard block
 block discarded – undo
1291 1291
 	 * @param  string $context View or edit context.
1292 1292
 	 * @return string
1293 1293
 	 */
1294
-	public function get_user_address( $context = 'view' ) {
1295
-		return $this->get_address( $context );
1294
+	public function get_user_address($context = 'view') {
1295
+		return $this->get_address($context);
1296 1296
     }
1297 1297
 
1298 1298
     /**
@@ -1302,8 +1302,8 @@  discard block
 block discarded – undo
1302 1302
 	 * @param  string $context View or edit context.
1303 1303
 	 * @return string
1304 1304
 	 */
1305
-	public function get_customer_address( $context = 'view' ) {
1306
-		return $this->get_address( $context );
1305
+	public function get_customer_address($context = 'view') {
1306
+		return $this->get_address($context);
1307 1307
     }
1308 1308
 
1309 1309
     /**
@@ -1313,8 +1313,8 @@  discard block
 block discarded – undo
1313 1313
 	 * @param  string $context View or edit context.
1314 1314
 	 * @return bool
1315 1315
 	 */
1316
-	public function get_is_viewed( $context = 'view' ) {
1317
-		return (bool) $this->get_prop( 'is_viewed', $context );
1316
+	public function get_is_viewed($context = 'view') {
1317
+		return (bool) $this->get_prop('is_viewed', $context);
1318 1318
 	}
1319 1319
 
1320 1320
 	/**
@@ -1324,8 +1324,8 @@  discard block
 block discarded – undo
1324 1324
 	 * @param  string $context View or edit context.
1325 1325
 	 * @return bool
1326 1326
 	 */
1327
-	public function get_email_cc( $context = 'view' ) {
1328
-		return $this->get_prop( 'email_cc', $context );
1327
+	public function get_email_cc($context = 'view') {
1328
+		return $this->get_prop('email_cc', $context);
1329 1329
 	}
1330 1330
 
1331 1331
 	/**
@@ -1335,8 +1335,8 @@  discard block
 block discarded – undo
1335 1335
 	 * @param  string $context View or edit context.
1336 1336
 	 * @return bool
1337 1337
 	 */
1338
-	public function get_template( $context = 'view' ) {
1339
-		return $this->get_prop( 'template', $context );
1338
+	public function get_template($context = 'view') {
1339
+		return $this->get_prop('template', $context);
1340 1340
 	}
1341 1341
 
1342 1342
 	/**
@@ -1346,8 +1346,8 @@  discard block
 block discarded – undo
1346 1346
 	 * @param  string $context View or edit context.
1347 1347
 	 * @return bool
1348 1348
 	 */
1349
-	public function get_created_via( $context = 'view' ) {
1350
-		return $this->get_prop( 'created_via', $context );
1349
+	public function get_created_via($context = 'view') {
1350
+		return $this->get_prop('created_via', $context);
1351 1351
 	}
1352 1352
 
1353 1353
 	/**
@@ -1357,8 +1357,8 @@  discard block
 block discarded – undo
1357 1357
 	 * @param  string $context View or edit context.
1358 1358
 	 * @return bool
1359 1359
 	 */
1360
-	public function get_address_confirmed( $context = 'view' ) {
1361
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1360
+	public function get_address_confirmed($context = 'view') {
1361
+		return (bool) $this->get_prop('address_confirmed', $context);
1362 1362
     }
1363 1363
 
1364 1364
     /**
@@ -1368,8 +1368,8 @@  discard block
 block discarded – undo
1368 1368
 	 * @param  string $context View or edit context.
1369 1369
 	 * @return bool
1370 1370
 	 */
1371
-	public function get_user_address_confirmed( $context = 'view' ) {
1372
-		return $this->get_address_confirmed( $context );
1371
+	public function get_user_address_confirmed($context = 'view') {
1372
+		return $this->get_address_confirmed($context);
1373 1373
     }
1374 1374
 
1375 1375
     /**
@@ -1379,8 +1379,8 @@  discard block
 block discarded – undo
1379 1379
 	 * @param  string $context View or edit context.
1380 1380
 	 * @return bool
1381 1381
 	 */
1382
-	public function get_customer_address_confirmed( $context = 'view' ) {
1383
-		return $this->get_address_confirmed( $context );
1382
+	public function get_customer_address_confirmed($context = 'view') {
1383
+		return $this->get_address_confirmed($context);
1384 1384
     }
1385 1385
 
1386 1386
 	/**
@@ -1391,8 +1391,8 @@  discard block
 block discarded – undo
1391 1391
 	 */
1392 1392
 	public function get_shipping_address() {
1393 1393
 
1394
-		$shipping_address = get_post_meta( $this->get_id(), 'shipping_address', true );
1395
-		return is_array( $shipping_address ) ? $shipping_address : false;
1394
+		$shipping_address = get_post_meta($this->get_id(), 'shipping_address', true);
1395
+		return is_array($shipping_address) ? $shipping_address : false;
1396 1396
     }
1397 1397
 
1398 1398
 	/**
@@ -1409,17 +1409,17 @@  discard block
 block discarded – undo
1409 1409
 	 * @param  string $context View or edit context.
1410 1410
 	 * @return float
1411 1411
 	 */
1412
-	public function get_shipping( $context = 'view' ) {
1412
+	public function get_shipping($context = 'view') {
1413 1413
 
1414
-		if ( $context = 'view' ) {
1415
-			return floatval( $this->get_prop( 'shipping', $context ) );
1414
+		if ($context = 'view') {
1415
+			return floatval($this->get_prop('shipping', $context));
1416 1416
 		}
1417 1417
 
1418
-		return $this->get_prop( 'shipping', $context );
1418
+		return $this->get_prop('shipping', $context);
1419 1419
     }
1420 1420
 
1421 1421
 	public function has_shipping() {
1422
-		return defined( 'GETPAID_SHIPPING_CALCULATOR_VERSION' ) && $this->get_prop( 'shipping', 'edit' );
1422
+		return defined('GETPAID_SHIPPING_CALCULATOR_VERSION') && $this->get_prop('shipping', 'edit');
1423 1423
     }
1424 1424
 
1425 1425
     /**
@@ -1429,12 +1429,12 @@  discard block
 block discarded – undo
1429 1429
 	 * @param  string $context View or edit context.
1430 1430
 	 * @return float
1431 1431
 	 */
1432
-	public function get_subtotal( $context = 'view' ) {
1433
-        $subtotal = (float) $this->get_prop( 'subtotal', $context );
1432
+	public function get_subtotal($context = 'view') {
1433
+        $subtotal = (float) $this->get_prop('subtotal', $context);
1434 1434
 
1435 1435
         // Backwards compatibility.
1436
-        if ( is_bool( $context ) && $context ) {
1437
-            return wpinv_price( $subtotal, $this->get_currency() );
1436
+        if (is_bool($context) && $context) {
1437
+            return wpinv_price($subtotal, $this->get_currency());
1438 1438
         }
1439 1439
 
1440 1440
         return $subtotal;
@@ -1447,8 +1447,8 @@  discard block
 block discarded – undo
1447 1447
 	 * @param  string $context View or edit context.
1448 1448
 	 * @return float
1449 1449
 	 */
1450
-	public function get_total_discount( $context = 'view' ) {
1451
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1450
+	public function get_total_discount($context = 'view') {
1451
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_discount', $context)));
1452 1452
     }
1453 1453
 
1454 1454
     /**
@@ -1458,18 +1458,18 @@  discard block
 block discarded – undo
1458 1458
 	 * @param  string $context View or edit context.
1459 1459
 	 * @return float
1460 1460
 	 */
1461
-	public function get_total_tax( $context = 'view' ) {
1462
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1461
+	public function get_total_tax($context = 'view') {
1462
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_tax', $context)));
1463 1463
 	}
1464 1464
 
1465 1465
 	/**
1466 1466
 	 * @deprecated
1467 1467
 	 */
1468
-	public function get_final_tax( $currency = false ) {
1468
+	public function get_final_tax($currency = false) {
1469 1469
 		$tax = $this->get_total_tax();
1470 1470
 
1471
-        if ( $currency ) {
1472
-			return wpinv_price( $tax, $this->get_currency() );
1471
+        if ($currency) {
1472
+			return wpinv_price($tax, $this->get_currency());
1473 1473
         }
1474 1474
 
1475 1475
         return $tax;
@@ -1482,8 +1482,8 @@  discard block
 block discarded – undo
1482 1482
 	 * @param  string $context View or edit context.
1483 1483
 	 * @return float
1484 1484
 	 */
1485
-	public function get_total_fees( $context = 'view' ) {
1486
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1485
+	public function get_total_fees($context = 'view') {
1486
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_fees', $context)));
1487 1487
     }
1488 1488
 
1489 1489
     /**
@@ -1493,8 +1493,8 @@  discard block
 block discarded – undo
1493 1493
 	 * @param  string $context View or edit context.
1494 1494
 	 * @return float
1495 1495
 	 */
1496
-	public function get_fees_total( $context = 'view' ) {
1497
-		return $this->get_total_fees( $context );
1496
+	public function get_fees_total($context = 'view') {
1497
+		return $this->get_total_fees($context);
1498 1498
     }
1499 1499
 
1500 1500
     /**
@@ -1503,14 +1503,14 @@  discard block
 block discarded – undo
1503 1503
 	 * @since 1.0.19
1504 1504
      * @return float
1505 1505
 	 */
1506
-	public function get_total( $context = 'view' ) {
1507
-		$total = $this->get_prop( 'total', $context );
1506
+	public function get_total($context = 'view') {
1507
+		$total = $this->get_prop('total', $context);
1508 1508
 
1509
-		if ( $this->has_shipping() && $context == 'view' ) {
1510
-			$total = $this->get_prop( 'total', $context ) + $this->get_shipping( $context );
1509
+		if ($this->has_shipping() && $context == 'view') {
1510
+			$total = $this->get_prop('total', $context) + $this->get_shipping($context);
1511 1511
 		}
1512 1512
 
1513
-		return wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1513
+		return wpinv_round_amount(wpinv_sanitize_amount($total));
1514 1514
 	}
1515 1515
 
1516 1516
 	/**
@@ -1522,20 +1522,20 @@  discard block
 block discarded – undo
1522 1522
 	public function get_non_recurring_total() {
1523 1523
 
1524 1524
 		$subtotal = 0;
1525
-		foreach ( $this->get_items() as $item ) {
1526
-			if ( ! $item->is_recurring() ) {
1525
+		foreach ($this->get_items() as $item) {
1526
+			if (!$item->is_recurring()) {
1527 1527
 				$subtotal += $item->get_sub_total();
1528 1528
 			}
1529 1529
 		}
1530 1530
 
1531
-		foreach ( $this->get_fees() as $fee ) {
1532
-			if ( empty( $fee['recurring_fee'] ) ) {
1533
-				$subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1531
+		foreach ($this->get_fees() as $fee) {
1532
+			if (empty($fee['recurring_fee'])) {
1533
+				$subtotal += wpinv_sanitize_amount($fee['initial_fee']);
1534 1534
 			}
1535 1535
 		}
1536 1536
 
1537
-		$subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1538
-        return apply_filters( 'wpinv_get_non_recurring_invoice_total', $subtotal, $this );
1537
+		$subtotal = wpinv_round_amount(wpinv_sanitize_amount($subtotal));
1538
+        return apply_filters('wpinv_get_non_recurring_invoice_total', $subtotal, $this);
1539 1539
 
1540 1540
     }
1541 1541
 
@@ -1558,7 +1558,7 @@  discard block
 block discarded – undo
1558 1558
 	 */
1559 1559
     public function get_initial_total() {
1560 1560
 
1561
-		if ( empty( $this->totals ) ) {
1561
+		if (empty($this->totals)) {
1562 1562
 			$this->recalculate_total();
1563 1563
 		}
1564 1564
 
@@ -1568,12 +1568,12 @@  discard block
 block discarded – undo
1568 1568
 		$subtotal = $this->totals['subtotal']['initial'];
1569 1569
 		$total    = $tax + $fee - $discount + $subtotal;
1570 1570
 
1571
-		if ( 0 > $total ) {
1571
+		if (0 > $total) {
1572 1572
 			$total = 0;
1573 1573
 		}
1574 1574
 
1575
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1576
-        return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1575
+		$total = wpinv_round_amount(wpinv_sanitize_amount($total));
1576
+        return apply_filters('wpinv_get_initial_invoice_total', $total, $this);
1577 1577
 	}
1578 1578
 
1579 1579
 	/**
@@ -1585,7 +1585,7 @@  discard block
 block discarded – undo
1585 1585
 	 */
1586 1586
     public function get_recurring_total() {
1587 1587
 
1588
-		if ( empty( $this->totals ) ) {
1588
+		if (empty($this->totals)) {
1589 1589
 			$this->recalculate_total();
1590 1590
 		}
1591 1591
 
@@ -1595,12 +1595,12 @@  discard block
 block discarded – undo
1595 1595
 		$subtotal = $this->totals['subtotal']['recurring'];
1596 1596
 		$total    = $tax + $fee - $discount + $subtotal;
1597 1597
 
1598
-		if ( 0 > $total ) {
1598
+		if (0 > $total) {
1599 1599
 			$total = 0;
1600 1600
 		}
1601 1601
 
1602
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1603
-        return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1602
+		$total = wpinv_round_amount(wpinv_sanitize_amount($total));
1603
+        return apply_filters('wpinv_get_recurring_invoice_total', $total, $this);
1604 1604
 	}
1605 1605
 
1606 1606
 	/**
@@ -1611,10 +1611,10 @@  discard block
 block discarded – undo
1611 1611
 	 * @param string $currency Whether to include the currency.
1612 1612
      * @return float|string
1613 1613
 	 */
1614
-    public function get_recurring_details( $field = '', $currency = false ) {
1614
+    public function get_recurring_details($field = '', $currency = false) {
1615 1615
 
1616 1616
 		// Maybe recalculate totals.
1617
-		if ( empty( $this->totals ) ) {
1617
+		if (empty($this->totals)) {
1618 1618
 			$this->recalculate_total();
1619 1619
 		}
1620 1620
 
@@ -1634,8 +1634,8 @@  discard block
 block discarded – undo
1634 1634
 			$currency
1635 1635
 		);
1636 1636
 
1637
-        if ( isset( $data[ $field ] ) ) {
1638
-            return ( $currency ? wpinv_price( $data[ $field ], $this->get_currency() ) : $data[ $field ] );
1637
+        if (isset($data[$field])) {
1638
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1639 1639
         }
1640 1640
 
1641 1641
         return $data;
@@ -1648,8 +1648,8 @@  discard block
 block discarded – undo
1648 1648
 	 * @param  string $context View or edit context.
1649 1649
 	 * @return array
1650 1650
 	 */
1651
-	public function get_fees( $context = 'view' ) {
1652
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1651
+	public function get_fees($context = 'view') {
1652
+		return wpinv_parse_list($this->get_prop('fees', $context));
1653 1653
     }
1654 1654
 
1655 1655
     /**
@@ -1659,8 +1659,8 @@  discard block
 block discarded – undo
1659 1659
 	 * @param  string $context View or edit context.
1660 1660
 	 * @return array
1661 1661
 	 */
1662
-	public function get_discounts( $context = 'view' ) {
1663
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1662
+	public function get_discounts($context = 'view') {
1663
+		return wpinv_parse_list($this->get_prop('discounts', $context));
1664 1664
     }
1665 1665
 
1666 1666
     /**
@@ -1670,8 +1670,8 @@  discard block
 block discarded – undo
1670 1670
 	 * @param  string $context View or edit context.
1671 1671
 	 * @return array
1672 1672
 	 */
1673
-	public function get_taxes( $context = 'view' ) {
1674
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1673
+	public function get_taxes($context = 'view') {
1674
+		return wpinv_parse_list($this->get_prop('taxes', $context));
1675 1675
     }
1676 1676
 
1677 1677
     /**
@@ -1681,8 +1681,8 @@  discard block
 block discarded – undo
1681 1681
 	 * @param  string $context View or edit context.
1682 1682
 	 * @return GetPaid_Form_Item[]
1683 1683
 	 */
1684
-	public function get_items( $context = 'view' ) {
1685
-        return $this->get_prop( 'items', $context );
1684
+	public function get_items($context = 'view') {
1685
+        return $this->get_prop('items', $context);
1686 1686
 	}
1687 1687
 
1688 1688
 	/**
@@ -1692,7 +1692,7 @@  discard block
 block discarded – undo
1692 1692
 	 * @return string
1693 1693
 	 */
1694 1694
 	public function get_item_ids() {
1695
-		return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1695
+		return implode(', ', wp_list_pluck($this->get_cart_details(), 'item_id'));
1696 1696
     }
1697 1697
 
1698 1698
     /**
@@ -1702,8 +1702,8 @@  discard block
 block discarded – undo
1702 1702
 	 * @param  string $context View or edit context.
1703 1703
 	 * @return int
1704 1704
 	 */
1705
-	public function get_payment_form( $context = 'view' ) {
1706
-		return intval( $this->get_prop( 'payment_form', $context ) );
1705
+	public function get_payment_form($context = 'view') {
1706
+		return intval($this->get_prop('payment_form', $context));
1707 1707
     }
1708 1708
 
1709 1709
     /**
@@ -1713,8 +1713,8 @@  discard block
 block discarded – undo
1713 1713
 	 * @param  string $context View or edit context.
1714 1714
 	 * @return string
1715 1715
 	 */
1716
-	public function get_submission_id( $context = 'view' ) {
1717
-		return $this->get_prop( 'submission_id', $context );
1716
+	public function get_submission_id($context = 'view') {
1717
+		return $this->get_prop('submission_id', $context);
1718 1718
     }
1719 1719
 
1720 1720
     /**
@@ -1724,8 +1724,8 @@  discard block
 block discarded – undo
1724 1724
 	 * @param  string $context View or edit context.
1725 1725
 	 * @return string
1726 1726
 	 */
1727
-	public function get_discount_code( $context = 'view' ) {
1728
-		return $this->get_prop( 'discount_code', $context );
1727
+	public function get_discount_code($context = 'view') {
1728
+		return $this->get_prop('discount_code', $context);
1729 1729
     }
1730 1730
 
1731 1731
     /**
@@ -1735,8 +1735,8 @@  discard block
 block discarded – undo
1735 1735
 	 * @param  string $context View or edit context.
1736 1736
 	 * @return string
1737 1737
 	 */
1738
-	public function get_gateway( $context = 'view' ) {
1739
-		return $this->get_prop( 'gateway', $context );
1738
+	public function get_gateway($context = 'view') {
1739
+		return $this->get_prop('gateway', $context);
1740 1740
     }
1741 1741
 
1742 1742
     /**
@@ -1746,8 +1746,8 @@  discard block
 block discarded – undo
1746 1746
 	 * @return string
1747 1747
 	 */
1748 1748
     public function get_gateway_title() {
1749
-        $title = wpinv_get_gateway_checkout_label( $this->get_gateway() );
1750
-        return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1749
+        $title = wpinv_get_gateway_checkout_label($this->get_gateway());
1750
+        return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this);
1751 1751
     }
1752 1752
 
1753 1753
     /**
@@ -1757,8 +1757,8 @@  discard block
 block discarded – undo
1757 1757
 	 * @param  string $context View or edit context.
1758 1758
 	 * @return string
1759 1759
 	 */
1760
-	public function get_transaction_id( $context = 'view' ) {
1761
-		return $this->get_prop( 'transaction_id', $context );
1760
+	public function get_transaction_id($context = 'view') {
1761
+		return $this->get_prop('transaction_id', $context);
1762 1762
     }
1763 1763
 
1764 1764
     /**
@@ -1768,9 +1768,9 @@  discard block
 block discarded – undo
1768 1768
 	 * @param  string $context View or edit context.
1769 1769
 	 * @return string
1770 1770
 	 */
1771
-	public function get_currency( $context = 'view' ) {
1772
-        $currency = $this->get_prop( 'currency', $context );
1773
-        return empty( $currency ) ? wpinv_get_currency() : $currency;
1771
+	public function get_currency($context = 'view') {
1772
+        $currency = $this->get_prop('currency', $context);
1773
+        return empty($currency) ? wpinv_get_currency() : $currency;
1774 1774
     }
1775 1775
 
1776 1776
     /**
@@ -1780,8 +1780,8 @@  discard block
 block discarded – undo
1780 1780
 	 * @param  string $context View or edit context.
1781 1781
 	 * @return bool
1782 1782
 	 */
1783
-	public function get_disable_taxes( $context = 'view' ) {
1784
-        return (bool) $this->get_prop( 'disable_taxes', $context );
1783
+	public function get_disable_taxes($context = 'view') {
1784
+        return (bool) $this->get_prop('disable_taxes', $context);
1785 1785
     }
1786 1786
 
1787 1787
     /**
@@ -1791,8 +1791,8 @@  discard block
 block discarded – undo
1791 1791
 	 * @param  string $context View or edit context.
1792 1792
 	 * @return int
1793 1793
 	 */
1794
-    public function get_subscription_id( $context = 'view' ) {
1795
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1794
+    public function get_subscription_id($context = 'view') {
1795
+		return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context);
1796 1796
 	}
1797 1797
 
1798 1798
 	/**
@@ -1802,12 +1802,12 @@  discard block
 block discarded – undo
1802 1802
 	 * @param  string $context View or edit context.
1803 1803
 	 * @return int
1804 1804
 	 */
1805
-    public function get_remote_subscription_id( $context = 'view' ) {
1806
-        $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1805
+    public function get_remote_subscription_id($context = 'view') {
1806
+        $subscription_id = $this->get_prop('remote_subscription_id', $context);
1807 1807
 
1808
-        if ( empty( $subscription_id ) && $this->is_renewal() ) {
1808
+        if (empty($subscription_id) && $this->is_renewal()) {
1809 1809
             $parent = $this->get_parent();
1810
-            return $parent->get_remote_subscription_id( $context );
1810
+            return $parent->get_remote_subscription_id($context);
1811 1811
         }
1812 1812
 
1813 1813
         return $subscription_id;
@@ -1820,8 +1820,8 @@  discard block
 block discarded – undo
1820 1820
 	 * @param  string $context View or edit context.
1821 1821
 	 * @return string
1822 1822
 	 */
1823
-	public function get_is_anonymized( $context = 'view' ) {
1824
-		return (bool) $this->get_prop( 'is_anonymized', $context );
1823
+	public function get_is_anonymized($context = 'view') {
1824
+		return (bool) $this->get_prop('is_anonymized', $context);
1825 1825
     }
1826 1826
 
1827 1827
     /**
@@ -1831,20 +1831,20 @@  discard block
 block discarded – undo
1831 1831
 	 * @param  string $context View or edit context.
1832 1832
 	 * @return array
1833 1833
 	 */
1834
-    public function get_payment_meta( $context = 'view' ) {
1834
+    public function get_payment_meta($context = 'view') {
1835 1835
 
1836 1836
         return array(
1837
-            'price'        => $this->get_total( $context ),
1838
-            'date'         => $this->get_date_created( $context ),
1839
-            'user_email'   => $this->get_email( $context ),
1840
-            'invoice_key'  => $this->get_key( $context ),
1841
-            'currency'     => $this->get_currency( $context ),
1842
-            'items'        => $this->get_items( $context ),
1843
-            'user_info'    => $this->get_user_info( $context ),
1837
+            'price'        => $this->get_total($context),
1838
+            'date'         => $this->get_date_created($context),
1839
+            'user_email'   => $this->get_email($context),
1840
+            'invoice_key'  => $this->get_key($context),
1841
+            'currency'     => $this->get_currency($context),
1842
+            'items'        => $this->get_items($context),
1843
+            'user_info'    => $this->get_user_info($context),
1844 1844
             'cart_details' => $this->get_cart_details(),
1845
-            'status'       => $this->get_status( $context ),
1846
-            'fees'         => $this->get_fees( $context ),
1847
-            'taxes'        => $this->get_taxes( $context ),
1845
+            'status'       => $this->get_status($context),
1846
+            'fees'         => $this->get_fees($context),
1847
+            'taxes'        => $this->get_taxes($context),
1848 1848
         );
1849 1849
 
1850 1850
     }
@@ -1859,9 +1859,9 @@  discard block
 block discarded – undo
1859 1859
         $items        = $this->get_items();
1860 1860
         $cart_details = array();
1861 1861
 
1862
-        foreach ( $items as $item ) {
1862
+        foreach ($items as $item) {
1863 1863
 			$item->invoice_id = $this->get_id();
1864
-            $cart_details[]   = $item->prepare_data_for_saving();
1864
+            $cart_details[] = $item->prepare_data_for_saving();
1865 1865
         }
1866 1866
 
1867 1867
         return $cart_details;
@@ -1872,11 +1872,11 @@  discard block
 block discarded – undo
1872 1872
 	 *
1873 1873
 	 * @return null|GetPaid_Form_Item|int
1874 1874
 	 */
1875
-	public function get_recurring( $object = false ) {
1875
+	public function get_recurring($object = false) {
1876 1876
 
1877 1877
 		// Are we returning an object?
1878
-        if ( $object ) {
1879
-            return $this->get_item( $this->recurring_item );
1878
+        if ($object) {
1879
+            return $this->get_item($this->recurring_item);
1880 1880
         }
1881 1881
 
1882 1882
         return $this->recurring_item;
@@ -1891,15 +1891,15 @@  discard block
 block discarded – undo
1891 1891
 	public function get_subscription_name() {
1892 1892
 
1893 1893
 		// Retrieve the recurring name
1894
-        $item = $this->get_recurring( true );
1894
+        $item = $this->get_recurring(true);
1895 1895
 
1896 1896
 		// Abort if it does not exist.
1897
-        if ( empty( $item ) ) {
1897
+        if (empty($item)) {
1898 1898
             return '';
1899 1899
         }
1900 1900
 
1901 1901
 		// Return the item name.
1902
-        return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1902
+        return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this);
1903 1903
 	}
1904 1904
 
1905 1905
 	/**
@@ -1909,9 +1909,9 @@  discard block
 block discarded – undo
1909 1909
 	 * @return string
1910 1910
 	 */
1911 1911
 	public function get_view_url() {
1912
-        $invoice_url = get_permalink( $this->get_id() );
1913
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1914
-        return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1912
+        $invoice_url = get_permalink($this->get_id());
1913
+		$invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url);
1914
+        return apply_filters('wpinv_get_view_url', $invoice_url, $this);
1915 1915
 	}
1916 1916
 
1917 1917
 	/**
@@ -1920,25 +1920,25 @@  discard block
 block discarded – undo
1920 1920
 	 * @since 1.0.19
1921 1921
 	 * @return string
1922 1922
 	 */
1923
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1923
+	public function get_checkout_payment_url($deprecated = false, $secret = false) {
1924 1924
 
1925 1925
 		// Retrieve the checkout url.
1926 1926
         $pay_url = wpinv_get_checkout_uri();
1927 1927
 
1928 1928
 		// Maybe force ssl.
1929
-        if ( is_ssl() ) {
1930
-            $pay_url = str_replace( 'http:', 'https:', $pay_url );
1929
+        if (is_ssl()) {
1930
+            $pay_url = str_replace('http:', 'https:', $pay_url);
1931 1931
         }
1932 1932
 
1933 1933
 		// Add the invoice key.
1934
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1934
+		$pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url);
1935 1935
 
1936 1936
 		// (Maybe?) add a secret
1937
-        if ( $secret ) {
1938
-            $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1937
+        if ($secret) {
1938
+            $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url);
1939 1939
         }
1940 1940
 
1941
-        return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1941
+        return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret);
1942 1942
 	}
1943 1943
 
1944 1944
 	/**
@@ -1953,14 +1953,14 @@  discard block
 block discarded – undo
1953 1953
         $receipt_url = wpinv_get_success_page_uri();
1954 1954
 
1955 1955
 		// Maybe force ssl.
1956
-        if ( is_ssl() ) {
1957
-            $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1956
+        if (is_ssl()) {
1957
+            $receipt_url = str_replace('http:', 'https:', $receipt_url);
1958 1958
         }
1959 1959
 
1960 1960
 		// Add the invoice key.
1961
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1961
+		$receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url);
1962 1962
 
1963
-        return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1963
+        return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this);
1964 1964
 	}
1965 1965
 
1966 1966
 	/**
@@ -1970,7 +1970,7 @@  discard block
 block discarded – undo
1970 1970
 	 * @return string
1971 1971
 	 */
1972 1972
 	public function get_transaction_url() {
1973
-		return apply_filters( 'getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this );
1973
+		return apply_filters('getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this);
1974 1974
 	}
1975 1975
 
1976 1976
 	/**
@@ -1983,7 +1983,7 @@  discard block
 block discarded – undo
1983 1983
 
1984 1984
 		$type   = $this->get_type();
1985 1985
 		$status = "wpi-$type-pending";
1986
-		return str_replace( '-invoice', '', $status );
1986
+		return str_replace('-invoice', '', $status);
1987 1987
 
1988 1988
 	}
1989 1989
 
@@ -1997,14 +1997,14 @@  discard block
 block discarded – undo
1997 1997
 	 * @param  string $context View or edit context.
1998 1998
 	 * @return mixed Value of the given invoice property (if set).
1999 1999
 	 */
2000
-	public function get( $key, $context = 'view' ) {
2000
+	public function get($key, $context = 'view') {
2001 2001
 		$method = "get_$key";
2002 2002
 
2003
-		if ( is_callable( array( $this, $method ) ) ) {
2004
-			return $this->$method( $context );
2003
+		if (is_callable(array($this, $method))) {
2004
+			return $this->$method($context);
2005 2005
 		}
2006 2006
 
2007
-        return $this->get_prop( $key, $context );
2007
+        return $this->get_prop($key, $context);
2008 2008
 	}
2009 2009
 
2010 2010
     /*
@@ -2027,11 +2027,11 @@  discard block
 block discarded – undo
2027 2027
 	 * @param  mixed $value new value.
2028 2028
 	 * @return mixed Value of the given invoice property (if set).
2029 2029
 	 */
2030
-	public function set( $key, $value ) {
2030
+	public function set($key, $value) {
2031 2031
 
2032 2032
         $setter = "set_$key";
2033
-        if ( is_callable( array( $this, $setter ) ) ) {
2034
-            $this->{$setter}( $value );
2033
+        if (is_callable(array($this, $setter))) {
2034
+            $this->{$setter}($value);
2035 2035
         }
2036 2036
 
2037 2037
 	}
@@ -2045,45 +2045,45 @@  discard block
 block discarded – undo
2045 2045
 	 * @param bool   $manual_update Is this a manual status change?.
2046 2046
 	 * @return array details of change.
2047 2047
 	 */
2048
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
2048
+	public function set_status($new_status, $note = '', $manual_update = false) {
2049 2049
 		$old_status = $this->get_status();
2050 2050
 
2051 2051
 		$statuses = $this->get_all_statuses();
2052 2052
 
2053
-		if ( isset( $statuses['draft'] ) ) {
2054
-			unset( $statuses['draft'] );
2053
+		if (isset($statuses['draft'])) {
2054
+			unset($statuses['draft']);
2055 2055
 		}
2056 2056
 
2057
-		$this->set_prop( 'status', $new_status );
2057
+		$this->set_prop('status', $new_status);
2058 2058
 
2059 2059
 		// If setting the status, ensure it's set to a valid status.
2060
-		if ( true === $this->object_read ) {
2060
+		if (true === $this->object_read) {
2061 2061
 
2062 2062
 			// Only allow valid new status.
2063
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
2063
+			if (!array_key_exists($new_status, $statuses)) {
2064 2064
 				$new_status = $this->get_default_status();
2065 2065
 			}
2066 2066
 
2067 2067
 			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
2068
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
2068
+			if ($old_status && !array_key_exists($new_status, $statuses)) {
2069 2069
 				$old_status = $this->get_default_status();
2070 2070
 			}
2071 2071
 
2072 2072
 			// Paid - Renewal (i.e when duplicating a parent invoice )
2073
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
2073
+			if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) {
2074 2074
 				$old_status = 'wpi-pending';
2075 2075
 			}
2076 2076
 
2077
-			if ( $old_status !== $new_status ) {
2077
+			if ($old_status !== $new_status) {
2078 2078
 				$this->status_transition = array(
2079
-					'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
2079
+					'from'   => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status,
2080 2080
 					'to'     => $new_status,
2081 2081
 					'note'   => $note,
2082 2082
 					'manual' => (bool) $manual_update,
2083 2083
 				);
2084 2084
 
2085
-				if ( $manual_update ) {
2086
-					do_action( 'getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status );
2085
+				if ($manual_update) {
2086
+					do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status);
2087 2087
 				}
2088 2088
 
2089 2089
 				$this->maybe_set_date_paid();
@@ -2107,8 +2107,8 @@  discard block
 block discarded – undo
2107 2107
 	 */
2108 2108
 	public function maybe_set_date_paid() {
2109 2109
 
2110
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2111
-			$this->set_date_completed( current_time( 'mysql' ) );
2110
+		if (!$this->get_date_completed('edit') && $this->is_paid()) {
2111
+			$this->set_date_completed(current_time('mysql'));
2112 2112
 		}
2113 2113
 	}
2114 2114
 
@@ -2117,11 +2117,11 @@  discard block
 block discarded – undo
2117 2117
 	 *
2118 2118
 	 * @since 1.0.19
2119 2119
 	 */
2120
-	public function set_parent_id( $value ) {
2121
-		if ( $value && ( $value === $this->get_id() ) ) {
2120
+	public function set_parent_id($value) {
2121
+		if ($value && ($value === $this->get_id())) {
2122 2122
 			return;
2123 2123
 		}
2124
-		$this->set_prop( 'parent_id', absint( $value ) );
2124
+		$this->set_prop('parent_id', absint($value));
2125 2125
     }
2126 2126
 
2127 2127
     /**
@@ -2129,8 +2129,8 @@  discard block
 block discarded – undo
2129 2129
 	 *
2130 2130
 	 * @since 1.0.19
2131 2131
 	 */
2132
-	public function set_version( $value ) {
2133
-		$this->set_prop( 'version', $value );
2132
+	public function set_version($value) {
2133
+		$this->set_prop('version', $value);
2134 2134
     }
2135 2135
 
2136 2136
     /**
@@ -2140,15 +2140,15 @@  discard block
 block discarded – undo
2140 2140
 	 * @param string $value Value to set.
2141 2141
      * @return bool Whether or not the date was set.
2142 2142
 	 */
2143
-	public function set_date_created( $value ) {
2144
-        $date = strtotime( $value );
2143
+	public function set_date_created($value) {
2144
+        $date = strtotime($value);
2145 2145
 
2146
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2147
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
2146
+        if ($date && $value !== '0000-00-00 00:00:00') {
2147
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
2148 2148
             return true;
2149 2149
         }
2150 2150
 
2151
-		$this->set_prop( 'date_created', '' );
2151
+		$this->set_prop('date_created', '');
2152 2152
 		return false;
2153 2153
 
2154 2154
     }
@@ -2160,15 +2160,15 @@  discard block
 block discarded – undo
2160 2160
 	 * @param string $value Value to set.
2161 2161
      * @return bool Whether or not the date was set.
2162 2162
 	 */
2163
-	public function set_due_date( $value ) {
2164
-        $date = strtotime( $value );
2163
+	public function set_due_date($value) {
2164
+        $date = strtotime($value);
2165 2165
 
2166
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2167
-            $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) );
2166
+        if ($date && $value !== '0000-00-00 00:00:00') {
2167
+            $this->set_prop('due_date', date('Y-m-d H:i:s', $date));
2168 2168
             return true;
2169 2169
         }
2170 2170
 
2171
-		$this->set_prop( 'due_date', '' );
2171
+		$this->set_prop('due_date', '');
2172 2172
         return false;
2173 2173
 
2174 2174
     }
@@ -2179,8 +2179,8 @@  discard block
 block discarded – undo
2179 2179
 	 * @since 1.0.19
2180 2180
 	 * @param  string $value New name.
2181 2181
 	 */
2182
-	public function set_date_due( $value ) {
2183
-		$this->set_due_date( $value );
2182
+	public function set_date_due($value) {
2183
+		$this->set_due_date($value);
2184 2184
     }
2185 2185
 
2186 2186
     /**
@@ -2190,15 +2190,15 @@  discard block
 block discarded – undo
2190 2190
 	 * @param string $value Value to set.
2191 2191
      * @return bool Whether or not the date was set.
2192 2192
 	 */
2193
-	public function set_completed_date( $value ) {
2194
-        $date = strtotime( $value );
2193
+	public function set_completed_date($value) {
2194
+        $date = strtotime($value);
2195 2195
 
2196
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2197
-            $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) );
2196
+        if ($date && $value !== '0000-00-00 00:00:00') {
2197
+            $this->set_prop('completed_date', date('Y-m-d H:i:s', $date));
2198 2198
             return true;
2199 2199
         }
2200 2200
 
2201
-		$this->set_prop( 'completed_date', '' );
2201
+		$this->set_prop('completed_date', '');
2202 2202
         return false;
2203 2203
 
2204 2204
     }
@@ -2209,8 +2209,8 @@  discard block
 block discarded – undo
2209 2209
 	 * @since 1.0.19
2210 2210
 	 * @param  string $value New name.
2211 2211
 	 */
2212
-	public function set_date_completed( $value ) {
2213
-		$this->set_completed_date( $value );
2212
+	public function set_date_completed($value) {
2213
+		$this->set_completed_date($value);
2214 2214
     }
2215 2215
 
2216 2216
     /**
@@ -2220,15 +2220,15 @@  discard block
 block discarded – undo
2220 2220
 	 * @param string $value Value to set.
2221 2221
      * @return bool Whether or not the date was set.
2222 2222
 	 */
2223
-	public function set_date_modified( $value ) {
2224
-        $date = strtotime( $value );
2223
+	public function set_date_modified($value) {
2224
+        $date = strtotime($value);
2225 2225
 
2226
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2227
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
2226
+        if ($date && $value !== '0000-00-00 00:00:00') {
2227
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
2228 2228
             return true;
2229 2229
         }
2230 2230
 
2231
-		$this->set_prop( 'date_modified', '' );
2231
+		$this->set_prop('date_modified', '');
2232 2232
         return false;
2233 2233
 
2234 2234
     }
@@ -2239,9 +2239,9 @@  discard block
 block discarded – undo
2239 2239
 	 * @since 1.0.19
2240 2240
 	 * @param  string $value New number.
2241 2241
 	 */
2242
-	public function set_number( $value ) {
2243
-        $number = sanitize_text_field( $value );
2244
-		$this->set_prop( 'number', $number );
2242
+	public function set_number($value) {
2243
+        $number = sanitize_text_field($value);
2244
+		$this->set_prop('number', $number);
2245 2245
     }
2246 2246
 
2247 2247
     /**
@@ -2250,9 +2250,9 @@  discard block
 block discarded – undo
2250 2250
 	 * @since 1.0.19
2251 2251
 	 * @param  string $value Type.
2252 2252
 	 */
2253
-	public function set_type( $value ) {
2254
-        $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2255
-		$this->set_prop( 'type', $type );
2253
+	public function set_type($value) {
2254
+        $type = sanitize_text_field(str_replace('wpi_', '', $value));
2255
+		$this->set_prop('type', $type);
2256 2256
 	}
2257 2257
 
2258 2258
     /**
@@ -2261,10 +2261,10 @@  discard block
 block discarded – undo
2261 2261
 	 * @since 1.0.19
2262 2262
 	 * @param  string $value Post type.
2263 2263
 	 */
2264
-	public function set_post_type( $value ) {
2265
-        if ( getpaid_is_invoice_post_type( $value ) ) {
2266
-			$this->set_type( $value );
2267
-            $this->set_prop( 'post_type', $value );
2264
+	public function set_post_type($value) {
2265
+        if (getpaid_is_invoice_post_type($value)) {
2266
+			$this->set_type($value);
2267
+            $this->set_prop('post_type', $value);
2268 2268
         }
2269 2269
     }
2270 2270
 
@@ -2274,9 +2274,9 @@  discard block
 block discarded – undo
2274 2274
 	 * @since 1.0.19
2275 2275
 	 * @param  string $value New key.
2276 2276
 	 */
2277
-	public function set_key( $value ) {
2278
-        $key = sanitize_text_field( $value );
2279
-		$this->set_prop( 'key', $key );
2277
+	public function set_key($value) {
2278
+        $key = sanitize_text_field($value);
2279
+		$this->set_prop('key', $key);
2280 2280
     }
2281 2281
 
2282 2282
     /**
@@ -2285,9 +2285,9 @@  discard block
 block discarded – undo
2285 2285
 	 * @since 1.0.19
2286 2286
 	 * @param  string $value mode.
2287 2287
 	 */
2288
-	public function set_mode( $value ) {
2289
-        if ( in_array( $value, array( 'live', 'test' ) ) ) {
2290
-            $this->set_prop( 'mode', $value );
2288
+	public function set_mode($value) {
2289
+        if (in_array($value, array('live', 'test'))) {
2290
+            $this->set_prop('mode', $value);
2291 2291
         }
2292 2292
     }
2293 2293
 
@@ -2297,8 +2297,8 @@  discard block
 block discarded – undo
2297 2297
 	 * @since 1.0.19
2298 2298
 	 * @param  string $value path.
2299 2299
 	 */
2300
-	public function set_path( $value ) {
2301
-        $this->set_prop( 'path', $value );
2300
+	public function set_path($value) {
2301
+        $this->set_prop('path', $value);
2302 2302
     }
2303 2303
 
2304 2304
     /**
@@ -2307,9 +2307,9 @@  discard block
 block discarded – undo
2307 2307
 	 * @since 1.0.19
2308 2308
 	 * @param  string $value New name.
2309 2309
 	 */
2310
-	public function set_name( $value ) {
2311
-        $name = sanitize_text_field( $value );
2312
-		$this->set_prop( 'name', $name );
2310
+	public function set_name($value) {
2311
+        $name = sanitize_text_field($value);
2312
+		$this->set_prop('name', $name);
2313 2313
     }
2314 2314
 
2315 2315
     /**
@@ -2318,8 +2318,8 @@  discard block
 block discarded – undo
2318 2318
 	 * @since 1.0.19
2319 2319
 	 * @param  string $value New name.
2320 2320
 	 */
2321
-	public function set_title( $value ) {
2322
-		$this->set_name( $value );
2321
+	public function set_title($value) {
2322
+		$this->set_name($value);
2323 2323
     }
2324 2324
 
2325 2325
     /**
@@ -2328,9 +2328,9 @@  discard block
 block discarded – undo
2328 2328
 	 * @since 1.0.19
2329 2329
 	 * @param  string $value New description.
2330 2330
 	 */
2331
-	public function set_description( $value ) {
2332
-        $description = wp_kses_post( $value );
2333
-		$this->set_prop( 'description', $description );
2331
+	public function set_description($value) {
2332
+        $description = wp_kses_post($value);
2333
+		$this->set_prop('description', $description);
2334 2334
     }
2335 2335
 
2336 2336
     /**
@@ -2339,8 +2339,8 @@  discard block
 block discarded – undo
2339 2339
 	 * @since 1.0.19
2340 2340
 	 * @param  string $value New description.
2341 2341
 	 */
2342
-	public function set_excerpt( $value ) {
2343
-		$this->set_description( $value );
2342
+	public function set_excerpt($value) {
2343
+		$this->set_description($value);
2344 2344
     }
2345 2345
 
2346 2346
     /**
@@ -2349,8 +2349,8 @@  discard block
 block discarded – undo
2349 2349
 	 * @since 1.0.19
2350 2350
 	 * @param  string $value New description.
2351 2351
 	 */
2352
-	public function set_summary( $value ) {
2353
-		$this->set_description( $value );
2352
+	public function set_summary($value) {
2353
+		$this->set_description($value);
2354 2354
     }
2355 2355
 
2356 2356
     /**
@@ -2359,12 +2359,12 @@  discard block
 block discarded – undo
2359 2359
 	 * @since 1.0.19
2360 2360
 	 * @param  int $value New author.
2361 2361
 	 */
2362
-	public function set_author( $value ) {
2363
-		$user = get_user_by( 'id', (int) $value );
2362
+	public function set_author($value) {
2363
+		$user = get_user_by('id', (int) $value);
2364 2364
 
2365
-		if ( $user && $user->ID ) {
2366
-			$this->set_prop( 'author', $user->ID );
2367
-			$this->set_prop( 'email', $user->user_email );
2365
+		if ($user && $user->ID) {
2366
+			$this->set_prop('author', $user->ID);
2367
+			$this->set_prop('email', $user->user_email);
2368 2368
 		}
2369 2369
 
2370 2370
     }
@@ -2375,8 +2375,8 @@  discard block
 block discarded – undo
2375 2375
 	 * @since 1.0.19
2376 2376
 	 * @param  int $value New user id.
2377 2377
 	 */
2378
-	public function set_user_id( $value ) {
2379
-		$this->set_author( $value );
2378
+	public function set_user_id($value) {
2379
+		$this->set_author($value);
2380 2380
     }
2381 2381
 
2382 2382
     /**
@@ -2385,8 +2385,8 @@  discard block
 block discarded – undo
2385 2385
 	 * @since 1.0.19
2386 2386
 	 * @param  int $value New user id.
2387 2387
 	 */
2388
-	public function set_customer_id( $value ) {
2389
-		$this->set_prop( 'customer_id', (int) $value );
2388
+	public function set_customer_id($value) {
2389
+		$this->set_prop('customer_id', (int) $value);
2390 2390
     }
2391 2391
 
2392 2392
     /**
@@ -2395,8 +2395,8 @@  discard block
 block discarded – undo
2395 2395
 	 * @since 1.0.19
2396 2396
 	 * @param  string $value ip address.
2397 2397
 	 */
2398
-	public function set_ip( $value ) {
2399
-		$this->set_prop( 'ip', $value );
2398
+	public function set_ip($value) {
2399
+		$this->set_prop('ip', $value);
2400 2400
     }
2401 2401
 
2402 2402
     /**
@@ -2405,8 +2405,8 @@  discard block
 block discarded – undo
2405 2405
 	 * @since 1.0.19
2406 2406
 	 * @param  string $value ip address.
2407 2407
 	 */
2408
-	public function set_user_ip( $value ) {
2409
-		$this->set_ip( $value );
2408
+	public function set_user_ip($value) {
2409
+		$this->set_ip($value);
2410 2410
     }
2411 2411
 
2412 2412
     /**
@@ -2415,8 +2415,8 @@  discard block
 block discarded – undo
2415 2415
 	 * @since 1.0.19
2416 2416
 	 * @param  string $value first name.
2417 2417
 	 */
2418
-	public function set_first_name( $value ) {
2419
-		$this->set_prop( 'first_name', $value );
2418
+	public function set_first_name($value) {
2419
+		$this->set_prop('first_name', $value);
2420 2420
     }
2421 2421
 
2422 2422
     /**
@@ -2425,8 +2425,8 @@  discard block
 block discarded – undo
2425 2425
 	 * @since 1.0.19
2426 2426
 	 * @param  string $value first name.
2427 2427
 	 */
2428
-	public function set_user_first_name( $value ) {
2429
-		$this->set_first_name( $value );
2428
+	public function set_user_first_name($value) {
2429
+		$this->set_first_name($value);
2430 2430
     }
2431 2431
 
2432 2432
     /**
@@ -2435,8 +2435,8 @@  discard block
 block discarded – undo
2435 2435
 	 * @since 1.0.19
2436 2436
 	 * @param  string $value first name.
2437 2437
 	 */
2438
-	public function set_customer_first_name( $value ) {
2439
-		$this->set_first_name( $value );
2438
+	public function set_customer_first_name($value) {
2439
+		$this->set_first_name($value);
2440 2440
     }
2441 2441
 
2442 2442
     /**
@@ -2445,8 +2445,8 @@  discard block
 block discarded – undo
2445 2445
 	 * @since 1.0.19
2446 2446
 	 * @param  string $value last name.
2447 2447
 	 */
2448
-	public function set_last_name( $value ) {
2449
-		$this->set_prop( 'last_name', $value );
2448
+	public function set_last_name($value) {
2449
+		$this->set_prop('last_name', $value);
2450 2450
     }
2451 2451
 
2452 2452
     /**
@@ -2455,8 +2455,8 @@  discard block
 block discarded – undo
2455 2455
 	 * @since 1.0.19
2456 2456
 	 * @param  string $value last name.
2457 2457
 	 */
2458
-	public function set_user_last_name( $value ) {
2459
-		$this->set_last_name( $value );
2458
+	public function set_user_last_name($value) {
2459
+		$this->set_last_name($value);
2460 2460
     }
2461 2461
 
2462 2462
     /**
@@ -2465,8 +2465,8 @@  discard block
 block discarded – undo
2465 2465
 	 * @since 1.0.19
2466 2466
 	 * @param  string $value last name.
2467 2467
 	 */
2468
-	public function set_customer_last_name( $value ) {
2469
-		$this->set_last_name( $value );
2468
+	public function set_customer_last_name($value) {
2469
+		$this->set_last_name($value);
2470 2470
     }
2471 2471
 
2472 2472
     /**
@@ -2475,8 +2475,8 @@  discard block
 block discarded – undo
2475 2475
 	 * @since 1.0.19
2476 2476
 	 * @param  string $value phone.
2477 2477
 	 */
2478
-	public function set_phone( $value ) {
2479
-		$this->set_prop( 'phone', $value );
2478
+	public function set_phone($value) {
2479
+		$this->set_prop('phone', $value);
2480 2480
     }
2481 2481
 
2482 2482
     /**
@@ -2485,8 +2485,8 @@  discard block
 block discarded – undo
2485 2485
 	 * @since 1.0.19
2486 2486
 	 * @param  string $value phone.
2487 2487
 	 */
2488
-	public function set_user_phone( $value ) {
2489
-		$this->set_phone( $value );
2488
+	public function set_user_phone($value) {
2489
+		$this->set_phone($value);
2490 2490
     }
2491 2491
 
2492 2492
     /**
@@ -2495,8 +2495,8 @@  discard block
 block discarded – undo
2495 2495
 	 * @since 1.0.19
2496 2496
 	 * @param  string $value phone.
2497 2497
 	 */
2498
-	public function set_customer_phone( $value ) {
2499
-		$this->set_phone( $value );
2498
+	public function set_customer_phone($value) {
2499
+		$this->set_phone($value);
2500 2500
     }
2501 2501
 
2502 2502
     /**
@@ -2505,8 +2505,8 @@  discard block
 block discarded – undo
2505 2505
 	 * @since 1.0.19
2506 2506
 	 * @param  string $value phone.
2507 2507
 	 */
2508
-	public function set_phone_number( $value ) {
2509
-		$this->set_phone( $value );
2508
+	public function set_phone_number($value) {
2509
+		$this->set_phone($value);
2510 2510
     }
2511 2511
 
2512 2512
     /**
@@ -2515,8 +2515,8 @@  discard block
 block discarded – undo
2515 2515
 	 * @since 1.0.19
2516 2516
 	 * @param  string $value email address.
2517 2517
 	 */
2518
-	public function set_email( $value ) {
2519
-		$this->set_prop( 'email', $value );
2518
+	public function set_email($value) {
2519
+		$this->set_prop('email', $value);
2520 2520
     }
2521 2521
 
2522 2522
     /**
@@ -2525,8 +2525,8 @@  discard block
 block discarded – undo
2525 2525
 	 * @since 1.0.19
2526 2526
 	 * @param  string $value email address.
2527 2527
 	 */
2528
-	public function set_user_email( $value ) {
2529
-		$this->set_email( $value );
2528
+	public function set_user_email($value) {
2529
+		$this->set_email($value);
2530 2530
     }
2531 2531
 
2532 2532
     /**
@@ -2535,8 +2535,8 @@  discard block
 block discarded – undo
2535 2535
 	 * @since 1.0.19
2536 2536
 	 * @param  string $value email address.
2537 2537
 	 */
2538
-	public function set_email_address( $value ) {
2539
-		$this->set_email( $value );
2538
+	public function set_email_address($value) {
2539
+		$this->set_email($value);
2540 2540
     }
2541 2541
 
2542 2542
     /**
@@ -2545,8 +2545,8 @@  discard block
 block discarded – undo
2545 2545
 	 * @since 1.0.19
2546 2546
 	 * @param  string $value email address.
2547 2547
 	 */
2548
-	public function set_customer_email( $value ) {
2549
-		$this->set_email( $value );
2548
+	public function set_customer_email($value) {
2549
+		$this->set_email($value);
2550 2550
     }
2551 2551
 
2552 2552
     /**
@@ -2555,8 +2555,8 @@  discard block
 block discarded – undo
2555 2555
 	 * @since 1.0.19
2556 2556
 	 * @param  string $value country.
2557 2557
 	 */
2558
-	public function set_country( $value ) {
2559
-		$this->set_prop( 'country', $value );
2558
+	public function set_country($value) {
2559
+		$this->set_prop('country', $value);
2560 2560
     }
2561 2561
 
2562 2562
     /**
@@ -2565,8 +2565,8 @@  discard block
 block discarded – undo
2565 2565
 	 * @since 1.0.19
2566 2566
 	 * @param  string $value country.
2567 2567
 	 */
2568
-	public function set_user_country( $value ) {
2569
-		$this->set_country( $value );
2568
+	public function set_user_country($value) {
2569
+		$this->set_country($value);
2570 2570
     }
2571 2571
 
2572 2572
     /**
@@ -2575,8 +2575,8 @@  discard block
 block discarded – undo
2575 2575
 	 * @since 1.0.19
2576 2576
 	 * @param  string $value country.
2577 2577
 	 */
2578
-	public function set_customer_country( $value ) {
2579
-		$this->set_country( $value );
2578
+	public function set_customer_country($value) {
2579
+		$this->set_country($value);
2580 2580
     }
2581 2581
 
2582 2582
     /**
@@ -2585,8 +2585,8 @@  discard block
 block discarded – undo
2585 2585
 	 * @since 1.0.19
2586 2586
 	 * @param  string $value state.
2587 2587
 	 */
2588
-	public function set_state( $value ) {
2589
-		$this->set_prop( 'state', $value );
2588
+	public function set_state($value) {
2589
+		$this->set_prop('state', $value);
2590 2590
     }
2591 2591
 
2592 2592
     /**
@@ -2595,8 +2595,8 @@  discard block
 block discarded – undo
2595 2595
 	 * @since 1.0.19
2596 2596
 	 * @param  string $value state.
2597 2597
 	 */
2598
-	public function set_user_state( $value ) {
2599
-		$this->set_state( $value );
2598
+	public function set_user_state($value) {
2599
+		$this->set_state($value);
2600 2600
     }
2601 2601
 
2602 2602
     /**
@@ -2605,8 +2605,8 @@  discard block
 block discarded – undo
2605 2605
 	 * @since 1.0.19
2606 2606
 	 * @param  string $value state.
2607 2607
 	 */
2608
-	public function set_customer_state( $value ) {
2609
-		$this->set_state( $value );
2608
+	public function set_customer_state($value) {
2609
+		$this->set_state($value);
2610 2610
     }
2611 2611
 
2612 2612
     /**
@@ -2615,8 +2615,8 @@  discard block
 block discarded – undo
2615 2615
 	 * @since 1.0.19
2616 2616
 	 * @param  string $value city.
2617 2617
 	 */
2618
-	public function set_city( $value ) {
2619
-		$this->set_prop( 'city', $value );
2618
+	public function set_city($value) {
2619
+		$this->set_prop('city', $value);
2620 2620
     }
2621 2621
 
2622 2622
     /**
@@ -2625,8 +2625,8 @@  discard block
 block discarded – undo
2625 2625
 	 * @since 1.0.19
2626 2626
 	 * @param  string $value city.
2627 2627
 	 */
2628
-	public function set_user_city( $value ) {
2629
-		$this->set_city( $value );
2628
+	public function set_user_city($value) {
2629
+		$this->set_city($value);
2630 2630
     }
2631 2631
 
2632 2632
     /**
@@ -2635,8 +2635,8 @@  discard block
 block discarded – undo
2635 2635
 	 * @since 1.0.19
2636 2636
 	 * @param  string $value city.
2637 2637
 	 */
2638
-	public function set_customer_city( $value ) {
2639
-		$this->set_city( $value );
2638
+	public function set_customer_city($value) {
2639
+		$this->set_city($value);
2640 2640
     }
2641 2641
 
2642 2642
     /**
@@ -2645,8 +2645,8 @@  discard block
 block discarded – undo
2645 2645
 	 * @since 1.0.19
2646 2646
 	 * @param  string $value zip.
2647 2647
 	 */
2648
-	public function set_zip( $value ) {
2649
-		$this->set_prop( 'zip', $value );
2648
+	public function set_zip($value) {
2649
+		$this->set_prop('zip', $value);
2650 2650
     }
2651 2651
 
2652 2652
     /**
@@ -2655,8 +2655,8 @@  discard block
 block discarded – undo
2655 2655
 	 * @since 1.0.19
2656 2656
 	 * @param  string $value zip.
2657 2657
 	 */
2658
-	public function set_user_zip( $value ) {
2659
-		$this->set_zip( $value );
2658
+	public function set_user_zip($value) {
2659
+		$this->set_zip($value);
2660 2660
     }
2661 2661
 
2662 2662
     /**
@@ -2665,8 +2665,8 @@  discard block
 block discarded – undo
2665 2665
 	 * @since 1.0.19
2666 2666
 	 * @param  string $value zip.
2667 2667
 	 */
2668
-	public function set_customer_zip( $value ) {
2669
-		$this->set_zip( $value );
2668
+	public function set_customer_zip($value) {
2669
+		$this->set_zip($value);
2670 2670
     }
2671 2671
 
2672 2672
     /**
@@ -2675,8 +2675,8 @@  discard block
 block discarded – undo
2675 2675
 	 * @since 1.0.19
2676 2676
 	 * @param  string $value company.
2677 2677
 	 */
2678
-	public function set_company( $value ) {
2679
-		$this->set_prop( 'company', $value );
2678
+	public function set_company($value) {
2679
+		$this->set_prop('company', $value);
2680 2680
     }
2681 2681
 
2682 2682
     /**
@@ -2685,8 +2685,8 @@  discard block
 block discarded – undo
2685 2685
 	 * @since 1.0.19
2686 2686
 	 * @param  string $value company.
2687 2687
 	 */
2688
-	public function set_user_company( $value ) {
2689
-		$this->set_company( $value );
2688
+	public function set_user_company($value) {
2689
+		$this->set_company($value);
2690 2690
     }
2691 2691
 
2692 2692
     /**
@@ -2695,8 +2695,8 @@  discard block
 block discarded – undo
2695 2695
 	 * @since 1.0.19
2696 2696
 	 * @param  string $value company.
2697 2697
 	 */
2698
-	public function set_customer_company( $value ) {
2699
-		$this->set_company( $value );
2698
+	public function set_customer_company($value) {
2699
+		$this->set_company($value);
2700 2700
     }
2701 2701
 
2702 2702
 	/**
@@ -2705,8 +2705,8 @@  discard block
 block discarded – undo
2705 2705
 	 * @since 1.0.19
2706 2706
 	 * @param  string $value company id.
2707 2707
 	 */
2708
-	public function set_company_id( $value ) {
2709
-		$this->set_prop( 'company_id', $value );
2708
+	public function set_company_id($value) {
2709
+		$this->set_prop('company_id', $value);
2710 2710
     }
2711 2711
 
2712 2712
     /**
@@ -2715,8 +2715,8 @@  discard block
 block discarded – undo
2715 2715
 	 * @since 1.0.19
2716 2716
 	 * @param  string $value var number.
2717 2717
 	 */
2718
-	public function set_vat_number( $value ) {
2719
-		$this->set_prop( 'vat_number', $value );
2718
+	public function set_vat_number($value) {
2719
+		$this->set_prop('vat_number', $value);
2720 2720
     }
2721 2721
 
2722 2722
     /**
@@ -2725,8 +2725,8 @@  discard block
 block discarded – undo
2725 2725
 	 * @since 1.0.19
2726 2726
 	 * @param  string $value var number.
2727 2727
 	 */
2728
-	public function set_user_vat_number( $value ) {
2729
-		$this->set_vat_number( $value );
2728
+	public function set_user_vat_number($value) {
2729
+		$this->set_vat_number($value);
2730 2730
     }
2731 2731
 
2732 2732
     /**
@@ -2735,8 +2735,8 @@  discard block
 block discarded – undo
2735 2735
 	 * @since 1.0.19
2736 2736
 	 * @param  string $value var number.
2737 2737
 	 */
2738
-	public function set_customer_vat_number( $value ) {
2739
-		$this->set_vat_number( $value );
2738
+	public function set_customer_vat_number($value) {
2739
+		$this->set_vat_number($value);
2740 2740
     }
2741 2741
 
2742 2742
     /**
@@ -2745,8 +2745,8 @@  discard block
 block discarded – undo
2745 2745
 	 * @since 1.0.19
2746 2746
 	 * @param  string $value var rate.
2747 2747
 	 */
2748
-	public function set_vat_rate( $value ) {
2749
-		$this->set_prop( 'vat_rate', $value );
2748
+	public function set_vat_rate($value) {
2749
+		$this->set_prop('vat_rate', $value);
2750 2750
     }
2751 2751
 
2752 2752
     /**
@@ -2755,8 +2755,8 @@  discard block
 block discarded – undo
2755 2755
 	 * @since 1.0.19
2756 2756
 	 * @param  string $value var number.
2757 2757
 	 */
2758
-	public function set_user_vat_rate( $value ) {
2759
-		$this->set_vat_rate( $value );
2758
+	public function set_user_vat_rate($value) {
2759
+		$this->set_vat_rate($value);
2760 2760
     }
2761 2761
 
2762 2762
     /**
@@ -2765,8 +2765,8 @@  discard block
 block discarded – undo
2765 2765
 	 * @since 1.0.19
2766 2766
 	 * @param  string $value var number.
2767 2767
 	 */
2768
-	public function set_customer_vat_rate( $value ) {
2769
-		$this->set_vat_rate( $value );
2768
+	public function set_customer_vat_rate($value) {
2769
+		$this->set_vat_rate($value);
2770 2770
     }
2771 2771
 
2772 2772
     /**
@@ -2775,8 +2775,8 @@  discard block
 block discarded – undo
2775 2775
 	 * @since 1.0.19
2776 2776
 	 * @param  string $value address.
2777 2777
 	 */
2778
-	public function set_address( $value ) {
2779
-		$this->set_prop( 'address', $value );
2778
+	public function set_address($value) {
2779
+		$this->set_prop('address', $value);
2780 2780
     }
2781 2781
 
2782 2782
     /**
@@ -2785,8 +2785,8 @@  discard block
 block discarded – undo
2785 2785
 	 * @since 1.0.19
2786 2786
 	 * @param  string $value address.
2787 2787
 	 */
2788
-	public function set_user_address( $value ) {
2789
-		$this->set_address( $value );
2788
+	public function set_user_address($value) {
2789
+		$this->set_address($value);
2790 2790
     }
2791 2791
 
2792 2792
     /**
@@ -2795,8 +2795,8 @@  discard block
 block discarded – undo
2795 2795
 	 * @since 1.0.19
2796 2796
 	 * @param  string $value address.
2797 2797
 	 */
2798
-	public function set_customer_address( $value ) {
2799
-		$this->set_address( $value );
2798
+	public function set_customer_address($value) {
2799
+		$this->set_address($value);
2800 2800
     }
2801 2801
 
2802 2802
     /**
@@ -2805,8 +2805,8 @@  discard block
 block discarded – undo
2805 2805
 	 * @since 1.0.19
2806 2806
 	 * @param  int|bool $value confirmed.
2807 2807
 	 */
2808
-	public function set_is_viewed( $value ) {
2809
-		$this->set_prop( 'is_viewed', $value );
2808
+	public function set_is_viewed($value) {
2809
+		$this->set_prop('is_viewed', $value);
2810 2810
 	}
2811 2811
 
2812 2812
 	/**
@@ -2815,8 +2815,8 @@  discard block
 block discarded – undo
2815 2815
 	 * @since 1.0.19
2816 2816
 	 * @param  string $value email recipients.
2817 2817
 	 */
2818
-	public function set_email_cc( $value ) {
2819
-		$this->set_prop( 'email_cc', $value );
2818
+	public function set_email_cc($value) {
2819
+		$this->set_prop('email_cc', $value);
2820 2820
 	}
2821 2821
 
2822 2822
 	/**
@@ -2825,9 +2825,9 @@  discard block
 block discarded – undo
2825 2825
 	 * @since 1.0.19
2826 2826
 	 * @param  string $value template.
2827 2827
 	 */
2828
-	public function set_template( $value ) {
2829
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2830
-			$this->set_prop( 'template', $value );
2828
+	public function set_template($value) {
2829
+		if (in_array($value, array('quantity', 'hours', 'amount'))) {
2830
+			$this->set_prop('template', $value);
2831 2831
 		}
2832 2832
 	}
2833 2833
 
@@ -2838,8 +2838,8 @@  discard block
 block discarded – undo
2838 2838
 	 * @param  string $value source.
2839 2839
 	 * @deprecated
2840 2840
 	 */
2841
-	public function created_via( $value ) {
2842
-		$this->set_created_via( sanitize_text_field( $value ) );
2841
+	public function created_via($value) {
2842
+		$this->set_created_via(sanitize_text_field($value));
2843 2843
 	}
2844 2844
 
2845 2845
 	/**
@@ -2848,8 +2848,8 @@  discard block
 block discarded – undo
2848 2848
 	 * @since 1.0.19
2849 2849
 	 * @param  string $value source.
2850 2850
 	 */
2851
-	public function set_created_via( $value ) {
2852
-		$this->set_prop( 'created_via', sanitize_text_field( $value ) );
2851
+	public function set_created_via($value) {
2852
+		$this->set_prop('created_via', sanitize_text_field($value));
2853 2853
 	}
2854 2854
 
2855 2855
 	/**
@@ -2858,8 +2858,8 @@  discard block
 block discarded – undo
2858 2858
 	 * @since 1.0.19
2859 2859
 	 * @param  int|bool $value confirmed.
2860 2860
 	 */
2861
-	public function set_address_confirmed( $value ) {
2862
-		$this->set_prop( 'address_confirmed', $value );
2861
+	public function set_address_confirmed($value) {
2862
+		$this->set_prop('address_confirmed', $value);
2863 2863
     }
2864 2864
 
2865 2865
     /**
@@ -2868,8 +2868,8 @@  discard block
 block discarded – undo
2868 2868
 	 * @since 1.0.19
2869 2869
 	 * @param  int|bool $value confirmed.
2870 2870
 	 */
2871
-	public function set_user_address_confirmed( $value ) {
2872
-		$this->set_address_confirmed( $value );
2871
+	public function set_user_address_confirmed($value) {
2872
+		$this->set_address_confirmed($value);
2873 2873
     }
2874 2874
 
2875 2875
     /**
@@ -2878,8 +2878,8 @@  discard block
 block discarded – undo
2878 2878
 	 * @since 1.0.19
2879 2879
 	 * @param  int|bool $value confirmed.
2880 2880
 	 */
2881
-	public function set_customer_address_confirmed( $value ) {
2882
-		$this->set_address_confirmed( $value );
2881
+	public function set_customer_address_confirmed($value) {
2882
+		$this->set_address_confirmed($value);
2883 2883
     }
2884 2884
 
2885 2885
     /**
@@ -2888,13 +2888,13 @@  discard block
 block discarded – undo
2888 2888
 	 * @since 1.0.19
2889 2889
 	 * @param  float $value shipping amount.
2890 2890
 	 */
2891
-	public function set_shipping( $value ) {
2891
+	public function set_shipping($value) {
2892 2892
 
2893
-		if ( ! is_numeric( $value ) ) {
2894
-			return $this->set_prop( 'shipping', null );
2893
+		if (!is_numeric($value)) {
2894
+			return $this->set_prop('shipping', null);
2895 2895
 		}
2896 2896
 
2897
-		$this->set_prop( 'shipping', max( 0, floatval( $value ) ) );
2897
+		$this->set_prop('shipping', max(0, floatval($value)));
2898 2898
 	}
2899 2899
 
2900 2900
 	/**
@@ -2903,8 +2903,8 @@  discard block
 block discarded – undo
2903 2903
 	 * @since 1.0.19
2904 2904
 	 * @param  float $value sub total.
2905 2905
 	 */
2906
-	public function set_subtotal( $value ) {
2907
-		$this->set_prop( 'subtotal', max( 0, $value ) );
2906
+	public function set_subtotal($value) {
2907
+		$this->set_prop('subtotal', max(0, $value));
2908 2908
 	}
2909 2909
 
2910 2910
 	/**
@@ -2913,8 +2913,8 @@  discard block
 block discarded – undo
2913 2913
 	 * @since 1.0.19
2914 2914
 	 * @param  float $value sub total.
2915 2915
 	 */
2916
-	public function set_total( $value ) {
2917
-		$this->set_prop( 'total', max( 0, $value ) );
2916
+	public function set_total($value) {
2917
+		$this->set_prop('total', max(0, $value));
2918 2918
     }
2919 2919
 
2920 2920
     /**
@@ -2923,8 +2923,8 @@  discard block
 block discarded – undo
2923 2923
 	 * @since 1.0.19
2924 2924
 	 * @param  float $value discount total.
2925 2925
 	 */
2926
-	public function set_total_discount( $value ) {
2927
-		$this->set_prop( 'total_discount', max( 0, $value ) );
2926
+	public function set_total_discount($value) {
2927
+		$this->set_prop('total_discount', max(0, $value));
2928 2928
     }
2929 2929
 
2930 2930
     /**
@@ -2933,8 +2933,8 @@  discard block
 block discarded – undo
2933 2933
 	 * @since 1.0.19
2934 2934
 	 * @param  float $value discount total.
2935 2935
 	 */
2936
-	public function set_discount( $value ) {
2937
-		$this->set_total_discount( $value );
2936
+	public function set_discount($value) {
2937
+		$this->set_total_discount($value);
2938 2938
     }
2939 2939
 
2940 2940
     /**
@@ -2943,8 +2943,8 @@  discard block
 block discarded – undo
2943 2943
 	 * @since 1.0.19
2944 2944
 	 * @param  float $value tax total.
2945 2945
 	 */
2946
-	public function set_total_tax( $value ) {
2947
-		$this->set_prop( 'total_tax', max( 0, $value ) );
2946
+	public function set_total_tax($value) {
2947
+		$this->set_prop('total_tax', max(0, $value));
2948 2948
     }
2949 2949
 
2950 2950
     /**
@@ -2953,8 +2953,8 @@  discard block
 block discarded – undo
2953 2953
 	 * @since 1.0.19
2954 2954
 	 * @param  float $value tax total.
2955 2955
 	 */
2956
-	public function set_tax_total( $value ) {
2957
-		$this->set_total_tax( $value );
2956
+	public function set_tax_total($value) {
2957
+		$this->set_total_tax($value);
2958 2958
     }
2959 2959
 
2960 2960
     /**
@@ -2963,8 +2963,8 @@  discard block
 block discarded – undo
2963 2963
 	 * @since 1.0.19
2964 2964
 	 * @param  float $value fees total.
2965 2965
 	 */
2966
-	public function set_total_fees( $value ) {
2967
-		$this->set_prop( 'total_fees', max( 0, $value ) );
2966
+	public function set_total_fees($value) {
2967
+		$this->set_prop('total_fees', max(0, $value));
2968 2968
     }
2969 2969
 
2970 2970
     /**
@@ -2973,8 +2973,8 @@  discard block
 block discarded – undo
2973 2973
 	 * @since 1.0.19
2974 2974
 	 * @param  float $value fees total.
2975 2975
 	 */
2976
-	public function set_fees_total( $value ) {
2977
-		$this->set_total_fees( $value );
2976
+	public function set_fees_total($value) {
2977
+		$this->set_total_fees($value);
2978 2978
     }
2979 2979
 
2980 2980
     /**
@@ -2983,13 +2983,13 @@  discard block
 block discarded – undo
2983 2983
 	 * @since 1.0.19
2984 2984
 	 * @param  array $value fees.
2985 2985
 	 */
2986
-	public function set_fees( $value ) {
2986
+	public function set_fees($value) {
2987 2987
 
2988
-		if ( ! is_array( $value ) ) {
2988
+		if (!is_array($value)) {
2989 2989
 			$value = array();
2990 2990
 		}
2991 2991
 
2992
-		$this->set_prop( 'fees', $value );
2992
+		$this->set_prop('fees', $value);
2993 2993
 
2994 2994
     }
2995 2995
 
@@ -2999,13 +2999,13 @@  discard block
 block discarded – undo
2999 2999
 	 * @since 1.0.19
3000 3000
 	 * @param  array $value taxes.
3001 3001
 	 */
3002
-	public function set_taxes( $value ) {
3002
+	public function set_taxes($value) {
3003 3003
 
3004
-		if ( ! is_array( $value ) ) {
3004
+		if (!is_array($value)) {
3005 3005
 			$value = array();
3006 3006
 		}
3007 3007
 
3008
-		$this->set_prop( 'taxes', $value );
3008
+		$this->set_prop('taxes', $value);
3009 3009
 
3010 3010
     }
3011 3011
 
@@ -3015,13 +3015,13 @@  discard block
 block discarded – undo
3015 3015
 	 * @since 1.0.19
3016 3016
 	 * @param  array $value discounts.
3017 3017
 	 */
3018
-	public function set_discounts( $value ) {
3018
+	public function set_discounts($value) {
3019 3019
 
3020
-		if ( ! is_array( $value ) ) {
3020
+		if (!is_array($value)) {
3021 3021
 			$value = array();
3022 3022
 		}
3023 3023
 
3024
-		$this->set_prop( 'discounts', $value );
3024
+		$this->set_prop('discounts', $value);
3025 3025
     }
3026 3026
 
3027 3027
     /**
@@ -3030,19 +3030,19 @@  discard block
 block discarded – undo
3030 3030
 	 * @since 1.0.19
3031 3031
 	 * @param  GetPaid_Form_Item[] $value items.
3032 3032
 	 */
3033
-	public function set_items( $value ) {
3033
+	public function set_items($value) {
3034 3034
 
3035 3035
         // Remove existing items.
3036
-        $this->set_prop( 'items', array() );
3036
+        $this->set_prop('items', array());
3037 3037
 		$this->recurring_item = null;
3038 3038
 
3039 3039
         // Ensure that we have an array.
3040
-        if ( ! is_array( $value ) ) {
3040
+        if (!is_array($value)) {
3041 3041
             return;
3042 3042
         }
3043 3043
 
3044
-        foreach ( $value as $item ) {
3045
-            $this->add_item( $item );
3044
+        foreach ($value as $item) {
3045
+            $this->add_item($item);
3046 3046
         }
3047 3047
 
3048 3048
     }
@@ -3053,8 +3053,8 @@  discard block
 block discarded – undo
3053 3053
 	 * @since 1.0.19
3054 3054
 	 * @param  int $value payment form.
3055 3055
 	 */
3056
-	public function set_payment_form( $value ) {
3057
-		$this->set_prop( 'payment_form', $value );
3056
+	public function set_payment_form($value) {
3057
+		$this->set_prop('payment_form', $value);
3058 3058
     }
3059 3059
 
3060 3060
     /**
@@ -3063,8 +3063,8 @@  discard block
 block discarded – undo
3063 3063
 	 * @since 1.0.19
3064 3064
 	 * @param  string $value submission id.
3065 3065
 	 */
3066
-	public function set_submission_id( $value ) {
3067
-		$this->set_prop( 'submission_id', $value );
3066
+	public function set_submission_id($value) {
3067
+		$this->set_prop('submission_id', $value);
3068 3068
     }
3069 3069
 
3070 3070
     /**
@@ -3073,8 +3073,8 @@  discard block
 block discarded – undo
3073 3073
 	 * @since 1.0.19
3074 3074
 	 * @param  string $value discount code.
3075 3075
 	 */
3076
-	public function set_discount_code( $value ) {
3077
-		$this->set_prop( 'discount_code', sanitize_text_field( $value ) );
3076
+	public function set_discount_code($value) {
3077
+		$this->set_prop('discount_code', sanitize_text_field($value));
3078 3078
     }
3079 3079
 
3080 3080
     /**
@@ -3083,8 +3083,8 @@  discard block
 block discarded – undo
3083 3083
 	 * @since 1.0.19
3084 3084
 	 * @param  string $value gateway.
3085 3085
 	 */
3086
-	public function set_gateway( $value ) {
3087
-		$this->set_prop( 'gateway', $value );
3086
+	public function set_gateway($value) {
3087
+		$this->set_prop('gateway', $value);
3088 3088
     }
3089 3089
 
3090 3090
     /**
@@ -3093,9 +3093,9 @@  discard block
 block discarded – undo
3093 3093
 	 * @since 1.0.19
3094 3094
 	 * @param  string $value transaction id.
3095 3095
 	 */
3096
-	public function set_transaction_id( $value ) {
3097
-		if ( ! empty( $value ) ) {
3098
-			$this->set_prop( 'transaction_id', $value );
3096
+	public function set_transaction_id($value) {
3097
+		if (!empty($value)) {
3098
+			$this->set_prop('transaction_id', $value);
3099 3099
 		}
3100 3100
     }
3101 3101
 
@@ -3105,8 +3105,8 @@  discard block
 block discarded – undo
3105 3105
 	 * @since 1.0.19
3106 3106
 	 * @param  string $value currency id.
3107 3107
 	 */
3108
-	public function set_currency( $value ) {
3109
-		$this->set_prop( 'currency', $value );
3108
+	public function set_currency($value) {
3109
+		$this->set_prop('currency', $value);
3110 3110
     }
3111 3111
 
3112 3112
 	/**
@@ -3115,8 +3115,8 @@  discard block
 block discarded – undo
3115 3115
 	 * @since 1.0.19
3116 3116
 	 * @param  bool $value value.
3117 3117
 	 */
3118
-	public function set_disable_taxes( $value ) {
3119
-		$this->set_prop( 'disable_taxes', (bool) $value );
3118
+	public function set_disable_taxes($value) {
3119
+		$this->set_prop('disable_taxes', (bool) $value);
3120 3120
 	}
3121 3121
 
3122 3122
     /**
@@ -3125,8 +3125,8 @@  discard block
 block discarded – undo
3125 3125
 	 * @since 1.0.19
3126 3126
 	 * @param  string $value subscription id.
3127 3127
 	 */
3128
-	public function set_subscription_id( $value ) {
3129
-		$this->set_prop( 'subscription_id', $value );
3128
+	public function set_subscription_id($value) {
3129
+		$this->set_prop('subscription_id', $value);
3130 3130
 	}
3131 3131
 
3132 3132
 	/**
@@ -3135,8 +3135,8 @@  discard block
 block discarded – undo
3135 3135
 	 * @since 1.0.19
3136 3136
 	 * @param  string $value subscription id.
3137 3137
 	 */
3138
-	public function set_remote_subscription_id( $value ) {
3139
-		$this->set_prop( 'remote_subscription_id', $value );
3138
+	public function set_remote_subscription_id($value) {
3139
+		$this->set_prop('remote_subscription_id', $value);
3140 3140
     }
3141 3141
 
3142 3142
 	/**
@@ -3145,8 +3145,8 @@  discard block
 block discarded – undo
3145 3145
 	 * @since 2.8.22
3146 3146
 	 * @param  bool $is_anonymized is anonymized.
3147 3147
 	 */
3148
-	public function set_is_anonymized( $is_anonymized ) {
3149
-		$this->set_prop( 'is_anonymized', (bool) $is_anonymized );
3148
+	public function set_is_anonymized($is_anonymized) {
3149
+		$this->set_prop('is_anonymized', (bool) $is_anonymized);
3150 3150
     }
3151 3151
 
3152 3152
     /*
@@ -3163,28 +3163,28 @@  discard block
 block discarded – undo
3163 3163
      */
3164 3164
     public function is_parent() {
3165 3165
         $parent = $this->get_parent_id();
3166
-        return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this );
3166
+        return apply_filters('wpinv_invoice_is_parent', empty($parent), $this);
3167 3167
     }
3168 3168
 
3169 3169
     /**
3170 3170
      * Checks if this is a renewal invoice.
3171 3171
      */
3172 3172
     public function is_renewal() {
3173
-        return $this->is_recurring() && ! $this->is_parent();
3173
+        return $this->is_recurring() && !$this->is_parent();
3174 3174
     }
3175 3175
 
3176 3176
     /**
3177 3177
      * Checks if this is a recurring invoice.
3178 3178
      */
3179 3179
     public function is_recurring() {
3180
-        return ! empty( $this->recurring_item );
3180
+        return !empty($this->recurring_item);
3181 3181
     }
3182 3182
 
3183 3183
     /**
3184 3184
      * Checks if this is a taxable invoice.
3185 3185
      */
3186 3186
     public function is_taxable() {
3187
-        return ! $this->get_disable_taxes();
3187
+        return !$this->get_disable_taxes();
3188 3188
 	}
3189 3189
 
3190 3190
 	/**
@@ -3198,45 +3198,45 @@  discard block
 block discarded – undo
3198 3198
 	 * Checks to see if the invoice requires payment.
3199 3199
 	 */
3200 3200
 	public function is_free() {
3201
-        $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
3201
+        $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0);
3202 3202
 
3203
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3203
+		if ($this->is_recurring() && $this->get_recurring_total() > 0) {
3204 3204
 			$is_free = false;
3205 3205
 		}
3206 3206
 
3207
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
3207
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
3208 3208
     }
3209 3209
 
3210 3210
     /**
3211 3211
      * Checks if the invoice is paid.
3212 3212
      */
3213 3213
     public function is_paid() {
3214
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
3215
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
3214
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
3215
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
3216 3216
 	}
3217 3217
 
3218 3218
 	/**
3219 3219
      * Checks if the invoice needs payment.
3220 3220
      */
3221 3221
 	public function needs_payment() {
3222
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3223
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
3222
+		$needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free();
3223
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this);
3224 3224
     }
3225 3225
 
3226 3226
 	/**
3227 3227
      * Checks if the invoice is refunded.
3228 3228
      */
3229 3229
 	public function is_refunded() {
3230
-        $is_refunded = $this->has_status( 'wpi-refunded' );
3231
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
3230
+        $is_refunded = $this->has_status('wpi-refunded');
3231
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
3232 3232
 	}
3233 3233
 
3234 3234
 	/**
3235 3235
      * Checks if the invoice is held.
3236 3236
      */
3237 3237
 	public function is_held() {
3238
-        $is_held = $this->has_status( 'wpi-onhold' );
3239
-        return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3238
+        $is_held = $this->has_status('wpi-onhold');
3239
+        return apply_filters('wpinv_invoice_is_held', $is_held, $this);
3240 3240
 	}
3241 3241
 
3242 3242
 	/**
@@ -3244,30 +3244,30 @@  discard block
 block discarded – undo
3244 3244
      */
3245 3245
 	public function is_due() {
3246 3246
 		$due_date = $this->get_due_date();
3247
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3247
+		return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date);
3248 3248
 	}
3249 3249
 
3250 3250
 	/**
3251 3251
      * Checks if the invoice is draft.
3252 3252
      */
3253 3253
 	public function is_draft() {
3254
-        return $this->has_status( 'draft, auto-draft' );
3254
+        return $this->has_status('draft, auto-draft');
3255 3255
 	}
3256 3256
 
3257 3257
     /**
3258 3258
      * Checks if the invoice has a given status.
3259 3259
      */
3260
-    public function has_status( $status ) {
3261
-        $status = wpinv_parse_list( $status );
3262
-        return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3260
+    public function has_status($status) {
3261
+        $status = wpinv_parse_list($status);
3262
+        return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status);
3263 3263
 	}
3264 3264
 
3265 3265
 	/**
3266 3266
      * Checks if the invoice is of a given type.
3267 3267
      */
3268
-    public function is_type( $type ) {
3269
-        $type = wpinv_parse_list( $type );
3270
-        return in_array( $this->get_type(), $type );
3268
+    public function is_type($type) {
3269
+        $type = wpinv_parse_list($type);
3270
+        return in_array($this->get_type(), $type);
3271 3271
     }
3272 3272
 
3273 3273
     /**
@@ -3299,8 +3299,8 @@  discard block
 block discarded – undo
3299 3299
      *
3300 3300
      */
3301 3301
 	public function is_initial_free() {
3302
-        $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3303
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3302
+        $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0);
3303
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this);
3304 3304
     }
3305 3305
 
3306 3306
 	/**
@@ -3310,11 +3310,11 @@  discard block
 block discarded – undo
3310 3310
     public function item_has_free_trial() {
3311 3311
 
3312 3312
         // Ensure we have a recurring item.
3313
-        if ( ! $this->is_recurring() ) {
3313
+        if (!$this->is_recurring()) {
3314 3314
             return false;
3315 3315
         }
3316 3316
 
3317
-        $item = $this->get_recurring( true );
3317
+        $item = $this->get_recurring(true);
3318 3318
         return $item->has_free_trial();
3319 3319
 	}
3320 3320
 
@@ -3322,7 +3322,7 @@  discard block
 block discarded – undo
3322 3322
      * Check if the free trial is a result of a discount.
3323 3323
      */
3324 3324
     public function is_free_trial_from_discount() {
3325
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3325
+		return $this->has_free_trial() && !$this->item_has_free_trial();
3326 3326
 	}
3327 3327
 
3328 3328
 	/**
@@ -3339,12 +3339,12 @@  discard block
 block discarded – undo
3339 3339
      */
3340 3340
     public function discount_first_payment_only() {
3341 3341
 
3342
-		$discount = wpinv_get_discount_obj( $this->get_discount_code() );
3343
-        if ( ! $discount->exists() || ! $this->is_recurring() ) {
3342
+		$discount = wpinv_get_discount_obj($this->get_discount_code());
3343
+        if (!$discount->exists() || !$this->is_recurring()) {
3344 3344
             return true;
3345 3345
         }
3346 3346
 
3347
-        return ! $discount->get_is_recurring();
3347
+        return !$discount->get_is_recurring();
3348 3348
     }
3349 3349
 
3350 3350
     /*
@@ -3362,23 +3362,23 @@  discard block
 block discarded – undo
3362 3362
      * @param GetPaid_Form_Item|array $item
3363 3363
      * @return WP_Error|Bool
3364 3364
      */
3365
-    public function add_item( $item ) {
3365
+    public function add_item($item) {
3366 3366
 
3367
-		if ( is_array( $item ) ) {
3368
-			$item = $this->process_array_item( $item );
3367
+		if (is_array($item)) {
3368
+			$item = $this->process_array_item($item);
3369 3369
 		}
3370 3370
 
3371
-		if ( is_numeric( $item ) ) {
3372
-			$item = new GetPaid_Form_Item( $item );
3371
+		if (is_numeric($item)) {
3372
+			$item = new GetPaid_Form_Item($item);
3373 3373
 		}
3374 3374
 
3375 3375
         // Make sure that it is available for purchase.
3376
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3377
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3376
+		if ($item->get_id() > 0 && !$item->can_purchase()) {
3377
+			return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing'));
3378 3378
         }
3379 3379
 
3380 3380
         // Do we have a recurring item?
3381
-		if ( $item->is_recurring() ) {
3381
+		if ($item->is_recurring()) {
3382 3382
 			$this->recurring_item = $item->get_id();
3383 3383
         }
3384 3384
 
@@ -3386,9 +3386,9 @@  discard block
 block discarded – undo
3386 3386
         $item->invoice_id = (int) $this->get_id();
3387 3387
 
3388 3388
 		// Remove duplicates.
3389
-		$this->remove_item( $item->get_id() );
3389
+		$this->remove_item($item->get_id());
3390 3390
 
3391
-		if ( 0 == $item->get_quantity() ) {
3391
+		if (0 == $item->get_quantity()) {
3392 3392
 			return;
3393 3393
 		}
3394 3394
 
@@ -3398,7 +3398,7 @@  discard block
 block discarded – undo
3398 3398
 		// Add new item.
3399 3399
         $items[] = $item;
3400 3400
 
3401
-        $this->set_prop( 'items', $items );
3401
+        $this->set_prop('items', $items);
3402 3402
 
3403 3403
 		return true;
3404 3404
 	}
@@ -3409,26 +3409,26 @@  discard block
 block discarded – undo
3409 3409
 	 * @since 1.0.19
3410 3410
 	 * @return GetPaid_Form_Item
3411 3411
 	 */
3412
-	protected function process_array_item( $array ) {
3412
+	protected function process_array_item($array) {
3413 3413
 
3414
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3415
-		$item    = new GetPaid_Form_Item( $item_id );
3414
+		$item_id = isset($array['item_id']) ? $array['item_id'] : 0;
3415
+		$item    = new GetPaid_Form_Item($item_id);
3416 3416
 
3417 3417
 		// Set item data.
3418
-		foreach ( array( 'name', 'price', 'description' ) as $key ) {
3419
-			if ( isset( $array[ "item_$key" ] ) ) {
3418
+		foreach (array('name', 'price', 'description') as $key) {
3419
+			if (isset($array["item_$key"])) {
3420 3420
 				$method = "set_$key";
3421
-				$item->$method( $array[ "item_$key" ] );
3421
+				$item->$method($array["item_$key"]);
3422 3422
 			}
3423 3423
 		}
3424 3424
 
3425
-		if ( isset( $array['quantity'] ) ) {
3426
-			$item->set_quantity( $array['quantity'] );
3425
+		if (isset($array['quantity'])) {
3426
+			$item->set_quantity($array['quantity']);
3427 3427
 		}
3428 3428
 
3429 3429
 		// Set item meta.
3430
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3431
-			$item->set_item_meta( $array['meta'] );
3430
+		if (isset($array['meta']) && is_array($array['meta'])) {
3431
+			$item->set_item_meta($array['meta']);
3432 3432
 		}
3433 3433
 
3434 3434
 		return $item;
@@ -3441,10 +3441,10 @@  discard block
 block discarded – undo
3441 3441
 	 * @since 1.0.19
3442 3442
 	 * @return GetPaid_Form_Item|null
3443 3443
 	 */
3444
-	public function get_item( $item_id ) {
3444
+	public function get_item($item_id) {
3445 3445
 
3446
-		foreach ( $this->get_items() as $item ) {
3447
-			if ( (int) $item_id == $item->get_id() ) {
3446
+		foreach ($this->get_items() as $item) {
3447
+			if ((int) $item_id == $item->get_id()) {
3448 3448
 				return $item;
3449 3449
 			}
3450 3450
 		}
@@ -3457,16 +3457,16 @@  discard block
 block discarded – undo
3457 3457
 	 *
3458 3458
 	 * @since 1.0.19
3459 3459
 	 */
3460
-	public function remove_item( $item_id ) {
3460
+	public function remove_item($item_id) {
3461 3461
 		$items   = $this->get_items();
3462 3462
 		$item_id = (int) $item_id;
3463 3463
 
3464
-		foreach ( $items as $index => $item ) {
3465
-			if ( (int) $item_id == $item->get_id() ) {
3466
-				unset( $items[ $index ] );
3467
-				$this->set_prop( 'items', $items );
3464
+		foreach ($items as $index => $item) {
3465
+			if ((int) $item_id == $item->get_id()) {
3466
+				unset($items[$index]);
3467
+				$this->set_prop('items', $items);
3468 3468
 
3469
-				if ( $item_id == $this->recurring_item ) {
3469
+				if ($item_id == $this->recurring_item) {
3470 3470
 					$this->recurring_item = null;
3471 3471
 				}
3472 3472
 }
@@ -3480,11 +3480,11 @@  discard block
 block discarded – undo
3480 3480
 	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3481 3481
 	 * @since 1.0.19
3482 3482
 	 */
3483
-    public function add_fee( $fee ) {
3483
+    public function add_fee($fee) {
3484 3484
 
3485 3485
 		$fees                 = $this->get_fees();
3486
-		$fees[ $fee['name'] ] = $fee;
3487
-		$this->set_prop( 'fees', $fees );
3486
+		$fees[$fee['name']] = $fee;
3487
+		$this->set_prop('fees', $fees);
3488 3488
 
3489 3489
     }
3490 3490
 
@@ -3493,9 +3493,9 @@  discard block
 block discarded – undo
3493 3493
 	 *
3494 3494
 	 * @since 1.0.19
3495 3495
 	 */
3496
-	public function get_fee( $fee ) {
3496
+	public function get_fee($fee) {
3497 3497
         $fees = $this->get_fees();
3498
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3498
+		return isset($fees[$fee]) ? $fees[$fee] : null;
3499 3499
     }
3500 3500
 
3501 3501
     /**
@@ -3503,11 +3503,11 @@  discard block
 block discarded – undo
3503 3503
 	 *
3504 3504
 	 * @since 1.0.19
3505 3505
 	 */
3506
-	public function remove_fee( $fee ) {
3506
+	public function remove_fee($fee) {
3507 3507
         $fees = $this->get_fees();
3508
-        if ( isset( $fees[ $fee ] ) ) {
3509
-            unset( $fees[ $fee ] );
3510
-            $this->set_prop( 'fees', $fees );
3508
+        if (isset($fees[$fee])) {
3509
+            unset($fees[$fee]);
3510
+            $this->set_prop('fees', $fees);
3511 3511
         }
3512 3512
     }
3513 3513
 
@@ -3517,11 +3517,11 @@  discard block
 block discarded – undo
3517 3517
 	 * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3518 3518
 	 * @since 1.0.19
3519 3519
 	 */
3520
-	public function add_discount( $discount ) {
3520
+	public function add_discount($discount) {
3521 3521
 
3522 3522
 		$discounts = $this->get_discounts();
3523
-		$discounts[ $discount['name'] ] = $discount;
3524
-		$this->set_prop( 'discounts', $discounts );
3523
+		$discounts[$discount['name']] = $discount;
3524
+		$this->set_prop('discounts', $discounts);
3525 3525
 
3526 3526
 	}
3527 3527
 
@@ -3531,15 +3531,15 @@  discard block
 block discarded – undo
3531 3531
 	 * @since 1.0.19
3532 3532
 	 * @return float
3533 3533
 	 */
3534
-	public function get_discount( $discount = false ) {
3534
+	public function get_discount($discount = false) {
3535 3535
 
3536 3536
 		// Backwards compatibility.
3537
-		if ( empty( $discount ) ) {
3537
+		if (empty($discount)) {
3538 3538
 			return $this->get_total_discount();
3539 3539
 		}
3540 3540
 
3541 3541
         $discounts = $this->get_discounts();
3542
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3542
+		return isset($discounts[$discount]) ? $discounts[$discount] : null;
3543 3543
     }
3544 3544
 
3545 3545
     /**
@@ -3547,15 +3547,15 @@  discard block
 block discarded – undo
3547 3547
 	 *
3548 3548
 	 * @since 1.0.19
3549 3549
 	 */
3550
-	public function remove_discount( $discount ) {
3550
+	public function remove_discount($discount) {
3551 3551
         $discounts = $this->get_discounts();
3552
-        if ( isset( $discounts[ $discount ] ) ) {
3553
-            unset( $discounts[ $discount ] );
3554
-            $this->set_prop( 'discounts', $discounts );
3552
+        if (isset($discounts[$discount])) {
3553
+            unset($discounts[$discount]);
3554
+            $this->set_prop('discounts', $discounts);
3555 3555
         }
3556 3556
 
3557
-		if ( 'discount_code' == $discount ) {
3558
-			foreach ( $this->get_items() as $item ) {
3557
+		if ('discount_code' == $discount) {
3558
+			foreach ($this->get_items() as $item) {
3559 3559
 				$item->item_discount           = 0;
3560 3560
 				$item->recurring_item_discount = 0;
3561 3561
 			}
@@ -3568,12 +3568,12 @@  discard block
 block discarded – undo
3568 3568
      *
3569 3569
      * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required.
3570 3570
      */
3571
-    public function add_tax( $tax ) {
3572
-        if ( $this->is_taxable() ) {
3571
+    public function add_tax($tax) {
3572
+        if ($this->is_taxable()) {
3573 3573
 
3574
-            $taxes                 = $this->get_taxes();
3575
-			$taxes[ $tax['name'] ] = $tax;
3576
-			$this->set_prop( 'taxes', $tax );
3574
+            $taxes = $this->get_taxes();
3575
+			$taxes[$tax['name']] = $tax;
3576
+			$this->set_prop('taxes', $tax);
3577 3577
 
3578 3578
         }
3579 3579
     }
@@ -3583,29 +3583,29 @@  discard block
 block discarded – undo
3583 3583
 	 *
3584 3584
 	 * @since 1.0.19
3585 3585
 	 */
3586
-	public function get_tax( $tax = null ) {
3586
+	public function get_tax($tax = null) {
3587 3587
 
3588 3588
 		// Backwards compatibility.
3589
-		if ( empty( $tax ) ) {
3589
+		if (empty($tax)) {
3590 3590
 			return $this->get_total_tax();
3591 3591
 		}
3592 3592
 
3593 3593
         $taxes = $this->get_taxes();
3594
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3594
+		return isset($taxes[$tax]) ? $taxes[$tax] : null;
3595 3595
     }
3596 3596
 
3597
-	public function get_tax_total_by_name( $name ) {
3598
-		if ( $name && 0 === strpos( $name, 'tax__' ) ) {
3599
-			$name = str_replace( 'tax__', '', $name );
3597
+	public function get_tax_total_by_name($name) {
3598
+		if ($name && 0 === strpos($name, 'tax__')) {
3599
+			$name = str_replace('tax__', '', $name);
3600 3600
 		}
3601 3601
 
3602
-		if ( empty( $name ) ) {
3602
+		if (empty($name)) {
3603 3603
 			return 0;
3604 3604
 		}
3605 3605
 
3606
-		$tax = $this->get_tax( $name );
3606
+		$tax = $this->get_tax($name);
3607 3607
 
3608
-		if ( empty( $tax ) ) {
3608
+		if (empty($tax)) {
3609 3609
 			return 0;
3610 3610
 		}
3611 3611
 
@@ -3617,18 +3617,18 @@  discard block
 block discarded – undo
3617 3617
 	 *
3618 3618
 	 * @since 2.8.8
3619 3619
 	 */
3620
-	public function get_tax_item_name( $tax_key, $tax_item, $suffix = '' ) {
3621
-		$tax_name = _x( 'Tax', 'Tax name', 'invoicing' );
3620
+	public function get_tax_item_name($tax_key, $tax_item, $suffix = '') {
3621
+		$tax_name = _x('Tax', 'Tax name', 'invoicing');
3622 3622
 
3623
-		if ( ! empty( $tax_item ) && is_array( $tax_item ) && ! empty( $tax_item['name'] ) ) {
3624
-			$tax_name = __( $tax_item['name'], 'invoicing' );
3623
+		if (!empty($tax_item) && is_array($tax_item) && !empty($tax_item['name'])) {
3624
+			$tax_name = __($tax_item['name'], 'invoicing');
3625 3625
 		}
3626 3626
 
3627
-		if ( $suffix ) {
3627
+		if ($suffix) {
3628 3628
 			$tax_name .= $suffix;
3629 3629
 		}
3630 3630
 
3631
-		return apply_filters( 'wpinv_invoice_get_tax_name', $tax_name, $this, $tax_key, $tax_item, $suffix );
3631
+		return apply_filters('wpinv_invoice_get_tax_name', $tax_name, $this, $tax_key, $tax_item, $suffix);
3632 3632
 	}
3633 3633
 
3634 3634
 	/**
@@ -3636,44 +3636,44 @@  discard block
 block discarded – undo
3636 3636
 	 *
3637 3637
 	 * @since 2.8.8
3638 3638
 	 */
3639
-	public function get_tax_item_amount( $tax_key, $tax_item, $with_currency = false ) {
3640
-		$tax_amount = $this->get_tax_total_by_name( $tax_key );
3639
+	public function get_tax_item_amount($tax_key, $tax_item, $with_currency = false) {
3640
+		$tax_amount = $this->get_tax_total_by_name($tax_key);
3641 3641
 
3642
-		if ( $with_currency ) {
3643
-			$tax_amount = wpinv_price( $tax_amount, $this->get_currency() );
3642
+		if ($with_currency) {
3643
+			$tax_amount = wpinv_price($tax_amount, $this->get_currency());
3644 3644
 		}
3645 3645
 
3646
-		return apply_filters( 'wpinv_invoice_get_tax_amount', $tax_amount, $this, $tax_item, $with_currency );
3646
+		return apply_filters('wpinv_invoice_get_tax_amount', $tax_amount, $this, $tax_item, $with_currency);
3647 3647
 	}
3648 3648
 
3649
-	public function get_item_tax_name( $percentage = true, $sep = ' + ' ) {
3649
+	public function get_item_tax_name($percentage = true, $sep = ' + ') {
3650 3650
 		$taxes = $this->get_taxes();
3651 3651
 
3652
-		if ( ! empty( $taxes ) && is_array( $taxes ) && count( $taxes ) == 1 && wpinv_display_individual_tax_rates() ) {
3652
+		if (!empty($taxes) && is_array($taxes) && count($taxes) == 1 && wpinv_display_individual_tax_rates()) {
3653 3653
 			$names = array();
3654 3654
 
3655
-			foreach ( $taxes as $key => $tax ) {
3656
-				if ( ! empty( $tax ) && ! empty( $tax['name'] ) ) {
3657
-					$name = __( $tax['name'], 'invoicing' );
3655
+			foreach ($taxes as $key => $tax) {
3656
+				if (!empty($tax) && !empty($tax['name'])) {
3657
+					$name = __($tax['name'], 'invoicing');
3658 3658
 
3659 3659
 					$names[] = $name;
3660 3660
 				}
3661 3661
 			}
3662 3662
 
3663
-			if ( ! empty( $names ) ) {
3664
-				$names = array_unique( $names );
3663
+			if (!empty($names)) {
3664
+				$names = array_unique($names);
3665 3665
 
3666
-				$tax_name = implode( $sep, $names );
3666
+				$tax_name = implode($sep, $names);
3667 3667
 			}
3668 3668
 
3669
-			if ( $percentage ) {
3670
-				$tax_name = wp_sprintf( _x( '%s (%%)', 'Tax name with %. Ex: Tax (%)', 'invoicing' ), $tax_name );
3669
+			if ($percentage) {
3670
+				$tax_name = wp_sprintf(_x('%s (%%)', 'Tax name with %. Ex: Tax (%)', 'invoicing'), $tax_name);
3671 3671
 			}
3672 3672
 		} else {
3673
-			$tax_name = $percentage ? __( 'Tax (%)', 'invoicing' ) : _x( 'Tax', 'Tax name', 'invoicing' );
3673
+			$tax_name = $percentage ? __('Tax (%)', 'invoicing') : _x('Tax', 'Tax name', 'invoicing');
3674 3674
 		}
3675 3675
 
3676
-		return apply_filters( 'wpinv_invoice_get_item_tax_name', $tax_name, $this, $percentage, $sep );
3676
+		return apply_filters('wpinv_invoice_get_item_tax_name', $tax_name, $this, $percentage, $sep);
3677 3677
 	}
3678 3678
 
3679 3679
     /**
@@ -3681,11 +3681,11 @@  discard block
 block discarded – undo
3681 3681
 	 *
3682 3682
 	 * @since 1.0.19
3683 3683
 	 */
3684
-	public function remove_tax( $tax ) {
3684
+	public function remove_tax($tax) {
3685 3685
         $taxes = $this->get_taxes();
3686
-        if ( isset( $taxes[ $tax ] ) ) {
3687
-            unset( $taxes[ $tax ] );
3688
-            $this->set_prop( 'taxes', $taxes );
3686
+        if (isset($taxes[$tax])) {
3687
+            unset($taxes[$tax]);
3688
+            $this->set_prop('taxes', $taxes);
3689 3689
         }
3690 3690
     }
3691 3691
 
@@ -3696,22 +3696,22 @@  discard block
 block discarded – undo
3696 3696
 	 * @return float The recalculated subtotal
3697 3697
 	 */
3698 3698
 	public function recalculate_subtotal() {
3699
-        $items     = $this->get_items();
3699
+        $items = $this->get_items();
3700 3700
 		$subtotal  = 0;
3701 3701
 		$recurring = 0;
3702 3702
 
3703
-        foreach ( $items as $item ) {
3704
-			$subtotal  += $item->get_sub_total( 'edit' );
3705
-			$recurring += $item->get_recurring_sub_total( 'edit' );
3703
+        foreach ($items as $item) {
3704
+			$subtotal  += $item->get_sub_total('edit');
3705
+			$recurring += $item->get_recurring_sub_total('edit');
3706 3706
         }
3707 3707
 
3708
-		if ( wpinv_prices_include_tax() ) {
3709
-			$subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3710
-			$recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3708
+		if (wpinv_prices_include_tax()) {
3709
+			$subtotal  = max(0, $subtotal - $this->totals['tax']['initial']);
3710
+			$recurring = max(0, $recurring - $this->totals['tax']['recurring']);
3711 3711
 		}
3712 3712
 
3713 3713
 		$current = $this->is_renewal() ? $recurring : $subtotal;
3714
-		$this->set_subtotal( $current );
3714
+		$this->set_subtotal($current);
3715 3715
 
3716 3716
 		$this->totals['subtotal'] = array(
3717 3717
 			'initial'   => $subtotal,
@@ -3729,12 +3729,12 @@  discard block
 block discarded – undo
3729 3729
 	 */
3730 3730
 	public function recalculate_total_discount() {
3731 3731
 		// Fix renewal invoice amount when tax + recurring discount applied.
3732
-		if ( $this->is_renewal() && $this->get_discount_code() ) {
3732
+		if ($this->is_renewal() && $this->get_discount_code()) {
3733 3733
 			// Maybe recalculate discount (Pre-GetPaid Fix).
3734
-			$discount = new WPInv_Discount( $this->get_discount_code() );
3734
+			$discount = new WPInv_Discount($this->get_discount_code());
3735 3735
 
3736
-			if ( $discount->exists() && $discount->is_recurring() ) {
3737
-				getpaid_calculate_invoice_discount( $this, $discount );
3736
+			if ($discount->exists() && $discount->is_recurring()) {
3737
+				getpaid_calculate_invoice_discount($this, $discount);
3738 3738
 			}
3739 3739
 		}
3740 3740
 
@@ -3742,14 +3742,14 @@  discard block
 block discarded – undo
3742 3742
 		$discount  = 0;
3743 3743
 		$recurring = 0;
3744 3744
 
3745
-        foreach ( $discounts as $data ) {
3746
-			$discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3747
-			$recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3745
+        foreach ($discounts as $data) {
3746
+			$discount  += wpinv_sanitize_amount($data['initial_discount']);
3747
+			$recurring += wpinv_sanitize_amount($data['recurring_discount']);
3748 3748
 		}
3749 3749
 
3750 3750
 		$current = $this->is_renewal() ? $recurring : $discount;
3751 3751
 
3752
-		$this->set_total_discount( $current );
3752
+		$this->set_total_discount($current);
3753 3753
 
3754 3754
 		$this->totals['discount'] = array(
3755 3755
 			'initial'   => $discount,
@@ -3770,13 +3770,13 @@  discard block
 block discarded – undo
3770 3770
 
3771 3771
 		// Maybe disable taxes.
3772 3772
 		$vat_number = $this->get_vat_number();
3773
-		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3773
+		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction($this->get_country()) && !empty($vat_number);
3774 3774
 
3775
-		if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' === wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3775
+		if (wpinv_is_base_country($this->get_country()) && 'vat_too' === wpinv_get_option('vat_same_country_rule', 'vat_too')) {
3776 3776
 			$skip_tax = false;
3777 3777
 		}
3778 3778
 
3779
-		if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax ) {
3779
+		if (!wpinv_use_taxes() || $this->get_disable_taxes() || !wpinv_is_country_taxable($this->get_country()) || $skip_tax) {
3780 3780
 
3781 3781
 			$this->totals['tax'] = array(
3782 3782
 				'initial'   => 0,
@@ -3785,36 +3785,36 @@  discard block
 block discarded – undo
3785 3785
 
3786 3786
 			$this->tax_rate = 0;
3787 3787
 
3788
-			$this->set_taxes( array() );
3788
+			$this->set_taxes(array());
3789 3789
 			$current = 0;
3790 3790
 		} else {
3791 3791
 
3792 3792
 			$item_taxes = array();
3793 3793
 
3794
-			foreach ( $this->get_items() as $item ) {
3795
-				$rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3796
-				$rates    = getpaid_filter_item_tax_rates( $item, $rates );
3797
-				$taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3798
-				$r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3799
-				foreach ( $taxes as $name => $amount ) {
3800
-					$recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3801
-					$tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3802
-
3803
-					if ( ! isset( $item_taxes[ $name ] ) ) {
3804
-						$item_taxes[ $name ] = $tax;
3794
+			foreach ($this->get_items() as $item) {
3795
+				$rates    = getpaid_get_item_tax_rates($item, $this->get_country(), $this->get_state());
3796
+				$rates    = getpaid_filter_item_tax_rates($item, $rates);
3797
+				$taxes    = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, false), $rates);
3798
+				$r_taxes  = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, true), $rates);
3799
+				foreach ($taxes as $name => $amount) {
3800
+					$recurring = isset($r_taxes[$name]) ? $r_taxes[$name] : 0;
3801
+					$tax       = getpaid_prepare_item_tax($item, $name, $amount, $recurring);
3802
+
3803
+					if (!isset($item_taxes[$name])) {
3804
+						$item_taxes[$name] = $tax;
3805 3805
 						continue;
3806 3806
 					}
3807 3807
 
3808
-					$item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3809
-					$item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3808
+					$item_taxes[$name]['initial_tax']   += $tax['initial_tax'];
3809
+					$item_taxes[$name]['recurring_tax'] += $tax['recurring_tax'];
3810 3810
 
3811 3811
 				}
3812 3812
 			}
3813 3813
 
3814
-			$this->set_taxes( $item_taxes );
3814
+			$this->set_taxes($item_taxes);
3815 3815
 
3816
-			$initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3817
-			$recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3816
+			$initial_tax   = array_sum(wp_list_pluck($item_taxes, 'initial_tax'));
3817
+			$recurring_tax = array_sum(wp_list_pluck($item_taxes, 'recurring_tax'));
3818 3818
 
3819 3819
 			$current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3820 3820
 
@@ -3825,7 +3825,7 @@  discard block
 block discarded – undo
3825 3825
 
3826 3826
 		}
3827 3827
 
3828
-		$this->set_total_tax( $current );
3828
+		$this->set_total_tax($current);
3829 3829
 
3830 3830
 		return $current;
3831 3831
 
@@ -3842,20 +3842,20 @@  discard block
 block discarded – undo
3842 3842
 		$fee       = 0;
3843 3843
 		$recurring = 0;
3844 3844
 
3845
-        foreach ( $fees as $data ) {
3846
-			$fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3847
-			$recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3845
+        foreach ($fees as $data) {
3846
+			$fee       += wpinv_sanitize_amount($data['initial_fee']);
3847
+			$recurring += wpinv_sanitize_amount($data['recurring_fee']);
3848 3848
 		}
3849 3849
 
3850 3850
 		$current = $this->is_renewal() ? $recurring : $fee;
3851
-		$this->set_total_fees( $current );
3851
+		$this->set_total_fees($current);
3852 3852
 
3853 3853
 		$this->totals['fee'] = array(
3854 3854
 			'initial'   => $fee,
3855 3855
 			'recurring' => $recurring,
3856 3856
 		);
3857 3857
 
3858
-        $this->set_total_fees( $fee );
3858
+        $this->set_total_fees($fee);
3859 3859
         return $current;
3860 3860
     }
3861 3861
 
@@ -3870,7 +3870,7 @@  discard block
 block discarded – undo
3870 3870
         $this->recalculate_total_discount();
3871 3871
 		$this->recalculate_total_tax();
3872 3872
 		$this->recalculate_subtotal();
3873
-		$this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) );
3873
+		$this->set_total($this->get_total_tax('edit') + $this->get_total_fees('edit') + $this->get_subtotal('edit') - $this->get_total_discount('edit'));
3874 3874
 		return $this->get_total();
3875 3875
 	}
3876 3876
 
@@ -3879,7 +3879,7 @@  discard block
 block discarded – undo
3879 3879
 	 */
3880 3880
     public function recalculate_totals() {
3881 3881
         $this->recalculate_total();
3882
-        $this->save( true );
3882
+        $this->save(true);
3883 3883
         return $this;
3884 3884
     }
3885 3885
 
@@ -3897,8 +3897,8 @@  discard block
 block discarded – undo
3897 3897
 	 * @return int|false The new note's ID on success, false on failure.
3898 3898
      *
3899 3899
      */
3900
-    public function add_system_note( $note ) {
3901
-		return $this->add_note( $note, false, false, true );
3900
+    public function add_system_note($note) {
3901
+		return $this->add_note($note, false, false, true);
3902 3902
 	}
3903 3903
 
3904 3904
     /**
@@ -3908,10 +3908,10 @@  discard block
 block discarded – undo
3908 3908
 	 * @return int|false The new note's ID on success, false on failure.
3909 3909
      *
3910 3910
      */
3911
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
3911
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
3912 3912
 
3913 3913
         // Bail if no note specified or this invoice is not yet saved.
3914
-        if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) {
3914
+        if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) {
3915 3915
             return false;
3916 3916
         }
3917 3917
 
@@ -3919,23 +3919,23 @@  discard block
 block discarded – undo
3919 3919
 		$author_email = '[email protected]';
3920 3920
 
3921 3921
 		// If this is an admin comment or it has been added by the user.
3922
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3923
-			$user         = get_user_by( 'id', get_current_user_id() );
3922
+		if (is_user_logged_in() && (!$system || $added_by_user)) {
3923
+			$user = get_user_by('id', get_current_user_id());
3924 3924
             $author       = $user->display_name;
3925 3925
             $author_email = $user->user_email;
3926 3926
 		}
3927 3927
 
3928
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3928
+		return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type);
3929 3929
 
3930 3930
 	}
3931 3931
 
3932 3932
 	/**
3933 3933
      * Generates a unique key for the invoice.
3934 3934
      */
3935
-    public function generate_key( $string = '' ) {
3936
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
3935
+    public function generate_key($string = '') {
3936
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
3937 3937
         return strtolower(
3938
-            $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) )
3938
+            $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))
3939 3939
         );
3940 3940
     }
3941 3941
 
@@ -3945,11 +3945,11 @@  discard block
 block discarded – undo
3945 3945
     public function generate_number() {
3946 3946
         $number = $this->get_id();
3947 3947
 
3948
-        if ( wpinv_sequential_number_active( $this->get_post_type() ) ) {
3949
-            $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3948
+        if (wpinv_sequential_number_active($this->get_post_type())) {
3949
+            $number = wpinv_get_next_invoice_number($this->get_post_type());
3950 3950
         }
3951 3951
 
3952
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3952
+		return wpinv_format_invoice_number($number, $this->get_post_type());
3953 3953
 
3954 3954
 	}
3955 3955
 
@@ -3962,55 +3962,55 @@  discard block
 block discarded – undo
3962 3962
 		// Reset status transition variable.
3963 3963
 		$this->status_transition = false;
3964 3964
 
3965
-		if ( $status_transition ) {
3965
+		if ($status_transition) {
3966 3966
 			try {
3967 3967
 
3968 3968
 				// Fire a hook for the status change.
3969
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3969
+				do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition);
3970 3970
 
3971 3971
 				// @deprecated this is deprecated and will be removed in the future.
3972
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3972
+				do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3973 3973
 
3974
-				if ( ! empty( $status_transition['from'] ) ) {
3974
+				if (!empty($status_transition['from'])) {
3975 3975
 
3976 3976
 					/* translators: 1: old invoice status 2: new invoice status */
3977
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) );
3977
+					$transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from'], $this), wpinv_status_nicename($status_transition['to'], $this));
3978 3978
 
3979 3979
 					// Fire another hook.
3980
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3981
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3980
+					do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this);
3981
+					do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']);
3982 3982
 
3983 3983
 					// @deprecated this is deprecated and will be removed in the future.
3984
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3984
+					do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3985 3985
 
3986 3986
 					// Note the transition occurred.
3987
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3987
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), false, $status_transition['manual']);
3988 3988
 
3989 3989
 					// Work out if this was for a payment, and trigger a payment_status hook instead.
3990 3990
 					if (
3991
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'pending', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3992
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3991
+						in_array($status_transition['from'], array('wpi-cancelled', 'pending', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true)
3992
+						&& in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3993 3993
 					) {
3994
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3994
+						do_action('getpaid_invoice_payment_status_changed', $this, $status_transition);
3995 3995
 					}
3996 3996
 
3997 3997
 					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3998 3998
 					if (
3999
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
4000
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'pending', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3999
+						in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
4000
+						&& in_array($status_transition['to'], array('wpi-cancelled', 'pending', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true)
4001 4001
 					) {
4002
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
4002
+						do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition);
4003 4003
 					}
4004 4004
 				} else {
4005 4005
 					/* translators: %s: new invoice status */
4006
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) );
4006
+					$transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'], $this));
4007 4007
 
4008 4008
 					// Note the transition occurred.
4009
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
4009
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
4010 4010
 
4011 4011
 				}
4012
-			} catch ( Exception $e ) {
4013
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
4012
+			} catch (Exception $e) {
4013
+				$this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage());
4014 4014
 			}
4015 4015
 		}
4016 4016
 	}
@@ -4018,13 +4018,13 @@  discard block
 block discarded – undo
4018 4018
 	/**
4019 4019
 	 * Updates an invoice status.
4020 4020
 	 */
4021
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
4021
+	public function update_status($new_status = false, $note = '', $manual = false) {
4022 4022
 
4023 4023
 		// Fires before updating a status.
4024
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
4024
+		do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit'));
4025 4025
 
4026 4026
 		// Update the status.
4027
-		$this->set_status( $new_status, $note, $manual );
4027
+		$this->set_status($new_status, $note, $manual);
4028 4028
 
4029 4029
 		// Save the order.
4030 4030
 		return $this->save();
@@ -4035,18 +4035,18 @@  discard block
 block discarded – undo
4035 4035
 	 * @deprecated
4036 4036
 	 */
4037 4037
 	public function refresh_item_ids() {
4038
-        $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) );
4039
-        update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
4038
+        $item_ids = implode(',', array_unique(wp_list_pluck($this->get_cart_details(), 'item_id')));
4039
+        update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids);
4040 4040
 	}
4041 4041
 
4042 4042
 	/**
4043 4043
 	 * @deprecated
4044 4044
 	 */
4045
-	public function update_items( $temp = false ) {
4045
+	public function update_items($temp = false) {
4046 4046
 
4047
-		$this->set_items( $this->get_items() );
4047
+		$this->set_items($this->get_items());
4048 4048
 
4049
-		if ( ! $temp ) {
4049
+		if (!$temp) {
4050 4050
 			$this->save();
4051 4051
 		}
4052 4052
 
@@ -4060,11 +4060,11 @@  discard block
 block discarded – undo
4060 4060
 
4061 4061
         $discount_code = $this->get_discount_code();
4062 4062
 
4063
-        if ( empty( $discount_code ) ) {
4063
+        if (empty($discount_code)) {
4064 4064
             return false;
4065 4065
         }
4066 4066
 
4067
-        $discount = wpinv_get_discount_obj( $discount_code );
4067
+        $discount = wpinv_get_discount_obj($discount_code);
4068 4068
 
4069 4069
         // Ensure it is active.
4070 4070
         return $discount->exists();
@@ -4075,7 +4075,7 @@  discard block
 block discarded – undo
4075 4075
 	 * Refunds an invoice.
4076 4076
 	 */
4077 4077
     public function refund() {
4078
-		$this->set_status( 'wpi-refunded' );
4078
+		$this->set_status('wpi-refunded');
4079 4079
         $this->save();
4080 4080
 	}
4081 4081
 
@@ -4084,53 +4084,53 @@  discard block
 block discarded – undo
4084 4084
 	 *
4085 4085
 	 * @param string $transaction_id
4086 4086
 	 */
4087
-    public function mark_paid( $transaction_id = null, $note = '' ) {
4087
+    public function mark_paid($transaction_id = null, $note = '') {
4088 4088
 
4089 4089
 		// Set the transaction id.
4090
-		if ( empty( $transaction_id ) ) {
4091
-			$transaction_id = $this->generate_key( 'trans_' );
4090
+		if (empty($transaction_id)) {
4091
+			$transaction_id = $this->generate_key('trans_');
4092 4092
 		}
4093 4093
 
4094
-		if ( ! $this->get_transaction_id() ) {
4095
-			$this->set_transaction_id( $transaction_id );
4094
+		if (!$this->get_transaction_id()) {
4095
+			$this->set_transaction_id($transaction_id);
4096 4096
 		}
4097 4097
 
4098
-		if ( $this->is_paid() && 'wpi-processing' !== $this->get_status() ) {
4098
+		if ($this->is_paid() && 'wpi-processing' !== $this->get_status()) {
4099 4099
 			return $this->save();
4100 4100
 		}
4101 4101
 
4102 4102
 		// Set the completed date.
4103
-		$this->set_date_completed( current_time( 'mysql' ) );
4103
+		$this->set_date_completed(current_time('mysql'));
4104 4104
 
4105 4105
 		// Set the new status.
4106
-		$gateway = sanitize_text_field( $this->get_gateway_title() );
4107
-		if ( $this->is_renewal() || ! $this->is_parent() ) {
4106
+		$gateway = sanitize_text_field($this->get_gateway_title());
4107
+		if ($this->is_renewal() || !$this->is_parent()) {
4108 4108
 
4109
-			$_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
4110
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
4109
+			$_note = wp_sprintf(__('Renewed via %s', 'invoicing'), $gateway);
4110
+			$_note = $_note . empty($note) ? '' : " ($note)";
4111 4111
 
4112
-			if ( 'none' == $this->get_gateway() ) {
4112
+			if ('none' == $this->get_gateway()) {
4113 4113
 				$_note = $note;
4114 4114
 			}
4115 4115
 
4116
-			$this->set_status( 'wpi-renewal', $_note );
4116
+			$this->set_status('wpi-renewal', $_note);
4117 4117
 
4118 4118
 		} else {
4119 4119
 
4120
-			$_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
4121
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
4120
+			$_note = wp_sprintf(__('Paid via %s', 'invoicing'), $gateway);
4121
+			$_note = $_note . empty($note) ? '' : " ($note)";
4122 4122
 
4123
-			if ( 'none' == $this->get_gateway() ) {
4123
+			if ('none' == $this->get_gateway()) {
4124 4124
 				$_note = $note;
4125 4125
 			}
4126 4126
 
4127
-			$this->set_status( 'publish', $_note );
4127
+			$this->set_status('publish', $_note);
4128 4128
 
4129 4129
 		}
4130 4130
 
4131 4131
 		// Set checkout mode.
4132
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
4133
-		$this->set_mode( $mode );
4132
+		$mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live';
4133
+		$this->set_mode($mode);
4134 4134
 
4135 4135
 		// Save the invoice.
4136 4136
         $this->save();
@@ -4155,16 +4155,16 @@  discard block
 block discarded – undo
4155 4155
      * Clears the subscription's cache.
4156 4156
      */
4157 4157
     public function clear_cache() {
4158
-		if ( $this->get_key() ) {
4159
-			wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
4158
+		if ($this->get_key()) {
4159
+			wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids');
4160 4160
 		}
4161 4161
 
4162
-		if ( $this->get_number() ) {
4163
-			wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
4162
+		if ($this->get_number()) {
4163
+			wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids');
4164 4164
 		}
4165 4165
 
4166
-		if ( $this->get_transaction_id() ) {
4167
-			wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
4166
+		if ($this->get_transaction_id()) {
4167
+			wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids');
4168 4168
 		}
4169 4169
 	}
4170 4170
 
Please login to merge, or discard this patch.