Passed
Push — master ( 1dfee0...b8b308 )
by Brian
11:47 queued 10s
created
includes/class-wpinv-privacy-exporters.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Personal data exporters.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * WPInv_Privacy_Exporters Class.
@@ -17,39 +17,39 @@  discard block
 block discarded – undo
17 17
      * @param int    $page  Page.
18 18
      * @return array An array of invoice data in name value pairs
19 19
      */
20
-    public static function customer_invoice_data_exporter( $email_address, $page ) {
20
+    public static function customer_invoice_data_exporter($email_address, $page) {
21 21
         $done           = false;
22 22
         $page           = (int) $page;
23 23
         $data_to_export = array();
24 24
 
25
-        $user           = get_user_by( 'email', $email_address );
26
-        if ( ! $user instanceof WP_User ) {
25
+        $user           = get_user_by('email', $email_address);
26
+        if (!$user instanceof WP_User) {
27 27
             return array(
28 28
                 'data' => $data_to_export,
29 29
                 'done' => true,
30 30
             );
31 31
         }
32 32
 
33
-        $args    = array(
33
+        $args = array(
34 34
             'limit'    => 30,
35 35
             'page'     => $page,
36 36
             'user'     => $user->ID,
37 37
             'paginate' => false,
38 38
         );
39 39
 
40
-        $invoices = wpinv_get_invoices( $args );
40
+        $invoices = wpinv_get_invoices($args);
41 41
 
42
-        if ( 0 < count( $invoices ) ) {
43
-            foreach ( $invoices as $invoice ) {
42
+        if (0 < count($invoices)) {
43
+            foreach ($invoices as $invoice) {
44 44
                 $data_to_export[] = array(
45 45
                     'group_id'          => 'customer_invoices',
46
-                    'group_label'       => __( 'Invoicing Data', 'invoicing' ),
47
-                    'group_description' => __( 'Customer invoicing data.', 'invoicing' ),
46
+                    'group_label'       => __('Invoicing Data', 'invoicing'),
47
+                    'group_description' => __('Customer invoicing data.', 'invoicing'),
48 48
                     'item_id'           => "wpinv-{$invoice->ID}",
49
-                    'data'              => self::get_customer_invoice_data( $invoice ),
49
+                    'data'              => self::get_customer_invoice_data($invoice),
50 50
                 );
51 51
             }
52
-            $done = 30 > count( $invoices );
52
+            $done = 30 > count($invoices);
53 53
         } else {
54 54
             $done = true;
55 55
         }
@@ -67,59 +67,59 @@  discard block
 block discarded – undo
67 67
      * @param WPInv_Invoice $invoice invoice object.
68 68
      * @return array
69 69
      */
70
-    public static function get_customer_invoice_data( $invoice ) {
70
+    public static function get_customer_invoice_data($invoice) {
71 71
         $personal_data = array();
72 72
 
73 73
         $props_to_export = array(
74
-            'number'               => __( 'Invoice Number', 'invoicing' ),
75
-            'created_date'         => __( 'Invoice Date', 'invoicing' ),
76
-            'status'               => __( 'Invoice Status', 'invoicing' ),
77
-            'total'                => __( 'Invoice Total', 'invoicing' ),
78
-            'items'                => __( 'Invoice Items', 'invoicing' ),
79
-            'first_name'           => __( 'First Name', 'invoicing' ),
80
-            'last_name'            => __( 'Last Name', 'invoicing' ),
81
-            'email'                => __( 'Email Address', 'invoicing' ),
82
-            '_wpinv_company'       => __( 'Company', 'invoicing' ),
83
-            'phone'                => __( 'Phone Number', 'invoicing' ),
84
-            'address'              => __( 'Address', 'invoicing' ),
85
-            '_wpinv_city'          => __( 'City', 'invoicing' ),
86
-            '_wpinv_country'       => __( 'Country', 'invoicing' ),
87
-            '_wpinv_state'         => __( 'State', 'invoicing' ),
88
-            '_wpinv_zip'           => __( 'Zip Code', 'invoicing' ),
74
+            'number'               => __('Invoice Number', 'invoicing'),
75
+            'created_date'         => __('Invoice Date', 'invoicing'),
76
+            'status'               => __('Invoice Status', 'invoicing'),
77
+            'total'                => __('Invoice Total', 'invoicing'),
78
+            'items'                => __('Invoice Items', 'invoicing'),
79
+            'first_name'           => __('First Name', 'invoicing'),
80
+            'last_name'            => __('Last Name', 'invoicing'),
81
+            'email'                => __('Email Address', 'invoicing'),
82
+            '_wpinv_company'       => __('Company', 'invoicing'),
83
+            'phone'                => __('Phone Number', 'invoicing'),
84
+            'address'              => __('Address', 'invoicing'),
85
+            '_wpinv_city'          => __('City', 'invoicing'),
86
+            '_wpinv_country'       => __('Country', 'invoicing'),
87
+            '_wpinv_state'         => __('State', 'invoicing'),
88
+            '_wpinv_zip'           => __('Zip Code', 'invoicing'),
89 89
         );
90 90
 
91
-        $subscription = wpinv_get_subscription( $invoice );
91
+        $subscription = wpinv_get_subscription($invoice);
92 92
         $period = $initial_amt = $bill_times = $billed = $renewal_date = '';
93 93
 
94
-        if ( $invoice->is_recurring() && !empty( $subscription ) ) {
95
-            $frequency = getpaid_get_subscription_period_label( $subscription->get_period(),$subscription->get_frequency() );
96
-            $period = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ) . ' / ' . $frequency;
97
-            $initial_amt = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() );
98
-            $bill_times = $subscription->get_times_billed() . ' / ' . ( ( $subscription->get_bill_times() == 0 ) ? __( 'Until Cancelled', 'invoicing' ) : $subscription->get_bill_times() );
99
-            $renewal_date = ! empty( $subscription->get_expiration() ) ? getpaid_format_date( $subscription->get_expiration() ) : __( 'N/A', 'invoicing' );
100
-
101
-            $props_to_export['period'] = __( 'Billing Cycle', 'invoicing' );
102
-            $props_to_export['initial_amount'] = __( 'Initial Amount', 'invoicing' );
103
-            $props_to_export['bill_times'] = __( 'Times Billed', 'invoicing' );
104
-            $props_to_export['renewal_date'] = __( 'Renewal Date', 'invoicing' );
94
+        if ($invoice->is_recurring() && !empty($subscription)) {
95
+            $frequency = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency());
96
+            $period = wpinv_price($subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency()) . ' / ' . $frequency;
97
+            $initial_amt = wpinv_price($subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency());
98
+            $bill_times = $subscription->get_times_billed() . ' / ' . (($subscription->get_bill_times() == 0) ? __('Until Cancelled', 'invoicing') : $subscription->get_bill_times());
99
+            $renewal_date = !empty($subscription->get_expiration()) ? getpaid_format_date($subscription->get_expiration()) : __('N/A', 'invoicing');
100
+
101
+            $props_to_export['period'] = __('Billing Cycle', 'invoicing');
102
+            $props_to_export['initial_amount'] = __('Initial Amount', 'invoicing');
103
+            $props_to_export['bill_times'] = __('Times Billed', 'invoicing');
104
+            $props_to_export['renewal_date'] = __('Renewal Date', 'invoicing');
105 105
         }
106 106
 
107
-        $props_to_export['ip'] = __( 'IP Address', 'invoicing' );
108
-        $props_to_export['view_url'] = __( 'Invoice Link', 'invoicing' );
107
+        $props_to_export['ip'] = __('IP Address', 'invoicing');
108
+        $props_to_export['view_url'] = __('Invoice Link', 'invoicing');
109 109
 
110
-        $props_to_export = apply_filters( 'wpinv_privacy_export_invoice_personal_data_props', $props_to_export, $invoice, $subscription);
110
+        $props_to_export = apply_filters('wpinv_privacy_export_invoice_personal_data_props', $props_to_export, $invoice, $subscription);
111 111
 
112
-        foreach ( $props_to_export as $prop => $name ) {
112
+        foreach ($props_to_export as $prop => $name) {
113 113
             $value = '';
114 114
 
115
-            switch ( $prop ) {
115
+            switch ($prop) {
116 116
                 case 'items':
117 117
                     $item_names = array();
118
-                    foreach ( $invoice->get_cart_details() as $key => $cart_item ) {
119
-                        $item_quantity  = $cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1;
118
+                    foreach ($invoice->get_cart_details() as $key => $cart_item) {
119
+                        $item_quantity = $cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1;
120 120
                         $item_names[] = $cart_item['name'] . ' x ' . $item_quantity;
121 121
                     }
122
-                    $value = implode( ', ', $item_names );
122
+                    $value = implode(', ', $item_names);
123 123
                     break;
124 124
                 case 'status':
125 125
                     $value = $invoice->get_status(true);
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
                     $value = $renewal_date;
141 141
                     break;
142 142
                 default:
143
-                    if ( is_callable( array( $invoice, 'get_' . $prop ) ) ) {
143
+                    if (is_callable(array($invoice, 'get_' . $prop))) {
144 144
                         $value = $invoice->{"get_$prop"}();
145 145
                     } else {
146 146
                         $value = $invoice->get_meta($prop);
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
                     break;
149 149
             }
150 150
 
151
-            $value = apply_filters( 'wpi_privacy_export_invoice_personal_data_prop', $value, $prop, $invoice );
151
+            $value = apply_filters('wpi_privacy_export_invoice_personal_data_prop', $value, $prop, $invoice);
152 152
 
153
-            if ( $value ) {
153
+            if ($value) {
154 154
                 $personal_data[] = array(
155 155
                     'name'  => $name,
156 156
                     'value' => $value,
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 
160 160
         }
161 161
 
162
-        $personal_data = apply_filters( 'wpinv_privacy_export_invoice_personal_data', $personal_data, $invoice );
162
+        $personal_data = apply_filters('wpinv_privacy_export_invoice_personal_data', $personal_data, $invoice);
163 163
 
164 164
         return $personal_data;
165 165
 
Please login to merge, or discard this patch.