Passed
Push — master ( 94dde4...c3b9b9 )
by Stiofan
07:58
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' );
118
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' );
119
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' );
120
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' );
121
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php' );
122
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
123
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
124
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
125
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php' );
126
-        if ( !class_exists( 'Geodir_EUVat' ) ) {
127
-            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.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
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php');
119
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php');
120
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php');
121
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php');
122
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
123
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
124
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
125
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php');
126
+        if (!class_exists('Geodir_EUVat')) {
127
+            require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
128 128
         }
129 129
         
130
-        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
131
-        if ( !empty( $gateways ) ) {
132
-            foreach ( $gateways as $gateway ) {
133
-                if ( $gateway == 'manual' ) {
130
+        $gateways = array_keys(wpinv_get_enabled_payment_gateways());
131
+        if (!empty($gateways)) {
132
+            foreach ($gateways as $gateway) {
133
+                if ($gateway == 'manual') {
134 134
                     continue;
135 135
                 }
136 136
                 
137 137
                 $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
138 138
                 
139
-                if ( file_exists( $gateway_file ) ) {
140
-                    require_once( $gateway_file );
139
+                if (file_exists($gateway_file)) {
140
+                    require_once($gateway_file);
141 141
                 }
142 142
             }
143 143
         }
144
-        require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' );
145
-        
146
-        if ( is_admin() ) {
147
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
148
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' );
149
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' );
150
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' );
151
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
152
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' );
153
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
144
+        require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php');
145
+        
146
+        if (is_admin()) {
147
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
148
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php');
149
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php');
150
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php');
151
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
152
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php');
153
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
154 154
         }
155 155
         
156 156
         // include css inliner
157
-        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
158
-            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
157
+        if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
158
+            include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
159 159
         }
160 160
         
161
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
161
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
162 162
     }
163 163
     
164 164
     public function init() {
165 165
     }
166 166
     
167 167
     public function admin_init() {
168
-        if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) {
168
+        if (!(defined('DOING_AJAX') && DOING_AJAX)) {
169 169
         }
170 170
         
171
-        add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) );
171
+        add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php'));
172 172
     }
173 173
 
174 174
     public function activation_redirect() {
175 175
         // Bail if no activation redirect
176
-        if ( !get_transient( '_wpinv_activation_redirect' ) ) {
176
+        if (!get_transient('_wpinv_activation_redirect')) {
177 177
             return;
178 178
         }
179 179
 
180 180
         // Delete the redirect transient
181
-        delete_transient( '_wpinv_activation_redirect' );
181
+        delete_transient('_wpinv_activation_redirect');
182 182
 
183 183
         // Bail if activating from network, or bulk
184
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
184
+        if (is_network_admin() || isset($_GET['activate-multi'])) {
185 185
             return;
186 186
         }
187 187
 
188
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
188
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
189 189
         exit;
190 190
     }
191 191
     
192 192
     public function enqueue_scripts() {
193
-        $suffix       = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
193
+        $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
194 194
         
195
-        wp_deregister_style( 'font-awesome' );
196
-        wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' );
197
-        wp_enqueue_style( 'font-awesome' );
195
+        wp_deregister_style('font-awesome');
196
+        wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0');
197
+        wp_enqueue_style('font-awesome');
198 198
         
199
-        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION );
200
-        wp_enqueue_style( 'wpinv_front_style' );
199
+        wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION);
200
+        wp_enqueue_style('wpinv_front_style');
201 201
                
202 202
         // Register scripts
203
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
204
-        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array( 'jquery', 'wpinv-vat-script' ),  WPINV_VERSION );
203
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
204
+        wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array('jquery', 'wpinv-vat-script'), WPINV_VERSION);
205 205
         
206 206
         $localize                         = array();
207
-        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
208
-        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
207
+        $localize['ajax_url']             = admin_url('admin-ajax.php');
208
+        $localize['nonce']                = wp_create_nonce('wpinv-nonce');
209 209
         $localize['currency_symbol']      = wpinv_currency_symbol();
210 210
         $localize['currency_pos']         = wpinv_currency_position();
211 211
         $localize['thousand_sep']         = wpinv_thousands_seperator();
212 212
         $localize['decimal_sep']          = wpinv_decimal_seperator();
213 213
         $localize['decimals']             = wpinv_decimals();
214 214
         
215
-        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
215
+        $localize = apply_filters('wpinv_front_js_localize', $localize);
216 216
         
217
-        wp_enqueue_script( 'jquery-blockui' );
218
-        wp_enqueue_script( 'wpinv-front-script' );
219
-        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
217
+        wp_enqueue_script('jquery-blockui');
218
+        wp_enqueue_script('wpinv-front-script');
219
+        wp_localize_script('wpinv-front-script', 'WPInv', $localize);
220 220
     }
221 221
     
222 222
     public function admin_enqueue_scripts() {
223 223
         global $post, $pagenow;
224 224
         
225 225
         $post_type  = wpinv_admin_post_type();
226
-        $suffix     = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
226
+        $suffix     = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
227 227
         
228
-        wp_deregister_style( 'font-awesome' );
229
-        wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' );
230
-        wp_enqueue_style( 'font-awesome' );
228
+        wp_deregister_style('font-awesome');
229
+        wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0');
230
+        wp_enqueue_style('font-awesome');
231 231
         
232
-        wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
233
-        wp_enqueue_style( 'jquery-ui-css' );
232
+        wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16');
233
+        wp_enqueue_style('jquery-ui-css');
234 234
         
235
-        wp_register_style( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2' );
236
-        wp_enqueue_style( 'jquery-chosen' );
235
+        wp_register_style('jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2');
236
+        wp_enqueue_style('jquery-chosen');
237 237
 
238
-        wp_register_script( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array( 'jquery' ), '1.6.2' );
239
-        wp_enqueue_script( 'jquery-chosen' );
238
+        wp_register_script('jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array('jquery'), '1.6.2');
239
+        wp_enqueue_script('jquery-chosen');
240 240
         
241
-        wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
242
-        wp_enqueue_style( 'wpinv_meta_box_style' );
241
+        wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
242
+        wp_enqueue_style('wpinv_meta_box_style');
243 243
         
244
-        wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION );
245
-        wp_enqueue_style( 'wpinv_admin_style' );
244
+        wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION);
245
+        wp_enqueue_style('wpinv_admin_style');
246 246
         
247
-        if ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) {
248
-            wp_enqueue_script( 'jquery-ui-datepicker' );
247
+        if ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
248
+            wp_enqueue_script('jquery-ui-datepicker');
249 249
         }
250 250
 
251
-        wp_enqueue_style( 'wp-color-picker' );
252
-        wp_enqueue_script( 'wp-color-picker' );
251
+        wp_enqueue_style('wp-color-picker');
252
+        wp_enqueue_script('wp-color-picker');
253 253
         
254
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
254
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
255 255
         
256
-        wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui' ),  WPINV_VERSION );
257
-        wp_enqueue_script( 'wpinv-admin-script' );
256
+        wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array('jquery', 'jquery-blockui'), WPINV_VERSION);
257
+        wp_enqueue_script('wpinv-admin-script');
258 258
         
259 259
         $localize                               = array();
260
-        $localize['ajax_url']                   = admin_url( 'admin-ajax.php' );
261
-        $localize['post_ID']                    = isset( $post->ID ) ? $post->ID : '';
262
-        $localize['wpinv_nonce']                = wp_create_nonce( 'wpinv-nonce' );
263
-        $localize['add_invoice_note_nonce']     = wp_create_nonce( 'add-invoice-note' );
264
-        $localize['delete_invoice_note_nonce']  = wp_create_nonce( 'delete-invoice-note' );
265
-        $localize['invoice_item_nonce']         = wp_create_nonce( 'invoice-item' );
266
-        $localize['billing_details_nonce']      = wp_create_nonce( 'get-billing-details' );
260
+        $localize['ajax_url']                   = admin_url('admin-ajax.php');
261
+        $localize['post_ID']                    = isset($post->ID) ? $post->ID : '';
262
+        $localize['wpinv_nonce']                = wp_create_nonce('wpinv-nonce');
263
+        $localize['add_invoice_note_nonce']     = wp_create_nonce('add-invoice-note');
264
+        $localize['delete_invoice_note_nonce']  = wp_create_nonce('delete-invoice-note');
265
+        $localize['invoice_item_nonce']         = wp_create_nonce('invoice-item');
266
+        $localize['billing_details_nonce']      = wp_create_nonce('get-billing-details');
267 267
         $localize['tax']                        = wpinv_tax_amount();
268 268
         $localize['discount']                   = wpinv_discount_amount();
269 269
         $localize['currency_symbol']            = wpinv_currency_symbol();
@@ -271,55 +271,55 @@  discard block
 block discarded – undo
271 271
         $localize['thousand_sep']               = wpinv_thousands_seperator();
272 272
         $localize['decimal_sep']                = wpinv_decimal_seperator();
273 273
         $localize['decimals']                   = wpinv_decimals();
274
-        $localize['save_invoice']               = __( 'Save Invoice', 'invoicing' );
275
-        $localize['status_publish']             = wpinv_status_nicename( 'publish' );
276
-        $localize['status_pending']             = wpinv_status_nicename( 'pending' );
277
-        $localize['delete_tax_rate']            = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' );
278
-        $localize['OneItemMin']                 = __( 'Invoice must contain at least one item', 'invoicing' );
279
-        $localize['DeleteInvoiceItem']          = __( 'Are you sure you wish to delete this item?', 'invoicing' );
280
-        $localize['FillBillingDetails']         = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' );
281
-        $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' );
282
-        $localize['AreYouSure']                 = __( 'Are you sure?', 'invoicing' );
283
-        $localize['hasGD']                      = wpinv_gd_active();;
274
+        $localize['save_invoice']               = __('Save Invoice', 'invoicing');
275
+        $localize['status_publish']             = wpinv_status_nicename('publish');
276
+        $localize['status_pending']             = wpinv_status_nicename('pending');
277
+        $localize['delete_tax_rate']            = __('Are you sure you wish to delete this tax rate?', 'invoicing');
278
+        $localize['OneItemMin']                 = __('Invoice must contain at least one item', 'invoicing');
279
+        $localize['DeleteInvoiceItem']          = __('Are you sure you wish to delete this item?', 'invoicing');
280
+        $localize['FillBillingDetails']         = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing');
281
+        $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');
282
+        $localize['AreYouSure']                 = __('Are you sure?', 'invoicing');
283
+        $localize['hasGD']                      = wpinv_gd_active(); ;
284 284
         $localize['hasPM']                      = wpinv_pm_active();
