Passed
Push — master ( 831686...e88989 )
by Brian
10:54
created
includes/class-wpinv.php 1 patch
Spacing   +244 added lines, -244 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 class WPInv_Plugin {
15 15
     private static $instance;
16 16
     
17 17
     public static function run() {
18
-        if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) {
18
+        if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) {
19 19
             self::$instance = new WPInv_Plugin;
20 20
             self::$instance->includes();
21 21
             self::$instance->actions();
@@ -33,34 +33,34 @@  discard block
 block discarded – undo
33 33
     }
34 34
     
35 35
     public function define_constants() {
36
-        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
37
-        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
36
+        define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
37
+        define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
38 38
     }
39 39
     
40 40
     private function actions() {
41 41
         /* Internationalize the text strings used. */
42
-        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
42
+        add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
43 43
         
44 44
         /* Perform actions on admin initialization. */
45
-        add_action( 'admin_init', array( &$this, 'admin_init') );
46
-        add_action( 'init', array( &$this, 'init' ), 3 );
47
-        add_action( 'init', array( &$this, 'wpinv_actions' ) );
45
+        add_action('admin_init', array(&$this, 'admin_init'));
46
+        add_action('init', array(&$this, 'init'), 3);
47
+        add_action('init', array(&$this, 'wpinv_actions'));
48 48
         
49
-        if ( class_exists( 'BuddyPress' ) ) {
50
-            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
49
+        if (class_exists('BuddyPress')) {
50
+            add_action('bp_include', array(&$this, 'bp_invoicing_init'));
51 51
         }
52 52
 
53
-        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
54
-        add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
55
-        add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
53
+        add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
54
+        add_action('widgets_init', array(&$this, 'register_widgets'));
55
+        add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids'));
56 56
 
57
-        if ( is_admin() ) {
58
-            add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
59
-            add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ) );
60
-            add_action( 'admin_init', array( &$this, 'init_ayecode_connect_helper' ) );
57
+        if (is_admin()) {
58
+            add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
59
+            add_filter('admin_body_class', array(&$this, 'admin_body_class'));
60
+            add_action('admin_init', array(&$this, 'init_ayecode_connect_helper'));
61 61
 
62 62
         } else {
63
-            add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
63
+            add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
64 64
         }
65 65
         
66 66
         /**
@@ -70,28 +70,28 @@  discard block
 block discarded – undo
70 70
          *
71 71
          * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference.
72 72
          */
73
-        do_action_ref_array( 'wpinv_actions', array( &$this ) );
73
+        do_action_ref_array('wpinv_actions', array(&$this));
74 74
 
75
-        add_action( 'admin_init', array( &$this, 'activation_redirect') );
75
+        add_action('admin_init', array(&$this, 'activation_redirect'));
76 76
     }
77 77
 
78 78
     /**
79 79
      * Maybe show the AyeCode Connect Notice.
80 80
      */
81
-    public function init_ayecode_connect_helper(){
81
+    public function init_ayecode_connect_helper() {
82 82
         // AyeCode Connect notice
83
-        if ( is_admin() ){
83
+        if (is_admin()) {
84 84
             // set the strings so they can be translated
85 85
             $strings = array(
86
-                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
87
-                'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
88
-                'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
89
-                'connect_button'    => __("Connect Site","invoicing"),
90
-                'connecting_button'    => __("Connecting...","invoicing"),
91
-                'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
92
-                'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
86
+                'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
87
+                'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
88
+                'connect'           => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"),
89
+                'connect_button'    => __("Connect Site", "invoicing"),
90
+                'connecting_button'    => __("Connecting...", "invoicing"),
91
+                'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
92
+                'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
93 93
             );
94
-            new AyeCode_Connect_Helper($strings,array('wpi-addons'));
94
+            new AyeCode_Connect_Helper($strings, array('wpi-addons'));
95 95
         }
96 96
     }
97 97
     
@@ -99,10 +99,10 @@  discard block
 block discarded – undo
99 99
         /* Internationalize the text strings used. */
100 100
         $this->load_textdomain();
101 101
 
102
-        do_action( 'wpinv_loaded' );
102
+        do_action('wpinv_loaded');
103 103
 
104 104
         // Fix oxygen page builder conflict
105
-        if ( function_exists( 'ct_css_output' ) ) {
105
+        if (function_exists('ct_css_output')) {
106 106
             wpinv_oxygen_fix_conflict();
107 107
         }
108 108
     }
@@ -112,237 +112,237 @@  discard block
 block discarded – undo
112 112
      *
113 113
      * @since 1.0
114 114
      */
115
-    public function load_textdomain( $locale = NULL ) {
116
-        if ( empty( $locale ) ) {
117
-            $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
115
+    public function load_textdomain($locale = NULL) {
116
+        if (empty($locale)) {
117
+            $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
118 118
         }
119 119
 
120
-        $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
120
+        $locale = apply_filters('plugin_locale', $locale, 'invoicing');
121 121
         
122
-        unload_textdomain( 'invoicing' );
123
-        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
124
-        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
122
+        unload_textdomain('invoicing');
123
+        load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
124
+        load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
125 125
         
126 126
         /**
127 127
          * Define language constants.
128 128
          */
129
-        require_once( WPINV_PLUGIN_DIR . 'language.php' );
129
+        require_once(WPINV_PLUGIN_DIR . 'language.php');
130 130
     }
131 131
         
132 132
     public function includes() {
133 133
         global $wpinv_options;
134 134
         
135
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
135
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
136 136
         $wpinv_options = wpinv_get_settings();
137 137
         
138
-        require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
139
-        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' );
140
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
141
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
142
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
143
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
144
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
145
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
146
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' );
147
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
148
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
149
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
150
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
151
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
152
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' );
153
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' );
154
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' );
155
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php' );
156
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' );
157
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' );
158
-        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
159
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
160
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
161
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
162
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
163
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
164
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
165
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
166
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
167
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' );
168
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
169
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' );
170
-        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
171
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
172
-        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
173
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
174
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
175
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
176
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
177
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
178
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
179
-        require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
180
-        require_once( WPINV_PLUGIN_DIR . 'widgets/payment-form.php' );
181
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
182
-
183
-        if ( !class_exists( 'WPInv_EUVat' ) ) {
184
-            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
138
+        require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php');
139
+        require_once(WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php');
140
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
141
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
142
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
143
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
144
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
145
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
146
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php');
147
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
148
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
149
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
150
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
151
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php');
152
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php');
153
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php');
154
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php');
155
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php');
156
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php');
157
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php');
158
+        require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php');
159
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php');
160
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
161
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
162
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
163
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php');
164
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php');
165
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php');
166
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php');
167
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php');
168
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php');
169
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php');
170
+        require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php');
171
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php');
172
+        require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php');
173
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php');
174
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php');
175
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php');
176
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php');
177
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php');
178
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php');
179
+        require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php');
180
+        require_once(WPINV_PLUGIN_DIR . 'widgets/payment-form.php');
181
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php');
182
+
183
+        if (!class_exists('WPInv_EUVat')) {
184
+            require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
185 185
         }
186 186
         
187
-        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
188
-        if ( !empty( $gateways ) ) {
189
-            foreach ( $gateways as $gateway ) {
190
-                if ( $gateway == 'manual' ) {
187
+        $gateways = array_keys(wpinv_get_enabled_payment_gateways());
188
+        if (!empty($gateways)) {
189
+            foreach ($gateways as $gateway) {
190
+                if ($gateway == 'manual') {
191 191
                     continue;
192 192
                 }
193 193
                 
194 194
                 $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
195 195
                 
196
-                if ( file_exists( $gateway_file ) ) {
197
-                    require_once( $gateway_file );
196
+                if (file_exists($gateway_file)) {
197
+                    require_once($gateway_file);
198 198
                 }
199 199
             }
200 200
         }
201
-        require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' );
201
+        require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php');
202 202
         
203
-        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
204
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
205
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
206
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' );
203
+        if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
204
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php');
205
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
206
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php');
207 207
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' );
208
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' );
209
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' );
210
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
211
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
212
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' );
213
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
214
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
215
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
208
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php');
209
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php');
210
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php');
211
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
212
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php');
213
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
214
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php');
215
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php');
216 216
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
217 217
             // load the user class only on the users.php page
218 218
             global $pagenow;
219
-            if($pagenow=='users.php'){
219
+            if ($pagenow == 'users.php') {
220 220
                 new WPInv_Admin_Users();
221 221
             }
222 222
         }
223 223
 
224 224
         // Register cli commands
225
-        if ( defined( 'WP_CLI' ) && WP_CLI ) {
226
-            require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
227
-            WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
225
+        if (defined('WP_CLI') && WP_CLI) {
226
+            require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php');
227
+            WP_CLI::add_command('invoicing', 'WPInv_CLI');
228 228
         }
229 229
         
230 230
         // include css inliner
231
-        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
232
-            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
231
+        if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
232
+            include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
233 233
         }
234 234
         
235
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
235
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
236 236
     }
237 237
     
238 238
     public function init() {
239 239
     }
240 240
     
241 241
     public function admin_init() {
242
-        add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) );
242
+        add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php'));
243 243
     }
244 244
 
245 245
     public function activation_redirect() {
246 246
         // Bail if no activation redirect
247
-        if ( !get_transient( '_wpinv_activation_redirect' ) ) {
247
+        if (!get_transient('_wpinv_activation_redirect')) {
248 248
             return;
249 249
         }
250 250
 
251 251
         // Delete the redirect transient
252
-        delete_transient( '_wpinv_activation_redirect' );
252
+        delete_transient('_wpinv_activation_redirect');
253 253
 
254 254
         // Bail if activating from network, or bulk
255
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
255
+        if (is_network_admin() || isset($_GET['activate-multi'])) {
256 256
             return;
257 257
         }
258 258
 
259
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
259
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
260 260
         exit;
261 261
     }
262 262
     
263 263
     public function enqueue_scripts() {
264
-        $suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
264
+        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
265 265
         
266
-        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION );
267
-        wp_enqueue_style( 'wpinv_front_style' );
266
+        wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION);
267
+        wp_enqueue_style('wpinv_front_style');
268 268
                
269 269
         // Register scripts
270
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
271
-        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) );
270
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
271
+        wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), filemtime(WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js'));
272 272
 
273 273
         $localize                         = array();
274
-        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
275
-        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
274
+        $localize['ajax_url']             = admin_url('admin-ajax.php');
275
+        $localize['nonce']                = wp_create_nonce('wpinv-nonce');
276 276
         $localize['currency_symbol']      = wpinv_currency_symbol();
277 277
         $localize['currency_pos']         = wpinv_currency_position();
278 278
         $localize['thousand_sep']         = wpinv_thousands_separator();
279 279
         $localize['decimal_sep']          = wpinv_decimal_separator();
280 280
         $localize['decimals']             = wpinv_decimals();
281
-        $localize['txtComplete']          = __( 'Complete', 'invoicing' );
281
+        $localize['txtComplete']          = __('Complete', 'invoicing');
282 282
         $localize['UseTaxes']             = wpinv_use_taxes();
283
-        $localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
283
+        $localize['checkoutNonce']        = wp_create_nonce('wpinv_checkout_nonce');
284 284
 
285
-        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
285
+        $localize = apply_filters('wpinv_front_js_localize', $localize);
286 286
         
287
-        wp_enqueue_script( 'jquery-blockui' );
287
+        wp_enqueue_script('jquery-blockui');
288 288
         $autofill_api = wpinv_get_option('address_autofill_api');
289 289
         $autofill_active = wpinv_get_option('address_autofill_active');
290
-        if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
291
-            if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
292
-                wp_dequeue_script( 'google-maps-api' );
290
+        if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) {
291
+            if (wp_script_is('google-maps-api', 'enqueued')) {
292
+                wp_dequeue_script('google-maps-api');
293 293
             }
294
-            wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
295
-            wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
294
+            wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false);
295
+            wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true);
296 296
         }
297 297
 
298
-        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
299
-        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
298
+        wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
299
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
300 300
 
301
-        wp_enqueue_script( 'wpinv-front-script' );
302
-        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
301
+        wp_enqueue_script('wpinv-front-script');
302
+        wp_localize_script('wpinv-front-script', 'WPInv', $localize);
303 303
 
304
-        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
305
-        wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script' ),  $version, true );
304
+        $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js');
305
+        wp_enqueue_script('wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('wpinv-front-script'), $version, true);
306 306
     }
307 307
 
308
-    public function admin_enqueue_scripts( $hook ) {
308
+    public function admin_enqueue_scripts($hook) {
309 309
         global $post, $pagenow;
310 310
         
311 311
         $post_type  = wpinv_admin_post_type();
312
-        $suffix     = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
313
-        $page       = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : '';
312
+        $suffix     = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
313
+        $page       = isset($_GET['page']) ? strtolower($_GET['page']) : '';
314 314
 
315 315
         $jquery_ui_css = false;
316
-        if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) {
316
+        if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
317 317
             $jquery_ui_css = true;
318
-        } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) {
318
+        } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') {
319 319
             $jquery_ui_css = true;
320 320
         }
321
-        if ( $jquery_ui_css ) {
322
-            wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
323
-            wp_enqueue_style( 'jquery-ui-css' );
321
+        if ($jquery_ui_css) {
322
+            wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16');
323
+            wp_enqueue_style('jquery-ui-css');
324 324
         }
325 325
 
326
-        wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
327
-        wp_enqueue_style( 'wpinv_meta_box_style' );
326
+        wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
327
+        wp_enqueue_style('wpinv_meta_box_style');
328 328
         
329
-        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
330
-        wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version );
331
-        wp_enqueue_style( 'wpinv_admin_style' );
329
+        $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
330
+        wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version);
331
+        wp_enqueue_style('wpinv_admin_style');
332 332
 
333
-        $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) );
334
-        if ( $page == 'wpinv-subscriptions' ) {
335
-            wp_enqueue_script( 'jquery-ui-datepicker' );
333
+        $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php'));
334
+        if ($page == 'wpinv-subscriptions') {
335
+            wp_enqueue_script('jquery-ui-datepicker');
336 336
         }
337 337
         
338
-        if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) {
339
-            wp_enqueue_script( 'jquery-ui-datepicker' );
338
+        if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) {
339
+            wp_enqueue_script('jquery-ui-datepicker');
340 340
         }
341 341
 
342
-        wp_enqueue_style( 'wp-color-picker' );
343
-        wp_enqueue_script( 'wp-color-picker' );
342
+        wp_enqueue_style('wp-color-picker');
343
+        wp_enqueue_script('wp-color-picker');
344 344
         
345
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
345
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
346 346
 
347 347
         if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
348 348
             $autofill_api = wpinv_get_option('address_autofill_api');
@@ -353,20 +353,20 @@  discard block
 block discarded – undo
353 353
             }
354 354
         }
355 355
 
356
-        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
357
-        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
356
+        wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
357
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
358 358
 
359
-        wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ),  WPINV_VERSION );
360
-        wp_enqueue_script( 'wpinv-admin-script' );
359
+        wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION);
360
+        wp_enqueue_script('wpinv-admin-script');
361 361
         
362 362
         $localize                               = array();
363
-        $localize['ajax_url']                   = admin_url( 'admin-ajax.php' );
364
-        $localize['post_ID']                    = isset( $post->ID ) ? $post->ID : '';
365
-        $localize['wpinv_nonce']                = wp_create_nonce( 'wpinv-nonce' );
366
-        $localize['add_invoice_note_nonce']     = wp_create_nonce( 'add-invoice-note' );
367
-        $localize['delete_invoice_note_nonce']  = wp_create_nonce( 'delete-invoice-note' );
368
-        $localize['invoice_item_nonce']         = wp_create_nonce( 'invoice-item' );
369
-        $localize['billing_details_nonce']      = wp_create_nonce( 'get-billing-details' );
363
+        $localize['ajax_url']                   = admin_url('admin-ajax.php');
364
+        $localize['post_ID']                    = isset($post->ID) ? $post->ID : '';
365
+        $localize['wpinv_nonce']                = wp_create_nonce('wpinv-nonce');
366
+        $localize['add_invoice_note_nonce']     = wp_create_nonce('add-invoice-note');
367
+        $localize['delete_invoice_note_nonce']  = wp_create_nonce('delete-invoice-note');
368
+        $localize['invoice_item_nonce']         = wp_create_nonce('invoice-item');
369
+        $localize['billing_details_nonce']      = wp_create_nonce('get-billing-details');
370 370
         $localize['tax']                        = wpinv_tax_amount();
371 371
         $localize['discount']                   = wpinv_discount_amount();
372 372
         $localize['currency_symbol']            = wpinv_currency_symbol();
@@ -374,95 +374,95 @@  discard block
 block discarded – undo
374 374
         $localize['thousand_sep']               = wpinv_thousands_separator();
375 375
         $localize['decimal_sep']                = wpinv_decimal_separator();
376 376
         $localize['decimals']                   = wpinv_decimals();
377
-        $localize['save_invoice']               = __( 'Save Invoice', 'invoicing' );
378
-        $localize['status_publish']             = wpinv_status_nicename( 'publish' );
379
-        $localize['status_pending']             = wpinv_status_nicename( 'wpi-pending' );
380
-        $localize['delete_tax_rate']            = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' );
381
-        $localize['OneItemMin']                 = __( 'Invoice must contain at least one item', 'invoicing' );
382
-        $localize['DeleteInvoiceItem']          = __( 'Are you sure you wish to delete this item?', 'invoicing' );
383
-        $localize['FillBillingDetails']         = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' );
384
-        $localize['confirmCalcTotals']          = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' );
385
-        $localize['AreYouSure']                 = __( 'Are you sure?', 'invoicing' );
386
-        $localize['emptyInvoice']               = __( 'Add at least one item to save invoice!', 'invoicing' );
387
-        $localize['errDeleteItem']              = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' );
388
-        $localize['delete_subscription']        = __( 'Are you sure you want to delete this subscription?', 'invoicing' );
389
-        $localize['action_edit']                = __( 'Edit', 'invoicing' );
390
-        $localize['action_cancel']              = __( 'Cancel', 'invoicing' );
391
-
392
-        $localize = apply_filters( 'wpinv_admin_js_localize', $localize );
393
-
394
-        wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize );
377
+        $localize['save_invoice']               = __('Save Invoice', 'invoicing');
378
+        $localize['status_publish']             = wpinv_status_nicename('publish');
379
+        $localize['status_pending']             = wpinv_status_nicename('wpi-pending');
380
+        $localize['delete_tax_rate']            = __('Are you sure you wish to delete this tax rate?', 'invoicing');
381
+        $localize['OneItemMin']                 = __('Invoice must contain at least one item', 'invoicing');
382
+        $localize['DeleteInvoiceItem']          = __('Are you sure you wish to delete this item?', 'invoicing');
383
+        $localize['FillBillingDetails']         = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing');
384
+        $localize['confirmCalcTotals']          = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing');
385
+        $localize['AreYouSure']                 = __('Are you sure?', 'invoicing');
386
+        $localize['emptyInvoice']               = __('Add at least one item to save invoice!', 'invoicing');
387
+        $localize['errDeleteItem']              = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing');
388
+        $localize['delete_subscription']        = __('Are you sure you want to delete this subscription?', 'invoicing');
389
+        $localize['action_edit']                = __('Edit', 'invoicing');
390
+        $localize['action_cancel']              = __('Cancel', 'invoicing');
391
+
392
+        $localize = apply_filters('wpinv_admin_js_localize', $localize);
393
+
394
+        wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize);
395 395
 
396 396
         // Load payment form scripts on our admin pages only.
397
-        if ( ( $hook == 'post-new.php' || $hook == 'post.php' ) && 'wpi_payment_form' === $post->post_type ) {
397
+        if (($hook == 'post-new.php' || $hook == 'post.php') && 'wpi_payment_form' === $post->post_type) {
398 398
 
399
-            wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
400
-            wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
401
-            wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
399
+            wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION);
400
+            wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
401
+            wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
402 402
 
403
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
404
-            wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
403
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
404
+            wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version);
405 405
         
406
-            wp_localize_script( 'wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array(
406
+            wp_localize_script('wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array(
407 407
                 'elements'      => $this->form_elements->get_elements(),
408
-                'form_elements' => $this->form_elements->get_form_elements( $post->ID ),
408
+                'form_elements' => $this->form_elements->get_form_elements($post->ID),
409 409
                 'all_items'     => $this->form_elements->get_published_items(),
410 410
                 'currency'      => wpinv_currency_symbol(),
411 411
                 'position'      => wpinv_currency_position(),
412 412
                 'decimals'      => (int) wpinv_decimals(),
413 413
                 'thousands_sep' => wpinv_thousands_separator(),
414 414
                 'decimals_sep'  => wpinv_decimal_separator(),
415
-                'form_items'    => $this->form_elements->get_form_items( $post->ID ),
416
-            ) );
415
+                'form_items'    => $this->form_elements->get_form_items($post->ID),
416
+            ));
417 417
 
418
-            wp_enqueue_script( 'wpinv-admin-payment-form-script' );
418
+            wp_enqueue_script('wpinv-admin-payment-form-script');
419 419
         }
420 420
 
421
-        if ( $page == 'wpinv-subscriptions' ) {
422
-            wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
423
-            wp_enqueue_script( 'wpinv-sub-admin-script' );
421
+        if ($page == 'wpinv-subscriptions') {
422
+            wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION);
423
+            wp_enqueue_script('wpinv-sub-admin-script');
424 424
         }
425 425
 
426 426
     }
427 427
     
428
-    public function admin_body_class( $classes ) {
428
+    public function admin_body_class($classes) {
429 429
         global $pagenow, $post, $current_screen;
430 430
         
431
-        if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_payment_form' || $current_screen->post_type == 'wpi_quote' ) ) {
431
+        if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_payment_form' || $current_screen->post_type == 'wpi_quote')) {
432 432
             $classes .= ' wpinv-cpt';
433 433
         }
434 434
         
435
-        $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
435
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
436 436
 
437
-        $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false;
438
-        if ( $add_class ) {
439
-            $classes .= ' wpi-' . wpinv_sanitize_key( $page );
437
+        $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false;
438
+        if ($add_class) {
439
+            $classes .= ' wpi-' . wpinv_sanitize_key($page);
440 440
         }
441 441
         
442 442
         $settings_class = array();
443
-        if ( $page == 'wpinv-settings' ) {
444
-            if ( !empty( $_REQUEST['tab'] ) ) {
445
-                $settings_class[] = sanitize_text_field( $_REQUEST['tab'] );
443
+        if ($page == 'wpinv-settings') {
444
+            if (!empty($_REQUEST['tab'])) {
445
+                $settings_class[] = sanitize_text_field($_REQUEST['tab']);
446 446
             }
447 447
             
448
-            if ( !empty( $_REQUEST['section'] ) ) {
449
-                $settings_class[] = sanitize_text_field( $_REQUEST['section'] );
448
+            if (!empty($_REQUEST['section'])) {
449
+                $settings_class[] = sanitize_text_field($_REQUEST['section']);
450 450
             }
451 451
             
452
-            $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main';
452
+            $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main';
453 453
         }
454 454
         
455
-        if ( !empty( $settings_class ) ) {
456
-            $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) );
455
+        if (!empty($settings_class)) {
456
+            $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-'));
457 457
         }
458 458
         
459 459
         $post_type = wpinv_admin_post_type();
460 460
 
461
-        if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) {
461
+        if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) {
462 462
             return $classes .= ' wpinv';
463 463
         }
464 464
         
465
-        if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) {
465
+        if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) {
466 466
             $classes .= ' wpi-editable-n';
467 467
         }
468 468
 
@@ -474,21 +474,21 @@  discard block
 block discarded – undo
474 474
     }
475 475
     
476 476
     public function wpinv_actions() {
477
-        if ( isset( $_REQUEST['wpi_action'] ) ) {
478
-            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
477
+        if (isset($_REQUEST['wpi_action'])) {
478
+            do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
479 479
         }
480 480
     }
481 481
     
482
-    public function pre_get_posts( $wp_query ) {
483
-        if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
484
-            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
482
+    public function pre_get_posts($wp_query) {
483
+        if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
484
+            $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
485 485
         }
486 486
         
487 487
         return $wp_query;
488 488
     }
489 489
     
490 490
     public function bp_invoicing_init() {
491
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
491
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
492 492
     }
493 493
 
494 494
 	/**
@@ -496,13 +496,13 @@  discard block
 block discarded – undo
496 496
 	 *
497 497
 	 */
498 498
 	public function register_widgets() {
499
-		register_widget( "WPInv_Checkout_Widget" );
500
-		register_widget( "WPInv_History_Widget" );
501
-		register_widget( "WPInv_Receipt_Widget" );
502
-		register_widget( "WPInv_Subscriptions_Widget" );
503
-		register_widget( "WPInv_Buy_Item_Widget" );
504
-        register_widget( "WPInv_Messages_Widget" );
505
-        register_widget( 'WPInv_Payment_Form_Widget' );
499
+		register_widget("WPInv_Checkout_Widget");
500
+		register_widget("WPInv_History_Widget");
501
+		register_widget("WPInv_Receipt_Widget");
502
+		register_widget("WPInv_Subscriptions_Widget");
503
+		register_widget("WPInv_Buy_Item_Widget");
504
+        register_widget("WPInv_Messages_Widget");
505
+        register_widget('WPInv_Payment_Form_Widget');
506 506
 	}
507 507
     
508 508
     /**
@@ -511,10 +511,10 @@  discard block
 block discarded – undo
511 511
      * @since 1.0.19
512 512
      * @param int[] $excluded_posts_ids
513 513
      */
514
-    function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
514
+    function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) {
515 515
 
516 516
         // Ensure that we have an array.
517
-        if ( ! is_array( $excluded_posts_ids ) ) {
517
+        if (!is_array($excluded_posts_ids)) {
518 518
             $excluded_posts_ids = array();
519 519
         }
520 520
 
@@ -522,24 +522,24 @@  discard block
 block discarded – undo
522 522
         $our_pages = array();
523 523
     
524 524
         // Checkout page.
525
-        $our_pages[] = wpinv_get_option( 'checkout_page', false );
525
+        $our_pages[] = wpinv_get_option('checkout_page', false);
526 526
 
527 527
         // Success page.
528
-        $our_pages[] = wpinv_get_option( 'success_page', false );
528
+        $our_pages[] = wpinv_get_option('success_page', false);
529 529
 
530 530
         // Failure page.
531
-        $our_pages[] = wpinv_get_option( 'failure_page', false );
531
+        $our_pages[] = wpinv_get_option('failure_page', false);
532 532
 
533 533
         // History page.
534
-        $our_pages[] = wpinv_get_option( 'invoice_history_page', false );
534
+        $our_pages[] = wpinv_get_option('invoice_history_page', false);
535 535
 
536 536
         // Subscriptions page.
537
-        $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
537
+        $our_pages[] = wpinv_get_option('invoice_subscription_page', false);
538 538
 
539
-        $our_pages   = array_map( 'intval', array_filter( $our_pages ) );
539
+        $our_pages   = array_map('intval', array_filter($our_pages));
540 540
 
541 541
         $excluded_posts_ids = $excluded_posts_ids + $our_pages;
542
-        return array_unique( $excluded_posts_ids );
542
+        return array_unique($excluded_posts_ids);
543 543
 
544 544
     }
545 545
 }
Please login to merge, or discard this patch.
includes/class-wpinv-ajax.php 1 patch
Spacing   +305 added lines, -305 removed lines patch added patch discarded remove patch
@@ -7,28 +7,28 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 class WPInv_Ajax {
15 15
     public static function init() {
16
-        add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
17
-        add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 );
16
+        add_action('init', array(__CLASS__, 'define_ajax'), 0);
17
+        add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0);
18 18
         self::add_ajax_events();
19 19
     }
20 20
 
21 21
     public static function define_ajax() {
22
-        if ( !empty( $_GET['wpinv-ajax'] ) ) {
23
-            if ( ! defined( 'DOING_AJAX' ) ) {
24
-                define( 'DOING_AJAX', true );
22
+        if (!empty($_GET['wpinv-ajax'])) {
23
+            if (!defined('DOING_AJAX')) {
24
+                define('DOING_AJAX', true);
25 25
             }
26
-            if ( ! defined( 'WC_DOING_AJAX' ) ) {
27
-                define( 'WC_DOING_AJAX', true );
26
+            if (!defined('WC_DOING_AJAX')) {
27
+                define('WC_DOING_AJAX', true);
28 28
             }
29 29
             // Turn off display_errors during AJAX events to prevent malformed JSON
30
-            if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
31
-                /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 );
30
+            if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) {
31
+                /** @scrutinizer ignore-unhandled */ @ini_set('display_errors', 0);
32 32
             }
33 33
             $GLOBALS['wpdb']->hide_errors();
34 34
         }
@@ -37,24 +37,24 @@  discard block
 block discarded – undo
37 37
     public static function do_wpinv_ajax() {
38 38
         global $wp_query;
39 39
 
40
-        if ( !empty( $_GET['wpinv-ajax'] ) ) {
41
-            $wp_query->set( 'wpinv-ajax', sanitize_text_field( $_GET['wpinv-ajax'] ) );
40
+        if (!empty($_GET['wpinv-ajax'])) {
41
+            $wp_query->set('wpinv-ajax', sanitize_text_field($_GET['wpinv-ajax']));
42 42
         }
43 43
 
44
-        if ( $action = $wp_query->get( 'wpinv-ajax' ) ) {
44
+        if ($action = $wp_query->get('wpinv-ajax')) {
45 45
             self::wpinv_ajax_headers();
46
-            do_action( 'wpinv_ajax_' . sanitize_text_field( $action ) );
46
+            do_action('wpinv_ajax_' . sanitize_text_field($action));
47 47
             die();
48 48
         }
49 49
     }
50 50
     
51 51
     private static function wpinv_ajax_headers() {
52 52
         send_origin_headers();
53
-        /** @scrutinizer ignore-unhandled */ @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
54
-        /** @scrutinizer ignore-unhandled */ @header( 'X-Robots-Tag: noindex' );
53
+        /** @scrutinizer ignore-unhandled */ @header('Content-Type: text/html; charset=' . get_option('blog_charset'));
54
+        /** @scrutinizer ignore-unhandled */ @header('X-Robots-Tag: noindex');
55 55
         send_nosniff_header();
56 56
         nocache_headers();
57
-        status_header( 200 );
57
+        status_header(200);
58 58
     }
59 59
     
60 60
     public static function add_ajax_events() {
@@ -78,39 +78,39 @@  discard block
 block discarded – undo
78 78
             'buy_items' => true,
79 79
         );
80 80
 
81
-        foreach ( $ajax_events as $ajax_event => $nopriv ) {
82
-            add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
81
+        foreach ($ajax_events as $ajax_event => $nopriv) {
82
+            add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
83 83
             
84
-            if ( !defined( 'WPI_AJAX_' . strtoupper( $nopriv ) ) ) {
85
-                define( 'WPI_AJAX_' . strtoupper( $nopriv ), 1 );
84
+            if (!defined('WPI_AJAX_' . strtoupper($nopriv))) {
85
+                define('WPI_AJAX_' . strtoupper($nopriv), 1);
86 86
             }
87 87
 
88
-            if ( $nopriv ) {
89
-                add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
88
+            if ($nopriv) {
89
+                add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
90 90
 
91
-                add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) );
91
+                add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event));
92 92
             }
93 93
         }
94 94
     }
95 95
     
96 96
     public static function add_note() {
97
-        check_ajax_referer( 'add-invoice-note', '_nonce' );
97
+        check_ajax_referer('add-invoice-note', '_nonce');
98 98
 
99
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
99
+        if (!wpinv_current_user_can_manage_invoicing()) {
100 100
             die(-1);
101 101
         }
102 102
 
103
-        $post_id   = absint( $_POST['post_id'] );
104
-        $note      = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) );
105
-        $note_type = sanitize_text_field( $_POST['note_type'] );
103
+        $post_id   = absint($_POST['post_id']);
104
+        $note      = wp_kses_post(trim(stripslashes($_POST['note'])));
105
+        $note_type = sanitize_text_field($_POST['note_type']);
106 106
 
107 107
         $is_customer_note = $note_type == 'customer' ? 1 : 0;
108 108
 
109
-        if ( $post_id > 0 ) {
110
-            $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note );
109
+        if ($post_id > 0) {
110
+            $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note);
111 111
 
112
-            if ( $note_id > 0 && !is_wp_error( $note_id ) ) {
113
-                wpinv_get_invoice_note_line_item( $note_id );
112
+            if ($note_id > 0 && !is_wp_error($note_id)) {
113
+                wpinv_get_invoice_note_line_item($note_id);
114 114
             }
115 115
         }
116 116
 
@@ -118,16 +118,16 @@  discard block
 block discarded – undo
118 118
     }
119 119
 
120 120
     public static function delete_note() {
121
-        check_ajax_referer( 'delete-invoice-note', '_nonce' );
121
+        check_ajax_referer('delete-invoice-note', '_nonce');
122 122
 
123
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
123
+        if (!wpinv_current_user_can_manage_invoicing()) {
124 124
             die(-1);
125 125
         }
126 126
 
127
-        $note_id = (int)$_POST['note_id'];
127
+        $note_id = (int) $_POST['note_id'];
128 128
 
129
-        if ( $note_id > 0 ) {
130
-            wp_delete_comment( $note_id, true );
129
+        if ($note_id > 0) {
130
+            wp_delete_comment($note_id, true);
131 131
         }
132 132
 
133 133
         die();
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
     }
141 141
     
142 142
     public static function checkout() {
143
-        if ( ! defined( 'WPINV_CHECKOUT' ) ) {
144
-            define( 'WPINV_CHECKOUT', true );
143
+        if (!defined('WPINV_CHECKOUT')) {
144
+            define('WPINV_CHECKOUT', true);
145 145
         }
146 146
 
147 147
         wpinv_process_checkout();
@@ -150,53 +150,53 @@  discard block
 block discarded – undo
150 150
     
151 151
     public static function add_invoice_item() {
152 152
         global $wpi_userID, $wpinv_ip_address_country;
153
-        check_ajax_referer( 'invoice-item', '_nonce' );
154
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
153
+        check_ajax_referer('invoice-item', '_nonce');
154
+        if (!wpinv_current_user_can_manage_invoicing()) {
155 155
             die(-1);
156 156
         }
157 157
         
158
-        $item_id    = sanitize_text_field( $_POST['item_id'] );
159
-        $invoice_id = absint( $_POST['invoice_id'] );
158
+        $item_id    = sanitize_text_field($_POST['item_id']);
159
+        $invoice_id = absint($_POST['invoice_id']);
160 160
         
161
-        if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) {
161
+        if (!is_numeric($invoice_id) || !is_numeric($item_id)) {
162 162
             die();
163 163
         }
164 164
         
165
-        $invoice    = wpinv_get_invoice( $invoice_id );
166
-        if ( empty( $invoice ) ) {
165
+        $invoice = wpinv_get_invoice($invoice_id);
166
+        if (empty($invoice)) {
167 167
             die();
168 168
         }
169 169
         
170
-        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
170
+        if ($invoice->is_paid() || $invoice->is_refunded()) {
171 171
             die(); // Don't allow modify items for paid invoice.
172 172
         }
173 173
         
174
-        if ( !empty( $_POST['user_id'] ) ) {
175
-            $wpi_userID = absint( $_POST['user_id'] ); 
174
+        if (!empty($_POST['user_id'])) {
175
+            $wpi_userID = absint($_POST['user_id']); 
176 176
         }
177 177
 
178
-        $item = new WPInv_Item( $item_id );
179
-        if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) {
178
+        $item = new WPInv_Item($item_id);
179
+        if (!(!empty($item) && $item->post_type == 'wpi_item')) {
180 180
             die();
181 181
         }
182 182
         
183 183
         // Validate item before adding to invoice because recurring item must be paid individually.
184
-        if ( !empty( $invoice->cart_details ) ) {
184
+        if (!empty($invoice->cart_details)) {
185 185
             $valid = true;
186 186
             
187
-            if ( $recurring_item = $invoice->get_recurring() ) {
188
-                if ( $recurring_item != $item_id ) {
187
+            if ($recurring_item = $invoice->get_recurring()) {
188
+                if ($recurring_item != $item_id) {
189 189
                     $valid = false;
190 190
                 }
191
-            } else if ( wpinv_is_recurring_item( $item_id ) ) {
191
+            } else if (wpinv_is_recurring_item($item_id)) {
192 192
                 $valid = false;
193 193
             }
194 194
             
195
-            if ( !$valid ) {
195
+            if (!$valid) {
196 196
                 $response               = array();
197 197
                 $response['success']    = false;
198
-                $response['msg']        = __( 'You can not add item because recurring item must be paid individually!', 'invoicing' );
199
-                wp_send_json( $response );
198
+                $response['msg']        = __('You can not add item because recurring item must be paid individually!', 'invoicing');
199
+                wp_send_json($response);
200 200
             }
201 201
         }
202 202
         
@@ -204,11 +204,11 @@  discard block
 block discarded – undo
204 204
         
205 205
         $data                   = array();
206 206
         $data['invoice_id']     = $invoice_id;
207
-        $data['cart_discounts'] = $invoice->get_discounts( true );
207
+        $data['cart_discounts'] = $invoice->get_discounts(true);
208 208
         
209
-        wpinv_set_checkout_session( $data );
209
+        wpinv_set_checkout_session($data);
210 210
         
211
-        $quantity = wpinv_item_quantities_enabled() && !empty($_POST['qty']) && (int)$_POST['qty'] > 0 ? (int)$_POST['qty'] : 1;
211
+        $quantity = wpinv_item_quantities_enabled() && !empty($_POST['qty']) && (int) $_POST['qty'] > 0 ? (int) $_POST['qty'] : 1;
212 212
 
213 213
         $args = array(
214 214
             'id'            => $item_id,
@@ -221,21 +221,21 @@  discard block
 block discarded – undo
221 221
             'fees'          => array()
222 222
         );
223 223
 
224
-        $invoice->add_item( $item_id, $args );
224
+        $invoice->add_item($item_id, $args);
225 225
         $invoice->save();
226 226
         
227
-        if ( empty( $_POST['country'] ) ) {
227
+        if (empty($_POST['country'])) {
228 228
             $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
229 229
         }
230
-        if ( empty( $_POST['state'] ) ) {
230
+        if (empty($_POST['state'])) {
231 231
             $_POST['state'] = $invoice->state;
232 232
         }
233 233
          
234
-        $invoice->country   = sanitize_text_field( $_POST['country'] );
235
-        $invoice->state     = sanitize_text_field( $_POST['state'] );
234
+        $invoice->country   = sanitize_text_field($_POST['country']);
235
+        $invoice->state     = sanitize_text_field($_POST['state']);
236 236
         
237
-        $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
238
-        $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
237
+        $invoice->set('country', sanitize_text_field($_POST['country']));
238
+        $invoice->set('state', sanitize_text_field($_POST['state']));
239 239
         
240 240
         $wpinv_ip_address_country = $invoice->country;
241 241
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
         
244 244
         $response                       = array();
245 245
         $response['success']            = true;
246
-        $response['data']['items']      = wpinv_admin_get_line_items( $invoice );
246
+        $response['data']['items']      = wpinv_admin_get_line_items($invoice);
247 247
         $response['data']['subtotal']   = $invoice->get_subtotal();
248 248
         $response['data']['subtotalf']  = $invoice->get_subtotal(true);
249 249
         $response['data']['tax']        = $invoice->get_tax();
@@ -255,41 +255,41 @@  discard block
 block discarded – undo
255 255
         
256 256
         wpinv_set_checkout_session($checkout_session);
257 257
         
258
-        wp_send_json( $response );
258
+        wp_send_json($response);
259 259
     }
260 260
 
261 261
 
262 262
     public static function remove_invoice_item() {
263 263
         global $wpi_userID, $wpinv_ip_address_country;
264 264
         
265
-        check_ajax_referer( 'invoice-item', '_nonce' );
266
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
265
+        check_ajax_referer('invoice-item', '_nonce');
266
+        if (!wpinv_current_user_can_manage_invoicing()) {
267 267
             die(-1);
268 268
         }
269 269
         
270
-        $item_id    = sanitize_text_field( $_POST['item_id'] );
271
-        $invoice_id = absint( $_POST['invoice_id'] );
272
-        $cart_index = isset( $_POST['index'] ) && $_POST['index'] >= 0 ? $_POST['index'] : false;
270
+        $item_id    = sanitize_text_field($_POST['item_id']);
271
+        $invoice_id = absint($_POST['invoice_id']);
272
+        $cart_index = isset($_POST['index']) && $_POST['index'] >= 0 ? $_POST['index'] : false;
273 273
         
274
-        if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) {
274
+        if (!is_numeric($invoice_id) || !is_numeric($item_id)) {
275 275
             die();
276 276
         }
277 277
 
278
-        $invoice    = wpinv_get_invoice( $invoice_id );
279
-        if ( empty( $invoice ) ) {
278
+        $invoice = wpinv_get_invoice($invoice_id);
279
+        if (empty($invoice)) {
280 280
             die();
281 281
         }
282 282
         
283
-        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
283
+        if ($invoice->is_paid() || $invoice->is_refunded()) {
284 284
             die(); // Don't allow modify items for paid invoice.
285 285
         }
286 286
         
287
-        if ( !empty( $_POST['user_id'] ) ) {
288
-            $wpi_userID = absint( $_POST['user_id'] ); 
287
+        if (!empty($_POST['user_id'])) {
288
+            $wpi_userID = absint($_POST['user_id']); 
289 289
         }
290 290
 
291
-        $item       = new WPInv_Item( $item_id );
292
-        if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) {
291
+        $item = new WPInv_Item($item_id);
292
+        if (!(!empty($item) && $item->post_type == 'wpi_item')) {
293 293
             die();
294 294
         }
295 295
         
@@ -297,9 +297,9 @@  discard block
 block discarded – undo
297 297
         
298 298
         $data                   = array();
299 299
         $data['invoice_id']     = $invoice_id;
300
-        $data['cart_discounts'] = $invoice->get_discounts( true );
300
+        $data['cart_discounts'] = $invoice->get_discounts(true);
301 301
         
302
-        wpinv_set_checkout_session( $data );
302
+        wpinv_set_checkout_session($data);
303 303
 
304 304
         $args = array(
305 305
             'id'         => $item_id,
@@ -307,21 +307,21 @@  discard block
 block discarded – undo
307 307
             'cart_index' => $cart_index
308 308
         );
309 309
 
310
-        $invoice->remove_item( $item_id, $args );
310
+        $invoice->remove_item($item_id, $args);
311 311
         $invoice->save();
312 312
         
313
-        if ( empty( $_POST['country'] ) ) {
313
+        if (empty($_POST['country'])) {
314 314
             $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
315 315
         }
316
-        if ( empty( $_POST['state'] ) ) {
316
+        if (empty($_POST['state'])) {
317 317
             $_POST['state'] = $invoice->state;
318 318
         }
319 319
          
320
-        $invoice->country   = sanitize_text_field( $_POST['country'] );
321
-        $invoice->state     = sanitize_text_field( $_POST['state'] );
320
+        $invoice->country   = sanitize_text_field($_POST['country']);
321
+        $invoice->state     = sanitize_text_field($_POST['state']);
322 322
         
323
-        $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
324
-        $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
323
+        $invoice->set('country', sanitize_text_field($_POST['country']));
324
+        $invoice->set('state', sanitize_text_field($_POST['state']));
325 325
         
326 326
         $wpinv_ip_address_country = $invoice->country;
327 327
         
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
         
330 330
         $response                       = array();
331 331
         $response['success']            = true;
332
-        $response['data']['items']      = wpinv_admin_get_line_items( $invoice );
332
+        $response['data']['items']      = wpinv_admin_get_line_items($invoice);
333 333
         $response['data']['subtotal']   = $invoice->get_subtotal();
334 334
         $response['data']['subtotalf']  = $invoice->get_subtotal(true);
335 335
         $response['data']['tax']        = $invoice->get_tax();
@@ -341,55 +341,55 @@  discard block
 block discarded – undo
341 341
         
342 342
         wpinv_set_checkout_session($checkout_session);
343 343
         
344
-        wp_send_json( $response );
344
+        wp_send_json($response);
345 345
     }
346 346
     
347 347
     public static function create_invoice_item() {
348
-        check_ajax_referer( 'invoice-item', '_nonce' );
349
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
348
+        check_ajax_referer('invoice-item', '_nonce');
349
+        if (!wpinv_current_user_can_manage_invoicing()) {
350 350
             die(-1);
351 351
         }
352 352
         
353
-        $invoice_id = absint( $_POST['invoice_id'] );
353
+        $invoice_id = absint($_POST['invoice_id']);
354 354
 
355 355
         // Find the item
356
-        if ( !is_numeric( $invoice_id ) ) {
356
+        if (!is_numeric($invoice_id)) {
357 357
             die();
358 358
         }        
359 359
         
360
-        $invoice     = wpinv_get_invoice( $invoice_id );
361
-        if ( empty( $invoice ) ) {
360
+        $invoice = wpinv_get_invoice($invoice_id);
361
+        if (empty($invoice)) {
362 362
             die();
363 363
         }
364 364
         
365 365
         // Validate item before adding to invoice because recurring item must be paid individually.
366
-        if ( !empty( $invoice->cart_details ) && $invoice->get_recurring() ) {
366
+        if (!empty($invoice->cart_details) && $invoice->get_recurring()) {
367 367
             $response               = array();
368 368
             $response['success']    = false;
369
-            $response['msg']        = __( 'You can not add item because recurring item must be paid individually!', 'invoicing' );
370
-            wp_send_json( $response );
369
+            $response['msg']        = __('You can not add item because recurring item must be paid individually!', 'invoicing');
370
+            wp_send_json($response);
371 371
         }        
372 372
         
373
-        $save_item = wp_unslash( $_POST['_wpinv_quick'] );
373
+        $save_item = wp_unslash($_POST['_wpinv_quick']);
374 374
         
375 375
         $meta               = array();
376 376
         $meta['type']       = !empty($save_item['type']) ? sanitize_text_field($save_item['type']) : 'custom';
377
-        $meta['price']      = !empty($save_item['price']) ? wpinv_sanitize_amount( $save_item['price'] ) : 0;
377
+        $meta['price']      = !empty($save_item['price']) ? wpinv_sanitize_amount($save_item['price']) : 0;
378 378
         $meta['vat_rule']   = !empty($save_item['vat_rule']) ? sanitize_text_field($save_item['vat_rule']) : 'digital';
379 379
         $meta['vat_class']  = !empty($save_item['vat_class']) ? sanitize_text_field($save_item['vat_class']) : '_standard';
380 380
         
381 381
         $data                   = array();
382 382
         $data['post_title']     = sanitize_text_field($save_item['name']);
383 383
         $data['post_status']    = 'publish';
384
-        $data['post_excerpt']   = ! empty( $save_item['excerpt'] ) ? wp_kses_post( $save_item['excerpt'] ) : '';
384
+        $data['post_excerpt']   = !empty($save_item['excerpt']) ? wp_kses_post($save_item['excerpt']) : '';
385 385
         $data['meta']           = $meta;
386 386
         
387 387
         $item = new WPInv_Item();
388
-        $item->create( $data );
388
+        $item->create($data);
389 389
         
390
-        if ( !empty( $item ) ) {
390
+        if (!empty($item)) {
391 391
             $_POST['item_id']   = $item->ID;
392
-            $_POST['qty']       = !empty($save_item['qty']) && $save_item['qty'] > 0 ? (int)$save_item['qty'] : 1;
392
+            $_POST['qty']       = !empty($save_item['qty']) && $save_item['qty'] > 0 ? (int) $save_item['qty'] : 1;
393 393
             
394 394
             self::add_invoice_item();
395 395
         }
@@ -397,15 +397,15 @@  discard block
 block discarded – undo
397 397
     }
398 398
     
399 399
     public static function get_billing_details() {
400
-        check_ajax_referer( 'get-billing-details', '_nonce' );
400
+        check_ajax_referer('get-billing-details', '_nonce');
401 401
         
402
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
402
+        if (!wpinv_current_user_can_manage_invoicing()) {
403 403
             die(-1);
404 404
         }
405 405
 
406
-        $user_id            = (int)$_POST['user_id'];
406
+        $user_id            = (int) $_POST['user_id'];
407 407
         $billing_details    = wpinv_get_user_address($user_id);
408
-        $billing_details    = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id );
408
+        $billing_details    = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id);
409 409
         
410 410
         if (isset($billing_details['user_id'])) {
411 411
             unset($billing_details['user_id']);
@@ -419,20 +419,20 @@  discard block
 block discarded – undo
419 419
         $response['success']                    = true;
420 420
         $response['data']['billing_details']    = $billing_details;
421 421
         
422
-        wp_send_json( $response );
422
+        wp_send_json($response);
423 423
     }
424 424
     
425 425
     public static function admin_recalculate_totals() {
426 426
         global $wpi_userID, $wpinv_ip_address_country;
427 427
         
428
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
429
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
428
+        check_ajax_referer('wpinv-nonce', '_nonce');
429
+        if (!wpinv_current_user_can_manage_invoicing()) {
430 430
             die(-1);
431 431
         }
432 432
         
433
-        $invoice_id = absint( $_POST['invoice_id'] );        
434
-        $invoice    = wpinv_get_invoice( $invoice_id );
435
-        if ( empty( $invoice ) ) {
433
+        $invoice_id = absint($_POST['invoice_id']);        
434
+        $invoice    = wpinv_get_invoice($invoice_id);
435
+        if (empty($invoice)) {
436 436
             die();
437 437
         }
438 438
         
@@ -440,23 +440,23 @@  discard block
 block discarded – undo
440 440
         
441 441
         $data                   = array();
442 442
         $data['invoice_id']     = $invoice_id;
443
-        $data['cart_discounts'] = $invoice->get_discounts( true );
443
+        $data['cart_discounts'] = $invoice->get_discounts(true);
444 444
         
445
-        wpinv_set_checkout_session( $data );
445
+        wpinv_set_checkout_session($data);
446 446
         
447
-        if ( !empty( $_POST['user_id'] ) ) {
448
-            $wpi_userID = absint( $_POST['user_id'] ); 
447
+        if (!empty($_POST['user_id'])) {
448
+            $wpi_userID = absint($_POST['user_id']); 
449 449
         }
450 450
         
451
-        if ( empty( $_POST['country'] ) ) {
451
+        if (empty($_POST['country'])) {
452 452
             $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
453 453
         }
454 454
             
455
-        $invoice->country = sanitize_text_field( $_POST['country'] );
456
-        $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
457
-        if ( isset( $_POST['state'] ) ) {
458
-            $invoice->state = sanitize_text_field( $_POST['state'] );
459
-            $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
455
+        $invoice->country = sanitize_text_field($_POST['country']);
456
+        $invoice->set('country', sanitize_text_field($_POST['country']));
457
+        if (isset($_POST['state'])) {
458
+            $invoice->state = sanitize_text_field($_POST['state']);
459
+            $invoice->set('state', sanitize_text_field($_POST['state']));
460 460
         }
461 461
         
462 462
         $wpinv_ip_address_country = $invoice->country;
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
         
466 466
         $response                       = array();
467 467
         $response['success']            = true;
468
-        $response['data']['items']      = wpinv_admin_get_line_items( $invoice );
468
+        $response['data']['items']      = wpinv_admin_get_line_items($invoice);
469 469
         $response['data']['subtotal']   = $invoice->get_subtotal();
470 470
         $response['data']['subtotalf']  = $invoice->get_subtotal(true);
471 471
         $response['data']['tax']        = $invoice->get_tax();
@@ -477,25 +477,25 @@  discard block
 block discarded – undo
477 477
         
478 478
         wpinv_set_checkout_session($checkout_session);
479 479
         
480
-        wp_send_json( $response );
480
+        wp_send_json($response);
481 481
     }
482 482
     
483 483
     public static function admin_apply_discount() {
484 484
         global $wpi_userID;
485 485
         
486
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
487
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
486
+        check_ajax_referer('wpinv-nonce', '_nonce');
487
+        if (!wpinv_current_user_can_manage_invoicing()) {
488 488
             die(-1);
489 489
         }
490 490
         
491
-        $invoice_id = absint( $_POST['invoice_id'] );
492
-        $discount_code = sanitize_text_field( $_POST['code'] );
493
-        if ( empty( $invoice_id ) || empty( $discount_code ) ) {
491
+        $invoice_id = absint($_POST['invoice_id']);
492
+        $discount_code = sanitize_text_field($_POST['code']);
493
+        if (empty($invoice_id) || empty($discount_code)) {
494 494
             die();
495 495
         }
496 496
         
497
-        $invoice = wpinv_get_invoice( $invoice_id );
498
-        if ( empty( $invoice ) || ( !empty( $invoice ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) ) {
497
+        $invoice = wpinv_get_invoice($invoice_id);
498
+        if (empty($invoice) || (!empty($invoice) && ($invoice->is_paid() || $invoice->is_refunded()))) {
499 499
             die();
500 500
         }
501 501
         
@@ -503,49 +503,49 @@  discard block
 block discarded – undo
503 503
         
504 504
         $data                   = array();
505 505
         $data['invoice_id']     = $invoice_id;
506
-        $data['cart_discounts'] = $invoice->get_discounts( true );
506
+        $data['cart_discounts'] = $invoice->get_discounts(true);
507 507
         
508
-        wpinv_set_checkout_session( $data );
508
+        wpinv_set_checkout_session($data);
509 509
         
510 510
         $response               = array();
511 511
         $response['success']    = false;
512
-        $response['msg']        = __( 'This discount is invalid.', 'invoicing' );
512
+        $response['msg']        = __('This discount is invalid.', 'invoicing');
513 513
         $response['data']['code'] = $discount_code;
514 514
         
515
-        if ( wpinv_is_discount_valid( $discount_code, $invoice->get_user_id() ) ) {
516
-            $discounts = wpinv_set_cart_discount( $discount_code );
515
+        if (wpinv_is_discount_valid($discount_code, $invoice->get_user_id())) {
516
+            $discounts = wpinv_set_cart_discount($discount_code);
517 517
             
518 518
             $response['success'] = true;
519
-            $response['msg'] = __( 'Discount has been applied successfully.', 'invoicing' );
520
-        }  else {
519
+            $response['msg'] = __('Discount has been applied successfully.', 'invoicing');
520
+        } else {
521 521
             $errors = wpinv_get_errors();
522
-            if ( !empty( $errors['wpinv-discount-error'] ) ) {
522
+            if (!empty($errors['wpinv-discount-error'])) {
523 523
                 $response['msg'] = $errors['wpinv-discount-error'];
524 524
             }
525
-            wpinv_unset_error( 'wpinv-discount-error' );
525
+            wpinv_unset_error('wpinv-discount-error');
526 526
         }
527 527
         
528 528
         wpinv_set_checkout_session($checkout_session);
529 529
         
530
-        wp_send_json( $response );
530
+        wp_send_json($response);
531 531
     }
532 532
     
533 533
     public static function admin_remove_discount() {
534 534
         global $wpi_userID;
535 535
         
536
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
537
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
536
+        check_ajax_referer('wpinv-nonce', '_nonce');
537
+        if (!wpinv_current_user_can_manage_invoicing()) {
538 538
             die(-1);
539 539
         }
540 540
         
541
-        $invoice_id = absint( $_POST['invoice_id'] );
542
-        $discount_code = sanitize_text_field( $_POST['code'] );
543
-        if ( empty( $invoice_id ) || empty( $discount_code ) ) {
541
+        $invoice_id = absint($_POST['invoice_id']);
542
+        $discount_code = sanitize_text_field($_POST['code']);
543
+        if (empty($invoice_id) || empty($discount_code)) {
544 544
             die();
545 545
         }
546 546
         
547
-        $invoice = wpinv_get_invoice( $invoice_id );
548
-        if ( empty( $invoice ) || ( !empty( $invoice ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) ) {
547
+        $invoice = wpinv_get_invoice($invoice_id);
548
+        if (empty($invoice) || (!empty($invoice) && ($invoice->is_paid() || $invoice->is_refunded()))) {
549 549
             die();
550 550
         }
551 551
         
@@ -553,38 +553,38 @@  discard block
 block discarded – undo
553 553
         
554 554
         $data                   = array();
555 555
         $data['invoice_id']     = $invoice_id;
556
-        $data['cart_discounts'] = $invoice->get_discounts( true );
556
+        $data['cart_discounts'] = $invoice->get_discounts(true);
557 557
         
558
-        wpinv_set_checkout_session( $data );
558
+        wpinv_set_checkout_session($data);
559 559
         
560 560
         $response               = array();
561 561
         $response['success']    = false;
562 562
         $response['msg']        = NULL;
563 563
         
564
-        $discounts  = wpinv_unset_cart_discount( $discount_code );
564
+        $discounts = wpinv_unset_cart_discount($discount_code);
565 565
         $response['success'] = true;
566
-        $response['msg'] = __( 'Discount has been removed successfully.', 'invoicing' );
566
+        $response['msg'] = __('Discount has been removed successfully.', 'invoicing');
567 567
         
568 568
         wpinv_set_checkout_session($checkout_session);
569 569
         
570
-        wp_send_json( $response );
570
+        wp_send_json($response);
571 571
     }
572 572
     
573 573
     public static function check_email() {
574
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
575
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
574
+        check_ajax_referer('wpinv-nonce', '_nonce');
575
+        if (!wpinv_current_user_can_manage_invoicing()) {
576 576
             die(-1);
577 577
         }
578 578
         
579
-        $email = sanitize_text_field( $_POST['email'] );
579
+        $email = sanitize_text_field($_POST['email']);
580 580
         
581 581
         $response = array();
582
-        if ( is_email( $email ) && email_exists( $email ) && $user_data = get_user_by( 'email', $email ) ) {
582
+        if (is_email($email) && email_exists($email) && $user_data = get_user_by('email', $email)) {
583 583
             $user_id            = $user_data->ID;
584 584
             $user_login         = $user_data->user_login;
585 585
             $display_name       = $user_data->display_name ? $user_data->display_name : $user_login;
586 586
             $billing_details    = wpinv_get_user_address($user_id);
587
-            $billing_details    = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id );
587
+            $billing_details    = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id);
588 588
             
589 589
             if (isset($billing_details['user_id'])) {
590 590
                 unset($billing_details['user_id']);
@@ -600,54 +600,54 @@  discard block
 block discarded – undo
600 600
             $response['data']['billing_details']    = $billing_details;
601 601
         }
602 602
         
603
-        wp_send_json( $response );
603
+        wp_send_json($response);
604 604
     }
605 605
     
606 606
     public static function run_tool() {
607
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
608
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
607
+        check_ajax_referer('wpinv-nonce', '_nonce');
608
+        if (!wpinv_current_user_can_manage_invoicing()) {
609 609
             die(-1);
610 610
         }
611 611
         
612
-        $tool = sanitize_text_field( $_POST['tool'] );
612
+        $tool = sanitize_text_field($_POST['tool']);
613 613
         
614
-        do_action( 'wpinv_run_tool' );
614
+        do_action('wpinv_run_tool');
615 615
         
616
-        if ( !empty( $tool ) ) {
617
-            do_action( 'wpinv_tool_' . $tool );
616
+        if (!empty($tool)) {
617
+            do_action('wpinv_tool_' . $tool);
618 618
         }
619 619
     }
620 620
     
621 621
     public static function apply_discount() {
622 622
         global $wpi_userID;
623 623
         
624
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
624
+        check_ajax_referer('wpinv-nonce', '_nonce');
625 625
         
626 626
         $response = array();
627 627
         
628
-        if ( isset( $_POST['code'] ) ) {
629
-            $discount_code = sanitize_text_field( $_POST['code'] );
628
+        if (isset($_POST['code'])) {
629
+            $discount_code = sanitize_text_field($_POST['code']);
630 630
 
631 631
             $response['success']        = false;
632 632
             $response['msg']            = '';
633 633
             $response['data']['code']   = $discount_code;
634 634
             
635 635
             $invoice = wpinv_get_invoice_cart();
636
-            if ( empty( $invoice->ID ) ) {
637
-                $response['msg'] = __( 'Invalid checkout request.', 'invoicing' );
638
-                wp_send_json( $response );
636
+            if (empty($invoice->ID)) {
637
+                $response['msg'] = __('Invalid checkout request.', 'invoicing');
638
+                wp_send_json($response);
639 639
             }
640 640
 
641 641
             $wpi_userID = $invoice->get_user_id();
642 642
 
643
-            if ( wpinv_is_discount_valid( $discount_code, $wpi_userID ) ) {
644
-                $discount       = wpinv_get_discount_by_code( $discount_code );
645
-                $discounts      = wpinv_set_cart_discount( $discount_code );
646
-                $amount         = wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) );
647
-                $total          = wpinv_get_cart_total( null, $discounts );
648
-                $cart_totals    = wpinv_recalculate_tax( true );
643
+            if (wpinv_is_discount_valid($discount_code, $wpi_userID)) {
644
+                $discount       = wpinv_get_discount_by_code($discount_code);
645
+                $discounts      = wpinv_set_cart_discount($discount_code);
646
+                $amount         = wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID));
647
+                $total          = wpinv_get_cart_total(null, $discounts);
648
+                $cart_totals    = wpinv_recalculate_tax(true);
649 649
             
650
-                if ( !empty( $cart_totals ) ) {
650
+                if (!empty($cart_totals)) {
651 651
                     $response['success']        = true;
652 652
                     $response['data']           = $cart_totals;
653 653
                     $response['data']['code']   = $discount_code;
@@ -656,29 +656,29 @@  discard block
 block discarded – undo
656 656
                 }
657 657
             } else {
658 658
                 $errors = wpinv_get_errors();
659
-                $response['msg']  = $errors['wpinv-discount-error'];
660
-                wpinv_unset_error( 'wpinv-discount-error' );
659
+                $response['msg'] = $errors['wpinv-discount-error'];
660
+                wpinv_unset_error('wpinv-discount-error');
661 661
             }
662 662
 
663 663
             // Allow for custom discount code handling
664
-            $response = apply_filters( 'wpinv_ajax_discount_response', $response );
664
+            $response = apply_filters('wpinv_ajax_discount_response', $response);
665 665
         }
666 666
         
667
-        wp_send_json( $response );
667
+        wp_send_json($response);
668 668
     }
669 669
     
670 670
     public static function remove_discount() {
671
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
671
+        check_ajax_referer('wpinv-nonce', '_nonce');
672 672
         
673 673
         $response = array();
674 674
         
675
-        if ( isset( $_POST['code'] ) ) {
676
-            $discount_code  = sanitize_text_field( $_POST['code'] );
677
-            $discounts      = wpinv_unset_cart_discount( $discount_code );
678
-            $total          = wpinv_get_cart_total( null, $discounts );
679
-            $cart_totals    = wpinv_recalculate_tax( true );
675
+        if (isset($_POST['code'])) {
676
+            $discount_code  = sanitize_text_field($_POST['code']);
677
+            $discounts      = wpinv_unset_cart_discount($discount_code);
678
+            $total          = wpinv_get_cart_total(null, $discounts);
679
+            $cart_totals    = wpinv_recalculate_tax(true);
680 680
             
681
-            if ( !empty( $cart_totals ) ) {
681
+            if (!empty($cart_totals)) {
682 682
                 $response['success']        = true;
683 683
                 $response['data']           = $cart_totals;
684 684
                 $response['data']['code']   = $discount_code;
@@ -687,10 +687,10 @@  discard block
 block discarded – undo
687 687
             }
688 688
             
689 689
             // Allow for custom discount code handling
690
-            $response = apply_filters( 'wpinv_ajax_discount_response', $response );
690
+            $response = apply_filters('wpinv_ajax_discount_response', $response);
691 691
         }
692 692
         
693
-        wp_send_json( $response );
693
+        wp_send_json($response);
694 694
     }
695 695
 
696 696
     /**
@@ -702,74 +702,74 @@  discard block
 block discarded – undo
702 702
         global $invoicing, $wpi_checkout_id, $cart_total;
703 703
 
704 704
         // Check nonce.
705
-        if ( ! isset( $_POST['wpinv_payment_form'] ) || ! wp_verify_nonce( $_POST['wpinv_payment_form'], 'wpinv_payment_form' ) ) {
706
-            wp_send_json_error( __( 'Security checks failed.', 'invoicing' ) );
705
+        if (!isset($_POST['wpinv_payment_form']) || !wp_verify_nonce($_POST['wpinv_payment_form'], 'wpinv_payment_form')) {
706
+            wp_send_json_error(__('Security checks failed.', 'invoicing'));
707 707
         }
708 708
 
709 709
         // Prepare submitted data...
710
-        $data = wp_unslash( $_POST );
710
+        $data = wp_unslash($_POST);
711 711
 
712 712
         // ... form fields...
713
-        if ( empty( $data['form_id'] ) || 'publish' != get_post_status( $data['form_id'] ) ) {
714
-            wp_send_json_error( __( 'This payment form is no longer active.', 'invoicing' ) );
713
+        if (empty($data['form_id']) || 'publish' != get_post_status($data['form_id'])) {
714
+            wp_send_json_error(__('This payment form is no longer active.', 'invoicing'));
715 715
         }
716 716
 
717
-        if ( empty( $data['billing_email'] ) || ! is_email( $data['billing_email'] ) ) {
718
-            wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) );
717
+        if (empty($data['billing_email']) || !is_email($data['billing_email'])) {
718
+            wp_send_json_error(__('Provide a valid billing email.', 'invoicing'));
719 719
         }
720 720
 
721 721
         $prepared = array(
722
-            'billing_email'                    => sanitize_email( $data['billing_email'] ),
723
-            __( 'Billing Email', 'invoicing' ) => sanitize_email( $data['billing_email'] ),
724
-            __( 'Form Id', 'invoicing' )       => absint( $data['form_id'] ),
722
+            'billing_email'                    => sanitize_email($data['billing_email']),
723
+            __('Billing Email', 'invoicing') => sanitize_email($data['billing_email']),
724
+            __('Form Id', 'invoicing')       => absint($data['form_id']),
725 725
         );
726 726
 
727
-        $prepared['billing_email'] = sanitize_email( $data['billing_email'] );
727
+        $prepared['billing_email'] = sanitize_email($data['billing_email']);
728 728
 
729
-        $fields = $invoicing->form_elements->get_form_elements( $data['form_id'] );
729
+        $fields = $invoicing->form_elements->get_form_elements($data['form_id']);
730 730
 
731 731
         // ... and form items.
732
-        $items          = $invoicing->form_elements->get_form_items( $data['form_id'] );
732
+        $items          = $invoicing->form_elements->get_form_items($data['form_id']);
733 733
         $prepared_items = array();
734 734
 
735
-        if ( ! empty( $data['wpinv-items'] ) ) {
735
+        if (!empty($data['wpinv-items'])) {
736 736
 
737
-            $selected_items = wpinv_clean( $data['wpinv-items'] );
737
+            $selected_items = wpinv_clean($data['wpinv-items']);
738 738
 
739
-            foreach ( $items as $item ) {
739
+            foreach ($items as $item) {
740 740
 
741
-                if ( ! empty( $item['required'] ) && ! isset( $selected_items[ $item['id'] ] ) ) {
742
-                    wp_send_json_error( __( 'A required item is missing.', 'invoicing' ) );
741
+                if (!empty($item['required']) && !isset($selected_items[$item['id']])) {
742
+                    wp_send_json_error(__('A required item is missing.', 'invoicing'));
743 743
                 }
744 744
 
745
-                if ( ! isset( $selected_items[ $item['id'] ] ) ) {
745
+                if (!isset($selected_items[$item['id']])) {
746 746
                     continue;
747 747
                 }
748 748
 
749 749
                 $quantity = 1;
750 750
 
751
-                if ( ! empty( $item['allow_quantities'] ) && ! empty( $data["wpinv-item-{$item['id']}-quantity"] ) ) {
751
+                if (!empty($item['allow_quantities']) && !empty($data["wpinv-item-{$item['id']}-quantity"])) {
752 752
 
753
-                    $quantity = intval( $data["wpinv-item-{$item['id']}-quantity"] );
753
+                    $quantity = intval($data["wpinv-item-{$item['id']}-quantity"]);
754 754
 
755
-                    if ( empty( $quantity ) ) {
755
+                    if (empty($quantity)) {
756 756
                         $quantity = 1;
757 757
                     }
758 758
                 }
759 759
 
760 760
                 // Custom pricing.
761
-                if ( ! empty( $item['custom_price'] ) ) {
761
+                if (!empty($item['custom_price'])) {
762 762
 
763
-                    $minimum_price = wpinv_sanitize_amount( $item['minimum_price'] );
764
-                    $set_price     = wpinv_sanitize_amount( $selected_items[ $item['id'] ] );
763
+                    $minimum_price = wpinv_sanitize_amount($item['minimum_price']);
764
+                    $set_price     = wpinv_sanitize_amount($selected_items[$item['id']]);
765 765
 
766
-                    if ( $set_price < $minimum_price ) {
767
-                        wp_send_json_error( __( 'The provided amount is less than the minimum allowed value.', 'invoicing' ) );
766
+                    if ($set_price < $minimum_price) {
767
+                        wp_send_json_error(__('The provided amount is less than the minimum allowed value.', 'invoicing'));
768 768
                     }
769 769
 
770 770
                     $prepared_items[] = array(
771 771
                         'id'           =>$item['id'],
772
-                        'item_price'   => wpinv_sanitize_amount( $item['price'] ),
772
+                        'item_price'   => wpinv_sanitize_amount($item['price']),
773 773
                         'custom_price' => $set_price,
774 774
                         'name'         => $item['title'],
775 775
                         'quantity'     => $quantity,
@@ -779,8 +779,8 @@  discard block
 block discarded – undo
779 779
 
780 780
                     $prepared_items[] = array(
781 781
                         'id'           => $item['id'],
782
-                        'item_price'   => wpinv_sanitize_amount( $item['price'] ),
783
-                        'custom_price' => wpinv_sanitize_amount( $item['price'] ),
782
+                        'item_price'   => wpinv_sanitize_amount($item['price']),
783
+                        'custom_price' => wpinv_sanitize_amount($item['price']),
784 784
                         'name'         => $item['title'],
785 785
                         'quantity'     => $quantity,
786 786
                     );
@@ -791,45 +791,45 @@  discard block
 block discarded – undo
791 791
 
792 792
         } else {
793 793
 
794
-            wp_send_json_error( __( 'You have not selected any items.', 'invoicing' ) );
794
+            wp_send_json_error(__('You have not selected any items.', 'invoicing'));
795 795
 
796 796
         }
797 797
 
798 798
         // Are all required fields provided?
799
-        foreach ( $fields as $field ) {
799
+        foreach ($fields as $field) {
800 800
 
801
-            if ( ! empty( $field['premade'] ) ) {
801
+            if (!empty($field['premade'])) {
802 802
                 continue;
803 803
             }
804 804
 
805
-            if ( ! empty( $field['required'] ) && empty( $data[ $field['id'] ] ) ) {
806
-                wp_send_json_error( __( 'Some required fields have not been filled.', 'invoicing' ) );
805
+            if (!empty($field['required']) && empty($data[$field['id']])) {
806
+                wp_send_json_error(__('Some required fields have not been filled.', 'invoicing'));
807 807
             }
808 808
 
809
-            if ( isset( $data[ $field['id'] ] ) ) {
809
+            if (isset($data[$field['id']])) {
810 810
                 $label = $field['id'];
811 811
 
812
-                if ( isset( $field['label'] ) ) {
812
+                if (isset($field['label'])) {
813 813
                     $label = $field['label'];
814 814
                 }
815 815
 
816
-                $prepared[ wpinv_clean( $label ) ] = wpinv_clean( $data[ $field['id'] ] );
816
+                $prepared[wpinv_clean($label)] = wpinv_clean($data[$field['id']]);
817 817
             }
818 818
 
819 819
         }
820 820
         
821
-        $user = get_user_by( 'email', $prepared['billing_email'] );
821
+        $user = get_user_by('email', $prepared['billing_email']);
822 822
 
823
-        if ( empty( $user ) ) {
824
-            $user = wpinv_create_user( $prepared['billing_email'] );
823
+        if (empty($user)) {
824
+            $user = wpinv_create_user($prepared['billing_email']);
825 825
         }
826 826
 
827
-        if ( is_wp_error( $user ) ) {
828
-            wp_send_json_error( $user->get_error_message() );
827
+        if (is_wp_error($user)) {
828
+            wp_send_json_error($user->get_error_message());
829 829
         }
830 830
 
831
-        if ( is_numeric( $user ) ) {
832
-            $user = get_user_by( 'id', $user );
831
+        if (is_numeric($user)) {
832
+            $user = get_user_by('id', $user);
833 833
         }
834 834
 
835 835
         // Create the invoice.
@@ -843,36 +843,36 @@  discard block
 block discarded – undo
843 843
             true
844 844
         );
845 845
 
846
-        if ( is_wp_error( $created ) ) {
847
-            wp_send_json_error( $created->get_error_message() );
846
+        if (is_wp_error($created)) {
847
+            wp_send_json_error($created->get_error_message());
848 848
         }
849 849
 
850
-        if ( empty( $created ) ) {
851
-            wp_send_json_error( __( 'Could not create your invoice.', 'invoicing' ) );
850
+        if (empty($created)) {
851
+            wp_send_json_error(__('Could not create your invoice.', 'invoicing'));
852 852
         }
853 853
 
854
-        unset( $prepared['billing_email'] );
855
-        update_post_meta( $created->ID, 'payment_form_data', $prepared );
854
+        unset($prepared['billing_email']);
855
+        update_post_meta($created->ID, 'payment_form_data', $prepared);
856 856
 
857 857
         $wpi_checkout_id = $created->ID;
858 858
         $cart_total = wpinv_price(
859 859
             wpinv_format_amount(
860
-                wpinv_get_cart_total( $created->get_cart_details(), NULL, $created ) ),
860
+                wpinv_get_cart_total($created->get_cart_details(), NULL, $created) ),
861 861
                 $created->get_currency()
862 862
         );
863 863
         ob_start();
864
-            $form_action  = esc_url( wpinv_get_checkout_uri() );
864
+            $form_action = esc_url(wpinv_get_checkout_uri());
865 865
             echo '<form id="wpinv_checkout_form" action="' . $form_action . '" method="POST" class="wpi-form wpi-payment-form-checkout-form mt-4">';
866 866
             
867
-                echo wpinv_display_line_items( $created->ID );
867
+                echo wpinv_display_line_items($created->ID);
868 868
 
869 869
                 echo "<div class='mt-4'>";
870
-                    do_action( 'wpinv_payment_mode_select' );
871
-                    do_action( 'wpinv_checkout_form_bottom' );
870
+                    do_action('wpinv_payment_mode_select');
871
+                    do_action('wpinv_checkout_form_bottom');
872 872
                 echo "</div>";
873 873
 
874 874
             echo "</form>";
875
-        wp_send_json_success( ob_get_clean() );
875
+        wp_send_json_success(ob_get_clean());
876 876
 
877 877
     }
878 878
 
@@ -884,53 +884,53 @@  discard block
 block discarded – undo
884 884
     public static function buy_items() {
885 885
         $user_id = get_current_user_id();
886 886
 
887
-        if ( empty( $user_id ) ) { // If not logged in then lets redirect to the login page
888
-            wp_send_json( array(
889
-                'success' => wp_login_url( wp_get_referer() )
890
-            ) );
887
+        if (empty($user_id)) { // If not logged in then lets redirect to the login page
888
+            wp_send_json(array(
889
+                'success' => wp_login_url(wp_get_referer())
890
+            ));
891 891
         } else {
892 892
             // Only check nonce if logged in as it could be cached when logged out.
893
-            if ( ! isset( $_POST['wpinv_buy_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_buy_nonce'], 'wpinv_buy_items' ) ) {
894
-                wp_send_json( array(
895
-                    'error' => __( 'Security checks failed.', 'invoicing' )
896
-                ) );
893
+            if (!isset($_POST['wpinv_buy_nonce']) || !wp_verify_nonce($_POST['wpinv_buy_nonce'], 'wpinv_buy_items')) {
894
+                wp_send_json(array(
895
+                    'error' => __('Security checks failed.', 'invoicing')
896
+                ));
897 897
                 wp_die();
898 898
             }
899 899
 
900 900
             // allow to set a custom price through post_id
901 901
             $items = $_POST['items'];
902
-            $related_post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : 0;
903
-            $custom_item_price = $related_post_id ? abs( get_post_meta( $related_post_id, '_wpi_custom_price', true ) ) : 0;
902
+            $related_post_id = isset($_POST['post_id']) ? (int) $_POST['post_id'] : 0;
903
+            $custom_item_price = $related_post_id ? abs(get_post_meta($related_post_id, '_wpi_custom_price', true)) : 0;
904 904
 
905 905
             $cart_items = array();
906
-            if ( $items ) {
907
-                $items = explode( ',', $items );
906
+            if ($items) {
907
+                $items = explode(',', $items);
908 908
 
909
-                foreach( $items as $item ) {
909
+                foreach ($items as $item) {
910 910
                     $item_id = $item;
911 911
                     $quantity = 1;
912 912
 
913
-                    if ( strpos( $item, '|' ) !== false ) {
914
-                        $item_parts = explode( '|', $item );
913
+                    if (strpos($item, '|') !== false) {
914
+                        $item_parts = explode('|', $item);
915 915
                         $item_id = $item_parts[0];
916 916
                         $quantity = $item_parts[1];
917 917
                     }
918 918
 
919
-                    if ( $item_id && $quantity ) {
919
+                    if ($item_id && $quantity) {
920 920
                         $cart_items_arr = array(
921
-                            'id'            => (int)$item_id,
922
-                            'quantity'      => (int)$quantity
921
+                            'id'            => (int) $item_id,
922
+                            'quantity'      => (int) $quantity
923 923
                         );
924 924
 
925 925
                         // If there is a related post id then add it to meta
926
-                        if ( $related_post_id ) {
926
+                        if ($related_post_id) {
927 927
                             $cart_items_arr['meta'] = array(
928 928
                                 'post_id'   => $related_post_id
929 929
                             );
930 930
                         }
931 931
 
932 932
                         // If there is a custom price then set it.
933
-                        if ( $custom_item_price ) {
933
+                        if ($custom_item_price) {
934 934
                             $cart_items_arr['custom_price'] = $custom_item_price;
935 935
                         }
936 936
 
@@ -946,37 +946,37 @@  discard block
 block discarded – undo
946 946
              * @param int $related_post_id The related post id if any.
947 947
              * @since 1.0.0
948 948
              */
949
-            $cart_items = apply_filters( 'wpinv_buy_cart_items', $cart_items, $related_post_id );
949
+            $cart_items = apply_filters('wpinv_buy_cart_items', $cart_items, $related_post_id);
950 950
 
951 951
             // Make sure its not in the cart already, if it is then redirect to checkout.
952 952
             $cart_invoice = wpinv_get_invoice_cart();
953 953
 
954
-            if ( isset( $cart_invoice->items ) && !empty( $cart_invoice->items ) && !empty( $cart_items ) && serialize( $cart_invoice->items ) == serialize( $cart_items ) ) {
955
-                wp_send_json( array(
954
+            if (isset($cart_invoice->items) && !empty($cart_invoice->items) && !empty($cart_items) && serialize($cart_invoice->items) == serialize($cart_items)) {
955
+                wp_send_json(array(
956 956
                     'success' =>  $cart_invoice->get_checkout_payment_url()
957
-                ) );
957
+                ));
958 958
                 wp_die();
959 959
             }
960 960
 
961 961
             // Check if user has invoice with same items waiting to be paid.
962
-            $user_invoices = wpinv_get_users_invoices( $user_id , 10 , false , 'wpi-pending' );
963
-            if ( !empty( $user_invoices ) ) {
964
-                foreach( $user_invoices as $user_invoice ) {
962
+            $user_invoices = wpinv_get_users_invoices($user_id, 10, false, 'wpi-pending');
963
+            if (!empty($user_invoices)) {
964
+                foreach ($user_invoices as $user_invoice) {
965 965
                     $user_cart_details = array();
966
-                    $invoice  = wpinv_get_invoice( $user_invoice->ID );
966
+                    $invoice = wpinv_get_invoice($user_invoice->ID);
967 967
                     $cart_details = $invoice->get_cart_details();
968 968
 
969
-                    if ( !empty( $cart_details ) ) {
970
-                        foreach ( $cart_details as $invoice_item ) {
969
+                    if (!empty($cart_details)) {
970
+                        foreach ($cart_details as $invoice_item) {
971 971
                             $ii_arr = array();
972
-                            $ii_arr['id'] = (int)$invoice_item['id'];
973
-                            $ii_arr['quantity'] = (int)$invoice_item['quantity'];
972
+                            $ii_arr['id'] = (int) $invoice_item['id'];
973
+                            $ii_arr['quantity'] = (int) $invoice_item['quantity'];
974 974
 
975
-                            if (isset( $invoice_item['meta'] ) && !empty( $invoice_item['meta'] ) ) {
975
+                            if (isset($invoice_item['meta']) && !empty($invoice_item['meta'])) {
976 976
                                 $ii_arr['meta'] = $invoice_item['meta'];
977 977
                             }
978 978
 
979
-                            if ( isset( $invoice_item['custom_price'] ) && !empty( $invoice_item['custom_price'] ) ) {
979
+                            if (isset($invoice_item['custom_price']) && !empty($invoice_item['custom_price'])) {
980 980
                                 $ii_arr['custom_price'] = $invoice_item['custom_price'];
981 981
                             }
982 982
 
@@ -984,17 +984,17 @@  discard block
 block discarded – undo
984 984
                         }
985 985
                     }
986 986
 
987
-                    if ( !empty( $user_cart_details ) && serialize( $cart_items ) == serialize( $user_cart_details ) ) {
988
-                        wp_send_json( array(
987
+                    if (!empty($user_cart_details) && serialize($cart_items) == serialize($user_cart_details)) {
988
+                        wp_send_json(array(
989 989
                             'success' =>  $invoice->get_checkout_payment_url()
990
-                        ) );
990
+                        ));
991 991
                         wp_die();
992 992
                     }
993 993
                 }
994 994
             }
995 995
 
996 996
             // Create invoice and send user to checkout
997
-            if ( !empty( $cart_items ) ) {
997
+            if (!empty($cart_items)) {
998 998
                 $invoice_data = array(
999 999
                     'status'        =>  'wpi-pending',
1000 1000
                     'created_via'   =>  'wpi',
@@ -1002,21 +1002,21 @@  discard block
 block discarded – undo
1002 1002
                     'cart_details'  =>  $cart_items,
1003 1003
                 );
1004 1004
 
1005
-                $invoice = wpinv_insert_invoice( $invoice_data, true );
1005
+                $invoice = wpinv_insert_invoice($invoice_data, true);
1006 1006
 
1007
-                if ( !empty( $invoice ) && isset( $invoice->ID ) ) {
1008
-                    wp_send_json( array(
1007
+                if (!empty($invoice) && isset($invoice->ID)) {
1008
+                    wp_send_json(array(
1009 1009
                         'success' =>  $invoice->get_checkout_payment_url()
1010
-                    ) );
1010
+                    ));
1011 1011
                 } else {
1012
-                    wp_send_json( array(
1013
-                        'error' => __( 'Invoice failed to create', 'invoicing' )
1014
-                    ) );
1012
+                    wp_send_json(array(
1013
+                        'error' => __('Invoice failed to create', 'invoicing')
1014
+                    ));
1015 1015
                 }
1016 1016
             } else {
1017
-                wp_send_json( array(
1018
-                    'error' => __( 'Items not valid.', 'invoicing' )
1019
-                ) );
1017
+                wp_send_json(array(
1018
+                    'error' => __('Items not valid.', 'invoicing')
1019
+                ));
1020 1020
             }
1021 1021
         }
1022 1022
 
Please login to merge, or discard this patch.
includes/wpinv-template-functions.php 1 patch
Spacing   +743 added lines, -743 removed lines patch added patch discarded remove patch
@@ -7,91 +7,91 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14
-if ( !is_admin() ) {
15
-    add_filter( 'template_include', 'wpinv_template', 10, 1 );
16
-    add_action( 'wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar' );
17
-    add_action( 'wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions' );
18
-    add_action( 'wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions' );
14
+if (!is_admin()) {
15
+    add_filter('template_include', 'wpinv_template', 10, 1);
16
+    add_action('wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar');
17
+    add_action('wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions');
18
+    add_action('wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions');
19 19
 }
20 20
 
21 21
 function wpinv_template_path() {
22
-    return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() );
22
+    return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name());
23 23
 }
24 24
 
25
-function wpinv_display_invoice_top_bar( $invoice ) {
26
-    if ( empty( $invoice ) ) {
25
+function wpinv_display_invoice_top_bar($invoice) {
26
+    if (empty($invoice)) {
27 27
         return;
28 28
     }
29 29
     ?>
30 30
     <div class="row wpinv-top-bar no-print">
31 31
         <div class="container">
32 32
             <div class="col-xs-6">
33
-                <?php do_action( 'wpinv_invoice_top_bar_left', $invoice );?>
33
+                <?php do_action('wpinv_invoice_top_bar_left', $invoice); ?>
34 34
             </div>
35 35
             <div class="col-xs-6 text-right">
36
-                <?php do_action( 'wpinv_invoice_top_bar_right', $invoice );?>
36
+                <?php do_action('wpinv_invoice_top_bar_right', $invoice); ?>
37 37
             </div>
38 38
         </div>
39 39
     </div>
40 40
     <?php
41 41
 }
42 42
 
43
-function wpinv_invoice_display_left_actions( $invoice ) {
44
-    if ( empty( $invoice ) ) {
43
+function wpinv_invoice_display_left_actions($invoice) {
44
+    if (empty($invoice)) {
45 45
         return; // Exit if invoice is not set.
46 46
     }
47 47
     
48
-    if ( $invoice->post_type == 'wpi_invoice' ) {
49
-        if ( $invoice->needs_payment() ) {
50
-            ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e( 'Pay This Invoice', 'invoicing' ); ?>" href="<?php echo esc_url( $invoice->get_checkout_payment_url() ); ?>"><?php _e( 'Pay For Invoice', 'invoicing' ); ?></a><?php
48
+    if ($invoice->post_type == 'wpi_invoice') {
49
+        if ($invoice->needs_payment()) {
50
+            ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e('Pay This Invoice', 'invoicing'); ?>" href="<?php echo esc_url($invoice->get_checkout_payment_url()); ?>"><?php _e('Pay For Invoice', 'invoicing'); ?></a><?php
51 51
         }
52 52
     }
53 53
     do_action('wpinv_invoice_display_left_actions', $invoice);
54 54
 }
55 55
 
56
-function wpinv_invoice_display_right_actions( $invoice ) {
57
-    if ( empty( $invoice ) ) {
56
+function wpinv_invoice_display_right_actions($invoice) {
57
+    if (empty($invoice)) {
58 58
         return; // Exit if invoice is not set.
59 59
     }
60 60
 
61
-    if ( $invoice->post_type == 'wpi_invoice' ) { ?>
62
-        <a class="btn btn-primary btn-sm btn-print-invoice" onclick="window.print();" href="javascript:void(0)"><?php _e( 'Print Invoice', 'invoicing' ); ?></a>
63
-        <?php if ( is_user_logged_in() ) { ?>
64
-        &nbsp;&nbsp;<a class="btn btn-warning btn-sm btn-invoice-history" href="<?php echo esc_url( wpinv_get_history_page_uri() ); ?>"><?php _e( 'Invoice History', 'invoicing' ); ?></a>
61
+    if ($invoice->post_type == 'wpi_invoice') { ?>
62
+        <a class="btn btn-primary btn-sm btn-print-invoice" onclick="window.print();" href="javascript:void(0)"><?php _e('Print Invoice', 'invoicing'); ?></a>
63
+        <?php if (is_user_logged_in()) { ?>
64
+        &nbsp;&nbsp;<a class="btn btn-warning btn-sm btn-invoice-history" href="<?php echo esc_url(wpinv_get_history_page_uri()); ?>"><?php _e('Invoice History', 'invoicing'); ?></a>
65 65
         <?php }
66 66
     }
67 67
     do_action('wpinv_invoice_display_right_actions', $invoice);
68 68
 }
69 69
 
70
-function wpinv_before_invoice_content( $content ) {
70
+function wpinv_before_invoice_content($content) {
71 71
     global $post;
72 72
 
73
-    if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) {
73
+    if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) {
74 74
         ob_start();
75
-        do_action( 'wpinv_before_invoice_content', $post->ID );
75
+        do_action('wpinv_before_invoice_content', $post->ID);
76 76
         $content = ob_get_clean() . $content;
77 77
     }
78 78
 
79 79
     return $content;
80 80
 }
81
-add_filter( 'the_content', 'wpinv_before_invoice_content' );
81
+add_filter('the_content', 'wpinv_before_invoice_content');
82 82
 
83
-function wpinv_after_invoice_content( $content ) {
83
+function wpinv_after_invoice_content($content) {
84 84
     global $post;
85 85
 
86
-    if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) {
86
+    if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) {
87 87
         ob_start();
88
-        do_action( 'wpinv_after_invoice_content', $post->ID );
88
+        do_action('wpinv_after_invoice_content', $post->ID);
89 89
         $content .= ob_get_clean();
90 90
     }
91 91
 
92 92
     return $content;
93 93
 }
94
-add_filter( 'the_content', 'wpinv_after_invoice_content' );
94
+add_filter('the_content', 'wpinv_after_invoice_content');
95 95
 
96 96
 function wpinv_get_templates_dir() {
97 97
     return WPINV_PLUGIN_DIR . 'templates';
@@ -101,105 +101,105 @@  discard block
 block discarded – undo
101 101
     return WPINV_PLUGIN_URL . 'templates';
102 102
 }
103 103
 
104
-function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
105
-    if ( ! empty( $args ) && is_array( $args ) ) {
106
-		extract( $args );
104
+function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
105
+    if (!empty($args) && is_array($args)) {
106
+		extract($args);
107 107
 	}
108 108
 
109
-	$located = wpinv_locate_template( $template_name, $template_path, $default_path );
109
+	$located = wpinv_locate_template($template_name, $template_path, $default_path);
110 110
 	// Allow 3rd party plugin filter template file from their plugin.
111
-	$located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path );
111
+	$located = apply_filters('wpinv_get_template', $located, $template_name, $args, $template_path, $default_path);
112 112
 
113
-	if ( ! file_exists( $located ) ) {
114
-        _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' );
113
+	if (!file_exists($located)) {
114
+        _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1');
115 115
 		return;
116 116
 	}
117 117
 
118
-	do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args );
118
+	do_action('wpinv_before_template_part', $template_name, $template_path, $located, $args);
119 119
 
120
-	include( $located );
120
+	include($located);
121 121
 
122
-	do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args );
122
+	do_action('wpinv_after_template_part', $template_name, $template_path, $located, $args);
123 123
 }
124 124
 
125
-function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
125
+function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') {
126 126
 	ob_start();
127
-	wpinv_get_template( $template_name, $args, $template_path, $default_path );
127
+	wpinv_get_template($template_name, $args, $template_path, $default_path);
128 128
 	return ob_get_clean();
129 129
 }
130 130
 
131
-function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) {
132
-    if ( ! $template_path ) {
131
+function wpinv_locate_template($template_name, $template_path = '', $default_path = '') {
132
+    if (!$template_path) {
133 133
         $template_path = wpinv_template_path();
134 134
     }
135 135
 
136
-    if ( ! $default_path ) {
136
+    if (!$default_path) {
137 137
         $default_path = WPINV_PLUGIN_DIR . 'templates/';
138 138
     }
139 139
 
140 140
     // Look within passed path within the theme - this is priority.
141 141
     $template = locate_template(
142 142
         array(
143
-            trailingslashit( $template_path ) . $template_name,
143
+            trailingslashit($template_path) . $template_name,
144 144
             $template_name
145 145
         )
146 146
     );
147 147
 
148 148
     // Get default templates/
149
-    if ( !$template && $default_path ) {
150
-        $template = trailingslashit( $default_path ) . $template_name;
149
+    if (!$template && $default_path) {
150
+        $template = trailingslashit($default_path) . $template_name;
151 151
     }
152 152
 
153 153
     // Return what we found.
154
-    return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path );
154
+    return apply_filters('wpinv_locate_template', $template, $template_name, $template_path);
155 155
 }
156 156
 
157
-function wpinv_get_template_part( $slug, $name = null, $load = true ) {
158
-	do_action( 'get_template_part_' . $slug, $slug, $name );
157
+function wpinv_get_template_part($slug, $name = null, $load = true) {
158
+	do_action('get_template_part_' . $slug, $slug, $name);
159 159
 
160 160
 	// Setup possible parts
161 161
 	$templates = array();
162
-	if ( isset( $name ) )
162
+	if (isset($name))
163 163
 		$templates[] = $slug . '-' . $name . '.php';
164 164
 	$templates[] = $slug . '.php';
165 165
 
166 166
 	// Allow template parts to be filtered
167
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
167
+	$templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name);
168 168
 
169 169
 	// Return the part that is found
170
-	return wpinv_locate_tmpl( $templates, $load, false );
170
+	return wpinv_locate_tmpl($templates, $load, false);
171 171
 }
172 172
 
173
-function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
173
+function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) {
174 174
 	// No file found yet
175 175
 	$located = false;
176 176
 
177 177
 	// Try to find a template file
178
-	foreach ( (array)$template_names as $template_name ) {
178
+	foreach ((array) $template_names as $template_name) {
179 179
 
180 180
 		// Continue if template is empty
181
-		if ( empty( $template_name ) )
181
+		if (empty($template_name))
182 182
 			continue;
183 183
 
184 184
 		// Trim off any slashes from the template name
185
-		$template_name = ltrim( $template_name, '/' );
185
+		$template_name = ltrim($template_name, '/');
186 186
 
187 187
 		// try locating this template file by looping through the template paths
188
-		foreach( wpinv_get_theme_template_paths() as $template_path ) {
188
+		foreach (wpinv_get_theme_template_paths() as $template_path) {
189 189
 
190
-			if( file_exists( $template_path . $template_name ) ) {
190
+			if (file_exists($template_path . $template_name)) {
191 191
 				$located = $template_path . $template_name;
192 192
 				break;
193 193
 			}
194 194
 		}
195 195
 
196
-		if( !empty( $located ) ) {
196
+		if (!empty($located)) {
197 197
 			break;
198 198
 		}
199 199
 	}
200 200
 
201
-	if ( ( true == $load ) && ! empty( $located ) )
202
-		load_template( $located, $require_once );
201
+	if ((true == $load) && !empty($located))
202
+		load_template($located, $require_once);
203 203
 
204 204
 	return $located;
205 205
 }
@@ -208,159 +208,159 @@  discard block
 block discarded – undo
208 208
 	$template_dir = wpinv_get_theme_template_dir_name();
209 209
 
210 210
 	$file_paths = array(
211
-		1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
212
-		10 => trailingslashit( get_template_directory() ) . $template_dir,
211
+		1 => trailingslashit(get_stylesheet_directory()) . $template_dir,
212
+		10 => trailingslashit(get_template_directory()) . $template_dir,
213 213
 		100 => wpinv_get_templates_dir()
214 214
 	);
215 215
 
216
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
216
+	$file_paths = apply_filters('wpinv_template_paths', $file_paths);
217 217
 
218 218
 	// sort the file paths based on priority
219
-	ksort( $file_paths, SORT_NUMERIC );
219
+	ksort($file_paths, SORT_NUMERIC);
220 220
 
221
-	return array_map( 'trailingslashit', $file_paths );
221
+	return array_map('trailingslashit', $file_paths);
222 222
 }
223 223
 
224 224
 function wpinv_get_theme_template_dir_name() {
225
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
225
+	return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing'));
226 226
 }
227 227
 
228 228
 function wpinv_checkout_meta_tags() {
229 229
 
230 230
 	$pages   = array();
231
-	$pages[] = wpinv_get_option( 'success_page' );
232
-	$pages[] = wpinv_get_option( 'failure_page' );
233
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
234
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
231
+	$pages[] = wpinv_get_option('success_page');
232
+	$pages[] = wpinv_get_option('failure_page');
233
+	$pages[] = wpinv_get_option('invoice_history_page');
234
+	$pages[] = wpinv_get_option('invoice_subscription_page');
235 235
 
236
-	if( !wpinv_is_checkout() && !is_page( $pages ) ) {
236
+	if (!wpinv_is_checkout() && !is_page($pages)) {
237 237
 		return;
238 238
 	}
239 239
 
240 240
 	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
241 241
 }
242
-add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
242
+add_action('wp_head', 'wpinv_checkout_meta_tags');
243 243
 
244
-function wpinv_add_body_classes( $class ) {
245
-	$classes = (array)$class;
244
+function wpinv_add_body_classes($class) {
245
+	$classes = (array) $class;
246 246
 
247
-	if( wpinv_is_checkout() ) {
247
+	if (wpinv_is_checkout()) {
248 248
 		$classes[] = 'wpinv-checkout';
249 249
 		$classes[] = 'wpinv-page';
250 250
 	}
251 251
 
252
-	if( wpinv_is_success_page() ) {
252
+	if (wpinv_is_success_page()) {
253 253
 		$classes[] = 'wpinv-success';
254 254
 		$classes[] = 'wpinv-page';
255 255
 	}
256 256
 
257
-	if( wpinv_is_failed_transaction_page() ) {
257
+	if (wpinv_is_failed_transaction_page()) {
258 258
 		$classes[] = 'wpinv-failed-transaction';
259 259
 		$classes[] = 'wpinv-page';
260 260
 	}
261 261
 
262
-	if( wpinv_is_invoice_history_page() ) {
262
+	if (wpinv_is_invoice_history_page()) {
263 263
 		$classes[] = 'wpinv-history';
264 264
 		$classes[] = 'wpinv-page';
265 265
 	}
266 266
 
267
-	if( wpinv_is_subscriptions_history_page() ) {
267
+	if (wpinv_is_subscriptions_history_page()) {
268 268
 		$classes[] = 'wpinv-subscription';
269 269
 		$classes[] = 'wpinv-page';
270 270
 	}
271 271
 
272
-	if( wpinv_is_test_mode() ) {
272
+	if (wpinv_is_test_mode()) {
273 273
 		$classes[] = 'wpinv-test-mode';
274 274
 		$classes[] = 'wpinv-page';
275 275
 	}
276 276
 
277
-	return array_unique( $classes );
277
+	return array_unique($classes);
278 278
 }
279
-add_filter( 'body_class', 'wpinv_add_body_classes' );
279
+add_filter('body_class', 'wpinv_add_body_classes');
280 280
 
281
-function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) {
282
-    $args = array( 'nopaging' => true );
281
+function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') {
282
+    $args = array('nopaging' => true);
283 283
 
284
-    if ( ! empty( $status ) )
284
+    if (!empty($status))
285 285
         $args['post_status'] = $status;
286 286
 
287
-    $discounts = wpinv_get_discounts( $args );
287
+    $discounts = wpinv_get_discounts($args);
288 288
     $options   = array();
289 289
 
290
-    if ( $discounts ) {
291
-        foreach ( $discounts as $discount ) {
292
-            $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) );
290
+    if ($discounts) {
291
+        foreach ($discounts as $discount) {
292
+            $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID));
293 293
         }
294 294
     } else {
295
-        $options[0] = __( 'No discounts found', 'invoicing' );
295
+        $options[0] = __('No discounts found', 'invoicing');
296 296
     }
297 297
 
298
-    $output = wpinv_html_select( array(
298
+    $output = wpinv_html_select(array(
299 299
         'name'             => $name,
300 300
         'selected'         => $selected,
301 301
         'options'          => $options,
302 302
         'show_option_all'  => false,
303 303
         'show_option_none' => false,
304
-    ) );
304
+    ));
305 305
 
306 306
     return $output;
307 307
 }
308 308
 
309
-function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
310
-    $current     = date( 'Y' );
311
-    $start_year  = $current - absint( $years_before );
312
-    $end_year    = $current + absint( $years_after );
313
-    $selected    = empty( $selected ) ? date( 'Y' ) : $selected;
309
+function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) {
310
+    $current     = date('Y');
311
+    $start_year  = $current - absint($years_before);
312
+    $end_year    = $current + absint($years_after);
313
+    $selected    = empty($selected) ? date('Y') : $selected;
314 314
     $options     = array();
315 315
 
316
-    while ( $start_year <= $end_year ) {
317
-        $options[ absint( $start_year ) ] = $start_year;
316
+    while ($start_year <= $end_year) {
317
+        $options[absint($start_year)] = $start_year;
318 318
         $start_year++;
319 319
     }
320 320
 
321
-    $output = wpinv_html_select( array(
321
+    $output = wpinv_html_select(array(
322 322
         'name'             => $name,
323 323
         'selected'         => $selected,
324 324
         'options'          => $options,
325 325
         'show_option_all'  => false,
326 326
         'show_option_none' => false
327
-    ) );
327
+    ));
328 328
 
329 329
     return $output;
330 330
 }
331 331
 
332
-function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) {
332
+function wpinv_html_month_dropdown($name = 'month', $selected = 0) {
333 333
 
334 334
     $options = array(
335
-        '1'  => __( 'January', 'invoicing' ),
336
-        '2'  => __( 'February', 'invoicing' ),
337
-        '3'  => __( 'March', 'invoicing' ),
338
-        '4'  => __( 'April', 'invoicing' ),
339
-        '5'  => __( 'May', 'invoicing' ),
340
-        '6'  => __( 'June', 'invoicing' ),
341
-        '7'  => __( 'July', 'invoicing' ),
342
-        '8'  => __( 'August', 'invoicing' ),
343
-        '9'  => __( 'September', 'invoicing' ),
344
-        '10' => __( 'October', 'invoicing' ),
345
-        '11' => __( 'November', 'invoicing' ),
346
-        '12' => __( 'December', 'invoicing' ),
335
+        '1'  => __('January', 'invoicing'),
336
+        '2'  => __('February', 'invoicing'),
337
+        '3'  => __('March', 'invoicing'),
338
+        '4'  => __('April', 'invoicing'),
339
+        '5'  => __('May', 'invoicing'),
340
+        '6'  => __('June', 'invoicing'),
341
+        '7'  => __('July', 'invoicing'),
342
+        '8'  => __('August', 'invoicing'),
343
+        '9'  => __('September', 'invoicing'),
344
+        '10' => __('October', 'invoicing'),
345
+        '11' => __('November', 'invoicing'),
346
+        '12' => __('December', 'invoicing'),
347 347
     );
348 348
 
349 349
     // If no month is selected, default to the current month
350
-    $selected = empty( $selected ) ? date( 'n' ) : $selected;
350
+    $selected = empty($selected) ? date('n') : $selected;
351 351
 
352
-    $output = wpinv_html_select( array(
352
+    $output = wpinv_html_select(array(
353 353
         'name'             => $name,
354 354
         'selected'         => $selected,
355 355
         'options'          => $options,
356 356
         'show_option_all'  => false,
357 357
         'show_option_none' => false
358
-    ) );
358
+    ));
359 359
 
360 360
     return $output;
361 361
 }
362 362
 
363
-function wpinv_html_select( $args = array() ) {
363
+function wpinv_html_select($args = array()) {
364 364
     $defaults = array(
365 365
         'options'          => array(),
366 366
         'name'             => null,
@@ -369,8 +369,8 @@  discard block
 block discarded – undo
369 369
         'selected'         => 0,
370 370
         'placeholder'      => null,
371 371
         'multiple'         => false,
372
-        'show_option_all'  => _x( 'All', 'all dropdown items', 'invoicing' ),
373
-        'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ),
372
+        'show_option_all'  => _x('All', 'all dropdown items', 'invoicing'),
373
+        'show_option_none' => _x('None', 'no dropdown items', 'invoicing'),
374 374
         'data'             => array(),
375 375
         'onchange'         => null,
376 376
         'required'         => false,
@@ -378,74 +378,74 @@  discard block
 block discarded – undo
378 378
         'readonly'         => false,
379 379
     );
380 380
 
381
-    $args = wp_parse_args( $args, $defaults );
381
+    $args = wp_parse_args($args, $defaults);
382 382
 
383 383
     $data_elements = '';
384
-    foreach ( $args['data'] as $key => $value ) {
385
-        $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
384
+    foreach ($args['data'] as $key => $value) {
385
+        $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"';
386 386
     }
387 387
 
388
-    if( $args['multiple'] ) {
388
+    if ($args['multiple']) {
389 389
         $multiple = ' MULTIPLE';
390 390
     } else {
391 391
         $multiple = '';
392 392
     }
393 393
 
394
-    if( $args['placeholder'] ) {
394
+    if ($args['placeholder']) {
395 395
         $placeholder = $args['placeholder'];
396 396
     } else {
397 397
         $placeholder = '';
398 398
     }
399 399
     
400 400
     $options = '';
401
-    if( !empty( $args['onchange'] ) ) {
402
-        $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"';
401
+    if (!empty($args['onchange'])) {
402
+        $options .= ' onchange="' . esc_attr($args['onchange']) . '"';
403 403
     }
404 404
     
405
-    if( !empty( $args['required'] ) ) {
405
+    if (!empty($args['required'])) {
406 406
         $options .= ' required="required"';
407 407
     }
408 408
     
409
-    if( !empty( $args['disabled'] ) ) {
409
+    if (!empty($args['disabled'])) {
410 410
         $options .= ' disabled';
411 411
     }
412 412
     
413
-    if( !empty( $args['readonly'] ) ) {
413
+    if (!empty($args['readonly'])) {
414 414
         $options .= ' readonly';
415 415
     }
416 416
 
417
-    $class  = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
418
-    $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>';
417
+    $class  = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
418
+    $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>';
419 419
 
420
-    if ( $args['show_option_all'] ) {
421
-        if( $args['multiple'] ) {
422
-            $selected = selected( true, in_array( 0, $args['selected'] ), false );
420
+    if ($args['show_option_all']) {
421
+        if ($args['multiple']) {
422
+            $selected = selected(true, in_array(0, $args['selected']), false);
423 423
         } else {
424
-            $selected = selected( $args['selected'], 0, false );
424
+            $selected = selected($args['selected'], 0, false);
425 425
         }
426
-        $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
426
+        $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>';
427 427
     }
428 428
 
429
-    if ( !empty( $args['options'] ) ) {
429
+    if (!empty($args['options'])) {
430 430
 
431
-        if ( $args['show_option_none'] ) {
432
-            if( $args['multiple'] ) {
433
-                $selected = selected( true, in_array( "", $args['selected'] ), false );
431
+        if ($args['show_option_none']) {
432
+            if ($args['multiple']) {
433
+                $selected = selected(true, in_array("", $args['selected']), false);
434 434
             } else {
435
-                $selected = selected( $args['selected'] === "", true, false );
435
+                $selected = selected($args['selected'] === "", true, false);
436 436
             }
437
-            $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
437
+            $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>';
438 438
         }
439 439
 
440
-        foreach( $args['options'] as $key => $option ) {
440
+        foreach ($args['options'] as $key => $option) {
441 441
 
442
-            if( $args['multiple'] && is_array( $args['selected'] ) ) {
443
-                $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false );
442
+            if ($args['multiple'] && is_array($args['selected'])) {
443
+                $selected = selected(true, (bool) in_array($key, $args['selected']), false);
444 444
             } else {
445
-                $selected = selected( $args['selected'], $key, false );
445
+                $selected = selected($args['selected'], $key, false);
446 446
             }
447 447
 
448
-            $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
448
+            $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>';
449 449
         }
450 450
     }
451 451
 
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
     return $output;
455 455
 }
456 456
 
457
-function wpinv_item_dropdown( $args = array() ) {
457
+function wpinv_item_dropdown($args = array()) {
458 458
     $defaults = array(
459 459
         'name'              => 'wpi_item',
460 460
         'id'                => 'wpi_item',
@@ -462,14 +462,14 @@  discard block
 block discarded – undo
462 462
         'multiple'          => false,
463 463
         'selected'          => 0,
464 464
         'number'            => 100,
465
-        'placeholder'       => __( 'Choose a item', 'invoicing' ),
466
-        'data'              => array( 'search-type' => 'item' ),
465
+        'placeholder'       => __('Choose a item', 'invoicing'),
466
+        'data'              => array('search-type' => 'item'),
467 467
         'show_option_all'   => false,
468 468
         'show_option_none'  => false,
469 469
         'show_recurring'    => false,
470 470
     );
471 471
 
472
-    $args = wp_parse_args( $args, $defaults );
472
+    $args = wp_parse_args($args, $defaults);
473 473
 
474 474
     $item_args = array(
475 475
         'post_type'      => 'wpi_item',
@@ -478,44 +478,44 @@  discard block
 block discarded – undo
478 478
         'posts_per_page' => $args['number']
479 479
     );
480 480
     
481
-    $item_args  = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults );
481
+    $item_args  = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults);
482 482
 
483
-    $items      = get_posts( $item_args );
483
+    $items      = get_posts($item_args);
484 484
     $options    = array();
485
-    if ( $items ) {
486
-        foreach ( $items as $item ) {
487
-            $title = esc_html( $item->post_title );
485
+    if ($items) {
486
+        foreach ($items as $item) {
487
+            $title = esc_html($item->post_title);
488 488
             
489
-            if ( !empty( $args['show_recurring'] ) ) {
490
-                $title .= wpinv_get_item_suffix( $item->ID, false );
489
+            if (!empty($args['show_recurring'])) {
490
+                $title .= wpinv_get_item_suffix($item->ID, false);
491 491
             }
492 492
             
493
-            $options[ absint( $item->ID ) ] = $title;
493
+            $options[absint($item->ID)] = $title;
494 494
         }
495 495
     }
496 496
 
497 497
     // This ensures that any selected items are included in the drop down
498
-    if( is_array( $args['selected'] ) ) {
499
-        foreach( $args['selected'] as $item ) {
500
-            if( ! in_array( $item, $options ) ) {
501
-                $title = get_the_title( $item );
502
-                if ( !empty( $args['show_recurring'] ) ) {
503
-                    $title .= wpinv_get_item_suffix( $item, false );
498
+    if (is_array($args['selected'])) {
499
+        foreach ($args['selected'] as $item) {
500
+            if (!in_array($item, $options)) {
501
+                $title = get_the_title($item);
502
+                if (!empty($args['show_recurring'])) {
503
+                    $title .= wpinv_get_item_suffix($item, false);
504 504
                 }
505 505
                 $options[$item] = $title;
506 506
             }
507 507
         }
508
-    } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) {
509
-        if ( ! in_array( $args['selected'], $options ) ) {
510
-            $title = get_the_title( $args['selected'] );
511
-            if ( !empty( $args['show_recurring'] ) ) {
512
-                $title .= wpinv_get_item_suffix( $args['selected'], false );
508
+    } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
509
+        if (!in_array($args['selected'], $options)) {
510
+            $title = get_the_title($args['selected']);
511
+            if (!empty($args['show_recurring'])) {
512
+                $title .= wpinv_get_item_suffix($args['selected'], false);
513 513
             }
514
-            $options[$args['selected']] = get_the_title( $args['selected'] );
514
+            $options[$args['selected']] = get_the_title($args['selected']);
515 515
         }
516 516
     }
517 517
 
518
-    $output = wpinv_html_select( array(
518
+    $output = wpinv_html_select(array(
519 519
         'name'             => $args['name'],
520 520
         'selected'         => $args['selected'],
521 521
         'id'               => $args['id'],
@@ -526,12 +526,12 @@  discard block
 block discarded – undo
526 526
         'show_option_all'  => $args['show_option_all'],
527 527
         'show_option_none' => $args['show_option_none'],
528 528
         'data'             => $args['data'],
529
-    ) );
529
+    ));
530 530
 
531 531
     return $output;
532 532
 }
533 533
 
534
-function wpinv_html_checkbox( $args = array() ) {
534
+function wpinv_html_checkbox($args = array()) {
535 535
     $defaults = array(
536 536
         'name'     => null,
537 537
         'current'  => null,
@@ -542,38 +542,38 @@  discard block
 block discarded – undo
542 542
         )
543 543
     );
544 544
 
545
-    $args = wp_parse_args( $args, $defaults );
545
+    $args = wp_parse_args($args, $defaults);
546 546
 
547
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
547
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
548 548
     $options = '';
549
-    if ( ! empty( $args['options']['disabled'] ) ) {
549
+    if (!empty($args['options']['disabled'])) {
550 550
         $options .= ' disabled="disabled"';
551
-    } elseif ( ! empty( $args['options']['readonly'] ) ) {
551
+    } elseif (!empty($args['options']['readonly'])) {
552 552
         $options .= ' readonly';
553 553
     }
554 554
 
555
-    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />';
555
+    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />';
556 556
 
557 557
     return $output;
558 558
 }
559 559
 
560
-function wpinv_html_text( $args = array() ) {
560
+function wpinv_html_text($args = array()) {
561 561
     // Backwards compatibility
562
-    if ( func_num_args() > 1 ) {
562
+    if (func_num_args() > 1) {
563 563
         $args = func_get_args();
564 564
 
565 565
         $name  = $args[0];
566
-        $value = isset( $args[1] ) ? $args[1] : '';
567
-        $label = isset( $args[2] ) ? $args[2] : '';
568
-        $desc  = isset( $args[3] ) ? $args[3] : '';
566
+        $value = isset($args[1]) ? $args[1] : '';
567
+        $label = isset($args[2]) ? $args[2] : '';
568
+        $desc  = isset($args[3]) ? $args[3] : '';
569 569
     }
570 570
 
571 571
     $defaults = array(
572 572
         'id'           => '',
573
-        'name'         => isset( $name )  ? $name  : 'text',
574
-        'value'        => isset( $value ) ? $value : null,
575
-        'label'        => isset( $label ) ? $label : null,
576
-        'desc'         => isset( $desc )  ? $desc  : null,
573
+        'name'         => isset($name) ? $name : 'text',
574
+        'value'        => isset($value) ? $value : null,
575
+        'label'        => isset($label) ? $label : null,
576
+        'desc'         => isset($desc) ? $desc : null,
577 577
         'placeholder'  => '',
578 578
         'class'        => 'regular-text',
579 579
         'disabled'     => false,
@@ -583,51 +583,51 @@  discard block
 block discarded – undo
583 583
         'data'         => false
584 584
     );
585 585
 
586
-    $args = wp_parse_args( $args, $defaults );
586
+    $args = wp_parse_args($args, $defaults);
587 587
 
588
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
588
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
589 589
     $options = '';
590
-    if( $args['required'] ) {
590
+    if ($args['required']) {
591 591
         $options .= ' required="required"';
592 592
     }
593
-    if( $args['readonly'] ) {
593
+    if ($args['readonly']) {
594 594
         $options .= ' readonly';
595 595
     }
596
-    if( $args['readonly'] ) {
596
+    if ($args['readonly']) {
597 597
         $options .= ' readonly';
598 598
     }
599 599
 
600 600
     $data = '';
601
-    if ( !empty( $args['data'] ) ) {
602
-        foreach ( $args['data'] as $key => $value ) {
603
-            $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" ';
601
+    if (!empty($args['data'])) {
602
+        foreach ($args['data'] as $key => $value) {
603
+            $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" ';
604 604
         }
605 605
     }
606 606
 
607
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
608
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
609
-    if ( ! empty( $args['desc'] ) ) {
610
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
607
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
608
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>';
609
+    if (!empty($args['desc'])) {
610
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
611 611
     }
612 612
 
613
-    $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] )  . '" autocomplete="' . esc_attr( $args['autocomplete'] )  . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>';
613
+    $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>';
614 614
 
615 615
     $output .= '</span>';
616 616
 
617 617
     return $output;
618 618
 }
619 619
 
620
-function wpinv_html_date_field( $args = array() ) {
621
-    if( empty( $args['class'] ) ) {
620
+function wpinv_html_date_field($args = array()) {
621
+    if (empty($args['class'])) {
622 622
         $args['class'] = 'wpiDatepicker';
623
-    } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) {
623
+    } elseif (!strpos($args['class'], 'wpiDatepicker')) {
624 624
         $args['class'] .= ' wpiDatepicker';
625 625
     }
626 626
 
627
-    return wpinv_html_text( $args );
627
+    return wpinv_html_text($args);
628 628
 }
629 629
 
630
-function wpinv_html_textarea( $args = array() ) {
630
+function wpinv_html_textarea($args = array()) {
631 631
     $defaults = array(
632 632
         'name'        => 'textarea',
633 633
         'value'       => null,
@@ -638,31 +638,31 @@  discard block
 block discarded – undo
638 638
         'placeholder' => '',
639 639
     );
640 640
 
641
-    $args = wp_parse_args( $args, $defaults );
641
+    $args = wp_parse_args($args, $defaults);
642 642
 
643
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
643
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
644 644
     $disabled = '';
645
-    if( $args['disabled'] ) {
645
+    if ($args['disabled']) {
646 646
         $disabled = ' disabled="disabled"';
647 647
     }
648 648
 
649
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
650
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
651
-    $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
649
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
650
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>';
651
+    $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>';
652 652
 
653
-    if ( ! empty( $args['desc'] ) ) {
654
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
653
+    if (!empty($args['desc'])) {
654
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
655 655
     }
656 656
     $output .= '</span>';
657 657
 
658 658
     return $output;
659 659
 }
660 660
 
661
-function wpinv_html_ajax_user_search( $args = array() ) {
661
+function wpinv_html_ajax_user_search($args = array()) {
662 662
     $defaults = array(
663 663
         'name'        => 'user_id',
664 664
         'value'       => null,
665
-        'placeholder' => __( 'Enter username', 'invoicing' ),
665
+        'placeholder' => __('Enter username', 'invoicing'),
666 666
         'label'       => null,
667 667
         'desc'        => null,
668 668
         'class'       => '',
@@ -671,13 +671,13 @@  discard block
 block discarded – undo
671 671
         'data'        => false
672 672
     );
673 673
 
674
-    $args = wp_parse_args( $args, $defaults );
674
+    $args = wp_parse_args($args, $defaults);
675 675
 
676 676
     $args['class'] = 'wpinv-ajax-user-search ' . $args['class'];
677 677
 
678 678
     $output  = '<span class="wpinv_user_search_wrap">';
679
-        $output .= wpinv_html_text( $args );
680
-        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>';
679
+        $output .= wpinv_html_text($args);
680
+        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>';
681 681
     $output .= '</span>';
682 682
 
683 683
     return $output;
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
 function wpinv_ip_geolocation() {
687 687
     global $wpinv_euvat;
688 688
     
689
-    $ip         = !empty( $_GET['ip'] ) ? sanitize_text_field( $_GET['ip'] ) : '';    
689
+    $ip         = !empty($_GET['ip']) ? sanitize_text_field($_GET['ip']) : '';    
690 690
     $content    = '';
691 691
     $iso        = '';
692 692
     $country    = '';
@@ -697,69 +697,69 @@  discard block
 block discarded – undo
697 697
     $credit     = '';
698 698
     $address    = '';
699 699
     
700
-    if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record( $ip ) ) {
700
+    if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record($ip)) {
701 701
         try {
702 702
             $iso        = $geoip2_city->country->isoCode;
703 703
             $country    = $geoip2_city->country->name;
704
-            $region     = !empty( $geoip2_city->subdivisions ) && !empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : '';
704
+            $region     = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : '';
705 705
             $city       = $geoip2_city->city->name;
706 706
             $longitude  = $geoip2_city->location->longitude;
707 707
             $latitude   = $geoip2_city->location->latitude;
708
-            $credit     = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' );
709
-        } catch( Exception $e ) { }
708
+            $credit     = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing');
709
+        } catch (Exception $e) { }
710 710
     }
711 711
     
712
-    if ( !( $iso && $longitude && $latitude ) && function_exists( 'simplexml_load_file' ) ) {
712
+    if (!($iso && $longitude && $latitude) && function_exists('simplexml_load_file')) {
713 713
         try {
714
-            $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip );
714
+            $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip);
715 715
             
716
-            if ( !empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && !empty( $load_xml->geoplugin_latitude ) && !empty( $load_xml->geoplugin_longitude ) ) {
716
+            if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) {
717 717
                 $iso        = $load_xml->geoplugin_countryCode;
718 718
                 $country    = $load_xml->geoplugin_countryName;
719
-                $region     = !empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : '';
720
-                $city       = !empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : '';
719
+                $region     = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : '';
720
+                $city       = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : '';
721 721
                 $longitude  = $load_xml->geoplugin_longitude;
722 722
                 $latitude   = $load_xml->geoplugin_latitude;
723 723
                 $credit     = $load_xml->geoplugin_credit;
724
-                $credit     = __( 'Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing' ) . '<br>' . $load_xml->geoplugin_credit;
724
+                $credit     = __('Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing') . '<br>' . $load_xml->geoplugin_credit;
725 725
             }
726
-        } catch( Exception $e ) { }
726
+        } catch (Exception $e) { }
727 727
     }
728 728
     
729
-    if ( $iso && $longitude && $latitude ) {
730
-        if ( $city ) {
729
+    if ($iso && $longitude && $latitude) {
730
+        if ($city) {
731 731
             $address .= $city . ', ';
732 732
         }
733 733
         
734
-        if ( $region ) {
734
+        if ($region) {
735 735
             $address .= $region . ', ';
736 736
         }
737 737
         
738 738
         $address .= $country . ' (' . $iso . ')';
739
-        $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $address ) . '</p>';
740
-        $content .= '<p>'. $credit . '</p>';
739
+        $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $address) . '</p>';
740
+        $content .= '<p>' . $credit . '</p>';
741 741
     } else {
742
-        $content = '<p>'. sprintf( __( 'Unable to find geolocation for the IP address: %s', 'invoicing' ), $ip ) . '</p>';
742
+        $content = '<p>' . sprintf(__('Unable to find geolocation for the IP address: %s', 'invoicing'), $ip) . '</p>';
743 743
     }
744 744
     ?>
745 745
 <!DOCTYPE html>
746
-<html><head><title><?php echo sprintf( __( 'IP: %s', 'invoicing' ), $ip );?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head>
746
+<html><head><title><?php echo sprintf(__('IP: %s', 'invoicing'), $ip); ?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head>
747 747
 <body>
748
-    <?php if ( $latitude && $latitude ) { ?>
748
+    <?php if ($latitude && $latitude) { ?>
749 749
     <div id="map"></div>
750 750
         <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.js"></script>
751 751
         <script type="text/javascript">
752 752
         var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
753 753
             osmAttrib = '&copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',
754 754
             osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}),
755
-            latlng = new L.LatLng(<?php echo $latitude;?>, <?php echo $longitude;?>);
755
+            latlng = new L.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>);
756 756
 
757 757
         var map = new L.Map('map', {center: latlng, zoom: 12, layers: [osm]});
758 758
 
759 759
         var marker = new L.Marker(latlng);
760 760
         map.addLayer(marker);
761 761
 
762
-        marker.bindPopup("<p><?php esc_attr_e( $address );?></p>");
762
+        marker.bindPopup("<p><?php esc_attr_e($address); ?></p>");
763 763
     </script>
764 764
     <?php } ?>
765 765
     <div style="height:100px"><?php echo $content; ?></div>
@@ -767,18 +767,18 @@  discard block
 block discarded – undo
767 767
 <?php
768 768
     exit;
769 769
 }
770
-add_action( 'wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation' );
771
-add_action( 'wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation' );
770
+add_action('wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation');
771
+add_action('wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation');
772 772
 
773 773
 // Set up the template for the invoice.
774
-function wpinv_template( $template ) {
774
+function wpinv_template($template) {
775 775
     global $post, $wp_query;
776 776
     
777
-    if ( ( is_single() || is_404() ) && !empty( $post->ID ) && (get_post_type( $post->ID ) == 'wpi_invoice' or get_post_type( $post->ID ) == 'wpi_quote')) {
778
-        if ( wpinv_user_can_view_invoice( $post->ID ) ) {
779
-            $template = wpinv_get_template_part( 'wpinv-invoice-print', false, false );
777
+    if ((is_single() || is_404()) && !empty($post->ID) && (get_post_type($post->ID) == 'wpi_invoice' or get_post_type($post->ID) == 'wpi_quote')) {
778
+        if (wpinv_user_can_view_invoice($post->ID)) {
779
+            $template = wpinv_get_template_part('wpinv-invoice-print', false, false);
780 780
         } else {
781
-            $template = wpinv_get_template_part( 'wpinv-invalid-access', false, false );
781
+            $template = wpinv_get_template_part('wpinv-invalid-access', false, false);
782 782
         }
783 783
     }
784 784
 
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 
788 788
 function wpinv_get_business_address() {
789 789
     $business_address   = wpinv_store_address();
790
-    $business_address   = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : '';
790
+    $business_address   = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : '';
791 791
     
792 792
     /*
793 793
     $default_country    = wpinv_get_default_country();
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
     
812 812
     $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : '';
813 813
     
814
-    return apply_filters( 'wpinv_get_business_address', $business_address );
814
+    return apply_filters('wpinv_get_business_address', $business_address);
815 815
 }
816 816
 
817 817
 function wpinv_display_from_address() {
@@ -821,107 +821,107 @@  discard block
 block discarded – undo
821 821
     if (empty($from_name)) {
822 822
         $from_name = wpinv_get_business_name();
823 823
     }
824
-    ?><div class="from col-xs-2"><strong><?php _e( 'From:', 'invoicing' ) ?></strong></div>
824
+    ?><div class="from col-xs-2"><strong><?php _e('From:', 'invoicing') ?></strong></div>
825 825
     <div class="wrapper col-xs-10">
826
-        <div class="name"><?php echo esc_html( $from_name ); ?></div>
827
-        <?php if ( $address = wpinv_get_business_address() ) { ?>
828
-        <div class="address"><?php echo wpautop( wp_kses_post( $address ) );?></div>
826
+        <div class="name"><?php echo esc_html($from_name); ?></div>
827
+        <?php if ($address = wpinv_get_business_address()) { ?>
828
+        <div class="address"><?php echo wpautop(wp_kses_post($address)); ?></div>
829 829
         <?php } ?>
830
-        <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?>
831
-        <div class="email_from"><?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), $email_from );?></div>
830
+        <?php if ($email_from = wpinv_mail_get_from_address()) { ?>
831
+        <div class="email_from"><?php echo wp_sprintf(__('Email: %s', 'invoicing'), $email_from); ?></div>
832 832
         <?php } ?>
833 833
     </div>
834 834
     <?php
835 835
 }
836 836
 
837
-function wpinv_watermark( $id = 0 ) {
838
-    $output = wpinv_get_watermark( $id );
837
+function wpinv_watermark($id = 0) {
838
+    $output = wpinv_get_watermark($id);
839 839
     
840
-    return apply_filters( 'wpinv_get_watermark', $output, $id );
840
+    return apply_filters('wpinv_get_watermark', $output, $id);
841 841
 }
842 842
 
843
-function wpinv_get_watermark( $id ) {
844
-    if ( !$id > 0 ) {
843
+function wpinv_get_watermark($id) {
844
+    if (!$id > 0) {
845 845
         return NULL;
846 846
     }
847
-    $invoice = wpinv_get_invoice( $id );
847
+    $invoice = wpinv_get_invoice($id);
848 848
     
849
-    if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) {
850
-        if ( $invoice->is_paid() ) {
851
-            return __( 'Paid', 'invoicing' );
849
+    if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) {
850
+        if ($invoice->is_paid()) {
851
+            return __('Paid', 'invoicing');
852 852
         }
853
-        if ( $invoice->is_refunded() ) {
854
-            return __( 'Refunded', 'invoicing' );
853
+        if ($invoice->is_refunded()) {
854
+            return __('Refunded', 'invoicing');
855 855
         }
856
-        if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) {
857
-            return __( 'Cancelled', 'invoicing' );
856
+        if ($invoice->has_status(array('wpi-cancelled'))) {
857
+            return __('Cancelled', 'invoicing');
858 858
         }
859 859
     }
860 860
     
861 861
     return NULL;
862 862
 }
863 863
 
864
-function wpinv_display_invoice_details( $invoice ) {
864
+function wpinv_display_invoice_details($invoice) {
865 865
     global $wpinv_euvat;
866 866
     
867 867
     $invoice_id = $invoice->ID;
868 868
     $vat_name   = $wpinv_euvat->get_vat_name();
869 869
     $use_taxes  = wpinv_use_taxes();
870 870
     
871
-    $invoice_status = wpinv_get_invoice_status( $invoice_id );
871
+    $invoice_status = wpinv_get_invoice_status($invoice_id);
872 872
     ?>
873 873
     <table class="table table-bordered table-sm">
874
-        <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?>
874
+        <?php if ($invoice_number = wpinv_get_invoice_number($invoice_id)) { ?>
875 875
             <tr class="wpi-row-number">
876
-                <th><?php echo apply_filters( 'wpinv_invoice_number_label', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></th>
877
-                <td><?php echo esc_html( $invoice_number ); ?></td>
876
+                <th><?php echo apply_filters('wpinv_invoice_number_label', __('Invoice Number', 'invoicing'), $invoice); ?></th>
877
+                <td><?php echo esc_html($invoice_number); ?></td>
878 878
             </tr>
879 879
         <?php } ?>
880 880
         <tr class="wpi-row-status">
881
-            <th><?php echo apply_filters( 'wpinv_invoice_status_label', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></th>
882
-            <td><?php echo wpinv_invoice_status_label( $invoice_status, wpinv_get_invoice_status( $invoice_id, true ) ); ?></td>
881
+            <th><?php echo apply_filters('wpinv_invoice_status_label', __('Invoice Status', 'invoicing'), $invoice); ?></th>
882
+            <td><?php echo wpinv_invoice_status_label($invoice_status, wpinv_get_invoice_status($invoice_id, true)); ?></td>
883 883
         </tr>
884
-        <?php if ( $invoice->is_renewal() ) { ?>
884
+        <?php if ($invoice->is_renewal()) { ?>
885 885
         <tr class="wpi-row-parent">
886
-            <th><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Parent Invoice', 'invoicing' ), $invoice ); ?></th>
887
-            <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td>
886
+            <th><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Parent Invoice', 'invoicing'), $invoice); ?></th>
887
+            <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td>
888 888
         </tr>
889 889
         <?php } ?>
890
-        <?php if ( ( $gateway_name = wpinv_get_payment_gateway_name( $invoice_id ) ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?>
890
+        <?php if (($gateway_name = wpinv_get_payment_gateway_name($invoice_id)) && ($invoice->is_paid() || $invoice->is_refunded())) { ?>
891 891
             <tr class="wpi-row-gateway">
892
-                <th><?php echo apply_filters( 'wpinv_invoice_payment_method_label', __( 'Payment Method', 'invoicing' ), $invoice ); ?></th>
892
+                <th><?php echo apply_filters('wpinv_invoice_payment_method_label', __('Payment Method', 'invoicing'), $invoice); ?></th>
893 893
                 <td><?php echo $gateway_name; ?></td>
894 894
             </tr>
895 895
         <?php } ?>
896
-        <?php if ( $invoice_date = wpinv_get_invoice_date( $invoice_id ) ) { ?>
896
+        <?php if ($invoice_date = wpinv_get_invoice_date($invoice_id)) { ?>
897 897
             <tr class="wpi-row-date">
898
-                <th><?php echo apply_filters( 'wpinv_invoice_date_label', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></th>
898
+                <th><?php echo apply_filters('wpinv_invoice_date_label', __('Invoice Date', 'invoicing'), $invoice); ?></th>
899 899
                 <td><?php echo $invoice_date; ?></td>
900 900
             </tr>
901 901
         <?php } ?>
902
-        <?php do_action( 'wpinv_display_details_before_due_date', $invoice_id ); ?>
903
-        <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date( true ) ) ) { ?>
902
+        <?php do_action('wpinv_display_details_before_due_date', $invoice_id); ?>
903
+        <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date(true))) { ?>
904 904
             <tr class="wpi-row-date">
905
-                <th><?php echo apply_filters( 'wpinv_invoice_due_date_label', __( 'Due Date', 'invoicing' ), $invoice ); ?></th>
905
+                <th><?php echo apply_filters('wpinv_invoice_due_date_label', __('Due Date', 'invoicing'), $invoice); ?></th>
906 906
                 <td><?php echo $due_date; ?></td>
907 907
             </tr>
908 908
         <?php } ?>
909
-        <?php do_action( 'wpinv_display_details_after_due_date', $invoice_id ); ?>
910
-        <?php if ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?>
909
+        <?php do_action('wpinv_display_details_after_due_date', $invoice_id); ?>
910
+        <?php if ($owner_vat_number = $wpinv_euvat->get_vat_number()) { ?>
911 911
             <tr class="wpi-row-ovatno">
912
-                <th><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th>
912
+                <th><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th>
913 913
                 <td><?php echo $owner_vat_number; ?></td>
914 914
             </tr>
915 915
         <?php } ?>
916
-        <?php if ( $use_taxes && ( $user_vat_number = wpinv_get_invoice_vat_number( $invoice_id ) ) ) { ?>
916
+        <?php if ($use_taxes && ($user_vat_number = wpinv_get_invoice_vat_number($invoice_id))) { ?>
917 917
             <tr class="wpi-row-uvatno">
918
-                <th><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th>
918
+                <th><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th>
919 919
                 <td><?php echo $user_vat_number; ?></td>
920 920
             </tr>
921 921
         <?php } ?>
922 922
         <tr class="table-active tr-total wpi-row-total">
923
-            <th><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></th>
924
-            <td><strong><?php echo wpinv_payment_total( $invoice_id, true ); ?></strong></td>
923
+            <th><strong><?php _e('Total Amount', 'invoicing') ?></strong></th>
924
+            <td><strong><?php echo wpinv_payment_total($invoice_id, true); ?></strong></td>
925 925
         </tr>
926 926
     </table>
927 927
 <?php
@@ -937,84 +937,84 @@  discard block
 block discarded – undo
937 937
  * @param  string $separator How to separate address lines.
938 938
  * @return string
939 939
  */
940
-function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) {
940
+function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') {
941 941
 
942 942
     // Retrieve the address markup...
943
-    $country= empty( $billing_details['country'] ) ? '' : $billing_details['country'];
944
-    $format = wpinv_get_full_address_format( $country );
943
+    $country = empty($billing_details['country']) ? '' : $billing_details['country'];
944
+    $format = wpinv_get_full_address_format($country);
945 945
 
946 946
     // ... and the replacements.
947
-    $replacements = wpinv_get_invoice_address_replacements( $billing_details );
947
+    $replacements = wpinv_get_invoice_address_replacements($billing_details);
948 948
 
949
-    $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
949
+    $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format);
950 950
     
951 951
 	// Remove unavailable tags.
952
-    $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address );
952
+    $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address);
953 953
 
954 954
     // Clean up white space.
955
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
956
-    $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
955
+	$formatted_address = preg_replace('/  +/', ' ', trim($formatted_address));
956
+    $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address);
957 957
     
958 958
     // Break newlines apart and remove empty lines/trim commas and white space.
959
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
959
+	$formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address)));
960 960
 
961 961
     // Add html breaks.
962
-	$formatted_address = implode( $separator, $formatted_address );
962
+	$formatted_address = implode($separator, $formatted_address);
963 963
 
964 964
 	// We're done!
965 965
 	return $formatted_address;
966 966
     
967 967
 }
968 968
 
969
-function wpinv_display_to_address( $invoice_id = 0 ) {
970
-    $invoice = wpinv_get_invoice( $invoice_id );
969
+function wpinv_display_to_address($invoice_id = 0) {
970
+    $invoice = wpinv_get_invoice($invoice_id);
971 971
     
972
-    if ( empty( $invoice ) ) {
972
+    if (empty($invoice)) {
973 973
         return NULL;
974 974
     }
975 975
     
976 976
     $billing_details = $invoice->get_user_info();
977
-    $output = '<div class="to col-xs-2"><strong>' . __( 'To:', 'invoicing' ) . '</strong></div>';
977
+    $output = '<div class="to col-xs-2"><strong>' . __('To:', 'invoicing') . '</strong></div>';
978 978
     $output .= '<div class="wrapper col-xs-10">';
979 979
     
980 980
     ob_start();
981
-    do_action( 'wpinv_display_to_address_top', $invoice );
981
+    do_action('wpinv_display_to_address_top', $invoice);
982 982
     $output .= ob_get_clean();
983 983
     
984
-    $address_row = wpinv_get_invoice_address_markup( $billing_details );
984
+    $address_row = wpinv_get_invoice_address_markup($billing_details);
985 985
 
986
-    if ( $address_row ) {
986
+    if ($address_row) {
987 987
         $output .= '<div class="address">' . $address_row . '</div>';
988 988
     }
989 989
 
990
-    if ( $phone = $invoice->get_phone() ) {
991
-        $output .= '<div class="phone">' . wp_sprintf( __( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ) . '</div>';
990
+    if ($phone = $invoice->get_phone()) {
991
+        $output .= '<div class="phone">' . wp_sprintf(__('Phone: %s', 'invoicing'), esc_html($phone)) . '</div>';
992 992
     }
993
-    if ( $email = $invoice->get_email() ) {
994
-        $output .= '<div class="email">' . wp_sprintf( __( 'Email: %s' , 'invoicing'), esc_html( $email ) ) . '</div>';
993
+    if ($email = $invoice->get_email()) {
994
+        $output .= '<div class="email">' . wp_sprintf(__('Email: %s', 'invoicing'), esc_html($email)) . '</div>';
995 995
     }
996 996
 
997 997
     ob_start();
998
-    do_action( 'wpinv_display_to_address_bottom', $invoice );
998
+    do_action('wpinv_display_to_address_bottom', $invoice);
999 999
     $output .= ob_get_clean();
1000 1000
     
1001 1001
     $output .= '</div>';
1002
-    $output = apply_filters( 'wpinv_display_to_address', $output, $invoice );
1002
+    $output = apply_filters('wpinv_display_to_address', $output, $invoice);
1003 1003
 
1004 1004
     echo $output;
1005 1005
 }
1006 1006
 
1007
-function wpinv_display_line_items( $invoice_id = 0 ) {
1007
+function wpinv_display_line_items($invoice_id = 0) {
1008 1008
     global $wpinv_euvat, $ajax_cart_details;
1009
-    $invoice            = wpinv_get_invoice( $invoice_id );
1009
+    $invoice            = wpinv_get_invoice($invoice_id);
1010 1010
     $quantities_enabled = wpinv_item_quantities_enabled();
1011 1011
     $use_taxes          = wpinv_use_taxes();
1012
-    if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) {
1012
+    if (!$use_taxes && (float) $invoice->get_tax() > 0) {
1013 1013
         $use_taxes = true;
1014 1014
     }
1015
-    $zero_tax           = !(float)$invoice->get_tax() > 0 ? true : false;
1016
-    $tax_label           = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' );
1017
-    $tax_title          = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : '';
1015
+    $zero_tax           = !(float) $invoice->get_tax() > 0 ? true : false;
1016
+    $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing');
1017
+    $tax_title          = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : '';
1018 1018
 
1019 1019
     $cart_details       = $invoice->get_cart_details();
1020 1020
     $ajax_cart_details  = $cart_details;
@@ -1023,67 +1023,67 @@  discard block
 block discarded – undo
1023 1023
     <table class="table table-sm table-bordered">
1024 1024
         <thead>
1025 1025
             <tr>
1026
-                <th class="name"><strong><?php _e( "Item Name", "invoicing" );?></strong></th>
1027
-                <th class="rate"><strong><?php _e( "Price", "invoicing" );?></strong></th>
1026
+                <th class="name"><strong><?php _e("Item Name", "invoicing"); ?></strong></th>
1027
+                <th class="rate"><strong><?php _e("Price", "invoicing"); ?></strong></th>
1028 1028
                 <?php if ($quantities_enabled) { ?>
1029
-                    <th class="qty"><strong><?php _e( "Qty", "invoicing" );?></strong></th>
1029
+                    <th class="qty"><strong><?php _e("Qty", "invoicing"); ?></strong></th>
1030 1030
                 <?php } ?>
1031 1031
                 <?php if ($use_taxes && !$zero_tax) { ?>
1032 1032
                     <th class="tax"><strong><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></strong></th>
1033 1033
                 <?php } ?>
1034
-                <th class="total"><strong><?php echo __( "Item Total", "invoicing" ) . ' <span class="normal small">' . $tax_title . '<span>';?></strong></th>
1034
+                <th class="total"><strong><?php echo __("Item Total", "invoicing") . ' <span class="normal small">' . $tax_title . '<span>'; ?></strong></th>
1035 1035
             </tr>
1036 1036
         </thead>
1037 1037
         <tbody>
1038 1038
         <?php 
1039
-            if ( !empty( $cart_details ) ) {
1040
-                do_action( 'wpinv_display_line_items_start', $invoice );
1039
+            if (!empty($cart_details)) {
1040
+                do_action('wpinv_display_line_items_start', $invoice);
1041 1041
 
1042 1042
                 $count = 0;
1043 1043
                 $cols  = 3;
1044
-                foreach ( $cart_details as $key => $cart_item ) {
1045
-                    $item_id    = !empty($cart_item['id']) ? absint( $cart_item['id'] ) : '';
1046
-                    $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount( $cart_item["item_price"] ) : 0;
1047
-                    $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount( $cart_item["subtotal"] ) : 0;
1048
-                    $quantity   = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1;
1044
+                foreach ($cart_details as $key => $cart_item) {
1045
+                    $item_id    = !empty($cart_item['id']) ? absint($cart_item['id']) : '';
1046
+                    $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount($cart_item["item_price"]) : 0;
1047
+                    $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount($cart_item["subtotal"]) : 0;
1048
+                    $quantity   = !empty($cart_item['quantity']) && (int) $cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1;
1049 1049
 
1050
-                    $item       = $item_id ? new WPInv_Item( $item_id ) : NULL;
1050
+                    $item       = $item_id ? new WPInv_Item($item_id) : NULL;
1051 1051
                     $summary    = '';
1052
-	                $item_name    = '';
1052
+	                $item_name = '';
1053 1053
                     $cols       = 3;
1054
-                    if ( !empty($item) ) {
1054
+                    if (!empty($item)) {
1055 1055
                         $item_name  = $item->get_name();
1056 1056
                         $summary    = $item->get_summary();
1057 1057
                     }
1058
-                    $item_name  = !empty($cart_item['name']) ? $cart_item['name'] : $item_name;
1058
+                    $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name;
1059 1059
 
1060
-                    $summary = apply_filters( 'wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice );
1060
+                    $summary = apply_filters('wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice);
1061 1061
 
1062 1062
                     $item_tax       = '';
1063 1063
                     $tax_rate       = '';
1064
-                    if ( $use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) {
1065
-                        $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() );
1066
-                        $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100;
1067
-                        $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : '';
1064
+                    if ($use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) {
1065
+                        $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency());
1066
+                        $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100;
1067
+                        $tax_rate = $tax_rate > 0 ? (float) wpinv_round_amount($tax_rate, 4) : '';
1068 1068
                         $tax_rate = $tax_rate != '' ? ' <small class="tax-rate">(' . $tax_rate . '%)</small>' : '';
1069 1069
                     }
1070 1070
 
1071 1071
                     $line_item_tax = $item_tax . $tax_rate;
1072 1072
 
1073
-                    if ( $line_item_tax === '' ) {
1073
+                    if ($line_item_tax === '') {
1074 1074
                         $line_item_tax = 0; // Zero tax
1075 1075
                     }
1076 1076
 
1077
-                    $action = apply_filters( 'wpinv_display_line_item_action', '', $cart_item, $invoice, $cols );
1077
+                    $action = apply_filters('wpinv_display_line_item_action', '', $cart_item, $invoice, $cols);
1078 1078
 
1079
-                    $line_item = '<tr class="row-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . ' wpinv-item">';
1080
-                        $line_item .= '<td class="name">' . $action. esc_html__( $item_name, 'invoicing' ) . wpinv_get_item_suffix( $item );
1081
-                        if ( $summary !== '' ) {
1082
-                            $line_item .= '<br/><small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>';
1079
+                    $line_item = '<tr class="row-' . (($count % 2 == 0) ? 'even' : 'odd') . ' wpinv-item">';
1080
+                        $line_item .= '<td class="name">' . $action . esc_html__($item_name, 'invoicing') . wpinv_get_item_suffix($item);
1081
+                        if ($summary !== '') {
1082
+                            $line_item .= '<br/><small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>';
1083 1083
                         }
1084 1084
                         $line_item .= '</td>';
1085 1085
 
1086
-                        $line_item .= '<td class="rate">' . esc_html__( wpinv_price( wpinv_format_amount( $item_price ), $invoice->get_currency() ) ) . '</td>';
1086
+                        $line_item .= '<td class="rate">' . esc_html__(wpinv_price(wpinv_format_amount($item_price), $invoice->get_currency())) . '</td>';
1087 1087
                         if ($quantities_enabled) {
1088 1088
                             $cols++;
1089 1089
                             $line_item .= '<td class="qty">' . $quantity . '</td>';
@@ -1092,55 +1092,55 @@  discard block
 block discarded – undo
1092 1092
                             $cols++;
1093 1093
                             $line_item .= '<td class="tax">' . $line_item_tax . '</td>';
1094 1094
                         }
1095
-                        $line_item .= '<td class="total">' . esc_html__( wpinv_price( wpinv_format_amount( $line_total ), $invoice->get_currency() ) ) . '</td>';
1095
+                        $line_item .= '<td class="total">' . esc_html__(wpinv_price(wpinv_format_amount($line_total), $invoice->get_currency())) . '</td>';
1096 1096
                     $line_item .= '</tr>';
1097 1097
 
1098
-                    echo apply_filters( 'wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols );
1098
+                    echo apply_filters('wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols);
1099 1099
 
1100 1100
                     $count++;
1101 1101
                 }
1102 1102
 
1103
-                do_action( 'wpinv_display_before_subtotal', $invoice, $cols );
1103
+                do_action('wpinv_display_before_subtotal', $invoice, $cols);
1104 1104
                 ?>
1105 1105
                 <tr class="row-sub-total row_odd">
1106
-                    <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_subtotal_label', '<strong>' . __( 'Sub Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td>
1107
-                    <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td>
1106
+                    <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_subtotal_label', '<strong>' . __('Sub Total', 'invoicing') . ':</strong>', $invoice); ?></td>
1107
+                    <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td>
1108 1108
                 </tr>
1109 1109
                 <?php
1110
-                do_action( 'wpinv_display_after_subtotal', $invoice, $cols );
1110
+                do_action('wpinv_display_after_subtotal', $invoice, $cols);
1111 1111
                 
1112
-                if ( wpinv_discount( $invoice_id, false ) > 0 ) {
1113
-                    do_action( 'wpinv_display_before_discount', $invoice, $cols );
1112
+                if (wpinv_discount($invoice_id, false) > 0) {
1113
+                    do_action('wpinv_display_before_discount', $invoice, $cols);
1114 1114
                     ?>
1115 1115
                         <tr class="row-discount">
1116
-                            <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</td>
1117
-                            <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td>
1116
+                            <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</td>
1117
+                            <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td>
1118 1118
                         </tr>
1119 1119
                     <?php
1120
-                    do_action( 'wpinv_display_after_discount', $invoice, $cols );
1120
+                    do_action('wpinv_display_after_discount', $invoice, $cols);
1121 1121
                 }
1122 1122
 
1123
-                if ( $use_taxes ) {
1124
-                    do_action( 'wpinv_display_before_tax', $invoice, $cols );
1123
+                if ($use_taxes) {
1124
+                    do_action('wpinv_display_before_tax', $invoice, $cols);
1125 1125
                     ?>
1126 1126
                     <tr class="row-tax">
1127
-                        <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice ); ?></td>
1128
-                        <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td>
1127
+                        <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice); ?></td>
1128
+                        <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td>
1129 1129
                     </tr>
1130 1130
                     <?php
1131
-                    do_action( 'wpinv_display_after_tax', $invoice, $cols );
1131
+                    do_action('wpinv_display_after_tax', $invoice, $cols);
1132 1132
                 }
1133 1133
 
1134
-                do_action( 'wpinv_display_before_total', $invoice, $cols );
1134
+                do_action('wpinv_display_before_total', $invoice, $cols);
1135 1135
                 ?>
1136 1136
                 <tr class="table-active row-total">
1137
-                    <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td>
1138
-                    <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td>
1137
+                    <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?></td>
1138
+                    <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td>
1139 1139
                 </tr>
1140 1140
                 <?php
1141
-                do_action( 'wpinv_display_after_total', $invoice, $cols );
1141
+                do_action('wpinv_display_after_total', $invoice, $cols);
1142 1142
 
1143
-                do_action( 'wpinv_display_line_end', $invoice, $cols );
1143
+                do_action('wpinv_display_line_end', $invoice, $cols);
1144 1144
             }
1145 1145
         ?>
1146 1146
         </tbody>
@@ -1152,56 +1152,56 @@  discard block
 block discarded – undo
1152 1152
 /**
1153 1153
  * @param WPInv_Invoice $invoice
1154 1154
  */
1155
-function wpinv_display_invoice_notes( $invoice ) {
1155
+function wpinv_display_invoice_notes($invoice) {
1156 1156
 
1157
-    $notes = wpinv_get_invoice_notes( $invoice->ID, 'customer' );
1157
+    $notes = wpinv_get_invoice_notes($invoice->ID, 'customer');
1158 1158
 
1159
-    if ( empty( $notes ) ) {
1159
+    if (empty($notes)) {
1160 1160
         return;
1161 1161
     }
1162 1162
 
1163 1163
     echo '<div class="wpi_invoice_notes_container">';
1164
-    echo '<h2>' . __( 'Invoice Notes', 'invoicing' ) .'</h2>';
1164
+    echo '<h2>' . __('Invoice Notes', 'invoicing') . '</h2>';
1165 1165
     echo '<ul class="wpi_invoice_notes">';
1166 1166
 
1167
-    foreach( $notes as $note ) {
1168
-        wpinv_get_invoice_note_line_item( $note );
1167
+    foreach ($notes as $note) {
1168
+        wpinv_get_invoice_note_line_item($note);
1169 1169
     }
1170 1170
 
1171 1171
     echo '</ul>';
1172 1172
     echo '</div>';
1173 1173
 }
1174
-add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_display_invoice_notes' );
1174
+add_action('wpinv_invoice_print_after_line_items', 'wpinv_display_invoice_notes');
1175 1175
 
1176
-function wpinv_display_invoice_totals( $invoice_id = 0 ) {
1176
+function wpinv_display_invoice_totals($invoice_id = 0) {
1177 1177
     $use_taxes = wpinv_use_taxes();
1178 1178
 
1179
-    do_action( 'wpinv_before_display_totals_table', $invoice_id ); 
1179
+    do_action('wpinv_before_display_totals_table', $invoice_id); 
1180 1180
     ?>
1181 1181
     <table class="table table-sm table-bordered table-responsive">
1182 1182
         <tbody>
1183
-            <?php do_action( 'wpinv_before_display_totals' ); ?>
1183
+            <?php do_action('wpinv_before_display_totals'); ?>
1184 1184
             <tr class="row-sub-total">
1185
-                <td class="rate"><strong><?php _e( 'Sub Total', 'invoicing' ); ?></strong></td>
1186
-                <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td>
1185
+                <td class="rate"><strong><?php _e('Sub Total', 'invoicing'); ?></strong></td>
1186
+                <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td>
1187 1187
             </tr>
1188
-            <?php do_action( 'wpinv_after_display_totals' ); ?>
1189
-            <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?>
1188
+            <?php do_action('wpinv_after_display_totals'); ?>
1189
+            <?php if (wpinv_discount($invoice_id, false) > 0) { ?>
1190 1190
                 <tr class="row-discount">
1191
-                    <td class="rate"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?></td>
1192
-                    <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td>
1191
+                    <td class="rate"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?></td>
1192
+                    <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td>
1193 1193
                 </tr>
1194
-            <?php do_action( 'wpinv_after_display_discount' ); ?>
1194
+            <?php do_action('wpinv_after_display_discount'); ?>
1195 1195
             <?php } ?>
1196
-            <?php if ( $use_taxes ) { ?>
1196
+            <?php if ($use_taxes) { ?>
1197 1197
             <tr class="row-tax">
1198
-                <td class="rate"><?php _e( 'Tax', 'invoicing' ); ?></td>
1199
-                <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td>
1198
+                <td class="rate"><?php _e('Tax', 'invoicing'); ?></td>
1199
+                <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td>
1200 1200
             </tr>
1201
-            <?php do_action( 'wpinv_after_display_tax' ); ?>
1201
+            <?php do_action('wpinv_after_display_tax'); ?>
1202 1202
             <?php } ?>
1203
-            <?php if ( $fees = wpinv_get_fees( $invoice_id ) ) { ?>
1204
-                <?php foreach ( $fees as $fee ) { ?>
1203
+            <?php if ($fees = wpinv_get_fees($invoice_id)) { ?>
1204
+                <?php foreach ($fees as $fee) { ?>
1205 1205
                     <tr class="row-fee">
1206 1206
                         <td class="rate"><?php echo $fee['label']; ?></td>
1207 1207
                         <td class="total"><?php echo $fee['amount_display']; ?></td>
@@ -1209,82 +1209,82 @@  discard block
 block discarded – undo
1209 1209
                 <?php } ?>
1210 1210
             <?php } ?>
1211 1211
             <tr class="table-active row-total">
1212
-                <td class="rate"><strong><?php _e( 'Total', 'invoicing' ) ?></strong></td>
1213
-                <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td>
1212
+                <td class="rate"><strong><?php _e('Total', 'invoicing') ?></strong></td>
1213
+                <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td>
1214 1214
             </tr>
1215
-            <?php do_action( 'wpinv_after_totals' ); ?>
1215
+            <?php do_action('wpinv_after_totals'); ?>
1216 1216
         </tbody>
1217 1217
 
1218 1218
     </table>
1219 1219
 
1220
-    <?php do_action( 'wpinv_after_totals_table' );
1220
+    <?php do_action('wpinv_after_totals_table');
1221 1221
 }
1222 1222
 
1223
-function wpinv_display_payments_info( $invoice_id = 0, $echo = true ) {
1224
-    $invoice = wpinv_get_invoice( $invoice_id );
1223
+function wpinv_display_payments_info($invoice_id = 0, $echo = true) {
1224
+    $invoice = wpinv_get_invoice($invoice_id);
1225 1225
 
1226 1226
     ob_start();
1227
-    do_action( 'wpinv_before_display_payments_info', $invoice_id );
1228
-    if ( ( $gateway_title = $invoice->get_gateway_title() ) || $invoice->is_paid() || $invoice->is_refunded() ) {
1227
+    do_action('wpinv_before_display_payments_info', $invoice_id);
1228
+    if (($gateway_title = $invoice->get_gateway_title()) || $invoice->is_paid() || $invoice->is_refunded()) {
1229 1229
         ?>
1230 1230
         <div class="wpi-payment-info">
1231
-            <p class="wpi-payment-gateway"><?php echo wp_sprintf( __( 'Payment via %s', 'invoicing' ), $gateway_title ? $gateway_title : __( 'Manually', 'invoicing' ) ); ?></p>
1232
-            <?php if ( $gateway_title ) { ?>
1233
-            <p class="wpi-payment-transid"><?php echo wp_sprintf( __( 'Transaction ID: %s', 'invoicing' ), $invoice->get_transaction_id() ); ?></p>
1231
+            <p class="wpi-payment-gateway"><?php echo wp_sprintf(__('Payment via %s', 'invoicing'), $gateway_title ? $gateway_title : __('Manually', 'invoicing')); ?></p>
1232
+            <?php if ($gateway_title) { ?>
1233
+            <p class="wpi-payment-transid"><?php echo wp_sprintf(__('Transaction ID: %s', 'invoicing'), $invoice->get_transaction_id()); ?></p>
1234 1234
             <?php } ?>
1235 1235
         </div>
1236 1236
         <?php
1237 1237
     }
1238
-    do_action( 'wpinv_after_display_payments_info', $invoice_id );
1238
+    do_action('wpinv_after_display_payments_info', $invoice_id);
1239 1239
     $outout = ob_get_clean();
1240 1240
 
1241
-    if ( $echo ) {
1241
+    if ($echo) {
1242 1242
         echo $outout;
1243 1243
     } else {
1244 1244
         return $outout;
1245 1245
     }
1246 1246
 }
1247 1247
 
1248
-function wpinv_display_style( $invoice ) {
1249
-    wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION );
1248
+function wpinv_display_style($invoice) {
1249
+    wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION);
1250 1250
 
1251
-    wp_print_styles( 'open-sans' );
1252
-    wp_print_styles( 'wpinv-single-style' );
1251
+    wp_print_styles('open-sans');
1252
+    wp_print_styles('wpinv-single-style');
1253 1253
 
1254 1254
     $custom_css = wpinv_get_option('template_custom_css');
1255
-    if(isset($custom_css) && !empty($custom_css)){
1256
-        $custom_css     = wp_kses( $custom_css, array( '\'', '\"' ) );
1257
-        $custom_css     = str_replace( '&gt;', '>', $custom_css );
1255
+    if (isset($custom_css) && !empty($custom_css)) {
1256
+        $custom_css     = wp_kses($custom_css, array('\'', '\"'));
1257
+        $custom_css     = str_replace('&gt;', '>', $custom_css);
1258 1258
         echo '<style type="text/css">';
1259 1259
         echo $custom_css;
1260 1260
         echo '</style>';
1261 1261
     }
1262 1262
 }
1263
-add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' );
1264
-add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' );
1263
+add_action('wpinv_invoice_print_head', 'wpinv_display_style');
1264
+add_action('wpinv_invalid_invoice_head', 'wpinv_display_style');
1265 1265
 
1266 1266
 function wpinv_checkout_billing_details() {
1267
-    $invoice_id = (int)wpinv_get_invoice_cart_id();
1267
+    $invoice_id = (int) wpinv_get_invoice_cart_id();
1268 1268
     if (empty($invoice_id)) {
1269
-        wpinv_error_log( 'Invoice id not found', 'ERROR', __FILE__, __LINE__ );
1269
+        wpinv_error_log('Invoice id not found', 'ERROR', __FILE__, __LINE__);
1270 1270
         return null;
1271 1271
     }
1272 1272
 
1273
-    $invoice = wpinv_get_invoice_cart( $invoice_id );
1273
+    $invoice = wpinv_get_invoice_cart($invoice_id);
1274 1274
     if (empty($invoice)) {
1275
-        wpinv_error_log( 'Invoice not found', 'ERROR', __FILE__, __LINE__ );
1275
+        wpinv_error_log('Invoice not found', 'ERROR', __FILE__, __LINE__);
1276 1276
         return null;
1277 1277
     }
1278 1278
     $user_id        = $invoice->get_user_id();
1279 1279
     $user_info      = $invoice->get_user_info();
1280
-    $address_info   = wpinv_get_user_address( $user_id );
1280
+    $address_info   = wpinv_get_user_address($user_id);
1281 1281
 
1282
-    if ( empty( $user_info['first_name'] ) && !empty( $user_info['first_name'] ) ) {
1282
+    if (empty($user_info['first_name']) && !empty($user_info['first_name'])) {
1283 1283
         $user_info['first_name'] = $user_info['first_name'];
1284 1284
         $user_info['last_name'] = $user_info['last_name'];
1285 1285
     }
1286 1286
 
1287
-    if ( ( ( empty( $user_info['country'] ) && !empty( $address_info['country'] ) ) || ( empty( $user_info['state'] ) && !empty( $address_info['state'] ) && $user_info['country'] == $address_info['country'] ) ) ) {
1287
+    if (((empty($user_info['country']) && !empty($address_info['country'])) || (empty($user_info['state']) && !empty($address_info['state']) && $user_info['country'] == $address_info['country']))) {
1288 1288
         $user_info['country']   = $address_info['country'];
1289 1289
         $user_info['state']     = $address_info['state'];
1290 1290
         $user_info['city']      = $address_info['city'];
@@ -1300,98 +1300,98 @@  discard block
 block discarded – undo
1300 1300
         'address'
1301 1301
     );
1302 1302
 
1303
-    foreach ( $address_fields as $field ) {
1304
-        if ( empty( $user_info[$field] ) ) {
1303
+    foreach ($address_fields as $field) {
1304
+        if (empty($user_info[$field])) {
1305 1305
             $user_info[$field] = $address_info[$field];
1306 1306
         }
1307 1307
     }
1308 1308
 
1309
-    return apply_filters( 'wpinv_checkout_billing_details', $user_info, $invoice );
1309
+    return apply_filters('wpinv_checkout_billing_details', $user_info, $invoice);
1310 1310
 }
1311 1311
 
1312 1312
 function wpinv_admin_get_line_items($invoice = array()) {
1313 1313
     $item_quantities    = wpinv_item_quantities_enabled();
1314 1314
     $use_taxes          = wpinv_use_taxes();
1315 1315
 
1316
-    if ( empty( $invoice ) ) {
1316
+    if (empty($invoice)) {
1317 1317
         return NULL;
1318 1318
     }
1319 1319
 
1320 1320
     $cart_items = $invoice->get_cart_details();
1321
-    if ( empty( $cart_items ) ) {
1321
+    if (empty($cart_items)) {
1322 1322
         return NULL;
1323 1323
     }
1324 1324
     ob_start();
1325 1325
 
1326
-    do_action( 'wpinv_admin_before_line_items', $cart_items, $invoice );
1326
+    do_action('wpinv_admin_before_line_items', $cart_items, $invoice);
1327 1327
 
1328 1328
     $count = 0;
1329
-    foreach ( $cart_items as $key => $cart_item ) {
1329
+    foreach ($cart_items as $key => $cart_item) {
1330 1330
         $item_id    = $cart_item['id'];
1331
-        $wpi_item   = $item_id > 0 ? new WPInv_Item( $item_id ) : NULL;
1331
+        $wpi_item   = $item_id > 0 ? new WPInv_Item($item_id) : NULL;
1332 1332
 
1333 1333
         if (empty($wpi_item)) {
1334 1334
             continue;
1335 1335
         }
1336 1336
 
1337
-        $item_price     = wpinv_price( wpinv_format_amount( $cart_item['item_price'] ), $invoice->get_currency() );
1338
-        $quantity       = !empty( $cart_item['quantity'] ) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1;
1339
-        $item_subtotal  = wpinv_price( wpinv_format_amount( $cart_item['subtotal'] ), $invoice->get_currency() );
1337
+        $item_price     = wpinv_price(wpinv_format_amount($cart_item['item_price']), $invoice->get_currency());
1338
+        $quantity       = !empty($cart_item['quantity']) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1;
1339
+        $item_subtotal  = wpinv_price(wpinv_format_amount($cart_item['subtotal']), $invoice->get_currency());
1340 1340
         $can_remove     = true;
1341 1341
 
1342
-        $summary = apply_filters( 'wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice );
1342
+        $summary = apply_filters('wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice);
1343 1343
 
1344 1344
         $item_tax       = '';
1345 1345
         $tax_rate       = '';
1346
-        if ( $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) {
1347
-            $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() );
1348
-            $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100;
1349
-            $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : '';
1346
+        if ($cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) {
1347
+            $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency());
1348
+            $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100;
1349
+            $tax_rate = $tax_rate > 0 ? (float) wpinv_round_amount($tax_rate, 4) : '';
1350 1350
             $tax_rate = $tax_rate != '' ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : '';
1351 1351
         }
1352 1352
         $line_item_tax = $item_tax . $tax_rate;
1353 1353
 
1354
-        if ( $line_item_tax === '' ) {
1354
+        if ($line_item_tax === '') {
1355 1355
             $line_item_tax = 0; // Zero tax
1356 1356
         }
1357 1357
 
1358
-        $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . $item_id . '">';
1358
+        $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . $item_id . '">';
1359 1359
             $line_item .= '<td class="id">' . $item_id . '</td>';
1360
-            $line_item .= '<td class="title"><a href="' . get_edit_post_link( $item_id ) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix( $wpi_item );
1361
-            if ( $summary !== '' ) {
1362
-                $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>';
1360
+            $line_item .= '<td class="title"><a href="' . get_edit_post_link($item_id) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix($wpi_item);
1361
+            if ($summary !== '') {
1362
+                $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>';
1363 1363
             }
1364 1364
             $line_item .= '</td>';
1365 1365
             $line_item .= '<td class="price">' . $item_price . '</td>';
1366 1366
             
1367
-            if ( $item_quantities ) {
1368
-                if ( count( $cart_items ) == 1 && $quantity <= 1 ) {
1367
+            if ($item_quantities) {
1368
+                if (count($cart_items) == 1 && $quantity <= 1) {
1369 1369
                     $can_remove = false;
1370 1370
                 }
1371 1371
                 $line_item .= '<td class="qty" data-quantity="' . $quantity . '">&nbsp;&times;&nbsp;' . $quantity . '</td>';
1372 1372
             } else {
1373
-                if ( count( $cart_items ) == 1 ) {
1373
+                if (count($cart_items) == 1) {
1374 1374
                     $can_remove = false;
1375 1375
                 }
1376 1376
             }
1377 1377
             $line_item .= '<td class="total">' . $item_subtotal . '</td>';
1378 1378
             
1379
-            if ( $use_taxes ) {
1379
+            if ($use_taxes) {
1380 1380
                 $line_item .= '<td class="tax">' . $line_item_tax . '</td>';
1381 1381
             }
1382 1382
             $line_item .= '<td class="action">';
1383
-            if ( !$invoice->is_paid() && !$invoice->is_refunded() ) {
1383
+            if (!$invoice->is_paid() && !$invoice->is_refunded()) {
1384 1384
                 $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>';
1385 1385
             }
1386 1386
             $line_item .= '</td>';
1387 1387
         $line_item .= '</tr>';
1388 1388
 
1389
-        echo apply_filters( 'wpinv_admin_line_item', $line_item, $cart_item, $invoice );
1389
+        echo apply_filters('wpinv_admin_line_item', $line_item, $cart_item, $invoice);
1390 1390
 
1391 1391
         $count++;
1392 1392
     } 
1393 1393
 
1394
-    do_action( 'wpinv_admin_after_line_items', $cart_items, $invoice );
1394
+    do_action('wpinv_admin_after_line_items', $cart_items, $invoice);
1395 1395
 
1396 1396
     return ob_get_clean();
1397 1397
 }
@@ -1403,32 +1403,32 @@  discard block
 block discarded – undo
1403 1403
     $wpi_checkout_id = wpinv_get_invoice_cart_id();
1404 1404
 
1405 1405
     //Maybe update the prices
1406
-    if(! empty( $_GET['wpi_dynamic_item'] ) && ! empty( $_GET['wpi_dynamic_price'] ) ) {
1406
+    if (!empty($_GET['wpi_dynamic_item']) && !empty($_GET['wpi_dynamic_price'])) {
1407 1407
 
1408 1408
         //If the invoice exists, update it with new pricing details
1409
-        if (! empty( $wpi_checkout_id ) ) {
1409
+        if (!empty($wpi_checkout_id)) {
1410 1410
 
1411 1411
             $_invoice       = wpinv_get_invoice_cart();
1412 1412
             $_cart_details  = $_invoice->get_cart_details();
1413
-            $_dynamic_item  = sanitize_text_field( $_GET['wpi_dynamic_item'] );
1413
+            $_dynamic_item  = sanitize_text_field($_GET['wpi_dynamic_item']);
1414 1414
 
1415 1415
             //First, fetch the item
1416
-            $item    = new WPInv_Item( $_dynamic_item );
1416
+            $item = new WPInv_Item($_dynamic_item);
1417 1417
     
1418 1418
             //Next, ensure it supports dynamic pricing...
1419
-            if( $item->supports_dynamic_pricing() && $item->get_is_dynamic_pricing() ) {
1419
+            if ($item->supports_dynamic_pricing() && $item->get_is_dynamic_pricing()) {
1420 1420
                 
1421 1421
                 //... and that the new price is not lower than the minimum price
1422
-                $_dynamic_price = (float) wpinv_sanitize_amount( sanitize_text_field( $_GET['wpi_dynamic_price'] ) );
1423
-                if( $_dynamic_price < $item->get_minimum_price() ) {
1422
+                $_dynamic_price = (float) wpinv_sanitize_amount(sanitize_text_field($_GET['wpi_dynamic_price']));
1423
+                if ($_dynamic_price < $item->get_minimum_price()) {
1424 1424
                     $_dynamic_price = $item->get_minimum_price();
1425 1425
                 }
1426 1426
 
1427 1427
                 //Finally, update our invoice with the new price
1428
-                if ( !empty( $_cart_details ) ) {
1428
+                if (!empty($_cart_details)) {
1429 1429
 
1430
-                    foreach ( $_cart_details as $key => $item ) {
1431
-                        if ( !empty( $item['id'] ) && $_dynamic_item == $item['id'] ) {
1430
+                    foreach ($_cart_details as $key => $item) {
1431
+                        if (!empty($item['id']) && $_dynamic_item == $item['id']) {
1432 1432
                             $_cart_details[$key]['custom_price'] = $_dynamic_price;
1433 1433
                             $_cart_details[$key]['item_price']   = $_dynamic_price;
1434 1434
                         }
@@ -1436,8 +1436,8 @@  discard block
 block discarded – undo
1436 1436
 
1437 1437
                     $_meta = $_invoice->get_meta();
1438 1438
                     $_meta['cart_details'] = $_cart_details;
1439
-                    $_invoice->set( 'payment_meta', $_meta );
1440
-                    $_invoice->set( 'cart_details', $_cart_details );
1439
+                    $_invoice->set('payment_meta', $_meta);
1440
+                    $_invoice->set('cart_details', $_cart_details);
1441 1441
                     $_invoice->recalculate_totals();
1442 1442
 
1443 1443
                 }
@@ -1448,60 +1448,60 @@  discard block
 block discarded – undo
1448 1448
 
1449 1449
     }
1450 1450
 
1451
-    $form_action  = esc_url( wpinv_get_checkout_uri() );
1451
+    $form_action = esc_url(wpinv_get_checkout_uri());
1452 1452
 
1453 1453
     ob_start();
1454
-	    do_action( 'wpinv_checkout_content_before' );
1454
+	    do_action('wpinv_checkout_content_before');
1455 1455
         echo '<div id="wpinv_checkout_wrap">';
1456 1456
 
1457
-        if ( wpinv_get_cart_contents() || wpinv_cart_has_fees() ) {
1457
+        if (wpinv_get_cart_contents() || wpinv_cart_has_fees()) {
1458 1458
             ?>
1459 1459
             <div id="wpinv_checkout_form_wrap" class="wpinv_clearfix table-responsive">
1460
-                <?php do_action( 'wpinv_before_checkout_form' ); ?>
1460
+                <?php do_action('wpinv_before_checkout_form'); ?>
1461 1461
                 <form id="wpinv_checkout_form" class="wpi-form" action="<?php echo $form_action; ?>" method="POST">
1462 1462
                     <?php
1463
-                    do_action( 'wpinv_checkout_form_top' );
1464
-                    do_action( 'wpinv_checkout_billing_info' );
1465
-                    do_action( 'wpinv_checkout_cart' );
1466
-                    do_action( 'wpinv_payment_mode_select'  );
1467
-                    do_action( 'wpinv_checkout_form_bottom' )
1463
+                    do_action('wpinv_checkout_form_top');
1464
+                    do_action('wpinv_checkout_billing_info');
1465
+                    do_action('wpinv_checkout_cart');
1466
+                    do_action('wpinv_payment_mode_select');
1467
+                    do_action('wpinv_checkout_form_bottom')
1468 1468
                     ?>
1469 1469
                 </form>
1470
-                <?php do_action( 'wpinv_after_purchase_form' ); ?>
1470
+                <?php do_action('wpinv_after_purchase_form'); ?>
1471 1471
             </div><!--end #wpinv_checkout_form_wrap-->
1472 1472
         <?php
1473 1473
         } else {
1474
-            do_action( 'wpinv_cart_empty' );
1474
+            do_action('wpinv_cart_empty');
1475 1475
         }
1476 1476
         echo '</div><!--end #wpinv_checkout_wrap-->';
1477
-	    do_action( 'wpinv_checkout_content_after' );
1477
+	    do_action('wpinv_checkout_content_after');
1478 1478
     return ob_get_clean();
1479 1479
 }
1480 1480
 
1481
-function wpinv_checkout_cart( $cart_details = array(), $echo = true ) {
1481
+function wpinv_checkout_cart($cart_details = array(), $echo = true) {
1482 1482
     global $ajax_cart_details;
1483 1483
     $ajax_cart_details = $cart_details;
1484 1484
 
1485 1485
     ob_start();
1486
-    do_action( 'wpinv_before_checkout_cart' );
1486
+    do_action('wpinv_before_checkout_cart');
1487 1487
     echo '<div id="wpinv_checkout_cart_form" method="post">';
1488 1488
         echo '<div id="wpinv_checkout_cart_wrap">';
1489
-            wpinv_get_template_part( 'wpinv-checkout-cart' );
1489
+            wpinv_get_template_part('wpinv-checkout-cart');
1490 1490
         echo '</div>';
1491 1491
     echo '</div>';
1492
-    do_action( 'wpinv_after_checkout_cart' );
1492
+    do_action('wpinv_after_checkout_cart');
1493 1493
     $content = ob_get_clean();
1494 1494
 
1495
-    if ( $echo ) {
1495
+    if ($echo) {
1496 1496
         echo $content;
1497 1497
     } else {
1498 1498
         return $content;
1499 1499
     }
1500 1500
 }
1501
-add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 );
1501
+add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10);
1502 1502
 
1503 1503
 function wpinv_empty_cart_message() {
1504
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1504
+	return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>');
1505 1505
 }
1506 1506
 
1507 1507
 /**
@@ -1513,83 +1513,83 @@  discard block
 block discarded – undo
1513 1513
 function wpinv_empty_checkout_cart() {
1514 1514
 	echo wpinv_empty_cart_message();
1515 1515
 }
1516
-add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' );
1516
+add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart');
1517 1517
 
1518 1518
 function wpinv_update_cart_button() {
1519
-    if ( !wpinv_item_quantities_enabled() )
1519
+    if (!wpinv_item_quantities_enabled())
1520 1520
         return;
1521 1521
 ?>
1522
-    <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/>
1522
+    <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e('Update Cart', 'invoicing'); ?>"/>
1523 1523
     <input type="hidden" name="wpi_action" value="update_cart"/>
1524 1524
 <?php
1525 1525
 }
1526 1526
 
1527 1527
 function wpinv_checkout_cart_columns() {
1528 1528
     $default = 3;
1529
-    if ( wpinv_item_quantities_enabled() ) {
1529
+    if (wpinv_item_quantities_enabled()) {
1530 1530
         $default++;
1531 1531
     }
1532 1532
     
1533
-    if ( wpinv_use_taxes() ) {
1533
+    if (wpinv_use_taxes()) {
1534 1534
         $default++;
1535 1535
     }
1536 1536
 
1537
-    return apply_filters( 'wpinv_checkout_cart_columns', $default );
1537
+    return apply_filters('wpinv_checkout_cart_columns', $default);
1538 1538
 }
1539 1539
 
1540 1540
 function wpinv_display_cart_messages() {
1541 1541
     global $wpi_session;
1542 1542
 
1543
-    $messages = $wpi_session->get( 'wpinv_cart_messages' );
1543
+    $messages = $wpi_session->get('wpinv_cart_messages');
1544 1544
 
1545
-    if ( $messages ) {
1546
-        foreach ( $messages as $message_id => $message ) {
1545
+    if ($messages) {
1546
+        foreach ($messages as $message_id => $message) {
1547 1547
             // Try and detect what type of message this is
1548
-            if ( strpos( strtolower( $message ), 'error' ) ) {
1548
+            if (strpos(strtolower($message), 'error')) {
1549 1549
                 $type = 'error';
1550
-            } elseif ( strpos( strtolower( $message ), 'success' ) ) {
1550
+            } elseif (strpos(strtolower($message), 'success')) {
1551 1551
                 $type = 'success';
1552 1552
             } else {
1553 1553
                 $type = 'info';
1554 1554
             }
1555 1555
 
1556
-            $classes = apply_filters( 'wpinv_' . $type . '_class', array( 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type ) );
1556
+            $classes = apply_filters('wpinv_' . $type . '_class', array('wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type));
1557 1557
 
1558
-            echo '<div class="' . implode( ' ', $classes ) . '">';
1558
+            echo '<div class="' . implode(' ', $classes) . '">';
1559 1559
                 // Loop message codes and display messages
1560 1560
                     echo '<p class="wpinv_error" id="wpinv_msg_' . $message_id . '">' . $message . '</p>';
1561 1561
             echo '</div>';
1562 1562
         }
1563 1563
 
1564 1564
         // Remove all of the cart saving messages
1565
-        $wpi_session->set( 'wpinv_cart_messages', null );
1565
+        $wpi_session->set('wpinv_cart_messages', null);
1566 1566
     }
1567 1567
 }
1568
-add_action( 'wpinv_before_checkout_cart', 'wpinv_display_cart_messages' );
1568
+add_action('wpinv_before_checkout_cart', 'wpinv_display_cart_messages');
1569 1569
 
1570 1570
 function wpinv_discount_field() {
1571
-    if ( isset( $_GET['wpi-gateway'] ) && wpinv_is_ajax_disabled() ) {
1571
+    if (isset($_GET['wpi-gateway']) && wpinv_is_ajax_disabled()) {
1572 1572
         return; // Only show before a payment method has been selected if ajax is disabled
1573 1573
     }
1574 1574
 
1575
-    if ( !wpinv_is_checkout() ) {
1575
+    if (!wpinv_is_checkout()) {
1576 1576
         return;
1577 1577
     }
1578 1578
 
1579
-    if ( wpinv_has_active_discounts() && wpinv_get_cart_total() ) {
1579
+    if (wpinv_has_active_discounts() && wpinv_get_cart_total()) {
1580 1580
     ?>
1581 1581
     <div id="wpinv-discount-field" class="panel panel-default">
1582 1582
         <div class="panel-body">
1583 1583
             <p>
1584
-                <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e( 'Discount', 'invoicing' ); ?></strong></label>
1585
-                <span class="wpinv-description"><?php _e( 'Enter a discount code if you have one.', 'invoicing' ); ?></span>
1584
+                <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e('Discount', 'invoicing'); ?></strong></label>
1585
+                <span class="wpinv-description"><?php _e('Enter a discount code if you have one.', 'invoicing'); ?></span>
1586 1586
             </p>
1587 1587
             <div class="form-group row">
1588 1588
                 <div class="col-sm-4">
1589
-                    <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e( 'Enter discount code', 'invoicing' ); ?>"/>
1589
+                    <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e('Enter discount code', 'invoicing'); ?>"/>
1590 1590
                 </div>
1591 1591
                 <div class="col-sm-3">
1592
-                    <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e( 'Apply Discount', 'invoicing' ); ?></button>
1592
+                    <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e('Apply Discount', 'invoicing'); ?></button>
1593 1593
                 </div>
1594 1594
                 <div style="clear:both"></div>
1595 1595
                 <div class="col-sm-12 wpinv-discount-msg">
@@ -1602,10 +1602,10 @@  discard block
 block discarded – undo
1602 1602
 <?php
1603 1603
     }
1604 1604
 }
1605
-add_action( 'wpinv_after_checkout_cart', 'wpinv_discount_field', -10 );
1605
+add_action('wpinv_after_checkout_cart', 'wpinv_discount_field', -10);
1606 1606
 
1607 1607
 function wpinv_agree_to_terms_js() {
1608
-    if ( wpinv_get_option( 'show_agree_to_terms', false ) ) {
1608
+    if (wpinv_get_option('show_agree_to_terms', false)) {
1609 1609
 ?>
1610 1610
 <script type="text/javascript">
1611 1611
     jQuery(document).ready(function($){
@@ -1620,125 +1620,125 @@  discard block
 block discarded – undo
1620 1620
 <?php
1621 1621
     }
1622 1622
 }
1623
-add_action( 'wpinv_checkout_form_top', 'wpinv_agree_to_terms_js' );
1623
+add_action('wpinv_checkout_form_top', 'wpinv_agree_to_terms_js');
1624 1624
 
1625 1625
 function wpinv_payment_mode_select() {
1626
-    $gateways = wpinv_get_enabled_payment_gateways( true );
1627
-    $gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways );
1628
-    $invoice = wpinv_get_invoice( 0, true );
1626
+    $gateways = wpinv_get_enabled_payment_gateways(true);
1627
+    $gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways);
1628
+    $invoice = wpinv_get_invoice(0, true);
1629 1629
 
1630 1630
     do_action('wpinv_payment_mode_top');
1631
-    $invoice_id = (int)$invoice->ID;
1632
-    $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id );
1631
+    $invoice_id = (int) $invoice->ID;
1632
+    $chosen_gateway = wpinv_get_chosen_gateway($invoice_id);
1633 1633
     ?>
1634
-    <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ( $invoice->is_free() ? 'style="display:none;" data-free="1"' : '' ); ?>>
1635
-            <?php do_action( 'wpinv_payment_mode_before_gateways_wrap' ); ?>
1634
+    <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ($invoice->is_free() ? 'style="display:none;" data-free="1"' : ''); ?>>
1635
+            <?php do_action('wpinv_payment_mode_before_gateways_wrap'); ?>
1636 1636
             <div id="wpinv-payment-mode-wrap" class="panel panel-default">
1637
-                <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Select Payment Method', 'invoicing' ); ?></h3></div>
1637
+                <div class="panel-heading"><h3 class="panel-title"><?php _e('Select Payment Method', 'invoicing'); ?></h3></div>
1638 1638
                 <div class="panel-body list-group wpi-payment_methods">
1639 1639
                     <?php
1640
-                    do_action( 'wpinv_payment_mode_before_gateways' );
1641
-
1642
-                    if ( !empty( $gateways ) ) {
1643
-                        foreach ( $gateways as $gateway_id => $gateway ) {
1644
-                            $checked       = checked( $gateway_id, $chosen_gateway, false );
1645
-                            $button_label  = wpinv_get_gateway_button_label( $gateway_id );
1646
-                            $gateway_label = wpinv_get_gateway_checkout_label( $gateway_id );
1647
-                            $description   = wpinv_get_gateway_description( $gateway_id );
1640
+                    do_action('wpinv_payment_mode_before_gateways');
1641
+
1642
+                    if (!empty($gateways)) {
1643
+                        foreach ($gateways as $gateway_id => $gateway) {
1644
+                            $checked       = checked($gateway_id, $chosen_gateway, false);
1645
+                            $button_label  = wpinv_get_gateway_button_label($gateway_id);
1646
+                            $gateway_label = wpinv_get_gateway_checkout_label($gateway_id);
1647
+                            $description   = wpinv_get_gateway_description($gateway_id);
1648 1648
                             ?>
1649 1649
                             <div class="list-group-item">
1650 1650
                                 <div class="radio">
1651
-                                    <label><input type="radio" data-button-text="<?php echo esc_attr( $button_label );?>" value="<?php echo esc_attr( $gateway_id ) ;?>" <?php echo $checked ;?> id="wpi_gateway_<?php echo esc_attr( $gateway_id );?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html( $gateway_label ); ?></label>
1651
+                                    <label><input type="radio" data-button-text="<?php echo esc_attr($button_label); ?>" value="<?php echo esc_attr($gateway_id); ?>" <?php echo $checked; ?> id="wpi_gateway_<?php echo esc_attr($gateway_id); ?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html($gateway_label); ?></label>
1652 1652
                                 </div>
1653
-                                <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr( $gateway_id );?>" role="alert">
1654
-                                    <?php if ( !empty( $description ) ) { ?>
1655
-                                        <div class="wpi-gateway-desc alert alert-info"><?php _e( $description, 'invoicing' ); ?></div>
1653
+                                <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr($gateway_id); ?>" role="alert">
1654
+                                    <?php if (!empty($description)) { ?>
1655
+                                        <div class="wpi-gateway-desc alert alert-info"><?php _e($description, 'invoicing'); ?></div>
1656 1656
                                     <?php } ?>
1657
-                                    <?php do_action( 'wpinv_' . $gateway_id . '_cc_form', $invoice_id ) ;?>
1657
+                                    <?php do_action('wpinv_' . $gateway_id . '_cc_form', $invoice_id); ?>
1658 1658
                                 </div>
1659 1659
                             </div>
1660 1660
                             <?php
1661 1661
                         }
1662 1662
                     } else {
1663
-                        echo '<div class="alert alert-warning">'. __( 'No payment gateway active', 'invoicing' ) .'</div>';
1663
+                        echo '<div class="alert alert-warning">' . __('No payment gateway active', 'invoicing') . '</div>';
1664 1664
                     }
1665 1665
 
1666
-                    do_action( 'wpinv_payment_mode_after_gateways' );
1666
+                    do_action('wpinv_payment_mode_after_gateways');
1667 1667
                     ?>
1668 1668
                 </div>
1669 1669
             </div>
1670
-            <?php do_action( 'wpinv_payment_mode_after_gateways_wrap' ); ?>
1670
+            <?php do_action('wpinv_payment_mode_after_gateways_wrap'); ?>
1671 1671
     </div>
1672 1672
     <?php
1673 1673
     do_action('wpinv_payment_mode_bottom');
1674 1674
 }
1675
-add_action( 'wpinv_payment_mode_select', 'wpinv_payment_mode_select' );
1675
+add_action('wpinv_payment_mode_select', 'wpinv_payment_mode_select');
1676 1676
 
1677 1677
 function wpinv_checkout_billing_info() {
1678
-    if ( wpinv_is_checkout() ) {
1678
+    if (wpinv_is_checkout()) {
1679 1679
         $billing_details    = wpinv_checkout_billing_details();
1680
-        $selected_country   = !empty( $billing_details['country'] ) ? $billing_details['country'] : wpinv_default_billing_country();
1680
+        $selected_country   = !empty($billing_details['country']) ? $billing_details['country'] : wpinv_default_billing_country();
1681 1681
         ?>
1682 1682
         <div id="wpinv-fields" class="clearfix">
1683 1683
             <div id="wpi-billing" class="wpi-billing clearfix panel panel-default">
1684
-                <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Billing Details', 'invoicing' );?></h3></div>
1684
+                <div class="panel-heading"><h3 class="panel-title"><?php _e('Billing Details', 'invoicing'); ?></h3></div>
1685 1685
                 <div id="wpinv-fields-box" class="panel-body">
1686
-                    <?php do_action( 'wpinv_checkout_billing_fields_first', $billing_details ); ?>
1686
+                    <?php do_action('wpinv_checkout_billing_fields_first', $billing_details); ?>
1687 1687
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1688
-                        <label for="wpinv_first_name" class="wpi-label"><?php _e( 'First Name', 'invoicing' );?><?php if ( wpinv_get_option( 'fname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1688
+                        <label for="wpinv_first_name" class="wpi-label"><?php _e('First Name', 'invoicing'); ?><?php if (wpinv_get_option('fname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1689 1689
                         <?php
1690
-                        echo wpinv_html_text( array(
1690
+                        echo wpinv_html_text(array(
1691 1691
                                 'id'            => 'wpinv_first_name',
1692 1692
                                 'name'          => 'wpinv_first_name',
1693 1693
                                 'value'         => $billing_details['first_name'],
1694 1694
                                 'class'         => 'wpi-input form-control',
1695
-                                'placeholder'   => __( 'First name', 'invoicing' ),
1696
-                                'required'      => (bool)wpinv_get_option( 'fname_mandatory' ),
1697
-                            ) );
1695
+                                'placeholder'   => __('First name', 'invoicing'),
1696
+                                'required'      => (bool) wpinv_get_option('fname_mandatory'),
1697
+                            ));
1698 1698
                         ?>
1699 1699
                     </p>
1700 1700
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1701
-                        <label for="wpinv_last_name" class="wpi-label"><?php _e( 'Last Name', 'invoicing' );?><?php if ( wpinv_get_option( 'lname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1701
+                        <label for="wpinv_last_name" class="wpi-label"><?php _e('Last Name', 'invoicing'); ?><?php if (wpinv_get_option('lname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1702 1702
                         <?php
1703
-                        echo wpinv_html_text( array(
1703
+                        echo wpinv_html_text(array(
1704 1704
                                 'id'            => 'wpinv_last_name',
1705 1705
                                 'name'          => 'wpinv_last_name',
1706 1706
                                 'value'         => $billing_details['last_name'],
1707 1707
                                 'class'         => 'wpi-input form-control',
1708
-                                'placeholder'   => __( 'Last name', 'invoicing' ),
1709
-                                'required'      => (bool)wpinv_get_option( 'lname_mandatory' ),
1710
-                            ) );
1708
+                                'placeholder'   => __('Last name', 'invoicing'),
1709
+                                'required'      => (bool) wpinv_get_option('lname_mandatory'),
1710
+                            ));
1711 1711
                         ?>
1712 1712
                     </p>
1713 1713
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1714
-                        <label for="wpinv_address" class="wpi-label"><?php _e( 'Address', 'invoicing' );?><?php if ( wpinv_get_option( 'address_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1714
+                        <label for="wpinv_address" class="wpi-label"><?php _e('Address', 'invoicing'); ?><?php if (wpinv_get_option('address_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1715 1715
                         <?php
1716
-                        echo wpinv_html_text( array(
1716
+                        echo wpinv_html_text(array(
1717 1717
                                 'id'            => 'wpinv_address',
1718 1718
                                 'name'          => 'wpinv_address',
1719 1719
                                 'value'         => $billing_details['address'],
1720 1720
                                 'class'         => 'wpi-input form-control',
1721
-                                'placeholder'   => __( 'Address', 'invoicing' ),
1722
-                                'required'      => (bool)wpinv_get_option( 'address_mandatory' ),
1723
-                            ) );
1721
+                                'placeholder'   => __('Address', 'invoicing'),
1722
+                                'required'      => (bool) wpinv_get_option('address_mandatory'),
1723
+                            ));
1724 1724
                         ?>
1725 1725
                     </p>
1726 1726
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1727
-                        <label for="wpinv_city" class="wpi-label"><?php _e( 'City', 'invoicing' );?><?php if ( wpinv_get_option( 'city_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1727
+                        <label for="wpinv_city" class="wpi-label"><?php _e('City', 'invoicing'); ?><?php if (wpinv_get_option('city_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1728 1728
                         <?php
1729
-                        echo wpinv_html_text( array(
1729
+                        echo wpinv_html_text(array(
1730 1730
                                 'id'            => 'wpinv_city',
1731 1731
                                 'name'          => 'wpinv_city',
1732 1732
                                 'value'         => $billing_details['city'],
1733 1733
                                 'class'         => 'wpi-input form-control',
1734
-                                'placeholder'   => __( 'City', 'invoicing' ),
1735
-                                'required'      => (bool)wpinv_get_option( 'city_mandatory' ),
1736
-                            ) );
1734
+                                'placeholder'   => __('City', 'invoicing'),
1735
+                                'required'      => (bool) wpinv_get_option('city_mandatory'),
1736
+                            ));
1737 1737
                         ?>
1738 1738
                     </p>
1739 1739
                     <p id="wpinv_country_box" class="wpi-cart-field wpi-col2 wpi-colf">
1740
-                        <label for="wpinv_country" class="wpi-label"><?php _e( 'Country', 'invoicing' );?><?php if ( wpinv_get_option( 'country_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1741
-                        <?php echo wpinv_html_select( array(
1740
+                        <label for="wpinv_country" class="wpi-label"><?php _e('Country', 'invoicing'); ?><?php if (wpinv_get_option('country_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1741
+                        <?php echo wpinv_html_select(array(
1742 1742
                             'options'          => wpinv_get_country_list(),
1743 1743
                             'name'             => 'wpinv_country',
1744 1744
                             'id'               => 'wpinv_country',
@@ -1746,16 +1746,16 @@  discard block
 block discarded – undo
1746 1746
                             'show_option_all'  => false,
1747 1747
                             'show_option_none' => false,
1748 1748
                             'class'            => 'wpi-input form-control wpi_select2',
1749
-                            'placeholder'      => __( 'Choose a country', 'invoicing' ),
1750
-                            'required'         => (bool)wpinv_get_option( 'country_mandatory' ),
1751
-                        ) ); ?>
1749
+                            'placeholder'      => __('Choose a country', 'invoicing'),
1750
+                            'required'         => (bool) wpinv_get_option('country_mandatory'),
1751
+                        )); ?>
1752 1752
                     </p>
1753 1753
                     <p id="wpinv_state_box" class="wpi-cart-field wpi-col2 wpi-coll">
1754
-                        <label for="wpinv_state" class="wpi-label"><?php _e( 'State / Province', 'invoicing' );?><?php if ( wpinv_get_option( 'state_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1754
+                        <label for="wpinv_state" class="wpi-label"><?php _e('State / Province', 'invoicing'); ?><?php if (wpinv_get_option('state_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1755 1755
                         <?php
1756
-                        $states = wpinv_get_country_states( $selected_country );
1757
-                        if( !empty( $states ) ) {
1758
-                            echo wpinv_html_select( array(
1756
+                        $states = wpinv_get_country_states($selected_country);
1757
+                        if (!empty($states)) {
1758
+                            echo wpinv_html_select(array(
1759 1759
                                 'options'          => $states,
1760 1760
                                 'name'             => 'wpinv_state',
1761 1761
                                 'id'               => 'wpinv_state',
@@ -1763,61 +1763,61 @@  discard block
 block discarded – undo
1763 1763
                                 'show_option_all'  => false,
1764 1764
                                 'show_option_none' => false,
1765 1765
                                 'class'            => 'wpi-input form-control wpi_select2',
1766
-                                'placeholder'      => __( 'Choose a state', 'invoicing' ),
1767
-                                'required'         => (bool)wpinv_get_option( 'state_mandatory' ),
1768
-                            ) );
1766
+                                'placeholder'      => __('Choose a state', 'invoicing'),
1767
+                                'required'         => (bool) wpinv_get_option('state_mandatory'),
1768
+                            ));
1769 1769
                         } else {
1770
-                            echo wpinv_html_text( array(
1770
+                            echo wpinv_html_text(array(
1771 1771
                                 'name'          => 'wpinv_state',
1772 1772
                                 'value'         => $billing_details['state'],
1773 1773
                                 'id'            => 'wpinv_state',
1774 1774
                                 'class'         => 'wpi-input form-control',
1775
-                                'placeholder'   => __( 'State / Province', 'invoicing' ),
1776
-                                'required'      => (bool)wpinv_get_option( 'state_mandatory' ),
1777
-                            ) );
1775
+                                'placeholder'   => __('State / Province', 'invoicing'),
1776
+                                'required'      => (bool) wpinv_get_option('state_mandatory'),
1777
+                            ));
1778 1778
                         }
1779 1779
                         ?>
1780 1780
                     </p>
1781 1781
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1782
-                        <label for="wpinv_zip" class="wpi-label"><?php _e( 'ZIP / Postcode', 'invoicing' );?><?php if ( wpinv_get_option( 'zip_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1782
+                        <label for="wpinv_zip" class="wpi-label"><?php _e('ZIP / Postcode', 'invoicing'); ?><?php if (wpinv_get_option('zip_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1783 1783
                         <?php
1784
-                        echo wpinv_html_text( array(
1784
+                        echo wpinv_html_text(array(
1785 1785
                                 'name'          => 'wpinv_zip',
1786 1786
                                 'value'         => $billing_details['zip'],
1787 1787
                                 'id'            => 'wpinv_zip',
1788 1788
                                 'class'         => 'wpi-input form-control',
1789
-                                'placeholder'   => __( 'ZIP / Postcode', 'invoicing' ),
1790
-                                'required'      => (bool)wpinv_get_option( 'zip_mandatory' ),
1791
-                            ) );
1789
+                                'placeholder'   => __('ZIP / Postcode', 'invoicing'),
1790
+                                'required'      => (bool) wpinv_get_option('zip_mandatory'),
1791
+                            ));
1792 1792
                         ?>
1793 1793
                     </p>
1794 1794
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1795
-                        <label for="wpinv_phone" class="wpi-label"><?php _e( 'Phone', 'invoicing' );?><?php if ( wpinv_get_option( 'phone_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1795
+                        <label for="wpinv_phone" class="wpi-label"><?php _e('Phone', 'invoicing'); ?><?php if (wpinv_get_option('phone_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1796 1796
                         <?php
1797
-                        echo wpinv_html_text( array(
1797
+                        echo wpinv_html_text(array(
1798 1798
                                 'id'            => 'wpinv_phone',
1799 1799
                                 'name'          => 'wpinv_phone',
1800 1800
                                 'value'         => $billing_details['phone'],
1801 1801
                                 'class'         => 'wpi-input form-control',
1802
-                                'placeholder'   => __( 'Phone', 'invoicing' ),
1803
-                                'required'      => (bool)wpinv_get_option( 'phone_mandatory' ),
1804
-                            ) );
1802
+                                'placeholder'   => __('Phone', 'invoicing'),
1803
+                                'required'      => (bool) wpinv_get_option('phone_mandatory'),
1804
+                            ));
1805 1805
                         ?>
1806 1806
                     </p>
1807
-                    <?php do_action( 'wpinv_checkout_billing_fields_last', $billing_details ); ?>
1807
+                    <?php do_action('wpinv_checkout_billing_fields_last', $billing_details); ?>
1808 1808
                     <div class="clearfix"></div>
1809 1809
                 </div>
1810 1810
             </div>
1811
-            <?php do_action( 'wpinv_after_billing_fields', $billing_details ); ?>
1811
+            <?php do_action('wpinv_after_billing_fields', $billing_details); ?>
1812 1812
         </div>
1813 1813
         <?php
1814 1814
     }
1815 1815
 }
1816
-add_action( 'wpinv_checkout_billing_info', 'wpinv_checkout_billing_info' );
1816
+add_action('wpinv_checkout_billing_info', 'wpinv_checkout_billing_info');
1817 1817
 
1818 1818
 function wpinv_checkout_hidden_fields() {
1819 1819
 ?>
1820
-    <?php if ( is_user_logged_in() ) { ?>
1820
+    <?php if (is_user_logged_in()) { ?>
1821 1821
     <input type="hidden" name="wpinv_user_id" value="<?php echo get_current_user_id(); ?>"/>
1822 1822
     <?php } ?>
1823 1823
     <input type="hidden" name="wpi_action" value="payment" />
@@ -1827,9 +1827,9 @@  discard block
 block discarded – undo
1827 1827
 function wpinv_checkout_button_purchase() {
1828 1828
     ob_start();
1829 1829
 ?>
1830
-    <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>" name="wpinv_payment" value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>"/>
1830
+    <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>" name="wpinv_payment" value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>"/>
1831 1831
 <?php
1832
-    return apply_filters( 'wpinv_checkout_button_purchase', ob_get_clean() );
1832
+    return apply_filters('wpinv_checkout_button_purchase', ob_get_clean());
1833 1833
 }
1834 1834
 
1835 1835
 function wpinv_checkout_total() {
@@ -1838,84 +1838,84 @@  discard block
 block discarded – undo
1838 1838
 <div id="wpinv_checkout_total" class="panel panel-info">
1839 1839
     <div class="panel-body">
1840 1840
     <?php
1841
-    do_action( 'wpinv_purchase_form_before_checkout_total' );
1841
+    do_action('wpinv_purchase_form_before_checkout_total');
1842 1842
     ?>
1843
-    <strong><?php _e( 'Invoice Total:', 'invoicing' ) ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total;?></span>
1843
+    <strong><?php _e('Invoice Total:', 'invoicing') ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total; ?></span>
1844 1844
     <?php
1845
-    do_action( 'wpinv_purchase_form_after_checkout_total' );
1845
+    do_action('wpinv_purchase_form_after_checkout_total');
1846 1846
     ?>
1847 1847
     </div>
1848 1848
 </div>
1849 1849
 <?php
1850 1850
 }
1851
-add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998 );
1851
+add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998);
1852 1852
 
1853 1853
 function wpinv_checkout_accept_tandc() {
1854
-    $page = wpinv_get_option( 'tandc_page' );
1854
+    $page = wpinv_get_option('tandc_page');
1855 1855
     ?>
1856 1856
     <div id="wpinv_checkout_tandc" class="panel panel-success">
1857 1857
         <div class="panel-body">
1858 1858
             <?php echo wpinv_get_policy_text(); ?>
1859 1859
             <?php
1860
-            if(isset($page) && (int)$page > 0 && apply_filters( 'wpinv_checkout_show_terms', true )){
1861
-                $terms_link = esc_url( get_permalink( $page ) );
1860
+            if (isset($page) && (int) $page > 0 && apply_filters('wpinv_checkout_show_terms', true)) {
1861
+                $terms_link = esc_url(get_permalink($page));
1862 1862
                 ?>
1863 1863
                 <label class="">
1864
-                    <input type="checkbox" class="wpi-terms-checkbox" name="wpi_terms" id="wpi-terms" <?php checked( apply_filters( 'wpinv_terms_is_checked_default', isset( $_POST['wpi_terms'] ) ), true ); ?>> <span><?php printf( __( 'I&rsquo;ve read and accept the <a href="%s" target="_blank" class="wpi-terms-and-conditions-link">terms &amp; conditions</a>', 'invoicing' ), $terms_link ); ?></span> <span class="wpi-required">*</span>
1864
+                    <input type="checkbox" class="wpi-terms-checkbox" name="wpi_terms" id="wpi-terms" <?php checked(apply_filters('wpinv_terms_is_checked_default', isset($_POST['wpi_terms'])), true); ?>> <span><?php printf(__('I&rsquo;ve read and accept the <a href="%s" target="_blank" class="wpi-terms-and-conditions-link">terms &amp; conditions</a>', 'invoicing'), $terms_link); ?></span> <span class="wpi-required">*</span>
1865 1865
                 </label>
1866 1866
             <?php } ?>
1867 1867
         </div>
1868 1868
     </div>
1869 1869
     <?php
1870 1870
 }
1871
-add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_accept_tandc', 9995 );
1871
+add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_accept_tandc', 9995);
1872 1872
 
1873 1873
 function wpinv_checkout_submit() {
1874 1874
 ?>
1875 1875
 <div id="wpinv_purchase_submit" class="panel panel-success">
1876 1876
     <div class="panel-body text-center">
1877 1877
     <?php
1878
-    do_action( 'wpinv_purchase_form_before_submit' );
1878
+    do_action('wpinv_purchase_form_before_submit');
1879 1879
     wpinv_checkout_hidden_fields();
1880 1880
     echo wpinv_checkout_button_purchase();
1881
-    do_action( 'wpinv_purchase_form_after_submit' );
1881
+    do_action('wpinv_purchase_form_after_submit');
1882 1882
     ?>
1883 1883
     </div>
1884 1884
 </div>
1885 1885
 <?php
1886 1886
 }
1887
-add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999 );
1887
+add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999);
1888 1888
 
1889
-function wpinv_receipt_billing_address( $invoice_id = 0 ) {
1890
-    $invoice = wpinv_get_invoice( $invoice_id );
1889
+function wpinv_receipt_billing_address($invoice_id = 0) {
1890
+    $invoice = wpinv_get_invoice($invoice_id);
1891 1891
 
1892
-    if ( empty( $invoice ) ) {
1892
+    if (empty($invoice)) {
1893 1893
         return NULL;
1894 1894
     }
1895 1895
 
1896 1896
     $billing_details = $invoice->get_user_info();
1897
-    $address_row = wpinv_get_invoice_address_markup( $billing_details );
1897
+    $address_row = wpinv_get_invoice_address_markup($billing_details);
1898 1898
 
1899 1899
     ob_start();
1900 1900
     ?>
1901 1901
     <table class="table table-bordered table-sm wpi-billing-details">
1902 1902
         <tbody>
1903 1903
             <tr class="wpi-receipt-name">
1904
-                <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th>
1905
-                <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td>
1904
+                <th class="text-left"><?php _e('Name', 'invoicing'); ?></th>
1905
+                <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td>
1906 1906
             </tr>
1907 1907
             <tr class="wpi-receipt-email">
1908
-                <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th>
1909
-                <td><?php echo $billing_details['email'] ;?></td>
1908
+                <th class="text-left"><?php _e('Email', 'invoicing'); ?></th>
1909
+                <td><?php echo $billing_details['email']; ?></td>
1910 1910
             </tr>
1911 1911
             <tr class="wpi-receipt-address">
1912
-                <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th>
1913
-                <td><?php echo $address_row ;?></td>
1912
+                <th class="text-left"><?php _e('Address', 'invoicing'); ?></th>
1913
+                <td><?php echo $address_row; ?></td>
1914 1914
             </tr>
1915
-            <?php if ( $billing_details['phone'] ) { ?>
1915
+            <?php if ($billing_details['phone']) { ?>
1916 1916
             <tr class="wpi-receipt-phone">
1917
-                <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th>
1918
-                <td><?php echo esc_html( $billing_details['phone'] ) ;?></td>
1917
+                <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th>
1918
+                <td><?php echo esc_html($billing_details['phone']); ?></td>
1919 1919
             </tr>
1920 1920
             <?php } ?>
1921 1921
         </tbody>
@@ -1923,74 +1923,74 @@  discard block
 block discarded – undo
1923 1923
     <?php
1924 1924
     $output = ob_get_clean();
1925 1925
     
1926
-    $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id );
1926
+    $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id);
1927 1927
 
1928 1928
     echo $output;
1929 1929
 }
1930 1930
 
1931
-function wpinv_filter_success_page_content( $content ) {
1932
-    if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) {
1933
-        if ( has_filter( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ) ) ) {
1934
-            $content = apply_filters( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ), $content );
1931
+function wpinv_filter_success_page_content($content) {
1932
+    if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) {
1933
+        if (has_filter('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']))) {
1934
+            $content = apply_filters('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']), $content);
1935 1935
         }
1936 1936
     }
1937 1937
 
1938 1938
     return $content;
1939 1939
 }
1940
-add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 );
1940
+add_filter('the_content', 'wpinv_filter_success_page_content', 99999);
1941 1941
 
1942
-function wpinv_receipt_actions( $invoice ) {
1943
-    if ( !empty( $invoice ) ) {
1942
+function wpinv_receipt_actions($invoice) {
1943
+    if (!empty($invoice)) {
1944 1944
         $actions = array();
1945 1945
 
1946
-        if ( wpinv_user_can_view_invoice( $invoice->ID ) ) {
1947
-            $actions['print']   = array(
1948
-                'url'  => $invoice->get_view_url( true ),
1949
-                'name' => __( 'Print Invoice', 'invoicing' ),
1946
+        if (wpinv_user_can_view_invoice($invoice->ID)) {
1947
+            $actions['print'] = array(
1948
+                'url'  => $invoice->get_view_url(true),
1949
+                'name' => __('Print Invoice', 'invoicing'),
1950 1950
                 'class' => 'btn-primary',
1951 1951
             );
1952 1952
         }
1953 1953
 
1954
-        if ( is_user_logged_in() ) {
1954
+        if (is_user_logged_in()) {
1955 1955
             $actions['history'] = array(
1956 1956
                 'url'  => wpinv_get_history_page_uri(),
1957
-                'name' => __( 'Invoice History', 'invoicing' ),
1957
+                'name' => __('Invoice History', 'invoicing'),
1958 1958
                 'class' => 'btn-warning',
1959 1959
             );
1960 1960
         }
1961 1961
 
1962
-        $actions = apply_filters( 'wpinv_invoice_receipt_actions', $actions, $invoice );
1962
+        $actions = apply_filters('wpinv_invoice_receipt_actions', $actions, $invoice);
1963 1963
 
1964
-        if ( !empty( $actions ) ) {
1964
+        if (!empty($actions)) {
1965 1965
         ?>
1966 1966
         <div class="wpinv-receipt-actions text-right">
1967
-            <?php foreach ( $actions as $key => $action ) { $class = !empty($action['class']) ? sanitize_html_class( $action['class'] ) : ''; ?>
1968
-            <a href="<?php echo esc_url( $action['url'] );?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class( $key );?>" <?php echo ( !empty($action['attrs']) ? $action['attrs'] : '' ) ;?>><?php echo esc_html( $action['name'] );?></a>
1967
+            <?php foreach ($actions as $key => $action) { $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; ?>
1968
+            <a href="<?php echo esc_url($action['url']); ?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class($key); ?>" <?php echo (!empty($action['attrs']) ? $action['attrs'] : ''); ?>><?php echo esc_html($action['name']); ?></a>
1969 1969
             <?php } ?>
1970 1970
         </div>
1971 1971
         <?php
1972 1972
         }
1973 1973
     }
1974 1974
 }
1975
-add_action( 'wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1 );
1975
+add_action('wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1);
1976 1976
 
1977
-function wpinv_invoice_link( $invoice_id ) {
1978
-    $invoice = wpinv_get_invoice( $invoice_id );
1977
+function wpinv_invoice_link($invoice_id) {
1978
+    $invoice = wpinv_get_invoice($invoice_id);
1979 1979
 
1980
-    if ( empty( $invoice ) ) {
1980
+    if (empty($invoice)) {
1981 1981
         return NULL;
1982 1982
     }
1983 1983
 
1984
-    $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>';
1984
+    $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>';
1985 1985
 
1986
-    return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice );
1986
+    return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice);
1987 1987
 }
1988 1988
 
1989
-function wpinv_invoice_subscription_details( $invoice ) {
1990
-    if ( !empty( $invoice ) && $invoice->is_recurring() && ! wpinv_is_subscription_payment( $invoice ) ) {
1991
-        $subscription = wpinv_get_subscription( $invoice, true );
1989
+function wpinv_invoice_subscription_details($invoice) {
1990
+    if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) {
1991
+        $subscription = wpinv_get_subscription($invoice, true);
1992 1992
 
1993
-        if ( empty( $subscription ) ) {
1993
+        if (empty($subscription)) {
1994 1994
             return;
1995 1995
         }
1996 1996
 
@@ -2001,15 +2001,15 @@  discard block
 block discarded – undo
2001 2001
         $payments = $subscription->get_child_payments();
2002 2002
         ?>
2003 2003
         <div class="wpinv-subscriptions-details">
2004
-            <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3>
2004
+            <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3>
2005 2005
             <table class="table">
2006 2006
                 <thead>
2007 2007
                     <tr>
2008
-                        <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th>
2009
-                        <th><?php _e( 'Start Date', 'invoicing' ) ;?></th>
2010
-                        <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th>
2011
-                        <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th>
2012
-                        <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th>
2008
+                        <th><?php _e('Billing Cycle', 'invoicing'); ?></th>
2009
+                        <th><?php _e('Start Date', 'invoicing'); ?></th>
2010
+                        <th><?php _e('Expiration Date', 'invoicing'); ?></th>
2011
+                        <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th>
2012
+                        <th class="text-center"><?php _e('Status', 'invoicing'); ?></th>
2013 2013
                     </tr>
2014 2014
                 </thead>
2015 2015
                 <tbody>
@@ -2023,29 +2023,29 @@  discard block
 block discarded – undo
2023 2023
                 </tbody>
2024 2024
             </table>
2025 2025
         </div>
2026
-        <?php if ( !empty( $payments ) ) { ?>
2026
+        <?php if (!empty($payments)) { ?>
2027 2027
         <div class="wpinv-renewal-payments">
2028
-            <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3>
2028
+            <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3>
2029 2029
             <table class="table">
2030 2030
                 <thead>
2031 2031
                     <tr>
2032 2032
                         <th>#</th>
2033
-                        <th><?php _e( 'Invoice', 'invoicing' ) ;?></th>
2034
-                        <th><?php _e( 'Date', 'invoicing' ) ;?></th>
2035
-                        <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th>
2033
+                        <th><?php _e('Invoice', 'invoicing'); ?></th>
2034
+                        <th><?php _e('Date', 'invoicing'); ?></th>
2035
+                        <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th>
2036 2036
                     </tr>
2037 2037
                 </thead>
2038 2038
                 <tbody>
2039 2039
                     <?php
2040 2040
                         $i = 1;
2041
-                        foreach ( $payments as $payment ) {
2041
+                        foreach ($payments as $payment) {
2042 2042
                             $invoice_id = $payment->ID;
2043 2043
                     ?>
2044 2044
                     <tr>
2045
-                        <th scope="row"><?php echo $i;?></th>
2046
-                        <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td>
2047
-                        <td><?php echo wpinv_get_invoice_date( $invoice_id ); ?></td>
2048
-                        <td class="text-right"><?php echo wpinv_payment_total( $invoice_id, true ); ?></td>
2045
+                        <th scope="row"><?php echo $i; ?></th>
2046
+                        <td><?php echo wpinv_invoice_link($invoice_id); ?></td>
2047
+                        <td><?php echo wpinv_get_invoice_date($invoice_id); ?></td>
2048
+                        <td class="text-right"><?php echo wpinv_payment_total($invoice_id, true); ?></td>
2049 2049
                     </tr>
2050 2050
                     <?php $i++; } ?>
2051 2051
                 </tbody>
@@ -2056,52 +2056,52 @@  discard block
 block discarded – undo
2056 2056
     }
2057 2057
 }
2058 2058
 
2059
-function wpinv_cart_total_label( $label, $invoice ) {
2060
-    if ( empty( $invoice ) ) {
2059
+function wpinv_cart_total_label($label, $invoice) {
2060
+    if (empty($invoice)) {
2061 2061
         return $label;
2062 2062
     }
2063 2063
 
2064 2064
     $prefix_label = '';
2065
-    if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) {
2066
-        $prefix_label   = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice );
2067
-    } else if ( $invoice->is_renewal() ) {
2068
-        $prefix_label   = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> ';        
2065
+    if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) {
2066
+        $prefix_label   = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice);
2067
+    } else if ($invoice->is_renewal()) {
2068
+        $prefix_label   = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> ';        
2069 2069
     }
2070 2070
 
2071
-    if ( $prefix_label != '' ) {
2072
-        $label  = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
2071
+    if ($prefix_label != '') {
2072
+        $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
2073 2073
     }
2074 2074
 
2075 2075
     return $label;
2076 2076
 }
2077
-add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2078
-add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2079
-add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2077
+add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2078
+add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2079
+add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2080 2080
 
2081
-add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1 );
2081
+add_action('wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1);
2082 2082
 
2083
-function wpinv_invoice_print_description( $invoice ) {
2084
-    if ( empty( $invoice ) ) {
2083
+function wpinv_invoice_print_description($invoice) {
2084
+    if (empty($invoice)) {
2085 2085
         return NULL;
2086 2086
     }
2087
-    if ( $description = wpinv_get_invoice_description( $invoice->ID ) ) {
2087
+    if ($description = wpinv_get_invoice_description($invoice->ID)) {
2088 2088
         ?>
2089 2089
         <div class="row wpinv-lower">
2090 2090
             <div class="col-sm-12 wpinv-description">
2091
-                <?php echo wpautop( $description ); ?>
2091
+                <?php echo wpautop($description); ?>
2092 2092
             </div>
2093 2093
         </div>
2094 2094
         <?php
2095 2095
     }
2096 2096
 }
2097
-add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1 );
2097
+add_action('wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1);
2098 2098
 
2099
-function wpinv_invoice_print_payment_info( $invoice ) {
2100
-    if ( empty( $invoice ) ) {
2099
+function wpinv_invoice_print_payment_info($invoice) {
2100
+    if (empty($invoice)) {
2101 2101
         return NULL;
2102 2102
     }
2103 2103
 
2104
-    if ( $payments_info = wpinv_display_payments_info( $invoice->ID, false ) ) {
2104
+    if ($payments_info = wpinv_display_payments_info($invoice->ID, false)) {
2105 2105
         ?>
2106 2106
         <div class="row wpinv-payments">
2107 2107
             <div class="col-sm-12">
@@ -2113,43 +2113,43 @@  discard block
 block discarded – undo
2113 2113
 }
2114 2114
 // add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_invoice_print_payment_info', 10, 1 );
2115 2115
 
2116
-function wpinv_get_invoice_note_line_item( $note, $echo = true ) {
2117
-    if ( empty( $note ) ) {
2116
+function wpinv_get_invoice_note_line_item($note, $echo = true) {
2117
+    if (empty($note)) {
2118 2118
         return NULL;
2119 2119
     }
2120 2120
 
2121
-    if ( is_int( $note ) ) {
2122
-        $note = get_comment( $note );
2121
+    if (is_int($note)) {
2122
+        $note = get_comment($note);
2123 2123
     }
2124 2124
 
2125
-    if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) {
2125
+    if (!(is_object($note) && is_a($note, 'WP_Comment'))) {
2126 2126
         return NULL;
2127 2127
     }
2128 2128
 
2129
-    $note_classes   = array( 'note' );
2130
-    $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : '';
2129
+    $note_classes   = array('note');
2130
+    $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : '';
2131 2131
     $note_classes[] = $note->comment_author === 'System' ? 'system-note' : '';
2132
-    $note_classes   = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note );
2133
-    $note_classes   = !empty( $note_classes ) ? implode( ' ', $note_classes ) : '';
2132
+    $note_classes   = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note);
2133
+    $note_classes   = !empty($note_classes) ? implode(' ', $note_classes) : '';
2134 2134
 
2135 2135
     ob_start();
2136 2136
     ?>
2137
-    <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?>">
2137
+    <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?>">
2138 2138
         <div class="note_content">
2139
-            <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?>
2139
+            <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?>
2140 2140
         </div>
2141 2141
         <p class="meta">
2142
-            <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf( __( '%1$s - %2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ), date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ); ?></abbr>&nbsp;&nbsp;
2143
-            <?php if ( is_admin() && ( $note->comment_author !== 'System' || wpinv_current_user_can_manage_invoicing() ) ) { ?>
2144
-                <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a>
2142
+            <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf(__('%1$s - %2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n(get_option('date_format'), strtotime($note->comment_date)), date_i18n(get_option('time_format'), strtotime($note->comment_date))); ?></abbr>&nbsp;&nbsp;
2143
+            <?php if (is_admin() && ($note->comment_author !== 'System' || wpinv_current_user_can_manage_invoicing())) { ?>
2144
+                <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a>
2145 2145
             <?php } ?>
2146 2146
         </p>
2147 2147
     </li>
2148 2148
     <?php
2149 2149
     $note_content = ob_get_clean();
2150
-    $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo );
2150
+    $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo);
2151 2151
 
2152
-    if ( $echo ) {
2152
+    if ($echo) {
2153 2153
         echo $note_content;
2154 2154
     } else {
2155 2155
         return $note_content;
@@ -2159,43 +2159,43 @@  discard block
 block discarded – undo
2159 2159
 function wpinv_invalid_invoice_content() {
2160 2160
     global $post;
2161 2161
 
2162
-    $invoice = wpinv_get_invoice( $post->ID );
2162
+    $invoice = wpinv_get_invoice($post->ID);
2163 2163
 
2164
-    $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' );
2165
-    if ( !empty( $invoice->ID ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) {
2166
-        if ( is_user_logged_in() ) {
2167
-            if ( wpinv_require_login_to_checkout() ) {
2168
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
2169
-                    $error = __( 'You are not allowed to view this invoice.', 'invoicing' );
2164
+    $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing');
2165
+    if (!empty($invoice->ID) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) {
2166
+        if (is_user_logged_in()) {
2167
+            if (wpinv_require_login_to_checkout()) {
2168
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
2169
+                    $error = __('You are not allowed to view this invoice.', 'invoicing');
2170 2170
                 }
2171 2171
             }
2172 2172
         } else {
2173
-            if ( wpinv_require_login_to_checkout() ) {
2174
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
2175
-                    $error = __( 'You must be logged in to view this invoice.', 'invoicing' );
2173
+            if (wpinv_require_login_to_checkout()) {
2174
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
2175
+                    $error = __('You must be logged in to view this invoice.', 'invoicing');
2176 2176
                 }
2177 2177
             }
2178 2178
         }
2179 2179
     } else {
2180
-        $error = __( 'This invoice is deleted or does not exist.', 'invoicing' );
2180
+        $error = __('This invoice is deleted or does not exist.', 'invoicing');
2181 2181
     }
2182 2182
     ?>
2183 2183
     <div class="row wpinv-row-invalid">
2184 2184
         <div class="col-md-6 col-md-offset-3 wpinv-message error">
2185
-            <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3>
2185
+            <h3><?php _e('Access Denied', 'invoicing'); ?></h3>
2186 2186
             <p class="wpinv-msg-text"><?php echo $error; ?></p>
2187 2187
         </div>
2188 2188
     </div>
2189 2189
     <?php
2190 2190
 }
2191
-add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' );
2191
+add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content');
2192 2192
 
2193
-add_action( 'wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field');
2194
-function wpinv_force_company_name_field(){
2193
+add_action('wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field');
2194
+function wpinv_force_company_name_field() {
2195 2195
     $invoice = wpinv_get_invoice_cart();
2196
-    $user_id = wpinv_get_user_id( $invoice->ID );
2197
-    $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true );
2198
-    if ( 1 == wpinv_get_option( 'force_show_company' ) && !wpinv_use_taxes() ) {
2196
+    $user_id = wpinv_get_user_id($invoice->ID);
2197
+    $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true);
2198
+    if (1 == wpinv_get_option('force_show_company') && !wpinv_use_taxes()) {
2199 2199
         ?>
2200 2200
         <p class="wpi-cart-field wpi-col2 wpi-colf">
2201 2201
             <label for="wpinv_company" class="wpi-label"><?php _e('Company Name', 'invoicing'); ?></label>
@@ -2221,21 +2221,21 @@  discard block
 block discarded – undo
2221 2221
  * @return string
2222 2222
  */
2223 2223
 function wpinv_get_policy_text() {
2224
-    $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 );
2224
+    $privacy_page_id = get_option('wp_page_for_privacy_policy', 0);
2225 2225
 
2226
-    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' ));
2226
+    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]'));
2227 2227
 
2228
-    if(!$privacy_page_id){
2229
-        $privacy_page_id = wpinv_get_option( 'privacy_page', 0 );
2228
+    if (!$privacy_page_id) {
2229
+        $privacy_page_id = wpinv_get_option('privacy_page', 0);
2230 2230
     }
2231 2231
 
2232
-    $privacy_link    = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' );
2232
+    $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing');
2233 2233
 
2234 2234
     $find_replace = array(
2235 2235
         '[wpinv_privacy_policy]' => $privacy_link,
2236 2236
     );
2237 2237
 
2238
-    $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text );
2238
+    $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text);
2239 2239
 
2240 2240
     return wp_kses_post(wpautop($privacy_text));
2241 2241
 }
@@ -2244,25 +2244,25 @@  discard block
 block discarded – undo
2244 2244
 /**
2245 2245
  * Allows the user to set their own price for an invoice item
2246 2246
  */
2247
-function wpinv_checkout_cart_item_name_your_price( $cart_item, $key ) {
2247
+function wpinv_checkout_cart_item_name_your_price($cart_item, $key) {
2248 2248
     
2249 2249
     //Ensure we have an item id
2250
-    if(! is_array( $cart_item ) || empty( $cart_item['id'] ) ) {
2250
+    if (!is_array($cart_item) || empty($cart_item['id'])) {
2251 2251
         return;
2252 2252
     }
2253 2253
 
2254 2254
     //Fetch the item
2255 2255
     $item_id = $cart_item['id'];
2256
-    $item    = new WPInv_Item( $item_id );
2256
+    $item    = new WPInv_Item($item_id);
2257 2257
     
2258
-    if(! $item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing() ) {
2258
+    if (!$item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing()) {
2259 2259
         return;
2260 2260
     }
2261 2261
 
2262 2262
     //Fetch the dynamic pricing "strings"
2263
-    $suggested_price_text = esc_html( wpinv_get_option( 'suggested_price_text', __( 'Suggested Price:', 'invoicing' ) ) );
2264
-    $minimum_price_text   = esc_html( wpinv_get_option( 'minimum_price_text', __( 'Minimum Price:', 'invoicing' ) ) );
2265
-    $name_your_price_text = esc_html( wpinv_get_option( 'name_your_price_text', __( 'Name Your Price', 'invoicing' ) ) );
2263
+    $suggested_price_text = esc_html(wpinv_get_option('suggested_price_text', __('Suggested Price:', 'invoicing')));
2264
+    $minimum_price_text   = esc_html(wpinv_get_option('minimum_price_text', __('Minimum Price:', 'invoicing')));
2265
+    $name_your_price_text = esc_html(wpinv_get_option('name_your_price_text', __('Name Your Price', 'invoicing')));
2266 2266
 
2267 2267
     //Display a "name_your_price" button
2268 2268
     echo " &mdash; <a href='#' class='wpinv-name-your-price-frontend small'>$name_your_price_text</a></div>";
@@ -2271,7 +2271,7 @@  discard block
 block discarded – undo
2271 2271
     echo '<div class="name-your-price-miniform">';
2272 2272
     
2273 2273
     //Maybe display the recommended price
2274
-    if( $item->get_price() > 0 && !empty( $suggested_price_text ) ) {
2274
+    if ($item->get_price() > 0 && !empty($suggested_price_text)) {
2275 2275
         $suggested_price = $item->get_the_price();
2276 2276
         echo "<div>$suggested_price_text &mdash; $suggested_price</div>";
2277 2277
     }
@@ -2279,50 +2279,50 @@  discard block
 block discarded – undo
2279 2279
     //Display the update price form
2280 2280
     $symbol         = wpinv_currency_symbol();
2281 2281
     $position       = wpinv_currency_position();
2282
-    $minimum        = esc_attr( $item->get_minimum_price() );
2283
-    $price          = esc_attr( $cart_item['item_price'] );
2284
-    $update         = esc_attr__( "Update", 'invoicing' );
2282
+    $minimum        = esc_attr($item->get_minimum_price());
2283
+    $price          = esc_attr($cart_item['item_price']);
2284
+    $update         = esc_attr__("Update", 'invoicing');
2285 2285
 
2286 2286
     //Ensure it supports dynamic prici
2287
-    if( $price < $minimum ) {
2287
+    if ($price < $minimum) {
2288 2288
         $price = $minimum;
2289 2289
     }
2290 2290
 
2291 2291
     echo '<label>';
2292 2292
     echo $position != 'right' ? $symbol . '&nbsp;' : '';
2293 2293
     echo "<input type='number' min='$minimum' placeholder='$price' value='$price' class='wpi-field-price' />";
2294
-    echo $position == 'right' ? '&nbsp;' . $symbol : '' ;
2294
+    echo $position == 'right' ? '&nbsp;' . $symbol : '';
2295 2295
     echo "</label>";
2296 2296
     echo "<input type='hidden' value='$item_id' class='wpi-field-item' />";
2297 2297
     echo "<a class='btn btn-success wpinv-submit wpinv-update-dynamic-price-frontend'>$update</a>";
2298 2298
 
2299 2299
     //Maybe display the minimum price
2300
-    if( $item->get_minimum_price() > 0 && !empty( $minimum_price_text ) ) {
2301
-        $minimum_price = wpinv_price( wpinv_format_amount( $item->get_minimum_price() ) );
2300
+    if ($item->get_minimum_price() > 0 && !empty($minimum_price_text)) {
2301
+        $minimum_price = wpinv_price(wpinv_format_amount($item->get_minimum_price()));
2302 2302
         echo "<div>$minimum_price_text &mdash; $minimum_price</div>";
2303 2303
     }
2304 2304
 
2305 2305
     echo "</div>";
2306 2306
 
2307 2307
 }
2308
-add_action( 'wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2 );
2308
+add_action('wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2);
2309 2309
 
2310 2310
 function wpinv_oxygen_fix_conflict() {
2311 2311
     global $ct_ignore_post_types;
2312 2312
 
2313
-    if ( ! is_array( $ct_ignore_post_types ) ) {
2313
+    if (!is_array($ct_ignore_post_types)) {
2314 2314
         $ct_ignore_post_types = array();
2315 2315
     }
2316 2316
 
2317
-    $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item' );
2317
+    $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item');
2318 2318
 
2319
-    foreach ( $post_types as $post_type ) {
2319
+    foreach ($post_types as $post_type) {
2320 2320
         $ct_ignore_post_types[] = $post_type;
2321 2321
 
2322 2322
         // Ignore post type
2323
-        add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 );
2323
+        add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999);
2324 2324
     }
2325 2325
 
2326
-    remove_filter( 'template_include', 'wpinv_template', 10, 1 );
2327
-    add_filter( 'template_include', 'wpinv_template', 999, 1 );
2326
+    remove_filter('template_include', 'wpinv_template', 10, 1);
2327
+    add_filter('template_include', 'wpinv_template', 999, 1);
2328 2328
 }
2329 2329
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wpinv-payment-form-elements.php 1 patch
Spacing   +474 added lines, -474 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
     exit; // Exit if accessed directly
5 5
 }
6 6
 
@@ -13,19 +13,19 @@  discard block
 block discarded – undo
13 13
 
14 14
     public function __construct() {
15 15
 
16
-        foreach( $this->get_elements() as $element ) {
16
+        foreach ($this->get_elements() as $element) {
17 17
             $element = $element['type'];
18 18
 
19
-            if ( method_exists( $this, "render_{$element}_template" ) ) {
20
-                add_action( 'wpinv_payment_form_render_element_template', array( $this, "render_{$element}_template" ), 10, 2 );
19
+            if (method_exists($this, "render_{$element}_template")) {
20
+                add_action('wpinv_payment_form_render_element_template', array($this, "render_{$element}_template"), 10, 2);
21 21
             }
22 22
 
23
-            if ( method_exists( $this, "edit_{$element}_template" ) ) {
24
-                add_action( 'wpinv_payment_form_edit_element_template', array( $this, "edit_{$element}_template" ), 10, 2 );
23
+            if (method_exists($this, "edit_{$element}_template")) {
24
+                add_action('wpinv_payment_form_edit_element_template', array($this, "edit_{$element}_template"), 10, 2);
25 25
             }
26 26
 
27
-            if ( method_exists( $this, "frontend_render_{$element}_template" ) ) {
28
-                add_action( "wpinv_frontend_render_payment_form_$element", array( $this, "frontend_render_{$element}_template" ), 10, 3 );
27
+            if (method_exists($this, "frontend_render_{$element}_template")) {
28
+                add_action("wpinv_frontend_render_payment_form_$element", array($this, "frontend_render_{$element}_template"), 10, 3);
29 29
             }
30 30
 
31 31
         }
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public function get_elements() {
39 39
 
40
-        if ( ! empty( $this->elements ) ) {
40
+        if (!empty($this->elements)) {
41 41
             return $this->elements;
42 42
         }
43 43
 
@@ -45,28 +45,28 @@  discard block
 block discarded – undo
45 45
 
46 46
             array(
47 47
                 'type'     => 'heading',
48
-                'name'     => __( 'Heading', 'invoicing' ),
48
+                'name'     => __('Heading', 'invoicing'),
49 49
                 'defaults' => array(
50 50
                     'level' => 'h2',
51
-                    'text'  => __( 'Heading', 'invoicing' ),
51
+                    'text'  => __('Heading', 'invoicing'),
52 52
                 )
53 53
             ),
54 54
 
55 55
             array(
56 56
                 'type' => 'paragraph',
57
-                'name' => __( 'Paragraph', 'invoicing' ),
57
+                'name' => __('Paragraph', 'invoicing'),
58 58
                 'defaults'  => array(
59
-                    'text'  => __( 'Paragraph text', 'invoicing' ),
59
+                    'text'  => __('Paragraph text', 'invoicing'),
60 60
                 )
61 61
             ),
62 62
 
63 63
             array( 
64 64
                 'type' => 'alert',
65
-                'name' => __( 'Alert', 'invoicing' ),
65
+                'name' => __('Alert', 'invoicing'),
66 66
                 'defaults'  => array(
67 67
                     'value'        => '',
68 68
                     'class'        => 'alert-warning',
69
-                    'text'         => __( 'Alert', 'invoicing' ),
69
+                    'text'         => __('Alert', 'invoicing'),
70 70
                     'dismissible'  => false,
71 71
                 )
72 72
             ),
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
 
83 83
             array(
84 84
                 'type' => 'text',
85
-                'name' => __( 'Text Input', 'invoicing' ),
85
+                'name' => __('Text Input', 'invoicing'),
86 86
                 'defaults'  => array(
87
-                    'placeholder'  => __( 'Enter some text', 'invoicing' ),
87
+                    'placeholder'  => __('Enter some text', 'invoicing'),
88 88
                     'value'        => '',
89
-                    'label'        => __( 'Field Label', 'invoicing' ),
89
+                    'label'        => __('Field Label', 'invoicing'),
90 90
                     'description'  => '',
91 91
                     'required'     => false,
92 92
                 )
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
 
95 95
             array(
96 96
                 'type' => 'textarea',
97
-                'name' => __( 'Textarea', 'invoicing' ),
97
+                'name' => __('Textarea', 'invoicing'),
98 98
                 'defaults'         => array(
99
-                    'placeholder'  => __( 'Enter your text hear', 'invoicing' ),
99
+                    'placeholder'  => __('Enter your text hear', 'invoicing'),
100 100
                     'value'        => '',
101
-                    'label'        => __( 'Textarea Label', 'invoicing' ),
101
+                    'label'        => __('Textarea Label', 'invoicing'),
102 102
                     'description'  => '',
103 103
                     'required'     => false,
104 104
                 )
@@ -106,27 +106,27 @@  discard block
 block discarded – undo
106 106
 
107 107
             array(
108 108
                 'type' => 'select',
109
-                'name' => __( 'Dropdown', 'invoicing' ),
109
+                'name' => __('Dropdown', 'invoicing'),
110 110
                 'defaults'         => array(
111
-                    'placeholder'  => __( 'Select a value', 'invoicing' ),
111
+                    'placeholder'  => __('Select a value', 'invoicing'),
112 112
                     'value'        => '',
113
-                    'label'        => __( 'Dropdown Label', 'invoicing' ),
113
+                    'label'        => __('Dropdown Label', 'invoicing'),
114 114
                     'description'  => '',
115 115
                     'required'     => false,
116 116
                     'options'      => array(
117
-                        esc_attr__( 'Option One', 'invoicing' ),
118
-                        esc_attr__( 'Option Two', 'invoicing' ),
119
-                        esc_attr__( 'Option Three', 'invoicing' )
117
+                        esc_attr__('Option One', 'invoicing'),
118
+                        esc_attr__('Option Two', 'invoicing'),
119
+                        esc_attr__('Option Three', 'invoicing')
120 120
                     ),
121 121
                 )
122 122
             ),
123 123
 
124 124
             array(
125 125
                 'type' => 'checkbox',
126
-                'name' => __( 'Checkbox', 'invoicing' ),
126
+                'name' => __('Checkbox', 'invoicing'),
127 127
                 'defaults'         => array(
128 128
                     'value'        => '',
129
-                    'label'        => __( 'Checkbox Label', 'invoicing' ),
129
+                    'label'        => __('Checkbox Label', 'invoicing'),
130 130
                     'description'  => '',
131 131
                     'required'     => false,
132 132
                 )
@@ -134,24 +134,24 @@  discard block
 block discarded – undo
134 134
 
135 135
             array( 
136 136
                 'type' => 'radio',
137
-                'name' => __( 'Multiple Choice', 'invoicing' ),
137
+                'name' => __('Multiple Choice', 'invoicing'),
138 138
                 'defaults'     => array(
139
-                    'label'    => __( 'Select one choice', 'invoicing' ),
139
+                    'label'    => __('Select one choice', 'invoicing'),
140 140
                     'options'  => array(
141
-                        esc_attr__( 'Choice One', 'invoicing' ),
142
-                        esc_attr__( 'Choice Two', 'invoicing' ),
143
-                        esc_attr__( 'Choice Three', 'invoicing' )
141
+                        esc_attr__('Choice One', 'invoicing'),
142
+                        esc_attr__('Choice Two', 'invoicing'),
143
+                        esc_attr__('Choice Three', 'invoicing')
144 144
                     ),
145 145
                 )
146 146
             ),
147 147
 
148 148
             array( 
149 149
                 'type' => 'date',
150
-                'name' => __( 'Date', 'invoicing' ),
150
+                'name' => __('Date', 'invoicing'),
151 151
                 'defaults' => array(
152 152
                     'placeholder'  => '',
153 153
                     'value'        => '',
154
-                    'label'        => __( 'Date', 'invoicing' ),
154
+                    'label'        => __('Date', 'invoicing'),
155 155
                     'description'  => '',
156 156
                     'required'     => false,
157 157
                 )
@@ -159,11 +159,11 @@  discard block
 block discarded – undo
159 159
 
160 160
             array( 
161 161
                 'type' => 'time',
162
-                'name' => __( 'Time', 'invoicing' ),
162
+                'name' => __('Time', 'invoicing'),
163 163
                 'defaults' => array(
164 164
                     'placeholder'  => '',
165 165
                     'value'        => '',
166
-                    'label'        => __( 'Time', 'invoicing' ),
166
+                    'label'        => __('Time', 'invoicing'),
167 167
                     'description'  => '',
168 168
                     'required'     => false,
169 169
                 )
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
 
172 172
             array( 
173 173
                 'type' => 'number',
174
-                'name' => __( 'Number', 'invoicing' ),
174
+                'name' => __('Number', 'invoicing'),
175 175
                 'defaults' => array(
176 176
                     'placeholder'  => '',
177 177
                     'value'        => '',
178
-                    'label'        => __( 'Number', 'invoicing' ),
178
+                    'label'        => __('Number', 'invoicing'),
179 179
                     'description'  => '',
180 180
                     'required'     => false,
181 181
                 )
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
 
184 184
             array( 
185 185
                 'type' => 'website',
186
-                'name' => __( 'Website', 'invoicing' ),
186
+                'name' => __('Website', 'invoicing'),
187 187
                 'defaults' => array(
188 188
                     'placeholder'  => 'http://example.com',
189 189
                     'value'        => '',
190
-                    'label'        => __( 'Website', 'invoicing' ),
190
+                    'label'        => __('Website', 'invoicing'),
191 191
                     'description'  => '',
192 192
                     'required'     => false,
193 193
                 )
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
 
196 196
             array( 
197 197
                 'type' => 'email',
198
-                'name' => __( 'Email', 'invoicing' ),
198
+                'name' => __('Email', 'invoicing'),
199 199
                 'defaults'  => array(
200 200
                     'placeholder'  => '[email protected]',
201 201
                     'value'        => '',
202
-                    'label'        => __( 'Email Address', 'invoicing' ),
202
+                    'label'        => __('Email Address', 'invoicing'),
203 203
                     'description'  => '',
204 204
                     'required'     => false,
205 205
                 )
@@ -207,11 +207,11 @@  discard block
 block discarded – undo
207 207
 
208 208
             array( 
209 209
                 'type' => 'billing_email',
210
-                'name' => __( 'Billing Email', 'invoicing' ),
210
+                'name' => __('Billing Email', 'invoicing'),
211 211
                 'defaults'  => array(
212 212
                     'placeholder'  => '[email protected]',
213 213
                     'value'        => '',
214
-                    'label'        => __( 'Billing Email', 'invoicing' ),
214
+                    'label'        => __('Billing Email', 'invoicing'),
215 215
                     'description'  => '',
216 216
                     'premade'      => true,
217 217
                 )
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 
231 231
             array( 
232 232
                 'type' => 'items',
233
-                'name' => __( 'Items', 'invoicing' ),
233
+                'name' => __('Items', 'invoicing'),
234 234
                 'defaults'  => array(
235 235
                     'value'        => '',
236 236
                     'items_type'   => 'total',
@@ -241,25 +241,25 @@  discard block
 block discarded – undo
241 241
 
242 242
             array( 
243 243
                 'type'       => 'pay_button',
244
-                'name'       => __( 'Payment Button', 'invoicing' ),
244
+                'name'       => __('Payment Button', 'invoicing'),
245 245
                 'defaults'   => array(
246 246
                     'value'        => '',
247 247
                     'class'        => 'btn-primary',
248
-                    'label'        => __( 'Pay Now »', 'invoicing' ),
249
-                    'description'  => __( 'By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing' ),
248
+                    'label'        => __('Pay Now »', 'invoicing'),
249
+                    'description'  => __('By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing'),
250 250
                     'premade'      => true,
251 251
                 )
252 252
             )
253 253
         );
254 254
 
255
-        $this->elements = apply_filters( 'wpinv_filter_core_payment_form_elements', $this->elements );
255
+        $this->elements = apply_filters('wpinv_filter_core_payment_form_elements', $this->elements);
256 256
         return $this->elements;
257 257
     }
258 258
 
259 259
     /**
260 260
      * Returns the restrict markup.
261 261
      */
262
-    public function get_restrict_markup( $field, $field_type ) {
262
+    public function get_restrict_markup($field, $field_type) {
263 263
         $restrict = "$field.type=='$field_type'";
264 264
         return "v-if=\"$restrict\"";
265 265
     }
@@ -267,15 +267,15 @@  discard block
 block discarded – undo
267 267
     /**
268 268
      * Renders the title element template.
269 269
      */
270
-    public function render_heading_template( $field ) {
271
-        $restrict = $this->get_restrict_markup( $field, 'heading' );
270
+    public function render_heading_template($field) {
271
+        $restrict = $this->get_restrict_markup($field, 'heading');
272 272
         echo "<component :is='$field.level' $restrict v-html='$field.text'></component>";
273 273
     }
274 274
 
275 275
     /**
276 276
      * Renders the title element on the frontend.
277 277
      */
278
-    public function frontend_render_heading_template( $field ) {
278
+    public function frontend_render_heading_template($field) {
279 279
         $tag = $field['level'];
280 280
         echo "<$tag>{$field['text']}</$tag>";
281 281
     }
@@ -283,10 +283,10 @@  discard block
 block discarded – undo
283 283
     /**
284 284
      * Renders the edit title element template.
285 285
      */
286
-    public function edit_heading_template( $field ) {
287
-        $restrict = $this->get_restrict_markup( $field, 'heading' );
288
-        $label    = __( 'Heading', 'invoicing' );
289
-        $label2   = __( 'Select Heading Level', 'invoicing' );
286
+    public function edit_heading_template($field) {
287
+        $restrict = $this->get_restrict_markup($field, 'heading');
288
+        $label    = __('Heading', 'invoicing');
289
+        $label2   = __('Select Heading Level', 'invoicing');
290 290
         $id       = $field . '.id + "_edit"';
291 291
         $id2      = $field . '.id + "_edit2"';
292 292
 
@@ -318,8 +318,8 @@  discard block
 block discarded – undo
318 318
     /**
319 319
      * Renders a paragraph element template.
320 320
      */
321
-    public function render_paragraph_template( $field ) {
322
-        $restrict = $this->get_restrict_markup( $field, 'paragraph' );
321
+    public function render_paragraph_template($field) {
322
+        $restrict = $this->get_restrict_markup($field, 'paragraph');
323 323
         $label    = "$field.text";
324 324
         echo "<p $restrict v-html='$label' style='font-size: 16px;'></p>";
325 325
     }
@@ -327,16 +327,16 @@  discard block
 block discarded – undo
327 327
     /**
328 328
      * Renders the paragraph element on the frontend.
329 329
      */
330
-    public function frontend_render_paragraph_template( $field ) {
330
+    public function frontend_render_paragraph_template($field) {
331 331
         echo "<p>{$field['text']}</p>";
332 332
     }
333 333
 
334 334
     /**
335 335
      * Renders the edit paragraph element template.
336 336
      */
337
-    public function edit_paragraph_template( $field ) {
338
-        $restrict = $this->get_restrict_markup( $field, 'paragraph' );
339
-        $label    = __( 'Enter your text', 'invoicing' );
337
+    public function edit_paragraph_template($field) {
338
+        $restrict = $this->get_restrict_markup($field, 'paragraph');
339
+        $label    = __('Enter your text', 'invoicing');
340 340
         $id       = $field . '.id + "_edit"';
341 341
         echo "
342 342
             <div $restrict>
@@ -352,8 +352,8 @@  discard block
 block discarded – undo
352 352
     /**
353 353
      * Renders the text element template.
354 354
      */
355
-    public function render_text_template( $field ) {
356
-        $restrict = $this->get_restrict_markup( $field, 'text' );
355
+    public function render_text_template($field) {
356
+        $restrict = $this->get_restrict_markup($field, 'text');
357 357
         $label    = "$field.label";
358 358
         echo "
359 359
             <div $restrict>
@@ -367,23 +367,23 @@  discard block
 block discarded – undo
367 367
     /**
368 368
      * Renders the text element on the frontend.
369 369
      */
370
-    public function frontend_render_text_template( $field ) {
370
+    public function frontend_render_text_template($field) {
371 371
         
372 372
         echo "<div class='form-group'>";
373 373
 
374 374
         echo aui()->input(
375 375
             array(
376
-                'name'       => esc_attr( $field['id'] ),
377
-                'id'         => esc_attr( $field['id'] ),
378
-                'placeholder'=> esc_attr( $field['placeholder'] ),
376
+                'name'       => esc_attr($field['id']),
377
+                'id'         => esc_attr($field['id']),
378
+                'placeholder'=> esc_attr($field['placeholder']),
379 379
                 'required'   => (bool) $field['required'],
380
-                'label'      => wp_kses_post( $field['label'] ),
380
+                'label'      => wp_kses_post($field['label']),
381 381
                 'no_wrap'    => true,
382 382
             )
383 383
         );
384 384
 
385
-        if ( ! empty( $field['description'] ) ) {
386
-            $description = wp_kses_post( $field['description'] );
385
+        if (!empty($field['description'])) {
386
+            $description = wp_kses_post($field['description']);
387 387
             echo "<small class='form-text text-muted'>$description</small>";
388 388
         }
389 389
 
@@ -394,16 +394,16 @@  discard block
 block discarded – undo
394 394
     /**
395 395
      * Renders the edit text element template.
396 396
      */
397
-    public function edit_text_template( $field ) {
398
-        $restrict = $this->get_restrict_markup( $field, 'text' );
399
-        $label    = __( 'Field Label', 'invoicing' );
397
+    public function edit_text_template($field) {
398
+        $restrict = $this->get_restrict_markup($field, 'text');
399
+        $label    = __('Field Label', 'invoicing');
400 400
         $id       = $field . '.id + "_edit"';
401
-        $label2   = __( 'Placeholder text', 'invoicing' );
401
+        $label2   = __('Placeholder text', 'invoicing');
402 402
         $id2      = $field . '.id + "_edit2"';
403
-        $label3   = __( 'Help text', 'invoicing' );
404
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
403
+        $label3   = __('Help text', 'invoicing');
404
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
405 405
         $id3      = $field . '.id + "_edit3"';
406
-        $label5   = __( 'Is this field required?', 'invoicing' );
406
+        $label5   = __('Is this field required?', 'invoicing');
407 407
         $id4      = $field . '.id + "_edit4"';
408 408
         echo "
409 409
             <div $restrict>
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
     /**
432 432
      * Renders the textarea element template.
433 433
      */
434
-    public function render_textarea_template( $field ) {
435
-        $restrict = $this->get_restrict_markup( $field, 'textarea' );
434
+    public function render_textarea_template($field) {
435
+        $restrict = $this->get_restrict_markup($field, 'textarea');
436 436
         $label    = "$field.label";
437 437
         echo "
438 438
             <div $restrict>
@@ -446,24 +446,24 @@  discard block
 block discarded – undo
446 446
     /**
447 447
      * Renders the textarea element on the frontend.
448 448
      */
449
-    public function frontend_render_textarea_template( $field ) {
449
+    public function frontend_render_textarea_template($field) {
450 450
         
451 451
         echo "<div class='form-group'>";
452 452
 
453 453
         echo aui()->textarea(
454 454
             array(
455
-                'name'       => esc_attr( $field['id'] ),
456
-                'id'         => esc_attr( $field['id'] ),
457
-                'placeholder'=> esc_attr( $field['placeholder'] ),
455
+                'name'       => esc_attr($field['id']),
456
+                'id'         => esc_attr($field['id']),
457
+                'placeholder'=> esc_attr($field['placeholder']),
458 458
                 'required'   => (bool) $field['required'],
459
-                'label'      => wp_kses_post( $field['label'] ),
459
+                'label'      => wp_kses_post($field['label']),
460 460
                 'no_wrap'    => true,
461 461
                 'rows'       => 3,
462 462
             )
463 463
         );
464 464
 
465
-        if ( ! empty( $field['description'] ) ) {
466
-            $description = wp_kses_post( $field['description'] );
465
+        if (!empty($field['description'])) {
466
+            $description = wp_kses_post($field['description']);
467 467
             echo "<small class='form-text text-muted'>$description</small>";
468 468
         }
469 469
 
@@ -474,16 +474,16 @@  discard block
 block discarded – undo
474 474
     /**
475 475
      * Renders the edit textarea element template.
476 476
      */
477
-    public function edit_textarea_template( $field ) {
478
-        $restrict = $this->get_restrict_markup( $field, 'textarea' );
479
-        $label    = __( 'Field Label', 'invoicing' );
477
+    public function edit_textarea_template($field) {
478
+        $restrict = $this->get_restrict_markup($field, 'textarea');
479
+        $label    = __('Field Label', 'invoicing');
480 480
         $id       = $field . '.id + "_edit"';
481
-        $label2   = __( 'Placeholder text', 'invoicing' );
481
+        $label2   = __('Placeholder text', 'invoicing');
482 482
         $id2      = $field . '.id + "_edit2"';
483
-        $label3   = __( 'Help text', 'invoicing' );
484
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
483
+        $label3   = __('Help text', 'invoicing');
484
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
485 485
         $id3      = $field . '.id + "_edit3"';
486
-        $label5   = __( 'Is this field required?', 'invoicing' );
486
+        $label5   = __('Is this field required?', 'invoicing');
487 487
         $id4      = $field . '.id + "_edit4"';
488 488
         echo "
489 489
             <div $restrict>
@@ -511,8 +511,8 @@  discard block
 block discarded – undo
511 511
     /**
512 512
      * Renders the select element template.
513 513
      */
514
-    public function render_select_template( $field ) {
515
-        $restrict    = $this->get_restrict_markup( $field, 'select' );
514
+    public function render_select_template($field) {
515
+        $restrict    = $this->get_restrict_markup($field, 'select');
516 516
         $label       = "$field.label";
517 517
         $placeholder = "$field.placeholder";
518 518
         $id          = $field . '.id';
@@ -531,24 +531,24 @@  discard block
 block discarded – undo
531 531
     /**
532 532
      * Renders the select element on the frontend.
533 533
      */
534
-    public function frontend_render_select_template( $field ) {
534
+    public function frontend_render_select_template($field) {
535 535
         
536 536
         echo "<div class='form-group'>";
537 537
 
538 538
         echo aui()->select(
539 539
             array(
540
-                'name'       => esc_attr( $field['id'] ),
541
-                'id'         => esc_attr( $field['id'] ),
542
-                'placeholder'=> esc_attr( $field['placeholder'] ),
540
+                'name'       => esc_attr($field['id']),
541
+                'id'         => esc_attr($field['id']),
542
+                'placeholder'=> esc_attr($field['placeholder']),
543 543
                 'required'   => (bool) $field['required'],
544
-                'label'      => wp_kses_post( $field['label'] ),
544
+                'label'      => wp_kses_post($field['label']),
545 545
                 'no_wrap'    => true,
546
-                'options'    => array_combine( $field['options'], $field['options'] ),
546
+                'options'    => array_combine($field['options'], $field['options']),
547 547
             )
548 548
         );
549 549
 
550
-        if ( ! empty( $field['description'] ) ) {
551
-            $description = wp_kses_post( $field['description'] );
550
+        if (!empty($field['description'])) {
551
+            $description = wp_kses_post($field['description']);
552 552
             echo "<small class='form-text text-muted'>$description</small>";
553 553
         }
554 554
 
@@ -559,18 +559,18 @@  discard block
 block discarded – undo
559 559
     /**
560 560
      * Renders the edit select element template.
561 561
      */
562
-    public function edit_select_template( $field ) {
563
-        $restrict = $this->get_restrict_markup( $field, 'select' );
564
-        $label    = __( 'Field Label', 'invoicing' );
562
+    public function edit_select_template($field) {
563
+        $restrict = $this->get_restrict_markup($field, 'select');
564
+        $label    = __('Field Label', 'invoicing');
565 565
         $id       = $field . '.id + "_edit"';
566
-        $label2   = __( 'Placeholder text', 'invoicing' );
566
+        $label2   = __('Placeholder text', 'invoicing');
567 567
         $id2      = $field . '.id + "_edit2"';
568
-        $label3   = __( 'Help text', 'invoicing' );
569
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
568
+        $label3   = __('Help text', 'invoicing');
569
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
570 570
         $id3      = $field . '.id + "_edit3"';
571
-        $label5   = __( 'Is this field required?', 'invoicing' );
571
+        $label5   = __('Is this field required?', 'invoicing');
572 572
         $id4      = $field . '.id + "_edit4"';
573
-        $label6   = __( 'Available Options', 'invoicing' );
573
+        $label6   = __('Available Options', 'invoicing');
574 574
         echo "
575 575
             <div $restrict>
576 576
                 <div class='form-group'>
@@ -608,8 +608,8 @@  discard block
 block discarded – undo
608 608
     /**
609 609
      * Renders the checkbox element template.
610 610
      */
611
-    public function render_checkbox_template( $field ) {
612
-        $restrict = $this->get_restrict_markup( $field, 'checkbox' );
611
+    public function render_checkbox_template($field) {
612
+        $restrict = $this->get_restrict_markup($field, 'checkbox');
613 613
         $label    = "$field.label";
614 614
         echo "
615 615
             <div class='form-check' $restrict>
@@ -623,24 +623,24 @@  discard block
 block discarded – undo
623 623
     /**
624 624
      * Renders the checkbox element on the frontend.
625 625
      */
626
-    public function frontend_render_checkbox_template( $field ) {
626
+    public function frontend_render_checkbox_template($field) {
627 627
         
628 628
         echo "<div class='form-group'>";
629 629
 
630 630
         echo aui()->input(
631 631
             array(
632
-                'name'       => esc_attr( $field['id'] ),
633
-                'id'         => esc_attr( $field['id'] ),
632
+                'name'       => esc_attr($field['id']),
633
+                'id'         => esc_attr($field['id']),
634 634
                 'required'   => (bool) $field['required'],
635
-                'label'      => wp_kses_post( $field['label'] ),
635
+                'label'      => wp_kses_post($field['label']),
636 636
                 'no_wrap'    => true,
637
-                'value'      => esc_attr__( 'Yes', 'invoicing' ),
637
+                'value'      => esc_attr__('Yes', 'invoicing'),
638 638
                 'type'       => 'checkbox',
639 639
             )
640 640
         );
641 641
 
642
-        if ( ! empty( $field['description'] ) ) {
643
-            $description = wp_kses_post( $field['description'] );
642
+        if (!empty($field['description'])) {
643
+            $description = wp_kses_post($field['description']);
644 644
             echo "<small class='form-text text-muted'>$description</small>";
645 645
         }
646 646
 
@@ -651,14 +651,14 @@  discard block
 block discarded – undo
651 651
     /**
652 652
      * Renders the edit checkbox element template.
653 653
      */
654
-    public function edit_checkbox_template( $field ) {
655
-        $restrict = $this->get_restrict_markup( $field, 'checkbox' );
656
-        $label    = __( 'Field Label', 'invoicing' );
654
+    public function edit_checkbox_template($field) {
655
+        $restrict = $this->get_restrict_markup($field, 'checkbox');
656
+        $label    = __('Field Label', 'invoicing');
657 657
         $id       = $field . '.id + "_edit"';
658
-        $label2   = __( 'Help text', 'invoicing' );
659
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
658
+        $label2   = __('Help text', 'invoicing');
659
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
660 660
         $id2      = $field . '.id + "_edit2"';
661
-        $label4   = __( 'Is this field required?', 'invoicing' );
661
+        $label4   = __('Is this field required?', 'invoicing');
662 662
         $id3      = $field . '.id + "_edit3"';
663 663
         echo "
664 664
             <div $restrict>
@@ -682,8 +682,8 @@  discard block
 block discarded – undo
682 682
     /**
683 683
      * Renders the radio element template.
684 684
      */
685
-    public function render_radio_template( $field ) {
686
-        $restrict    = $this->get_restrict_markup( $field, 'radio' );
685
+    public function render_radio_template($field) {
686
+        $restrict    = $this->get_restrict_markup($field, 'radio');
687 687
         $label       = "$field.label";
688 688
         $id          = $field . '.id';
689 689
         echo "
@@ -701,20 +701,20 @@  discard block
 block discarded – undo
701 701
     /**
702 702
      * Renders the radio element on the frontend.
703 703
      */
704
-    public function frontend_render_radio_template( $field ) {
704
+    public function frontend_render_radio_template($field) {
705 705
         
706 706
         echo "<div class='form-group'>";
707 707
 
708
-        if ( ! empty( $field['label'] ) ) {
709
-            $label = wp_kses_post( $field['label'] );
708
+        if (!empty($field['label'])) {
709
+            $label = wp_kses_post($field['label']);
710 710
             echo "<legend class='col-form-label'>$label</legend>";
711 711
         }
712 712
 
713
-        foreach( $field['options'] as $index => $option ) {
713
+        foreach ($field['options'] as $index => $option) {
714 714
             $id    = $field['id'] . $index;
715 715
             $name  = $field['id'];
716
-            $value = esc_attr( $option );
717
-            $label = wp_kses_post( $option );
716
+            $value = esc_attr($option);
717
+            $label = wp_kses_post($option);
718 718
 
719 719
             echo "
720 720
                 <div class='form-check'>
@@ -724,8 +724,8 @@  discard block
 block discarded – undo
724 724
             ";
725 725
         }
726 726
 
727
-        if ( ! empty( $field['description'] ) ) {
728
-            $description = wp_kses_post( $field['description'] );
727
+        if (!empty($field['description'])) {
728
+            $description = wp_kses_post($field['description']);
729 729
             echo "<small class='form-text text-muted'>$description</small>";
730 730
         }
731 731
 
@@ -736,16 +736,16 @@  discard block
 block discarded – undo
736 736
     /**
737 737
      * Renders the edit radio element template.
738 738
      */
739
-    public function edit_radio_template( $field ) {
740
-        $restrict = $this->get_restrict_markup( $field, 'radio' );
741
-        $label    = __( 'Field Label', 'invoicing' );
739
+    public function edit_radio_template($field) {
740
+        $restrict = $this->get_restrict_markup($field, 'radio');
741
+        $label    = __('Field Label', 'invoicing');
742 742
         $id       = $field . '.id + "_edit"';
743
-        $label2   = __( 'Help text', 'invoicing' );
744
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
743
+        $label2   = __('Help text', 'invoicing');
744
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
745 745
         $id2      = $field . '.id + "_edit3"';
746
-        $label4   = __( 'Is this field required?', 'invoicing' );
746
+        $label4   = __('Is this field required?', 'invoicing');
747 747
         $id3      = $field . '.id + "_edit4"';
748
-        $label5   = __( 'Available Options', 'invoicing' );
748
+        $label5   = __('Available Options', 'invoicing');
749 749
         echo "
750 750
             <div $restrict>
751 751
                 <div class='form-group'>
@@ -779,8 +779,8 @@  discard block
 block discarded – undo
779 779
     /**
780 780
      * Renders the email element template.
781 781
      */
782
-    public function render_email_template( $field ) {
783
-        $restrict = $this->get_restrict_markup( $field, 'email' );
782
+    public function render_email_template($field) {
783
+        $restrict = $this->get_restrict_markup($field, 'email');
784 784
         $label    = "$field.label";
785 785
         echo "
786 786
             <div $restrict>
@@ -794,8 +794,8 @@  discard block
 block discarded – undo
794 794
     /**
795 795
      * Renders the billing_email element template.
796 796
      */
797
-    public function render_billing_email_template( $field ) {
798
-        $restrict = $this->get_restrict_markup( $field, 'billing_email' );
797
+    public function render_billing_email_template($field) {
798
+        $restrict = $this->get_restrict_markup($field, 'billing_email');
799 799
         $label    = "$field.label";
800 800
         echo "
801 801
             <div $restrict>
@@ -809,24 +809,24 @@  discard block
 block discarded – undo
809 809
     /**
810 810
      * Renders the email element on the frontend.
811 811
      */
812
-    public function frontend_render_email_template( $field ) {
812
+    public function frontend_render_email_template($field) {
813 813
         
814 814
         echo "<div class='form-group'>";
815 815
 
816 816
         echo aui()->input(
817 817
             array(
818
-                'name'       => esc_attr( $field['id'] ),
819
-                'id'         => esc_attr( $field['id'] ),
818
+                'name'       => esc_attr($field['id']),
819
+                'id'         => esc_attr($field['id']),
820 820
                 'required'   => (bool) $field['required'],
821
-                'label'      => wp_kses_post( $field['label'] ),
821
+                'label'      => wp_kses_post($field['label']),
822 822
                 'no_wrap'    => true,
823
-                'placeholder' => esc_attr( $field['placeholder'] ),
823
+                'placeholder' => esc_attr($field['placeholder']),
824 824
                 'type'       => 'email',
825 825
             )
826 826
         );
827 827
 
828
-        if ( ! empty( $field['description'] ) ) {
829
-            $description = wp_kses_post( $field['description'] );
828
+        if (!empty($field['description'])) {
829
+            $description = wp_kses_post($field['description']);
830 830
             echo "<small class='form-text text-muted'>$description</small>";
831 831
         }
832 832
 
@@ -837,30 +837,30 @@  discard block
 block discarded – undo
837 837
     /**
838 838
      * Renders the billing email element on the frontend.
839 839
      */
840
-    public function frontend_render_billing_email_template( $field ) {
840
+    public function frontend_render_billing_email_template($field) {
841 841
         
842 842
         echo "<div class='form-group'>";
843 843
         $value = '';
844 844
 
845
-        if ( is_user_logged_in() ) {
845
+        if (is_user_logged_in()) {
846 846
             $user  = wp_get_current_user();
847
-            $value = sanitize_email( $user->user_email );
847
+            $value = sanitize_email($user->user_email);
848 848
         }
849 849
         echo aui()->input(
850 850
             array(
851 851
                 'name'       => 'billing_email',
852 852
                 'value'      => $value,
853
-                'id'         => esc_attr( $field['id'] ),
853
+                'id'         => esc_attr($field['id']),
854 854
                 'required'   => true,
855
-                'label'      => wp_kses_post( $field['label'] ),
855
+                'label'      => wp_kses_post($field['label']),
856 856
                 'no_wrap'    => true,
857
-                'placeholder' => esc_attr( $field['placeholder'] ),
857
+                'placeholder' => esc_attr($field['placeholder']),
858 858
                 'type'       => 'email',
859 859
             )
860 860
         );
861 861
 
862
-        if ( ! empty( $field['description'] ) ) {
863
-            $description = wp_kses_post( $field['description'] );
862
+        if (!empty($field['description'])) {
863
+            $description = wp_kses_post($field['description']);
864 864
             echo "<small class='form-text text-muted'>$description</small>";
865 865
         }
866 866
 
@@ -871,16 +871,16 @@  discard block
 block discarded – undo
871 871
     /**
872 872
      * Renders the edit email element template.
873 873
      */
874
-    public function edit_email_template( $field ) {
875
-        $restrict = $this->get_restrict_markup( $field, 'email' );
876
-        $label    = __( 'Field Label', 'invoicing' );
874
+    public function edit_email_template($field) {
875
+        $restrict = $this->get_restrict_markup($field, 'email');
876
+        $label    = __('Field Label', 'invoicing');
877 877
         $id       = $field . '.id + "_edit"';
878
-        $label2   = __( 'Placeholder text', 'invoicing' );
878
+        $label2   = __('Placeholder text', 'invoicing');
879 879
         $id2      = $field . '.id + "_edit2"';
880
-        $label3   = __( 'Help text', 'invoicing' );
881
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
880
+        $label3   = __('Help text', 'invoicing');
881
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
882 882
         $id3      = $field . '.id + "_edit3"';
883
-        $label5   = __( 'Is this field required?', 'invoicing' );
883
+        $label5   = __('Is this field required?', 'invoicing');
884 884
         $id4      = $field . '.id + "_edit4"';
885 885
         echo "
886 886
             <div $restrict>
@@ -908,16 +908,16 @@  discard block
 block discarded – undo
908 908
     /**
909 909
      * Renders the edit billing_email element template.
910 910
      */
911
-    public function edit_billing_email_template( $field ) {
912
-        $restrict = $this->get_restrict_markup( $field, 'billing_email' );
913
-        $label    = __( 'Field Label', 'invoicing' );
911
+    public function edit_billing_email_template($field) {
912
+        $restrict = $this->get_restrict_markup($field, 'billing_email');
913
+        $label    = __('Field Label', 'invoicing');
914 914
         $id       = $field . '.id + "_edit"';
915
-        $label2   = __( 'Placeholder text', 'invoicing' );
915
+        $label2   = __('Placeholder text', 'invoicing');
916 916
         $id2      = $field . '.id + "_edit2"';
917
-        $label3   = __( 'Help text', 'invoicing' );
918
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
917
+        $label3   = __('Help text', 'invoicing');
918
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
919 919
         $id3      = $field . '.id + "_edit3"';
920
-        $label5   = __( 'Is this field required?', 'invoicing' );
920
+        $label5   = __('Is this field required?', 'invoicing');
921 921
         $id4      = $field . '.id + "_edit4"';
922 922
         echo "
923 923
             <div $restrict>
@@ -941,8 +941,8 @@  discard block
 block discarded – undo
941 941
     /**
942 942
      * Renders the website element template.
943 943
      */
944
-    public function render_website_template( $field ) {
945
-        $restrict = $this->get_restrict_markup( $field, 'website' );
944
+    public function render_website_template($field) {
945
+        $restrict = $this->get_restrict_markup($field, 'website');
946 946
         $label    = "$field.label";
947 947
         echo "
948 948
             <div $restrict>
@@ -956,24 +956,24 @@  discard block
 block discarded – undo
956 956
     /**
957 957
      * Renders the website element on the frontend.
958 958
      */
959
-    public function frontend_render_website_template( $field ) {
959
+    public function frontend_render_website_template($field) {
960 960
         
961 961
         echo "<div class='form-group'>";
962 962
 
963 963
         echo aui()->input(
964 964
             array(
965
-                'name'       => esc_attr( $field['id'] ),
966
-                'id'         => esc_attr( $field['id'] ),
965
+                'name'       => esc_attr($field['id']),
966
+                'id'         => esc_attr($field['id']),
967 967
                 'required'   => (bool) $field['required'],
968
-                'label'      => wp_kses_post( $field['label'] ),
968
+                'label'      => wp_kses_post($field['label']),
969 969
                 'no_wrap'    => true,
970
-                'placeholder' => esc_attr( $field['placeholder'] ),
970
+                'placeholder' => esc_attr($field['placeholder']),
971 971
                 'type'       => 'url',
972 972
             )
973 973
         );
974 974
 
975
-        if ( ! empty( $field['description'] ) ) {
976
-            $description = wp_kses_post( $field['description'] );
975
+        if (!empty($field['description'])) {
976
+            $description = wp_kses_post($field['description']);
977 977
             echo "<small class='form-text text-muted'>$description</small>";
978 978
         }
979 979
 
@@ -984,16 +984,16 @@  discard block
 block discarded – undo
984 984
     /**
985 985
      * Renders the edit website element template.
986 986
      */
987
-    public function edit_website_template( $field ) {
988
-        $restrict = $this->get_restrict_markup( $field, 'website' );
989
-        $label    = __( 'Field Label', 'invoicing' );
987
+    public function edit_website_template($field) {
988
+        $restrict = $this->get_restrict_markup($field, 'website');
989
+        $label    = __('Field Label', 'invoicing');
990 990
         $id       = $field . '.id + "_edit"';
991
-        $label2   = __( 'Placeholder text', 'invoicing' );
991
+        $label2   = __('Placeholder text', 'invoicing');
992 992
         $id2      = $field . '.id + "_edit2"';
993
-        $label3   = __( 'Help text', 'invoicing' );
994
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
993
+        $label3   = __('Help text', 'invoicing');
994
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
995 995
         $id3      = $field . '.id + "_edit3"';
996
-        $label5   = __( 'Is this field required?', 'invoicing' );
996
+        $label5   = __('Is this field required?', 'invoicing');
997 997
         $id4      = $field . '.id + "_edit4"';
998 998
         echo "
999 999
             <div $restrict>
@@ -1021,8 +1021,8 @@  discard block
 block discarded – undo
1021 1021
     /**
1022 1022
      * Renders the date element template.
1023 1023
      */
1024
-    public function render_date_template( $field ) {
1025
-        $restrict = $this->get_restrict_markup( $field, 'date' );
1024
+    public function render_date_template($field) {
1025
+        $restrict = $this->get_restrict_markup($field, 'date');
1026 1026
         $label    = "$field.label";
1027 1027
         echo "
1028 1028
             <div $restrict>
@@ -1036,24 +1036,24 @@  discard block
 block discarded – undo
1036 1036
     /**
1037 1037
      * Renders the date element on the frontend.
1038 1038
      */
1039
-    public function frontend_render_date_template( $field ) {
1039
+    public function frontend_render_date_template($field) {
1040 1040
         
1041 1041
         echo "<div class='form-group'>";
1042 1042
 
1043 1043
         echo aui()->input(
1044 1044
             array(
1045
-                'name'       => esc_attr( $field['id'] ),
1046
-                'id'         => esc_attr( $field['id'] ),
1045
+                'name'       => esc_attr($field['id']),
1046
+                'id'         => esc_attr($field['id']),
1047 1047
                 'required'   => (bool) $field['required'],
1048
-                'label'      => wp_kses_post( $field['label'] ),
1049
-                'placeholder' => esc_attr( $field['placeholder'] ),
1048
+                'label'      => wp_kses_post($field['label']),
1049
+                'placeholder' => esc_attr($field['placeholder']),
1050 1050
                 'no_wrap'    => true,
1051 1051
                 'type'       => 'date',
1052 1052
             )
1053 1053
         );
1054 1054
 
1055
-        if ( ! empty( $field['description'] ) ) {
1056
-            $description = wp_kses_post( $field['description'] );
1055
+        if (!empty($field['description'])) {
1056
+            $description = wp_kses_post($field['description']);
1057 1057
             echo "<small class='form-text text-muted'>$description</small>";
1058 1058
         }
1059 1059
 
@@ -1064,16 +1064,16 @@  discard block
 block discarded – undo
1064 1064
     /**
1065 1065
      * Renders the edit date element template.
1066 1066
      */
1067
-    public function edit_date_template( $field ) {
1068
-        $restrict = $this->get_restrict_markup( $field, 'date' );
1069
-        $label    = __( 'Field Label', 'invoicing' );
1067
+    public function edit_date_template($field) {
1068
+        $restrict = $this->get_restrict_markup($field, 'date');
1069
+        $label    = __('Field Label', 'invoicing');
1070 1070
         $id       = $field . '.id + "_edit"';
1071
-        $label2   = __( 'Placeholder text', 'invoicing' );
1071
+        $label2   = __('Placeholder text', 'invoicing');
1072 1072
         $id2      = $field . '.id + "_edit2"';
1073
-        $label3   = __( 'Help text', 'invoicing' );
1074
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1073
+        $label3   = __('Help text', 'invoicing');
1074
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1075 1075
         $id3      = $field . '.id + "_edit3"';
1076
-        $label5   = __( 'Is this field required?', 'invoicing' );
1076
+        $label5   = __('Is this field required?', 'invoicing');
1077 1077
         $id4      = $field . '.id + "_edit4"';
1078 1078
         echo "
1079 1079
             <div $restrict>
@@ -1101,8 +1101,8 @@  discard block
 block discarded – undo
1101 1101
     /**
1102 1102
      * Renders the time element template.
1103 1103
      */
1104
-    public function render_time_template( $field ) {
1105
-        $restrict = $this->get_restrict_markup( $field, 'time' );
1104
+    public function render_time_template($field) {
1105
+        $restrict = $this->get_restrict_markup($field, 'time');
1106 1106
         $label    = "$field.label";
1107 1107
         echo "
1108 1108
             <div $restrict>
@@ -1116,24 +1116,24 @@  discard block
 block discarded – undo
1116 1116
     /**
1117 1117
      * Renders the time element on the frontend.
1118 1118
      */
1119
-    public function frontend_render_time_template( $field ) {
1119
+    public function frontend_render_time_template($field) {
1120 1120
         
1121 1121
         echo "<div class='form-group'>";
1122 1122
 
1123 1123
         echo aui()->input(
1124 1124
             array(
1125
-                'name'       => esc_attr( $field['id'] ),
1126
-                'id'         => esc_attr( $field['id'] ),
1125
+                'name'       => esc_attr($field['id']),
1126
+                'id'         => esc_attr($field['id']),
1127 1127
                 'required'   => (bool) $field['required'],
1128
-                'label'      => wp_kses_post( $field['label'] ),
1128
+                'label'      => wp_kses_post($field['label']),
1129 1129
                 'no_wrap'    => true,
1130
-                'placeholder' => esc_attr( $field['placeholder'] ),
1130
+                'placeholder' => esc_attr($field['placeholder']),
1131 1131
                 'type'       => 'time',
1132 1132
             )
1133 1133
         );
1134 1134
 
1135
-        if ( ! empty( $field['description'] ) ) {
1136
-            $description = wp_kses_post( $field['description'] );
1135
+        if (!empty($field['description'])) {
1136
+            $description = wp_kses_post($field['description']);
1137 1137
             echo "<small class='form-text text-muted'>$description</small>";
1138 1138
         }
1139 1139
 
@@ -1144,16 +1144,16 @@  discard block
 block discarded – undo
1144 1144
     /**
1145 1145
      * Renders the edit time element template.
1146 1146
      */
1147
-    public function edit_time_template( $field ) {
1148
-        $restrict = $this->get_restrict_markup( $field, 'time' );
1149
-        $label    = __( 'Field Label', 'invoicing' );
1147
+    public function edit_time_template($field) {
1148
+        $restrict = $this->get_restrict_markup($field, 'time');
1149
+        $label    = __('Field Label', 'invoicing');
1150 1150
         $id       = $field . '.id + "_edit"';
1151
-        $label2   = __( 'Placeholder text', 'invoicing' );
1151
+        $label2   = __('Placeholder text', 'invoicing');
1152 1152
         $id2      = $field . '.id + "_edit2"';
1153
-        $label3   = __( 'Help text', 'invoicing' );
1154
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1153
+        $label3   = __('Help text', 'invoicing');
1154
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1155 1155
         $id3      = $field . '.id + "_edit3"';
1156
-        $label5   = __( 'Is this field required?', 'invoicing' );
1156
+        $label5   = __('Is this field required?', 'invoicing');
1157 1157
         $id4      = $field . '.id + "_edit4"';
1158 1158
         echo "
1159 1159
             <div $restrict>
@@ -1181,8 +1181,8 @@  discard block
 block discarded – undo
1181 1181
     /**
1182 1182
      * Renders the number element template.
1183 1183
      */
1184
-    public function render_number_template( $field ) {
1185
-        $restrict = $this->get_restrict_markup( $field, 'number' );
1184
+    public function render_number_template($field) {
1185
+        $restrict = $this->get_restrict_markup($field, 'number');
1186 1186
         $label    = "$field.label";
1187 1187
         echo "
1188 1188
             <div $restrict>
@@ -1196,24 +1196,24 @@  discard block
 block discarded – undo
1196 1196
     /**
1197 1197
      * Renders the number element on the frontend.
1198 1198
      */
1199
-    public function frontend_render_number_template( $field ) {
1199
+    public function frontend_render_number_template($field) {
1200 1200
         
1201 1201
         echo "<div class='form-group'>";
1202 1202
 
1203 1203
         echo aui()->input(
1204 1204
             array(
1205
-                'name'       => esc_attr( $field['id'] ),
1206
-                'id'         => esc_attr( $field['id'] ),
1205
+                'name'       => esc_attr($field['id']),
1206
+                'id'         => esc_attr($field['id']),
1207 1207
                 'required'   => (bool) $field['required'],
1208
-                'label'      => wp_kses_post( $field['label'] ),
1209
-                'placeholder' => esc_attr( $field['placeholder'] ),
1208
+                'label'      => wp_kses_post($field['label']),
1209
+                'placeholder' => esc_attr($field['placeholder']),
1210 1210
                 'no_wrap'    => true,
1211 1211
                 'type'       => 'number',
1212 1212
             )
1213 1213
         );
1214 1214
 
1215
-        if ( ! empty( $field['description'] ) ) {
1216
-            $description = wp_kses_post( $field['description'] );
1215
+        if (!empty($field['description'])) {
1216
+            $description = wp_kses_post($field['description']);
1217 1217
             echo "<small class='form-text text-muted'>$description</small>";
1218 1218
         }
1219 1219
 
@@ -1224,16 +1224,16 @@  discard block
 block discarded – undo
1224 1224
     /**
1225 1225
      * Renders the edit number element template.
1226 1226
      */
1227
-    public function edit_number_template( $field ) {
1228
-        $restrict = $this->get_restrict_markup( $field, 'number' );
1229
-        $label    = __( 'Field Label', 'invoicing' );
1227
+    public function edit_number_template($field) {
1228
+        $restrict = $this->get_restrict_markup($field, 'number');
1229
+        $label    = __('Field Label', 'invoicing');
1230 1230
         $id       = $field . '.id + "_edit"';
1231
-        $label2   = __( 'Placeholder text', 'invoicing' );
1231
+        $label2   = __('Placeholder text', 'invoicing');
1232 1232
         $id2      = $field . '.id + "_edit2"';
1233
-        $label3   = __( 'Help text', 'invoicing' );
1234
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1233
+        $label3   = __('Help text', 'invoicing');
1234
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1235 1235
         $id3      = $field . '.id + "_edit3"';
1236
-        $label5   = __( 'Is this field required?', 'invoicing' );
1236
+        $label5   = __('Is this field required?', 'invoicing');
1237 1237
         $id4      = $field . '.id + "_edit4"';
1238 1238
         echo "
1239 1239
             <div $restrict>
@@ -1261,23 +1261,23 @@  discard block
 block discarded – undo
1261 1261
     /**
1262 1262
      * Renders the separator element template.
1263 1263
      */
1264
-    public function render_separator_template( $field ) {
1265
-        $restrict = $this->get_restrict_markup( $field, 'separator' );
1264
+    public function render_separator_template($field) {
1265
+        $restrict = $this->get_restrict_markup($field, 'separator');
1266 1266
         echo "<hr class='featurette-divider mt-0 mb-2' $restrict>";
1267 1267
     }
1268 1268
 
1269 1269
     /**
1270 1270
      * Renders the separator element on the frontend.
1271 1271
      */
1272
-    public function frontend_render_separator_template( $field ) {
1272
+    public function frontend_render_separator_template($field) {
1273 1273
         echo '<hr class="featurette-divider mt-0 mb-2" />';
1274 1274
     }
1275 1275
 
1276 1276
     /**
1277 1277
      * Renders the pay button element template.
1278 1278
      */
1279
-    public function render_pay_button_template( $field ) {
1280
-        $restrict = $this->get_restrict_markup( $field, 'pay_button' );
1279
+    public function render_pay_button_template($field) {
1280
+        $restrict = $this->get_restrict_markup($field, 'pay_button');
1281 1281
         $label    = "$field.label";
1282 1282
         echo "
1283 1283
             <div $restrict>
@@ -1290,24 +1290,24 @@  discard block
 block discarded – undo
1290 1290
     /**
1291 1291
      * Renders the pay_button element on the frontend.
1292 1292
      */
1293
-    public function frontend_render_pay_button_template( $field ) {
1293
+    public function frontend_render_pay_button_template($field) {
1294 1294
         
1295 1295
         echo "<div class='form-group'>";
1296 1296
 
1297
-        $class = 'btn btn-block submit-button ' . sanitize_html_class( $field['class'] );
1297
+        $class = 'btn btn-block submit-button ' . sanitize_html_class($field['class']);
1298 1298
         echo aui()->input(
1299 1299
             array(
1300
-                'name'       => esc_attr( $field['id'] ),
1301
-                'id'         => esc_attr( $field['id'] ),
1302
-                'value'      => esc_attr( $field['label'] ),
1300
+                'name'       => esc_attr($field['id']),
1301
+                'id'         => esc_attr($field['id']),
1302
+                'value'      => esc_attr($field['label']),
1303 1303
                 'no_wrap'    => true,
1304 1304
                 'type'       => 'submit',
1305 1305
                 'class'      => $class,
1306 1306
             )
1307 1307
         );
1308 1308
 
1309
-        if ( ! empty( $field['description'] ) ) {
1310
-            $description = wp_kses_post( $field['description'] );
1309
+        if (!empty($field['description'])) {
1310
+            $description = wp_kses_post($field['description']);
1311 1311
             echo "<small class='form-text text-muted'>$description</small>";
1312 1312
         }
1313 1313
 
@@ -1318,14 +1318,14 @@  discard block
 block discarded – undo
1318 1318
     /**
1319 1319
      * Renders the pay button element template.
1320 1320
      */
1321
-    public function edit_pay_button_template( $field ) {
1322
-        $restrict = $this->get_restrict_markup( $field, 'pay_button' );
1323
-        $label    = __( 'Button Text', 'invoicing' );
1321
+    public function edit_pay_button_template($field) {
1322
+        $restrict = $this->get_restrict_markup($field, 'pay_button');
1323
+        $label    = __('Button Text', 'invoicing');
1324 1324
         $id       = $field . '.id + "_edit"';
1325
-        $label2   = __( 'Help text', 'invoicing' );
1326
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1325
+        $label2   = __('Help text', 'invoicing');
1326
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
1327 1327
         $id2      = $field . '.id + "_edit2"';
1328
-        $label4   = esc_attr__( 'Button Type', 'invoicing' );
1328
+        $label4   = esc_attr__('Button Type', 'invoicing');
1329 1329
         $id3      = $field . '.id + "_edit3"';
1330 1330
         echo "
1331 1331
             <div $restrict>
@@ -1341,15 +1341,15 @@  discard block
 block discarded – undo
1341 1341
                     <label :for='$id3'>$label4</label>
1342 1342
 
1343 1343
                     <select class='form-control custom-select' :id='$id3' v-model='$field.class'>
1344
-                        <option value='btn-primary'>"   . __( 'Primary', 'invoicing' ) ."</option>
1345
-                        <option value='btn-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option>
1346
-                        <option value='btn-success'>"   . __( 'Success', 'invoicing' ) ."</option>
1347
-                        <option value='btn-danger'>"    . __( 'Danger', 'invoicing' ) ."</option>
1348
-                        <option value='btn-warning'>"   . __( 'Warning', 'invoicing' ) ."</option>
1349
-                        <option value='btn-info'>"      . __( 'Info', 'invoicing' ) ."</option>
1350
-                        <option value='btn-light'>"     . __( 'Light', 'invoicing' ) ."</option>
1351
-                        <option value='btn-dark'>"      . __( 'Dark', 'invoicing' ) ."</option>
1352
-                        <option value='btn-link'>"      . __( 'Link', 'invoicing' ) ."</option>
1344
+                        <option value='btn-primary'>" . __('Primary', 'invoicing') . "</option>
1345
+                        <option value='btn-secondary'>" . __('Secondary', 'invoicing') . "</option>
1346
+                        <option value='btn-success'>"   . __('Success', 'invoicing') . "</option>
1347
+                        <option value='btn-danger'>"    . __('Danger', 'invoicing') . "</option>
1348
+                        <option value='btn-warning'>"   . __('Warning', 'invoicing') . "</option>
1349
+                        <option value='btn-info'>"      . __('Info', 'invoicing') . "</option>
1350
+                        <option value='btn-light'>"     . __('Light', 'invoicing') . "</option>
1351
+                        <option value='btn-dark'>"      . __('Dark', 'invoicing') . "</option>
1352
+                        <option value='btn-link'>"      . __('Link', 'invoicing') . "</option>
1353 1353
                     </select>
1354 1354
                 </div>
1355 1355
             </div>
@@ -1360,8 +1360,8 @@  discard block
 block discarded – undo
1360 1360
     /**
1361 1361
      * Renders the alert element template.
1362 1362
      */
1363
-    public function render_alert_template( $field ) {
1364
-        $restrict = $this->get_restrict_markup( $field, 'alert' );
1363
+    public function render_alert_template($field) {
1364
+        $restrict = $this->get_restrict_markup($field, 'alert');
1365 1365
         $text     = "$field.text";
1366 1366
         echo "
1367 1367
             <div $restrict class='alert' :class='$field.class' role='alert'>
@@ -1376,15 +1376,15 @@  discard block
 block discarded – undo
1376 1376
     /**
1377 1377
      * Renders the alert element on the frontend.
1378 1378
      */
1379
-    public function frontend_render_alert_template( $field ) {
1379
+    public function frontend_render_alert_template($field) {
1380 1380
         
1381 1381
         echo "<div class='form-group'>";
1382 1382
 
1383 1383
         echo aui()->alert(
1384 1384
             array(
1385
-                'content'     => wp_kses_post( $field['text'] ),
1385
+                'content'     => wp_kses_post($field['text']),
1386 1386
                 'dismissible' => $field['dismissible'],
1387
-                'type'        => str_replace( 'alert-', '', $field['class'] ),
1387
+                'type'        => str_replace('alert-', '', $field['class']),
1388 1388
             )
1389 1389
         );
1390 1390
 
@@ -1395,14 +1395,14 @@  discard block
 block discarded – undo
1395 1395
     /**
1396 1396
      * Renders the alert element template.
1397 1397
      */
1398
-    public function edit_alert_template( $field ) {
1399
-        $restrict = $this->get_restrict_markup( $field, 'alert' );
1400
-        $label    = __( 'Alert Text', 'invoicing' );
1401
-        $label2   = esc_attr__( 'Enter your alert text here', 'invoicing' );
1398
+    public function edit_alert_template($field) {
1399
+        $restrict = $this->get_restrict_markup($field, 'alert');
1400
+        $label    = __('Alert Text', 'invoicing');
1401
+        $label2   = esc_attr__('Enter your alert text here', 'invoicing');
1402 1402
         $id       = $field . '.id + "_edit"';
1403
-        $label3   = __( 'Is Dismissible?', 'invoicing' );
1403
+        $label3   = __('Is Dismissible?', 'invoicing');
1404 1404
         $id2      = $field . '.id + "_edit2"';
1405
-        $label4   = esc_attr__( 'Alert Type', 'invoicing' );
1405
+        $label4   = esc_attr__('Alert Type', 'invoicing');
1406 1406
         $id3      = $field . '.id + "_edit3"';
1407 1407
         echo "
1408 1408
             <div $restrict>
@@ -1418,14 +1418,14 @@  discard block
 block discarded – undo
1418 1418
                     <label :for='$id3'>$label4</label>
1419 1419
 
1420 1420
                     <select class='form-control custom-select' :id='$id3' v-model='$field.class'>
1421
-                        <option value='alert-primary'>"   . __( 'Primary', 'invoicing' ) ."</option>
1422
-                        <option value='alert-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option>
1423
-                        <option value='alert-success'>"   . __( 'Success', 'invoicing' ) ."</option>
1424
-                        <option value='alert-danger'>"    . __( 'Danger', 'invoicing' ) ."</option>
1425
-                        <option value='alert-warning'>"   . __( 'Warning', 'invoicing' ) ."</option>
1426
-                        <option value='alert-info'>"      . __( 'Info', 'invoicing' ) ."</option>
1427
-                        <option value='alert-light'>"     . __( 'Light', 'invoicing' ) ."</option>
1428
-                        <option value='alert-dark'>"      . __( 'Dark', 'invoicing' ) ."</option>
1421
+                        <option value='alert-primary'>" . __('Primary', 'invoicing') . "</option>
1422
+                        <option value='alert-secondary'>" . __('Secondary', 'invoicing') . "</option>
1423
+                        <option value='alert-success'>"   . __('Success', 'invoicing') . "</option>
1424
+                        <option value='alert-danger'>"    . __('Danger', 'invoicing') . "</option>
1425
+                        <option value='alert-warning'>"   . __('Warning', 'invoicing') . "</option>
1426
+                        <option value='alert-info'>"      . __('Info', 'invoicing') . "</option>
1427
+                        <option value='alert-light'>"     . __('Light', 'invoicing') . "</option>
1428
+                        <option value='alert-dark'>"      . __('Dark', 'invoicing') . "</option>
1429 1429
                     </select>
1430 1430
                 </div>
1431 1431
             </div>
@@ -1436,8 +1436,8 @@  discard block
 block discarded – undo
1436 1436
     /**
1437 1437
      * Renders the discount element template.
1438 1438
      */
1439
-    public function render_discount_template( $field ) {
1440
-        $restrict  = $this->get_restrict_markup( $field, 'discount' );
1439
+    public function render_discount_template($field) {
1440
+        $restrict = $this->get_restrict_markup($field, 'discount');
1441 1441
         ?>
1442 1442
 
1443 1443
             <div <?php echo $restrict; ?> class="discount_field  border rounded p-3">
@@ -1454,13 +1454,13 @@  discard block
 block discarded – undo
1454 1454
     /**
1455 1455
      * Renders the discount element on the frontend.
1456 1456
      */
1457
-    public function frontend_render_discount_template( $field ) {
1457
+    public function frontend_render_discount_template($field) {
1458 1458
         
1459
-        $placeholder = esc_attr( $field['input_label'] );
1460
-        $label       = sanitize_text_field( $field['button_label'] );
1459
+        $placeholder = esc_attr($field['input_label']);
1460
+        $label       = sanitize_text_field($field['button_label']);
1461 1461
         $description = '';
1462 1462
 
1463
-        if ( ! empty( $field['description'] ) ) {
1463
+        if (!empty($field['description'])) {
1464 1464
             $description = "<small class='form-text text-muted'>{$field['description']}</small>";
1465 1465
         }
1466 1466
 ?>
@@ -1481,12 +1481,12 @@  discard block
 block discarded – undo
1481 1481
     /**
1482 1482
      * Renders the discount element template.
1483 1483
      */
1484
-    public function edit_discount_template( $field ) {
1485
-        $restrict = $this->get_restrict_markup( $field, 'discount' );
1486
-        $label    = __( 'Discount Input Placeholder', 'invoicing' );
1487
-        $label2   = __( 'Help Text', 'invoicing' );
1488
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1489
-        $label4   = __( 'Button Text', 'invoicing' );
1484
+    public function edit_discount_template($field) {
1485
+        $restrict = $this->get_restrict_markup($field, 'discount');
1486
+        $label    = __('Discount Input Placeholder', 'invoicing');
1487
+        $label2   = __('Help Text', 'invoicing');
1488
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
1489
+        $label4   = __('Button Text', 'invoicing');
1490 1490
         $id       = $field . '.id + "_edit"';
1491 1491
         $id2      = $field . '.id + "_edit2"';
1492 1492
         $id3      = $field . '.id + "_edit3"';
@@ -1515,48 +1515,48 @@  discard block
 block discarded – undo
1515 1515
     /**
1516 1516
      * Renders the items element template.
1517 1517
      */
1518
-    public function render_items_template( $field ) {
1519
-        $restrict  = $this->get_restrict_markup( $field, 'items' );
1520
-        $label     = __( 'Item totals placeholder. Item totals will appear here. Click to set items.', 'invoicing' );
1518
+    public function render_items_template($field) {
1519
+        $restrict  = $this->get_restrict_markup($field, 'items');
1520
+        $label     = __('Item totals placeholder. Item totals will appear here. Click to set items.', 'invoicing');
1521 1521
         echo "<div $restrict class='item_totals p-4 bg-warning'>$label</div>";
1522 1522
     }
1523 1523
 
1524 1524
     /**
1525 1525
      * Renders the items element on the frontend.
1526 1526
      */
1527
-    public function frontend_render_items_template( $field, $items ) {
1527
+    public function frontend_render_items_template($field, $items) {
1528 1528
         
1529 1529
         echo "<div class='form-group item_totals'>";
1530 1530
         
1531
-        $id = esc_attr( $field['id'] );
1532
-        if ( 'total' == $field[ 'items_type' ] ) {
1531
+        $id = esc_attr($field['id']);
1532
+        if ('total' == $field['items_type']) {
1533 1533
             $total = 0;
1534 1534
 
1535 1535
             ?>
1536 1536
             <div class="border item_totals_type_total">
1537 1537
 
1538 1538
                 <?php
1539
-                    foreach( $items as $item ) {
1540
-                        $total = $total + floatval( $item['price'] );
1539
+                    foreach ($items as $item) {
1540
+                        $total = $total + floatval($item['price']);
1541 1541
 
1542 1542
                         $class  = 'col-8';
1543 1543
                         $class2 = '';
1544 1544
 
1545
-                        if ( ! empty( $item['allow_quantities'] ) ) {
1545
+                        if (!empty($item['allow_quantities'])) {
1546 1546
                             $class = 'col-6 pt-2';
1547 1547
                             $class2 = 'pt-2';
1548 1548
                         }
1549 1549
 
1550
-                        if ( ! empty( $item['custom_price'] ) ) {
1550
+                        if (!empty($item['custom_price'])) {
1551 1551
                             $class .= ' pt-2';
1552 1552
                         }
1553 1553
             
1554 1554
                 ?>
1555 1555
                     <div  class="item_totals_item">
1556 1556
                         <div class='row pl-2 pr-2 pt-2'>
1557
-                            <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div>
1557
+                            <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div>
1558 1558
 
1559
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
1559
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
1560 1560
 
1561 1561
                                 <div class='col-2'>
1562 1562
                                     <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required>
@@ -1564,11 +1564,11 @@  discard block
 block discarded – undo
1564 1564
 
1565 1565
                             <?php } else { ?>
1566 1566
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
1567
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
1567
+                            <?php } if (empty($item['custom_price'])) { ?>
1568 1568
 
1569 1569
                                 <div class='col-4 <?php echo $class2; ?>'>
1570
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
1571
-                                    <input name='wpinv-items[<?php echo (int) $item['id']; ?>]' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
1570
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
1571
+                                    <input name='wpinv-items[<?php echo (int) $item['id']; ?>]' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
1572 1572
                                 </div>
1573 1573
 
1574 1574
                             <?php } else {?>
@@ -1576,15 +1576,15 @@  discard block
 block discarded – undo
1576 1576
                                 <div class='col-4'>
1577 1577
                                     <div class='input-group'>
1578 1578
 
1579
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
1579
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
1580 1580
                                             <div class='input-group-prepend'>
1581 1581
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1582 1582
                                             </div>
1583 1583
                                         <?php } ?>
1584 1584
 
1585
-                                        <input type='number' name='wpinv-items[<?php echo (int) $item['id']; ?>]' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'>
1585
+                                        <input type='number' name='wpinv-items[<?php echo (int) $item['id']; ?>]' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'>
1586 1586
                                     
1587
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
1587
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
1588 1588
                                             <div class='input-group-append'>
1589 1589
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1590 1590
                                             </div>
@@ -1595,38 +1595,38 @@  discard block
 block discarded – undo
1595 1595
                             <?php } ?>
1596 1596
 
1597 1597
                         </div>
1598
-                        <?php if ( ! empty( $item['description'] )) { ?>
1599
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
1598
+                        <?php if (!empty($item['description'])) { ?>
1599
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
1600 1600
                         <?php } ?>
1601 1601
                     </div>
1602 1602
                 <?php } ?>
1603 1603
 
1604 1604
                 <div class='mt-4 border-top item_totals_total'>
1605 1605
                     <div class='row p-2'>
1606
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
1607
-                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div>
1606
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
1607
+                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div>
1608 1608
                     </div>
1609 1609
                 </div>
1610 1610
 
1611 1611
             </div>
1612 1612
         <?php } ?>
1613 1613
 
1614
-        <?php if ( 'radio' == $field[ 'items_type' ] ) { ?>
1614
+        <?php if ('radio' == $field['items_type']) { ?>
1615 1615
             <div class="item_totals_type_radio">
1616 1616
 
1617 1617
                 <?php
1618
-                    foreach( $items as $index => $item ) {
1618
+                    foreach ($items as $index => $item) {
1619 1619
                 
1620
-                        if ( ! empty( $item['required'] ) ) {
1620
+                        if (!empty($item['required'])) {
1621 1621
                             continue;
1622 1622
                         }
1623 1623
                 ?>
1624 1624
                     <div  class="form-check">
1625
-                        <input class='form-check-input wpinv-items-selector' <?php checked( ! isset( $selected_radio_item ) ); $selected_radio_item = 1; ?> type='radio' value='<?php echo $item['id']; ?>' id='<?php echo $id . $index; ?>' name='wpinv-payment-form-selected-item'>
1626
-                        <label class='form-check-label' for='<?php echo $id . $index; ?>'><?php echo sanitize_text_field( $item['title'] ); ?>&nbsp;<strong><?php echo wpinv_price( wpinv_format_amount( (float) sanitize_text_field(  $item['price'] ) ) ); ?></strong></label>
1625
+                        <input class='form-check-input wpinv-items-selector' <?php checked(!isset($selected_radio_item)); $selected_radio_item = 1; ?> type='radio' value='<?php echo $item['id']; ?>' id='<?php echo $id . $index; ?>' name='wpinv-payment-form-selected-item'>
1626
+                        <label class='form-check-label' for='<?php echo $id . $index; ?>'><?php echo sanitize_text_field($item['title']); ?>&nbsp;<strong><?php echo wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price']))); ?></strong></label>
1627 1627
                     </div>
1628
-                    <?php if ( ! empty( $item['description'] )) { ?>
1629
-                        <small class='form-text text-muted pl-4 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
1628
+                    <?php if (!empty($item['description'])) { ?>
1629
+                        <small class='form-text text-muted pl-4 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
1630 1630
                     <?php } ?>
1631 1631
                 <?php } ?>
1632 1632
 
@@ -1636,29 +1636,29 @@  discard block
 block discarded – undo
1636 1636
 
1637 1637
                         $total = 0;
1638 1638
 
1639
-                        foreach ( $items as $item ) {
1639
+                        foreach ($items as $item) {
1640 1640
 
1641 1641
                             $class  = 'col-8';
1642 1642
                             $class2 = '';
1643 1643
 
1644
-                            if ( ! empty( $item['allow_quantities'] ) ) {
1644
+                            if (!empty($item['allow_quantities'])) {
1645 1645
                                 $class = 'col-6 pt-2';
1646 1646
                                 $class2 = 'pt-2';
1647 1647
                             }
1648 1648
 
1649
-                            if ( ! empty( $item['custom_price'] ) ) {
1649
+                            if (!empty($item['custom_price'])) {
1650 1650
                                 $class .= ' pt-2';
1651 1651
                             }
1652 1652
 
1653 1653
                             $class3 = 'd-none';
1654 1654
                             $name   = '';
1655
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_radio_item ) ) {
1655
+                            if (!empty($item['required']) || !isset($totals_selected_radio_item)) {
1656 1656
 
1657
-                                $total = $total + floatval( $item['price'] );
1657
+                                $total = $total + floatval($item['price']);
1658 1658
                                 $class3 = '';
1659 1659
                                 $name   = "wpinv-items[{$item['id']}]";
1660 1660
 
1661
-                                if ( empty( $item['required'] ) ) {
1661
+                                if (empty($item['required'])) {
1662 1662
                                     $totals_selected_radio_item = 1;
1663 1663
                                 }
1664 1664
 
@@ -1670,9 +1670,9 @@  discard block
 block discarded – undo
1670 1670
 
1671 1671
                     <div  class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>">
1672 1672
                         <div class='row pl-2 pr-2 pt-2'>
1673
-                            <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div>
1673
+                            <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div>
1674 1674
 
1675
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
1675
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
1676 1676
 
1677 1677
                                 <div class='col-2'>
1678 1678
                                     <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required>
@@ -1680,11 +1680,11 @@  discard block
 block discarded – undo
1680 1680
 
1681 1681
                             <?php } else { ?>
1682 1682
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
1683
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
1683
+                            <?php } if (empty($item['custom_price'])) { ?>
1684 1684
 
1685 1685
                                 <div class='col-4 <?php echo $class2; ?>'>
1686
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
1687
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
1686
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
1687
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
1688 1688
                                 </div>
1689 1689
 
1690 1690
                             <?php } else {?>
@@ -1692,15 +1692,15 @@  discard block
 block discarded – undo
1692 1692
                                 <div class='col-4'>
1693 1693
                                     <div class='input-group'>
1694 1694
 
1695
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
1695
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
1696 1696
                                             <div class='input-group-prepend'>
1697 1697
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1698 1698
                                             </div>
1699 1699
                                         <?php } ?>
1700 1700
 
1701
-                                        <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'>
1701
+                                        <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'>
1702 1702
                                     
1703
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
1703
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
1704 1704
                                             <div class='input-group-append'>
1705 1705
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1706 1706
                                             </div>
@@ -1711,16 +1711,16 @@  discard block
 block discarded – undo
1711 1711
                             <?php } ?>
1712 1712
 
1713 1713
                         </div>
1714
-                        <?php if ( ! empty( $item['description'] )) { ?>
1715
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
1714
+                        <?php if (!empty($item['description'])) { ?>
1715
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
1716 1716
                         <?php } ?>
1717 1717
                     </div>
1718 1718
                 <?php } ?>
1719 1719
 
1720 1720
                 <div class='mt-4 border-top item_totals_total'>
1721 1721
                     <div class='row p-2'>
1722
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
1723
-                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div>
1722
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
1723
+                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div>
1724 1724
                     </div>
1725 1725
                 </div>
1726 1726
 
@@ -1728,22 +1728,22 @@  discard block
 block discarded – undo
1728 1728
             </div>
1729 1729
         <?php } ?>
1730 1730
 
1731
-        <?php if ( 'checkbox' == $field[ 'items_type' ] ) { ?>
1731
+        <?php if ('checkbox' == $field['items_type']) { ?>
1732 1732
 
1733 1733
             <div class="item_totals_type_checkbox">
1734 1734
 
1735 1735
                 <?php
1736
-                    foreach ( $items as $index => $item ) {
1736
+                    foreach ($items as $index => $item) {
1737 1737
 
1738
-                        if ( ! empty( $item['required'] ) ) {
1738
+                        if (!empty($item['required'])) {
1739 1739
                             continue;
1740 1740
                         }
1741 1741
 
1742
-                        $title = sanitize_text_field(  $item['title'] );
1743
-                        $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field(  $item['price'] ) ) );
1744
-                        $item_id    = esc_attr( $id . "_$index" );
1745
-                        $value = esc_attr( $item['id'] );
1746
-                        $checked = checked( ! isset( $selected_checkbox_item ), true, false );
1742
+                        $title = sanitize_text_field($item['title']);
1743
+                        $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price'])));
1744
+                        $item_id = esc_attr($id . "_$index");
1745
+                        $value = esc_attr($item['id']);
1746
+                        $checked = checked(!isset($selected_checkbox_item), true, false);
1747 1747
                         $selected_checkbox_item = 1;
1748 1748
 
1749 1749
                         echo "
@@ -1752,7 +1752,7 @@  discard block
 block discarded – undo
1752 1752
                                 <label for='$item_id' class='custom-control-label'>$title &nbsp; ($price)</label>
1753 1753
                             </div>";
1754 1754
 
1755
-                        if ( ! empty( $item['description'] ) ) {
1755
+                        if (!empty($item['description'])) {
1756 1756
                             echo "<small class='form-text text-muted'>{$item['description']}</small>";
1757 1757
                         }
1758 1758
                     }
@@ -1764,29 +1764,29 @@  discard block
 block discarded – undo
1764 1764
 
1765 1765
                         $total = 0;
1766 1766
 
1767
-                        foreach ( $items as $item ) {
1767
+                        foreach ($items as $item) {
1768 1768
 
1769 1769
                             $class  = 'col-8';
1770 1770
                             $class2 = '';
1771 1771
 
1772
-                            if ( ! empty( $item['allow_quantities'] ) ) {
1772
+                            if (!empty($item['allow_quantities'])) {
1773 1773
                                 $class = 'col-6 pt-2';
1774 1774
                                 $class2 = 'pt-2';
1775 1775
                             }
1776 1776
 
1777
-                            if ( ! empty( $item['custom_price'] ) ) {
1777
+                            if (!empty($item['custom_price'])) {
1778 1778
                                 $class .= ' pt-2';
1779 1779
                             }
1780 1780
 
1781 1781
                             $class3 = 'd-none';
1782
-                            $name  = '';
1783
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_checkbox_item ) ) {
1782
+                            $name = '';
1783
+                            if (!empty($item['required']) || !isset($totals_selected_checkbox_item)) {
1784 1784
 
1785
-                                $total = $total + floatval( $item['price'] );
1785
+                                $total = $total + floatval($item['price']);
1786 1786
                                 $class3 = '';
1787 1787
                                 $name  = "wpinv-items[{$item['id']}]";
1788 1788
 
1789
-                                if ( empty( $item['required'] ) ) {
1789
+                                if (empty($item['required'])) {
1790 1790
                                     $totals_selected_checkbox_item = 1;
1791 1791
                                 }
1792 1792
 
@@ -1798,9 +1798,9 @@  discard block
 block discarded – undo
1798 1798
 
1799 1799
                     <div  class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>">
1800 1800
                         <div class='row pl-2 pr-2 pt-2'>
1801
-                            <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div>
1801
+                            <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div>
1802 1802
 
1803
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
1803
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
1804 1804
 
1805 1805
                                 <div class='col-2'>
1806 1806
                                     <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required>
@@ -1808,11 +1808,11 @@  discard block
 block discarded – undo
1808 1808
 
1809 1809
                             <?php } else { ?>
1810 1810
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
1811
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
1811
+                            <?php } if (empty($item['custom_price'])) { ?>
1812 1812
 
1813 1813
                                 <div class='col-4 <?php echo $class2; ?>'>
1814
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
1815
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
1814
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
1815
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
1816 1816
                                 </div>
1817 1817
 
1818 1818
                             <?php } else {?>
@@ -1820,15 +1820,15 @@  discard block
 block discarded – undo
1820 1820
                                 <div class='col-4'>
1821 1821
                                     <div class='input-group'>
1822 1822
 
1823
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
1823
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
1824 1824
                                             <div class='input-group-prepend'>
1825 1825
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1826 1826
                                             </div>
1827 1827
                                         <?php } ?>
1828 1828
 
1829
-                                        <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'>
1829
+                                        <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'>
1830 1830
                                     
1831
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
1831
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
1832 1832
                                             <div class='input-group-append'>
1833 1833
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1834 1834
                                             </div>
@@ -1839,23 +1839,23 @@  discard block
 block discarded – undo
1839 1839
                             <?php } ?>
1840 1840
 
1841 1841
                         </div>
1842
-                        <?php if ( ! empty( $item['description'] )) { ?>
1843
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
1842
+                        <?php if (!empty($item['description'])) { ?>
1843
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
1844 1844
                         <?php } ?>
1845 1845
                     </div>
1846 1846
                 <?php } ?>
1847 1847
 
1848 1848
                 <div class='mt-4 border-top item_totals_total'>
1849 1849
                     <div class='row p-2'>
1850
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
1851
-                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div>
1850
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
1851
+                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div>
1852 1852
                     </div>
1853 1853
                 </div>
1854 1854
             </div>
1855 1855
             </div>
1856 1856
         <?php } ?>
1857 1857
 
1858
-        <?php if ( 'select' == $field[ 'items_type' ] ) { ?>
1858
+        <?php if ('select' == $field['items_type']) { ?>
1859 1859
 
1860 1860
             <div class="item_totals_type_select">
1861 1861
 
@@ -1863,17 +1863,17 @@  discard block
 block discarded – undo
1863 1863
 
1864 1864
                     $options  = array();
1865 1865
                     $selected = '';
1866
-                    foreach ( $items as $index => $item ) {
1866
+                    foreach ($items as $index => $item) {
1867 1867
 
1868
-                        if ( ! empty( $item['required'] ) ) {
1868
+                        if (!empty($item['required'])) {
1869 1869
                             continue;
1870 1870
                         }
1871 1871
 
1872
-                        $title = sanitize_text_field(  $item['title'] );
1873
-                        $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field(  $item['price'] ) ) );
1874
-                        $options[ $item['id'] ] = "$title &nbsp; ($price)";
1872
+                        $title = sanitize_text_field($item['title']);
1873
+                        $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price'])));
1874
+                        $options[$item['id']] = "$title &nbsp; ($price)";
1875 1875
 
1876
-                        if ( ! isset( $selected_item ) ) {
1876
+                        if (!isset($selected_item)) {
1877 1877
                             $selected = $item['id'];
1878 1878
                             $selected_item = 1;
1879 1879
                         }
@@ -1884,7 +1884,7 @@  discard block
 block discarded – undo
1884 1884
                         array(
1885 1885
                                 'name'        => 'payment-form-items',
1886 1886
                                 'id'          => $id,
1887
-                                'placeholder' => __( 'Select an item', 'invoicing' ),
1887
+                                'placeholder' => __('Select an item', 'invoicing'),
1888 1888
                                 'no_wrap'     => true,
1889 1889
                                 'options'     => $options,
1890 1890
                                 'class'       => 'wpi_select2 wpinv-items-select-selector',
@@ -1899,29 +1899,29 @@  discard block
 block discarded – undo
1899 1899
 
1900 1900
                         $total = 0;
1901 1901
 
1902
-                        foreach ( $items as $item ) {
1902
+                        foreach ($items as $item) {
1903 1903
 
1904 1904
                             $class  = 'col-8';
1905 1905
                             $class2 = '';
1906 1906
 
1907
-                            if ( ! empty( $item['allow_quantities'] ) ) {
1907
+                            if (!empty($item['allow_quantities'])) {
1908 1908
                                 $class = 'col-6 pt-2';
1909 1909
                                 $class2 = 'pt-2';
1910 1910
                             }
1911 1911
 
1912
-                            if ( ! empty( $item['custom_price'] ) ) {
1912
+                            if (!empty($item['custom_price'])) {
1913 1913
                                 $class .= ' pt-2';
1914 1914
                             }
1915 1915
 
1916 1916
                             $class3 = 'd-none';
1917
-                            $name  = '';
1918
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_select_item ) ) {
1917
+                            $name = '';
1918
+                            if (!empty($item['required']) || !isset($totals_selected_select_item)) {
1919 1919
 
1920
-                                $total = $total + floatval( $item['price'] );
1920
+                                $total = $total + floatval($item['price']);
1921 1921
                                 $class3 = '';
1922 1922
                                 $name  = "wpinv-items[{$item['id']}]";
1923 1923
 
1924
-                                if ( empty( $item['required'] ) ) {
1924
+                                if (empty($item['required'])) {
1925 1925
                                     $totals_selected_select_item = 1;
1926 1926
                                 }
1927 1927
 
@@ -1933,9 +1933,9 @@  discard block
 block discarded – undo
1933 1933
 
1934 1934
                     <div  class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>">
1935 1935
                         <div class='row pl-2 pr-2 pt-2'>
1936
-                            <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div>
1936
+                            <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div>
1937 1937
 
1938
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
1938
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
1939 1939
 
1940 1940
                                 <div class='col-2'>
1941 1941
                                     <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required>
@@ -1943,11 +1943,11 @@  discard block
 block discarded – undo
1943 1943
 
1944 1944
                             <?php } else { ?>
1945 1945
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
1946
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
1946
+                            <?php } if (empty($item['custom_price'])) { ?>
1947 1947
 
1948 1948
                                 <div class='col-4 <?php echo $class2; ?>'>
1949
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
1950
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
1949
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
1950
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
1951 1951
                                 </div>
1952 1952
 
1953 1953
                             <?php } else {?>
@@ -1955,15 +1955,15 @@  discard block
 block discarded – undo
1955 1955
                                 <div class='col-4'>
1956 1956
                                     <div class='input-group'>
1957 1957
 
1958
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
1958
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
1959 1959
                                             <div class='input-group-prepend'>
1960 1960
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1961 1961
                                             </div>
1962 1962
                                         <?php } ?>
1963 1963
 
1964
-                                        <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'>
1964
+                                        <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'>
1965 1965
                                     
1966
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
1966
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
1967 1967
                                             <div class='input-group-append'>
1968 1968
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1969 1969
                                             </div>
@@ -1974,23 +1974,23 @@  discard block
 block discarded – undo
1974 1974
                             <?php } ?>
1975 1975
 
1976 1976
                         </div>
1977
-                        <?php if ( ! empty( $item['description'] )) { ?>
1978
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
1977
+                        <?php if (!empty($item['description'])) { ?>
1978
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
1979 1979
                         <?php } ?>
1980 1980
                     </div>
1981 1981
                 <?php } ?>
1982 1982
 
1983 1983
                 <div class='mt-4 border-top item_totals_total'>
1984 1984
                     <div class='row p-2'>
1985
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
1986
-                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div>
1985
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
1986
+                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div>
1987 1987
                     </div>
1988 1988
                 </div>
1989 1989
 
1990 1990
             </div>
1991 1991
         <?php } ?>
1992 1992
 
1993
-        <?php if ( 'multi_select' == $field[ 'items_type' ] ) { ?>
1993
+        <?php if ('multi_select' == $field['items_type']) { ?>
1994 1994
 
1995 1995
             <div class="item_totals_type_multi_select">
1996 1996
 
@@ -1999,18 +1999,18 @@  discard block
 block discarded – undo
1999 1999
                     $options  = array();
2000 2000
                     $selected = array();
2001 2001
 
2002
-                    foreach ( $items as $index => $item ) {
2002
+                    foreach ($items as $index => $item) {
2003 2003
 
2004
-                        if ( ! empty( $item['required'] ) ) {
2004
+                        if (!empty($item['required'])) {
2005 2005
                             continue;
2006 2006
                         }
2007 2007
                     
2008
-                        $title = sanitize_text_field(  $item['title'] );
2009
-                        $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field(  $item['price'] ) ) );
2010
-                        $options[ $item['id'] ] = "$title &nbsp; ($price)";
2008
+                        $title = sanitize_text_field($item['title']);
2009
+                        $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price'])));
2010
+                        $options[$item['id']] = "$title &nbsp; ($price)";
2011 2011
 
2012
-                        if ( ! isset( $selected_item ) ) {
2013
-                            $selected = array( $item['id'] );
2012
+                        if (!isset($selected_item)) {
2013
+                            $selected = array($item['id']);
2014 2014
                             $selected_item = 1;
2015 2015
                         }
2016 2016
 
@@ -2035,29 +2035,29 @@  discard block
 block discarded – undo
2035 2035
 
2036 2036
                         $total = 0;
2037 2037
 
2038
-                        foreach ( $items as $item ) {
2038
+                        foreach ($items as $item) {
2039 2039
 
2040 2040
                             $class  = 'col-8';
2041 2041
                             $class2 = '';
2042 2042
 
2043
-                            if ( ! empty( $item['allow_quantities'] ) ) {
2043
+                            if (!empty($item['allow_quantities'])) {
2044 2044
                                 $class = 'col-6 pt-2';
2045 2045
                                 $class2 = 'pt-2';
2046 2046
                             }
2047 2047
 
2048
-                            if ( ! empty( $item['custom_price'] ) ) {
2048
+                            if (!empty($item['custom_price'])) {
2049 2049
                                 $class .= ' pt-2';
2050 2050
                             }
2051 2051
 
2052 2052
                             $class3 = 'd-none';
2053
-                            $name  = '';
2054
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_select_item ) ) {
2053
+                            $name = '';
2054
+                            if (!empty($item['required']) || !isset($totals_selected_select_item)) {
2055 2055
 
2056
-                                $total = $total + floatval( $item['price'] );
2056
+                                $total = $total + floatval($item['price']);
2057 2057
                                 $class3 = '';
2058 2058
                                 $name  = "wpinv-items[{$item['id']}]";
2059 2059
 
2060
-                                if ( empty( $item['required'] ) ) {
2060
+                                if (empty($item['required'])) {
2061 2061
                                     $totals_selected_select_item = 1;
2062 2062
                                 }
2063 2063
 
@@ -2069,9 +2069,9 @@  discard block
 block discarded – undo
2069 2069
 
2070 2070
                     <div  class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>">
2071 2071
                         <div class='row pl-2 pr-2 pt-2'>
2072
-                            <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div>
2072
+                            <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div>
2073 2073
 
2074
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
2074
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
2075 2075
 
2076 2076
                                 <div class='col-2'>
2077 2077
                                     <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required>
@@ -2079,11 +2079,11 @@  discard block
 block discarded – undo
2079 2079
 
2080 2080
                             <?php } else { ?>
2081 2081
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
2082
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
2082
+                            <?php } if (empty($item['custom_price'])) { ?>
2083 2083
 
2084 2084
                                 <div class='col-4 <?php echo $class2; ?>'>
2085
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
2086
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
2085
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
2086
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
2087 2087
                                 </div>
2088 2088
 
2089 2089
                             <?php } else {?>
@@ -2091,15 +2091,15 @@  discard block
 block discarded – undo
2091 2091
                                 <div class='col-4'>
2092 2092
                                     <div class='input-group'>
2093 2093
 
2094
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
2094
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
2095 2095
                                             <div class='input-group-prepend'>
2096 2096
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2097 2097
                                             </div>
2098 2098
                                         <?php } ?>
2099 2099
 
2100
-                                        <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'>
2100
+                                        <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'>
2101 2101
                                     
2102
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
2102
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
2103 2103
                                             <div class='input-group-append'>
2104 2104
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2105 2105
                                             </div>
@@ -2110,23 +2110,23 @@  discard block
 block discarded – undo
2110 2110
                             <?php } ?>
2111 2111
 
2112 2112
                         </div>
2113
-                        <?php if ( ! empty( $item['description'] )) { ?>
2114
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
2113
+                        <?php if (!empty($item['description'])) { ?>
2114
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
2115 2115
                         <?php } ?>
2116 2116
                     </div>
2117 2117
                 <?php } ?>
2118 2118
 
2119 2119
                 <div class='mt-4 border-top item_totals_total'>
2120 2120
                     <div class='row p-2'>
2121
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
2122
-                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div>
2121
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
2122
+                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div>
2123 2123
                     </div>
2124 2124
                 </div>
2125 2125
 
2126 2126
             </div>
2127 2127
         <?php } ?>
2128
-        <?php if ( ! empty( $field[ 'description' ] ) ) { ?>
2129
-            <small class='form-text text-muted'><?php echo wp_kses_post( $field[ 'description' ] ); ?></small>
2128
+        <?php if (!empty($field['description'])) { ?>
2129
+            <small class='form-text text-muted'><?php echo wp_kses_post($field['description']); ?></small>
2130 2130
         <?php } ?>
2131 2131
         </div>
2132 2132
         <?php
@@ -2135,20 +2135,20 @@  discard block
 block discarded – undo
2135 2135
     /**
2136 2136
      * Renders the items element template.
2137 2137
      */
2138
-    public function edit_items_template( $field ) {
2139
-        $restrict = $this->get_restrict_markup( $field, 'items' );
2140
-        $label    = __( 'Let customers...', 'invoicing' );
2141
-        $label2   = __( 'Available Items', 'invoicing' );
2142
-        $label3   = esc_attr__( 'Add some help text for this element', 'invoicing' );
2138
+    public function edit_items_template($field) {
2139
+        $restrict = $this->get_restrict_markup($field, 'items');
2140
+        $label    = __('Let customers...', 'invoicing');
2141
+        $label2   = __('Available Items', 'invoicing');
2142
+        $label3   = esc_attr__('Add some help text for this element', 'invoicing');
2143 2143
         $id       = $field . '.id + "_edit"';
2144 2144
         $id2      = $field . '.id + "_edit2"';
2145 2145
         $id3      = $field . '.id + "_edit3"';
2146 2146
         $id4      = $field . '.id + "_edit4"';
2147
-        $label4   = esc_attr__( 'This will be shown to the customer as the recommended price', 'invoicing' );
2148
-        $label5   = esc_attr__( 'Allow users to pay what they want', 'invoicing' );
2149
-        $label6   = esc_attr__( 'Enter the minimum price that a user can pay', 'invoicing' );
2150
-        $label7   = esc_attr__( 'Allow users to buy several quantities', 'invoicing' );
2151
-        $label8   = esc_attr__( 'This item is required', 'invoicing' );
2147
+        $label4   = esc_attr__('This will be shown to the customer as the recommended price', 'invoicing');
2148
+        $label5   = esc_attr__('Allow users to pay what they want', 'invoicing');
2149
+        $label6   = esc_attr__('Enter the minimum price that a user can pay', 'invoicing');
2150
+        $label7   = esc_attr__('Allow users to buy several quantities', 'invoicing');
2151
+        $label8   = esc_attr__('This item is required', 'invoicing');
2152 2152
         echo "<div $restrict>
2153 2153
 
2154 2154
                 <label>$label2</label>
@@ -2218,7 +2218,7 @@  discard block
 block discarded – undo
2218 2218
                 <div class='form-group mt-2'>
2219 2219
 
2220 2220
                     <select class='form-control custom-select' v-model='selected_item'>
2221
-                        <option value=''>"        . __( 'Add an existing item to the form', 'invoicing' ) ."</option>
2221
+                        <option value=''>" . __('Add an existing item to the form', 'invoicing') . "</option>
2222 2222
                         <option v-for='(item, index) in all_items' :value='index'>{{item.title}}</option>
2223 2223
                     </select>
2224 2224
 
@@ -2233,11 +2233,11 @@  discard block
 block discarded – undo
2233 2233
                     <label :for='$id2'>$label</label>
2234 2234
 
2235 2235
                     <select class='form-control custom-select' :id='$id2' v-model='$field.items_type'>
2236
-                        <option value='total'>"        . __( 'Buy all items on the list', 'invoicing' ) ."</option>
2237
-                        <option value='radio'>"        . __( 'Select a single item from the list', 'invoicing' ) ."</option>
2238
-                        <option value='checkbox'>"     . __( 'Select one or more items on the list', 'invoicing' ) ."</option>
2239
-                        <option value='select'>"       . __( 'Select a single item from a dropdown', 'invoicing' ) ."</option>
2240
-                        <option value='multi_select'>" . __( 'Select a one or more items from a dropdown', 'invoicing' ) ."</option>
2236
+                        <option value='total'>" . __('Buy all items on the list', 'invoicing') . "</option>
2237
+                        <option value='radio'>"        . __('Select a single item from the list', 'invoicing') . "</option>
2238
+                        <option value='checkbox'>"     . __('Select one or more items on the list', 'invoicing') . "</option>
2239
+                        <option value='select'>"       . __('Select a single item from a dropdown', 'invoicing') . "</option>
2240
+                        <option value='multi_select'>" . __('Select a one or more items from a dropdown', 'invoicing') . "</option>
2241 2241
                     </select>
2242 2242
 
2243 2243
                 </div>
@@ -2262,27 +2262,27 @@  discard block
 block discarded – undo
2262 2262
             'orderby'        => 'title',
2263 2263
             'order'          => 'ASC',
2264 2264
             'posts_per_page' => -1,
2265
-            'post_status'    => array( 'publish' ),
2265
+            'post_status'    => array('publish'),
2266 2266
         );
2267 2267
     
2268
-        $items      = get_posts( apply_filters( 'wpinv_item_dropdown_query_args', $item_args ) );
2268
+        $items = get_posts(apply_filters('wpinv_item_dropdown_query_args', $item_args));
2269 2269
 
2270
-        if ( empty( $items ) ) {
2270
+        if (empty($items)) {
2271 2271
             return array();
2272 2272
         }
2273 2273
 
2274
-        $options    = array();
2275
-        foreach ( $items as $item ) {
2276
-            $title            = esc_html( $item->post_title );
2277
-            $title           .= wpinv_get_item_suffix( $item->ID, false );
2278
-            $id               = absint( $item->ID );
2279
-            $price            = wpinv_sanitize_amount( get_post_meta( $id, '_wpinv_price', true ) );
2280
-            $recurring        = (bool) get_post_meta( $id, '_wpinv_is_recurring', true );
2274
+        $options = array();
2275
+        foreach ($items as $item) {
2276
+            $title            = esc_html($item->post_title);
2277
+            $title           .= wpinv_get_item_suffix($item->ID, false);
2278
+            $id               = absint($item->ID);
2279
+            $price            = wpinv_sanitize_amount(get_post_meta($id, '_wpinv_price', true));
2280
+            $recurring        = (bool) get_post_meta($id, '_wpinv_is_recurring', true);
2281 2281
             $description      = $item->post_excerpt;
2282
-            $custom_price     = (bool) get_post_meta( $id, '_wpinv_dynamic_pricing', true );
2283
-            $minimum_price    = (float) get_post_meta( $id, '_minimum_price', true );
2282
+            $custom_price     = (bool) get_post_meta($id, '_wpinv_dynamic_pricing', true);
2283
+            $minimum_price    = (float) get_post_meta($id, '_minimum_price', true);
2284 2284
             $allow_quantities = false;
2285
-            $options[]        = compact( 'title', 'id', 'price', 'recurring', 'description', 'custom_price', 'minimum_price', 'allow_quantities' );
2285
+            $options[]        = compact('title', 'id', 'price', 'recurring', 'description', 'custom_price', 'minimum_price', 'allow_quantities');
2286 2286
 
2287 2287
         }
2288 2288
         return $options;
@@ -2292,38 +2292,38 @@  discard block
 block discarded – undo
2292 2292
     /**
2293 2293
      * Returns an array of items for the currently being edited form.
2294 2294
      */
2295
-    public function get_form_items( $id = false ) {
2295
+    public function get_form_items($id = false) {
2296 2296
         
2297
-        if ( empty( $id ) ) {
2298
-            return wpinv_get_data( 'sample-payment-form-items' );
2297
+        if (empty($id)) {
2298
+            return wpinv_get_data('sample-payment-form-items');
2299 2299
         }
2300 2300
         
2301
-        $form_elements = get_post_meta( $id, 'wpinv_form_items', true );
2301
+        $form_elements = get_post_meta($id, 'wpinv_form_items', true);
2302 2302
 
2303
-        if ( is_array( $form_elements ) ) {
2303
+        if (is_array($form_elements)) {
2304 2304
             return $form_elements;
2305 2305
         }
2306 2306
 
2307
-        return wpinv_get_data( 'sample-payment-form-items' );
2307
+        return wpinv_get_data('sample-payment-form-items');
2308 2308
 
2309 2309
     }
2310 2310
 
2311 2311
     /**
2312 2312
      * Returns an array of elements for the currently being edited form.
2313 2313
      */
2314
-    public function get_form_elements( $id = false ) {
2314
+    public function get_form_elements($id = false) {
2315 2315
 
2316
-        if ( empty( $id ) ) {
2317
-            return wpinv_get_data( 'sample-payment-form' );
2316
+        if (empty($id)) {
2317
+            return wpinv_get_data('sample-payment-form');
2318 2318
         }
2319 2319
         
2320
-        $form_elements = get_post_meta( $id, 'wpinv_form_elements', true );
2320
+        $form_elements = get_post_meta($id, 'wpinv_form_elements', true);
2321 2321
 
2322
-        if ( is_array( $form_elements ) ) {
2322
+        if (is_array($form_elements)) {
2323 2323
             return $form_elements;
2324 2324
         }
2325 2325
 
2326
-        return wpinv_get_data( 'sample-payment-form' );
2326
+        return wpinv_get_data('sample-payment-form');
2327 2327
     }
2328 2328
 
2329 2329
 }
Please login to merge, or discard this patch.