Passed
Pull Request — master (#217)
by Patrik
03:45
created
includes/class-wpinv.php 1 patch
Spacing   +184 added lines, -184 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();
@@ -31,31 +31,31 @@  discard block
 block discarded – undo
31 31
     }
32 32
     
33 33
     public function define_constants() {
34
-        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
35
-        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
34
+        define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
35
+        define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
36 36
     }
37 37
     
38 38
     private function actions() {
39 39
         /* Internationalize the text strings used. */
40
-        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
40
+        add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
41 41
         
42 42
         /* Perform actions on admin initialization. */
43
-        add_action( 'admin_init', array( &$this, 'admin_init') );
44
-        add_action( 'init', array( &$this, 'init' ), 3 );
45
-        add_action( 'init', array( 'WPInv_Shortcodes', 'init' ) );
46
-        add_action( 'init', array( &$this, 'wpinv_actions' ) );
43
+        add_action('admin_init', array(&$this, 'admin_init'));
44
+        add_action('init', array(&$this, 'init'), 3);
45
+        add_action('init', array('WPInv_Shortcodes', 'init'));
46
+        add_action('init', array(&$this, 'wpinv_actions'));
47 47
         
48
-        if ( class_exists( 'BuddyPress' ) ) {
49
-            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
48
+        if (class_exists('BuddyPress')) {
49
+            add_action('bp_include', array(&$this, 'bp_invoicing_init'));
50 50
         }
51 51
 
52
-        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
52
+        add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
53 53
         
54
-        if ( is_admin() ) {
55
-            add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
56
-            add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) );
54
+        if (is_admin()) {
55
+            add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
56
+            add_action('admin_body_class', array(&$this, 'admin_body_class'));
57 57
         } else {
58
-            add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
58
+            add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
59 59
         }
60 60
         
61 61
         /**
@@ -65,16 +65,16 @@  discard block
 block discarded – undo
65 65
          *
66 66
          * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference.
67 67
          */
68
-        do_action_ref_array( 'wpinv_actions', array( &$this ) );
68
+        do_action_ref_array('wpinv_actions', array(&$this));
69 69
 
70
-        add_action( 'admin_init', array( &$this, 'activation_redirect') );
70
+        add_action('admin_init', array(&$this, 'activation_redirect'));
71 71
     }
72 72
     
73 73
     public function plugins_loaded() {
74 74
         /* Internationalize the text strings used. */
75 75
         $this->load_textdomain();
76 76
 
77
-        do_action( 'wpinv_loaded' );
77
+        do_action('wpinv_loaded');
78 78
     }
79 79
     
80 80
     /**
@@ -82,217 +82,217 @@  discard block
 block discarded – undo
82 82
      *
83 83
      * @since 1.0
84 84
      */
85
-    public function load_textdomain( $locale = NULL ) {
86
-        if ( empty( $locale ) ) {
87
-            $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
85
+    public function load_textdomain($locale = NULL) {
86
+        if (empty($locale)) {
87
+            $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
88 88
         }
89 89
 
90
-        $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
90
+        $locale = apply_filters('plugin_locale', $locale, 'invoicing');
91 91
         
92
-        unload_textdomain( 'invoicing' );
93
-        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
94
-        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
92
+        unload_textdomain('invoicing');
93
+        load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
94
+        load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
95 95
         
96 96
         /**
97 97
          * Define language constants.
98 98
          */
99
-        require_once( WPINV_PLUGIN_DIR . 'language.php' );
99
+        require_once(WPINV_PLUGIN_DIR . 'language.php');
100 100
     }
101 101
         
102 102
     public function includes() {
103 103
         global $wpinv_options;
104 104
         
105
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
105
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
106 106
         $wpinv_options = wpinv_get_settings();
107 107
         
108
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' );
109
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
110
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
111
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
112
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
113
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
114
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
115
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' );
116
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
117
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
118
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
119
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
120
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
121
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' );
122
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' );
123
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' );
124
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' );
125
-        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
126
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
127
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
128
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
129
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
130
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php' );
131
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
132
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
133
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
134
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
135
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' );
136
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
137
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' );
138
-        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
139
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
140
-        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
141
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
142
-        require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
108
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php');
109
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
110
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
111
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
112
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
113
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
114
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
115
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php');
116
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
117
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
118
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
119
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
120
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php');
121
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php');
122
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php');
123
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php');
124
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php');
125
+        require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php');
126
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php');
127
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
128
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
129
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
130
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php');
131
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php');
132
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php');
133
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php');
134
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php');
135
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php');
136
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php');
137
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php');
138
+        require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php');
139
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php');
140
+        require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php');
141
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php');
142
+        require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php');
143 143
 
144
-        if ( !class_exists( 'WPInv_EUVat' ) ) {
145
-            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
144
+        if (!class_exists('WPInv_EUVat')) {
145
+            require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
146 146
         }
147 147
         
148
-        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
149
-        if ( !empty( $gateways ) ) {
150
-            foreach ( $gateways as $gateway ) {
151
-                if ( $gateway == 'manual' ) {
148
+        $gateways = array_keys(wpinv_get_enabled_payment_gateways());
149
+        if (!empty($gateways)) {
150
+            foreach ($gateways as $gateway) {
151
+                if ($gateway == 'manual') {
152 152
                     continue;
153 153
                 }
154 154
                 
155 155
                 $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
156 156
                 
157
-                if ( file_exists( $gateway_file ) ) {
158
-                    require_once( $gateway_file );
157
+                if (file_exists($gateway_file)) {
158
+                    require_once($gateway_file);
159 159
                 }
160 160
             }
161 161
         }
162
-        require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' );
162
+        require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php');
163 163
         
164
-        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
165
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
166
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
167
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' );
164
+        if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
165
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php');
166
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
167
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php');
168 168
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' );
169
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' );
170
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' );
171
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
172
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' );
173
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
174
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
175
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
169
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php');
170
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php');
171
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
172
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php');
173
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
174
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php');
175
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php');
176 176
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
177 177
             // load the user class only on the users.php page
178 178
             global $pagenow;
179
-            if($pagenow=='users.php'){
179
+            if ($pagenow == 'users.php') {
180 180
                 new WPInv_Admin_Users();
181 181
             }
182 182
         }
183 183
         
184 184
         // include css inliner
185
-        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
186
-            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
185
+        if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
186
+            include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
187 187
         }
188 188
         
189
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
189
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
190 190
     }
191 191
     
192 192
     public function init() {
193 193
     }
194 194
     
195 195
     public function admin_init() {
196
-        add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) );
196
+        add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php'));
197 197
     }
198 198
 
199 199
     public function activation_redirect() {
200 200
         // Bail if no activation redirect
201
-        if ( !get_transient( '_wpinv_activation_redirect' ) ) {
201
+        if (!get_transient('_wpinv_activation_redirect')) {
202 202
             return;
203 203
         }
204 204
 
205 205
         // Delete the redirect transient
206
-        delete_transient( '_wpinv_activation_redirect' );
206
+        delete_transient('_wpinv_activation_redirect');
207 207
 
208 208
         // Bail if activating from network, or bulk
209
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
209
+        if (is_network_admin() || isset($_GET['activate-multi'])) {
210 210
             return;
211 211
         }
212 212
 
213
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
213
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
214 214
         exit;
215 215
     }
216 216
     
217 217
     public function enqueue_scripts() {
218
-        $suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
218
+        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
219 219
         
220
-        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION );
221
-        wp_enqueue_style( 'wpinv_front_style' );
220
+        wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION);
221
+        wp_enqueue_style('wpinv_front_style');
222 222
                
223 223
         // Register scripts
224
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
225
-        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  WPINV_VERSION );
224
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
225
+        wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), WPINV_VERSION);
226 226
 
227 227
         $localize                         = array();
228
-        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
229
-        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
228
+        $localize['ajax_url']             = admin_url('admin-ajax.php');
229
+        $localize['nonce']                = wp_create_nonce('wpinv-nonce');
230 230
         $localize['currency_symbol']      = wpinv_currency_symbol();
231 231
         $localize['currency_pos']         = wpinv_currency_position();
232 232
         $localize['thousand_sep']         = wpinv_thousands_separator();
233 233
         $localize['decimal_sep']          = wpinv_decimal_separator();
234 234
         $localize['decimals']             = wpinv_decimals();
235
-        $localize['txtComplete']          = __( 'Complete', 'invoicing' );
235
+        $localize['txtComplete']          = __('Complete', 'invoicing');
236 236
         $localize['UseTaxes']             = wpinv_use_taxes();
237
-        $localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
237
+        $localize['checkoutNonce']        = wp_create_nonce('wpinv_checkout_nonce');
238 238
 
239
-        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
239
+        $localize = apply_filters('wpinv_front_js_localize', $localize);
240 240
         
241
-        wp_enqueue_script( 'jquery-blockui' );
241
+        wp_enqueue_script('jquery-blockui');
242 242
         $autofill_api = wpinv_get_option('address_autofill_api');
243 243
         $autofill_active = wpinv_get_option('address_autofill_active');
244
-        if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
245
-            if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
246
-                wp_dequeue_script( 'google-maps-api' );
244
+        if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) {
245
+            if (wp_script_is('google-maps-api', 'enqueued')) {
246
+                wp_dequeue_script('google-maps-api');
247 247
             }
248
-            wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
249
-            wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
248
+            wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false);
249
+            wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true);
250 250
         }
