Passed
Push — master ( 169dfd...f76276 )
by Stiofan
04:33
created
includes/class-wpinv.php 1 patch
Spacing   +153 added lines, -153 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();
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
             self::$instance->reports    = new WPInv_Reports();
24 24
         }
25 25
         
26
-        do_action( 'wpinv_loaded' );
26
+        do_action('wpinv_loaded');
27 27
         
28 28
         return self::$instance;
29 29
     }
@@ -33,31 +33,31 @@  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( 'WPInv_Shortcodes', 'init' ) );
48
-        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('WPInv_Shortcodes', 'init'));
48
+        add_action('init', array(&$this, 'wpinv_actions'));
49 49
         
50
-        if ( class_exists( 'BuddyPress' ) ) {
51
-            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
50
+        if (class_exists('BuddyPress')) {
51
+            add_action('bp_include', array(&$this, 'bp_invoicing_init'));
52 52
         }
53 53
 
54
-        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
54
+        add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
55 55
         
56
-        if ( is_admin() ) {
57
-            add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
58
-            add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) );
56
+        if (is_admin()) {
57
+            add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
58
+            add_action('admin_body_class', array(&$this, 'admin_body_class'));
59 59
         } else {
60
-            add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
60
+            add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
61 61
         }
62 62
         
63 63
         /**
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
          *
68 68
          * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference.
69 69
          */
70
-        do_action_ref_array( 'wpinv_actions', array( &$this ) );
70
+        do_action_ref_array('wpinv_actions', array(&$this));
71 71
 
72
-        add_action( 'admin_init', array( &$this, 'activation_redirect') );
72
+        add_action('admin_init', array(&$this, 'activation_redirect'));
73 73
     }
74 74
     
75 75
     public function plugins_loaded() {
@@ -83,187 +83,187 @@  discard block
 block discarded – undo
83 83
      * @since 1.0
84 84
      */
85 85
     public function load_textdomain() {
86
-        $locale = apply_filters( 'plugin_locale', get_locale(), 'invoicing' );
86
+        $locale = apply_filters('plugin_locale', get_locale(), 'invoicing');
87 87
         
88
-        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
89
-        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
88
+        load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
89
+        load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
90 90
         
91 91
         /**
92 92
          * Define language constants.
93 93
          */
94
-        require_once( WPINV_PLUGIN_DIR . 'language.php' );
94
+        require_once(WPINV_PLUGIN_DIR . 'language.php');
95 95
     }
96 96
         
97 97
     public function includes() {
98 98
         global $wpinv_options;
99 99
         
100
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
100
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
101 101
         $wpinv_options = wpinv_get_settings();
102 102
         
103
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' );
104
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
105
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
106
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
107
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
108
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
109
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
110
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' );
111
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
112
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
113
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
114
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
115
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
116
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gd-functions.php' );
117
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' );
103
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php');
104
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
105
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
106
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
107
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
108
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
109
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
110
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php');
111
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
112
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
113
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
114
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
115
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php');
116
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gd-functions.php');
117
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php');
118 118
         //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
119 119
         //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
120
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' );
120
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php');
121 121
         //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscription.php' );
122
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' );
123
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' );
124
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php' );
125
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
126
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
127
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
128
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php' );
129
-        if ( !class_exists( 'Geodir_EUVat' ) ) {
130
-            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
122
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php');
123
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php');
124
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php');
125
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
126
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
127
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
128
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php');
129
+        if (!class_exists('Geodir_EUVat')) {
130
+            require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
131 131
         }
132 132
         
133
-        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
134
-        if ( !empty( $gateways ) ) {
135
-            foreach ( $gateways as $gateway ) {
136
-                if ( $gateway == 'manual' ) {
133
+        $gateways = array_keys(wpinv_get_enabled_payment_gateways());
134
+        if (!empty($gateways)) {
135
+            foreach ($gateways as $gateway) {
136
+                if ($gateway == 'manual') {
137 137
                     continue;
138 138
                 }
139 139
                 
140 140
                 $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
141 141
                 
142
-                if ( file_exists( $gateway_file ) ) {
143
-                    require_once( $gateway_file );
142
+                if (file_exists($gateway_file)) {
143
+                    require_once($gateway_file);
144 144
                 }
145 145
             }
146 146
         }
147
-        require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' );
147
+        require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php');
148 148
         
149
-        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
150
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
151
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
152
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' );
149
+        if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
150
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php');
151
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
152
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php');
153 153
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' );
154
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' );
155
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' );
156
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
157
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' );
158
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
154
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php');
155
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php');
156
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
157
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php');
158
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
159 159
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
160 160
         }
161 161
         
162 162
         // include css inliner
163
-        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
164
-            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
163
+        if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
164
+            include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
165 165
         }
166 166
         
167
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
167
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
168 168
     }
169 169
     
170 170
     public function init() {
171 171
     }
172 172
     
173 173
     public function admin_init() {
174
-        if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) {
174
+        if (!(defined('DOING_AJAX') && DOING_AJAX)) {
175 175
         }
176 176
         
177
-        add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) );
177
+        add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php'));
178 178
     }
179 179
 
180 180
     public function activation_redirect() {
181 181
         // Bail if no activation redirect
182
-        if ( !get_transient( '_wpinv_activation_redirect' ) ) {
182
+        if (!get_transient('_wpinv_activation_redirect')) {
183 183
             return;
184 184
         }
185 185
 
186 186
         // Delete the redirect transient
187
-        delete_transient( '_wpinv_activation_redirect' );
187
+        delete_transient('_wpinv_activation_redirect');
188 188
 
189 189
         // Bail if activating from network, or bulk
190
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
190
+        if (is_network_admin() || isset($_GET['activate-multi'])) {
191 191
             return;
192 192
         }
193 193
 
194
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
194
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
195 195
         exit;
196 196
     }
197 197
     
198 198
     public function enqueue_scripts() {
199
-        $suffix       = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
199
+        $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
200 200
         
201
-        wp_deregister_style( 'font-awesome' );
202
-        wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' );
203
-        wp_enqueue_style( 'font-awesome' );
201
+        wp_deregister_style('font-awesome');
202
+        wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0');
203
+        wp_enqueue_style('font-awesome');
204 204
         
205
-        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION );
206
-        wp_enqueue_style( 'wpinv_front_style' );
205
+        wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION);
206
+        wp_enqueue_style('wpinv_front_style');
207 207
                
208 208
         // Register scripts
209
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
210
-        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array( 'jquery', 'wpinv-vat-script' ),  WPINV_VERSION );
209
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
210
+        wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array('jquery', 'wpinv-vat-script'), WPINV_VERSION);
211 211
         
212 212
         $localize                         = array();
213
-        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
214
-        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
213
+        $localize['ajax_url']             = admin_url('admin-ajax.php');
214
+        $localize['nonce']                = wp_create_nonce('wpinv-nonce');
215 215
         $localize['currency_symbol']      = wpinv_currency_symbol();
216 216
         $localize['currency_pos']         = wpinv_currency_position();
217 217
         $localize['thousand_sep']         = wpinv_thousands_separator();
218 218
         $localize['decimal_sep']          = wpinv_decimal_separator();
219 219
         $localize['decimals']             = wpinv_decimals();
220 220
         
221
-        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
221
+        $localize = apply_filters('wpinv_front_js_localize', $localize);
222 222
         
223
-        wp_enqueue_script( 'jquery-blockui' );
223
+        wp_enqueue_script('jquery-blockui');
224 224
         $autofill_api = wpinv_get_option('address_autofill_api');
225 225
         $autofill_active = wpinv_get_option('address_autofill_active');
226 226
         if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) {
227 227
             wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false);
228 228
             wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery'), '', true);
229 229
         }
230
-        wp_enqueue_script( 'wpinv-front-script' );
231
-        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
230
+        wp_enqueue_script('wpinv-front-script');
231
+        wp_localize_script('wpinv-front-script', 'WPInv', $localize);
232 232
     }
233 233
     
234 234
     public function admin_enqueue_scripts() {
235 235
         global $post, $pagenow;
236 236
         
237 237
         $post_type  = wpinv_admin_post_type();
238
-        $suffix     = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
238
+        $suffix     = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
239 239
         
240
-        wp_deregister_style( 'font-awesome' );
241
-        wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' );
242
-        wp_enqueue_style( 'font-awesome' );
240
+        wp_deregister_style('font-awesome');
241
+        wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0');
242
+        wp_enqueue_style('font-awesome');
243 243
         
244
-        wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
245
-        wp_enqueue_style( 'jquery-ui-css' );
244
+        wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16');
245
+        wp_enqueue_style('jquery-ui-css');
246 246
         
247
-        wp_register_style( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2' );
248
-        wp_enqueue_style( 'jquery-chosen' );
247
+        wp_register_style('jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2');
248
+        wp_enqueue_style('jquery-chosen');
249 249
 
250
-        wp_register_script( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array( 'jquery' ), '1.6.2' );
251
-        wp_enqueue_script( 'jquery-chosen' );
250
+        wp_register_script('jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array('jquery'), '1.6.2');
251
+        wp_enqueue_script('jquery-chosen');
252 252
         
253
-        wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
254
-        wp_enqueue_style( 'wpinv_meta_box_style' );
253
+        wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
254
+        wp_enqueue_style('wpinv_meta_box_style');
255 255
         
256
-        wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION );
257
-        wp_enqueue_style( 'wpinv_admin_style' );
256
+        wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION);
257
+        wp_enqueue_style('wpinv_admin_style');
258 258
         
259
-        if ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) {
260
-            wp_enqueue_script( 'jquery-ui-datepicker' );
259
+        if ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
260
+            wp_enqueue_script('jquery-ui-datepicker');
261 261
         }
262 262
 
263
-        wp_enqueue_style( 'wp-color-picker' );
264
-        wp_enqueue_script( 'wp-color-picker' );
263
+        wp_enqueue_style('wp-color-picker');
264
+        wp_enqueue_script('wp-color-picker');
265 265
         
266
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
266
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
267 267
 
268 268
         if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
269 269
             $autofill_api = wpinv_get_option('address_autofill_api');
@@ -274,17 +274,17 @@  discard block
 block discarded – undo
274 274
             }
275 275
         }
276 276
 
277
-        wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui' ),  WPINV_VERSION );
278
-        wp_enqueue_script( 'wpinv-admin-script' );
277
+        wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array('jquery', 'jquery-blockui'), WPINV_VERSION);
278
+        wp_enqueue_script('wpinv-admin-script');
279 279
         
280 280
         $localize                               = array();
281
-        $localize['ajax_url']                   = admin_url( 'admin-ajax.php' );
282
-        $localize['post_ID']                    = isset( $post->ID ) ? $post->ID : '';
283
-        $localize['wpinv_nonce']                = wp_create_nonce( 'wpinv-nonce' );
284
-        $localize['add_invoice_note_nonce']     = wp_create_nonce( 'add-invoice-note' );
285
-        $localize['delete_invoice_note_nonce']  = wp_create_nonce( 'delete-invoice-note' );
286
-        $localize['invoice_item_nonce']         = wp_create_nonce( 'invoice-item' );
287
-        $localize['billing_details_nonce']      = wp_create_nonce( 'get-billing-details' );
281
+        $localize['ajax_url']                   = admin_url('admin-ajax.php');
282
+        $localize['post_ID']                    = isset($post->ID) ? $post->ID : '';
283
+        $localize['wpinv_nonce']                = wp_create_nonce('wpinv-nonce');
284
+        $localize['add_invoice_note_nonce']     = wp_create_nonce('add-invoice-note');
285
+        $localize['delete_invoice_note_nonce']  = wp_create_nonce('delete-invoice-note');
286
+        $localize['invoice_item_nonce']         = wp_create_nonce('invoice-item');
287
+        $localize['billing_details_nonce']      = wp_create_nonce('get-billing-details');
288 288
         $localize['tax']                        = wpinv_tax_amount();
