Completed
Push — master ( b6ca0b...43d636 )
by Brian
31s queued 16s
created
includes/class-wpinv-subscriptions.php 1 patch
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly.
3
-if (!defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5 5
 function wpinv_subscription_init() {
6 6
     return WPInv_Subscriptions::instance();
7 7
 }
8
-add_action( 'plugins_loaded', 'wpinv_subscription_init', 100 );
8
+add_action('plugins_loaded', 'wpinv_subscription_init', 100);
9 9
 
10 10
 /**
11 11
  * WPInv_Subscriptions Class.
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
      * Main WPInv_Subscriptions Instance
21 21
      */
22 22
     public static function instance() {
23
-        if ( ! isset( self::$instance ) ) {
23
+        if (!isset(self::$instance)) {
24 24
             self::$instance = new WPInv_Subscriptions;
25 25
 
26 26
             self::$instance->init();
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      *
35 35
      * @since 1.0.0
36 36
      */
37
-    private function __construct(){
37
+    private function __construct() {
38 38
 
39 39
     }
40 40
 
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
     private function setup_constants() {
64 64
 
65 65
         // Make sure CAL_GREGORIAN is defined.
66
-        if ( ! defined( 'CAL_GREGORIAN' ) ) {
67
-            define( 'CAL_GREGORIAN', 1 );
66
+        if (!defined('CAL_GREGORIAN')) {
67
+            define('CAL_GREGORIAN', 1);
68 68
         }
69 69
     }
70 70
 
@@ -76,13 +76,13 @@  discard block
 block discarded – undo
76 76
      */
77 77
     private function actions() {
78 78
 
79
-        add_action( 'admin_menu', array( $this, 'wpinv_subscriptions_list' ), 40 );
80
-        add_action( 'admin_notices', array( $this, 'notices' ) );
81
-        add_action( 'init', array( $this, 'wpinv_post_actions' ) );
82
-        add_action( 'init', array( $this, 'wpinv_get_actions' ) );
83
-        add_action( 'wpinv_cancel_subscription', array( $this, 'wpinv_process_cancellation' ) );
84
-        add_action( 'wpinv_checkout_before_send_to_gateway', array( $this, 'wpinv_checkout_add_subscription' ), -999, 2 );
85
-        add_action( 'wpinv_subscriptions_front_notices', array( $this, 'notices' ) );
79
+        add_action('admin_menu', array($this, 'wpinv_subscriptions_list'), 40);
80
+        add_action('admin_notices', array($this, 'notices'));
81
+        add_action('init', array($this, 'wpinv_post_actions'));
82
+        add_action('init', array($this, 'wpinv_get_actions'));
83
+        add_action('wpinv_cancel_subscription', array($this, 'wpinv_process_cancellation'));
84
+        add_action('wpinv_checkout_before_send_to_gateway', array($this, 'wpinv_checkout_add_subscription'), -999, 2);
85
+        add_action('wpinv_subscriptions_front_notices', array($this, 'notices'));
86 86
     }
87 87
 
88 88
     /**
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
     public function wpinv_subscriptions_list() {
105 105
         add_submenu_page(
106 106
             'wpinv',
107
-            __( 'Subscriptions', 'invoicing' ),
108
-            __( 'Subscriptions', 'invoicing' ),
107
+            __('Subscriptions', 'invoicing'),
108
+            __('Subscriptions', 'invoicing'),
109 109
             wpinv_get_capability(),
110 110
             'wpinv-subscriptions',
111 111
             'wpinv_subscriptions_page'
@@ -114,37 +114,37 @@  discard block
 block discarded – undo
114 114
 
115 115
     public function notices() {
116 116
 
117
-        if( empty( $_GET['wpinv-message'] ) ) {
117
+        if (empty($_GET['wpinv-message'])) {
118 118
             return;
119 119
         }
120 120
 
121 121
         $type    = 'updated';
122 122
         $message = '';
123 123
 
124
-        switch( strtolower( $_GET['wpinv-message'] ) ) {
124
+        switch (strtolower($_GET['wpinv-message'])) {
125 125
 
126 126
             case 'updated' :
127 127
 
128
-                $message = __( 'Subscription updated successfully.', 'invoicing' );
128
+                $message = __('Subscription updated successfully.', 'invoicing');
129 129
 
130 130
                 break;
131 131
 
132 132
             case 'deleted' :
133 133
 
134
-                $message = __( 'Subscription deleted successfully.', 'invoicing' );
134
+                $message = __('Subscription deleted successfully.', 'invoicing');
135 135
 
136 136
                 break;
137 137
 
138 138
             case 'cancelled' :
139 139
 
140
-                $message = __( 'Subscription cancelled successfully.', 'invoicing' );
140
+                $message = __('Subscription cancelled successfully.', 'invoicing');
141 141
 
142 142
                 break;
143 143
 
144 144
         }
145 145
 
146
-        if ( ! empty( $message ) ) {
147
-            echo '<div class="' . esc_attr( $type ) . '"><p>' . $message . '</p></div>';
146
+        if (!empty($message)) {
147
+            echo '<div class="' . esc_attr($type) . '"><p>' . $message . '</p></div>';
148 148
         }
149 149
 
150 150
     }
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
      * @return void
158 158
      */
159 159
     function wpinv_get_actions() {
160
-        if ( isset( $_GET['wpinv_action'] ) ) {
161
-            do_action( 'wpinv_' . $_GET['wpinv_action'], $_GET );
160
+        if (isset($_GET['wpinv_action'])) {
161
+            do_action('wpinv_' . $_GET['wpinv_action'], $_GET);
162 162
         }
163 163
     }
164 164
 
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
      * @return void
171 171
      */
172 172
     function wpinv_post_actions() {
173
-        if ( isset( $_POST['wpinv_action'] ) ) {
174
-            do_action( 'wpinv_' . $_POST['wpinv_action'], $_POST );
173
+        if (isset($_POST['wpinv_action'])) {
174
+            do_action('wpinv_' . $_POST['wpinv_action'], $_POST);
175 175
         }
176 176
     }
177 177
 
@@ -182,24 +182,24 @@  discard block
 block discarded – undo
182 182
      * @param int $frequency_count The frequency of the period.
183 183
      * @return mixed|string|void
184 184
      */
185
-    public static function wpinv_get_pretty_subscription_frequency( $period, $frequency_count = 1) {
185
+    public static function wpinv_get_pretty_subscription_frequency($period, $frequency_count = 1) {
186 186
         $frequency = '';
187 187
         //Format period details
188
-        switch ( $period ) {
188
+        switch ($period) {
189 189
             case 'day' :
190
-                $frequency = sprintf( _n('%d Day', '%d Days', $frequency_count, 'invoicing'), $frequency_count);
190
+                $frequency = sprintf(_n('%d Day', '%d Days', $frequency_count, 'invoicing'), $frequency_count);
191 191
                 break;
192 192
             case 'week' :
193
-                $frequency = sprintf( _n('%d Week', '%d Weeks', $frequency_count, 'invoicing'), $frequency_count);
193
+                $frequency = sprintf(_n('%d Week', '%d Weeks', $frequency_count, 'invoicing'), $frequency_count);
194 194
                 break;
195 195
             case 'month' :
196
-                $frequency = sprintf( _n('%d Month', '%d Months', $frequency_count, 'invoicing'), $frequency_count);
196
+                $frequency = sprintf(_n('%d Month', '%d Months', $frequency_count, 'invoicing'), $frequency_count);
197 197
                 break;
198 198
             case 'year' :
199
-                $frequency = sprintf( _n('%d Year', '%d Years', $frequency_count, 'invoicing'), $frequency_count);
199
+                $frequency = sprintf(_n('%d Year', '%d Years', $frequency_count, 'invoicing'), $frequency_count);
200 200
                 break;
201 201
             default :
202
-                $frequency = apply_filters( 'wpinv_recurring_subscription_frequency', $frequency, $period, $frequency_count );
202
+                $frequency = apply_filters('wpinv_recurring_subscription_frequency', $frequency, $period, $frequency_count);
203 203
                 break;
204 204
         }
205 205
 
@@ -214,50 +214,50 @@  discard block
 block discarded – undo
214 214
      * @since       1.0.0
215 215
      * @return      void
216 216
      */
217
-    public function wpinv_process_cancellation( $data ) {
217
+    public function wpinv_process_cancellation($data) {
218 218
 
219 219
 
220
-        if( empty( $data['sub_id'] ) ) {
220
+        if (empty($data['sub_id'])) {
221 221
             return;
222 222
         }
223 223
 
224
-        if( ! is_user_logged_in() ) {
224
+        if (!is_user_logged_in()) {
225 225
             return;
226 226
         }
227 227
 
228
-        if( ! wp_verify_nonce( $data['_wpnonce'], 'wpinv-recurring-cancel' ) ) {
229
-            wp_die( __( 'Error', 'invoicing' ), __( 'Nonce verification failed', 'invoicing' ), array( 'response' => 403 ) );
228
+        if (!wp_verify_nonce($data['_wpnonce'], 'wpinv-recurring-cancel')) {
229
+            wp_die(__('Error', 'invoicing'), __('Nonce verification failed', 'invoicing'), array('response' => 403));
230 230
         }
231 231
 
232
-        $data['sub_id'] = absint( $data['sub_id'] );
233
-        $subscription   = new WPInv_Subscription( $data['sub_id'] );
232
+        $data['sub_id'] = absint($data['sub_id']);
233
+        $subscription   = new WPInv_Subscription($data['sub_id']);
234 234
 
235
-        if( ! $subscription->can_cancel() ) {
236
-            wp_die( __( 'Error', 'invoicing' ), __( 'This subscription cannot be cancelled', 'invoicing' ), array( 'response' => 403 ) );
235
+        if (!$subscription->can_cancel()) {
236
+            wp_die(__('Error', 'invoicing'), __('This subscription cannot be cancelled', 'invoicing'), array('response' => 403));
237 237
         }
238 238
 
239 239
         try {
240 240
 
241
-            do_action( 'wpinv_recurring_cancel_' . $subscription->gateway . '_subscription', $subscription, true );
241
+            do_action('wpinv_recurring_cancel_' . $subscription->gateway . '_subscription', $subscription, true);
242 242
 
243 243
             $subscription->cancel();
244 244
 
245
-            if( is_admin() ) {
245
+            if (is_admin()) {
246 246
 
247
-                wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=cancelled&id=' . $subscription->id ) );
247
+                wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=cancelled&id=' . $subscription->id));
248 248
                 exit;
249 249
 
250 250
             } else {
251 251
 
252
-                $redirect = remove_query_arg( array( '_wpnonce', 'wpinv_action', 'sub_id' ), add_query_arg( array( 'wpinv-message' => 'cancelled' ) ) );
253
-                $redirect = apply_filters( 'wpinv_recurring_cancellation_redirect', $redirect, $subscription );
254
-                wp_safe_redirect( $redirect );
252
+                $redirect = remove_query_arg(array('_wpnonce', 'wpinv_action', 'sub_id'), add_query_arg(array('wpinv-message' => 'cancelled')));
253
+                $redirect = apply_filters('wpinv_recurring_cancellation_redirect', $redirect, $subscription);
254
+                wp_safe_redirect($redirect);
255 255
                 exit;
256 256
 
257 257
             }
258 258
 
259
-        } catch ( Exception $e ) {
260
-            wp_die( __( 'Error', 'invoicing' ), $e->getMessage(), array( 'response' => 403 ) );
259
+        } catch (Exception $e) {
260
+            wp_die(__('Error', 'invoicing'), $e->getMessage(), array('response' => 403));
261 261
         }
262 262
 
263 263
     }
@@ -270,40 +270,40 @@  discard block
 block discarded – undo
270 270
      * @since       1.0.0
271 271
      * @return      void
272 272
      */
273
-    public function wpinv_checkout_add_subscription( $invoice, $invoice_data ) {
274
-        if ( ! ( ! empty( $invoice->ID ) && $invoice->is_recurring() ) ) {
273
+    public function wpinv_checkout_add_subscription($invoice, $invoice_data) {
274
+        if (!(!empty($invoice->ID) && $invoice->is_recurring())) {
275 275
             return;
276 276
         }
277 277
 
278 278
         // Should we create a subscription for the invoice?
279
-        if ( apply_filters( 'wpinv_skip_invoice_subscription_creation', false, $invoice ) ) {
279
+        if (apply_filters('wpinv_skip_invoice_subscription_creation', false, $invoice)) {
280 280
             return;
281 281
         }
282 282
 
283
-        $item               = $invoice->get_recurring( true );
284
-        if ( empty( $item ) ) {
283
+        $item = $invoice->get_recurring(true);
284
+        if (empty($item)) {
285 285
             return;
286 286
         }
287 287
 
288
-        $invoice_date       = $invoice->get_invoice_date( false );
288
+        $invoice_date       = $invoice->get_invoice_date(false);
289 289
         $status             = 'pending';
290 290
 
291
-        $period             = $item->get_recurring_period( true );
291
+        $period             = $item->get_recurring_period(true);
292 292
         $interval           = $item->get_recurring_interval();
293
-        $bill_times         = (int)$item->get_recurring_limit();
293
+        $bill_times         = (int) $item->get_recurring_limit();
294 294
         $add_period         = $interval . ' ' . $period;
295 295
         $trial_period       = '';
296 296
 
297
-        if ( $invoice->is_free_trial() ) {
297
+        if ($invoice->is_free_trial()) {
298 298
             $status         = 'trialling';
299
-            $trial_period   = $item->get_trial_period( true );
299
+            $trial_period   = $item->get_trial_period(true);
300 300
             $free_interval  = $item->get_trial_interval();
301 301
             $trial_period   = $free_interval . ' ' . $trial_period;
302 302
 
303 303
             $add_period     = $trial_period;
304 304
         }
305 305
 
306
-        $expiration         = date_i18n( 'Y-m-d H:i:s', strtotime( '+' . $add_period  . ' 23:59:59', strtotime( $invoice_date ) ) );
306
+        $expiration         = date_i18n('Y-m-d H:i:s', strtotime('+' . $add_period . ' 23:59:59', strtotime($invoice_date)));
307 307
 
308 308
         $args = array(
309 309
             'product_id'        => $item->ID,
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
             'frequency'         => $interval,
314 314
             'period'            => $period,
315 315
             'initial_amount'    => $invoice->get_total(),
316
-            'recurring_amount'  => $invoice->get_recurring_details( 'total' ),
316
+            'recurring_amount'  => $invoice->get_recurring_details('total'),
317 317
             'bill_times'        => $bill_times,
318 318
             'created'           => $invoice_date,
319 319
             'expiration'        => $expiration,
@@ -322,11 +322,11 @@  discard block
 block discarded – undo
322 322
             'transaction_id'    => '',
323 323
         );
324 324
 
325
-        $subscription = wpinv_get_subscription( $invoice );
325
+        $subscription = wpinv_get_subscription($invoice);
326 326
 
327
-        if ( empty( $subscription ) ) {
327
+        if (empty($subscription)) {
328 328
             $subscription = new WPInv_Subscription();
329
-            $subscription->create( $args );
329
+            $subscription->create($args);
330 330
         }
331 331
         
332 332
         return $subscription;
Please login to merge, or discard this patch.
includes/class-wpinv-reports.php 1 patch
Spacing   +199 added lines, -199 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit; // Exit if accessed directly
4 4
 }
5 5
 
@@ -21,175 +21,175 @@  discard block
 block discarded – undo
21 21
     public function init() {
22 22
         global $wp_filesystem;
23 23
 
24
-        if ( empty( $wp_filesystem ) ) {
25
-            require_once( ABSPATH . '/wp-admin/includes/file.php' );
24
+        if (empty($wp_filesystem)) {
25
+            require_once(ABSPATH . '/wp-admin/includes/file.php');
26 26
             WP_Filesystem();
27 27
             global $wp_filesystem;
28 28
         }
29 29
         $this->wp_filesystem    = $wp_filesystem;
30 30
         
31 31
         $this->export_dir       = $this->export_location();
32
-        $this->export_url       = $this->export_location( true );
32
+        $this->export_url       = $this->export_location(true);
33 33
         $this->export           = 'invoicing';
34 34
         $this->filetype         = 'csv';
35 35
         $this->per_page         = 20;
36 36
         
37
-        do_action( 'wpinv_class_reports_init', $this );
37
+        do_action('wpinv_class_reports_init', $this);
38 38
     }
39 39
     
40 40
     public function includes() {
41
-        do_action( 'wpinv_class_reports_includes', $this );
41
+        do_action('wpinv_class_reports_includes', $this);
42 42
     }
43 43
     
44 44
     public function actions() {
45
-        if ( is_admin() ) {
46
-            add_action( 'admin_menu', array( $this, 'add_submenu' ), 20 );
47
-            add_action( 'wpinv_reports_tab_export', array( $this, 'export' ) );
48
-            add_action( 'wp_ajax_wpinv_ajax_export', array( $this, 'ajax_export' ) );
49
-            add_action( 'wp_ajax_wpinv_ajax_discount_use_export', array( $this, 'discount_use_export' ) );
45
+        if (is_admin()) {
46
+            add_action('admin_menu', array($this, 'add_submenu'), 20);
47
+            add_action('wpinv_reports_tab_export', array($this, 'export'));
48
+            add_action('wp_ajax_wpinv_ajax_export', array($this, 'ajax_export'));
49
+            add_action('wp_ajax_wpinv_ajax_discount_use_export', array($this, 'discount_use_export'));
50 50
             
51 51
             // Export Invoices.
52
-            add_action( 'wpinv_export_set_params_invoices', array( $this, 'set_invoices_export' ) );
53
-            add_filter( 'wpinv_export_get_columns_invoices', array( $this, 'get_invoices_columns' ) );
54
-            add_filter( 'wpinv_export_get_data_invoices', array( $this, 'get_invoices_data' ) );
55
-            add_filter( 'wpinv_get_export_status_invoices', array( $this, 'invoices_export_status' ) );
52
+            add_action('wpinv_export_set_params_invoices', array($this, 'set_invoices_export'));
53
+            add_filter('wpinv_export_get_columns_invoices', array($this, 'get_invoices_columns'));
54
+            add_filter('wpinv_export_get_data_invoices', array($this, 'get_invoices_data'));
55
+            add_filter('wpinv_get_export_status_invoices', array($this, 'invoices_export_status'));
56 56
         }
57
-        do_action( 'wpinv_class_reports_actions', $this );
57
+        do_action('wpinv_class_reports_actions', $this);
58 58
     }
59 59
     
60 60
     public function add_submenu() {
61 61
         global $wpi_reports_page;
62
-        $wpi_reports_page = add_submenu_page( 'wpinv', __( 'Reports', 'invoicing' ), __( 'Reports', 'invoicing' ), wpinv_get_capability(), 'wpinv-reports', array( $this, 'reports_page' ) );
62
+        $wpi_reports_page = add_submenu_page('wpinv', __('Reports', 'invoicing'), __('Reports', 'invoicing'), wpinv_get_capability(), 'wpinv-reports', array($this, 'reports_page'));
63 63
     }
64 64
     
65 65
     public function reports_page() {
66
-        if ( !wp_script_is( 'postbox', 'enqueued' ) ) {
67
-            wp_enqueue_script( 'postbox' );
66
+        if (!wp_script_is('postbox', 'enqueued')) {
67
+            wp_enqueue_script('postbox');
68 68
         }
69
-        if ( !wp_script_is( 'jquery-ui-datepicker', 'enqueued' ) ) {
70
-            wp_enqueue_script( 'jquery-ui-datepicker' );
69
+        if (!wp_script_is('jquery-ui-datepicker', 'enqueued')) {
70
+            wp_enqueue_script('jquery-ui-datepicker');
71 71
         }
72 72
         
73
-        $current_page = admin_url( 'admin.php?page=wpinv-reports' );
74
-        $active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'export';
73
+        $current_page = admin_url('admin.php?page=wpinv-reports');
74
+        $active_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'export';
75 75
         ?>
76 76
         <div class="wrap wpi-reports-wrap">
77
-            <h1><?php echo esc_html( __( 'Reports', 'invoicing' ) ); ?></h1>
77
+            <h1><?php echo esc_html(__('Reports', 'invoicing')); ?></h1>
78 78
             <h2 class="nav-tab-wrapper wp-clearfix">
79
-                <a href="<?php echo add_query_arg( array( 'tab' => 'export', 'settings-updated' => false ), $current_page ); ?>" class="nav-tab <?php echo $active_tab == 'export' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Export', 'invoicing' ); ?></a>
80
-                <?php do_action( 'wpinv_reports_page_tabs' ); ;?>
79
+                <a href="<?php echo add_query_arg(array('tab' => 'export', 'settings-updated' => false), $current_page); ?>" class="nav-tab <?php echo $active_tab == 'export' ? 'nav-tab-active' : ''; ?>"><?php _e('Export', 'invoicing'); ?></a>
80
+                <?php do_action('wpinv_reports_page_tabs'); ;?>
81 81
             </h2>
82
-            <div class="wpi-reports-content wpi-reports-<?php echo esc_attr( $active_tab ); ?>">
82
+            <div class="wpi-reports-content wpi-reports-<?php echo esc_attr($active_tab); ?>">
83 83
             <?php
84
-                do_action( 'wpinv_reports_page_top' );
85
-                do_action( 'wpinv_reports_tab_' . $active_tab );
86
-                do_action( 'wpinv_reports_page_bottom' );
84
+                do_action('wpinv_reports_page_top');
85
+                do_action('wpinv_reports_tab_' . $active_tab);
86
+                do_action('wpinv_reports_page_bottom');
87 87
             ?>
88 88
         </div>
89 89
         <?php
90 90
     }
91 91
     
92 92
     public function export() {
93
-        $statuses = wpinv_get_invoice_statuses( true );
94
-        $statuses = array_merge( array( 'any' => __( 'All Statuses', 'invoicing' ) ), $statuses );
93
+        $statuses = wpinv_get_invoice_statuses(true);
94
+        $statuses = array_merge(array('any' => __('All Statuses', 'invoicing')), $statuses);
95 95
         ?>
96 96
         <div class="metabox-holder">
97 97
             <div id="post-body">
98 98
                 <div id="post-body-content">
99
-                    <?php do_action( 'wpinv_reports_tab_export_content_top' ); ?>
99
+                    <?php do_action('wpinv_reports_tab_export_content_top'); ?>
100 100
                     
101 101
                     <div class="postbox wpi-export-invoices">
102
-                        <h2 class="hndle ui-sortabled-handle"><span><?php _e( 'Invoices','invoicing' ); ?></span></h2>
102
+                        <h2 class="hndle ui-sortabled-handle"><span><?php _e('Invoices', 'invoicing'); ?></span></h2>
103 103
                         <div class="inside">
104
-                            <p><?php _e( 'Download a CSV of all payment invoices.', 'invoicing' ); ?></p>
104
+                            <p><?php _e('Download a CSV of all payment invoices.', 'invoicing'); ?></p>
105 105
                             <form id="wpi-export-invoices" class="wpi-export-form" method="post">
106
-                                <?php echo wpinv_html_date_field( array( 
106
+                                <?php echo wpinv_html_date_field(array( 
107 107
                                     'id' => 'wpi_export_from_date', 
108 108
                                     'name' => 'from_date',
109 109
                                     'data' => array(
110 110
                                         'dateFormat' => 'yy-mm-dd'
111 111
                                     ),
112
-                                    'placeholder' => __( 'From date', 'invoicing' ) )
112
+                                    'placeholder' => __('From date', 'invoicing') )
113 113
                                 ); ?>
114
-                                <?php echo wpinv_html_date_field( array( 
114
+                                <?php echo wpinv_html_date_field(array( 
115 115
                                     'id' => 'wpi_export_to_date',
116 116
                                     'name' => 'to_date',
117 117
                                     'data' => array(
118 118
                                         'dateFormat' => 'yy-mm-dd'
119 119
                                     ),
120
-                                    'placeholder' => __( 'To date', 'invoicing' ) )
120
+                                    'placeholder' => __('To date', 'invoicing') )
121 121
                                 ); ?>
122 122
                                 <span id="wpinv-status-wrap">
123
-                                <?php echo wpinv_html_select( array(
123
+                                <?php echo wpinv_html_select(array(
124 124
                                     'options'          => $statuses,
125 125
                                     'name'             => 'status',
126 126
                                     'id'               => 'wpi_export_status',
127 127
                                     'show_option_all'  => false,
128 128
                                     'show_option_none' => false,
129 129
                                     'class'            => 'wpi_select2',
130
-                                ) ); ?>
131
-                                <?php wp_nonce_field( 'wpi_ajax_export', 'wpi_ajax_export' ); ?>
130
+                                )); ?>
131
+                                <?php wp_nonce_field('wpi_ajax_export', 'wpi_ajax_export'); ?>
132 132
                                 </span>
133 133
                                 <span id="wpinv-submit-wrap">
134 134
                                     <input type="hidden" value="invoices" name="export" />
135
-                                    <input type="submit" value="<?php _e( 'Generate CSV', 'invoicing' ); ?>" class="button-primary" />
135
+                                    <input type="submit" value="<?php _e('Generate CSV', 'invoicing'); ?>" class="button-primary" />
136 136
                                 </span>
137 137
                             </form>
138 138
                         </div>
139 139
                     </div>
140 140
 
141 141
                     <div class="postbox wpi-export-discount-uses">
142
-                        <h2 class="hndle ui-sortabled-handle"><span><?php _e( 'Discount Use','invoicing' ); ?></span></h2>
142
+                        <h2 class="hndle ui-sortabled-handle"><span><?php _e('Discount Use', 'invoicing'); ?></span></h2>
143 143
                         <div class="inside">
144
-                            <p><?php _e( 'Download a CSV of discount uses.', 'invoicing' ); ?></p>
145
-                            <a class="button-primary" href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin-ajax.php?action=wpinv_ajax_discount_use_export' ), 'wpi_discount_ajax_export', 'wpi_discount_ajax_export' ) ); ?>"><?php _e( 'Generate CSV', 'invoicing' ); ?></a>
144
+                            <p><?php _e('Download a CSV of discount uses.', 'invoicing'); ?></p>
145
+                            <a class="button-primary" href="<?php echo esc_url(wp_nonce_url(admin_url('admin-ajax.php?action=wpinv_ajax_discount_use_export'), 'wpi_discount_ajax_export', 'wpi_discount_ajax_export')); ?>"><?php _e('Generate CSV', 'invoicing'); ?></a>
146 146
                         </div>
147 147
                     </div>
148 148
                     
149
-                    <?php do_action( 'wpinv_reports_tab_export_content_bottom' ); ?>
149
+                    <?php do_action('wpinv_reports_tab_export_content_bottom'); ?>
150 150
                 </div>
151 151
             </div>
152 152
         </div>
153 153
         <?php
154 154
     }
155 155
     
156
-    public function export_location( $relative = false ) {
156
+    public function export_location($relative = false) {
157 157
         $upload_dir         = wp_upload_dir();
158
-        $export_location    = $relative ? trailingslashit( $upload_dir['baseurl'] ) . 'cache' : trailingslashit( $upload_dir['basedir'] ) . 'cache';
159
-        $export_location    = apply_filters( 'wpinv_export_location', $export_location, $relative );
158
+        $export_location    = $relative ? trailingslashit($upload_dir['baseurl']) . 'cache' : trailingslashit($upload_dir['basedir']) . 'cache';
159
+        $export_location    = apply_filters('wpinv_export_location', $export_location, $relative);
160 160
         
161
-        return trailingslashit( $export_location );
161
+        return trailingslashit($export_location);
162 162
     }
163 163
     
164 164
     public function check_export_location() {
165 165
         try {
166
-            if ( empty( $this->wp_filesystem ) ) {
167
-                return __( 'Filesystem ERROR: Could not access filesystem.', 'invoicing' );
166
+            if (empty($this->wp_filesystem)) {
167
+                return __('Filesystem ERROR: Could not access filesystem.', 'invoicing');
168 168
             }
169 169
 
170
-            if ( is_wp_error( $this->wp_filesystem ) ) {
171
-                return __( 'Filesystem ERROR: ' . $this->wp_filesystem->get_error_message(), 'invoicing' );
170
+            if (is_wp_error($this->wp_filesystem)) {
171
+                return __('Filesystem ERROR: ' . $this->wp_filesystem->get_error_message(), 'invoicing');
172 172
             }
173 173
         
174
-            $is_dir         = $this->wp_filesystem->is_dir( $this->export_dir );
175
-            $is_writeable   = $is_dir && is_writeable( $this->export_dir );
174
+            $is_dir         = $this->wp_filesystem->is_dir($this->export_dir);
175
+            $is_writeable   = $is_dir && is_writeable($this->export_dir);
176 176
             
177
-            if ( $is_dir && $is_writeable ) {
177
+            if ($is_dir && $is_writeable) {
178 178
                return true;
179
-            } else if ( $is_dir && !$is_writeable ) {
180
-               if ( !$this->wp_filesystem->chmod( $this->export_dir, FS_CHMOD_DIR ) ) {
181
-                   return wp_sprintf( __( 'Filesystem ERROR: Export location %s is not writable, check your file permissions.', 'invoicing' ), $this->export_dir );
179
+            } else if ($is_dir && !$is_writeable) {
180
+               if (!$this->wp_filesystem->chmod($this->export_dir, FS_CHMOD_DIR)) {
181
+                   return wp_sprintf(__('Filesystem ERROR: Export location %s is not writable, check your file permissions.', 'invoicing'), $this->export_dir);
182 182
                }
183 183
                
184 184
                return true;
185 185
             } else {
186
-                if ( !$this->wp_filesystem->mkdir( $this->export_dir, FS_CHMOD_DIR ) ) {
187
-                    return wp_sprintf( __( 'Filesystem ERROR: Could not create directory %s. This is usually due to inconsistent file permissions.', 'invoicing' ), $this->export_dir );
186
+                if (!$this->wp_filesystem->mkdir($this->export_dir, FS_CHMOD_DIR)) {
187
+                    return wp_sprintf(__('Filesystem ERROR: Could not create directory %s. This is usually due to inconsistent file permissions.', 'invoicing'), $this->export_dir);
188 188
                 }
189 189
                 
190 190
                 return true;
191 191
             }
192
-        } catch ( Exception $e ) {
192
+        } catch (Exception $e) {
193 193
             return $e->getMessage();
194 194
         }
195 195
     }
@@ -197,59 +197,59 @@  discard block
 block discarded – undo
197 197
     public function ajax_export() {
198 198
         $response               = array();
199 199
         $response['success']    = false;
200
-        $response['msg']        = __( 'Invalid export request found.', 'invoicing' );
200
+        $response['msg']        = __('Invalid export request found.', 'invoicing');
201 201
         
202
-        if ( empty( $_POST['data'] ) || ! wpinv_current_user_can_manage_invoicing() ) {
203
-            wp_send_json( $response );
202
+        if (empty($_POST['data']) || !wpinv_current_user_can_manage_invoicing()) {
203
+            wp_send_json($response);
204 204
         }
205 205
 
206
-        parse_str( $_POST['data'], $data );
206
+        parse_str($_POST['data'], $data);
207 207
         
208
-        $data['step']   = !empty( $_POST['step'] ) ? absint( $_POST['step'] ) : 1;
208
+        $data['step'] = !empty($_POST['step']) ? absint($_POST['step']) : 1;
209 209
 
210
-        $_REQUEST = (array)$data;
211
-        if ( !( !empty( $_REQUEST['wpi_ajax_export'] ) && wp_verify_nonce( $_REQUEST['wpi_ajax_export'], 'wpi_ajax_export' ) ) ) {
212
-            $response['msg']    = __( 'Security check failed.', 'invoicing' );
213
-            wp_send_json( $response );
210
+        $_REQUEST = (array) $data;
211
+        if (!(!empty($_REQUEST['wpi_ajax_export']) && wp_verify_nonce($_REQUEST['wpi_ajax_export'], 'wpi_ajax_export'))) {
212
+            $response['msg'] = __('Security check failed.', 'invoicing');
213
+            wp_send_json($response);
214 214
         }
215 215
         
216
-        if ( ( $error = $this->check_export_location( true ) ) !== true ) {
217
-            $response['msg'] = __( 'Filesystem ERROR: ' . $error, 'invoicing' );
218
-            wp_send_json( $response );
216
+        if (($error = $this->check_export_location(true)) !== true) {
217
+            $response['msg'] = __('Filesystem ERROR: ' . $error, 'invoicing');
218
+            wp_send_json($response);
219 219
         }
220 220
                         
221
-        $this->set_export_params( $_REQUEST );
221
+        $this->set_export_params($_REQUEST);
222 222
         
223 223
         $return = $this->process_export_step();
224 224
         $done   = $this->get_export_status();
225 225
         
226
-        if ( $return ) {
226
+        if ($return) {
227 227
             $this->step += 1;
228 228
             
229 229
             $response['success']    = true;
230 230
             $response['msg']        = '';
231 231
             
232
-            if ( $done >= 100 ) {
232
+            if ($done >= 100) {
233 233
                 $this->step     = 'done';
234
-                $new_filename   = 'wpi-' . $this->export . '-' . date( 'y-m-d-H-i' ) . '.' . $this->filetype;
234
+                $new_filename   = 'wpi-' . $this->export . '-' . date('y-m-d-H-i') . '.' . $this->filetype;
235 235
                 $new_file       = $this->export_dir . $new_filename;
236 236
                 
237
-                if ( file_exists( $this->file ) ) {
238
-                    $this->wp_filesystem->move( $this->file, $new_file, true );
237
+                if (file_exists($this->file)) {
238
+                    $this->wp_filesystem->move($this->file, $new_file, true);
239 239
                 }
240 240
                 
241
-                if ( file_exists( $new_file ) ) {
242
-                    $response['data']['file'] = array( 'u' => $this->export_url . $new_filename, 's' => size_format( filesize( $new_file ), 2 ) );
241
+                if (file_exists($new_file)) {
242
+                    $response['data']['file'] = array('u' => $this->export_url . $new_filename, 's' => size_format(filesize($new_file), 2));
243 243
                 }
244 244
             }
245 245
             
246 246
             $response['data']['step']   = $this->step;
247 247
             $response['data']['done']   = $done;
248 248
         } else {
249
-            $response['msg']    = __( 'No data found for export.', 'invoicing' );
249
+            $response['msg'] = __('No data found for export.', 'invoicing');
250 250
         }
251 251
 
252
-        wp_send_json( $response );
252
+        wp_send_json($response);
253 253
     }
254 254
 
255 255
     /**
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
      */
258 258
     public function discount_use_export() {
259 259
 
260
-        if ( ! wp_verify_nonce( $_GET['wpi_discount_ajax_export'], 'wpi_discount_ajax_export' ) || ! wpinv_current_user_can_manage_invoicing() ) {
260
+        if (!wp_verify_nonce($_GET['wpi_discount_ajax_export'], 'wpi_discount_ajax_export') || !wpinv_current_user_can_manage_invoicing()) {
261 261
             wp_die( -1, 403 );
262 262
         }
263 263
 
@@ -267,115 +267,115 @@  discard block
 block discarded – undo
267 267
             'posts_per_page' => -1,
268 268
         );
269 269
 
270
-        $discounts = get_posts( $args );
270
+        $discounts = get_posts($args);
271 271
 
272
-        if ( empty( $discounts ) ) {
273
-            die ( __( 'You have not set up any discounts', 'invoicing' ) );
272
+        if (empty($discounts)) {
273
+            die (__('You have not set up any discounts', 'invoicing'));
274 274
         }
275 275
 
276
-        $output  = fopen( 'php://output', 'w' ) or die( 'Unsupported server' );
276
+        $output = fopen('php://output', 'w') or die('Unsupported server');
277 277
 
278 278
         // Let the browser know what content we're streaming and how it should save the content.
279 279
 		$name = time();
280
-		header( "Content-Type:application/csv" );
281
-        header( "Content-Disposition:attachment;filename=noptin-subscribers-$name.csv" );
280
+		header("Content-Type:application/csv");
281
+        header("Content-Disposition:attachment;filename=noptin-subscribers-$name.csv");
282 282
 
283 283
         // Output the csv column headers.
284 284
 		fputcsv( 
285 285
             $output, 
286 286
             array( 
287
-                __( 'Discount Id', 'invoicing' ),
288
-                __( 'Discount Code', 'invoicing' ),
289
-                __( 'Discount Type', 'invoicing' ),
290
-                __( 'Discount Amount', 'invoicing' ),
291
-                __( 'Uses', 'invoicing' ),
287
+                __('Discount Id', 'invoicing'),
288
+                __('Discount Code', 'invoicing'),
289
+                __('Discount Type', 'invoicing'),
290
+                __('Discount Amount', 'invoicing'),
291
+                __('Uses', 'invoicing'),
292 292
             )
293 293
         );
294 294
 
295
-        foreach ( $discounts as $discount ) {
295
+        foreach ($discounts as $discount) {
296 296
 
297 297
             $discount = (int) $discount;
298 298
             $row      = array(
299 299
                 $discount,
300
-                get_post_meta( $discount, '_wpi_discount_code', true ),
301
-                get_post_meta( $discount, '_wpi_discount_type', true ),
302
-                get_post_meta( $discount, '_wpi_discount_amount', true ),
303
-                (int) get_post_meta( $discount, '_wpi_discount_uses', true )
300
+                get_post_meta($discount, '_wpi_discount_code', true),
301
+                get_post_meta($discount, '_wpi_discount_type', true),
302
+                get_post_meta($discount, '_wpi_discount_amount', true),
303
+                (int) get_post_meta($discount, '_wpi_discount_uses', true)
304 304
             );
305
-            fputcsv( $output, $row );
305
+            fputcsv($output, $row);
306 306
         }
307 307
 
308
-        fclose( $output );
308
+        fclose($output);
309 309
         exit;
310 310
 
311 311
     }
312 312
     
313
-    public function set_export_params( $request ) {
313
+    public function set_export_params($request) {
314 314
         $this->empty    = false;
315
-        $this->step     = !empty( $request['step'] ) ? absint( $request['step'] ) : 1;
316
-        $this->export   = !empty( $request['export'] ) ? $request['export'] : $this->export;
315
+        $this->step     = !empty($request['step']) ? absint($request['step']) : 1;
316
+        $this->export   = !empty($request['export']) ? $request['export'] : $this->export;
317 317
         $this->filename = 'wpi-' . $this->export . '-' . $request['wpi_ajax_export'] . '.' . $this->filetype;
318 318
         $this->file     = $this->export_dir . $this->filename;
319 319
         
320
-        do_action( 'wpinv_export_set_params_' . $this->export, $request );
320
+        do_action('wpinv_export_set_params_' . $this->export, $request);
321 321
     }
322 322
     
323 323
     public function get_columns() {
324 324
         $columns = array();
325 325
         
326
-        return apply_filters( 'wpinv_export_get_columns_' . $this->export, $columns );
326
+        return apply_filters('wpinv_export_get_columns_' . $this->export, $columns);
327 327
     }
328 328
     
329 329
     protected function get_export_file() {
330 330
         $file = '';
331 331
 
332
-        if ( $this->wp_filesystem->exists( $this->file ) ) {
333
-            $file = $this->wp_filesystem->get_contents( $this->file );
332
+        if ($this->wp_filesystem->exists($this->file)) {
333
+            $file = $this->wp_filesystem->get_contents($this->file);
334 334
         } else {
335
-            $this->wp_filesystem->put_contents( $this->file, '' );
335
+            $this->wp_filesystem->put_contents($this->file, '');
336 336
         }
337 337
 
338 338
         return $file;
339 339
     }
340 340
     
341
-    protected function attach_export_data( $data = '' ) {
342
-        $filedata   = $this->get_export_file();
343
-        $filedata   .= $data;
341
+    protected function attach_export_data($data = '') {
342
+        $filedata = $this->get_export_file();
343
+        $filedata .= $data;
344 344
         
345
-        $this->wp_filesystem->put_contents( $this->file, $filedata );
345
+        $this->wp_filesystem->put_contents($this->file, $filedata);
346 346
 
347
-        $rows       = file( $this->file, FILE_SKIP_EMPTY_LINES );
347
+        $rows       = file($this->file, FILE_SKIP_EMPTY_LINES);
348 348
         $columns    = $this->get_columns();
349
-        $columns    = empty( $columns ) ? 0 : 1;
349
+        $columns    = empty($columns) ? 0 : 1;
350 350
 
351
-        $this->empty = count( $rows ) == $columns ? true : false;
351
+        $this->empty = count($rows) == $columns ? true : false;
352 352
     }
353 353
     
354 354
     public function print_columns() {
355 355
         $column_data    = '';
356 356
         $columns        = $this->get_columns();
357 357
         $i              = 1;
358
-        foreach( $columns as $key => $column ) {
359
-            $column_data .= '"' . addslashes( $column ) . '"';
360
-            $column_data .= $i == count( $columns ) ? '' : ',';
358
+        foreach ($columns as $key => $column) {
359
+            $column_data .= '"' . addslashes($column) . '"';
360
+            $column_data .= $i == count($columns) ? '' : ',';
361 361
             $i++;
362 362
         }
363 363
         $column_data .= "\r\n";
364 364
 
365
-        $this->attach_export_data( $column_data );
365
+        $this->attach_export_data($column_data);
366 366
 
367 367
         return $column_data;
368 368
     }
369 369
     
370 370
     public function process_export_step() {
371
-        if ( $this->step < 2 ) {
372
-            /** @scrutinizer ignore-unhandled */ @unlink( $this->file );
371
+        if ($this->step < 2) {
372
+            /** @scrutinizer ignore-unhandled */ @unlink($this->file);
373 373
             $this->print_columns();
374 374
         }
375 375
         
376 376
         $return = $this->print_rows();
377 377
         
378
-        if ( $return ) {
378
+        if ($return) {
379 379
             return true;
380 380
         } else {
381 381
             return false;
@@ -384,14 +384,14 @@  discard block
 block discarded – undo
384 384
     
385 385
     public function get_export_status() {
386 386
         $status = 100;
387
-        return apply_filters( 'wpinv_get_export_status_' . $this->export, $status );
387
+        return apply_filters('wpinv_get_export_status_' . $this->export, $status);
388 388
     }
389 389
     
390 390
     public function get_export_data() {
391 391
         $data = array();
392 392
 
393
-        $data = apply_filters( 'wpinv_export_get_data', $data );
394
-        $data = apply_filters( 'wpinv_export_get_data_' . $this->export, $data );
393
+        $data = apply_filters('wpinv_export_get_data', $data);
394
+        $data = apply_filters('wpinv_export_get_data_' . $this->export, $data);
395 395
 
396 396
         return $data;
397 397
     }
@@ -401,20 +401,20 @@  discard block
 block discarded – undo
401 401
         $data       = $this->get_export_data();
402 402
         $columns    = $this->get_columns();
403 403
 
404
-        if ( $data ) {
405
-            foreach ( $data as $row ) {
404
+        if ($data) {
405
+            foreach ($data as $row) {
406 406
                 $i = 1;
407
-                foreach ( $row as $key => $column ) {
408
-                    if ( array_key_exists( $key, $columns ) ) {
409
-                        $row_data .= '"' . addslashes( preg_replace( "/\"/","'", $column ) ) . '"';
410
-                        $row_data .= $i == count( $columns ) ? '' : ',';
407
+                foreach ($row as $key => $column) {
408
+                    if (array_key_exists($key, $columns)) {
409
+                        $row_data .= '"' . addslashes(preg_replace("/\"/", "'", $column)) . '"';
410
+                        $row_data .= $i == count($columns) ? '' : ',';
411 411
                         $i++;
412 412
                     }
413 413
                 }
414 414
                 $row_data .= "\r\n";
415 415
             }
416 416
 
417
-            $this->attach_export_data( $row_data );
417
+            $this->attach_export_data($row_data);
418 418
 
419 419
             return $row_data;
420 420
         }
@@ -423,48 +423,48 @@  discard block
 block discarded – undo
423 423
     }
424 424
     
425 425
     // Export Invoices.
426
-    public function set_invoices_export( $request ) {
427
-        $this->from_date    = isset( $request['from_date'] ) ? sanitize_text_field( $request['from_date'] ) : '';
428
-        $this->to_date      = isset( $request['to_date'] ) ? sanitize_text_field( $request['to_date'] ) : '';
429
-        $this->status       = isset( $request['status'] ) ? sanitize_text_field( $request['status'] ) : 'publish';
426
+    public function set_invoices_export($request) {
427
+        $this->from_date    = isset($request['from_date']) ? sanitize_text_field($request['from_date']) : '';
428
+        $this->to_date      = isset($request['to_date']) ? sanitize_text_field($request['to_date']) : '';
429
+        $this->status       = isset($request['status']) ? sanitize_text_field($request['status']) : 'publish';
430 430
     }
431 431
     
432
-    public function get_invoices_columns( $columns = array() ) {
432
+    public function get_invoices_columns($columns = array()) {
433 433
         $columns = array(
434
-            'id'            => __( 'ID',   'invoicing' ),
435
-            'number'        => __( 'Number',   'invoicing' ),
436
-            'date'          => __( 'Date', 'invoicing' ),
437
-            'due_date'      => __( 'Due Date', 'invoicing' ),
438
-            'completed_date'=> __( 'Payment Done Date', 'invoicing' ),
439
-            'amount'        => __( 'Amount', 'invoicing' ),
440
-            'currency'      => __( 'Currency', 'invoicing' ),
441
-            'items'        => __( 'Items', 'invoicing' ),
442
-            'status_nicename'  => __( 'Status Nicename', 'invoicing' ),
443
-            'status'        => __( 'Status', 'invoicing' ),
444
-            'tax'           => __( 'Tax', 'invoicing' ),
445
-            'discount'      => __( 'Discount', 'invoicing' ),
446
-            'user_id'       => __( 'User ID', 'invoicing' ),
447
-            'email'         => __( 'Email', 'invoicing' ),
448
-            'first_name'    => __( 'First Name', 'invoicing' ),
449
-            'last_name'     => __( 'Last Name', 'invoicing' ),
450
-            'address'       => __( 'Address', 'invoicing' ),
451
-            'city'          => __( 'City', 'invoicing' ),
452
-            'state'         => __( 'State', 'invoicing' ),
453
-            'country'       => __( 'Country', 'invoicing' ),
454
-            'zip'           => __( 'Zipcode', 'invoicing' ),
455
-            'phone'         => __( 'Phone', 'invoicing' ),
456
-            'company'       => __( 'Company', 'invoicing' ),
457
-            'vat_number'    => __( 'Vat Number', 'invoicing' ),
458
-            'ip'            => __( 'IP', 'invoicing' ),
459
-            'gateway'       => __( 'Gateway', 'invoicing' ),
460
-            'gateway_nicename'       => __( 'Gateway Nicename', 'invoicing' ),
461
-            'transaction_id'=> __( 'Transaction ID', 'invoicing' ),
434
+            'id'            => __('ID', 'invoicing'),
435
+            'number'        => __('Number', 'invoicing'),
436
+            'date'          => __('Date', 'invoicing'),
437
+            'due_date'      => __('Due Date', 'invoicing'),
438
+            'completed_date'=> __('Payment Done Date', 'invoicing'),
439
+            'amount'        => __('Amount', 'invoicing'),
440
+            'currency'      => __('Currency', 'invoicing'),
441
+            'items'        => __('Items', 'invoicing'),
442
+            'status_nicename'  => __('Status Nicename', 'invoicing'),
443
+            'status'        => __('Status', 'invoicing'),
444
+            'tax'           => __('Tax', 'invoicing'),
445
+            'discount'      => __('Discount', 'invoicing'),
446
+            'user_id'       => __('User ID', 'invoicing'),
447
+            'email'         => __('Email', 'invoicing'),
448
+            'first_name'    => __('First Name', 'invoicing'),
449
+            'last_name'     => __('Last Name', 'invoicing'),
450
+            'address'       => __('Address', 'invoicing'),
451
+            'city'          => __('City', 'invoicing'),
452
+            'state'         => __('State', 'invoicing'),
453
+            'country'       => __('Country', 'invoicing'),
454
+            'zip'           => __('Zipcode', 'invoicing'),
455
+            'phone'         => __('Phone', 'invoicing'),
456
+            'company'       => __('Company', 'invoicing'),
457
+            'vat_number'    => __('Vat Number', 'invoicing'),
458
+            'ip'            => __('IP', 'invoicing'),
459
+            'gateway'       => __('Gateway', 'invoicing'),
460
+            'gateway_nicename'       => __('Gateway Nicename', 'invoicing'),
461
+            'transaction_id'=> __('Transaction ID', 'invoicing'),
462 462
         );
463 463
 
464 464
         return $columns;
465 465
     }
466 466
         
467
-    public function get_invoices_data( $response = array() ) {
467
+    public function get_invoices_data($response = array()) {
468 468
         $args = array(
469 469
             'limit'    => $this->per_page,
470 470
             'page'     => $this->step,
@@ -472,42 +472,42 @@  discard block
 block discarded – undo
472 472
             'orderby'  => 'date',
473 473
         );
474 474
         
475
-        if ( $this->status != 'any' ) {
475
+        if ($this->status != 'any') {
476 476
             $args['status'] = $this->status;
477 477
         } else {
478
-            $args['status'] = array_keys( wpinv_get_invoice_statuses( true ) );
478
+            $args['status'] = array_keys(wpinv_get_invoice_statuses(true));
479 479
         }
480 480
 
481
-        if ( !empty( $this->from_date ) || !empty( $this->to_date ) ) {
481
+        if (!empty($this->from_date) || !empty($this->to_date)) {
482 482
             $args['date_query'] = array(
483 483
                 array(
484
-                    'after'     => date( 'Y-n-d 00:00:00', strtotime( $this->from_date ) ),
485
-                    'before'    => date( 'Y-n-d 23:59:59', strtotime( $this->to_date ) ),
484
+                    'after'     => date('Y-n-d 00:00:00', strtotime($this->from_date)),
485
+                    'before'    => date('Y-n-d 23:59:59', strtotime($this->to_date)),
486 486
                     'inclusive' => true
487 487
                 )
488 488
             );
489 489
         }
490 490
 
491
-        $invoices = wpinv_get_invoices( $args );
491
+        $invoices = wpinv_get_invoices($args);
492 492
         
493 493
         $data = array();
494 494
         
495
-        if ( !empty( $invoices ) ) {
496
-            foreach ( $invoices as $invoice ) {
495
+        if (!empty($invoices)) {
496
+            foreach ($invoices as $invoice) {
497 497
                 $items = $this->get_invoice_items($invoice);
498 498
                 $row = array(
499 499
                     'id'            => $invoice->ID,
500 500
                     'number'        => $invoice->get_number(),
501
-                    'date'          => $invoice->get_invoice_date( false ),
502
-                    'due_date'      => $invoice->get_due_date( false ),
501
+                    'date'          => $invoice->get_invoice_date(false),
502
+                    'due_date'      => $invoice->get_due_date(false),
503 503
                     'completed_date'=> $invoice->get_completed_date(),
504
-                    'amount'        => wpinv_round_amount( $invoice->get_total() ),
504
+                    'amount'        => wpinv_round_amount($invoice->get_total()),
505 505
                     'currency'      => $invoice->get_currency(),
506 506
                     'items'         => $items,
507
-                    'status_nicename' => $invoice->get_status( true ),
507
+                    'status_nicename' => $invoice->get_status(true),
508 508
                     'status'        => $invoice->get_status(),
509
-                    'tax'           => $invoice->get_tax() > 0 ? wpinv_round_amount( $invoice->get_tax() ) : '',
510
-                    'discount'      => $invoice->get_discount() > 0 ? wpinv_round_amount( $invoice->get_discount() ) : '',
509
+                    'tax'           => $invoice->get_tax() > 0 ? wpinv_round_amount($invoice->get_tax()) : '',
510
+                    'discount'      => $invoice->get_discount() > 0 ? wpinv_round_amount($invoice->get_discount()) : '',
511 511
                     'user_id'       => $invoice->get_user_id(),
512 512
                     'email'         => $invoice->get_email(),
513 513
                     'first_name'    => $invoice->get_first_name(),
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
                     'transaction_id'=> $invoice->gateway ? $invoice->get_transaction_id() : '',
527 527
                 );
528 528
                 
529
-                $data[] = apply_filters( 'wpinv_export_invoice_row', $row, $invoice );
529
+                $data[] = apply_filters('wpinv_export_invoice_row', $row, $invoice);
530 530
             }
531 531
 
532 532
             return $data;
@@ -542,44 +542,44 @@  discard block
 block discarded – undo
542 542
             'return'   => 'ids',
543 543
         );
544 544
         
545
-        if ( $this->status != 'any' ) {
545
+        if ($this->status != 'any') {
546 546
             $args['status'] = $this->status;
547 547
         } else {
548
-            $args['status'] = array_keys( wpinv_get_invoice_statuses( true ) );
548
+            $args['status'] = array_keys(wpinv_get_invoice_statuses(true));
549 549
         }
550 550
 
551
-        if ( !empty( $this->from_date ) || !empty( $this->to_date ) ) {
551
+        if (!empty($this->from_date) || !empty($this->to_date)) {
552 552
             $args['date_query'] = array(
553 553
                 array(
554
-                    'after'     => date( 'Y-n-d 00:00:00', strtotime( $this->from_date ) ),
555
-                    'before'    => date( 'Y-n-d 23:59:59', strtotime( $this->to_date ) ),
554
+                    'after'     => date('Y-n-d 00:00:00', strtotime($this->from_date)),
555
+                    'before'    => date('Y-n-d 23:59:59', strtotime($this->to_date)),
556 556
                     'inclusive' => true
557 557
                 )
558 558
             );
559 559
         }
560 560
 
561
-        $invoices   = wpinv_get_invoices( $args );
562
-        $total      = !empty( $invoices ) ? count( $invoices ) : 0;
561
+        $invoices   = wpinv_get_invoices($args);
562
+        $total      = !empty($invoices) ? count($invoices) : 0;
563 563
         $status     = 100;
564 564
 
565
-        if ( $total > 0 ) {
566
-            $status = ( ( $this->per_page * $this->step ) / $total ) * 100;
565
+        if ($total > 0) {
566
+            $status = (($this->per_page * $this->step) / $total) * 100;
567 567
         }
568 568
 
569
-        if ( $status > 100 ) {
569
+        if ($status > 100) {
570 570
             $status = 100;
571 571
         }
572 572
 
573 573
         return $status;
574 574
     }
575 575
 
576
-    public function get_invoice_items($invoice){
577
-        if(!$invoice){
576
+    public function get_invoice_items($invoice) {
577
+        if (!$invoice) {
578 578
             return '';
579 579
         }
580 580
 
581 581
         $cart_details = $invoice->get_cart_details();
582
-        if(!empty($cart_details)){
582
+        if (!empty($cart_details)) {
583 583
             $cart_details = maybe_serialize($cart_details);
584 584
         } else {
585 585
             $cart_details = '';
Please login to merge, or discard this patch.