Passed
Push — master ( 330418...c4952f )
by Brian
05:45 queued 27s
created
includes/admin/class-wpinv-admin-menus.php 1 patch
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Setup menus in WP admin.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * WC_Admin_Menus Class.
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
      * Hook in tabs.
14 14
      */
15 15
     public function __construct() {
16
-        add_action( 'admin_head', array( $this, 'set_admin_menu_class' ) );
17
-        add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 );
18
-        add_action( 'admin_menu', array( $this, 'add_customers_menu' ), 18 );
19
-        add_action( 'admin_menu', array( $this, 'add_subscriptions_menu' ), 40 );
20
-        add_action( 'admin_menu', array( $this, 'add_addons_menu' ), 100 );
21
-        add_action( 'admin_menu', array( $this, 'add_settings_menu' ), 60 );
22
-        add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 );
23
-        add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) );
16
+        add_action('admin_head', array($this, 'set_admin_menu_class'));
17
+        add_action('admin_menu', array($this, 'admin_menu'), 10);
18
+        add_action('admin_menu', array($this, 'add_customers_menu'), 18);
19
+        add_action('admin_menu', array($this, 'add_subscriptions_menu'), 40);
20
+        add_action('admin_menu', array($this, 'add_addons_menu'), 100);
21
+        add_action('admin_menu', array($this, 'add_settings_menu'), 60);
22
+        add_action('admin_menu', array($this, 'remove_admin_submenus'), 10);
23
+        add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes'));
24 24
     }
25 25
 
26 26
     /**
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	public function set_admin_menu_class() {
30 30
 		global $current_screen, $parent_file, $submenu_file;
31 31
 
32
-        if ( ! empty( $current_screen->id ) && in_array( $current_screen->id , array( 'wpi_discount', 'wpi_payment_form', 'wpi_invoice' ) ) ) {
32
+        if (!empty($current_screen->id) && in_array($current_screen->id, array('wpi_discount', 'wpi_payment_form', 'wpi_invoice'))) {
33 33
 			$parent_file = 'wpinv';
34 34
 			$submenu_file = 'edit.php?post_type=' . $current_screen->id;
35 35
         }
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
 
39 39
     public function admin_menu() {
40 40
 
41
-        $capability = apply_filters( 'invoicing_capability', wpinv_get_capability() );
41
+        $capability = apply_filters('invoicing_capability', wpinv_get_capability());
42 42
         add_menu_page(
43
-            __( 'GetPaid', 'invoicing' ),
44
-            __( 'GetPaid', 'invoicing' ),
43
+            __('GetPaid', 'invoicing'),
44
+            __('GetPaid', 'invoicing'),
45 45
             $capability,
46 46
             'wpinv',
47 47
             null,
48
-            'data:image/svg+xml;base64,' . base64_encode( file_get_contents( WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg' ) ),
48
+            'data:image/svg+xml;base64,' . base64_encode(file_get_contents(WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg')),
49 49
             '54.123460'
50 50
         );
51 51
 
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
     public function add_customers_menu() {
58 58
         add_submenu_page(
59 59
             'wpinv',
60
-            __( 'Customers', 'invoicing' ),
61
-            __( 'Customers', 'invoicing' ),
60
+            __('Customers', 'invoicing'),
61
+            __('Customers', 'invoicing'),
62 62
             wpinv_get_capability(),
63 63
             'wpinv-customers',
64
-            array( $this, 'customers_page' )
64
+            array($this, 'customers_page')
65 65
         );
66 66
     }
67 67
 
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
     public function add_subscriptions_menu() {
72 72
         add_submenu_page(
73 73
             'wpinv',
74
-            __( 'Subscriptions', 'invoicing' ),
75
-            __( 'Subscriptions', 'invoicing' ),
74
+            __('Subscriptions', 'invoicing'),
75
+            __('Subscriptions', 'invoicing'),
76 76
             wpinv_get_capability(),
77 77
             'wpinv-subscriptions',
78 78
             'wpinv_subscriptions_page'
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      * Displays the customers page.
84 84
      */
85 85
     public function customers_page() {
86
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php' );
86
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php');
87 87
         ?>
88 88
         <div class="wrap wpi-customers-wrap">
89 89
             <style>
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
                     width: 30%;
92 92
                 }
93 93
             </style>
94
-            <h1><?php echo esc_html( __( 'Customers', 'invoicing' ) ); ?>&nbsp;<a href="<?php echo wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'download_customers' ), 'getpaid-nonce', 'getpaid-nonce' ); ?>" class="page-title-action"><?php _e( 'Export', 'invoicing' ); ?></a></h1>
94
+            <h1><?php echo esc_html(__('Customers', 'invoicing')); ?>&nbsp;<a href="<?php echo wp_nonce_url(add_query_arg('getpaid-admin-action', 'download_customers'), 'getpaid-nonce', 'getpaid-nonce'); ?>" class="page-title-action"><?php _e('Export', 'invoicing'); ?></a></h1>
95 95
             <form method="post">
96 96
             <?php
97 97
                 $table = new WPInv_Customers_Table();
98 98
                 $table->prepare_items();
99
-                $table->search_box( __( 'Search Customers', 'invoicing' ), 'search-customers' );
99
+                $table->search_box(__('Search Customers', 'invoicing'), 'search-customers');
100 100
                 $table->display();
101 101
             ?>
102 102
             </form>
@@ -110,16 +110,16 @@  discard block
 block discarded – undo
110 110
     public function add_settings_menu() {
111 111
         add_submenu_page(
112 112
             'wpinv',
113
-            __( 'Invoice Settings', 'invoicing' ),
114
-            __( 'Settings', 'invoicing' ),
115
-            apply_filters( 'invoicing_capability', wpinv_get_capability() ),
113
+            __('Invoice Settings', 'invoicing'),
114
+            __('Settings', 'invoicing'),
115
+            apply_filters('invoicing_capability', wpinv_get_capability()),
116 116
             'wpinv-settings',
117
-            array( $this, 'options_page' )
117
+            array($this, 'options_page')
118 118
         );
119 119
     }
120 120
 
