Passed
Push — master ( 9ee829...6e3436 )
by Brian
04:40
created
includes/admin/class-wpinv-users.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // MUST have WordPress.
10
-if ( ! defined( 'WPINC' ) ) {
10
+if (!defined('WPINC')) {
11 11
     exit;
12 12
 }
13 13
 
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
     private static $instance;
16 16
 
17 17
     public static function run() {
18
-        if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WPInv_Admin_Users ) ) {
18
+        if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Admin_Users)) {
19 19
             self::$instance = new WPInv_Admin_Users();
20 20
         }
21 21
 
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
     }
24 24
 
25 25
     public function __construct() {
26
-        add_filter( 'manage_users_columns', array( $this, 'wpinv_add_user_column' ) );
27
-        add_filter( 'manage_users_custom_column', array( $this, 'wpinv_user_column_content' ), 10, 3 );
26
+        add_filter('manage_users_columns', array($this, 'wpinv_add_user_column'));
27
+        add_filter('manage_users_custom_column', array($this, 'wpinv_user_column_content'), 10, 3);
28 28
     }
29 29
 
30 30
     /**
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
      *
35 35
      * @return mixed
36 36
      */
37
-    public function wpinv_add_user_column( $column ) {
38
-        $column['wpinvoicing'] = __( 'Invoicing', 'invoicing' );
37
+    public function wpinv_add_user_column($column) {
38
+        $column['wpinvoicing'] = __('Invoicing', 'invoicing');
39 39
         return $column;
40 40
     }
41 41
 
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
      *
49 49
      * @return string
50 50
      */
51
-    public function wpinv_user_column_content( $val, $column_name, $user_id ) {
52
-        switch ( $column_name ) {
51
+    public function wpinv_user_column_content($val, $column_name, $user_id) {
52
+        switch ($column_name) {
53 53
             case 'wpinvoicing':
54
-                return $this->get_user_invoices( $user_id );
54
+                return $this->get_user_invoices($user_id);
55 55
                 break;
56 56
             default:
57 57
         }
@@ -65,30 +65,30 @@  discard block
 block discarded – undo
65 65
      *
66 66
      * @return string
67 67
      */
68
-    public function get_user_invoices( $user_id ) {
68
+    public function get_user_invoices($user_id) {
69 69
         $output = '';
70 70
         $wp_query_args = array(
71 71
             'post_type'      => 'wpi_invoice',
72
-            'post_status'    => array( 'wpi-pending', 'publish', 'wpi-processing', 'wpi-onhold', 'wpi-refunded', 'wpi-cancelled', 'wpi-failed', 'wpi-renewal' ),
72
+            'post_status'    => array('wpi-pending', 'publish', 'wpi-processing', 'wpi-onhold', 'wpi-refunded', 'wpi-cancelled', 'wpi-failed', 'wpi-renewal'),
73 73
             'posts_per_page' => -1,
74 74
             'fields'         => 'ids',
75 75
             'author'         => $user_id,
76 76
         );
77 77
 
78
-        $wp_query_args = apply_filters( 'wpinv_get_user_invoices_args', $wp_query_args, $user_id );
78
+        $wp_query_args = apply_filters('wpinv_get_user_invoices_args', $wp_query_args, $user_id);
79 79
 
80
-        $invoices = new WP_Query( $wp_query_args );
81
-        $count = absint( $invoices->found_posts );
80
+        $invoices = new WP_Query($wp_query_args);
81
+        $count = absint($invoices->found_posts);
82 82
 
83
-        if ( empty( $count ) ) {
84
-            $output .= __( 'No Invoice(s)', 'invoicing' );
83
+        if (empty($count)) {
84
+            $output .= __('No Invoice(s)', 'invoicing');
85 85
         } else {
86
-            $link_url = admin_url( 'edit.php?post_type=wpi_invoice&author=' . absint( $user_id ) );
87
-            $link_text = sprintf( __( 'Invoices ( %d )', 'invoicing' ), $count );
86
+            $link_url = admin_url('edit.php?post_type=wpi_invoice&author=' . absint($user_id));
87
+            $link_text = sprintf(__('Invoices ( %d )', 'invoicing'), $count);
88 88
             $output .= "<a href='$link_url' >$link_text</a>";
89 89
         }
90 90
 
91
-        return apply_filters( 'wpinv_user_invoice_content', $output, $user_id );
91
+        return apply_filters('wpinv_user_invoice_content', $output, $user_id);
92 92
     }
93 93
 
94 94
 }
Please login to merge, or discard this patch.
includes/admin/class-getpaid-post-types-admin.php 2 patches
Indentation   +757 added lines, -757 removed lines patch added patch discarded remove patch
@@ -13,719 +13,719 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Post_Types_Admin {
14 14
 
15 15
     /**
16
-	 * Hook in methods.
17
-	 */
18
-	public static function init() {
19
-
20
-		// Init metaboxes.
21
-		GetPaid_Metaboxes::init();
22
-
23
-		// Filter the post updated messages.
24
-		add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
25
-
26
-		// Filter post actions.
27
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
29
-
30
-		// Invoice table columns.
31
-		add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
-		add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
-		add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
-		add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
35
-
36
-		// Items table columns.
37
-		add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
-		add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
-		add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
-		add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
-		add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
-		add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
43
-
44
-		// Payment forms columns.
45
-		add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
-		add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
48
-
49
-		// Discount table columns.
50
-		add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
-		add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
52
-
53
-		// Deleting posts.
54
-		add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
56
-
57
-		add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
58
-	}
59
-
60
-	/**
61
-	 * Post updated messages.
62
-	 */
63
-	public static function post_updated_messages( $messages ) {
64
-		global $post;
65
-
66
-		$messages['wpi_discount'] = array(
67
-			0  => '',
68
-			1  => __( 'Discount updated.', 'invoicing' ),
69
-			2  => __( 'Custom field updated.', 'invoicing' ),
70
-			3  => __( 'Custom field deleted.', 'invoicing' ),
71
-			4  => __( 'Discount updated.', 'invoicing' ),
72
-			5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
-			6  => __( 'Discount updated.', 'invoicing' ),
74
-			7  => __( 'Discount saved.', 'invoicing' ),
75
-			8  => __( 'Discount submitted.', 'invoicing' ),
76
-			9  => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
-			10 => __( 'Discount draft updated.', 'invoicing' ),
78
-		);
79
-
80
-		$messages['wpi_payment_form'] = array(
81
-			0  => '',
82
-			1  => __( 'Payment Form updated.', 'invoicing' ),
83
-			2  => __( 'Custom field updated.', 'invoicing' ),
84
-			3  => __( 'Custom field deleted.', 'invoicing' ),
85
-			4  => __( 'Payment Form updated.', 'invoicing' ),
86
-			5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
-			6  => __( 'Payment Form updated.', 'invoicing' ),
88
-			7  => __( 'Payment Form saved.', 'invoicing' ),
89
-			8  => __( 'Payment Form submitted.', 'invoicing' ),
90
-			9  => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
-			10 => __( 'Payment Form draft updated.', 'invoicing' ),
92
-		);
93
-
94
-		return $messages;
95
-
96
-	}
97
-
98
-	/**
99
-	 * Post row actions.
100
-	 */
101
-	public static function post_row_actions( $actions, $post ) {
102
-
103
-		$post = get_post( $post );
104
-
105
-		// We do not want to edit the default payment form.
106
-		if ( 'wpi_payment_form' == $post->post_type ) {
107
-
108
-			if ( $post->ID == wpinv_get_default_payment_form() ) {
109
-				unset( $actions['trash'] );
110
-				unset( $actions['inline hide-if-no-js'] );
111
-			}
112
-
113
-			$actions['duplicate'] = sprintf(
114
-				'<a href="%1$s">%2$s</a>',
115
-				esc_url(
116
-					wp_nonce_url(
117
-						add_query_arg(
118
-							array(
119
-								'getpaid-admin-action' => 'duplicate_form',
120
-								'form_id'              => $post->ID,
121
-							)
122
-						),
123
-						'getpaid-nonce',
124
-						'getpaid-nonce'
125
-					)
126
-				),
127
-				esc_html( __( 'Duplicate', 'invoicing' ) )
128
-			);
129
-
130
-		}
131
-
132
-		// Link to item payment form.
133
-		if ( 'wpi_item' == $post->post_type ) {
134
-
135
-			if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) {
136
-
137
-				$actions['buy'] = sprintf(
138
-					'<a href="%1$s">%2$s</a>',
139
-					esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
140
-					esc_html( __( 'Buy', 'invoicing' ) )
141
-				);
142
-
143
-			}
16
+     * Hook in methods.
17
+     */
18
+    public static function init() {
19
+
20
+        // Init metaboxes.
21
+        GetPaid_Metaboxes::init();
22
+
23
+        // Filter the post updated messages.
24
+        add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
25
+
26
+        // Filter post actions.
27
+        add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
+        add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
29
+
30
+        // Invoice table columns.
31
+        add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
+        add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
+        add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
+        add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
35
+
36
+        // Items table columns.
37
+        add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
+        add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
+        add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
+        add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
+        add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
+        add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
43
+
44
+        // Payment forms columns.
45
+        add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
+        add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
+        add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
48
+
49
+        // Discount table columns.
50
+        add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
+        add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
52
+
53
+        // Deleting posts.
54
+        add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
+        add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
56
+
57
+        add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
58
+    }
59
+
60
+    /**
61
+     * Post updated messages.
62
+     */
63
+    public static function post_updated_messages( $messages ) {
64
+        global $post;
65
+
66
+        $messages['wpi_discount'] = array(
67
+            0  => '',
68
+            1  => __( 'Discount updated.', 'invoicing' ),
69
+            2  => __( 'Custom field updated.', 'invoicing' ),
70
+            3  => __( 'Custom field deleted.', 'invoicing' ),
71
+            4  => __( 'Discount updated.', 'invoicing' ),
72
+            5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
+            6  => __( 'Discount updated.', 'invoicing' ),
74
+            7  => __( 'Discount saved.', 'invoicing' ),
75
+            8  => __( 'Discount submitted.', 'invoicing' ),
76
+            9  => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
+            10 => __( 'Discount draft updated.', 'invoicing' ),
78
+        );
79
+
80
+        $messages['wpi_payment_form'] = array(
81
+            0  => '',
82
+            1  => __( 'Payment Form updated.', 'invoicing' ),
83
+            2  => __( 'Custom field updated.', 'invoicing' ),
84
+            3  => __( 'Custom field deleted.', 'invoicing' ),
85
+            4  => __( 'Payment Form updated.', 'invoicing' ),
86
+            5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
+            6  => __( 'Payment Form updated.', 'invoicing' ),
88
+            7  => __( 'Payment Form saved.', 'invoicing' ),
89
+            8  => __( 'Payment Form submitted.', 'invoicing' ),
90
+            9  => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
+            10 => __( 'Payment Form draft updated.', 'invoicing' ),
92
+        );
93
+
94
+        return $messages;
95
+
96
+    }
97
+
98
+    /**
99
+     * Post row actions.
100
+     */
101
+    public static function post_row_actions( $actions, $post ) {
102
+
103
+        $post = get_post( $post );
104
+
105
+        // We do not want to edit the default payment form.
106
+        if ( 'wpi_payment_form' == $post->post_type ) {
107
+
108
+            if ( $post->ID == wpinv_get_default_payment_form() ) {
109
+                unset( $actions['trash'] );
110
+                unset( $actions['inline hide-if-no-js'] );
111
+            }
112
+
113
+            $actions['duplicate'] = sprintf(
114
+                '<a href="%1$s">%2$s</a>',
115
+                esc_url(
116
+                    wp_nonce_url(
117
+                        add_query_arg(
118
+                            array(
119
+                                'getpaid-admin-action' => 'duplicate_form',
120
+                                'form_id'              => $post->ID,
121
+                            )
122
+                        ),
123
+                        'getpaid-nonce',
124
+                        'getpaid-nonce'
125
+                    )
126
+                ),
127
+                esc_html( __( 'Duplicate', 'invoicing' ) )
128
+            );
129
+
130
+        }
131
+
132
+        // Link to item payment form.
133
+        if ( 'wpi_item' == $post->post_type ) {
134
+
135
+            if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) {
136
+
137
+                $actions['buy'] = sprintf(
138
+                    '<a href="%1$s">%2$s</a>',
139
+                    esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
140
+                    esc_html( __( 'Buy', 'invoicing' ) )
141
+                );
142
+
143
+            }
144 144
 }
145 145
 
146
-		return $actions;
147
-	}
146
+        return $actions;
147
+    }
148 148
 
149
-	/**
149
+    /**
150 150
      * Remove bulk edit option from admin side quote listing
151 151
      *
152 152
      * @since    1.0.0
153 153
      * @param array $actions post actions
154
-	 * @param WP_Post $post
154
+     * @param WP_Post $post
155 155
      * @return array $actions actions without edit option
156 156
      */
157 157
     public static function filter_invoice_row_actions( $actions, $post ) {
158 158
 
159 159
         if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
160 160
 
161
-			$actions = array();
162
-			$invoice = new WPInv_Invoice( $post );
163
-
164
-			$actions['edit'] = sprintf(
165
-				'<a href="%1$s">%2$s</a>',
166
-				esc_url( get_edit_post_link( $invoice->get_id() ) ),
167
-				esc_html( __( 'Edit', 'invoicing' ) )
168
-			);
169
-
170
-			if ( ! $invoice->is_draft() ) {
171
-
172
-				$actions['view'] = sprintf(
173
-					'<a href="%1$s">%2$s</a>',
174
-					esc_url( $invoice->get_view_url() ),
175
-					sprintf(
176
-						esc_html( __( 'View %s', 'invoicing' ) ),
177
-						getpaid_get_post_type_label( $invoice->get_post_type(), false )
178
-					)
179
-				);
180
-
181
-				$actions['send'] = sprintf(
182
-					'<a href="%1$s">%2$s</a>',
183
-					esc_url(
184
-						wp_nonce_url(
185
-							add_query_arg(
186
-								array(
187
-									'getpaid-admin-action' => 'send_invoice',
188
-									'invoice_id'           => $invoice->get_id(),
189
-								)
190
-							),
191
-							'getpaid-nonce',
192
-							'getpaid-nonce'
193
-						)
194
-					),
195
-					esc_html( __( 'Send to Customer', 'invoicing' ) )
196
-				);
197
-
198
-			}
199
-
200
-			$actions['duplicate'] = sprintf(
201
-				'<a href="%1$s">%2$s</a>',
202
-				esc_url(
203
-					wp_nonce_url(
204
-						add_query_arg(
205
-							array(
206
-								'getpaid-admin-action' => 'duplicate_invoice',
207
-								'invoice_id'           => $post->ID,
208
-							)
209
-						),
210
-						'getpaid-nonce',
211
-						'getpaid-nonce'
212
-					)
213
-				),
214
-				esc_html( __( 'Duplicate', 'invoicing' ) )
215
-			);
161
+            $actions = array();
162
+            $invoice = new WPInv_Invoice( $post );
163
+
164
+            $actions['edit'] = sprintf(
165
+                '<a href="%1$s">%2$s</a>',
166
+                esc_url( get_edit_post_link( $invoice->get_id() ) ),
167
+                esc_html( __( 'Edit', 'invoicing' ) )
168
+            );
169
+
170
+            if ( ! $invoice->is_draft() ) {
171
+
172
+                $actions['view'] = sprintf(
173
+                    '<a href="%1$s">%2$s</a>',
174
+                    esc_url( $invoice->get_view_url() ),
175
+                    sprintf(
176
+                        esc_html( __( 'View %s', 'invoicing' ) ),
177
+                        getpaid_get_post_type_label( $invoice->get_post_type(), false )
178
+                    )
179
+                );
180
+
181
+                $actions['send'] = sprintf(
182
+                    '<a href="%1$s">%2$s</a>',
183
+                    esc_url(
184
+                        wp_nonce_url(
185
+                            add_query_arg(
186
+                                array(
187
+                                    'getpaid-admin-action' => 'send_invoice',
188
+                                    'invoice_id'           => $invoice->get_id(),
189
+                                )
190
+                            ),
191
+                            'getpaid-nonce',
192
+                            'getpaid-nonce'
193
+                        )
194
+                    ),
195
+                    esc_html( __( 'Send to Customer', 'invoicing' ) )
196
+                );
197
+
198
+            }
199
+
200
+            $actions['duplicate'] = sprintf(
201
+                '<a href="%1$s">%2$s</a>',
202
+                esc_url(
203
+                    wp_nonce_url(
204
+                        add_query_arg(
205
+                            array(
206
+                                'getpaid-admin-action' => 'duplicate_invoice',
207
+                                'invoice_id'           => $post->ID,
208
+                            )
209
+                        ),
210
+                        'getpaid-nonce',
211
+                        'getpaid-nonce'
212
+                    )
213
+                ),
214
+                esc_html( __( 'Duplicate', 'invoicing' ) )
215
+            );
216 216
 
217 217
         }
218 218
 
219 219
         return $actions;
220
-	}
221
-
222
-	/**
223
-	 * Returns an array of invoice table columns.
224
-	 */
225
-	public static function invoice_columns( $columns ) {
226
-
227
-		$columns = array(
228
-			'cb'           => $columns['cb'],
229
-			'number'       => __( 'Invoice', 'invoicing' ),
230
-			'customer'     => __( 'Customer', 'invoicing' ),
231
-			'invoice_date' => __( 'Created', 'invoicing' ),
232
-			'payment_date' => __( 'Completed', 'invoicing' ),
233
-			'amount'       => __( 'Amount', 'invoicing' ),
234
-			'recurring'    => __( 'Recurring', 'invoicing' ),
235
-			'status'       => __( 'Status', 'invoicing' ),
236
-		);
237
-
238
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
239
-	}
240
-
241
-	/**
242
-	 * Displays invoice table columns.
243
-	 */
244
-	public static function display_invoice_columns( $column_name, $post_id ) {
245
-
246
-		$invoice = new WPInv_Invoice( $post_id );
247
-
248
-		switch ( $column_name ) {
249
-
250
-			case 'invoice_date':
251
-				$date_time = esc_attr( $invoice->get_created_date() );
252
-				$date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
253
-				echo wp_kses_post( "<span title='$date_time'>$date</span>" );
254
-				break;
255
-
256
-			case 'payment_date':
257
-				if ( $invoice->is_paid() ) {
258
-					$date_time = esc_attr( $invoice->get_completed_date() );
259
-					$date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
260
-					echo wp_kses_post( "<span title='$date_time'>$date</span>" );
261
-				} else {
262
-					echo '&mdash;';
263
-				}
264
-
265
-				break;
266
-
267
-			case 'amount':
268
-				$amount = $invoice->get_total();
269
-				$formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) );
270
-
271
-				if ( $invoice->is_refunded() ) {
272
-					$refunded_amount = wpinv_price( 0, $invoice->get_currency() );
273
-					echo wp_kses_post( "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>" );
274
-				} else {
275
-
276
-					$discount = $invoice->get_total_discount();
277
-
278
-					if ( ! empty( $discount ) ) {
279
-						$new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
280
-						echo wp_kses_post( "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>" );
281
-					} else {
282
-						echo wp_kses_post( $formated_amount );
283
-					}
220
+    }
221
+
222
+    /**
223
+     * Returns an array of invoice table columns.
224
+     */
225
+    public static function invoice_columns( $columns ) {
226
+
227
+        $columns = array(
228
+            'cb'           => $columns['cb'],
229
+            'number'       => __( 'Invoice', 'invoicing' ),
230
+            'customer'     => __( 'Customer', 'invoicing' ),
231
+            'invoice_date' => __( 'Created', 'invoicing' ),
232
+            'payment_date' => __( 'Completed', 'invoicing' ),
233
+            'amount'       => __( 'Amount', 'invoicing' ),
234
+            'recurring'    => __( 'Recurring', 'invoicing' ),
235
+            'status'       => __( 'Status', 'invoicing' ),
236
+        );
237
+
238
+        return apply_filters( 'wpi_invoice_table_columns', $columns );
239
+    }
240
+
241
+    /**
242
+     * Displays invoice table columns.
243
+     */
244
+    public static function display_invoice_columns( $column_name, $post_id ) {
245
+
246
+        $invoice = new WPInv_Invoice( $post_id );
247
+
248
+        switch ( $column_name ) {
249
+
250
+            case 'invoice_date':
251
+                $date_time = esc_attr( $invoice->get_created_date() );
252
+                $date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
253
+                echo wp_kses_post( "<span title='$date_time'>$date</span>" );
254
+                break;
255
+
256
+            case 'payment_date':
257
+                if ( $invoice->is_paid() ) {
258
+                    $date_time = esc_attr( $invoice->get_completed_date() );
259
+                    $date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
260
+                    echo wp_kses_post( "<span title='$date_time'>$date</span>" );
261
+                } else {
262
+                    echo '&mdash;';
263
+                }
264
+
265
+                break;
266
+
267
+            case 'amount':
268
+                $amount = $invoice->get_total();
269
+                $formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) );
270
+
271
+                if ( $invoice->is_refunded() ) {
272
+                    $refunded_amount = wpinv_price( 0, $invoice->get_currency() );
273
+                    echo wp_kses_post( "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>" );
274
+                } else {
275
+
276
+                    $discount = $invoice->get_total_discount();
277
+
278
+                    if ( ! empty( $discount ) ) {
279
+                        $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
280
+                        echo wp_kses_post( "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>" );
281
+                    } else {
282
+                        echo wp_kses_post( $formated_amount );
283
+                    }
284 284
 }
285 285
 
286
-				break;
287
-
288
-			case 'status':
289
-				$status       = esc_html( $invoice->get_status() );
290
-				$status_label = esc_html( $invoice->get_status_nicename() );
291
-
292
-				// If it is paid, show the gateway title.
293
-				if ( $invoice->is_paid() ) {
294
-					$gateway = esc_html( $invoice->get_gateway_title() );
295
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) );
296
-
297
-					echo wp_kses_post( "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>" );
298
-				} else {
299
-					echo wp_kses_post( "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>" );
300
-				}
301
-
302
-				// If it is not paid, display the overdue and view status.
303
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
304
-
305
-					// Invoice view status.
306
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
307
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>';
308
-					} else {
309
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>';
310
-					}
311
-
312
-					// Display the overview status.
313
-					if ( wpinv_get_option( 'overdue_active' ) ) {
314
-						$due_date = $invoice->get_due_date();
315
-						$fomatted = getpaid_format_date( $due_date );
316
-
317
-						if ( ! empty( $fomatted ) ) {
318
-							$date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
319
-							echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" );
320
-						}
321
-					}
286
+                break;
287
+
288
+            case 'status':
289
+                $status       = esc_html( $invoice->get_status() );
290
+                $status_label = esc_html( $invoice->get_status_nicename() );
291
+
292
+                // If it is paid, show the gateway title.
293
+                if ( $invoice->is_paid() ) {
294
+                    $gateway = esc_html( $invoice->get_gateway_title() );
295
+                    $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) );
296
+
297
+                    echo wp_kses_post( "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>" );
298
+                } else {
299
+                    echo wp_kses_post( "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>" );
300
+                }
301
+
302
+                // If it is not paid, display the overdue and view status.
303
+                if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
304
+
305
+                    // Invoice view status.
306
+                    if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
307
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>';
308
+                    } else {
309
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>';
310
+                    }
311
+
312
+                    // Display the overview status.
313
+                    if ( wpinv_get_option( 'overdue_active' ) ) {
314
+                        $due_date = $invoice->get_due_date();
315
+                        $fomatted = getpaid_format_date( $due_date );
316
+
317
+                        if ( ! empty( $fomatted ) ) {
318
+                            $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
319
+                            echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" );
320
+                        }
321
+                    }
322 322
 }
323 323
 
324
-				break;
324
+                break;
325 325
 
326
-			case 'recurring':
327
-				if ( $invoice->is_recurring() ) {
328
-					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
329
-				} else {
330
-					echo '<i class="fa fa-times" style="color:#616161;"></i>';
331
-				}
332
-				break;
326
+            case 'recurring':
327
+                if ( $invoice->is_recurring() ) {
328
+                    echo '<i class="fa fa-check" style="color:#43850a;"></i>';
329
+                } else {
330
+                    echo '<i class="fa fa-times" style="color:#616161;"></i>';
331
+                }
332
+                break;
333 333
 
334
-			case 'number':
335
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
336
-				$invoice_number  = esc_html( $invoice->get_number() );
337
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
334
+            case 'number':
335
+                $edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
336
+                $invoice_number  = esc_html( $invoice->get_number() );
337
+                $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
338 338
 
339
-				echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" );
339
+                echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" );
340 340
 
341
-				break;
341
+                break;
342 342
 
343
-			case 'customer':
344
-				$customer_name = $invoice->get_user_full_name();
343
+            case 'customer':
344
+                $customer_name = $invoice->get_user_full_name();
345 345
 
346
-				if ( empty( $customer_name ) ) {
347
-					$customer_name = $invoice->get_email();
348
-				}
346
+                if ( empty( $customer_name ) ) {
347
+                    $customer_name = $invoice->get_email();
348
+                }
349 349
 
350
-				if ( ! empty( $customer_name ) ) {
351
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
352
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
353
-					echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" );
354
-				} else {
355
-					echo '<div>&mdash;</div>';
356
-				}
350
+                if ( ! empty( $customer_name ) ) {
351
+                    $customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
352
+                    $view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
353
+                    echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" );
354
+                } else {
355
+                    echo '<div>&mdash;</div>';
356
+                }
357 357
 
358
-				break;
359
-
360
-		}
361
-
362
-	}
363
-
364
-	/**
365
-	 * Displays invoice bulk actions.
366
-	 */
367
-	public static function invoice_bulk_actions( $actions ) {
368
-		$actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
369
-		return $actions;
370
-	}
371
-
372
-	/**
373
-	 * Processes invoice bulk actions.
374
-	 */
375
-	public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
376
-
377
-		if ( $action == 'resend-invoice' ) {
378
-			foreach ( $post_ids as $post_id ) {
379
-				getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
380
-			}
381
-		}
382
-
383
-		return $redirect_url;
384
-
385
-	}
386
-
387
-	/**
388
-	 * Returns an array of payment forms table columns.
389
-	 */
390
-	public static function payment_form_columns( $columns ) {
391
-
392
-		$columns = array(
393
-			'cb'        => $columns['cb'],
394
-			'title'     => __( 'Name', 'invoicing' ),
395
-			'shortcode' => __( 'Shortcode', 'invoicing' ),
396
-			'earnings'  => __( 'Revenue', 'invoicing' ),
397
-			'refunds'   => __( 'Refunded', 'invoicing' ),
398
-			'items'     => __( 'Items', 'invoicing' ),
399
-			'date'      => __( 'Date', 'invoicing' ),
400
-		);
401
-
402
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
403
-
404
-	}
405
-
406
-	/**
407
-	 * Displays payment form table columns.
408
-	 */
409
-	public static function display_payment_form_columns( $column_name, $post_id ) {
410
-
411
-		// Retrieve the payment form.
412
-		$form = new GetPaid_Payment_Form( $post_id );
413
-
414
-		switch ( $column_name ) {
415
-
416
-			case 'earnings':
417
-				echo wp_kses_post( wpinv_price( $form->get_earned() ) );
418
-				break;
419
-
420
-			case 'refunds':
421
-				echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
422
-				break;
423
-
424
-			case 'refunds':
425
-				echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
426
-				break;
427
-
428
-			case 'shortcode':
429
-				if ( $form->is_default() ) {
430
-					echo '&mdash;';
431
-				} else {
432
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
433
-				}
434
-
435
-				break;
358
+                break;
436 359
 
437
-			case 'items':
438
-				$items = $form->get_items();
439
-
440
-				if ( $form->is_default() || empty( $items ) ) {
441
-					echo '&mdash;';
442
-					return;
443
-				}
444
-
445
-				$_items = array();
446
-
447
-				foreach ( $items as $item ) {
448
-					$url = $item->get_edit_url();
449
-
450
-					if ( empty( $url ) ) {
451
-						$_items[] = esc_html( $item->get_name() );
452
-					} else {
453
-						$_items[] = sprintf(
454
-							'<a href="%s">%s</a>',
455
-							esc_url( $url ),
456
-							esc_html( $item->get_name() )
457
-						);
458
-					}
360
+        }
361
+
362
+    }
363
+
364
+    /**
365
+     * Displays invoice bulk actions.
366
+     */
367
+    public static function invoice_bulk_actions( $actions ) {
368
+        $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
369
+        return $actions;
370
+    }
371
+
372
+    /**
373
+     * Processes invoice bulk actions.
374
+     */
375
+    public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
376
+
377
+        if ( $action == 'resend-invoice' ) {
378
+            foreach ( $post_ids as $post_id ) {
379
+                getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
380
+            }
381
+        }
382
+
383
+        return $redirect_url;
384
+
385
+    }
386
+
387
+    /**
388
+     * Returns an array of payment forms table columns.
389
+     */
390
+    public static function payment_form_columns( $columns ) {
391
+
392
+        $columns = array(
393
+            'cb'        => $columns['cb'],
394
+            'title'     => __( 'Name', 'invoicing' ),
395
+            'shortcode' => __( 'Shortcode', 'invoicing' ),
396
+            'earnings'  => __( 'Revenue', 'invoicing' ),
397
+            'refunds'   => __( 'Refunded', 'invoicing' ),
398
+            'items'     => __( 'Items', 'invoicing' ),
399
+            'date'      => __( 'Date', 'invoicing' ),
400
+        );
401
+
402
+        return apply_filters( 'wpi_payment_form_table_columns', $columns );
403
+
404
+    }
405
+
406
+    /**
407
+     * Displays payment form table columns.
408
+     */
409
+    public static function display_payment_form_columns( $column_name, $post_id ) {
410
+
411
+        // Retrieve the payment form.
412
+        $form = new GetPaid_Payment_Form( $post_id );
413
+
414
+        switch ( $column_name ) {
415
+
416
+            case 'earnings':
417
+                echo wp_kses_post( wpinv_price( $form->get_earned() ) );
418
+                break;
419
+
420
+            case 'refunds':
421
+                echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
422
+                break;
423
+
424
+            case 'refunds':
425
+                echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
426
+                break;
427
+
428
+            case 'shortcode':
429
+                if ( $form->is_default() ) {
430
+                    echo '&mdash;';
431
+                } else {
432
+                    echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
433
+                }
434
+
435
+                break;
436
+
437
+            case 'items':
438
+                $items = $form->get_items();
439
+
440
+                if ( $form->is_default() || empty( $items ) ) {
441
+                    echo '&mdash;';
442
+                    return;
443
+                }
444
+
445
+                $_items = array();
446
+
447
+                foreach ( $items as $item ) {
448
+                    $url = $item->get_edit_url();
449
+
450
+                    if ( empty( $url ) ) {
451
+                        $_items[] = esc_html( $item->get_name() );
452
+                    } else {
453
+                        $_items[] = sprintf(
454
+                            '<a href="%s">%s</a>',
455
+                            esc_url( $url ),
456
+                            esc_html( $item->get_name() )
457
+                        );
458
+                    }
459 459
 }
460 460
 
461
-				echo wp_kses_post( implode( '<br>', $_items ) );
461
+                echo wp_kses_post( implode( '<br>', $_items ) );
462 462
 
463
-				break;
463
+                break;
464 464
 
465
-		}
465
+        }
466 466
 
467
-	}
467
+    }
468 468
 
469
-	/**
470
-	 * Filters post states.
471
-	 */
472
-	public static function filter_payment_form_state( $post_states, $post ) {
469
+    /**
470
+     * Filters post states.
471
+     */
472
+    public static function filter_payment_form_state( $post_states, $post ) {
473 473
 
474
-		if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
475
-			$post_states['default_form'] = __( 'Default Payment Form', 'invoicing' );
476
-		}
474
+        if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
475
+            $post_states['default_form'] = __( 'Default Payment Form', 'invoicing' );
476
+        }
477 477
 
478
-		return $post_states;
478
+        return $post_states;
479 479
 
480
-	}
480
+    }
481 481
 
482
-	/**
483
-	 * Returns an array of coupon table columns.
484
-	 */
485
-	public static function discount_columns( $columns ) {
482
+    /**
483
+     * Returns an array of coupon table columns.
484
+     */
485
+    public static function discount_columns( $columns ) {
486
+
487
+        $columns = array(
488
+            'cb'          => $columns['cb'],
489
+            'title'       => __( 'Name', 'invoicing' ),
490
+            'code'        => __( 'Code', 'invoicing' ),
491
+            'amount'      => __( 'Amount', 'invoicing' ),
492
+            'usage'       => __( 'Usage / Limit', 'invoicing' ),
493
+            'start_date'  => __( 'Start Date', 'invoicing' ),
494
+            'expiry_date' => __( 'Expiry Date', 'invoicing' ),
495
+        );
496
+
497
+        return apply_filters( 'wpi_discount_table_columns', $columns );
498
+    }
486 499
 
487
-		$columns = array(
488
-			'cb'          => $columns['cb'],
489
-			'title'       => __( 'Name', 'invoicing' ),
490
-			'code'        => __( 'Code', 'invoicing' ),
491
-			'amount'      => __( 'Amount', 'invoicing' ),
492
-			'usage'       => __( 'Usage / Limit', 'invoicing' ),
493
-			'start_date'  => __( 'Start Date', 'invoicing' ),
494
-			'expiry_date' => __( 'Expiry Date', 'invoicing' ),
495
-		);
500
+    /**
501
+     * Filters post states.
502
+     */
503
+    public static function filter_discount_state( $post_states, $post ) {
496 504
 
497
-		return apply_filters( 'wpi_discount_table_columns', $columns );
498
-	}
505
+        if ( 'wpi_discount' == $post->post_type ) {
499 506
 
500
-	/**
501
-	 * Filters post states.
502
-	 */
503
-	public static function filter_discount_state( $post_states, $post ) {
507
+            $discount = new WPInv_Discount( $post );
504 508
 
505
-		if ( 'wpi_discount' == $post->post_type ) {
509
+            $status = $discount->is_expired() ? 'expired' : $discount->get_status();
506 510
 
507
-			$discount = new WPInv_Discount( $post );
511
+            if ( $status != 'publish' ) {
512
+                return array(
513
+                    'discount_status' => wpinv_discount_status( $status ),
514
+                );
515
+            }
508 516
 
509
-			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
517
+            return array();
510 518
 
511
-			if ( $status != 'publish' ) {
512
-				return array(
513
-					'discount_status' => wpinv_discount_status( $status ),
514
-				);
515
-			}
519
+        }
516 520
 
517
-			return array();
521
+        return $post_states;
518 522
 
519
-		}
523
+    }
520 524
 
521
-		return $post_states;
525
+    /**
526
+     * Returns an array of items table columns.
527
+     */
528
+    public static function item_columns( $columns ) {
529
+
530
+        $columns = array(
531
+            'cb'        => $columns['cb'],
532
+            'title'     => __( 'Name', 'invoicing' ),
533
+            'price'     => __( 'Price', 'invoicing' ),
534
+            'vat_rule'  => __( 'VAT rule', 'invoicing' ),
535
+            'vat_class' => __( 'VAT class', 'invoicing' ),
536
+            'type'      => __( 'Type', 'invoicing' ),
537
+            'shortcode' => __( 'Shortcode', 'invoicing' ),
538
+        );
539
+
540
+        if ( ! wpinv_use_taxes() ) {
541
+            unset( $columns['vat_rule'] );
542
+            unset( $columns['vat_class'] );
543
+        }
544
+
545
+        return apply_filters( 'wpi_item_table_columns', $columns );
546
+    }
547
+
548
+    /**
549
+     * Returns an array of sortable items table columns.
550
+     */
551
+    public static function sortable_item_columns( $columns ) {
552
+
553
+        return array_merge(
554
+            $columns,
555
+            array(
556
+                'price'     => 'price',
557
+                'vat_rule'  => 'vat_rule',
558
+                'vat_class' => 'vat_class',
559
+                'type'      => 'type',
560
+            )
561
+        );
562
+
563
+    }
564
+
565
+    /**
566
+     * Displays items table columns.
567
+     */
568
+    public static function display_item_columns( $column_name, $post_id ) {
569
+
570
+        $item = new WPInv_Item( $post_id );
571
+
572
+        switch ( $column_name ) {
573
+
574
+            case 'price':
575
+                if ( ! $item->is_recurring() ) {
576
+                    echo wp_kses_post( $item->get_the_price() );
577
+                    break;
578
+                }
579
+
580
+                $price = wp_sprintf(
581
+                    __( '%1$s / %2$s', 'invoicing' ),
582
+                    $item->get_the_price(),
583
+                    getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
584
+                );
585
+
586
+                if ( $item->get_the_price() == $item->get_the_initial_price() ) {
587
+                    echo wp_kses_post( $price );
588
+                    break;
589
+                }
590
+
591
+                echo wp_kses_post( $item->get_the_initial_price() );
592
+
593
+                echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>';
594
+                break;
595
+
596
+            case 'vat_rule':
597
+                echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) );
598
+                break;
599
+
600
+            case 'vat_class':
601
+                echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) );
602
+                break;
603
+
604
+            case 'shortcode':
605
+                if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
606
+                    echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
607
+                } else {
608
+                    echo '&mdash;';
609
+                }
610
+
611
+                break;
612
+
613
+            case 'type':
614
+                echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' );
615
+                break;
616
+
617
+        }
618
+
619
+    }
620
+
621
+    /**
622
+     * Lets users filter items using taxes.
623
+     */
624
+    public static function add_item_filters( $post_type ) {
625
+
626
+        // Abort if we're not dealing with items.
627
+        if ( $post_type != 'wpi_item' ) {
628
+            return;
629
+        }
630
+
631
+        // Filter by vat rules.
632
+        if ( wpinv_use_taxes() ) {
633
+
634
+            // Sanitize selected vat rule.
635
+            $vat_rule   = '';
636
+            $vat_rules  = getpaid_get_tax_rules();
637
+            if ( isset( $_GET['vat_rule'] ) ) {
638
+                $vat_rule   = sanitize_text_field( $_GET['vat_rule'] );
639
+            }
640
+
641
+            // Filter by VAT rule.
642
+            wpinv_html_select(
643
+                array(
644
+                    'options'          => array_merge(
645
+                        array(
646
+                            '' => __( 'All VAT rules', 'invoicing' ),
647
+                        ),
648
+                        $vat_rules
649
+                    ),
650
+                    'name'             => 'vat_rule',
651
+                    'id'               => 'vat_rule',
652
+                    'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
653
+                    'show_option_all'  => false,
654
+                    'show_option_none' => false,
655
+                )
656
+            );
657
+
658
+            // Filter by VAT class.
659
+
660
+            // Sanitize selected vat rule.
661
+            $vat_class   = '';
662
+            $vat_classes = getpaid_get_tax_classes();
663
+            if ( isset( $_GET['vat_class'] ) ) {
664
+                $vat_class   = sanitize_text_field( $_GET['vat_class'] );
665
+            }
666
+
667
+            wpinv_html_select(
668
+                array(
669
+                    'options'          => array_merge(
670
+                        array(
671
+                            '' => __( 'All VAT classes', 'invoicing' ),
672
+                        ),
673
+                        $vat_classes
674
+                    ),
675
+                    'name'             => 'vat_class',
676
+                    'id'               => 'vat_class',
677
+                    'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
678
+                    'show_option_all'  => false,
679
+                    'show_option_none' => false,
680
+                )
681
+            );
682
+
683
+        }
684
+
685
+        // Filter by item type.
686
+        $type   = '';
687
+        if ( isset( $_GET['type'] ) ) {
688
+            $type   = sanitize_text_field( $_GET['type'] );
689
+        }
522 690
 
523
-	}
691
+        wpinv_html_select(
692
+            array(
693
+                'options'          => array_merge(
694
+                    array(
695
+                        '' => __( 'All item types', 'invoicing' ),
696
+                    ),
697
+                    wpinv_get_item_types()
698
+                ),
699
+                'name'             => 'type',
700
+                'id'               => 'type',
701
+                'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
702
+                'show_option_all'  => false,
703
+                'show_option_none' => false,
704
+            )
705
+        );
524 706
 