251 251
 
252
-        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
253
-        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
252
+        wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
253
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
254 254
 
255
-        wp_enqueue_script( 'wpinv-front-script' );
256
-        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
255
+        wp_enqueue_script('wpinv-front-script');
256
+        wp_localize_script('wpinv-front-script', 'WPInv', $localize);
257 257
     }
258 258
 
259 259
     public function admin_enqueue_scripts() {
260 260
         global $post, $pagenow;
261 261
         
262 262
         $post_type  = wpinv_admin_post_type();
263
-        $suffix     = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
264
-        $page       = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : '';
263
+        $suffix     = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
264
+        $page       = isset($_GET['page']) ? strtolower($_GET['page']) : '';
265 265
 
266 266
         $jquery_ui_css = false;
267
-        if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) {
267
+        if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
268 268
             $jquery_ui_css = true;
269
-        } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) {
269
+        } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') {
270 270
             $jquery_ui_css = true;
271 271
         }
272
-        if ( $jquery_ui_css ) {
273
-            wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
274
-            wp_enqueue_style( 'jquery-ui-css' );
272
+        if ($jquery_ui_css) {
273
+            wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16');
274
+            wp_enqueue_style('jquery-ui-css');
275 275
         }
276 276
 
277
-        wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
278
-        wp_enqueue_style( 'wpinv_meta_box_style' );
277
+        wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
278
+        wp_enqueue_style('wpinv_meta_box_style');
279 279
         
280
-        wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION );
281
-        wp_enqueue_style( 'wpinv_admin_style' );
280
+        wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION);
281
+        wp_enqueue_style('wpinv_admin_style');
282 282
 
283
-        $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) );
284
-        if ( $page == 'wpinv-subscriptions' ) {
285
-            wp_enqueue_script( 'jquery-ui-datepicker' );
283
+        $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php'));
284
+        if ($page == 'wpinv-subscriptions') {
285
+            wp_enqueue_script('jquery-ui-datepicker');
286 286
         }
287 287
         
288
-        if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) {
289
-            wp_enqueue_script( 'jquery-ui-datepicker' );
288
+        if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) {
289
+            wp_enqueue_script('jquery-ui-datepicker');
290 290
         }
291 291
 
292
-        wp_enqueue_style( 'wp-color-picker' );
293
-        wp_enqueue_script( 'wp-color-picker' );
292
+        wp_enqueue_style('wp-color-picker');
293
+        wp_enqueue_script('wp-color-picker');
294 294
         
295
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
295
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
296 296
 
297 297
         if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
298 298
             $autofill_api = wpinv_get_option('address_autofill_api');
@@ -303,20 +303,20 @@  discard block
 block discarded – undo
303 303
             }
304 304
         }
305 305
 
306
-        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
307
-        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
306
+        wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
307
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
308 308
 
309
-        wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ),  WPINV_VERSION );
310
-        wp_enqueue_script( 'wpinv-admin-script' );
309
+        wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION);
310
+        wp_enqueue_script('wpinv-admin-script');
311 311
         
312 312
         $localize                               = array();
313
-        $localize['ajax_url']                   = admin_url( 'admin-ajax.php' );
314
-        $localize['post_ID']                    = isset( $post->ID ) ? $post->ID : '';
315
-        $localize['wpinv_nonce']                = wp_create_nonce( 'wpinv-nonce' );
316
-        $localize['add_invoice_note_nonce']     = wp_create_nonce( 'add-invoice-note' );
317
-        $localize['delete_invoice_note_nonce']  = wp_create_nonce( 'delete-invoice-note' );
318
-        $localize['invoice_item_nonce']         = wp_create_nonce( 'invoice-item' );
319
-        $localize['billing_details_nonce']      = wp_create_nonce( 'get-billing-details' );
313
+        $localize['ajax_url']                   = admin_url('admin-ajax.php');
314
+        $localize['post_ID']                    = isset($post->ID) ? $post->ID : '';
315
+        $localize['wpinv_nonce']                = wp_create_nonce('wpinv-nonce');
316
+        $localize['add_invoice_note_nonce']     = wp_create_nonce('add-invoice-note');
317
+        $localize['delete_invoice_note_nonce']  = wp_create_nonce('delete-invoice-note');
318
+        $localize['invoice_item_nonce']         = wp_create_nonce('invoice-item');
319
+        $localize['billing_details_nonce']      = wp_create_nonce('get-billing-details');
320 320
         $localize['tax']                        = wpinv_tax_amount();
321 321
         $localize['discount']                   = wpinv_discount_amount();
322 322
         $localize['currency_symbol']            = wpinv_currency_symbol();
@@ -324,69 +324,69 @@  discard block
 block discarded – undo
324 324
         $localize['thousand_sep']               = wpinv_thousands_separator();
325 325
         $localize['decimal_sep']                = wpinv_decimal_separator();
326 326
         $localize['decimals']                   = wpinv_decimals();