289 289
         $localize['discount']                   = wpinv_discount_amount();
290 290
         $localize['currency_symbol']            = wpinv_currency_symbol();
@@ -292,65 +292,65 @@  discard block
 block discarded – undo
292 292
         $localize['thousand_sep']               = wpinv_thousands_separator();
293 293
         $localize['decimal_sep']                = wpinv_decimal_separator();
294 294
         $localize['decimals']                   = wpinv_decimals();
295
-        $localize['save_invoice']               = __( 'Save Invoice', 'invoicing' );
296
-        $localize['status_publish']             = wpinv_status_nicename( 'publish' );
297
-        $localize['status_pending']             = wpinv_status_nicename( 'wpi-pending' );
298
-        $localize['delete_tax_rate']            = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' );
299
-        $localize['OneItemMin']                 = __( 'Invoice must contain at least one item', 'invoicing' );
300
-        $localize['DeleteInvoiceItem']          = __( 'Are you sure you wish to delete this item?', 'invoicing' );
301
-        $localize['FillBillingDetails']         = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' );
302
-        $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' );
303
-        $localize['AreYouSure']                 = __( 'Are you sure?', 'invoicing' );
295
+        $localize['save_invoice']               = __('Save Invoice', 'invoicing');
296
+        $localize['status_publish']             = wpinv_status_nicename('publish');
297
+        $localize['status_pending']             = wpinv_status_nicename('wpi-pending');
298
+        $localize['delete_tax_rate']            = __('Are you sure you wish to delete this tax rate?', 'invoicing');
299
+        $localize['OneItemMin']                 = __('Invoice must contain at least one item', 'invoicing');
300
+        $localize['DeleteInvoiceItem']          = __('Are you sure you wish to delete this item?', 'invoicing');
301
+        $localize['FillBillingDetails']         = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing');
302
+        $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');
303
+        $localize['AreYouSure']                 = __('Are you sure?', 'invoicing');
304 304
         $localize['hasGD']                      = wpinv_gd_active();
305 305
         $localize['hasPM']                      = wpinv_pm_active();
306
-        $localize['emptyInvoice']               = __( 'Add atleast one item to save invoice!', 'invoicing' );
307
-        $localize['deletePackage']              = __( 'GD package items should be deleted from GD payment manager only, otherwise it will break invoices that created with this package!', 'invoicing' );
308
-        $localize['deletePackages']             = __( 'GD package items should be deleted from GD payment manager only', 'invoicing' );
309
-        $localize['deleteInvoiceFirst']         = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' );
306
+        $localize['emptyInvoice']               = __('Add atleast one item to save invoice!', 'invoicing');
307
+        $localize['deletePackage']              = __('GD package items should be deleted from GD payment manager only, otherwise it will break invoices that created with this package!', 'invoicing');
308
+        $localize['deletePackages']             = __('GD package items should be deleted from GD payment manager only', 'invoicing');
309
+        $localize['deleteInvoiceFirst']         = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing');
310 310
 
311
-        $localize = apply_filters( 'wpinv_admin_js_localize', $localize );
311
+        $localize = apply_filters('wpinv_admin_js_localize', $localize);
312 312
 
313
-        wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize );
313
+        wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize);
314 314
     }
315 315
     