525
-	/**
526
-	 * Returns an array of items table columns.
527
-	 */
528
-	public static function item_columns( $columns ) {
707
+    }
529 708
 
530
-		$columns = array(
531
-			'cb'        => $columns['cb'],
532
-			'title'     => __( 'Name', 'invoicing' ),
533
-			'price'     => __( 'Price', 'invoicing' ),
534
-			'vat_rule'  => __( 'VAT rule', 'invoicing' ),
535
-			'vat_class' => __( 'VAT class', 'invoicing' ),
536
-			'type'      => __( 'Type', 'invoicing' ),
537
-			'shortcode' => __( 'Shortcode', 'invoicing' ),
538
-		);
709
+    /**
710
+     * Filters the item query.
711
+     */
712
+    public static function filter_item_query( $query ) {
539 713
 
540
-		if ( ! wpinv_use_taxes() ) {
541
-			unset( $columns['vat_rule'] );
542
-			unset( $columns['vat_class'] );
543
-		}
714
+        // modify the query only if it admin and main query.
715
+        if ( ! ( is_admin() && $query->is_main_query() ) ) {
716
+            return $query;
717
+        }
544 718
 
545
-		return apply_filters( 'wpi_item_table_columns', $columns );
546
-	}
719
+        // we want to modify the query for our items.
720
+        if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ) {
721
+            return $query;
722
+        }
547 723
 
548
-	/**
549
-	 * Returns an array of sortable items table columns.
550
-	 */
551
-	public static function sortable_item_columns( $columns ) {
552
-
553
-		return array_merge(
554
-			$columns,
555
-			array(
556
-				'price'     => 'price',
557
-				'vat_rule'  => 'vat_rule',
558
-				'vat_class' => 'vat_class',
559
-				'type'      => 'type',
560
-			)
561
-		);
562
-
563
-	}
564
-
565
-	/**
566
-	 * Displays items table columns.
567
-	 */
568
-	public static function display_item_columns( $column_name, $post_id ) {
569
-
570
-		$item = new WPInv_Item( $post_id );
571
-
572
-		switch ( $column_name ) {
573
-
574
-			case 'price':
575
-				if ( ! $item->is_recurring() ) {
576
-					echo wp_kses_post( $item->get_the_price() );
577
-					break;
578
-				}
579
-
580
-				$price = wp_sprintf(
581
-					__( '%1$s / %2$s', 'invoicing' ),
582
-					$item->get_the_price(),
583
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
584
-				);
585
-
586
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
587
-					echo wp_kses_post( $price );
588
-					break;
589
-				}
590
-
591
-				echo wp_kses_post( $item->get_the_initial_price() );
592
-
593
-				echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>';
594
-				break;
595
-
596
-			case 'vat_rule':
597
-				echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) );
598
-				break;
599
-
600
-			case 'vat_class':
601
-				echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) );
602
-				break;
603
-
604
-			case 'shortcode':
605
-				if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
606
-					echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
607
-				} else {
608
-					echo '&mdash;';
609
-				}
610
-
611
-				break;
612
-
613
-			case 'type':
614
-				echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' );
615
-				break;
616
-
617
-		}
618
-
619
-	}
620
-
621
-	/**
622
-	 * Lets users filter items using taxes.
623
-	 */
624
-	public static function add_item_filters( $post_type ) {
625
-
626
-		// Abort if we're not dealing with items.
627
-		if ( $post_type != 'wpi_item' ) {
628
-			return;
629
-		}
630
-
631
-		// Filter by vat rules.
632
-		if ( wpinv_use_taxes() ) {
633
-
634
-			// Sanitize selected vat rule.
635
-			$vat_rule   = '';
636
-			$vat_rules  = getpaid_get_tax_rules();
637
-			if ( isset( $_GET['vat_rule'] ) ) {
638
-				$vat_rule   = sanitize_text_field( $_GET['vat_rule'] );
639
-			}
640
-
641
-			// Filter by VAT rule.
642
-			wpinv_html_select(
643
-				array(
644
-					'options'          => array_merge(
645
-						array(
646
-							'' => __( 'All VAT rules', 'invoicing' ),
647
-						),
648
-						$vat_rules
649
-					),
650
-					'name'             => 'vat_rule',
651
-					'id'               => 'vat_rule',
652
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
653
-					'show_option_all'  => false,
654
-					'show_option_none' => false,
655
-				)
656
-			);
657
-
658
-			// Filter by VAT class.
659
-
660
-			// Sanitize selected vat rule.
661
-			$vat_class   = '';
662
-			$vat_classes = getpaid_get_tax_classes();
663
-			if ( isset( $_GET['vat_class'] ) ) {
664
-				$vat_class   = sanitize_text_field( $_GET['vat_class'] );
665
-			}
666
-
667
-			wpinv_html_select(
668
-				array(
669
-					'options'          => array_merge(
670
-						array(
671
-							'' => __( 'All VAT classes', 'invoicing' ),
672
-						),
673
-						$vat_classes
674
-					),
675
-					'name'             => 'vat_class',
676
-					'id'               => 'vat_class',
677
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
678
-					'show_option_all'  => false,
679
-					'show_option_none' => false,
680
-				)
681
-			);
682
-
683
-		}
684
-
685
-		// Filter by item type.
686
-		$type   = '';
687
-		if ( isset( $_GET['type'] ) ) {
688
-			$type   = sanitize_text_field( $_GET['type'] );
689
-		}
690
-
691
-		wpinv_html_select(
692
-			array(
693
-				'options'          => array_merge(
694
-					array(
695
-						'' => __( 'All item types', 'invoicing' ),
696
-					),
697
-					wpinv_get_item_types()
698
-				),
699
-				'name'             => 'type',
700
-				'id'               => 'type',
701
-				'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
702
-				'show_option_all'  => false,
703
-				'show_option_none' => false,
704
-			)
705
-		);
706
-
707
-	}
708
-
709
-	/**
710
-	 * Filters the item query.
711
-	 */
712
-	public static function filter_item_query( $query ) {
713
-
714
-		// modify the query only if it admin and main query.
715
-		if ( ! ( is_admin() && $query->is_main_query() ) ) {
716
-			return $query;
717
-		}
718
-
719
-		// we want to modify the query for our items.
720
-		if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ) {
721
-			return $query;
722
-		}
723
-
724
-		if ( empty( $query->query_vars['meta_query'] ) ) {
725
-			$query->query_vars['meta_query'] = array();
726
-		}
727
-
728
-		// Filter vat rule type
724
+        if ( empty( $query->query_vars['meta_query'] ) ) {
725
+            $query->query_vars['meta_query'] = array();
726
+        }
727
+
728
+        // Filter vat rule type
729 729
         if ( ! empty( $_GET['vat_rule'] ) ) {
730 730
             $query->query_vars['meta_query'][] = array(
731 731
                 'key'     => '_wpinv_vat_rule',
@@ -750,97 +750,97 @@  discard block
 block discarded – undo
750 750
                 'value'   => sanitize_text_field( $_GET['type'] ),
751 751
                 'compare' => '=',
752 752
             );
753
-		}
754
-
755
-	}
756
-
757
-	/**
758
-	 * Reorders items.
759
-	 */
760
-	public static function reorder_items( $vars ) {
761
-		global $typenow;
762
-
763
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
764
-			return $vars;
765
-		}
766
-
767
-		// By item type.
768
-		if ( 'type' == $vars['orderby'] ) {
769
-			return array_merge(
770
-				$vars,
771
-				array(
772
-					'meta_key' => '_wpinv_type',
773
-					'orderby'  => 'meta_value',
774
-				)
775
-			);
776
-		}
777
-
778
-		// By vat class.
779
-		if ( 'vat_class' == $vars['orderby'] ) {
780
-			return array_merge(
781
-				$vars,
782
-				array(
783
-					'meta_key' => '_wpinv_vat_class',
784
-					'orderby'  => 'meta_value',
785
-				)
786
-			);
787
-		}
788
-
789
-		// By vat rule.
790
-		if ( 'vat_rule' == $vars['orderby'] ) {
791
-			return array_merge(
792
-				$vars,
793
-				array(
794
-					'meta_key' => '_wpinv_vat_rule',
795
-					'orderby'  => 'meta_value',
796
-				)
797
-			);
798
-		}
799
-
800
-		// By price.
801
-		if ( 'price' == $vars['orderby'] ) {
802
-			return array_merge(
803
-				$vars,
804
-				array(
805
-					'meta_key' => '_wpinv_price',
806
-					'orderby'  => 'meta_value_num',
807
-				)
808
-			);
809
-		}
810
-
811
-		return $vars;
812
-
813
-	}
814
-
815
-	/**
816
-	 * Fired when deleting a post.
817
-	 */
818
-	public static function delete_post( $post_id ) {
819
-
820
-		switch ( get_post_type( $post_id ) ) {
821
-
822
-			case 'wpi_item':
823
-				do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) );
824
-				break;
825
-
826
-			case 'wpi_payment_form':
827
-				do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) );
828
-				break;
829
-
830
-			case 'wpi_discount':
831
-				do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) );
832
-				break;
833
-
834
-			case 'wpi_invoice':
835
-				$invoice = new WPInv_Invoice( $post_id );
836
-				do_action( 'getpaid_before_delete_invoice', $invoice );
837
-				$invoice->get_data_store()->delete_items( $invoice );
838
-				$invoice->get_data_store()->delete_special_fields( $invoice );
839
-				break;
840
-		}
841
-	}
842
-
843
-	/**
753
+        }
754
+
755
+    }
756
+
757
+    /**
758
+     * Reorders items.
759
+     */
760
+    public static function reorder_items( $vars ) {
761
+        global $typenow;
762
+
763
+        if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
764
+            return $vars;
765
+        }
766
+
767
+        // By item type.
768
+        if ( 'type' == $vars['orderby'] ) {
769
+            return array_merge(
770
+                $vars,
771
+                array(
772
+                    'meta_key' => '_wpinv_type',
773
+                    'orderby'  => 'meta_value',
774
+                )
775
+            );
776
+        }
777
+
778
+        // By vat class.
779
+        if ( 'vat_class' == $vars['orderby'] ) {
780
+            return array_merge(
781
+                $vars,
782
+                array(
783
+                    'meta_key' => '_wpinv_vat_class',
784
+                    'orderby'  => 'meta_value',
785
+                )
786
+            );
787
+        }
788
+
789
+        // By vat rule.
790
+        if ( 'vat_rule' == $vars['orderby'] ) {
791
+            return array_merge(
792
+                $vars,
793
+                array(
794
+                    'meta_key' => '_wpinv_vat_rule',
795
+                    'orderby'  => 'meta_value',
796
+                )
797
+            );
798
+        }
799
+
800
+        // By price.
801
+        if ( 'price' == $vars['orderby'] ) {
802
+            return array_merge(
803
+                $vars,
804
+                array(
805
+                    'meta_key' => '_wpinv_price',
806
+                    'orderby'  => 'meta_value_num',
807
+                )
808
+            );
809
+        }
810
+
811
+        return $vars;
812
+
813
+    }
814
+
815
+    /**
816
+     * Fired when deleting a post.
817
+     */
818
+    public static function delete_post( $post_id ) {
819
+
820
+        switch ( get_post_type( $post_id ) ) {
821
+
822
+            case 'wpi_item':
823
+                do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) );
824
+                break;
825
+
826
+            case 'wpi_payment_form':
827
+                do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) );
828
+                break;
829
+
830
+            case 'wpi_discount':
831
+                do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) );
832
+                break;
833
+
834
+            case 'wpi_invoice':
835
+                $invoice = new WPInv_Invoice( $post_id );
836
+                do_action( 'getpaid_before_delete_invoice', $invoice );
837
+                $invoice->get_data_store()->delete_items( $invoice );
838
+                $invoice->get_data_store()->delete_special_fields( $invoice );
839
+                break;
840
+        }
841
+    }
842
+
843
+    /**
844 844
      * Add a post display state for special GetPaid pages in the page list table.
845 845
      *
846 846
      * @param array   $post_states An array of post display states.
@@ -854,21 +854,21 @@  discard block
 block discarded – undo
854 854
             $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' );
855 855
         }
856 856
 
857
-		foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
857
+        foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
858 858
 
859
-			if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
860
-				$post_states[ "getpaid_{$post_type}_history_page" ] = sprintf(
861
-					__( 'GetPaid %s History Page', 'invoicing' ),
862
-					$label
863
-				);
864
-			}
859
+            if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
860
+                $post_states[ "getpaid_{$post_type}_history_page" ] = sprintf(
861
+                    __( 'GetPaid %s History Page', 'invoicing' ),
862
+                    $label
863
+                );
864
+            }
865 865
 }
866 866
 
867
-		if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
867
+        if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
868 868
             $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' );
869 869
         }
870 870
 
871
-		if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
871
+        if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
872 872
             $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' );
873 873
         }
874 874
 
Please login to merge, or discard this patch.
Spacing   +243 added lines, -243 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Post types Admin Class
@@ -21,74 +21,74 @@  discard block
 block discarded – undo
21 21
 		GetPaid_Metaboxes::init();
22 22
 
23 23
 		// Filter the post updated messages.
24
-		add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
24
+		add_filter('post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages');
25 25
 
26 26
 		// Filter post actions.
27
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
27
+		add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2);
28
+		add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2);
29 29
 
30 30
 		// Invoice table columns.
31
-		add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
-		add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
-		add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
-		add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
31
+		add_filter('manage_wpi_invoice_posts_columns', array(__CLASS__, 'invoice_columns'), 100);
32
+		add_action('manage_wpi_invoice_posts_custom_column', array(__CLASS__, 'display_invoice_columns'), 10, 2);
33
+		add_filter('bulk_actions-edit-wpi_invoice', array(__CLASS__, 'invoice_bulk_actions'));
34
+		add_filter('handle_bulk_actions-edit-wpi_invoice', array(__CLASS__, 'handle_invoice_bulk_actions'), 10, 3);
35 35
 
36 36
 		// Items table columns.
37
-		add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
-		add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
-		add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
-		add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
-		add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
-		add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
37
+		add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100);
38
+		add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20);
39
+		add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2);
40
+		add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100);
41
+		add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100);
42
+		add_action('request', array(__CLASS__, 'reorder_items'), 100);
43 43
 
44 44
 		// Payment forms columns.
45
-		add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
-		add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
45
+		add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100);
46
+		add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2);
47
+		add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2);
48 48
 
49 49
 		// Discount table columns.
50
-		add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
-		add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
50
+		add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100);
51
+		add_filter('bulk_actions-edit-wpi_discount', '__return_empty_array', 100);
52 52
 
53 53
 		// Deleting posts.
54
-		add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
54
+		add_action('delete_post', array(__CLASS__, 'delete_post'));
55
+		add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2);
56 56
 
57
-		add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
57
+		add_filter('display_post_states', array(__CLASS__, 'add_display_post_states'), 10, 2);
58 58
 	}
59 59
 
60 60
 	/**
61 61
 	 * Post updated messages.
62 62
 	 */