327
-        $localize['save_invoice']               = __( 'Save Invoice', 'invoicing' );
328
-        $localize['status_publish']             = wpinv_status_nicename( 'publish' );
329
-        $localize['status_pending']             = wpinv_status_nicename( 'wpi-pending' );
330
-        $localize['delete_tax_rate']            = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' );
331
-        $localize['OneItemMin']                 = __( 'Invoice must contain at least one item', 'invoicing' );
332
-        $localize['DeleteInvoiceItem']          = __( 'Are you sure you wish to delete this item?', 'invoicing' );
333
-        $localize['FillBillingDetails']         = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' );
334
-        $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' );
335
-        $localize['AreYouSure']                 = __( 'Are you sure?', 'invoicing' );
336
-        $localize['emptyInvoice']               = __( 'Add at least one item to save invoice!', 'invoicing' );
337
-        $localize['errDeleteItem']              = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' );
338
-        $localize['delete_subscription']        = __( 'Are you sure you want to delete this subscription?', 'invoicing' );
339
-        $localize['action_edit']                = __( 'Edit', 'invoicing' );
340
-        $localize['action_cancel']              = __( 'Cancel', 'invoicing' );
327
+        $localize['save_invoice']               = __('Save Invoice', 'invoicing');
328
+        $localize['status_publish']             = wpinv_status_nicename('publish');
329
+        $localize['status_pending']             = wpinv_status_nicename('wpi-pending');
330
+        $localize['delete_tax_rate']            = __('Are you sure you wish to delete this tax rate?', 'invoicing');
331
+        $localize['OneItemMin']                 = __('Invoice must contain at least one item', 'invoicing');
332
+        $localize['DeleteInvoiceItem']          = __('Are you sure you wish to delete this item?', 'invoicing');
333
+        $localize['FillBillingDetails']         = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing');
334
+        $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');
335
+        $localize['AreYouSure']                 = __('Are you sure?', 'invoicing');
336
+        $localize['emptyInvoice']               = __('Add at least one item to save invoice!', 'invoicing');
337
+        $localize['errDeleteItem']              = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing');
338
+        $localize['delete_subscription']        = __('Are you sure you want to delete this subscription?', 'invoicing');
339
+        $localize['action_edit']                = __('Edit', 'invoicing');
340
+        $localize['action_cancel']              = __('Cancel', 'invoicing');
341 341
 
342
-        $localize = apply_filters( 'wpinv_admin_js_localize', $localize );
342
+        $localize = apply_filters('wpinv_admin_js_localize', $localize);
343 343
 
344
-        wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize );
344
+        wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize);
345 345
 
346
-        if ( $page == 'wpinv-subscriptions' ) {
347
-            wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
348
-            wp_enqueue_script( 'wpinv-sub-admin-script' );
346
+        if ($page == 'wpinv-subscriptions') {
347
+            wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION);
348
+            wp_enqueue_script('wpinv-sub-admin-script');
349 349
         }
350 350
     }
351 351
     
352
-    public function admin_body_class( $classes ) {
352
+    public function admin_body_class($classes) {
353 353
         global $pagenow, $post, $current_screen;
354 354
         
355
-        if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote' ) ) {
355
+        if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote')) {
356 356
             $classes .= ' wpinv-cpt';
357 357
         }
358 358
         
359
-        $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
359
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
360 360
 
361
-        $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false;
362
-        if ( $add_class ) {
363
-            $classes .= ' wpi-' . wpinv_sanitize_key( $page );
361
+        $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false;
362
+        if ($add_class) {
363
+            $classes .= ' wpi-' . wpinv_sanitize_key($page);
364 364
         }
365 365
         
366 366
         $settings_class = array();
367
-        if ( $page == 'wpinv-settings' ) {
368
-            if ( !empty( $_REQUEST['tab'] ) ) {
369
-                $settings_class[] = sanitize_text_field( $_REQUEST['tab'] );
367
+        if ($page == 'wpinv-settings') {
368
+            if (!empty($_REQUEST['tab'])) {
369
+                $settings_class[] = sanitize_text_field($_REQUEST['tab']);
370 370
             }
371 371
             
372
-            if ( !empty( $_REQUEST['section'] ) ) {
373
-                $settings_class[] = sanitize_text_field( $_REQUEST['section'] );
372
+            if (!empty($_REQUEST['section'])) {
373
+                $settings_class[] = sanitize_text_field($_REQUEST['section']);
374 374
             }
375 375
             
376
-            $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main';
376
+            $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main';
377 377
         }
378 378
         
379
-        if ( !empty( $settings_class ) ) {
380
-            $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) );
379
+        if (!empty($settings_class)) {
380
+            $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-'));
381 381
         }
382 382
         
383 383
         $post_type = wpinv_admin_post_type();
384 384
 
385
-        if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) {
385
+        if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) {
386 386
             return $classes .= ' wpinv';
387 387
         }
388 388
         
389
-        if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) {
389
+        if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) {
390 390
             $classes .= ' wpi-editable-n';
391 391
         }
392 392
 
@@ -398,20 +398,20 @@  discard block
 block discarded – undo
398 398
     }
399 399
     
400 400
     public function wpinv_actions() {
401
-        if ( isset( $_REQUEST['wpi_action'] ) ) {
402
-            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
401
+        if (isset($_REQUEST['wpi_action'])) {
402
+            do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
403 403
         }
404 404
     }
405 405
     
406
-    public function pre_get_posts( $wp_query ) {
407
-        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() ) {
408
-            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
406
+    public function pre_get_posts($wp_query) {
407
+        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()) {
408
+            $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
409 409
         }
410 410
         
411 411
         return $wp_query;
412 412
     }
413 413
     
414 414
     public function bp_invoicing_init() {
415
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
415
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
416 416
     }
417 417
 }
418 418
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/admin-meta-boxes.php 1 patch
Spacing   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -1,67 +1,67 @@  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 32
 	remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal');
33 33
 }