316
-    public function admin_body_class( $classes ) {
316
+    public function admin_body_class($classes) {
317 317
         global $pagenow, $post, $current_screen;
318 318
         
319
-        if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote' ) ) {
319
+        if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote')) {
320 320
             $classes .= ' wpinv-cpt';
321 321
         }
322 322
         
323
-        $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
323
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
324 324
 
325 325
         $add_class = false;
326
-        if ( $pagenow == 'admin.php' && $page ) {
327
-            $add_class = strpos( $page, 'wpinv-' );
326
+        if ($pagenow == 'admin.php' && $page) {
327
+            $add_class = strpos($page, 'wpinv-');
328 328
         }
329 329
         
330 330
         $settings_class = array();
331
-        if ( $page == 'wpinv-settings' ) {
332
-            if ( !empty( $_REQUEST['tab'] ) ) {
333
-                $settings_class[] = sanitize_text_field( $_REQUEST['tab'] );
331
+        if ($page == 'wpinv-settings') {
332
+            if (!empty($_REQUEST['tab'])) {
333
+                $settings_class[] = sanitize_text_field($_REQUEST['tab']);
334 334
             }
335 335
             
336
-            if ( !empty( $_REQUEST['section'] ) ) {
337
-                $settings_class[] = sanitize_text_field( $_REQUEST['section'] );
336
+            if (!empty($_REQUEST['section'])) {
337
+                $settings_class[] = sanitize_text_field($_REQUEST['section']);
338 338
             }
339 339
             
340
-            $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main';
340
+            $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main';
341 341
         }
342 342
         
343
-        if ( !empty( $settings_class ) ) {
344
-            $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) );
343
+        if (!empty($settings_class)) {
344
+            $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-'));
345 345
         }
346 346
         
347 347
         $post_type = wpinv_admin_post_type();
348 348
 
349
-        if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) {
349
+        if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) {
350 350
             return $classes .= ' wpinv';
351 351
         }
352 352
         
353
-        if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) {
353
+        if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) {
354 354
             $classes .= ' wpi-editable-n';
355 355
         }
356 356
 
@@ -362,20 +362,20 @@  discard block
 block discarded – undo
362 362
     }
363 363
     
364 364
     public function wpinv_actions() {
365
-        if ( isset( $_REQUEST['wpi_action'] ) ) {
366
-            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
365
+        if (isset($_REQUEST['wpi_action'])) {
366
+            do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
367 367
         }
368 368
     }
369 369
     
370
-    public function pre_get_posts( $wp_query ) {
371
-        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() ) {
372
-            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
370
+    public function pre_get_posts($wp_query) {
371
+        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()) {
372
+            $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
373 373
         }
374 374
         
375 375
         return $wp_query;
376 376
     }
377 377
     
378 378
     public function bp_invoicing_init() {
379
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
379
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
380 380
     }
381 381
 }
382 382
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-invoice-address.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -1,34 +1,34 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Billing_Details {
8
-    public static function output( $post ) {
8
+    public static function output($post) {
9 9
         global $user_ID;
10
-        $post_id    = !empty( $post->ID ) ? $post->ID : 0;
11
-        $invoice    = new WPInv_Invoice( $post_id );
10
+        $post_id    = !empty($post->ID) ? $post->ID : 0;
11
+        $invoice    = new WPInv_Invoice($post_id);
12 12
 ?>
13 13
 <div class="gdmbx2-wrap form-table">
14 14
     <div id="gdmbx2-metabox-wpinv_address" class="gdmbx2-metabox gdmbx-field-list wpinv-address gdmbx-row">
15 15
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-user-id table-layout">
16 16
             <div class="gdmbx-th">
17
-                <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label>
17
+                <label for="post_author_override"><?php _e('Customer', 'invoicing'); ?></label>
18 18
             </div>
19 19
             <div class="gdmbx-td gdmbx-customer-div">
20
-            <?php wpinv_dropdown_users( array(
20
+            <?php wpinv_dropdown_users(array(
21 21
                             'name' => 'post_author_override',
22 22
                             'selected' => empty($post->ID) ? $user_ID : $post->post_author,
23 23
                             'include_selected' => true,
24 24
                             'show' => 'user_email',
25 25
                             'orderby' => 'user_email',
26 26
                             'class' => 'gdmbx2-text-large'
27
-                        ) ); ?>
27
+                        )); ?>
28 28
             </div>
29 29
         </div>
30 30
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-email table-layout" style="display:none">
31
-            <div class="gdmbx-th"><label for="wpinv_email"><?php _e( 'Email', 'invoicing' );?> <span class="required">*</span></label>
31
+            <div class="gdmbx-th"><label for="wpinv_email"><?php _e('Email', 'invoicing'); ?> <span class="required">*</span></label>
32 32
             </div>
33 33
             <div class="gdmbx-td">
34 34
                 <input type="hidden" id="wpinv_new_user" name="wpinv_new_user" value="" />
@@ -36,58 +36,58 @@  discard block
 block discarded – undo
36 36
             </div>
37 37
         </div>
38 38
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-btns table-layout">
39
-            <div class="gdmbx-th"><label><?php _e( 'Actions', 'invoicing' );?></label>
39
+            <div class="gdmbx-th"><label><?php _e('Actions', 'invoicing'); ?></label>
40 40
             </div>
41
-            <?php if($invoice->has_status(array('wpi-pending', 'wpi-quote-pending'))){ ?>
41
+            <?php if ($invoice->has_status(array('wpi-pending', 'wpi-quote-pending'))) { ?>
42 42
                 <div class="gdmbx-td">
43
-                    <a id="wpinv-fill-user-details" class="button button-small button-secondary" title="<?php esc_attr_e( 'Fill User Details', 'invoicing' );?>" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-refresh"></i><?php _e( 'Fill User Details', 'invoicing' );?></a>
44
-                    <a class="wpinv-new-user button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-plus"></i><?php _e( 'Add New User', 'invoicing' );?></a>
45
-                    <a style="display:none" class="wpinv-new-cancel button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-close"></i><?php _e( 'Cancel', 'invoicing' );?> </a>
43
+                    <a id="wpinv-fill-user-details" class="button button-small button-secondary" title="<?php esc_attr_e('Fill User Details', 'invoicing'); ?>" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-refresh"></i><?php _e('Fill User Details', 'invoicing'); ?></a>
44
+                    <a class="wpinv-new-user button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-plus"></i><?php _e('Add New User', 'invoicing'); ?></a>
45
+                    <a style="display:none" class="wpinv-new-cancel button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-close"></i><?php _e('Cancel', 'invoicing'); ?> </a>
46 46
                 </div>
47 47
             <?php } ?>
48 48
         </div>
49 49
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-first-name table-layout">
50
-            <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e( 'First Name', 'invoicing' );?></label></div>
50
+            <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e('First Name', 'invoicing'); ?></label></div>
51 51
             <div class="gdmbx-td">
52
-                <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr( $invoice->first_name );?>" />
52
+                <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr($invoice->first_name); ?>" />
53 53
             </div>
54 54
         </div>
55 55
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-last-name table-layout">
56
-            <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e( 'Last Name', 'invoicing' );?></label></div>
56
+            <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e('Last Name', 'invoicing'); ?></label></div>
57 57
             <div class="gdmbx-td">
58
-                <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr( $invoice->last_name );?>" />
58
+                <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr($invoice->last_name); ?>" />
59 59
             </div>
60 60
         </div>
61 61
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-company table-layout">
62
-            <div class="gdmbx-th"><label for="wpinv_company"><?php _e( 'Company', 'invoicing' );?></label></div>
62
+            <div class="gdmbx-th"><label for="wpinv_company"><?php _e('Company', 'invoicing'); ?></label></div>
63 63
             <div class="gdmbx-td">
64
-                <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr( $invoice->company );?>" />
64
+                <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr($invoice->company); ?>" />
65 65
             </div>
66 66
         </div>
67 67
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-vat-number table-layout">
68
-            <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e( 'Vat Number', 'invoicing' );?></label></div>
68
+            <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e('Vat Number', 'invoicing'); ?></label></div>
69 69
             <div class="gdmbx-td">
70
-                <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr( $invoice->vat_number );?>" />
70
+                <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr($invoice->vat_number); ?>" />
71 71
             </div>
72 72
         </div>
73 73
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-address table-layout">
74
-            <div class="gdmbx-th"><label for="wpinv_address"><?php _e( 'Address', 'invoicing' );?></label></div>
74
+            <div class="gdmbx-th"><label for="wpinv_address"><?php _e('Address', 'invoicing'); ?></label></div>
75 75
             <div class="gdmbx-td">
76
-                <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr( $invoice->address );?>" />
76
+                <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr($invoice->address); ?>" />
77 77
             </div>
78 78
         </div>
79 79
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-city table-layout">
80
-            <div class="gdmbx-th"><label for="wpinv_city"><?php _e( 'City', 'invoicing' );?></label></div>
80
+            <div class="gdmbx-th"><label for="wpinv_city"><?php _e('City', 'invoicing'); ?></label></div>
81 81
             <div class="gdmbx-td">
82
-                <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr( $invoice->city );?>" />
82
+                <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr($invoice->city); ?>" />
83 83
             </div>
84 84
         </div>
85 85
         <div class="gdmbx-row gdmbx-type-select gdmbx-wpinv-country table-layout">
86
-            <div class="gdmbx-th"><label for="wpinv_country"><?php _e( 'Country', 'invoicing' );?> <span class="wpi-loader"><i class="fa fa-refresh fa-spin"></i></span></label></div>
86
+            <div class="gdmbx-th"><label for="wpinv_country"><?php _e('Country', 'invoicing'); ?> <span class="wpi-loader"><i class="fa fa-refresh fa-spin"></i></span></label></div>
87 87
             <div class="gdmbx-td">
88 88
                 <?php
89
-                echo wpinv_html_select( array(
90
-                    'options'          => array_merge( array( '' => __( 'Choose a country', 'invoicing' ) ), wpinv_get_country_list() ),
89
+                echo wpinv_html_select(array(
90
+                    'options'          => array_merge(array('' => __('Choose a country', 'invoicing')), wpinv_get_country_list()),
91 91
                     'name'             => 'wpinv_country',
92 92
                     'id'               => 'wpinv_country',
93 93
                     'selected'         => $invoice->country,
@@ -95,20 +95,20 @@  discard block
 block discarded – undo
95 95
                     'show_option_none' => false,
96 96
                     'class'            => 'gdmbx2-text-large',
97 97
                     'chosen'           => false,
98
-                    'placeholder'      => __( 'Choose a country', 'invoicing' ),
98
+                    'placeholder'      => __('Choose a country', 'invoicing'),
99 99
                     'required'         => false,
100
-                ) );
100
+                ));
101 101
                 ?>
102 102
             </div>
103 103
         </div>
104 104
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-state table-layout">
105
-            <div class="gdmbx-th"><label for="wpinv_state"><?php _e( 'State', 'invoicing' );?></label></div>
105
+            <div class="gdmbx-th"><label for="wpinv_state"><?php _e('State', 'invoicing'); ?></label></div>
106 106
             <div class="gdmbx-td">
107 107
                 <?php
108
-                $states = wpinv_get_country_states( $invoice->country );
109
-                if( !empty( $states ) ) {
110
-                    echo wpinv_html_select( array(
111
-                        'options'          => array_merge( array( '' => __( 'Choose a state', 'invoicing' ) ), $states ),
108
+                $states = wpinv_get_country_states($invoice->country);
109
+                if (!empty($states)) {
110
+                    echo wpinv_html_select(array(
111
+                        'options'          => array_merge(array('' => __('Choose a state', 'invoicing')), $states),
112 112
                         'name'             => 'wpinv_state',
113 113
                         'id'               => 'wpinv_state',
114 114
                         'selected'         => $invoice->state,
@@ -116,44 +116,44 @@  discard block
 block discarded – undo
116 116
                         'show_option_none' => false,
117 117
                         'class'            => 'gdmbx2-text-large',
118 118
                         'chosen'           => false,
119
-                        'placeholder'      => __( 'Choose a state', 'invoicing' ),
119
+                        'placeholder'      => __('Choose a state', 'invoicing'),
120 120
                         'required'         => false,
121
-                    ) );
121
+                    ));
122 122
                 } else {
123
-                    echo wpinv_html_text( array(
123
+                    echo wpinv_html_text(array(
124 124
                         'name'  => 'wpinv_state',
125
-                        'value' => ! empty( $invoice->state ) ? $invoice->state : '',
125
+                        'value' => !empty($invoice->state) ? $invoice->state : '',
126 126
                         'id'    => 'wpinv_state',
127 127
                         'class' => 'gdmbx2-text-large',
128 128
                         'required' => false,
129
-                    ) );
129
+                    ));
130 130
                 }
131 131
                 ?>
132 132
             </div>
133 133
         </div>
134 134
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-zip table-layout">
135
-            <div class="gdmbx-th"><label for="wpinv_zip"><?php _e( 'Zipcode', 'invoicing' );?></label></div>
135
+            <div class="gdmbx-th"><label for="wpinv_zip"><?php _e('Zipcode', 'invoicing'); ?></label></div>
136 136
             <div class="gdmbx-td">
137
-                <input type="text" class="gdmbx2-text-large" name="wpinv_zip" id="wpinv_zip" value="<?php echo esc_attr( $invoice->zip );?>" />
137
+                <input type="text" class="gdmbx2-text-large" name="wpinv_zip" id="wpinv_zip" value="<?php echo esc_attr($invoice->zip); ?>" />
138 138
             </div>
139 139
         </div>
140 140
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-phone table-layout">
141
-            <div class="gdmbx-th"><label for="wpinv_phone"><?php _e( 'Phone', 'invoicing' );?></label></div>
141
+            <div class="gdmbx-th"><label for="wpinv_phone"><?php _e('Phone', 'invoicing'); ?></label></div>
142 142
             <div class="gdmbx-td">
143
-                <input type="text" class="gdmbx2-text-large" name="wpinv_phone" id="wpinv_phone" value="<?php echo esc_attr( $invoice->phone );?>" />
143
+                <input type="text" class="gdmbx2-text-large" name="wpinv_phone" id="wpinv_phone" value="<?php echo esc_attr($invoice->phone); ?>" />
144 144
             </div>
145 145
         </div>
146 146
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-ip table-layout">
147
-            <div class="gdmbx-th"><label for="wpinv_ip"><?php _e( 'IP Address', 'invoicing' );?><?php if ($invoice->ip) { ?>
148
-                &nbsp;&nbsp;<a href="<?php echo admin_url( 'admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $invoice->ip ); ?>" title="<?php esc_attr_e( 'View IP information', 'invoicing' );?>" target="_blank"><i class="fa fa-external-link" aria-hidden="true"></i></a>
147
+            <div class="gdmbx-th"><label for="wpinv_ip"><?php _e('IP Address', 'invoicing'); ?><?php if ($invoice->ip) { ?>
148
+                &nbsp;&nbsp;<a href="<?php echo admin_url('admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $invoice->ip); ?>" title="<?php esc_attr_e('View IP information', 'invoicing'); ?>" target="_blank"><i class="fa fa-external-link" aria-hidden="true"></i></a>
149 149
                 <?php } ?></label></div>
150 150
             <div class="gdmbx-td">
151
-                <input type="text" class="gdmbx2-text-large" value="<?php echo esc_attr( $invoice->ip );?>" readonly />
151
+                <input type="text" class="gdmbx2-text-large" value="<?php echo esc_attr($invoice->ip); ?>" readonly />
152 152
             </div>
153 153
         </div>
154 154
     </div>
155 155
 </div>
156
-<?php wp_nonce_field( 'wpinv_save_invoice', 'wpinv_save_invoice' ) ;?>
156
+<?php wp_nonce_field('wpinv_save_invoice', 'wpinv_save_invoice'); ?>
157 157
 <?php
158 158
     }
159 159
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-invoice-details.php 1 patch
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -1,30 +1,30 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Details {
8
-    public static function output( $post ) {
8
+    public static function output($post) {
9 9
         $currency_symbol    = wpinv_currency_symbol();
10 10
         $statuses           = wpinv_get_invoice_statuses();
11 11
         
12
-        $post_id            = !empty( $post->ID ) ? $post->ID : 0;
13
-        $invoice            = new WPInv_Invoice( $post_id );
12
+        $post_id            = !empty($post->ID) ? $post->ID : 0;
13
+        $invoice            = new WPInv_Invoice($post_id);
14 14
         
15
-        $status             = $invoice->get_status( false ); // Current status    
15
+        $status             = $invoice->get_status(false); // Current status    
16 16
         $discount           = $invoice->get_discount();
17 17
         $discount_code      = $discount > 0 ? $invoice->get_discount_code() : '';
18 18
         $invoice_number     = $invoice->get_number();
19 19
         
20 20
         $date_created       = $invoice->get_created_date();
21
-        $datetime_created   = strtotime( $date_created );
22
-        $date_created       = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $datetime_created ) : '';
21
+        $datetime_created   = strtotime($date_created);
22
+        $date_created       = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $datetime_created) : '';
23 23
         $date_completed     = $invoice->get_completed_date();
24
-        $date_completed     = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $date_completed ) ) : 'n/a';
25
-        $title['status'] = __( 'Invoice Status:', 'invoicing' );
26
-        $title['number'] = __( 'Invoice Number:', 'invoicing' );
27
-        $mail_notice = esc_attr__( 'After saving invoice, this will send a copy of the invoice to the user&#8217;s email address.', 'invoicing' );
24
+        $date_completed     = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime($date_completed)) : 'n/a';
25
+        $title['status'] = __('Invoice Status:', 'invoicing');
26
+        $title['number'] = __('Invoice Number:', 'invoicing');
27
+        $mail_notice = esc_attr__('After saving invoice, this will send a copy of the invoice to the user&#8217;s email address.', 'invoicing');
28 28
         
29 29
         $title = apply_filters('wpinv_details_metabox_titles', $title, $invoice);
30 30
         $statuses = apply_filters('wpinv_invoice_statuses', $statuses, $invoice);
@@ -34,29 +34,29 @@  discard block
 block discarded – undo
34 34
 <div class="gdmbx2-wrap form-table">
35 35
     <div class="gdmbx2-metabox gdmbx-field-list" id="gdmbx2-metabox-wpinv_details">
36 36
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-created">
37
-            <div class="gdmbx-th"><label><?php _e( 'Date Created:', 'invoicing' );?></label></div>
38
-            <div class="gdmbx-td"><?php echo $date_created;?></div>
37
+            <div class="gdmbx-th"><label><?php _e('Date Created:', 'invoicing'); ?></label></div>
38
+            <div class="gdmbx-td"><?php echo $date_created; ?></div>
39 39
         </div>
40
-        <?php if ( wpinv_get_option( 'overdue_active' ) && ( $invoice->needs_payment() || $invoice->has_status( array( 'auto-draft' ) ) ) ) { ?>
40
+        <?php if (wpinv_get_option('overdue_active') && ($invoice->needs_payment() || $invoice->has_status(array('auto-draft')))) { ?>
41 41
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-overdue">
42
-            <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e( 'Due Date:', 'invoicing' );?></label></div>
42
+            <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e('Due Date:', 'invoicing'); ?></label></div>
43 43
             <div class="gdmbx-td">
44
-                <input type="text" placeholder="<?php esc_attr_e( 'Y-m-d', 'invoicing' );?>" value="<?php echo esc_attr( $invoice->get_due_date() );?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr( date_i18n( 'Y-m-d', $datetime_created ) );?>" data-dateFormat="yy-mm-dd">
44
+                <input type="text" placeholder="<?php esc_attr_e('Y-m-d', 'invoicing'); ?>" value="<?php echo esc_attr($invoice->get_due_date()); ?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr(date_i18n('Y-m-d', $datetime_created)); ?>" data-dateFormat="yy-mm-dd">
45 45
             </div>
46 46
         </div>
47 47
         <?php } ?>
48
-        <?php if ( $date_completed && $date_completed != 'n/a' ) { ?>
48
+        <?php if ($date_completed && $date_completed != 'n/a') { ?>
49 49
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-completed">
50
-            <div class="gdmbx-th"><label><?php _e( 'Payment Date:', 'invoicing' );?></label></div>
51
-            <div class="gdmbx-td"><?php echo $date_completed;?></div>
50
+            <div class="gdmbx-th"><label><?php _e('Payment Date:', 'invoicing'); ?></label></div>
51
+            <div class="gdmbx-td"><?php echo $date_completed; ?></div>
52 52
         </div>
53 53
         <?php } ?>
54 54
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-status">
55 55
             <div class="gdmbx-th"><label for="wpinv_status"><?php echo $title['status']; ?></label></div>
56 56
             <div class="gdmbx-td">
57 57
                 <select required="required" id="wpinv_status" name="wpinv_status" class="gdmbx2_select">
58
-                    <?php foreach ( $statuses as $value => $label ) { ?>
59
-                    <option value="<?php echo $value;?>" <?php selected( $status, $value );?>><?php echo $label;?></option>
58
+                    <?php foreach ($statuses as $value => $label) { ?>
59
+                    <option value="<?php echo $value; ?>" <?php selected($status, $value); ?>><?php echo $label; ?></option>
60 60
                     <?php } ?>
61 61
                 </select>
62 62
             </div>
@@ -64,107 +64,107 @@  discard block
 block discarded – undo
64 64
         <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-number table-layout">
65 65
             <div class="gdmbx-th"><label for="wpinv_number"><?php echo $title['number']; ?></label></div>
66 66
             <div class="gdmbx-td">
67
-                <input type="text" value="<?php echo esc_attr( $invoice_number );?>" id="wpinv_number" name="wpinv_number" class="regular-text" readonly>
67
+                <input type="text" value="<?php echo esc_attr($invoice_number); ?>" id="wpinv_number" name="wpinv_number" class="regular-text" readonly>
68 68
             </div>
69 69
         </div>
70
-        <?php do_action( 'wpinv_meta_box_details_inner', $post_id ); ?>
71
-        <?php if ( !( $is_paid = ( $invoice->is_paid() || $invoice->is_refunded() ) ) || $discount_code ) { ?>
70
+        <?php do_action('wpinv_meta_box_details_inner', $post_id); ?>
71
+        <?php if (!($is_paid = ($invoice->is_paid() || $invoice->is_refunded())) || $discount_code) { ?>
72 72
         <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-discount-code table-layout">
73
-            <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e( 'Discount Code:', 'invoicing' );?></label></div>
73
+            <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e('Discount Code:', 'invoicing'); ?></label></div>
74 74
             <div class="gdmbx-td">
75
-                <input type="text" value="<?php echo esc_attr( $discount_code ); ?>" id="wpinv_discount" class="medium-text" <?php echo ( $discount_code ? 'readonly' : '' ); ?> /><?php if ( !$is_paid ) { ?><input value="<?php echo esc_attr_e( 'Apply', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-hide' : 'wpi-inlineb' ); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e( 'Remove', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-inlineb' : 'wpi-hide' ); ?>" id="wpinv-remove-code" type="button" /><?php } ?>
75
+                <input type="text" value="<?php echo esc_attr($discount_code); ?>" id="wpinv_discount" class="medium-text" <?php echo ($discount_code ? 'readonly' : ''); ?> /><?php if (!$is_paid) { ?><input value="<?php echo esc_attr_e('Apply', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-hide' : 'wpi-inlineb'); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e('Remove', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-inlineb' : 'wpi-hide'); ?>" id="wpinv-remove-code" type="button" /><?php } ?>
76 76
             </div>
77 77
         </div>
78 78
         <?php } ?>
79 79
     </div>
80 80
 </div>
81 81
 <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-save-send table-layout">
82
-    <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php echo sprintf(__( 'Send %s:', 'invoicing' ),$post_obj->labels->singular_name) ; ?></label>
82
+    <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php echo sprintf(__('Send %s:', 'invoicing'), $post_obj->labels->singular_name); ?></label>
83 83
         <select id="wpi_save_send" name="wpi_save_send">
84
-            <option value="1"><?php _e( 'Yes', 'invoicing' ); ?></option>
85
-            <option value="" selected="selected"><?php _e( 'No', 'invoicing' ); ?></option>
84
+            <option value="1"><?php _e('Yes', 'invoicing'); ?></option>
85
+            <option value="" selected="selected"><?php _e('No', 'invoicing'); ?></option>
86 86
         </select>
87 87
     </p>
88 88
     <p class="wpi-meta-row wpi-send-info"><?php echo $mail_notice; ?></p>
89 89
 </div>
90
-<?php wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ;?>
90
+<?php wp_nonce_field('wpinv_details', 'wpinv_details_nonce'); ?>
91 91
         <?php
92 92
     }
93 93
     
94
-    public static function resend_invoice( $post ) {
94
+    public static function resend_invoice($post) {
95 95
         global $wpi_mb_invoice;
96 96
         
97
-        if ( empty( $wpi_mb_invoice ) ) {
97
+        if (empty($wpi_mb_invoice)) {
98 98
             return;
99 99
         }
100 100
         
101 101
         $text = array(
102
-            'message'       => esc_attr__( 'This will send a copy of the invoice to the customer&#8217;s email address.', 'invoicing' ),
103
-            'button_text'   =>  __( 'Resend Invoice', 'invoicing' ),
102
+            'message'       => esc_attr__('This will send a copy of the invoice to the customer&#8217;s email address.', 'invoicing'),
103
+            'button_text'   =>  __('Resend Invoice', 'invoicing'),
104 104
         );
105 105
             
106 106
         $text = apply_filters('wpinv_resend_invoice_metabox_text', $text);
107
-        do_action( 'wpinv_metabox_resend_invoice_before', $wpi_mb_invoice );
107
+        do_action('wpinv_metabox_resend_invoice_before', $wpi_mb_invoice);
108 108
         
109
-        if ( $email = $wpi_mb_invoice->get_email() ) {
109
+        if ($email = $wpi_mb_invoice->get_email()) {
110 110
             $email_actions = array();
111
-            $email_actions['email_url']      = add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) );
112
-            $email_actions['reminder_url']   = add_query_arg( array( 'wpi_action' => 'send_reminder', 'invoice_id' => $post->ID ) );
111
+            $email_actions['email_url']      = add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID));
112
+            $email_actions['reminder_url']   = add_query_arg(array('wpi_action' => 'send_reminder', 'invoice_id' => $post->ID));
113 113
             
114
-            $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions );
114
+            $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions);
115 115
         ?>
116 116
         <p class="wpi-meta-row wpi-resend-info"><?php echo $text['message']; ?></p>
117
-        <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url( $email_actions['email_url'] ); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p>
118
-        <?php if ( wpinv_get_option( 'overdue_active' ) && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ( $due_date = $wpi_mb_invoice->get_due_date() ) ) { ?>
119
-        <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e( 'Send overdue reminder notification to customer', 'invoicing' ); ?>" href="<?php echo esc_url( $email_actions['reminder_url'] ); ?>" class="button button-secondary"><?php esc_attr_e( 'Send Reminder', 'invoicing' ); ?></a></p>
117
+        <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url($email_actions['email_url']); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p>
118
+        <?php if (wpinv_get_option('overdue_active') && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ($due_date = $wpi_mb_invoice->get_due_date())) { ?>
119
+        <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e('Send overdue reminder notification to customer', 'invoicing'); ?>" href="<?php echo esc_url($email_actions['reminder_url']); ?>" class="button button-secondary"><?php esc_attr_e('Send Reminder', 'invoicing'); ?></a></p>
120 120
         <?php } ?>
121 121
         <?php
122 122
         }
123 123
         
124
-        do_action( 'wpinv_metabox_resend_invoice_after', $wpi_mb_invoice );
124
+        do_action('wpinv_metabox_resend_invoice_after', $wpi_mb_invoice);
125 125
     }
126 126
     
127
-    public static function subscriptions( $post ) {
127
+    public static function subscriptions($post) {
128 128
         global $wpi_mb_invoice;
129 129
         
130 130
         $invoice = $wpi_mb_invoice;
131 131
         
132
-        if ( !empty( $invoice ) && $invoice->is_recurring() && $invoice->is_parent() ) {
132
+        if (!empty($invoice) && $invoice->is_recurring() && $invoice->is_parent()) {
133 133
             $payments       = $invoice->get_child_payments();
134 134
             
135 135
             $total_payments = (int)$invoice->get_total_payments();
136 136
             $subscription   = $invoice->get_subscription_data();
137 137
 
138
-            $billing_cycle  = wpinv_get_billing_cycle( $subscription['initial_amount'], $subscription['recurring_amount'], $subscription['period'], $subscription['interval'], $subscription['bill_times'], $subscription['trial_period'], $subscription['trial_interval'], $invoice->get_currency() );
139
-            $times_billed   = $total_payments . ' / ' . ( ( (int)$subscription['bill_times'] == 0 ) ? __( 'Until cancelled', 'invoicing' ) : $subscription['bill_times'] );
138
+            $billing_cycle  = wpinv_get_billing_cycle($subscription['initial_amount'], $subscription['recurring_amount'], $subscription['period'], $subscription['interval'], $subscription['bill_times'], $subscription['trial_period'], $subscription['trial_interval'], $invoice->get_currency());
139
+            $times_billed   = $total_payments . ' / ' . (((int)$subscription['bill_times'] == 0) ? __('Until cancelled', 'invoicing') : $subscription['bill_times']);
140 140
             $subscription_status = $invoice->get_subscription_status();
141 141
             ?>
142
-            <p class="wpi-meta-row wpi-sub-label"><?php _e( 'Recurring Payment', 'invoicing' );?></p>
143
-            <?php if ( $subscription_id = $invoice->get_subscription_id() ) { ?>
144
-            <p class="wpi-meta-row wpi-sub-id"><label><?php _e( 'Subscription ID:', 'invoicing' );?> </label><?php echo $subscription_id; ?></p>
142
+            <p class="wpi-meta-row wpi-sub-label"><?php _e('Recurring Payment', 'invoicing'); ?></p>
143
+            <?php if ($subscription_id = $invoice->get_subscription_id()) { ?>
144
+            <p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><?php echo $subscription_id; ?></p>
145 145
             <?php } ?>
146
-            <p class="wpi-meta-row wpi-bill-cycle"><label><?php _e( 'Billing Cycle:', 'invoicing' );?> </label><?php echo $billing_cycle; ?></p>
147
-            <p class="wpi-meta-row wpi-billed-times"><label><?php _e( 'Times Billed:', 'invoicing' );?> </label><?php echo $times_billed; ?></p>
148
-            <?php if ( !empty( $payments ) || $invoice->is_paid() ) { ?>
149
-                <p class="wpi-meta-row wpi-start-date"><label><?php _e( 'Start Date:', 'invoicing' );?> </label><?php echo $invoice->get_subscription_start(); ?></p>
150
-                <p class="wpi-meta-row wpi-end-date"><label><?php _e( 'Expiration Date:', 'invoicing' );?> </label><?php echo $invoice->get_subscription_end(); ?></p>
151
-                <?php if ( $status_label = $invoice->get_subscription_status_label( $subscription_status ) ) { ?>
152
-                <p class="wpi-meta-row wpi-sub-status"><label><?php _e( 'Subscription Status:', 'invoicing' );?> </label><?php echo $status_label; ?></p>
146
+            <p class="wpi-meta-row wpi-bill-cycle"><label><?php _e('Billing Cycle:', 'invoicing'); ?> </label><?php echo $billing_cycle; ?></p>
147
+            <p class="wpi-meta-row wpi-billed-times"><label><?php _e('Times Billed:', 'invoicing'); ?> </label><?php echo $times_billed; ?></p>
148
+            <?php if (!empty($payments) || $invoice->is_paid()) { ?>
149
+                <p class="wpi-meta-row wpi-start-date"><label><?php _e('Start Date:', 'invoicing'); ?> </label><?php echo $invoice->get_subscription_start(); ?></p>
150
+                <p class="wpi-meta-row wpi-end-date"><label><?php _e('Expiration Date:', 'invoicing'); ?> </label><?php echo $invoice->get_subscription_end(); ?></p>
151
+                <?php if ($status_label = $invoice->get_subscription_status_label($subscription_status)) { ?>
152
+                <p class="wpi-meta-row wpi-sub-status"><label><?php _e('Subscription Status:', 'invoicing'); ?> </label><?php echo $status_label; ?></p>
153 153
                 <?php } ?>
154
-                <?php if ( $subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date() ) { ?>
155
-                <p class="wpi-meta-row wpi-trial-date"><label><?php _e( 'Trial Until:', 'invoicing' );?> </label><?php echo $trial_end_date; ?></p>
154
+                <?php if ($subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date()) { ?>
155
+                <p class="wpi-meta-row wpi-trial-date"><label><?php _e('Trial Until:', 'invoicing'); ?> </label><?php echo $trial_end_date; ?></p>
156 156
                 <?php } ?>
157
-                <?php if ( $cancelled_date = $invoice->get_cancelled_date() ) { ?>
158
-                <p class="wpi-meta-row wpi-cancel-date"><label><?php _e( 'Cancelled On:', 'invoicing' );?> </label><?php echo $cancelled_date; ?></p>
157
+                <?php if ($cancelled_date = $invoice->get_cancelled_date()) { ?>
158
+                <p class="wpi-meta-row wpi-cancel-date"><label><?php _e('Cancelled On:', 'invoicing'); ?> </label><?php echo $cancelled_date; ?></p>
159 159
                 <?php } ?>
160
-                <?php if ( !empty( $payments ) ) { ?>
161
-                <p><strong><?php _e( 'Renewal Payments:', 'invoicing' ); ?></strong></p>
160
+                <?php if (!empty($payments)) { ?>
161
+                <p><strong><?php _e('Renewal Payments:', 'invoicing'); ?></strong></p>
162 162
                 <ul id="wpi-sub-payments">
163
-                <?php foreach ( $payments as $invoice_id ) { ?>
163
+                <?php foreach ($payments as $invoice_id) { ?>
164 164
                     <li>
165
-                        <a href="<?php echo esc_url( get_edit_post_link( $invoice_id ) ); ?>"><?php echo wpinv_get_invoice_number( $invoice_id ); ?></a>&nbsp;&ndash;&nbsp;
166
-                        <span><?php echo wpinv_get_invoice_date( $invoice_id ); ?>&nbsp;&ndash;&nbsp;</span>
167
-                        <span><?php echo wpinv_payment_total( $invoice_id, true ); ?></span>
165
+                        <a href="<?php echo esc_url(get_edit_post_link($invoice_id)); ?>"><?php echo wpinv_get_invoice_number($invoice_id); ?></a>&nbsp;&ndash;&nbsp;
166
+                        <span><?php echo wpinv_get_invoice_date($invoice_id); ?>&nbsp;&ndash;&nbsp;</span>
167
+                        <span><?php echo wpinv_payment_total($invoice_id, true); ?></span>
168 168
                     </li>
169 169
                 <?php } ?>
170 170
                 </ul>
@@ -172,49 +172,49 @@  discard block
 block discarded – undo
172 172
         }
173 173
     }
174 174
     
175
-    public static function renewals( $post ) {
175
+    public static function renewals($post) {
176 176
         global $wpi_mb_invoice;
177 177
         
178
-        if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) {
179
-            $parent_url = get_edit_post_link( $wpi_mb_invoice->parent_invoice );
180
-            $parent_id  = wpinv_get_invoice_number( $wpi_mb_invoice->parent_invoice );
178
+        if (wpinv_is_subscription_payment($wpi_mb_invoice)) {
179
+            $parent_url = get_edit_post_link($wpi_mb_invoice->parent_invoice);
180
+            $parent_id  = wpinv_get_invoice_number($wpi_mb_invoice->parent_invoice);
181 181
         ?>
182
-        <p class="wpi-meta-row wpi-sub-id"><label><?php _e( 'Subscription ID:', 'invoicing' );?> </label><?php echo $wpi_mb_invoice->get_subscription_id(); ?></p>
183
-        <p class="wpi-meta-row wpi-parent-id"><label><?php _e( 'Parent Invoice:', 'invoicing' );?> </label><a href="<?php echo esc_url( $parent_url ); ?>"><?php echo $parent_id; ?></a></p>
182
+        <p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><?php echo $wpi_mb_invoice->get_subscription_id(); ?></p>
183
+        <p class="wpi-meta-row wpi-parent-id"><label><?php _e('Parent Invoice:', 'invoicing'); ?> </label><a href="<?php echo esc_url($parent_url); ?>"><?php echo $parent_id; ?></a></p>
184 184
         <?php
185 185
         }
186 186
     }
187 187
     
188
-    public static function payment_meta( $post ) {
188
+    public static function payment_meta($post) {
189 189
         global $wpi_mb_invoice;
190 190
 
191
-        $set_dateway = empty( $wpi_mb_invoice->gateway ) ? true : false;
192
-        if ( !$set_dateway && !$wpi_mb_invoice->get_meta( '_wpinv_checkout', true ) && !$wpi_mb_invoice->is_paid() && !$wpi_mb_invoice->is_refunded() ) {
191
+        $set_dateway = empty($wpi_mb_invoice->gateway) ? true : false;
192
+        if (!$set_dateway && !$wpi_mb_invoice->get_meta('_wpinv_checkout', true) && !$wpi_mb_invoice->is_paid() && !$wpi_mb_invoice->is_refunded()) {
193 193
             $set_dateway = true;
194 194
         }
195 195
         
196 196
         ?>
197 197
         <p class="wpi-meta-row">
198
-        <?php if ( $set_dateway ) { $gateways = wpinv_get_enabled_payment_gateways( true ); ?>
199
-            <label for="wpinv_gateway"><?php _e( 'Gateway:', 'invoicing' ) ; ?></label>
198
+        <?php if ($set_dateway) { $gateways = wpinv_get_enabled_payment_gateways(true); ?>
199
+            <label for="wpinv_gateway"><?php _e('Gateway:', 'invoicing'); ?></label>
200 200
             <select required="required" id="wpinv_gateway" name="wpinv_gateway">
201
-                <?php foreach ( $gateways as $name => $gateway ) {
202
-                    if ( $wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription( $name ) ) {
201
+                <?php foreach ($gateways as $name => $gateway) {
202
+                    if ($wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription($name)) {
203 203
                         continue;
204 204
                     }
205 205
                     ?>
206
-                <option value="<?php echo $name;?>" <?php selected( $wpi_mb_invoice->gateway, $name );?>><?php echo !empty( $gateway['admin_label'] ) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option>
206
+                <option value="<?php echo $name; ?>" <?php selected($wpi_mb_invoice->gateway, $name); ?>><?php echo !empty($gateway['admin_label']) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option>
207 207
                 <?php } ?>
208 208
             </select>
209 209
         <?php } else { 
210
-            echo wp_sprintf( __( '<label>Gateway:</label> %s', 'invoicing' ), wpinv_get_gateway_checkout_label( $wpi_mb_invoice->gateway ) );
210
+            echo wp_sprintf(__('<label>Gateway:</label> %s', 'invoicing'), wpinv_get_gateway_checkout_label($wpi_mb_invoice->gateway));
211 211
         } ?>
212 212
         </p>
213
-        <?php if ( $key = $wpi_mb_invoice->get_key() ) { ?>
214
-        <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Key:</label> %s', 'invoicing' ), $key ); ?></p>
213
+        <?php if ($key = $wpi_mb_invoice->get_key()) { ?>
214
+        <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Key:</label> %s', 'invoicing'), $key); ?></p>
215 215
         <?php } ?>
216
-        <?php if ( $wpi_mb_invoice->is_paid() || $wpi_mb_invoice->is_refunded() ) { ?>
217
-        <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Transaction ID:</label> %s', 'invoicing' ), wpinv_payment_link_transaction_id( $wpi_mb_invoice ) ); ?></p>
216
+        <?php if ($wpi_mb_invoice->is_paid() || $wpi_mb_invoice->is_refunded()) { ?>
217
+        <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Transaction ID:</label> %s', 'invoicing'), wpinv_payment_link_transaction_id($wpi_mb_invoice)); ?></p>
218 218
         <?php } ?>
219 219
         <?php
220 220
     }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-invoice-items.php 1 patch
Spacing   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Items {
8
-    public static function output( $post ) {        
8
+    public static function output($post) {        
9 9
         global $wpinv_euvat, $ajax_cart_details;
10 10
         
11
-        $post_id            = !empty( $post->ID ) ? $post->ID : 0;
12
-        $invoice            = new WPInv_Invoice( $post_id );
11
+        $post_id            = !empty($post->ID) ? $post->ID : 0;
12
+        $invoice            = new WPInv_Invoice($post_id);
13 13
         $ajax_cart_details  = $invoice->get_cart_details();
14
-        $subtotal           = $invoice->get_subtotal( true );
14
+        $subtotal           = $invoice->get_subtotal(true);
15 15
         $discount_raw       = $invoice->get_discount();
16
-        $discount           = wpinv_price( $discount_raw, $invoice->get_currency() );
16
+        $discount           = wpinv_price($discount_raw, $invoice->get_currency());
17 17
         $discounts          = $discount_raw > 0 ? $invoice->get_discounts() : '';
18
-        $tax                = $invoice->get_tax( true );
19
-        $total              = $invoice->get_total( true );
18
+        $tax                = $invoice->get_tax(true);
19
+        $total              = $invoice->get_total(true);
20 20
         $item_quantities    = wpinv_item_quantities_enabled();
21 21
         $use_taxes          = wpinv_use_taxes();
22 22
         $item_types         = wpinv_get_item_types();
@@ -29,20 +29,20 @@  discard block
 block discarded – undo
29 29
         }
30 30
         
31 31
         $cols = 5;
32
-        if ( $item_quantities ) {
32
+        if ($item_quantities) {
33 33
             $cols++;
34 34
         }
35
-        if ( $use_taxes ) {
35
+        if ($use_taxes) {
36 36
             $cols++;
37 37
         }
38 38
         $class = '';
39
-        if ( $invoice->is_paid() ) {
39
+        if ($invoice->is_paid()) {
40 40
             $class .= ' wpinv-paid';
41 41
         }
42
-        if ( $invoice->is_refunded() ) {
42
+        if ($invoice->is_refunded()) {
43 43
             $class .= ' wpinv-refunded';
44 44
         }
45
-        if ( $is_recurring ) {
45
+        if ($is_recurring) {
46 46
             $class .= ' wpi-recurring';
47 47
         }
48 48
         ?>
@@ -50,21 +50,21 @@  discard block
 block discarded – undo
50 50
             <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0">
51 51
                 <thead>
52 52
                     <tr>
53
-                        <th class="id"><?php _e( 'ID', 'invoicing' );?></th>
54
-                        <th class="title"><?php _e( 'Item', 'invoicing' );?></th>
55
-                        <th class="price"><?php _e( 'Price', 'invoicing' );?></th>
56
-                        <?php if ( $item_quantities ) { ?>
57
-                        <th class="qty"><?php _e( 'Qty', 'invoicing' );?></th>
53
+                        <th class="id"><?php _e('ID', 'invoicing'); ?></th>
54
+                        <th class="title"><?php _e('Item', 'invoicing'); ?></th>
55
+                        <th class="price"><?php _e('Price', 'invoicing'); ?></th>
56
+                        <?php if ($item_quantities) { ?>
57
+                        <th class="qty"><?php _e('Qty', 'invoicing'); ?></th>
58 58
                         <?php } ?>
59
-                        <th class="total"><?php _e( 'Total', 'invoicing' );?></th>
60
-                        <?php if ( $use_taxes ) { ?>
61
-                        <th class="tax"><?php _e( 'Tax (%)', 'invoicing' );?></th>
59
+                        <th class="total"><?php _e('Total', 'invoicing'); ?></th>
60
+                        <?php if ($use_taxes) { ?>
61
+                        <th class="tax"><?php _e('Tax (%)', 'invoicing'); ?></th>
62 62
                         <?php } ?>
63 63
                         <th class="action"></th>
64 64
                     </tr>
65 65
                 </thead>
66 66
                 <tbody class="wpinv-line-items">
67
-                    <?php echo wpinv_admin_get_line_items( $invoice ); ?>
67
+                    <?php echo wpinv_admin_get_line_items($invoice); ?>
68 68
                 </tbody>
69 69
                 <tfoot class="wpinv-totals">
70 70
                     <tr>
@@ -76,44 +76,44 @@  discard block
 block discarded – undo
76 76
                                         </td>
77 77
                                         <td class="title">
78 78
                                             <input type="text" class="regular-text" placeholder="Item name" value="" name="_wpinv_quick[name]">
79
-                                            <?php if ( $wpinv_euvat->allow_vat_rules() ) { ?>
79
+                                            <?php if ($wpinv_euvat->allow_vat_rules()) { ?>
80 80
                                             <div class="wp-clearfix">
81 81
                                                 <label class="wpi-vat-rule">
82
-                                                    <span class="title"><?php _e( 'VAT rule type', 'invoicing' );?></span>
82
+                                                    <span class="title"><?php _e('VAT rule type', 'invoicing'); ?></span>
83 83
                                                     <span class="input-text-wrap">
84
-                                                        <?php echo wpinv_html_select( array(
84
+                                                        <?php echo wpinv_html_select(array(
85 85
                                                             'options'          => $wpinv_euvat->get_rules(),
86 86
                                                             'name'             => '_wpinv_quick[vat_rule]',
87 87
                                                             'id'               => '_wpinv_quick_vat_rule',
88 88
                                                             'show_option_all'  => false,
89 89
                                                             'show_option_none' => false,
90 90
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-rule',
91
-                                                        ) ); ?>
91
+                                                        )); ?>
92 92
                                                     </span>
93 93
                                                 </label>
94 94
                                             </div>
95
-                                            <?php } if ( $wpinv_euvat->allow_vat_classes() ) { ?>
95
+                                            <?php } if ($wpinv_euvat->allow_vat_classes()) { ?>
96 96
                                             <div class="wp-clearfix">
97 97
                                                 <label class="wpi-vat-class">
98
-                                                    <span class="title"><?php _e( 'VAT class', 'invoicing' );?></span>
98
+                                                    <span class="title"><?php _e('VAT class', 'invoicing'); ?></span>
99 99
                                                     <span class="input-text-wrap">
100
-                                                        <?php echo wpinv_html_select( array(
100
+                                                        <?php echo wpinv_html_select(array(
101 101
                                                             'options'          => $wpinv_euvat->get_all_classes(),
102 102
                                                             'name'             => '_wpinv_quick[vat_class]',
103 103
                                                             'id'               => '_wpinv_quick_vat_class',
104 104
                                                             'show_option_all'  => false,
105 105
                                                             'show_option_none' => false,
106 106
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-class',
107
-                                                        ) ); ?>
107
+                                                        )); ?>
108 108
                                                     </span>
109 109
                                                 </label>
110 110
                                             </div>
111 111
                                             <?php } ?>
112 112
                                             <div class="wp-clearfix">
113 113
                                                 <label class="wpi-item-type">
114
-                                                    <span class="title"><?php _e( 'Item type', 'invoicing' );?></span>
114
+                                                    <span class="title"><?php _e('Item type', 'invoicing'); ?></span>
115 115
                                                     <span class="input-text-wrap">
116
-                                                        <?php echo wpinv_html_select( array(
116
+                                                        <?php echo wpinv_html_select(array(
117 117
                                                             'options'          => $item_types,
118 118
                                                             'name'             => '_wpinv_quick[type]',
119 119
                                                             'id'               => '_wpinv_quick_type',
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
                                                             'show_option_all'  => false,
122 122
                                                             'show_option_none' => false,
123 123
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-type',
124
-                                                        ) ); ?>
124
+                                                        )); ?>
125 125
                                                     </span>
126 126
                                                 </label>
127 127
                                             </div>
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
                                             </div>
135 135
                                         </td>
136 136
                                         <td class="price"><input type="text" placeholder="0.00" class="wpi-field-price wpi-price" name="_wpinv_quick[price]" /></td>
137
-                                        <?php if ( $item_quantities ) { ?>
137
+                                        <?php if ($item_quantities) { ?>
138 138
                                         <td class="qty"><input type="number" class="small-text" step="1" min="1" value="1" name="_wpinv_quick[qty]" /></td>
139 139
                                         <?php } ?>
140 140
                                         <td class="total"></td>
141
-                                        <?php if ( $use_taxes ) { ?>
141
+                                        <?php if ($use_taxes) { ?>
142 142
                                         <td class="tax"></td>
143 143
                                         <?php } ?>
144 144
                                         <td class="action"></td>
@@ -151,29 +151,29 @@  discard block
 block discarded – undo
151 151
                         <td colspan="<?php echo $cols; ?>"></td>
152 152
                     </tr>
153 153
                     <tr class="totals">
154
-                        <td colspan="<?php echo ( $cols - 4 ); ?>"></td>
154
+                        <td colspan="<?php echo ($cols - 4); ?>"></td>
155 155
                         <td colspan="4">
156 156
                             <table cellspacing="0" cellpadding="0">
157 157
                                 <tr class="subtotal">
158
-                                    <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td>
159
-                                    <td class="total"><?php echo $subtotal;?></td>
158
+                                    <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td>
159
+                                    <td class="total"><?php echo $subtotal; ?></td>
160 160
                                     <td class="action"></td>
161 161
                                 </tr>
162 162
                                 <tr class="discount">
163
-                                    <td class="name"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice->ID ) ); ?>:</td>
164
-                                    <td class="total"><?php echo wpinv_discount( $invoice->ID, true, true ); ?></td>
163
+                                    <td class="name"><?php wpinv_get_discount_label(wpinv_discount_code($invoice->ID)); ?>:</td>
164
+                                    <td class="total"><?php echo wpinv_discount($invoice->ID, true, true); ?></td>
165 165
                                     <td class="action"></td>
166 166
                                 </tr>
167
-                                <?php if ( $use_taxes ) { ?>
167
+                                <?php if ($use_taxes) { ?>
168 168
                                 <tr class="tax">
169
-                                    <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td>
170
-                                    <td class="total"><?php echo $tax;?></td>
169
+                                    <td class="name"><?php _e('Tax:', 'invoicing'); ?></td>
170
+                                    <td class="total"><?php echo $tax; ?></td>
171 171
                                     <td class="action"></td>
172 172
                                 </tr>
173 173
                                 <?php } ?>
174 174
                                 <tr class="total">
175
-                                    <td class="name"><?php echo apply_filters( 'wpinv_invoice_items_total_label', __( 'Invoice Total:', 'invoicing' ), $invoice );?></td>
176
-                                    <td class="total"><?php echo $total;?></td>
175
+                                    <td class="name"><?php echo apply_filters('wpinv_invoice_items_total_label', __('Invoice Total:', 'invoicing'), $invoice); ?></td>
176
+                                    <td class="total"><?php echo $total; ?></td>
177 177
                                     <td class="action"></td>
178 178
                                 </tr>
179 179
                             </table>
@@ -183,89 +183,89 @@  discard block
 block discarded – undo
183 183
             </table>
184 184
             <div class="wpinv-actions">
185 185
                 <?php
186
-                    if ( !$invoice->is_paid() && !$invoice->is_refunded() ) {
187
-                    if ( !$invoice->is_recurring() ) {
188
-                    echo wpinv_item_dropdown( array(
186
+                    if (!$invoice->is_paid() && !$invoice->is_refunded()) {
187
+                    if (!$invoice->is_recurring()) {
188
+                    echo wpinv_item_dropdown(array(
189 189
                         'name'             => 'wpinv_invoice_item',
190 190
                         'id'               => 'wpinv_invoice_item',
191 191
                         'with_packages'    => false,
192 192
                         'show_recurring'   => true,
193
-                    ) );
193
+                    ));
194 194
                     ?>
195
-                <input type="button" value="<?php echo sprintf(esc_attr__( 'Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e( 'Create new item', 'invoicing' );?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e( 'Recalculate Totals', 'invoicing' );?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">
195
+                <input type="button" value="<?php echo sprintf(esc_attr__('Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e('Create new item', 'invoicing'); ?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e('Recalculate Totals', 'invoicing'); ?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">
196 196
                     <?php } ?>
197
-                <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?>
197
+                <?php do_action('wpinv_invoice_items_actions', $invoice); ?>
198 198
             </div>
199 199
         </div>
200 200
         <?php
201 201
     }
202 202
     
203
-    public static function prices( $post ) {        
203
+    public static function prices($post) {        
204 204
         $symbol         = wpinv_currency_symbol();
205 205
         $position       = wpinv_currency_position();
206
-        $item           = new WPInv_Item( $post->ID );
206
+        $item           = new WPInv_Item($post->ID);
207 207
         
208 208
         $price          = $item->get_price();
209 209
         $is_recurring   = $item->is_recurring();
210 210
         $period         = $item->get_recurring_period();
211
-        $interval       = absint( $item->get_recurring_interval() );
212
-        $times          = absint( $item->get_recurring_limit() );
211
+        $interval       = absint($item->get_recurring_interval());
212
+        $times          = absint($item->get_recurring_limit());
213 213
         $free_trial     = $item->has_free_trial();
214 214
         $trial_interval = $item->get_trial_interval();
215 215
         $trial_period   = $item->get_trial_period();
216 216
         
217 217
         $intervals      = array();
218
-        for ( $i = 1; $i <= 90; $i++ ) {
218
+        for ($i = 1; $i <= 90; $i++) {
219 219
             $intervals[$i] = $i;
220 220
         }
221 221
         
222
-        $interval       = $interval > 0 ? $interval : 1;
222
+        $interval = $interval > 0 ? $interval : 1;
223 223
         
224 224
         $class = $is_recurring ? 'wpinv-recurring-y' : 'wpinv-recurring-n';
225 225
         ?>
226
-        <p class="wpinv-row-prices"><?php echo ( $position != 'right' ? $symbol . '&nbsp;' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $price;?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled( $item->is_package(), true ); ?> /><?php echo ( $position == 'right' ? '&nbsp;' . $symbol : '' );?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce( 'wpinv_item_meta_box_save' ) ;?>" />
227
-        <?php if ( $item->is_package() ) { ?>
228
-        <span class="description"><?php _e( 'GD package item price can be edited only from GD payment manager.', 'invoicing' ); ?></span>
226
+        <p class="wpinv-row-prices"><?php echo ($position != 'right' ? $symbol . '&nbsp;' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $price; ?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled($item->is_package(), true); ?> /><?php echo ($position == 'right' ? '&nbsp;' . $symbol : ''); ?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce('wpinv_item_meta_box_save'); ?>" />
227
+        <?php if ($item->is_package()) { ?>
228
+        <span class="description"><?php _e('GD package item price can be edited only from GD payment manager.', 'invoicing'); ?></span>
229 229
         <?php } ?>
230 230
         </p>
231 231
         <p class="wpinv-row-is-recurring">
232 232
             <label for="wpinv_is_recurring">
233
-                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked( 1, $is_recurring ); ?> />
234
-                <?php echo apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Is Recurring Item?', 'invoicing' ) ); ?>
233
+                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked(1, $is_recurring); ?> />
234
+                <?php echo apply_filters('wpinv_is_recurring_toggle_text', __('Is Recurring Item?', 'invoicing')); ?>
235 235
             </label>
236 236
         </p>
237
-        <p class="wpinv-row-recurring-fields <?php echo $class;?>">
238
-                <label class="wpinv-period" for="wpinv_recurring_period"><?php _e( 'Recurring', 'invoicing' );?> <select class="wpinv-select " id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e( 'day(s)', 'invoicing' ); ?>" <?php selected( 'D', $period );?>><?php _e( 'Daily', 'invoicing' ); ?></option><option value="W" data-text="<?php esc_attr_e( 'week(s)', 'invoicing' ); ?>" <?php selected( 'W', $period );?>><?php _e( 'Weekly', 'invoicing' ); ?></option><option value="M" data-text="<?php esc_attr_e( 'month(s)', 'invoicing' ); ?>" <?php selected( 'M', $period );?>><?php _e( 'Monthly', 'invoicing' ); ?></option><option value="Y" data-text="<?php esc_attr_e( 'year(s)', 'invoicing' ); ?>" <?php selected( 'Y', $period );?>><?php _e( 'Yearly', 'invoicing' ); ?></option></select></label>
239
-                <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e( 'at every', 'invoicing' );?> <?php echo wpinv_html_select( array(
237
+        <p class="wpinv-row-recurring-fields <?php echo $class; ?>">
238
+                <label class="wpinv-period" for="wpinv_recurring_period"><?php _e('Recurring', 'invoicing'); ?> <select class="wpinv-select " id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e('day(s)', 'invoicing'); ?>" <?php selected('D', $period); ?>><?php _e('Daily', 'invoicing'); ?></option><option value="W" data-text="<?php esc_attr_e('week(s)', 'invoicing'); ?>" <?php selected('W', $period); ?>><?php _e('Weekly', 'invoicing'); ?></option><option value="M" data-text="<?php esc_attr_e('month(s)', 'invoicing'); ?>" <?php selected('M', $period); ?>><?php _e('Monthly', 'invoicing'); ?></option><option value="Y" data-text="<?php esc_attr_e('year(s)', 'invoicing'); ?>" <?php selected('Y', $period); ?>><?php _e('Yearly', 'invoicing'); ?></option></select></label>
239
+                <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e('at every', 'invoicing'); ?> <?php echo wpinv_html_select(array(
240 240
                     'options'          => $intervals,
241 241
                     'name'             => 'wpinv_recurring_interval',
242 242
                     'id'               => 'wpinv_recurring_interval',
243 243
                     'selected'         => $interval,
244 244
                     'show_option_all'  => false,
245 245
                     'show_option_none' => false
246
-                ) ); ?> <span id="wpinv_interval_text"><?php _e( 'day(s)', 'invoicing' );?></span></label>
247
-                <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e( 'for', 'invoicing' );?> <input class="small-text" type="number" value="<?php echo $times;?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e( 'time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing' );?></label>
246
+                )); ?> <span id="wpinv_interval_text"><?php _e('day(s)', 'invoicing'); ?></span></label>
247
+                <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e('for', 'invoicing'); ?> <input class="small-text" type="number" value="<?php echo $times; ?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e('time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing'); ?></label>
248 248
                 <span class="clear wpi-trial-clr"></span>
249 249
                 <label class="wpinv-free-trial" for="wpinv_free_trial">
250
-                    <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked( true, (bool)$free_trial ); ?> /> 
251
-                    <?php echo __( 'Offer free trial for', 'invoicing' ); ?>
250
+                    <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked(true, (bool)$free_trial); ?> /> 
251
+                    <?php echo __('Offer free trial for', 'invoicing'); ?>
252 252
                 </label>
253 253
                 <label class="wpinv-trial-interval" for="wpinv_trial_interval">
254
-                    <input class="small-text" type="number" value="<?php echo $trial_interval;?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected( 'D', $trial_period );?>><?php _e( 'day(s)', 'invoicing' ); ?></option><option value="W" <?php selected( 'W', $trial_period );?>><?php _e( 'week(s)', 'invoicing' ); ?></option><option value="M" <?php selected( 'M', $trial_period );?>><?php _e( 'month(s)', 'invoicing' ); ?></option><option value="Y" <?php selected( 'Y', $trial_period );?>><?php _e( 'year(s)', 'invoicing' ); ?></option></select>
254
+                    <input class="small-text" type="number" value="<?php echo $trial_interval; ?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected('D', $trial_period); ?>><?php _e('day(s)', 'invoicing'); ?></option><option value="W" <?php selected('W', $trial_period); ?>><?php _e('week(s)', 'invoicing'); ?></option><option value="M" <?php selected('M', $trial_period); ?>><?php _e('month(s)', 'invoicing'); ?></option><option value="Y" <?php selected('Y', $trial_period); ?>><?php _e('year(s)', 'invoicing'); ?></option></select>
255 255
                 </label>
256 256
         </p>
257
-        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type( $post->ID ); ?>" />
258
-        <?php do_action( 'wpinv_item_price_field', $post->ID ); ?>
257
+        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type($post->ID); ?>" />
258
+        <?php do_action('wpinv_item_price_field', $post->ID); ?>
259 259
         <?php
260 260
     }
261 261
     
262
-    public static function vat_rules( $post ) {
262
+    public static function vat_rules($post) {
263 263
         global $wpinv_euvat;
264 264
         
265
-        $rule_type = $wpinv_euvat->get_item_rule( $post->ID );
265
+        $rule_type = $wpinv_euvat->get_item_rule($post->ID);
266 266
         ?>
267
-        <p><label for="wpinv_vat_rules"><strong><?php _e( 'Select how VAT rules will be applied:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
268
-        <?php echo wpinv_html_select( array(
267
+        <p><label for="wpinv_vat_rules"><strong><?php _e('Select how VAT rules will be applied:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
268
+        <?php echo wpinv_html_select(array(
269 269
                     'options'          => $wpinv_euvat->get_rules(),
270 270
                     'name'             => 'wpinv_vat_rules',
271 271
                     'id'               => 'wpinv_vat_rules',
@@ -273,19 +273,19 @@  discard block
 block discarded – undo
273 273
                     'show_option_all'  => false,
274 274
                     'show_option_none' => false,
275 275
                     'class'            => 'gdmbx2-text-medium wpinv-vat-rules',
276
-                ) ); ?>
276
+                )); ?>
277 277
         </p>
278
-        <p class="wpi-m0"><?php _e( 'When you select physical product rules, only consumers and businesses in your country will be charged VAT.  The VAT rate used will be the rate in your country.', 'invoicing' ); ?></p>
279
-        <p class="wpi-m0"><?php _e( 'If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer.  Only businesses in your country will be charged VAT.', 'invoicing' ); ?></p>
278
+        <p class="wpi-m0"><?php _e('When you select physical product rules, only consumers and businesses in your country will be charged VAT.  The VAT rate used will be the rate in your country.', 'invoicing'); ?></p>
279
+        <p class="wpi-m0"><?php _e('If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer.  Only businesses in your country will be charged VAT.', 'invoicing'); ?></p>
280 280
         <?php
281 281
     }
282 282
     
283
-    public static function vat_classes( $post ) {
283
+    public static function vat_classes($post) {
284 284
         global $wpinv_euvat;
285 285
         
286
-        $vat_class = $wpinv_euvat->get_item_class( $post->ID );
286
+        $vat_class = $wpinv_euvat->get_item_class($post->ID);
287 287
         ?>
288
-        <p><?php echo wpinv_html_select( array(
288
+        <p><?php echo wpinv_html_select(array(
289 289
                     'options'          => $wpinv_euvat->get_all_classes(),
290 290
                     'name'             => 'wpinv_vat_class',
291 291
                     'id'               => 'wpinv_vat_class',
@@ -293,18 +293,18 @@  discard block
 block discarded – undo
293 293
                     'show_option_all'  => false,
294 294
                     'show_option_none' => false,
295 295
                     'class'            => 'gdmbx2-text-medium wpinv-vat-class',
296
-                ) ); ?>
296
+                )); ?>
297 297
         </p>
298
-        <p class="wpi-m0"><?php _e( 'Select the VAT rate class to use for this invoice item.', 'invoicing' ); ?></p>
298
+        <p class="wpi-m0"><?php _e('Select the VAT rate class to use for this invoice item.', 'invoicing'); ?></p>
299 299
         <?php
300 300
     }
301 301
     
302
-    public static function item_info( $post ) {
303
-        $item_type = wpinv_get_item_type( $post->ID );
304
-        do_action( 'wpinv_item_info_metabox_before', $post );
302
+    public static function item_info($post) {
303
+        $item_type = wpinv_get_item_type($post->ID);
304
+        do_action('wpinv_item_info_metabox_before', $post);
305 305
         ?>
306
-        <p><label for="wpinv_item_type"><strong><?php _e( 'Type:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
307
-        <?php echo wpinv_html_select( array(
306
+        <p><label for="wpinv_item_type"><strong><?php _e('Type:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
307
+        <?php echo wpinv_html_select(array(
308 308
                     'options'          => wpinv_get_item_types(),
309 309
                     'name'             => 'wpinv_item_type',
310 310
                     'id'               => 'wpinv_item_type',
@@ -313,114 +313,114 @@  discard block
 block discarded – undo
313 313
                     'show_option_none' => false,
314 314
                     'class'            => 'gdmbx2-text-medium wpinv-item-type',
315 315
                     //'disabled'         => $item_type == 'package' ? true : false,
316
-                ) ); ?>
316
+                )); ?>
317 317
         </p>
318
-        <p class="wpi-m0"><?php _e( 'Select item type.', 'invoicing' );?><br><?php _e( '<b>Standard:</b> Standard item type', 'invoicing' );?><br><?php _e( '<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing' );?></p>
318
+        <p class="wpi-m0"><?php _e('Select item type.', 'invoicing'); ?><br><?php _e('<b>Standard:</b> Standard item type', 'invoicing'); ?><br><?php _e('<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing'); ?></p>
319 319
         <?php
320
-        do_action( 'wpinv_item_info_metabox_after', $post );
320
+        do_action('wpinv_item_info_metabox_after', $post);
321 321
     }
322 322
     
323
-    public static function meta_values( $post ) {
324
-        $meta_keys = apply_filters( 'wpinv_show_meta_values_for_keys', array(
323
+    public static function meta_values($post) {
324
+        $meta_keys = apply_filters('wpinv_show_meta_values_for_keys', array(
325 325
             'type',
326 326
             'custom_id'
327
-        ) );
327
+        ));
328 328
         
329
-        if ( empty( $meta_keys ) ) {
329
+        if (empty($meta_keys)) {
330 330
             return;
331 331
         }
332 332
         
333
-        do_action( 'wpinv_meta_values_metabox_before', $post );
333
+        do_action('wpinv_meta_values_metabox_before', $post);
334 334
         
335
-        foreach ( $meta_keys as $meta_key ) {
335
+        foreach ($meta_keys as $meta_key) {
336 336
             ?>
337
-            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta( $post->ID, '_wpinv_' . $meta_key, true ); ?></label></p>
337
+            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta($post->ID, '_wpinv_' . $meta_key, true); ?></label></p>
338 338
             <?php 
339 339
         }
340 340
         
341
-        do_action( 'wpinv_meta_values_metabox_after', $post );
341
+        do_action('wpinv_meta_values_metabox_after', $post);
342 342
     }
343 343
     
344
-    public static function save( $post_id, $data, $post ) {
345
-        $invoice        = new WPInv_Invoice( $post_id );
344
+    public static function save($post_id, $data, $post) {
345
+        $invoice        = new WPInv_Invoice($post_id);
346 346
         
347 347
         // Billing
348
-        $first_name     = sanitize_text_field( $data['wpinv_first_name'] );
349
-        $last_name      = sanitize_text_field( $data['wpinv_last_name'] );
350
-        $company        = sanitize_text_field( $data['wpinv_company'] );
351
-        $vat_number     = sanitize_text_field( $data['wpinv_vat_number'] );
352
-        $phone          = sanitize_text_field( $data['wpinv_phone'] );
353
-        $address        = sanitize_text_field( $data['wpinv_address'] );
354
-        $city           = sanitize_text_field( $data['wpinv_city'] );
355
-        $zip            = sanitize_text_field( $data['wpinv_zip'] );
356
-        $country        = sanitize_text_field( $data['wpinv_country'] );
357
-        $state          = sanitize_text_field( $data['wpinv_state'] );
348
+        $first_name     = sanitize_text_field($data['wpinv_first_name']);
349
+        $last_name      = sanitize_text_field($data['wpinv_last_name']);
350
+        $company        = sanitize_text_field($data['wpinv_company']);
351
+        $vat_number     = sanitize_text_field($data['wpinv_vat_number']);
352
+        $phone          = sanitize_text_field($data['wpinv_phone']);
353
+        $address        = sanitize_text_field($data['wpinv_address']);
354
+        $city           = sanitize_text_field($data['wpinv_city']);
355
+        $zip            = sanitize_text_field($data['wpinv_zip']);
356
+        $country        = sanitize_text_field($data['wpinv_country']);
357
+        $state          = sanitize_text_field($data['wpinv_state']);
358 358
         
359 359
         // Details
360
-        $status         = sanitize_text_field( $data['wpinv_status'] );
361
-        $old_status     = !empty( $data['original_post_status'] ) ? sanitize_text_field( $data['original_post_status'] ) : $status;
362
-        $number         = sanitize_text_field( $data['wpinv_number'] );
363
-        $due_date       = isset( $data['wpinv_due_date'] ) ? sanitize_text_field( $data['wpinv_due_date'] ) : '';
360
+        $status         = sanitize_text_field($data['wpinv_status']);
361
+        $old_status     = !empty($data['original_post_status']) ? sanitize_text_field($data['original_post_status']) : $status;
362
+        $number         = sanitize_text_field($data['wpinv_number']);
363
+        $due_date       = isset($data['wpinv_due_date']) ? sanitize_text_field($data['wpinv_due_date']) : '';
364 364
         //$discounts      = sanitize_text_field( $data['wpinv_discounts'] );
365 365
         //$discount       = sanitize_text_field( $data['wpinv_discount'] );
366 366
         
367
-        $ip             = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
367
+        $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
368 368
         
369
-        $invoice->set( 'due_date', $due_date );
370
-        $invoice->set( 'first_name', $first_name );
371
-        $invoice->set( 'last_name', $last_name );
372
-        $invoice->set( 'company', $company );
373
-        $invoice->set( 'vat_number', $vat_number );
374
-        $invoice->set( 'phone', $phone );
375
-        $invoice->set( 'address', $address );
376
-        $invoice->set( 'city', $city );
377
-        $invoice->set( 'zip', $zip );
378
-        $invoice->set( 'country', $country );
379
-        $invoice->set( 'state', $state );
380
-        $invoice->set( 'status', $status );
369
+        $invoice->set('due_date', $due_date);
370
+        $invoice->set('first_name', $first_name);
371
+        $invoice->set('last_name', $last_name);
372
+        $invoice->set('company', $company);
373
+        $invoice->set('vat_number', $vat_number);
374
+        $invoice->set('phone', $phone);
375
+        $invoice->set('address', $address);
376
+        $invoice->set('city', $city);
377
+        $invoice->set('zip', $zip);
378
+        $invoice->set('country', $country);
379
+        $invoice->set('state', $state);
380
+        $invoice->set('status', $status);
381 381
         //$invoice->set( 'number', $number );
382 382
         //$invoice->set( 'discounts', $discounts );
383 383
         //$invoice->set( 'discount', $discount );
384
-        $invoice->set( 'ip', $ip );
384
+        $invoice->set('ip', $ip);
385 385
         $invoice->old_status = $_POST['original_post_status'];
386 386
         $invoice->currency = wpinv_get_currency();
387
-        if ( !empty( $data['wpinv_gateway'] ) ) {
388
-            $invoice->set( 'gateway', sanitize_text_field( $data['wpinv_gateway'] ) );
387
+        if (!empty($data['wpinv_gateway'])) {
388
+            $invoice->set('gateway', sanitize_text_field($data['wpinv_gateway']));
389 389
         }
390 390
         $saved = $invoice->save();
391 391
         
392 392
         // Check for payment notes
393
-        if ( !empty( $data['invoice_note'] ) ) {
394
-            $note               = wp_kses( $data['invoice_note'], array() );
395
-            $note_type          = sanitize_text_field( $data['invoice_note_type'] );
393
+        if (!empty($data['invoice_note'])) {
394
+            $note               = wp_kses($data['invoice_note'], array());
395
+            $note_type          = sanitize_text_field($data['invoice_note_type']);
396 396
             $is_customer_note   = $note_type == 'customer' ? 1 : 0;
397 397
         
398
-            wpinv_insert_payment_note( $invoice->ID, $note, $is_customer_note );
398
+            wpinv_insert_payment_note($invoice->ID, $note, $is_customer_note);
399 399
         }
400 400
         
401 401
         // Update user address if empty.
402
-        if ( $saved && !empty( $invoice ) ) {
403
-            if ( $user_id = $invoice->get_user_id() ) {
404
-                $user_address = wpinv_get_user_address( $user_id, false );
402
+        if ($saved && !empty($invoice)) {
403
+            if ($user_id = $invoice->get_user_id()) {
404
+                $user_address = wpinv_get_user_address($user_id, false);
405 405
                 
406 406
                 if (empty($user_address['first_name'])) {
407
-                    update_user_meta( $user_id, '_wpinv_first_name', $first_name );
408
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
407
+                    update_user_meta($user_id, '_wpinv_first_name', $first_name);
408
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
409 409
                 } else if (empty($user_address['last_name']) && $user_address['first_name'] == $first_name) {
410
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
410
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
411 411
                 }
412 412
                 
413 413
                 if (empty($user_address['address']) || empty($user_address['city']) || empty($user_address['state']) || empty($user_address['country'])) {
414
-                    update_user_meta( $user_id, '_wpinv_address', $address );
415
-                    update_user_meta( $user_id, '_wpinv_city', $city );
416
-                    update_user_meta( $user_id, '_wpinv_state', $state );
417
-                    update_user_meta( $user_id, '_wpinv_country', $country );
418
-                    update_user_meta( $user_id, '_wpinv_zip', $zip );
419
-                    update_user_meta( $user_id, '_wpinv_phone', $phone );
414
+                    update_user_meta($user_id, '_wpinv_address', $address);
415
+                    update_user_meta($user_id, '_wpinv_city', $city);
416
+                    update_user_meta($user_id, '_wpinv_state', $state);
417
+                    update_user_meta($user_id, '_wpinv_country', $country);
418
+                    update_user_meta($user_id, '_wpinv_zip', $zip);
419
+                    update_user_meta($user_id, '_wpinv_phone', $phone);
420 420
                 }
421 421
             }
422 422
             
423
-            do_action( 'wpinv_invoice_metabox_saved', $invoice );
423
+            do_action('wpinv_invoice_metabox_saved', $invoice);
424 424
         }
425 425
         
426 426
         return $saved;
Please login to merge, or discard this patch.