63
-	public static function post_updated_messages( $messages ) {
63
+	public static function post_updated_messages($messages) {
64 64
 		global $post;
65 65
 
66 66
 		$messages['wpi_discount'] = array(
67 67
 			0  => '',
68
-			1  => __( 'Discount updated.', 'invoicing' ),
69
-			2  => __( 'Custom field updated.', 'invoicing' ),
70
-			3  => __( 'Custom field deleted.', 'invoicing' ),
71
-			4  => __( 'Discount updated.', 'invoicing' ),
72
-			5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
-			6  => __( 'Discount updated.', 'invoicing' ),
74
-			7  => __( 'Discount saved.', 'invoicing' ),
75
-			8  => __( 'Discount submitted.', 'invoicing' ),
76
-			9  => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
-			10 => __( 'Discount draft updated.', 'invoicing' ),
68
+			1  => __('Discount updated.', 'invoicing'),
69
+			2  => __('Custom field updated.', 'invoicing'),
70
+			3  => __('Custom field deleted.', 'invoicing'),
71
+			4  => __('Discount updated.', 'invoicing'),
72
+			5  => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false,
73
+			6  => __('Discount updated.', 'invoicing'),
74
+			7  => __('Discount saved.', 'invoicing'),
75
+			8  => __('Discount submitted.', 'invoicing'),
76
+			9  => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
77
+			10 => __('Discount draft updated.', 'invoicing'),
78 78
 		);
79 79
 
80 80
 		$messages['wpi_payment_form'] = array(
81 81
 			0  => '',
82
-			1  => __( 'Payment Form updated.', 'invoicing' ),
83
-			2  => __( 'Custom field updated.', 'invoicing' ),
84
-			3  => __( 'Custom field deleted.', 'invoicing' ),
85
-			4  => __( 'Payment Form updated.', 'invoicing' ),
86
-			5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
-			6  => __( 'Payment Form updated.', 'invoicing' ),
88
-			7  => __( 'Payment Form saved.', 'invoicing' ),
89
-			8  => __( 'Payment Form submitted.', 'invoicing' ),
90
-			9  => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
-			10 => __( 'Payment Form draft updated.', 'invoicing' ),
82
+			1  => __('Payment Form updated.', 'invoicing'),
83
+			2  => __('Custom field updated.', 'invoicing'),
84
+			3  => __('Custom field deleted.', 'invoicing'),
85
+			4  => __('Payment Form updated.', 'invoicing'),
86
+			5  => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false,
87
+			6  => __('Payment Form updated.', 'invoicing'),
88
+			7  => __('Payment Form saved.', 'invoicing'),
89
+			8  => __('Payment Form submitted.', 'invoicing'),
90
+			9  => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
91
+			10 => __('Payment Form draft updated.', 'invoicing'),
92 92
 		);
93 93
 
94 94
 		return $messages;
@@ -98,16 +98,16 @@  discard block
 block discarded – undo
98 98
 	/**
99 99
 	 * Post row actions.
100 100
 	 */
101
-	public static function post_row_actions( $actions, $post ) {
101
+	public static function post_row_actions($actions, $post) {
102 102
 
103
-		$post = get_post( $post );
103
+		$post = get_post($post);
104 104
 
105 105
 		// We do not want to edit the default payment form.
106
-		if ( 'wpi_payment_form' == $post->post_type ) {
106
+		if ('wpi_payment_form' == $post->post_type) {
107 107
 
108
-			if ( $post->ID == wpinv_get_default_payment_form() ) {
109
-				unset( $actions['trash'] );
110
-				unset( $actions['inline hide-if-no-js'] );
108
+			if ($post->ID == wpinv_get_default_payment_form()) {
109
+				unset($actions['trash']);
110
+				unset($actions['inline hide-if-no-js']);
111 111
 			}
112 112
 
113 113
 			$actions['duplicate'] = sprintf(
@@ -124,20 +124,20 @@  discard block
 block discarded – undo
124 124
 						'getpaid-nonce'
125 125
 					)
126 126
 				),
127
-				esc_html( __( 'Duplicate', 'invoicing' ) )
127
+				esc_html(__('Duplicate', 'invoicing'))
128 128
 			);
129 129
 
130 130
 		}
131 131
 
132 132
 		// Link to item payment form.
133
-		if ( 'wpi_item' == $post->post_type ) {
133
+		if ('wpi_item' == $post->post_type) {
134 134
 
135
-			if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) {
135
+			if (in_array(get_post_meta($post->ID, '_wpinv_type', true), array('', 'fee', 'custom'))) {
136 136
 
137 137
 				$actions['buy'] = sprintf(
138 138
 					'<a href="%1$s">%2$s</a>',
139
-					esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
140
-					esc_html( __( 'Buy', 'invoicing' ) )
139
+					esc_url(getpaid_embed_url(false, $post->ID . '|0')),
140
+					esc_html(__('Buy', 'invoicing'))
141 141
 				);
142 142
 
143 143
 			}
@@ -154,27 +154,27 @@  discard block
 block discarded – undo
154 154
 	 * @param WP_Post $post
155 155
      * @return array $actions actions without edit option
156 156
      */
157
-    public static function filter_invoice_row_actions( $actions, $post ) {
157
+    public static function filter_invoice_row_actions($actions, $post) {
158 158
 
159
-        if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
159
+        if (getpaid_is_invoice_post_type($post->post_type)) {
160 160
 
161 161
 			$actions = array();
162
-			$invoice = new WPInv_Invoice( $post );
162
+			$invoice = new WPInv_Invoice($post);
163 163
 
164 164
 			$actions['edit'] = sprintf(
165 165
 				'<a href="%1$s">%2$s</a>',
166
-				esc_url( get_edit_post_link( $invoice->get_id() ) ),
167
-				esc_html( __( 'Edit', 'invoicing' ) )
166
+				esc_url(get_edit_post_link($invoice->get_id())),
167
+				esc_html(__('Edit', 'invoicing'))
168 168
 			);
169 169
 
170
-			if ( ! $invoice->is_draft() ) {
170
+			if (!$invoice->is_draft()) {
171 171
 
172 172
 				$actions['view'] = sprintf(
173 173
 					'<a href="%1$s">%2$s</a>',
174
-					esc_url( $invoice->get_view_url() ),
174
+					esc_url($invoice->get_view_url()),
175 175
 					sprintf(
176
-						esc_html( __( 'View %s', 'invoicing' ) ),
177
-						getpaid_get_post_type_label( $invoice->get_post_type(), false )
176
+						esc_html(__('View %s', 'invoicing')),
177
+						getpaid_get_post_type_label($invoice->get_post_type(), false)
178 178
 					)
179 179
 				);
180 180
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 							'getpaid-nonce'
193 193
 						)
194 194
 					),
195
-					esc_html( __( 'Send to Customer', 'invoicing' ) )
195
+					esc_html(__('Send to Customer', 'invoicing'))
196 196
 				);
197 197
 
198 198
 			}
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 						'getpaid-nonce'
212 212
 					)
213 213
 				),
214
-				esc_html( __( 'Duplicate', 'invoicing' ) )
214
+				esc_html(__('Duplicate', 'invoicing'))
215 215
 			);
216 216
 
217 217
         }
@@ -222,42 +222,42 @@  discard block
 block discarded – undo
222 222
 	/**
223 223
 	 * Returns an array of invoice table columns.
224 224
 	 */
225
-	public static function invoice_columns( $columns ) {
225
+	public static function invoice_columns($columns) {
226 226
 
227 227
 		$columns = array(
228 228
 			'cb'           => $columns['cb'],
229
-			'number'       => __( 'Invoice', 'invoicing' ),
230
-			'customer'     => __( 'Customer', 'invoicing' ),
231
-			'invoice_date' => __( 'Created', 'invoicing' ),
232
-			'payment_date' => __( 'Completed', 'invoicing' ),
233
-			'amount'       => __( 'Amount', 'invoicing' ),
234
-			'recurring'    => __( 'Recurring', 'invoicing' ),
235
-			'status'       => __( 'Status', 'invoicing' ),
229
+			'number'       => __('Invoice', 'invoicing'),
230
+			'customer'     => __('Customer', 'invoicing'),
231
+			'invoice_date' => __('Created', 'invoicing'),
232
+			'payment_date' => __('Completed', 'invoicing'),
233
+			'amount'       => __('Amount', 'invoicing'),
234
+			'recurring'    => __('Recurring', 'invoicing'),
235
+			'status'       => __('Status', 'invoicing'),
236 236
 		);
237 237
 
238
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
238
+		return apply_filters('wpi_invoice_table_columns', $columns);
239 239
 	}
240 240
 
241 241
 	/**
242 242
 	 * Displays invoice table columns.
243 243
 	 */
244
-	public static function display_invoice_columns( $column_name, $post_id ) {
244
+	public static function display_invoice_columns($column_name, $post_id) {
245 245
 
246
-		$invoice = new WPInv_Invoice( $post_id );
246
+		$invoice = new WPInv_Invoice($post_id);
247 247
 
248
-		switch ( $column_name ) {
248
+		switch ($column_name) {
249 249
 
250 250
 			case 'invoice_date':
251
-				$date_time = esc_attr( $invoice->get_created_date() );
252
-				$date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
253
-				echo wp_kses_post( "<span title='$date_time'>$date</span>" );
251
+				$date_time = esc_attr($invoice->get_created_date());
252
+				$date      = esc_html(getpaid_format_date_value($date_time, '&mdash;', true));
253
+				echo wp_kses_post("<span title='$date_time'>$date</span>");
254 254
 				break;
255 255
 
256 256
 			case 'payment_date':
257
-				if ( $invoice->is_paid() ) {
258
-					$date_time = esc_attr( $invoice->get_completed_date() );
259
-					$date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
260
-					echo wp_kses_post( "<span title='$date_time'>$date</span>" );
257
+				if ($invoice->is_paid()) {
258
+					$date_time = esc_attr($invoice->get_completed_date());
259
+					$date      = esc_html(getpaid_format_date_value($date_time, '&mdash;', true));
260
+					echo wp_kses_post("<span title='$date_time'>$date</span>");
261 261
 				} else {
262 262
 					echo '&mdash;';
263 263
 				}
@@ -266,57 +266,57 @@  discard block
 block discarded – undo
266 266
 
267 267
 			case 'amount':
268 268
 				$amount = $invoice->get_total();
269
-				$formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) );
269
+				$formated_amount = wp_kses_post(wpinv_price($amount, $invoice->get_currency()));
270 270
 
271
-				if ( $invoice->is_refunded() ) {
272
-					$refunded_amount = wpinv_price( 0, $invoice->get_currency() );
273
-					echo wp_kses_post( "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>" );
271
+				if ($invoice->is_refunded()) {
272
+					$refunded_amount = wpinv_price(0, $invoice->get_currency());
273
+					echo wp_kses_post("<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>");
274 274
 				} else {
275 275
 
276 276
 					$discount = $invoice->get_total_discount();
277 277
 
278
-					if ( ! empty( $discount ) ) {
279
-						$new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
280
-						echo wp_kses_post( "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>" );
278
+					if (!empty($discount)) {
279
+						$new_amount = wpinv_price($amount + $discount, $invoice->get_currency());
280
+						echo wp_kses_post("<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>");
281 281
 					} else {
282
-						echo wp_kses_post( $formated_amount );
282
+						echo wp_kses_post($formated_amount);
283 283
 					}
284 284
 }
285 285
 
286 286
 				break;
287 287
 
288 288
 			case 'status':
289
-				$status       = esc_html( $invoice->get_status() );
290
-				$status_label = esc_html( $invoice->get_status_nicename() );
289
+				$status       = esc_html($invoice->get_status());
290
+				$status_label = esc_html($invoice->get_status_nicename());
291 291
 
292 292
 				// If it is paid, show the gateway title.
293
-				if ( $invoice->is_paid() ) {
294
-					$gateway = esc_html( $invoice->get_gateway_title() );
295
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) );
293
+				if ($invoice->is_paid()) {
294
+					$gateway = esc_html($invoice->get_gateway_title());
295
+					$gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), esc_html($gateway));
296 296
 
297
-					echo wp_kses_post( "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>" );
297
+					echo wp_kses_post("<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>");
298 298
 				} else {
299
-					echo wp_kses_post( "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>" );
299
+					echo wp_kses_post("<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>");
300 300
 				}
301 301
 
302 302
 				// If it is not paid, display the overdue and view status.
303
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
303
+				if (!$invoice->is_paid() && !$invoice->is_refunded()) {
304 304
 
305 305
 					// Invoice view status.
306
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
307
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>';
306
+					if (wpinv_is_invoice_viewed($invoice->get_id())) {
307
+						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>';
308 308
 					} else {
309
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>';
309
+						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>';
310 310
 					}
311 311
 
312 312
 					// Display the overview status.
313
-					if ( wpinv_get_option( 'overdue_active' ) ) {
313
+					if (wpinv_get_option('overdue_active')) {
314 314
 						$due_date = $invoice->get_due_date();
315
-						$fomatted = getpaid_format_date( $due_date );
315
+						$fomatted = getpaid_format_date($due_date);
316 316
 
317
-						if ( ! empty( $fomatted ) ) {
318
-							$date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
319
-							echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" );
317
+						if (!empty($fomatted)) {
318
+							$date = wp_sprintf(__('Due %s', 'invoicing'), $fomatted);
319
+							echo wp_kses_post("<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>");
320 320
 						}
321 321
 					}
322 322
 }
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 				break;
325 325
 
326 326
 			case 'recurring':
327
-				if ( $invoice->is_recurring() ) {
327
+				if ($invoice->is_recurring()) {
328 328
 					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
329 329
 				} else {
330 330
 					echo '<i class="fa fa-times" style="color:#616161;"></i>';
@@ -332,25 +332,25 @@  discard block
 block discarded – undo
332 332
 				break;
333 333
 
334 334
 			case 'number':
335
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
336
-				$invoice_number  = esc_html( $invoice->get_number() );
337
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
335
+				$edit_link       = esc_url(get_edit_post_link($invoice->get_id()));
336
+				$invoice_number  = esc_html($invoice->get_number());
337
+				$invoice_details = esc_attr__('View Invoice Details', 'invoicing');
338 338
 
339
-				echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" );
339
+				echo wp_kses_post("<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>");
340 340
 
341 341
 				break;
342 342
 
343 343
 			case 'customer':
344 344
 				$customer_name = $invoice->get_user_full_name();
345 345
 
346
-				if ( empty( $customer_name ) ) {
346
+				if (empty($customer_name)) {
347 347
 					$customer_name = $invoice->get_email();
348 348
 				}
349 349
 
350
-				if ( ! empty( $customer_name ) ) {
351
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
352
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
353
-					echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" );
350
+				if (!empty($customer_name)) {
351
+					$customer_details = esc_attr__('View Customer Details', 'invoicing');
352
+					$view_link        = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php')));
353
+					echo wp_kses_post("<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>");
354 354
 				} else {
355 355
 					echo '<div>&mdash;</div>';
356 356
 				}
@@ -364,19 +364,19 @@  discard block
 block discarded – undo
364 364
 	/**
365 365
 	 * Displays invoice bulk actions.
366 366
 	 */
367
-	public static function invoice_bulk_actions( $actions ) {
368
-		$actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
367
+	public static function invoice_bulk_actions($actions) {
368
+		$actions['resend-invoice'] = __('Send to Customer', 'invoicing');
369 369
 		return $actions;
370 370
 	}
371 371
 
372 372
 	/**
373 373
 	 * Processes invoice bulk actions.
374 374
 	 */
375
-	public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
375
+	public static function handle_invoice_bulk_actions($redirect_url, $action, $post_ids) {
376 376
 
377
-		if ( $action == 'resend-invoice' ) {
378
-			foreach ( $post_ids as $post_id ) {
379
-				getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
377
+		if ($action == 'resend-invoice') {
378
+			foreach ($post_ids as $post_id) {
379
+				getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($post_id), true);
380 380
 			}
381 381
 		}
382 382
 
@@ -387,49 +387,49 @@  discard block
 block discarded – undo
387 387
 	/**
388 388
 	 * Returns an array of payment forms table columns.
389 389
 	 */
390
-	public static function payment_form_columns( $columns ) {
390
+	public static function payment_form_columns($columns) {
391 391
 
392 392
 		$columns = array(
393 393
 			'cb'        => $columns['cb'],
394
-			'title'     => __( 'Name', 'invoicing' ),
395
-			'shortcode' => __( 'Shortcode', 'invoicing' ),
396
-			'earnings'  => __( 'Revenue', 'invoicing' ),
397
-			'refunds'   => __( 'Refunded', 'invoicing' ),
398
-			'items'     => __( 'Items', 'invoicing' ),
399
-			'date'      => __( 'Date', 'invoicing' ),
394
+			'title'     => __('Name', 'invoicing'),
395
+			'shortcode' => __('Shortcode', 'invoicing'),
396
+			'earnings'  => __('Revenue', 'invoicing'),
397
+			'refunds'   => __('Refunded', 'invoicing'),
398
+			'items'     => __('Items', 'invoicing'),
399
+			'date'      => __('Date', 'invoicing'),
400 400
 		);
401 401
 
402
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
402
+		return apply_filters('wpi_payment_form_table_columns', $columns);
403 403
 
404 404
 	}
405 405
 
406 406
 	/**
407 407
 	 * Displays payment form table columns.
408 408
 	 */
409
-	public static function display_payment_form_columns( $column_name, $post_id ) {
409
+	public static function display_payment_form_columns($column_name, $post_id) {
410 410
 
411 411
 		// Retrieve the payment form.
412
-		$form = new GetPaid_Payment_Form( $post_id );
412
+		$form = new GetPaid_Payment_Form($post_id);
413 413
 
414
-		switch ( $column_name ) {
414
+		switch ($column_name) {
415 415
 
416 416
 			case 'earnings':
417
-				echo wp_kses_post( wpinv_price( $form->get_earned() ) );
417
+				echo wp_kses_post(wpinv_price($form->get_earned()));
418 418
 				break;
419 419
 
420 420
 			case 'refunds':
421
-				echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
421
+				echo wp_kses_post(wpinv_price($form->get_refunded()));
422 422
 				break;
423 423
 
424 424
 			case 'refunds':
425
-				echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
425
+				echo wp_kses_post(wpinv_price($form->get_refunded()));
426 426
 				break;
427 427
 
428 428
 			case 'shortcode':
429
-				if ( $form->is_default() ) {
429
+				if ($form->is_default()) {
430 430
 					echo '&mdash;';
431 431
 				} else {
432
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
432
+					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>';
433 433
 				}
434 434
 
435 435
 				break;
@@ -437,28 +437,28 @@  discard block
 block discarded – undo
437 437
 			case 'items':
438 438
 				$items = $form->get_items();
439 439
 
440
-				if ( $form->is_default() || empty( $items ) ) {
440
+				if ($form->is_default() || empty($items)) {
441 441
 					echo '&mdash;';
442 442
 					return;
443 443
 				}
444 444
 
445 445
 				$_items = array();
446 446
 
447
-				foreach ( $items as $item ) {
447
+				foreach ($items as $item) {
448 448
 					$url = $item->get_edit_url();
449 449
 
450
-					if ( empty( $url ) ) {
451
-						$_items[] = esc_html( $item->get_name() );
450
+					if (empty($url)) {
451
+						$_items[] = esc_html($item->get_name());
452 452
 					} else {
453 453
 						$_items[] = sprintf(
454 454
 							'<a href="%s">%s</a>',
455
-							esc_url( $url ),
456
-							esc_html( $item->get_name() )
455
+							esc_url($url),
456
+							esc_html($item->get_name())
457 457
 						);
458 458
 					}
459 459
 }
460 460
 
461
-				echo wp_kses_post( implode( '<br>', $_items ) );
461
+				echo wp_kses_post(implode('<br>', $_items));
462 462
 
463 463
 				break;
464 464
 
@@ -469,10 +469,10 @@  discard block
 block discarded – undo
469 469
 	/**
470 470
 	 * Filters post states.
471 471
 	 */
472
-	public static function filter_payment_form_state( $post_states, $post ) {
472
+	public static function filter_payment_form_state($post_states, $post) {
473 473
 
474
-		if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
475
-			$post_states['default_form'] = __( 'Default Payment Form', 'invoicing' );
474
+		if ('wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID) {
475
+			$post_states['default_form'] = __('Default Payment Form', 'invoicing');
476 476
 		}
477 477
 
478 478
 		return $post_states;
@@ -482,35 +482,35 @@  discard block
 block discarded – undo
482 482
 	/**
483 483
 	 * Returns an array of coupon table columns.
484 484
 	 */
485
-	public static function discount_columns( $columns ) {
485
+	public static function discount_columns($columns) {
486 486
 
487 487
 		$columns = array(
488 488
 			'cb'          => $columns['cb'],
489
-			'title'       => __( 'Name', 'invoicing' ),
490
-			'code'        => __( 'Code', 'invoicing' ),
491
-			'amount'      => __( 'Amount', 'invoicing' ),
492
-			'usage'       => __( 'Usage / Limit', 'invoicing' ),
493
-			'start_date'  => __( 'Start Date', 'invoicing' ),
494
-			'expiry_date' => __( 'Expiry Date', 'invoicing' ),
489
+			'title'       => __('Name', 'invoicing'),
490
+			'code'        => __('Code', 'invoicing'),
491
+			'amount'      => __('Amount', 'invoicing'),
492
+			'usage'       => __('Usage / Limit', 'invoicing'),
493
+			'start_date'  => __('Start Date', 'invoicing'),
494
+			'expiry_date' => __('Expiry Date', 'invoicing'),
495 495
 		);
496 496
 
497
-		return apply_filters( 'wpi_discount_table_columns', $columns );
497
+		return apply_filters('wpi_discount_table_columns', $columns);
498 498
 	}
499 499
 
500 500
 	/**
501 501
 	 * Filters post states.
502 502
 	 */
503
-	public static function filter_discount_state( $post_states, $post ) {
503
+	public static function filter_discount_state($post_states, $post) {
504 504
 
505
-		if ( 'wpi_discount' == $post->post_type ) {
505
+		if ('wpi_discount' == $post->post_type) {
506 506
 
507
-			$discount = new WPInv_Discount( $post );
507
+			$discount = new WPInv_Discount($post);
508 508
 
509 509
 			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
510 510
 
511
-			if ( $status != 'publish' ) {
511
+			if ($status != 'publish') {
512 512
 				return array(
513
-					'discount_status' => wpinv_discount_status( $status ),
513
+					'discount_status' => wpinv_discount_status($status),
514 514
 				);
515 515
 			}
516 516
 
@@ -525,30 +525,30 @@  discard block
 block discarded – undo
525 525
 	/**
526 526
 	 * Returns an array of items table columns.
527 527
 	 */
528
-	public static function item_columns( $columns ) {
528
+	public static function item_columns($columns) {
529 529
 
530 530
 		$columns = array(
531 531
 			'cb'        => $columns['cb'],
532
-			'title'     => __( 'Name', 'invoicing' ),
533
-			'price'     => __( 'Price', 'invoicing' ),
534
-			'vat_rule'  => __( 'VAT rule', 'invoicing' ),
535
-			'vat_class' => __( 'VAT class', 'invoicing' ),
536
-			'type'      => __( 'Type', 'invoicing' ),
537
-			'shortcode' => __( 'Shortcode', 'invoicing' ),
532
+			'title'     => __('Name', 'invoicing'),
533
+			'price'     => __('Price', 'invoicing'),
534
+			'vat_rule'  => __('VAT rule', 'invoicing'),
535
+			'vat_class' => __('VAT class', 'invoicing'),
536
+			'type'      => __('Type', 'invoicing'),
537
+			'shortcode' => __('Shortcode', 'invoicing'),
538 538
 		);
539 539
 
540
-		if ( ! wpinv_use_taxes() ) {
541
-			unset( $columns['vat_rule'] );
542
-			unset( $columns['vat_class'] );
540
+		if (!wpinv_use_taxes()) {
541
+			unset($columns['vat_rule']);
542
+			unset($columns['vat_class']);
543 543
 		}
544 544
 
545
-		return apply_filters( 'wpi_item_table_columns', $columns );
545
+		return apply_filters('wpi_item_table_columns', $columns);
546 546
 	}
547 547
 
548 548
 	/**
549 549
 	 * Returns an array of sortable items table columns.
550 550
 	 */
551
-	public static function sortable_item_columns( $columns ) {
551
+	public static function sortable_item_columns($columns) {
552 552
 
553 553
 		return array_merge(
554 554
 			$columns,
@@ -565,45 +565,45 @@  discard block
 block discarded – undo
565 565
 	/**
566 566
 	 * Displays items table columns.
567 567
 	 */
568
-	public static function display_item_columns( $column_name, $post_id ) {
568
+	public static function display_item_columns($column_name, $post_id) {
569 569
 
570
-		$item = new WPInv_Item( $post_id );
570
+		$item = new WPInv_Item($post_id);
571 571
 
572
-		switch ( $column_name ) {
572
+		switch ($column_name) {
573 573
 
574 574
 			case 'price':
575
-				if ( ! $item->is_recurring() ) {
576
-					echo wp_kses_post( $item->get_the_price() );
575
+				if (!$item->is_recurring()) {
576
+					echo wp_kses_post($item->get_the_price());
577 577
 					break;
578 578
 				}
579 579
 
580 580
 				$price = wp_sprintf(
581
-					__( '%1$s / %2$s', 'invoicing' ),
581
+					__('%1$s / %2$s', 'invoicing'),
582 582
 					$item->get_the_price(),
583
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
583
+					getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '')
584 584
 				);
585 585
 
586
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
587
-					echo wp_kses_post( $price );
586
+				if ($item->get_the_price() == $item->get_the_initial_price()) {
587
+					echo wp_kses_post($price);
588 588
 					break;
589 589
 				}
590 590
 
591
-				echo wp_kses_post( $item->get_the_initial_price() );
591
+				echo wp_kses_post($item->get_the_initial_price());
592 592
 
593
-				echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>';
593
+				echo '<span class="meta">' . wp_sprintf(esc_html__('then %s', 'invoicing'), wp_kses_post($price)) . '</span>';
594 594
 				break;
595 595
 
596 596
 			case 'vat_rule':
597
-				echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) );
597
+				echo wp_kses_post(getpaid_get_tax_rule_label($item->get_vat_rule()));
598 598
 				break;
599 599
 
600 600
 			case 'vat_class':
601
-				echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) );
601
+				echo wp_kses_post(getpaid_get_tax_class_label($item->get_vat_class()));
602 602
 				break;
603 603
 
604 604
 			case 'shortcode':
605
-				if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
606
-					echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
605
+				if ($item->is_type(array('', 'fee', 'custom'))) {
606
+					echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
607 607
 				} else {
608 608
 					echo '&mdash;';
609 609
 				}
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 				break;
612 612
 
613 613
 			case 'type':
614
-				echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' );
614
+				echo wp_kses_post(wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>');
615 615
 				break;
616 616
 
617 617
 		}
@@ -621,21 +621,21 @@  discard block
 block discarded – undo
621 621
 	/**
622 622
 	 * Lets users filter items using taxes.
623 623
 	 */
624
-	public static function add_item_filters( $post_type ) {
624
+	public static function add_item_filters($post_type) {
625 625
 
626 626
 		// Abort if we're not dealing with items.
627
-		if ( $post_type != 'wpi_item' ) {
627
+		if ($post_type != 'wpi_item') {
628 628
 			return;
629 629
 		}
630 630
 
631 631
 		// Filter by vat rules.
632
-		if ( wpinv_use_taxes() ) {
632
+		if (wpinv_use_taxes()) {
633 633
 
634 634
 			// Sanitize selected vat rule.
635 635
 			$vat_rule   = '';
636 636
 			$vat_rules  = getpaid_get_tax_rules();
637
-			if ( isset( $_GET['vat_rule'] ) ) {
638
-				$vat_rule   = sanitize_text_field( $_GET['vat_rule'] );
637
+			if (isset($_GET['vat_rule'])) {
638
+				$vat_rule = sanitize_text_field($_GET['vat_rule']);
639 639
 			}
640 640
 
641 641
 			// Filter by VAT rule.
@@ -643,13 +643,13 @@  discard block
 block discarded – undo
643 643
 				array(
644 644
 					'options'          => array_merge(
645 645
 						array(
646
-							'' => __( 'All VAT rules', 'invoicing' ),
646
+							'' => __('All VAT rules', 'invoicing'),
647 647
 						),
648 648
 						$vat_rules
649 649
 					),
650 650
 					'name'             => 'vat_rule',
651 651
 					'id'               => 'vat_rule',
652
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
652
+					'selected'         => in_array($vat_rule, array_keys($vat_rules)) ? $vat_rule : '',
653 653
 					'show_option_all'  => false,
654 654
 					'show_option_none' => false,
655 655
 				)
@@ -660,21 +660,21 @@  discard block
 block discarded – undo
660 660
 			// Sanitize selected vat rule.
661 661
 			$vat_class   = '';
662 662
 			$vat_classes = getpaid_get_tax_classes();
663
-			if ( isset( $_GET['vat_class'] ) ) {
664
-				$vat_class   = sanitize_text_field( $_GET['vat_class'] );
663
+			if (isset($_GET['vat_class'])) {
664
+				$vat_class = sanitize_text_field($_GET['vat_class']);
665 665
 			}
666 666
 
667 667
 			wpinv_html_select(
668 668
 				array(
669 669
 					'options'          => array_merge(
670 670
 						array(
671
-							'' => __( 'All VAT classes', 'invoicing' ),
671
+							'' => __('All VAT classes', 'invoicing'),
672 672
 						),
673 673
 						$vat_classes
674 674
 					),
675 675
 					'name'             => 'vat_class',
676 676
 					'id'               => 'vat_class',
677
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
677
+					'selected'         => in_array($vat_class, array_keys($vat_classes)) ? $vat_class : '',
678 678
 					'show_option_all'  => false,
679 679
 					'show_option_none' => false,
680 680
 				)
@@ -683,22 +683,22 @@  discard block
 block discarded – undo
683 683
 		}
684 684
 
685 685
 		// Filter by item type.
686
-		$type   = '';
687
-		if ( isset( $_GET['type'] ) ) {
688
-			$type   = sanitize_text_field( $_GET['type'] );
686
+		$type = '';
687
+		if (isset($_GET['type'])) {
688
+			$type = sanitize_text_field($_GET['type']);
689 689
 		}
690 690
 
691 691
 		wpinv_html_select(
692 692
 			array(
693 693
 				'options'          => array_merge(
694 694
 					array(
695
-						'' => __( 'All item types', 'invoicing' ),
695
+						'' => __('All item types', 'invoicing'),
696 696
 					),
697 697
 					wpinv_get_item_types()
698 698
 				),
699 699
 				'name'             => 'type',
700 700
 				'id'               => 'type',
701
-				'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
701
+				'selected'         => in_array($type, wpinv_item_types()) ? $type : '',
702 702
 				'show_option_all'  => false,
703 703
 				'show_option_none' => false,
704 704
 			)
@@ -709,45 +709,45 @@  discard block
 block discarded – undo
709 709
 	/**
710 710
 	 * Filters the item query.
711 711
 	 */
712
-	public static function filter_item_query( $query ) {
712
+	public static function filter_item_query($query) {
713 713
 
714 714
 		// modify the query only if it admin and main query.
715
-		if ( ! ( is_admin() && $query->is_main_query() ) ) {
715
+		if (!(is_admin() && $query->is_main_query())) {
716 716
 			return $query;
717 717
 		}
718 718
 
719 719
 		// we want to modify the query for our items.
720
-		if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ) {
720
+		if (empty($query->query['post_type']) || 'wpi_item' != $query->query['post_type']) {
721 721
 			return $query;
722 722
 		}
723 723
 
724
-		if ( empty( $query->query_vars['meta_query'] ) ) {
724
+		if (empty($query->query_vars['meta_query'])) {
725 725
 			$query->query_vars['meta_query'] = array();
726 726
 		}
727 727
 
728 728
 		// Filter vat rule type
729
-        if ( ! empty( $_GET['vat_rule'] ) ) {
729
+        if (!empty($_GET['vat_rule'])) {
730 730
             $query->query_vars['meta_query'][] = array(
731 731
                 'key'     => '_wpinv_vat_rule',
732
-                'value'   => sanitize_text_field( $_GET['vat_rule'] ),
732
+                'value'   => sanitize_text_field($_GET['vat_rule']),
733 733
                 'compare' => '=',
734 734
             );
735 735
         }
736 736
 
737 737
         // Filter vat class
738
-        if ( ! empty( $_GET['vat_class'] ) ) {
738
+        if (!empty($_GET['vat_class'])) {
739 739
             $query->query_vars['meta_query'][] = array(
740 740
                 'key'     => '_wpinv_vat_class',
741
-                'value'   => sanitize_text_field( $_GET['vat_class'] ),
741
+                'value'   => sanitize_text_field($_GET['vat_class']),
742 742
                 'compare' => '=',
743 743
             );
744 744
         }
745 745
 
746 746
         // Filter item type
747
-        if ( ! empty( $_GET['type'] ) ) {
747
+        if (!empty($_GET['type'])) {
748 748
             $query->query_vars['meta_query'][] = array(
749 749
                 'key'     => '_wpinv_type',
750
-                'value'   => sanitize_text_field( $_GET['type'] ),
750
+                'value'   => sanitize_text_field($_GET['type']),
751 751
                 'compare' => '=',
752 752
             );
753 753
 		}
@@ -757,15 +757,15 @@  discard block
 block discarded – undo
757 757
 	/**
758 758
 	 * Reorders items.
759 759
 	 */
760
-	public static function reorder_items( $vars ) {
760
+	public static function reorder_items($vars) {
761 761
 		global $typenow;
762 762
 
763
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
763
+		if ('wpi_item' !== $typenow || empty($vars['orderby'])) {
764 764
 			return $vars;
765 765
 		}
766 766
 
767 767
 		// By item type.
768
-		if ( 'type' == $vars['orderby'] ) {
768
+		if ('type' == $vars['orderby']) {
769 769
 			return array_merge(
770 770
 				$vars,
771 771
 				array(
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
 		}
777 777
 
778 778
 		// By vat class.
779
-		if ( 'vat_class' == $vars['orderby'] ) {
779
+		if ('vat_class' == $vars['orderby']) {
780 780
 			return array_merge(
781 781
 				$vars,
782 782
 				array(
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 		}
788 788
 
789 789
 		// By vat rule.
790
-		if ( 'vat_rule' == $vars['orderby'] ) {
790
+		if ('vat_rule' == $vars['orderby']) {
791 791
 			return array_merge(
792 792
 				$vars,
793 793
 				array(
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
 		}
799 799
 
800 800
 		// By price.
801
-		if ( 'price' == $vars['orderby'] ) {
801
+		if ('price' == $vars['orderby']) {
802 802
 			return array_merge(
803 803
 				$vars,
804 804
 				array(
@@ -815,27 +815,27 @@  discard block
 block discarded – undo
815 815
 	/**
816 816
 	 * Fired when deleting a post.
817 817
 	 */
818
-	public static function delete_post( $post_id ) {
818
+	public static function delete_post($post_id) {
819 819
 
820
-		switch ( get_post_type( $post_id ) ) {
820
+		switch (get_post_type($post_id)) {
821 821
 
822 822
 			case 'wpi_item':
823
-				do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) );
823
+				do_action('getpaid_before_delete_item', new WPInv_Item($post_id));
824 824
 				break;
825 825
 
826 826
 			case 'wpi_payment_form':
827
-				do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) );
827
+				do_action('getpaid_before_delete_payment_form', new GetPaid_Payment_Form($post_id));
828 828
 				break;
829 829
 
830 830
 			case 'wpi_discount':
831
-				do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) );
831
+				do_action('getpaid_before_delete_discount', new WPInv_Discount($post_id));
832 832
 				break;
833 833
 
834 834
 			case 'wpi_invoice':
835
-				$invoice = new WPInv_Invoice( $post_id );
836
-				do_action( 'getpaid_before_delete_invoice', $invoice );
837
-				$invoice->get_data_store()->delete_items( $invoice );
838
-				$invoice->get_data_store()->delete_special_fields( $invoice );
835
+				$invoice = new WPInv_Invoice($post_id);
836
+				do_action('getpaid_before_delete_invoice', $invoice);
837
+				$invoice->get_data_store()->delete_items($invoice);
838
+				$invoice->get_data_store()->delete_special_fields($invoice);
839 839
 				break;
840 840
 		}
841 841
 	}
@@ -848,28 +848,28 @@  discard block
 block discarded – undo
848 848
      *
849 849
      * @return mixed
850 850
      */
851
-    public static function add_display_post_states( $post_states, $post ) {
851
+    public static function add_display_post_states($post_states, $post) {
852 852
 
853
-        if ( wpinv_get_option( 'success_page', 0 ) == $post->ID ) {
854
-            $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' );
853
+        if (wpinv_get_option('success_page', 0) == $post->ID) {
854
+            $post_states['getpaid_success_page'] = __('GetPaid Receipt Page', 'invoicing');
855 855
         }
856 856
 
857
-		foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
857
+		foreach (getpaid_get_invoice_post_types() as $post_type => $label) {
858 858
 
859
-			if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
860
-				$post_states[ "getpaid_{$post_type}_history_page" ] = sprintf(
861
-					__( 'GetPaid %s History Page', 'invoicing' ),
859
+			if (wpinv_get_option("{$post_type}_history_page", 0) == $post->ID) {
860
+				$post_states["getpaid_{$post_type}_history_page"] = sprintf(
861
+					__('GetPaid %s History Page', 'invoicing'),
862 862
 					$label
863 863
 				);
864 864
 			}
865 865
 }
866 866
 
867
-		if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
868
-            $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' );
867
+		if (wpinv_get_option('invoice_subscription_page', 0) == $post->ID) {
868
+            $post_states['getpaid_invoice_subscription_page'] = __('GetPaid Subscription Page', 'invoicing');
869 869
         }
870 870
 
871
-		if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
872
-            $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' );
871
+		if (wpinv_get_option('checkout_page', 0) == $post->ID) {
872
+            $post_states['getpaid_checkout_page'] = __('GetPaid Checkout Page', 'invoicing');
873 873
         }
874 874
 
875 875
         return $post_states;
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-address.php 2 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Invoice_Address {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the invoice.
@@ -225,37 +225,37 @@  discard block
 block discarded – undo
225 225
 
226 226
                                 if ( empty( $states ) ) {
227 227
 
228
-								aui()->input(
229
-								array(
230
-								'type'        => 'text',
231
-								'id'          => 'wpinv_state',
232
-								'name'        => 'wpinv_state',
233
-								'label'       => __( 'State', 'invoicing' ),
234
-								'label_type'  => 'vertical',
235
-								'placeholder' => '',
236
-								'class'       => 'form-control-sm',
237
-								'value'       => $invoice->get_state( 'edit' ),
238
-								),
239
-								true
240
-							);
228
+                                aui()->input(
229
+                                array(
230
+                                'type'        => 'text',
231
+                                'id'          => 'wpinv_state',
232
+                                'name'        => 'wpinv_state',
233
+                                'label'       => __( 'State', 'invoicing' ),
234
+                                'label_type'  => 'vertical',
235
+                                'placeholder' => '',
236
+                                'class'       => 'form-control-sm',
237
+                                'value'       => $invoice->get_state( 'edit' ),
238
+                                ),
239
+                                true
240
+                            );
241 241
 
242 242
                                 } else {
243 243
 
244
-								aui()->select(
245
-								array(
246
-								'id'               => 'wpinv_state',
247
-								'name'             => 'wpinv_state',
248
-								'label'            => __( 'State', 'invoicing' ),
249
-								'label_type'       => 'vertical',
250
-								'placeholder'      => __( 'Select a state', 'invoicing' ),
251
-								'class'            => 'form-control-sm',
252
-								'value'            => $invoice->get_state( 'edit' ),
253
-								'options'          => $states,
254
-								'data-allow-clear' => 'false',
255
-								'select2'          => true,
256
-								),
257
-								true
258
-								);
244
+                                aui()->select(
245
+                                array(
246
+                                'id'               => 'wpinv_state',
247
+                                'name'             => 'wpinv_state',
248
+                                'label'            => __( 'State', 'invoicing' ),
249
+                                'label_type'       => 'vertical',
250
+                                'placeholder'      => __( 'Select a state', 'invoicing' ),
251
+                                'class'            => 'form-control-sm',
252
+                                'value'            => $invoice->get_state( 'edit' ),
253
+                                'options'          => $states,
254
+                                'data-allow-clear' => 'false',
255
+                                'select2'          => true,
256
+                                ),
257
+                                true
258
+                                );
259 259
 
260 260
                                 }
261 261
 
@@ -381,18 +381,18 @@  discard block
 block discarded – undo
381 381
     }
382 382
 
383 383
     /**
384
-	 * Save meta box data.
385
-	 *
386
-	 * @param int $post_id
387
-	 */
388
-	public static function save( $post_id ) {
384
+     * Save meta box data.
385
+     *
386
+     * @param int $post_id
387
+     */
388
+    public static function save( $post_id ) {
389 389
 
390 390
         // Prepare the invoice.
391 391
         $invoice = new WPInv_Invoice( $post_id );
392 392
 
393 393
         // Load new data.
394 394
         $invoice->set_props(
395
-			array(
395
+            array(
396 396
                 'template'       => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null,
397 397
                 'email_cc'       => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null,
398 398
                 'disable_taxes'  => ! empty( $_POST['disable_taxes'] ),
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
                 'due_date'       => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null,
416 416
                 'number'         => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null,
417 417
                 'status'         => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null,
418
-			)
418
+            )
419 419
         );
420 420
 
421 421
         // Discount code.
@@ -471,6 +471,6 @@  discard block
 block discarded – undo
471 471
         }
472 472
 
473 473
         // Fires after an invoice is saved.
474
-		do_action( 'wpinv_invoice_metabox_saved', $invoice );
475
-	}
474
+        do_action( 'wpinv_invoice_metabox_saved', $invoice );
475
+    }
476 476
 }
Please login to merge, or discard this patch.
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the invoice.
27
-        $invoice  = new WPInv_Invoice( $post );
28
-        $customer = $invoice->exists() ? $invoice->get_user_id( 'edit' ) : get_current_user_id();
29
-        $customer = new WP_User( $customer );
30
-        $display  = sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email );
31
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
27
+        $invoice  = new WPInv_Invoice($post);
28
+        $customer = $invoice->exists() ? $invoice->get_user_id('edit') : get_current_user_id();
29
+        $customer = new WP_User($customer);
30
+        $display  = sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email);
31
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
32 32
 
33 33
         ?>
34 34
 
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
                         <div class="col-12 col-sm-6">
44 44
                             <div id="getpaid-invoice-user-id-wrapper" class="form-group">
45 45
                                 <div>
46
-                                    <label for="post_author_override"><?php esc_html_e( 'Customer', 'invoicing' ); ?></label>
46
+                                    <label for="post_author_override"><?php esc_html_e('Customer', 'invoicing'); ?></label>
47 47
                                 </div>
48 48
                                 <div>
49
-                                    <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e( 'Search for a customer by email or name', 'invoicing' ); ?>">
50
-                                        <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo esc_html( $display ); ?> </option>)
49
+                                    <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e('Search for a customer by email or name', 'invoicing'); ?>">
50
+                                        <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo esc_html($display); ?> </option>)
51 51
                                     </select>
52 52
                                 </div>
53 53
                             </div>
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
                                             'type'        => 'text',
61 61
                                             'id'          => 'getpaid-invoice-new-user-email',
62 62
                                             'name'        => 'wpinv_email',
63
-                                            'label'       => __( 'Email', 'invoicing' ) . '<span class="required">*</span>',
63
+                                            'label'       => __('Email', 'invoicing') . '<span class="required">*</span>',
64 64
                                             'label_type'  => 'vertical',
65 65
                                             'placeholder' => '[email protected]',
66 66
                                             'class'       => 'form-control-sm',
@@ -71,18 +71,18 @@  discard block
 block discarded – undo
71 71
                             </div>
72 72
                         </div>
73 73
                         <div class="col-12 col-sm-6 form-group mt-sm-4">
74
-                            <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?>
74
+                            <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?>
75 75
                                 <a id="getpaid-invoice-fill-user-details" class="button button-small button-secondary" href="javascript:void(0)">
76 76
                                     <i aria-hidden="true" class="fa fa-refresh"></i>
77
-                                    <?php esc_html_e( 'Fill User Details', 'invoicing' ); ?>
77
+                                    <?php esc_html_e('Fill User Details', 'invoicing'); ?>
78 78
                                 </a>
79 79
                                 <a id="getpaid-invoice-create-new-user-button" class="button button-small button-secondary" href="javascript:void(0)">
80 80
                                     <i aria-hidden="true" class="fa fa-plus"></i>
81
-                                    <?php esc_html_e( 'Add New User', 'invoicing' ); ?>
81
+                                    <?php esc_html_e('Add New User', 'invoicing'); ?>
82 82
                                 </a>
83 83
                                 <a id="getpaid-invoice-cancel-create-new-user" class="button button-small button-secondary d-none" href="javascript:void(0)">
84 84
                                     <i aria-hidden="true" class="fa fa-close"></i>
85
-                                    <?php esc_html_e( 'Cancel', 'invoicing' ); ?>
85
+                                    <?php esc_html_e('Cancel', 'invoicing'); ?>
86 86
                                 </a>
87 87
                             <?php endif; ?>
88 88
                         </div>
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
                                         'type'        => 'text',
96 96
                                         'id'          => 'wpinv_first_name',
97 97
                                         'name'        => 'wpinv_first_name',
98
-                                        'label'       => __( 'First Name', 'invoicing' ),
98
+                                        'label'       => __('First Name', 'invoicing'),
99 99
                                         'label_type'  => 'vertical',
100 100
                                         'placeholder' => '',
101 101
                                         'class'       => 'form-control-sm',
102
-                                        'value'       => $invoice->get_first_name( 'edit' ),
102
+                                        'value'       => $invoice->get_first_name('edit'),
103 103
                                     ),
104 104
                                     true
105 105
                                 );
@@ -112,11 +112,11 @@  discard block
 block discarded – undo
112 112
                                         'type'        => 'text',
113 113
                                         'id'          => 'wpinv_last_name',
114 114
                                         'name'        => 'wpinv_last_name',
115
-                                        'label'       => __( 'Last Name', 'invoicing' ),
115
+                                        'label'       => __('Last Name', 'invoicing'),
116 116
                                         'label_type'  => 'vertical',
117 117
                                         'placeholder' => '',
118 118
                                         'class'       => 'form-control-sm',
119
-                                        'value'       => $invoice->get_last_name( 'edit' ),
119
+                                        'value'       => $invoice->get_last_name('edit'),
120 120
                                     ),
121 121
                                     true
122 122
                                 );
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
                                         'type'        => 'text',
133 133
                                         'id'          => 'wpinv_company',
134 134
                                         'name'        => 'wpinv_company',
135
-                                        'label'       => __( 'Company', 'invoicing' ),
135
+                                        'label'       => __('Company', 'invoicing'),
136 136
                                         'label_type'  => 'vertical',
137 137
                                         'placeholder' => '',
138 138
                                         'class'       => 'form-control-sm',
139
-                                        'value'       => $invoice->get_company( 'edit' ),
139
+                                        'value'       => $invoice->get_company('edit'),
140 140
                                     ),
141 141
                                     true
142 142
                                 );
@@ -149,11 +149,11 @@  discard block
 block discarded – undo
149 149
                                         'type'        => 'text',
150 150
                                         'id'          => 'wpinv_vat_number',
151 151
                                         'name'        => 'wpinv_vat_number',
152
-                                        'label'       => __( 'Vat Number', 'invoicing' ),
152
+                                        'label'       => __('Vat Number', 'invoicing'),
153 153
                                         'label_type'  => 'vertical',
154 154
                                         'placeholder' => '',
155 155
                                         'class'       => 'form-control-sm getpaid-recalculate-prices-on-change',
156
-                                        'value'       => $invoice->get_vat_number( 'edit' ),
156
+                                        'value'       => $invoice->get_vat_number('edit'),
157 157
                                     ),
158 158
                                     true
159 159
                                 );
@@ -169,11 +169,11 @@  discard block
 block discarded – undo
169 169
                                         'type'        => 'text',
170 170
                                         'id'          => 'wpinv_address',
171 171
                                         'name'        => 'wpinv_address',
172
-                                        'label'       => __( 'Address', 'invoicing' ),
172
+                                        'label'       => __('Address', 'invoicing'),
173 173
                                         'label_type'  => 'vertical',
174 174
                                         'placeholder' => '',
175 175
                                         'class'       => 'form-control-sm',
176
-                                        'value'       => $invoice->get_address( 'edit' ),
176
+                                        'value'       => $invoice->get_address('edit'),
177 177
                                     ),
178 178
                                     true
179 179
                                 );
@@ -186,11 +186,11 @@  discard block
 block discarded – undo
186 186
                                         'type'        => 'text',
187 187
                                         'id'          => 'wpinv_city',
188 188
                                         'name'        => 'wpinv_city',
189
-                                        'label'       => __( 'City', 'invoicing' ),
189
+                                        'label'       => __('City', 'invoicing'),
190 190
                                         'label_type'  => 'vertical',
191 191
                                         'placeholder' => '',
192 192
                                         'class'       => 'form-control-sm',
193
-                                        'value'       => $invoice->get_city( 'edit' ),
193
+                                        'value'       => $invoice->get_city('edit'),
194 194
                                     ),
195 195
                                     true
196 196
                                 );
@@ -205,11 +205,11 @@  discard block
 block discarded – undo
205 205
                                     array(
206 206
                                         'id'               => 'wpinv_country',
207 207
                                         'name'             => 'wpinv_country',
208
-                                        'label'            => __( 'Country', 'invoicing' ),
208
+                                        'label'            => __('Country', 'invoicing'),
209 209
                                         'label_type'       => 'vertical',
210
-                                        'placeholder'      => __( 'Choose a country', 'invoicing' ),
210
+                                        'placeholder'      => __('Choose a country', 'invoicing'),
211 211
                                         'class'            => 'form-control-sm getpaid-recalculate-prices-on-change',
212
-                                        'value'            => $invoice->get_country( 'edit' ),
212
+                                        'value'            => $invoice->get_country('edit'),
213 213
                                         'options'          => wpinv_get_country_list(),
214 214
                                         'data-allow-clear' => 'false',
215 215
                                         'select2'          => true,
@@ -221,20 +221,20 @@  discard block
 block discarded – undo
221 221
                         <div class="col-12 col-sm-6">
222 222
                             <?php
223 223
 
224
-                                $states = wpinv_get_country_states( $invoice->get_country( 'edit' ) );
224
+                                $states = wpinv_get_country_states($invoice->get_country('edit'));
225 225
 
226
-                                if ( empty( $states ) ) {
226
+                                if (empty($states)) {
227 227
 
228 228
 								aui()->input(
229 229
 								array(
230 230
 								'type'        => 'text',
231 231
 								'id'          => 'wpinv_state',
232 232
 								'name'        => 'wpinv_state',
233
-								'label'       => __( 'State', 'invoicing' ),
233
+								'label'       => __('State', 'invoicing'),
234 234
 								'label_type'  => 'vertical',
235 235
 								'placeholder' => '',
236 236
 								'class'       => 'form-control-sm',
237
-								'value'       => $invoice->get_state( 'edit' ),
237
+								'value'       => $invoice->get_state('edit'),
238 238
 								),
239 239
 								true
240 240
 							);
@@ -245,11 +245,11 @@  discard block
 block discarded – undo
245 245
 								array(
246 246
 								'id'               => 'wpinv_state',
247 247
 								'name'             => 'wpinv_state',
248
-								'label'            => __( 'State', 'invoicing' ),
248
+								'label'            => __('State', 'invoicing'),
249 249
 								'label_type'       => 'vertical',
250
-								'placeholder'      => __( 'Select a state', 'invoicing' ),
250
+								'placeholder'      => __('Select a state', 'invoicing'),
251 251
 								'class'            => 'form-control-sm',
252
-								'value'            => $invoice->get_state( 'edit' ),
252
+								'value'            => $invoice->get_state('edit'),
253 253
 								'options'          => $states,
254 254
 								'data-allow-clear' => 'false',
255 255
 								'select2'          => true,
@@ -271,11 +271,11 @@  discard block
 block discarded – undo
271 271
                                         'type'        => 'text',
272 272
                                         'id'          => 'wpinv_zip',
273 273
                                         'name'        => 'wpinv_zip',
274
-                                        'label'       => __( 'Zip / Postal Code', 'invoicing' ),
274
+                                        'label'       => __('Zip / Postal Code', 'invoicing'),
275 275
                                         'label_type'  => 'vertical',
276 276
                                         'placeholder' => '',
277 277
                                         'class'       => 'form-control-sm',
278
-                                        'value'       => $invoice->get_zip( 'edit' ),
278
+                                        'value'       => $invoice->get_zip('edit'),
279 279
                                     ),
280 280
                                     true
281 281
                                 );
@@ -288,11 +288,11 @@  discard block
 block discarded – undo
288 288
                                         'type'        => 'text',
289 289
                                         'id'          => 'wpinv_phone',
290 290
                                         'name'        => 'wpinv_phone',
291
-                                        'label'       => __( 'Phone', 'invoicing' ),
291
+                                        'label'       => __('Phone', 'invoicing'),
292 292
                                         'label_type'  => 'vertical',
293 293
                                         'placeholder' => '',
294 294
                                         'class'       => 'form-control-sm',
295
-                                        'value'       => $invoice->get_phone( 'edit' ),
295
+                                        'value'       => $invoice->get_phone('edit'),
296 296
                                     ),
297 297
                                     true
298 298
                                 );
@@ -300,8 +300,8 @@  discard block
 block discarded – undo
300 300
                         </div>
301 301
                     </div>
302 302
 
303
-                    <?php if ( ! apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) : ?>
304
-                        <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?>
303
+                    <?php if (!apply_filters('getpaid_use_new_invoice_items_metabox', false)) : ?>
304
+                        <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?>
305 305
 
306 306
                         <div class="row">
307 307
                             <div class="col-12 col-sm-6">
@@ -310,14 +310,14 @@  discard block
 block discarded – undo
310 310
                                         array(
311 311
                                             'id'          => 'wpinv_template',
312 312
                                             'name'        => 'wpinv_template',
313
-                                            'label'       => __( 'Template', 'invoicing' ),
313
+                                            'label'       => __('Template', 'invoicing'),
314 314
                                             'label_type'  => 'vertical',
315
-                                            'placeholder' => __( 'Choose a template', 'invoicing' ),
315
+                                            'placeholder' => __('Choose a template', 'invoicing'),
316 316
                                             'class'       => 'form-control-sm',
317
-                                            'value'       => $invoice->get_template( 'edit' ),
317
+                                            'value'       => $invoice->get_template('edit'),
318 318
                                             'options'     => array(
319
-                                                'quantity' => __( 'Quantity', 'invoicing' ),
320
-                                                'hours'    => __( 'Hours', 'invoicing' ),
319
+                                                'quantity' => __('Quantity', 'invoicing'),
320
+                                                'hours'    => __('Hours', 'invoicing'),
321 321
                                                 //'amount'   => __( 'Amount Only', 'invoicing' ),
322 322
                                             ),
323 323
                                             'data-allow-clear' => 'false',
@@ -335,11 +335,11 @@  discard block
 block discarded – undo
335 335
                                         array(
336 336
                                             'id'          => 'wpinv_currency',
337 337
                                             'name'        => 'wpinv_currency',
338
-                                            'label'       => __( 'Currency', 'invoicing' ),
338
+                                            'label'       => __('Currency', 'invoicing'),
339 339
                                             'label_type'  => 'vertical',
340
-                                            'placeholder' => __( 'Select Invoice Currency', 'invoicing' ),
340
+                                            'placeholder' => __('Select Invoice Currency', 'invoicing'),
341 341
                                             'class'       => 'form-control-sm getpaid-recalculate-prices-on-change',
342
-                                            'value'       => $invoice->get_currency( 'edit' ),
342
+                                            'value'       => $invoice->get_currency('edit'),
343 343
                                             'required'    => false,
344 344
                                             'data-allow-clear' => 'false',
345 345
                                             'select2'     => true,
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
                             </div>
353 353
                         </div>
354 354
 
355
-                        <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?>
355
+                        <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?>
356 356
                     <?php endif; ?>
357 357
 
358 358
                     <div class="row">
@@ -363,11 +363,11 @@  discard block
 block discarded – undo
363 363
                                         'type'        => 'text',
364 364
                                         'id'          => 'wpinv_company_id',
365 365
                                         'name'        => 'wpinv_company_id',
366
-                                        'label'       => __( 'Company ID', 'invoicing' ),
366
+                                        'label'       => __('Company ID', 'invoicing'),
367 367
                                         'label_type'  => 'vertical',
368 368
                                         'placeholder' => '',
369 369
                                         'class'       => 'form-control-sm',
370
-                                        'value'       => $invoice->get_company_id( 'edit' ),
370
+                                        'value'       => $invoice->get_company_id('edit'),
371 371
                                     ),
372 372
                                     true
373 373
                                 );
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
                         </div>
376 376
                     </div>
377 377
 
378
-                    <?php do_action( 'getpaid_after_metabox_invoice_address', $invoice ); ?>
378
+                    <?php do_action('getpaid_after_metabox_invoice_address', $invoice); ?>
379 379
             </div>
380 380
         <?php
381 381
     }
@@ -385,51 +385,51 @@  discard block
 block discarded – undo
385 385
 	 *
386 386
 	 * @param int $post_id
387 387
 	 */
388
-	public static function save( $post_id ) {
388
+	public static function save($post_id) {
389 389
 
390 390
         // Prepare the invoice.
391
-        $invoice = new WPInv_Invoice( $post_id );
391
+        $invoice = new WPInv_Invoice($post_id);
392 392
 
393 393
         // Load new data.
394 394
         $invoice->set_props(
395 395
 			array(
396
-                'template'       => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null,
397
-                'email_cc'       => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null,
398
-                'disable_taxes'  => ! empty( $_POST['disable_taxes'] ),
399
-                'currency'       => isset( $_POST['wpinv_currency'] ) ? wpinv_clean( $_POST['wpinv_currency'] ) : null,
400
-                'gateway'        => ( $invoice->needs_payment() && isset( $_POST['wpinv_gateway'] ) ) ? wpinv_clean( $_POST['wpinv_gateway'] ) : null,
401
-                'address'        => isset( $_POST['wpinv_address'] ) ? wpinv_clean( $_POST['wpinv_address'] ) : null,
402
-                'vat_number'     => isset( $_POST['wpinv_vat_number'] ) ? wpinv_clean( $_POST['wpinv_vat_number'] ) : null,
403
-                'company'        => isset( $_POST['wpinv_company'] ) ? wpinv_clean( $_POST['wpinv_company'] ) : null,
404
-                'company_id'     => isset( $_POST['wpinv_company_id'] ) ? wpinv_clean( $_POST['wpinv_company_id'] ) : null,
405
-                'zip'            => isset( $_POST['wpinv_zip'] ) ? wpinv_clean( $_POST['wpinv_zip'] ) : null,
406
-                'state'          => isset( $_POST['wpinv_state'] ) ? wpinv_clean( $_POST['wpinv_state'] ) : null,
407
-                'city'           => isset( $_POST['wpinv_city'] ) ? wpinv_clean( $_POST['wpinv_city'] ) : null,
408
-                'country'        => isset( $_POST['wpinv_country'] ) ? wpinv_clean( $_POST['wpinv_country'] ) : null,
409
-                'phone'          => isset( $_POST['wpinv_phone'] ) ? wpinv_clean( $_POST['wpinv_phone'] ) : null,
410
-                'first_name'     => isset( $_POST['wpinv_first_name'] ) ? wpinv_clean( $_POST['wpinv_first_name'] ) : null,
411
-                'last_name'      => isset( $_POST['wpinv_last_name'] ) ? wpinv_clean( $_POST['wpinv_last_name'] ) : null,
412
-                'author'         => isset( $_POST['post_author_override'] ) ? wpinv_clean( $_POST['post_author_override'] ) : null,
413
-                'date_created'   => isset( $_POST['date_created'] ) ? wpinv_clean( $_POST['date_created'] ) : null,
414
-                'date_completed' => isset( $_POST['wpinv_date_completed'] ) ? wpinv_clean( $_POST['wpinv_date_completed'] ) : null,
415
-                'due_date'       => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null,
416
-                'number'         => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null,
417
-                'status'         => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null,
396
+                'template'       => isset($_POST['wpinv_template']) ? wpinv_clean($_POST['wpinv_template']) : null,
397
+                'email_cc'       => isset($_POST['wpinv_cc']) ? wpinv_clean($_POST['wpinv_cc']) : null,
398
+                'disable_taxes'  => !empty($_POST['disable_taxes']),
399
+                'currency'       => isset($_POST['wpinv_currency']) ? wpinv_clean($_POST['wpinv_currency']) : null,
400
+                'gateway'        => ($invoice->needs_payment() && isset($_POST['wpinv_gateway'])) ? wpinv_clean($_POST['wpinv_gateway']) : null,
401
+                'address'        => isset($_POST['wpinv_address']) ? wpinv_clean($_POST['wpinv_address']) : null,
402
+                'vat_number'     => isset($_POST['wpinv_vat_number']) ? wpinv_clean($_POST['wpinv_vat_number']) : null,
403
+                'company'        => isset($_POST['wpinv_company']) ? wpinv_clean($_POST['wpinv_company']) : null,
404
+                'company_id'     => isset($_POST['wpinv_company_id']) ? wpinv_clean($_POST['wpinv_company_id']) : null,
405
+                'zip'            => isset($_POST['wpinv_zip']) ? wpinv_clean($_POST['wpinv_zip']) : null,
406
+                'state'          => isset($_POST['wpinv_state']) ? wpinv_clean($_POST['wpinv_state']) : null,
407
+                'city'           => isset($_POST['wpinv_city']) ? wpinv_clean($_POST['wpinv_city']) : null,
408
+                'country'        => isset($_POST['wpinv_country']) ? wpinv_clean($_POST['wpinv_country']) : null,
409
+                'phone'          => isset($_POST['wpinv_phone']) ? wpinv_clean($_POST['wpinv_phone']) : null,
410
+                'first_name'     => isset($_POST['wpinv_first_name']) ? wpinv_clean($_POST['wpinv_first_name']) : null,
411
+                'last_name'      => isset($_POST['wpinv_last_name']) ? wpinv_clean($_POST['wpinv_last_name']) : null,
412
+                'author'         => isset($_POST['post_author_override']) ? wpinv_clean($_POST['post_author_override']) : null,
413
+                'date_created'   => isset($_POST['date_created']) ? wpinv_clean($_POST['date_created']) : null,
414
+                'date_completed' => isset($_POST['wpinv_date_completed']) ? wpinv_clean($_POST['wpinv_date_completed']) : null,
415
+                'due_date'       => isset($_POST['wpinv_due_date']) ? wpinv_clean($_POST['wpinv_due_date']) : null,
416
+                'number'         => isset($_POST['wpinv_number']) ? wpinv_clean($_POST['wpinv_number']) : null,
417
+                'status'         => isset($_POST['wpinv_status']) ? wpinv_clean($_POST['wpinv_status']) : null,
418 418
 			)
419 419
         );
420 420
 
421 421
         // Discount code.
422
-        if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
422
+        if (!$invoice->is_paid() && !$invoice->is_refunded()) {
423 423
 
424
-            if ( isset( $_POST['wpinv_discount_code'] ) ) {
425
-                $invoice->set_discount_code( wpinv_clean( $_POST['wpinv_discount_code'] ) );
424
+            if (isset($_POST['wpinv_discount_code'])) {
425
+                $invoice->set_discount_code(wpinv_clean($_POST['wpinv_discount_code']));
426 426
             }
427 427
 
428
-            $discount = new WPInv_Discount( $invoice->get_discount_code() );
429
-            if ( $discount->exists() ) {
430
-                $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
428
+            $discount = new WPInv_Discount($invoice->get_discount_code());
429
+            if ($discount->exists()) {
430
+                $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
431 431
             } else {
432
-                $invoice->remove_discount( 'discount_code' );
432
+                $invoice->remove_discount('discount_code');
433 433
             }
434 434
 
435 435
             // Recalculate totals.
@@ -438,16 +438,16 @@  discard block
 block discarded – undo
438 438
         }
439 439
 
440 440
         // If we're creating a new user...
441
-        if ( ! empty( $_POST['wpinv_new_user'] ) && is_email( stripslashes( $_POST['wpinv_email'] ) ) ) {
441
+        if (!empty($_POST['wpinv_new_user']) && is_email(stripslashes($_POST['wpinv_email']))) {
442 442
 
443 443
             // Attempt to create the user.
444
-            $user = wpinv_create_user( sanitize_email( stripslashes( $_POST['wpinv_email'] ) ) );
444
+            $user = wpinv_create_user(sanitize_email(stripslashes($_POST['wpinv_email'])));
445 445
 
446 446
             // If successful, update the invoice author.
447
-            if ( is_numeric( $user ) ) {
448
-                $invoice->set_author( $user );
447
+            if (is_numeric($user)) {
448
+                $invoice->set_author($user);
449 449
             } else {
450
-                wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ );
450
+                wpinv_error_log($user->get_error_message(), __('Invoice add new user', 'invoicing'), __FILE__, __LINE__);
451 451
             }
452 452
         }
453 453
 
@@ -461,16 +461,16 @@  discard block
 block discarded – undo
461 461
         $GLOBALS['wpinv_skip_invoice_notification'] = false;
462 462
 
463 463
         // (Maybe) send new user notification.
464
-        $should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
465
-        if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) {
466
-            wp_send_new_user_notifications( $user, 'user' );
464
+        $should_send_notification = wpinv_get_option('disable_new_user_emails');
465
+        if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', empty($should_send_notification))) {
466
+            wp_send_new_user_notifications($user, 'user');
467 467
         }
468 468
 
469
-        if ( ! empty( $_POST['send_to_customer'] ) && ! $invoice->is_draft() ) {
470
-            getpaid()->get( 'invoice_emails' )->user_invoice( $invoice, true );
469
+        if (!empty($_POST['send_to_customer']) && !$invoice->is_draft()) {
470
+            getpaid()->get('invoice_emails')->user_invoice($invoice, true);
471 471
         }
472 472
 
473 473
         // Fires after an invoice is saved.
474
-		do_action( 'wpinv_invoice_metabox_saved', $invoice );
474
+		do_action('wpinv_invoice_metabox_saved', $invoice);
475 475
 	}
476 476
 }
Please login to merge, or discard this patch.
includes/wpinv-address-functions.php 2 patches
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@  discard block
 block discarded – undo
13 13
 
14 14
 
15 15
 function wpinv_get_default_country() {
16
-	$country = wpinv_get_option( 'default_country', 'UK' );
16
+    $country = wpinv_get_option( 'default_country', 'UK' );
17 17
 
18
-	return apply_filters( 'wpinv_default_country', $country );
18
+    return apply_filters( 'wpinv_default_country', $country );
19 19
 }
20 20
 
21 21
 /**
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
  */
37 37
 function wpinv_sanitize_country( $country ) {
38 38
 
39
-	// Enure the country is specified
39
+    // Enure the country is specified
40 40
     if ( empty( $country ) ) {
41 41
         $country = wpinv_get_default_country();
42 42
     }
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 }
67 67
 
68 68
 function wpinv_get_default_state() {
69
-	$state = wpinv_get_option( 'default_state', '' );
69
+    $state = wpinv_get_option( 'default_state', '' );
70 70
 
71
-	return apply_filters( 'wpinv_default_state', $state );
71
+    return apply_filters( 'wpinv_default_state', $state );
72 72
 }
73 73
 
74 74
 function wpinv_state_name( $state_code = '', $country_code = '' ) {
@@ -303,11 +303,11 @@  discard block
 block discarded – undo
303 303
 
304 304
     $country = wpinv_sanitize_country( $country );
305 305
 
306
-	foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) {
307
-		if ( false !== array_search( $country, $countries, true ) ) {
308
-			return $continent_code;
309
-		}
310
-	}
306
+    foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) {
307
+        if ( false !== array_search( $country, $countries, true ) ) {
308
+            return $continent_code;
309
+        }
310
+    }
311 311
 
312 312
     return '';
313 313
 
@@ -599,31 +599,31 @@  discard block
 block discarded – undo
599 599
 }
600 600
 
601 601
 function wpinv_get_states_field() {
602
-	if ( empty( $_POST['country'] ) ) {
603
-		$_POST['country'] = wpinv_get_default_country();
604
-	}
605
-	$states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) );
602
+    if ( empty( $_POST['country'] ) ) {
603
+        $_POST['country'] = wpinv_get_default_country();
604
+    }
605
+    $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) );
606 606
 
607
-	if ( ! empty( $states ) ) {
608
-		$sanitized_field_name = sanitize_text_field( $_POST['field_name'] );
607
+    if ( ! empty( $states ) ) {
608
+        $sanitized_field_name = sanitize_text_field( $_POST['field_name'] );
609 609
 
610 610
         $class  = isset( $_POST['class'] ) ? esc_attr( sanitize_text_field( $_POST['class'] ) ) : '';
611 611
         $class .= " $sanitized_field_name getpaid_js_field-state custom-select wpinv-select wpi_select2";
612 612
 
613 613
         $args  = array(
614
-			'name'             => $sanitized_field_name,
615
-			'id'               => $sanitized_field_name,
616
-			'class'            => implode( ' ', array_unique( explode( ' ', $class ) ) ),
617
-			'options'          => array_merge( array( '' => '' ), $states ),
618
-			'show_option_all'  => false,
619
-			'show_option_none' => false,
620
-		);
621
-
622
-		wpinv_html_select( $args );
623
-
624
-	} else {
625
-		echo 'nostates';
626
-	}
614
+            'name'             => $sanitized_field_name,
615
+            'id'               => $sanitized_field_name,
616
+            'class'            => implode( ' ', array_unique( explode( ' ', $class ) ) ),
617
+            'options'          => array_merge( array( '' => '' ), $states ),
618
+            'show_option_all'  => false,
619
+            'show_option_none' => false,
620
+        );
621
+
622
+        wpinv_html_select( $args );
623
+
624
+    } else {
625
+        echo 'nostates';
626
+    }
627 627
 
628 628
 }
629 629
 
@@ -642,47 +642,47 @@  discard block
 block discarded – undo
642 642
  */
643 643
 function wpinv_get_address_formats() {
644 644
 
645
-		return apply_filters(
645
+        return apply_filters(
646 646
             'wpinv_localisation_address_formats',
647
-			array(
648
-				'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}",
649
-				'AU'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}",
650
-				'AT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
651
-				'BE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
652
-				'CA'      => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{state_code}}&nbsp;&nbsp;{{zip}}\n{{country}}",
653
-				'CH'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
654
-				'CL'      => "{{company}}\n{{name}}\n{{address}}\n{{state}}\n{{zip}} {{city}}\n{{country}}",
655
-				'CN'      => "{{country}} {{zip}}\n{{state}}, {{city}}, {{address}}\n{{company}}\n{{name}}",
656
-				'CZ'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
657
-				'DE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
658
-				'EE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
659
-				'FI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
660
-				'DK'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
661
-				'FR'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city_upper}}\n{{country}}",
662
-				'HK'      => "{{company}}\n{{first_name}} {{last_name_upper}}\n{{address}}\n{{city_upper}}\n{{state_upper}}\n{{country}}",
663
-				'HU'      => "{{name}}\n{{company}}\n{{city}}\n{{address}}\n{{zip}}\n{{country}}",
664
-				'IN'      => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{zip}}\n{{state}}, {{country}}",
665
-				'IS'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
666
-				'IT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}}\n{{city}}\n{{state_upper}}\n{{country}}",
667
-				'JP'      => "{{zip}}\n{{state}} {{city}} {{address}}\n{{company}}\n{{last_name}} {{first_name}}\n{{country}}",
668
-				'TW'      => "{{company}}\n{{last_name}} {{first_name}}\n{{address}}\n{{state}}, {{city}} {{zip}}\n{{country}}",
669
-				'LI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
670
-				'NL'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
671
-				'NZ'      => "{{name}}\n{{company}}\n{{address}}\n{{city}} {{zip}}\n{{country}}",
672
-				'NO'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
673
-				'PL'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
674
-				'PT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
675
-				'SK'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
676
-				'RS'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
677
-				'SI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
678
-				'ES'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{state}}\n{{country}}",
679
-				'SE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
680
-				'TR'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}} {{state}}\n{{country}}",
681
-				'UG'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}, {{country}}",
682
-				'US'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}, {{state_code}} {{zip}}\n{{country}}",
683
-				'VN'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{country}}",
684
-			)
685
-		);
647
+            array(
648
+                'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}",
649
+                'AU'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}",
650
+                'AT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
651
+                'BE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
652
+                'CA'      => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{state_code}}&nbsp;&nbsp;{{zip}}\n{{country}}",
653
+                'CH'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
654
+                'CL'      => "{{company}}\n{{name}}\n{{address}}\n{{state}}\n{{zip}} {{city}}\n{{country}}",
655
+                'CN'      => "{{country}} {{zip}}\n{{state}}, {{city}}, {{address}}\n{{company}}\n{{name}}",
656
+                'CZ'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
657
+                'DE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
658
+                'EE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
659
+                'FI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
660
+                'DK'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
661
+                'FR'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city_upper}}\n{{country}}",
662
+                'HK'      => "{{company}}\n{{first_name}} {{last_name_upper}}\n{{address}}\n{{city_upper}}\n{{state_upper}}\n{{country}}",
663
+                'HU'      => "{{name}}\n{{company}}\n{{city}}\n{{address}}\n{{zip}}\n{{country}}",
664
+                'IN'      => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{zip}}\n{{state}}, {{country}}",
665
+                'IS'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
666
+                'IT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}}\n{{city}}\n{{state_upper}}\n{{country}}",
667
+                'JP'      => "{{zip}}\n{{state}} {{city}} {{address}}\n{{company}}\n{{last_name}} {{first_name}}\n{{country}}",
668
+                'TW'      => "{{company}}\n{{last_name}} {{first_name}}\n{{address}}\n{{state}}, {{city}} {{zip}}\n{{country}}",
669
+                'LI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
670
+                'NL'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
671
+                'NZ'      => "{{name}}\n{{company}}\n{{address}}\n{{city}} {{zip}}\n{{country}}",
672
+                'NO'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
673
+                'PL'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
674
+                'PT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
675
+                'SK'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
676
+                'RS'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
677
+                'SI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
678
+                'ES'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{state}}\n{{country}}",
679
+                'SE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
680
+                'TR'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}} {{state}}\n{{country}}",
681
+                'UG'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}, {{country}}",
682
+                'US'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}, {{state_code}} {{zip}}\n{{country}}",
683
+                'VN'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{country}}",
684
+            )
685
+        );
686 686
 }
687 687
 
688 688
 /**
@@ -699,21 +699,21 @@  discard block
 block discarded – undo
699 699
     }
700 700
 
701 701
     // Get all formats.
702
-	$formats = wpinv_get_address_formats();
702
+    $formats = wpinv_get_address_formats();
703 703
 
704
-	// Get format for the specified country.
705
-	$format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default'];
704
+    // Get format for the specified country.
705
+    $format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default'];
706 706
 
707 707
     /**
708
-	 * Filters the address format to use on Invoices.
708
+     * Filters the address format to use on Invoices.
709 709
      *
710 710
      * New lines will be replaced by a `br` element. Double new lines will be replaced by a paragraph. HTML tags are allowed.
711
-	 *
712
-	 * @since 1.0.13
713
-	 *
714
-	 * @param string $format  The address format to use.
711
+     *
712
+     * @since 1.0.13
713
+     *
714
+     * @param string $format  The address format to use.
715 715
      * @param string $country The country who's address format is being retrieved.
716
-	 */
716
+     */
717 717
     return apply_filters( 'wpinv_get_full_address_format', $format, $country );
718 718
 }
719 719
 
@@ -734,8 +734,8 @@  discard block
 block discarded – undo
734 734
         'country'    => '',
735 735
         'zip'        => '',
736 736
         'first_name' => '',
737
-		'last_name'  => '',
738
-		'company'    => '',
737
+        'last_name'  => '',
738
+        'company'    => '',
739 739
     );
740 740
 
741 741
     $args    = map_deep( wp_parse_args( $billing_details, $default_args ), 'trim' );
@@ -756,14 +756,14 @@  discard block
 block discarded – undo
756 756
     $args['country_code'] = $country;
757 757
 
758 758
     /**
759
-	 * Filters the address format replacements to use on Invoices.
759
+     * Filters the address format replacements to use on Invoices.
760
+     *
761
+     *
762
+     * @since 1.0.13
760 763
      *
761
-	 *
762
-	 * @since 1.0.13
763
-	 *
764
-	 * @param array $replacements  The address replacements to use.
764
+     * @param array $replacements  The address replacements to use.
765 765
      * @param array $billing_details  The billing details to use.
766
-	 */
766
+     */
767 767
     $replacements = apply_filters( 'wpinv_get_invoice_address_replacements', $args, $billing_details );
768 768
 
769 769
     $return = array();
@@ -786,5 +786,5 @@  discard block
 block discarded – undo
786 786
  * @return string
787 787
  */
788 788
 function wpinv_trim_formatted_address_line( $line ) {
789
-	return trim( $line, ', ' );
789
+    return trim( $line, ', ' );
790 790
 }
Please login to merge, or discard this patch.
Spacing   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // MUST have WordPress.
10
-if ( ! defined( 'WPINC' ) ) {
10
+if (!defined('WPINC')) {
11 11
     exit;
12 12
 }
13 13
 
14 14
 
15 15
 function wpinv_get_default_country() {
16
-	$country = wpinv_get_option( 'default_country', 'UK' );
16
+	$country = wpinv_get_option('default_country', 'UK');
17 17
 
18
-	return apply_filters( 'wpinv_default_country', $country );
18
+	return apply_filters('wpinv_default_country', $country);
19 19
 }
20 20
 
21 21
 /**
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return string
25 25
  */
26
-function getpaid_get_ip_country( $ip_address = '' ) {
27
-    $country = GetPaid_Geolocation::geolocate_ip( $ip_address, true );
26
+function getpaid_get_ip_country($ip_address = '') {
27
+    $country = GetPaid_Geolocation::geolocate_ip($ip_address, true);
28 28
     return $country['country'];
29 29
 }
30 30
 
@@ -34,59 +34,59 @@  discard block
 block discarded – undo
34 34
  * @param string $country The country code to sanitize
35 35
  * @return array
36 36
  */
37
-function wpinv_sanitize_country( $country ) {
37
+function wpinv_sanitize_country($country) {
38 38
 
39 39
 	// Enure the country is specified
40
-    if ( empty( $country ) ) {
40
+    if (empty($country)) {
41 41
         $country = wpinv_get_default_country();
42 42
     }
43
-    return trim( wpinv_utf8_strtoupper( $country ) );
43
+    return trim(wpinv_utf8_strtoupper($country));
44 44
 
45 45
 }
46 46
 
47
-function wpinv_is_base_country( $country ) {
47
+function wpinv_is_base_country($country) {
48 48
     $base_country = wpinv_get_default_country();
49 49
 
50
-    if ( $base_country === 'UK' ) {
50
+    if ($base_country === 'UK') {
51 51
         $base_country = 'GB';
52 52
     }
53
-    if ( $country == 'UK' ) {
53
+    if ($country == 'UK') {
54 54
         $country = 'GB';
55 55
     }
56 56
 
57
-    return ( $country && $country === $base_country ) ? true : false;
57
+    return ($country && $country === $base_country) ? true : false;
58 58
 }
59 59
 
60
-function wpinv_country_name( $country_code = '' ) {
60
+function wpinv_country_name($country_code = '') {
61 61
     $countries = wpinv_get_country_list();
62 62
     $country_code = $country_code == 'UK' ? 'GB' : $country_code;
63
-    $country = isset( $countries[ $country_code ] ) ? $countries[ $country_code ] : $country_code;
63
+    $country = isset($countries[$country_code]) ? $countries[$country_code] : $country_code;
64 64
 
65
-    return apply_filters( 'wpinv_country_name', $country, $country_code );
65
+    return apply_filters('wpinv_country_name', $country, $country_code);
66 66
 }
67 67
 
68 68
 function wpinv_get_default_state() {
69
-	$state = wpinv_get_option( 'default_state', '' );
69
+	$state = wpinv_get_option('default_state', '');
70 70
 
71
-	return apply_filters( 'wpinv_default_state', $state );
71
+	return apply_filters('wpinv_default_state', $state);
72 72
 }
73 73
 
74
-function wpinv_state_name( $state_code = '', $country_code = '' ) {
74
+function wpinv_state_name($state_code = '', $country_code = '') {
75 75
     $state = $state_code;
76 76
 
77
-    if ( ! empty( $country_code ) ) {
78
-        $states = wpinv_get_country_states( $country_code );
77
+    if (!empty($country_code)) {
78
+        $states = wpinv_get_country_states($country_code);
79 79
 
80
-        $state = ! empty( $states ) && isset( $states[ $state_code ] ) ? $states[ $state_code ] : $state;
80
+        $state = !empty($states) && isset($states[$state_code]) ? $states[$state_code] : $state;
81 81
     }
82 82
 
83
-    return apply_filters( 'wpinv_state_name', $state, $state_code, $country_code );
83
+    return apply_filters('wpinv_state_name', $state, $state_code, $country_code);
84 84
 }
85 85
 
86 86
 function wpinv_store_address() {
87
-    $address = wpinv_get_option( 'store_address', '' );
87
+    $address = wpinv_get_option('store_address', '');
88 88
 
89
-    return apply_filters( 'wpinv_store_address', $address );
89
+    return apply_filters('wpinv_store_address', $address);
90 90
 }
91 91
 
92 92
 /**
@@ -94,24 +94,24 @@  discard block
 block discarded – undo
94 94
  *
95 95
  * @param WPInv_Invoice $invoice
96 96
  */
97
-function getpaid_maybe_add_default_address( &$invoice ) {
97
+function getpaid_maybe_add_default_address(&$invoice) {
98 98
 
99 99
     $user_id = $invoice->get_user_id();
100 100
 
101 101
     // Abort if the invoice belongs to no one.
102
-    if ( empty( $user_id ) ) {
102
+    if (empty($user_id)) {
103 103
         return;
104 104
     }
105 105
 
106 106
     // Fill in defaults whenever necessary.
107
-    foreach ( wpinv_get_user_address( $user_id ) as $key => $value ) {
107
+    foreach (wpinv_get_user_address($user_id) as $key => $value) {
108 108
 
109
-        if ( is_callable( $invoice, "get_$key" ) ) {
110
-            $current = call_user_func( array( $invoice, "get_$key" ) );
109
+        if (is_callable($invoice, "get_$key")) {
110
+            $current = call_user_func(array($invoice, "get_$key"));
111 111
 
112
-            if ( empty( $current ) ) {
112
+            if (empty($current)) {
113 113
                 $method = "set_$key";
114
-                $invoice->$method( $value );
114
+                $invoice->$method($value);
115 115
             }
116 116
 }
117 117
 }
@@ -128,22 +128,22 @@  discard block
 block discarded – undo
128 128
     $address_fields = apply_filters(
129 129
         'getpaid_user_address_fields',
130 130
         array(
131
-            'first_name' => __( 'First Name', 'invoicing' ),
132
-            'last_name'  => __( 'Last Name', 'invoicing' ),
133
-            'address'    => __( 'Address', 'invoicing' ),
134
-            'city'       => __( 'City', 'invoicing' ),
135
-            'country'    => __( 'Country', 'invoicing' ),
136
-            'state'      => __( 'State', 'invoicing' ),
137
-            'zip'        => __( 'Zip/Postal Code', 'invoicing' ),
138
-            'phone'      => __( 'Phone Number', 'invoicing' ),
139
-            'company'    => __( 'Company', 'invoicing' ),
140
-            'company_id' => __( 'Company ID', 'invoicing' ),
141
-            'vat_number' => __( 'VAT Number', 'invoicing' ),
131
+            'first_name' => __('First Name', 'invoicing'),
132
+            'last_name'  => __('Last Name', 'invoicing'),
133
+            'address'    => __('Address', 'invoicing'),
134
+            'city'       => __('City', 'invoicing'),
135
+            'country'    => __('Country', 'invoicing'),
136
+            'state'      => __('State', 'invoicing'),
137
+            'zip'        => __('Zip/Postal Code', 'invoicing'),
138
+            'phone'      => __('Phone Number', 'invoicing'),
139
+            'company'    => __('Company', 'invoicing'),
140
+            'company_id' => __('Company ID', 'invoicing'),
141
+            'vat_number' => __('VAT Number', 'invoicing'),
142 142
         )
143 143
     );
144 144
 
145
-    if ( ! wpinv_use_taxes() && isset( $address_fields['vat_number'] ) ) {
146
-        unset( $address_fields['vat_number'] );
145
+    if (!wpinv_use_taxes() && isset($address_fields['vat_number'])) {
146
+        unset($address_fields['vat_number']);
147 147
     }
148 148
 
149 149
     return $address_fields;
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
  *
155 155
  * @return bool
156 156
  */
157
-function getpaid_is_address_field_whitelisted( $key ) {
158
-    return array_key_exists( $key, getpaid_user_address_fields() );
157
+function getpaid_is_address_field_whitelisted($key) {
158
+    return array_key_exists($key, getpaid_user_address_fields());
159 159
 }
160 160
 
161 161
 /**
@@ -165,30 +165,30 @@  discard block
 block discarded – undo
165 165
  *
166 166
  * @param WPInv_Invoice $invoice
167 167
  */
168
-function getpaid_save_invoice_user_address( $invoice ) {
168
+function getpaid_save_invoice_user_address($invoice) {
169 169
 
170 170
     // Retrieve the invoice.
171
-    $invoice = wpinv_get_invoice( $invoice );
171
+    $invoice = wpinv_get_invoice($invoice);
172 172
 
173 173
     // Abort if it does not exist.
174
-    if ( empty( $invoice ) || $invoice->is_renewal() ) {
174
+    if (empty($invoice) || $invoice->is_renewal()) {
175 175
         return;
176 176
     }
177 177
 
178
-    foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
178
+    foreach (array_keys(getpaid_user_address_fields()) as $field) {
179 179
 
180
-        if ( is_callable( array( $invoice, "get_$field" ) ) ) {
181
-            $value = call_user_func( array( $invoice, "get_$field" ) );
180
+        if (is_callable(array($invoice, "get_$field"))) {
181
+            $value = call_user_func(array($invoice, "get_$field"));
182 182
 
183 183
             // Only save if it is not empty.
184
-            if ( ! empty( $value ) ) {
185
-                update_user_meta( $invoice->get_user_id(), '_wpinv_' . $field, $value );
184
+            if (!empty($value)) {
185
+                update_user_meta($invoice->get_user_id(), '_wpinv_' . $field, $value);
186 186
             }
187 187
 }
188 188
 }
189 189
 
190 190
 }
191
-add_action( 'getpaid_checkout_invoice_updated', 'getpaid_save_invoice_user_address' );
191
+add_action('getpaid_checkout_invoice_updated', 'getpaid_save_invoice_user_address');
192 192
 
193 193
 /**
194 194
  * Retrieves a saved user address.
@@ -196,14 +196,14 @@  discard block
 block discarded – undo
196 196
  * @param int $user_id The user id whose address we should get. Defaults to the current user id.
197 197
  * @return array
198 198
  */
199
-function wpinv_get_user_address( $user_id = 0 ) {
199
+function wpinv_get_user_address($user_id = 0) {
200 200
 
201 201
     // Prepare the user id.
202
-    $user_id   = empty( $user_id ) ? get_current_user_id() : $user_id;
203
-    $user_info = get_userdata( $user_id );
202
+    $user_id   = empty($user_id) ? get_current_user_id() : $user_id;
203
+    $user_info = get_userdata($user_id);
204 204
 
205 205
     // Abort if non exists.
206
-    if ( empty( $user_info ) ) {
206
+    if (empty($user_info)) {
207 207
         return array();
208 208
     }
209 209
 
@@ -214,11 +214,11 @@  discard block
 block discarded – undo
214 214
         'display_name' => $user_info->display_name,
215 215
     );
216 216
 
217
-    foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
218
-        $address[ $field ] = getpaid_get_user_address_field( $user_id, $field );
217
+    foreach (array_keys(getpaid_user_address_fields()) as $field) {
218
+        $address[$field] = getpaid_get_user_address_field($user_id, $field);
219 219
     }
220 220
 
221
-    $address = array_filter( $address );
221
+    $address = array_filter($address);
222 222
 
223 223
     $defaults = array(
224 224
         'first_name' => $user_info->first_name,
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
         'country'    => wpinv_get_default_country(),
228 228
     );
229 229
 
230
-    return getpaid_array_merge_if_empty( $address, $defaults );
230
+    return getpaid_array_merge_if_empty($address, $defaults);
231 231
 
232 232
 }
233 233
 
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
  * @param string $field The field to use.
239 239
  * @return string|null
240 240
  */
241
-function getpaid_get_user_address_field( $user_id, $field ) {
241
+function getpaid_get_user_address_field($user_id, $field) {
242 242
 
243 243
     $prefixes = array(
244 244
         '_wpinv_',
@@ -246,15 +246,15 @@  discard block
 block discarded – undo
246 246
         '',
247 247
     );
248 248
 
249
-    foreach ( $prefixes as $prefix ) {
249
+    foreach ($prefixes as $prefix) {
250 250
 
251 251
         // Meta table.
252
-        $value = get_user_meta( $user_id, $prefix . $field, true );
252
+        $value = get_user_meta($user_id, $prefix . $field, true);
253 253
 
254 254
         // UWP table.
255
-        $value = ( empty( $value ) && function_exists( 'uwp_get_usermeta' ) ) ? uwp_get_usermeta( $user_id, $prefix . $field ) : $value;
255
+        $value = (empty($value) && function_exists('uwp_get_usermeta')) ? uwp_get_usermeta($user_id, $prefix . $field) : $value;
256 256
 
257
-        if ( ! empty( $value ) ) {
257
+        if (!empty($value)) {
258 258
             return $value;
259 259
         }
260 260
 }
@@ -270,16 +270,16 @@  discard block
 block discarded – undo
270 270
  * @param string $return What to return.
271 271
  * @return array
272 272
  */
273
-function wpinv_get_continents( $return = 'all' ) {
273
+function wpinv_get_continents($return = 'all') {
274 274
 
275
-    $continents = wpinv_get_data( 'continents' );
275
+    $continents = wpinv_get_data('continents');
276 276
 
277
-    switch ( $return ) {
277
+    switch ($return) {
278 278
         case 'name':
279
-            return wp_list_pluck( $continents, 'name' );
279
+            return wp_list_pluck($continents, 'name');
280 280
             break;
281 281
         case 'countries':
282
-            return wp_list_pluck( $continents, 'countries' );
282
+            return wp_list_pluck($continents, 'countries');
283 283
             break;
284 284
         default:
285 285
             return $continents;
@@ -295,12 +295,12 @@  discard block
 block discarded – undo
295 295
  * @param string $country Country code. If no code is specified, defaults to the default country.
296 296
  * @return string
297 297
  */
298
-function wpinv_get_continent_code_for_country( $country = false ) {
298
+function wpinv_get_continent_code_for_country($country = false) {
299 299
 
300
-    $country = wpinv_sanitize_country( $country );
300
+    $country = wpinv_sanitize_country($country);
301 301
 
302
-	foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) {
303
-		if ( false !== array_search( $country, $countries, true ) ) {
302
+	foreach (wpinv_get_continents('countries') as $continent_code => $countries) {
303
+		if (false !== array_search($country, $countries, true)) {
304 304
 			return $continent_code;
305 305
 		}
306 306
 	}
@@ -316,13 +316,13 @@  discard block
 block discarded – undo
316 316
  * @param string $country Country code. If no code is specified, defaults to the default country.
317 317
  * @return array
318 318
  */
319
-function wpinv_get_country_calling_code( $country = null ) {
319
+function wpinv_get_country_calling_code($country = null) {
320 320
 
321
-    $country = wpinv_sanitize_country( $country );
322
-    $codes   = wpinv_get_data( 'phone-codes' );
323
-    $code    = isset( $codes[ $country ] ) ? $codes[ $country ] : '';
321
+    $country = wpinv_sanitize_country($country);
322
+    $codes   = wpinv_get_data('phone-codes');
323
+    $code    = isset($codes[$country]) ? $codes[$country] : '';
324 324
 
325
-    if ( is_array( $code ) ) {
325
+    if (is_array($code)) {
326 326
         return $code[0];
327 327
     }
328 328
     return $code;
@@ -335,8 +335,8 @@  discard block
 block discarded – undo
335 335
  * @param bool $first_empty Whether or not the first item in the list should be empty
336 336
  * @return array
337 337
  */
338
-function wpinv_get_country_list( $first_empty = false ) {
339
-    return wpinv_maybe_add_empty_option( apply_filters( 'wpinv_countries', wpinv_get_data( 'countries' ) ), $first_empty );
338
+function wpinv_get_country_list($first_empty = false) {
339
+    return wpinv_maybe_add_empty_option(apply_filters('wpinv_countries', wpinv_get_data('countries')), $first_empty);
340 340
 }
341 341
 
342 342
 /**
@@ -346,22 +346,22 @@  discard block
 block discarded – undo
346 346
  * @param bool $first_empty Whether or not the first item in the list should be empty
347 347
  * @return array
348 348
  */
349
-function wpinv_get_country_states( $country = null, $first_empty = false ) {
349
+function wpinv_get_country_states($country = null, $first_empty = false) {
350 350
 
351 351
     // Prepare the country.
352
-    $country = wpinv_sanitize_country( $country );
352
+    $country = wpinv_sanitize_country($country);
353 353
 
354 354
     // Fetch all states.
355
-    $all_states = wpinv_get_data( 'states' );
355
+    $all_states = wpinv_get_data('states');
356 356
 
357 357
     // Fetch the specified country's states.
358
-    $states     = isset( $all_states[ $country ] ) ? $all_states[ $country ] : array();
359
-    $states     = apply_filters( "wpinv_{$country}_states", $states );
360
-    $states     = apply_filters( 'wpinv_country_states', $states, $country );
358
+    $states     = isset($all_states[$country]) ? $all_states[$country] : array();
359
+    $states     = apply_filters("wpinv_{$country}_states", $states);
360
+    $states     = apply_filters('wpinv_country_states', $states, $country);
361 361
 
362
-    asort( $states );
362
+    asort($states);
363 363
 
364
-    return wpinv_maybe_add_empty_option( $states, $first_empty );
364
+    return wpinv_maybe_add_empty_option($states, $first_empty);
365 365
 }
366 366
 
367 367
 /**
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
  * @return array
372 372
  */
373 373
 function wpinv_get_us_states_list() {
374
-    return apply_filters( 'wpinv_usa_states', wpinv_get_country_states( 'US' ) );
374
+    return apply_filters('wpinv_usa_states', wpinv_get_country_states('US'));
375 375
 }
376 376
 
377 377
 /**
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
  * @return array
382 382
  */
383 383
 function wpinv_get_canada_states_list() {
384
-    return apply_filters( 'wpinv_canada_provinces', wpinv_get_country_states( 'CA' ) );
384
+    return apply_filters('wpinv_canada_provinces', wpinv_get_country_states('CA'));
385 385
 }
386 386
 
387 387
 /**
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
  * @return array
392 392
  */
393 393
 function wpinv_get_australia_states_list() {
394
-    return apply_filters( 'wpinv_australia_states', wpinv_get_country_states( 'AU' ) );
394
+    return apply_filters('wpinv_australia_states', wpinv_get_country_states('AU'));
395 395
 }
396 396
 
397 397
 /**
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
  * @return array
402 402
  */
403 403
 function wpinv_get_bangladesh_states_list() {
404
-    return apply_filters( 'wpinv_bangladesh_states', wpinv_get_country_states( 'BD' ) );
404
+    return apply_filters('wpinv_bangladesh_states', wpinv_get_country_states('BD'));
405 405
 }
406 406
 
407 407
 /**
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
  * @return array
412 412
  */
413 413
 function wpinv_get_brazil_states_list() {
414
-    return apply_filters( 'wpinv_brazil_states', wpinv_get_country_states( 'BR' ) );
414
+    return apply_filters('wpinv_brazil_states', wpinv_get_country_states('BR'));
415 415
 }
416 416
 
417 417
 /**
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
  * @return array
422 422
  */
423 423
 function wpinv_get_bulgaria_states_list() {
424
-    return apply_filters( 'wpinv_bulgaria_states', wpinv_get_country_states( 'BG' ) );
424
+    return apply_filters('wpinv_bulgaria_states', wpinv_get_country_states('BG'));
425 425
 }
426 426
 
427 427
 /**
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
  * @return array
432 432
  */
433 433
 function wpinv_get_hong_kong_states_list() {
434
-    return apply_filters( 'wpinv_hong_kong_states', wpinv_get_country_states( 'HK' ) );
434
+    return apply_filters('wpinv_hong_kong_states', wpinv_get_country_states('HK'));
435 435
 }
436 436
 
437 437
 /**
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
  * @return array
442 442
  */
443 443
 function wpinv_get_hungary_states_list() {
444
-    return apply_filters( 'wpinv_hungary_states', wpinv_get_country_states( 'HU' ) );
444
+    return apply_filters('wpinv_hungary_states', wpinv_get_country_states('HU'));
445 445
 }
446 446
 
447 447
 /**
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
  * @return array
452 452
  */
453 453
 function wpinv_get_japan_states_list() {
454
-    return apply_filters( 'wpinv_japan_states', wpinv_get_country_states( 'JP' ) );
454
+    return apply_filters('wpinv_japan_states', wpinv_get_country_states('JP'));
455 455
 }
456 456
 
457 457
 /**
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
  * @return array
462 462
  */
463 463
 function wpinv_get_china_states_list() {
464
-    return apply_filters( 'wpinv_china_states', wpinv_get_country_states( 'CN' ) );
464
+    return apply_filters('wpinv_china_states', wpinv_get_country_states('CN'));
465 465
 }
466 466
 
467 467
 /**
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
  * @return array
472 472
  */
473 473
 function wpinv_get_new_zealand_states_list() {
474
-    return apply_filters( 'wpinv_new_zealand_states', wpinv_get_country_states( 'NZ' ) );
474
+    return apply_filters('wpinv_new_zealand_states', wpinv_get_country_states('NZ'));
475 475
 }
476 476
 
477 477
 /**
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
  * @return array
482 482
  */
483 483
 function wpinv_get_peru_states_list() {
484
-    return apply_filters( 'wpinv_peru_states', wpinv_get_country_states( 'PE' ) );
484
+    return apply_filters('wpinv_peru_states', wpinv_get_country_states('PE'));
485 485
 }
486 486
 
487 487
 /**
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
  * @return array
492 492
  */
493 493
 function wpinv_get_indonesia_states_list() {
494
-    return apply_filters( 'wpinv_indonesia_states', wpinv_get_country_states( 'ID' ) );
494
+    return apply_filters('wpinv_indonesia_states', wpinv_get_country_states('ID'));
495 495
 }
496 496
 
497 497
 /**
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
  * @return array
502 502
  */
503 503
 function wpinv_get_india_states_list() {
504
-    return apply_filters( 'wpinv_india_states', wpinv_get_country_states( 'IN' ) );
504
+    return apply_filters('wpinv_india_states', wpinv_get_country_states('IN'));
505 505
 }
506 506
 
507 507
 /**
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
  * @return array
512 512
  */
513 513
 function wpinv_get_iran_states_list() {
514
-    return apply_filters( 'wpinv_iran_states', wpinv_get_country_states( 'IR' ) );
514
+    return apply_filters('wpinv_iran_states', wpinv_get_country_states('IR'));
515 515
 }
516 516
 
517 517
 /**
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
  * @return array
522 522
  */
523 523
 function wpinv_get_italy_states_list() {
524
-    return apply_filters( 'wpinv_italy_states', wpinv_get_country_states( 'IT' ) );
524
+    return apply_filters('wpinv_italy_states', wpinv_get_country_states('IT'));
525 525
 }
526 526
 
527 527
 /**
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
  * @return array
532 532
  */
533 533
 function wpinv_get_malaysia_states_list() {
534
-    return apply_filters( 'wpinv_malaysia_states', wpinv_get_country_states( 'MY' ) );
534
+    return apply_filters('wpinv_malaysia_states', wpinv_get_country_states('MY'));
535 535
 }
536 536
 
537 537
 /**
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
  * @return array
542 542
  */
543 543
 function wpinv_get_mexico_states_list() {
544
-    return apply_filters( 'wpinv_mexico_states', wpinv_get_country_states( 'MX' ) );
544
+    return apply_filters('wpinv_mexico_states', wpinv_get_country_states('MX'));
545 545
 }
546 546
 
547 547
 /**
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
  * @return array
552 552
  */
553 553
 function wpinv_get_nepal_states_list() {
554
-    return apply_filters( 'wpinv_nepal_states', wpinv_get_country_states( 'NP' ) );
554
+    return apply_filters('wpinv_nepal_states', wpinv_get_country_states('NP'));
555 555
 }
556 556
 
557 557
 /**
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
  * @return array
562 562
  */
563 563
 function wpinv_get_south_africa_states_list() {
564
-    return apply_filters( 'wpinv_south_africa_states', wpinv_get_country_states( 'ZA' ) );
564
+    return apply_filters('wpinv_south_africa_states', wpinv_get_country_states('ZA'));
565 565
 }
566 566
 
567 567
 /**
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
  * @return array
572 572
  */
573 573
 function wpinv_get_thailand_states_list() {
574
-    return apply_filters( 'wpinv_thailand_states', wpinv_get_country_states( 'TH' ) );
574
+    return apply_filters('wpinv_thailand_states', wpinv_get_country_states('TH'));
575 575
 }
576 576
 
577 577
 /**
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
  * @return array
582 582
  */
583 583
 function wpinv_get_turkey_states_list() {
584
-    return apply_filters( 'wpinv_turkey_states', wpinv_get_country_states( 'TR' ) );
584
+    return apply_filters('wpinv_turkey_states', wpinv_get_country_states('TR'));
585 585
 }
586 586
 
587 587
 /**
@@ -591,31 +591,31 @@  discard block
 block discarded – undo
591 591
  * @return array
592 592
  */
593 593
 function wpinv_get_spain_states_list() {
594
-    return apply_filters( 'wpinv_spain_states', wpinv_get_country_states( 'ES' ) );
594
+    return apply_filters('wpinv_spain_states', wpinv_get_country_states('ES'));
595 595
 }
596 596
 
597 597
 function wpinv_get_states_field() {
598
-	if ( empty( $_POST['country'] ) ) {
598
+	if (empty($_POST['country'])) {
599 599
 		$_POST['country'] = wpinv_get_default_country();
600 600
 	}
601
-	$states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) );
601
+	$states = wpinv_get_country_states(sanitize_text_field($_POST['country']));
602 602
 
603
-	if ( ! empty( $states ) ) {
604
-		$sanitized_field_name = sanitize_text_field( $_POST['field_name'] );
603
+	if (!empty($states)) {
604
+		$sanitized_field_name = sanitize_text_field($_POST['field_name']);
605 605
 
606
-        $class  = isset( $_POST['class'] ) ? esc_attr( sanitize_text_field( $_POST['class'] ) ) : '';
606
+        $class  = isset($_POST['class']) ? esc_attr(sanitize_text_field($_POST['class'])) : '';
607 607
         $class .= " $sanitized_field_name getpaid_js_field-state custom-select wpinv-select wpi_select2";
608 608
 
609
-        $args  = array(
609
+        $args = array(
610 610
 			'name'             => $sanitized_field_name,
611 611
 			'id'               => $sanitized_field_name,
612
-			'class'            => implode( ' ', array_unique( explode( ' ', $class ) ) ),
613
-			'options'          => array_merge( array( '' => '' ), $states ),
612
+			'class'            => implode(' ', array_unique(explode(' ', $class))),
613
+			'options'          => array_merge(array('' => ''), $states),
614 614
 			'show_option_all'  => false,
615 615
 			'show_option_none' => false,
616 616
 		);
617 617
 
618
-		wpinv_html_select( $args );
618
+		wpinv_html_select($args);
619 619
 
620 620
 	} else {
621 621
 		echo 'nostates';
@@ -623,10 +623,10 @@  discard block
 block discarded – undo
623 623
 
624 624
 }
625 625
 
626
-function wpinv_default_billing_country( $country = '', $user_id = 0 ) {
627
-    $country = ! empty( $country ) ? $country : wpinv_get_default_country();
626
+function wpinv_default_billing_country($country = '', $user_id = 0) {
627
+    $country = !empty($country) ? $country : wpinv_get_default_country();
628 628
 
629
-    return apply_filters( 'wpinv_default_billing_country', $country, $user_id );
629
+    return apply_filters('wpinv_default_billing_country', $country, $user_id);
630 630
 }
631 631
 
632 632
 /**
@@ -688,9 +688,9 @@  discard block
 block discarded – undo
688 688
  * @see `wpinv_get_invoice_address_replacements`
689 689
  * @return string
690 690
  */
691
-function wpinv_get_full_address_format( $country = false ) {
691
+function wpinv_get_full_address_format($country = false) {
692 692
 
693
-    if ( empty( $country ) ) {
693
+    if (empty($country)) {
694 694
         $country = wpinv_get_default_country();
695 695
     }
696 696
 
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 	$formats = wpinv_get_address_formats();
699 699
 
700 700
 	// Get format for the specified country.
701
-	$format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default'];
701
+	$format = ($country && isset($formats[$country])) ? $formats[$country] : $formats['default'];
702 702
 
703 703
     /**
704 704
 	 * Filters the address format to use on Invoices.
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
 	 * @param string $format  The address format to use.
711 711
      * @param string $country The country who's address format is being retrieved.
712 712
 	 */
713
-    return apply_filters( 'wpinv_get_full_address_format', $format, $country );
713
+    return apply_filters('wpinv_get_full_address_format', $format, $country);
714 714
 }
715 715
 
716 716
 /**
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
  * @param array $billing_details customer's billing details
722 722
  * @return array
723 723
  */
724
-function wpinv_get_invoice_address_replacements( $billing_details ) {
724
+function wpinv_get_invoice_address_replacements($billing_details) {
725 725
 
726 726
     $default_args = array(
727 727
         'address'    => '',
@@ -734,15 +734,15 @@  discard block
 block discarded – undo
734 734
 		'company'    => '',
735 735
     );
736 736
 
737
-    $args    = map_deep( wp_parse_args( $billing_details, $default_args ), 'trim' );
737
+    $args    = map_deep(wp_parse_args($billing_details, $default_args), 'trim');
738 738
     $state   = $args['state'];
739 739
     $country = $args['country'];
740 740
 
741 741
     // Handle full country name.
742
-    $full_country = empty( $country ) ? $country : wpinv_country_name( $country );
742
+    $full_country = empty($country) ? $country : wpinv_country_name($country);
743 743
 
744 744
     // Handle full state name.
745
-    $full_state   = ( $country && $state ) ? wpinv_state_name( $state, $country ) : $state;
745
+    $full_state   = ($country && $state) ? wpinv_state_name($state, $country) : $state;
746 746
 
747 747
     $args['postcode']    = $args['zip'];
748 748
     $args['name']        = $args['first_name'] . ' ' . $args['last_name'];
@@ -760,14 +760,14 @@  discard block
 block discarded – undo
760 760
 	 * @param array $replacements  The address replacements to use.
761 761
      * @param array $billing_details  The billing details to use.
762 762
 	 */
763
-    $replacements = apply_filters( 'wpinv_get_invoice_address_replacements', $args, $billing_details );
763
+    $replacements = apply_filters('wpinv_get_invoice_address_replacements', $args, $billing_details);
764 764
 
765 765
     $return = array();
766 766
 
767
-    foreach ( $replacements as $key => $value ) {
768
-        $value  = is_scalar( $value ) ? trim( sanitize_text_field( $value ) ) : '';
769
-        $return[ '{{' . $key . '}}' ] = $value;
770
-        $return[ '{{' . $key . '_upper}}' ] = wpinv_utf8_strtoupper( $value );
767
+    foreach ($replacements as $key => $value) {
768
+        $value = is_scalar($value) ? trim(sanitize_text_field($value)) : '';
769
+        $return['{{' . $key . '}}'] = $value;
770
+        $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper($value);
771 771
     }
772 772
 
773 773
     return $return;
@@ -781,6 +781,6 @@  discard block
 block discarded – undo
781 781
  * @since 1.0.14
782 782
  * @return string
783 783
  */
784
-function wpinv_trim_formatted_address_line( $line ) {
785
-	return trim( $line, ', ' );
784
+function wpinv_trim_formatted_address_line($line) {
785
+	return trim($line, ', ');
786 786
 }
Please login to merge, or discard this patch.
includes/wpinv-template-functions.php 2 patches
Indentation   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
141 141
  */
142 142
 function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
143
-	return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path );
143
+    return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path );
144 144
 }
145 145
 
146 146
 /**
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
  * @return string
159 159
  */
160 160
 function wpinv_get_theme_template_dir_name() {
161
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
161
+    return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
162 162
 }
163 163
 
164 164
 /**
@@ -175,125 +175,125 @@  discard block
 block discarded – undo
175 175
 }
176 176
 
177 177
 function wpinv_get_template_part( $slug, $name = null, $load = true ) {
178
-	do_action( 'get_template_part_' . $slug, $slug, $name );
178
+    do_action( 'get_template_part_' . $slug, $slug, $name );
179 179
 
180
-	// Setup possible parts
181
-	$templates = array();
182
-	if ( isset( $name ) ) {
183
-		$templates[] = $slug . '-' . $name . '.php';
180
+    // Setup possible parts
181
+    $templates = array();
182
+    if ( isset( $name ) ) {
183
+        $templates[] = $slug . '-' . $name . '.php';
184 184
     }
185
-	$templates[] = $slug . '.php';
185
+    $templates[] = $slug . '.php';
186 186
 
187
-	// Allow template parts to be filtered
188
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
187
+    // Allow template parts to be filtered
188
+    $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
189 189
 
190
-	// Return the part that is found
191
-	return wpinv_locate_tmpl( $templates, $load, false );
190
+    // Return the part that is found
191
+    return wpinv_locate_tmpl( $templates, $load, false );
192 192
 }
193 193
 
194 194
 function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
195
-	// No file found yet
196
-	$located = false;
195
+    // No file found yet
196
+    $located = false;
197 197
 
198
-	// Try to find a template file
199
-	foreach ( (array)$template_names as $template_name ) {
198
+    // Try to find a template file
199
+    foreach ( (array)$template_names as $template_name ) {
200 200
 
201
-		// Continue if template is empty
202
-		if ( empty( $template_name ) ) {
203
-			continue;
201
+        // Continue if template is empty
202
+        if ( empty( $template_name ) ) {
203
+            continue;
204 204
         }
205 205
 
206
-		// Trim off any slashes from the template name
207
-		$template_name = ltrim( $template_name, '/' );
206
+        // Trim off any slashes from the template name
207
+        $template_name = ltrim( $template_name, '/' );
208 208
 
209
-		// try locating this template file by looping through the template paths
210
-		foreach ( wpinv_get_theme_template_paths() as $template_path ) {
209
+        // try locating this template file by looping through the template paths
210
+        foreach ( wpinv_get_theme_template_paths() as $template_path ) {
211 211
 
212
-			if ( file_exists( $template_path . $template_name ) ) {
213
-				$located = $template_path . $template_name;
214
-				break;
215
-			}
216
-		}
212
+            if ( file_exists( $template_path . $template_name ) ) {
213
+                $located = $template_path . $template_name;
214
+                break;
215
+            }
216
+        }
217 217
 
218
-		if ( ! empty( $located ) ) {
219
-			break;
220
-		}
221
-	}
218
+        if ( ! empty( $located ) ) {
219
+            break;
220
+        }
221
+    }
222 222
 
223
-	if ( ( true == $load ) && ! empty( $located ) ) {
224
-		load_template( $located, $require_once );
223
+    if ( ( true == $load ) && ! empty( $located ) ) {
224
+        load_template( $located, $require_once );
225 225
     }
226 226
 
227
-	return $located;
227
+    return $located;
228 228
 }
229 229
 
230 230
 function wpinv_get_theme_template_paths() {
231
-	$template_dir = wpinv_get_theme_template_dir_name();
231
+    $template_dir = wpinv_get_theme_template_dir_name();
232 232
 
233
-	$file_paths = array(
234
-		1   => trailingslashit( get_stylesheet_directory() ) . $template_dir,
235
-		10  => trailingslashit( get_template_directory() ) . $template_dir,
236
-		100 => wpinv_get_templates_dir(),
237
-	);
233
+    $file_paths = array(
234
+        1   => trailingslashit( get_stylesheet_directory() ) . $template_dir,
235
+        10  => trailingslashit( get_template_directory() ) . $template_dir,
236
+        100 => wpinv_get_templates_dir(),
237
+    );
238 238
 
239
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
239
+    $file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
240 240
 
241
-	// sort the file paths based on priority
242
-	ksort( $file_paths, SORT_NUMERIC );
241
+    // sort the file paths based on priority
242
+    ksort( $file_paths, SORT_NUMERIC );
243 243
 
244
-	return array_map( 'trailingslashit', $file_paths );
244
+    return array_map( 'trailingslashit', $file_paths );
245 245
 }
246 246
 
247 247
 function wpinv_checkout_meta_tags() {
248 248
 
249
-	$pages   = array();
250
-	$pages[] = wpinv_get_option( 'success_page' );
251
-	$pages[] = wpinv_get_option( 'failure_page' );
252
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
253
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
249
+    $pages   = array();
250
+    $pages[] = wpinv_get_option( 'success_page' );
251
+    $pages[] = wpinv_get_option( 'failure_page' );
252
+    $pages[] = wpinv_get_option( 'invoice_history_page' );
253
+    $pages[] = wpinv_get_option( 'invoice_subscription_page' );
254 254
 
255
-	if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) {
256
-		return;
257
-	}
255
+    if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) {
256
+        return;
257
+    }
258 258
 
259
-	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
259
+    echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
260 260
 }
261 261
 add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
262 262
 
263 263
 function wpinv_add_body_classes( $class ) {
264
-	$classes = (array)$class;
264
+    $classes = (array)$class;
265 265
 
266
-	if ( wpinv_is_checkout() ) {
267
-		$classes[] = 'wpinv-checkout';
268
-		$classes[] = 'wpinv-page';
269
-	}
266
+    if ( wpinv_is_checkout() ) {
267
+        $classes[] = 'wpinv-checkout';
268
+        $classes[] = 'wpinv-page';
269
+    }
270 270
 
271
-	if ( wpinv_is_success_page() ) {
272
-		$classes[] = 'wpinv-success';
273
-		$classes[] = 'wpinv-page';
274
-	}
271
+    if ( wpinv_is_success_page() ) {
272
+        $classes[] = 'wpinv-success';
273
+        $classes[] = 'wpinv-page';
274
+    }
275 275
 
276
-	if ( wpinv_is_failed_transaction_page() ) {
277
-		$classes[] = 'wpinv-failed-transaction';
278
-		$classes[] = 'wpinv-page';
279
-	}
276
+    if ( wpinv_is_failed_transaction_page() ) {
277
+        $classes[] = 'wpinv-failed-transaction';
278
+        $classes[] = 'wpinv-page';
279
+    }
280 280
 
281
-	if ( wpinv_is_invoice_history_page() ) {
282
-		$classes[] = 'wpinv-history';
283
-		$classes[] = 'wpinv-page';
284
-	}
281
+    if ( wpinv_is_invoice_history_page() ) {
282
+        $classes[] = 'wpinv-history';
283
+        $classes[] = 'wpinv-page';
284
+    }
285 285
 
286
-	if ( wpinv_is_subscriptions_history_page() ) {
287
-		$classes[] = 'wpinv-subscription';
288
-		$classes[] = 'wpinv-page';
289
-	}
286
+    if ( wpinv_is_subscriptions_history_page() ) {
287
+        $classes[] = 'wpinv-subscription';
288
+        $classes[] = 'wpinv-page';
289
+    }
290 290
 
291
-	if ( wpinv_is_test_mode() ) {
292
-		$classes[] = 'wpinv-test-mode';
293
-		$classes[] = 'wpinv-page';
294
-	}
291
+    if ( wpinv_is_test_mode() ) {
292
+        $classes[] = 'wpinv-test-mode';
293
+        $classes[] = 'wpinv-page';
294
+    }
295 295
 
296
-	return array_unique( $classes );
296
+    return array_unique( $classes );
297 297
 }
298 298
 add_filter( 'body_class', 'wpinv_add_body_classes' );
299 299
 
@@ -458,16 +458,16 @@  discard block
 block discarded – undo
458 458
 
459 459
     wpinv_html_select(
460 460
         array(
461
-			'name'             => $args['name'],
462
-			'selected'         => $args['selected'],
463
-			'id'               => $args['id'],
464
-			'class'            => $args['class'],
465
-			'options'          => $options,
466
-			'multiple'         => $args['multiple'],
467
-			'placeholder'      => $args['placeholder'],
468
-			'show_option_all'  => $args['show_option_all'],
469
-			'show_option_none' => $args['show_option_none'],
470
-			'data'             => $args['data'],
461
+            'name'             => $args['name'],
462
+            'selected'         => $args['selected'],
463
+            'id'               => $args['id'],
464
+            'class'            => $args['class'],
465
+            'options'          => $options,
466
+            'multiple'         => $args['multiple'],
467
+            'placeholder'      => $args['placeholder'],
468
+            'show_option_all'  => $args['show_option_all'],
469
+            'show_option_none' => $args['show_option_none'],
470
+            'data'             => $args['data'],
471 471
         )
472 472
     );
473 473
 
@@ -767,21 +767,21 @@  discard block
 block discarded – undo
767 767
 
768 768
     $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
769 769
 
770
-	// Remove unavailable tags.
770
+    // Remove unavailable tags.
771 771
     $formatted_address = preg_replace( '/\{\{\w+\}\}/', '', $formatted_address );
772 772
 
773 773
     // Clean up white space.
774
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
774
+    $formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
775 775
     $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
776 776
 
777 777
     // Break newlines apart and remove empty lines/trim commas and white space.
778
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
778
+    $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
779 779
 
780 780
     // Add html breaks.
781
-	$formatted_address = implode( $separator, $formatted_address );
781
+    $formatted_address = implode( $separator, $formatted_address );
782 782
 
783
-	// We're done!
784
-	return $formatted_address;
783
+    // We're done!
784
+    return $formatted_address;
785 785
 
786 786
 }
787 787
 
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 function getpaid_display_invoice_subscriptions( $invoice ) {
828 828
 
829 829
     // Subscriptions.
830
-	$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
830
+    $subscriptions = getpaid_get_invoice_subscriptions( $invoice );
831 831
 
832 832
     if ( empty( $subscriptions ) || ! $invoice->is_recurring() ) {
833 833
         return;
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
 }
1040 1040
 
1041 1041
 function wpinv_empty_cart_message() {
1042
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1042
+    return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1043 1043
 }
1044 1044
 
1045 1045
 /**
@@ -1237,9 +1237,9 @@  discard block
 block discarded – undo
1237 1237
 
1238 1238
     if ( 0 == count( $form->get_items() ) ) {
1239 1239
         aui()->alert(
1240
-			array(
1241
-				'type'    => 'warning',
1242
-				'content' => __( 'No published items found', 'invoicing' ),
1240
+            array(
1241
+                'type'    => 'warning',
1242
+                'content' => __( 'No published items found', 'invoicing' ),
1243 1243
             ),
1244 1244
             true
1245 1245
         );
@@ -1262,10 +1262,10 @@  discard block
 block discarded – undo
1262 1262
     $invoice = wpinv_get_invoice( $invoice_id );
1263 1263
 
1264 1264
     if ( empty( $invoice ) ) {
1265
-		aui()->alert(
1266
-			array(
1267
-				'type'    => 'warning',
1268
-				'content' => __( 'Invoice not found', 'invoicing' ),
1265
+        aui()->alert(
1266
+            array(
1267
+                'type'    => 'warning',
1268
+                'content' => __( 'Invoice not found', 'invoicing' ),
1269 1269
             ),
1270 1270
             true
1271 1271
         );
@@ -1273,10 +1273,10 @@  discard block
 block discarded – undo
1273 1273
     }
1274 1274
 
1275 1275
     if ( $invoice->is_paid() ) {
1276
-		aui()->alert(
1277
-			array(
1278
-				'type'    => 'warning',
1279
-				'content' => __( 'Invoice has already been paid', 'invoicing' ),
1276
+        aui()->alert(
1277
+            array(
1278
+                'type'    => 'warning',
1279
+                'content' => __( 'Invoice has already been paid', 'invoicing' ),
1280 1280
             ),
1281 1281
             true
1282 1282
         );
@@ -1340,7 +1340,7 @@  discard block
 block discarded – undo
1340 1340
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>";
1341 1341
     }
1342 1342
 
1343
-	if ( ! empty( $items ) ) {
1343
+    if ( ! empty( $items ) ) {
1344 1344
         $items  = esc_attr( $items );
1345 1345
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>";
1346 1346
     }
@@ -1526,21 +1526,21 @@  discard block
 block discarded – undo
1526 1526
 
1527 1527
         return aui()->select(
1528 1528
             array(
1529
-				'options'          => $states,
1530
-				'name'             => esc_attr( $field_name ),
1531
-				'id'               => sanitize_html_class( $field_name ) . $uniqid,
1532
-				'value'            => sanitize_text_field( $state ),
1533
-				'placeholder'      => $placeholder,
1534
-				'required'         => $required,
1535
-				'label'            => wp_kses_post( $label ),
1536
-				'label_type'       => 'vertical',
1537
-				'help_text'        => $help_text,
1538
-				'class'            => 'getpaid-address-field wpinv_state',
1539
-				'wrap_class'       => "$wrapper_class getpaid-address-field-wrapper__state",
1540
-				'label_class'      => 'getpaid-address-field-label getpaid-address-field-label__state',
1541
-				'extra_attributes' => array(
1542
-					'autocomplete' => 'address-level1',
1543
-				),
1529
+                'options'          => $states,
1530
+                'name'             => esc_attr( $field_name ),
1531
+                'id'               => sanitize_html_class( $field_name ) . $uniqid,
1532
+                'value'            => sanitize_text_field( $state ),
1533
+                'placeholder'      => $placeholder,
1534
+                'required'         => $required,
1535
+                'label'            => wp_kses_post( $label ),
1536
+                'label_type'       => 'vertical',
1537
+                'help_text'        => $help_text,
1538
+                'class'            => 'getpaid-address-field wpinv_state',
1539
+                'wrap_class'       => "$wrapper_class getpaid-address-field-wrapper__state",
1540
+                'label_class'      => 'getpaid-address-field-label getpaid-address-field-label__state',
1541
+                'extra_attributes' => array(
1542
+                    'autocomplete' => 'address-level1',
1543
+                ),
1544 1544
             ),
1545 1545
             $echo
1546 1546
         );
Please login to merge, or discard this patch.
Spacing   +441 added lines, -441 removed lines patch added patch discarded remove patch
@@ -4,99 +4,99 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Displays an invoice.
11 11
  *
12 12
  * @param WPInv_Invoice $invoice.
13 13
  */
14
-function getpaid_invoice( $invoice ) {
15
-    if ( ! empty( $invoice ) ) {
16
-        wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) );
14
+function getpaid_invoice($invoice) {
15
+    if (!empty($invoice)) {
16
+        wpinv_get_template('invoice/invoice.php', compact('invoice'));
17 17
     }
18 18
 }
19
-add_action( 'getpaid_invoice', 'getpaid_invoice', 10 );
19
+add_action('getpaid_invoice', 'getpaid_invoice', 10);
20 20
 
21 21
 /**
22 22
  * Displays the invoice footer.
23 23
  */
24
-function getpaid_invoice_footer( $invoice ) {
25
-    if ( ! empty( $invoice ) ) {
26
-        wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) );
24
+function getpaid_invoice_footer($invoice) {
25
+    if (!empty($invoice)) {
26
+        wpinv_get_template('invoice/footer.php', compact('invoice'));
27 27
     }
28 28
 }
29
-add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 );
29
+add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10);
30 30
 
31 31
 /**
32 32
  * Displays the invoice top bar.
33 33
  */
34
-function getpaid_invoice_header( $invoice ) {
35
-    if ( ! empty( $invoice ) ) {
36
-        wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) );
34
+function getpaid_invoice_header($invoice) {
35
+    if (!empty($invoice)) {
36
+        wpinv_get_template('invoice/header.php', compact('invoice'));
37 37
     }
38 38
 }
39
-add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 );
39
+add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10);
40 40
 
41 41
 /**
42 42
  * Displays actions on the left side of the header.
43 43
  */
44
-function getpaid_invoice_header_left_actions( $invoice ) {
45
-    if ( ! empty( $invoice ) ) {
46
-        wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) );
44
+function getpaid_invoice_header_left_actions($invoice) {
45
+    if (!empty($invoice)) {
46
+        wpinv_get_template('invoice/header-left-actions.php', compact('invoice'));
47 47
     }
48 48
 }
49
-add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 );
49
+add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10);
50 50
 
51 51
 /**
52 52
  * Displays actions on the right side of the invoice top bar.
53 53
  */
54
-function getpaid_invoice_header_right_actions( $invoice ) {
55
-    if ( ! empty( $invoice ) ) {
56
-        wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) );
54
+function getpaid_invoice_header_right_actions($invoice) {
55
+    if (!empty($invoice)) {
56
+        wpinv_get_template('invoice/header-right-actions.php', compact('invoice'));
57 57
     }
58 58
 }
59
-add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 );
59
+add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10);
60 60
 
61 61
 /**
62 62
  * Displays the invoice title, logo etc.
63 63
  */
64
-function getpaid_invoice_details_top( $invoice ) {
65
-    if ( ! empty( $invoice ) ) {
66
-        wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) );
64
+function getpaid_invoice_details_top($invoice) {
65
+    if (!empty($invoice)) {
66
+        wpinv_get_template('invoice/details-top.php', compact('invoice'));
67 67
     }
68 68
 }
69
-add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 );
69
+add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10);
70 70
 
71 71
 /**
72 72
  * Displays the company logo.
73 73
  */
74
-function getpaid_invoice_logo( $invoice ) {
75
-    if ( ! empty( $invoice ) ) {
76
-        wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) );
74
+function getpaid_invoice_logo($invoice) {
75
+    if (!empty($invoice)) {
76
+        wpinv_get_template('invoice/invoice-logo.php', compact('invoice'));
77 77
     }
78 78
 }
79
-add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' );
79
+add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo');
80 80
 
81 81
 /**
82 82
  * Displays the type of invoice.
83 83
  */
84
-function getpaid_invoice_type( $invoice ) {
85
-    if ( ! empty( $invoice ) ) {
86
-        wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) );
84
+function getpaid_invoice_type($invoice) {
85
+    if (!empty($invoice)) {
86
+        wpinv_get_template('invoice/invoice-type.php', compact('invoice'));
87 87
     }
88 88
 }
89
-add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' );
89
+add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type');
90 90
 
91 91
 /**
92 92
  * Displays the invoice details.
93 93
  */
94
-function getpaid_invoice_details_main( $invoice ) {
95
-    if ( ! empty( $invoice ) ) {
96
-        wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) );
94
+function getpaid_invoice_details_main($invoice) {
95
+    if (!empty($invoice)) {
96
+        wpinv_get_template('invoice/details.php', compact('invoice'));
97 97
     }
98 98
 }
99
-add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 );
99
+add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50);
100 100
 
101 101
 /**
102 102
  * Returns a path to the templates directory.
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
  * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
126 126
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
127 127
  */
128
-function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
129
-    getpaid_template()->display_template( $template_name, $args, $template_path, $default_path );
128
+function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
129
+    getpaid_template()->display_template($template_name, $args, $template_path, $default_path);
130 130
 }
131 131
 
132 132
 /**
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
  * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
140 140
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
141 141
  */
142
-function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
143
-	return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path );
142
+function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') {
143
+	return getpaid_template()->get_template($template_name, $args, $template_path, $default_path);
144 144
 }
145 145
 
146 146
 /**
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
  * @return string
150 150
  */
151 151
 function wpinv_template_path() {
152
-    return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() );
152
+    return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name());
153 153
 }
154 154
 
155 155
 /**
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
  * @return string
159 159
  */
160 160
 function wpinv_get_theme_template_dir_name() {
161
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
161
+	return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing'));
162 162
 }
163 163
 
164 164
 /**
@@ -170,58 +170,58 @@  discard block
 block discarded – undo
170 170
  * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'.
171 171
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
172 172
  */
173
-function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) {
174
-    return getpaid_template()->locate_template( $template_name, $template_path, $default_path );
173
+function wpinv_locate_template($template_name, $template_path = '', $default_path = '') {
174
+    return getpaid_template()->locate_template($template_name, $template_path, $default_path);
175 175
 }
176 176
 
177
-function wpinv_get_template_part( $slug, $name = null, $load = true ) {
178
-	do_action( 'get_template_part_' . $slug, $slug, $name );
177
+function wpinv_get_template_part($slug, $name = null, $load = true) {
178
+	do_action('get_template_part_' . $slug, $slug, $name);
179 179
 
180 180
 	// Setup possible parts
181 181
 	$templates = array();
182
-	if ( isset( $name ) ) {
182
+	if (isset($name)) {
183 183
 		$templates[] = $slug . '-' . $name . '.php';
184 184
     }
185 185
 	$templates[] = $slug . '.php';
186 186
 
187 187
 	// Allow template parts to be filtered
188
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
188
+	$templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name);
189 189
 
190 190
 	// Return the part that is found
191
-	return wpinv_locate_tmpl( $templates, $load, false );
191
+	return wpinv_locate_tmpl($templates, $load, false);
192 192
 }
193 193
 
194
-function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
194
+function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) {
195 195
 	// No file found yet
196 196
 	$located = false;
197 197
 
198 198
 	// Try to find a template file
199
-	foreach ( (array)$template_names as $template_name ) {
199
+	foreach ((array) $template_names as $template_name) {
200 200
 
201 201
 		// Continue if template is empty
202
-		if ( empty( $template_name ) ) {
202
+		if (empty($template_name)) {
203 203
 			continue;
204 204
         }
205 205
 
206 206
 		// Trim off any slashes from the template name
207
-		$template_name = ltrim( $template_name, '/' );
207
+		$template_name = ltrim($template_name, '/');
208 208
 
209 209
 		// try locating this template file by looping through the template paths
210
-		foreach ( wpinv_get_theme_template_paths() as $template_path ) {
210
+		foreach (wpinv_get_theme_template_paths() as $template_path) {
211 211
 
212
-			if ( file_exists( $template_path . $template_name ) ) {
212
+			if (file_exists($template_path . $template_name)) {
213 213
 				$located = $template_path . $template_name;
214 214
 				break;
215 215
 			}
216 216
 		}
217 217
 
218
-		if ( ! empty( $located ) ) {
218
+		if (!empty($located)) {
219 219
 			break;
220 220
 		}
221 221
 	}
222 222
 
223
-	if ( ( true == $load ) && ! empty( $located ) ) {
224
-		load_template( $located, $require_once );
223
+	if ((true == $load) && !empty($located)) {
224
+		load_template($located, $require_once);
225 225
     }
226 226
 
227 227
 	return $located;
@@ -231,73 +231,73 @@  discard block
 block discarded – undo
231 231
 	$template_dir = wpinv_get_theme_template_dir_name();
232 232
 
233 233
 	$file_paths = array(
234
-		1   => trailingslashit( get_stylesheet_directory() ) . $template_dir,
235
-		10  => trailingslashit( get_template_directory() ) . $template_dir,
234
+		1   => trailingslashit(get_stylesheet_directory()) . $template_dir,
235
+		10  => trailingslashit(get_template_directory()) . $template_dir,
236 236
 		100 => wpinv_get_templates_dir(),
237 237
 	);
238 238
 
239
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
239
+	$file_paths = apply_filters('wpinv_template_paths', $file_paths);
240 240
 
241 241
 	// sort the file paths based on priority
242
-	ksort( $file_paths, SORT_NUMERIC );
242
+	ksort($file_paths, SORT_NUMERIC);
243 243
 
244
-	return array_map( 'trailingslashit', $file_paths );
244
+	return array_map('trailingslashit', $file_paths);
245 245
 }
246 246
 
247 247
 function wpinv_checkout_meta_tags() {
248 248
 
249 249
 	$pages   = array();
250
-	$pages[] = wpinv_get_option( 'success_page' );
251
-	$pages[] = wpinv_get_option( 'failure_page' );
252
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
253
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
250
+	$pages[] = wpinv_get_option('success_page');
251
+	$pages[] = wpinv_get_option('failure_page');
252
+	$pages[] = wpinv_get_option('invoice_history_page');
253
+	$pages[] = wpinv_get_option('invoice_subscription_page');
254 254
 
255
-	if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) {
255
+	if (!wpinv_is_checkout() && !is_page($pages)) {
256 256
 		return;
257 257
 	}
258 258
 
259 259
 	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
260 260
 }
261
-add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
261
+add_action('wp_head', 'wpinv_checkout_meta_tags');
262 262
 
263
-function wpinv_add_body_classes( $class ) {
264
-	$classes = (array)$class;
263
+function wpinv_add_body_classes($class) {
264
+	$classes = (array) $class;
265 265
 
266
-	if ( wpinv_is_checkout() ) {
266
+	if (wpinv_is_checkout()) {
267 267
 		$classes[] = 'wpinv-checkout';
268 268
 		$classes[] = 'wpinv-page';
269 269
 	}
270 270
 
271
-	if ( wpinv_is_success_page() ) {
271
+	if (wpinv_is_success_page()) {
272 272
 		$classes[] = 'wpinv-success';
273 273
 		$classes[] = 'wpinv-page';
274 274
 	}
275 275
 
276
-	if ( wpinv_is_failed_transaction_page() ) {
276
+	if (wpinv_is_failed_transaction_page()) {
277 277
 		$classes[] = 'wpinv-failed-transaction';
278 278
 		$classes[] = 'wpinv-page';
279 279
 	}
280 280
 
281
-	if ( wpinv_is_invoice_history_page() ) {
281
+	if (wpinv_is_invoice_history_page()) {
282 282
 		$classes[] = 'wpinv-history';
283 283
 		$classes[] = 'wpinv-page';
284 284
 	}
285 285
 
286
-	if ( wpinv_is_subscriptions_history_page() ) {
286
+	if (wpinv_is_subscriptions_history_page()) {
287 287
 		$classes[] = 'wpinv-subscription';
288 288
 		$classes[] = 'wpinv-page';
289 289
 	}
290 290
 
291
-	if ( wpinv_is_test_mode() ) {
291
+	if (wpinv_is_test_mode()) {
292 292
 		$classes[] = 'wpinv-test-mode';
293 293
 		$classes[] = 'wpinv-page';
294 294
 	}
295 295
 
296
-	return array_unique( $classes );
296
+	return array_unique($classes);
297 297
 }
298
-add_filter( 'body_class', 'wpinv_add_body_classes' );
298
+add_filter('body_class', 'wpinv_add_body_classes');
299 299
 
300
-function wpinv_html_select( $args = array() ) {
300
+function wpinv_html_select($args = array()) {
301 301
     $defaults = array(
302 302
         'options'          => array(),
303 303
         'name'             => null,
@@ -306,8 +306,8 @@  discard block
 block discarded – undo
306 306
         'selected'         => 0,
307 307
         'placeholder'      => null,
308 308
         'multiple'         => false,
309
-        'show_option_all'  => _x( 'All', 'all dropdown items', 'invoicing' ),
310
-        'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ),
309
+        'show_option_all'  => _x('All', 'all dropdown items', 'invoicing'),
310
+        'show_option_none' => _x('None', 'no dropdown items', 'invoicing'),
311 311
         'data'             => array(),
312 312
         'onchange'         => null,
313 313
         'required'         => false,
@@ -315,79 +315,79 @@  discard block
 block discarded – undo
315 315
         'readonly'         => false,
316 316
     );
317 317
 
318
-    $args = wp_parse_args( $args, $defaults );
318
+    $args = wp_parse_args($args, $defaults);
319 319
 
320 320
     $attrs = array(
321 321
         'name'     => $args['name'],
322 322
         'id'       => $args['id'],
323
-        'class'    => 'wpinv-select ' . implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ),
324
-        'multiple' => ! empty( $args['multiple'] ),
325
-        'readonly' => ! empty( $args['readonly'] ),
326
-        'disabled' => ! empty( $args['disabled'] ),
327
-        'required' => ! empty( $args['required'] ),
328
-        'onchange' => ! empty( $args['onchange'] ),
323
+        'class'    => 'wpinv-select ' . implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))),
324
+        'multiple' => !empty($args['multiple']),
325
+        'readonly' => !empty($args['readonly']),
326
+        'disabled' => !empty($args['disabled']),
327
+        'required' => !empty($args['required']),
328
+        'onchange' => !empty($args['onchange']),
329 329
     );
330 330
 
331
-    if ( $args['placeholder'] ) {
331
+    if ($args['placeholder']) {
332 332
         $attrs['data-placeholder'] = $args['placeholder'];
333 333
     }
334 334
 
335
-    if ( $args['onchange'] ) {
335
+    if ($args['onchange']) {
336 336
         $attrs['onchange'] = $args['onchange'];
337 337
     }
338 338
 
339
-    foreach ( $args['data'] as $key => $value ) {
339
+    foreach ($args['data'] as $key => $value) {
340 340
         $attrs["data-$key"] = $value;
341 341
     }
342 342
 
343 343
     echo '<select ';
344 344
 
345
-    foreach ( $attrs as $attr => $value ) {
345
+    foreach ($attrs as $attr => $value) {
346 346
         
347
-        if ( false === $value ) {
347
+        if (false === $value) {
348 348
             continue;
349 349
         }
350 350
 
351
-        if ( true === $value ) {
352
-            echo ' ' . esc_attr( $attr );
351
+        if (true === $value) {
352
+            echo ' ' . esc_attr($attr);
353 353
         } else {
354
-            echo ' ' . esc_attr( $attr ) . '="' . esc_attr( $value ) . '"';
354
+            echo ' ' . esc_attr($attr) . '="' . esc_attr($value) . '"';
355 355
         }
356 356
 
357 357
     }
358 358
 
359 359
     echo '>';
360 360
 
361
-    if ( $args['show_option_all'] ) {
362
-        if ( $args['multiple'] ) {
363
-            $selected = in_array( 0, $args['selected'] );
361
+    if ($args['show_option_all']) {
362
+        if ($args['multiple']) {
363
+            $selected = in_array(0, $args['selected']);
364 364
         } else {
365
-            $selected = empty( $args['selected'] );
365
+            $selected = empty($args['selected']);
366 366
         }
367
-        echo '<option value="all"' . selected( $selected, true, false ) . '>' . esc_html( $args['show_option_all'] ) . '</option>';
367
+        echo '<option value="all"' . selected($selected, true, false) . '>' . esc_html($args['show_option_all']) . '</option>';
368 368
     }
369 369
 
370
-    if ( ! empty( $args['options'] ) ) {
370
+    if (!empty($args['options'])) {
371 371
 
372
-        if ( $args['show_option_none'] ) {
373
-            if ( $args['multiple'] ) {
374
-                $selected = in_array( '', $args['selected'] );
372
+        if ($args['show_option_none']) {
373
+            if ($args['multiple']) {
374
+                $selected = in_array('', $args['selected']);
375 375
             } else {
376 376
                 $selected = $args['selected'] === '';
377 377
             }
378 378
 
379
-            echo '<option value=""' . selected( $selected, true, false ) . '>' . esc_html( $args['show_option_none'] ) . '</option>';
379
+            echo '<option value=""' . selected($selected, true, false) . '>' . esc_html($args['show_option_none']) . '</option>';
380 380
         }
381 381
 
382
-        foreach ( $args['options'] as $key => $option ) {
382
+        foreach ($args['options'] as $key => $option) {
383 383
 
384
-            if ( $args['multiple'] && is_array( $args['selected'] ) ) {
385
-                $selected = in_array( $key, $args['selected'] );
384
+            if ($args['multiple'] && is_array($args['selected'])) {
385
+                $selected = in_array($key, $args['selected']);
386 386
             } else {
387 387
                 $selected = $args['selected'] == $key;
388 388
             }
389 389
 
390
-            echo '<option value="' . esc_attr( $key ) . '"' . selected( $selected, true, false ) . '>' . esc_html( $option ) . '</option>';
390
+            echo '<option value="' . esc_attr($key) . '"' . selected($selected, true, false) . '>' . esc_html($option) . '</option>';
391 391
         }
392 392
     }
393 393
 
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 
396 396
 }
397 397
 
398
-function wpinv_item_dropdown( $args = array() ) {
398
+function wpinv_item_dropdown($args = array()) {
399 399
     $defaults = array(
400 400
         'name'             => 'wpi_item',
401 401
         'id'               => 'wpi_item',
@@ -403,14 +403,14 @@  discard block
 block discarded – undo
403 403
         'multiple'         => false,
404 404
         'selected'         => 0,
405 405
         'number'           => -1,
406
-        'placeholder'      => __( 'Choose a item', 'invoicing' ),
407
-        'data'             => array( 'search-type' => 'item' ),
406
+        'placeholder'      => __('Choose a item', 'invoicing'),
407
+        'data'             => array('search-type' => 'item'),
408 408
         'show_option_all'  => false,
409 409
         'show_option_none' => false,
410 410
         'show_recurring'   => false,
411 411
     );
412 412
 
413
-    $args = wp_parse_args( $args, $defaults );
413
+    $args = wp_parse_args($args, $defaults);
414 414
 
415 415
     $item_args = array(
416 416
         'post_type'      => 'wpi_item',
@@ -419,40 +419,40 @@  discard block
 block discarded – undo
419 419
         'posts_per_page' => $args['number'],
420 420
     );
421 421
 
422
-    $item_args  = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults );
422
+    $item_args  = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults);
423 423
 
424
-    $items      = get_posts( $item_args );
424
+    $items      = get_posts($item_args);
425 425
     $options    = array();
426
-    if ( $items ) {
427
-        foreach ( $items as $item ) {
428
-            $title = esc_html( $item->post_title );
426
+    if ($items) {
427
+        foreach ($items as $item) {
428
+            $title = esc_html($item->post_title);
429 429
 
430
-            if ( ! empty( $args['show_recurring'] ) ) {
431
-                $title .= wpinv_get_item_suffix( $item->ID, false );
430
+            if (!empty($args['show_recurring'])) {
431
+                $title .= wpinv_get_item_suffix($item->ID, false);
432 432
             }
433 433
 
434
-            $options[ absint( $item->ID ) ] = $title;
434
+            $options[absint($item->ID)] = $title;
435 435
         }
436 436
     }
437 437
 
438 438
     // This ensures that any selected items are included in the drop down
439
-    if ( is_array( $args['selected'] ) ) {
440
-        foreach ( $args['selected'] as $item ) {
441
-            if ( ! in_array( $item, $options ) ) {
442
-                $title = get_the_title( $item );
443
-                if ( ! empty( $args['show_recurring'] ) ) {
444
-                    $title .= wpinv_get_item_suffix( $item, false );
439
+    if (is_array($args['selected'])) {
440
+        foreach ($args['selected'] as $item) {
441
+            if (!in_array($item, $options)) {
442
+                $title = get_the_title($item);
443
+                if (!empty($args['show_recurring'])) {
444
+                    $title .= wpinv_get_item_suffix($item, false);
445 445
                 }
446
-                $options[ $item ] = $title;
446
+                $options[$item] = $title;
447 447
             }
448 448
         }
449
-    } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) {
450
-        if ( ! in_array( $args['selected'], $options ) ) {
451
-            $title = get_the_title( $args['selected'] );
452
-            if ( ! empty( $args['show_recurring'] ) ) {
453
-                $title .= wpinv_get_item_suffix( $args['selected'], false );
449
+    } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
450
+        if (!in_array($args['selected'], $options)) {
451
+            $title = get_the_title($args['selected']);
452
+            if (!empty($args['show_recurring'])) {
453
+                $title .= wpinv_get_item_suffix($args['selected'], false);
454 454
             }
455
-            $options[ $args['selected'] ] = get_the_title( $args['selected'] );
455
+            $options[$args['selected']] = get_the_title($args['selected']);
456 456
         }
457 457
     }
458 458
 
@@ -488,16 +488,16 @@  discard block
 block discarded – undo
488 488
     );
489 489
 
490 490
     $options = array();
491
-    if ( $items ) {
492
-        foreach ( $items as $item ) {
493
-            $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false );
491
+    if ($items) {
492
+        foreach ($items as $item) {
493
+            $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false);
494 494
         }
495 495
     }
496 496
 
497 497
     return $options;
498 498
 }
499 499
 
500
-function wpinv_html_checkbox( $args = array() ) {
500
+function wpinv_html_checkbox($args = array()) {
501 501
     $defaults = array(
502 502
         'name'    => null,
503 503
         'current' => null,
@@ -508,17 +508,17 @@  discard block
 block discarded – undo
508 508
         ),
509 509
     );
510 510
 
511
-    $args = wp_parse_args( $args, $defaults );
511
+    $args = wp_parse_args($args, $defaults);
512 512
 
513
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
513
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
514 514
     $attr  = '';
515
-    if ( ! empty( $args['options']['disabled'] ) ) {
515
+    if (!empty($args['options']['disabled'])) {
516 516
         $attr .= ' disabled="disabled"';
517
-    } elseif ( ! empty( $args['options']['readonly'] ) ) {
517
+    } elseif (!empty($args['options']['readonly'])) {
518 518
         $attr .= ' readonly';
519 519
     }
520 520
 
521
-    $output = '<input type="checkbox"' . $attr . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . esc_attr( $class ) . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />';
521
+    $output = '<input type="checkbox"' . $attr . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . esc_attr($class) . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />';
522 522
 
523 523
     return $output;
524 524
 }
@@ -526,34 +526,34 @@  discard block
 block discarded – undo
526 526
 /**
527 527
  * Displays a hidden field.
528 528
  */
529
-function getpaid_hidden_field( $name, $value ) {
530
-    echo "<input type='hidden' name='" . esc_attr( $name ) . "' value=' " . esc_attr( $value ) . "' />";
529
+function getpaid_hidden_field($name, $value) {
530
+    echo "<input type='hidden' name='" . esc_attr($name) . "' value=' " . esc_attr($value) . "' />";
531 531
 }
532 532
 
533 533
 /**
534 534
  * Displays a submit field.
535 535
  */
536
-function getpaid_submit_field( $value, $name = 'submit', $class = 'btn-primary' ) {
537
-    echo "<input type='submit' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "' class='btn " . esc_attr( $class ) . "' />";
536
+function getpaid_submit_field($value, $name = 'submit', $class = 'btn-primary') {
537
+    echo "<input type='submit' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' class='btn " . esc_attr($class) . "' />";
538 538
 }
539 539
 
540
-function wpinv_html_text( $args = array() ) {
540
+function wpinv_html_text($args = array()) {
541 541
     // Backwards compatibility
542
-    if ( func_num_args() > 1 ) {
542
+    if (func_num_args() > 1) {
543 543
         $args = func_get_args();
544 544
 
545 545
         $name  = $args[0];
546
-        $value = isset( $args[1] ) ? $args[1] : '';
547
-        $label = isset( $args[2] ) ? $args[2] : '';
548
-        $desc  = isset( $args[3] ) ? $args[3] : '';
546
+        $value = isset($args[1]) ? $args[1] : '';
547
+        $label = isset($args[2]) ? $args[2] : '';
548
+        $desc  = isset($args[3]) ? $args[3] : '';
549 549
     }
550 550
 
551 551
     $defaults = array(
552 552
         'id'           => '',
553
-        'name'         => isset( $name ) ? $name : 'text',
554
-        'value'        => isset( $value ) ? $value : null,
555
-        'label'        => isset( $label ) ? $label : null,
556
-        'desc'         => isset( $desc ) ? $desc : null,
553
+        'name'         => isset($name) ? $name : 'text',
554
+        'value'        => isset($value) ? $value : null,
555
+        'label'        => isset($label) ? $label : null,
556
+        'desc'         => isset($desc) ? $desc : null,
557 557
         'placeholder'  => '',
558 558
         'class'        => 'regular-text',
559 559
         'disabled'     => false,
@@ -563,41 +563,41 @@  discard block
 block discarded – undo
563 563
         'data'         => false,
564 564
     );
565 565
 
566
-    $args = wp_parse_args( $args, $defaults );
566
+    $args = wp_parse_args($args, $defaults);
567 567
 
568
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
568
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
569 569
     $options = '';
570
-    if ( $args['required'] ) {
570
+    if ($args['required']) {
571 571
         $options .= ' required="required"';
572 572
     }
573
-    if ( $args['readonly'] ) {
573
+    if ($args['readonly']) {
574 574
         $options .= ' readonly';
575 575
     }
576
-    if ( $args['readonly'] ) {
576
+    if ($args['readonly']) {
577 577
         $options .= ' readonly';
578 578
     }
579 579
 
580 580
     $data = '';
581
-    if ( ! empty( $args['data'] ) ) {
582
-        foreach ( $args['data'] as $key => $value ) {
583
-            $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" ';
581
+    if (!empty($args['data'])) {
582
+        foreach ($args['data'] as $key => $value) {
583
+            $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" ';
584 584
         }
585 585
     }
586 586
 
587
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
588
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
589
-    if ( ! empty( $args['desc'] ) ) {
590
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
587
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
588
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>';
589
+    if (!empty($args['desc'])) {
590
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
591 591
     }
592 592
 
593
-    $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>';
593
+    $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>';
594 594
 
595 595
     $output .= '</span>';
596 596
 
597 597
     return $output;
598 598
 }
599 599
 
600
-function wpinv_html_textarea( $args = array() ) {
600
+function wpinv_html_textarea($args = array()) {
601 601
     $defaults = array(
602 602
         'name'        => 'textarea',
603 603
         'value'       => null,
@@ -608,31 +608,31 @@  discard block
 block discarded – undo
608 608
         'placeholder' => '',
609 609
     );
610 610
 
611
-    $args = wp_parse_args( $args, $defaults );
611
+    $args = wp_parse_args($args, $defaults);
612 612
 
613
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
613
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
614 614
     $disabled = '';
615
-    if ( $args['disabled'] ) {
615
+    if ($args['disabled']) {
616 616
         $disabled = ' disabled="disabled"';
617 617
     }
618 618
 
619
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
620
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
621
-    $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
619
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
620
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>';
621
+    $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>';
622 622
 
623
-    if ( ! empty( $args['desc'] ) ) {
624
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
623
+    if (!empty($args['desc'])) {
624
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
625 625
     }
626 626
     $output .= '</span>';
627 627
 
628 628
     return $output;
629 629
 }
630 630
 
631
-function wpinv_html_ajax_user_search( $args = array() ) {
631
+function wpinv_html_ajax_user_search($args = array()) {
632 632
     $defaults = array(
633 633
         'name'         => 'user_id',
634 634
         'value'        => null,
635
-        'placeholder'  => __( 'Enter username', 'invoicing' ),
635
+        'placeholder'  => __('Enter username', 'invoicing'),
636 636
         'label'        => null,
637 637
         'desc'         => null,
638 638
         'class'        => '',
@@ -641,13 +641,13 @@  discard block
 block discarded – undo
641 641
         'data'         => false,
642 642
     );
643 643
 
644
-    $args = wp_parse_args( $args, $defaults );
644
+    $args = wp_parse_args($args, $defaults);
645 645
 
646 646
     $args['class'] = 'wpinv-ajax-user-search ' . $args['class'];
647 647
 
648 648
     $output  = '<span class="wpinv_user_search_wrap">';
649
-        $output .= wpinv_html_text( $args );
650
-        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>';
649
+        $output .= wpinv_html_text($args);
650
+        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>';
651 651
     $output .= '</span>';
652 652
 
653 653
     return $output;
@@ -658,44 +658,44 @@  discard block
 block discarded – undo
658 658
  *
659 659
  * @param string $template the template that is currently being used.
660 660
  */
661
-function wpinv_template( $template ) {
661
+function wpinv_template($template) {
662 662
     global $post;
663 663
 
664
-    if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) {
664
+    if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) {
665 665
 
666 666
         // If the user can view this invoice, display it.
667
-        if ( wpinv_user_can_view_invoice( $post->ID ) ) {
667
+        if (wpinv_user_can_view_invoice($post->ID)) {
668 668
 
669
-            return wpinv_get_template_part( 'wpinv-invoice-print', false, false );
669
+            return wpinv_get_template_part('wpinv-invoice-print', false, false);
670 670
 
671 671
         // Else display an error message.
672 672
         } else {
673 673
 
674
-            return wpinv_get_template_part( 'wpinv-invalid-access', false, false );
674
+            return wpinv_get_template_part('wpinv-invalid-access', false, false);
675 675
 
676 676
         }
677 677
 }
678 678
 
679 679
     return $template;
680 680
 }
681
-add_filter( 'template_include', 'wpinv_template', 10, 1 );
681
+add_filter('template_include', 'wpinv_template', 10, 1);
682 682
 
683 683
 function wpinv_get_business_address() {
684 684
     $business_address   = wpinv_store_address();
685
-    $business_address   = ! empty( $business_address ) ? wp_kses_post( wpautop( $business_address ) ) : '';
685
+    $business_address   = !empty($business_address) ? wp_kses_post(wpautop($business_address)) : '';
686 686
 
687 687
     $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : '';
688 688
 
689
-    return apply_filters( 'wpinv_get_business_address', $business_address );
689
+    return apply_filters('wpinv_get_business_address', $business_address);
690 690
 }
691 691
 
692 692
 /**
693 693
  * Displays the company address.
694 694
  */
695 695
 function wpinv_display_from_address() {
696
-    wpinv_get_template( 'invoice/company-address.php' );
696
+    wpinv_get_template('invoice/company-address.php');
697 697
 }
698
-add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 );
698
+add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10);
699 699
 
700 700
 /**
701 701
  * Generates a watermark text for an invoice.
@@ -703,9 +703,9 @@  discard block
 block discarded – undo
703 703
  * @param WPInv_Invoice $invoice
704 704
  * @return string
705 705
  */
706
-function wpinv_watermark( $invoice ) {
707
-    $watermark = wpinv_get_watermark( $invoice );
708
-    return apply_filters( 'wpinv_get_watermark', $watermark, $invoice );
706
+function wpinv_watermark($invoice) {
707
+    $watermark = wpinv_get_watermark($invoice);
708
+    return apply_filters('wpinv_get_watermark', $watermark, $invoice);
709 709
 }
710 710
 
711 711
 /**
@@ -714,37 +714,37 @@  discard block
 block discarded – undo
714 714
  * @param WPInv_Invoice $invoice
715 715
  * @return string
716 716
  */
717
-function wpinv_get_watermark( $invoice ) {
717
+function wpinv_get_watermark($invoice) {
718 718
     return $invoice->get_status_nicename();
719 719
 }
720 720
 
721 721
 /**
722 722
  * @deprecated
723 723
  */
724
-function wpinv_display_invoice_details( $invoice ) {
725
-    return getpaid_invoice_meta( $invoice );
724
+function wpinv_display_invoice_details($invoice) {
725
+    return getpaid_invoice_meta($invoice);
726 726
 }
727 727
 
728 728
 /**
729 729
  * Displays invoice meta.
730 730
  */
731
-function getpaid_invoice_meta( $invoice ) {
731
+function getpaid_invoice_meta($invoice) {
732 732
 
733
-    $invoice = new WPInv_Invoice( $invoice );
733
+    $invoice = new WPInv_Invoice($invoice);
734 734
 
735 735
     // Ensure that we have an invoice.
736
-    if ( 0 == $invoice->get_id() ) {
736
+    if (0 == $invoice->get_id()) {
737 737
         return;
738 738
     }
739 739
 
740 740
     // Get the invoice meta.
741
-    $meta = getpaid_get_invoice_meta( $invoice );
741
+    $meta = getpaid_get_invoice_meta($invoice);
742 742
 
743 743
     // Display the meta.
744
-    wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) );
744
+    wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta'));
745 745
 
746 746
 }
747
-add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 );
747
+add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10);
748 748
 
749 749
 /**
750 750
  * Retrieves the address markup to use on Invoices.
@@ -756,29 +756,29 @@  discard block
 block discarded – undo
756 756
  * @param  string $separator How to separate address lines.
757 757
  * @return string
758 758
  */
759
-function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) {
759
+function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') {
760 760
 
761 761
     // Retrieve the address markup...
762
-    $country = empty( $billing_details['country'] ) ? '' : $billing_details['country'];
763
-    $format = wpinv_get_full_address_format( $country );
762
+    $country = empty($billing_details['country']) ? '' : $billing_details['country'];
763
+    $format = wpinv_get_full_address_format($country);
764 764
 
765 765
     // ... and the replacements.
766
-    $replacements = wpinv_get_invoice_address_replacements( $billing_details );
766
+    $replacements = wpinv_get_invoice_address_replacements($billing_details);
767 767
 
768
-    $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
768
+    $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format);
769 769
 
770 770
 	// Remove unavailable tags.
771
-    $formatted_address = preg_replace( '/\{\{\w+\}\}/', '', $formatted_address );
771
+    $formatted_address = preg_replace('/\{\{\w+\}\}/', '', $formatted_address);
772 772
 
773 773
     // Clean up white space.
774
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
775
-    $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
774
+	$formatted_address = preg_replace('/  +/', ' ', trim($formatted_address));
775
+    $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address);
776 776
 
777 777
     // Break newlines apart and remove empty lines/trim commas and white space.
778
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
778
+	$formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address)));
779 779
 
780 780
     // Add html breaks.
781
-	$formatted_address = implode( $separator, $formatted_address );
781
+	$formatted_address = implode($separator, $formatted_address);
782 782
 
783 783
 	// We're done!
784 784
 	return $formatted_address;
@@ -790,118 +790,118 @@  discard block
 block discarded – undo
790 790
  *
791 791
  * @param WPInv_Invoice $invoice
792 792
  */
793
-function wpinv_display_to_address( $invoice = 0 ) {
794
-    if ( ! empty( $invoice ) ) {
795
-        wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) );
793
+function wpinv_display_to_address($invoice = 0) {
794
+    if (!empty($invoice)) {
795
+        wpinv_get_template('invoice/billing-address.php', compact('invoice'));
796 796
     }
797 797
 }
798
-add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 );
798
+add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40);
799 799
 
800 800
 
801 801
 /**
802 802
  * Displays invoice line items.
803 803
  */
804
-function wpinv_display_line_items( $invoice_id = 0 ) {
804
+function wpinv_display_line_items($invoice_id = 0) {
805 805
 
806 806
     // Prepare the invoice.
807
-    $invoice = new WPInv_Invoice( $invoice_id );
807
+    $invoice = new WPInv_Invoice($invoice_id);
808 808
 
809 809
     // Abort if there is no invoice.
810
-    if ( 0 == $invoice->get_id() ) {
810
+    if (0 == $invoice->get_id()) {
811 811
         return;
812 812
     }
813 813
 
814 814
     // Line item columns.
815
-    $columns = getpaid_invoice_item_columns( $invoice );
816
-    $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice );
815
+    $columns = getpaid_invoice_item_columns($invoice);
816
+    $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice);
817 817
 
818
-    wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) );
818
+    wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns'));
819 819
 }
820
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 );
820
+add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10);
821 821
 
822 822
 /**
823 823
  * Displays invoice subscriptions.
824 824
  *
825 825
  * @param WPInv_Invoice $invoice
826 826
  */
827
-function getpaid_display_invoice_subscriptions( $invoice ) {
827
+function getpaid_display_invoice_subscriptions($invoice) {
828 828
 
829 829
     // Subscriptions.
830
-	$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
830
+	$subscriptions = getpaid_get_invoice_subscriptions($invoice);
831 831
 
832
-    if ( empty( $subscriptions ) || ! $invoice->is_recurring() ) {
832
+    if (empty($subscriptions) || !$invoice->is_recurring()) {
833 833
         return;
834 834
     }
835 835
 
836
-    $main_subscription = getpaid_get_invoice_subscription( $invoice );
836
+    $main_subscription = getpaid_get_invoice_subscription($invoice);
837 837
 
838 838
     // Display related subscriptions.
839
-    if ( is_array( $subscriptions ) ) {
840
-        printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Subscriptions', 'invoicing' ) );
841
-        getpaid_admin_subscription_related_subscriptions_metabox( $main_subscription, false );
839
+    if (is_array($subscriptions)) {
840
+        printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Subscriptions', 'invoicing'));
841
+        getpaid_admin_subscription_related_subscriptions_metabox($main_subscription, false);
842 842
     }
843 843
 
844
-    if ( $main_subscription->get_total_payments() > 1 ) {
845
-        printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Invoices', 'invoicing' ) );
846
-        getpaid_admin_subscription_invoice_details_metabox( $main_subscription, false );
844
+    if ($main_subscription->get_total_payments() > 1) {
845
+        printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Invoices', 'invoicing'));
846
+        getpaid_admin_subscription_invoice_details_metabox($main_subscription, false);
847 847
     }
848 848
 
849 849
 }
850
-add_action( 'getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55 );
851
-add_action( 'wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11 );
850
+add_action('getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55);
851
+add_action('wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11);
852 852
 
853 853
 /**
854 854
  * Displays invoice notices on invoices.
855 855
  */
856 856
 function wpinv_display_invoice_notice() {
857 857
 
858
-    $label  = wpinv_get_option( 'vat_invoice_notice_label' );
859
-    $notice = wpinv_get_option( 'vat_invoice_notice' );
858
+    $label  = wpinv_get_option('vat_invoice_notice_label');
859
+    $notice = wpinv_get_option('vat_invoice_notice');
860 860
 
861
-    if ( empty( $label ) && empty( $notice ) ) {
861
+    if (empty($label) && empty($notice)) {
862 862
         return;
863 863
     }
864 864
 
865 865
     echo '<div class="mt-4 mb-4 wpinv-vat-notice">';
866 866
 
867
-    if ( ! empty( $label ) ) {
868
-        echo "<h5>" . esc_html( $label ) . "</h5>";
867
+    if (!empty($label)) {
868
+        echo "<h5>" . esc_html($label) . "</h5>";
869 869
     }
870 870
 
871
-    if ( ! empty( $notice ) ) {
872
-        echo '<small class="form-text text-muted">' . wp_kses_post( wpautop( wptexturize( $notice ) ) ) . '</small>';
871
+    if (!empty($notice)) {
872
+        echo '<small class="form-text text-muted">' . wp_kses_post(wpautop(wptexturize($notice))) . '</small>';
873 873
     }
874 874
 
875 875
     echo '</div>';
876 876
 }
877
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 );
877
+add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100);
878 878
 
879 879
 /**
880 880
  * @param WPInv_Invoice $invoice
881 881
  */
882
-function wpinv_display_invoice_notes( $invoice ) {
882
+function wpinv_display_invoice_notes($invoice) {
883 883
 
884 884
     // Retrieve the notes.
885
-    $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' );
885
+    $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer');
886 886
 
887 887
     // Abort if we have non.
888
-    if ( empty( $notes ) ) {
888
+    if (empty($notes)) {
889 889
         return;
890 890
     }
891 891
 
892 892
     // Echo the note.
893 893
     echo '<div class="getpaid-invoice-notes-wrapper position-relative my-4">';
894
-    echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . esc_html__( 'Notes', 'invoicing' ) . '</h2>';
894
+    echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . esc_html__('Notes', 'invoicing') . '</h2>';
895 895
     echo '<ul class="getpaid-invoice-notes text-break overflow-auto list-unstyled p-0 m-0">';
896 896
 
897
-    foreach ( $notes as $note ) {
898
-        wpinv_get_invoice_note_line_item( $note );
897
+    foreach ($notes as $note) {
898
+        wpinv_get_invoice_note_line_item($note);
899 899
     }
900 900
 
901 901
     echo '</ul>';
902 902
     echo '</div>';
903 903
 }
904
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 );
904
+add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60);
905 905
 
906 906
 /**
907 907
  * Loads scripts on our invoice templates.
@@ -909,32 +909,32 @@  discard block
 block discarded – undo
909 909
 function wpinv_display_style() {
910 910
 
911 911
     // Make sure that all scripts have been loaded.
912
-    if ( ! did_action( 'wp_enqueue_scripts' ) ) {
913
-        do_action( 'wp_enqueue_scripts' );
912
+    if (!did_action('wp_enqueue_scripts')) {
913
+        do_action('wp_enqueue_scripts');
914 914
     }
915 915
 
916 916
     // Register the invoices style.
917
-    wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) );
917
+    wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css'));
918 918
 
919 919
     // Load required styles
920
-    wp_print_styles( 'wpinv-single-style' );
921
-    wp_print_styles( 'ayecode-ui' );
920
+    wp_print_styles('wpinv-single-style');
921
+    wp_print_styles('ayecode-ui');
922 922
 
923 923
     // Maybe load custom css.
924
-    $custom_css = wpinv_get_option( 'template_custom_css' );
924
+    $custom_css = wpinv_get_option('template_custom_css');
925 925
 
926
-    if ( isset( $custom_css ) && ! empty( $custom_css ) ) {
927
-        $custom_css     = wp_kses( $custom_css, array( '\'', '\"' ) );
928
-        $custom_css     = str_replace( '&gt;', '>', $custom_css );
926
+    if (isset($custom_css) && !empty($custom_css)) {
927
+        $custom_css     = wp_kses($custom_css, array('\'', '\"'));
928
+        $custom_css     = str_replace('&gt;', '>', $custom_css);
929 929
         echo '<style type="text/css">';
930
-        echo wp_kses_post( $custom_css );
930
+        echo wp_kses_post($custom_css);
931 931
         echo '</style>';
932 932
     }
933 933
 
934 934
     wp_site_icon();
935 935
 }
936
-add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' );
937
-add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' );
936
+add_action('wpinv_invoice_print_head', 'wpinv_display_style');
937
+add_action('wpinv_invalid_invoice_head', 'wpinv_display_style');
938 938
 
939 939
 
940 940
 /**
@@ -946,41 +946,41 @@  discard block
 block discarded – undo
946 946
     // Retrieve the current invoice.
947 947
     $invoice_id = getpaid_get_current_invoice_id();
948 948
 
949
-    if ( empty( $invoice_id ) ) {
949
+    if (empty($invoice_id)) {
950 950
 
951 951
         return aui()->alert(
952 952
             array(
953 953
                 'type'    => 'warning',
954
-                'content' => __( 'Invalid invoice', 'invoicing' ),
954
+                'content' => __('Invalid invoice', 'invoicing'),
955 955
             )
956 956
         );
957 957
 
958 958
     }
959 959
 
960 960
     // Can the user view this invoice?
961
-    if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) {
961
+    if (!wpinv_user_can_view_invoice($invoice_id)) {
962 962
 
963 963
         return aui()->alert(
964 964
             array(
965 965
                 'type'    => 'warning',
966
-                'content' => __( 'You are not allowed to view this invoice', 'invoicing' ),
966
+                'content' => __('You are not allowed to view this invoice', 'invoicing'),
967 967
             )
968 968
         );
969 969
 
970 970
     }
971 971
 
972 972
     // Ensure that it is not yet paid for.
973
-    $invoice = new WPInv_Invoice( $invoice_id );
973
+    $invoice = new WPInv_Invoice($invoice_id);
974 974
 
975 975
     // Maybe mark it as viewed.
976
-    getpaid_maybe_mark_invoice_as_viewed( $invoice );
976
+    getpaid_maybe_mark_invoice_as_viewed($invoice);
977 977
 
978
-    if ( $invoice->is_paid() ) {
978
+    if ($invoice->is_paid()) {
979 979
 
980 980
         return aui()->alert(
981 981
             array(
982 982
                 'type'    => 'success',
983
-                'content' => __( 'This invoice has already been paid.', 'invoicing' ),
983
+                'content' => __('This invoice has already been paid.', 'invoicing'),
984 984
             )
985 985
         );
986 986
 
@@ -990,15 +990,15 @@  discard block
 block discarded – undo
990 990
     $wpi_checkout_id = $invoice_id;
991 991
 
992 992
     // Retrieve appropriate payment form.
993
-    $payment_form = new GetPaid_Payment_Form( $invoice->get_meta( 'force_payment_form' ) );
994
-    $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
993
+    $payment_form = new GetPaid_Payment_Form($invoice->get_meta('force_payment_form'));
994
+    $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form(wpinv_get_default_payment_form());
995 995
 
996
-    if ( ! $payment_form->exists() ) {
996
+    if (!$payment_form->exists()) {
997 997
 
998 998
         return aui()->alert(
999 999
             array(
1000 1000
                 'type'    => 'warning',
1001
-                'content' => __( 'Error loading the payment form', 'invoicing' ),
1001
+                'content' => __('Error loading the payment form', 'invoicing'),
1002 1002
             )
1003 1003
         );
1004 1004
 
@@ -1007,29 +1007,29 @@  discard block
 block discarded – undo
1007 1007
     // Set the invoice.
1008 1008
     $payment_form->invoice = $invoice;
1009 1009
 
1010
-    if ( ! $payment_form->is_default() ) {
1010
+    if (!$payment_form->is_default()) {
1011 1011
 
1012 1012
         $items    = array();
1013 1013
         $item_ids = array();
1014 1014
 
1015
-        foreach ( $invoice->get_items() as $item ) {
1016
-            if ( ! in_array( $item->get_id(), $item_ids ) ) {
1015
+        foreach ($invoice->get_items() as $item) {
1016
+            if (!in_array($item->get_id(), $item_ids)) {
1017 1017
                 $item_ids[] = $item->get_id();
1018 1018
                 $items[]    = $item;
1019 1019
             }
1020 1020
         }
1021 1021
 
1022
-        foreach ( $payment_form->get_items() as $item ) {
1023
-            if ( ! in_array( $item->get_id(), $item_ids ) ) {
1022
+        foreach ($payment_form->get_items() as $item) {
1023
+            if (!in_array($item->get_id(), $item_ids)) {
1024 1024
                 $item_ids[] = $item->get_id();
1025 1025
                 $items[]    = $item;
1026 1026
             }
1027 1027
         }
1028 1028
 
1029
-        $payment_form->set_items( $items );
1029
+        $payment_form->set_items($items);
1030 1030
 
1031 1031
     } else {
1032
-        $payment_form->set_items( $invoice->get_items() );
1032
+        $payment_form->set_items($invoice->get_items());
1033 1033
     }
1034 1034
 
1035 1035
     // Generate the html.
@@ -1038,7 +1038,7 @@  discard block
 block discarded – undo
1038 1038
 }
1039 1039
 
1040 1040
 function wpinv_empty_cart_message() {
1041
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1041
+	return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>');
1042 1042
 }
1043 1043
 
1044 1044
 /**
@@ -1056,76 +1056,76 @@  discard block
 block discarded – undo
1056 1056
         true
1057 1057
     );
1058 1058
 }
1059
-add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' );
1059
+add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart');
1060 1060
 
1061 1061
 /**
1062 1062
  * Filters the receipt page.
1063 1063
  */
1064
-function wpinv_filter_success_page_content( $content ) {
1064
+function wpinv_filter_success_page_content($content) {
1065 1065
 
1066 1066
     // Maybe abort early.
1067
-    if ( is_admin() || ! is_singular() || ! in_the_loop() || ! is_main_query() || is_preview() ) {
1067
+    if (is_admin() || !is_singular() || !in_the_loop() || !is_main_query() || is_preview()) {
1068 1068
         return $content;
1069 1069
     }
1070 1070
 
1071 1071
     // Ensure this is our page.
1072
-    if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) {
1072
+    if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) {
1073 1073
 
1074
-        $gateway = sanitize_text_field( $_GET['payment-confirm'] );
1075
-        return apply_filters( "wpinv_payment_confirm_$gateway", $content );
1074
+        $gateway = sanitize_text_field($_GET['payment-confirm']);
1075
+        return apply_filters("wpinv_payment_confirm_$gateway", $content);
1076 1076
 
1077 1077
     }
1078 1078
 
1079 1079
     return $content;
1080 1080
 }
1081
-add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 );
1081
+add_filter('the_content', 'wpinv_filter_success_page_content', 99999);
1082 1082
 
1083
-function wpinv_invoice_link( $invoice_id ) {
1084
-    $invoice = wpinv_get_invoice( $invoice_id );
1083
+function wpinv_invoice_link($invoice_id) {
1084
+    $invoice = wpinv_get_invoice($invoice_id);
1085 1085
 
1086
-    if ( empty( $invoice ) ) {
1086
+    if (empty($invoice)) {
1087 1087
         return null;
1088 1088
     }
1089 1089
 
1090
-    $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>';
1090
+    $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>';
1091 1091
 
1092
-    return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice );
1092
+    return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice);
1093 1093
 }
1094 1094
 
1095
-function wpinv_get_invoice_note_line_item( $note, $echo = true ) {
1096
-    if ( empty( $note ) ) {
1095
+function wpinv_get_invoice_note_line_item($note, $echo = true) {
1096
+    if (empty($note)) {
1097 1097
         return null;
1098 1098
     }
1099 1099
 
1100
-    if ( is_int( $note ) ) {
1101
-        $note = get_comment( $note );
1100
+    if (is_int($note)) {
1101
+        $note = get_comment($note);
1102 1102
     }
1103 1103
 
1104
-    if ( ! ( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) {
1104
+    if (!(is_object($note) && is_a($note, 'WP_Comment'))) {
1105 1105
         return null;
1106 1106
     }
1107 1107
 
1108
-    $note_classes   = array( 'note' );
1109
-    $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : '';
1108
+    $note_classes   = array('note');
1109
+    $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : '';
1110 1110
     $note_classes[] = $note->comment_author === 'System' ? 'system-note' : '';
1111
-    $note_classes   = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note );
1112
-    $note_classes   = ! empty( $note_classes ) ? implode( ' ', $note_classes ) : '';
1111
+    $note_classes   = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note);
1112
+    $note_classes   = !empty($note_classes) ? implode(' ', $note_classes) : '';
1113 1113
 
1114 1114
     ob_start();
1115 1115
     ?>
1116
-    <li rel="<?php echo absint( $note->comment_ID ); ?>" class="<?php echo esc_attr( $note_classes ); ?> mb-2">
1116
+    <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mb-2">
1117 1117
         <div class="note_content">
1118 1118
 
1119
-            <?php echo wp_kses_post( wptexturize( $note->comment_content ) ); ?>
1119
+            <?php echo wp_kses_post(wptexturize($note->comment_content)); ?>
1120 1120
 
1121
-            <?php if ( ! is_admin() ) : ?>
1121
+            <?php if (!is_admin()) : ?>
1122 1122
                 <em class="small form-text text-muted mt-0">
1123 1123
                     <?php
1124 1124
                         printf(
1125
-                            esc_html__( '%1$s - %2$s at %3$s', 'invoicing' ),
1126
-                            esc_html( $note->comment_author ),
1127
-                            esc_html( getpaid_format_date_value( $note->comment_date ) ),
1128
-                            esc_html( date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) )
1125
+                            esc_html__('%1$s - %2$s at %3$s', 'invoicing'),
1126
+                            esc_html($note->comment_author),
1127
+                            esc_html(getpaid_format_date_value($note->comment_date)),
1128
+                            esc_html(date_i18n(get_option('time_format'), strtotime($note->comment_date)))
1129 1129
                         );
1130 1130
                     ?>
1131 1131
                 </em>
@@ -1133,21 +1133,21 @@  discard block
 block discarded – undo
1133 1133
 
1134 1134
         </div>
1135 1135
 
1136
-        <?php if ( is_admin() ) : ?>
1136
+        <?php if (is_admin()) : ?>
1137 1137
 
1138 1138
             <p class="meta px-4 py-2">
1139
-                <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>">
1139
+                <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>">
1140 1140
                     <?php
1141 1141
                         printf(
1142
-                            esc_html__( '%1$s - %2$s at %3$s', 'invoicing' ),
1143
-                            esc_html( $note->comment_author ),
1144
-                            esc_html( getpaid_format_date_value( $note->comment_date ) ),
1145
-                            esc_html( date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) )
1142
+                            esc_html__('%1$s - %2$s at %3$s', 'invoicing'),
1143
+                            esc_html($note->comment_author),
1144
+                            esc_html(getpaid_format_date_value($note->comment_date)),
1145
+                            esc_html(date_i18n(get_option('time_format'), strtotime($note->comment_date)))
1146 1146
                         );
1147 1147
                     ?>
1148 1148
                 </abbr>&nbsp;&nbsp;
1149
-                <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?>
1150
-                    <a href="#" class="delete_note"><?php esc_html_e( 'Delete note', 'invoicing' ); ?></a>
1149
+                <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?>
1150
+                    <a href="#" class="delete_note"><?php esc_html_e('Delete note', 'invoicing'); ?></a>
1151 1151
                 <?php } ?>
1152 1152
             </p>
1153 1153
 
@@ -1156,10 +1156,10 @@  discard block
 block discarded – undo
1156 1156
     </li>
1157 1157
     <?php
1158 1158
     $note_content = ob_get_clean();
1159
-    $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo );
1159
+    $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo);
1160 1160
 
1161
-    if ( $echo ) {
1162
-        echo wp_kses_post( $note_content );
1161
+    if ($echo) {
1162
+        echo wp_kses_post($note_content);
1163 1163
     } else {
1164 1164
         return $note_content;
1165 1165
     }
@@ -1172,43 +1172,43 @@  discard block
 block discarded – undo
1172 1172
  * @return string
1173 1173
  */
1174 1174
 function wpinv_get_policy_text() {
1175
-    $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 );
1175
+    $privacy_page_id = get_option('wp_page_for_privacy_policy', 0);
1176 1176
 
1177
-    $text = wpinv_get_option( 'invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' ) );
1177
+    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]'));
1178 1178
 
1179
-    if ( ! $privacy_page_id ) {
1180
-        $privacy_page_id = wpinv_get_option( 'privacy_page', 0 );
1179
+    if (!$privacy_page_id) {
1180
+        $privacy_page_id = wpinv_get_option('privacy_page', 0);
1181 1181
     }
1182 1182
 
1183
-    $privacy_link    = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' );
1183
+    $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing');
1184 1184
 
1185 1185
     $find_replace = array(
1186 1186
         '[wpinv_privacy_policy]' => $privacy_link,
1187 1187
     );
1188 1188
 
1189
-    $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text );
1189
+    $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text);
1190 1190
 
1191
-    return wp_kses_post( wpautop( $privacy_text ) );
1191
+    return wp_kses_post(wpautop($privacy_text));
1192 1192
 }
1193 1193
 
1194 1194
 function wpinv_oxygen_fix_conflict() {
1195 1195
     global $ct_ignore_post_types;
1196 1196
 
1197
-    if ( ! is_array( $ct_ignore_post_types ) ) {
1197
+    if (!is_array($ct_ignore_post_types)) {
1198 1198
         $ct_ignore_post_types = array();
1199 1199
     }
1200 1200
 
1201
-    $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form' );
1201
+    $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form');
1202 1202
 
1203
-    foreach ( $post_types as $post_type ) {
1203
+    foreach ($post_types as $post_type) {
1204 1204
         $ct_ignore_post_types[] = $post_type;
1205 1205
 
1206 1206
         // Ignore post type
1207
-        add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 );
1207
+        add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999);
1208 1208
     }
1209 1209
 
1210
-    remove_filter( 'template_include', 'wpinv_template', 10, 1 );
1211
-    add_filter( 'template_include', 'wpinv_template', 999, 1 );
1210
+    remove_filter('template_include', 'wpinv_template', 10, 1);
1211
+    add_filter('template_include', 'wpinv_template', 999, 1);
1212 1212
 }
1213 1213
 
1214 1214
 /**
@@ -1216,10 +1216,10 @@  discard block
 block discarded – undo
1216 1216
  *
1217 1217
  * @param GetPaid_Payment_Form $form
1218 1218
  */
1219
-function getpaid_display_payment_form( $form ) {
1219
+function getpaid_display_payment_form($form) {
1220 1220
 
1221
-    if ( is_numeric( $form ) ) {
1222
-        $form = new GetPaid_Payment_Form( $form );
1221
+    if (is_numeric($form)) {
1222
+        $form = new GetPaid_Payment_Form($form);
1223 1223
     }
1224 1224
 
1225 1225
     $form->display();
@@ -1229,61 +1229,61 @@  discard block
 block discarded – undo
1229 1229
 /**
1230 1230
  * Helper function to display a item payment form on the frontend.
1231 1231
  */
1232
-function getpaid_display_item_payment_form( $items ) {
1232
+function getpaid_display_item_payment_form($items) {
1233 1233
 
1234
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1235
-    $form->set_items( $items );
1234
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1235
+    $form->set_items($items);
1236 1236
 
1237
-    if ( 0 == count( $form->get_items() ) ) {
1237
+    if (0 == count($form->get_items())) {
1238 1238
         aui()->alert(
1239 1239
 			array(
1240 1240
 				'type'    => 'warning',
1241
-				'content' => __( 'No published items found', 'invoicing' ),
1241
+				'content' => __('No published items found', 'invoicing'),
1242 1242
             ),
1243 1243
             true
1244 1244
         );
1245 1245
         return;
1246 1246
     }
1247 1247
 
1248
-    $extra_items     = esc_attr( getpaid_convert_items_to_string( $items ) );
1249
-    $extra_items_key = md5( NONCE_KEY . AUTH_KEY . $extra_items );
1248
+    $extra_items     = esc_attr(getpaid_convert_items_to_string($items));
1249
+    $extra_items_key = md5(NONCE_KEY . AUTH_KEY . $extra_items);
1250 1250
     $extra_items     = "<input type='hidden' name='getpaid-form-items' value='$extra_items' />";
1251 1251
     $extra_items    .= "<input type='hidden' name='getpaid-form-items-key' value='$extra_items_key' />";
1252 1252
 
1253
-    $form->display( $extra_items );
1253
+    $form->display($extra_items);
1254 1254
 }
1255 1255
 
1256 1256
 /**
1257 1257
  * Helper function to display an invoice payment form on the frontend.
1258 1258
  */
1259
-function getpaid_display_invoice_payment_form( $invoice_id ) {
1259
+function getpaid_display_invoice_payment_form($invoice_id) {
1260 1260
 
1261
-    $invoice = wpinv_get_invoice( $invoice_id );
1261
+    $invoice = wpinv_get_invoice($invoice_id);
1262 1262
 
1263
-    if ( empty( $invoice ) ) {
1263
+    if (empty($invoice)) {
1264 1264
 		aui()->alert(
1265 1265
 			array(
1266 1266
 				'type'    => 'warning',
1267
-				'content' => __( 'Invoice not found', 'invoicing' ),
1267
+				'content' => __('Invoice not found', 'invoicing'),
1268 1268
             ),
1269 1269
             true
1270 1270
         );
1271 1271
         return;
1272 1272
     }
1273 1273
 
1274
-    if ( $invoice->is_paid() ) {
1274
+    if ($invoice->is_paid()) {
1275 1275
 		aui()->alert(
1276 1276
 			array(
1277 1277
 				'type'    => 'warning',
1278
-				'content' => __( 'Invoice has already been paid', 'invoicing' ),
1278
+				'content' => __('Invoice has already been paid', 'invoicing'),
1279 1279
             ),
1280 1280
             true
1281 1281
         );
1282 1282
         return;
1283 1283
     }
1284 1284
 
1285
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1286
-    $form->set_items( $invoice->get_items() );
1285
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1286
+    $form->set_items($invoice->get_items());
1287 1287
 
1288 1288
     $form->display();
1289 1289
 }
@@ -1291,23 +1291,23 @@  discard block
 block discarded – undo
1291 1291
 /**
1292 1292
  * Helper function to convert item string to array.
1293 1293
  */
1294
-function getpaid_convert_items_to_array( $items ) {
1295
-    $items    = array_filter( array_map( 'trim', explode( ',', $items ) ) );
1294
+function getpaid_convert_items_to_array($items) {
1295
+    $items    = array_filter(array_map('trim', explode(',', $items)));
1296 1296
     $prepared = array();
1297 1297
 
1298
-    foreach ( $items as $item ) {
1299
-        $data = array_map( 'trim', explode( '|', $item ) );
1298
+    foreach ($items as $item) {
1299
+        $data = array_map('trim', explode('|', $item));
1300 1300
 
1301
-        if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) {
1301
+        if (empty($data[0]) || !is_numeric($data[0])) {
1302 1302
             continue;
1303 1303
         }
1304 1304
 
1305 1305
         $quantity = 1;
1306
-        if ( isset( $data[1] ) && is_numeric( $data[1] ) ) {
1306
+        if (isset($data[1]) && is_numeric($data[1])) {
1307 1307
             $quantity = (float) $data[1];
1308 1308
         }
1309 1309
 
1310
-        $prepared[ $data[0] ] = $quantity;
1310
+        $prepared[$data[0]] = $quantity;
1311 1311
 
1312 1312
     }
1313 1313
 
@@ -1317,13 +1317,13 @@  discard block
 block discarded – undo
1317 1317
 /**
1318 1318
  * Helper function to convert item array to string.
1319 1319
  */
1320
-function getpaid_convert_items_to_string( $items ) {
1320
+function getpaid_convert_items_to_string($items) {
1321 1321
     $prepared = array();
1322 1322
 
1323
-    foreach ( $items as $item => $quantity ) {
1323
+    foreach ($items as $item => $quantity) {
1324 1324
         $prepared[] = "$item|$quantity";
1325 1325
     }
1326
-    return implode( ',', $prepared );
1326
+    return implode(',', $prepared);
1327 1327
 }
1328 1328
 
1329 1329
 /**
@@ -1331,21 +1331,21 @@  discard block
 block discarded – undo
1331 1331
  *
1332 1332
  * Provide a label and one of $form, $items or $invoice.
1333 1333
  */
1334
-function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) {
1335
-    $label = sanitize_text_field( $label );
1334
+function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) {
1335
+    $label = sanitize_text_field($label);
1336 1336
 
1337
-    if ( ! empty( $form ) ) {
1338
-        $form  = esc_attr( $form );
1337
+    if (!empty($form)) {
1338
+        $form = esc_attr($form);
1339 1339
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>";
1340 1340
     }
1341 1341
 
1342
-	if ( ! empty( $items ) ) {
1343
-        $items  = esc_attr( $items );
1342
+	if (!empty($items)) {
1343
+        $items = esc_attr($items);
1344 1344
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>";
1345 1345
     }
1346 1346
 
1347
-    if ( ! empty( $invoice ) ) {
1348
-        $invoice  = esc_attr( $invoice );
1347
+    if (!empty($invoice)) {
1348
+        $invoice = esc_attr($invoice);
1349 1349
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-invoice='$invoice'>$label</button>";
1350 1350
     }
1351 1351
 
@@ -1356,17 +1356,17 @@  discard block
 block discarded – undo
1356 1356
  *
1357 1357
  * @param WPInv_Invoice $invoice
1358 1358
  */
1359
-function getpaid_the_invoice_description( $invoice ) {
1359
+function getpaid_the_invoice_description($invoice) {
1360 1360
     $description = $invoice->get_description();
1361 1361
 
1362
-    if ( empty( $description ) ) {
1362
+    if (empty($description)) {
1363 1363
         return;
1364 1364
     }
1365 1365
 
1366
-    echo "<small class='getpaid-invoice-description text-dark p-2 form-text' style='margin-bottom: 20px; border-left: 2px solid #2196F3;'><em>" . wp_kses_post( wpautop( $description ) ) . "</em></small>";
1366
+    echo "<small class='getpaid-invoice-description text-dark p-2 form-text' style='margin-bottom: 20px; border-left: 2px solid #2196F3;'><em>" . wp_kses_post(wpautop($description)) . "</em></small>";
1367 1367
 }
1368
-add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 );
1369
-add_action( 'wpinv_email_billing_details', 'getpaid_the_invoice_description', 100 );
1368
+add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100);
1369
+add_action('wpinv_email_billing_details', 'getpaid_the_invoice_description', 100);
1370 1370
 
1371 1371
 /**
1372 1372
  * Render element on a form.
@@ -1374,71 +1374,71 @@  discard block
 block discarded – undo
1374 1374
  * @param array $element
1375 1375
  * @param GetPaid_Payment_Form $form
1376 1376
  */
1377
-function getpaid_payment_form_element( $element, $form ) {
1377
+function getpaid_payment_form_element($element, $form) {
1378 1378
 
1379 1379
     // Set up the args.
1380
-    $element_type    = trim( $element['type'] );
1380
+    $element_type    = trim($element['type']);
1381 1381
     $element['form'] = $form;
1382
-    extract( $element );
1382
+    extract($element);
1383 1383
 
1384 1384
     // Try to locate the appropriate template.
1385
-    $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" );
1385
+    $located = wpinv_locate_template("payment-forms/elements/$element_type.php");
1386 1386
 
1387 1387
     // Abort if this is not our element.
1388
-    if ( empty( $located ) || ! file_exists( $located ) ) {
1388
+    if (empty($located) || !file_exists($located)) {
1389 1389
         return;
1390 1390
     }
1391 1391
 
1392 1392
     // Generate the class and id of the element.
1393
-    $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) );
1394
-    $id            = isset( $id ) ? $id : uniqid( 'gp' );
1393
+    $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type));
1394
+    $id            = isset($id) ? $id : uniqid('gp');
1395 1395
 
1396 1396
     // Echo the opening wrapper.
1397
-    echo "<div class='getpaid-payment-form-element " . esc_attr( $wrapper_class ) . "'>";
1397
+    echo "<div class='getpaid-payment-form-element " . esc_attr($wrapper_class) . "'>";
1398 1398
 
1399 1399
     // Fires before displaying a given element type's content.
1400
-    do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form );
1400
+    do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form);
1401 1401
 
1402 1402
     // Include the template for the element.
1403 1403
     include $located;
1404 1404
 
1405 1405
     // Fires after displaying a given element type's content.
1406
-    do_action( "getpaid_payment_form_{$element_type}_element", $element, $form );
1406
+    do_action("getpaid_payment_form_{$element_type}_element", $element, $form);
1407 1407
 
1408 1408
     // Echo the closing wrapper.
1409 1409
     echo '</div>';
1410 1410
 }
1411
-add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 );
1411
+add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2);
1412 1412
 
1413 1413
 /**
1414 1414
  * Render an element's edit page.
1415 1415
  *
1416 1416
  * @param WP_Post $post
1417 1417
  */
1418
-function getpaid_payment_form_edit_element_template( $post ) {
1418
+function getpaid_payment_form_edit_element_template($post) {
1419 1419
 
1420 1420
     // Retrieve all elements.
1421
-    $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' );
1421
+    $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type');
1422 1422
 
1423
-    foreach ( $all_elements as $element ) {
1423
+    foreach ($all_elements as $element) {
1424 1424
 
1425 1425
         // Try to locate the appropriate template.
1426
-        $element = esc_attr( sanitize_key( $element ) );
1427
-        $located = wpinv_locate_template( "payment-forms-admin/edit/$element.php" );
1426
+        $element = esc_attr(sanitize_key($element));
1427
+        $located = wpinv_locate_template("payment-forms-admin/edit/$element.php");
1428 1428
 
1429 1429
         // Continue if this is not our element.
1430
-        if ( empty( $located ) || ! file_exists( $located ) ) {
1430
+        if (empty($located) || !file_exists($located)) {
1431 1431
             continue;
1432 1432
         }
1433 1433
 
1434 1434
         // Include the template for the element.
1435
-        echo "<div v-if=\"active_form_element.type=='" . esc_attr( $element ) . "'\">";
1435
+        echo "<div v-if=\"active_form_element.type=='" . esc_attr($element) . "'\">";
1436 1436
         include $located;
1437 1437
         echo '</div>';
1438 1438
     }
1439 1439
 
1440 1440
 }
1441
-add_action( 'getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template' );
1441
+add_action('getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template');
1442 1442
 
1443 1443
 /**
1444 1444
  * Render an element's preview.
@@ -1447,27 +1447,27 @@  discard block
 block discarded – undo
1447 1447
 function getpaid_payment_form_render_element_preview_template() {
1448 1448
 
1449 1449
     // Retrieve all elements.
1450
-    $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' );
1450
+    $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type');
1451 1451
 
1452
-    foreach ( $all_elements as $element ) {
1452
+    foreach ($all_elements as $element) {
1453 1453
 
1454 1454
         // Try to locate the appropriate template.
1455
-        $element = sanitize_key( $element );
1456
-        $located = wpinv_locate_template( "payment-forms-admin/previews/$element.php" );
1455
+        $element = sanitize_key($element);
1456
+        $located = wpinv_locate_template("payment-forms-admin/previews/$element.php");
1457 1457
 
1458 1458
         // Continue if this is not our element.
1459
-        if ( empty( $located ) || ! file_exists( $located ) ) {
1459
+        if (empty($located) || !file_exists($located)) {
1460 1460
             continue;
1461 1461
         }
1462 1462
 
1463 1463
         // Include the template for the element.
1464
-        echo "<div v-if=\"form_element.type=='" . esc_html( $element ) . "'\">";
1464
+        echo "<div v-if=\"form_element.type=='" . esc_html($element) . "'\">";
1465 1465
         include $located;
1466 1466
         echo '</div>';
1467 1467
     }
1468 1468
 
1469 1469
 }
1470
-add_action( 'wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template' );
1470
+add_action('wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template');
1471 1471
 
1472 1472
 /**
1473 1473
  * Shows a list of gateways that support recurring payments.
@@ -1475,17 +1475,17 @@  discard block
 block discarded – undo
1475 1475
 function wpinv_get_recurring_gateways_text() {
1476 1476
     $gateways = array();
1477 1477
 
1478
-    foreach ( wpinv_get_payment_gateways() as $key => $gateway ) {
1479
-        if ( wpinv_gateway_support_subscription( $key ) ) {
1480
-            $gateways[] = sanitize_text_field( $gateway['admin_label'] );
1478
+    foreach (wpinv_get_payment_gateways() as $key => $gateway) {
1479
+        if (wpinv_gateway_support_subscription($key)) {
1480
+            $gateways[] = sanitize_text_field($gateway['admin_label']);
1481 1481
         }
1482 1482
     }
1483 1483
 
1484
-    if ( empty( $gateways ) ) {
1485
-        return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) . '</span>';
1484
+    if (empty($gateways)) {
1485
+        return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . '</span>';
1486 1486
     }
1487 1487
 
1488
-    return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) . '</span>';
1488
+    return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . '</span>';
1489 1489
 
1490 1490
 }
1491 1491
 
@@ -1495,7 +1495,7 @@  discard block
 block discarded – undo
1495 1495
  * @return GetPaid_Template
1496 1496
  */
1497 1497
 function getpaid_template() {
1498
-    return getpaid()->get( 'template' );
1498
+    return getpaid()->get('template');
1499 1499
 }
1500 1500
 
1501 1501
 /**
@@ -1504,8 +1504,8 @@  discard block
 block discarded – undo
1504 1504
  * @param array args
1505 1505
  * @return string
1506 1506
  */
1507
-function getpaid_paginate_links( $args ) {
1508
-    return str_replace( 'page-link dots', 'page-link text-dark', aui()->pagination( $args ) );
1507
+function getpaid_paginate_links($args) {
1508
+    return str_replace('page-link dots', 'page-link text-dark', aui()->pagination($args));
1509 1509
 }
1510 1510
 
1511 1511
 /**
@@ -1515,22 +1515,22 @@  discard block
 block discarded – undo
1515 1515
  * @param string state
1516 1516
  * @return string
1517 1517
  */
1518
-function getpaid_get_states_select_markup( $country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state', $echo = false ) {
1518
+function getpaid_get_states_select_markup($country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state', $echo = false) {
1519 1519
 
1520
-    $states = wpinv_get_country_states( $country );
1521
-    $uniqid = uniqid( '_' );
1520
+    $states = wpinv_get_country_states($country);
1521
+    $uniqid = uniqid('_');
1522 1522
 
1523
-    if ( ! empty( $states ) ) {
1523
+    if (!empty($states)) {
1524 1524
 
1525 1525
         return aui()->select(
1526 1526
             array(
1527 1527
 				'options'          => $states,
1528
-				'name'             => esc_attr( $field_name ),
1529
-				'id'               => sanitize_html_class( $field_name ) . $uniqid,
1530
-				'value'            => sanitize_text_field( $state ),
1528
+				'name'             => esc_attr($field_name),
1529
+				'id'               => sanitize_html_class($field_name) . $uniqid,
1530
+				'value'            => sanitize_text_field($state),
1531 1531
 				'placeholder'      => $placeholder,
1532 1532
 				'required'         => $required,
1533
-				'label'            => wp_kses_post( $label ),
1533
+				'label'            => wp_kses_post($label),
1534 1534
 				'label_type'       => 'vertical',
1535 1535
 				'help_text'        => $help_text,
1536 1536
 				'class'            => 'getpaid-address-field wpinv_state',
@@ -1547,14 +1547,14 @@  discard block
 block discarded – undo
1547 1547
 
1548 1548
     return aui()->input(
1549 1549
         array(
1550
-            'name'             => esc_attr( $field_name ),
1551
-            'id'               => sanitize_html_class( $field_name ) . $uniqid,
1550
+            'name'             => esc_attr($field_name),
1551
+            'id'               => sanitize_html_class($field_name) . $uniqid,
1552 1552
             'placeholder'      => $placeholder,
1553 1553
             'required'         => $required,
1554
-            'label'            => wp_kses_post( $label ),
1554
+            'label'            => wp_kses_post($label),
1555 1555
             'label_type'       => 'vertical',
1556 1556
             'help_text'        => $help_text,
1557
-            'value'            => sanitize_text_field( $state ),
1557
+            'value'            => sanitize_text_field($state),
1558 1558
             'class'            => 'getpaid-address-field wpinv_state',
1559 1559
             'wrap_class'       => "$wrapper_class getpaid-address-field-wrapper__state",
1560 1560
             'label_class'      => 'getpaid-address-field-label getpaid-address-field-label__state',
@@ -1573,16 +1573,16 @@  discard block
 block discarded – undo
1573 1573
  * @param array $element
1574 1574
  * @return string
1575 1575
  */
1576
-function getpaid_get_form_element_grid_class( $element ) {
1576
+function getpaid_get_form_element_grid_class($element) {
1577 1577
 
1578 1578
     $class = 'col-12';
1579
-    $width = empty( $element['grid_width'] ) ? 'full' : $element['grid_width'];
1579
+    $width = empty($element['grid_width']) ? 'full' : $element['grid_width'];
1580 1580
 
1581
-    if ( $width == 'half' ) {
1581
+    if ($width == 'half') {
1582 1582
         $class .= ' col-md-6';
1583 1583
     }
1584 1584
 
1585
-    if ( $width == 'third' ) {
1585
+    if ($width == 'third') {
1586 1586
         $class .= ' col-md-4';
1587 1587
     }
1588 1588
 
@@ -1597,15 +1597,15 @@  discard block
 block discarded – undo
1597 1597
  *
1598 1598
  * @return string
1599 1599
  */
1600
-function getpaid_embed_url( $payment_form = false, $items = false ) {
1600
+function getpaid_embed_url($payment_form = false, $items = false) {
1601 1601
 
1602 1602
     return add_query_arg(
1603 1603
         array(
1604 1604
             'getpaid_embed' => 1,
1605
-            'form'          => $payment_form ? absint( $payment_form ) : false,
1606
-            'item'          => $items ? urlencode( $items ) : false,
1605
+            'form'          => $payment_form ? absint($payment_form) : false,
1606
+            'item'          => $items ? urlencode($items) : false,
1607 1607
         ),
1608
-        home_url( 'index.php' )
1608
+        home_url('index.php')
1609 1609
     );
1610 1610
 
1611 1611
 }
@@ -1615,13 +1615,13 @@  discard block
 block discarded – undo
1615 1615
  *
1616 1616
  * @return string
1617 1617
  */
1618
-function getpaid_filter_embed_template( $template ) {
1618
+function getpaid_filter_embed_template($template) {
1619 1619
 
1620
-    if ( isset( $_GET['getpaid_embed'] ) ) {
1621
-        wpinv_get_template( 'payment-forms/embed.php' );
1620
+    if (isset($_GET['getpaid_embed'])) {
1621
+        wpinv_get_template('payment-forms/embed.php');
1622 1622
         exit;
1623 1623
     }
1624 1624
 
1625 1625
     return $template;
1626 1626
 }
1627
-add_filter( 'template_include', 'getpaid_filter_embed_template' );
1627
+add_filter('template_include', 'getpaid_filter_embed_template');
Please login to merge, or discard this patch.
includes/admin/views/html-tax-rate-edit.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @var array $tax_rate
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 ?>
12 12
 
@@ -18,13 +18,13 @@  discard block
 block discarded – undo
18 18
             aui()->select(
19 19
                 array(
20 20
                     'options' => array_merge(
21
-                        array( '' => __( 'All Countries', 'invoicing' ) ),
21
+                        array('' => __('All Countries', 'invoicing')),
22 22
                         wpinv_get_country_list()
23 23
                     ),
24 24
                     'name'    => "tax_rates[$key][country]",
25
-                    'id'      => uniqid( 'tax_rate_country' ),
26
-                    'value'   => esc_html( $tax_rate['country'] ),
27
-                    'label'   => __( 'Country', 'invoicing' ),
25
+                    'id'      => uniqid('tax_rate_country'),
26
+                    'value'   => esc_html($tax_rate['country']),
27
+                    'label'   => __('Country', 'invoicing'),
28 28
                     'class'   => 'wpinv_country',
29 29
                     'no_wrap' => true,
30 30
                 ),
@@ -37,35 +37,35 @@  discard block
 block discarded – undo
37 37
     <td class="wpinv_tax_state">
38 38
 
39 39
         <label class="w-100">
40
-            <span class="screen-reader-text"><?php esc_html_e( 'States', 'invoicing' ); ?></span>
41
-            <input type="text" placeholder="<?php esc_attr_e( 'Apply to whole country', 'invoicing' ); ?>" name="tax_rates[<?php echo esc_attr( $key ); ?>][state]" value="<?php echo empty( $tax_rate['global'] ) ? esc_attr( $tax_rate['state'] ) : ''; ?>"/>
40
+            <span class="screen-reader-text"><?php esc_html_e('States', 'invoicing'); ?></span>
41
+            <input type="text" placeholder="<?php esc_attr_e('Apply to whole country', 'invoicing'); ?>" name="tax_rates[<?php echo esc_attr($key); ?>][state]" value="<?php echo empty($tax_rate['global']) ? esc_attr($tax_rate['state']) : ''; ?>"/>
42 42
         </label>
43 43
 
44 44
     </td>
45 45
 
46 46
     <td class="wpinv_standard_rate">
47 47
         <label class="w-100">
48
-            <span class="screen-reader-text"><?php esc_html_e( 'Standard Rate', 'invoicing' ); ?></span>
49
-            <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr( $key ); ?>][rate]" value="<?php echo esc_attr( $tax_rate['rate'] ); ?>"/>
48
+            <span class="screen-reader-text"><?php esc_html_e('Standard Rate', 'invoicing'); ?></span>
49
+            <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr($key); ?>][rate]" value="<?php echo esc_attr($tax_rate['rate']); ?>"/>
50 50
         </label>
51 51
     </td>
52 52
 
53 53
     <td class="wpinv_reduced_rate">
54 54
         <label class="w-100">
55
-            <span class="screen-reader-text"><?php esc_html_e( 'Reduced Rate', 'invoicing' ); ?></span>
56
-            <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr( $key ); ?>][reduced_rate]" value="<?php echo esc_attr( $tax_rate['reduced_rate'] ); ?>"/>
55
+            <span class="screen-reader-text"><?php esc_html_e('Reduced Rate', 'invoicing'); ?></span>
56
+            <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr($key); ?>][reduced_rate]" value="<?php echo esc_attr($tax_rate['reduced_rate']); ?>"/>
57 57
         </label>
58 58
     </td>
59 59
 
60 60
     <td class="wpinv_tax_name">
61 61
         <label class="w-100">
62
-            <span class="screen-reader-text"><?php esc_html_e( 'Tax Name', 'invoicing' ); ?></span>
63
-            <input type="text" name="tax_rates[<?php echo esc_attr( $key ); ?>][name]" value="<?php echo esc_attr( $tax_rate['name'] ); ?>"/>
62
+            <span class="screen-reader-text"><?php esc_html_e('Tax Name', 'invoicing'); ?></span>
63
+            <input type="text" name="tax_rates[<?php echo esc_attr($key); ?>][name]" value="<?php echo esc_attr($tax_rate['name']); ?>"/>
64 64
         </label>
65 65
     </td>
66 66
 
67 67
     <td class="wpinv_tax_remove">
68
-        <button type="button" class="close wpinv_remove_tax_rate" aria-label="<?php esc_attr_e( 'Delete', 'invoicing' ); ?>" title="<?php esc_attr_e( 'Delete', 'invoicing' ); ?>">
68
+        <button type="button" class="close wpinv_remove_tax_rate" aria-label="<?php esc_attr_e('Delete', 'invoicing'); ?>" title="<?php esc_attr_e('Delete', 'invoicing'); ?>">
69 69
             <span aria-hidden="true">&times;</span>
70 70
         </button>
71 71
     </td>
Please login to merge, or discard this patch.
includes/admin/views/html-tax-rates-edit.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 $tax_rates  = GetPaid_Tax::get_all_tax_rates();
10 10
 $dummy_rate = array(
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
     'global'       => true,
14 14
     'rate'         => wpinv_get_default_tax_rate(),
15 15
     'reduced_rate' => 5,
16
-    'name'         => __( 'VAT', 'invoicing' ),
16
+    'name'         => __('VAT', 'invoicing'),
17 17
 );
18 18
 
19 19
 $reset_url = wp_nonce_url(
20
-    add_query_arg( 'getpaid-admin-action', 'reset_tax_rates' ),
20
+    add_query_arg('getpaid-admin-action', 'reset_tax_rates'),
21 21
     'getpaid-nonce',
22 22
     'getpaid-nonce'
23 23
 );
@@ -25,34 +25,34 @@  discard block
 block discarded – undo
25 25
 ?>
26 26
 <div class="table-responsive">
27 27
     <table id="wpinv_tax_rates" class="widefat fixed table">
28
-        <caption><?php echo esc_html_e( 'Enter tax rates for specific regions.', 'invoicing' ); ?></caption>
28
+        <caption><?php echo esc_html_e('Enter tax rates for specific regions.', 'invoicing'); ?></caption>
29 29
 
30 30
         <thead>
31 31
             <tr class="table-light">
32 32
 
33 33
                 <th scope="col" class="border-bottom border-top">
34
-                    <?php esc_html_e( 'Country', 'invoicing' ); ?>
35
-                    <?php getpaid_get_help_tip( __( 'Optionally limit this tax rate to a specific country.', 'invoicing' ), 'position-static', true ); ?>
34
+                    <?php esc_html_e('Country', 'invoicing'); ?>
35
+                    <?php getpaid_get_help_tip(__('Optionally limit this tax rate to a specific country.', 'invoicing'), 'position-static', true); ?>
36 36
                 </th>
37 37
 
38 38
                 <th scope="col" class="border-bottom border-top">
39
-                    <?php esc_html_e( 'State', 'invoicing' ); ?>
40
-                    <?php getpaid_get_help_tip( __( 'Separate state codes using a comma or leave blank to apply country wide.', 'invoicing' ), 'position-static', true ); ?>
39
+                    <?php esc_html_e('State', 'invoicing'); ?>
40
+                    <?php getpaid_get_help_tip(__('Separate state codes using a comma or leave blank to apply country wide.', 'invoicing'), 'position-static', true); ?>
41 41
                 </th>
42 42
 
43 43
                 <th scope="col" class="border-bottom border-top">
44
-                    <?php esc_html_e( 'Standard Rate %', 'invoicing' ); ?>
45
-                    <?php getpaid_get_help_tip( __( 'The tax rate (percentage) to charge on items that use the "Standard rate" tax class.', 'invoicing' ), 'position-static', true ); ?>
44
+                    <?php esc_html_e('Standard Rate %', 'invoicing'); ?>
45
+                    <?php getpaid_get_help_tip(__('The tax rate (percentage) to charge on items that use the "Standard rate" tax class.', 'invoicing'), 'position-static', true); ?>
46 46
                 </th>
47 47
 
48 48
                 <th scope="col" class="border-bottom border-top">
49
-                    <?php esc_html_e( 'Reduced Rate %', 'invoicing' ); ?>
50
-                    <?php getpaid_get_help_tip( __( 'The tax rate (percentage) to charge on items that use the "Reduced rate" tax class.', 'invoicing' ), 'position-static', true ); ?>
49
+                    <?php esc_html_e('Reduced Rate %', 'invoicing'); ?>
50
+                    <?php getpaid_get_help_tip(__('The tax rate (percentage) to charge on items that use the "Reduced rate" tax class.', 'invoicing'), 'position-static', true); ?>
51 51
                 </th>
52 52
 
53 53
                 <th scope="col" class="border-bottom border-top">
54
-                    <?php esc_html_e( 'Tax Name', 'invoicing' ); ?>
55
-                    <?php getpaid_get_help_tip( __( 'The name of this tax, e.g VAT.', 'invoicing' ), 'position-static', true ); ?>
54
+                    <?php esc_html_e('Tax Name', 'invoicing'); ?>
55
+                    <?php getpaid_get_help_tip(__('The name of this tax, e.g VAT.', 'invoicing'), 'position-static', true); ?>
56 56
                 </th>
57 57
 
58 58
                 <th scope="col" class="border-bottom border-top" style="width:32px">&nbsp;</th>
@@ -61,19 +61,19 @@  discard block
 block discarded – undo
61 61
         </thead>
62 62
 
63 63
         <tbody>
64
-            <?php array_walk( $tax_rates, 'wpinv_tax_rate_callback' ); ?>
64
+            <?php array_walk($tax_rates, 'wpinv_tax_rate_callback'); ?>
65 65
         </tbody>
66 66
 
67 67
         <tfoot>
68 68
             <tr class="table-light">
69 69
                 <td colspan="6" class="border-top">
70 70
 
71
-                    <button type="button" class="button button-secondary wpinv_add_tax_rate" aria-label="<?php esc_attr_e( 'Add Tax Rate', 'invoicing' ); ?>">
72
-                        <span><?php esc_html_e( 'Add Tax Rate', 'invoicing' ); ?></span>
71
+                    <button type="button" class="button button-secondary wpinv_add_tax_rate" aria-label="<?php esc_attr_e('Add Tax Rate', 'invoicing'); ?>">
72
+                        <span><?php esc_html_e('Add Tax Rate', 'invoicing'); ?></span>
73 73
                     </button>
74 74
 
75
-                    <a href="<?php echo esc_url( $reset_url ); ?>" class="button button-secondary wpinv_reset_tax_rates" aria-label="<?php esc_attr_e( 'Reset Tax Rates', 'invoicing' ); ?>">
76
-                        <span><?php esc_html_e( 'Reset Tax Rates', 'invoicing' ); ?></span>
75
+                    <a href="<?php echo esc_url($reset_url); ?>" class="button button-secondary wpinv_reset_tax_rates" aria-label="<?php esc_attr_e('Reset Tax Rates', 'invoicing'); ?>">
76
+                        <span><?php esc_html_e('Reset Tax Rates', 'invoicing'); ?></span>
77 77
                     </a>
78 78
                 </td>
79 79
             </tr>
@@ -82,6 +82,6 @@  discard block
 block discarded – undo
82 82
 </div>
83 83
 
84 84
 <script type="text/html" id="tmpl-wpinv-tax-rate-row">
85
-    <?php wpinv_tax_rate_callback( $dummy_rate, 0, true ); ?>
85
+    <?php wpinv_tax_rate_callback($dummy_rate, 0, true); ?>
86 86
 </script>
87 87
 
Please login to merge, or discard this patch.
includes/user-functions.php 2 patches
Spacing   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package GetPaid
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  *  Generates a users select dropdown.
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
  * @param array $args
17 17
  * @see wp_dropdown_users
18 18
  */
19
-function wpinv_dropdown_users( $args = '' ) {
19
+function wpinv_dropdown_users($args = '') {
20 20
 
21
-    if ( is_array( $args ) && ! empty( $args['show'] ) && 'display_name_with_email' == $args['show'] ) {
21
+    if (is_array($args) && !empty($args['show']) && 'display_name_with_email' == $args['show']) {
22 22
         $args['show'] = 'display_name_with_login';
23 23
     }
24 24
 
25
-    return wp_dropdown_users( $args );
25
+    return wp_dropdown_users($args);
26 26
 }
27 27
 
28 28
 /**
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
  * @return string capability to check against
33 33
  * @param string $capalibilty Optional. The alternative capability to check against.
34 34
  */
35
-function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) {
35
+function wpinv_get_capability($capalibilty = 'manage_invoicing') {
36 36
 
37
-	if ( current_user_can( 'manage_options' ) ) {
37
+	if (current_user_can('manage_options')) {
38 38
 		return 'manage_options';
39 39
 	};
40 40
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
  * @return bool
49 49
  */
50 50
 function wpinv_current_user_can_manage_invoicing() {
51
-    return current_user_can( wpinv_get_capability() );
51
+    return current_user_can(wpinv_get_capability());
52 52
 }
53 53
 
54 54
 /**
@@ -57,19 +57,19 @@  discard block
 block discarded – undo
57 57
  * @since 1.0.19
58 58
  * @return int|WP_Error
59 59
  */
60
-function wpinv_create_user( $email, $prefix = '' ) {
60
+function wpinv_create_user($email, $prefix = '') {
61 61
 
62 62
     // Prepare user values.
63
-    $prefix = preg_replace( '/\s+/', '', $prefix );
64
-    $prefix = empty( $prefix ) ? $email : $prefix;
65
-	$args   = array(
66
-		'user_login' => wpinv_generate_user_name( $prefix ),
63
+    $prefix = preg_replace('/\s+/', '', $prefix);
64
+    $prefix = empty($prefix) ? $email : $prefix;
65
+	$args = array(
66
+		'user_login' => wpinv_generate_user_name($prefix),
67 67
 		'user_pass'  => wp_generate_password(),
68 68
 		'user_email' => $email,
69 69
         'role'       => 'subscriber',
70 70
     );
71 71
 
72
-    return wp_insert_user( $args );
72
+    return wp_insert_user($args);
73 73
 
74 74
 }
75 75
 
@@ -79,26 +79,26 @@  discard block
 block discarded – undo
79 79
  * @since 1.0.19
80 80
  * @return bool|WP_User
81 81
  */
82
-function wpinv_generate_user_name( $prefix = '' ) {
82
+function wpinv_generate_user_name($prefix = '') {
83 83
 
84 84
     // If prefix is an email, retrieve the part before the email.
85
-	$prefix = strtok( $prefix, '@' );
86
-    $prefix = trim( $prefix, '.' );
85
+	$prefix = strtok($prefix, '@');
86
+    $prefix = trim($prefix, '.');
87 87
 
88 88
 	// Sanitize the username.
89
-	$prefix = sanitize_user( $prefix, true );
89
+	$prefix = sanitize_user($prefix, true);
90 90
 
91
-	$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
92
-	if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) {
93
-		$prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 );
91
+	$illegal_logins = (array) apply_filters('illegal_user_logins', array());
92
+	if (empty($prefix) || in_array(strtolower($prefix), array_map('strtolower', $illegal_logins), true)) {
93
+		$prefix = 'gtp_' . zeroise(wp_rand(0, 9999), 4);
94 94
 	}
95 95
 
96 96
     $username = $prefix;
97 97
     $postfix  = 2;
98 98
 
99
-    while ( username_exists( $username ) ) {
99
+    while (username_exists($username)) {
100 100
         $username = $prefix + $postfix;
101
-        $postfix ++;
101
+        $postfix++;
102 102
     }
103 103
 
104 104
     return $username;
@@ -115,31 +115,31 @@  discard block
 block discarded – undo
115 115
     $tabs = array(
116 116
 
117 117
         'gp-invoices'      => array(
118
-            'label'   => __( 'Invoices', 'invoicing' ), // Name of the tab.
118
+            'label'   => __('Invoices', 'invoicing'), // Name of the tab.
119 119
             'content' => '[wpinv_history]', // Content of the tab. Or specify "callback" to provide a callback instead.
120 120
             'icon'    => 'fas fa-file-invoice', // Shown on some profile plugins.
121 121
         ),
122 122
 
123 123
         'gp-subscriptions' => array(
124
-            'label'   => __( 'Subscriptions', 'invoicing' ),
124
+            'label'   => __('Subscriptions', 'invoicing'),
125 125
             'content' => '[wpinv_subscriptions]',
126 126
             'icon'    => 'fas fa-redo',
127 127
         ),
128 128
 
129 129
         'gp-edit-address'  => array(
130
-            'label'    => __( 'Billing Address', 'invoicing' ),
130
+            'label'    => __('Billing Address', 'invoicing'),
131 131
             'callback' => 'getpaid_display_address_edit_tab',
132 132
             'icon'     => 'fas fa-credit-card',
133 133
         ),
134 134
 
135 135
     );
136 136
 
137
-    $tabs = apply_filters( 'getpaid_user_content_tabs', $tabs );
137
+    $tabs = apply_filters('getpaid_user_content_tabs', $tabs);
138 138
 
139 139
     // Make sure address editing is last on the list.
140
-    if ( isset( $tabs['gp-edit-address'] ) ) {
140
+    if (isset($tabs['gp-edit-address'])) {
141 141
         $address = $tabs['gp-edit-address'];
142
-        unset( $tabs['gp-edit-address'] );
142
+        unset($tabs['gp-edit-address']);
143 143
         $tabs['gp-edit-address'] = $address;
144 144
     }
145 145
 
@@ -153,19 +153,19 @@  discard block
 block discarded – undo
153 153
  * @param array $tab
154 154
  * @return array
155 155
  */
156
-function getpaid_prepare_user_content_tab( $tab ) {
156
+function getpaid_prepare_user_content_tab($tab) {
157 157
 
158
-    if ( ! empty( $tab['callback'] ) ) {
159
-        return call_user_func( $tab['callback'] );
158
+    if (!empty($tab['callback'])) {
159
+        return call_user_func($tab['callback']);
160 160
     }
161 161
 
162
-    if ( ! empty( $tab['content'] ) ) {
163
-        return convert_smilies( capital_P_dangit( wp_filter_content_tags( do_shortcode( shortcode_unautop( wpautop( wptexturize( do_blocks( $tab['content'] ) ) ) ) ) ) ) );
162
+    if (!empty($tab['content'])) {
163
+        return convert_smilies(capital_P_dangit(wp_filter_content_tags(do_shortcode(shortcode_unautop(wpautop(wptexturize(do_blocks($tab['content']))))))));
164 164
     }
165 165
 
166 166
     $notice = aui()->alert(
167 167
         array(
168
-            'content' => __( 'This tab has no content or content callback.', 'invoicing' ),
168
+            'content' => __('This tab has no content or content callback.', 'invoicing'),
169 169
             'type'    => 'error',
170 170
         )
171 171
     );
@@ -181,14 +181,14 @@  discard block
 block discarded – undo
181 181
  * @param string $default
182 182
  * @return array
183 183
  */
184
-function getpaid_get_tab_url( $tab, $default ) {
184
+function getpaid_get_tab_url($tab, $default) {
185 185
     global $getpaid_tab_url;
186 186
 
187
-    if ( empty( $getpaid_tab_url ) ) {
187
+    if (empty($getpaid_tab_url)) {
188 188
         return $default;
189 189
     }
190 190
 
191
-    return sprintf( $getpaid_tab_url, $tab );
191
+    return sprintf($getpaid_tab_url, $tab);
192 192
 
193 193
 }
194 194
 
@@ -200,11 +200,11 @@  discard block
 block discarded – undo
200 200
  */
201 201
 function getpaid_display_address_edit_tab() {
202 202
 
203
-    if ( 0 === get_current_user_id() ) {
203
+    if (0 === get_current_user_id()) {
204 204
         return '<div class="bsui">' . aui()->alert(
205 205
             array(
206 206
                 'type'        => 'error',
207
-                'content'     => __( 'Your must be logged in to view this section', 'invoicing' ),
207
+                'content'     => __('Your must be logged in to view this section', 'invoicing'),
208 208
                 'dismissible' => false,
209 209
             )
210 210
         ) . '</div>';
@@ -218,19 +218,19 @@  discard block
 block discarded – undo
218 218
 
219 219
                 <?php
220 220
 
221
-                    foreach ( getpaid_user_address_fields() as $key => $label ) {
221
+                    foreach (getpaid_user_address_fields() as $key => $label) {
222 222
 
223 223
 					// Display the country.
224
-					if ( 'country' == $key ) {
224
+					if ('country' == $key) {
225 225
 
226 226
 						aui()->select(
227 227
 							array(
228 228
 								'options'     => wpinv_get_country_list(),
229
-								'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
230
-								'id'          => 'wpinv-' . sanitize_html_class( $key ),
231
-								'value'       => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ),
229
+								'name'        => 'getpaid_address[' . esc_attr($key) . ']',
230
+								'id'          => 'wpinv-' . sanitize_html_class($key),
231
+								'value'       => sanitize_text_field(getpaid_get_user_address_field(get_current_user_id(), $key)),
232 232
 								'placeholder' => $label,
233
-								'label'       => wp_kses_post( $label ),
233
+								'label'       => wp_kses_post($label),
234 234
 								'label_type'  => 'vertical',
235 235
 								'class'       => 'getpaid-address-field',
236 236
                             ),
@@ -240,17 +240,17 @@  discard block
 block discarded – undo
240 240
 					}
241 241
 
242 242
 					// Display the state.
243
-					elseif ( 'state' == $key ) {
243
+					elseif ('state' == $key) {
244 244
 
245 245
 						getpaid_get_states_select_markup(
246
-							getpaid_get_user_address_field( get_current_user_id(), 'country' ),
247
-							getpaid_get_user_address_field( get_current_user_id(), 'state' ),
246
+							getpaid_get_user_address_field(get_current_user_id(), 'country'),
247
+							getpaid_get_user_address_field(get_current_user_id(), 'state'),
248 248
 							$label,
249 249
 							$label,
250 250
 							'',
251 251
 							false,
252 252
 							'',
253
-							'getpaid_address[' . esc_attr( $key ) . ']',
253
+							'getpaid_address[' . esc_attr($key) . ']',
254 254
                             true
255 255
 						);
256 256
 
@@ -258,13 +258,13 @@  discard block
 block discarded – undo
258 258
 
259 259
 						aui()->input(
260 260
                             array(
261
-                                'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
262
-                                'id'          => 'wpinv-' . sanitize_html_class( $key ),
261
+                                'name'        => 'getpaid_address[' . esc_attr($key) . ']',
262
+                                'id'          => 'wpinv-' . sanitize_html_class($key),
263 263
                                 'placeholder' => $label,
264
-                                'label'       => wp_kses_post( $label ),
264
+                                'label'       => wp_kses_post($label),
265 265
                                 'label_type'  => 'vertical',
266 266
                                 'type'        => 'text',
267
-                                'value'       => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ),
267
+                                'value'       => sanitize_text_field(getpaid_get_user_address_field(get_current_user_id(), $key)),
268 268
                                 'class'       => 'getpaid-address-field',
269 269
                             ),
270 270
                             true
@@ -278,32 +278,32 @@  discard block
 block discarded – undo
278 278
                             'name'        => 'getpaid_address[email_cc]',
279 279
                             'id'          => 'wpinv-email_cc',
280 280
                             'placeholder' => '[email protected], [email protected]',
281
-                            'label'       => __( 'Other email addresses', 'invoicing' ),
281
+                            'label'       => __('Other email addresses', 'invoicing'),
282 282
                             'label_type'  => 'vertical',
283 283
                             'type'        => 'text',
284
-                            'value'       => sanitize_text_field( get_user_meta( get_current_user_id(), '_wpinv_email_cc', true ) ),
284
+                            'value'       => sanitize_text_field(get_user_meta(get_current_user_id(), '_wpinv_email_cc', true)),
285 285
                             'class'       => 'getpaid-address-field',
286
-                            'help_text'   => __( 'Optionally provide other email addresses where we should send payment notifications', 'invoicing' ),
286
+                            'help_text'   => __('Optionally provide other email addresses where we should send payment notifications', 'invoicing'),
287 287
                         ),
288 288
                         true
289 289
                     );
290 290
 
291
-                    do_action( 'getpaid_display_address_edit_tab' );
291
+                    do_action('getpaid_display_address_edit_tab');
292 292
 
293 293
                     aui()->input(
294 294
                         array(
295 295
                             'name'      => 'getpaid_profile_edit_submit_button',
296 296
                             'id'        => 'getpaid_profile_edit_submit_button',
297
-                            'value'     => __( 'Save Address', 'invoicing' ),
298
-                            'help_text' => __( 'New invoices will use this address as the billing address.', 'invoicing' ),
297
+                            'value'     => __('Save Address', 'invoicing'),
298
+                            'help_text' => __('New invoices will use this address as the billing address.', 'invoicing'),
299 299
                             'type'      => 'submit',
300 300
                             'class'     => 'btn btn-primary btn-block submit-button',
301 301
                         ),
302 302
                         true
303 303
                     );
304 304
 
305
-                    wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' );
306
-                    getpaid_hidden_field( 'getpaid-action', 'edit_billing_details' );
305
+                    wp_nonce_field('getpaid-nonce', 'getpaid-nonce');
306
+                    getpaid_hidden_field('getpaid-action', 'edit_billing_details');
307 307
                 ?>
308 308
 
309 309
             </form>
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 
314 314
     return ob_get_clean();
315 315
 }
316
-add_shortcode( 'getpaid_edit_address', 'getpaid_display_address_edit_tab' );
316
+add_shortcode('getpaid_edit_address', 'getpaid_display_address_edit_tab');
317 317
 
318 318
 /**
319 319
  * Saves the billing address edit tab.
@@ -321,30 +321,30 @@  discard block
 block discarded – undo
321 321
  * @since 2.1.4
322 322
  * @param array $data
323 323
  */
324
-function getpaid_save_address_edit_tab( $data ) {
324
+function getpaid_save_address_edit_tab($data) {
325 325
 
326
-    if ( empty( $data['getpaid_address'] ) || ! is_array( $data['getpaid_address'] ) ) {
326
+    if (empty($data['getpaid_address']) || !is_array($data['getpaid_address'])) {
327 327
         return;
328 328
     }
329 329
 
330 330
     $data    = $data['getpaid_address'];
331 331
     $user_id = get_current_user_id();
332 332
 
333
-    foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
333
+    foreach (array_keys(getpaid_user_address_fields()) as $field) {
334 334
 
335
-        if ( isset( $data[ $field ] ) ) {
336
-            $value = sanitize_text_field( $data[ $field ] );
337
-            update_user_meta( $user_id, '_wpinv_' . $field, $value );
335
+        if (isset($data[$field])) {
336
+            $value = sanitize_text_field($data[$field]);
337
+            update_user_meta($user_id, '_wpinv_' . $field, $value);
338 338
         }
339 339
 }
340 340
 
341
-    if ( isset( $data['email_cc'] ) ) {
342
-        update_user_meta( $user_id, '_wpinv_email_cc', sanitize_text_field( $data['email_cc'] ) );
341
+    if (isset($data['email_cc'])) {
342
+        update_user_meta($user_id, '_wpinv_email_cc', sanitize_text_field($data['email_cc']));
343 343
     }
344 344
 
345
-    wpinv_set_error( 'address_updated', __( 'Your billing address has been updated', 'invoicing' ), 'success' );
345
+    wpinv_set_error('address_updated', __('Your billing address has been updated', 'invoicing'), 'success');
346 346
 }
347
-add_action( 'getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab' );
347
+add_action('getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab');
348 348
 
349 349
 
350 350
 /*
@@ -362,27 +362,27 @@  discard block
 block discarded – undo
362 362
  * @param  array $tabs
363 363
  * @return array
364 364
  */
365
-function getpaid_filter_userswp_account_tabs( $tabs ) {
365
+function getpaid_filter_userswp_account_tabs($tabs) {
366 366
 
367 367
     // Abort if the integration is inactive.
368
-    if ( ! getpaid_is_userswp_integration_active() ) {
368
+    if (!getpaid_is_userswp_integration_active()) {
369 369
         return $tabs;
370 370
     }
371 371
 
372
-    $new_tabs   = array();
372
+    $new_tabs = array();
373 373
 
374
-    foreach ( getpaid_get_user_content_tabs() as $slug => $tab ) {
374
+    foreach (getpaid_get_user_content_tabs() as $slug => $tab) {
375 375
 
376
-        $new_tabs[ $slug ] = array(
376
+        $new_tabs[$slug] = array(
377 377
             'title' => $tab['label'],
378 378
             'icon'  => $tab['icon'],
379 379
         );
380 380
 
381 381
     }
382 382
 
383
-    return array_merge( $tabs, $new_tabs );
383
+    return array_merge($tabs, $new_tabs);
384 384
 }
385
-add_filter( 'uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs' );
385
+add_filter('uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs');
386 386
 
387 387
 /**
388 388
  * Display our UsersWP account tabs.
@@ -391,21 +391,21 @@  discard block
 block discarded – undo
391 391
  * @param  array $tabs
392 392
  * @return array
393 393
  */
394
-function getpaid_display_userswp_account_tabs( $tab ) {
394
+function getpaid_display_userswp_account_tabs($tab) {
395 395
     global $getpaid_tab_url;
396 396
 
397 397
     $our_tabs = getpaid_get_user_content_tabs();
398 398
 
399
-    if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) {
400
-        $getpaid_tab_url = add_query_arg( 'type', '%s', uwp_get_account_page_url() );
401
-        echo wp_kses( getpaid_prepare_user_content_tab( $our_tabs[ $tab ] ), getpaid_allowed_html() );
399
+    if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) {
400
+        $getpaid_tab_url = add_query_arg('type', '%s', uwp_get_account_page_url());
401
+        echo wp_kses(getpaid_prepare_user_content_tab($our_tabs[$tab]), getpaid_allowed_html());
402 402
     }
403 403
 
404 404
 }
405
-add_action( 'uwp_account_form_display', 'getpaid_display_userswp_account_tabs' );
405
+add_action('uwp_account_form_display', 'getpaid_display_userswp_account_tabs');
406 406
 
407 407
 function getpaid_allowed_html() {
408
-    $allowed_html = wp_kses_allowed_html( 'post' );
408
+    $allowed_html = wp_kses_allowed_html('post');
409 409
 
410 410
 	// form fields
411 411
     $allowed_html['form'] = array(
@@ -453,17 +453,17 @@  discard block
 block discarded – undo
453 453
  * @param  string $tab   Current tab.
454 454
  * @return string Title.
455 455
  */
456
-function getpaid_filter_userswp_account_title( $title, $tab ) {
456
+function getpaid_filter_userswp_account_title($title, $tab) {
457 457
 
458
-    $our_tabs   = getpaid_get_user_content_tabs();
458
+    $our_tabs = getpaid_get_user_content_tabs();
459 459
 
460
-    if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) {
461
-        return $our_tabs[ $tab ]['label'];
460
+    if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) {
461
+        return $our_tabs[$tab]['label'];
462 462
     }
463 463
 
464 464
     return $title;
465 465
 }
466
-add_filter( 'uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2 );
466
+add_filter('uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2);
467 467
 
468 468
 /**
469 469
  * Registers the UsersWP integration settings.
@@ -472,26 +472,26 @@  discard block
 block discarded – undo
472 472
  * @param  array $settings An array of integration settings.
473 473
  * @return array
474 474
  */
475
-function getpaid_register_userswp_settings( $settings ) {
475
+function getpaid_register_userswp_settings($settings) {
476 476
 
477
-    if ( defined( 'USERSWP_PLUGIN_FILE' ) ) {
477
+    if (defined('USERSWP_PLUGIN_FILE')) {
478 478
 
479 479
         $settings[] = array(
480 480
 
481 481
             'id'       => 'userswp',
482
-            'label'    => __( 'UsersWP', 'invoicing' ),
482
+            'label'    => __('UsersWP', 'invoicing'),
483 483
             'settings' => array(
484 484
 
485 485
                 'userswp_settings' => array(
486 486
                     'id'   => 'userswp_settings',
487
-                    'name' => '<h3>' . __( 'UsersWP', 'invoicing' ) . '</h3>',
487
+                    'name' => '<h3>' . __('UsersWP', 'invoicing') . '</h3>',
488 488
                     'type' => 'header',
489 489
                 ),
490 490
 
491 491
                 'enable_userswp'   => array(
492 492
                     'id'   => 'enable_userswp',
493
-                    'name' => __( 'Enable Integration', 'invoicing' ),
494
-                    'desc' => __( 'Display GetPaid items on UsersWP account page.', 'invoicing' ),
493
+                    'name' => __('Enable Integration', 'invoicing'),
494
+                    'desc' => __('Display GetPaid items on UsersWP account page.', 'invoicing'),
495 495
                     'type' => 'checkbox',
496 496
                     'std'  => 1,
497 497
                 ),
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 
505 505
     return $settings;
506 506
 }
507
-add_filter( 'getpaid_integration_settings', 'getpaid_register_userswp_settings' );
507
+add_filter('getpaid_integration_settings', 'getpaid_register_userswp_settings');
508 508
 
509 509
 /**
510 510
  * Ovewrites the invoices history page to UsersWP.
@@ -512,18 +512,18 @@  discard block
 block discarded – undo
512 512
  * @since  2.3.1
513 513
  * @return bool
514 514
  */
515
-function getpaid_userswp_overwrite_invoice_history_page( $url, $post_type ) {
515
+function getpaid_userswp_overwrite_invoice_history_page($url, $post_type) {
516 516
 
517 517
     $our_tabs = getpaid_get_user_content_tabs();
518 518
     $tab      = "gp-{$post_type}s";
519
-    if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) {
520
-        return add_query_arg( 'type', $tab, uwp_get_account_page_url() );
519
+    if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) {
520
+        return add_query_arg('type', $tab, uwp_get_account_page_url());
521 521
     }
522 522
 
523 523
     return $url;
524 524
 
525 525
 }
526
-add_filter( 'wpinv_get_history_page_uri', 'getpaid_userswp_overwrite_invoice_history_page', 10, 2 );
526
+add_filter('wpinv_get_history_page_uri', 'getpaid_userswp_overwrite_invoice_history_page', 10, 2);
527 527
 
528 528
 /**
529 529
  * Checks if the integration is enabled.
@@ -532,8 +532,8 @@  discard block
 block discarded – undo
532 532
  * @return bool
533 533
  */
534 534
 function getpaid_is_userswp_integration_active() {
535
-    $enabled = wpinv_get_option( 'enable_userswp', 1 );
536
-    return defined( 'USERSWP_PLUGIN_FILE' ) && ! empty( $enabled );
535
+    $enabled = wpinv_get_option('enable_userswp', 1);
536
+    return defined('USERSWP_PLUGIN_FILE') && !empty($enabled);
537 537
 }
538 538
 
539 539
 /*
@@ -551,26 +551,26 @@  discard block
 block discarded – undo
551 551
  * @param  array $settings An array of integration settings.
552 552
  * @return array
553 553
  */
554
-function getpaid_register_buddypress_settings( $settings ) {
554
+function getpaid_register_buddypress_settings($settings) {
555 555
 
556
-    if ( class_exists( 'BuddyPress' ) ) {
556
+    if (class_exists('BuddyPress')) {
557 557
 
558 558
         $settings[] = array(
559 559
 
560 560
             'id'       => 'buddypress',
561
-            'label'    => __( 'BuddyPress', 'invoicing' ),
561
+            'label'    => __('BuddyPress', 'invoicing'),
562 562
             'settings' => array(
563 563
 
564 564
                 'buddypress_settings' => array(
565 565
                     'id'   => 'buddypress_settings',
566
-                    'name' => '<h3>' . __( 'BuddyPress', 'invoicing' ) . '</h3>',
566
+                    'name' => '<h3>' . __('BuddyPress', 'invoicing') . '</h3>',
567 567
                     'type' => 'header',
568 568
                 ),
569 569
 
570 570
                 'enable_buddypress'   => array(
571 571
                     'id'   => 'enable_buddypress',
572
-                    'name' => __( 'Enable Integration', 'invoicing' ),
573
-                    'desc' => __( 'Display GetPaid items on BuddyPress account pages.', 'invoicing' ),
572
+                    'name' => __('Enable Integration', 'invoicing'),
573
+                    'desc' => __('Display GetPaid items on BuddyPress account pages.', 'invoicing'),
574 574
                     'type' => 'checkbox',
575 575
                     'std'  => 1,
576 576
                 ),
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
 
584 584
     return $settings;
585 585
 }
586
-add_filter( 'getpaid_integration_settings', 'getpaid_register_buddypress_settings' );
586
+add_filter('getpaid_integration_settings', 'getpaid_register_buddypress_settings');
587 587
 
588 588
 /**
589 589
  * Checks if the integration is enabled.
@@ -592,8 +592,8 @@  discard block
 block discarded – undo
592 592
  * @return bool
593 593
  */
594 594
 function getpaid_is_buddypress_integration_active() {
595
-    $enabled = wpinv_get_option( 'enable_buddypress', 1 );
596
-    return class_exists( 'BuddyPress' ) && ! empty( $enabled );
595
+    $enabled = wpinv_get_option('enable_buddypress', 1);
596
+    return class_exists('BuddyPress') && !empty($enabled);
597 597
 }
598 598
 
599 599
 /**
@@ -604,10 +604,10 @@  discard block
 block discarded – undo
604 604
  */
605 605
 function getpaid_setup_buddypress_integration() {
606 606
 
607
-    if ( getpaid_is_buddypress_integration_active() ) {
607
+    if (getpaid_is_buddypress_integration_active()) {
608 608
         require_once WPINV_PLUGIN_DIR . 'includes/class-bp-getpaid-component.php';
609 609
         buddypress()->getpaid = new BP_GetPaid_Component();
610 610
     }
611 611
 
612 612
 }
613
-add_action( 'bp_setup_components', 'getpaid_setup_buddypress_integration' );
613
+add_action('bp_setup_components', 'getpaid_setup_buddypress_integration');
Please login to merge, or discard this patch.
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -34,11 +34,11 @@  discard block
 block discarded – undo
34 34
  */
35 35
 function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) {
36 36
 
37
-	if ( current_user_can( 'manage_options' ) ) {
38
-		return 'manage_options';
39
-	};
37
+    if ( current_user_can( 'manage_options' ) ) {
38
+        return 'manage_options';
39
+    };
40 40
 
41
-	return $capalibilty;
41
+    return $capalibilty;
42 42
 }
43 43
 
44 44
 /**
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
     // Prepare user values.
63 63
     $prefix = preg_replace( '/\s+/', '', $prefix );
64 64
     $prefix = empty( $prefix ) ? $email : $prefix;
65
-	$args   = array(
66
-		'user_login' => wpinv_generate_user_name( $prefix ),
67
-		'user_pass'  => wp_generate_password(),
68
-		'user_email' => $email,
65
+    $args   = array(
66
+        'user_login' => wpinv_generate_user_name( $prefix ),
67
+        'user_pass'  => wp_generate_password(),
68
+        'user_email' => $email,
69 69
         'role'       => 'subscriber',
70 70
     );
71 71
 
@@ -82,16 +82,16 @@  discard block
 block discarded – undo
82 82
 function wpinv_generate_user_name( $prefix = '' ) {
83 83
 
84 84
     // If prefix is an email, retrieve the part before the email.
85
-	$prefix = strtok( $prefix, '@' );
85
+    $prefix = strtok( $prefix, '@' );
86 86
     $prefix = trim( $prefix, '.' );
87 87
 
88
-	// Sanitize the username.
89
-	$prefix = sanitize_user( $prefix, true );
88
+    // Sanitize the username.
89
+    $prefix = sanitize_user( $prefix, true );
90 90
 
91
-	$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
92
-	if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) {
93
-		$prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 );
94
-	}
91
+    $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
92
+    if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) {
93
+        $prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 );
94
+    }
95 95
 
96 96
     $username = $prefix;
97 97
     $postfix  = 2;
@@ -220,43 +220,43 @@  discard block
 block discarded – undo
220 220
 
221 221
                     foreach ( getpaid_user_address_fields() as $key => $label ) {
222 222
 
223
-					// Display the country.
224
-					if ( 'country' == $key ) {
225
-
226
-						aui()->select(
227
-							array(
228
-								'options'     => wpinv_get_country_list(),
229
-								'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
230
-								'id'          => 'wpinv-' . sanitize_html_class( $key ),
231
-								'value'       => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ),
232
-								'placeholder' => $label,
233
-								'label'       => wp_kses_post( $label ),
234
-								'label_type'  => 'vertical',
235
-								'class'       => 'getpaid-address-field',
223
+                    // Display the country.
224
+                    if ( 'country' == $key ) {
225
+
226
+                        aui()->select(
227
+                            array(
228
+                                'options'     => wpinv_get_country_list(),
229
+                                'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
230
+                                'id'          => 'wpinv-' . sanitize_html_class( $key ),
231
+                                'value'       => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ),
232
+                                'placeholder' => $label,
233
+                                'label'       => wp_kses_post( $label ),
234
+                                'label_type'  => 'vertical',
235
+                                'class'       => 'getpaid-address-field',
236 236
                             ),
237 237
                             true
238
-						);
239
-
240
-					}
241
-
242
-					// Display the state.
243
-					elseif ( 'state' == $key ) {
244
-
245
-						getpaid_get_states_select_markup(
246
-							getpaid_get_user_address_field( get_current_user_id(), 'country' ),
247
-							getpaid_get_user_address_field( get_current_user_id(), 'state' ),
248
-							$label,
249
-							$label,
250
-							'',
251
-							false,
252
-							'',
253
-							'getpaid_address[' . esc_attr( $key ) . ']',
238
+                        );
239
+
240
+                    }
241
+
242
+                    // Display the state.
243
+                    elseif ( 'state' == $key ) {
244
+
245
+                        getpaid_get_states_select_markup(
246
+                            getpaid_get_user_address_field( get_current_user_id(), 'country' ),
247
+                            getpaid_get_user_address_field( get_current_user_id(), 'state' ),
248
+                            $label,
249
+                            $label,
250
+                            '',
251
+                            false,
252
+                            '',
253
+                            'getpaid_address[' . esc_attr( $key ) . ']',
254 254
                             true
255
-						);
255
+                        );
256 256
 
257 257
                         } else {
258 258
 
259
-						aui()->input(
259
+                        aui()->input(
260 260
                             array(
261 261
                                 'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
262 262
                                 'id'          => 'wpinv-' . sanitize_html_class( $key ),
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
                                 'class'       => 'getpaid-address-field',
269 269
                             ),
270 270
                             true
271
-						);
271
+                        );
272 272
 
273 273
                         }
274 274
                     }
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 function getpaid_allowed_html() {
408 408
     $allowed_html = wp_kses_allowed_html( 'post' );
409 409
 
410
-	// form fields
410
+    // form fields
411 411
     $allowed_html['form'] = array(
412 412
         'action'         => true,
413 413
         'accept'         => true,
@@ -419,37 +419,37 @@  discard block
 block discarded – undo
419 419
     );
420 420
     
421 421
     // - input
422
-	$allowed_html['input'] = array(
423
-		'class' => array(),
424
-		'id'    => array(),
425
-		'name'  => array(),
426
-		'value' => array(),
427
-		'type'  => array(),
428
-	);
422
+    $allowed_html['input'] = array(
423
+        'class' => array(),
424
+        'id'    => array(),
425
+        'name'  => array(),
426
+        'value' => array(),
427
+        'type'  => array(),
428
+    );
429 429
 
430 430
     // - input
431
-	$allowed_html['textarea'] = array(
432
-		'class' => array(),
433
-		'id'    => array(),
434
-		'name'  => array(),
435
-		'value' => array(),
436
-	);
437
-
438
-	// select
439
-	$allowed_html['select'] = array(
440
-		'class'  => array(),
441
-		'id'     => array(),
442
-		'name'   => array(),
443
-		'value'  => array(),
444
-		'type'   => array(),
445
-	);
446
-
447
-	// select options
448
-	$allowed_html['option'] = array(
449
-		'selected' => array(),
450
-	);
451
-
452
-	return $allowed_html;
431
+    $allowed_html['textarea'] = array(
432
+        'class' => array(),
433
+        'id'    => array(),
434
+        'name'  => array(),
435
+        'value' => array(),
436
+    );
437
+
438
+    // select
439
+    $allowed_html['select'] = array(
440
+        'class'  => array(),
441
+        'id'     => array(),
442
+        'name'   => array(),
443
+        'value'  => array(),
444
+        'type'   => array(),
445
+    );
446
+
447
+    // select options
448
+    $allowed_html['option'] = array(
449
+        'selected' => array(),
450
+    );
451
+
452
+    return $allowed_html;
453 453
 
454 454
 }
455 455
 
Please login to merge, or discard this patch.
includes/class-wpinv-cache-helper.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit; // Exit if accessed directly
4 4
 }
5 5
 
@@ -14,18 +14,18 @@  discard block
 block discarded – undo
14 14
      * Hook in methods.
15 15
      */
16 16
     public static function init() {
17
-        add_action( 'init', array( __CLASS__, 'init_hooks' ), 0 );
18
-        add_action( 'admin_notices', array( __CLASS__, 'notices' ) );
17
+        add_action('init', array(__CLASS__, 'init_hooks'), 0);
18
+        add_action('admin_notices', array(__CLASS__, 'notices'));
19 19
     }
20 20
 
21 21
     public static function init_hooks() {
22
-        if ( false === ( $page_uris = get_transient( 'wpinv_cache_excluded_uris' ) ) ) {
23
-            $checkout_page = wpinv_get_option( 'checkout_page', '' );
24
-            $success_page  = wpinv_get_option( 'success_page', '' );
25
-            $failure_page  = wpinv_get_option( 'failure_page', '' );
26
-            $history_page  = wpinv_get_option( 'invoice_history_page', '' );
27
-            $subscr_page   = wpinv_get_option( 'invoice_subscription_page', '' );
28
-            if ( empty( $checkout_page ) || empty( $success_page ) || empty( $failure_page ) || empty( $history_page ) || empty( $subscr_page ) ) {
22
+        if (false === ($page_uris = get_transient('wpinv_cache_excluded_uris'))) {
23
+            $checkout_page = wpinv_get_option('checkout_page', '');
24
+            $success_page  = wpinv_get_option('success_page', '');
25
+            $failure_page  = wpinv_get_option('failure_page', '');
26
+            $history_page  = wpinv_get_option('invoice_history_page', '');
27
+            $subscr_page   = wpinv_get_option('invoice_subscription_page', '');
28
+            if (empty($checkout_page) || empty($success_page) || empty($failure_page) || empty($history_page) || empty($subscr_page)) {
29 29
                 return;
30 30
             }
31 31
 
@@ -39,34 +39,34 @@  discard block
 block discarded – undo
39 39
             $page_uris[] = 'p=' . $subscr_page;
40 40
 
41 41
             // Exclude permalinks
42
-            $checkout_page  = get_post( $checkout_page );
43
-            $success_page   = get_post( $success_page );
44
-            $failure_page   = get_post( $failure_page );
45
-            $history_page   = get_post( $history_page );
46
-            $subscr_page    = get_post( $subscr_page );
42
+            $checkout_page  = get_post($checkout_page);
43
+            $success_page   = get_post($success_page);
44
+            $failure_page   = get_post($failure_page);
45
+            $history_page   = get_post($history_page);
46
+            $subscr_page    = get_post($subscr_page);
47 47
 
48
-            if ( ! is_null( $checkout_page ) ) {
48
+            if (!is_null($checkout_page)) {
49 49
                 $page_uris[] = '/' . $checkout_page->post_name;
50 50
             }
51
-            if ( ! is_null( $success_page ) ) {
51
+            if (!is_null($success_page)) {
52 52
                 $page_uris[] = '/' . $success_page->post_name;
53 53
             }
54
-            if ( ! is_null( $failure_page ) ) {
54
+            if (!is_null($failure_page)) {
55 55
                 $page_uris[] = '/' . $failure_page->post_name;
56 56
             }
57
-            if ( ! is_null( $history_page ) ) {
57
+            if (!is_null($history_page)) {
58 58
                 $page_uris[] = '/' . $history_page->post_name;
59 59
             }
60
-            if ( ! is_null( $subscr_page ) ) {
60
+            if (!is_null($subscr_page)) {
61 61
                 $page_uris[] = '/' . $subscr_page->post_name;
62 62
             }
63 63
 
64
-            set_transient( 'wpinv_cache_excluded_uris', $page_uris );
64
+            set_transient('wpinv_cache_excluded_uris', $page_uris);
65 65
         }
66 66
 
67
-        if ( is_array( $page_uris ) ) {
68
-            foreach ( $page_uris as $uri ) {
69
-                if ( strstr( $_SERVER['REQUEST_URI'], $uri ) ) {
67
+        if (is_array($page_uris)) {
68
+            foreach ($page_uris as $uri) {
69
+                if (strstr($_SERVER['REQUEST_URI'], $uri)) {
70 70
                     self::nocache();
71 71
                     break;
72 72
                 }
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
      * @access private
80 80
      */
81 81
     private static function nocache() {
82
-        if ( ! defined( 'DONOTCACHEPAGE' ) ) {
83
-            define( 'DONOTCACHEPAGE', true );
82
+        if (!defined('DONOTCACHEPAGE')) {
83
+            define('DONOTCACHEPAGE', true);
84 84
         }
85
-        if ( ! defined( 'DONOTCACHEOBJECT' ) ) {
86
-            define( 'DONOTCACHEOBJECT', true );
85
+        if (!defined('DONOTCACHEOBJECT')) {
86
+            define('DONOTCACHEOBJECT', true);
87 87
         }
88
-        if ( ! defined( 'DONOTCACHEDB' ) ) {
89
-            define( 'DONOTCACHEDB', true );
88
+        if (!defined('DONOTCACHEDB')) {
89
+            define('DONOTCACHEDB', true);
90 90
         }
91 91
         nocache_headers();
92 92
     }
@@ -95,18 +95,18 @@  discard block
 block discarded – undo
95 95
      * notices function.
96 96
      */
97 97
     public static function notices() {
98
-        if ( ! function_exists( 'w3tc_pgcache_flush' ) || ! function_exists( 'w3_instance' ) ) {
98
+        if (!function_exists('w3tc_pgcache_flush') || !function_exists('w3_instance')) {
99 99
             return;
100 100
         }
101 101
 
102
-        $config   = w3_instance( 'W3_Config' );
103
-        $enabled  = $config->get_integer( 'dbcache.enabled' );
104
-        $settings = array_map( 'trim', $config->get_array( 'dbcache.reject.sql' ) );
102
+        $config   = w3_instance('W3_Config');
103
+        $enabled  = $config->get_integer('dbcache.enabled');
104
+        $settings = array_map('trim', $config->get_array('dbcache.reject.sql'));
105 105
 
106
-        if ( $enabled && ! in_array( '_wp_session_', $settings ) ) {
106
+        if ($enabled && !in_array('_wp_session_', $settings)) {
107 107
             ?>
108 108
             <div class="error">
109
-                <p><?php printf( wp_kses_post( __( 'In order for <strong>database caching</strong> to work with Invoicing you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'invoicing' ) ), '<code>_wp_session_</code>', esc_url( admin_url( 'admin.php?page=w3tc_dbcache' ) ) ); ?></p>
109
+                <p><?php printf(wp_kses_post(__('In order for <strong>database caching</strong> to work with Invoicing you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'invoicing')), '<code>_wp_session_</code>', esc_url(admin_url('admin.php?page=w3tc_dbcache'))); ?></p>
110 110
             </div>
111 111
             <?php
112 112
         }
Please login to merge, or discard this patch.