34
-add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 );
34
+add_action('add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2);
35 35
 
36
-function wpinv_save_meta_boxes( $post_id, $post, $update = false ) {
37
-    remove_action( 'save_post', __FUNCTION__ );
36
+function wpinv_save_meta_boxes($post_id, $post, $update = false) {
37
+    remove_action('save_post', __FUNCTION__);
38 38
     
39 39
     // $post_id and $post are required
40
-    if ( empty( $post_id ) || empty( $post ) ) {
40
+    if (empty($post_id) || empty($post)) {
41 41
         return;
42 42
     }
43 43
         
44
-    if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) {
44
+    if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) {
45 45
         return;
46 46
     }
47 47
     
48 48
     // Dont' save meta boxes for revisions or autosaves
49
-    if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
49
+    if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
50 50
         return;
51 51
     }
52 52
         
53
-    if ( $post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote' ) {
54
-        if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
53
+    if ($post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote') {
54
+        if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
55 55
             return;
56 56
         }
57 57
     
58
-        if ( isset( $_POST['wpinv_save_invoice'] ) && wp_verify_nonce( $_POST['wpinv_save_invoice'], 'wpinv_save_invoice' ) ) {
59
-            WPInv_Meta_Box_Items::save( $post_id, $_POST, $post );
58
+        if (isset($_POST['wpinv_save_invoice']) && wp_verify_nonce($_POST['wpinv_save_invoice'], 'wpinv_save_invoice')) {
59
+            WPInv_Meta_Box_Items::save($post_id, $_POST, $post);
60 60
         }
61
-    } else if ( $post->post_type == 'wpi_item' ) {
61
+    } else if ($post->post_type == 'wpi_item') {
62 62
         // verify nonce
63
-        if ( isset( $_POST['wpinv_vat_meta_box_nonce'] ) && wp_verify_nonce( $_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save' ) ) {
64
-            $fields                                 = array();
63
+        if (isset($_POST['wpinv_vat_meta_box_nonce']) && wp_verify_nonce($_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save')) {
64
+            $fields = array();
65 65
             $fields['_wpinv_price']              = 'wpinv_item_price';
66 66
             $fields['_wpinv_vat_class']          = 'wpinv_vat_class';
67 67
             $fields['_wpinv_vat_rule']           = 'wpinv_vat_rules';
@@ -74,92 +74,92 @@  discard block
 block discarded – undo
74 74
             $fields['_wpinv_trial_period']       = 'wpinv_trial_period';
75 75
             $fields['_wpinv_trial_interval']     = 'wpinv_trial_interval';
76 76
             
77
-            if ( !isset( $_POST['wpinv_is_recurring'] ) ) {
77
+            if (!isset($_POST['wpinv_is_recurring'])) {
78 78
                 $_POST['wpinv_is_recurring'] = 0;
79 79
             }
80 80
             
81
-            if ( !isset( $_POST['wpinv_free_trial'] ) || empty( $_POST['wpinv_is_recurring'] ) ) {
81
+            if (!isset($_POST['wpinv_free_trial']) || empty($_POST['wpinv_is_recurring'])) {
82 82
                 $_POST['wpinv_free_trial'] = 0;
83 83
             }
84 84
             
85
-            foreach ( $fields as $field => $name ) {
86
-                if ( isset( $_POST[ $name ] ) ) {
87
-                    $allowed = apply_filters( 'wpinv_item_allowed_save_meta_value', true, $field, $post_id );
85
+            foreach ($fields as $field => $name) {
86
+                if (isset($_POST[$name])) {
87
+                    $allowed = apply_filters('wpinv_item_allowed_save_meta_value', true, $field, $post_id);
88 88
 
89
-                    if ( !$allowed ) {
89
+                    if (!$allowed) {
90 90
                         continue;
91 91
                     }
92 92
 
93
-                    if ( $field == '_wpinv_price' ) {
94
-                        $value = wpinv_sanitize_amount( $_POST[ $name ] );
93
+                    if ($field == '_wpinv_price') {
94
+                        $value = wpinv_sanitize_amount($_POST[$name]);
95 95
                     } else {
96
-                        $value = is_string( $_POST[ $name ] ) ? sanitize_text_field( $_POST[ $name ] ) : $_POST[ $name ];
96
+                        $value = is_string($_POST[$name]) ? sanitize_text_field($_POST[$name]) : $_POST[$name];
97 97
                     }
98 98
                     
99
-                    $value = apply_filters( 'wpinv_item_metabox_save_' . $field, $value, $name );
100
-                    update_post_meta( $post_id, $field, $value );
99
+                    $value = apply_filters('wpinv_item_metabox_save_' . $field, $value, $name);
100
+                    update_post_meta($post_id, $field, $value);
101 101
                 }
102 102
             }
103 103
             
104
-            if ( !get_post_meta( $post_id, '_wpinv_custom_id', true ) ) {
105
-                update_post_meta( $post_id, '_wpinv_custom_id', $post_id );
104
+            if (!get_post_meta($post_id, '_wpinv_custom_id', true)) {
105
+                update_post_meta($post_id, '_wpinv_custom_id', $post_id);
106 106
             }
107 107
         }
108 108
     }
109 109
 }
110
-add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 );
110
+add_action('save_post', 'wpinv_save_meta_boxes', 10, 3);
111 111
 
112 112
 function wpinv_register_item_meta_boxes() {    
113 113
     global $wpinv_euvat;
114 114
     
115
-    add_meta_box( 'wpinv_field_prices', __( 'Item Price', 'invoicing' ), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high' );
115
+    add_meta_box('wpinv_field_prices', __('Item Price', 'invoicing'), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high');
116 116
 
117
-    if ( $wpinv_euvat->allow_vat_rules() ) {
118
-        add_meta_box( 'wpinv_field_vat_rules', __( 'VAT rules type to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high' );
117
+    if ($wpinv_euvat->allow_vat_rules()) {
118
+        add_meta_box('wpinv_field_vat_rules', __('VAT rules type to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high');
119 119
     }
120 120
     
121
-    if ( $wpinv_euvat->allow_vat_classes() ) {
122
-        add_meta_box( 'wpinv_field_vat_classes', __( 'VAT rates class to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high' );
121
+    if ($wpinv_euvat->allow_vat_classes()) {
122
+        add_meta_box('wpinv_field_vat_classes', __('VAT rates class to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high');
123 123
     }
124 124
     
125
-    add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core' );
126
-    add_meta_box( 'wpinv_field_meta_values', __( 'Item Meta Values', 'invoicing' ), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core' );
125
+    add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core');
126
+    add_meta_box('wpinv_field_meta_values', __('Item Meta Values', 'invoicing'), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core');
127 127
 }
128 128
 
129 129
 function wpinv_register_discount_meta_boxes() {
130
-    add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' );
130
+    add_meta_box('wpinv_discount_fields', __('Discount Details', 'invoicing'), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high');
131 131
 }
132 132
 
133
-function wpinv_discount_metabox_details( $post ) {
133
+function wpinv_discount_metabox_details($post) {
134 134
     $discount_id    = $post->ID;
135
-    $discount       = wpinv_get_discount( $discount_id );
135
+    $discount       = wpinv_get_discount($discount_id);
136 136
     
137
-    $type               = wpinv_get_discount_type( $discount_id );
138
-    $item_reqs          = wpinv_get_discount_item_reqs( $discount_id );
139
-    $excluded_items     = wpinv_get_discount_excluded_items( $discount_id );
140
-    $min_total          = wpinv_get_discount_min_total( $discount_id );
141
-    $max_total          = wpinv_get_discount_max_total( $discount_id );
142
-    $max_uses           = wpinv_get_discount_max_uses( $discount_id );
143
-    $single_use         = wpinv_discount_is_single_use( $discount_id );
144
-    $recurring          = (bool)wpinv_discount_is_recurring( $discount_id );
145
-    $start_date         = wpinv_get_discount_start_date( $discount_id );
146
-    $expiration_date    = wpinv_get_discount_expiration( $discount_id );
137
+    $type               = wpinv_get_discount_type($discount_id);
138
+    $item_reqs          = wpinv_get_discount_item_reqs($discount_id);
139
+    $excluded_items     = wpinv_get_discount_excluded_items($discount_id);
140
+    $min_total          = wpinv_get_discount_min_total($discount_id);
141
+    $max_total          = wpinv_get_discount_max_total($discount_id);
142
+    $max_uses           = wpinv_get_discount_max_uses($discount_id);
143
+    $single_use         = wpinv_discount_is_single_use($discount_id);
144
+    $recurring          = (bool)wpinv_discount_is_recurring($discount_id);
145
+    $start_date         = wpinv_get_discount_start_date($discount_id);
146
+    $expiration_date    = wpinv_get_discount_expiration($discount_id);
147 147
     
148
-    if ( ! empty( $start_date ) && strpos( $start_date, '0000' ) === false ) {
149
-        $start_time         = strtotime( $start_date );
150
-        $start_h            = date_i18n( 'H', $start_time );
151
-        $start_m            = date_i18n( 'i', $start_time );
152
-        $start_date         = date_i18n( 'Y-m-d', $start_time );
148
+    if (!empty($start_date) && strpos($start_date, '0000') === false) {
149
+        $start_time         = strtotime($start_date);
150
+        $start_h            = date_i18n('H', $start_time);
151
+        $start_m            = date_i18n('i', $start_time);
152
+        $start_date         = date_i18n('Y-m-d', $start_time);
153 153
     } else {
154 154
         $start_h            = '00';
155 155
         $start_m            = '00';
156 156
     }
157 157
 
158
-    if ( ! empty( $expiration_date ) && strpos( $expiration_date, '0000' ) === false ) {
159
-        $expiration_time    = strtotime( $expiration_date );
160
-        $expiration_h       = date_i18n( 'H', $expiration_time );
161
-        $expiration_m       = date_i18n( 'i', $expiration_time );
162
-        $expiration_date    = date_i18n( 'Y-m-d', $expiration_time );
158
+    if (!empty($expiration_date) && strpos($expiration_date, '0000') === false) {
159
+        $expiration_time    = strtotime($expiration_date);
160
+        $expiration_h       = date_i18n('H', $expiration_time);
161
+        $expiration_m       = date_i18n('i', $expiration_time);
162
+        $expiration_date    = date_i18n('Y-m-d', $expiration_time);
163 163
     } else {
164 164
         $expiration_h       = '23';
165 165
         $expiration_m       = '59';
@@ -169,207 +169,207 @@  discard block
 block discarded – undo
169 169
     $max_total          = $max_total > 0 ? $max_total : '';
170 170
     $max_uses           = $max_uses > 0 ? $max_uses : '';
171 171
 ?>
172
-<?php do_action( 'wpinv_discount_form_top', $post ); ?>
173
-<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?>
172
+<?php do_action('wpinv_discount_form_top', $post); ?>
173
+<?php wp_nonce_field('wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce'); ;?>
174 174
 <table class="form-table wpi-form-table">
175 175
     <tbody>
176
-        <?php do_action( 'wpinv_discount_form_first', $post ); ?>
177
-        <?php do_action( 'wpinv_discount_form_before_code', $post ); ?>
176
+        <?php do_action('wpinv_discount_form_first', $post); ?>
177
+        <?php do_action('wpinv_discount_form_before_code', $post); ?>
178 178
         <tr>
179 179
             <th valign="top" scope="row">
180
-                <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label>
180
+                <label for="wpinv_discount_code"><?php _e('Discount Code', 'invoicing'); ?></label>
181 181
             </th>
182 182
             <td>
183
-                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required>
184
-                <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p>
183
+                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr(wpinv_get_discount_code($discount_id)); ?>" required>
184
+                <p class="description"><?php _e('Enter a code for this discount, such as 10OFF', 'invoicing'); ?></p>
185 185
             </td>
186 186
         </tr>
187
-        <?php do_action( 'wpinv_discount_form_before_type', $post ); ?>
187
+        <?php do_action('wpinv_discount_form_before_type', $post); ?>
188 188
         <tr>
189 189
             <th valign="top" scope="row">
190
-                <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label>
190
+                <label for="wpinv_discount_type"><?php _e('Discount Type', 'invoicing'); ?></label>
191 191
             </th>
192 192
             <td>
193 193
                 <select id="wpinv_discount_type" name="type" class="medium-text wpi_select2">
194
-                    <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?>
195
-                    <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option>
194
+                    <?php foreach (wpinv_get_discount_types() as $value => $label) { ?>
195
+                    <option value="<?php echo $value; ?>" <?php selected($type, $value); ?>><?php echo $label; ?></option>
196 196
                     <?php } ?>
197 197
                 </select>
198
-                <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p>
198
+                <p class="description"><?php _e('The kind of discount to apply for this discount.', 'invoicing'); ?></p>
199 199
             </td>
200 200
         </tr>
201
-        <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?>
201
+        <?php do_action('wpinv_discount_form_before_amount', $post); ?>
202 202
         <tr>
203 203
             <th valign="top" scope="row">
204
-                <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label>
204
+                <label for="wpinv_discount_amount"><?php _e('Amount', 'invoicing'); ?></label>
205 205
             </th>
206 206
             <td>
207
-                <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>
208
-                <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p>
209
-                <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p>
207
+                <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>
208
+                <p style="display:none;" class="description"><?php _e('Enter the discount amount in USD', 'invoicing'); ?></p>
209
+                <p class="description"><?php _e('Enter the discount value. Ex: 10', 'invoicing'); ?></p>
210 210
             </td>
211 211
         </tr>
212
-        <?php do_action( 'wpinv_discount_form_before_items', $post ); ?>
212
+        <?php do_action('wpinv_discount_form_before_items', $post); ?>
213 213
         <tr>
214 214
             <th valign="top" scope="row">
215
-                <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label>
215
+                <label for="wpinv_discount_items"><?php _e('Items', 'invoicing'); ?></label>
216 216
             </th>
217 217
             <td>
218
-                <p><?php echo wpinv_item_dropdown( array(
218
+                <p><?php echo wpinv_item_dropdown(array(
219 219
                         'name'              => 'items[]',
220 220
                         'id'                => 'items',
221 221
                         'selected'          => $item_reqs,
222 222
                         'multiple'          => true,
223 223
                         'class'             => 'medium-text wpi_select2',
224
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
224
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
225 225
                         'show_recurring'    => true,
226
-                    ) ); ?>
226
+                    )); ?>
227 227
                 </p>
228
-                <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>
228
+                <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>
229 229
             </td>
230 230
         </tr>
231
-        <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?>
231
+        <?php do_action('wpinv_discount_form_before_excluded_items', $post); ?>
232 232
         <tr>
233 233
             <th valign="top" scope="row">
234
-                <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label>
234
+                <label for="wpinv_discount_excluded_items"><?php _e('Excluded Items', 'invoicing'); ?></label>
235 235
             </th>
236 236
             <td>
237
-                <p><?php echo wpinv_item_dropdown( array(
237
+                <p><?php echo wpinv_item_dropdown(array(
238 238
                         'name'              => 'excluded_items[]',
239 239
                         'id'                => 'excluded_items',
240 240
                         'selected'          => $excluded_items,
241 241
                         'multiple'          => true,
242 242
                         'class'             => 'medium-text wpi_select2',
243
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
243
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
244 244
                         'show_recurring'    => true,
245
-                    ) ); ?>
245
+                    )); ?>
246 246
                 </p>
247
-                <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p>
247
+                <p class="description"><?php _e('Items which are NOT allowed to use this discount.', 'invoicing'); ?></p>
248 248
             </td>
249 249
         </tr>
250
-        <?php do_action( 'wpinv_discount_form_before_start', $post ); ?>
250
+        <?php do_action('wpinv_discount_form_before_start', $post); ?>
251 251
         <tr>
252 252
             <th valign="top" scope="row">
253
-                <label for="wpinv_discount_start"><?php _e( 'Start Date', 'invoicing' ); ?></label>
253
+                <label for="wpinv_discount_start"><?php _e('Start Date', 'invoicing'); ?></label>
254 254
             </th>
255 255
             <td>
256
-                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr( $start_date ); ?>"> @ <select id="wpinv_discount_start_h" name="start_h">
257
-                    <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
258
-                    <option value="<?php echo $value;?>" <?php selected( $value, $start_h ); ?>><?php echo $value;?></option>
256
+                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr($start_date); ?>"> @ <select id="wpinv_discount_start_h" name="start_h">
257
+                    <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
258
+                    <option value="<?php echo $value; ?>" <?php selected($value, $start_h); ?>><?php echo $value; ?></option>
259 259
                     <?php } ?>
260 260
                 </select> : <select id="wpinv_discount_start_m" name="start_m">
261
-                    <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
262
-                    <option value="<?php echo $value;?>" <?php selected( $value, $start_m ); ?>><?php echo $value;?></option>
261
+                    <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
262
+                    <option value="<?php echo $value; ?>" <?php selected($value, $start_m); ?>><?php echo $value; ?></option>
263 263
                     <?php } ?>
264 264
                 </select>
265
-                <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>
265
+                <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>
266 266
             </td>
267 267
         </tr>
268
-        <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?>
268
+        <?php do_action('wpinv_discount_form_before_expiration', $post); ?>
269 269
         <tr>
270 270
             <th valign="top" scope="row">
271
-                <label for="wpinv_discount_expiration"><?php _e( 'Expiration Date', 'invoicing' ); ?></label>
271
+                <label for="wpinv_discount_expiration"><?php _e('Expiration Date', 'invoicing'); ?></label>
272 272
             </th>
273 273
             <td>
274
-                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr( $expiration_date ); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h">
275
-                    <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
276
-                    <option value="<?php echo $value;?>" <?php selected( $value, $expiration_h ); ?>><?php echo $value;?></option>
274
+                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr($expiration_date); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h">
275
+                    <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
276
+                    <option value="<?php echo $value; ?>" <?php selected($value, $expiration_h); ?>><?php echo $value; ?></option>
277 277
                     <?php } ?>
278 278
                 </select> : <select id="wpinv_discount_expiration_m" name="expiration_m">
279
-                    <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
280
-                    <option value="<?php echo $value;?>" <?php selected( $value, $expiration_m ); ?>><?php echo $value;?></option>
279
+                    <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
280
+                    <option value="<?php echo $value; ?>" <?php selected($value, $expiration_m); ?>><?php echo $value; ?></option>
281 281
                     <?php } ?>
282 282
                 </select>
283
-                <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>
283
+                <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>
284 284
             </td>
285 285
         </tr>
286
-        <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?>
286
+        <?php do_action('wpinv_discount_form_before_min_total', $post); ?>
287 287
         <tr>
288 288
             <th valign="top" scope="row">
289
-                <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label>
289
+                <label for="wpinv_discount_min_total"><?php _e('Minimum Amount', 'invoicing'); ?></label>
290 290
             </th>
291 291
             <td>
292 292
                 <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>">
293
-                <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
293
+                <p class="description"><?php _e('This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
294 294
             </td>
295 295
         </tr>
296
-        <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?>
296
+        <?php do_action('wpinv_discount_form_before_max_total', $post); ?>
297 297
         <tr>
298 298
             <th valign="top" scope="row">
299
-                <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label>
299
+                <label for="wpinv_discount_max_total"><?php _e('Maximum Amount', 'invoicing'); ?></label>
300 300
             </th>
301 301
             <td>
302 302
                 <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>">
303
-                <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
303
+                <p class="description"><?php _e('This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
304 304
             </td>
305 305
         </tr>
306
-        <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?>
306
+        <?php do_action('wpinv_discount_form_before_recurring', $post); ?>
307 307
         <tr>
308 308
             <th valign="top" scope="row">
309
-                <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label>
309
+                <label for="wpinv_discount_recurring"><?php _e('For recurring apply to', 'invoicing'); ?></label>
310 310
             </th>
311 311
             <td>
312 312
                 <select id="wpinv_discount_recurring" name="recurring" class="medium-text wpi_select2">
313
-                    <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option>
314
-                    <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option>
313
+                    <option value="0" <?php selected(false, $recurring); ?>><?php _e('All payments', 'invoicing'); ?></option>
314
+                    <option value="1" <?php selected(true, $recurring); ?>><?php _e('First payment only', 'invoicing'); ?></option>
315 315
                 </select>
316
-                <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>
316
+                <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>
317 317
             </td>
318 318
         </tr>
319
-        <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?>
319
+        <?php do_action('wpinv_discount_form_before_max_uses', $post); ?>
320 320
         <tr>
321 321
             <th valign="top" scope="row">
322
-                <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label>
322
+                <label for="wpinv_discount_max_uses"><?php _e('Max Uses', 'invoicing'); ?></label>
323 323
             </th>
324 324
             <td>
325 325
                 <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>">
326
-                <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p>
326
+                <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing'); ?></p>
327 327
             </td>
328 328
         </tr>
329
-        <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?>
329
+        <?php do_action('wpinv_discount_form_before_single_use', $post); ?>
330 330
         <tr>
331 331
             <th valign="top" scope="row">
332
-                <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label>
332
+                <label for="wpinv_discount_single_use"><?php _e('Use Once Per User', 'invoicing'); ?></label>
333 333
             </th>
334 334
             <td>
335
-                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>>
336
-                <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span>
335
+                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked(true, $single_use); ?>>
336
+                <span class="description"><?php _e('Limit this discount to a single use per user?', 'invoicing'); ?></span>
337 337
             </td>
338 338
         </tr>
339
-        <?php do_action( 'wpinv_discount_form_last', $post ); ?>
339
+        <?php do_action('wpinv_discount_form_last', $post); ?>
340 340
     </tbody>
341 341
 </table>
342
-<?php do_action( 'wpinv_discount_form_bottom', $post ); ?>
342
+<?php do_action('wpinv_discount_form_bottom', $post); ?>
343 343
     <?php
344 344
 }
345 345
 
346
-function wpinv_discount_metabox_save( $post_id, $post, $update = false ) {
347
-    $post_type = !empty( $post ) ? $post->post_type : '';
346
+function wpinv_discount_metabox_save($post_id, $post, $update = false) {
347
+    $post_type = !empty($post) ? $post->post_type : '';
348 348
     
349
-    if ( $post_type != 'wpi_discount' ) {
349
+    if ($post_type != 'wpi_discount') {
350 350
         return;
351 351
     }
352 352
     
353
-    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' ) ) ) {
353
+    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'))) {
354 354
         return;
355 355
     }
356 356
     
357
-    if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
357
+    if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
358 358
         return;
359 359
     }
360 360
     
361
-    if ( !current_user_can( 'manage_options', $post_id ) ) {
361
+    if (!current_user_can('manage_options', $post_id)) {
362 362
         return;
363 363
     }
364 364
     
365
-    if ( !empty( $_POST['start'] ) && isset( $_POST['start_h'] ) && isset( $_POST['start_m'] ) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '' ) {
365
+    if (!empty($_POST['start']) && isset($_POST['start_h']) && isset($_POST['start_m']) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '') {
366 366
         $_POST['start'] = $_POST['start'] . ' ' . $_POST['start_h'] . ':' . $_POST['start_m'];
367 367
     }
368 368
 
369
-    if ( !empty( $_POST['expiration'] ) && isset( $_POST['expiration_h'] ) && isset( $_POST['expiration_m'] ) ) {
369
+    if (!empty($_POST['expiration']) && isset($_POST['expiration_h']) && isset($_POST['expiration_m'])) {
370 370
         $_POST['expiration'] = $_POST['expiration'] . ' ' . $_POST['expiration_h'] . ':' . $_POST['expiration_m'];
371 371
     }
372 372
     
373
-    return wpinv_store_discount( $post_id, $_POST, $post, $update );
373
+    return wpinv_store_discount($post_id, $_POST, $post, $update);
374 374
 }
375
-add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 );
376 375
\ No newline at end of file
376
+add_action('save_post', 'wpinv_discount_metabox_save', 10, 3);
377 377
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wpinv-session-handler.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * Session handler class.
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
 	 */
53 53
 	public function __construct() {
54 54
 
55
-	    $this->_cookie = apply_filters( 'wpinv_cookie', 'wpinv_session_' . COOKIEHASH );
56
-        add_action( 'init', array( $this, 'init' ), -1 );
57
-		add_action( 'wp_logout', array( $this, 'destroy_session' ) );
58
-		add_action( 'wp', array( $this, 'set_customer_session_cookie' ), 10 );
59
-		add_action( 'shutdown', array( $this, 'save_data' ), 20 );
55
+	    $this->_cookie = apply_filters('wpinv_cookie', 'wpinv_session_' . COOKIEHASH);
56
+        add_action('init', array($this, 'init'), -1);
57
+		add_action('wp_logout', array($this, 'destroy_session'));
58
+		add_action('wp', array($this, 'set_customer_session_cookie'), 10);
59
+		add_action('shutdown', array($this, 'save_data'), 20);
60 60
 	}
61 61
 
62 62
 	/**
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
 	public function init() {
68 68
 		$this->init_session_cookie();
69 69
 
70
-		if ( ! is_user_logged_in() ) {
71
-			add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ) );
70
+		if (!is_user_logged_in()) {
71
+			add_filter('nonce_user_logged_out', array($this, 'nonce_user_logged_out'));
72 72
 		}
73 73
 	}
74 74
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	public function init_session_cookie() {
81 81
 		$cookie = $this->get_session_cookie();
82 82
 
83
-		if ( $cookie ) {
83
+		if ($cookie) {
84 84
 			$this->_customer_id        = $cookie[0];
85 85
 			$this->_session_expiration = $cookie[1];
86 86
 			$this->_session_expiring   = $cookie[2];
@@ -88,17 +88,17 @@  discard block
 block discarded – undo
88 88
 			$this->_data               = $this->get_session_data();
89 89
 
90 90
 			// If the user logs in, update session.
91
-			if ( is_user_logged_in() && get_current_user_id() != $this->_customer_id ) {
91
+			if (is_user_logged_in() && get_current_user_id() != $this->_customer_id) {
92 92
 				$this->_customer_id = get_current_user_id();
93 93
 				$this->_dirty       = true;
94 94
 				$this->save_data();
95
-				$this->set_customer_session_cookie( true );
95
+				$this->set_customer_session_cookie(true);
96 96
 			}
97 97
 
98 98
 			// Update session if its close to expiring.
99
-			if ( time() > $this->_session_expiring ) {
99
+			if (time() > $this->_session_expiring) {
100 100
 				$this->set_session_expiration();
101
-				$this->update_session_timestamp( $this->_customer_id, $this->_session_expiration );
101
+				$this->update_session_timestamp($this->_customer_id, $this->_session_expiration);
102 102
 			}
103 103
 		} else {
104 104
 			$this->set_session_expiration();
@@ -116,25 +116,25 @@  discard block
 block discarded – undo
116 116
 	 *
117 117
 	 * @param bool $set Should the session cookie be set.
118 118
 	 */
119
-	public function set_customer_session_cookie( $set ) {
120
-		if ( $set ) {
119
+	public function set_customer_session_cookie($set) {
120
+		if ($set) {
121 121
 			$to_hash           = $this->_customer_id . '|' . $this->_session_expiration;
122
-			$cookie_hash       = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
122
+			$cookie_hash       = hash_hmac('md5', $to_hash, wp_hash($to_hash));
123 123
 			$cookie_value      = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash;
124 124
 			$this->_has_cookie = true;
125 125
 
126
-			if ( ! isset( $_COOKIE[ $this->_cookie ] ) || $_COOKIE[ $this->_cookie ] !== $cookie_value ) {
127
-				$this->setcookie( $this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true );
126
+			if (!isset($_COOKIE[$this->_cookie]) || $_COOKIE[$this->_cookie] !== $cookie_value) {
127
+				$this->setcookie($this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true);
128 128
 			}
129 129
 		}
130 130
 	}
131 131
 
132
-	public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false){
133
-        if ( ! headers_sent() ) {
134
-            setcookie( $name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters( 'wpinv_cookie_httponly', $httponly, $name, $value, $expire, $secure ) );
135
-        } elseif ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
136
-            headers_sent( $file, $line );
137
-            trigger_error( "{$name} cookie cannot be set - headers already sent by {$file} on line {$line}", E_USER_NOTICE ); // @codingStandardsIgnoreLine
132
+	public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false) {
133
+        if (!headers_sent()) {
134
+            setcookie($name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters('wpinv_cookie_httponly', $httponly, $name, $value, $expire, $secure));
135
+        } elseif (defined('WP_DEBUG') && WP_DEBUG) {
136
+            headers_sent($file, $line);
137
+            trigger_error("{$name} cookie cannot be set - headers already sent by {$file} on line {$line}", E_USER_NOTICE); // @codingStandardsIgnoreLine
138 138
         }
139 139
     }
140 140
 
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
 	 * @return bool
146 146
 	 */
147 147
 	protected function use_secure_cookie() {
148
-        $is_https = false !== strstr( get_option( 'home' ), 'https:' );
149
-		return apply_filters( 'wpinv_session_use_secure_cookie', $is_https && is_ssl() );
148
+        $is_https = false !== strstr(get_option('home'), 'https:');
149
+		return apply_filters('wpinv_session_use_secure_cookie', $is_https && is_ssl());
150 150
 	}
151 151
 
152 152
 	/**
@@ -155,15 +155,15 @@  discard block
 block discarded – undo
155 155
 	 * @return bool
156 156
 	 */
157 157
 	public function has_session() {
158
-		return isset( $_COOKIE[ $this->_cookie ] ) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine.
158
+		return isset($_COOKIE[$this->_cookie]) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine.
159 159
 	}
160 160
 
161 161
 	/**
162 162
 	 * Set session expiration.
163 163
 	 */
164 164
 	public function set_session_expiration() {
165
-		$this->_session_expiring   = time() + intval( apply_filters( 'wpinv_session_expiring', 60 * 60 * 47 ) ); // 47 Hours.
166
-		$this->_session_expiration = time() + intval( apply_filters( 'wpinv_session_expiration', 60 * 60 * 48 ) ); // 48 Hours.
165
+		$this->_session_expiring   = time() + intval(apply_filters('wpinv_session_expiring', 60 * 60 * 47)); // 47 Hours.
166
+		$this->_session_expiration = time() + intval(apply_filters('wpinv_session_expiration', 60 * 60 * 48)); // 48 Hours.
167 167
 	}
168 168
 
169 169
 	/**
@@ -176,11 +176,11 @@  discard block
 block discarded – undo
176 176
 	public function generate_customer_id() {
177 177
 		$customer_id = '';
178 178
 
179
-		if ( is_user_logged_in() ) {
179
+		if (is_user_logged_in()) {
180 180
 			$customer_id = get_current_user_id();
181 181
 		}
182 182
 
183
-		if ( empty( $customer_id ) ) {
183
+		if (empty($customer_id)) {
184 184
             $customer_id = wp_create_nonce('wpinv-session-customer-id');
185 185
 		}
186 186
 
@@ -195,27 +195,27 @@  discard block
 block discarded – undo
195 195
 	 * @return bool|array
196 196
 	 */
197 197
 	public function get_session_cookie() {
198
-		$cookie_value = isset( $_COOKIE[ $this->_cookie ] ) ? wp_unslash( $_COOKIE[ $this->_cookie ] ) : false; // @codingStandardsIgnoreLine.
198
+		$cookie_value = isset($_COOKIE[$this->_cookie]) ? wp_unslash($_COOKIE[$this->_cookie]) : false; // @codingStandardsIgnoreLine.
199 199
 
200
-		if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) {
200
+		if (empty($cookie_value) || !is_string($cookie_value)) {
201 201
 			return false;
202 202
 		}
203 203
 
204
-		list( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value );
204
+		list($customer_id, $session_expiration, $session_expiring, $cookie_hash) = explode('||', $cookie_value);
205 205
 
206
-		if ( empty( $customer_id ) ) {
206
+		if (empty($customer_id)) {
207 207
 			return false;
208 208
 		}
209 209
 
210 210
 		// Validate hash.
211 211
 		$to_hash = $customer_id . '|' . $session_expiration;
212
-		$hash    = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
212
+		$hash    = hash_hmac('md5', $to_hash, wp_hash($to_hash));
213 213
 
214
-		if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) {
214
+		if (empty($cookie_hash) || !hash_equals($hash, $cookie_hash)) {
215 215
 			return false;
216 216
 		}
217 217
 
218
-		return array( $customer_id, $session_expiration, $session_expiring, $cookie_hash );
218
+		return array($customer_id, $session_expiration, $session_expiring, $cookie_hash);
219 219
 	}
220 220
 
221 221
 	/**
@@ -224,15 +224,15 @@  discard block
 block discarded – undo
224 224
 	 * @return array
225 225
 	 */
226 226
 	public function get_session_data() {
227
-		return $this->has_session() ? (array) $this->get_session( $this->_customer_id ) : array();
227
+		return $this->has_session() ? (array)$this->get_session($this->_customer_id) : array();
228 228
 	}
229 229
 
230
-	public function generate_key($customer_id){
231
-        if(!$customer_id){
230
+	public function generate_key($customer_id) {
231
+        if (!$customer_id) {
232 232
             return;
233 233
         }
234 234
 
235
-        return 'wpi_trans_'.$customer_id;
235
+        return 'wpi_trans_' . $customer_id;
236 236
     }
237 237
 
238 238
 	/**
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
 	 */
241 241
 	public function save_data() {
242 242
 		// Dirty if something changed - prevents saving nothing new.
243
-		if ( $this->_dirty && $this->has_session() ) {
243
+		if ($this->_dirty && $this->has_session()) {
244 244
 
245
-            set_transient( $this->generate_key($this->_customer_id), $this->_data, $this->_session_expiration);
245
+            set_transient($this->generate_key($this->_customer_id), $this->_data, $this->_session_expiration);
246 246
 
247 247
 			$this->_dirty = false;
248 248
 		}
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 	 * Destroy all session data.
253 253
 	 */
254 254
 	public function destroy_session() {
255
-		$this->delete_session( $this->_customer_id );
255
+		$this->delete_session($this->_customer_id);
256 256
 		$this->forget_session();
257 257
 	}
258 258
 
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	 * Forget all session data without destroying it.
261 261
 	 */
262 262
 	public function forget_session() {
263
-		$this->setcookie( $this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true );
263
+		$this->setcookie($this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true);
264 264
 
265 265
 		wpinv_empty_cart();
266 266
 
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 	 * @param int $uid User ID.
276 276
 	 * @return string
277 277
 	 */
278
-	public function nonce_user_logged_out( $uid ) {
278
+	public function nonce_user_logged_out($uid) {
279 279
 		return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid;
280 280
 	}
281 281
 
@@ -286,14 +286,14 @@  discard block
 block discarded – undo
286 286
 	 * @param mixed  $default Default session value.
287 287
 	 * @return string|array
288 288
 	 */
289
-	public function get_session( $customer_id, $default = false ) {
289
+	public function get_session($customer_id, $default = false) {
290 290
 
291
-		if ( defined( 'WP_SETUP_CONFIG' ) ) {
291
+		if (defined('WP_SETUP_CONFIG')) {
292 292
 			return array();
293 293
 		}
294 294
 
295
-        if ( !is_user_logged_in() ) {
296
-            if(!wp_verify_nonce( $customer_id, 'wpinv-session-customer-id' )){
295
+        if (!is_user_logged_in()) {
296
+            if (!wp_verify_nonce($customer_id, 'wpinv-session-customer-id')) {
297 297
                 return array();
298 298
             }
299 299
         }
@@ -301,11 +301,11 @@  discard block
 block discarded – undo
301 301
         $key = $this->generate_key($customer_id);
302 302
         $value = get_transient($key);
303 303
 
304
-        if ( !$value ) {
304
+        if (!$value) {
305 305
             $value = $default;
306 306
         }
307 307
 
308
-		return maybe_unserialize( $value );
308
+		return maybe_unserialize($value);
309 309
 	}
310 310
 
311 311
 	/**
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 	 *
314 314
 	 * @param int $customer_id Customer ID.
315 315
 	 */
316
-	public function delete_session( $customer_id ) {
316
+	public function delete_session($customer_id) {
317 317
 
318 318
         $key = $this->generate_key($customer_id);
319 319
 
@@ -326,9 +326,9 @@  discard block
 block discarded – undo
326 326
 	 * @param string $customer_id Customer ID.
327 327
 	 * @param int    $timestamp Timestamp to expire the cookie.
328 328
 	 */
329
-	public function update_session_timestamp( $customer_id, $timestamp ) {
329
+	public function update_session_timestamp($customer_id, $timestamp) {
330 330
 
331
-        set_transient( $this->generate_key($customer_id), maybe_serialize( $this->_data ), $timestamp);
331
+        set_transient($this->generate_key($customer_id), maybe_serialize($this->_data), $timestamp);
332 332
 
333 333
 	}
334 334
 }
Please login to merge, or discard this patch.