Passed
Push — master ( 24d4c3...a419ab )
by Stiofan
12:50
created
includes/admin/meta-boxes/class-mb-invoice-details.php 1 patch
Spacing   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -1,30 +1,30 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Details {
8
-    public static function output( $post ) {
8
+    public static function output($post) {
9 9
         $currency_symbol    = wpinv_currency_symbol();
10
-        $statuses           = wpinv_get_invoice_statuses( true );
10
+        $statuses           = wpinv_get_invoice_statuses(true);
11 11
         
12
-        $post_id            = !empty( $post->ID ) ? $post->ID : 0;
13
-        $invoice            = new WPInv_Invoice( $post_id );
12
+        $post_id            = !empty($post->ID) ? $post->ID : 0;
13
+        $invoice            = new WPInv_Invoice($post_id);
14 14
         
15
-        $status             = $invoice->get_status( false ); // Current status    
15
+        $status             = $invoice->get_status(false); // Current status    
16 16
         $discount           = $invoice->get_discount();
17 17
         $discount_code      = $discount > 0 ? $invoice->get_discount_code() : '';
18 18
         $invoice_number     = $invoice->get_number();
19 19
         
20 20
         $date_created       = $invoice->get_created_date();
21
-        $datetime_created   = strtotime( $date_created );
22
-        $date_created       = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $datetime_created ) : '';
21
+        $datetime_created   = strtotime($date_created);
22
+        $date_created       = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $datetime_created) : '';
23 23
         $date_completed     = $invoice->get_completed_date();
24
-        $date_completed     = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $date_completed ) ) : 'n/a';
25
-        $title['status'] = __( 'Invoice Status:', 'invoicing' );
26
-        $title['number'] = __( 'Invoice Number:', 'invoicing' );
27
-        $mail_notice = esc_attr__( 'After saving invoice, this will send a copy of the invoice to the user&#8217;s email address.', 'invoicing' );
24
+        $date_completed     = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime($date_completed)) : 'n/a';
25
+        $title['status'] = __('Invoice Status:', 'invoicing');
26
+        $title['number'] = __('Invoice Number:', 'invoicing');
27
+        $mail_notice = esc_attr__('After saving invoice, this will send a copy of the invoice to the user&#8217;s email address.', 'invoicing');
28 28
         
29 29
         $title = apply_filters('wpinv_details_metabox_titles', $title, $invoice);
30 30
         $statuses = apply_filters('wpinv_invoice_statuses', $statuses, $invoice);
@@ -34,36 +34,36 @@  discard block
 block discarded – undo
34 34
 <div class="gdmbx2-wrap form-table">
35 35
     <div class="gdmbx2-metabox gdmbx-field-list" id="gdmbx2-metabox-wpinv_details">
36 36
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-created">
37
-            <div class="gdmbx-th"><label><?php _e( 'Date Created:', 'invoicing' );?></label></div>
38
-            <div class="gdmbx-td"><?php echo $date_created;?></div>
37
+            <div class="gdmbx-th"><label><?php _e('Date Created:', 'invoicing'); ?></label></div>
38
+            <div class="gdmbx-td"><?php echo $date_created; ?></div>
39 39
         </div>