285
-        $localize['emptyInvoice']               = __( 'Add atleast one item to save invoice!', 'invoicing' );
286
-        $localize['deletePackage']              = __( 'GD package items should be deleted from GD payment manager only, otherwise it will break invoices that created with this package!', 'invoicing' );
287
-        $localize['deletePackages']             = __( 'GD package items should be deleted from GD payment manager only', 'invoicing' );
288
-        $localize['deleteInvoiceFirst']         = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' );
285
+        $localize['emptyInvoice']               = __('Add atleast one item to save invoice!', 'invoicing');
286
+        $localize['deletePackage']              = __('GD package items should be deleted from GD payment manager only, otherwise it will break invoices that created with this package!', 'invoicing');
287
+        $localize['deletePackages']             = __('GD package items should be deleted from GD payment manager only', 'invoicing');
288
+        $localize['deleteInvoiceFirst']         = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing');
289 289
         
290
-        wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize );
290
+        wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize);
291 291
     }
292 292
     
293
-    public function admin_body_class( $classes ) {
293
+    public function admin_body_class($classes) {
294 294
         global $pagenow;
295 295
         
296
-        $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
296
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
297 297
 
298 298
         $add_class = false;
299
-        if ( $pagenow == 'admin.php' && $page ) {
300
-            $add_class = strpos( $page, 'wpinv-' );
299
+        if ($pagenow == 'admin.php' && $page) {
300
+            $add_class = strpos($page, 'wpinv-');
301 301
         }
302 302
         
303 303
         $settings_class = array();
304
-        if ( $page == 'wpinv-settings' ) {
305
-            if ( !empty( $_REQUEST['tab'] ) ) {
306
-                $settings_class[] = sanitize_text_field( $_REQUEST['tab'] );
304
+        if ($page == 'wpinv-settings') {
305
+            if (!empty($_REQUEST['tab'])) {
306
+                $settings_class[] = sanitize_text_field($_REQUEST['tab']);
307 307
             }
308 308
             
309
-            if ( !empty( $_REQUEST['section'] ) ) {
310
-                $settings_class[] = sanitize_text_field( $_REQUEST['section'] );
309
+            if (!empty($_REQUEST['section'])) {
310
+                $settings_class[] = sanitize_text_field($_REQUEST['section']);
311 311
             }
312 312
             
313
-            $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main';
313
+            $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main';
314 314
         }
315 315
         
316
-        if ( !empty( $settings_class ) ) {
317
-            $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) );
316
+        if (!empty($settings_class)) {
317
+            $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-'));
318 318
         }
319 319
         
320 320
         $post_type = wpinv_admin_post_type();
321 321
         
322
-        if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) {
322
+        if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) {
323 323
             return $classes .= ' wpinv';
324 324
         } else {
325 325
             return $classes;
@@ -331,26 +331,26 @@  discard block
 block discarded – undo
331 331
     public function admin_print_scripts_edit_php() {
332 332
         $post_type = wpinv_admin_post_type();
333 333
         
334
-        if ( $post_type == 'wpi_item' ) {
335
-            wp_enqueue_script( 'wpinv-inline-edit-post', WPINV_PLUGIN_URL . 'assets/js/quick-edit.js', array( 'jquery', 'inline-edit-post' ), '', true );
334
+        if ($post_type == 'wpi_item') {
335
+            wp_enqueue_script('wpinv-inline-edit-post', WPINV_PLUGIN_URL . 'assets/js/quick-edit.js', array('jquery', 'inline-edit-post'), '', true);
336 336
         }
337 337
     }
338 338
     
339 339
     public function wpinv_actions() {
340
-        if ( isset( $_REQUEST['wpi_action'] ) ) {
341
-            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
340
+        if (isset($_REQUEST['wpi_action'])) {
341
+            do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
342 342
         }
343 343
     }
344 344
     
345
-    public function pre_get_posts( $wp_query ) {
346
-        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() ) {
347
-            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
345
+    public function pre_get_posts($wp_query) {
346
+        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()) {
347
+            $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
348 348
         }
349 349
         
350 350
         return $wp_query;
351 351
     }
352 352
     
353 353
     public function bp_invoicing_init() {
354
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
354
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
355 355
     }
356 356
 }
357 357
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/admin-meta-boxes.php 1 patch
Spacing   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -1,65 +1,65 @@  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
-function wpinv_add_meta_boxes( $post_type, $post ) {
7
+function wpinv_add_meta_boxes($post_type, $post) {
8 8
     global $wpi_mb_invoice;
9
-    if ( $post_type == 'wpi_invoice' && !empty( $post->ID ) ) {
10
-        $wpi_mb_invoice = wpinv_get_invoice( $post->ID );
9
+    if ($post_type == 'wpi_invoice' && !empty($post->ID)) {
10
+        $wpi_mb_invoice = wpinv_get_invoice($post->ID);
11 11
     }
12 12
     
13
-    if ( !empty( $wpi_mb_invoice ) && !$wpi_mb_invoice->has_status( array( 'draft', 'auto-draft' ) ) ) {
14
-        add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high' );
13
+    if (!empty($wpi_mb_invoice) && !$wpi_mb_invoice->has_status(array('draft', 'auto-draft'))) {
14
+        add_meta_box('wpinv-mb-resend-invoice', __('Resend Invoice', 'invoicing'), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high');
15 15
     }
16 16
     
17
-    if ( !empty( $wpi_mb_invoice ) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent() ) {
18
-        add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscriptions', 'invoicing' ), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high' );
17
+    if (!empty($wpi_mb_invoice) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent()) {
18
+        add_meta_box('wpinv-mb-subscriptions', __('Subscriptions', 'invoicing'), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high');
19 19
     }
20 20
     
21
-    if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) {
22
-        add_meta_box( 'wpinv-mb-renewals', __( 'Renewal Payment', 'invoicing' ), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high' );
21
+    if (wpinv_is_subscription_payment($wpi_mb_invoice)) {
22
+        add_meta_box('wpinv-mb-renewals', __('Renewal Payment', 'invoicing'), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high');
23 23
     }
24 24
     
25
-    add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default' );
26
-    add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default' );
25
+    add_meta_box('wpinv-details', __('Invoice Details', 'invoicing'), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default');
26
+    add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default');
27 27
    
28
-    add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high' );
29
-    add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high' );
30
-    add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' );
28
+    add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high');
29
+    add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high');
30
+    add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high');
31 31
 }
32
-add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 );
32
+add_action('add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2);
33 33
 
34
-function wpinv_save_meta_boxes( $post_id, $post, $update = false ) {
35
-    remove_action( 'save_post', __FUNCTION__ );
34
+function wpinv_save_meta_boxes($post_id, $post, $update = false) {
35
+    remove_action('save_post', __FUNCTION__);
36 36
     
37 37
     // $post_id and $post are required
38
-    if ( empty( $post_id ) || empty( $post ) ) {
38
+    if (empty($post_id) || empty($post)) {
39 39
         return;
40 40
     }
41 41
         
42
-    if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) {
42
+    if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) {
43 43
         return;
44 44
     }
45 45
     
46 46
     // Dont' save meta boxes for revisions or autosaves
47
-    if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
47
+    if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
48 48
         return;
49 49
     }
50 50
         
51
-    if ( $post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote' ) {
52
-        if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
51
+    if ($post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote') {
52
+        if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
53 53
             return;
54 54
         }
55 55
     
56
-        if ( isset( $_POST['wpinv_save_invoice'] ) && wp_verify_nonce( $_POST['wpinv_save_invoice'], 'wpinv_save_invoice' ) ) {
57
-            WPInv_Meta_Box_Items::save( $post_id, $_POST, $post );
56
+        if (isset($_POST['wpinv_save_invoice']) && wp_verify_nonce($_POST['wpinv_save_invoice'], 'wpinv_save_invoice')) {
57
+            WPInv_Meta_Box_Items::save($post_id, $_POST, $post);
58 58
         }
59
-    } else if ( $post->post_type == 'wpi_item' ) {
59
+    } else if ($post->post_type == 'wpi_item') {
60 60
         // verify nonce
61
-        if ( isset( $_POST['wpinv_vat_meta_box_nonce'] ) && wp_verify_nonce( $_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save' ) ) {
62
-            $fields                                 = array();
61
+        if (isset($_POST['wpinv_vat_meta_box_nonce']) && wp_verify_nonce($_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save')) {
62
+            $fields = array();
63 63
             $fields['_wpinv_price']              = 'wpinv_item_price';
64 64
             $fields['_wpinv_vat_class']          = 'wpinv_vat_class';
65 65
             $fields['_wpinv_vat_rule']           = 'wpinv_vat_rules';
@@ -72,291 +72,291 @@  discard block
 block discarded – undo
72 72
             $fields['_wpinv_trial_period']       = 'wpinv_trial_period';
73 73
             $fields['_wpinv_trial_interval']     = 'wpinv_trial_interval';
74 74
             
75
-            if ( !isset( $_POST['wpinv_is_recurring'] ) ) {
75
+            if (!isset($_POST['wpinv_is_recurring'])) {
76 76
                 $_POST['wpinv_is_recurring'] = 0;
77 77
             }
78 78
             
79
-            if ( !isset( $_POST['wpinv_free_trial'] ) || empty( $_POST['wpinv_is_recurring'] ) ) {
79
+            if (!isset($_POST['wpinv_free_trial']) || empty($_POST['wpinv_is_recurring'])) {
80 80
                 $_POST['wpinv_free_trial'] = 0;
81 81
             }
82 82
             
83
-            foreach ( $fields as $field => $name ) {
84
-                if ( isset( $_POST[ $name ] ) ) {
85
-                    if ( $field == '_wpinv_price' ) {
86
-                        if ( get_post_meta( $post_id, '_wpinv_type', true ) === 'package' ) {
87
-                            $value = wpinv_sanitize_amount( get_post_meta( $post_id, '_wpinv_price', true ) ); // Don't allow edit GD package item price.
83
+            foreach ($fields as $field => $name) {
84
+                if (isset($_POST[$name])) {
85
+                    if ($field == '_wpinv_price') {
86
+                        if (get_post_meta($post_id, '_wpinv_type', true) === 'package') {
87
+                            $value = wpinv_sanitize_amount(get_post_meta($post_id, '_wpinv_price', true)); // Don't allow edit GD package item price.
88 88
                         } else {
89
-                            $value = wpinv_sanitize_amount( $_POST[ $name ] );
89
+                            $value = wpinv_sanitize_amount($_POST[$name]);
90 90
                         }
91 91
                     } else {
92
-                        $value = is_string( $_POST[ $name ] ) ? sanitize_text_field( $_POST[ $name ] ) : $_POST[ $name ];
92
+                        $value = is_string($_POST[$name]) ? sanitize_text_field($_POST[$name]) : $_POST[$name];
93 93
                     }
94 94
                     
95
-                    $value = apply_filters( 'wpinv_item_metabox_save_' . $field, $value, $name );
96
-                    update_post_meta( $post_id, $field, $value );
95
+                    $value = apply_filters('wpinv_item_metabox_save_' . $field, $value, $name);
96
+                    update_post_meta($post_id, $field, $value);
97 97
                 }
98 98
             }
99 99
         }
100 100
     }
101 101
 }
102
-add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 );
102
+add_action('save_post', 'wpinv_save_meta_boxes', 10, 3);
103 103
 
104
-function wpinv_bulk_and_quick_edit_save( $post_id, $post, $update = false ) {
105
-    if ( !( !empty( $_POST['action'] ) && $_POST['action'] == 'inline-save' ) ) {
104
+function wpinv_bulk_and_quick_edit_save($post_id, $post, $update = false) {
105
+    if (!(!empty($_POST['action']) && $_POST['action'] == 'inline-save')) {
106 106
         return;
107 107
     }
108 108
     
109 109
     // $post_id and $post are required
110
-    if ( empty( $post_id ) || empty( $post ) ) {
110
+    if (empty($post_id) || empty($post)) {
111 111
         return;
112 112
     }
113 113
         
114
-    if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) {
114
+    if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) {
115 115
         return;
116 116
     }
117 117
     
118 118
     // Dont' save meta boxes for revisions or autosaves
119
-    if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
119
+    if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
120 120
         return;
121 121
     }
122 122
 
123
-    if ( $post->post_type == 'wpi_item' ) {
123
+    if ($post->post_type == 'wpi_item') {
124 124
         // verify nonce
125
-        if ( isset( $_POST['_wpinv_item_price'] ) && get_post_meta( $post->ID, '_wpinv_type', true ) !== 'package' ) {
126
-            update_post_meta( $post_id, '_wpinv_price', wpinv_sanitize_amount( $_POST['_wpinv_item_price'] ) );
125
+        if (isset($_POST['_wpinv_item_price']) && get_post_meta($post->ID, '_wpinv_type', true) !== 'package') {
126
+            update_post_meta($post_id, '_wpinv_price', wpinv_sanitize_amount($_POST['_wpinv_item_price']));
127 127
         }
128 128
         
129
-        if ( isset( $_POST['_wpinv_vat_class'] ) ) {
130
-            update_post_meta( $post_id, '_wpinv_vat_class', sanitize_text_field( $_POST['_wpinv_vat_class'] ) );
129
+        if (isset($_POST['_wpinv_vat_class'])) {
130
+            update_post_meta($post_id, '_wpinv_vat_class', sanitize_text_field($_POST['_wpinv_vat_class']));
131 131
         }
132 132
 
133
-        if ( isset( $_POST['_wpinv_vat_rules'] ) ) {
134
-            update_post_meta( $post_id, '_wpinv_vat_rule', sanitize_text_field( $_POST['_wpinv_vat_rules'] ) );
133
+        if (isset($_POST['_wpinv_vat_rules'])) {
134
+            update_post_meta($post_id, '_wpinv_vat_rule', sanitize_text_field($_POST['_wpinv_vat_rules']));
135 135
         }
136 136
         
137
-        if ( isset( $_POST['_wpinv_item_type'] ) ) {
138
-            update_post_meta( $post_id, '_wpinv_type', sanitize_text_field( $_POST['_wpinv_item_type'] ) );
137
+        if (isset($_POST['_wpinv_item_type'])) {
138
+            update_post_meta($post_id, '_wpinv_type', sanitize_text_field($_POST['_wpinv_item_type']));
139 139
         }
140 140
     }
141 141
 }
142
-add_action( 'save_post', 'wpinv_bulk_and_quick_edit_save', 10, 3 );
142
+add_action('save_post', 'wpinv_bulk_and_quick_edit_save', 10, 3);
143 143
 
144 144
 function wpinv_register_item_meta_boxes() {    
145 145
     global $wpinv_euvat;
146 146
     
147
-    add_meta_box( 'wpinv_field_prices', __( 'Item Price', 'invoicing' ), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high' );
147
+    add_meta_box('wpinv_field_prices', __('Item Price', 'invoicing'), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high');
148 148
 
149
-    if ( $wpinv_euvat->allow_vat_rules() ) {
150
-        add_meta_box( 'wpinv_field_vat_rules', __( 'VAT rules type to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high' );
149
+    if ($wpinv_euvat->allow_vat_rules()) {
150
+        add_meta_box('wpinv_field_vat_rules', __('VAT rules type to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high');
151 151
     }
152 152
     
153
-    if ( $wpinv_euvat->allow_vat_classes() ) {
154
-        add_meta_box( 'wpinv_field_vat_classes', __( 'VAT rates class to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high' );
153
+    if ($wpinv_euvat->allow_vat_classes()) {
154
+        add_meta_box('wpinv_field_vat_classes', __('VAT rates class to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high');
155 155
     }
156 156
     
157
-    add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core' );
157
+    add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core');
158 158
 }
159 159
 
160 160
 function wpinv_register_discount_meta_boxes() {
161
-    add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' );
161
+    add_meta_box('wpinv_discount_fields', __('Discount Details', 'invoicing'), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high');
162 162
 }
163 163
 
164
-function wpinv_discount_metabox_details( $post ) {
164
+function wpinv_discount_metabox_details($post) {
165 165
     $discount_id    = $post->ID;
166
-    $discount       = wpinv_get_discount( $discount_id );
166
+    $discount       = wpinv_get_discount($discount_id);
167 167
     
168
-    $type           = wpinv_get_discount_type( $discount_id );
169
-    $item_reqs      = wpinv_get_discount_item_reqs( $discount_id );
170
-    $excluded_items = wpinv_get_discount_excluded_items( $discount_id );
171
-    $min_total      = wpinv_get_discount_min_total( $discount_id );
172
-    $max_total      = wpinv_get_discount_max_total( $discount_id );
173
-    $max_uses       = wpinv_get_discount_max_uses( $discount_id );
174
-    $single_use     = wpinv_discount_is_single_use( $discount_id );
175
-    $recurring      = (bool)wpinv_discount_is_recurring( $discount_id );
168
+    $type           = wpinv_get_discount_type($discount_id);
169
+    $item_reqs      = wpinv_get_discount_item_reqs($discount_id);
170
+    $excluded_items = wpinv_get_discount_excluded_items($discount_id);
171
+    $min_total      = wpinv_get_discount_min_total($discount_id);
172
+    $max_total      = wpinv_get_discount_max_total($discount_id);
173
+    $max_uses       = wpinv_get_discount_max_uses($discount_id);
174
+    $single_use     = wpinv_discount_is_single_use($discount_id);
175
+    $recurring      = (bool)wpinv_discount_is_recurring($discount_id);
176 176
     
177 177
     $min_total      = $min_total > 0 ? $min_total : '';
178 178
     $max_total      = $max_total > 0 ? $max_total : '';
179 179
     $max_uses       = $max_uses > 0 ? $max_uses : '';
180 180
 ?>
181
-<?php do_action( 'wpinv_discount_form_top', $post ); ?>
182
-<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?>
181
+<?php do_action('wpinv_discount_form_top', $post); ?>
182
+<?php wp_nonce_field('wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce'); ;?>
183 183
 <table class="form-table wpi-form-table">
184 184
     <tbody>
185
-        <?php do_action( 'wpinv_discount_form_first', $post ); ?>
186
-        <?php do_action( 'wpinv_discount_form_before_code', $post ); ?>
185
+        <?php do_action('wpinv_discount_form_first', $post); ?>
186
+        <?php do_action('wpinv_discount_form_before_code', $post); ?>
187 187
         <tr>
188 188
             <th valign="top" scope="row">
189
-                <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label>
189
+                <label for="wpinv_discount_code"><?php _e('Discount Code', 'invoicing'); ?></label>
190 190
             </th>
191 191
             <td>
192
-                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required>
193
-                <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p>
192
+                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr(wpinv_get_discount_code($discount_id)); ?>" required>
193
+                <p class="description"><?php _e('Enter a code for this discount, such as 10OFF', 'invoicing'); ?></p>
194 194
             </td>
195 195
         </tr>
196
-        <?php do_action( 'wpinv_discount_form_before_type', $post ); ?>
196
+        <?php do_action('wpinv_discount_form_before_type', $post); ?>
197 197
         <tr>
198 198
             <th valign="top" scope="row">
199
-                <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label>
199
+                <label for="wpinv_discount_type"><?php _e('Discount Type', 'invoicing'); ?></label>
200 200
             </th>
201 201
             <td>
202 202
                 <select id="wpinv_discount_type" name="type" class="medium-text">
203
-                    <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?>
204
-                    <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option>
203
+                    <?php foreach (wpinv_get_discount_types() as $value => $label) { ?>
204
+                    <option value="<?php echo $value; ?>" <?php selected($type, $value); ?>><?php echo $label; ?></option>
205 205
                     <?php } ?>
206 206
                 </select>
207
-                <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p>
207
+                <p class="description"><?php _e('The kind of discount to apply for this discount.', 'invoicing'); ?></p>
208 208
             </td>
209 209
         </tr>
210
-        <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?>
210
+        <?php do_action('wpinv_discount_form_before_amount', $post); ?>
211 211
         <tr>
212 212
             <th valign="top" scope="row">
213
-                <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label>
213
+                <label for="wpinv_discount_amount"><?php _e('Amount', 'invoicing'); ?></label>
214 214
             </th>
215 215
             <td>
216
-                <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr( wpinv_get_discount_amount( $discount_id ) ); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol() ;?></font>
217
-                <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p>
218
-                <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p>
216
+                <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr(wpinv_get_discount_amount($discount_id)); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol(); ?></font>
217
+                <p style="display:none;" class="description"><?php _e('Enter the discount amount in USD', 'invoicing'); ?></p>
218
+                <p class="description"><?php _e('Enter the discount value. Ex: 10', 'invoicing'); ?></p>
219 219
             </td>
220 220
         </tr>
221
-        <?php do_action( 'wpinv_discount_form_before_items', $post ); ?>
221
+        <?php do_action('wpinv_discount_form_before_items', $post); ?>
222 222
         <tr>
223 223
             <th valign="top" scope="row">
224
-                <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label>
224
+                <label for="wpinv_discount_items"><?php _e('Items', 'invoicing'); ?></label>
225 225
             </th>
226 226
             <td>
227
-                <p><?php echo wpinv_item_dropdown( array(
227
+                <p><?php echo wpinv_item_dropdown(array(
228 228
                         'name'              => 'items[]',
229 229
                         'id'                => 'items',
230 230
                         'selected'          => $item_reqs,
231 231
                         'multiple'          => true,
232 232
                         'chosen'            => true,
233 233
                         'class'             => 'medium-text',
234
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
234
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
235 235
                         'show_recurring'    => true,
236
-                    ) ); ?>
236
+                    )); ?>
237 237
                 </p>
238
-                <p class="description"><?php _e( 'Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing' ); ?></p>
238
+                <p class="description"><?php _e('Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing'); ?></p>
239 239
             </td>
240 240
         </tr>
241
-        <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?>
241
+        <?php do_action('wpinv_discount_form_before_excluded_items', $post); ?>
242 242
         <tr>
243 243
             <th valign="top" scope="row">
244
-                <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label>
244
+                <label for="wpinv_discount_excluded_items"><?php _e('Excluded Items', 'invoicing'); ?></label>
245 245
             </th>
246 246
             <td>
247
-                <p><?php echo wpinv_item_dropdown( array(
247
+                <p><?php echo wpinv_item_dropdown(array(
248 248
                         'name'              => 'excluded_items[]',
249 249
                         'id'                => 'excluded_items',
250 250
                         'selected'          => $excluded_items,
251 251
                         'multiple'          => true,
252 252
                         'chosen'            => true,
253 253
                         'class'             => 'medium-text',
254
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
254
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
255 255
                         'show_recurring'    => true,
256
-                    ) ); ?>
256
+                    )); ?>
257 257
                 </p>
258
-                <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p>
258
+                <p class="description"><?php _e('Items which are NOT allowed to use this discount.', 'invoicing'); ?></p>
259 259
             </td>
260 260
         </tr>
261
-        <?php do_action( 'wpinv_discount_form_before_start', $post ); ?>
261
+        <?php do_action('wpinv_discount_form_before_start', $post); ?>
262 262
         <tr>
263 263
             <th valign="top" scope="row">
264
-                <label for="wpinv_discount_start"><?php _e( 'Start date', 'invoicing' ); ?></label>
264
+                <label for="wpinv_discount_start"><?php _e('Start date', 'invoicing'); ?></label>
265 265
             </th>
266 266
             <td>
267
-                <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr( wpinv_get_discount_start_date( $discount_id ) ); ?>">
268
-                <p class="description"><?php _e( 'Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?></p>
267
+                <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr(wpinv_get_discount_start_date($discount_id)); ?>">
268
+                <p class="description"><?php _e('Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?></p>
269 269
             </td>
270 270
         </tr>
271
-        <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?>
271
+        <?php do_action('wpinv_discount_form_before_expiration', $post); ?>
272 272
         <tr>
273 273
             <th valign="top" scope="row">
274
-                <label for="wpinv_discount_expiration"><?php _e( 'Expiration date', 'invoicing' ); ?></label>
274
+                <label for="wpinv_discount_expiration"><?php _e('Expiration date', 'invoicing'); ?></label>
275 275
             </th>
276 276
             <td>
277
-                <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr( wpinv_get_discount_expiration( $discount_id ) ); ?>">
278
-                <p class="description"><?php _e( 'Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing' ); ?></p>
277
+                <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr(wpinv_get_discount_expiration($discount_id)); ?>">
278
+                <p class="description"><?php _e('Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing'); ?></p>
279 279
             </td>
280 280
         </tr>
281
-        <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?>
281
+        <?php do_action('wpinv_discount_form_before_min_total', $post); ?>
282 282
         <tr>
283 283
             <th valign="top" scope="row">
284
-                <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label>
284
+                <label for="wpinv_discount_min_total"><?php _e('Minimum Amount', 'invoicing'); ?></label>
285 285
             </th>
286 286
             <td>
287 287
                 <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>">
288
-                <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
288
+                <p class="description"><?php _e('This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
289 289
             </td>
290 290
         </tr>
291
-        <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?>
291
+        <?php do_action('wpinv_discount_form_before_max_total', $post); ?>
292 292
         <tr>
293 293
             <th valign="top" scope="row">
294
-                <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label>
294
+                <label for="wpinv_discount_max_total"><?php _e('Maximum Amount', 'invoicing'); ?></label>
295 295
             </th>
296 296
             <td>
297 297
                 <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>">
298
-                <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
298
+                <p class="description"><?php _e('This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
299 299
             </td>
300 300
         </tr>
301
-        <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?>
301
+        <?php do_action('wpinv_discount_form_before_recurring', $post); ?>
302 302
         <tr>
303 303
             <th valign="top" scope="row">
304
-                <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label>
304
+                <label for="wpinv_discount_recurring"><?php _e('For recurring apply to', 'invoicing'); ?></label>
305 305
             </th>
306 306
             <td>
307 307
                 <select id="wpinv_discount_recurring" name="recurring" class="medium-text">
308
-                    <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option>
309
-                    <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option>
308
+                    <option value="0" <?php selected(false, $recurring); ?>><?php _e('All payments', 'invoicing'); ?></option>
309
+                    <option value="1" <?php selected(true, $recurring); ?>><?php _e('First payment only', 'invoicing'); ?></option>
310 310
                 </select>
311
-                <p class="description"><?php _e( '<b>All payments:</b> apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> apply this discount to only first payment of the recurring invoice.', 'invoicing' ); ?></p>
311
+                <p class="description"><?php _e('<b>All payments:</b> apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> apply this discount to only first payment of the recurring invoice.', 'invoicing'); ?></p>
312 312
             </td>
313 313
         </tr>
314
-        <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?>
314
+        <?php do_action('wpinv_discount_form_before_max_uses', $post); ?>
315 315
         <tr>
316 316
             <th valign="top" scope="row">
317
-                <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label>
317
+                <label for="wpinv_discount_max_uses"><?php _e('Max Uses', 'invoicing'); ?></label>
318 318
             </th>
319 319
             <td>
320 320
                 <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>">
321
-                <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p>
321
+                <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing'); ?></p>
322 322
             </td>
323 323
         </tr>
324
-        <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?>
324
+        <?php do_action('wpinv_discount_form_before_single_use', $post); ?>
325 325
         <tr>
326 326
             <th valign="top" scope="row">
327
-                <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label>
327
+                <label for="wpinv_discount_single_use"><?php _e('Use Once Per User', 'invoicing'); ?></label>
328 328
             </th>
329 329
             <td>
330
-                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>>
331
-                <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span>
330
+                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked(true, $single_use); ?>>
331
+                <span class="description"><?php _e('Limit this discount to a single use per user?', 'invoicing'); ?></span>
332 332
             </td>
333 333
         </tr>
334
-        <?php do_action( 'wpinv_discount_form_last', $post ); ?>
334
+        <?php do_action('wpinv_discount_form_last', $post); ?>
335 335
     </tbody>
336 336
 </table>
337
-<?php do_action( 'wpinv_discount_form_bottom', $post ); ?>
337
+<?php do_action('wpinv_discount_form_bottom', $post); ?>
338 338
     <?php
339 339
 }
340 340
 
341
-function wpinv_discount_metabox_save( $post_id, $post, $update = false ) {
342
-    $post_type = !empty( $post ) ? $post->post_type : '';
341
+function wpinv_discount_metabox_save($post_id, $post, $update = false) {
342
+    $post_type = !empty($post) ? $post->post_type : '';
343 343
     
344
-    if ( $post_type != 'wpi_discount' ) {
344
+    if ($post_type != 'wpi_discount') {
345 345
         return;
346 346
     }
347 347
     
348
-    if ( !isset( $_POST['wpinv_discount_metabox_nonce'] ) || ( isset( $_POST['wpinv_discount_metabox_nonce'] ) && !wp_verify_nonce( $_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce' ) ) ) {
348
+    if (!isset($_POST['wpinv_discount_metabox_nonce']) || (isset($_POST['wpinv_discount_metabox_nonce']) && !wp_verify_nonce($_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce'))) {
349 349
         return;
350 350
     }
351 351
     
352
-    if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
352
+    if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
353 353
         return;
354 354
     }
355 355
     
356
-    if ( !current_user_can( 'manage_options', $post_id ) ) {
356
+    if (!current_user_can('manage_options', $post_id)) {
357 357
         return;
358 358
     }
359 359
     
360
-    return wpinv_store_discount( $post_id, $_POST, $post, $update );
360
+    return wpinv_store_discount($post_id, $_POST, $post, $update);
361 361
 }
362
-add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 );
363 362
\ No newline at end of file
363
+add_action('save_post', 'wpinv_discount_metabox_save', 10, 3);
364 364
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-invoice-items.php 1 patch
Spacing   +142 added lines, -142 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,17 +29,17 @@  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 ( $is_recurring ) {
42
+        if ($is_recurring) {
43 43
             $class .= ' wpi-recurring';
44 44
         }
45 45
         ?>
@@ -47,21 +47,21 @@  discard block
 block discarded – undo
47 47
             <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0">
48 48
                 <thead>
49 49
                     <tr>
50
-                        <th class="id"><?php _e( 'ID', 'invoicing' );?></th>
51
-                        <th class="title"><?php _e( 'Item', 'invoicing' );?></th>
52
-                        <th class="price"><?php _e( 'Price', 'invoicing' );?></th>
53
-                        <?php if ( $item_quantities ) { ?>
54
-                        <th class="qty"><?php _e( 'Qty', 'invoicing' );?></th>
50
+                        <th class="id"><?php _e('ID', 'invoicing'); ?></th>
51
+                        <th class="title"><?php _e('Item', 'invoicing'); ?></th>
52
+                        <th class="price"><?php _e('Price', 'invoicing'); ?></th>
53
+                        <?php if ($item_quantities) { ?>
54
+                        <th class="qty"><?php _e('Qty', 'invoicing'); ?></th>
55 55
                         <?php } ?>
56
-                        <th class="total"><?php _e( 'Total', 'invoicing' );?></th>
57
-                        <?php if ( $use_taxes ) { ?>
58
-                        <th class="tax"><?php _e( 'Tax (%)', 'invoicing' );?></th>
56
+                        <th class="total"><?php _e('Total', 'invoicing'); ?></th>
57
+                        <?php if ($use_taxes) { ?>
58
+                        <th class="tax"><?php _e('Tax (%)', 'invoicing'); ?></th>
59 59
                         <?php } ?>
60 60
                         <th class="action"></th>
61 61
                     </tr>
62 62
                 </thead>
63 63
                 <tbody class="wpinv-line-items">
64
-                    <?php echo wpinv_admin_get_line_items( $invoice ); ?>
64
+                    <?php echo wpinv_admin_get_line_items($invoice); ?>
65 65
                 </tbody>
66 66
                 <tfoot class="wpinv-totals">
67 67
                     <tr>
@@ -73,44 +73,44 @@  discard block
 block discarded – undo
73 73
                                         </td>
74 74
                                         <td class="title">
75 75
                                             <input type="text" class="regular-text" placeholder="Item name" value="" name="_wpinv_quick[name]">
76
-                                            <?php if ( $wpinv_euvat->allow_vat_rules() ) { ?>
76
+                                            <?php if ($wpinv_euvat->allow_vat_rules()) { ?>
77 77
                                             <div class="wp-clearfix">
78 78
                                                 <label class="wpi-vat-rule">
79
-                                                    <span class="title"><?php _e( 'VAT rule type', 'invoicing' );?></span>
79
+                                                    <span class="title"><?php _e('VAT rule type', 'invoicing'); ?></span>
80 80
                                                     <span class="input-text-wrap">
81
-                                                        <?php echo wpinv_html_select( array(
81
+                                                        <?php echo wpinv_html_select(array(
82 82
                                                             'options'          => $wpinv_euvat->get_rules(),
83 83
                                                             'name'             => '_wpinv_quick[vat_rule]',
84 84
                                                             'id'               => '_wpinv_quick_vat_rule',
85 85
                                                             'show_option_all'  => false,
86 86
                                                             'show_option_none' => false,
87 87
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-rule',
88
-                                                        ) ); ?>
88
+                                                        )); ?>
89 89
                                                     </span>
90 90
                                                 </label>
91 91
                                             </div>
92
-                                            <?php } if ( $wpinv_euvat->allow_vat_classes() ) { ?>
92
+                                            <?php } if ($wpinv_euvat->allow_vat_classes()) { ?>
93 93
                                             <div class="wp-clearfix">
94 94
                                                 <label class="wpi-vat-class">
95
-                                                    <span class="title"><?php _e( 'VAT class', 'invoicing' );?></span>
95
+                                                    <span class="title"><?php _e('VAT class', 'invoicing'); ?></span>
96 96
                                                     <span class="input-text-wrap">
97
-                                                        <?php echo wpinv_html_select( array(
97
+                                                        <?php echo wpinv_html_select(array(
98 98
                                                             'options'          => $wpinv_euvat->get_all_classes(),
99 99
                                                             'name'             => '_wpinv_quick[vat_class]',
100 100
                                                             'id'               => '_wpinv_quick_vat_class',
101 101
                                                             'show_option_all'  => false,
102 102
                                                             'show_option_none' => false,
103 103
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-class',
104
-                                                        ) ); ?>
104
+                                                        )); ?>
105 105
                                                     </span>
106 106
                                                 </label>
107 107
                                             </div>
108 108
                                             <?php } ?>
109 109
                                             <div class="wp-clearfix">
110 110
                                                 <label class="wpi-item-type">
111
-                                                    <span class="title"><?php _e( 'Item type', 'invoicing' );?></span>
111
+                                                    <span class="title"><?php _e('Item type', 'invoicing'); ?></span>
112 112
                                                     <span class="input-text-wrap">
113
-                                                        <?php echo wpinv_html_select( array(
113
+                                                        <?php echo wpinv_html_select(array(
114 114
                                                             'options'          => $item_types,
115 115
                                                             'name'             => '_wpinv_quick[type]',
116 116
                                                             'id'               => '_wpinv_quick_type',
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
                                                             'show_option_all'  => false,
119 119
                                                             'show_option_none' => false,
120 120
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-type',
121
-                                                        ) ); ?>
121
+                                                        )); ?>
122 122
                                                     </span>
123 123
                                                 </label>
124 124
                                             </div>
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
                                             </div>
132 132
                                         </td>
133 133
                                         <td class="price"><input type="text" placeholder="0.00" class="wpi-field-price wpi-price" name="_wpinv_quick[price]" /></td>
134
-                                        <?php if ( $item_quantities ) { ?>
134
+                                        <?php if ($item_quantities) { ?>
135 135
                                         <td class="qty"><input type="number" class="small-text" step="1" min="1" value="1" name="_wpinv_quick[qty]" /></td>
136 136
                                         <?php } ?>
137 137
                                         <td class="total"></td>
138
-                                        <?php if ( $use_taxes ) { ?>
138
+                                        <?php if ($use_taxes) { ?>
139 139
                                         <td class="tax"></td>
140 140
                                         <?php } ?>
141 141
                                         <td class="action"></td>
@@ -148,29 +148,29 @@  discard block
 block discarded – undo
148 148
                         <td colspan="<?php echo $cols; ?>"></td>
149 149
                     </tr>
150 150
                     <tr class="totals">
151
-                        <td colspan="<?php echo ( $cols - 4 ); ?>"></td>
151
+                        <td colspan="<?php echo ($cols - 4); ?>"></td>
152 152
                         <td colspan="4">
153 153
                             <table cellspacing="0" cellpadding="0">
154 154
                                 <tr class="subtotal">
155
-                                    <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td>
156
-                                    <td class="total"><?php echo $subtotal;?></td>
155
+                                    <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td>
156
+                                    <td class="total"><?php echo $subtotal; ?></td>
157 157
                                     <td class="action"></td>
158 158
                                 </tr>
159 159
                                 <tr class="discount">
160
-                                    <td class="name"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice->ID ) ); ?>:</td>
161
-                                    <td class="total"><?php echo wpinv_discount( $invoice->ID, true, true ); ?></td>
160
+                                    <td class="name"><?php wpinv_get_discount_label(wpinv_discount_code($invoice->ID)); ?>:</td>
161
+                                    <td class="total"><?php echo wpinv_discount($invoice->ID, true, true); ?></td>
162 162
                                     <td class="action"></td>
163 163
                                 </tr>
164
-                                <?php if ( $use_taxes ) { ?>
164
+                                <?php if ($use_taxes) { ?>
165 165
                                 <tr class="tax">
166
-                                    <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td>
167
-                                    <td class="total"><?php echo $tax;?></td>
166
+                                    <td class="name"><?php _e('Tax:', 'invoicing'); ?></td>
167
+                                    <td class="total"><?php echo $tax; ?></td>
168 168
                                     <td class="action"></td>
169 169
                                 </tr>
170 170
                                 <?php } ?>
171 171
                                 <tr class="total">
172
-                                    <td class="name"><?php _e( 'Invoice Total:', 'invoicing' );?></td>
173
-                                    <td class="total"><?php echo $total;?></td>
172
+                                    <td class="name"><?php _e('Invoice Total:', 'invoicing'); ?></td>
173
+                                    <td class="total"><?php echo $total; ?></td>
174 174
                                     <td class="action"></td>
175 175
                                 </tr>
176 176
                             </table>
@@ -180,89 +180,89 @@  discard block
 block discarded – undo
180 180
             </table>
181 181
             <div class="wpinv-actions">
182 182
                 <?php
183
-                    if ( !$invoice->is_paid() ) {
184
-                    if ( !$invoice->is_recurring() ) {
185
-                    echo wpinv_item_dropdown( array(
183
+                    if (!$invoice->is_paid()) {
184
+                    if (!$invoice->is_recurring()) {
185
+                    echo wpinv_item_dropdown(array(
186 186
                         'name'             => 'wpinv_invoice_item',
187 187
                         'id'               => 'wpinv_invoice_item',
188 188
                         'with_packages'    => false,
189 189
                         'show_recurring'   => true,
190
-                    ) );
190
+                    ));
191 191
                     ?>
192
-                <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">
192
+                <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">
193 193
                     <?php } ?>
194
-                <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?>
194
+                <?php do_action('wpinv_invoice_items_actions', $invoice); ?>
195 195
             </div>
196 196
         </div>
197 197
         <?php
198 198
     }
199 199
     
200
-    public static function prices( $post ) {        
200
+    public static function prices($post) {        
201 201
         $symbol         = wpinv_currency_symbol();
202 202
         $position       = wpinv_currency_position();
203
-        $item           = new WPInv_Item( $post->ID );
203
+        $item           = new WPInv_Item($post->ID);
204 204
         
205 205
         $price          = $item->get_price();
206 206
         $is_recurring   = $item->is_recurring();
207 207
         $period         = $item->get_recurring_period();
208
-        $interval       = absint( $item->get_recurring_interval() );
209
-        $times          = absint( $item->get_recurring_limit() );
208
+        $interval       = absint($item->get_recurring_interval());
209
+        $times          = absint($item->get_recurring_limit());
210 210
         $free_trial     = $item->has_free_trial();
211 211
         $trial_interval = $item->get_trial_interval();
212 212
         $trial_period   = $item->get_trial_period();
213 213
         
214 214
         $intervals      = array();
215
-        for ( $i = 1; $i <= 90; $i++ ) {
215
+        for ($i = 1; $i <= 90; $i++) {
216 216
             $intervals[$i] = $i;
217 217
         }
218 218
         
219
-        $interval       = $interval > 0 ? $interval : 1;
219
+        $interval = $interval > 0 ? $interval : 1;
220 220
         
221 221
         $class = $is_recurring ? 'wpinv-recurring-y' : 'wpinv-recurring-n';
222 222
         ?>
223
-        <p class="wpinv-row-prices"><?php echo ( $position != 'right' ? $symbol . '&nbsp;' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_format_amount( 0 ); ?>" value="<?php echo wpinv_format_amount( $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' ) ;?>" />
224
-        <?php if ( $item->is_package() ) { ?>
225
-        <span class="description"><?php _e( 'GD package item price can be edited only from GD payment manager.', 'invoicing' ); ?></span>
223
+        <p class="wpinv-row-prices"><?php echo ($position != 'right' ? $symbol . '&nbsp;' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_format_amount(0); ?>" value="<?php echo wpinv_format_amount($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'); ?>" />
224
+        <?php if ($item->is_package()) { ?>
225
+        <span class="description"><?php _e('GD package item price can be edited only from GD payment manager.', 'invoicing'); ?></span>
226 226
         <?php } ?>
227 227
         </p>
228 228
         <p class="wpinv-row-is-recurring">
229 229
             <label for="wpinv_is_recurring">
230
-                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked( 1, $is_recurring ); ?> />
231
-                <?php echo apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Is Recurring Item?', 'invoicing' ) ); ?>
230
+                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked(1, $is_recurring); ?> />
231
+                <?php echo apply_filters('wpinv_is_recurring_toggle_text', __('Is Recurring Item?', 'invoicing')); ?>
232 232
             </label>
233 233
         </p>
234
-        <p class="wpinv-row-recurring-fields <?php echo $class;?>">
235
-                <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>
236
-                <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e( 'at every', 'invoicing' );?> <?php echo wpinv_html_select( array(
234
+        <p class="wpinv-row-recurring-fields <?php echo $class; ?>">
235
+                <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>
236
+                <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e('at every', 'invoicing'); ?> <?php echo wpinv_html_select(array(
237 237
                     'options'          => $intervals,
238 238
                     'name'             => 'wpinv_recurring_interval',
239 239
                     'id'               => 'wpinv_recurring_interval',
240 240
                     'selected'         => $interval,
241 241
                     'show_option_all'  => false,
242 242
                     'show_option_none' => false
243
-                ) ); ?> <span id="wpinv_interval_text"><?php _e( 'day(s)', 'invoicing' );?></span></label>
244
-                <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>
243
+                )); ?> <span id="wpinv_interval_text"><?php _e('day(s)', 'invoicing'); ?></span></label>
244
+                <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>
245 245
                 <span class="clear wpi-trial-clr"></span>
246 246
                 <label class="wpinv-free-trial" for="wpinv_free_trial">
247
-                    <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked( true, (bool)$free_trial ); ?> /> 
248
-                    <?php echo __( 'Offer free trial for', 'invoicing' ); ?>
247
+                    <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked(true, (bool)$free_trial); ?> /> 
248
+                    <?php echo __('Offer free trial for', 'invoicing'); ?>
249 249
                 </label>
250 250
                 <label class="wpinv-trial-interval" for="wpinv_trial_interval">
251
-                    <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>
251
+                    <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>
252 252
                 </label>
253 253
         </p>
254
-        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type( $post->ID ); ?>" />
255
-        <?php do_action( 'wpinv_item_price_field', $post->ID ); ?>
254
+        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type($post->ID); ?>" />
255
+        <?php do_action('wpinv_item_price_field', $post->ID); ?>
256 256
         <?php
257 257
     }
258 258
     
259
-    public static function vat_rules( $post ) {
259
+    public static function vat_rules($post) {
260 260
         global $wpinv_euvat;
261 261
         
262
-        $rule_type = $wpinv_euvat->get_item_rule( $post->ID );
262
+        $rule_type = $wpinv_euvat->get_item_rule($post->ID);
263 263
         ?>
264
-        <p><label for="wpinv_vat_rules"><strong><?php _e( 'Select how VAT rules will be applied:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
265
-        <?php echo wpinv_html_select( array(
264
+        <p><label for="wpinv_vat_rules"><strong><?php _e('Select how VAT rules will be applied:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
265
+        <?php echo wpinv_html_select(array(
266 266
                     'options'          => $wpinv_euvat->get_rules(),
267 267
                     'name'             => 'wpinv_vat_rules',
268 268
                     'id'               => 'wpinv_vat_rules',
@@ -270,19 +270,19 @@  discard block
 block discarded – undo
270 270
                     'show_option_all'  => false,
271 271
                     'show_option_none' => false,
272 272
                     'class'            => 'gdmbx2-text-medium wpinv-vat-rules',
273
-                ) ); ?>
273
+                )); ?>
274 274
         </p>
275
-        <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>
276
-        <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>
275
+        <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>
276
+        <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>
277 277
         <?php
278 278
     }
279 279
     
280
-    public static function vat_classes( $post ) {
280
+    public static function vat_classes($post) {
281 281
         global $wpinv_euvat;
282 282
         
283
-        $vat_class = $wpinv_euvat->get_item_class( $post->ID );
283
+        $vat_class = $wpinv_euvat->get_item_class($post->ID);
284 284
         ?>
285
-        <p><?php echo wpinv_html_select( array(
285
+        <p><?php echo wpinv_html_select(array(
286 286
                     'options'          => $wpinv_euvat->get_all_classes(),
287 287
                     'name'             => 'wpinv_vat_class',
288 288
                     'id'               => 'wpinv_vat_class',
@@ -290,18 +290,18 @@  discard block
 block discarded – undo
290 290
                     'show_option_all'  => false,
291 291
                     'show_option_none' => false,
292 292
                     'class'            => 'gdmbx2-text-medium wpinv-vat-class',
293
-                ) ); ?>
293
+                )); ?>
294 294
         </p>
295
-        <p class="wpi-m0"><?php _e( 'Select the VAT rate class to use for this invoice item.', 'invoicing' ); ?></p>
295
+        <p class="wpi-m0"><?php _e('Select the VAT rate class to use for this invoice item.', 'invoicing'); ?></p>
296 296
         <?php
297 297
     }
298 298
     
299
-    public static function item_info( $post ) {
300
-        $item_type = wpinv_get_item_type( $post->ID );
301
-        do_action( 'wpinv_item_info_metabox_before', $post );
299
+    public static function item_info($post) {
300
+        $item_type = wpinv_get_item_type($post->ID);
301
+        do_action('wpinv_item_info_metabox_before', $post);
302 302
         ?>
303
-        <p><label for="wpinv_item_type"><strong><?php _e( 'Type:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
304
-        <?php echo wpinv_html_select( array(
303
+        <p><label for="wpinv_item_type"><strong><?php _e('Type:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
304
+        <?php echo wpinv_html_select(array(
305 305
                     'options'          => wpinv_get_item_types(),
306 306
                     'name'             => 'wpinv_item_type',
307 307
                     'id'               => 'wpinv_item_type',
@@ -310,93 +310,93 @@  discard block
 block discarded – undo
310 310
                     'show_option_none' => false,
311 311
                     'class'            => 'gdmbx2-text-medium wpinv-item-type',
312 312
                     //'disabled'         => $item_type == 'package' ? true : false,
313
-                ) ); ?>
313
+                )); ?>
314 314
         </p>
315
-        <p class="wpi-m0"><?php _e( 'Select item type.', 'invoicing' );?><br><?php _e( 'Standard: standard item type', 'invoicing' );?><br><?php _e( 'Fee: like Registration Fee, Signup Fee etc.', 'invoicing' );?></p>
315
+        <p class="wpi-m0"><?php _e('Select item type.', 'invoicing'); ?><br><?php _e('Standard: standard item type', 'invoicing'); ?><br><?php _e('Fee: like Registration Fee, Signup Fee etc.', 'invoicing'); ?></p>
316 316
         <?php
317
-        do_action( 'wpinv_item_info_metabox_after', $post );
317
+        do_action('wpinv_item_info_metabox_after', $post);
318 318
     }
319 319
     
320
-    public static function save( $post_id, $data, $post ) {
321
-        $invoice        = new WPInv_Invoice( $post_id );
320
+    public static function save($post_id, $data, $post) {
321
+        $invoice        = new WPInv_Invoice($post_id);
322 322
         
323 323
         // Billing
324
-        $first_name     = sanitize_text_field( $data['wpinv_first_name'] );
325
-        $last_name      = sanitize_text_field( $data['wpinv_last_name'] );
326
-        $company        = sanitize_text_field( $data['wpinv_company'] );
327
-        $vat_number     = sanitize_text_field( $data['wpinv_vat_number'] );
328
-        $phone          = sanitize_text_field( $data['wpinv_phone'] );
329
-        $address        = sanitize_text_field( $data['wpinv_address'] );
330
-        $city           = sanitize_text_field( $data['wpinv_city'] );
331
-        $zip            = sanitize_text_field( $data['wpinv_zip'] );
332
-        $country        = sanitize_text_field( $data['wpinv_country'] );
333
-        $state          = sanitize_text_field( $data['wpinv_state'] );
324
+        $first_name     = sanitize_text_field($data['wpinv_first_name']);
325
+        $last_name      = sanitize_text_field($data['wpinv_last_name']);
326
+        $company        = sanitize_text_field($data['wpinv_company']);
327
+        $vat_number     = sanitize_text_field($data['wpinv_vat_number']);
328
+        $phone          = sanitize_text_field($data['wpinv_phone']);
329
+        $address        = sanitize_text_field($data['wpinv_address']);
330
+        $city           = sanitize_text_field($data['wpinv_city']);
331
+        $zip            = sanitize_text_field($data['wpinv_zip']);
332
+        $country        = sanitize_text_field($data['wpinv_country']);
333
+        $state          = sanitize_text_field($data['wpinv_state']);
334 334
         
335 335
         // Details
336
-        $status         = sanitize_text_field( $data['wpinv_status'] );
337
-        $old_status     = !empty( $data['original_post_status'] ) ? sanitize_text_field( $data['original_post_status'] ) : $status;
338
-        $number         = sanitize_text_field( $data['wpinv_number'] );
339
-        $due_date       = isset( $data['wpinv_due_date'] ) ? sanitize_text_field( $data['wpinv_due_date'] ) : '';
336
+        $status         = sanitize_text_field($data['wpinv_status']);
337
+        $old_status     = !empty($data['original_post_status']) ? sanitize_text_field($data['original_post_status']) : $status;
338
+        $number         = sanitize_text_field($data['wpinv_number']);
339
+        $due_date       = isset($data['wpinv_due_date']) ? sanitize_text_field($data['wpinv_due_date']) : '';
340 340
         //$discounts      = sanitize_text_field( $data['wpinv_discounts'] );
341 341
         //$discount       = sanitize_text_field( $data['wpinv_discount'] );
342 342
         
343
-        $ip             = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
343
+        $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
344 344
         
345
-        $invoice->set( 'due_date', $due_date );
346
-        $invoice->set( 'first_name', $first_name );
347
-        $invoice->set( 'last_name', $last_name );
348
-        $invoice->set( 'company', $company );
349
-        $invoice->set( 'vat_number', $vat_number );
350
-        $invoice->set( 'phone', $phone );
351
-        $invoice->set( 'address', $address );
352
-        $invoice->set( 'city', $city );
353
-        $invoice->set( 'zip', $zip );
354
-        $invoice->set( 'country', $country );
355
-        $invoice->set( 'state', $state );
356
-        $invoice->set( 'status', $status );
357
-        $invoice->set( 'number', $number );
345
+        $invoice->set('due_date', $due_date);
346
+        $invoice->set('first_name', $first_name);
347
+        $invoice->set('last_name', $last_name);
348
+        $invoice->set('company', $company);
349
+        $invoice->set('vat_number', $vat_number);
350
+        $invoice->set('phone', $phone);
351
+        $invoice->set('address', $address);
352
+        $invoice->set('city', $city);
353
+        $invoice->set('zip', $zip);
354
+        $invoice->set('country', $country);
355
+        $invoice->set('state', $state);
356
+        $invoice->set('status', $status);
357
+        $invoice->set('number', $number);
358 358
         //$invoice->set( 'discounts', $discounts );
359 359
         //$invoice->set( 'discount', $discount );
360
-        $invoice->set( 'ip', $ip );
360
+        $invoice->set('ip', $ip);
361 361
         $invoice->old_status = $_POST['original_post_status'];
362 362
         $invoice->currency = wpinv_get_currency();
363
-        if ( !empty( $data['wpinv_gateway'] ) ) {
364
-            $invoice->set( 'gateway', sanitize_text_field( $data['wpinv_gateway'] ) );
363
+        if (!empty($data['wpinv_gateway'])) {
364
+            $invoice->set('gateway', sanitize_text_field($data['wpinv_gateway']));
365 365
         }
366 366
         $saved = $invoice->save();
367 367
         
368 368
         // Check for payment notes
369
-        if ( !empty( $data['invoice_note'] ) ) {
370
-            $note               = wp_kses( $data['invoice_note'], array() );
371
-            $note_type          = sanitize_text_field( $data['invoice_note_type'] );
369
+        if (!empty($data['invoice_note'])) {
370
+            $note               = wp_kses($data['invoice_note'], array());
371
+            $note_type          = sanitize_text_field($data['invoice_note_type']);
372 372
             $is_customer_note   = $note_type == 'customer' ? 1 : 0;
373 373
         
374
-            wpinv_insert_payment_note( $invoice->ID, $note, $is_customer_note );
374
+            wpinv_insert_payment_note($invoice->ID, $note, $is_customer_note);
375 375
         }
376 376
         
377 377
         // Update user address if empty.
378
-        if ( $saved && !empty( $invoice ) ) {
379
-            if ( $user_id = $invoice->get_user_id() ) {
380
-                $user_address = wpinv_get_user_address( $user_id, false );
378
+        if ($saved && !empty($invoice)) {
379
+            if ($user_id = $invoice->get_user_id()) {
380
+                $user_address = wpinv_get_user_address($user_id, false);
381 381
                 
382 382
                 if (empty($user_address['first_name'])) {
383
-                    update_user_meta( $user_id, '_wpinv_first_name', $first_name );
384
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
383
+                    update_user_meta($user_id, '_wpinv_first_name', $first_name);
384
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
385 385
                 } else if (empty($user_address['last_name']) && $user_address['first_name'] == $first_name) {
386
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
386
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
387 387
                 }
388 388
                 
389 389
                 if (empty($user_address['address']) || empty($user_address['city']) || empty($user_address['state']) || empty($user_address['country'])) {
390
-                    update_user_meta( $user_id, '_wpinv_address', $address );
391
-                    update_user_meta( $user_id, '_wpinv_city', $city );
392
-                    update_user_meta( $user_id, '_wpinv_state', $state );
393
-                    update_user_meta( $user_id, '_wpinv_country', $country );
394
-                    update_user_meta( $user_id, '_wpinv_zip', $zip );
395
-                    update_user_meta( $user_id, '_wpinv_phone', $phone );
390
+                    update_user_meta($user_id, '_wpinv_address', $address);
391
+                    update_user_meta($user_id, '_wpinv_city', $city);
392
+                    update_user_meta($user_id, '_wpinv_state', $state);
393
+                    update_user_meta($user_id, '_wpinv_country', $country);
394
+                    update_user_meta($user_id, '_wpinv_zip', $zip);
395
+                    update_user_meta($user_id, '_wpinv_phone', $phone);
396 396
                 }
397 397
             }
398 398
             
399
-            do_action( 'wpinv_invoice_metabox_saveed', $invoice );
399
+            do_action('wpinv_invoice_metabox_saveed', $invoice);
400 400
         }
401 401
         
402 402
         return $saved;
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-invoice-details.php 1 patch
Spacing   +85 added lines, -85 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 save 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 save 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,104 +64,104 @@  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" placeholder="<?php echo esc_attr( wpinv_format_invoice_number( 1 ) ); ?>" value="<?php echo esc_attr( $invoice_number );?>" id="wpinv_number" name="wpinv_number" class="regular-text">
67
+                <input type="text" placeholder="<?php echo esc_attr(wpinv_format_invoice_number(1)); ?>" value="<?php echo esc_attr($invoice_number); ?>" id="wpinv_number" name="wpinv_number" class="regular-text">
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() ) || $discount_code ) { ?>
70
+        <?php do_action('wpinv_meta_box_details_inner', $post_id); ?>
71
+        <?php if (!($is_paid = $invoice->is_paid()) || $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 user&#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 user&#8217;s email address.', 'invoicing'),
103
+            'button_text'   =>  __('Resend Invoice', 'invoicing'),
104 104
         );
105 105
             
106 106
         $text = apply_filters('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() ) {
110
-            $email_url      = add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) );
111
-            $reminder_url   = add_query_arg( array( 'wpi_action' => 'send_reminder', 'invoice_id' => $post->ID ) );
109
+        if ($email = $wpi_mb_invoice->get_email()) {
110
+            $email_url      = add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID));
111
+            $reminder_url   = add_query_arg(array('wpi_action' => 'send_reminder', 'invoice_id' => $post->ID));
112 112
         ?>
113 113
         <p class="wpi-meta-row wpi-resend-info"><?php echo $text['message']; ?></p>
114
-        <p class="wpi-meta-row wpi-resend-email"><a title="<?php esc_attr_e( 'Send invoice to customer', 'invoicing' ); ?>" href="<?php echo esc_url( $email_url ); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p>
115
-        <?php if ( wpinv_get_option( 'overdue_active' ) && $wpi_mb_invoice->needs_payment() && ( $due_date = $wpi_mb_invoice->get_due_date() ) ) { ?>
116
-        <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( $reminder_url ); ?>" class="button button-secondary"><?php esc_attr_e( 'Send Reminder', 'invoicing' ); ?></a></p>
114
+        <p class="wpi-meta-row wpi-resend-email"><a title="<?php esc_attr_e('Send invoice to customer', 'invoicing'); ?>" href="<?php echo esc_url($email_url); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p>
115
+        <?php if (wpinv_get_option('overdue_active') && $wpi_mb_invoice->needs_payment() && ($due_date = $wpi_mb_invoice->get_due_date())) { ?>
116
+        <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($reminder_url); ?>" class="button button-secondary"><?php esc_attr_e('Send Reminder', 'invoicing'); ?></a></p>
117 117
         <?php } ?>
118 118
         <?php
119 119
         }
120 120
         
121
-        do_action( 'wpinv_metabox_resend_invoice_after', $wpi_mb_invoice );
121
+        do_action('wpinv_metabox_resend_invoice_after', $wpi_mb_invoice);
122 122
     }
123 123
     
124
-    public static function subscriptions( $post ) {
124
+    public static function subscriptions($post) {
125 125
         global $wpi_mb_invoice;
126 126
         
127 127
         $invoice = $wpi_mb_invoice;
128 128
         
129
-        if ( !empty( $invoice ) && $invoice->is_recurring() && $invoice->is_parent() ) {
129
+        if (!empty($invoice) && $invoice->is_recurring() && $invoice->is_parent()) {
130 130
             $payments       = $invoice->get_child_payments();
131 131
             
132 132
             $total_payments = (int)$invoice->get_total_payments();
133 133
             $subscription   = $invoice->get_subscription_data();
134 134
 
135
-            $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() );
136
-            $times_billed   = $total_payments . ' / ' . ( ( (int)$subscription['bill_times'] == 0 ) ? __( 'Until cancelled', 'invoicing' ) : $subscription['bill_times'] );
135
+            $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());
136
+            $times_billed   = $total_payments . ' / ' . (((int)$subscription['bill_times'] == 0) ? __('Until cancelled', 'invoicing') : $subscription['bill_times']);
137 137
             $subscription_status = $invoice->get_subscription_status();
138 138
             ?>
139
-            <p class="wpi-meta-row wpi-sub-label"><?php _e( 'Recurring Payment', 'invoicing' );?></p>
140
-            <?php if ( $subscription_id = $invoice->get_subscription_id() ) { ?>
141
-            <p class="wpi-meta-row wpi-sub-id"><label><?php _e( 'Subscription ID:', 'invoicing' );?> </label><?php echo $subscription_id; ?></p>
139
+            <p class="wpi-meta-row wpi-sub-label"><?php _e('Recurring Payment', 'invoicing'); ?></p>
140
+            <?php if ($subscription_id = $invoice->get_subscription_id()) { ?>
141
+            <p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><?php echo $subscription_id; ?></p>
142 142
             <?php } ?>
143
-            <p class="wpi-meta-row wpi-bill-cycle"><label><?php _e( 'Billing Cycle:', 'invoicing' );?> </label><?php echo $billing_cycle; ?></p>
144
-            <p class="wpi-meta-row wpi-billed-times"><label><?php _e( 'Times Billed:', 'invoicing' );?> </label><?php echo $times_billed; ?></p>
145
-            <?php if ( !empty( $payments ) || $invoice->is_paid() ) { ?>
146
-                <p class="wpi-meta-row wpi-start-date"><label><?php _e( 'Start Date:', 'invoicing' );?> </label><?php echo $invoice->get_subscription_start(); ?></p>
147
-                <p class="wpi-meta-row wpi-end-date"><label><?php _e( 'Expiration Date:', 'invoicing' );?> </label><?php echo $invoice->get_subscription_end(); ?></p>
148
-                <?php if ( $status_label = $invoice->get_subscription_status_label( $subscription_status ) ) { ?>
149
-                <p class="wpi-meta-row wpi-sub-status"><label><?php _e( 'Subscription Status:', 'invoicing' );?> </label><?php echo $status_label; ?></p>
143
+            <p class="wpi-meta-row wpi-bill-cycle"><label><?php _e('Billing Cycle:', 'invoicing'); ?> </label><?php echo $billing_cycle; ?></p>
144
+            <p class="wpi-meta-row wpi-billed-times"><label><?php _e('Times Billed:', 'invoicing'); ?> </label><?php echo $times_billed; ?></p>
145
+            <?php if (!empty($payments) || $invoice->is_paid()) { ?>
146
+                <p class="wpi-meta-row wpi-start-date"><label><?php _e('Start Date:', 'invoicing'); ?> </label><?php echo $invoice->get_subscription_start(); ?></p>
147
+                <p class="wpi-meta-row wpi-end-date"><label><?php _e('Expiration Date:', 'invoicing'); ?> </label><?php echo $invoice->get_subscription_end(); ?></p>
148
+                <?php if ($status_label = $invoice->get_subscription_status_label($subscription_status)) { ?>
149
+                <p class="wpi-meta-row wpi-sub-status"><label><?php _e('Subscription Status:', 'invoicing'); ?> </label><?php echo $status_label; ?></p>
150 150
                 <?php } ?>
151
-                <?php if ( $subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date() ) { ?>
152
-                <p class="wpi-meta-row wpi-trial-date"><label><?php _e( 'Trial Until:', 'invoicing' );?> </label><?php echo $trial_end_date; ?></p>
151
+                <?php if ($subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date()) { ?>
152
+                <p class="wpi-meta-row wpi-trial-date"><label><?php _e('Trial Until:', 'invoicing'); ?> </label><?php echo $trial_end_date; ?></p>
153 153
                 <?php } ?>
154
-                <?php if ( $cancelled_date = $invoice->get_cancelled_date() ) { ?>
155
-                <p class="wpi-meta-row wpi-cancel-date"><label><?php _e( 'Cancelled On:', 'invoicing' );?> </label><?php echo $cancelled_date; ?></p>
154
+                <?php if ($cancelled_date = $invoice->get_cancelled_date()) { ?>
155
+                <p class="wpi-meta-row wpi-cancel-date"><label><?php _e('Cancelled On:', 'invoicing'); ?> </label><?php echo $cancelled_date; ?></p>
156 156
                 <?php } ?>
157
-                <?php if ( !empty( $payments ) ) { ?>
158
-                <p><strong><?php _e( 'Renewal Payments:', 'invoicing' ); ?></strong></p>
157
+                <?php if (!empty($payments)) { ?>
158
+                <p><strong><?php _e('Renewal Payments:', 'invoicing'); ?></strong></p>
159 159
                 <ul id="wpi-sub-payments">
160
-                <?php foreach ( $payments as $invoice_id ) { ?>
160
+                <?php foreach ($payments as $invoice_id) { ?>
161 161
                     <li>
162
-                        <a href="<?php echo esc_url( get_edit_post_link( $invoice_id ) ); ?>"><?php echo wpinv_get_invoice_number( $invoice_id ); ?></a>&nbsp;&ndash;&nbsp;
163
-                        <span><?php echo wpinv_get_invoice_date( $invoice_id ); ?>&nbsp;&ndash;&nbsp;</span>
164
-                        <span><?php echo wpinv_payment_total( $invoice_id, true ); ?></span>
162
+                        <a href="<?php echo esc_url(get_edit_post_link($invoice_id)); ?>"><?php echo wpinv_get_invoice_number($invoice_id); ?></a>&nbsp;&ndash;&nbsp;
163
+                        <span><?php echo wpinv_get_invoice_date($invoice_id); ?>&nbsp;&ndash;&nbsp;</span>
164
+                        <span><?php echo wpinv_payment_total($invoice_id, true); ?></span>
165 165
                     </li>
166 166
                 <?php } ?>
167 167
                 </ul>
@@ -169,47 +169,47 @@  discard block
 block discarded – undo
169 169
         }
170 170
     }
171 171
     
172
-    public static function renewals( $post ) {
172
+    public static function renewals($post) {
173 173
         global $wpi_mb_invoice;
174 174
         
175
-        if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) {
176
-            $parent_url = get_edit_post_link( $wpi_mb_invoice->parent_invoice );
177
-            $parent_id  = wpinv_get_invoice_number( $wpi_mb_invoice->parent_invoice );
175
+        if (wpinv_is_subscription_payment($wpi_mb_invoice)) {
176
+            $parent_url = get_edit_post_link($wpi_mb_invoice->parent_invoice);
177
+            $parent_id  = wpinv_get_invoice_number($wpi_mb_invoice->parent_invoice);
178 178
         ?>
179
-        <p class="wpi-meta-row wpi-sub-id"><label><?php _e( 'Subscription ID:', 'invoicing' );?> </label><?php echo $wpi_mb_invoice->get_subscription_id(); ?></p>
180
-        <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>
179
+        <p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><?php echo $wpi_mb_invoice->get_subscription_id(); ?></p>
180
+        <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>
181 181
         <?php
182 182
         }
183 183
     }
184 184
     
185
-    public static function payment_meta( $post ) {
185
+    public static function payment_meta($post) {
186 186
         global $wpi_mb_invoice;
187 187
 
188
-        $set_dateway = empty( $wpi_mb_invoice->gateway ) ? true : false;
189
-        if ( !$set_dateway && !$wpi_mb_invoice->get_meta( '_wpinv_checkout', true ) && !$wpi_mb_invoice->is_paid() ) {
188
+        $set_dateway = empty($wpi_mb_invoice->gateway) ? true : false;
189
+        if (!$set_dateway && !$wpi_mb_invoice->get_meta('_wpinv_checkout', true) && !$wpi_mb_invoice->is_paid()) {
190 190
             $set_dateway = true;
191 191
         }
192 192
         
193 193
         ?>
194 194
         <p class="wpi-meta-row">
195
-        <?php if ( $set_dateway ) { $gateways = wpinv_get_enabled_payment_gateways( true ); ?>
196
-            <label for="wpinv_gateway"><?php _e( 'Gateway:', 'invoicing' ) ; ?></label>
195
+        <?php if ($set_dateway) { $gateways = wpinv_get_enabled_payment_gateways(true); ?>
196
+            <label for="wpinv_gateway"><?php _e('Gateway:', 'invoicing'); ?></label>
197 197
             <select required="required" id="wpinv_gateway" name="wpinv_gateway">
198
-                <?php foreach ( $gateways as $name => $gateway ) {
199
-                    if ( $wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription( $name ) ) {
198
+                <?php foreach ($gateways as $name => $gateway) {
199
+                    if ($wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription($name)) {
200 200
                         continue;
201 201
                     }
202 202
                     ?>
203
-                <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>
203
+                <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>
204 204
                 <?php } ?>
205 205
             </select>
206 206
         <?php } else { 
207
-            echo wp_sprintf( __( '<label>Gateway:</label> %s', 'invoicing' ), wpinv_get_gateway_checkout_label( $wpi_mb_invoice->gateway ) );
207
+            echo wp_sprintf(__('<label>Gateway:</label> %s', 'invoicing'), wpinv_get_gateway_checkout_label($wpi_mb_invoice->gateway));
208 208
         } ?>
209 209
         </p>
210
-        <?php if ( $wpi_mb_invoice->is_paid() ) { ?>
211
-        <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Key:</label> %s', 'invoicing' ), $wpi_mb_invoice->get_key() ); ?></p>
212
-        <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Transaction ID:</label> %s', 'invoicing' ), wpinv_payment_link_transaction_id( $wpi_mb_invoice ) ); ?></p>
210
+        <?php if ($wpi_mb_invoice->is_paid()) { ?>
211
+        <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Key:</label> %s', 'invoicing'), $wpi_mb_invoice->get_key()); ?></p>
212
+        <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Transaction ID:</label> %s', 'invoicing'), wpinv_payment_link_transaction_id($wpi_mb_invoice)); ?></p>
213 213
         <?php } ?>
214 214
         <?php
215 215
     }
Please login to merge, or discard this patch.