121
-    public function add_addons_menu(){
122
-        if ( !apply_filters( 'wpi_show_addons_page', true ) ) {
121
+    public function add_addons_menu() {
122
+        if (!apply_filters('wpi_show_addons_page', true)) {
123 123
             return;
124 124
         }
125 125
 
@@ -129,78 +129,78 @@  discard block
 block discarded – undo
129 129
             __('Extensions', 'invoicing'),
130 130
             'manage_options',
131 131
             'wpi-addons',
132
-            array( $this, 'addons_page' )
132
+            array($this, 'addons_page')
133 133
         );
134 134
     }
135 135
 
136
-    public function addons_page(){
136
+    public function addons_page() {
137 137
         $addon_obj = new WPInv_Admin_Addons();
138 138
         $addon_obj->output();
139 139
     }
140 140
 
141 141
     function options_page() {
142 142
 
143
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
143
+        if (!wpinv_current_user_can_manage_invoicing()) {
144 144
             return;
145 145
         }
146 146
 
147 147
         $settings_tabs = wpinv_get_settings_tabs();
148 148
         $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs;
149
-        $active_tab    = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general';
150
-        $sections      = wpinv_get_settings_tab_sections( $active_tab );
149
+        $active_tab    = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general';
150
+        $sections      = wpinv_get_settings_tab_sections($active_tab);
151 151
         $key           = 'main';
152 152
 
153
-        if ( is_array( $sections ) ) {
154
-            $key = key( $sections );
153
+        if (is_array($sections)) {
154
+            $key = key($sections);
155 155
         }
156 156
 
157 157
         add_thickbox();
158 158
 
159
-        $registered_sections = wpinv_get_settings_tab_sections( $active_tab );
160
-        $section             = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? sanitize_text_field( $_GET['section'] ) : $key;
159
+        $registered_sections = wpinv_get_settings_tab_sections($active_tab);
160
+        $section             = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? sanitize_text_field($_GET['section']) : $key;
161 161
         ?>
162 162
         <div class="wrap">
163 163
             <h1 class="nav-tab-wrapper">
164 164
                 <?php
165
-                foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) {
166
-                    $tab_url = add_query_arg( array(
165
+                foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) {
166
+                    $tab_url = add_query_arg(array(
167 167
                         'settings-updated' => false,
168 168
                         'tab' => $tab_id,
169
-                    ), 'admin.php?page=wpinv-settings' );
169
+                    ), 'admin.php?page=wpinv-settings');
170 170
 
171 171
                     // Remove the section from the tabs so we always end up at the main section
172
-                    $tab_url = remove_query_arg( 'section', $tab_url );
173
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
172
+                    $tab_url = remove_query_arg('section', $tab_url);
173
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
174 174
 
175 175
                     $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
176 176
 
177
-                    echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">';
178
-                    echo esc_html( $tab_name );
177
+                    echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">';
178
+                    echo esc_html($tab_name);
179 179
                     echo '</a>';
180 180
                 }
181 181
                 ?>
182 182
             </h1>
183 183
             <?php
184
-            $number_of_sections = count( $sections );
184
+            $number_of_sections = count($sections);
185 185
             $number = 0;
186
-            if ( $number_of_sections > 1 ) {
186
+            if ($number_of_sections > 1) {
187 187
                 echo '<div><ul class="subsubsub">';
188
-                foreach( $sections as $section_id => $section_name ) {
188
+                foreach ($sections as $section_id => $section_name) {
189 189
                     echo '<li>';
190 190
                     $number++;
191
-                    $tab_url = add_query_arg( array(
191
+                    $tab_url = add_query_arg(array(
192 192
                         'settings-updated' => false,
193 193
                         'tab' => $active_tab,
194 194
                         'section' => $section_id
195
-                    ), admin_url( 'admin.php?page=wpinv-settings' ) );
196
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
195
+                    ), admin_url('admin.php?page=wpinv-settings'));
196
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
197 197
                     $class = '';
198
-                    if ( $section == $section_id ) {
198
+                    if ($section == $section_id) {
199 199
                         $class = 'current';
200 200
                     }
201
-                    echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>';
201
+                    echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>';
202 202
 
203
-                    if ( $number != $number_of_sections ) {
203
+                    if ($number != $number_of_sections) {
204 204
                         echo ' | ';
205 205
                     }
206 206
                     echo '</li>';
@@ -212,20 +212,20 @@  discard block
 block discarded – undo
212 212
                 <form method="post" action="options.php">
213 213
                     <table class="form-table">
214 214
                         <?php
215
-                        settings_fields( 'wpinv_settings' );
215
+                        settings_fields('wpinv_settings');
216 216
 
217
-                        if ( 'main' === $section ) {
218
-                            do_action( 'wpinv_settings_tab_top', $active_tab );
217
+                        if ('main' === $section) {
218
+                            do_action('wpinv_settings_tab_top', $active_tab);
219 219
                         }
220 220
 
221
-                        do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section );
222
-                        do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section );
223
-                        do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section );
224
-                        do_action( 'getpaid_settings_tab_bottom', $active_tab, $section );
221
+                        do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section);
222
+                        do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section);
223
+                        do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section);
224
+                        do_action('getpaid_settings_tab_bottom', $active_tab, $section);
225 225
 
226 226
                         // For backwards compatibility
227
-                        if ( 'main' === $section ) {
228
-                            do_action( 'wpinv_settings_tab_bottom', $active_tab );
227
+                        if ('main' === $section) {
228
+                            do_action('wpinv_settings_tab_bottom', $active_tab);
229 229
                         }
230 230
                         ?>
231 231
                     </table>
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
     }
238 238
 
239 239
     public function remove_admin_submenus() {
240
-        remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' );
240
+        remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice');
241 241
     }
242 242
 
243 243
     /**
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
 
248 248
         add_meta_box(
249 249
             'wpinv_endpoints_nav_link',
250
-            __( 'GetPaid endpoints', 'invoicing' ),
251
-            array( $this, 'nav_menu_links' ),
250
+            __('GetPaid endpoints', 'invoicing'),
251
+            array($this, 'nav_menu_links'),
252 252
             'nav-menus',
253 253
             'side',
254 254
             'low'
@@ -263,12 +263,12 @@  discard block
 block discarded – undo
263 263
         $endpoints = $this->get_menu_items();
264 264
         ?>
265 265
         <div id="invoicing-endpoints" class="posttypediv">
266
-            <?php if ( ! empty( $endpoints['pages'] ) ) : ?>
266
+            <?php if (!empty($endpoints['pages'])) : ?>
267 267
                 <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active">
268 268
                     <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear">
269 269
                         <?php
270
-                            $walker = new Walker_Nav_Menu_Checklist( array() );
271
-                            echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $endpoints['pages'] ), 0, (object) array( 'walker' => $walker ) );
270
+                            $walker = new Walker_Nav_Menu_Checklist(array());
271
+                            echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object) array('walker' => $walker));
272 272
                         ?>
273 273
                     </ul>
274 274
                 </div>
@@ -277,11 +277,11 @@  discard block
 block discarded – undo
277 277
             <p class="button-controls wp-clearfix" data-items-type="invoicing-endpoints">
278 278
                 <span class="list-controls hide-if-no-js">
279 279
                     <input type="checkbox" id="invoicing-endpoints-tab" class="select-all">
280
-                    <label for="invoicing-endpoints-tab"><?php _e( 'Select all', 'invoicing' ); ?></label>
280
+                    <label for="invoicing-endpoints-tab"><?php _e('Select all', 'invoicing'); ?></label>
281 281
                 </span>
282 282
 
283 283
                 <span class="add-to-menu">
284
-                    <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'invoicing' ); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints">
284
+                    <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'invoicing'); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints">
285 285
                     <span class="spinner"></span>
286 286
                 </span>
287 287
             </p>
@@ -294,35 +294,35 @@  discard block
 block discarded – undo
294 294
      *
295 295
      * @return array.
296 296
      */
297
-    public function get_menu_items(){
297
+    public function get_menu_items() {
298 298
         $items = array();
299 299
 
300 300
         $pages = array(
301 301
             array(
302
-                'id'    => wpinv_get_option( 'invoice_history_page' ),
303
-                'label' => __( 'My Invoices', 'invoicing' ),
302
+                'id'    => wpinv_get_option('invoice_history_page'),
303
+                'label' => __('My Invoices', 'invoicing'),
304 304
             ),
305 305
             array(
306
-                'id'    => wpinv_get_option( 'invoice_subscription_page' ),
307
-                'label' => __( 'My Subscriptions', 'invoicing' ),
306
+                'id'    => wpinv_get_option('invoice_subscription_page'),
307
+                'label' => __('My Subscriptions', 'invoicing'),
308 308
             )
309 309
         );
310 310
 
311
-        foreach ( apply_filters( 'getpaid_menu_pages', $pages ) as $page ) {
311
+        foreach (apply_filters('getpaid_menu_pages', $pages) as $page) {
312 312
 
313
-            if ( (int) $page['id'] > 0 ) {
313
+            if ((int) $page['id'] > 0) {
314 314
 
315 315
                 $item                   = new stdClass();
316 316
                 $item->object_id        = (int) $page['id'];
317 317
                 $item->db_id            = 0;
318
-                $item->object           =  'page';
318
+                $item->object           = 'page';
319 319
                 $item->menu_item_parent = 0;
320 320
                 $item->type             = 'post_type';
321
-                $item->title            = esc_html( $page['label'] );
322
-                $item->url              = get_permalink( (int) $page['id'] );
321
+                $item->title            = esc_html($page['label']);
322
+                $item->url              = get_permalink((int) $page['id']);
323 323
                 $item->target           = '';
324 324
                 $item->attr_title       = '';
325
-                $item->classes          = array( 'wpinv-menu-item' );
325
+                $item->classes          = array('wpinv-menu-item');
326 326
                 $item->xfn              = '';
327 327
 
328 328
                 $items['pages'][]       = $item;
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 
332 332
         }
333 333
 
334
-        return apply_filters( 'wpinv_menu_items', $items );
334
+        return apply_filters('wpinv_menu_items', $items);
335 335
     }
336 336
 
337 337
 }
Please login to merge, or discard this patch.
includes/admin/admin-pages.php 1 patch
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -1,51 +1,51 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7
-add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' );
8
-function wpinv_discount_custom_column( $column ) {
7
+add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column');
8
+function wpinv_discount_custom_column($column) {
9 9
     global $post;
10 10
 
11
-    $discount = new WPInv_Discount( $post );
11
+    $discount = new WPInv_Discount($post);
12 12
 
13
-    switch ( $column ) {
13
+    switch ($column) {
14 14
         case 'code' :
15
-            echo esc_html( $discount->get_code() );
15
+            echo esc_html($discount->get_code());
16 16
         break;
17 17
         case 'amount' :
18
-            echo wp_kses_post( $discount->get_formatted_amount() );
18
+            echo wp_kses_post($discount->get_formatted_amount());
19 19
         break;
20 20
         case 'usage' :
21
-            echo wp_kses_post( $discount->get_usage() );
21
+            echo wp_kses_post($discount->get_usage());
22 22
         break;
23 23
         case 'start_date' :
24
-            echo wp_kses_post( getpaid_format_date_value( $discount->get_start_date() ) );
24
+            echo wp_kses_post(getpaid_format_date_value($discount->get_start_date()));
25 25
         break;
26 26
         case 'expiry_date' :
27
-            echo wp_kses_post( getpaid_format_date_value( $discount->get_expiration_date(), __( 'Never', 'invoicing' ) ) );
27
+            echo wp_kses_post(getpaid_format_date_value($discount->get_expiration_date(), __('Never', 'invoicing')));
28 28
         break;
29 29
     }
30 30
 }
31 31
 
32
-add_filter( 'post_row_actions', 'wpinv_post_row_actions', 90, 2 );
33
-function wpinv_post_row_actions( $actions, $post ) {
34
-    $post_type = !empty( $post->post_type ) ? $post->post_type : '';
32
+add_filter('post_row_actions', 'wpinv_post_row_actions', 90, 2);
33
+function wpinv_post_row_actions($actions, $post) {
34
+    $post_type = !empty($post->post_type) ? $post->post_type : '';
35 35
 
36
-    if ( $post_type == 'wpi_discount' ) {
37
-        $actions = wpinv_discount_row_actions( $post, $actions );
36
+    if ($post_type == 'wpi_discount') {
37
+        $actions = wpinv_discount_row_actions($post, $actions);
38 38
     }
39 39
 
40 40
     return $actions;
41 41
 }
42 42
 
43
-function wpinv_discount_row_actions( $discount, $row_actions ) {
44
-    $row_actions  = array();
45
-    $edit_link = get_edit_post_link( $discount->ID );
46
-    $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>';
43
+function wpinv_discount_row_actions($discount, $row_actions) {
44
+    $row_actions = array();
45
+    $edit_link = get_edit_post_link($discount->ID);
46
+    $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>';
47 47
 
48
-    if ( in_array( strtolower( $discount->post_status ),  array(  'publish' ) ) ) {
48
+    if (in_array(strtolower($discount->post_status), array('publish'))) {
49 49
 
50 50
         $url = wp_nonce_url(
51 51
             add_query_arg(
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
             'getpaid-nonce',
58 58
             'getpaid-nonce'
59 59
         );
60
-		$anchor = __( 'Deactivate', 'invoicing' );
61
-		$title  = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' );
60
+		$anchor = __('Deactivate', 'invoicing');
61
+		$title  = esc_attr__('Are you sure you want to deactivate this discount?', 'invoicing');
62 62
         $row_actions['deactivate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
63 63
 
64
-    } else if( in_array( strtolower( $discount->post_status ),  array( 'pending', 'draft' ) ) ) {
64
+    } else if (in_array(strtolower($discount->post_status), array('pending', 'draft'))) {
65 65
 
66
-        $url    = wp_nonce_url(
66
+        $url = wp_nonce_url(
67 67
             add_query_arg(
68 68
                 array(
69 69
                     'getpaid-admin-action' => 'activate_discount',
@@ -73,13 +73,13 @@  discard block
 block discarded – undo
73 73
             'getpaid-nonce',
74 74
             'getpaid-nonce'
75 75
         );
76
-		$anchor = __( 'Activate', 'invoicing' );
77
-		$title  = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' );
76
+		$anchor = __('Activate', 'invoicing');
77
+		$title  = esc_attr__('Are you sure you want to activate this discount?', 'invoicing');
78 78
         $row_actions['activate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
79 79
 
80 80
     }
81 81
 
82
-    $url    = esc_url(
82
+    $url = esc_url(
83 83
         wp_nonce_url(
84 84
             add_query_arg(
85 85
                 array(
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
             'getpaid-nonce'
92 92
         )
93 93
     );
94
-	$anchor = __( 'Delete', 'invoicing' );
95
-	$title  = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' );
94
+	$anchor = __('Delete', 'invoicing');
95
+	$title  = esc_attr__('Are you sure you want to delete this discount?', 'invoicing');
96 96
     $row_actions['delete'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
97 97
 
98
-    $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount );
98
+    $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount);
99 99
 
100 100
     return $row_actions;
101 101
 }
@@ -103,68 +103,68 @@  discard block
 block discarded – undo
103 103
 function wpinv_restrict_manage_posts() {
104 104
     global $typenow;
105 105
 
106
-    if( 'wpi_discount' == $typenow ) {
106
+    if ('wpi_discount' == $typenow) {
107 107
         wpinv_discount_filters();
108 108
     }
109 109
 }
110
-add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 );
110
+add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10);
111 111
 
112 112
 function wpinv_discount_filters() {
113 113
 
114 114
     ?>
115 115
     <select name="discount_type" id="dropdown_wpinv_discount_type">
116
-        <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option>
116
+        <option value=""><?php _e('Show all types', 'invoicing'); ?></option>
117 117
         <?php
118 118
             $types = wpinv_get_discount_types();
119 119
 
120
-            foreach ( $types as $name => $type ) {
121
-                echo '<option value="' . esc_attr( $name ) . '"';
120
+            foreach ($types as $name => $type) {
121
+                echo '<option value="' . esc_attr($name) . '"';
122 122
 
123
-                if ( isset( $_GET['discount_type'] ) )
124
-                    selected( $name, sanitize_text_field( $_GET['discount_type'] ) );
123
+                if (isset($_GET['discount_type']))
124
+                    selected($name, sanitize_text_field($_GET['discount_type']));
125 125
 
126
-                echo '>' . esc_html__( $type, 'invoicing' ) . '</option>';
126
+                echo '>' . esc_html__($type, 'invoicing') . '</option>';
127 127
             }
128 128
         ?>
129 129
     </select>
130 130
     <?php
131 131
 }
132 132
 
133
-function wpinv_request( $vars ) {
133
+function wpinv_request($vars) {
134 134
     global $typenow, $wp_post_statuses;
135 135
 
136
-    if ( getpaid_is_invoice_post_type( $typenow ) ) {
137
-        if ( ! isset( $vars['post_status'] ) ) {
138
-            $post_statuses = wpinv_get_invoice_statuses( false, false, $typenow );
136
+    if (getpaid_is_invoice_post_type($typenow)) {
137
+        if (!isset($vars['post_status'])) {
138
+            $post_statuses = wpinv_get_invoice_statuses(false, false, $typenow);
139 139
 
140
-            foreach ( $post_statuses as $status => $value ) {
141
-                if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) {
142
-                    unset( $post_statuses[ $status ] );
140
+            foreach ($post_statuses as $status => $value) {
141
+                if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) {
142
+                    unset($post_statuses[$status]);
143 143
                 }
144 144
             }
145 145
 
146
-            $vars['post_status'] = array_keys( $post_statuses );
146
+            $vars['post_status'] = array_keys($post_statuses);
147 147
         }
148 148
 
149
-    } else if ( 'wpi_discount' == $typenow ) {
150
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
149
+    } else if ('wpi_discount' == $typenow) {
150
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
151 151
         // Filter vat rule type
152
-        if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) {
152
+        if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') {
153 153
             $meta_query[] = array(
154 154
                     'key'   => '_wpi_discount_type',
155
-                    'value' => sanitize_key( urldecode( $_GET['discount_type'] ) ),
155
+                    'value' => sanitize_key(urldecode($_GET['discount_type'])),
156 156
                     'compare' => '='
157 157
                 );
158 158
         }
159 159
 
160
-        if ( !empty( $meta_query ) ) {
160
+        if (!empty($meta_query)) {
161 161
             $vars['meta_query'] = $meta_query;
162 162
         }
163 163
     }
164 164
 
165 165
     return $vars;
166 166
 }
167
-add_filter( 'request', 'wpinv_request' );
167
+add_filter('request', 'wpinv_request');
168 168
 
169 169
 /**
170 170
  * Create a page and store the ID in an option.
@@ -176,19 +176,19 @@  discard block
 block discarded – undo
176 176
  * @param int $post_parent (default: 0) Parent for the new page
177 177
  * @return int page ID
178 178
  */
179
-function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) {
179
+function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) {
180 180
     global $wpdb;
181 181
 
182
-    $option_value = wpinv_get_option( $option );
182
+    $option_value = wpinv_get_option($option);
183 183
 
184
-    if ( ! empty( $option_value ) && ( $page_object = get_post( $option_value ) ) ) {
185
-        if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) {
184
+    if (!empty($option_value) && ($page_object = get_post($option_value))) {
185
+        if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) {
186 186
             // Valid page is already in place
187 187
             return $page_object->ID;
188 188
         }
189 189
     }
190 190
 
191
-    if(!empty($post_parent)){
191
+    if (!empty($post_parent)) {
192 192
         $page = get_page_by_path($post_parent);
193 193
         if ($page) {
194 194
             $post_parent = $page->ID;
@@ -197,40 +197,40 @@  discard block
 block discarded – undo
197 197
         }
198 198
     }
199 199
 
200
-    if ( strlen( $page_content ) > 0 ) {
200
+    if (strlen($page_content) > 0) {
201 201
         // Search for an existing page with the specified page content (typically a shortcode)
202
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
202
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
203 203
     } else {
204 204
         // Search for an existing page with the specified page slug
205
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug ) );
205
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug));
206 206
     }
207 207
 
208
-    $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content );
208
+    $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content);
209 209
 
210
-    if ( $valid_page_found ) {
211
-        if ( $option ) {
212
-            wpinv_update_option( $option, $valid_page_found );
210
+    if ($valid_page_found) {
211
+        if ($option) {
212
+            wpinv_update_option($option, $valid_page_found);
213 213
         }
214 214
         return $valid_page_found;
215 215
     }
216 216
 
217 217
     // Search for a matching valid trashed page
218
-    if ( strlen( $page_content ) > 0 ) {
218
+    if (strlen($page_content) > 0) {
219 219
         // Search for an existing page with the specified page content (typically a shortcode)
220
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
220
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
221 221
     } else {
222 222
         // Search for an existing page with the specified page slug
223
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) );
223
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug));
224 224
     }
225 225
 
226
-    if ( $trashed_page_found ) {
226
+    if ($trashed_page_found) {
227 227
         $page_id   = $trashed_page_found;
228 228
         $page_data = array(
229 229
             'ID'             => $page_id,
230 230
             'post_status'    => 'publish',
231 231
             'post_parent'    => $post_parent,
232 232
         );
233
-        wp_update_post( $page_data );
233
+        wp_update_post($page_data);
234 234
     } else {
235 235
         $page_data = array(
236 236
             'post_status'    => 'publish',
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
             'post_parent'    => $post_parent,
243 243
             'comment_status' => 'closed',
244 244
         );
245
-        $page_id = wp_insert_post( $page_data );
245
+        $page_id = wp_insert_post($page_data);
246 246
     }
247 247
 
248
-    if ( $option ) {
249
-        wpinv_update_option( $option, (int) $page_id );
248
+    if ($option) {
249
+        wpinv_update_option($option, (int) $page_id);
250 250
     }
251 251
 
252 252
     return $page_id;
@@ -259,11 +259,11 @@  discard block
 block discarded – undo
259 259
  *
260 260
  * @return array
261 261
  */
262
-function wpinv_add_aui_screens($screen_ids){
262
+function wpinv_add_aui_screens($screen_ids) {
263 263
 
264 264
     // load on these pages if set
265
-    $screen_ids = array_merge( $screen_ids, wpinv_get_screen_ids() );
265
+    $screen_ids = array_merge($screen_ids, wpinv_get_screen_ids());
266 266
 
267 267
     return $screen_ids;
268 268
 }
269
-add_filter('aui_screen_ids','wpinv_add_aui_screens');
270 269
\ No newline at end of file
270
+add_filter('aui_screen_ids', 'wpinv_add_aui_screens');
271 271
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/class-wpinv-subscriptions-list-table.php 1 patch
Spacing   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -3,9 +3,9 @@  discard block
 block discarded – undo
3 3
  * Displays a list of all subscriptions rules
4 4
  */
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) exit;
6
+if (!defined('ABSPATH')) exit;
7 7
 
8
-if ( ! class_exists( 'WP_List_Table' ) ) {
8
+if (!class_exists('WP_List_Table')) {
9 9
 	include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
10 10
 }
11 11
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
 		$this->prepare_query();
80 80
 
81
-		$this->base_url = remove_query_arg( 'status' );
81
+		$this->base_url = remove_query_arg('status');
82 82
 
83 83
 	}
84 84
 
@@ -91,13 +91,13 @@  discard block
 block discarded – undo
91 91
 		$query = array(
92 92
 			'number'  => $this->per_page,
93 93
 			'paged'   => $this->get_paged(),
94
-			'status'  => ( isset( $_GET['status'] ) && array_key_exists( $_GET['status'], getpaid_get_subscription_statuses() ) ) ? sanitize_text_field( $_GET['status'] ) : 'all',
95
-			'orderby' => ( isset( $_GET['orderby'] ) ) ? sanitize_text_field( $_GET['orderby'] ) : 'id',
96
-			'order'   => ( isset( $_GET['order'] ) ) ? sanitize_text_field( $_GET['order'] ) : 'DESC',
94
+			'status'  => (isset($_GET['status']) && array_key_exists($_GET['status'], getpaid_get_subscription_statuses())) ? sanitize_text_field($_GET['status']) : 'all',
95
+			'orderby' => (isset($_GET['orderby'])) ? sanitize_text_field($_GET['orderby']) : 'id',
96
+			'order'   => (isset($_GET['order'])) ? sanitize_text_field($_GET['order']) : 'DESC',
97 97
 			'customer_in' => $this->get_user_in(),
98 98
 		);
99 99
 
100
-		if ( is_array( $query['customer_in'] ) && empty( $query['customer_in'] ) ) {
100
+		if (is_array($query['customer_in']) && empty($query['customer_in'])) {
101 101
 			$this->total_count         = 0;
102 102
 			$this->current_total_count = 0;
103 103
 			$this->items               = array();
@@ -106,15 +106,15 @@  discard block
 block discarded – undo
106 106
 		}
107 107
 
108 108
 		// Prepare class properties.
109
-		$this->query               = new GetPaid_Subscriptions_Query( $query );
109
+		$this->query               = new GetPaid_Subscriptions_Query($query);
110 110
 		$this->total_count         = $this->query->get_total();
111 111
 		$this->current_total_count = $this->query->get_total();
112 112
 		$this->items               = $this->query->get_results();
113
-		$this->status_counts       = getpaid_get_subscription_status_counts( $query );
113
+		$this->status_counts       = getpaid_get_subscription_status_counts($query);
114 114
 
115
-		if ( 'all' != $query['status'] ) {
116
-			unset( $query['status'] );
117
-			$this->total_count   = getpaid_get_subscriptions( $query, 'count' );
115
+		if ('all' != $query['status']) {
116
+			unset($query['status']);
117
+			$this->total_count = getpaid_get_subscriptions($query, 'count');
118 118
 		}
119 119
 
120 120
 	}
@@ -126,14 +126,14 @@  discard block
 block discarded – undo
126 126
 	public function get_user_in() {
127 127
 
128 128
 		// Abort if no user.
129
-		if ( empty( $_GET['s'] ) ) {
129
+		if (empty($_GET['s'])) {
130 130
 			return null;
131 131
 		}
132 132
 
133 133
 		// Or invalid user.
134
-		$user = wp_unslash( sanitize_text_field( $_REQUEST['s'] ) );
134
+		$user = wp_unslash(sanitize_text_field($_REQUEST['s']));
135 135
 
136
-		if ( empty( $user ) ) {
136
+		if (empty($user)) {
137 137
 			return null;
138 138
 		}
139 139
 
@@ -162,26 +162,26 @@  discard block
 block discarded – undo
162 162
 	 */
163 163
 	public function get_views() {
164 164
 
165
-		$current  = isset( $_GET['status'] ) ? sanitize_text_field( $_GET['status'] ) : 'all';
165
+		$current  = isset($_GET['status']) ? sanitize_text_field($_GET['status']) : 'all';
166 166
 		$views    = array(
167 167
 
168 168
 			'all' => sprintf(
169 169
 				'<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
170
-				esc_url( add_query_arg( 'status', false, $this->base_url ) ),
170
+				esc_url(add_query_arg('status', false, $this->base_url)),
171 171
 				$current === 'all' ? ' class="current"' : '',
172
-				__('All','invoicing' ),
172
+				__('All', 'invoicing'),
173 173
 				$this->total_count
174 174
 			)
175 175
 
176 176
 		);
177 177
 
178
-		foreach ( array_filter( $this->status_counts ) as $status => $count ) {
178
+		foreach (array_filter($this->status_counts) as $status => $count) {
179 179
 
180
-			$views[ $status ] = sprintf(
180
+			$views[$status] = sprintf(
181 181
 				'<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
182
-				esc_url( add_query_arg( 'status', urlencode( $status ), $this->base_url ) ),
182
+				esc_url(add_query_arg('status', urlencode($status), $this->base_url)),
183 183
 				$current === $status ? ' class="current"' : '',
184
-				esc_html( getpaid_get_subscription_status_label( $status ) ),
184
+				esc_html(getpaid_get_subscription_status_label($status)),
185 185
 				$count
186 186
 			);
187 187
 
@@ -198,8 +198,8 @@  discard block
 block discarded – undo
198 198
 	 * @since       1.0.0
199 199
 	 * @return      string
200 200
 	 */
201
-	public function column_default( $item, $column_name ) {
202
-		return apply_filters( "getpaid_subscriptions_table_column_$column_name", $item->$column_name );
201
+	public function column_default($item, $column_name) {
202
+		return apply_filters("getpaid_subscriptions_table_column_$column_name", $item->$column_name);
203 203
 	}
204 204
 
205 205
 	/**
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 	 * @param WPInv_Subscription $item
209 209
 	 * @return string
210 210
 	 */
211
-	public function column_cb( $item ) {
212
-		return sprintf( '<input type="checkbox" name="id[]" value="%s" />', esc_html( $item->get_id() ) );
211
+	public function column_cb($item) {
212
+		return sprintf('<input type="checkbox" name="id[]" value="%s" />', esc_html($item->get_id()));
213 213
 	}
214 214
 
215 215
 	/**
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 	 * @since       1.0.0
220 220
 	 * @return      string
221 221
 	 */
222
-	public function column_status( $item ) {
222
+	public function column_status($item) {
223 223
 		return $item->get_status_label_html();
224 224
 	}
225 225
 
@@ -230,44 +230,44 @@  discard block
 block discarded – undo
230 230
 	 * @since       1.0.0
231 231
 	 * @return      string
232 232
 	 */
233
-	public function column_subscription( $item ) {
233
+	public function column_subscription($item) {
234 234
 
235
-		$username = __( '(Missing User)', 'invoicing' );
235
+		$username = __('(Missing User)', 'invoicing');
236 236
 
237
-		$user = get_userdata( $item->get_customer_id() );
238
-		if ( $user ) {
237
+		$user = get_userdata($item->get_customer_id());
238
+		if ($user) {
239 239
 
240 240
 			$username = sprintf(
241 241
 				'<a href="user-edit.php?user_id=%s">%s</a>',
242
-				absint( $user->ID ),
243
-				! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
242
+				absint($user->ID),
243
+				!empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email)
244 244
 			);
245 245
 
246 246
 		}
247 247
 
248 248
 		// translators: $1: is opening link, $2: is subscription id number, $3: is closing link tag, $4: is user's name
249 249
 		$column_content = sprintf(
250
-			_x( '%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing' ),
251
-			'<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $item->get_id() ) ) ) . '">',
252
-			'<strong>' . esc_attr( $item->get_id() ) . '</strong>', '</a>',
250
+			_x('%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing'),
251
+			'<a href="' . esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($item->get_id()))) . '">',
252
+			'<strong>' . esc_attr($item->get_id()) . '</strong>', '</a>',
253 253
 			$username
254 254
 		);
255 255
 
256 256
 		$row_actions = array();
257 257
 
258 258
 		// View subscription.
259
-		$view_url    = esc_url( add_query_arg( 'id', $item->get_id(), admin_url( 'admin.php?page=wpinv-subscriptions' ) ));
260
-		$row_actions['view'] = '<a href="' . $view_url . '">' . __( 'View Subscription', 'invoicing' ) . '</a>';
259
+		$view_url    = esc_url(add_query_arg('id', $item->get_id(), admin_url('admin.php?page=wpinv-subscriptions')));
260
+		$row_actions['view'] = '<a href="' . $view_url . '">' . __('View Subscription', 'invoicing') . '</a>';
261 261
 
262 262
 		// View invoice.
263
-		$invoice = get_post( $item->get_parent_invoice_id() );
263
+		$invoice = get_post($item->get_parent_invoice_id());
264 264
 
265
-		if ( ! empty( $invoice ) ) {
266
-			$invoice_url            = get_edit_post_link( $invoice );
267
-			$row_actions['invoice'] = '<a href="' . $invoice_url . '">' . __( 'View Invoice', 'invoicing' ) . '</a>';
265
+		if (!empty($invoice)) {
266
+			$invoice_url            = get_edit_post_link($invoice);
267
+			$row_actions['invoice'] = '<a href="' . $invoice_url . '">' . __('View Invoice', 'invoicing') . '</a>';
268 268
 		}
269 269
 
270
-		$delete_url            = esc_url(
270
+		$delete_url = esc_url(
271 271
 			wp_nonce_url(
272 272
 				add_query_arg(
273 273
 					array(
@@ -279,11 +279,11 @@  discard block
 block discarded – undo
279 279
 				'getpaid-nonce'
280 280
 			)
281 281
 		);
282
-		$row_actions['delete'] = '<a class="text-danger" href="' . $delete_url . '">' . __( 'Delete Subscription', 'invoicing' ) . '</a>';
282
+		$row_actions['delete'] = '<a class="text-danger" href="' . $delete_url . '">' . __('Delete Subscription', 'invoicing') . '</a>';
283 283
 
284
-		$row_actions = $this->row_actions( apply_filters( 'getpaid_subscription_table_row_actions', $row_actions, $item ) );
284
+		$row_actions = $this->row_actions(apply_filters('getpaid_subscription_table_row_actions', $row_actions, $item));
285 285
 
286
-		return "<strong>$column_content</strong>" . $this->column_amount( $item ) . $row_actions;
286
+		return "<strong>$column_content</strong>" . $this->column_amount($item) . $row_actions;
287 287
 	}
288 288
 
289 289
 	/**
@@ -293,8 +293,8 @@  discard block
 block discarded – undo
293 293
 	 * @since       1.0.0
294 294
 	 * @return      string
295 295
 	 */
296
-	public function column_renewal_date( $item ) {
297
-		return getpaid_format_date_value( $item->get_expiration() );
296
+	public function column_renewal_date($item) {
297
+		return getpaid_format_date_value($item->get_expiration());
298 298
 	}
299 299
 
300 300
 	/**
@@ -304,27 +304,27 @@  discard block
 block discarded – undo
304 304
 	 * @since       1.0.0
305 305
 	 * @return      string
306 306
 	 */
307
-	public function column_start_date( $item ) {
307
+	public function column_start_date($item) {
308 308
 
309 309
 		$gateway = $item->get_parent_invoice()->get_gateway_title();
310 310
 
311
-		if ( empty( $gateway ) ) {
312
-			return getpaid_format_date_value( $item->get_date_created() );
311
+		if (empty($gateway)) {
312
+			return getpaid_format_date_value($item->get_date_created());
313 313
 		}
314 314
 
315
-		$url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $item );
316
-		if ( ! empty( $url ) ) {
315
+		$url = apply_filters('getpaid_remote_subscription_profile_url', '', $item);
316
+		if (!empty($url)) {
317 317
 
318
-			return getpaid_format_date_value( $item->get_date_created() ) . '<br>' . sprintf(
319
-				__( 'Via %s', 'invoicing' ),
320
-				'<strong><a href="' . esc_url( $url ) . '" target="_blank">' . esc_html( $item->get_parent_invoice()->get_gateway_title() ) . '</a></strong>'
318
+			return getpaid_format_date_value($item->get_date_created()) . '<br>' . sprintf(
319
+				__('Via %s', 'invoicing'),
320
+				'<strong><a href="' . esc_url($url) . '" target="_blank">' . esc_html($item->get_parent_invoice()->get_gateway_title()) . '</a></strong>'
321 321
 			);
322 322
 
323 323
 		}
324 324
 
325
-		return getpaid_format_date_value( $item->get_date_created() ) . '<br>' . sprintf(
326
-			__( 'Via %s', 'invoicing' ),
327
-			'<strong>' . esc_html( $item->get_parent_invoice()->get_gateway_title() ) . '</strong>'
325
+		return getpaid_format_date_value($item->get_date_created()) . '<br>' . sprintf(
326
+			__('Via %s', 'invoicing'),
327
+			'<strong>' . esc_html($item->get_parent_invoice()->get_gateway_title()) . '</strong>'
328 328
 		);
329 329
 
330 330
 	}
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
 	 * @since       1.0.19
337 337
 	 * @return      string
338 338
 	 */
339
-	public static function column_amount( $item ) {
340
-		$amount = getpaid_get_formatted_subscription_amount( $item );
339
+	public static function column_amount($item) {
340
+		$amount = getpaid_get_formatted_subscription_amount($item);
341 341
 		return "<span class='text-muted form-text mt-2 mb-2'>$amount</span>";
342 342
 	}
343 343
 
@@ -348,9 +348,9 @@  discard block
 block discarded – undo
348 348
 	 * @since       1.0.0
349 349
 	 * @return      string
350 350
 	 */
351
-	public function column_renewals( $item ) {
351
+	public function column_renewals($item) {
352 352
 		$max_bills = $item->get_bill_times();
353
-		return $item->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
353
+		return $item->get_times_billed() . ' / ' . (empty($max_bills) ? "&infin;" : $max_bills);
354 354
 	}
355 355
 
356 356
 	/**
@@ -360,15 +360,15 @@  discard block
 block discarded – undo
360 360
 	 * @since       1.0.0
361 361
 	 * @return      string
362 362
 	 */
363
-	public function column_item( $item ) {
364
-		$subscription_group = getpaid_get_invoice_subscription_group( $item->get_parent_invoice_id(), $item->get_id() );
363
+	public function column_item($item) {
364
+		$subscription_group = getpaid_get_invoice_subscription_group($item->get_parent_invoice_id(), $item->get_id());
365 365
 
366
-		if ( empty( $subscription_group ) ) {
367
-			return $this->generate_item_markup( $item->get_product_id() );
366
+		if (empty($subscription_group)) {
367
+			return $this->generate_item_markup($item->get_product_id());
368 368
 		}
369 369
 
370
-		$markup = array_map( array( $this, 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
371
-		return implode( ' | ', $markup );
370
+		$markup = array_map(array($this, 'generate_item_markup'), array_keys($subscription_group['items']));
371
+		return implode(' | ', $markup);
372 372
 
373 373
 	}
374 374
 
@@ -379,16 +379,16 @@  discard block
 block discarded – undo
379 379
 	 * @since       1.0.0
380 380
 	 * @return      string
381 381
 	 */
382
-	public static function generate_item_markup( $item_id ) {
383
-		$item = get_post( $item_id );
382
+	public static function generate_item_markup($item_id) {
383
+		$item = get_post($item_id);
384 384
 
385
-		if ( ! empty( $item ) ) {
386
-			$link = get_edit_post_link( $item );
387
-			$link = esc_url( $link );
388
-			$name = esc_html( get_the_title( $item ) );
385
+		if (!empty($item)) {
386
+			$link = get_edit_post_link($item);
387
+			$link = esc_url($link);
388
+			$name = esc_html(get_the_title($item));
389 389
 			return wpinv_current_user_can_manage_invoicing() ? "<a href='$link'>$name</a>" : $name;
390 390
 		} else {
391
-			return sprintf( __( 'Item #%s', 'invoicing' ), $item_id );
391
+			return sprintf(__('Item #%s', 'invoicing'), $item_id);
392 392
 		}
393 393
 
394 394
 	}
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 	 * @return      int
400 400
 	 */
401 401
 	public function get_paged() {
402
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
402
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
403 403
 	}
404 404
 
405 405
 	/**
@@ -412,13 +412,13 @@  discard block
 block discarded – undo
412 412
 		$hidden   = array();
413 413
 		$sortable = $this->get_sortable_columns();
414 414
 
415
-		$this->_column_headers = array( $columns, $hidden, $sortable );
415
+		$this->_column_headers = array($columns, $hidden, $sortable);
416 416
 
417 417
 		$this->set_pagination_args(
418 418
 			array(
419 419
 			'total_items' => $this->current_total_count,
420 420
 			'per_page'    => $this->per_page,
421
-			'total_pages' => ceil( $this->current_total_count / $this->per_page )
421
+			'total_pages' => ceil($this->current_total_count / $this->per_page)
422 422
 			)
423 423
 		);
424 424
 	}
@@ -428,18 +428,18 @@  discard block
 block discarded – undo
428 428
 	 *
429 429
 	 * @return array
430 430
 	 */
431
-	public function get_columns(){
431
+	public function get_columns() {
432 432
 		$columns = array(
433 433
 			'cb'                => '<input type="checkbox" />',
434
-			'subscription'      => __( 'Subscription', 'invoicing' ),
435
-			'start_date'        => __( 'Start Date', 'invoicing' ),
436
-			'renewal_date'      => __( 'Next Payment', 'invoicing' ),
437
-			'renewals'          => __( 'Payments', 'invoicing' ),
438
-			'item'              => __( 'Items', 'invoicing' ),
439
-			'status'            => __( 'Status', 'invoicing' ),
434
+			'subscription'      => __('Subscription', 'invoicing'),
435
+			'start_date'        => __('Start Date', 'invoicing'),
436
+			'renewal_date'      => __('Next Payment', 'invoicing'),
437
+			'renewals'          => __('Payments', 'invoicing'),
438
+			'item'              => __('Items', 'invoicing'),
439
+			'status'            => __('Status', 'invoicing'),
440 440
 		);
441 441
 
442
-		return apply_filters( 'manage_getpaid_subscriptions_table_columns', $columns );
442
+		return apply_filters('manage_getpaid_subscriptions_table_columns', $columns);
443 443
 	}
444 444
 
445 445
 	/**
@@ -449,15 +449,15 @@  discard block
 block discarded – undo
449 449
 	 */
450 450
 	public function get_sortable_columns() {
451 451
 		$sortable = array(
452
-			'subscription' => array( 'id', true ),
453
-			'start_date'   => array( 'created', true ),
454
-			'renewal_date' => array( 'expiration', true ),
455
-			'renewals'     => array( 'bill_times', true ),
456
-			'item'         => array( 'product_id', true ),
457
-			'status'       => array( 'status', true ),
452
+			'subscription' => array('id', true),
453
+			'start_date'   => array('created', true),
454
+			'renewal_date' => array('expiration', true),
455
+			'renewals'     => array('bill_times', true),
456
+			'item'         => array('product_id', true),
457
+			'status'       => array('status', true),
458 458
 		);
459 459
 
460
-		return apply_filters( 'manage_getpaid_subscriptions_sortable_table_columns', $sortable );
460
+		return apply_filters('manage_getpaid_subscriptions_sortable_table_columns', $sortable);
461 461
 	}
462 462
 
463 463
 	/**
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 	 * @return bool
467 467
 	 */
468 468
 	public function has_items() {
469
-		return ! empty( $this->current_total_count );
469
+		return !empty($this->current_total_count);
470 470
 	}
471 471
 
472 472
 	/**
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin-profile.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -4,11 +4,11 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-if ( ! defined( 'ABSPATH' ) ) {
7
+if (!defined('ABSPATH')) {
8 8
 	exit; // Exit if accessed directly
9 9
 }
10 10
 
11
-if ( ! class_exists( 'GetPaid_Admin_Profile', false ) ) :
11
+if (!class_exists('GetPaid_Admin_Profile', false)) :
12 12
 
13 13
 	/**
14 14
 	 * GetPaid_Admin_Profile Class.
@@ -19,11 +19,11 @@  discard block
 block discarded – undo
19 19
 		 * Hook in tabs.
20 20
 		 */
21 21
 		public function __construct() {
22
-			add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 );
23
-			add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 );
22
+			add_action('show_user_profile', array($this, 'add_customer_meta_fields'), 100);
23
+			add_action('edit_user_profile', array($this, 'add_customer_meta_fields'), 100);
24 24
 
25
-			add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) );
26
-			add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) );
25
+			add_action('personal_options_update', array($this, 'save_customer_meta_fields'));
26
+			add_action('edit_user_profile_update', array($this, 'save_customer_meta_fields'));
27 27
 		}
28 28
 
29 29
 		/**
@@ -37,54 +37,54 @@  discard block
 block discarded – undo
37 37
 				'getpaid_customer_meta_fields',
38 38
 				array(
39 39
 					'billing'  => array(
40
-						'title'  => __( 'Billing Details (GetPaid)', 'invoicing' ),
40
+						'title'  => __('Billing Details (GetPaid)', 'invoicing'),
41 41
 						'fields' => array(
42 42
 							'_wpinv_first_name' => array(
43
-								'label'       => __( 'First name', 'invoicing' ),
43
+								'label'       => __('First name', 'invoicing'),
44 44
 								'description' => '',
45 45
 							),
46 46
 							'_wpinv_last_name'  => array(
47
-								'label'       => __( 'Last name', 'invoicing' ),
47
+								'label'       => __('Last name', 'invoicing'),
48 48
 								'description' => '',
49 49
 							),
50 50
 							'_wpinv_company'    => array(
51
-								'label'       => __( 'Company', 'invoicing' ),
51
+								'label'       => __('Company', 'invoicing'),
52 52
 								'description' => '',
53 53
 							),
54 54
 							'_wpinv_company_id'    => array(
55
-								'label'       => __( 'Company ID', 'invoicing' ),
55
+								'label'       => __('Company ID', 'invoicing'),
56 56
 								'description' => '',
57 57
 							),
58 58
 							'_wpinv_address'  => array(
59
-								'label'       => __( 'Address', 'invoicing' ),
59
+								'label'       => __('Address', 'invoicing'),
60 60
 								'description' => '',
61 61
 							),
62 62
 							'_wpinv_city'       => array(
63
-								'label'       => __( 'City', 'invoicing' ),
63
+								'label'       => __('City', 'invoicing'),
64 64
 								'description' => '',
65 65
 							),
66 66
 							'_wpinv_zip'   => array(
67
-								'label'       => __( 'Postcode / ZIP', 'invoicing' ),
67
+								'label'       => __('Postcode / ZIP', 'invoicing'),
68 68
 								'description' => '',
69 69
 							),
70 70
 							'_wpinv_country'    => array(
71
-								'label'       => __( 'Country / Region', 'invoicing' ),
71
+								'label'       => __('Country / Region', 'invoicing'),
72 72
 								'description' => '',
73 73
 								'class'       => 'getpaid_js_field-country',
74 74
 								'type'        => 'select',
75
-								'options'     => array( '' => __( 'Select a country / region&hellip;', 'invoicing' ) ) + wpinv_get_country_list(),
75
+								'options'     => array('' => __('Select a country / region&hellip;', 'invoicing')) + wpinv_get_country_list(),
76 76
 							),
77 77
 							'_wpinv_state'      => array(
78
-								'label'       => __( 'State / County', 'invoicing' ),
79
-								'description' => __( 'State / County or state code', 'invoicing' ),
78
+								'label'       => __('State / County', 'invoicing'),
79
+								'description' => __('State / County or state code', 'invoicing'),
80 80
 								'class'       => 'getpaid_js_field-state regular-text',
81 81
 							),
82 82
 							'_wpinv_phone'      => array(
83
-								'label'       => __( 'Phone', 'invoicing' ),
83
+								'label'       => __('Phone', 'invoicing'),
84 84
 								'description' => '',
85 85
 							),
86 86
 							'_wpinv_vat_number'      => array(
87
-								'label'       => __( 'VAT Number', 'invoicing' ),
87
+								'label'       => __('VAT Number', 'invoicing'),
88 88
 								'description' => '',
89 89
 							),
90 90
 						),
@@ -99,39 +99,39 @@  discard block
 block discarded – undo
99 99
 		 *
100 100
 		 * @param WP_User $user
101 101
 		 */
102
-		public function add_customer_meta_fields( $user ) {
102
+		public function add_customer_meta_fields($user) {
103 103
 
104
-			if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) {
104
+			if (!apply_filters('getpaid_current_user_can_edit_customer_meta_fields', current_user_can('manage_options'), $user->ID)) {
105 105
 				return;
106 106
 			}
107 107
 
108 108
 			$show_fields = $this->get_customer_meta_fields();
109 109
 
110
-			foreach ( $show_fields as $fieldset_key => $fieldset ) :
110
+			foreach ($show_fields as $fieldset_key => $fieldset) :
111 111
 				?>
112
-				<h2><?php echo esc_html( $fieldset['title'] ); ?></h2>
113
-				<table class="form-table" id="<?php echo esc_attr( 'getpaid-fieldset-' . $fieldset_key ); ?>">
114
-					<?php foreach ( $fieldset['fields'] as $key => $field ) : ?>
112
+				<h2><?php echo esc_html($fieldset['title']); ?></h2>
113
+				<table class="form-table" id="<?php echo esc_attr('getpaid-fieldset-' . $fieldset_key); ?>">
114
+					<?php foreach ($fieldset['fields'] as $key => $field) : ?>
115 115
 						<tr>
116 116
 							<th>
117
-								<label for="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $field['label'] ); ?></label>
117
+								<label for="<?php echo esc_attr($key); ?>"><?php echo esc_html($field['label']); ?></label>
118 118
 							</th>
119 119
 							<td>
120
-								<?php if ( ! empty( $field['type'] ) && 'select' === $field['type'] ) : ?>
121
-									<select name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" class="<?php echo esc_attr( $field['class'] ); ?> wpi_select2" style="width: 25em;">
120
+								<?php if (!empty($field['type']) && 'select' === $field['type']) : ?>
121
+									<select name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" class="<?php echo esc_attr($field['class']); ?> wpi_select2" style="width: 25em;">
122 122
 										<?php
123
-											$selected = esc_attr( get_user_meta( $user->ID, $key, true ) );
124
-										foreach ( $field['options'] as $option_key => $option_value ) :
123
+											$selected = esc_attr(get_user_meta($user->ID, $key, true));
124
+										foreach ($field['options'] as $option_key => $option_value) :
125 125
 											?>
126
-											<option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $selected, $option_key, true ); ?>><?php echo esc_html( $option_value ); ?></option>
126
+											<option value="<?php echo esc_attr($option_key); ?>" <?php selected($selected, $option_key, true); ?>><?php echo esc_html($option_value); ?></option>
127 127
 										<?php endforeach; ?>
128 128
 									</select>
129
-								<?php elseif ( ! empty( $field['type'] ) && 'checkbox' === $field['type'] ) : ?>
130
-									<input type="checkbox" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="1" class="<?php echo esc_attr( $field['class'] ); ?>" <?php checked( (int) get_user_meta( $user->ID, $key, true ), 1, true ); ?> />
129
+								<?php elseif (!empty($field['type']) && 'checkbox' === $field['type']) : ?>
130
+									<input type="checkbox" name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" value="1" class="<?php echo esc_attr($field['class']); ?>" <?php checked((int) get_user_meta($user->ID, $key, true), 1, true); ?> />
131 131
 								<?php else : ?>
132
-									<input type="text" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $this->get_user_meta( $user->ID, $key ) ); ?>" class="<?php echo ( ! empty( $field['class'] ) ? esc_attr( $field['class'] ) : 'regular-text' ); ?>" />
132
+									<input type="text" name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" value="<?php echo esc_attr($this->get_user_meta($user->ID, $key)); ?>" class="<?php echo (!empty($field['class']) ? esc_attr($field['class']) : 'regular-text'); ?>" />
133 133
 								<?php endif; ?>
134
-								<p class="description"><?php echo wp_kses_post( $field['description'] ); ?></p>
134
+								<p class="description"><?php echo wp_kses_post($field['description']); ?></p>
135 135
 							</td>
136 136
 						</tr>
137 137
 					<?php endforeach; ?>
@@ -145,21 +145,21 @@  discard block
 block discarded – undo
145 145
 		 *
146 146
 		 * @param int $user_id User ID of the user being saved
147 147
 		 */
148
-		public function save_customer_meta_fields( $user_id ) {
149
-			if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) {
148
+		public function save_customer_meta_fields($user_id) {
149
+			if (!apply_filters('getpaid_current_user_can_edit_customer_meta_fields', current_user_can('manage_options'), $user_id)) {
150 150
 				return;
151 151
 			}
152 152
 
153 153
 			$save_fields = $this->get_customer_meta_fields();
154 154
 
155
-			foreach ( $save_fields as $fieldset ) {
155
+			foreach ($save_fields as $fieldset) {
156 156
 
157
-				foreach ( $fieldset['fields'] as $key => $field ) {
157
+				foreach ($fieldset['fields'] as $key => $field) {
158 158
 
159
-					if ( isset( $field['type'] ) && 'checkbox' === $field['type'] ) {
160
-						update_user_meta( $user_id, $key, ! empty( $_POST[ $key ] ) );
161
-					} elseif ( isset( $_POST[ $key ] ) ) {
162
-						update_user_meta( $user_id, $key, wpinv_clean( $_POST[ $key ] ) );
159
+					if (isset($field['type']) && 'checkbox' === $field['type']) {
160
+						update_user_meta($user_id, $key, !empty($_POST[$key]));
161
+					} elseif (isset($_POST[$key])) {
162
+						update_user_meta($user_id, $key, wpinv_clean($_POST[$key]));
163 163
 					}
164 164
 				}
165 165
 			}
@@ -173,11 +173,11 @@  discard block
 block discarded – undo
173 173
 		 * @param string $key     Key for user meta field
174 174
 		 * @return string
175 175
 		 */
176
-		protected function get_user_meta( $user_id, $key ) {
177
-			$value           = get_user_meta( $user_id, $key, true );
178
-			$existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' );
179
-			if ( ! $value && in_array( $key, $existing_fields ) ) {
180
-				$value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true );
176
+		protected function get_user_meta($user_id, $key) {
177
+			$value           = get_user_meta($user_id, $key, true);
178
+			$existing_fields = array('_wpinv_first_name', '_wpinv_last_name');
179
+			if (!$value && in_array($key, $existing_fields)) {
180
+				$value = get_user_meta($user_id, str_replace('_wpinv_', '', $key), true);
181 181
 			}
182 182
 
183 183
 			return $value;
Please login to merge, or discard this patch.
includes/admin/class-getpaid-metaboxes.php 1 patch
Spacing   +62 added lines, -62 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
  * Metaboxes Admin Class
@@ -25,35 +25,35 @@  discard block
 block discarded – undo
25 25
 	public static function init() {
26 26
 
27 27
 		// Register metaboxes.
28
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2 );
28
+		add_action('add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2);
29 29
 
30 30
 		// Remove metaboxes.
31
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 );
31
+		add_action('add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30);
32 32
 
33 33
 		// Rename metaboxes.
34
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 );
34
+		add_action('add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45);
35 35
 
36 36
 		// Save metaboxes.
37
-		add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 );
37
+		add_action('save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2);
38 38
 	}
39 39
 
40 40
 	/**
41 41
 	 * Register core metaboxes.
42 42
 	 */
43
-	public static function add_meta_boxes( $post_type, $post ) {
43
+	public static function add_meta_boxes($post_type, $post) {
44 44
 
45 45
 		// For invoices...
46
-		self::add_invoice_meta_boxes( $post_type, $post );
46
+		self::add_invoice_meta_boxes($post_type, $post);
47 47
 
48 48
 		// For payment forms.
49
-		self::add_payment_form_meta_boxes( $post_type, $post );
49
+		self::add_payment_form_meta_boxes($post_type, $post);
50 50
 
51 51
 		// For invoice items.
52
-		self::add_item_meta_boxes( $post_type );
52
+		self::add_item_meta_boxes($post_type);
53 53
 
54 54
 		// For invoice discounts.
55
-		if ( $post_type == 'wpi_discount' ) {
56
-			add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' );
55
+		if ($post_type == 'wpi_discount') {
56
+			add_meta_box('wpinv_discount_details', __('Discount Details', 'invoicing'), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high');
57 57
 		}
58 58
 
59 59
 	}
@@ -61,17 +61,17 @@  discard block
 block discarded – undo
61 61
 	/**
62 62
 	 * Register core metaboxes.
63 63
 	 */
64
-	protected static function add_payment_form_meta_boxes( $post_type, $post ) {
64
+	protected static function add_payment_form_meta_boxes($post_type, $post) {
65 65
 
66 66
 		// For payment forms.
67
-		if ( $post_type == 'wpi_payment_form' ) {
67
+		if ($post_type == 'wpi_payment_form') {
68 68
 
69 69
 			// Design payment form.
70
-			add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' );
70
+			add_meta_box('wpinv-payment-form-design', __('Payment Form', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal');
71 71
 
72 72
 			// Payment form information.
73
-			if ( $post->ID != wpinv_get_default_payment_form() ) {
74
-				add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' );
73
+			if ($post->ID != wpinv_get_default_payment_form()) {
74
+				add_meta_box('wpinv-payment-form-info', __('Details', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side');
75 75
 			}
76 76
 
77 77
 		}
@@ -81,20 +81,20 @@  discard block
 block discarded – undo
81 81
 	/**
82 82
 	 * Register core metaboxes.
83 83
 	 */
84
-	protected static function add_item_meta_boxes( $post_type ) {
84
+	protected static function add_item_meta_boxes($post_type) {
85 85
 
86
-		if ( $post_type == 'wpi_item' ) {
86
+		if ($post_type == 'wpi_item') {
87 87
 
88 88
 			// Item details.
89
-			add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' );
89
+			add_meta_box('wpinv_item_details', __('Item Details', 'invoicing'), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high');
90 90
 
91 91
 			// If taxes are enabled, register the tax metabox.
92
-			if ( wpinv_use_taxes() ) {
93
-				add_meta_box( 'wpinv_item_vat', __( 'Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' );
92
+			if (wpinv_use_taxes()) {
93
+				add_meta_box('wpinv_item_vat', __('Tax', 'invoicing'), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high');
94 94
 			}
95 95
 
96 96
 			// Item info.
97
-			add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' );
97
+			add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core');
98 98
 
99 99
 		}
100 100
 
@@ -103,20 +103,20 @@  discard block
 block discarded – undo
103 103
 	/**
104 104
 	 * Register invoice metaboxes.
105 105
 	 */
106
-	protected static function add_invoice_meta_boxes( $post_type, $post ) {
106
+	protected static function add_invoice_meta_boxes($post_type, $post) {
107 107
 
108 108
 		// For invoices...
109
-		if ( getpaid_is_invoice_post_type( $post_type ) ) {
110
-			$invoice = new WPInv_Invoice( $post );
109
+		if (getpaid_is_invoice_post_type($post_type)) {
110
+			$invoice = new WPInv_Invoice($post);
111 111
 
112 112
 			// Resend invoice.
113
-			if ( ! $invoice->is_draft() ) {
113
+			if (!$invoice->is_draft()) {
114 114
 
115 115
 				add_meta_box(
116 116
 					'wpinv-mb-resend-invoice',
117 117
 					sprintf(
118
-						__( 'Resend %s', 'invoicing' ),
119
-						ucfirst( $invoice->get_invoice_quote_type() )
118
+						__('Resend %s', 'invoicing'),
119
+						ucfirst($invoice->get_invoice_quote_type())
120 120
 					),
121 121
 					'GetPaid_Meta_Box_Resend_Invoice::output',
122 122
 					$post_type,
@@ -127,17 +127,17 @@  discard block
 block discarded – undo
127 127
 			}
128 128
 
129 129
 			// Subscriptions.
130
-			$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
131
-			if ( ! empty( $subscriptions ) ) {
130
+			$subscriptions = getpaid_get_invoice_subscriptions($invoice);
131
+			if (!empty($subscriptions)) {
132 132
 
133
-				if ( is_array( $subscriptions ) ) {
134
-					add_meta_box( 'wpinv-mb-subscriptions', __( 'Related Subscriptions', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_related', $post_type, 'advanced' );
133
+				if (is_array($subscriptions)) {
134
+					add_meta_box('wpinv-mb-subscriptions', __('Related Subscriptions', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output_related', $post_type, 'advanced');
135 135
 				} else {
136
-					add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced' );
136
+					add_meta_box('wpinv-mb-subscriptions', __('Subscription Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced');
137 137
 				}
138 138
 
139
-				if ( getpaid_count_subscription_invoices( $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id() ) > 1 ) {
140
-					add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced' );
139
+				if (getpaid_count_subscription_invoices($invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id()) > 1) {
140
+					add_meta_box('wpinv-mb-subscription-invoices', __('Related Payments', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced');
141 141
 				}
142 142
 
143 143
 			}
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 			add_meta_box(
147 147
 				'wpinv-details',
148 148
 				sprintf(
149
-					__( '%s Details', 'invoicing' ),
150
-					ucfirst( $invoice->get_invoice_quote_type() )
149
+					__('%s Details', 'invoicing'),
150
+					ucfirst($invoice->get_invoice_quote_type())
151 151
 				),
152 152
 				'GetPaid_Meta_Box_Invoice_Details::output',
153 153
 				$post_type,
@@ -155,17 +155,17 @@  discard block
 block discarded – undo
155 155
 			);
156 156
 
157 157
 			// Payment details.
158
-			add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default' );
158
+			add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default');
159 159
 
160 160
 			// Billing details.
161
-			add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high' );
161
+			add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high');
162 162
 			
163 163
 			// Invoice items.
164 164
 			add_meta_box(
165 165
 				'wpinv-items',
166 166
 				sprintf(
167
-					__( '%s Items', 'invoicing' ),
168
-					ucfirst( $invoice->get_invoice_quote_type() )
167
+					__('%s Items', 'invoicing'),
168
+					ucfirst($invoice->get_invoice_quote_type())
169 169
 				),
170 170
 				'GetPaid_Meta_Box_Invoice_Items::output',
171 171
 				$post_type,
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
 			add_meta_box(
178 178
 				'wpinv-notes',
179 179
 				sprintf(
180
-					__( '%s Notes', 'invoicing' ),
181
-					ucfirst( $invoice->get_invoice_quote_type() )
180
+					__('%s Notes', 'invoicing'),
181
+					ucfirst($invoice->get_invoice_quote_type())
182 182
 				),
183 183
 				'WPInv_Meta_Box_Notes::output',
184 184
 				$post_type,
@@ -187,13 +187,13 @@  discard block
 block discarded – undo
187 187
 			);
188 188
 
189 189
 			// Shipping Address.
190
-			if ( get_post_meta( $invoice->get_id(), 'shipping_address', true ) ) {
191
-				add_meta_box( 'wpinv-invoice-shipping-details', __( 'Shipping Address', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high' );
190
+			if (get_post_meta($invoice->get_id(), 'shipping_address', true)) {
191
+				add_meta_box('wpinv-invoice-shipping-details', __('Shipping Address', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high');
192 192
 			}
193 193
 
194 194
 			// Payment form information.
195
-			if ( get_post_meta( $invoice->get_id(), 'payment_form_data', true ) ) {
196
-				add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high' );
195
+			if (get_post_meta($invoice->get_id(), 'payment_form_data', true)) {
196
+				add_meta_box('wpinv-invoice-payment-form-details', __('Payment Form Details', 'invoicing'), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high');
197 197
 			}
198 198
 
199 199
 		}
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	 * Remove some metaboxes.
205 205
 	 */
206 206
 	public static function remove_meta_boxes() {
207
-		remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' );
207
+		remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal');
208 208
 	}
209 209
 
210 210
 	/**
@@ -220,46 +220,46 @@  discard block
 block discarded – undo
220 220
 	 * @param  int    $post_id Post ID.
221 221
 	 * @param  object $post Post object.
222 222
 	 */
223
-	public static function save_meta_boxes( $post_id, $post ) {
224
-		$post_id = absint( $post_id );
225
-		$data    = wp_kses_post_deep( wp_unslash( $_POST ) );
223
+	public static function save_meta_boxes($post_id, $post) {
224
+		$post_id = absint($post_id);
225
+		$data    = wp_kses_post_deep(wp_unslash($_POST));
226 226
 
227 227
 		// Do not save for ajax requests.
228
-		if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
228
+		if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
229 229
 			return;
230 230
 		}
231 231
 
232 232
 		// $post_id and $post are required
233
-		if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) {
233
+		if (empty($post_id) || empty($post) || self::$saved_meta_boxes) {
234 234
 			return;
235 235
 		}
236 236
 
237 237
 		// Dont' save meta boxes for revisions or autosaves.
238
-		if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
238
+		if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
239 239
 			return;
240 240
 		}
241 241
 
242 242
 		// Check the nonce.
243
-		if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) {
243
+		if (empty($data['getpaid_meta_nonce']) || !wp_verify_nonce($data['getpaid_meta_nonce'], 'getpaid_meta_nonce')) {
244 244
 			return;
245 245
 		}
246 246
 
247 247
 		// Check the post being saved == the $post_id to prevent triggering this call for other save_post events.
248
-		if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) {
248
+		if (empty($data['post_ID']) || absint($data['post_ID']) !== $post_id) {
249 249
 			return;
250 250
 		}
251 251
 
252 252
 		// Check user has permission to edit.
253
-		if ( ! current_user_can( 'edit_post', $post_id ) ) {
253
+		if (!current_user_can('edit_post', $post_id)) {
254 254
 			return;
255 255
 		}
256 256
 
257
-		if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
257
+		if (getpaid_is_invoice_post_type($post->post_type)) {
258 258
 
259 259
 			// We need this save event to run once to avoid potential endless loops.
260 260
 			self::$saved_meta_boxes = true;
261 261
 
262
-			return GetPaid_Meta_Box_Invoice_Address::save( $post_id );
262
+			return GetPaid_Meta_Box_Invoice_Address::save($post_id);
263 263
 
264 264
 		}
265 265
 
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 		);
272 272
 
273 273
 		// Is this our post type?
274
-		if ( ! isset( $post_types_map[ $post->post_type ] ) ) {
274
+		if (!isset($post_types_map[$post->post_type])) {
275 275
 			return;
276 276
 		}
277 277
 
@@ -279,8 +279,8 @@  discard block
 block discarded – undo
279 279
 		self::$saved_meta_boxes = true;
280 280
 		
281 281
 		// Save the post.
282
-		$class = $post_types_map[ $post->post_type ];
283
-		$class::save( $post_id, wp_kses_post_deep( $_POST ), $post );
282
+		$class = $post_types_map[$post->post_type];
283
+		$class::save($post_id, wp_kses_post_deep($_POST), $post);
284 284
 
285 285
 	}
286 286
 
Please login to merge, or discard this patch.
includes/admin/class-getpaid-post-types-admin.php 1 patch
Spacing   +235 added lines, -235 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,19 +98,19 @@  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
-			$actions['duplicate'] =  sprintf(
113
+			$actions['duplicate'] = sprintf(
114 114
 				'<a href="%1$s">%2$s</a>',
115 115
 				esc_url(
116 116
 					wp_nonce_url(
@@ -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
-				$actions['buy'] =  sprintf(
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
 			}
@@ -155,31 +155,31 @@  discard block
 block discarded – undo
155 155
 	 * @param WP_Post $post
156 156
      * @return array $actions actions without edit option
157 157
      */
158
-    public static function filter_invoice_row_actions( $actions, $post ) {
158
+    public static function filter_invoice_row_actions($actions, $post) {
159 159
 
160
-        if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
160
+        if (getpaid_is_invoice_post_type($post->post_type)) {
161 161
 
162 162
 			$actions = array();
163
-			$invoice = new WPInv_Invoice( $post );
163
+			$invoice = new WPInv_Invoice($post);
164 164
 
165
-			$actions['edit'] =  sprintf(
165
+			$actions['edit'] = sprintf(
166 166
 				'<a href="%1$s">%2$s</a>',
167
-				esc_url( get_edit_post_link( $invoice->get_id() ) ),
168
-				esc_html( __( 'Edit', 'invoicing' ) )
167
+				esc_url(get_edit_post_link($invoice->get_id())),
168
+				esc_html(__('Edit', 'invoicing'))
169 169
 			);
170 170
 
171
-			if ( ! $invoice->is_draft() ) {
171
+			if (!$invoice->is_draft()) {
172 172
 
173
-				$actions['view'] =  sprintf(
173
+				$actions['view'] = sprintf(
174 174
 					'<a href="%1$s">%2$s</a>',
175
-					esc_url( $invoice->get_view_url() ),
175
+					esc_url($invoice->get_view_url()),
176 176
 					sprintf(
177
-						esc_html( __( 'View %s', 'invoicing' ) ),
178
-						getpaid_get_post_type_label( $invoice->get_post_type(), false )
177
+						esc_html(__('View %s', 'invoicing')),
178
+						getpaid_get_post_type_label($invoice->get_post_type(), false)
179 179
 					)
180 180
 				);
181 181
 
182
-				$actions['send'] =  sprintf(
182
+				$actions['send'] = sprintf(
183 183
 					'<a href="%1$s">%2$s</a>',
184 184
 					esc_url(
185 185
 						wp_nonce_url(
@@ -193,12 +193,12 @@  discard block
 block discarded – undo
193 193
 							'getpaid-nonce'
194 194
 						)
195 195
 					),
196
-					esc_html( __( 'Send to Customer', 'invoicing' ) )
196
+					esc_html(__('Send to Customer', 'invoicing'))
197 197
 				);
198 198
 
199 199
 			}
200 200
 
201
-			$actions['duplicate'] =  sprintf(
201
+			$actions['duplicate'] = sprintf(
202 202
 				'<a href="%1$s">%2$s</a>',
203 203
 				esc_url(
204 204
 					wp_nonce_url(
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 						'getpaid-nonce'
213 213
 					)
214 214
 				),
215
-				esc_html( __( 'Duplicate', 'invoicing' ) )
215
+				esc_html(__('Duplicate', 'invoicing'))
216 216
 			);
217 217
 
218 218
         }
@@ -223,42 +223,42 @@  discard block
 block discarded – undo
223 223
 	/**
224 224
 	 * Returns an array of invoice table columns.
225 225
 	 */
226
-	public static function invoice_columns( $columns ) {
226
+	public static function invoice_columns($columns) {
227 227
 
228 228
 		$columns = array(
229 229
 			'cb'                => $columns['cb'],
230
-			'number'            => __( 'Invoice', 'invoicing' ),
231
-			'customer'          => __( 'Customer', 'invoicing' ),
232
-			'invoice_date'      => __( 'Created', 'invoicing' ),
233
-			'payment_date'      => __( 'Completed', 'invoicing' ),
234
-			'amount'            => __( 'Amount', 'invoicing' ),
235
-			'recurring'         => __( 'Recurring', 'invoicing' ),
236
-			'status'            => __( 'Status', 'invoicing' ),
230
+			'number'            => __('Invoice', 'invoicing'),
231
+			'customer'          => __('Customer', 'invoicing'),
232
+			'invoice_date'      => __('Created', 'invoicing'),
233
+			'payment_date'      => __('Completed', 'invoicing'),
234
+			'amount'            => __('Amount', 'invoicing'),
235
+			'recurring'         => __('Recurring', 'invoicing'),
236
+			'status'            => __('Status', 'invoicing'),
237 237
 		);
238 238
 
239
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
239
+		return apply_filters('wpi_invoice_table_columns', $columns);
240 240
 	}
241 241
 
242 242
 	/**
243 243
 	 * Displays invoice table columns.
244 244
 	 */
245
-	public static function display_invoice_columns( $column_name, $post_id ) {
245
+	public static function display_invoice_columns($column_name, $post_id) {
246 246
 
247
-		$invoice = new WPInv_Invoice( $post_id );
247
+		$invoice = new WPInv_Invoice($post_id);
248 248
 
249
-		switch ( $column_name ) {
249
+		switch ($column_name) {
250 250
 
251 251
 			case 'invoice_date' :
252
-				$date_time = esc_attr( $invoice->get_created_date() );
253
-				$date      = esc_html( getpaid_format_date_value( $date_time, "&mdash;", true ) );
252
+				$date_time = esc_attr($invoice->get_created_date());
253
+				$date      = esc_html(getpaid_format_date_value($date_time, "&mdash;", true));
254 254
 				echo "<span title='$date_time'>$date</span>";
255 255
 				break;
256 256
 
257 257
 			case 'payment_date' :
258 258
 
259
-				if ( $invoice->is_paid() ) {
260
-					$date_time = esc_attr( $invoice->get_completed_date() );
261
-					$date      = esc_html( getpaid_format_date_value( $date_time, "&mdash;", true ) );
259
+				if ($invoice->is_paid()) {
260
+					$date_time = esc_attr($invoice->get_completed_date());
261
+					$date      = esc_html(getpaid_format_date_value($date_time, "&mdash;", true));
262 262
 					echo "<span title='$date_time'>$date</span>";
263 263
 				} else {
264 264
 					echo "&mdash;";
@@ -269,17 +269,17 @@  discard block
 block discarded – undo
269 269
 			case 'amount' :
270 270
 
271 271
 				$amount = $invoice->get_total();
272
-				$formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) );
272
+				$formated_amount = wp_kses_post(wpinv_price($amount, $invoice->get_currency()));
273 273
 
274
-				if ( $invoice->is_refunded() ) {
275
-					$refunded_amount = wp_kses_post( wpinv_price( 0, $invoice->get_currency() ) );
274
+				if ($invoice->is_refunded()) {
275
+					$refunded_amount = wp_kses_post(wpinv_price(0, $invoice->get_currency()));
276 276
 					echo "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>";
277 277
 				} else {
278 278
 
279 279
 					$discount = $invoice->get_total_discount();
280 280
 
281
-					if ( ! empty( $discount ) ) {
282
-						$new_amount = wp_kses_post( wpinv_price( $amount + $discount, $invoice->get_currency() ) );
281
+					if (!empty($discount)) {
282
+						$new_amount = wp_kses_post(wpinv_price($amount + $discount, $invoice->get_currency()));
283 283
 						echo "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>";
284 284
 					} else {
285 285
 						echo $formated_amount;
@@ -290,13 +290,13 @@  discard block
 block discarded – undo
290 290
 				break;
291 291
 
292 292
 			case 'status' :
293
-				$status       = esc_html( $invoice->get_status() );
294
-				$status_label = esc_html( $invoice->get_status_nicename() );
293
+				$status       = esc_html($invoice->get_status());
294
+				$status_label = esc_html($invoice->get_status_nicename());
295 295
 
296 296
 				// If it is paid, show the gateway title.
297
-				if ( $invoice->is_paid() ) {
298
-					$gateway = esc_html( $invoice->get_gateway_title() );
299
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) );
297
+				if ($invoice->is_paid()) {
298
+					$gateway = esc_html($invoice->get_gateway_title());
299
+					$gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), esc_html($gateway));
300 300
 
301 301
 					echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
302 302
 				} else {
@@ -304,22 +304,22 @@  discard block
 block discarded – undo
304 304
 				}
305 305
 
306 306
 				// If it is not paid, display the overdue and view status.
307
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
307
+				if (!$invoice->is_paid() && !$invoice->is_refunded()) {
308 308
 
309 309
 					// Invoice view status.
310
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
311
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';
310
+					if (wpinv_is_invoice_viewed($invoice->get_id())) {
311
+						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>';
312 312
 					} else {
313
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
313
+						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>';
314 314
 					}
315 315
 
316 316
 					// Display the overview status.
317
-					if ( wpinv_get_option( 'overdue_active' ) ) {
317
+					if (wpinv_get_option('overdue_active')) {
318 318
 						$due_date = $invoice->get_due_date();
319
-						$fomatted = getpaid_format_date( $due_date );
319
+						$fomatted = getpaid_format_date($due_date);
320 320
 
321
-						if ( ! empty( $fomatted ) ) {
322
-							$date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
321
+						if (!empty($fomatted)) {
322
+							$date = wp_sprintf(__('Due %s', 'invoicing'), $fomatted);
323 323
 							echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>";
324 324
 						}
325 325
 					}
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 
331 331
 			case 'recurring':
332 332
 
333
-				if ( $invoice->is_recurring() ) {
333
+				if ($invoice->is_recurring()) {
334 334
 					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
335 335
 				} else {
336 336
 					echo '<i class="fa fa-times" style="color:#616161;"></i>';
@@ -339,9 +339,9 @@  discard block
 block discarded – undo
339 339
 
340 340
 			case 'number' :
341 341
 
342
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
343
-				$invoice_number  = esc_html( $invoice->get_number() );
344
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
342
+				$edit_link       = esc_url(get_edit_post_link($invoice->get_id()));
343
+				$invoice_number  = esc_html($invoice->get_number());
344
+				$invoice_details = esc_attr__('View Invoice Details', 'invoicing');
345 345
 
346 346
 				echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
347 347
 
@@ -351,13 +351,13 @@  discard block
 block discarded – undo
351 351
 	
352 352
 				$customer_name = $invoice->get_user_full_name();
353 353
 	
354
-				if ( empty( $customer_name ) ) {
354
+				if (empty($customer_name)) {
355 355
 					$customer_name = $invoice->get_email();
356 356
 				}
357 357
 	
358
-				if ( ! empty( $customer_name ) ) {
359
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
360
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
358
+				if (!empty($customer_name)) {
359
+					$customer_details = esc_attr__('View Customer Details', 'invoicing');
360
+					$view_link        = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php')));
361 361
 					echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
362 362
 				} else {
363 363
 					echo '<div>&mdash;</div>';
@@ -372,19 +372,19 @@  discard block
 block discarded – undo
372 372
 	/**
373 373
 	 * Displays invoice bulk actions.
374 374
 	 */
375
-	public static function invoice_bulk_actions( $actions ) {
376
-		$actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
375
+	public static function invoice_bulk_actions($actions) {
376
+		$actions['resend-invoice'] = __('Send to Customer', 'invoicing');
377 377
 		return $actions;
378 378
 	}
379 379
 
380 380
 	/**
381 381
 	 * Processes invoice bulk actions.
382 382
 	 */
383
-	public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
383
+	public static function handle_invoice_bulk_actions($redirect_url, $action, $post_ids) {
384 384
 
385
-		if ( $action == 'resend-invoice' ) {
386
-			foreach ( $post_ids as $post_id ) {
387
-				getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
385
+		if ($action == 'resend-invoice') {
386
+			foreach ($post_ids as $post_id) {
387
+				getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($post_id), true);
388 388
 			}
389 389
 		}
390 390
 
@@ -395,50 +395,50 @@  discard block
 block discarded – undo
395 395
 	/**
396 396
 	 * Returns an array of payment forms table columns.
397 397
 	 */
398
-	public static function payment_form_columns( $columns ) {
398
+	public static function payment_form_columns($columns) {
399 399
 
400 400
 		$columns = array(
401 401
 			'cb'                => $columns['cb'],
402
-			'title'             => __( 'Name', 'invoicing' ),
403
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
404
-			'earnings'          => __( 'Revenue', 'invoicing' ),
405
-			'refunds'           => __( 'Refunded', 'invoicing' ),
406
-			'items'             => __( 'Items', 'invoicing' ),
407
-			'date'              => __( 'Date', 'invoicing' ),
402
+			'title'             => __('Name', 'invoicing'),
403
+			'shortcode'         => __('Shortcode', 'invoicing'),
404
+			'earnings'          => __('Revenue', 'invoicing'),
405
+			'refunds'           => __('Refunded', 'invoicing'),
406
+			'items'             => __('Items', 'invoicing'),
407
+			'date'              => __('Date', 'invoicing'),
408 408
 		);
409 409
 
410
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
410
+		return apply_filters('wpi_payment_form_table_columns', $columns);
411 411
 
412 412
 	}
413 413
 
414 414
 	/**
415 415
 	 * Displays payment form table columns.
416 416
 	 */
417
-	public static function display_payment_form_columns( $column_name, $post_id ) {
417
+	public static function display_payment_form_columns($column_name, $post_id) {
418 418
 
419 419
 		// Retrieve the payment form.
420
-		$form = new GetPaid_Payment_Form( $post_id );
420
+		$form = new GetPaid_Payment_Form($post_id);
421 421
 
422
-		switch ( $column_name ) {
422
+		switch ($column_name) {
423 423
 
424 424
 			case 'earnings' :
425
-				echo wpinv_price( $form->get_earned() );
425
+				echo wpinv_price($form->get_earned());
426 426
 				break;
427 427
 
428 428
 			case 'refunds' :
429
-				echo wpinv_price( $form->get_refunded() );
429
+				echo wpinv_price($form->get_refunded());
430 430
 				break;
431 431
 
432 432
 			case 'refunds' :
433
-				echo wpinv_price( $form->get_refunded() );
433
+				echo wpinv_price($form->get_refunded());
434 434
 				break;
435 435
 
436 436
 			case 'shortcode' :
437 437
 
438
-				if ( $form->is_default() ) {
438
+				if ($form->is_default()) {
439 439
 					echo '&mdash;';
440 440
 				} else {
441
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
441
+					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>';
442 442
 				}
443 443
 
444 444
 				break;
@@ -447,29 +447,29 @@  discard block
 block discarded – undo
447 447
 
448 448
 				$items = $form->get_items();
449 449
 
450
-				if ( $form->is_default() || empty( $items ) ) {
450
+				if ($form->is_default() || empty($items)) {
451 451
 					echo '&mdash;';
452 452
 					return;
453 453
 				}
454 454
 
455 455
 				$_items = array();
456 456
 
457
-				foreach ( $items as $item ) {
457
+				foreach ($items as $item) {
458 458
 					$url = $item->get_edit_url();
459 459
 
460
-					if ( empty( $url ) ) {
461
-						$_items[] = esc_html( $item->get_name() );
460
+					if (empty($url)) {
461
+						$_items[] = esc_html($item->get_name());
462 462
 					} else {
463 463
 						$_items[] = sprintf(
464 464
 							'<a href="%s">%s</a>',
465
-							esc_url( $url ),
466
-							esc_html( $item->get_name() )
465
+							esc_url($url),
466
+							esc_html($item->get_name())
467 467
 						);
468 468
 					}
469 469
 
470 470
 				}
471 471
 
472
-				echo implode( '<br>', $_items );
472
+				echo implode('<br>', $_items);
473 473
 
474 474
 				break;
475 475
 
@@ -480,10 +480,10 @@  discard block
 block discarded – undo
480 480
 	/**
481 481
 	 * Filters post states.
482 482
 	 */
483
-	public static function filter_payment_form_state( $post_states, $post ) {
483
+	public static function filter_payment_form_state($post_states, $post) {
484 484
 
485
-		if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
486
-			$post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' );
485
+		if ('wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID) {
486
+			$post_states['default_form'] = __('Default Payment Form', 'invoicing');
487 487
 		}
488 488
 	
489 489
 		return $post_states;
@@ -493,35 +493,35 @@  discard block
 block discarded – undo
493 493
 	/**
494 494
 	 * Returns an array of coupon table columns.
495 495
 	 */
496
-	public static function discount_columns( $columns ) {
496
+	public static function discount_columns($columns) {
497 497
 
498 498
 		$columns = array(
499 499
 			'cb'                => $columns['cb'],
500
-			'title'             => __( 'Name', 'invoicing' ),
501
-			'code'              => __( 'Code', 'invoicing' ),
502
-			'amount'            => __( 'Amount', 'invoicing' ),
503
-			'usage'             => __( 'Usage / Limit', 'invoicing' ),
504
-			'start_date'        => __( 'Start Date', 'invoicing' ),
505
-			'expiry_date'       => __( 'Expiry Date', 'invoicing' ),
500
+			'title'             => __('Name', 'invoicing'),
501
+			'code'              => __('Code', 'invoicing'),
502
+			'amount'            => __('Amount', 'invoicing'),
503
+			'usage'             => __('Usage / Limit', 'invoicing'),
504
+			'start_date'        => __('Start Date', 'invoicing'),
505
+			'expiry_date'       => __('Expiry Date', 'invoicing'),
506 506
 		);
507 507
 
508
-		return apply_filters( 'wpi_discount_table_columns', $columns );
508
+		return apply_filters('wpi_discount_table_columns', $columns);
509 509
 	}
510 510
 
511 511
 	/**
512 512
 	 * Filters post states.
513 513
 	 */
514
-	public static function filter_discount_state( $post_states, $post ) {
514
+	public static function filter_discount_state($post_states, $post) {
515 515
 
516
-		if ( 'wpi_discount' == $post->post_type ) {
516
+		if ('wpi_discount' == $post->post_type) {
517 517
 
518
-			$discount = new WPInv_Discount( $post );
518
+			$discount = new WPInv_Discount($post);
519 519
 
520 520
 			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
521 521
 
522
-			if ( $status != 'publish' ) {
522
+			if ($status != 'publish') {
523 523
 				return array(
524
-					'discount_status' => wpinv_discount_status( $status ),
524
+					'discount_status' => wpinv_discount_status($status),
525 525
 				);
526 526
 			}
527 527
 
@@ -536,30 +536,30 @@  discard block
 block discarded – undo
536 536
 	/**
537 537
 	 * Returns an array of items table columns.
538 538
 	 */
539
-	public static function item_columns( $columns ) {
539
+	public static function item_columns($columns) {
540 540
 
541 541
 		$columns = array(
542 542
 			'cb'                => $columns['cb'],
543
-			'title'             => __( 'Name', 'invoicing' ),
544
-			'price'             => __( 'Price', 'invoicing' ),
545
-			'vat_rule'          => __( 'VAT rule', 'invoicing' ),
546
-			'vat_class'         => __( 'VAT class', 'invoicing' ),
547
-			'type'              => __( 'Type', 'invoicing' ),
548
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
543
+			'title'             => __('Name', 'invoicing'),
544
+			'price'             => __('Price', 'invoicing'),
545
+			'vat_rule'          => __('VAT rule', 'invoicing'),
546
+			'vat_class'         => __('VAT class', 'invoicing'),
547
+			'type'              => __('Type', 'invoicing'),
548
+			'shortcode'         => __('Shortcode', 'invoicing'),
549 549
 		);
550 550
 
551
-		if ( ! wpinv_use_taxes() ) {
552
-			unset( $columns['vat_rule'] );
553
-			unset( $columns['vat_class'] );
551
+		if (!wpinv_use_taxes()) {
552
+			unset($columns['vat_rule']);
553
+			unset($columns['vat_class']);
554 554
 		}
555 555
 
556
-		return apply_filters( 'wpi_item_table_columns', $columns );
556
+		return apply_filters('wpi_item_table_columns', $columns);
557 557
 	}
558 558
 
559 559
 	/**
560 560
 	 * Returns an array of sortable items table columns.
561 561
 	 */
562
-	public static function sortable_item_columns( $columns ) {
562
+	public static function sortable_item_columns($columns) {
563 563
 
564 564
 		return array_merge(
565 565
 			$columns,
@@ -576,47 +576,47 @@  discard block
 block discarded – undo
576 576
 	/**
577 577
 	 * Displays items table columns.
578 578
 	 */
579
-	public static function display_item_columns( $column_name, $post_id ) {
579
+	public static function display_item_columns($column_name, $post_id) {
580 580
  
581
-		$item = new WPInv_Item( $post_id );
581
+		$item = new WPInv_Item($post_id);
582 582
 
583
-		switch ( $column_name ) {
583
+		switch ($column_name) {
584 584
 
585 585
 			case 'price' :
586 586
 
587
-				if ( ! $item->is_recurring() ) {
587
+				if (!$item->is_recurring()) {
588 588
 					echo $item->get_the_price();
589 589
 					break;
590 590
 				}
591 591
 
592 592
 				$price = wp_sprintf(
593
-					__( '%s / %s', 'invoicing' ),
593
+					__('%s / %s', 'invoicing'),
594 594
 					$item->get_the_price(),
595
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
595
+					getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '')
596 596
 				);
597 597
 
598
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
598
+				if ($item->get_the_price() == $item->get_the_initial_price()) {
599 599
 					echo $price;
600 600
 					break;
601 601
 				}
602 602
 
603 603
 				echo $item->get_the_initial_price();
604 604
 
605
-				echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price )  .'</span>';
605
+				echo '<span class="meta">' . wp_sprintf(__('then %s', 'invoicing'), $price) . '</span>';
606 606
 				break;
607 607
 
608 608
 			case 'vat_rule' :
609
-				echo getpaid_get_tax_rule_label( $item->get_vat_rule() );
609
+				echo getpaid_get_tax_rule_label($item->get_vat_rule());
610 610
 				break;
611 611
 
612 612
 			case 'vat_class' :
613
-				echo getpaid_get_tax_class_label( $item->get_vat_class() );
613
+				echo getpaid_get_tax_class_label($item->get_vat_class());
614 614
 				break;
615 615
 
616 616
 			case 'shortcode' :
617 617
 
618
-				if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
619
-					echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
618
+				if ($item->is_type(array('', 'fee', 'custom'))) {
619
+					echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
620 620
 				} else {
621 621
 					echo "&mdash;";
622 622
 				}
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 				break;
625 625
 
626 626
 			case 'type' :
627
-				echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
627
+				echo wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
628 628
 				break;
629 629
 
630 630
 		}
@@ -634,21 +634,21 @@  discard block
 block discarded – undo
634 634
 	/**
635 635
 	 * Lets users filter items using taxes.
636 636
 	 */
637
-	public static function add_item_filters( $post_type ) {
637
+	public static function add_item_filters($post_type) {
638 638
 
639 639
 		// Abort if we're not dealing with items.
640
-		if ( $post_type != 'wpi_item' ) {
640
+		if ($post_type != 'wpi_item') {
641 641
 			return;
642 642
 		}
643 643
 
644 644
 		// Filter by vat rules.
645
-		if ( wpinv_use_taxes() ) {
645
+		if (wpinv_use_taxes()) {
646 646
 	
647 647
 			// Sanitize selected vat rule.
648 648
 			$vat_rule   = '';
649 649
 			$vat_rules  = getpaid_get_tax_rules();
650
-			if ( isset( $_GET['vat_rule'] ) ) {
651
-				$vat_rule   =  sanitize_text_field( $_GET['vat_rule'] );
650
+			if (isset($_GET['vat_rule'])) {
651
+				$vat_rule = sanitize_text_field($_GET['vat_rule']);
652 652
 			}
653 653
 
654 654
 			// Filter by VAT rule.
@@ -656,13 +656,13 @@  discard block
 block discarded – undo
656 656
 				array(
657 657
 					'options'          => array_merge(
658 658
 						array(
659
-							'' => __( 'All VAT rules', 'invoicing' )
659
+							'' => __('All VAT rules', 'invoicing')
660 660
 						),
661 661
 						$vat_rules
662 662
 					),
663 663
 					'name'             => 'vat_rule',
664 664
 					'id'               => 'vat_rule',
665
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
665
+					'selected'         => in_array($vat_rule, array_keys($vat_rules)) ? $vat_rule : '',
666 666
 					'show_option_all'  => false,
667 667
 					'show_option_none' => false,
668 668
 				)
@@ -673,21 +673,21 @@  discard block
 block discarded – undo
673 673
 			// Sanitize selected vat rule.
674 674
 			$vat_class   = '';
675 675
 			$vat_classes = getpaid_get_tax_classes();
676
-			if ( isset( $_GET['vat_class'] ) ) {
677
-				$vat_class   = sanitize_text_field( $_GET['vat_class'] );
676
+			if (isset($_GET['vat_class'])) {
677
+				$vat_class = sanitize_text_field($_GET['vat_class']);
678 678
 			}
679 679
 
680 680
 			echo wpinv_html_select(
681 681
 				array(
682 682
 					'options'          => array_merge(
683 683
 						array(
684
-							'' => __( 'All VAT classes', 'invoicing' )
684
+							'' => __('All VAT classes', 'invoicing')
685 685
 						),
686 686
 						$vat_classes
687 687
 					),
688 688
 					'name'             => 'vat_class',
689 689
 					'id'               => 'vat_class',
690
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
690
+					'selected'         => in_array($vat_class, array_keys($vat_classes)) ? $vat_class : '',
691 691
 					'show_option_all'  => false,
692 692
 					'show_option_none' => false,
693 693
 				)
@@ -696,22 +696,22 @@  discard block
 block discarded – undo
696 696
 		}
697 697
 
698 698
 		// Filter by item type.
699
-		$type   = '';
700
-		if ( isset( $_GET['type'] ) ) {
701
-			$type   = sanitize_text_field( $_GET['type'] );
699
+		$type = '';
700
+		if (isset($_GET['type'])) {
701
+			$type = sanitize_text_field($_GET['type']);
702 702
 		}
703 703
 
704 704
 		echo wpinv_html_select(
705 705
 			array(
706 706
 				'options'          => array_merge(
707 707
 					array(
708
-						'' => __( 'All item types', 'invoicing' )
708
+						'' => __('All item types', 'invoicing')
709 709
 					),
710 710
 					wpinv_get_item_types()
711 711
 				),
712 712
 				'name'             => 'type',
713 713
 				'id'               => 'type',
714
-				'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
714
+				'selected'         => in_array($type, wpinv_item_types()) ? $type : '',
715 715
 				'show_option_all'  => false,
716 716
 				'show_option_none' => false,
717 717
 			)
@@ -722,45 +722,45 @@  discard block
 block discarded – undo
722 722
 	/**
723 723
 	 * Filters the item query.
724 724
 	 */
725
-	public static function filter_item_query( $query ) {
725
+	public static function filter_item_query($query) {
726 726
 
727 727
 		// modify the query only if it admin and main query.
728
-		if ( ! ( is_admin() && $query->is_main_query() ) ){ 
728
+		if (!(is_admin() && $query->is_main_query())) { 
729 729
 			return $query;
730 730
 		}
731 731
 
732 732
 		// we want to modify the query for our items.
733
-		if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){
733
+		if (empty($query->query['post_type']) || 'wpi_item' != $query->query['post_type']) {
734 734
 			return $query;
735 735
 		}
736 736
 
737
-		if ( empty( $query->query_vars['meta_query'] ) ) {
737
+		if (empty($query->query_vars['meta_query'])) {
738 738
 			$query->query_vars['meta_query'] = array();
739 739
 		}
740 740
 
741 741
 		// Filter vat rule type
742
-        if ( ! empty( $_GET['vat_rule'] ) ) {
742
+        if (!empty($_GET['vat_rule'])) {
743 743
             $query->query_vars['meta_query'][] = array(
744 744
                 'key'     => '_wpinv_vat_rule',
745
-                'value'   => sanitize_text_field( $_GET['vat_rule'] ),
745
+                'value'   => sanitize_text_field($_GET['vat_rule']),
746 746
                 'compare' => '='
747 747
             );
748 748
         }
749 749
 
750 750
         // Filter vat class
751
-        if ( ! empty( $_GET['vat_class'] ) ) {
751
+        if (!empty($_GET['vat_class'])) {
752 752
             $query->query_vars['meta_query'][] = array(
753 753
                 'key'     => '_wpinv_vat_class',
754
-                'value'   => sanitize_text_field( $_GET['vat_class'] ),
754
+                'value'   => sanitize_text_field($_GET['vat_class']),
755 755
                 'compare' => '='
756 756
             );
757 757
         }
758 758
 
759 759
         // Filter item type
760
-        if ( ! empty( $_GET['type'] ) ) {
760
+        if (!empty($_GET['type'])) {
761 761
             $query->query_vars['meta_query'][] = array(
762 762
                 'key'     => '_wpinv_type',
763
-                'value'   => sanitize_text_field( $_GET['type'] ),
763
+                'value'   => sanitize_text_field($_GET['type']),
764 764
                 'compare' => '='
765 765
             );
766 766
 		}
@@ -770,15 +770,15 @@  discard block
 block discarded – undo
770 770
 	/**
771 771
 	 * Reorders items.
772 772
 	 */
773
-	public static function reorder_items( $vars ) {
773
+	public static function reorder_items($vars) {
774 774
 		global $typenow;
775 775
 
776
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
776
+		if ('wpi_item' !== $typenow || empty($vars['orderby'])) {
777 777
 			return $vars;
778 778
 		}
779 779
 
780 780
 		// By item type.
781
-		if ( 'type' == $vars['orderby'] ) {
781
+		if ('type' == $vars['orderby']) {
782 782
 			return array_merge(
783 783
 				$vars,
784 784
 				array(
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
 		}
790 790
 
791 791
 		// By vat class.
792
-		if ( 'vat_class' == $vars['orderby'] ) {
792
+		if ('vat_class' == $vars['orderby']) {
793 793
 			return array_merge(
794 794
 				$vars,
795 795
 				array(
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
 		}
801 801
 
802 802
 		// By vat rule.
803
-		if ( 'vat_rule' == $vars['orderby'] ) {
803
+		if ('vat_rule' == $vars['orderby']) {
804 804
 			return array_merge(
805 805
 				$vars,
806 806
 				array(
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
 		}
812 812
 
813 813
 		// By price.
814
-		if ( 'price' == $vars['orderby'] ) {
814
+		if ('price' == $vars['orderby']) {
815 815
 			return array_merge(
816 816
 				$vars,
817 817
 				array(
@@ -828,27 +828,27 @@  discard block
 block discarded – undo
828 828
 	/**
829 829
 	 * Fired when deleting a post.
830 830
 	 */
831
-	public static function delete_post( $post_id ) {
831
+	public static function delete_post($post_id) {
832 832
 
833
-		switch ( get_post_type( $post_id ) ) {
833
+		switch (get_post_type($post_id)) {
834 834
 
835 835
 			case 'wpi_item' :
836
-				do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
836
+				do_action("getpaid_before_delete_item", new WPInv_Item($post_id));
837 837
 				break;
838 838
 
839 839
 			case 'wpi_payment_form' :
840
-				do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
840
+				do_action("getpaid_before_delete_payment_form", new GetPaid_Payment_Form($post_id));
841 841
 				break;
842 842
 
843 843
 			case 'wpi_discount' :
844
-				do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
844
+				do_action("getpaid_before_delete_discount", new WPInv_Discount($post_id));
845 845
 				break;
846 846
 
847 847
 			case 'wpi_invoice' :
848
-				$invoice = new WPInv_Invoice( $post_id );
849
-				do_action( "getpaid_before_delete_invoice", $invoice );
850
-				$invoice->get_data_store()->delete_items( $invoice );
851
-				$invoice->get_data_store()->delete_special_fields( $invoice );
848
+				$invoice = new WPInv_Invoice($post_id);
849
+				do_action("getpaid_before_delete_invoice", $invoice);
850
+				$invoice->get_data_store()->delete_items($invoice);
851
+				$invoice->get_data_store()->delete_special_fields($invoice);
852 852
 				break;
853 853
 		}
854 854
 	}
@@ -861,29 +861,29 @@  discard block
 block discarded – undo
861 861
      *
862 862
      * @return mixed
863 863
      */
864
-    public static function add_display_post_states( $post_states, $post ) {
864
+    public static function add_display_post_states($post_states, $post) {
865 865
 
866
-        if ( wpinv_get_option( 'success_page', 0 ) == $post->ID ) {
867
-            $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' );
866
+        if (wpinv_get_option('success_page', 0) == $post->ID) {
867
+            $post_states['getpaid_success_page'] = __('GetPaid Receipt Page', 'invoicing');
868 868
         }
869 869
 
870
-		foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
870
+		foreach (getpaid_get_invoice_post_types() as $post_type => $label) {
871 871
 
872
-			if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
872
+			if (wpinv_get_option("{$post_type}_history_page", 0) == $post->ID) {
873 873
 				$post_states["getpaid_{$post_type}_history_page"] = sprintf(
874
-					__( 'GetPaid %s History Page', 'invoicing' ),
874
+					__('GetPaid %s History Page', 'invoicing'),
875 875
 					$label
876 876
 				);
877 877
 			}
878 878
 
879 879
 		}
880 880
 		
881
-		if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
882
-            $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' );
881
+		if (wpinv_get_option('invoice_subscription_page', 0) == $post->ID) {
882
+            $post_states['getpaid_invoice_subscription_page'] = __('GetPaid Subscription Page', 'invoicing');
883 883
         }
884 884
 
885
-		if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
886
-            $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' );
885
+		if (wpinv_get_option('checkout_page', 0) == $post->ID) {
886
+            $post_states['getpaid_checkout_page'] = __('GetPaid Checkout Page', 'invoicing');
887 887
         }
888 888
 
889 889
         return $post_states;
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission.php 1 patch
Spacing   +129 added lines, -129 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;
4 4
 }
5 5
 
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 		$this->state   = wpinv_get_default_state();
147 147
 
148 148
 		// Do we have an actual submission?
149
-		if ( isset( $_POST['getpaid_payment_form_submission'] ) ) {
150
-			$this->load_data( wp_kses_post_deep( wp_unslash( $_POST ) ) );
149
+		if (isset($_POST['getpaid_payment_form_submission'])) {
150
+			$this->load_data(wp_kses_post_deep(wp_unslash($_POST)));
151 151
 		}
152 152
 
153 153
 	}
@@ -157,16 +157,16 @@  discard block
 block discarded – undo
157 157
 	 *
158 158
 	 * @param array $data
159 159
 	 */
160
-	public function load_data( $data ) {
160
+	public function load_data($data) {
161 161
 
162 162
 		// Allow plugins to filter the data.
163
-		$data       = apply_filters( 'getpaid_submission_data', $data, $this );
163
+		$data       = apply_filters('getpaid_submission_data', $data, $this);
164 164
 
165 165
 		// Cache it...
166 166
 		$this->data = $data;
167 167
 
168 168
 		// Then generate a unique id from the data.
169
-		$this->id   = md5( wp_json_encode( $data ) );
169
+		$this->id   = md5(wp_json_encode($data));
170 170
 
171 171
 		// Finally, process the submission.
172 172
 		try {
@@ -176,30 +176,30 @@  discard block
 block discarded – undo
176 176
 			$processors = apply_filters(
177 177
 				'getpaid_payment_form_submission_processors',
178 178
 				array(
179
-					array( $this, 'process_payment_form' ),
180
-					array( $this, 'process_invoice' ),
181
-					array( $this, 'process_fees' ),
182
-					array( $this, 'process_items' ),
183
-					array( $this, 'process_discount' ),
184
-					array( $this, 'process_taxes' ),
179
+					array($this, 'process_payment_form'),
180
+					array($this, 'process_invoice'),
181
+					array($this, 'process_fees'),
182
+					array($this, 'process_items'),
183
+					array($this, 'process_discount'),
184
+					array($this, 'process_taxes'),
185 185
 				),
186 186
 				$this		
187 187
 			);
188 188
 
189
-			foreach ( $processors as $processor ) {
190
-				call_user_func_array( $processor, array( &$this ) );
189
+			foreach ($processors as $processor) {
190
+				call_user_func_array($processor, array(&$this));
191 191
 			}
192 192
 
193
-		} catch( GetPaid_Payment_Exception $e ) {
193
+		} catch (GetPaid_Payment_Exception $e) {
194 194
 			$this->last_error      = $e->getMessage();
195 195
 			$this->last_error_code = $e->getErrorCode();
196
-		} catch ( Exception $e ) {
196
+		} catch (Exception $e) {
197 197
 			$this->last_error      = $e->getMessage();
198 198
 			$this->last_error_code = $e->getCode();
199 199
 		}
200 200
 
201 201
 		// Fired when we are done processing a submission.
202
-		do_action_ref_array( 'getpaid_process_submission', array( &$this ) );
202
+		do_action_ref_array('getpaid_process_submission', array(&$this));
203 203
 
204 204
 	}
205 205
 
@@ -220,18 +220,18 @@  discard block
 block discarded – undo
220 220
 	public function process_payment_form() {
221 221
 
222 222
 		// Every submission needs an active payment form.
223
-		if ( empty( $this->data['form_id'] ) ) {
224
-			throw new Exception( __( 'Missing payment form', 'invoicing' ) );
223
+		if (empty($this->data['form_id'])) {
224
+			throw new Exception(__('Missing payment form', 'invoicing'));
225 225
 		}
226 226
 
227 227
 		// Fetch the payment form.
228
-		$this->payment_form = new GetPaid_Payment_Form( $this->data['form_id'] );
228
+		$this->payment_form = new GetPaid_Payment_Form($this->data['form_id']);
229 229
 
230
-		if ( ! $this->payment_form->is_active() ) {
231
-			throw new Exception( __( 'Payment form not active', 'invoicing' ) );
230
+		if (!$this->payment_form->is_active()) {
231
+			throw new Exception(__('Payment form not active', 'invoicing'));
232 232
 		}
233 233
 
234
-		do_action_ref_array( 'getpaid_submissions_process_payment_form', array( &$this ) );
234
+		do_action_ref_array('getpaid_submissions_process_payment_form', array(&$this));
235 235
 	}
236 236
 
237 237
     /**
@@ -261,53 +261,53 @@  discard block
 block discarded – undo
261 261
 	public function process_invoice() {
262 262
 
263 263
 		// Abort if there is no invoice.
264
-		if ( empty( $this->data['invoice_id'] ) ) {
264
+		if (empty($this->data['invoice_id'])) {
265 265
 			return;
266 266
 		}
267 267
 
268 268
 		// If the submission is for an existing invoice, ensure that it exists
269 269
 		// and that it is not paid for.
270
-		$invoice = wpinv_get_invoice( $this->data['invoice_id'] );
270
+		$invoice = wpinv_get_invoice($this->data['invoice_id']);
271 271
 
272
-        if ( empty( $invoice ) ) {
273
-			throw new Exception( __( 'Invalid invoice', 'invoicing' ) );
272
+        if (empty($invoice)) {
273
+			throw new Exception(__('Invalid invoice', 'invoicing'));
274 274
 		}
275 275
 
276
-		if ( $invoice->is_paid() ) {
277
-			throw new Exception( __( 'This invoice is already paid for.', 'invoicing' ) );
276
+		if ($invoice->is_paid()) {
277
+			throw new Exception(__('This invoice is already paid for.', 'invoicing'));
278 278
 		}
279 279
 
280 280
 		$this->payment_form->invoice = $invoice;
281
-		if ( ! $this->payment_form->is_default() ) {
281
+		if (!$this->payment_form->is_default()) {
282 282
 
283 283
 			$items    = array();
284 284
 			$item_ids = array();
285 285
 	
286
-			foreach ( $invoice->get_items() as $item ) {
287
-				if ( ! in_array( $item->get_id(), $item_ids ) ) {
286
+			foreach ($invoice->get_items() as $item) {
287
+				if (!in_array($item->get_id(), $item_ids)) {
288 288
 					$item_ids[] = $item->get_id();
289 289
 					$items[]    = $item;
290 290
 				}
291 291
 			}
292 292
 	
293
-			foreach ( $this->payment_form->get_items() as $item ) {
294
-				if ( ! in_array( $item->get_id(), $item_ids ) ) {
293
+			foreach ($this->payment_form->get_items() as $item) {
294
+				if (!in_array($item->get_id(), $item_ids)) {
295 295
 					$item_ids[] = $item->get_id();
296 296
 					$items[]    = $item;
297 297
 				}
298 298
 			}
299 299
 	
300
-			$this->payment_form->set_items( $items );
300
+			$this->payment_form->set_items($items);
301 301
 	
302 302
 		} else {
303
-			$this->payment_form->set_items( $invoice->get_items() );
303
+			$this->payment_form->set_items($invoice->get_items());
304 304
 		}
305 305
 
306 306
 		$this->country = $invoice->get_country();
307 307
 		$this->state   = $invoice->get_state();
308 308
 		$this->invoice = $invoice;
309 309
 
310
-		do_action_ref_array( 'getpaid_submissions_process_invoice', array( &$this ) );
310
+		do_action_ref_array('getpaid_submissions_process_invoice', array(&$this));
311 311
 	}
312 312
 
313 313
 	/**
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 	 * @return bool
328 328
 	 */
329 329
 	public function has_invoice() {
330
-		return ! empty( $this->invoice );
330
+		return !empty($this->invoice);
331 331
 	}
332 332
 
333 333
 	/*
@@ -346,13 +346,13 @@  discard block
 block discarded – undo
346 346
 	 */
347 347
 	public function process_items() {
348 348
 
349
-		$processor = new GetPaid_Payment_Form_Submission_Items( $this );
349
+		$processor = new GetPaid_Payment_Form_Submission_Items($this);
350 350
 
351
-		foreach ( $processor->items as $item ) {
352
-			$this->add_item( $item );
351
+		foreach ($processor->items as $item) {
352
+			$this->add_item($item);
353 353
 		}
354 354
 
355
-		do_action_ref_array( 'getpaid_submissions_process_items', array( &$this ) );
355
+		do_action_ref_array('getpaid_submissions_process_items', array(&$this));
356 356
 	}
357 357
 
358 358
 	/**
@@ -361,20 +361,20 @@  discard block
 block discarded – undo
361 361
 	 * @since 1.0.19
362 362
 	 * @param GetPaid_Form_Item $item
363 363
 	 */
364
-	public function add_item( $item ) {
364
+	public function add_item($item) {
365 365
 
366 366
 		// Make sure that it is available for purchase.
367
-		if ( ! $item->can_purchase() || isset( $this->items[ $item->get_id() ] ) ) {
367
+		if (!$item->can_purchase() || isset($this->items[$item->get_id()])) {
368 368
 			return;
369 369
 		}
370 370
 
371 371
 		// Each submission can only contain one recurring item.
372
-		if ( $item->is_recurring() ) {
372
+		if ($item->is_recurring()) {
373 373
 			$this->has_recurring = $item->get_id();
374 374
 		}
375 375
 
376 376
 		// Update the items and totals.
377
-		$this->items[ $item->get_id() ]         = $item;
377
+		$this->items[$item->get_id()]         = $item;
378 378
 		$this->totals['subtotal']['initial']   += $item->get_sub_total();
379 379
 		$this->totals['subtotal']['recurring'] += $item->get_recurring_sub_total();
380 380
 
@@ -388,17 +388,17 @@  discard block
 block discarded – undo
388 388
 	 *
389 389
 	 * @since 1.0.19
390 390
 	 */
391
-	public function remove_item( $item_id ) {
391
+	public function remove_item($item_id) {
392 392
 
393
-		if ( isset( $this->items[ $item_id ] ) ) {
394
-			$this->totals['subtotal']['initial']   -= $this->items[ $item_id ]->get_sub_total();
395
-			$this->totals['subtotal']['recurring'] -= $this->items[ $item_id ]->get_recurring_sub_total();
393
+		if (isset($this->items[$item_id])) {
394
+			$this->totals['subtotal']['initial']   -= $this->items[$item_id]->get_sub_total();
395
+			$this->totals['subtotal']['recurring'] -= $this->items[$item_id]->get_recurring_sub_total();
396 396
 
397
-			if ( $this->items[ $item_id ]->is_recurring() ) {
397
+			if ($this->items[$item_id]->is_recurring()) {
398 398
 				$this->has_recurring = 0;
399 399
 			}
400 400
 
401
-			unset( $this->items[ $item_id ] );
401
+			unset($this->items[$item_id]);
402 402
 		}
403 403
 
404 404
 	}
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 	 */
411 411
 	public function get_subtotal() {
412 412
 
413
-		if ( wpinv_prices_include_tax() ) {
413
+		if (wpinv_prices_include_tax()) {
414 414
 			return $this->totals['subtotal']['initial'] - $this->totals['taxes']['initial'];
415 415
 		}
416 416
 
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 	 */
425 425
 	public function get_recurring_subtotal() {
426 426
 
427
-		if ( wpinv_prices_include_tax() ) {
427
+		if (wpinv_prices_include_tax()) {
428 428
 			return $this->totals['subtotal']['recurring'] - $this->totals['taxes']['recurring'];
429 429
 		}
430 430
 
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 	 * @return bool
449 449
 	 */
450 450
 	public function has_subscription_group() {
451
-		return $this->has_recurring && getpaid_should_group_subscriptions( $this ) && 1 == count( getpaid_get_subscription_groups( $this ) );
451
+		return $this->has_recurring && getpaid_should_group_subscriptions($this) && 1 == count(getpaid_get_subscription_groups($this));
452 452
 	}
453 453
 
454 454
 	/**
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
 	 * @return bool
459 459
 	 */
460 460
 	public function has_multiple_subscription_groups() {
461
-		return $this->has_recurring && 1 < count( getpaid_get_subscription_groups( $this ) );
461
+		return $this->has_recurring && 1 < count(getpaid_get_subscription_groups($this));
462 462
 	}
463 463
 
464 464
 	/*
@@ -478,39 +478,39 @@  discard block
 block discarded – undo
478 478
 	public function process_taxes() {
479 479
 
480 480
 		// Abort if we're not using taxes.
481
-		if ( ! $this->use_taxes() ) {
481
+		if (!$this->use_taxes()) {
482 482
 			return;
483 483
 		}
484 484
 
485 485
 		// If a custom country && state has been passed in, use it to calculate taxes.
486
-		$country = $this->get_field( 'wpinv_country', 'billing' );
487
-		if ( ! empty( $country ) ) {
486
+		$country = $this->get_field('wpinv_country', 'billing');
487
+		if (!empty($country)) {
488 488
 			$this->country = $country;
489 489
 		}
490 490
 
491
-		$state = $this->get_field( 'wpinv_state', 'billing' );
492
-		if ( ! empty( $state ) ) {
491
+		$state = $this->get_field('wpinv_state', 'billing');
492
+		if (!empty($state)) {
493 493
 			$this->state = $state;
494 494
 		}
495 495
 
496 496
 		// Confirm if the provided country and the ip country are similar.
497
-		$address_confirmed = $this->get_field( 'confirm-address' );
498
-		if ( isset( $_POST['billing']['country'] ) && wpinv_should_validate_vat_number() && getpaid_get_ip_country() != $this->country && empty( $address_confirmed ) ) {
499
-			throw new Exception( __( 'The country of your current location must be the same as the country of your billing location or you must confirm the billing address is your home country.', 'invoicing' ) );
497
+		$address_confirmed = $this->get_field('confirm-address');
498
+		if (isset($_POST['billing']['country']) && wpinv_should_validate_vat_number() && getpaid_get_ip_country() != $this->country && empty($address_confirmed)) {
499
+			throw new Exception(__('The country of your current location must be the same as the country of your billing location or you must confirm the billing address is your home country.', 'invoicing'));
500 500
 		}
501 501
 
502 502
 		// Abort if the country is not taxable.
503
-		if ( ! wpinv_is_country_taxable( $this->country ) ) {
503
+		if (!wpinv_is_country_taxable($this->country)) {
504 504
 			return;
505 505
 		}
506 506
 
507
-		$processor = new GetPaid_Payment_Form_Submission_Taxes( $this );
507
+		$processor = new GetPaid_Payment_Form_Submission_Taxes($this);
508 508
 
509
-		foreach ( $processor->taxes as $tax ) {
510
-			$this->add_tax( $tax );
509
+		foreach ($processor->taxes as $tax) {
510
+			$this->add_tax($tax);
511 511
 		}
512 512
 
513
-		do_action_ref_array( 'getpaid_submissions_process_taxes', array( &$this ) );
513
+		do_action_ref_array('getpaid_submissions_process_taxes', array(&$this));
514 514
 	}
515 515
 
516 516
 	/**
@@ -519,16 +519,16 @@  discard block
 block discarded – undo
519 519
 	 * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required.
520 520
 	 * @since 1.0.19
521 521
 	 */
522
-	public function add_tax( $tax ) {
522
+	public function add_tax($tax) {
523 523
 
524
-		if ( wpinv_round_tax_per_tax_rate() ) {
525
-			$tax['initial_tax']   = wpinv_round_amount( $tax['initial_tax'] );
526
-			$tax['recurring_tax'] = wpinv_round_amount( $tax['recurring_tax'] );
524
+		if (wpinv_round_tax_per_tax_rate()) {
525
+			$tax['initial_tax']   = wpinv_round_amount($tax['initial_tax']);
526
+			$tax['recurring_tax'] = wpinv_round_amount($tax['recurring_tax']);
527 527
 		}
528 528
 
529
-		$this->taxes[ $tax['name'] ]         = $tax;
530
-		$this->totals['taxes']['initial']   += wpinv_sanitize_amount( $tax['initial_tax'] );
531
-		$this->totals['taxes']['recurring'] += wpinv_sanitize_amount( $tax['recurring_tax'] );
529
+		$this->taxes[$tax['name']]         = $tax;
530
+		$this->totals['taxes']['initial']   += wpinv_sanitize_amount($tax['initial_tax']);
531
+		$this->totals['taxes']['recurring'] += wpinv_sanitize_amount($tax['recurring_tax']);
532 532
 
533 533
 	}
534 534
 
@@ -537,12 +537,12 @@  discard block
 block discarded – undo
537 537
 	 *
538 538
 	 * @since 1.0.19
539 539
 	 */
540
-	public function remove_tax( $tax_name ) {
540
+	public function remove_tax($tax_name) {
541 541
 
542
-		if ( isset( $this->taxes[ $tax_name ] ) ) {
543
-			$this->totals['taxes']['initial']   -= $this->taxes[ $tax_name ]['initial_tax'];
544
-			$this->totals['taxes']['recurring'] -= $this->taxes[ $tax_name ]['recurring_tax'];
545
-			unset( $this->taxes[ $tax_name ] );
542
+		if (isset($this->taxes[$tax_name])) {
543
+			$this->totals['taxes']['initial']   -= $this->taxes[$tax_name]['initial_tax'];
544
+			$this->totals['taxes']['recurring'] -= $this->taxes[$tax_name]['recurring_tax'];
545
+			unset($this->taxes[$tax_name]);
546 546
 		}
547 547
 
548 548
 	}
@@ -556,11 +556,11 @@  discard block
 block discarded – undo
556 556
 
557 557
 		$use_taxes = wpinv_use_taxes();
558 558
 
559
-		if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) {
559
+		if ($this->has_invoice() && !$this->invoice->is_taxable()) {
560 560
 			$use_taxes = false;
561 561
 		}
562 562
 
563
-		return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this );
563
+		return apply_filters('getpaid_submission_use_taxes', $use_taxes, $this);
564 564
 
565 565
 	}
566 566
 
@@ -609,13 +609,13 @@  discard block
 block discarded – undo
609 609
 
610 610
 		$initial_total    = $this->get_subtotal() + $this->get_fee() + $this->get_tax();
611 611
 		$recurring_total  = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax();
612
-		$processor        = new GetPaid_Payment_Form_Submission_Discount( $this, $initial_total, $recurring_total );
612
+		$processor        = new GetPaid_Payment_Form_Submission_Discount($this, $initial_total, $recurring_total);
613 613
 
614
-		foreach ( $processor->discounts as $discount ) {
615
-			$this->add_discount( $discount );
614
+		foreach ($processor->discounts as $discount) {
615
+			$this->add_discount($discount);
616 616
 		}
617 617
 
618
-		do_action_ref_array( 'getpaid_submissions_process_discounts', array( &$this ) );
618
+		do_action_ref_array('getpaid_submissions_process_discounts', array(&$this));
619 619
 	}
620 620
 
621 621
 	/**
@@ -624,10 +624,10 @@  discard block
 block discarded – undo
624 624
 	 * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
625 625
 	 * @since 1.0.19
626 626
 	 */
627
-	public function add_discount( $discount ) {
628
-		$this->discounts[ $discount['name'] ]   = $discount;
629
-		$this->totals['discount']['initial']   += wpinv_sanitize_amount( $discount['initial_discount'] );
630
-		$this->totals['discount']['recurring'] += wpinv_sanitize_amount( $discount['recurring_discount'] );
627
+	public function add_discount($discount) {
628
+		$this->discounts[$discount['name']]   = $discount;
629
+		$this->totals['discount']['initial']   += wpinv_sanitize_amount($discount['initial_discount']);
630
+		$this->totals['discount']['recurring'] += wpinv_sanitize_amount($discount['recurring_discount']);
631 631
 	}
632 632
 
633 633
 	/**
@@ -635,12 +635,12 @@  discard block
 block discarded – undo
635 635
 	 *
636 636
 	 * @since 1.0.19
637 637
 	 */
638
-	public function remove_discount( $name ) {
638
+	public function remove_discount($name) {
639 639
 
640
-		if ( isset( $this->discounts[ $name ] ) ) {
641
-			$this->totals['discount']['initial']   -= $this->discounts[ $name ]['initial_discount'];
642
-			$this->totals['discount']['recurring'] -= $this->discounts[ $name ]['recurring_discount'];
643
-			unset( $this->discounts[ $name ] );
640
+		if (isset($this->discounts[$name])) {
641
+			$this->totals['discount']['initial']   -= $this->discounts[$name]['initial_discount'];
642
+			$this->totals['discount']['recurring'] -= $this->discounts[$name]['recurring_discount'];
643
+			unset($this->discounts[$name]);
644 644
 		}
645 645
 
646 646
 	}
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
 	 * @return bool
653 653
 	 */
654 654
 	public function has_discount_code() {
655
-		return ! empty( $this->discounts['discount_code'] );
655
+		return !empty($this->discounts['discount_code']);
656 656
 	}
657 657
 
658 658
 	/**
@@ -709,13 +709,13 @@  discard block
 block discarded – undo
709 709
 	 */
710 710
 	public function process_fees() {
711 711
 
712
-		$fees_processor = new GetPaid_Payment_Form_Submission_Fees( $this );
712
+		$fees_processor = new GetPaid_Payment_Form_Submission_Fees($this);
713 713
 
714
-		foreach ( $fees_processor->fees as $fee ) {
715
-			$this->add_fee( $fee );
714
+		foreach ($fees_processor->fees as $fee) {
715
+			$this->add_fee($fee);
716 716
 		}
717 717
 
718
-		do_action_ref_array( 'getpaid_submissions_process_fees', array( &$this ) );
718
+		do_action_ref_array('getpaid_submissions_process_fees', array(&$this));
719 719
 	}
720 720
 
721 721
 	/**
@@ -724,17 +724,17 @@  discard block
 block discarded – undo
724 724
 	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
725 725
 	 * @since 1.0.19
726 726
 	 */
727
-	public function add_fee( $fee ) {
727
+	public function add_fee($fee) {
728 728
 
729
-		if ( $fee['name'] == 'shipping' ) {
730
-			$this->totals['shipping']['initial']   += wpinv_sanitize_amount( $fee['initial_fee'] );
731
-			$this->totals['shipping']['recurring'] += wpinv_sanitize_amount( $fee['recurring_fee'] );
729
+		if ($fee['name'] == 'shipping') {
730
+			$this->totals['shipping']['initial']   += wpinv_sanitize_amount($fee['initial_fee']);
731
+			$this->totals['shipping']['recurring'] += wpinv_sanitize_amount($fee['recurring_fee']);
732 732
 			return;
733 733
 		}
734 734
 
735
-		$this->fees[ $fee['name'] ]         = $fee;
736
-		$this->totals['fees']['initial']   += wpinv_sanitize_amount( $fee['initial_fee'] );
737
-		$this->totals['fees']['recurring'] += wpinv_sanitize_amount( $fee['recurring_fee'] );
735
+		$this->fees[$fee['name']]         = $fee;
736
+		$this->totals['fees']['initial']   += wpinv_sanitize_amount($fee['initial_fee']);
737
+		$this->totals['fees']['recurring'] += wpinv_sanitize_amount($fee['recurring_fee']);
738 738
 
739 739
 	}
740 740
 
@@ -743,15 +743,15 @@  discard block
 block discarded – undo
743 743
 	 *
744 744
 	 * @since 1.0.19
745 745
 	 */
746
-	public function remove_fee( $name ) {
746
+	public function remove_fee($name) {
747 747
 
748
-		if ( isset( $this->fees[ $name ] ) ) {
749
-			$this->totals['fees']['initial']   -= $this->fees[ $name ]['initial_fee'];
750
-			$this->totals['fees']['recurring'] -= $this->fees[ $name ]['recurring_fee'];
751
-			unset( $this->fees[ $name ] );
748
+		if (isset($this->fees[$name])) {
749
+			$this->totals['fees']['initial']   -= $this->fees[$name]['initial_fee'];
750
+			$this->totals['fees']['recurring'] -= $this->fees[$name]['recurring_fee'];
751
+			unset($this->fees[$name]);
752 752
 		}
753 753
 
754
-		if ( 'shipping' == $name ) {
754
+		if ('shipping' == $name) {
755 755
 			$this->totals['shipping']['initial']   = 0;
756 756
 			$this->totals['shipping']['recurring'] = 0;
757 757
 		}
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
 	 * @since 1.0.19
793 793
 	 */
794 794
 	public function has_fees() {
795
-		return count( $this->fees ) !== 0;
795
+		return count($this->fees) !== 0;
796 796
 	}
797 797
 
798 798
 	/*
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
 	 * @since 1.0.19
829 829
 	 */
830 830
 	public function has_shipping() {
831
-		return apply_filters( 'getpaid_payment_form_has_shipping', false, $this );
831
+		return apply_filters('getpaid_payment_form_has_shipping', false, $this);
832 832
 	}
833 833
 
834 834
 	/**
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 	 * @since 1.0.19
839 839
 	 */
840 840
 	public function is_initial_fetch() {
841
-		return empty( $this->data['initial_state'] );
841
+		return empty($this->data['initial_state']);
842 842
 	}
843 843
 
844 844
 	/**
@@ -848,7 +848,7 @@  discard block
 block discarded – undo
848 848
 	 */
849 849
 	public function get_total() {
850 850
 		$total = $this->get_subtotal() + $this->get_fee() + $this->get_tax() + $this->get_shipping() - $this->get_discount();
851
-		return max( $total, 0 );
851
+		return max($total, 0);
852 852
 	}
853 853
 
854 854
 	/**
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
 	 */
859 859
 	public function get_recurring_total() {
860 860
 		$total = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax() + $this->get_recurring_shipping() - $this->get_recurring_discount();
861
-		return max( $total, 0 );
861
+		return max($total, 0);
862 862
 	}
863 863
 
864 864
 	/**
@@ -870,12 +870,12 @@  discard block
 block discarded – undo
870 870
 		$initial   = $this->get_total();
871 871
 		$recurring = $this->get_recurring_total();
872 872
 
873
-		if ( $this->has_recurring == 0 ) {
873
+		if ($this->has_recurring == 0) {
874 874
 			$recurring = 0;
875 875
 		}
876 876
 
877 877
 		$collect = $initial > 0 || $recurring > 0;
878
-		return apply_filters( 'getpaid_submission_should_collect_payment_details', $collect, $this  );
878
+		return apply_filters('getpaid_submission_should_collect_payment_details', $collect, $this);
879 879
 	}
880 880
 
881 881
 	/**
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
 	 * @since 1.0.19
885 885
 	 */
886 886
 	public function get_billing_email() {
887
-		return apply_filters( 'getpaid_get_submission_billing_email', $this->get_field( 'billing_email' ), $this  );
887
+		return apply_filters('getpaid_get_submission_billing_email', $this->get_field('billing_email'), $this);
888 888
 	}
889 889
 
890 890
 	/**
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
 	 */
895 895
 	public function has_billing_email() {
896 896
 		$billing_email = $this->get_billing_email();
897
-		return ! empty( $billing_email ) && is_email( $billing_email );
897
+		return !empty($billing_email) && is_email($billing_email);
898 898
 	}
899 899
 
900 900
 	/**
@@ -924,8 +924,8 @@  discard block
 block discarded – undo
924 924
 	 * @since 1.0.19
925 925
 	 * @return mixed|null
926 926
 	 */
927
-	public function get_field( $field, $sub_array_key = null ) {
928
-		return getpaid_get_array_field( $this->data, $field, $sub_array_key );
927
+	public function get_field($field, $sub_array_key = null) {
928
+		return getpaid_get_array_field($this->data, $field, $sub_array_key);
929 929
 	}
930 930
 
931 931
 	/**
@@ -933,8 +933,8 @@  discard block
 block discarded – undo
933 933
 	 *
934 934
 	 * @since 1.0.19
935 935
 	 */
936
-	public function is_required_field_set( $field ) {
937
-		return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] );
936
+	public function is_required_field_set($field) {
937
+		return empty($field['required']) || !empty($this->data[$field['id']]);
938 938
 	}
939 939
 
940 940
 	/**
@@ -942,8 +942,8 @@  discard block
 block discarded – undo
942 942
 	 *
943 943
 	 * @since 1.0.19
944 944
 	 */
945
-	public function format_amount( $amount ) {
946
-		return wpinv_price( $amount, $this->get_currency() );
945
+	public function format_amount($amount) {
946
+		return wpinv_price($amount, $this->get_currency());
947 947
 	}
948 948
 
949 949
 }
Please login to merge, or discard this patch.
includes/class-wpinv.php 1 patch
Spacing   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @since   1.0.0
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Main Invoicing class.
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	 * @param string $prop The prop to set.
57 57
 	 * @param mixed $value The value to retrieve.
58 58
 	 */
59
-	public function set( $prop, $value ) {
60
-		$this->data[ $prop ] = $value;
59
+	public function set($prop, $value) {
60
+		$this->data[$prop] = $value;
61 61
 	}
62 62
 
63 63
 	/**
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
 	 * @param string $prop The prop to set.
67 67
 	 * @return mixed The value.
68 68
 	 */
69
-	public function get( $prop ) {
69
+	public function get($prop) {
70 70
 
71
-		if ( isset( $this->data[ $prop ] ) ) {
72
-			return $this->data[ $prop ];
71
+		if (isset($this->data[$prop])) {
72
+			return $this->data[$prop];
73 73
 		}
74 74
 
75 75
 		return null;
@@ -81,23 +81,23 @@  discard block
 block discarded – undo
81 81
 	public function set_properties() {
82 82
 
83 83
 		// Sessions.
84
-		$this->set( 'session', new WPInv_Session_Handler() );
85
-		$GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
84
+		$this->set('session', new WPInv_Session_Handler());
85
+		$GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility.
86 86
 		$GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility.
87 87
 
88 88
 		// Init other objects.
89
-		$this->set( 'session', new WPInv_Session_Handler() );
90
-		$this->set( 'notes', new WPInv_Notes() );
91
-		$this->set( 'api', new WPInv_API() );
92
-		$this->set( 'post_types', new GetPaid_Post_Types() );
93
-		$this->set( 'template', new GetPaid_Template() );
94
-		$this->set( 'admin', new GetPaid_Admin() );
95
-		$this->set( 'subscriptions', new WPInv_Subscriptions() );
96
-		$this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
97
-		$this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
98
-		$this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
99
-		$this->set( 'payment_forms', new GetPaid_Payment_Forms() );
100
-		$this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() );
89
+		$this->set('session', new WPInv_Session_Handler());
90
+		$this->set('notes', new WPInv_Notes());
91
+		$this->set('api', new WPInv_API());
92
+		$this->set('post_types', new GetPaid_Post_Types());
93
+		$this->set('template', new GetPaid_Template());
94
+		$this->set('admin', new GetPaid_Admin());
95
+		$this->set('subscriptions', new WPInv_Subscriptions());
96
+		$this->set('invoice_emails', new GetPaid_Invoice_Notification_Emails());
97
+		$this->set('subscription_emails', new GetPaid_Subscription_Notification_Emails());
98
+		$this->set('daily_maintenace', new GetPaid_Daily_Maintenance());
99
+		$this->set('payment_forms', new GetPaid_Payment_Forms());
100
+		$this->set('maxmind', new GetPaid_MaxMind_Geolocation());
101 101
 
102 102
 	}
103 103
 
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 	 * Define plugin constants.
106 106
 	 */
107 107
 	public function define_constants() {
108
-		define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
109
-		define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
108
+		define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
109
+		define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
110 110
 		$this->version = WPINV_VERSION;
111 111
 	}
112 112
 
@@ -117,27 +117,27 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	protected function init_hooks() {
119 119
 		/* Internationalize the text strings used. */
120
-		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
120
+		add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
121 121
 
122 122
 		// Init the plugin after WordPress inits.
123
-		add_action( 'init', array( $this, 'init' ), 1 );
124
-		add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 );
125
-		add_action( 'init', array( $this, 'wpinv_actions' ) );
126
-		add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
127
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
128
-		add_action( 'wp_footer', array( $this, 'wp_footer' ) );
129
-		add_action( 'wp_head', array( $this, 'wp_head' ) );
130
-		add_action( 'widgets_init', array( $this, 'register_widgets' ) );
131
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
132
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
133
-
134
-		add_filter( 'query_vars', array( $this, 'custom_query_vars' ) );
135
-        add_action( 'init', array( $this, 'add_rewrite_rule' ), 10, 0 );
136
-		add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 );
123
+		add_action('init', array($this, 'init'), 1);
124
+		add_action('init', array($this, 'maybe_process_ipn'), 10);
125
+		add_action('init', array($this, 'wpinv_actions'));
126
+		add_action('init', array($this, 'maybe_do_authenticated_action'), 100);
127
+		add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 11);
128
+		add_action('wp_footer', array($this, 'wp_footer'));
129
+		add_action('wp_head', array($this, 'wp_head'));
130
+		add_action('widgets_init', array($this, 'register_widgets'));
131
+		add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids'));
132
+		add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
133
+
134
+		add_filter('query_vars', array($this, 'custom_query_vars'));
135
+        add_action('init', array($this, 'add_rewrite_rule'), 10, 0);
136
+		add_action('pre_get_posts', array($this, 'maybe_process_new_ipn'), 1);
137 137
 
138 138
 		// Fires after registering actions.
139
-		do_action( 'wpinv_actions', $this );
140
-		do_action( 'getpaid_actions', $this );
139
+		do_action('wpinv_actions', $this);
140
+		do_action('getpaid_actions', $this);
141 141
 
142 142
 	}
143 143
 
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
 		/* Internationalize the text strings used. */
146 146
 		$this->load_textdomain();
147 147
 
148
-		do_action( 'wpinv_loaded' );
148
+		do_action('wpinv_loaded');
149 149
 
150 150
 		// Fix oxygen page builder conflict
151
-		if ( function_exists( 'ct_css_output' ) ) {
151
+		if (function_exists('ct_css_output')) {
152 152
 			wpinv_oxygen_fix_conflict();
153 153
 		}
154 154
 	}
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 		load_plugin_textdomain(
170 170
 			'invoicing',
171 171
 			false,
172
-			plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/'
172
+			plugin_basename(dirname(WPINV_PLUGIN_FILE)) . '/languages/'
173 173
 		);
174 174
 
175 175
 	}
@@ -180,79 +180,79 @@  discard block
 block discarded – undo
180 180
 	public function includes() {
181 181
 
182 182
 		// Start with the settings.
183
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
183
+		require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
184 184
 
185 185
 		// Packages/libraries.
186
-		require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
187
-		require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
186
+		require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php');
187
+		require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php');
188 188
 
189 189
 		// Load functions.
190
-		require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
191
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
192
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
193
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
194
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
195
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
196
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
197
-		require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
198
-		require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' );
199
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
200
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
201
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
202
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
203
-		require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' );
204
-		require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
190
+		require_once(WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php');
191
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
192
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
193
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
194
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
195
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
196
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
197
+		require_once(WPINV_PLUGIN_DIR . 'includes/invoice-functions.php');
198
+		require_once(WPINV_PLUGIN_DIR . 'includes/subscription-functions.php');
199
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
200
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
201
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
202
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
203
+		require_once(WPINV_PLUGIN_DIR . 'includes/user-functions.php');
204
+		require_once(WPINV_PLUGIN_DIR . 'includes/error-functions.php');
205 205
 
206 206
 		// Register autoloader.
207 207
 		try {
208
-			spl_autoload_register( array( $this, 'autoload' ), true );
209
-		} catch ( Exception $e ) {
210
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
208
+			spl_autoload_register(array($this, 'autoload'), true);
209
+		} catch (Exception $e) {
210
+			wpinv_error_log($e->getMessage(), '', __FILE__, 149, true);
211 211
 		}
212 212
 
213
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
214
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
215
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
216
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
217
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
218
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
219
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
220
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
221
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
222
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
223
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
224
-		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
225
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
226
-		require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
227
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
228
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
229
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
230
-		require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
231
-		require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
232
-		require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
233
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice.php' );
234
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
235
-
236
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
213
+		require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php');
214
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php');
215
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
216
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
217
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php');
218
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php');
219
+		require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php');
220
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php');
221
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php');
222
+		require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php');
223
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php');
224
+		require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php');
225
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php');
226
+		require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php');
227
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php');
228
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php');
229
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php');
230
+		require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php');
231
+		require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php');
232
+		require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php');
233
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice.php');
234
+		require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
235
+
236
+		if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
237 237
 			GetPaid_Post_Types_Admin::init();
238 238
 
239
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
240
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
241
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
242
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
243
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
244
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
239
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
240
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php');
241
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
242
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php');
243
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php');
244
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php');
245 245
 			// load the user class only on the users.php page
246 246
 			global $pagenow;
247
-			if($pagenow=='users.php'){
247
+			if ($pagenow == 'users.php') {
248 248
 				new WPInv_Admin_Users();
249 249
 			}
250 250
 		}
251 251
 
252 252
 		// Register cli commands
253
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
254
-			require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
255
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
253
+		if (defined('WP_CLI') && WP_CLI) {
254
+			require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php');
255
+			WP_CLI::add_command('invoicing', 'WPInv_CLI');
256 256
 		}
257 257
 
258 258
 	}
@@ -265,21 +265,21 @@  discard block
 block discarded – undo
265 265
 	 * @since       1.0.19
266 266
 	 * @return      void
267 267
 	 */
268
-	public function autoload( $class_name ) {
268
+	public function autoload($class_name) {
269 269
 
270 270
 		// Normalize the class name...
271
-		$class_name  = strtolower( $class_name );
271
+		$class_name = strtolower($class_name);
272 272
 
273 273
 		// ... and make sure it is our class.
274
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
274
+		if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) {
275 275
 			return;
276 276
 		}
277 277
 
278 278
 		// Next, prepare the file name from the class.
279
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
279
+		$file_name = 'class-' . str_replace('_', '-', $class_name) . '.php';
280 280
 
281 281
 		// Base path of the classes.
282
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
282
+		$plugin_path = untrailingslashit(WPINV_PLUGIN_DIR);
283 283
 
284 284
 		// And an array of possible locations in order of importance.
285 285
 		$locations = array(
@@ -294,10 +294,10 @@  discard block
 block discarded – undo
294 294
 			"$plugin_path/includes/admin/meta-boxes",
295 295
 		);
296 296
 
297
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
297
+		foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) {
298 298
 
299
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
300
-				include trailingslashit( $location ) . $file_name;
299
+			if (file_exists(trailingslashit($location) . $file_name)) {
300
+				include trailingslashit($location) . $file_name;
301 301
 				break;
302 302
 			}
303 303
 
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 	public function init() {
312 312
 
313 313
 		// Fires before getpaid inits.
314
-		do_action( 'before_getpaid_init', $this );
314
+		do_action('before_getpaid_init', $this);
315 315
 
316 316
 		// Maybe upgrade.
317 317
 		$this->maybe_upgrade_database();
@@ -328,17 +328,17 @@  discard block
 block discarded – undo
328 328
 			)
329 329
 		);
330 330
 
331
-		foreach ( $gateways as $id => $class ) {
332
-			$this->gateways[ $id ] = new $class();
331
+		foreach ($gateways as $id => $class) {
332
+			$this->gateways[$id] = new $class();
333 333
 		}
334 334
 
335
-		if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) {
335
+		if ('yes' != get_option('wpinv_renamed_gateways')) {
336 336
 			GetPaid_Installer::rename_gateways_label();
337
-			update_option( 'wpinv_renamed_gateways', 'yes' );
337
+			update_option('wpinv_renamed_gateways', 'yes');
338 338
 		}
339 339
 
340 340
 		// Fires after getpaid inits.
341
-		do_action( 'getpaid_init', $this );
341
+		do_action('getpaid_init', $this);
342 342
 
343 343
 	}
344 344
 
@@ -348,14 +348,14 @@  discard block
 block discarded – undo
348 348
 	public function maybe_process_ipn() {
349 349
 
350 350
 		// Ensure that this is an IPN request.
351
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
351
+		if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) {
352 352
 			return;
353 353
 		}
354 354
 
355
-		$gateway = sanitize_text_field( $_GET['wpi-gateway'] );
355
+		$gateway = sanitize_text_field($_GET['wpi-gateway']);
356 356
 
357
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
358
-		do_action( "wpinv_verify_{$gateway}_ipn" );
357
+		do_action('wpinv_verify_payment_ipn', $gateway);
358
+		do_action("wpinv_verify_{$gateway}_ipn");
359 359
 		exit;
360 360
 
361 361
 	}
@@ -363,33 +363,33 @@  discard block
 block discarded – undo
363 363
 	public function enqueue_scripts() {
364 364
 
365 365
 		// Fires before adding scripts.
366
-		do_action( 'getpaid_enqueue_scripts' );
366
+		do_action('getpaid_enqueue_scripts');
367 367
 
368 368
 		$localize                         = array();
369
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
369
+		$localize['ajax_url']             = admin_url('admin-ajax.php');
370 370
 		$localize['thousands']            = wpinv_thousands_separator();
371 371
 		$localize['decimals']             = wpinv_decimal_separator();
372
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
373
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
372
+		$localize['nonce']                = wp_create_nonce('wpinv-nonce');
373
+		$localize['txtComplete']          = __('Continue', 'invoicing');
374 374
 		$localize['UseTaxes']             = wpinv_use_taxes();
375
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
376
-		$localize['loading']              = __( 'Loading...', 'invoicing' );
377
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
375
+		$localize['formNonce']            = wp_create_nonce('getpaid_form_nonce');
376
+		$localize['loading']              = __('Loading...', 'invoicing');
377
+		$localize['connectionError']      = __('Could not establish a connection to the server.', 'invoicing');
378 378
 
379
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
379
+		$localize = apply_filters('wpinv_front_js_localize', $localize);
380 380
 
381
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
382
-		wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ),  $version, true );
383
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
381
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js');
382
+		wp_enqueue_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('jquery'), $version, true);
383
+		wp_localize_script('wpinv-front-script', 'WPInv', $localize);
384 384
 	}
385 385
 
386 386
 	public function wpinv_actions() {
387
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
388
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
387
+		if (isset($_REQUEST['wpi_action'])) {
388
+			do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
389 389
 		}
390 390
 
391
-		if ( defined( 'WP_ALL_IMPORT_ROOT_DIR' ) ) {
392
-			include plugin_dir_path( __FILE__ ) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php';
391
+		if (defined('WP_ALL_IMPORT_ROOT_DIR')) {
392
+			include plugin_dir_path(__FILE__) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php';
393 393
 		}
394 394
 	}
395 395
 
@@ -401,24 +401,24 @@  discard block
 block discarded – undo
401 401
      */
402 402
     public function maybe_do_authenticated_action() {
403 403
 
404
-		if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
404
+		if (isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
405 405
 
406
-			$key  = sanitize_key( $_REQUEST['getpaid-action'] );
407
-			$data = wp_unslash( $_REQUEST );
408
-			if ( is_user_logged_in() ) {
409
-				do_action( "getpaid_authenticated_action_$key", $data );
406
+			$key  = sanitize_key($_REQUEST['getpaid-action']);
407
+			$data = wp_unslash($_REQUEST);
408
+			if (is_user_logged_in()) {
409
+				do_action("getpaid_authenticated_action_$key", $data);
410 410
 			}
411 411
 
412
-			do_action( "getpaid_unauthenticated_action_$key", $data );
412
+			do_action("getpaid_unauthenticated_action_$key", $data);
413 413
 
414 414
 		}
415 415
 
416 416
     }
417 417
 
418
-	public function pre_get_posts( $wp_query ) {
418
+	public function pre_get_posts($wp_query) {
419 419
 
420
-		if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
421
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
420
+		if (!is_admin() && !empty($wp_query->query_vars['post_type']) && getpaid_is_invoice_post_type($wp_query->query_vars['post_type']) && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
421
+			$wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses(false, false, $wp_query->query_vars['post_type']));
422 422
 		}
423 423
 
424 424
 		return $wp_query;
@@ -433,18 +433,18 @@  discard block
 block discarded – undo
433 433
 
434 434
 		// Currently, UX Builder does not work particulaly well with SuperDuper.
435 435
 		// So we disable our widgets when editing a page with UX Builder.
436
-		if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) {
436
+		if (function_exists('ux_builder_is_active') && ux_builder_is_active()) {
437 437
 			return;
438 438
 		}
439 439
 
440 440
 		$block_widget_init_screens = function_exists('sd_pagenow_exclude') ? sd_pagenow_exclude() : array();
441 441
 
442
-		if ( is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) {
442
+		if (is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) {
443 443
 			// don't initiate in these conditions.
444
-		}else{
444
+		} else {
445 445
 
446 446
 			// Only load allowed widgets.
447
-			$exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array();
447
+			$exclude = function_exists('sd_widget_exclude') ? sd_widget_exclude() : array();
448 448
 			$widgets = apply_filters(
449 449
 				'getpaid_widget_classes',
450 450
 				array(
@@ -460,16 +460,16 @@  discard block
 block discarded – undo
460 460
 			);
461 461
 
462 462
 			// For each widget...
463
-			foreach ( $widgets as $widget ) {
463
+			foreach ($widgets as $widget) {
464 464
 
465 465
 				// Abort early if it is excluded for this page.
466
-				if ( in_array( $widget, $exclude ) ) {
466
+				if (in_array($widget, $exclude)) {
467 467
 					continue;
468 468
 				}
469 469
 
470 470
 				// SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it.
471
-				if ( is_subclass_of( $widget, 'WP_Widget' ) ) {
472
-					register_widget( $widget );
471
+				if (is_subclass_of($widget, 'WP_Widget')) {
472
+					register_widget($widget);
473 473
 				} else {
474 474
 					new $widget();
475 475
 				}
@@ -487,29 +487,29 @@  discard block
 block discarded – undo
487 487
 	 */
488 488
 	public function maybe_upgrade_database() {
489 489
 
490
-		$wpi_version = get_option( 'wpinv_version', 0 );
490
+		$wpi_version = get_option('wpinv_version', 0);
491 491
 
492
-		if ( $wpi_version == WPINV_VERSION ) {
492
+		if ($wpi_version == WPINV_VERSION) {
493 493
 			return;
494 494
 		}
495 495
 
496 496
 		$installer = new GetPaid_Installer();
497 497
 
498
-		if ( empty( $wpi_version ) ) {
499
-			return $installer->upgrade_db( 0 );
498
+		if (empty($wpi_version)) {
499
+			return $installer->upgrade_db(0);
500 500
 		}
501 501
 
502
-		$upgrades  = array(
502
+		$upgrades = array(
503 503
 			'0.0.5' => '004',
504 504
 			'1.0.3' => '102',
505 505
 			'2.0.0' => '118',
506 506
 			'2.0.8' => '207',
507 507
 		);
508 508
 
509
-		foreach ( $upgrades as $key => $method ) {
509
+		foreach ($upgrades as $key => $method) {
510 510
 
511
-			if ( version_compare( $wpi_version, $key, '<' ) ) {
512
-				return $installer->upgrade_db( $method );
511
+			if (version_compare($wpi_version, $key, '<')) {
512
+				return $installer->upgrade_db($method);
513 513
 			}
514 514
 
515 515
 		}
@@ -523,11 +523,11 @@  discard block
 block discarded – undo
523 523
 	 */
524 524
 	public function maybe_flush_permalinks() {
525 525
 
526
-		$flush = get_option( 'wpinv_flush_permalinks', 0 );
526
+		$flush = get_option('wpinv_flush_permalinks', 0);
527 527
 
528
-		if ( ! empty( $flush ) ) {
528
+		if (!empty($flush)) {
529 529
 			flush_rewrite_rules();
530
-			delete_option( 'wpinv_flush_permalinks' );
530
+			delete_option('wpinv_flush_permalinks');
531 531
 		}
532 532
 
533 533
 	}
@@ -538,10 +538,10 @@  discard block
 block discarded – undo
538 538
 	 * @since 1.0.19
539 539
 	 * @param int[] $excluded_posts_ids
540 540
 	 */
541
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
541
+	public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) {
542 542
 
543 543
 		// Ensure that we have an array.
544
-		if ( ! is_array( $excluded_posts_ids ) ) {
544
+		if (!is_array($excluded_posts_ids)) {
545 545
 			$excluded_posts_ids = array();
546 546
 		}
547 547
 
@@ -549,24 +549,24 @@  discard block
 block discarded – undo
549 549
 		$our_pages = array();
550 550
 
551 551
 		// Checkout page.
552
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
552
+		$our_pages[] = wpinv_get_option('checkout_page', false);
553 553
 
554 554
 		// Success page.
555
-		$our_pages[] = wpinv_get_option( 'success_page', false );
555
+		$our_pages[] = wpinv_get_option('success_page', false);
556 556
 
557 557
 		// Failure page.
558
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
558
+		$our_pages[] = wpinv_get_option('failure_page', false);
559 559
 
560 560
 		// History page.
561
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
561
+		$our_pages[] = wpinv_get_option('invoice_history_page', false);
562 562
 
563 563
 		// Subscriptions page.
564
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
564
+		$our_pages[] = wpinv_get_option('invoice_subscription_page', false);
565 565
 
566
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
566
+		$our_pages   = array_map('intval', array_filter($our_pages));
567 567
 
568 568
 		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
569
-		return array_unique( $excluded_posts_ids );
569
+		return array_unique($excluded_posts_ids);
570 570
 
571 571
 	}
572 572
 
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 	 * @since 2.0.0
577 577
 	 */
578 578
 	public function wp_footer() {
579
-		wpinv_get_template( 'frontend-footer.php' );
579
+		wpinv_get_template('frontend-footer.php');
580 580
 	}
581 581
 
582 582
 	/**
@@ -585,14 +585,14 @@  discard block
 block discarded – undo
585 585
 	 * @since 2.0.0
586 586
 	 */
587 587
 	public function wp_head() {
588
-		wpinv_get_template( 'frontend-head.php' );
588
+		wpinv_get_template('frontend-head.php');
589 589
 	}
590 590
 
591 591
 	/**
592 592
 	 * Custom query vars.
593 593
 	 *
594 594
 	 */
595
-	public function custom_query_vars( $vars ) {
595
+	public function custom_query_vars($vars) {
596 596
         $vars[] = 'getpaid-ipn';
597 597
         return $vars;
598 598
 	}
@@ -603,28 +603,28 @@  discard block
 block discarded – undo
603 603
 	 */
604 604
 	public function add_rewrite_rule() {
605 605
         $tag = 'getpaid-ipn';
606
-        add_rewrite_tag( "%$tag%", '([^&]+)' );
607
-        add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]",'top' );
606
+        add_rewrite_tag("%$tag%", '([^&]+)');
607
+        add_rewrite_rule("^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top');
608 608
 	}
609 609
 
610 610
 	/**
611 611
 	 * Processes non-query string ipns.
612 612
 	 *
613 613
 	 */
614
-	public function maybe_process_new_ipn( $query ) {
614
+	public function maybe_process_new_ipn($query) {
615 615
 
616
-        if ( is_admin() || ! $query->is_main_query() ) {
616
+        if (is_admin() || !$query->is_main_query()) {
617 617
             return;
618 618
         }
619 619
 
620
-		$gateway = get_query_var( 'getpaid-ipn' );
620
+		$gateway = get_query_var('getpaid-ipn');
621 621
 
622
-        if ( ! empty( $gateway ) ){
622
+        if (!empty($gateway)) {
623 623
 
624
-			$gateway = sanitize_text_field( $gateway );
624
+			$gateway = sanitize_text_field($gateway);
625 625
 			nocache_headers();
626
-			do_action( 'wpinv_verify_payment_ipn', $gateway );
627
-			do_action( "wpinv_verify_{$gateway}_ipn" );
626
+			do_action('wpinv_verify_payment_ipn', $gateway);
627
+			do_action("wpinv_verify_{$gateway}_ipn");
628 628
 			exit;
629 629
 
630 630
         }
Please login to merge, or discard this patch.
includes/class-wpinv-ajax.php 1 patch
Spacing   +326 added lines, -326 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
  
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * WPInv_Ajax class.
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
 	 * Hook in ajax handlers.
18 18
 	 */
19 19
 	public static function init() {
20
-		add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
21
-		add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 );
20
+		add_action('init', array(__CLASS__, 'define_ajax'), 0);
21
+		add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0);
22 22
 		self::add_ajax_events();
23 23
     }
24 24
 
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	public static function define_ajax() {
29 29
 
30
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
31
-			getpaid_maybe_define_constant( 'DOING_AJAX', true );
32
-			getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true );
33
-			if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
34
-				/** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 );
30
+		if (!empty($_GET['wpinv-ajax'])) {
31
+			getpaid_maybe_define_constant('DOING_AJAX', true);
32
+			getpaid_maybe_define_constant('WPInv_DOING_AJAX', true);
33
+			if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) {
34
+				/** @scrutinizer ignore-unhandled */ @ini_set('display_errors', 0);
35 35
 			}
36 36
 			$GLOBALS['wpdb']->hide_errors();
37 37
 		}
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
 	 * @since 1.0.18
45 45
 	 */
46 46
 	private static function wpinv_ajax_headers() {
47
-		if ( ! headers_sent() ) {
47
+		if (!headers_sent()) {
48 48
 			send_origin_headers();
49 49
 			send_nosniff_header();
50 50
 			nocache_headers();
51
-			header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
52
-			header( 'X-Robots-Tag: noindex' );
53
-			status_header( 200 );
51
+			header('Content-Type: text/html; charset=' . get_option('blog_charset'));
52
+			header('X-Robots-Tag: noindex');
53
+			status_header(200);
54 54
 		}
55 55
     }
56 56
     
@@ -60,16 +60,16 @@  discard block
 block discarded – undo
60 60
 	public static function do_wpinv_ajax() {
61 61
 		global $wp_query;
62 62
 
63
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
64
-			$wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) );
63
+		if (!empty($_GET['wpinv-ajax'])) {
64
+			$wp_query->set('wpinv-ajax', sanitize_text_field(wp_unslash($_GET['wpinv-ajax'])));
65 65
 		}
66 66
 
67
-		$action = $wp_query->get( 'wpinv-ajax' );
67
+		$action = $wp_query->get('wpinv-ajax');
68 68
 
69
-		if ( $action ) {
69
+		if ($action) {
70 70
 			self::wpinv_ajax_headers();
71
-			$action = sanitize_text_field( $action );
72
-			do_action( 'wpinv_ajax_' . $action );
71
+			$action = sanitize_text_field($action);
72
+			do_action('wpinv_ajax_' . $action);
73 73
 			wp_die();
74 74
 		}
75 75
 
@@ -106,36 +106,36 @@  discard block
 block discarded – undo
106 106
             'file_upload'                 => true,
107 107
         );
108 108
 
109
-        foreach ( $ajax_events as $ajax_event => $nopriv ) {
110
-            add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
111
-            add_action( 'wp_ajax_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) );
109
+        foreach ($ajax_events as $ajax_event => $nopriv) {
110
+            add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
111
+            add_action('wp_ajax_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event));
112 112
 
113
-            if ( $nopriv ) {
114
-                add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
115
-                add_action( 'wp_ajax_nopriv_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) );
116
-                add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) );
113
+            if ($nopriv) {
114
+                add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
115
+                add_action('wp_ajax_nopriv_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event));
116
+                add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event));
117 117
             }
118 118
         }
119 119
     }
120 120
     
121 121
     public static function add_note() {
122
-        check_ajax_referer( 'add-invoice-note', '_nonce' );
122
+        check_ajax_referer('add-invoice-note', '_nonce');
123 123
 
124
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
124
+        if (!wpinv_current_user_can_manage_invoicing()) {
125 125
             die(-1);
126 126
         }
127 127
 
128
-        $post_id   = absint( $_POST['post_id'] );
129
-        $note      = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) );
130
-        $note_type = sanitize_text_field( $_POST['note_type'] );
128
+        $post_id   = absint($_POST['post_id']);
129
+        $note      = wp_kses_post(trim(stripslashes($_POST['note'])));
130
+        $note_type = sanitize_text_field($_POST['note_type']);
131 131
 
132 132
         $is_customer_note = $note_type == 'customer' ? 1 : 0;
133 133
 
134
-        if ( $post_id > 0 ) {
135
-            $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note );
134
+        if ($post_id > 0) {
135
+            $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note);
136 136
 
137
-            if ( $note_id > 0 && !is_wp_error( $note_id ) ) {
138
-                wpinv_get_invoice_note_line_item( $note_id );
137
+            if ($note_id > 0 && !is_wp_error($note_id)) {
138
+                wpinv_get_invoice_note_line_item($note_id);
139 139
             }
140 140
         }
141 141
 
@@ -143,16 +143,16 @@  discard block
 block discarded – undo
143 143
     }
144 144
 
145 145
     public static function delete_note() {
146
-        check_ajax_referer( 'delete-invoice-note', '_nonce' );
146
+        check_ajax_referer('delete-invoice-note', '_nonce');
147 147
 
148
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
148
+        if (!wpinv_current_user_can_manage_invoicing()) {
149 149
             die(-1);
150 150
         }
151 151
 
152
-        $note_id = (int)$_POST['note_id'];
152
+        $note_id = (int) $_POST['note_id'];
153 153
 
154
-        if ( $note_id > 0 ) {
155
-            wp_delete_comment( $note_id, true );
154
+        if ($note_id > 0) {
155
+            wp_delete_comment($note_id, true);
156 156
         }
157 157
 
158 158
         die();
@@ -170,34 +170,34 @@  discard block
 block discarded – undo
170 170
     public static function get_billing_details() {
171 171
 
172 172
         // Verify nonce.
173
-        check_ajax_referer( 'wpinv-nonce' );
173
+        check_ajax_referer('wpinv-nonce');
174 174
 
175 175
         // Can the user manage the plugin?
176
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
176
+        if (!wpinv_current_user_can_manage_invoicing()) {
177 177
             die(-1);
178 178
         }
179 179
 
180 180
         // Do we have a user id?
181 181
         $user_id = (int) $_GET['user_id'];
182 182
 
183
-        if ( empty( $user_id ) || ! is_numeric( $user_id ) ) {
183
+        if (empty($user_id) || !is_numeric($user_id)) {
184 184
             die(-1);
185 185
         }
186 186
 
187 187
         // Fetch the billing details.
188
-        $billing_details    = wpinv_get_user_address( $user_id );
189
-        $billing_details    = apply_filters( 'wpinv_ajax_billing_details', $billing_details, $user_id );
188
+        $billing_details    = wpinv_get_user_address($user_id);
189
+        $billing_details    = apply_filters('wpinv_ajax_billing_details', $billing_details, $user_id);
190 190
 
191 191
         // unset the user id and email.
192
-        $to_ignore = array( 'user_id', 'email' );
192
+        $to_ignore = array('user_id', 'email');
193 193
 
194
-        foreach ( $to_ignore as $key ) {
195
-            if ( isset( $billing_details[ $key ] ) ) {
196
-                unset( $billing_details[ $key ] );
194
+        foreach ($to_ignore as $key) {
195
+            if (isset($billing_details[$key])) {
196
+                unset($billing_details[$key]);
197 197
             }
198 198
         }
199 199
 
200
-        wp_send_json_success( $billing_details );
200
+        wp_send_json_success($billing_details);
201 201
 
202 202
     }
203 203
 
@@ -207,47 +207,47 @@  discard block
 block discarded – undo
207 207
     public static function check_new_user_email() {
208 208
 
209 209
         // Verify nonce.
210
-        check_ajax_referer( 'wpinv-nonce' );
210
+        check_ajax_referer('wpinv-nonce');
211 211
 
212 212
         // Can the user manage the plugin?
213
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
213
+        if (!wpinv_current_user_can_manage_invoicing()) {
214 214
             die(-1);
215 215
         }
216 216
 
217 217
         // We need an email address.
218
-        if ( empty( $_GET['email'] ) ) {
219
-            _e( "Provide the new user's email address", 'invoicing' );
218
+        if (empty($_GET['email'])) {
219
+            _e("Provide the new user's email address", 'invoicing');
220 220
             exit;
221 221
         }
222 222
 
223 223
         // Ensure the email is valid.
224
-        $email = sanitize_email( $_GET['email'] );
225
-        if ( ! is_email( $email ) ) {
226
-            _e( 'Invalid email address', 'invoicing' );
224
+        $email = sanitize_email($_GET['email']);
225
+        if (!is_email($email)) {
226
+            _e('Invalid email address', 'invoicing');
227 227
             exit;
228 228
         }
229 229
 
230 230
         // And it does not exist.
231
-        $id = email_exists( $email );
232
-        if ( $id ) {
233
-            wp_send_json_success( compact( 'id' ) );
231
+        $id = email_exists($email);
232
+        if ($id) {
233
+            wp_send_json_success(compact('id'));
234 234
         }
235 235
 
236
-        wp_send_json_success( true );
236
+        wp_send_json_success(true);
237 237
     }
238 238
     
239 239
     public static function run_tool() {
240
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
241
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
240
+        check_ajax_referer('wpinv-nonce', '_nonce');
241
+        if (!wpinv_current_user_can_manage_invoicing()) {
242 242
             die(-1);
243 243
         }
244 244
         
245
-        $tool = sanitize_text_field( $_POST['tool'] );
245
+        $tool = sanitize_text_field($_POST['tool']);
246 246
         
247
-        do_action( 'wpinv_run_tool' );
247
+        do_action('wpinv_run_tool');
248 248
         
249
-        if ( !empty( $tool ) ) {
250
-            do_action( 'wpinv_tool_' . $tool );
249
+        if (!empty($tool)) {
250
+            do_action('wpinv_tool_' . $tool);
251 251
         }
252 252
     }
253 253
 
@@ -258,43 +258,43 @@  discard block
 block discarded – undo
258 258
         global $getpaid_force_checkbox;
259 259
 
260 260
         // Check nonce.
261
-        check_ajax_referer( 'getpaid_form_nonce' );
261
+        check_ajax_referer('getpaid_form_nonce');
262 262
 
263 263
         // Is the request set up correctly?
264
-		if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) && empty( $_GET['invoice'] ) ) {
264
+		if (empty($_GET['form']) && empty($_GET['item']) && empty($_GET['invoice'])) {
265 265
 			echo aui()->alert(
266 266
 				array(
267 267
 					'type'    => 'warning',
268
-					'content' => __( 'No payment form or item provided', 'invoicing' ),
268
+					'content' => __('No payment form or item provided', 'invoicing'),
269 269
 				)
270 270
             );
271 271
             exit;
272 272
         }
273 273
 
274 274
         // Payment form or button?
275
-		if ( ! empty( $_GET['form'] ) ) {
276
-            $form = sanitize_text_field( urldecode( $_GET['form'] ) );
275
+		if (!empty($_GET['form'])) {
276
+            $form = sanitize_text_field(urldecode($_GET['form']));
277 277
 
278
-            if ( false !== strpos( $form, '|' ) ) {
279
-                $form_pos = strpos( $form, '|' );
280
-                $_items   = getpaid_convert_items_to_array( substr( $form, $form_pos + 1 ) );
281
-                $form     = substr( $form, 0, $form_pos );
278
+            if (false !== strpos($form, '|')) {
279
+                $form_pos = strpos($form, '|');
280
+                $_items   = getpaid_convert_items_to_array(substr($form, $form_pos + 1));
281
+                $form     = substr($form, 0, $form_pos);
282 282
 
283 283
                 // Retrieve appropriate payment form.
284
-                $payment_form = new GetPaid_Payment_Form( $form );
285
-                $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
284
+                $payment_form = new GetPaid_Payment_Form($form);
285
+                $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form(wpinv_get_default_payment_form());
286 286
 
287 287
                 $items    = array();
288 288
                 $item_ids = array();
289 289
 
290
-                foreach ( $_items as $item_id => $qty ) {
291
-                    if ( ! in_array( $item_id, $item_ids ) ) {
292
-                        $item = new GetPaid_Form_Item( $item_id );
293
-                        $item->set_quantity( $qty );
290
+                foreach ($_items as $item_id => $qty) {
291
+                    if (!in_array($item_id, $item_ids)) {
292
+                        $item = new GetPaid_Form_Item($item_id);
293
+                        $item->set_quantity($qty);
294 294
 
295
-                        if ( 0 == $qty ) {
296
-                            $item->set_allow_quantities( true );
297
-                            $item->set_is_required( false );
295
+                        if (0 == $qty) {
296
+                            $item->set_allow_quantities(true);
297
+                            $item->set_is_required(false);
298 298
                             $getpaid_force_checkbox = true;
299 299
                         }
300 300
 
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
                     }
304 304
                 }
305 305
 
306
-                if ( ! $payment_form->is_default() ) {
306
+                if (!$payment_form->is_default()) {
307 307
 
308
-                    foreach ( $payment_form->get_items() as $item ) {
309
-                        if ( ! in_array( $item->get_id(), $item_ids ) ) {
308
+                    foreach ($payment_form->get_items() as $item) {
309
+                        if (!in_array($item->get_id(), $item_ids)) {
310 310
                             $item_ids[] = $item->get_id();
311 311
                             $items[]    = $item;
312 312
                         }
@@ -314,23 +314,23 @@  discard block
 block discarded – undo
314 314
 
315 315
                 }
316 316
 
317
-                $payment_form->set_items( $items );
318
-                $extra_items     = esc_attr( getpaid_convert_items_to_string( $_items ) );
319
-                $extra_items_key = md5( NONCE_KEY . AUTH_KEY . $extra_items );
317
+                $payment_form->set_items($items);
318
+                $extra_items     = esc_attr(getpaid_convert_items_to_string($_items));
319
+                $extra_items_key = md5(NONCE_KEY . AUTH_KEY . $extra_items);
320 320
                 $extra_items     = "<input type='hidden' name='getpaid-form-items' value='$extra_items' />";
321 321
                 $extra_items    .= "<input type='hidden' name='getpaid-form-items-key' value='$extra_items_key' />";
322
-                $payment_form->display( $extra_items );
322
+                $payment_form->display($extra_items);
323 323
                 $getpaid_force_checkbox = false;
324 324
 
325 325
             } else {
326
-                getpaid_display_payment_form( $form );
326
+                getpaid_display_payment_form($form);
327 327
             }
328 328
 
329
-		} else if( ! empty( $_GET['invoice'] ) ) {
330
-		    getpaid_display_invoice_payment_form( (int) urldecode( $_GET['invoice'] ) );
329
+		} else if (!empty($_GET['invoice'])) {
330
+		    getpaid_display_invoice_payment_form((int) urldecode($_GET['invoice']));
331 331
         } else {
332
-			$items = getpaid_convert_items_to_array( sanitize_text_field( urldecode( $_GET['item'] ) ) );
333
-		    getpaid_display_item_payment_form( $items );
332
+			$items = getpaid_convert_items_to_array(sanitize_text_field(urldecode($_GET['item'])));
333
+		    getpaid_display_item_payment_form($items);
334 334
         }
335 335
 
336 336
         exit;
@@ -345,17 +345,17 @@  discard block
 block discarded – undo
345 345
     public static function payment_form() {
346 346
 
347 347
         // Check nonce.
348
-        check_ajax_referer( 'getpaid_form_nonce' );
348
+        check_ajax_referer('getpaid_form_nonce');
349 349
 
350 350
         // ... form fields...
351
-        if ( empty( $_POST['getpaid_payment_form_submission'] ) ) {
352
-            _e( 'Error: Reload the page and try again.', 'invoicing' );
351
+        if (empty($_POST['getpaid_payment_form_submission'])) {
352
+            _e('Error: Reload the page and try again.', 'invoicing');
353 353
             exit;
354 354
         }
355 355
 
356 356
         // Process the payment form.
357
-        $checkout_class = apply_filters( 'getpaid_checkout_class', 'GetPaid_Checkout' );
358
-        $checkout       = new $checkout_class( new GetPaid_Payment_Form_Submission() );
357
+        $checkout_class = apply_filters('getpaid_checkout_class', 'GetPaid_Checkout');
358
+        $checkout       = new $checkout_class(new GetPaid_Payment_Form_Submission());
359 359
         $checkout->process_checkout();
360 360
 
361 361
         exit;
@@ -368,55 +368,55 @@  discard block
 block discarded – undo
368 368
      */
369 369
     public static function get_payment_form_states_field() {
370 370
 
371
-        if ( empty( $_GET['country'] ) || empty( $_GET['form'] ) ) {
371
+        if (empty($_GET['country']) || empty($_GET['form'])) {
372 372
             exit;
373 373
         }
374 374
 
375
-        $elements = getpaid_get_payment_form_elements( (int) $_GET['form'] );
375
+        $elements = getpaid_get_payment_form_elements((int) $_GET['form']);
376 376
 
377
-        if ( empty( $elements ) ) {
377
+        if (empty($elements)) {
378 378
             exit;
379 379
         }
380 380
 
381 381
         $address_fields = array();
382
-        foreach ( $elements as $element ) {
383
-            if ( 'address' === $element['type'] ) {
382
+        foreach ($elements as $element) {
383
+            if ('address' === $element['type']) {
384 384
                 $address_fields = $element;
385 385
                 break;
386 386
             }
387 387
         }
388 388
 
389
-        if ( empty( $address_fields ) ) {
389
+        if (empty($address_fields)) {
390 390
             exit;
391 391
         }
392 392
 
393
-        foreach ( $address_fields['fields'] as $address_field ) {
393
+        foreach ($address_fields['fields'] as $address_field) {
394 394
 
395
-            if ( 'wpinv_state' == $address_field['name'] ) {
395
+            if ('wpinv_state' == $address_field['name']) {
396 396
 
397
-                $wrap_class  = getpaid_get_form_element_grid_class( $address_field );
398
-                $wrap_class  = esc_attr( "$wrap_class getpaid-address-field-wrapper" );
399
-                $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] );
400
-                $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] );
401
-                $value       = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_wpinv_state', true ) : '';
402
-                $label       = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] );
397
+                $wrap_class  = getpaid_get_form_element_grid_class($address_field);
398
+                $wrap_class  = esc_attr("$wrap_class getpaid-address-field-wrapper");
399
+                $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']);
400
+                $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']);
401
+                $value       = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_wpinv_state', true) : '';
402
+                $label       = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']);
403 403
 
404
-                if ( ! empty( $address_field['required'] ) ) {
404
+                if (!empty($address_field['required'])) {
405 405
                     $label .= "<span class='text-danger'> *</span>";
406 406
                 }
407 407
 
408
-                $html = getpaid_get_states_select_markup (
409
-                    sanitize_text_field( $_GET['country'] ),
408
+                $html = getpaid_get_states_select_markup(
409
+                    sanitize_text_field($_GET['country']),
410 410
                     $value,
411 411
                     $placeholder,
412 412
                     $label,
413 413
                     $description,
414
-                    ! empty( $address_field['required'] ),
414
+                    !empty($address_field['required']),
415 415
                     $wrap_class,
416
-                    sanitize_text_field( $_GET['name'] )
416
+                    sanitize_text_field($_GET['name'])
417 417
                 );
418 418
 
419
-                wp_send_json_success( $html );
419
+                wp_send_json_success($html);
420 420
                 exit;
421 421
 
422 422
             }
@@ -432,66 +432,66 @@  discard block
 block discarded – undo
432 432
     public static function recalculate_invoice_totals() {
433 433
 
434 434
         // Verify nonce.
435
-        check_ajax_referer( 'wpinv-nonce' );
435
+        check_ajax_referer('wpinv-nonce');
436 436
 
437
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
437
+        if (!wpinv_current_user_can_manage_invoicing()) {
438 438
             exit;
439 439
         }
440 440
 
441 441
         // We need an invoice.
442
-        if ( empty( $_POST['post_id'] ) ) {
442
+        if (empty($_POST['post_id'])) {
443 443
             exit;
444 444
         }
445 445
 
446 446
         // Fetch the invoice.
447
-        $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) );
447
+        $invoice = new WPInv_Invoice(intval($_POST['post_id']));
448 448
 
449 449
         // Ensure it exists.
450
-        if ( ! $invoice->get_id() ) {
450
+        if (!$invoice->get_id()) {
451 451
             exit;
452 452
         }
453 453
 
454 454
         // Maybe set the country, state, currency.
455
-        foreach ( array( 'country', 'state', 'currency', 'vat_number', 'discount_code' ) as $key ) {
456
-            if ( isset( $_POST[ $key ] ) ) {
455
+        foreach (array('country', 'state', 'currency', 'vat_number', 'discount_code') as $key) {
456
+            if (isset($_POST[$key])) {
457 457
                 $method = "set_$key";
458
-                $invoice->$method( sanitize_text_field( $_POST[ $key ] ) );
458
+                $invoice->$method(sanitize_text_field($_POST[$key]));
459 459
             }
460 460
         }
461 461
 
462 462
         // Maybe disable taxes.
463
-        $invoice->set_disable_taxes( ! empty( $_POST['taxes'] ) );
463
+        $invoice->set_disable_taxes(!empty($_POST['taxes']));
464 464
 
465 465
         // Discount code.
466
-        if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
467
-            $discount = new WPInv_Discount( $invoice->get_discount_code() );
468
-            if ( $discount->exists() ) {
469
-                $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
466
+        if (!$invoice->is_paid() && !$invoice->is_refunded()) {
467
+            $discount = new WPInv_Discount($invoice->get_discount_code());
468
+            if ($discount->exists()) {
469
+                $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
470 470
             } else {
471
-                $invoice->remove_discount( 'discount_code' );
471
+                $invoice->remove_discount('discount_code');
472 472
             }
473 473
         }
474 474
 
475 475
         // Recalculate totals.
476 476
         $invoice->recalculate_total();
477 477
 
478
-        $total        = wpinv_price( $invoice->get_total(), $invoice->get_currency() );
479
-        $suscriptions = getpaid_get_invoice_subscriptions( $invoice );
480
-        if ( is_a( $suscriptions, 'WPInv_Subscription' ) && $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total() ) {
481
-            $recurring_total = wpinv_price( $invoice->get_recurring_total(), $invoice->get_currency() );
482
-            $total          .= '<small class="form-text text-muted">' . sprintf( __( 'Recurring Price: %s', 'invoicing' ), $recurring_total ) . '</small>';
478
+        $total        = wpinv_price($invoice->get_total(), $invoice->get_currency());
479
+        $suscriptions = getpaid_get_invoice_subscriptions($invoice);
480
+        if (is_a($suscriptions, 'WPInv_Subscription') && $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total()) {
481
+            $recurring_total = wpinv_price($invoice->get_recurring_total(), $invoice->get_currency());
482
+            $total          .= '<small class="form-text text-muted">' . sprintf(__('Recurring Price: %s', 'invoicing'), $recurring_total) . '</small>';
483 483
         }
484 484
 
485 485
         $totals = array(
486
-            'subtotal' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ),
487
-            'discount' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ),
488
-            'tax'      => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ),
486
+            'subtotal' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()),
487
+            'discount' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()),
488
+            'tax'      => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()),
489 489
             'total'    => $total,
490 490
         );
491 491
 
492
-        $totals = apply_filters( 'getpaid_invoice_totals', $totals, $invoice );
492
+        $totals = apply_filters('getpaid_invoice_totals', $totals, $invoice);
493 493
 
494
-        wp_send_json_success( compact( 'totals' ) );
494
+        wp_send_json_success(compact('totals'));
495 495
     }
496 496
 
497 497
     /**
@@ -500,33 +500,33 @@  discard block
 block discarded – undo
500 500
     public static function get_invoice_items() {
501 501
 
502 502
         // Verify nonce.
503
-        check_ajax_referer( 'wpinv-nonce' );
503
+        check_ajax_referer('wpinv-nonce');
504 504
 
505
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
505
+        if (!wpinv_current_user_can_manage_invoicing()) {
506 506
             exit;
507 507
         }
508 508
 
509 509
         // We need an invoice and items.
510
-        if ( empty( $_POST['post_id'] ) ) {
510
+        if (empty($_POST['post_id'])) {
511 511
             exit;
512 512
         }
513 513
 
514 514
         // Fetch the invoice.
515
-        $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) );
515
+        $invoice = new WPInv_Invoice(intval($_POST['post_id']));
516 516
 
517 517
         // Ensure it exists.
518
-        if ( ! $invoice->get_id() ) {
518
+        if (!$invoice->get_id()) {
519 519
             exit;
520 520
         }
521 521
 
522 522
         // Return an array of invoice items.
523 523
         $items = array();
524 524
 
525
-        foreach ( $invoice->get_items() as $item ) {
526
-            $items[] = $item->prepare_data_for_invoice_edit_ajax(  $invoice->get_currency(), $invoice->is_renewal()  );
525
+        foreach ($invoice->get_items() as $item) {
526
+            $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency(), $invoice->is_renewal());
527 527
         }
528 528
 
529
-        wp_send_json_success( compact( 'items' ) );
529
+        wp_send_json_success(compact('items'));
530 530
     }
531 531
 
532 532
     /**
@@ -535,50 +535,50 @@  discard block
 block discarded – undo
535 535
     public static function edit_invoice_item() {
536 536
 
537 537
         // Verify nonce.
538
-        check_ajax_referer( 'wpinv-nonce' );
538
+        check_ajax_referer('wpinv-nonce');
539 539
 
540
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
540
+        if (!wpinv_current_user_can_manage_invoicing()) {
541 541
             exit;
542 542
         }
543 543
 
544 544
         // We need an invoice and item details.
545
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['data'] ) ) {
545
+        if (empty($_POST['post_id']) || empty($_POST['data'])) {
546 546
             exit;
547 547
         }
548 548
 
549 549
         // Fetch the invoice.
550
-        $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) );
550
+        $invoice = new WPInv_Invoice(intval($_POST['post_id']));
551 551
 
552 552
         // Ensure it exists and its not been paid for.
553
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
553
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
554 554
             exit;
555 555
         }
556 556
 
557 557
         // Format the data.
558
-        $data = wp_kses_post_deep( wp_unslash( wp_list_pluck( $_POST['data'], 'value', 'field' ) ) );
558
+        $data = wp_kses_post_deep(wp_unslash(wp_list_pluck($_POST['data'], 'value', 'field')));
559 559
 
560 560
         // Ensure that we have an item id.
561
-        if ( empty( $data['id'] ) ) {
561
+        if (empty($data['id'])) {
562 562
             exit;
563 563
         }
564 564
 
565 565
         // Abort if the invoice does not have the specified item.
566
-        $item = $invoice->get_item( (int) $data['id'] );
566
+        $item = $invoice->get_item((int) $data['id']);
567 567
 
568
-        if ( empty( $item ) ) {
568
+        if (empty($item)) {
569 569
             exit;
570 570
         }
571 571
 
572 572
         // Update the item.
573
-        $item->set_price( getpaid_standardize_amount( $data['price'] ) );
574
-        $item->set_name( sanitize_text_field( $data['name'] ) );
575
-        $item->set_description( wp_kses_post( $data['description'] ) );
576
-        $item->set_quantity( floatval( $data['quantity'] ) );
573
+        $item->set_price(getpaid_standardize_amount($data['price']));
574
+        $item->set_name(sanitize_text_field($data['name']));
575
+        $item->set_description(wp_kses_post($data['description']));
576
+        $item->set_quantity(floatval($data['quantity']));
577 577
 
578 578
         // Add it to the invoice.
579
-        $error = $invoice->add_item( $item );
579
+        $error = $invoice->add_item($item);
580 580
         $alert = false;
581
-        if ( is_wp_error( $error ) ) {
581
+        if (is_wp_error($error)) {
582 582
             $alert = $error->get_error_message();
583 583
         }
584 584
 
@@ -591,11 +591,11 @@  discard block
 block discarded – undo
591 591
         // Return an array of invoice items.
592 592
         $items = array();
593 593
 
594
-        foreach ( $invoice->get_items() as $item ) {
595
-            $items[] = $item->prepare_data_for_invoice_edit_ajax(  $invoice->get_currency()  );
594
+        foreach ($invoice->get_items() as $item) {
595
+            $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
596 596
         }
597 597
 
598
-        wp_send_json_success( compact( 'items', 'alert' ) );
598
+        wp_send_json_success(compact('items', 'alert'));
599 599
     }
600 600
 
601 601
     /**
@@ -604,53 +604,53 @@  discard block
 block discarded – undo
604 604
     public static function create_invoice_item() {
605 605
 
606 606
         // Verify nonce.
607
-        check_ajax_referer( 'wpinv-nonce' );
607
+        check_ajax_referer('wpinv-nonce');
608 608
 
609
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
609
+        if (!wpinv_current_user_can_manage_invoicing()) {
610 610
             exit;
611 611
         }
612 612
 
613 613
         // We need an invoice and item details.
614
-        if ( empty( $_POST['invoice_id'] ) || empty( $_POST['_wpinv_quick'] ) ) {
614
+        if (empty($_POST['invoice_id']) || empty($_POST['_wpinv_quick'])) {
615 615
             exit;
616 616
         }
617 617
 
618 618
         // Fetch the invoice.
619
-        $invoice = new WPInv_Invoice( intval( $_POST['invoice_id'] ) );
619
+        $invoice = new WPInv_Invoice(intval($_POST['invoice_id']));
620 620
 
621 621
         // Ensure it exists and its not been paid for.
622
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
622
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
623 623
             exit;
624 624
         }
625 625
 
626 626
         // Format the data.
627
-        $data = wp_kses_post_deep( wp_unslash( $_POST['_wpinv_quick'] ) );
627
+        $data = wp_kses_post_deep(wp_unslash($_POST['_wpinv_quick']));
628 628
 
629 629
         $item = new WPInv_Item();
630
-        $item->set_price( getpaid_standardize_amount( $data['price'] ) );
631
-        $item->set_name( sanitize_text_field( $data['name'] ) );
632
-        $item->set_description( wp_kses_post( $data['description'] ) );
633
-        $item->set_type( sanitize_text_field( $data['type'] ) );
634
-        $item->set_vat_rule( sanitize_text_field( $data['vat_rule'] ) );
635
-        $item->set_vat_class( sanitize_text_field( $data['vat_class'] ) );
636
-        $item->set_status( 'publish' );
630
+        $item->set_price(getpaid_standardize_amount($data['price']));
631
+        $item->set_name(sanitize_text_field($data['name']));
632
+        $item->set_description(wp_kses_post($data['description']));
633
+        $item->set_type(sanitize_text_field($data['type']));
634
+        $item->set_vat_rule(sanitize_text_field($data['vat_rule']));
635
+        $item->set_vat_class(sanitize_text_field($data['vat_class']));
636
+        $item->set_status('publish');
637 637
         $item->save();
638 638
 
639
-        if ( ! $item->exists() ) {
640
-            $alert = __( 'Could not create invoice item. Please try again.', 'invoicing' );
641
-            wp_send_json_success( compact( 'alert' ) );
639
+        if (!$item->exists()) {
640
+            $alert = __('Could not create invoice item. Please try again.', 'invoicing');
641
+            wp_send_json_success(compact('alert'));
642 642
         }
643 643
 
644
-        $item = new GetPaid_Form_Item( $item->get_id() );
645
-        $item->set_quantity( floatval( $data['qty'] ) );
644
+        $item = new GetPaid_Form_Item($item->get_id());
645
+        $item->set_quantity(floatval($data['qty']));
646 646
 
647 647
         // Add it to the invoice.
648
-        $error = $invoice->add_item( $item );
648
+        $error = $invoice->add_item($item);
649 649
         $alert = false;
650 650
 
651
-        if ( is_wp_error( $error ) ) {
651
+        if (is_wp_error($error)) {
652 652
             $alert = $error->get_error_message();
653
-            wp_send_json_success( compact( 'alert' ) );
653
+            wp_send_json_success(compact('alert'));
654 654
          }
655 655
 
656 656
         // Update totals.
@@ -663,9 +663,9 @@  discard block
 block discarded – undo
663 663
         $invoice->recalculate_total();
664 664
         $invoice->save();
665 665
         ob_start();
666
-        GetPaid_Meta_Box_Invoice_Items::output_row( GetPaid_Meta_Box_Invoice_Items::get_columns( $invoice ), $item, $invoice );
666
+        GetPaid_Meta_Box_Invoice_Items::output_row(GetPaid_Meta_Box_Invoice_Items::get_columns($invoice), $item, $invoice);
667 667
         $row = ob_get_clean();
668
-        wp_send_json_success( compact( 'row' ) );
668
+        wp_send_json_success(compact('row'));
669 669
     }
670 670
 
671 671
     /**
@@ -674,33 +674,33 @@  discard block
 block discarded – undo
674 674
     public static function remove_invoice_item() {
675 675
 
676 676
         // Verify nonce.
677
-        check_ajax_referer( 'wpinv-nonce' );
677
+        check_ajax_referer('wpinv-nonce');
678 678
 
679
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
679
+        if (!wpinv_current_user_can_manage_invoicing()) {
680 680
             exit;
681 681
         }
682 682
 
683 683
         // We need an invoice and an item.
684
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) {
684
+        if (empty($_POST['post_id']) || empty($_POST['item_id'])) {
685 685
             exit;
686 686
         }
687 687
 
688 688
         // Fetch the invoice.
689
-        $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) );
689
+        $invoice = new WPInv_Invoice(intval($_POST['post_id']));
690 690
 
691 691
         // Ensure it exists and its not been paid for.
692
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
692
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
693 693
             exit;
694 694
         }
695 695
 
696 696
         // Abort if the invoice does not have the specified item.
697
-        $item = $invoice->get_item( (int) $_POST['item_id'] );
697
+        $item = $invoice->get_item((int) $_POST['item_id']);
698 698
 
699
-        if ( empty( $item ) ) {
699
+        if (empty($item)) {
700 700
             exit;
701 701
         }
702 702
 
703
-        $invoice->remove_item( (int) $_POST['item_id'] );
703
+        $invoice->remove_item((int) $_POST['item_id']);
704 704
 
705 705
         // Update totals.
706 706
         $invoice->recalculate_total();
@@ -711,11 +711,11 @@  discard block
 block discarded – undo
711 711
         // Return an array of invoice items.
712 712
         $items = array();
713 713
 
714
-        foreach ( $invoice->get_items() as $item ) {
715
-            $items[] = $item->prepare_data_for_invoice_edit_ajax(  $invoice->get_currency()  );
714
+        foreach ($invoice->get_items() as $item) {
715
+            $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
716 716
         }
717 717
 
718
-        wp_send_json_success( compact( 'items' ) );
718
+        wp_send_json_success(compact('items'));
719 719
     }
720 720
 
721 721
     /**
@@ -724,69 +724,69 @@  discard block
 block discarded – undo
724 724
     public static function recalculate_full_prices() {
725 725
 
726 726
         // Verify nonce.
727
-        check_ajax_referer( 'wpinv-nonce' );
727
+        check_ajax_referer('wpinv-nonce');
728 728
 
729
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
729
+        if (!wpinv_current_user_can_manage_invoicing()) {
730 730
             exit;
731 731
         }
732 732
 
733 733
         // We need an invoice and item.
734
-        if ( empty( $_POST['post_id'] ) ) {
734
+        if (empty($_POST['post_id'])) {
735 735
             exit;
736 736
         }
737 737
 
738 738
         // Fetch the invoice.
739
-        $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) );
739
+        $invoice = new WPInv_Invoice(intval($_POST['post_id']));
740 740
         $alert   = false;
741 741
 
742 742
         // Ensure it exists and its not been paid for.
743
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
743
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
744 744
             exit;
745 745
         }
746 746
 
747
-        $invoice->set_items( array() );
747
+        $invoice->set_items(array());
748 748
 
749
-        if ( ! empty( $_POST['getpaid_items'] ) ) {
749
+        if (!empty($_POST['getpaid_items'])) {
750 750
 
751
-            foreach ( wp_kses_post_deep( $_POST['getpaid_items'] ) as $item_id => $args ) {
752
-                $item = new GetPaid_Form_Item( $item_id );
751
+            foreach (wp_kses_post_deep($_POST['getpaid_items']) as $item_id => $args) {
752
+                $item = new GetPaid_Form_Item($item_id);
753 753
 
754
-                if ( $item->exists() ) {
755
-                    $item->set_price( getpaid_standardize_amount( $args['price'] ) );
756
-                    $item->set_quantity( floatval( $args['quantity'] ) );
757
-                    $item->set_name( sanitize_text_field( $args['name'] ) );
758
-                    $item->set_description( wp_kses_post( $args['description'] ) );
759
-                    $invoice->add_item( $item );
754
+                if ($item->exists()) {
755
+                    $item->set_price(getpaid_standardize_amount($args['price']));
756
+                    $item->set_quantity(floatval($args['quantity']));
757
+                    $item->set_name(sanitize_text_field($args['name']));
758
+                    $item->set_description(wp_kses_post($args['description']));
759
+                    $invoice->add_item($item);
760 760
                 }
761 761
             }
762 762
 
763 763
         }
764 764
 
765
-        $invoice->set_disable_taxes( ! empty( $_POST['disable_taxes'] ) );
765
+        $invoice->set_disable_taxes(!empty($_POST['disable_taxes']));
766 766
 
767 767
         // Maybe set the country, state, currency.
768
-        foreach ( array( 'wpinv_country', 'wpinv_state', 'wpinv_currency', 'wpinv_vat_number', 'wpinv_discount_code' ) as $key ) {
769
-            if ( isset( $_POST[ $key ] ) ) {
770
-                $_key   = str_replace( 'wpinv_', '', $key );
768
+        foreach (array('wpinv_country', 'wpinv_state', 'wpinv_currency', 'wpinv_vat_number', 'wpinv_discount_code') as $key) {
769
+            if (isset($_POST[$key])) {
770
+                $_key   = str_replace('wpinv_', '', $key);
771 771
                 $method = "set_$_key";
772
-                $invoice->$method( sanitize_text_field( $_POST[ $key ] ) );
772
+                $invoice->$method(sanitize_text_field($_POST[$key]));
773 773
             }
774 774
         }
775 775
 
776
-        $discount = new WPInv_Discount( $invoice->get_discount_code() );
777
-        if ( $discount->exists() ) {
778
-            $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
776
+        $discount = new WPInv_Discount($invoice->get_discount_code());
777
+        if ($discount->exists()) {
778
+            $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
779 779
         } else {
780
-            $invoice->remove_discount( 'discount_code' );
780
+            $invoice->remove_discount('discount_code');
781 781
         }
782 782
 
783 783
         // Save the invoice.
784 784
         $invoice->recalculate_total();
785 785
         $invoice->save();
786 786
         ob_start();
787
-        GetPaid_Meta_Box_Invoice_Items::output( get_post( $invoice->get_id() ), $invoice );
787
+        GetPaid_Meta_Box_Invoice_Items::output(get_post($invoice->get_id()), $invoice);
788 788
         $table = ob_get_clean();
789
-        wp_send_json_success( compact( 'table' ) );
789
+        wp_send_json_success(compact('table'));
790 790
     }
791 791
 
792 792
     /**
@@ -795,42 +795,42 @@  discard block
 block discarded – undo
795 795
     public static function admin_add_invoice_item() {
796 796
 
797 797
         // Verify nonce.
798
-        check_ajax_referer( 'wpinv-nonce' );
798
+        check_ajax_referer('wpinv-nonce');
799 799
 
800
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
800
+        if (!wpinv_current_user_can_manage_invoicing()) {
801 801
             exit;
802 802
         }
803 803
 
804 804
         // We need an invoice and item.
805
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) {
805
+        if (empty($_POST['post_id']) || empty($_POST['item_id'])) {
806 806
             exit;
807 807
         }
808 808
 
809 809
         // Fetch the invoice.
810
-        $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) );
810
+        $invoice = new WPInv_Invoice(intval($_POST['post_id']));
811 811
         $alert   = false;
812 812
 
813 813
         // Ensure it exists and its not been paid for.
814
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
814
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
815 815
             exit;
816 816
         }
817 817
 
818 818
         // Add the item.
819
-        $item  = new GetPaid_Form_Item( (int) $_POST['item_id'] );
820
-        $error = $invoice->add_item( $item );
819
+        $item  = new GetPaid_Form_Item((int) $_POST['item_id']);
820
+        $error = $invoice->add_item($item);
821 821
 
822
-        if ( is_wp_error( $error ) ) {
822
+        if (is_wp_error($error)) {
823 823
             $alert = $error->get_error_message();
824
-            wp_send_json_success( compact( 'alert' ) );
824
+            wp_send_json_success(compact('alert'));
825 825
         }
826 826
 
827 827
         // Save the invoice.
828 828
         $invoice->recalculate_total();
829 829
         $invoice->save();
830 830
         ob_start();
831
-        GetPaid_Meta_Box_Invoice_Items::output_row( GetPaid_Meta_Box_Invoice_Items::get_columns( $invoice ), $item, $invoice );
831
+        GetPaid_Meta_Box_Invoice_Items::output_row(GetPaid_Meta_Box_Invoice_Items::get_columns($invoice), $item, $invoice);
832 832
         $row = ob_get_clean();
833
-        wp_send_json_success( compact( 'row' ) );
833
+        wp_send_json_success(compact('row'));
834 834
     }
835 835
 
836 836
     /**
@@ -839,39 +839,39 @@  discard block
 block discarded – undo
839 839
     public static function add_invoice_items() {
840 840
 
841 841
         // Verify nonce.
842
-        check_ajax_referer( 'wpinv-nonce' );
842
+        check_ajax_referer('wpinv-nonce');
843 843
 
844
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
844
+        if (!wpinv_current_user_can_manage_invoicing()) {
845 845
             exit;
846 846
         }
847 847
 
848 848
         // We need an invoice and items.
849
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['items'] ) ) {
849
+        if (empty($_POST['post_id']) || empty($_POST['items'])) {
850 850
             exit;
851 851
         }
852 852
 
853 853
         // Fetch the invoice.
854
-        $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) );
854
+        $invoice = new WPInv_Invoice(intval($_POST['post_id']));
855 855
         $alert   = false;
856 856
 
857 857
         // Ensure it exists and its not been paid for.
858
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
858
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
859 859
             exit;
860 860
         }
861 861
 
862 862
         // Add the items.
863
-        foreach ( wp_kses_post_deep( wp_unslash( $_POST['items'] ) ) as $data ) {
863
+        foreach (wp_kses_post_deep(wp_unslash($_POST['items'])) as $data) {
864 864
 
865
-            $item = new GetPaid_Form_Item( (int) $data[ 'id' ] );
865
+            $item = new GetPaid_Form_Item((int) $data['id']);
866 866
 
867
-            if ( is_numeric( $data[ 'qty' ] ) && (float) $data[ 'qty' ] > 0 ) {
868
-                $item->set_quantity( floatval( $data[ 'qty' ] ) );
867
+            if (is_numeric($data['qty']) && (float) $data['qty'] > 0) {
868
+                $item->set_quantity(floatval($data['qty']));
869 869
             }
870 870
 
871
-            if ( $item->get_id() > 0 ) {
872
-                $error = $invoice->add_item( $item );
871
+            if ($item->get_id() > 0) {
872
+                $error = $invoice->add_item($item);
873 873
 
874
-                if ( is_wp_error( $error ) ) {
874
+                if (is_wp_error($error)) {
875 875
                     $alert = $error->get_error_message();
876 876
                 }
877 877
 
@@ -886,11 +886,11 @@  discard block
 block discarded – undo
886 886
         // Return an array of invoice items.
887 887
         $items = array();
888 888
 
889
-        foreach ( $invoice->get_items() as $item ) {
890
-            $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() );
889
+        foreach ($invoice->get_items() as $item) {
890
+            $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
891 891
         }
892 892
 
893
-        wp_send_json_success( compact( 'items', 'alert' ) );
893
+        wp_send_json_success(compact('items', 'alert'));
894 894
     }
895 895
 
896 896
     /**
@@ -899,15 +899,15 @@  discard block
 block discarded – undo
899 899
     public static function get_invoicing_items() {
900 900
 
901 901
         // Verify nonce.
902
-        check_ajax_referer( 'wpinv-nonce' );
902
+        check_ajax_referer('wpinv-nonce');
903 903
 
904
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
904
+        if (!wpinv_current_user_can_manage_invoicing()) {
905 905
             exit;
906 906
         }
907 907
 
908 908
         // We need a search term.
909
-        if ( empty( $_GET['search'] ) ) {
910
-            wp_send_json_success( array() );
909
+        if (empty($_GET['search'])) {
910
+            wp_send_json_success(array());
911 911
         }
912 912
 
913 913
         // Retrieve items.
@@ -916,8 +916,8 @@  discard block
 block discarded – undo
916 916
             'orderby'        => 'title',
917 917
             'order'          => 'ASC',
918 918
             'posts_per_page' => -1,
919
-            'post_status'    => array( 'publish' ),
920
-            's'              => sanitize_text_field( urldecode( $_GET['search'] ) ),
919
+            'post_status'    => array('publish'),
920
+            's'              => sanitize_text_field(urldecode($_GET['search'])),
921 921
             'meta_query'     => array(
922 922
                 array(
923 923
                     'key'       => '_wpinv_type',
@@ -927,25 +927,25 @@  discard block
 block discarded – undo
927 927
             )
928 928
         );
929 929
 
930
-        if ( ! empty( $_GET['ignore'] ) ) {
931
-            $item_args['exclude'] = wp_parse_id_list( sanitize_text_field( $_GET['ignore'] ) );
930
+        if (!empty($_GET['ignore'])) {
931
+            $item_args['exclude'] = wp_parse_id_list(sanitize_text_field($_GET['ignore']));
932 932
         }
933 933
 
934
-        $items = get_posts( apply_filters( 'getpaid_ajax_invoice_items_query_args', $item_args ) );
934
+        $items = get_posts(apply_filters('getpaid_ajax_invoice_items_query_args', $item_args));
935 935
         $data  = array();
936 936
 
937
-        $is_payment_form = ( ! empty( $_GET['post_id'] ) && 'wpi_payment_form' == get_post_type( (int) $_GET['post_id'] ) );
937
+        $is_payment_form = (!empty($_GET['post_id']) && 'wpi_payment_form' == get_post_type((int) $_GET['post_id']));
938 938
 
939
-        foreach ( $items as $item ) {
940
-            $item      = new GetPaid_Form_Item( $item );
939
+        foreach ($items as $item) {
940
+            $item = new GetPaid_Form_Item($item);
941 941
             $data[] = array(
942 942
                 'id'        => (int) $item->get_id(),
943
-                'text'      => strip_tags( $item->get_name() ),
944
-                'form_data' => $is_payment_form ? $item->prepare_data_for_use( false ) : '',
943
+                'text'      => strip_tags($item->get_name()),
944
+                'form_data' => $is_payment_form ? $item->prepare_data_for_use(false) : '',
945 945
             );
946 946
         }
947 947
 
948
-        wp_send_json_success( $data );
948
+        wp_send_json_success($data);
949 949
 
950 950
     }
951 951
 
@@ -955,37 +955,37 @@  discard block
 block discarded – undo
955 955
     public static function get_customers() {
956 956
 
957 957
         // Verify nonce.
958
-        check_ajax_referer( 'wpinv-nonce' );
958
+        check_ajax_referer('wpinv-nonce');
959 959
 
960
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
960
+        if (!wpinv_current_user_can_manage_invoicing()) {
961 961
             exit;
962 962
         }
963 963
 
964 964
         // We need a search term.
965
-        if ( empty( $_GET['search'] ) ) {
966
-            wp_send_json_success( array() );
965
+        if (empty($_GET['search'])) {
966
+            wp_send_json_success(array());
967 967
         }
968 968
 
969 969
         // Retrieve customers.
970 970
     
971 971
         $customer_args = array(
972
-            'fields'         => array( 'ID', 'user_email', 'display_name' ),
972
+            'fields'         => array('ID', 'user_email', 'display_name'),
973 973
             'orderby'        => 'display_name',
974
-            'search'         => '*' . sanitize_text_field( $_GET['search'] ) . '*',
975
-            'search_columns' => array( 'user_login', 'user_email', 'display_name' ),
974
+            'search'         => '*' . sanitize_text_field($_GET['search']) . '*',
975
+            'search_columns' => array('user_login', 'user_email', 'display_name'),
976 976
         );
977 977
 
978
-        $customers = get_users( apply_filters( 'getpaid_ajax_invoice_customers_query_args', $customer_args ) );
978
+        $customers = get_users(apply_filters('getpaid_ajax_invoice_customers_query_args', $customer_args));
979 979
         $data      = array();
980 980
 
981
-        foreach ( $customers as $customer ) {
981
+        foreach ($customers as $customer) {
982 982
             $data[] = array(
983 983
                 'id'        => (int) $customer->ID,
984
-                'text'      => strip_tags( sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email ) ),
984
+                'text'      => strip_tags(sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email)),
985 985
             );
986 986
         }
987 987
 
988
-        wp_send_json_success( $data );
988
+        wp_send_json_success($data);
989 989
 
990 990
     }
991 991
 
@@ -995,28 +995,28 @@  discard block
 block discarded – undo
995 995
     public static function get_aui_states_field() {
996 996
 
997 997
         // Verify nonce.
998
-        check_ajax_referer( 'wpinv-nonce' );
998
+        check_ajax_referer('wpinv-nonce');
999 999
 
1000 1000
         // We need a country.
1001
-        if ( empty( $_GET['country'] ) ) {
1001
+        if (empty($_GET['country'])) {
1002 1002
             exit;
1003 1003
         }
1004 1004
 
1005
-        $states = wpinv_get_country_states( sanitize_text_field( $_GET['country'] ) );
1006
-        $state  = isset( $_GET['state'] ) ? sanitize_text_field( $_GET['state'] ) : wpinv_get_default_state();
1007
-        $name   = isset( $_GET['name'] ) ? sanitize_text_field( $_GET['name'] ) : 'wpinv_state';
1008
-        $class  = isset( $_GET['class'] ) ? sanitize_text_field( $_GET['class'] ) : 'form-control-sm';
1005
+        $states = wpinv_get_country_states(sanitize_text_field($_GET['country']));
1006
+        $state  = isset($_GET['state']) ? sanitize_text_field($_GET['state']) : wpinv_get_default_state();
1007
+        $name   = isset($_GET['name']) ? sanitize_text_field($_GET['name']) : 'wpinv_state';
1008
+        $class  = isset($_GET['class']) ? sanitize_text_field($_GET['class']) : 'form-control-sm';
1009 1009
 
1010
-        if ( empty( $states ) ) {
1010
+        if (empty($states)) {
1011 1011
 
1012 1012
             $html = aui()->input(
1013 1013
                 array(
1014 1014
                     'type'        => 'text',
1015 1015
                     'id'          => 'wpinv_state',
1016 1016
                     'name'        => $name,
1017
-                    'label'       => __( 'State', 'invoicing' ),
1017
+                    'label'       => __('State', 'invoicing'),
1018 1018
                     'label_type'  => 'vertical',
1019
-                    'placeholder' => __( 'State', 'invoicing' ),
1019
+                    'placeholder' => __('State', 'invoicing'),
1020 1020
                     'class'       => $class,
1021 1021
                     'value'       => $state,
1022 1022
                 )
@@ -1028,9 +1028,9 @@  discard block
 block discarded – undo
1028 1028
                 array(
1029 1029
                     'id'          => 'wpinv_state',
1030 1030
                     'name'        => $name,
1031
-                    'label'       => __( 'State', 'invoicing' ),
1031
+                    'label'       => __('State', 'invoicing'),
1032 1032
                     'label_type'  => 'vertical',
1033
-                    'placeholder' => __( 'Select a state', 'invoicing' ),
1033
+                    'placeholder' => __('Select a state', 'invoicing'),
1034 1034
                     'class'       => $class,
1035 1035
                     'value'       => $state,
1036 1036
                     'options'     => $states,
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
         wp_send_json_success(
1045 1045
             array(
1046 1046
                 'html'   => $html,
1047
-                'select' => ! empty ( $states )
1047
+                'select' => !empty ($states)
1048 1048
             )
1049 1049
         );
1050 1050
 
@@ -1058,11 +1058,11 @@  discard block
 block discarded – undo
1058 1058
     public static function payment_form_refresh_prices() {
1059 1059
 
1060 1060
         // Check nonce.
1061
-        check_ajax_referer( 'getpaid_form_nonce' );
1061
+        check_ajax_referer('getpaid_form_nonce');
1062 1062
 
1063 1063
         // ... form fields...
1064
-        if ( empty( $_POST['getpaid_payment_form_submission'] ) ) {
1065
-            _e( 'Error: Reload the page and try again.', 'invoicing' );
1064
+        if (empty($_POST['getpaid_payment_form_submission'])) {
1065
+            _e('Error: Reload the page and try again.', 'invoicing');
1066 1066
             exit;
1067 1067
         }
1068 1068
 
@@ -1070,7 +1070,7 @@  discard block
 block discarded – undo
1070 1070
         $submission = new GetPaid_Payment_Form_Submission();
1071 1071
 
1072 1072
         // Do we have an error?
1073
-        if ( ! empty( $submission->last_error ) ) {
1073
+        if (!empty($submission->last_error)) {
1074 1074
             wp_send_json_error(
1075 1075
                 array(
1076 1076
                     'code'  => $submission->last_error_code,
@@ -1080,12 +1080,12 @@  discard block
 block discarded – undo
1080 1080
         }
1081 1081
 
1082 1082
         // Prepare the response.
1083
-        $response = new GetPaid_Payment_Form_Submission_Refresh_Prices( $submission );
1083
+        $response = new GetPaid_Payment_Form_Submission_Refresh_Prices($submission);
1084 1084
 
1085 1085
         // Filter the response.
1086
-        $response = apply_filters( 'getpaid_payment_form_ajax_refresh_prices', $response->response, $submission );
1086
+        $response = apply_filters('getpaid_payment_form_ajax_refresh_prices', $response->response, $submission);
1087 1087
 
1088
-        wp_send_json_success( $response );
1088
+        wp_send_json_success($response);
1089 1089
     }
1090 1090
 
1091 1091
     /**
@@ -1097,63 +1097,63 @@  discard block
 block discarded – undo
1097 1097
 	public static function file_upload() {
1098 1098
 
1099 1099
         // Check nonce.
1100
-        check_ajax_referer( 'getpaid_form_nonce' );
1100
+        check_ajax_referer('getpaid_form_nonce');
1101 1101
 
1102
-        if ( empty( $_POST['form_id'] ) || empty( $_POST['field_name'] ) || empty( $_FILES['file'] ) ) {
1103
-            wp_die( __( 'Bad Request', 'invoicing' ), 400 );
1102
+        if (empty($_POST['form_id']) || empty($_POST['field_name']) || empty($_FILES['file'])) {
1103
+            wp_die(__('Bad Request', 'invoicing'), 400);
1104 1104
         }
1105 1105
 
1106 1106
         // Fetch form.
1107
-        $form = new GetPaid_Payment_Form( intval( $_POST['form_id'] ) );
1107
+        $form = new GetPaid_Payment_Form(intval($_POST['form_id']));
1108 1108
 
1109
-        if ( ! $form->is_active() ) {
1110
-            wp_send_json_error( __( 'Payment form not active', 'invoicing' ) );
1109
+        if (!$form->is_active()) {
1110
+            wp_send_json_error(__('Payment form not active', 'invoicing'));
1111 1111
         }
1112 1112
 
1113 1113
         // Fetch appropriate field.
1114
-        $upload_field = current( wp_list_filter( $form->get_elements(), array( 'id' => sanitize_text_field( $_POST['field_name'] ) ) ) );
1115
-        if ( empty( $upload_field ) ) {
1116
-            wp_send_json_error( __( 'Invalid upload field.', 'invoicing' ) );
1114
+        $upload_field = current(wp_list_filter($form->get_elements(), array('id' => sanitize_text_field($_POST['field_name']))));
1115
+        if (empty($upload_field)) {
1116
+            wp_send_json_error(__('Invalid upload field.', 'invoicing'));
1117 1117
         }
1118 1118
 
1119 1119
         // Prepare allowed file types.
1120
-        $file_types = isset( $upload_field['file_types'] ) ? $upload_field['file_types'] : array( 'jpg|jpeg|jpe', 'gif', 'png' );
1120
+        $file_types = isset($upload_field['file_types']) ? $upload_field['file_types'] : array('jpg|jpeg|jpe', 'gif', 'png');
1121 1121
         $all_types  = getpaid_get_allowed_mime_types();
1122 1122
         $mime_types = array();
1123 1123
 
1124
-        foreach ( $file_types as $file_type ) {
1125
-            if ( isset( $all_types[ $file_type ] ) ) {
1126
-                $mime_types[] = $all_types[ $file_type ];
1124
+        foreach ($file_types as $file_type) {
1125
+            if (isset($all_types[$file_type])) {
1126
+                $mime_types[] = $all_types[$file_type];
1127 1127
             }
1128 1128
         }
1129 1129
 
1130
-        if ( ! in_array( $_FILES['file']['type'], $mime_types ) ) {
1131
-            wp_send_json_error( __( 'Unsupported file type.', 'invoicing' ) );
1130
+        if (!in_array($_FILES['file']['type'], $mime_types)) {
1131
+            wp_send_json_error(__('Unsupported file type.', 'invoicing'));
1132 1132
         }
1133 1133
 
1134 1134
         // Upload file.
1135
-        $file_name = explode( '.', strtolower( $_FILES['file']['name'] ) );
1136
-        $file_name = uniqid( 'getpaid-' ) . '.' . array_pop( $file_name );
1135
+        $file_name = explode('.', strtolower($_FILES['file']['name']));
1136
+        $file_name = uniqid('getpaid-') . '.' . array_pop($file_name);
1137 1137
 
1138 1138
         $uploaded = wp_upload_bits(
1139 1139
             $file_name,
1140 1140
             null,
1141
-            file_get_contents( $_FILES["file"]["tmp_name"] )
1141
+            file_get_contents($_FILES["file"]["tmp_name"])
1142 1142
         );
1143 1143
 
1144
-        if ( ! empty( $uploaded['error'] ) ) {
1145
-            wp_send_json_error( $uploaded['error'] );
1144
+        if (!empty($uploaded['error'])) {
1145
+            wp_send_json_error($uploaded['error']);
1146 1146
         }
1147 1147
 
1148 1148
         // Retrieve response.
1149 1149
         $response = sprintf(
1150 1150
             '<input type="hidden" name="%s[%s]" value="%s" />',
1151
-            esc_attr( sanitize_text_field( $_POST['field_name'] ) ),
1152
-            esc_url( $uploaded['url'] ),
1153
-            esc_attr( sanitize_text_field( strtolower( $_FILES['file']['name'] ) ) )
1151
+            esc_attr(sanitize_text_field($_POST['field_name'])),
1152
+            esc_url($uploaded['url']),
1153
+            esc_attr(sanitize_text_field(strtolower($_FILES['file']['name'])))
1154 1154
         );
1155 1155
 
1156
-        wp_send_json_success( $response );
1156
+        wp_send_json_success($response);
1157 1157
 
1158 1158
 	}
1159 1159
 
Please login to merge, or discard this patch.