40
-        <?php if ( $invoice->post_type == 'wpi_invoice' && wpinv_get_option( 'overdue_active' ) && ( $invoice->needs_payment() || $invoice->has_status( array( 'auto-draft', 'draft' ) ) ) ) { ?>
40
+        <?php if ($invoice->post_type == 'wpi_invoice' && wpinv_get_option('overdue_active') && ($invoice->needs_payment() || $invoice->has_status(array('auto-draft', 'draft')))) { ?>
41 41
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-overdue">
42
-            <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e( 'Due Date:', 'invoicing' );?></label></div>
42
+            <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e('Due Date:', 'invoicing'); ?></label></div>
43 43
             <div class="gdmbx-td">
44
-                <input type="text" placeholder="<?php esc_attr_e( 'Y-m-d', 'invoicing' );?>" value="<?php echo esc_attr( $invoice->get_due_date() );?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr( date_i18n( 'Y-m-d', $datetime_created ) );?>" data-dateFormat="yy-mm-dd">
45
-                <p class="wpi-meta-row wpi-meta-desc"><?php _e( 'Leave blank to disable sending auto reminder for this invoice.', 'invoicing' );?></p>
44
+                <input type="text" placeholder="<?php esc_attr_e('Y-m-d', 'invoicing'); ?>" value="<?php echo esc_attr($invoice->get_due_date()); ?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr(date_i18n('Y-m-d', $datetime_created)); ?>" data-dateFormat="yy-mm-dd">
45
+                <p class="wpi-meta-row wpi-meta-desc"><?php _e('Leave blank to disable sending auto reminder for this invoice.', 'invoicing'); ?></p>
46 46
             </div>
47 47
         </div>
48 48
         <?php } ?>
49
-        <?php do_action( 'wpinv_meta_box_details_after_due_date', $post_id ); ?>
50
-        <?php if ( $date_completed && $date_completed != 'n/a' ) { ?>
49
+        <?php do_action('wpinv_meta_box_details_after_due_date', $post_id); ?>
50
+        <?php if ($date_completed && $date_completed != 'n/a') { ?>
51 51
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-completed">
52
-            <div class="gdmbx-th"><label><?php _e( 'Payment Date:', 'invoicing' );?></label></div>
53
-            <div class="gdmbx-td"><?php echo $date_completed;?></div>
52
+            <div class="gdmbx-th"><label><?php _e('Payment Date:', 'invoicing'); ?></label></div>
53
+            <div class="gdmbx-td"><?php echo $date_completed; ?></div>
54 54
         </div>
55 55
         <?php } ?>
56
-        <?php $is_viewed = wpinv_is_invoice_viewed( $post_id ); ?>
56
+        <?php $is_viewed = wpinv_is_invoice_viewed($post_id); ?>
57 57
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-customer-viewed">
58
-            <div class="gdmbx-th"><label><?php _e( 'Viewed by Customer:', 'invoicing' );?></label></div>
59
-            <div class="gdmbx-td"><?php ( 1 == $is_viewed ) ? _e( 'Yes', 'invoicing' ) : _e( 'No', 'invoicing' ); ?></div>
58
+            <div class="gdmbx-th"><label><?php _e('Viewed by Customer:', 'invoicing'); ?></label></div>
59
+            <div class="gdmbx-td"><?php (1 == $is_viewed) ? _e('Yes', 'invoicing') : _e('No', 'invoicing'); ?></div>
60 60
         </div>
61 61
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-status">
62 62
             <div class="gdmbx-th"><label for="wpinv_status"><?php echo $title['status']; ?></label></div>
63 63
             <div class="gdmbx-td">
64 64
                 <select required="required" id="wpinv_status" name="wpinv_status" class="gdmbx2_select">
65
-                    <?php foreach ( $statuses as $value => $label ) { ?>
66
-                    <option value="<?php echo $value;?>" <?php selected( $status, $value );?>><?php echo $label;?></option>
65
+                    <?php foreach ($statuses as $value => $label) { ?>
66
+                    <option value="<?php echo $value; ?>" <?php selected($status, $value); ?>><?php echo $label; ?></option>
67 67
                     <?php } ?>
68 68
                 </select>
69 69
             </div>
@@ -71,117 +71,117 @@  discard block
 block discarded – undo
71 71
         <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-number table-layout">
72 72
             <div class="gdmbx-th"><label for="wpinv_number"><?php echo $title['number']; ?></label></div>
73 73
             <div class="gdmbx-td">
74
-                <input type="text" value="<?php echo esc_attr( $invoice_number );?>" id="wpinv_number" name="wpinv_number" class="regular-text" readonly>
74
+                <input type="text" value="<?php echo esc_attr($invoice_number); ?>" id="wpinv_number" name="wpinv_number" class="regular-text" readonly>
75 75
             </div>
76 76
         </div>
77
-        <?php do_action( 'wpinv_meta_box_details_inner', $post_id );
77
+        <?php do_action('wpinv_meta_box_details_inner', $post_id);
78 78
         $disable_discount = apply_filters('wpinv_disable_apply_discount', false, $invoice, $post_id);
79 79
         ?>
80
-        <?php if ( !( $is_paid = ( $invoice->is_paid() || $invoice->is_refunded() ) ) && !$disable_discount || $discount_code ) { ?>
80
+        <?php if (!($is_paid = ($invoice->is_paid() || $invoice->is_refunded())) && !$disable_discount || $discount_code) { ?>
81 81
         <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-discount-code table-layout">
82
-            <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e( 'Discount Code:', 'invoicing' );?></label></div>
82
+            <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e('Discount Code:', 'invoicing'); ?></label></div>
83 83
             <div class="gdmbx-td">
84
-                <input type="text" value="<?php echo esc_attr( $discount_code ); ?>" id="wpinv_discount" class="medium-text" <?php echo ( $discount_code ? 'readonly' : '' ); ?> /><?php if ( !$is_paid && !$disable_discount ) { ?><input value="<?php echo esc_attr_e( 'Apply', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-hide' : 'wpi-inlineb' ); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e( 'Remove', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-inlineb' : 'wpi-hide' ); ?>" id="wpinv-remove-code" type="button" /><?php } ?>
84
+                <input type="text" value="<?php echo esc_attr($discount_code); ?>" id="wpinv_discount" class="medium-text" <?php echo ($discount_code ? 'readonly' : ''); ?> /><?php if (!$is_paid && !$disable_discount) { ?><input value="<?php echo esc_attr_e('Apply', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-hide' : 'wpi-inlineb'); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e('Remove', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-inlineb' : 'wpi-hide'); ?>" id="wpinv-remove-code" type="button" /><?php } ?>
85 85
             </div>
86 86
         </div>
87 87
         <?php } ?>
88 88
     </div>
89 89
 </div>
90 90
 <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-save-send table-layout">
91
-    <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php echo sprintf(__( 'Send %s:', 'invoicing' ),$post_obj->labels->singular_name) ; ?></label>
91
+    <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php echo sprintf(__('Send %s:', 'invoicing'), $post_obj->labels->singular_name); ?></label>
92 92
         <select id="wpi_save_send" name="wpi_save_send">
93
-            <option value="1"><?php _e( 'Yes', 'invoicing' ); ?></option>
94
-            <option value="" selected="selected"><?php _e( 'No', 'invoicing' ); ?></option>
93
+            <option value="1"><?php _e('Yes', 'invoicing'); ?></option>
94
+            <option value="" selected="selected"><?php _e('No', 'invoicing'); ?></option>
95 95
         </select>
96 96
     </p>
97 97
     <p class="wpi-meta-row wpi-send-info"><?php echo $mail_notice; ?></p>
98 98
 </div>
99
-<?php wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ;?>
99
+<?php wp_nonce_field('wpinv_details', 'wpinv_details_nonce'); ?>
100 100
         <?php
101 101
     }
102 102
     
103
-    public static function resend_invoice( $post ) {
103
+    public static function resend_invoice($post) {
104 104
         global $wpi_mb_invoice;
105 105
         
106
-        if ( empty( $wpi_mb_invoice ) ) {
106
+        if (empty($wpi_mb_invoice)) {
107 107
             return;
108 108
         }
109 109
         
110 110
         $text = array(
111
-            'message'       => esc_attr__( 'This will send a copy of the invoice to the customer&#8217;s email address.', 'invoicing' ),
112
-            'button_text'   =>  __( 'Resend Invoice', 'invoicing' ),
111
+            'message'       => esc_attr__('This will send a copy of the invoice to the customer&#8217;s email address.', 'invoicing'),
112
+            'button_text'   =>  __('Resend Invoice', 'invoicing'),
113 113
         );
114 114
             
115 115
         $text = apply_filters('wpinv_resend_invoice_metabox_text', $text);
116
-        do_action( 'wpinv_metabox_resend_invoice_before', $wpi_mb_invoice );
116
+        do_action('wpinv_metabox_resend_invoice_before', $wpi_mb_invoice);
117 117
         
118
-        if ( $email = $wpi_mb_invoice->get_email() ) {
118
+        if ($email = $wpi_mb_invoice->get_email()) {
119 119
             $email_actions = array();
120
-            $email_actions['email_url']      = remove_query_arg( 'wpinv-message', add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) );
121
-            $email_actions['reminder_url']   = add_query_arg( array( 'wpi_action' => 'send_reminder', 'invoice_id' => $post->ID ) );
120
+            $email_actions['email_url']      = remove_query_arg('wpinv-message', add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID)));
121
+            $email_actions['reminder_url']   = add_query_arg(array('wpi_action' => 'send_reminder', 'invoice_id' => $post->ID));
122 122
             
123
-            $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions );
123
+            $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions);
124 124
         ?>
125 125
         <p class="wpi-meta-row wpi-resend-info"><?php echo $text['message']; ?></p>
126
-        <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url( $email_actions['email_url'] ); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p>
127
-        <?php if ( wpinv_get_option( 'overdue_active' ) && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ( $due_date = $wpi_mb_invoice->get_due_date() ) ) { ?>
128
-        <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e( 'Send overdue reminder notification to customer', 'invoicing' ); ?>" href="<?php echo esc_url( $email_actions['reminder_url'] ); ?>" class="button button-secondary"><?php esc_attr_e( 'Send Reminder', 'invoicing' ); ?></a></p>
126
+        <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url($email_actions['email_url']); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p>
127
+        <?php if (wpinv_get_option('overdue_active') && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ($due_date = $wpi_mb_invoice->get_due_date())) { ?>
128
+        <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e('Send overdue reminder notification to customer', 'invoicing'); ?>" href="<?php echo esc_url($email_actions['reminder_url']); ?>" class="button button-secondary"><?php esc_attr_e('Send Reminder', 'invoicing'); ?></a></p>
129 129
         <?php } ?>
130 130
         <?php
131 131
         }
132 132
         
133
-        do_action( 'wpinv_metabox_resend_invoice_after', $wpi_mb_invoice );
133
+        do_action('wpinv_metabox_resend_invoice_after', $wpi_mb_invoice);
134 134
     }
135 135
     
136
-    public static function subscriptions( $post ) {
137
-        $invoice = wpinv_get_invoice( $post->ID );
136
+    public static function subscriptions($post) {
137
+        $invoice = wpinv_get_invoice($post->ID);
138 138
 
139
-        if ( ! empty( $invoice ) && $invoice->is_recurring() && $invoice->is_parent() ) {
140
-            $subscription = wpinv_get_subscription( $invoice );
139
+        if (!empty($invoice) && $invoice->is_recurring() && $invoice->is_parent()) {
140
+            $subscription = wpinv_get_subscription($invoice);
141 141
 
142
-            if ( empty( $subscription ) ) {
142
+            if (empty($subscription)) {
143 143
                 ?>
144
-                <p class="wpi-meta-row"><?php echo wp_sprintf( __( 'New Subscription will be created when customer will checkout and pay the invoice. Go to: %sSubscriptions%s', 'invoicing' ), '<a href="' . admin_url( 'admin.php?page=wpinv-subscriptions' ).'">', '</a>' ); ?></p>
144
+                <p class="wpi-meta-row"><?php echo wp_sprintf(__('New Subscription will be created when customer will checkout and pay the invoice. Go to: %sSubscriptions%s', 'invoicing'), '<a href="' . admin_url('admin.php?page=wpinv-subscriptions') . '">', '</a>'); ?></p>
145 145
                 <?php
146 146
                 return;
147 147
             }
148
-            $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $subscription->period, $subscription->frequency );
149
-            $billing = wpinv_price(wpinv_format_amount( $subscription->recurring_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) ) . ' / ' . $frequency;
150
-            $initial = wpinv_price(wpinv_format_amount( $subscription->initial_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) );
148
+            $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($subscription->period, $subscription->frequency);
149
+            $billing = wpinv_price(wpinv_format_amount($subscription->recurring_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id)) . ' / ' . $frequency;
150
+            $initial = wpinv_price(wpinv_format_amount($subscription->initial_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id));
151 151
             $payments = $subscription->get_child_payments();
152 152
             ?>
153 153
             <p class="wpi-meta-row wpi-sub-label <?php echo 'status-' . $subscription->status; ?>"><?php _e('Recurring Payment', 'invoicing'); ?></p>
154
-            <?php if ( ! empty( $subscription ) && ! empty( $subscription->id ) ) { ?>
154
+            <?php if (!empty($subscription) && !empty($subscription->id)) { ?>
155 155
                 <p class="wpi-meta-row wpi-sub-id">
156
-                    <label><?php _e( 'Subscription ID:', 'invoicing' ); ?> </label><a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $subscription->id ) ); ?>" title="<?php esc_attr_e( 'View or edit subscription', 'invoicing' ); ?>" target="_blank"><?php echo $subscription->id; ?></a></p>
156
+                    <label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $subscription->id)); ?>" title="<?php esc_attr_e('View or edit subscription', 'invoicing'); ?>" target="_blank"><?php echo $subscription->id; ?></a></p>
157 157
             <?php } ?>
158 158
             <p class="wpi-meta-row wpi-bill-cycle">
159
-                <label><?php _e( 'Billing Cycle:', 'invoicing'); ?> </label><?php printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); ?>
159
+                <label><?php _e('Billing Cycle:', 'invoicing'); ?> </label><?php printf(_x('%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing'), $initial, $billing); ?>
160 160
             </p>
161 161
             <p class="wpi-meta-row wpi-billed-times">
162
-                <label><?php _e( 'Times Billed:', 'invoicing' ); ?> </label><?php echo $subscription->get_times_billed() . ' / ' . ( ( $subscription->bill_times == 0 ) ? 'Until Cancelled' : $subscription->bill_times ); ?>
162
+                <label><?php _e('Times Billed:', 'invoicing'); ?> </label><?php echo $subscription->get_times_billed() . ' / ' . (($subscription->bill_times == 0) ? 'Until Cancelled' : $subscription->bill_times); ?>
163 163
             </p>
164 164
             <p class="wpi-meta-row wpi-start-date">
165
-                <label><?php _e( 'Start Date:', 'invoicing' ); ?> </label><?php echo date_i18n( get_option( 'date_format' ), strtotime( $subscription->created, current_time( 'timestamp' ) ) ); ?>
165
+                <label><?php _e('Start Date:', 'invoicing'); ?> </label><?php echo date_i18n(get_option('date_format'), strtotime($subscription->created, current_time('timestamp'))); ?>
166 166
             </p>
167 167
             <p class="wpi-meta-row wpi-end-date">
168
-                <label><?php echo ( 'trialling' == $subscription->status ? __( 'Trialling Until:', 'invoicing' ) : __( 'Expiration Date:', 'invoicing' ) ); ?> </label><?php echo date_i18n( get_option( 'date_format' ), strtotime( $subscription->expiration, current_time( 'timestamp' ) ) ); ?>
168
+                <label><?php echo ('trialling' == $subscription->status ? __('Trialling Until:', 'invoicing') : __('Expiration Date:', 'invoicing')); ?> </label><?php echo date_i18n(get_option('date_format'), strtotime($subscription->expiration, current_time('timestamp'))); ?>
169 169
             </p>
170
-            <?php if ( $subscription->status ) { ?>
170
+            <?php if ($subscription->status) { ?>
171 171
                 <p class="wpi-meta-row wpi-sub-status">
172
-                    <label><?php _e( 'Subscription Status:', 'invoicing'); ?> </label><?php echo $subscription->get_status_label(); ?>
172
+                    <label><?php _e('Subscription Status:', 'invoicing'); ?> </label><?php echo $subscription->get_status_label(); ?>
173 173
                 </p>
174 174
             <?php } ?>
175
-            <?php if ( !empty( $payments ) ) { ?>
176
-                <p><strong><?php _e( 'Renewal Payments:', 'invoicing' ); ?></strong></p>
175
+            <?php if (!empty($payments)) { ?>
176
+                <p><strong><?php _e('Renewal Payments:', 'invoicing'); ?></strong></p>
177 177
                 <ul id="wpi-sub-payments">
178
-                <?php foreach ( $payments as $payment ) {
178
+                <?php foreach ($payments as $payment) {
179 179
                     $invoice_id = $payment->ID;
180 180
                     ?>
181 181
                     <li>
182
-                        <a href="<?php echo esc_url( get_edit_post_link( $invoice_id ) ); ?>"><?php echo wpinv_get_invoice_number( $invoice_id ); ?></a>&nbsp;&ndash;&nbsp;
183
-                        <span><?php echo wpinv_get_invoice_date( $invoice_id ); ?>&nbsp;&ndash;&nbsp;</span>
184
-                        <span><?php echo wpinv_payment_total( $invoice_id, true ); ?></span>
182
+                        <a href="<?php echo esc_url(get_edit_post_link($invoice_id)); ?>"><?php echo wpinv_get_invoice_number($invoice_id); ?></a>&nbsp;&ndash;&nbsp;
183
+                        <span><?php echo wpinv_get_invoice_date($invoice_id); ?>&nbsp;&ndash;&nbsp;</span>
184
+                        <span><?php echo wpinv_payment_total($invoice_id, true); ?></span>
185 185
                     </li>
186 186
                 <?php } ?>
187 187
                 </ul>
@@ -189,50 +189,50 @@  discard block
 block discarded – undo
189 189
         }
190 190
     }
191 191
     
192
-    public static function renewals( $post ) {
193
-        $invoice = wpinv_get_invoice( $post->ID );
192
+    public static function renewals($post) {
193
+        $invoice = wpinv_get_invoice($post->ID);
194 194
         
195
-        if ( wpinv_is_subscription_payment( $invoice ) ) {
196
-            $parent_url = get_edit_post_link( $invoice->parent_invoice );
197
-            $parent_id  = wpinv_get_invoice_number( $invoice->parent_invoice );
198
-            $subscription = wpinv_get_subscription( $invoice );
195
+        if (wpinv_is_subscription_payment($invoice)) {
196
+            $parent_url = get_edit_post_link($invoice->parent_invoice);
197
+            $parent_id  = wpinv_get_invoice_number($invoice->parent_invoice);
198
+            $subscription = wpinv_get_subscription($invoice);
199 199
         ?>
200
-        <?php if ( ! empty( $subscription ) ) { ?><p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $subscription->id ) ); ?>" title="<?php esc_attr_e( 'View or edit subscription', 'invoicing' ); ?>" target="_blank"><?php echo $subscription->id; ?></a></p><?php } ?>
201
-        <p class="wpi-meta-row wpi-parent-id"><label><?php _e( 'Parent Invoice:', 'invoicing' );?> </label><a href="<?php echo esc_url( $parent_url ); ?>"><?php echo $parent_id; ?></a></p>
200
+        <?php if (!empty($subscription)) { ?><p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $subscription->id)); ?>" title="<?php esc_attr_e('View or edit subscription', 'invoicing'); ?>" target="_blank"><?php echo $subscription->id; ?></a></p><?php } ?>
201
+        <p class="wpi-meta-row wpi-parent-id"><label><?php _e('Parent Invoice:', 'invoicing'); ?> </label><a href="<?php echo esc_url($parent_url); ?>"><?php echo $parent_id; ?></a></p>
202 202
         <?php
203 203
         }
204 204
     }
205 205
     
206
-    public static function payment_meta( $post ) {
206
+    public static function payment_meta($post) {
207 207
         global $wpi_mb_invoice;
208 208
 
209
-        $set_dateway = empty( $wpi_mb_invoice->gateway ) ? true : false;
210
-        if ( !$set_dateway && !$wpi_mb_invoice->get_meta( '_wpinv_checkout', true ) && !$wpi_mb_invoice->is_paid() && !$wpi_mb_invoice->is_refunded() ) {
209
+        $set_dateway = empty($wpi_mb_invoice->gateway) ? true : false;
210
+        if (!$set_dateway && !$wpi_mb_invoice->get_meta('_wpinv_checkout', true) && !$wpi_mb_invoice->is_paid() && !$wpi_mb_invoice->is_refunded()) {
211 211
             $set_dateway = true;
212 212
         }
213 213
         
214 214
         ?>
215 215
         <p class="wpi-meta-row">
216
-        <?php if ( $set_dateway ) { $gateways = wpinv_get_enabled_payment_gateways( true ); ?>
217
-            <label for="wpinv_gateway"><?php _e( 'Gateway:', 'invoicing' ) ; ?></label>
216
+        <?php if ($set_dateway) { $gateways = wpinv_get_enabled_payment_gateways(true); ?>
217
+            <label for="wpinv_gateway"><?php _e('Gateway:', 'invoicing'); ?></label>
218 218
             <select required="required" id="wpinv_gateway" name="wpinv_gateway">
219
-                <?php foreach ( $gateways as $name => $gateway ) {
220
-                    if ( $wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription( $name ) ) {
219
+                <?php foreach ($gateways as $name => $gateway) {
220
+                    if ($wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription($name)) {
221 221
                         continue;
222 222
                     }
223 223
                     ?>
224
-                <option value="<?php echo $name;?>" <?php selected( $wpi_mb_invoice->gateway, $name );?>><?php echo !empty( $gateway['admin_label'] ) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option>
224
+                <option value="<?php echo $name; ?>" <?php selected($wpi_mb_invoice->gateway, $name); ?>><?php echo !empty($gateway['admin_label']) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option>
225 225
                 <?php } ?>
226 226
             </select>
227 227
         <?php } else { 
228
-            echo wp_sprintf( __( '<label>Gateway:</label> %s', 'invoicing' ), wpinv_get_gateway_admin_label( $wpi_mb_invoice->gateway ) );
228
+            echo wp_sprintf(__('<label>Gateway:</label> %s', 'invoicing'), wpinv_get_gateway_admin_label($wpi_mb_invoice->gateway));
229 229
         } ?>
230 230
         </p>
231
-        <?php if ( $key = $wpi_mb_invoice->get_key() ) { ?>
232
-        <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Key:</label> %s', 'invoicing' ), $key ); ?></p>
231
+        <?php if ($key = $wpi_mb_invoice->get_key()) { ?>
232
+        <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Key:</label> %s', 'invoicing'), $key); ?></p>
233 233
         <?php } ?>
234
-        <?php if ( $wpi_mb_invoice->is_paid() || $wpi_mb_invoice->is_refunded() ) { ?>
235
-        <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Transaction ID:</label> %s', 'invoicing' ), wpinv_payment_link_transaction_id( $wpi_mb_invoice ) ); ?></p>
234
+        <?php if ($wpi_mb_invoice->is_paid() || $wpi_mb_invoice->is_refunded()) { ?>
235
+        <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Transaction ID:</label> %s', 'invoicing'), wpinv_payment_link_transaction_id($wpi_mb_invoice)); ?></p>
236 236
         <?php } ?>
237 237
         <?php
238 238
     }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-invoice-address.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -1,34 +1,34 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Billing_Details {
8
-    public static function output( $post ) {
8
+    public static function output($post) {
9 9
         global $user_ID;
10
-        $post_id    = !empty( $post->ID ) ? $post->ID : 0;
11
-        $invoice    = new WPInv_Invoice( $post_id );
10
+        $post_id    = !empty($post->ID) ? $post->ID : 0;
11
+        $invoice    = new WPInv_Invoice($post_id);
12 12
 ?>
13 13
 <div class="gdmbx2-wrap form-table">
14 14
     <div id="gdmbx2-metabox-wpinv_address" class="gdmbx2-metabox gdmbx-field-list wpinv-address gdmbx-row">
15 15
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-user-id table-layout">
16 16
             <div class="gdmbx-th">
17
-                <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label>
17
+                <label for="post_author_override"><?php _e('Customer', 'invoicing'); ?></label>
18 18
             </div>
19 19
             <div class="gdmbx-td gdmbx-customer-div">
20
-            <?php wpinv_dropdown_users( array(
20
+            <?php wpinv_dropdown_users(array(
21 21
                             'name' => 'post_author_override',
22 22
                             'selected' => empty($post->ID) ? $user_ID : $post->post_author,
23 23
                             'include_selected' => true,
24 24
                             'show' => 'user_email',
25 25
                             'orderby' => 'user_email',
26 26
                             'class' => 'gdmbx2-text-large'
27
-                        ) ); ?>
27
+                        )); ?>
28 28
             </div>
29 29
         </div>
30 30
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-email table-layout" style="display:none">
31
-            <div class="gdmbx-th"><label for="wpinv_email"><?php _e( 'Email', 'invoicing' );?> <span class="required">*</span></label>
31
+            <div class="gdmbx-th"><label for="wpinv_email"><?php _e('Email', 'invoicing'); ?> <span class="required">*</span></label>
32 32
             </div>
33 33
             <div class="gdmbx-td">
34 34
                 <input type="hidden" id="wpinv_new_user" name="wpinv_new_user" value="" />
@@ -36,122 +36,122 @@  discard block
 block discarded – undo
36 36
             </div>
37 37
         </div>
38 38
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-btns table-layout">
39
-            <div class="gdmbx-th"><label><?php _e( 'Actions', 'invoicing' );?></label>
39
+            <div class="gdmbx-th"><label><?php _e('Actions', 'invoicing'); ?></label>
40 40
             </div>
41
-            <?php if ( $invoice->has_status( array( 'auto-draft', 'draft', 'wpi-pending', 'wpi-quote-pending' ) ) ) { ?>
41
+            <?php if ($invoice->has_status(array('auto-draft', 'draft', 'wpi-pending', 'wpi-quote-pending'))) { ?>
42 42
                 <div class="gdmbx-td">
43
-                    <a id="wpinv-fill-user-details" class="button button-small button-secondary" title="<?php esc_attr_e( 'Fill User Details', 'invoicing' );?>" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-refresh"></i><?php _e( 'Fill User Details', 'invoicing' );?></a>
44
-                    <a class="wpinv-new-user button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-plus"></i><?php _e( 'Add New User', 'invoicing' );?></a>
45
-                    <a style="display:none" class="wpinv-new-cancel button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-close"></i><?php _e( 'Cancel', 'invoicing' );?> </a>
43
+                    <a id="wpinv-fill-user-details" class="button button-small button-secondary" title="<?php esc_attr_e('Fill User Details', 'invoicing'); ?>" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-refresh"></i><?php _e('Fill User Details', 'invoicing'); ?></a>
44
+                    <a class="wpinv-new-user button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-plus"></i><?php _e('Add New User', 'invoicing'); ?></a>
45
+                    <a style="display:none" class="wpinv-new-cancel button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-close"></i><?php _e('Cancel', 'invoicing'); ?> </a>
46 46
                 </div>
47 47
             <?php } ?>
48 48
         </div>
49 49
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-first-name table-layout">
50
-            <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e( 'First Name', 'invoicing' );?></label></div>
50
+            <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e('First Name', 'invoicing'); ?></label></div>
51 51
             <div class="gdmbx-td">
52
-                <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr( $invoice->first_name );?>" />
52
+                <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr($invoice->first_name); ?>" />
53 53
             </div>
54 54
         </div>
55 55
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-last-name table-layout">
56
-            <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e( 'Last Name', 'invoicing' );?></label></div>
56
+            <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e('Last Name', 'invoicing'); ?></label></div>
57 57
             <div class="gdmbx-td">
58
-                <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr( $invoice->last_name );?>" />
58
+                <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr($invoice->last_name); ?>" />
59 59
             </div>
60 60
         </div>
61 61
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-company table-layout">
62
-            <div class="gdmbx-th"><label for="wpinv_company"><?php _e( 'Company', 'invoicing' );?></label></div>
62
+            <div class="gdmbx-th"><label for="wpinv_company"><?php _e('Company', 'invoicing'); ?></label></div>
63 63
             <div class="gdmbx-td">
64
-                <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr( $invoice->company );?>" />
64
+                <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr($invoice->company); ?>" />
65 65
             </div>
66 66
         </div>
67 67
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-vat-number table-layout">
68
-            <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e( 'Vat Number', 'invoicing' );?></label></div>
68
+            <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e('Vat Number', 'invoicing'); ?></label></div>
69 69
             <div class="gdmbx-td">
70
-                <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr( $invoice->vat_number );?>" />
70
+                <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr($invoice->vat_number); ?>" />
71 71
             </div>
72 72
         </div>
73 73
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-address table-layout">
74
-            <div class="gdmbx-th"><label for="wpinv_address"><?php _e( 'Address', 'invoicing' );?></label></div>
74
+            <div class="gdmbx-th"><label for="wpinv_address"><?php _e('Address', 'invoicing'); ?></label></div>
75 75
             <div class="gdmbx-td">
76
-                <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr( $invoice->address );?>" />
76
+                <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr($invoice->address); ?>" />
77 77
             </div>
78 78
         </div>
79 79
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-city table-layout">
80
-            <div class="gdmbx-th"><label for="wpinv_city"><?php _e( 'City', 'invoicing' );?></label></div>
80
+            <div class="gdmbx-th"><label for="wpinv_city"><?php _e('City', 'invoicing'); ?></label></div>
81 81
             <div class="gdmbx-td">
82
-                <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr( $invoice->city );?>" />
82
+                <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr($invoice->city); ?>" />
83 83
             </div>
84 84
         </div>
85 85
         <div class="gdmbx-row gdmbx-type-select gdmbx-wpinv-country table-layout">
86
-            <div class="gdmbx-th"><label for="wpinv_country"><?php _e( 'Country', 'invoicing' );?> <span class="wpi-loader"><i class="fa fa-refresh fa-spin"></i></span></label></div>
86
+            <div class="gdmbx-th"><label for="wpinv_country"><?php _e('Country', 'invoicing'); ?> <span class="wpi-loader"><i class="fa fa-refresh fa-spin"></i></span></label></div>
87 87
             <div class="gdmbx-td">
88 88
                 <?php
89
-                echo wpinv_html_select( array(
90
-                    'options'          => array_merge( array( '' => __( 'Choose a country', 'invoicing' ) ), wpinv_get_country_list() ),
89
+                echo wpinv_html_select(array(
90
+                    'options'          => array_merge(array('' => __('Choose a country', 'invoicing')), wpinv_get_country_list()),
91 91
                     'name'             => 'wpinv_country',
92 92
                     'id'               => 'wpinv_country',
93 93
                     'selected'         => $invoice->country,
94 94
                     'show_option_all'  => false,
95 95
                     'show_option_none' => false,
96 96
                     'class'            => 'gdmbx2-text-large',
97
-                    'placeholder'      => __( 'Choose a country', 'invoicing' ),
97
+                    'placeholder'      => __('Choose a country', 'invoicing'),
98 98
                     'required'         => false,
99
-                ) );
99
+                ));
100 100
                 ?>
101 101
             </div>
102 102
         </div>
103 103
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-state table-layout">
104
-            <div class="gdmbx-th"><label for="wpinv_state"><?php _e( 'State', 'invoicing' );?></label></div>
104
+            <div class="gdmbx-th"><label for="wpinv_state"><?php _e('State', 'invoicing'); ?></label></div>
105 105
             <div class="gdmbx-td">
106 106
                 <?php
107
-                $states = wpinv_get_country_states( $invoice->country );
108
-                if( !empty( $states ) ) {
109
-                    echo wpinv_html_select( array(
110
-                        'options'          => array_merge( array( '' => __( 'Choose a state', 'invoicing' ) ), $states ),
107
+                $states = wpinv_get_country_states($invoice->country);
108
+                if (!empty($states)) {
109
+                    echo wpinv_html_select(array(
110
+                        'options'          => array_merge(array('' => __('Choose a state', 'invoicing')), $states),
111 111
                         'name'             => 'wpinv_state',
112 112
                         'id'               => 'wpinv_state',
113 113
                         'selected'         => $invoice->state,
114 114
                         'show_option_all'  => false,
115 115
                         'show_option_none' => false,
116 116
                         'class'            => 'gdmbx2-text-large',
117
-                        'placeholder'      => __( 'Choose a state', 'invoicing' ),
117
+                        'placeholder'      => __('Choose a state', 'invoicing'),
118 118
                         'required'         => false,
119
-                    ) );
119
+                    ));
120 120
                 } else {
121
-                    echo wpinv_html_text( array(
121
+                    echo wpinv_html_text(array(
122 122
                         'name'  => 'wpinv_state',
123
-                        'value' => ! empty( $invoice->state ) ? $invoice->state : '',
123
+                        'value' => !empty($invoice->state) ? $invoice->state : '',
124 124
                         'id'    => 'wpinv_state',
125 125
                         'class' => 'gdmbx2-text-large',
126 126
                         'required' => false,
127
-                    ) );
127
+                    ));
128 128
                 }
129 129
                 ?>
130 130
             </div>
131 131
         </div>
132 132
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-zip table-layout">
133
-            <div class="gdmbx-th"><label for="wpinv_zip"><?php _e( 'Zipcode', 'invoicing' );?></label></div>
133
+            <div class="gdmbx-th"><label for="wpinv_zip"><?php _e('Zipcode', 'invoicing'); ?></label></div>
134 134
             <div class="gdmbx-td">
135
-                <input type="text" class="gdmbx2-text-large" name="wpinv_zip" id="wpinv_zip" value="<?php echo esc_attr( $invoice->zip );?>" />
135
+                <input type="text" class="gdmbx2-text-large" name="wpinv_zip" id="wpinv_zip" value="<?php echo esc_attr($invoice->zip); ?>" />
136 136
             </div>
137 137
         </div>
138 138
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-phone table-layout">
139
-            <div class="gdmbx-th"><label for="wpinv_phone"><?php _e( 'Phone', 'invoicing' );?></label></div>
139
+            <div class="gdmbx-th"><label for="wpinv_phone"><?php _e('Phone', 'invoicing'); ?></label></div>
140 140
             <div class="gdmbx-td">
141
-                <input type="text" class="gdmbx2-text-large" name="wpinv_phone" id="wpinv_phone" value="<?php echo esc_attr( $invoice->phone );?>" />
141
+                <input type="text" class="gdmbx2-text-large" name="wpinv_phone" id="wpinv_phone" value="<?php echo esc_attr($invoice->phone); ?>" />
142 142
             </div>
143 143
         </div>
144 144
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-ip table-layout">
145
-            <div class="gdmbx-th"><label for="wpinv_ip"><?php _e( 'IP Address', 'invoicing' );?><?php if ($invoice->ip) { ?>
146
-                &nbsp;&nbsp;<a href="<?php echo admin_url( 'admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $invoice->ip ); ?>" title="<?php esc_attr_e( 'View IP information', 'invoicing' );?>" target="_blank"><i class="fa fa-external-link" aria-hidden="true"></i></a>
145
+            <div class="gdmbx-th"><label for="wpinv_ip"><?php _e('IP Address', 'invoicing'); ?><?php if ($invoice->ip) { ?>
146
+                &nbsp;&nbsp;<a href="<?php echo admin_url('admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $invoice->ip); ?>" title="<?php esc_attr_e('View IP information', 'invoicing'); ?>" target="_blank"><i class="fa fa-external-link" aria-hidden="true"></i></a>
147 147
                 <?php } ?></label></div>
148 148
             <div class="gdmbx-td">
149
-                <input type="text" class="gdmbx2-text-large" value="<?php echo esc_attr( $invoice->ip );?>" readonly />
149
+                <input type="text" class="gdmbx2-text-large" value="<?php echo esc_attr($invoice->ip); ?>" readonly />
150 150
             </div>
151 151
         </div>
152 152
     </div>
153 153
 </div>
154
-<?php wp_nonce_field( 'wpinv_save_invoice', 'wpinv_save_invoice' ) ;?>
154
+<?php wp_nonce_field('wpinv_save_invoice', 'wpinv_save_invoice'); ?>
155 155
 <?php
156 156
     }
157 157
 }
Please login to merge, or discard this patch.