Passed
Pull Request — master (#236)
by Patrik
03:27
created
includes/libraries/class-ayecode-addons.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,8 +51,8 @@
 block discarded – undo
51 51
         /**
52 52
          * Get section for the addons screen.
53 53
          *
54
-         * @param  string $section_id
55 54
          *
55
+         * @param string $tab_id
56 56
          * @return object|bool
57 57
          */
58 58
         public function get_tab($tab_id)
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly
3
-if ( ! defined( 'ABSPATH' ) ) exit;
4
-if(!class_exists('Ayecode_Addons')) {
3
+if (!defined('ABSPATH')) exit;
4
+if (!class_exists('Ayecode_Addons')) {
5 5
 
6 6
     abstract class Ayecode_Addons
7 7
     {
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly
3
-if ( ! defined( 'ABSPATH' ) ) exit;
3
+if ( ! defined( 'ABSPATH' ) ) {
4
+    exit;
5
+}
4 6
 if(!class_exists('Ayecode_Addons')) {
5 7
 
6 8
     abstract class Ayecode_Addons
Please login to merge, or discard this patch.
vendor/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php 2 patches
Indentation   +385 added lines, -385 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * Bail if we are not in WP.
14 14
  */
15 15
 if ( ! defined( 'ABSPATH' ) ) {
16
-	exit;
16
+    exit;
17 17
 }
18 18
 
19 19
 /**
@@ -21,294 +21,294 @@  discard block
 block discarded – undo
21 21
  */
22 22
 if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) {
23 23
 
24
-	/**
25
-	 * A Class to be able to change settings for Font Awesome.
26
-	 *
27
-	 * Class WP_Font_Awesome_Settings
28
-	 * @since 1.0.10 Now able to pass wp.org theme check.
29
-	 * @since 1.0.11 Font Awesome Pro now supported.
30
-	 * @since 1.0.11 Font Awesome Kits now supported.
31
-	 * @ver 1.0.11
32
-	 * @todo decide how to implement textdomain
33
-	 */
34
-	class WP_Font_Awesome_Settings {
35
-
36
-		/**
37
-		 * Class version version.
38
-		 *
39
-		 * @var string
40
-		 */
41
-		public $version = '1.0.11';
42
-
43
-		/**
44
-		 * Class textdomain.
45
-		 *
46
-		 * @var string
47
-		 */
48
-		public $textdomain = 'font-awesome-settings';
49
-
50
-		/**
51
-		 * Latest version of Font Awesome at time of publish published.
52
-		 *
53
-		 * @var string
54
-		 */
55
-		public $latest = "5.8.2";
56
-
57
-		/**
58
-		 * The title.
59
-		 *
60
-		 * @var string
61
-		 */
62
-		public $name = 'Font Awesome';
63
-
64
-		/**
65
-		 * Holds the settings values.
66
-		 *
67
-		 * @var array
68
-		 */
69
-		private $settings;
70
-
71
-		/**
72
-		 * WP_Font_Awesome_Settings instance.
73
-		 *
74
-		 * @access private
75
-		 * @since  1.0.0
76
-		 * @var    WP_Font_Awesome_Settings There can be only one!
77
-		 */
78
-		private static $instance = null;
79
-
80
-		/**
81
-		 * Main WP_Font_Awesome_Settings Instance.
82
-		 *
83
-		 * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded.
84
-		 *
85
-		 * @since 1.0.0
86
-		 * @static
87
-		 * @return WP_Font_Awesome_Settings - Main instance.
88
-		 */
89
-		public static function instance() {
90
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
91
-				self::$instance = new WP_Font_Awesome_Settings;
92
-
93
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
94
-
95
-				if ( is_admin() ) {
96
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
97
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
98
-				}
99
-
100
-				do_action( 'wp_font_awesome_settings_loaded' );
101
-			}
102
-
103
-			return self::$instance;
104
-		}
105
-
106
-		/**
107
-		 * Initiate the settings and add the required action hooks.
108
-		 *
109
-		 * @since 1.0.8 Settings name wrong - FIXED
110
-		 */
111
-		public function init() {
112
-			$this->settings = $this->get_settings();
113
-
114
-			if ( $this->settings['type'] == 'CSS' ) {
115
-
116
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
117
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
118
-				}
119
-
120
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
121
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
122
-				}
123
-
124
-			} else {
125
-
126
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
127
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
128
-				}
129
-
130
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
131
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
132
-				}
133
-			}
134
-
135
-			// remove font awesome if set to do so
136
-			if ( $this->settings['dequeue'] == '1' ) {
137
-				add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
138
-			}
139
-
140
-		}
141
-
142
-		/**
143
-		 * Adds the Font Awesome styles.
144
-		 */
145
-		public function enqueue_style() {
146
-			// build url
147
-			$url = $this->get_url();
148
-
149
-			wp_deregister_style( 'font-awesome' ); // deregister in case its already there
150
-			wp_register_style( 'font-awesome', $url, array(), null );
151
-			wp_enqueue_style( 'font-awesome' );
152
-
153
-			if ( $this->settings['shims'] ) {
154
-				$url = $this->get_url( true );
155
-				wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
156
-				wp_register_style( 'font-awesome-shims', $url, array(), null );
157
-				wp_enqueue_style( 'font-awesome-shims' );
158
-			}
159
-		}
160
-
161
-		/**
162
-		 * Adds the Font Awesome JS.
163
-		 */
164
-		public function enqueue_scripts() {
165
-			// build url
166
-			$url = $this->get_url();
167
-
168
-			$deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script';
169
-			call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
170
-			wp_register_script( 'font-awesome', $url, array(), null );
171
-			wp_enqueue_script( 'font-awesome' );
172
-
173
-			if ( $this->settings['shims'] ) {
174
-				$url = $this->get_url( true );
175
-				call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
176
-				wp_register_script( 'font-awesome-shims', $url, array(), null );
177
-				wp_enqueue_script( 'font-awesome-shims' );
178
-			}
179
-		}
180
-
181
-		/**
182
-		 * Get the url of the Font Awesome files.
183
-		 *
184
-		 * @param bool $shims If this is a shim file or not.
185
-		 *
186
-		 * @return string The url to the file.
187
-		 */
188
-		public function get_url( $shims = false ) {
189
-			$script  = $shims ? 'v4-shims' : 'all';
190
-			$sub     = $this->settings['pro'] ? 'pro' : 'use';
191
-			$type    = $this->settings['type'];
192
-			$version = $this->settings['version'];
193
-			$kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : '';
194
-			$url     = '';
195
-
196
-			if ( $type == 'KIT' && $kit_url ) {
197
-				if ( $shims ) {
198
-					// if its a kit then we don't add shims here
199
-					return '';
200
-				}
201
-				$url .= $kit_url; // CDN
202
-				$url .= "?wpfas=true"; // set our var so our version is not removed
203
-			} else {
204
-				$url .= "https://$sub.fontawesome.com/releases/"; // CDN
205
-				$url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
206
-				$url .= $type == 'CSS' ? 'css/' : 'js/'; // type
207
-				$url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
208
-				$url .= "?wpfas=true"; // set our var so our version is not removed
209
-			}
210
-
211
-			return $url;
212
-		}
213
-
214
-		/**
215
-		 * Try and remove any other versions of Font Awesome added by other plugins/themes.
216
-		 *
217
-		 * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version.
218
-		 *
219
-		 * @param $url
220
-		 * @param $original_url
221
-		 * @param $_context
222
-		 *
223
-		 * @return string The filtered url.
224
-		 */
225
-		public function remove_font_awesome( $url, $original_url, $_context ) {
226
-
227
-			if ( $_context == 'display'
228
-			     && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
229
-			     && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
230
-			) {// it's a font-awesome-url (probably)
231
-
232
-				if ( strstr( $url, "wpfas=true" ) !== false ) {
233
-					if ( $this->settings['type'] == 'JS' ) {
234
-						if ( $this->settings['js-pseudo'] ) {
235
-							$url .= "' data-search-pseudo-elements defer='defer";
236
-						} else {
237
-							$url .= "' defer='defer";
238
-						}
239
-					}
240
-				} else {
241
-					$url = ''; // removing the url removes the file
242
-				}
243
-
244
-			}
245
-
246
-			return $url;
247
-		}
248
-
249
-		/**
250
-		 * Register the database settings with WordPress.
251
-		 */
252
-		public function register_settings() {
253
-			register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
254
-		}
255
-
256
-		/**
257
-		 * Add the WordPress settings menu item.
258
-		 * @since 1.0.10 Calling function name direct will fail theme check so we don't.
259
-		 */
260
-		public function menu_item() {
261
-			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
262
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
263
-				$this,
264
-				'settings_page'
265
-			) );
266
-		}
267
-
268
-		/**
269
-		 * Get the current Font Awesome output settings.
270
-		 *
271
-		 * @return array The array of settings.
272
-		 */
273
-		public function get_settings() {
274
-
275
-			$db_settings = get_option( 'wp-font-awesome-settings' );
276
-
277
-			$defaults = array(
278
-				'type'      => 'CSS', // type to use, CSS or JS or KIT
279
-				'version'   => '', // latest
280
-				'enqueue'   => '', // front and backend
281
-				'shims'     => '1', // default on for now, @todo maybe change to off in 2020
282
-				'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive)
283
-				'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
284
-				'pro'       => '0', // if pro CDN url should be used
285
-				'kit-url'   => '', // the kit url
286
-			);
287
-
288
-			$settings = wp_parse_args( $db_settings, $defaults );
289
-
290
-			/**
291
-			 * Filter the Font Awesome settings.
292
-			 *
293
-			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
294
-			 */
295
-			return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
296
-		}
297
-
298
-
299
-		/**
300
-		 * The settings page html output.
301
-		 */
302
-		public function settings_page() {
303
-			if ( ! current_user_can( 'manage_options' ) ) {
304
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) );
305
-			}
306
-
307
-			// a hidden way to force the update of the verison number vai api instead of waiting the 48 hours
308
-			if ( isset( $_REQUEST['force-version-check'] ) ) {
309
-				$this->get_latest_version( $force_api = true );
310
-			}
311
-			?>
24
+    /**
25
+     * A Class to be able to change settings for Font Awesome.
26
+     *
27
+     * Class WP_Font_Awesome_Settings
28
+     * @since 1.0.10 Now able to pass wp.org theme check.
29
+     * @since 1.0.11 Font Awesome Pro now supported.
30
+     * @since 1.0.11 Font Awesome Kits now supported.
31
+     * @ver 1.0.11
32
+     * @todo decide how to implement textdomain
33
+     */
34
+    class WP_Font_Awesome_Settings {
35
+
36
+        /**
37
+         * Class version version.
38
+         *
39
+         * @var string
40
+         */
41
+        public $version = '1.0.11';
42
+
43
+        /**
44
+         * Class textdomain.
45
+         *
46
+         * @var string
47
+         */
48
+        public $textdomain = 'font-awesome-settings';
49
+
50
+        /**
51
+         * Latest version of Font Awesome at time of publish published.
52
+         *
53
+         * @var string
54
+         */
55
+        public $latest = "5.8.2";
56
+
57
+        /**
58
+         * The title.
59
+         *
60
+         * @var string
61
+         */
62
+        public $name = 'Font Awesome';
63
+
64
+        /**
65
+         * Holds the settings values.
66
+         *
67
+         * @var array
68
+         */
69
+        private $settings;
70
+
71
+        /**
72
+         * WP_Font_Awesome_Settings instance.
73
+         *
74
+         * @access private
75
+         * @since  1.0.0
76
+         * @var    WP_Font_Awesome_Settings There can be only one!
77
+         */
78
+        private static $instance = null;
79
+
80
+        /**
81
+         * Main WP_Font_Awesome_Settings Instance.
82
+         *
83
+         * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded.
84
+         *
85
+         * @since 1.0.0
86
+         * @static
87
+         * @return WP_Font_Awesome_Settings - Main instance.
88
+         */
89
+        public static function instance() {
90
+            if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
91
+                self::$instance = new WP_Font_Awesome_Settings;
92
+
93
+                add_action( 'init', array( self::$instance, 'init' ) ); // set settings
94
+
95
+                if ( is_admin() ) {
96
+                    add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
97
+                    add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
98
+                }
99
+
100
+                do_action( 'wp_font_awesome_settings_loaded' );
101
+            }
102
+
103
+            return self::$instance;
104
+        }
105
+
106
+        /**
107
+         * Initiate the settings and add the required action hooks.
108
+         *
109
+         * @since 1.0.8 Settings name wrong - FIXED
110
+         */
111
+        public function init() {
112
+            $this->settings = $this->get_settings();
113
+
114
+            if ( $this->settings['type'] == 'CSS' ) {
115
+
116
+                if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
117
+                    add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
118
+                }
119
+
120
+                if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
121
+                    add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
122
+                }
123
+
124
+            } else {
125
+
126
+                if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
127
+                    add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
128
+                }
129
+
130
+                if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
131
+                    add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
132
+                }
133
+            }
134
+
135
+            // remove font awesome if set to do so
136
+            if ( $this->settings['dequeue'] == '1' ) {
137
+                add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
138
+            }
139
+
140
+        }
141
+
142
+        /**
143
+         * Adds the Font Awesome styles.
144
+         */
145
+        public function enqueue_style() {
146
+            // build url
147
+            $url = $this->get_url();
148
+
149
+            wp_deregister_style( 'font-awesome' ); // deregister in case its already there
150
+            wp_register_style( 'font-awesome', $url, array(), null );
151
+            wp_enqueue_style( 'font-awesome' );
152
+
153
+            if ( $this->settings['shims'] ) {
154
+                $url = $this->get_url( true );
155
+                wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
156
+                wp_register_style( 'font-awesome-shims', $url, array(), null );
157
+                wp_enqueue_style( 'font-awesome-shims' );
158
+            }
159
+        }
160
+
161
+        /**
162
+         * Adds the Font Awesome JS.
163
+         */
164
+        public function enqueue_scripts() {
165
+            // build url
166
+            $url = $this->get_url();
167
+
168
+            $deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script';
169
+            call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
170
+            wp_register_script( 'font-awesome', $url, array(), null );
171
+            wp_enqueue_script( 'font-awesome' );
172
+
173
+            if ( $this->settings['shims'] ) {
174
+                $url = $this->get_url( true );
175
+                call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
176
+                wp_register_script( 'font-awesome-shims', $url, array(), null );
177
+                wp_enqueue_script( 'font-awesome-shims' );
178
+            }
179
+        }
180
+
181
+        /**
182
+         * Get the url of the Font Awesome files.
183
+         *
184
+         * @param bool $shims If this is a shim file or not.
185
+         *
186
+         * @return string The url to the file.
187
+         */
188
+        public function get_url( $shims = false ) {
189
+            $script  = $shims ? 'v4-shims' : 'all';
190
+            $sub     = $this->settings['pro'] ? 'pro' : 'use';
191
+            $type    = $this->settings['type'];
192
+            $version = $this->settings['version'];
193
+            $kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : '';
194
+            $url     = '';
195
+
196
+            if ( $type == 'KIT' && $kit_url ) {
197
+                if ( $shims ) {
198
+                    // if its a kit then we don't add shims here
199
+                    return '';
200
+                }
201
+                $url .= $kit_url; // CDN
202
+                $url .= "?wpfas=true"; // set our var so our version is not removed
203
+            } else {
204
+                $url .= "https://$sub.fontawesome.com/releases/"; // CDN
205
+                $url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
206
+                $url .= $type == 'CSS' ? 'css/' : 'js/'; // type
207
+                $url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
208
+                $url .= "?wpfas=true"; // set our var so our version is not removed
209
+            }
210
+
211
+            return $url;
212
+        }
213
+
214
+        /**
215
+         * Try and remove any other versions of Font Awesome added by other plugins/themes.
216
+         *
217
+         * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version.
218
+         *
219
+         * @param $url
220
+         * @param $original_url
221
+         * @param $_context
222
+         *
223
+         * @return string The filtered url.
224
+         */
225
+        public function remove_font_awesome( $url, $original_url, $_context ) {
226
+
227
+            if ( $_context == 'display'
228
+                 && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
229
+                 && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
230
+            ) {// it's a font-awesome-url (probably)
231
+
232
+                if ( strstr( $url, "wpfas=true" ) !== false ) {
233
+                    if ( $this->settings['type'] == 'JS' ) {
234
+                        if ( $this->settings['js-pseudo'] ) {
235
+                            $url .= "' data-search-pseudo-elements defer='defer";
236
+                        } else {
237
+                            $url .= "' defer='defer";
238
+                        }
239
+                    }
240
+                } else {
241
+                    $url = ''; // removing the url removes the file
242
+                }
243
+
244
+            }
245
+
246
+            return $url;
247
+        }
248
+
249
+        /**
250
+         * Register the database settings with WordPress.
251
+         */
252
+        public function register_settings() {
253
+            register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
254
+        }
255
+
256
+        /**
257
+         * Add the WordPress settings menu item.
258
+         * @since 1.0.10 Calling function name direct will fail theme check so we don't.
259
+         */
260
+        public function menu_item() {
261
+            $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
262
+            call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
263
+                $this,
264
+                'settings_page'
265
+            ) );
266
+        }
267
+
268
+        /**
269
+         * Get the current Font Awesome output settings.
270
+         *
271
+         * @return array The array of settings.
272
+         */
273
+        public function get_settings() {
274
+
275
+            $db_settings = get_option( 'wp-font-awesome-settings' );
276
+
277
+            $defaults = array(
278
+                'type'      => 'CSS', // type to use, CSS or JS or KIT
279
+                'version'   => '', // latest
280
+                'enqueue'   => '', // front and backend
281
+                'shims'     => '1', // default on for now, @todo maybe change to off in 2020
282
+                'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive)
283
+                'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
284
+                'pro'       => '0', // if pro CDN url should be used
285
+                'kit-url'   => '', // the kit url
286
+            );
287
+
288
+            $settings = wp_parse_args( $db_settings, $defaults );
289
+
290
+            /**
291
+             * Filter the Font Awesome settings.
292
+             *
293
+             * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
294
+             */
295
+            return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
296
+        }
297
+
298
+
299
+        /**
300
+         * The settings page html output.
301
+         */
302
+        public function settings_page() {
303
+            if ( ! current_user_can( 'manage_options' ) ) {
304
+                wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) );
305
+            }
306
+
307
+            // a hidden way to force the update of the verison number vai api instead of waiting the 48 hours
308
+            if ( isset( $_REQUEST['force-version-check'] ) ) {
309
+                $this->get_latest_version( $force_api = true );
310
+            }
311
+            ?>
312 312
 			<style>
313 313
 				.wpfas-kit-show {
314 314
 					display: none;
@@ -326,10 +326,10 @@  discard block
 block discarded – undo
326 326
 				<h1><?php echo $this->name; ?></h1>
327 327
 				<form method="post" action="options.php">
328 328
 					<?php
329
-					settings_fields( 'wp-font-awesome-settings' );
330
-					do_settings_sections( 'wp-font-awesome-settings' );
331
-					$kit_set = $this->settings['type'] == 'KIT' ? 'wpfas-kit-set' : '';
332
-					?>
329
+                    settings_fields( 'wp-font-awesome-settings' );
330
+                    do_settings_sections( 'wp-font-awesome-settings' );
331
+                    $kit_set = $this->settings['type'] == 'KIT' ? 'wpfas-kit-set' : '';
332
+                    ?>
333 333
 					<table class="form-table wpfas-table-settings <?php echo esc_attr( $kit_set ); ?>">
334 334
 						<tr valign="top">
335 335
 							<th scope="row"><label
@@ -355,12 +355,12 @@  discard block
 block discarded – undo
355 355
 								       value="<?php echo esc_attr( $this->settings['kit-url'] ); ?>"
356 356
 								       placeholder="https://kit.fontawesome.com/123abc.js"/>
357 357
 								<span><?php
358
-									echo sprintf(
359
-										__( 'Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings' ),
360
-										'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>',
361
-										'</a>'
362
-									);
363
-									?></span>
358
+                                    echo sprintf(
359
+                                        __( 'Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings' ),
360
+                                        '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>',
361
+                                        '</a>'
362
+                                    );
363
+                                    ?></span>
364 364
 							</td>
365 365
 						</tr>
366 366
 
@@ -420,14 +420,14 @@  discard block
 block discarded – undo
420 420
 								<input type="checkbox" name="wp-font-awesome-settings[pro]"
421 421
 								       value="1" <?php checked( $this->settings['pro'], '1' ); ?> id="wpfas-pro"/>
422 422
 								<span><?php
423
-									echo sprintf(
424
-										__( 'Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings' ),
425
-										'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/pro"><i class="fas fa-external-link-alt"></i>',
426
-										'</a>',
427
-										'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn"><i class="fas fa-external-link-alt"></i>',
428
-										'</a>'
429
-									);
430
-									?></span>
423
+                                    echo sprintf(
424
+                                        __( 'Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings' ),
425
+                                        '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/pro"><i class="fas fa-external-link-alt"></i>',
426
+                                        '</a>',
427
+                                        '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn"><i class="fas fa-external-link-alt"></i>',
428
+                                        '</a>'
429
+                                    );
430
+                                    ?></span>
431 431
 							</td>
432 432
 						</tr>
433 433
 
@@ -470,88 +470,88 @@  discard block
 block discarded – undo
470 470
 
471 471
 					</table>
472 472
 					<?php
473
-					submit_button();
474
-					?>
473
+                    submit_button();
474
+                    ?>
475 475
 				</form>
476 476
 
477 477
 				<div id="wpfas-version"><?php echo $this->version; ?></div>
478 478
 			</div>
479 479
 
480 480
 			<?php
481
-		}
482
-
483
-		/**
484
-		 * Check a version number is valid and if so return it or else return an empty string.
485
-		 *
486
-		 * @param $version string The version number to check.
487
-		 *
488
-		 * @since 1.0.6
489
-		 *
490
-		 * @return string Either a valid version number or an empty string.
491
-		 */
492
-		public function validate_version_number( $version ) {
493
-
494
-			if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
495
-				// valid
496
-			} else {
497
-				$version = '';// not validated
498
-			}
499
-
500
-			return $version;
501
-		}
502
-
503
-
504
-		/**
505
-		 * Get the latest version of Font Awesome.
506
-		 *
507
-		 * We check for a cached bersion and if none we will check for a live version via API and then cache it for 48 hours.
508
-		 *
509
-		 * @since 1.0.7
510
-		 * @return mixed|string The latest version number found.
511
-		 */
512
-		public function get_latest_version( $force_api = false ) {
513
-			$latest_version = $this->latest;
514
-
515
-			$cache = get_transient( 'wp-font-awesome-settings-version' );
516
-
517
-			if ( $cache === false || $force_api ) { // its not set
518
-				$api_ver = $this->get_latest_version_from_api();
519
-				if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
520
-					$latest_version = $api_ver;
521
-					set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
522
-				}
523
-			} elseif ( $this->validate_version_number( $cache ) ) {
524
-				if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
525
-					$latest_version = $cache;
526
-				}
527
-			}
528
-
529
-			return $latest_version;
530
-		}
531
-
532
-		/**
533
-		 * Get the latest Font Awesome version from the github API.
534
-		 *
535
-		 * @since 1.0.7
536
-		 * @return string The latest version number or `0` on API fail.
537
-		 */
538
-		public function get_latest_version_from_api() {
539
-			$version  = "0";
540
-			$response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
541
-			if ( ! is_wp_error( $response ) && is_array( $response ) ) {
542
-				$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
543
-				if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
544
-					$version = $api_response['tag_name'];
545
-				}
546
-			}
547
-
548
-			return $version;
549
-		}
550
-
551
-	}
552
-
553
-	/**
554
-	 * Run the class if found.
555
-	 */
556
-	WP_Font_Awesome_Settings::instance();
481
+        }
482
+
483
+        /**
484
+         * Check a version number is valid and if so return it or else return an empty string.
485
+         *
486
+         * @param $version string The version number to check.
487
+         *
488
+         * @since 1.0.6
489
+         *
490
+         * @return string Either a valid version number or an empty string.
491
+         */
492
+        public function validate_version_number( $version ) {
493
+
494
+            if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
495
+                // valid
496
+            } else {
497
+                $version = '';// not validated
498
+            }
499
+
500
+            return $version;
501
+        }
502
+
503
+
504
+        /**
505
+         * Get the latest version of Font Awesome.
506
+         *
507
+         * We check for a cached bersion and if none we will check for a live version via API and then cache it for 48 hours.
508
+         *
509
+         * @since 1.0.7
510
+         * @return mixed|string The latest version number found.
511
+         */
512
+        public function get_latest_version( $force_api = false ) {
513
+            $latest_version = $this->latest;
514
+
515
+            $cache = get_transient( 'wp-font-awesome-settings-version' );
516
+
517
+            if ( $cache === false || $force_api ) { // its not set
518
+                $api_ver = $this->get_latest_version_from_api();
519
+                if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
520
+                    $latest_version = $api_ver;
521
+                    set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
522
+                }
523
+            } elseif ( $this->validate_version_number( $cache ) ) {
524
+                if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
525
+                    $latest_version = $cache;
526
+                }
527
+            }
528
+
529
+            return $latest_version;
530
+        }
531
+
532
+        /**
533
+         * Get the latest Font Awesome version from the github API.
534
+         *
535
+         * @since 1.0.7
536
+         * @return string The latest version number or `0` on API fail.
537
+         */
538
+        public function get_latest_version_from_api() {
539
+            $version  = "0";
540
+            $response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
541
+            if ( ! is_wp_error( $response ) && is_array( $response ) ) {
542
+                $api_response = json_decode( wp_remote_retrieve_body( $response ), true );
543
+                if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
544
+                    $version = $api_response['tag_name'];
545
+                }
546
+            }
547
+
548
+            return $version;
549
+        }
550
+
551
+    }
552
+
553
+    /**
554
+     * Run the class if found.
555
+     */
556
+    WP_Font_Awesome_Settings::instance();
557 557
 }
558 558
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
 /**
13 13
  * Bail if we are not in WP.
14 14
  */
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if (!defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
19 19
 /**
20 20
  * Only add if the class does not already exist.
21 21
  */
22
-if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) {
22
+if (!class_exists('WP_Font_Awesome_Settings')) {
23 23
 
24 24
 	/**
25 25
 	 * A Class to be able to change settings for Font Awesome.
@@ -87,17 +87,17 @@  discard block
 block discarded – undo
87 87
 		 * @return WP_Font_Awesome_Settings - Main instance.
88 88
 		 */
89 89
 		public static function instance() {
90
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
90
+			if (!isset(self::$instance) && !(self::$instance instanceof WP_Font_Awesome_Settings)) {
91 91
 				self::$instance = new WP_Font_Awesome_Settings;
92 92
 
93
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
93
+				add_action('init', array(self::$instance, 'init')); // set settings
94 94
 
95
-				if ( is_admin() ) {
96
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
97
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
95
+				if (is_admin()) {
96
+					add_action('admin_menu', array(self::$instance, 'menu_item'));
97
+					add_action('admin_init', array(self::$instance, 'register_settings'));
98 98
 				}
99 99
 
100
-				do_action( 'wp_font_awesome_settings_loaded' );
100
+				do_action('wp_font_awesome_settings_loaded');
101 101
 			}
102 102
 
103 103
 			return self::$instance;
@@ -111,30 +111,30 @@  discard block
 block discarded – undo
111 111
 		public function init() {
112 112
 			$this->settings = $this->get_settings();
113 113
 
114
-			if ( $this->settings['type'] == 'CSS' ) {
114
+			if ($this->settings['type'] == 'CSS') {
115 115
 
116
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
117
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
116
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') {
117
+					add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), 5000);
118 118
 				}
119 119
 
120
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
121
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
120
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') {
121
+					add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 5000);
122 122
 				}
123 123
 
124 124
 			} else {
125 125
 
126
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
127
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
126
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') {
127
+					add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 5000);
128 128
 				}
129 129
 
130
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
131
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
130
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') {
131
+					add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 5000);
132 132
 				}
133 133
 			}
134 134
 
135 135
 			// remove font awesome if set to do so
136
-			if ( $this->settings['dequeue'] == '1' ) {
137
-				add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
136
+			if ($this->settings['dequeue'] == '1') {
137
+				add_action('clean_url', array($this, 'remove_font_awesome'), 5000, 3);
138 138
 			}
139 139
 
140 140
 		}
@@ -146,15 +146,15 @@  discard block
 block discarded – undo
146 146
 			// build url
147 147
 			$url = $this->get_url();
148 148
 
149
-			wp_deregister_style( 'font-awesome' ); // deregister in case its already there
150
-			wp_register_style( 'font-awesome', $url, array(), null );
151
-			wp_enqueue_style( 'font-awesome' );
149
+			wp_deregister_style('font-awesome'); // deregister in case its already there
150
+			wp_register_style('font-awesome', $url, array(), null);
151
+			wp_enqueue_style('font-awesome');
152 152
 
153
-			if ( $this->settings['shims'] ) {
154
-				$url = $this->get_url( true );
155
-				wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
156
-				wp_register_style( 'font-awesome-shims', $url, array(), null );
157
-				wp_enqueue_style( 'font-awesome-shims' );
153
+			if ($this->settings['shims']) {
154
+				$url = $this->get_url(true);
155
+				wp_deregister_style('font-awesome-shims'); // deregister in case its already there
156
+				wp_register_style('font-awesome-shims', $url, array(), null);
157
+				wp_enqueue_style('font-awesome-shims');
158 158
 			}
159 159
 		}
160 160
 
@@ -166,15 +166,15 @@  discard block
 block discarded – undo
166 166
 			$url = $this->get_url();
167 167
 
168 168
 			$deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script';
169
-			call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
170
-			wp_register_script( 'font-awesome', $url, array(), null );
171
-			wp_enqueue_script( 'font-awesome' );
172
-
173
-			if ( $this->settings['shims'] ) {
174
-				$url = $this->get_url( true );
175
-				call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
176
-				wp_register_script( 'font-awesome-shims', $url, array(), null );
177
-				wp_enqueue_script( 'font-awesome-shims' );
169
+			call_user_func($deregister_function, 'font-awesome'); // deregister in case its already there
170
+			wp_register_script('font-awesome', $url, array(), null);
171
+			wp_enqueue_script('font-awesome');
172
+
173
+			if ($this->settings['shims']) {
174
+				$url = $this->get_url(true);
175
+				call_user_func($deregister_function, 'font-awesome-shims'); // deregister in case its already there
176
+				wp_register_script('font-awesome-shims', $url, array(), null);
177
+				wp_enqueue_script('font-awesome-shims');
178 178
 			}
179 179
 		}
180 180
 
@@ -185,16 +185,16 @@  discard block
 block discarded – undo
185 185
 		 *
186 186
 		 * @return string The url to the file.
187 187
 		 */
188
-		public function get_url( $shims = false ) {
188
+		public function get_url($shims = false) {
189 189
 			$script  = $shims ? 'v4-shims' : 'all';
190 190
 			$sub     = $this->settings['pro'] ? 'pro' : 'use';
191 191
 			$type    = $this->settings['type'];
192 192
 			$version = $this->settings['version'];
193
-			$kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : '';
193
+			$kit_url = $this->settings['kit-url'] ? esc_url($this->settings['kit-url']) : '';
194 194
 			$url     = '';
195 195
 
196
-			if ( $type == 'KIT' && $kit_url ) {
197
-				if ( $shims ) {
196
+			if ($type == 'KIT' && $kit_url) {
197
+				if ($shims) {
198 198
 					// if its a kit then we don't add shims here
199 199
 					return '';
200 200
 				}
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 				$url .= "?wpfas=true"; // set our var so our version is not removed
203 203
 			} else {
204 204
 				$url .= "https://$sub.fontawesome.com/releases/"; // CDN
205
-				$url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
205
+				$url .= !empty($version) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
206 206
 				$url .= $type == 'CSS' ? 'css/' : 'js/'; // type
207 207
 				$url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
208 208
 				$url .= "?wpfas=true"; // set our var so our version is not removed
@@ -222,16 +222,16 @@  discard block
 block discarded – undo
222 222
 		 *
223 223
 		 * @return string The filtered url.
224 224
 		 */
225
-		public function remove_font_awesome( $url, $original_url, $_context ) {
225
+		public function remove_font_awesome($url, $original_url, $_context) {
226 226
 
227
-			if ( $_context == 'display'
228
-			     && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
229
-			     && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
227
+			if ($_context == 'display'
228
+			     && (strstr($url, "fontawesome") !== false || strstr($url, "font-awesome") !== false)
229
+			     && (strstr($url, ".js") !== false || strstr($url, ".css") !== false)
230 230
 			) {// it's a font-awesome-url (probably)
231 231
 
232
-				if ( strstr( $url, "wpfas=true" ) !== false ) {
233
-					if ( $this->settings['type'] == 'JS' ) {
234
-						if ( $this->settings['js-pseudo'] ) {
232
+				if (strstr($url, "wpfas=true") !== false) {
233
+					if ($this->settings['type'] == 'JS') {
234
+						if ($this->settings['js-pseudo']) {
235 235
 							$url .= "' data-search-pseudo-elements defer='defer";
236 236
 						} else {
237 237
 							$url .= "' defer='defer";
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 		 * Register the database settings with WordPress.
251 251
 		 */
252 252
 		public function register_settings() {
253
-			register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
253
+			register_setting('wp-font-awesome-settings', 'wp-font-awesome-settings');
254 254
 		}
255 255
 
256 256
 		/**
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
 		 */
260 260
 		public function menu_item() {
261 261
 			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
262
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
262
+			call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
263 263
 				$this,
264 264
 				'settings_page'
265
-			) );
265
+			));
266 266
 		}
267 267
 
268 268
 		/**
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 		 */
273 273
 		public function get_settings() {
274 274
 
275
-			$db_settings = get_option( 'wp-font-awesome-settings' );
275
+			$db_settings = get_option('wp-font-awesome-settings');
276 276
 
277 277
 			$defaults = array(
278 278
 				'type'      => 'CSS', // type to use, CSS or JS or KIT
@@ -285,14 +285,14 @@  discard block
 block discarded – undo
285 285
 				'kit-url'   => '', // the kit url
286 286
 			);
287 287
 
288
-			$settings = wp_parse_args( $db_settings, $defaults );
288
+			$settings = wp_parse_args($db_settings, $defaults);
289 289
 
290 290
 			/**
291 291
 			 * Filter the Font Awesome settings.
292 292
 			 *
293 293
 			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
294 294
 			 */
295
-			return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
295
+			return $this->settings = apply_filters('wp-font-awesome-settings', $settings, $db_settings, $defaults);
296 296
 		}
297 297
 
298 298
 
@@ -300,13 +300,13 @@  discard block
 block discarded – undo
300 300
 		 * The settings page html output.
301 301
 		 */
302 302
 		public function settings_page() {
303
-			if ( ! current_user_can( 'manage_options' ) ) {
304
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) );
303
+			if (!current_user_can('manage_options')) {
304
+				wp_die(__('You do not have sufficient permissions to access this page.', 'font-awesome-settings'));
305 305
 			}
306 306
 
307 307
 			// a hidden way to force the update of the verison number vai api instead of waiting the 48 hours
308
-			if ( isset( $_REQUEST['force-version-check'] ) ) {
309
-				$this->get_latest_version( $force_api = true );
308
+			if (isset($_REQUEST['force-version-check'])) {
309
+				$this->get_latest_version($force_api = true);
310 310
 			}
311 311
 			?>
312 312
 			<style>
@@ -326,37 +326,37 @@  discard block
 block discarded – undo
326 326
 				<h1><?php echo $this->name; ?></h1>
327 327
 				<form method="post" action="options.php">
328 328
 					<?php
329
-					settings_fields( 'wp-font-awesome-settings' );
330
-					do_settings_sections( 'wp-font-awesome-settings' );
329
+					settings_fields('wp-font-awesome-settings');
330
+					do_settings_sections('wp-font-awesome-settings');
331 331
 					$kit_set = $this->settings['type'] == 'KIT' ? 'wpfas-kit-set' : '';
332 332
 					?>
333
-					<table class="form-table wpfas-table-settings <?php echo esc_attr( $kit_set ); ?>">
333
+					<table class="form-table wpfas-table-settings <?php echo esc_attr($kit_set); ?>">
334 334
 						<tr valign="top">
335 335
 							<th scope="row"><label
336
-									for="wpfas-type"><?php _e( 'Type', 'font-awesome-settings' ); ?></label></th>
336
+									for="wpfas-type"><?php _e('Type', 'font-awesome-settings'); ?></label></th>
337 337
 							<td>
338 338
 								<select name="wp-font-awesome-settings[type]" id="wpfas-type"
339 339
 								        onchange="if(this.value=='KIT'){jQuery('.wpfas-table-settings').addClass('wpfas-kit-set');}else{jQuery('.wpfas-table-settings').removeClass('wpfas-kit-set');}">
340 340
 									<option
341
-										value="CSS" <?php selected( $this->settings['type'], 'CSS' ); ?>><?php _e( 'CSS (default)', 'font-awesome-settings' ); ?></option>
342
-									<option value="JS" <?php selected( $this->settings['type'], 'JS' ); ?>>JS</option>
341
+										value="CSS" <?php selected($this->settings['type'], 'CSS'); ?>><?php _e('CSS (default)', 'font-awesome-settings'); ?></option>
342
+									<option value="JS" <?php selected($this->settings['type'], 'JS'); ?>>JS</option>
343 343
 									<option
344
-										value="KIT" <?php selected( $this->settings['type'], 'KIT' ); ?>><?php _e( 'Kits (settings managed on fontawesome.com)', 'font-awesome-settings' ); ?></option>
344
+										value="KIT" <?php selected($this->settings['type'], 'KIT'); ?>><?php _e('Kits (settings managed on fontawesome.com)', 'font-awesome-settings'); ?></option>
345 345
 								</select>
346 346
 							</td>
347 347
 						</tr>
348 348
 
349 349
 						<tr valign="top" class="wpfas-kit-show">
350 350
 							<th scope="row"><label
351
-									for="wpfas-kit-url"><?php _e( 'Kit URL', 'font-awesome-settings' ); ?></label></th>
351
+									for="wpfas-kit-url"><?php _e('Kit URL', 'font-awesome-settings'); ?></label></th>
352 352
 							<td>
353 353
 								<input class="regular-text" id="wpfas-kit-url" type="url"
354 354
 								       name="wp-font-awesome-settings[kit-url]"
355
-								       value="<?php echo esc_attr( $this->settings['kit-url'] ); ?>"
355
+								       value="<?php echo esc_attr($this->settings['kit-url']); ?>"
356 356
 								       placeholder="https://kit.fontawesome.com/123abc.js"/>
357 357
 								<span><?php
358 358
 									echo sprintf(
359
-										__( 'Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings' ),
359
+										__('Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings'),
360 360
 										'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>',
361 361
 										'</a>'
362 362
 									);
@@ -366,31 +366,31 @@  discard block
 block discarded – undo
366 366
 
367 367
 						<tr valign="top" class="wpfas-kit-hide">
368 368
 							<th scope="row"><label
369
-									for="wpfas-version"><?php _e( 'Version', 'font-awesome-settings' ); ?></label></th>
369
+									for="wpfas-version"><?php _e('Version', 'font-awesome-settings'); ?></label></th>
370 370
 							<td>
371 371
 								<select name="wp-font-awesome-settings[version]" id="wpfas-version">
372 372
 									<option
373
-										value="" <?php selected( $this->settings['version'], '' ); ?>><?php echo sprintf( __( 'Latest - %s (default)', 'font-awesome-settings' ), $this->get_latest_version() ); ?>
373
+										value="" <?php selected($this->settings['version'], ''); ?>><?php echo sprintf(__('Latest - %s (default)', 'font-awesome-settings'), $this->get_latest_version()); ?>
374 374
 									</option>
375
-									<option value="5.6.0" <?php selected( $this->settings['version'], '5.6.0' ); ?>>
375
+									<option value="5.6.0" <?php selected($this->settings['version'], '5.6.0'); ?>>
376 376
 										5.6.0
377 377
 									</option>
378
-									<option value="5.5.0" <?php selected( $this->settings['version'], '5.5.0' ); ?>>
378
+									<option value="5.5.0" <?php selected($this->settings['version'], '5.5.0'); ?>>
379 379
 										5.5.0
380 380
 									</option>
381
-									<option value="5.4.0" <?php selected( $this->settings['version'], '5.4.0' ); ?>>
381
+									<option value="5.4.0" <?php selected($this->settings['version'], '5.4.0'); ?>>
382 382
 										5.4.0
383 383
 									</option>
384
-									<option value="5.3.0" <?php selected( $this->settings['version'], '5.3.0' ); ?>>
384
+									<option value="5.3.0" <?php selected($this->settings['version'], '5.3.0'); ?>>
385 385
 										5.3.0
386 386
 									</option>
387
-									<option value="5.2.0" <?php selected( $this->settings['version'], '5.2.0' ); ?>>
387
+									<option value="5.2.0" <?php selected($this->settings['version'], '5.2.0'); ?>>
388 388
 										5.2.0
389 389
 									</option>
390
-									<option value="5.1.0" <?php selected( $this->settings['version'], '5.1.0' ); ?>>
390
+									<option value="5.1.0" <?php selected($this->settings['version'], '5.1.0'); ?>>
391 391
 										5.1.0
392 392
 									</option>
393
-									<option value="4.7.0" <?php selected( $this->settings['version'], '4.7.0' ); ?>>
393
+									<option value="4.7.0" <?php selected($this->settings['version'], '4.7.0'); ?>>
394 394
 										4.7.1 (CSS only)
395 395
 									</option>
396 396
 								</select>
@@ -399,29 +399,29 @@  discard block
 block discarded – undo
399 399
 
400 400
 						<tr valign="top">
401 401
 							<th scope="row"><label
402
-									for="wpfas-enqueue"><?php _e( 'Enqueue', 'font-awesome-settings' ); ?></label></th>
402
+									for="wpfas-enqueue"><?php _e('Enqueue', 'font-awesome-settings'); ?></label></th>
403 403
 							<td>
404 404
 								<select name="wp-font-awesome-settings[enqueue]" id="wpfas-enqueue">
405 405
 									<option
406
-										value="" <?php selected( $this->settings['enqueue'], '' ); ?>><?php _e( 'Frontend + Backend (default)', 'font-awesome-settings' ); ?></option>
406
+										value="" <?php selected($this->settings['enqueue'], ''); ?>><?php _e('Frontend + Backend (default)', 'font-awesome-settings'); ?></option>
407 407
 									<option
408
-										value="frontend" <?php selected( $this->settings['enqueue'], 'frontend' ); ?>><?php _e( 'Frontend', 'font-awesome-settings' ); ?></option>
408
+										value="frontend" <?php selected($this->settings['enqueue'], 'frontend'); ?>><?php _e('Frontend', 'font-awesome-settings'); ?></option>
409 409
 									<option
410
-										value="backend" <?php selected( $this->settings['enqueue'], 'backend' ); ?>><?php _e( 'Backend', 'font-awesome-settings' ); ?></option>
410
+										value="backend" <?php selected($this->settings['enqueue'], 'backend'); ?>><?php _e('Backend', 'font-awesome-settings'); ?></option>
411 411
 								</select>
412 412
 							</td>
413 413
 						</tr>
414 414
 
415 415
 						<tr valign="top" class="wpfas-kit-hide">
416 416
 							<th scope="row"><label
417
-									for="wpfas-pro"><?php _e( 'Enable pro', 'font-awesome-settings' ); ?></label></th>
417
+									for="wpfas-pro"><?php _e('Enable pro', 'font-awesome-settings'); ?></label></th>
418 418
 							<td>
419 419
 								<input type="hidden" name="wp-font-awesome-settings[pro]" value="0"/>
420 420
 								<input type="checkbox" name="wp-font-awesome-settings[pro]"
421
-								       value="1" <?php checked( $this->settings['pro'], '1' ); ?> id="wpfas-pro"/>
421
+								       value="1" <?php checked($this->settings['pro'], '1'); ?> id="wpfas-pro"/>
422 422
 								<span><?php
423 423
 									echo sprintf(
424
-										__( 'Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings' ),
424
+										__('Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings'),
425 425
 										'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/pro"><i class="fas fa-external-link-alt"></i>',
426 426
 										'</a>',
427 427
 										'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn"><i class="fas fa-external-link-alt"></i>',
@@ -433,38 +433,38 @@  discard block
 block discarded – undo
433 433
 
434 434
 						<tr valign="top" class="wpfas-kit-hide">
435 435
 							<th scope="row"><label
436
-									for="wpfas-shims"><?php _e( 'Enable v4 shims compatibility', 'font-awesome-settings' ); ?></label>
436
+									for="wpfas-shims"><?php _e('Enable v4 shims compatibility', 'font-awesome-settings'); ?></label>
437 437
 							</th>
438 438
 							<td>
439 439
 								<input type="hidden" name="wp-font-awesome-settings[shims]" value="0"/>
440 440
 								<input type="checkbox" name="wp-font-awesome-settings[shims]"
441
-								       value="1" <?php checked( $this->settings['shims'], '1' ); ?> id="wpfas-shims"/>
442
-								<span><?php _e( 'This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'font-awesome-settings' ); ?></span>
441
+								       value="1" <?php checked($this->settings['shims'], '1'); ?> id="wpfas-shims"/>
442
+								<span><?php _e('This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'font-awesome-settings'); ?></span>
443 443
 							</td>
444 444
 						</tr>
445 445
 
446 446
 						<tr valign="top" class="wpfas-kit-hide">
447 447
 							<th scope="row"><label
448
-									for="wpfas-js-pseudo"><?php _e( 'Enable JS pseudo elements (not recommended)', 'font-awesome-settings' ); ?></label>
448
+									for="wpfas-js-pseudo"><?php _e('Enable JS pseudo elements (not recommended)', 'font-awesome-settings'); ?></label>
449 449
 							</th>
450 450
 							<td>
451 451
 								<input type="hidden" name="wp-font-awesome-settings[js-pseudo]" value="0"/>
452 452
 								<input type="checkbox" name="wp-font-awesome-settings[js-pseudo]"
453
-								       value="1" <?php checked( $this->settings['js-pseudo'], '1' ); ?>
453
+								       value="1" <?php checked($this->settings['js-pseudo'], '1'); ?>
454 454
 								       id="wpfas-js-pseudo"/>
455
-								<span><?php _e( 'Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'font-awesome-settings' ); ?></span>
455
+								<span><?php _e('Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'font-awesome-settings'); ?></span>
456 456
 							</td>
457 457
 						</tr>
458 458
 
459 459
 						<tr valign="top">
460 460
 							<th scope="row"><label
461
-									for="wpfas-dequeue"><?php _e( 'Dequeue', 'font-awesome-settings' ); ?></label></th>
461
+									for="wpfas-dequeue"><?php _e('Dequeue', 'font-awesome-settings'); ?></label></th>
462 462
 							<td>
463 463
 								<input type="hidden" name="wp-font-awesome-settings[dequeue]" value="0"/>
464 464
 								<input type="checkbox" name="wp-font-awesome-settings[dequeue]"
465
-								       value="1" <?php checked( $this->settings['dequeue'], '1' ); ?>
465
+								       value="1" <?php checked($this->settings['dequeue'], '1'); ?>
466 466
 								       id="wpfas-dequeue"/>
467
-								<span><?php _e( 'This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'font-awesome-settings' ); ?></span>
467
+								<span><?php _e('This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'font-awesome-settings'); ?></span>
468 468
 							</td>
469 469
 						</tr>
470 470
 
@@ -489,12 +489,12 @@  discard block
 block discarded – undo
489 489
 		 *
490 490
 		 * @return string Either a valid version number or an empty string.
491 491
 		 */
492
-		public function validate_version_number( $version ) {
492
+		public function validate_version_number($version) {
493 493
 
494
-			if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
494
+			if (version_compare($version, '0.0.1', '>=') >= 0) {
495 495
 				// valid
496 496
 			} else {
497
-				$version = '';// not validated
497
+				$version = ''; // not validated
498 498
 			}
499 499
 
500 500
 			return $version;
@@ -509,19 +509,19 @@  discard block
 block discarded – undo
509 509
 		 * @since 1.0.7
510 510
 		 * @return mixed|string The latest version number found.
511 511
 		 */
512
-		public function get_latest_version( $force_api = false ) {
512
+		public function get_latest_version($force_api = false) {
513 513
 			$latest_version = $this->latest;
514 514
 
515
-			$cache = get_transient( 'wp-font-awesome-settings-version' );
515
+			$cache = get_transient('wp-font-awesome-settings-version');
516 516
 
517
-			if ( $cache === false || $force_api ) { // its not set
517
+			if ($cache === false || $force_api) { // its not set
518 518
 				$api_ver = $this->get_latest_version_from_api();
519
-				if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
519
+				if (version_compare($api_ver, $this->latest, '>=') >= 0) {
520 520
 					$latest_version = $api_ver;
521
-					set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
521
+					set_transient('wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS);
522 522
 				}
523
-			} elseif ( $this->validate_version_number( $cache ) ) {
524
-				if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
523
+			} elseif ($this->validate_version_number($cache)) {
524
+				if (version_compare($cache, $this->latest, '>=') >= 0) {
525 525
 					$latest_version = $cache;
526 526
 				}
527 527
 			}
@@ -537,10 +537,10 @@  discard block
 block discarded – undo
537 537
 		 */
538 538
 		public function get_latest_version_from_api() {
539 539
 			$version  = "0";
540
-			$response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
541
-			if ( ! is_wp_error( $response ) && is_array( $response ) ) {
542
-				$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
543
-				if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
540
+			$response = wp_remote_get("https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest");
541
+			if (!is_wp_error($response) && is_array($response)) {
542
+				$api_response = json_decode(wp_remote_retrieve_body($response), true);
543
+				if (isset($api_response['tag_name']) && version_compare($api_response['tag_name'], $this->latest, '>=') >= 0 && empty($api_response['prerelease'])) {
544 544
 					$version = $api_response['tag_name'];
545 545
 				}
546 546
 			}
Please login to merge, or discard this patch.
includes/class-wpinv-session-handler.php 3 patches
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -130,6 +130,10 @@  discard block
 block discarded – undo
130 130
 		}
131 131
 	}
132 132
 
133
+	/**
134
+	 * @param string $name
135
+	 * @param string $value
136
+	 */
133 137
 	public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false){
134 138
         if ( ! headers_sent() ) {
135 139
             setcookie( $name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters( 'wpinv_cookie_httponly', $httponly, $name, $value, $expire, $secure ) );
@@ -274,7 +278,7 @@  discard block
 block discarded – undo
274 278
 	 * When a user is logged out, ensure they have a unique nonce by using the customer/session ID.
275 279
 	 *
276 280
 	 * @param int $uid User ID.
277
-	 * @return string
281
+	 * @return integer
278 282
 	 */
279 283
 	public function nonce_user_logged_out( $uid ) {
280 284
 		return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid;
Please login to merge, or discard this patch.
Indentation   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -12,124 +12,124 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class WPInv_Session_Handler extends WPInv_Session {
14 14
 
15
-	/**
16
-	 * Cookie name used for the session.
17
-	 *
18
-	 * @var string cookie name
19
-	 */
20
-	protected $_cookie;
21
-
22
-	/**
23
-	 * Stores session expiry.
24
-	 *
25
-	 * @var int session due to expire timestamp
26
-	 */
27
-	protected $_session_expiring;
28
-
29
-	/**
30
-	 * Stores session due to expire timestamp.
31
-	 *
32
-	 * @var string session expiration timestamp
33
-	 */
34
-	protected $_session_expiration;
35
-
36
-	/**
37
-	 * True when the cookie exists.
38
-	 *
39
-	 * @var bool Based on whether a cookie exists.
40
-	 */
41
-	protected $_has_cookie = false;
42
-
43
-	/**
44
-	 * Table name for session data.
45
-	 *
46
-	 * @var string Custom session table name
47
-	 */
48
-	protected $_table;
49
-
50
-	/**
51
-	 * Constructor for the session class.
52
-	 */
53
-	public function __construct() {
54
-
55
-	    $this->_cookie = apply_filters( 'wpinv_cookie', 'wpinv_session_' . COOKIEHASH );
15
+    /**
16
+     * Cookie name used for the session.
17
+     *
18
+     * @var string cookie name
19
+     */
20
+    protected $_cookie;
21
+
22
+    /**
23
+     * Stores session expiry.
24
+     *
25
+     * @var int session due to expire timestamp
26
+     */
27
+    protected $_session_expiring;
28
+
29
+    /**
30
+     * Stores session due to expire timestamp.
31
+     *
32
+     * @var string session expiration timestamp
33
+     */
34
+    protected $_session_expiration;
35
+
36
+    /**
37
+     * True when the cookie exists.
38
+     *
39
+     * @var bool Based on whether a cookie exists.
40
+     */
41
+    protected $_has_cookie = false;
42
+
43
+    /**
44
+     * Table name for session data.
45
+     *
46
+     * @var string Custom session table name
47
+     */
48
+    protected $_table;
49
+
50
+    /**
51
+     * Constructor for the session class.
52
+     */
53
+    public function __construct() {
54
+
55
+        $this->_cookie = apply_filters( 'wpinv_cookie', 'wpinv_session_' . COOKIEHASH );
56 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
-	}
61
-
62
-	/**
63
-	 * Init hooks and session data.
64
-	 *
65
-	 * @since 3.3.0
66
-	 */
67
-	public function init() {
68
-		$this->init_session_cookie();
69
-
70
-		if ( ! is_user_logged_in() ) {
71
-			add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ) );
72
-		}
73
-	}
74
-
75
-	/**
76
-	 * Setup cookie and customer ID.
77
-	 *
78
-	 * @since 3.6.0
79
-	 */
80
-	public function init_session_cookie() {
81
-		$cookie = $this->get_session_cookie();
82
-
83
-		if ( $cookie ) {
84
-			$this->_customer_id        = $cookie[0];
85
-			$this->_session_expiration = $cookie[1];
86
-			$this->_session_expiring   = $cookie[2];
87
-			$this->_has_cookie         = true;
88
-			$this->_data               = $this->get_session_data();
89
-
90
-			// If the user logs in, update session.
91
-			if ( is_user_logged_in() && get_current_user_id() != $this->_customer_id ) {
92
-				$this->_customer_id = get_current_user_id();
93
-				$this->_dirty       = true;
94
-				$this->save_data();
95
-				$this->set_customer_session_cookie( true );
96
-			}
97
-
98
-			// Update session if its close to expiring.
99
-			if ( time() > $this->_session_expiring ) {
100
-				$this->set_session_expiration();
101
-				$this->update_session_timestamp( $this->_customer_id, $this->_session_expiration );
102
-			}
103
-		} else {
104
-			$this->set_session_expiration();
105
-			$this->_customer_id = $this->generate_customer_id();
106
-			$this->_data        = $this->get_session_data();
107
-		}
108
-	}
109
-
110
-	/**
111
-	 * Sets the session cookie on-demand (usually after adding an item to the cart).
112
-	 *
113
-	 * Since the cookie name (as of 2.1) is prepended with wp, cache systems like batcache will not cache pages when set.
114
-	 *
115
-	 * Warning: Cookies will only be set if this is called before the headers are sent.
116
-	 *
117
-	 * @param bool $set Should the session cookie be set.
118
-	 */
119
-	public function set_customer_session_cookie( $set ) {
120
-		if ( $set ) {
121
-			$to_hash           = $this->_customer_id . '|' . $this->_session_expiration;
122
-			$cookie_hash       = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
123
-			$cookie_value      = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash;
124
-			$this->_has_cookie = true;
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 );
128
-			}
129
-		}
130
-	}
131
-
132
-	public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false){
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
+    }
61
+
62
+    /**
63
+     * Init hooks and session data.
64
+     *
65
+     * @since 3.3.0
66
+     */
67
+    public function init() {
68
+        $this->init_session_cookie();
69
+
70
+        if ( ! is_user_logged_in() ) {
71
+            add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ) );
72
+        }
73
+    }
74
+
75
+    /**
76
+     * Setup cookie and customer ID.
77
+     *
78
+     * @since 3.6.0
79
+     */
80
+    public function init_session_cookie() {
81
+        $cookie = $this->get_session_cookie();
82
+
83
+        if ( $cookie ) {
84
+            $this->_customer_id        = $cookie[0];
85
+            $this->_session_expiration = $cookie[1];
86
+            $this->_session_expiring   = $cookie[2];
87
+            $this->_has_cookie         = true;
88
+            $this->_data               = $this->get_session_data();
89
+
90
+            // If the user logs in, update session.
91
+            if ( is_user_logged_in() && get_current_user_id() != $this->_customer_id ) {
92
+                $this->_customer_id = get_current_user_id();
93
+                $this->_dirty       = true;
94
+                $this->save_data();
95
+                $this->set_customer_session_cookie( true );
96
+            }
97
+
98
+            // Update session if its close to expiring.
99
+            if ( time() > $this->_session_expiring ) {
100
+                $this->set_session_expiration();
101
+                $this->update_session_timestamp( $this->_customer_id, $this->_session_expiration );
102
+            }
103
+        } else {
104
+            $this->set_session_expiration();
105
+            $this->_customer_id = $this->generate_customer_id();
106
+            $this->_data        = $this->get_session_data();
107
+        }
108
+    }
109
+
110
+    /**
111
+     * Sets the session cookie on-demand (usually after adding an item to the cart).
112
+     *
113
+     * Since the cookie name (as of 2.1) is prepended with wp, cache systems like batcache will not cache pages when set.
114
+     *
115
+     * Warning: Cookies will only be set if this is called before the headers are sent.
116
+     *
117
+     * @param bool $set Should the session cookie be set.
118
+     */
119
+    public function set_customer_session_cookie( $set ) {
120
+        if ( $set ) {
121
+            $to_hash           = $this->_customer_id . '|' . $this->_session_expiration;
122
+            $cookie_hash       = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
123
+            $cookie_value      = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash;
124
+            $this->_has_cookie = true;
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 );
128
+            }
129
+        }
130
+    }
131
+
132
+    public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false){
133 133
         if ( ! headers_sent() ) {
134 134
             setcookie( $name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters( 'wpinv_cookie_httponly', $httponly, $name, $value, $expire, $secure ) );
135 135
         } elseif ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
@@ -138,96 +138,96 @@  discard block
 block discarded – undo
138 138
         }
139 139
     }
140 140
 
141
-	/**
142
-	 * Should the session cookie be secure?
143
-	 *
144
-	 * @since 3.6.0
145
-	 * @return bool
146
-	 */
147
-	protected function use_secure_cookie() {
141
+    /**
142
+     * Should the session cookie be secure?
143
+     *
144
+     * @since 3.6.0
145
+     * @return bool
146
+     */
147
+    protected function use_secure_cookie() {
148 148
         $is_https = false !== strstr( get_option( 'home' ), 'https:' );
149
-		return apply_filters( 'wpinv_session_use_secure_cookie', $is_https && is_ssl() );
150
-	}
151
-
152
-	/**
153
-	 * Return true if the current user has an active session, i.e. a cookie to retrieve values.
154
-	 *
155
-	 * @return bool
156
-	 */
157
-	public function has_session() {
158
-		return isset( $_COOKIE[ $this->_cookie ] ) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine.
159
-	}
160
-
161
-	/**
162
-	 * Set session expiration.
163
-	 */
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.
167
-	}
168
-
169
-	/**
170
-	 * Generate a unique customer ID for guests, or return user ID if logged in.
171
-	 *
172
-	 * Uses Portable PHP password hashing framework to generate a unique cryptographically strong ID.
173
-	 *
174
-	 * @return string
175
-	 */
176
-	public function generate_customer_id() {
177
-		$customer_id = '';
178
-
179
-		if ( is_user_logged_in() ) {
180
-			$customer_id = get_current_user_id();
181
-		}
182
-
183
-		if ( empty( $customer_id ) ) {
149
+        return apply_filters( 'wpinv_session_use_secure_cookie', $is_https && is_ssl() );
150
+    }
151
+
152
+    /**
153
+     * Return true if the current user has an active session, i.e. a cookie to retrieve values.
154
+     *
155
+     * @return bool
156
+     */
157
+    public function has_session() {
158
+        return isset( $_COOKIE[ $this->_cookie ] ) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine.
159
+    }
160
+
161
+    /**
162
+     * Set session expiration.
163
+     */
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.
167
+    }
168
+
169
+    /**
170
+     * Generate a unique customer ID for guests, or return user ID if logged in.
171
+     *
172
+     * Uses Portable PHP password hashing framework to generate a unique cryptographically strong ID.
173
+     *
174
+     * @return string
175
+     */
176
+    public function generate_customer_id() {
177
+        $customer_id = '';
178
+
179
+        if ( is_user_logged_in() ) {
180
+            $customer_id = get_current_user_id();
181
+        }
182
+
183
+        if ( empty( $customer_id ) ) {
184 184
             $customer_id = wp_create_nonce('wpinv-session-customer-id');
185
-		}
186
-
187
-		return $customer_id;
188
-	}
189
-
190
-	/**
191
-	 * Get the session cookie, if set. Otherwise return false.
192
-	 *
193
-	 * Session cookies without a customer ID are invalid.
194
-	 *
195
-	 * @return bool|array
196
-	 */
197
-	public function get_session_cookie() {
198
-		$cookie_value = isset( $_COOKIE[ $this->_cookie ] ) ? wp_unslash( $_COOKIE[ $this->_cookie ] ) : false; // @codingStandardsIgnoreLine.
199
-
200
-		if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) {
201
-			return false;
202
-		}
203
-
204
-		list( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value );
205
-
206
-		if ( empty( $customer_id ) ) {
207
-			return false;
208
-		}
209
-
210
-		// Validate hash.
211
-		$to_hash = $customer_id . '|' . $session_expiration;
212
-		$hash    = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
213
-
214
-		if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) {
215
-			return false;
216
-		}
217
-
218
-		return array( $customer_id, $session_expiration, $session_expiring, $cookie_hash );
219
-	}
220
-
221
-	/**
222
-	 * Get session data.
223
-	 *
224
-	 * @return array
225
-	 */
226
-	public function get_session_data() {
227
-		return $this->has_session() ? (array) $this->get_session( $this->_customer_id ) : array();
228
-	}
229
-
230
-	public function generate_key($customer_id){
185
+        }
186
+
187
+        return $customer_id;
188
+    }
189
+
190
+    /**
191
+     * Get the session cookie, if set. Otherwise return false.
192
+     *
193
+     * Session cookies without a customer ID are invalid.
194
+     *
195
+     * @return bool|array
196
+     */
197
+    public function get_session_cookie() {
198
+        $cookie_value = isset( $_COOKIE[ $this->_cookie ] ) ? wp_unslash( $_COOKIE[ $this->_cookie ] ) : false; // @codingStandardsIgnoreLine.
199
+
200
+        if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) {
201
+            return false;
202
+        }
203
+
204
+        list( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value );
205
+
206
+        if ( empty( $customer_id ) ) {
207
+            return false;
208
+        }
209
+
210
+        // Validate hash.
211
+        $to_hash = $customer_id . '|' . $session_expiration;
212
+        $hash    = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
213
+
214
+        if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) {
215
+            return false;
216
+        }
217
+
218
+        return array( $customer_id, $session_expiration, $session_expiring, $cookie_hash );
219
+    }
220
+
221
+    /**
222
+     * Get session data.
223
+     *
224
+     * @return array
225
+     */
226
+    public function get_session_data() {
227
+        return $this->has_session() ? (array) $this->get_session( $this->_customer_id ) : array();
228
+    }
229
+
230
+    public function generate_key($customer_id){
231 231
         if(!$customer_id){
232 232
             return;
233 233
         }
@@ -235,62 +235,62 @@  discard block
 block discarded – undo
235 235
         return 'wpi_trans_'.$customer_id;
236 236
     }
237 237
 
238
-	/**
239
-	 * Save data.
240
-	 */
241
-	public function save_data() {
242
-		// Dirty if something changed - prevents saving nothing new.
243
-		if ( $this->_dirty && $this->has_session() ) {
238
+    /**
239
+     * Save data.
240
+     */
241
+    public function save_data() {
242
+        // Dirty if something changed - prevents saving nothing new.
243
+        if ( $this->_dirty && $this->has_session() ) {
244 244
 
245 245
             set_transient( $this->generate_key($this->_customer_id), $this->_data, $this->_session_expiration);
246 246
 
247
-			$this->_dirty = false;
248
-		}
249
-	}
250
-
251
-	/**
252
-	 * Destroy all session data.
253
-	 */
254
-	public function destroy_session() {
255
-		$this->delete_session( $this->_customer_id );
256
-		$this->forget_session();
257
-	}
258
-
259
-	/**
260
-	 * Forget all session data without destroying it.
261
-	 */
262
-	public function forget_session() {
263
-		$this->setcookie( $this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true );
264
-
265
-		wpinv_empty_cart();
266
-
267
-		$this->_data        = array();
268
-		$this->_dirty       = false;
269
-		$this->_customer_id = $this->generate_customer_id();
270
-	}
271
-
272
-	/**
273
-	 * When a user is logged out, ensure they have a unique nonce by using the customer/session ID.
274
-	 *
275
-	 * @param int $uid User ID.
276
-	 * @return string
277
-	 */
278
-	public function nonce_user_logged_out( $uid ) {
279
-		return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid;
280
-	}
281
-
282
-	/**
283
-	 * Returns the session.
284
-	 *
285
-	 * @param string $customer_id Customer ID.
286
-	 * @param mixed  $default Default session value.
287
-	 * @return string|array
288
-	 */
289
-	public function get_session( $customer_id, $default = false ) {
290
-
291
-		if ( defined( 'WP_SETUP_CONFIG' ) ) {
292
-			return array();
293
-		}
247
+            $this->_dirty = false;
248
+        }
249
+    }
250
+
251
+    /**
252
+     * Destroy all session data.
253
+     */
254
+    public function destroy_session() {
255
+        $this->delete_session( $this->_customer_id );
256
+        $this->forget_session();
257
+    }
258
+
259
+    /**
260
+     * Forget all session data without destroying it.
261
+     */
262
+    public function forget_session() {
263
+        $this->setcookie( $this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true );
264
+
265
+        wpinv_empty_cart();
266
+
267
+        $this->_data        = array();
268
+        $this->_dirty       = false;
269
+        $this->_customer_id = $this->generate_customer_id();
270
+    }
271
+
272
+    /**
273
+     * When a user is logged out, ensure they have a unique nonce by using the customer/session ID.
274
+     *
275
+     * @param int $uid User ID.
276
+     * @return string
277
+     */
278
+    public function nonce_user_logged_out( $uid ) {
279
+        return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid;
280
+    }
281
+
282
+    /**
283
+     * Returns the session.
284
+     *
285
+     * @param string $customer_id Customer ID.
286
+     * @param mixed  $default Default session value.
287
+     * @return string|array
288
+     */
289
+    public function get_session( $customer_id, $default = false ) {
290
+
291
+        if ( defined( 'WP_SETUP_CONFIG' ) ) {
292
+            return array();
293
+        }
294 294
 
295 295
         if ( !is_user_logged_in() ) {
296 296
             if(!wp_verify_nonce( $customer_id, 'wpinv-session-customer-id' )){
@@ -305,32 +305,32 @@  discard block
 block discarded – undo
305 305
             $value = $default;
306 306
         }
307 307
 
308
-		return maybe_unserialize( $value );
309
-	}
308
+        return maybe_unserialize( $value );
309
+    }
310 310
 
311
-	/**
312
-	 * Delete the session from the cache and database.
313
-	 *
314
-	 * @param int $customer_id Customer ID.
315
-	 */
316
-	public function delete_session( $customer_id ) {
311
+    /**
312
+     * Delete the session from the cache and database.
313
+     *
314
+     * @param int $customer_id Customer ID.
315
+     */
316
+    public function delete_session( $customer_id ) {
317 317
 
318 318
         $key = $this->generate_key($customer_id);
319 319
 
320
-		delete_transient($key);
321
-	}
320
+        delete_transient($key);
321
+    }
322 322
 
323
-	/**
324
-	 * Update the session expiry timestamp.
325
-	 *
326
-	 * @param string $customer_id Customer ID.
327
-	 * @param int    $timestamp Timestamp to expire the cookie.
328
-	 */
329
-	public function update_session_timestamp( $customer_id, $timestamp ) {
323
+    /**
324
+     * Update the session expiry timestamp.
325
+     *
326
+     * @param string $customer_id Customer ID.
327
+     * @param int    $timestamp Timestamp to expire the cookie.
328
+     */
329
+    public function update_session_timestamp( $customer_id, $timestamp ) {
330 330
 
331 331
         set_transient( $this->generate_key($customer_id), maybe_serialize( $this->_data ), $timestamp);
332 332
 
333
-	}
333
+    }
334 334
 }
335 335
 
336 336
 global $wpi_session;
Please login to merge, or discard this 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.
includes/abstracts/abstract-wpinv-privacy.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Abstract privacy class.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * Abstract class that is intended to be extended by
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      *
39 39
      * @param string $name Plugin identifier.
40 40
      */
41
-    public function __construct( $name = '' ) {
41
+    public function __construct($name = '') {
42 42
         $this->name = $name;
43 43
         $this->init();
44 44
     }
@@ -47,22 +47,22 @@  discard block
 block discarded – undo
47 47
      * Hook in events.
48 48
      */
49 49
     protected function init() {
50
-        add_action( 'admin_init', array( $this, 'add_privacy_message' ) );
50
+        add_action('admin_init', array($this, 'add_privacy_message'));
51 51
         // Register data exporters
52
-        add_filter( 'wp_privacy_personal_data_exporters', array( $this, 'register_exporters' ), 10 );
52
+        add_filter('wp_privacy_personal_data_exporters', array($this, 'register_exporters'), 10);
53 53
         // Register data erasers
54
-        add_filter( 'wp_privacy_personal_data_erasers', array( $this, 'register_erasers' ) );
54
+        add_filter('wp_privacy_personal_data_erasers', array($this, 'register_erasers'));
55 55
     }
56 56
 
57 57
     /**
58 58
      * Adds the privacy message on invoicing privacy page.
59 59
      */
60 60
     public function add_privacy_message() {
61
-        if ( function_exists( 'wp_add_privacy_policy_content' ) ) {
61
+        if (function_exists('wp_add_privacy_policy_content')) {
62 62
             $content = $this->get_privacy_message();
63 63
 
64
-            if ( $content ) {
65
-                wp_add_privacy_policy_content( $this->name, $this->get_privacy_message() );
64
+            if ($content) {
65
+                wp_add_privacy_policy_content($this->name, $this->get_privacy_message());
66 66
             }
67 67
         }
68 68
     }
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
      * @param array $exporters List of exporter callbacks.
84 84
      * @return array
85 85
      */
86
-    public function register_exporters( $exporters = array() ) {
87
-        foreach ( $this->exporters as $id => $exporter ) {
88
-            $exporters[ $id ] = $exporter;
86
+    public function register_exporters($exporters = array()) {
87
+        foreach ($this->exporters as $id => $exporter) {
88
+            $exporters[$id] = $exporter;
89 89
         }
90 90
         return $exporters;
91 91
     }
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
      * @param array $erasers List of eraser callbacks.
97 97
      * @return array
98 98
      */
99
-    public function register_erasers( $erasers = array() ) {
100
-        foreach ( $this->erasers as $id => $eraser ) {
101
-            $erasers[ $id ] = $eraser;
99
+    public function register_erasers($erasers = array()) {
100
+        foreach ($this->erasers as $id => $eraser) {
101
+            $erasers[$id] = $eraser;
102 102
         }
103 103
         return $erasers;
104 104
     }
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
      *
113 113
      * @return array
114 114
      */
115
-    public function add_exporter( $id, $name, $callback ) {
116
-        $this->exporters[ $id ] = array(
115
+    public function add_exporter($id, $name, $callback) {
116
+        $this->exporters[$id] = array(
117 117
             'exporter_friendly_name' => $name,
118 118
             'callback'               => $callback,
119 119
         );
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
      *
130 130
      * @return array
131 131
      */
132
-    public function add_eraser( $id, $name, $callback ) {
133
-        $this->erasers[ $id ] = array(
132
+    public function add_eraser($id, $name, $callback) {
133
+        $this->erasers[$id] = array(
134 134
             'eraser_friendly_name' => $name,
135 135
             'callback'             => $callback,
136 136
         );
Please login to merge, or discard this patch.
includes/abstracts/abstract-wpinv-session.php 2 patches
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  */
5 5
 
6 6
 if ( ! defined( 'ABSPATH' ) ) {
7
-	exit;
7
+    exit;
8 8
 }
9 9
 
10 10
 /**
@@ -12,112 +12,112 @@  discard block
 block discarded – undo
12 12
  */
13 13
 abstract class WPInv_Session {
14 14
 
15
-	/**
16
-	 * Customer ID.
17
-	 *
18
-	 * @var int $_customer_id Customer ID.
19
-	 */
20
-	protected $_customer_id;
15
+    /**
16
+     * Customer ID.
17
+     *
18
+     * @var int $_customer_id Customer ID.
19
+     */
20
+    protected $_customer_id;
21 21
 
22
-	/**
23
-	 * Session Data.
24
-	 *
25
-	 * @var array $_data Data array.
26
-	 */
27
-	protected $_data = array();
22
+    /**
23
+     * Session Data.
24
+     *
25
+     * @var array $_data Data array.
26
+     */
27
+    protected $_data = array();
28 28
 
29
-	/**
30
-	 * Dirty when the session needs saving.
31
-	 *
32
-	 * @var bool $_dirty When something changes
33
-	 */
34
-	protected $_dirty = false;
29
+    /**
30
+     * Dirty when the session needs saving.
31
+     *
32
+     * @var bool $_dirty When something changes
33
+     */
34
+    protected $_dirty = false;
35 35
 
36
-	/**
37
-	 * Init hooks and session data. Extended by child classes.
38
-	 *
39
-	 * @since 3.3.0
40
-	 */
41
-	public function init() {}
36
+    /**
37
+     * Init hooks and session data. Extended by child classes.
38
+     *
39
+     * @since 3.3.0
40
+     */
41
+    public function init() {}
42 42
 
43
-	/**
44
-	 * Cleanup session data. Extended by child classes.
45
-	 */
46
-	public function cleanup_sessions() {}
43
+    /**
44
+     * Cleanup session data. Extended by child classes.
45
+     */
46
+    public function cleanup_sessions() {}
47 47
 
48
-	/**
49
-	 * Magic get method.
50
-	 *
51
-	 * @param mixed $key Key to get.
52
-	 * @return mixed
53
-	 */
54
-	public function __get( $key ) {
55
-		return $this->get( $key );
56
-	}
48
+    /**
49
+     * Magic get method.
50
+     *
51
+     * @param mixed $key Key to get.
52
+     * @return mixed
53
+     */
54
+    public function __get( $key ) {
55
+        return $this->get( $key );
56
+    }
57 57
 
58
-	/**
59
-	 * Magic set method.
60
-	 *
61
-	 * @param mixed $key Key to set.
62
-	 * @param mixed $value Value to set.
63
-	 */
64
-	public function __set( $key, $value ) {
65
-		$this->set( $key, $value );
66
-	}
58
+    /**
59
+     * Magic set method.
60
+     *
61
+     * @param mixed $key Key to set.
62
+     * @param mixed $value Value to set.
63
+     */
64
+    public function __set( $key, $value ) {
65
+        $this->set( $key, $value );
66
+    }
67 67
 
68
-	/**
69
-	 * Magic isset method.
70
-	 *
71
-	 * @param mixed $key Key to check.
72
-	 * @return bool
73
-	 */
74
-	public function __isset( $key ) {
75
-		return isset( $this->_data[ sanitize_title( $key ) ] );
76
-	}
68
+    /**
69
+     * Magic isset method.
70
+     *
71
+     * @param mixed $key Key to check.
72
+     * @return bool
73
+     */
74
+    public function __isset( $key ) {
75
+        return isset( $this->_data[ sanitize_title( $key ) ] );
76
+    }
77 77
 
78
-	/**
79
-	 * Magic unset method.
80
-	 *
81
-	 * @param mixed $key Key to unset.
82
-	 */
83
-	public function __unset( $key ) {
84
-		if ( isset( $this->_data[ $key ] ) ) {
85
-			unset( $this->_data[ $key ] );
86
-			$this->_dirty = true;
87
-		}
88
-	}
78
+    /**
79
+     * Magic unset method.
80
+     *
81
+     * @param mixed $key Key to unset.
82
+     */
83
+    public function __unset( $key ) {
84
+        if ( isset( $this->_data[ $key ] ) ) {
85
+            unset( $this->_data[ $key ] );
86
+            $this->_dirty = true;
87
+        }
88
+    }
89 89
 
90
-	/**
91
-	 * Get a session variable.
92
-	 *
93
-	 * @param string $key Key to get.
94
-	 * @param mixed  $default used if the session variable isn't set.
95
-	 * @return array|string value of session variable
96
-	 */
97
-	public function get( $key, $default = null ) {
98
-		$key = sanitize_key( $key );
99
-		return isset( $this->_data[ $key ] ) ? maybe_unserialize( $this->_data[ $key ] ) : $default;
100
-	}
90
+    /**
91
+     * Get a session variable.
92
+     *
93
+     * @param string $key Key to get.
94
+     * @param mixed  $default used if the session variable isn't set.
95
+     * @return array|string value of session variable
96
+     */
97
+    public function get( $key, $default = null ) {
98
+        $key = sanitize_key( $key );
99
+        return isset( $this->_data[ $key ] ) ? maybe_unserialize( $this->_data[ $key ] ) : $default;
100
+    }
101 101
 
102
-	/**
103
-	 * Set a session variable.
104
-	 *
105
-	 * @param string $key Key to set.
106
-	 * @param mixed  $value Value to set.
107
-	 */
108
-	public function set( $key, $value ) {
109
-		if ( $value !== $this->get( $key ) ) {
110
-			$this->_data[ sanitize_key( $key ) ] = maybe_serialize( $value );
111
-			$this->_dirty                        = true;
112
-		}
113
-	}
102
+    /**
103
+     * Set a session variable.
104
+     *
105
+     * @param string $key Key to set.
106
+     * @param mixed  $value Value to set.
107
+     */
108
+    public function set( $key, $value ) {
109
+        if ( $value !== $this->get( $key ) ) {
110
+            $this->_data[ sanitize_key( $key ) ] = maybe_serialize( $value );
111
+            $this->_dirty                        = true;
112
+        }
113
+    }
114 114
 
115
-	/**
116
-	 * Get customer ID.
117
-	 *
118
-	 * @return int
119
-	 */
120
-	public function get_customer_id() {
121
-		return $this->_customer_id;
122
-	}
115
+    /**
116
+     * Get customer ID.
117
+     *
118
+     * @return int
119
+     */
120
+    public function get_customer_id() {
121
+        return $this->_customer_id;
122
+    }
123 123
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Handle data for the current customer session
4 4
  */
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if (!defined('ABSPATH')) {
7 7
 	exit;
8 8
 }
9 9
 
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
 	 * @param mixed $key Key to get.
52 52
 	 * @return mixed
53 53
 	 */
54
-	public function __get( $key ) {
55
-		return $this->get( $key );
54
+	public function __get($key) {
55
+		return $this->get($key);
56 56
 	}
57 57
 
58 58
 	/**
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 	 * @param mixed $key Key to set.
62 62
 	 * @param mixed $value Value to set.
63 63
 	 */
64
-	public function __set( $key, $value ) {
65
-		$this->set( $key, $value );
64
+	public function __set($key, $value) {
65
+		$this->set($key, $value);
66 66
 	}
67 67
 
68 68
 	/**
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 	 * @param mixed $key Key to check.
72 72
 	 * @return bool
73 73
 	 */
74
-	public function __isset( $key ) {
75
-		return isset( $this->_data[ sanitize_title( $key ) ] );
74
+	public function __isset($key) {
75
+		return isset($this->_data[sanitize_title($key)]);
76 76
 	}
77 77
 
78 78
 	/**
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @param mixed $key Key to unset.
82 82
 	 */
83
-	public function __unset( $key ) {
84
-		if ( isset( $this->_data[ $key ] ) ) {
85
-			unset( $this->_data[ $key ] );
83
+	public function __unset($key) {
84
+		if (isset($this->_data[$key])) {
85
+			unset($this->_data[$key]);
86 86
 			$this->_dirty = true;
87 87
 		}
88 88
 	}
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
 	 * @param mixed  $default used if the session variable isn't set.
95 95
 	 * @return array|string value of session variable
96 96
 	 */
97
-	public function get( $key, $default = null ) {
98
-		$key = sanitize_key( $key );
99
-		return isset( $this->_data[ $key ] ) ? maybe_unserialize( $this->_data[ $key ] ) : $default;
97
+	public function get($key, $default = null) {
98
+		$key = sanitize_key($key);
99
+		return isset($this->_data[$key]) ? maybe_unserialize($this->_data[$key]) : $default;
100 100
 	}
101 101
 
102 102
 	/**
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 	 * @param string $key Key to set.
106 106
 	 * @param mixed  $value Value to set.
107 107
 	 */
108
-	public function set( $key, $value ) {
109
-		if ( $value !== $this->get( $key ) ) {
110
-			$this->_data[ sanitize_key( $key ) ] = maybe_serialize( $value );
108
+	public function set($key, $value) {
109
+		if ($value !== $this->get($key)) {
110
+			$this->_data[sanitize_key($key)] = maybe_serialize($value);
111 111
 			$this->_dirty                        = true;
112 112
 		}
113 113
 	}
Please login to merge, or discard this patch.
includes/admin/admin-meta-boxes.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
     add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high' );
30 30
     add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' );
31 31
 
32
-	remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal');
32
+    remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal');
33 33
 }
34 34
 add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 );
35 35
 
Please login to merge, or discard this patch.
Spacing   +149 added lines, -149 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';
@@ -76,96 +76,96 @@  discard block
 block discarded – undo
76 76
             $fields['_wpinv_dynamic_pricing']    = 'wpinv_name_your_price';
77 77
             $fields['_minimum_price']            = 'wpinv_minimum_price';
78 78
             
79
-            if ( !isset( $_POST['wpinv_is_recurring'] ) ) {
79
+            if (!isset($_POST['wpinv_is_recurring'])) {
80 80
                 $_POST['wpinv_is_recurring'] = 0;
81 81
             }
82 82
 
83
-            if ( !isset( $_POST['wpinv_name_your_price'] ) ) {
83
+            if (!isset($_POST['wpinv_name_your_price'])) {
84 84
                 $_POST['wpinv_name_your_price'] = 0;
85 85
             }
86 86
             
87
-            if ( !isset( $_POST['wpinv_free_trial'] ) || empty( $_POST['wpinv_is_recurring'] ) ) {
87
+            if (!isset($_POST['wpinv_free_trial']) || empty($_POST['wpinv_is_recurring'])) {
88 88
                 $_POST['wpinv_free_trial'] = 0;
89 89
             }
90 90
             
91
-            foreach ( $fields as $field => $name ) {
92
-                if ( isset( $_POST[ $name ] ) ) {
93
-                    $allowed = apply_filters( 'wpinv_item_allowed_save_meta_value', true, $field, $post_id );
91
+            foreach ($fields as $field => $name) {
92
+                if (isset($_POST[$name])) {
93
+                    $allowed = apply_filters('wpinv_item_allowed_save_meta_value', true, $field, $post_id);
94 94
 
95
-                    if ( !$allowed ) {
95
+                    if (!$allowed) {
96 96
                         continue;
97 97
                     }
98 98
 
99
-                    if ( $field == '_wpinv_price' ) {
100
-                        $value = wpinv_sanitize_amount( $_POST[ $name ] );
99
+                    if ($field == '_wpinv_price') {
100
+                        $value = wpinv_sanitize_amount($_POST[$name]);
101 101
                     } else {
102
-                        $value = is_string( $_POST[ $name ] ) ? sanitize_text_field( $_POST[ $name ] ) : $_POST[ $name ];
102
+                        $value = is_string($_POST[$name]) ? sanitize_text_field($_POST[$name]) : $_POST[$name];
103 103
                     }
104 104
                     
105
-                    $value = apply_filters( 'wpinv_item_metabox_save_' . $field, $value, $name );
106
-                    update_post_meta( $post_id, $field, $value );
105
+                    $value = apply_filters('wpinv_item_metabox_save_' . $field, $value, $name);
106
+                    update_post_meta($post_id, $field, $value);
107 107
                 }
108 108
             }
109 109
             
110
-            if ( !get_post_meta( $post_id, '_wpinv_custom_id', true ) ) {
111
-                update_post_meta( $post_id, '_wpinv_custom_id', $post_id );
110
+            if (!get_post_meta($post_id, '_wpinv_custom_id', true)) {
111
+                update_post_meta($post_id, '_wpinv_custom_id', $post_id);
112 112
             }
113 113
         }
114 114
     }
115 115
 }
116
-add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 );
116
+add_action('save_post', 'wpinv_save_meta_boxes', 10, 3);
117 117
 
118 118
 function wpinv_register_item_meta_boxes() {    
119 119
     global $wpinv_euvat;
120 120
     
121
-    add_meta_box( 'wpinv_field_prices', __( 'Item Price', 'invoicing' ), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high' );
121
+    add_meta_box('wpinv_field_prices', __('Item Price', 'invoicing'), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high');
122 122
 
123
-    if ( $wpinv_euvat->allow_vat_rules() ) {
124
-        add_meta_box( 'wpinv_field_vat_rules', __( 'VAT rules type to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high' );
123
+    if ($wpinv_euvat->allow_vat_rules()) {
124
+        add_meta_box('wpinv_field_vat_rules', __('VAT rules type to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high');
125 125
     }
126 126
     
127
-    if ( $wpinv_euvat->allow_vat_classes() ) {
128
-        add_meta_box( 'wpinv_field_vat_classes', __( 'VAT rates class to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high' );
127
+    if ($wpinv_euvat->allow_vat_classes()) {
128
+        add_meta_box('wpinv_field_vat_classes', __('VAT rates class to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high');
129 129
     }
130 130
     
131
-    add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core' );
132
-    add_meta_box( 'wpinv_field_meta_values', __( 'Item Meta Values', 'invoicing' ), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core' );
131
+    add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core');
132
+    add_meta_box('wpinv_field_meta_values', __('Item Meta Values', 'invoicing'), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core');
133 133
 }
134 134
 
135 135
 function wpinv_register_discount_meta_boxes() {
136
-    add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' );
136
+    add_meta_box('wpinv_discount_fields', __('Discount Details', 'invoicing'), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high');
137 137
 }
138 138
 
139
-function wpinv_discount_metabox_details( $post ) {
139
+function wpinv_discount_metabox_details($post) {
140 140
     $discount_id    = $post->ID;
141
-    $discount       = wpinv_get_discount( $discount_id );
141
+    $discount       = wpinv_get_discount($discount_id);
142 142
     
143
-    $type               = wpinv_get_discount_type( $discount_id );
144
-    $item_reqs          = wpinv_get_discount_item_reqs( $discount_id );
145
-    $excluded_items     = wpinv_get_discount_excluded_items( $discount_id );
146
-    $min_total          = wpinv_get_discount_min_total( $discount_id );
147
-    $max_total          = wpinv_get_discount_max_total( $discount_id );
148
-    $max_uses           = wpinv_get_discount_max_uses( $discount_id );
149
-    $single_use         = wpinv_discount_is_single_use( $discount_id );
150
-    $recurring          = (bool)wpinv_discount_is_recurring( $discount_id );
151
-    $start_date         = wpinv_get_discount_start_date( $discount_id );
152
-    $expiration_date    = wpinv_get_discount_expiration( $discount_id );
143
+    $type               = wpinv_get_discount_type($discount_id);
144
+    $item_reqs          = wpinv_get_discount_item_reqs($discount_id);
145
+    $excluded_items     = wpinv_get_discount_excluded_items($discount_id);
146
+    $min_total          = wpinv_get_discount_min_total($discount_id);
147
+    $max_total          = wpinv_get_discount_max_total($discount_id);
148
+    $max_uses           = wpinv_get_discount_max_uses($discount_id);
149
+    $single_use         = wpinv_discount_is_single_use($discount_id);
150
+    $recurring          = (bool)wpinv_discount_is_recurring($discount_id);
151
+    $start_date         = wpinv_get_discount_start_date($discount_id);
152
+    $expiration_date    = wpinv_get_discount_expiration($discount_id);
153 153
     
154
-    if ( ! empty( $start_date ) && strpos( $start_date, '0000' ) === false ) {
155
-        $start_time         = strtotime( $start_date );
156
-        $start_h            = date_i18n( 'H', $start_time );
157
-        $start_m            = date_i18n( 'i', $start_time );
158
-        $start_date         = date_i18n( 'Y-m-d', $start_time );
154
+    if (!empty($start_date) && strpos($start_date, '0000') === false) {
155
+        $start_time         = strtotime($start_date);
156
+        $start_h            = date_i18n('H', $start_time);
157
+        $start_m            = date_i18n('i', $start_time);
158
+        $start_date         = date_i18n('Y-m-d', $start_time);
159 159
     } else {
160 160
         $start_h            = '00';
161 161
         $start_m            = '00';
162 162
     }
163 163
 
164
-    if ( ! empty( $expiration_date ) && strpos( $expiration_date, '0000' ) === false ) {
165
-        $expiration_time    = strtotime( $expiration_date );
166
-        $expiration_h       = date_i18n( 'H', $expiration_time );
167
-        $expiration_m       = date_i18n( 'i', $expiration_time );
168
-        $expiration_date    = date_i18n( 'Y-m-d', $expiration_time );
164
+    if (!empty($expiration_date) && strpos($expiration_date, '0000') === false) {
165
+        $expiration_time    = strtotime($expiration_date);
166
+        $expiration_h       = date_i18n('H', $expiration_time);
167
+        $expiration_m       = date_i18n('i', $expiration_time);
168
+        $expiration_date    = date_i18n('Y-m-d', $expiration_time);
169 169
     } else {
170 170
         $expiration_h       = '23';
171 171
         $expiration_m       = '59';
@@ -175,207 +175,207 @@  discard block
 block discarded – undo
175 175
     $max_total          = $max_total > 0 ? $max_total : '';
176 176
     $max_uses           = $max_uses > 0 ? $max_uses : '';
177 177
 ?>
178
-<?php do_action( 'wpinv_discount_form_top', $post ); ?>
179
-<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?>
178
+<?php do_action('wpinv_discount_form_top', $post); ?>
179
+<?php wp_nonce_field('wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce'); ;?>
180 180
 <table class="form-table wpi-form-table">
181 181
     <tbody>
182
-        <?php do_action( 'wpinv_discount_form_first', $post ); ?>
183
-        <?php do_action( 'wpinv_discount_form_before_code', $post ); ?>
182
+        <?php do_action('wpinv_discount_form_first', $post); ?>
183
+        <?php do_action('wpinv_discount_form_before_code', $post); ?>
184 184
         <tr>
185 185
             <th valign="top" scope="row">
186
-                <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label>
186
+                <label for="wpinv_discount_code"><?php _e('Discount Code', 'invoicing'); ?></label>
187 187
             </th>
188 188
             <td>
189
-                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required>
190
-                <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p>
189
+                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr(wpinv_get_discount_code($discount_id)); ?>" required>
190
+                <p class="description"><?php _e('Enter a code for this discount, such as 10OFF', 'invoicing'); ?></p>
191 191
             </td>
192 192
         </tr>
193
-        <?php do_action( 'wpinv_discount_form_before_type', $post ); ?>
193
+        <?php do_action('wpinv_discount_form_before_type', $post); ?>
194 194
         <tr>
195 195
             <th valign="top" scope="row">
196
-                <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label>
196
+                <label for="wpinv_discount_type"><?php _e('Discount Type', 'invoicing'); ?></label>
197 197
             </th>
198 198
             <td>
199 199
                 <select id="wpinv_discount_type" name="type" class="medium-text wpi_select2">
200
-                    <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?>
201
-                    <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option>
200
+                    <?php foreach (wpinv_get_discount_types() as $value => $label) { ?>
201
+                    <option value="<?php echo $value; ?>" <?php selected($type, $value); ?>><?php echo $label; ?></option>
202 202
                     <?php } ?>
203 203
                 </select>
204
-                <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p>
204
+                <p class="description"><?php _e('The kind of discount to apply for this discount.', 'invoicing'); ?></p>
205 205
             </td>
206 206
         </tr>
207
-        <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?>
207
+        <?php do_action('wpinv_discount_form_before_amount', $post); ?>
208 208
         <tr>
209 209
             <th valign="top" scope="row">
210
-                <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label>
210
+                <label for="wpinv_discount_amount"><?php _e('Amount', 'invoicing'); ?></label>
211 211
             </th>
212 212
             <td>
213
-                <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>
214
-                <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p>
215
-                <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p>
213
+                <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>
214
+                <p style="display:none;" class="description"><?php _e('Enter the discount amount in USD', 'invoicing'); ?></p>
215
+                <p class="description"><?php _e('Enter the discount value. Ex: 10', 'invoicing'); ?></p>
216 216
             </td>
217 217
         </tr>
218
-        <?php do_action( 'wpinv_discount_form_before_items', $post ); ?>
218
+        <?php do_action('wpinv_discount_form_before_items', $post); ?>
219 219
         <tr>
220 220
             <th valign="top" scope="row">
221
-                <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label>
221
+                <label for="wpinv_discount_items"><?php _e('Items', 'invoicing'); ?></label>
222 222
             </th>
223 223
             <td>
224
-                <p><?php echo wpinv_item_dropdown( array(
224
+                <p><?php echo wpinv_item_dropdown(array(
225 225
                         'name'              => 'items[]',
226 226
                         'id'                => 'items',
227 227
                         'selected'          => $item_reqs,
228 228
                         'multiple'          => true,
229 229
                         'class'             => 'medium-text wpi_select2',
230
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
230
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
231 231
                         'show_recurring'    => true,
232
-                    ) ); ?>
232
+                    )); ?>
233 233
                 </p>
234
-                <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>
234
+                <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>
235 235
             </td>
236 236
         </tr>
237
-        <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?>
237
+        <?php do_action('wpinv_discount_form_before_excluded_items', $post); ?>
238 238
         <tr>
239 239
             <th valign="top" scope="row">
240
-                <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label>
240
+                <label for="wpinv_discount_excluded_items"><?php _e('Excluded Items', 'invoicing'); ?></label>
241 241
             </th>
242 242
             <td>
243
-                <p><?php echo wpinv_item_dropdown( array(
243
+                <p><?php echo wpinv_item_dropdown(array(
244 244
                         'name'              => 'excluded_items[]',
245 245
                         'id'                => 'excluded_items',
246 246
                         'selected'          => $excluded_items,
247 247
                         'multiple'          => true,
248 248
                         'class'             => 'medium-text wpi_select2',
249
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
249
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
250 250
                         'show_recurring'    => true,
251
-                    ) ); ?>
251
+                    )); ?>
252 252
                 </p>
253
-                <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p>
253
+                <p class="description"><?php _e('Items which are NOT allowed to use this discount.', 'invoicing'); ?></p>
254 254
             </td>
255 255
         </tr>
256
-        <?php do_action( 'wpinv_discount_form_before_start', $post ); ?>
256
+        <?php do_action('wpinv_discount_form_before_start', $post); ?>
257 257
         <tr>
258 258
             <th valign="top" scope="row">
259
-                <label for="wpinv_discount_start"><?php _e( 'Start Date', 'invoicing' ); ?></label>
259
+                <label for="wpinv_discount_start"><?php _e('Start Date', 'invoicing'); ?></label>
260 260
             </th>
261 261
             <td>
262
-                <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">
263
-                    <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
264
-                    <option value="<?php echo $value;?>" <?php selected( $value, $start_h ); ?>><?php echo $value;?></option>
262
+                <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">
263
+                    <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
264
+                    <option value="<?php echo $value; ?>" <?php selected($value, $start_h); ?>><?php echo $value; ?></option>
265 265
                     <?php } ?>
266 266
                 </select> : <select id="wpinv_discount_start_m" name="start_m">
267
-                    <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
268
-                    <option value="<?php echo $value;?>" <?php selected( $value, $start_m ); ?>><?php echo $value;?></option>
267
+                    <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
268
+                    <option value="<?php echo $value; ?>" <?php selected($value, $start_m); ?>><?php echo $value; ?></option>
269 269
                     <?php } ?>
270 270
                 </select>
271
-                <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>
271
+                <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>
272 272
             </td>
273 273
         </tr>
274
-        <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?>
274
+        <?php do_action('wpinv_discount_form_before_expiration', $post); ?>
275 275
         <tr>
276 276
             <th valign="top" scope="row">
277
-                <label for="wpinv_discount_expiration"><?php _e( 'Expiration Date', 'invoicing' ); ?></label>
277
+                <label for="wpinv_discount_expiration"><?php _e('Expiration Date', 'invoicing'); ?></label>
278 278
             </th>
279 279
             <td>
280
-                <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">
281
-                    <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
282
-                    <option value="<?php echo $value;?>" <?php selected( $value, $expiration_h ); ?>><?php echo $value;?></option>
280
+                <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">
281
+                    <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
282
+                    <option value="<?php echo $value; ?>" <?php selected($value, $expiration_h); ?>><?php echo $value; ?></option>
283 283
                     <?php } ?>
284 284
                 </select> : <select id="wpinv_discount_expiration_m" name="expiration_m">
285
-                    <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
286
-                    <option value="<?php echo $value;?>" <?php selected( $value, $expiration_m ); ?>><?php echo $value;?></option>
285
+                    <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
286
+                    <option value="<?php echo $value; ?>" <?php selected($value, $expiration_m); ?>><?php echo $value; ?></option>
287 287
                     <?php } ?>
288 288
                 </select>
289
-                <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>
289
+                <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>
290 290
             </td>
291 291
         </tr>
292
-        <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?>
292
+        <?php do_action('wpinv_discount_form_before_min_total', $post); ?>
293 293
         <tr>
294 294
             <th valign="top" scope="row">
295
-                <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label>
295
+                <label for="wpinv_discount_min_total"><?php _e('Minimum Amount', 'invoicing'); ?></label>
296 296
             </th>
297 297
             <td>
298 298
                 <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>">
299
-                <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
299
+                <p class="description"><?php _e('This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
300 300
             </td>
301 301
         </tr>
302
-        <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?>
302
+        <?php do_action('wpinv_discount_form_before_max_total', $post); ?>
303 303
         <tr>
304 304
             <th valign="top" scope="row">
305
-                <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label>
305
+                <label for="wpinv_discount_max_total"><?php _e('Maximum Amount', 'invoicing'); ?></label>
306 306
             </th>
307 307
             <td>
308 308
                 <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>">
309
-                <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
309
+                <p class="description"><?php _e('This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
310 310
             </td>
311 311
         </tr>
312
-        <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?>
312
+        <?php do_action('wpinv_discount_form_before_recurring', $post); ?>
313 313
         <tr>
314 314
             <th valign="top" scope="row">
315
-                <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label>
315
+                <label for="wpinv_discount_recurring"><?php _e('For recurring apply to', 'invoicing'); ?></label>
316 316
             </th>
317 317
             <td>
318 318
                 <select id="wpinv_discount_recurring" name="recurring" class="medium-text wpi_select2">
319
-                    <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option>
320
-                    <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option>
319
+                    <option value="0" <?php selected(false, $recurring); ?>><?php _e('All payments', 'invoicing'); ?></option>
320
+                    <option value="1" <?php selected(true, $recurring); ?>><?php _e('First payment only', 'invoicing'); ?></option>
321 321
                 </select>
322
-                <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>
322
+                <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>
323 323
             </td>
324 324
         </tr>
325
-        <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?>
325
+        <?php do_action('wpinv_discount_form_before_max_uses', $post); ?>
326 326
         <tr>
327 327
             <th valign="top" scope="row">
328
-                <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label>
328
+                <label for="wpinv_discount_max_uses"><?php _e('Max Uses', 'invoicing'); ?></label>
329 329
             </th>
330 330
             <td>
331 331
                 <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>">
332
-                <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p>
332
+                <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing'); ?></p>
333 333
             </td>
334 334
         </tr>
335
-        <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?>
335
+        <?php do_action('wpinv_discount_form_before_single_use', $post); ?>
336 336
         <tr>
337 337
             <th valign="top" scope="row">
338
-                <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label>
338
+                <label for="wpinv_discount_single_use"><?php _e('Use Once Per User', 'invoicing'); ?></label>
339 339
             </th>
340 340
             <td>
341
-                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>>
342
-                <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span>
341
+                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked(true, $single_use); ?>>
342
+                <span class="description"><?php _e('Limit this discount to a single use per user?', 'invoicing'); ?></span>
343 343
             </td>
344 344
         </tr>
345
-        <?php do_action( 'wpinv_discount_form_last', $post ); ?>
345
+        <?php do_action('wpinv_discount_form_last', $post); ?>
346 346
     </tbody>
347 347
 </table>
348
-<?php do_action( 'wpinv_discount_form_bottom', $post ); ?>
348
+<?php do_action('wpinv_discount_form_bottom', $post); ?>
349 349
     <?php
350 350
 }
351 351
 
352
-function wpinv_discount_metabox_save( $post_id, $post, $update = false ) {
353
-    $post_type = !empty( $post ) ? $post->post_type : '';
352
+function wpinv_discount_metabox_save($post_id, $post, $update = false) {
353
+    $post_type = !empty($post) ? $post->post_type : '';
354 354
     
355
-    if ( $post_type != 'wpi_discount' ) {
355
+    if ($post_type != 'wpi_discount') {
356 356
         return;
357 357
     }
358 358
     
359
-    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' ) ) ) {
359
+    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'))) {
360 360
         return;
361 361
     }
362 362
     
363
-    if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
363
+    if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
364 364
         return;
365 365
     }
366 366
     
367
-    if ( !current_user_can( 'manage_options', $post_id ) ) {
367
+    if (!current_user_can('manage_options', $post_id)) {
368 368
         return;
369 369
     }
370 370
     
371
-    if ( !empty( $_POST['start'] ) && isset( $_POST['start_h'] ) && isset( $_POST['start_m'] ) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '' ) {
371
+    if (!empty($_POST['start']) && isset($_POST['start_h']) && isset($_POST['start_m']) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '') {
372 372
         $_POST['start'] = $_POST['start'] . ' ' . $_POST['start_h'] . ':' . $_POST['start_m'];
373 373
     }
374 374
 
375
-    if ( !empty( $_POST['expiration'] ) && isset( $_POST['expiration_h'] ) && isset( $_POST['expiration_m'] ) ) {
375
+    if (!empty($_POST['expiration']) && isset($_POST['expiration_h']) && isset($_POST['expiration_m'])) {
376 376
         $_POST['expiration'] = $_POST['expiration'] . ' ' . $_POST['expiration_h'] . ':' . $_POST['expiration_m'];
377 377
     }
378 378
     
379
-    return wpinv_store_discount( $post_id, $_POST, $post, $update );
379
+    return wpinv_store_discount($post_id, $_POST, $post, $update);
380 380
 }
381
-add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 );
382 381
\ No newline at end of file
382
+add_action('save_post', 'wpinv_discount_metabox_save', 10, 3);
383 383
\ 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   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -1,47 +1,47 @@  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
-        if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) {
22
+        if (!$use_taxes && (float)$invoice->get_tax() > 0) {
23 23
             $use_taxes = true;
24 24
         }
25
-        $item_types         = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post );
25
+        $item_types         = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post);
26 26
         $is_recurring       = $invoice->is_recurring();
27 27
         $post_type_object   = get_post_type_object($invoice->post_type);
28 28
         $type_title         = $post_type_object->labels->singular_name;
29 29
 
30 30
         $cols = 5;
31
-        if ( $item_quantities ) {
31
+        if ($item_quantities) {
32 32
             $cols++;
33 33
         }
34
-        if ( $use_taxes ) {
34
+        if ($use_taxes) {
35 35
             $cols++;
36 36
         }
37 37
         $class = '';
38
-        if ( $invoice->is_paid() ) {
38
+        if ($invoice->is_paid()) {
39 39
             $class .= ' wpinv-paid';
40 40
         }
41
-        if ( $invoice->is_refunded() ) {
41
+        if ($invoice->is_refunded()) {
42 42
             $class .= ' wpinv-refunded';
43 43
         }
44
-        if ( $is_recurring ) {
44
+        if ($is_recurring) {
45 45
             $class .= ' wpi-recurring';
46 46
         }
47 47
         ?>
@@ -49,21 +49,21 @@  discard block
 block discarded – undo
49 49
             <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0">
50 50
                 <thead>
51 51
                     <tr>
52
-                        <th class="id"><?php _e( 'ID', 'invoicing' );?></th>
53
-                        <th class="title"><?php _e( 'Item', 'invoicing' );?></th>
54
-                        <th class="price"><?php _e( 'Price', 'invoicing' );?></th>
55
-                        <?php if ( $item_quantities ) { ?>
56
-                        <th class="qty"><?php _e( 'Qty', 'invoicing' );?></th>
52
+                        <th class="id"><?php _e('ID', 'invoicing'); ?></th>
53
+                        <th class="title"><?php _e('Item', 'invoicing'); ?></th>
54
+                        <th class="price"><?php _e('Price', 'invoicing'); ?></th>
55
+                        <?php if ($item_quantities) { ?>
56
+                        <th class="qty"><?php _e('Qty', 'invoicing'); ?></th>
57 57
                         <?php } ?>
58
-                        <th class="total"><?php _e( 'Total', 'invoicing' );?></th>
59
-                        <?php if ( $use_taxes ) { ?>
60
-                        <th class="tax"><?php _e( 'Tax (%)', 'invoicing' );?></th>
58
+                        <th class="total"><?php _e('Total', 'invoicing'); ?></th>
59
+                        <?php if ($use_taxes) { ?>
60
+                        <th class="tax"><?php _e('Tax (%)', 'invoicing'); ?></th>
61 61
                         <?php } ?>
62 62
                         <th class="action"></th>
63 63
                     </tr>
64 64
                 </thead>
65 65
                 <tbody class="wpinv-line-items">
66
-                    <?php echo wpinv_admin_get_line_items( $invoice ); ?>
66
+                    <?php echo wpinv_admin_get_line_items($invoice); ?>
67 67
                 </tbody>
68 68
                 <tfoot class="wpinv-totals">
69 69
                     <tr>
@@ -74,45 +74,45 @@  discard block
 block discarded – undo
74 74
                                         <td class="id">
75 75
                                         </td>
76 76
                                         <td class="title">
77
-                                            <input type="text" class="regular-text" placeholder="<?php _e( 'Item Name', 'invoicing' ); ?>" value="" name="_wpinv_quick[name]">
78
-                                            <?php if ( $wpinv_euvat->allow_vat_rules() ) { ?>
77
+                                            <input type="text" class="regular-text" placeholder="<?php _e('Item Name', 'invoicing'); ?>" value="" name="_wpinv_quick[name]">
78
+                                            <?php if ($wpinv_euvat->allow_vat_rules()) { ?>
79 79
                                             <div class="wp-clearfix">
80 80
                                                 <label class="wpi-vat-rule">
81
-                                                    <span class="title"><?php _e( 'VAT rule type', 'invoicing' );?></span>
81
+                                                    <span class="title"><?php _e('VAT rule type', 'invoicing'); ?></span>
82 82
                                                     <span class="input-text-wrap">
83
-                                                        <?php echo wpinv_html_select( array(
83
+                                                        <?php echo wpinv_html_select(array(
84 84
                                                             'options'          => $wpinv_euvat->get_rules(),
85 85
                                                             'name'             => '_wpinv_quick[vat_rule]',
86 86
                                                             'id'               => '_wpinv_quick_vat_rule',
87 87
                                                             'show_option_all'  => false,
88 88
                                                             'show_option_none' => false,
89 89
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-rule wpi_select2',
90
-                                                        ) ); ?>
90
+                                                        )); ?>
91 91
                                                     </span>
92 92
                                                 </label>
93 93
                                             </div>
94
-                                            <?php } if ( $wpinv_euvat->allow_vat_classes() ) { ?>
94
+                                            <?php } if ($wpinv_euvat->allow_vat_classes()) { ?>
95 95
                                             <div class="wp-clearfix">
96 96
                                                 <label class="wpi-vat-class">
97
-                                                    <span class="title"><?php _e( 'VAT class', 'invoicing' );?></span>
97
+                                                    <span class="title"><?php _e('VAT class', 'invoicing'); ?></span>
98 98
                                                     <span class="input-text-wrap">
99
-                                                        <?php echo wpinv_html_select( array(
99
+                                                        <?php echo wpinv_html_select(array(
100 100
                                                             'options'          => $wpinv_euvat->get_all_classes(),
101 101
                                                             'name'             => '_wpinv_quick[vat_class]',
102 102
                                                             'id'               => '_wpinv_quick_vat_class',
103 103
                                                             'show_option_all'  => false,
104 104
                                                             'show_option_none' => false,
105 105
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-class wpi_select2',
106
-                                                        ) ); ?>
106
+                                                        )); ?>
107 107
                                                     </span>
108 108
                                                 </label>
109 109
                                             </div>
110 110
                                             <?php } ?>
111 111
                                             <div class="wp-clearfix">
112 112
                                                 <label class="wpi-item-type">
113
-                                                    <span class="title"><?php _e( 'Item type', 'invoicing' );?></span>
113
+                                                    <span class="title"><?php _e('Item type', 'invoicing'); ?></span>
114 114
                                                     <span class="input-text-wrap">
115
-                                                        <?php echo wpinv_html_select( array(
115
+                                                        <?php echo wpinv_html_select(array(
116 116
                                                             'options'          => $item_types,
117 117
                                                             'name'             => '_wpinv_quick[type]',
118 118
                                                             'id'               => '_wpinv_quick_type',
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
                                                             'show_option_all'  => false,
121 121
                                                             'show_option_none' => false,
122 122
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-type wpi_select2',
123
-                                                        ) ); ?>
123
+                                                        )); ?>
124 124
                                                     </span>
125 125
                                                 </label>
126 126
                                             </div>
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
                                             </div>
134 134
                                         </td>
135 135
                                         <td class="price"><input type="text" placeholder="0.00" class="wpi-field-price wpi-price" name="_wpinv_quick[price]" /></td>
136
-                                        <?php if ( $item_quantities ) { ?>
136
+                                        <?php if ($item_quantities) { ?>
137 137
                                         <td class="qty"><input type="number" class="small-text" step="1" min="1" value="1" name="_wpinv_quick[qty]" /></td>
138 138
                                         <?php } ?>
139 139
                                         <td class="total"></td>
140
-                                        <?php if ( $use_taxes ) { ?>
140
+                                        <?php if ($use_taxes) { ?>
141 141
                                         <td class="tax"></td>
142 142
                                         <?php } ?>
143 143
                                         <td class="action"></td>
@@ -150,29 +150,29 @@  discard block
 block discarded – undo
150 150
                         <td colspan="<?php echo $cols; ?>"></td>
151 151
                     </tr>
152 152
                     <tr class="totals">
153
-                        <td colspan="<?php echo ( $cols - 4 ); ?>"></td>
153
+                        <td colspan="<?php echo ($cols - 4); ?>"></td>
154 154
                         <td colspan="4">
155 155
                             <table cellspacing="0" cellpadding="0">
156 156
                                 <tr class="subtotal">
157
-                                    <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td>
158
-                                    <td class="total"><?php echo $subtotal;?></td>
157
+                                    <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td>
158
+                                    <td class="total"><?php echo $subtotal; ?></td>
159 159
                                     <td class="action"></td>
160 160
                                 </tr>
161 161
                                 <tr class="discount">
162
-                                    <td class="name"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice->ID ) ); ?>:</td>
163
-                                    <td class="total"><?php echo wpinv_discount( $invoice->ID, true, true ); ?></td>
162
+                                    <td class="name"><?php wpinv_get_discount_label(wpinv_discount_code($invoice->ID)); ?>:</td>
163
+                                    <td class="total"><?php echo wpinv_discount($invoice->ID, true, true); ?></td>
164 164
                                     <td class="action"></td>
165 165
                                 </tr>
166
-                                <?php if ( $use_taxes ) { ?>
166
+                                <?php if ($use_taxes) { ?>
167 167
                                 <tr class="tax">
168
-                                    <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td>
169
-                                    <td class="total"><?php echo $tax;?></td>
168
+                                    <td class="name"><?php _e('Tax:', 'invoicing'); ?></td>
169
+                                    <td class="total"><?php echo $tax; ?></td>
170 170
                                     <td class="action"></td>
171 171
                                 </tr>
172 172
                                 <?php } ?>
173 173
                                 <tr class="total">
174
-                                    <td class="name"><?php echo apply_filters( 'wpinv_invoice_items_total_label', __( 'Invoice Total:', 'invoicing' ), $invoice );?></td>
175
-                                    <td class="total"><?php echo $total;?></td>
174
+                                    <td class="name"><?php echo apply_filters('wpinv_invoice_items_total_label', __('Invoice Total:', 'invoicing'), $invoice); ?></td>
175
+                                    <td class="total"><?php echo $total; ?></td>
176 176
                                     <td class="action"></td>
177 177
                                 </tr>
178 178
                             </table>
@@ -183,90 +183,90 @@  discard block
 block discarded – undo
183 183
             <div class="wpinv-actions">
184 184
                 <?php ob_start(); ?>
185 185
                 <?php
186
-                    if ( !$invoice->is_paid() && !$invoice->is_refunded() ) {
187
-                        if ( !$invoice->is_recurring() ) {
188
-                            echo wpinv_item_dropdown( array(
186
+                    if (!$invoice->is_paid() && !$invoice->is_refunded()) {
187
+                        if (!$invoice->is_recurring()) {
188
+                            echo wpinv_item_dropdown(array(
189 189
                                 'name'             => 'wpinv_invoice_item',
190 190
                                 'id'               => 'wpinv_invoice_item',
191 191
                                 'show_recurring'   => true,
192 192
                                 'class'            => 'wpi_select2',
193
-                            ) );
193
+                            ));
194 194
                     ?>
195
-                <input type="button" value="<?php echo sprintf(esc_attr__( 'Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e( 'Create new item', 'invoicing' );?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e( 'Recalculate Totals', 'invoicing' );?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">
195
+                <input type="button" value="<?php echo sprintf(esc_attr__('Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e('Create new item', 'invoicing'); ?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e('Recalculate Totals', 'invoicing'); ?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">
196 196
                     <?php } ?>
197
-                <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?>
198
-                <?php $item_actions = ob_get_clean(); echo apply_filters( 'wpinv_invoice_items_actions_content', $item_actions, $invoice, $post ); ?>
197
+                <?php do_action('wpinv_invoice_items_actions', $invoice); ?>
198
+                <?php $item_actions = ob_get_clean(); echo apply_filters('wpinv_invoice_items_actions_content', $item_actions, $invoice, $post); ?>
199 199
             </div>
200 200
         </div>
201 201
         <?php
202 202
     }
203 203
 
204
-    public static function prices( $post ) {        
204
+    public static function prices($post) {        
205 205
         $symbol         = wpinv_currency_symbol();
206 206
         $position       = wpinv_currency_position();
207
-        $item           = new WPInv_Item( $post->ID );
207
+        $item           = new WPInv_Item($post->ID);
208 208
 
209 209
         $price                = $item->get_price();
210 210
         $is_dynamic_pricing   = $item->get_is_dynamic_pricing();
211 211
         $minimum_price        = $item->get_minimum_price();
212 212
         $is_recurring         = $item->is_recurring();
213 213
         $period               = $item->get_recurring_period();
214
-        $interval             = absint( $item->get_recurring_interval() );
215
-        $times                = absint( $item->get_recurring_limit() );
214
+        $interval             = absint($item->get_recurring_interval());
215
+        $times                = absint($item->get_recurring_limit());
216 216
         $free_trial           = $item->has_free_trial();
217 217
         $trial_interval       = $item->get_trial_interval();
218 218
         $trial_period         = $item->get_trial_period();
219 219
 
220 220
         $intervals            = array();
221
-        for ( $i = 1; $i <= 90; $i++ ) {
221
+        for ($i = 1; $i <= 90; $i++) {
222 222
             $intervals[$i] = $i;
223 223
         }
224 224
 
225
-        $interval       = $interval > 0 ? $interval : 1;
225
+        $interval = $interval > 0 ? $interval : 1;
226 226
 
227 227
         $class = $is_recurring ? 'wpinv-recurring-y' : 'wpinv-recurring-n';
228 228
 
229 229
         $minimum_price_style = 'margin-left: 24px;';
230
-        if(! $is_dynamic_pricing ) {
230
+        if (!$is_dynamic_pricing) {
231 231
             $minimum_price_style .= 'display: none;';
232 232
         }
233 233
 
234 234
         ?>
235
-        <p class="wpinv-row-prices"><?php echo ( $position != 'right' ? $symbol . '&nbsp;' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $price;?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled( $item->is_editable(), false ); ?> /><?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' ) ;?>" />
236
-        <?php do_action( 'wpinv_prices_metabox_price', $item ); ?>
235
+        <p class="wpinv-row-prices"><?php echo ($position != 'right' ? $symbol . '&nbsp;' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $price; ?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled($item->is_editable(), false); ?> /><?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'); ?>" />
236
+        <?php do_action('wpinv_prices_metabox_price', $item); ?>
237 237
         </p>
238 238
 
239
-    <?php if( $item->supports_dynamic_pricing() ) { ?>
239
+    <?php if ($item->supports_dynamic_pricing()) { ?>
240 240
 
241 241
         <p class="wpinv-row-name-your-price">
242 242
             <label>
243
-                <input type="checkbox" name="wpinv_name_your_price" id="wpinv_name_your_price" value="1" <?php checked( 1, $is_dynamic_pricing ); ?> />
244
-                <?php echo apply_filters( 'wpinv_name_your_price_toggle_text', __( 'User can set a custom price', 'invoicing' ) ); ?>
243
+                <input type="checkbox" name="wpinv_name_your_price" id="wpinv_name_your_price" value="1" <?php checked(1, $is_dynamic_pricing); ?> />
244
+                <?php echo apply_filters('wpinv_name_your_price_toggle_text', __('User can set a custom price', 'invoicing')); ?>
245 245
             </label>
246
-            <?php do_action( 'wpinv_prices_metabox_name_your_price_field', $item ); ?>
246
+            <?php do_action('wpinv_prices_metabox_name_your_price_field', $item); ?>
247 247
         </p>
248 248
 
249 249
         <p class="wpinv-row-minimum-price" style="<?php echo $minimum_price_style; ?>">
250 250
             <label>
251
-                <?php _e( 'Minimum Price', 'invoicing' ); ?>
252
-                <?php echo ( $position != 'right' ? $symbol . '&nbsp;' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $minimum_price;?>" id="wpinv_minimum_price" name="wpinv_minimum_price" class="medium-text wpi-field-price" <?php disabled( $item->is_editable(), false ); ?> /><?php echo ( $position == 'right' ? '&nbsp;' . $symbol : '' );?>
251
+                <?php _e('Minimum Price', 'invoicing'); ?>
252
+                <?php echo ($position != 'right' ? $symbol . '&nbsp;' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $minimum_price; ?>" id="wpinv_minimum_price" name="wpinv_minimum_price" class="medium-text wpi-field-price" <?php disabled($item->is_editable(), false); ?> /><?php echo ($position == 'right' ? '&nbsp;' . $symbol : ''); ?>
253 253
             </label>
254 254
 
255
-            <?php do_action( 'wpinv_prices_metabox_minimum_price_field', $item ); ?>
255
+            <?php do_action('wpinv_prices_metabox_minimum_price_field', $item); ?>
256 256
         </p>
257 257
 
258 258
     <?php } ?>
259 259
 
260 260
         <p class="wpinv-row-is-recurring">
261 261
             <label for="wpinv_is_recurring">
262
-                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked( 1, $is_recurring ); ?> />
263
-                <?php echo apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Is Recurring Item?', 'invoicing' ) ); ?>
262
+                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked(1, $is_recurring); ?> />
263
+                <?php echo apply_filters('wpinv_is_recurring_toggle_text', __('Is Recurring Item?', 'invoicing')); ?>
264 264
             </label>
265
-            <?php do_action( 'wpinv_prices_metabox_is_recurring_field', $item ); ?>
265
+            <?php do_action('wpinv_prices_metabox_is_recurring_field', $item); ?>
266 266
         </p>
267
-        <p class="wpinv-row-recurring-fields <?php echo $class;?>">
268
-            <label class="wpinv-period" for="wpinv_recurring_period"><?php _e( 'Recurring', 'invoicing' );?> <select class="wpinv-select wpi_select2" 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>
269
-            <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e( 'at every', 'invoicing' );?> <?php echo wpinv_html_select( array(
267
+        <p class="wpinv-row-recurring-fields <?php echo $class; ?>">
268
+            <label class="wpinv-period" for="wpinv_recurring_period"><?php _e('Recurring', 'invoicing'); ?> <select class="wpinv-select wpi_select2" 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>
269
+            <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e('at every', 'invoicing'); ?> <?php echo wpinv_html_select(array(
270 270
                 'options'          => $intervals,
271 271
                 'name'             => 'wpinv_recurring_interval',
272 272
                 'id'               => 'wpinv_recurring_interval',
@@ -274,30 +274,30 @@  discard block
 block discarded – undo
274 274
                 'show_option_all'  => false,
275 275
                 'show_option_none' => false,
276 276
                 'class'            => 'wpi_select2',
277
-            ) ); ?> <span id="wpinv_interval_text"><?php _e( 'day(s)', 'invoicing' );?></span></label>
278
-            <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>
277
+            )); ?> <span id="wpinv_interval_text"><?php _e('day(s)', 'invoicing'); ?></span></label>
278
+            <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>
279 279
             <span class="clear wpi-trial-clr"></span>
280 280
             <label class="wpinv-free-trial" for="wpinv_free_trial">
281
-                <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked( true, (bool)$free_trial ); ?> /> 
282
-                <?php echo __( 'Offer free trial for', 'invoicing' ); ?>
281
+                <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked(true, (bool)$free_trial); ?> /> 
282
+                <?php echo __('Offer free trial for', 'invoicing'); ?>
283 283
             </label>
284 284
             <label class="wpinv-trial-interval" for="wpinv_trial_interval">
285
-                <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 wpi_select2" 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>
285
+                <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 wpi_select2" 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>
286 286
             </label>
287
-            <?php do_action( 'wpinv_prices_metabox_recurring_fields', $item ); ?>
287
+            <?php do_action('wpinv_prices_metabox_recurring_fields', $item); ?>
288 288
         </p>
289
-        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type( $post->ID ); ?>" />
290
-        <?php do_action( 'wpinv_item_price_field', $post->ID ); ?>
289
+        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type($post->ID); ?>" />
290
+        <?php do_action('wpinv_item_price_field', $post->ID); ?>
291 291
         <?php
292 292
     }
293 293
 
294
-    public static function vat_rules( $post ) {
294
+    public static function vat_rules($post) {
295 295
         global $wpinv_euvat;
296 296
 
297
-        $rule_type = $wpinv_euvat->get_item_rule( $post->ID );
297
+        $rule_type = $wpinv_euvat->get_item_rule($post->ID);
298 298
         ?>
299
-        <p><label for="wpinv_vat_rules"><strong><?php _e( 'Select how VAT rules will be applied:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
300
-        <?php echo wpinv_html_select( array(
299
+        <p><label for="wpinv_vat_rules"><strong><?php _e('Select how VAT rules will be applied:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
300
+        <?php echo wpinv_html_select(array(
301 301
                     'options'          => $wpinv_euvat->get_rules(),
302 302
                     'name'             => 'wpinv_vat_rules',
303 303
                     'id'               => 'wpinv_vat_rules',
@@ -305,19 +305,19 @@  discard block
 block discarded – undo
305 305
                     'show_option_all'  => false,
306 306
                     'show_option_none' => false,
307 307
                     'class'            => 'gdmbx2-text-medium wpinv-vat-rules wpi_select2',
308
-                ) ); ?>
308
+                )); ?>
309 309
         </p>
310
-        <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>
311
-        <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>
310
+        <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>
311
+        <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>
312 312
         <?php
313 313
     }
314 314
 
315
-    public static function vat_classes( $post ) {
315
+    public static function vat_classes($post) {
316 316
         global $wpinv_euvat;
317 317
         
318
-        $vat_class = $wpinv_euvat->get_item_class( $post->ID );
318
+        $vat_class = $wpinv_euvat->get_item_class($post->ID);
319 319
         ?>
320
-        <p><?php echo wpinv_html_select( array(
320
+        <p><?php echo wpinv_html_select(array(
321 321
                     'options'          => $wpinv_euvat->get_all_classes(),
322 322
                     'name'             => 'wpinv_vat_class',
323 323
                     'id'               => 'wpinv_vat_class',
@@ -325,18 +325,18 @@  discard block
 block discarded – undo
325 325
                     'show_option_all'  => false,
326 326
                     'show_option_none' => false,
327 327
                     'class'            => 'gdmbx2-text-medium wpinv-vat-class wpi_select2',
328
-                ) ); ?>
328
+                )); ?>
329 329
         </p>
330
-        <p class="wpi-m0"><?php _e( 'Select the VAT rate class to use for this invoice item.', 'invoicing' ); ?></p>
330
+        <p class="wpi-m0"><?php _e('Select the VAT rate class to use for this invoice item.', 'invoicing'); ?></p>
331 331
         <?php
332 332
     }
333 333
 
334
-    public static function item_info( $post ) {
335
-        $item_type = wpinv_get_item_type( $post->ID );
336
-        do_action( 'wpinv_item_info_metabox_before', $post );
334
+    public static function item_info($post) {
335
+        $item_type = wpinv_get_item_type($post->ID);
336
+        do_action('wpinv_item_info_metabox_before', $post);
337 337
         ?>
338
-        <p><label for="wpinv_item_type"><strong><?php _e( 'Type:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
339
-        <?php echo wpinv_html_select( array(
338
+        <p><label for="wpinv_item_type"><strong><?php _e('Type:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
339
+        <?php echo wpinv_html_select(array(
340 340
                     'options'          => wpinv_get_item_types(),
341 341
                     'name'             => 'wpinv_item_type',
342 342
                     'id'               => 'wpinv_item_type',
@@ -344,114 +344,114 @@  discard block
 block discarded – undo
344 344
                     'show_option_all'  => false,
345 345
                     'show_option_none' => false,
346 346
                     'class'            => 'gdmbx2-text-medium wpinv-item-type',
347
-                ) ); ?>
347
+                )); ?>
348 348
         </p>
349
-        <p class="wpi-m0"><?php _e( 'Select item type.', 'invoicing' );?><br><?php _e( '<b>Standard:</b> Standard item type', 'invoicing' );?><br><?php _e( '<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing' );?></p>
349
+        <p class="wpi-m0"><?php _e('Select item type.', 'invoicing'); ?><br><?php _e('<b>Standard:</b> Standard item type', 'invoicing'); ?><br><?php _e('<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing'); ?></p>
350 350
         <?php
351
-        do_action( 'wpinv_item_info_metabox_after', $post );
351
+        do_action('wpinv_item_info_metabox_after', $post);
352 352
     }
353 353
 
354
-    public static function meta_values( $post ) {
355
-        $meta_keys = apply_filters( 'wpinv_show_meta_values_for_keys', array(
354
+    public static function meta_values($post) {
355
+        $meta_keys = apply_filters('wpinv_show_meta_values_for_keys', array(
356 356
             'type',
357 357
             'custom_id'
358
-        ) );
358
+        ));
359 359
 
360
-        if ( empty( $meta_keys ) ) {
360
+        if (empty($meta_keys)) {
361 361
             return;
362 362
         }
363 363
 
364
-        do_action( 'wpinv_meta_values_metabox_before', $post );
364
+        do_action('wpinv_meta_values_metabox_before', $post);
365 365
 
366
-        foreach ( $meta_keys as $meta_key ) {
366
+        foreach ($meta_keys as $meta_key) {
367 367
             ?>
368
-            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta( $post->ID, '_wpinv_' . $meta_key, true ); ?></label></p>
368
+            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta($post->ID, '_wpinv_' . $meta_key, true); ?></label></p>
369 369
             <?php 
370 370
         }
371 371
 
372
-        do_action( 'wpinv_meta_values_metabox_after', $post );
372
+        do_action('wpinv_meta_values_metabox_after', $post);
373 373
     }
374 374
 
375
-    public static function save( $post_id, $data, $post ) {
376
-        $invoice        = new WPInv_Invoice( $post_id );
375
+    public static function save($post_id, $data, $post) {
376
+        $invoice        = new WPInv_Invoice($post_id);
377 377
 
378 378
         // Billing
379
-        $first_name     = sanitize_text_field( $data['wpinv_first_name'] );
380
-        $last_name      = sanitize_text_field( $data['wpinv_last_name'] );
381
-        $company        = sanitize_text_field( $data['wpinv_company'] );
382
-        $vat_number     = sanitize_text_field( $data['wpinv_vat_number'] );
383
-        $phone          = sanitize_text_field( $data['wpinv_phone'] );
384
-        $address        = sanitize_text_field( $data['wpinv_address'] );
385
-        $city           = sanitize_text_field( $data['wpinv_city'] );
386
-        $zip            = sanitize_text_field( $data['wpinv_zip'] );
387
-        $country        = sanitize_text_field( $data['wpinv_country'] );
388
-        $state          = sanitize_text_field( $data['wpinv_state'] );
379
+        $first_name     = sanitize_text_field($data['wpinv_first_name']);
380
+        $last_name      = sanitize_text_field($data['wpinv_last_name']);
381
+        $company        = sanitize_text_field($data['wpinv_company']);
382
+        $vat_number     = sanitize_text_field($data['wpinv_vat_number']);
383
+        $phone          = sanitize_text_field($data['wpinv_phone']);
384
+        $address        = sanitize_text_field($data['wpinv_address']);
385
+        $city           = sanitize_text_field($data['wpinv_city']);
386
+        $zip            = sanitize_text_field($data['wpinv_zip']);
387
+        $country        = sanitize_text_field($data['wpinv_country']);
388
+        $state          = sanitize_text_field($data['wpinv_state']);
389 389
 
390 390
         // Details
391
-        $status         = sanitize_text_field( $data['wpinv_status'] );
392
-        $old_status     = !empty( $data['original_post_status'] ) ? sanitize_text_field( $data['original_post_status'] ) : $status;
393
-        $number         = sanitize_text_field( $data['wpinv_number'] );
394
-        $due_date       = isset( $data['wpinv_due_date'] ) ? sanitize_text_field( $data['wpinv_due_date'] ) : '';
391
+        $status         = sanitize_text_field($data['wpinv_status']);
392
+        $old_status     = !empty($data['original_post_status']) ? sanitize_text_field($data['original_post_status']) : $status;
393
+        $number         = sanitize_text_field($data['wpinv_number']);
394
+        $due_date       = isset($data['wpinv_due_date']) ? sanitize_text_field($data['wpinv_due_date']) : '';
395 395
         //$discounts      = sanitize_text_field( $data['wpinv_discounts'] );
396 396
         //$discount       = sanitize_text_field( $data['wpinv_discount'] );
397 397
 
398
-        $ip             = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
399
-
400
-        $invoice->set( 'due_date', $due_date );
401
-        $invoice->set( 'first_name', $first_name );
402
-        $invoice->set( 'last_name', $last_name );
403
-        $invoice->set( 'company', $company );
404
-        $invoice->set( 'vat_number', $vat_number );
405
-        $invoice->set( 'phone', $phone );
406
-        $invoice->set( 'address', $address );
407
-        $invoice->set( 'city', $city );
408
-        $invoice->set( 'zip', $zip );
409
-        $invoice->set( 'country', $country );
410
-        $invoice->set( 'state', $state );
411
-        $invoice->set( 'status', $status );
398
+        $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
399
+
400
+        $invoice->set('due_date', $due_date);
401
+        $invoice->set('first_name', $first_name);
402
+        $invoice->set('last_name', $last_name);
403
+        $invoice->set('company', $company);
404
+        $invoice->set('vat_number', $vat_number);
405
+        $invoice->set('phone', $phone);
406
+        $invoice->set('address', $address);
407
+        $invoice->set('city', $city);
408
+        $invoice->set('zip', $zip);
409
+        $invoice->set('country', $country);
410
+        $invoice->set('state', $state);
411
+        $invoice->set('status', $status);
412 412
         //$invoice->set( 'number', $number );
413 413
         //$invoice->set( 'discounts', $discounts );
414 414
         //$invoice->set( 'discount', $discount );
415
-        $invoice->set( 'ip', $ip );
415
+        $invoice->set('ip', $ip);
416 416
         $invoice->old_status = $_POST['original_post_status'];
417 417
         $invoice->currency = wpinv_get_currency();
418
-        if ( !empty( $data['wpinv_gateway'] ) ) {
419
-            $invoice->set( 'gateway', sanitize_text_field( $data['wpinv_gateway'] ) );
418
+        if (!empty($data['wpinv_gateway'])) {
419
+            $invoice->set('gateway', sanitize_text_field($data['wpinv_gateway']));
420 420
         }
421 421
         $saved = $invoice->save();
422 422
 
423 423
         // Check for payment notes
424
-        if ( !empty( $data['invoice_note'] ) ) {
425
-            $note               = wp_kses( $data['invoice_note'], array() );
426
-            $note_type          = sanitize_text_field( $data['invoice_note_type'] );
424
+        if (!empty($data['invoice_note'])) {
425
+            $note               = wp_kses($data['invoice_note'], array());
426
+            $note_type          = sanitize_text_field($data['invoice_note_type']);
427 427
             $is_customer_note   = $note_type == 'customer' ? 1 : 0;
428 428
 
429
-            wpinv_insert_payment_note( $invoice->ID, $note, $is_customer_note );
429
+            wpinv_insert_payment_note($invoice->ID, $note, $is_customer_note);
430 430
         }
431 431
 
432 432
         // Update user address if empty.
433
-        if ( $saved && !empty( $invoice ) ) {
434
-            if ( $user_id = $invoice->get_user_id() ) {
435
-                $user_address = wpinv_get_user_address( $user_id, false );
433
+        if ($saved && !empty($invoice)) {
434
+            if ($user_id = $invoice->get_user_id()) {
435
+                $user_address = wpinv_get_user_address($user_id, false);
436 436
 
437 437
                 if (empty($user_address['first_name'])) {
438
-                    update_user_meta( $user_id, '_wpinv_first_name', $first_name );
439
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
438
+                    update_user_meta($user_id, '_wpinv_first_name', $first_name);
439
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
440 440
                 } else if (empty($user_address['last_name']) && $user_address['first_name'] == $first_name) {
441
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
441
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
442 442
                 }
443 443
 
444 444
                 if (empty($user_address['address']) || empty($user_address['city']) || empty($user_address['state']) || empty($user_address['country'])) {
445
-                    update_user_meta( $user_id, '_wpinv_address', $address );
446
-                    update_user_meta( $user_id, '_wpinv_city', $city );
447
-                    update_user_meta( $user_id, '_wpinv_state', $state );
448
-                    update_user_meta( $user_id, '_wpinv_country', $country );
449
-                    update_user_meta( $user_id, '_wpinv_zip', $zip );
450
-                    update_user_meta( $user_id, '_wpinv_phone', $phone );
445
+                    update_user_meta($user_id, '_wpinv_address', $address);
446
+                    update_user_meta($user_id, '_wpinv_city', $city);
447
+                    update_user_meta($user_id, '_wpinv_state', $state);
448
+                    update_user_meta($user_id, '_wpinv_country', $country);
449
+                    update_user_meta($user_id, '_wpinv_zip', $zip);
450
+                    update_user_meta($user_id, '_wpinv_phone', $phone);
451 451
                 }
452 452
             }
453 453
 
454
-            do_action( 'wpinv_invoice_metabox_saved', $invoice );
454
+            do_action('wpinv_invoice_metabox_saved', $invoice);
455 455
         }
456 456
 
457 457
         return $saved;
Please login to merge, or discard this patch.
includes/admin/wpinv-admin-functions.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
         case 'status' :
102 102
             $value   = $wpi_invoice->get_status( true ) . ( $wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '' );
103 103
             $is_viewed = wpinv_is_invoice_viewed( $wpi_invoice->ID );
104
-	        $gateway_title = wpinv_get_gateway_admin_label( $wpi_invoice->get_gateway() );
105
-	        $offline_gateways = apply_filters('wpinv_offline_payments', array('bank_transfer', 'cheque', 'cod'));
106
-	        $is_offline_payment = in_array($wpi_invoice->get_gateway(), $offline_gateways) ? true : false;
104
+            $gateway_title = wpinv_get_gateway_admin_label( $wpi_invoice->get_gateway() );
105
+            $offline_gateways = apply_filters('wpinv_offline_payments', array('bank_transfer', 'cheque', 'cod'));
106
+            $is_offline_payment = in_array($wpi_invoice->get_gateway(), $offline_gateways) ? true : false;
107 107
 
108 108
             if ( 1 == $is_viewed ) {
109 109
                 $value .= '&nbsp;&nbsp;<i class="fa fa-eye" title="'.__( 'Viewed by Customer', 'invoicing' ).'"></i>';
@@ -174,69 +174,69 @@  discard block
 block discarded – undo
174 174
 }
175 175
 
176 176
 function wpinv_admin_messages() {
177
-	global $wpinv_options, $pagenow, $post;
177
+    global $wpinv_options, $pagenow, $post;
178 178
 
179
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
180
-		 add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' );
181
-	}
179
+    if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
180
+            add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' );
181
+    }
182 182
 
183
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
184
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' );
185
-	}
183
+    if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
184
+        add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' );
185
+    }
186 186
 
187
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
188
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' );
189
-	}
187
+    if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
188
+        add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' );
189
+    }
190 190
 
191
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
192
-		 add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' );
193
-	}
191
+    if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
192
+            add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' );
193
+    }
194 194
 
195
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
196
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' );
197
-	}
195
+    if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
196
+        add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' );
197
+    }
198 198
 
199
-	if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
200
-		add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' );
201
-	}
199
+    if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
200
+        add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' );
201
+    }
202 202
 
203
-	if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
204
-		add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' );
205
-	}
203
+    if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
204
+        add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' );
205
+    }
206 206
 
207
-	if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
208
-		add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' );
207
+    if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
208
+        add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' );
209 209
     }
210 210
     
211 211
     if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
212
-		add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' );
212
+        add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' );
213 213
     }
214 214
 
215 215
     if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
216 216
         add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' );
217 217
     }
218 218
 
219
-	if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
220
-		add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' );
221
-	}
219
+    if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
220
+        add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' );
221
+    }
222 222
 
223
-	if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
224
-		add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' );
225
-	}
223
+    if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
224
+        add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' );
225
+    }
226 226
 
227
-	if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
228
-		add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' );
229
-	}
227
+    if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
228
+        add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' );
229
+    }
230 230
     
231
-	if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) {
232
-		$message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID );
231
+    if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) {
232
+        $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID );
233 233
 
234
-		if ( !empty( $message ) ) {
235
-			add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' );
236
-		}
237
-	}
234
+        if ( !empty( $message ) ) {
235
+            add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' );
236
+        }
237
+    }
238 238
 
239
-	settings_errors( 'wpinv-notices' );
239
+    settings_errors( 'wpinv-notices' );
240 240
 }
241 241
 add_action( 'admin_notices', 'wpinv_admin_messages' );
242 242
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
         break;
327 327
         case 'id' :
328 328
            echo $post->ID;
329
-           echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '">
329
+            echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '">
330 330
                     <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>';
331 331
                     if ( $wpinv_euvat->allow_vat_rules() ) {
332 332
                         echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>';
Please login to merge, or discard this patch.
Spacing   +232 added lines, -232 removed lines patch added patch discarded remove patch
@@ -7,245 +7,245 @@  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
-function wpinv_columns( $columns ) {
14
+function wpinv_columns($columns) {
15 15
     $columns = array(
16 16
         'cb'                => $columns['cb'],
17
-        'number'            => __( 'Number', 'invoicing' ),
18
-        'customer'          => __( 'Customer', 'invoicing' ),
19
-        'amount'            => __( 'Amount', 'invoicing' ),
20
-        'invoice_date'      => __( 'Created Date', 'invoicing' ),
21
-        'payment_date'      => __( 'Payment Date', 'invoicing' ),
22
-        'status'            => __( 'Status', 'invoicing' ),
23
-        'ID'                => __( 'ID', 'invoicing' ),
24
-        'wpi_actions'       => __( 'Actions', 'invoicing' ),
17
+        'number'            => __('Number', 'invoicing'),
18
+        'customer'          => __('Customer', 'invoicing'),
19
+        'amount'            => __('Amount', 'invoicing'),
20
+        'invoice_date'      => __('Created Date', 'invoicing'),
21
+        'payment_date'      => __('Payment Date', 'invoicing'),
22
+        'status'            => __('Status', 'invoicing'),
23
+        'ID'                => __('ID', 'invoicing'),
24
+        'wpi_actions'       => __('Actions', 'invoicing'),
25 25
     );
26 26
 
27
-    return apply_filters( 'wpi_invoice_table_columns', $columns );
27
+    return apply_filters('wpi_invoice_table_columns', $columns);
28 28
 }
29
-add_filter( 'manage_wpi_invoice_posts_columns', 'wpinv_columns' );
29
+add_filter('manage_wpi_invoice_posts_columns', 'wpinv_columns');
30 30
 
31
-function wpinv_bulk_actions( $actions ) {
32
-    if ( isset( $actions['edit'] ) ) {
33
-        unset( $actions['edit'] );
31
+function wpinv_bulk_actions($actions) {
32
+    if (isset($actions['edit'])) {
33
+        unset($actions['edit']);
34 34
     }
35 35
 
36 36
     return $actions;
37 37
 }
38
-add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' );
39
-add_filter( 'bulk_actions-edit-wpi_item', 'wpinv_bulk_actions' );
38
+add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions');
39
+add_filter('bulk_actions-edit-wpi_item', 'wpinv_bulk_actions');
40 40
 
41
-function wpinv_sortable_columns( $columns ) {
41
+function wpinv_sortable_columns($columns) {
42 42
     $columns = array(
43
-        'ID'            => array( 'ID', true ),
44
-        'number'        => array( 'number', false ),
45
-        'amount'        => array( 'amount', false ),
46
-        'invoice_date'  => array( 'date', false ),
47
-        'payment_date'  => array( 'payment_date', true ),
48
-        'customer'      => array( 'customer', false ),
49
-        'status'        => array( 'status', false ),
43
+        'ID'            => array('ID', true),
44
+        'number'        => array('number', false),
45
+        'amount'        => array('amount', false),
46
+        'invoice_date'  => array('date', false),
47
+        'payment_date'  => array('payment_date', true),
48
+        'customer'      => array('customer', false),
49
+        'status'        => array('status', false),
50 50
     );
51 51
     
52
-    return apply_filters( 'wpi_invoice_table_sortable_columns', $columns );
52
+    return apply_filters('wpi_invoice_table_sortable_columns', $columns);
53 53
 }
54
-add_filter( 'manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns' );
54
+add_filter('manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns');
55 55
 
56
-add_action( 'manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column');
57
-function wpinv_posts_custom_column( $column_name, $post_id = 0 ) {
56
+add_action('manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column');
57
+function wpinv_posts_custom_column($column_name, $post_id = 0) {
58 58
     global $post, $wpi_invoice;
59 59
     
60
-    if ( empty( $wpi_invoice ) || ( !empty( $wpi_invoice ) && $post->ID != $wpi_invoice->ID ) ) {
61
-        $wpi_invoice = new WPInv_Invoice( $post->ID );
60
+    if (empty($wpi_invoice) || (!empty($wpi_invoice) && $post->ID != $wpi_invoice->ID)) {
61
+        $wpi_invoice = new WPInv_Invoice($post->ID);
62 62
     }
63 63
 
64 64
     $value = NULL;
65 65
     
66
-    switch ( $column_name ) {
66
+    switch ($column_name) {
67 67
         case 'email' :
68
-            $value   = $wpi_invoice->get_email();
68
+            $value = $wpi_invoice->get_email();
69 69
             break;
70 70
         case 'customer' :
71 71
             $customer_name = $wpi_invoice->get_user_full_name();
72
-            $customer_name = $customer_name != '' ? $customer_name : __( 'Customer', 'invoicing' );
73
-            $value = '<a href="' . esc_url( get_edit_user_link( $wpi_invoice->get_user_id() ) ) . '">' . $customer_name . '</a>';
74
-            if ( $email = $wpi_invoice->get_email() ) {
72
+            $customer_name = $customer_name != '' ? $customer_name : __('Customer', 'invoicing');
73
+            $value = '<a href="' . esc_url(get_edit_user_link($wpi_invoice->get_user_id())) . '">' . $customer_name . '</a>';
74
+            if ($email = $wpi_invoice->get_email()) {
75 75
                 $value .= '<br><a class="email" href="mailto:' . $email . '">' . $email . '</a>';
76 76
             }
77 77
             break;
78 78
         case 'amount' :
79
-            echo $wpi_invoice->get_total( true );
79
+            echo $wpi_invoice->get_total(true);
80 80
             break;
81 81
         case 'invoice_date' :
82
-            $date_format = get_option( 'date_format' );
82
+            $date_format = get_option('date_format');
83 83
             
84 84
             $m_time = $post->post_date;
85
-            $h_time = mysql2date( $date_format, $m_time );
85
+            $h_time = mysql2date($date_format, $m_time);
86 86
             
87
-            $value   = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>';
87
+            $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>';
88 88
             break;
89 89
         case 'payment_date' :
90
-            if ( $date_completed = $wpi_invoice->get_meta( '_wpinv_completed_date', true ) ) {
91
-                $date_format = get_option( 'date_format' );
90
+            if ($date_completed = $wpi_invoice->get_meta('_wpinv_completed_date', true)) {
91
+                $date_format = get_option('date_format');
92 92
                 
93 93
                 $m_time = $date_completed;
94
-                $h_time = mysql2date( $date_format, $m_time );
94
+                $h_time = mysql2date($date_format, $m_time);
95 95
                 
96
-                $value   = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>';
96
+                $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>';
97 97
             } else {
98 98
                 $value = '-';
99 99
             }
100 100
             break;
101 101
         case 'status' :
102
-            $value   = $wpi_invoice->get_status( true ) . ( $wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '' );
103
-            $is_viewed = wpinv_is_invoice_viewed( $wpi_invoice->ID );
104
-	        $gateway_title = wpinv_get_gateway_admin_label( $wpi_invoice->get_gateway() );
102
+            $value = $wpi_invoice->get_status(true) . ($wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : '');
103
+            $is_viewed = wpinv_is_invoice_viewed($wpi_invoice->ID);
104
+	        $gateway_title = wpinv_get_gateway_admin_label($wpi_invoice->get_gateway());
105 105
 	        $offline_gateways = apply_filters('wpinv_offline_payments', array('bank_transfer', 'cheque', 'cod'));
106 106
 	        $is_offline_payment = in_array($wpi_invoice->get_gateway(), $offline_gateways) ? true : false;
107 107
 
108
-            if ( 1 == $is_viewed ) {
109
-                $value .= '&nbsp;&nbsp;<i class="fa fa-eye" title="'.__( 'Viewed by Customer', 'invoicing' ).'"></i>';
108
+            if (1 == $is_viewed) {
109
+                $value .= '&nbsp;&nbsp;<i class="fa fa-eye" title="' . __('Viewed by Customer', 'invoicing') . '"></i>';
110 110
             }
111
-            if ( ( $wpi_invoice->is_paid() || $wpi_invoice->is_refunded() || $is_offline_payment ) && ( isset( $gateway_title ) ) ) {
112
-                $value .= '<br><small class="meta gateway">' . wp_sprintf( __( 'Via %s', 'invoicing' ), $gateway_title ) . '</small>';
111
+            if (($wpi_invoice->is_paid() || $wpi_invoice->is_refunded() || $is_offline_payment) && (isset($gateway_title))) {
112
+                $value .= '<br><small class="meta gateway">' . wp_sprintf(__('Via %s', 'invoicing'), $gateway_title) . '</small>';
113 113
             }
114 114
             break;
115 115
         case 'number' :
116
-            $edit_link = get_edit_post_link( $post->ID );
117
-            $value = '<a title="' . esc_attr__( 'View Invoice Details', 'invoicing' ) . '" href="' . esc_url( $edit_link ) . '">' . $wpi_invoice->get_number() . '</a>';
116
+            $edit_link = get_edit_post_link($post->ID);
117
+            $value = '<a title="' . esc_attr__('View Invoice Details', 'invoicing') . '" href="' . esc_url($edit_link) . '">' . $wpi_invoice->get_number() . '</a>';
118 118
             break;
119 119
         case 'wpi_actions' :
120 120
             $value = '';
121
-            if ( !empty( $post->post_name ) ) {
122
-                $value .= '<a title="' . esc_attr__( 'Print invoice', 'invoicing' ) . '" href="' . esc_url( get_permalink( $post->ID ) ) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>';
121
+            if (!empty($post->post_name)) {
122
+                $value .= '<a title="' . esc_attr__('Print invoice', 'invoicing') . '" href="' . esc_url(get_permalink($post->ID)) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>';
123 123
             }
124 124
             
125
-            if ( $email = $wpi_invoice->get_email() ) {
126
-                $value .= '<a title="' . esc_attr__( 'Send invoice to customer', 'invoicing' ) . '" href="' . esc_url( add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) ) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>';
125
+            if ($email = $wpi_invoice->get_email()) {
126
+                $value .= '<a title="' . esc_attr__('Send invoice to customer', 'invoicing') . '" href="' . esc_url(add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID))) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>';
127 127
             }
128 128
             
129 129
             break;
130 130
         default:
131
-            $value = isset( $post->$column_name ) ? $post->$column_name : '';
131
+            $value = isset($post->$column_name) ? $post->$column_name : '';
132 132
             break;
133 133
 
134 134
     }
135
-    $value = apply_filters( 'wpinv_payments_table_column', $value, $post->ID, $column_name );
135
+    $value = apply_filters('wpinv_payments_table_column', $value, $post->ID, $column_name);
136 136
     
137
-    if ( $value !== NULL ) {
137
+    if ($value !== NULL) {
138 138
         echo $value;
139 139
     }
140 140
 }
141 141
 
142
-function wpinv_admin_post_id( $id = 0 ) {
142
+function wpinv_admin_post_id($id = 0) {
143 143
     global $post;
144 144
 
145
-    if ( isset( $id ) && ! empty( $id ) ) {
145
+    if (isset($id) && !empty($id)) {
146 146
         return (int)$id;
147
-    } else if ( get_the_ID() ) {
148
-        return (int) get_the_ID();
149
-    } else if ( isset( $post->ID ) && !empty( $post->ID ) ) {
150
-        return (int) $post->ID;
151
-    } else if ( isset( $_GET['post'] ) && !empty( $_GET['post'] ) ) {
152
-        return (int) $_GET['post'];
153
-    } else if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) {
154
-        return (int) $_GET['id'];
155
-    } else if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) {
156
-        return (int) $_POST['id'];
147
+    } else if (get_the_ID()) {
148
+        return (int)get_the_ID();
149
+    } else if (isset($post->ID) && !empty($post->ID)) {
150
+        return (int)$post->ID;
151
+    } else if (isset($_GET['post']) && !empty($_GET['post'])) {
152
+        return (int)$_GET['post'];
153
+    } else if (isset($_GET['id']) && !empty($_GET['id'])) {
154
+        return (int)$_GET['id'];
155
+    } else if (isset($_POST['id']) && !empty($_POST['id'])) {
156
+        return (int)$_POST['id'];
157 157
     } 
158 158
 
159 159
     return null;
160 160
 }
161 161
     
162
-function wpinv_admin_post_type( $id = 0 ) {
163
-    if ( !$id ) {
162
+function wpinv_admin_post_type($id = 0) {
163
+    if (!$id) {
164 164
         $id = wpinv_admin_post_id();
165 165
     }
166 166
     
167
-    $type = get_post_type( $id );
167
+    $type = get_post_type($id);
168 168
     
169
-    if ( !$type ) {
170
-        $type = isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) ? $_GET['post_type'] : null;
169
+    if (!$type) {
170
+        $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? $_GET['post_type'] : null;
171 171
     }
172 172
     
173
-    return apply_filters( 'wpinv_admin_post_type', $type, $id );
173
+    return apply_filters('wpinv_admin_post_type', $type, $id);
174 174
 }
175 175
 
176 176
 function wpinv_admin_messages() {
177 177
 	global $wpinv_options, $pagenow, $post;
178 178
 
179
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
180
-		 add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' );
179
+	if (isset($_GET['wpinv-message']) && 'discount_added' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
180
+		 add_settings_error('wpinv-notices', 'wpinv-discount-added', __('Discount code added.', 'invoicing'), 'updated');
181 181
 	}
182 182
 
183
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
184
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' );
183
+	if (isset($_GET['wpinv-message']) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
184
+		add_settings_error('wpinv-notices', 'wpinv-discount-add-fail', __('There was a problem adding your discount code, please try again.', 'invoicing'), 'error');
185 185
 	}
186 186
 
187
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
188
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' );
187
+	if (isset($_GET['wpinv-message']) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
188
+		add_settings_error('wpinv-notices', 'wpinv-discount-exists', __('A discount with that code already exists, please use a different code.', 'invoicing'), 'error');
189 189
 	}
190 190
 
191
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
192
-		 add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' );
191
+	if (isset($_GET['wpinv-message']) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
192
+		 add_settings_error('wpinv-notices', 'wpinv-discount-updated', __('Discount code updated.', 'invoicing'), 'updated');
193 193
 	}
194 194
 
195
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
196
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' );
195
+	if (isset($_GET['wpinv-message']) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
196
+		add_settings_error('wpinv-notices', 'wpinv-discount-updated-fail', __('There was a problem updating your discount code, please try again.', 'invoicing'), 'error');
197 197
 	}
198 198
 
199
-	if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
200
-		add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' );
199
+	if (isset($_GET['wpinv-message']) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
200
+		add_settings_error('wpinv-notices', 'wpinv-deleted', __('The invoice has been deleted.', 'invoicing'), 'updated');
201 201
 	}
202 202
 
203
-	if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
204
-		add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' );
203
+	if (isset($_GET['wpinv-message']) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
204
+		add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Email notification is disabled. Please check settings.', 'invoicing'), 'error');
205 205
 	}
206 206
 
207
-	if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
208
-		add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' );
207
+	if (isset($_GET['wpinv-message']) && 'email_sent' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
208
+		add_settings_error('wpinv-notices', 'wpinv-sent', __('The email has been sent to customer.', 'invoicing'), 'updated');
209 209
     }
210 210
     
211
-    if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
212
-		add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' );
211
+    if (isset($_GET['wpinv-message']) && 'email_fail' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
212
+		add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Fail to send email to the customer.', 'invoicing'), 'error');
213 213
     }
214 214
 
215
-    if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
216
-        add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' );
215
+    if (isset($_GET['wpinv-message']) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
216
+        add_settings_error('wpinv-notices', 'wpinv-note-deleted', __('The invoice note has been deleted.', 'invoicing'), 'updated');
217 217
     }
218 218
 
219
-	if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
220
-		add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' );
219
+	if (isset($_GET['wpinv-message']) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
220
+		add_settings_error('wpinv-notices', 'wpinv-settings-imported', __('The settings have been imported.', 'invoicing'), 'updated');
221 221
 	}
222 222
 
223
-	if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
224
-		add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' );
223
+	if (isset($_GET['wpinv-message']) && 'note-added' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
224
+		add_settings_error('wpinv-notices', 'wpinv-note-added', __('The invoice note has been added successfully.', 'invoicing'), 'updated');
225 225
 	}
226 226
 
227
-	if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
228
-		add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' );
227
+	if (isset($_GET['wpinv-message']) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
228
+		add_settings_error('wpinv-notices', 'wpinv-updated', __('The invoice has been successfully updated.', 'invoicing'), 'updated');
229 229
 	}
230 230
     
231
-	if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) {
232
-		$message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID );
231
+	if ($pagenow == 'post.php' && !empty($post->post_type) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable($post)) {
232
+		$message = apply_filters('wpinv_item_non_editable_message', __('This item in not editable.', 'invoicing'), $post->ID);
233 233
 
234
-		if ( !empty( $message ) ) {
235
-			add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' );
234
+		if (!empty($message)) {
235
+			add_settings_error('wpinv-notices', 'wpinv-edit-n', $message, 'updated');
236 236
 		}
237 237
 	}
238 238
 
239
-	settings_errors( 'wpinv-notices' );
239
+	settings_errors('wpinv-notices');
240 240
 }
241
-add_action( 'admin_notices', 'wpinv_admin_messages' );
241
+add_action('admin_notices', 'wpinv_admin_messages');
242 242
 
243
-add_action( 'admin_init', 'wpinv_show_test_payment_gateway_notice' );
244
-function wpinv_show_test_payment_gateway_notice(){
245
-    add_action( 'admin_notices', 'wpinv_test_payment_gateway_messages' );
243
+add_action('admin_init', 'wpinv_show_test_payment_gateway_notice');
244
+function wpinv_show_test_payment_gateway_notice() {
245
+    add_action('admin_notices', 'wpinv_test_payment_gateway_messages');
246 246
 }
247 247
 
248
-function wpinv_test_payment_gateway_messages(){
248
+function wpinv_test_payment_gateway_messages() {
249 249
     $gateways = wpinv_get_enabled_payment_gateways();
250 250
     $name = array(); $test_gateways = '';
251 251
     if ($gateways) {
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
         }
257 257
         $test_gateways = implode(', ', $name);
258 258
     }
259
-    if(isset($test_gateways) && !empty($test_gateways)){
259
+    if (isset($test_gateways) && !empty($test_gateways)) {
260 260
         $link = admin_url('admin.php?page=wpinv-settings&tab=gateways');
261
-        $notice = wp_sprintf( __('<strong>Important:</strong> Payment Gateway(s) %s are in testing mode and will not receive real payments. Go to <a href="%s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link );
261
+        $notice = wp_sprintf(__('<strong>Important:</strong> Payment Gateway(s) %s are in testing mode and will not receive real payments. Go to <a href="%s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link);
262 262
         ?>
263 263
         <div class="notice notice-warning is-dismissible">
264 264
             <p><?php echo $notice; ?></p>
@@ -267,29 +267,29 @@  discard block
 block discarded – undo
267 267
     }
268 268
 }
269 269
 
270
-function wpinv_items_columns( $existing_columns ) {
270
+function wpinv_items_columns($existing_columns) {
271 271
     global $wpinv_euvat;
272 272
     
273 273
     $columns                = array();
274 274
     $columns['cb']          = $existing_columns['cb'];
275
-    $columns['title']       = __( 'Title', 'invoicing' );
276
-    $columns['price']       = __( 'Price', 'invoicing' );
277
-    if ( $wpinv_euvat->allow_vat_rules() ) {
278
-        $columns['vat_rule']    = __( 'VAT rule type', 'invoicing' );
275
+    $columns['title']       = __('Title', 'invoicing');
276
+    $columns['price']       = __('Price', 'invoicing');
277
+    if ($wpinv_euvat->allow_vat_rules()) {
278
+        $columns['vat_rule']    = __('VAT rule type', 'invoicing');
279 279
     }
280
-    if ( $wpinv_euvat->allow_vat_classes() ) {
281
-        $columns['vat_class']   = __( 'VAT class', 'invoicing' );
280
+    if ($wpinv_euvat->allow_vat_classes()) {
281
+        $columns['vat_class']   = __('VAT class', 'invoicing');
282 282
     }
283
-    $columns['type']        = __( 'Type', 'invoicing' );
284
-    $columns['recurring']   = __( 'Recurring', 'invoicing' );
285
-    $columns['date']        = __( 'Date', 'invoicing' );
286
-    $columns['id']          = __( 'ID', 'invoicing' );
283
+    $columns['type']        = __('Type', 'invoicing');
284
+    $columns['recurring']   = __('Recurring', 'invoicing');
285
+    $columns['date']        = __('Date', 'invoicing');
286
+    $columns['id']          = __('ID', 'invoicing');
287 287
 
288
-    return apply_filters( 'wpinv_items_columns', $columns );
288
+    return apply_filters('wpinv_items_columns', $columns);
289 289
 }
290
-add_filter( 'manage_wpi_item_posts_columns', 'wpinv_items_columns' );
290
+add_filter('manage_wpi_item_posts_columns', 'wpinv_items_columns');
291 291
 
292
-function wpinv_items_sortable_columns( $columns ) {
292
+function wpinv_items_sortable_columns($columns) {
293 293
     $columns['price']       = 'price';
294 294
     $columns['vat_rule']    = 'vat_rule';
295 295
     $columns['vat_class']   = 'vat_class';
@@ -299,151 +299,151 @@  discard block
 block discarded – undo
299 299
 
300 300
     return $columns;
301 301
 }
302
-add_filter( 'manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns' );
302
+add_filter('manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns');
303 303
 
304
-function wpinv_items_table_custom_column( $column ) {
304
+function wpinv_items_table_custom_column($column) {
305 305
     global $wpinv_euvat, $post, $wpi_item;
306 306
     
307
-    if ( empty( $wpi_item ) || ( !empty( $wpi_item ) && $post->ID != $wpi_item->ID ) ) {
308
-        $wpi_item = new WPInv_Item( $post->ID );
307
+    if (empty($wpi_item) || (!empty($wpi_item) && $post->ID != $wpi_item->ID)) {
308
+        $wpi_item = new WPInv_Item($post->ID);
309 309
     }
310 310
 
311
-    switch ( $column ) {
311
+    switch ($column) {
312 312
         case 'price' :
313
-            echo wpinv_item_price( $post->ID );
313
+            echo wpinv_item_price($post->ID);
314 314
         break;
315 315
         case 'vat_rule' :
316
-            echo $wpinv_euvat->item_rule_label( $post->ID );
316
+            echo $wpinv_euvat->item_rule_label($post->ID);
317 317
         break;
318 318
         case 'vat_class' :
319
-            echo $wpinv_euvat->item_class_label( $post->ID );
319
+            echo $wpinv_euvat->item_class_label($post->ID);
320 320
         break;
321 321
         case 'type' :
322
-            echo wpinv_item_type( $post->ID ) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>';
322
+            echo wpinv_item_type($post->ID) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>';
323 323
         break;
324 324
         case 'recurring' :
325
-            echo ( wpinv_is_recurring_item( $post->ID ) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>' );
325
+            echo (wpinv_is_recurring_item($post->ID) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>');
326 326
         break;
327 327
         case 'id' :
328 328
            echo $post->ID;
329 329
            echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '">
330
-                    <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>';
331
-                    if ( $wpinv_euvat->allow_vat_rules() ) {
332
-                        echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>';
330
+                    <div class="price">' . wpinv_get_item_price($post->ID) . '</div>';
331
+                    if ($wpinv_euvat->allow_vat_rules()) {
332
+                        echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule($post->ID) . '</div>';
333 333
                     }
334
-                    if ( $wpinv_euvat->allow_vat_classes() ) {
335
-                        echo '<div class="vat_class">' . $wpinv_euvat->get_item_class( $post->ID ) . '</div>';
334
+                    if ($wpinv_euvat->allow_vat_classes()) {
335
+                        echo '<div class="vat_class">' . $wpinv_euvat->get_item_class($post->ID) . '</div>';
336 336
                     }
337
-                    echo '<div class="type">' . wpinv_get_item_type( $post->ID ) . '</div>
337
+                    echo '<div class="type">' . wpinv_get_item_type($post->ID) . '</div>
338 338
                 </div>';
339 339
         break;
340 340
     }
341 341
     
342
-    do_action( 'wpinv_items_table_column_item_' . $column, $wpi_item, $post );
342
+    do_action('wpinv_items_table_column_item_' . $column, $wpi_item, $post);
343 343
 }
344
-add_action( 'manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column' );
344
+add_action('manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column');
345 345
 
346 346
 function wpinv_add_items_filters() {
347 347
     global $wpinv_euvat, $typenow;
348 348
 
349 349
     // Checks if the current post type is 'item'
350
-    if ( $typenow == 'wpi_item') {
351
-        if ( $wpinv_euvat->allow_vat_rules() ) {
352
-            echo wpinv_html_select( array(
353
-                    'options'          => array_merge( array( '' => __( 'All VAT rules', 'invoicing' ) ), $wpinv_euvat->get_rules() ),
350
+    if ($typenow == 'wpi_item') {
351
+        if ($wpinv_euvat->allow_vat_rules()) {
352
+            echo wpinv_html_select(array(
353
+                    'options'          => array_merge(array('' => __('All VAT rules', 'invoicing')), $wpinv_euvat->get_rules()),
354 354
                     'name'             => 'vat_rule',
355 355
                     'id'               => 'vat_rule',
356
-                    'selected'         => ( isset( $_GET['vat_rule'] ) ? $_GET['vat_rule'] : '' ),
356
+                    'selected'         => (isset($_GET['vat_rule']) ? $_GET['vat_rule'] : ''),
357 357
                     'show_option_all'  => false,
358 358
                     'show_option_none' => false,
359 359
                     'class'            => 'gdmbx2-text-medium wpi_select2',
360
-                ) );
360
+                ));
361 361
         }
362 362
         
363
-        if ( $wpinv_euvat->allow_vat_classes() ) {
364
-            echo wpinv_html_select( array(
365
-                    'options'          => array_merge( array( '' => __( 'All VAT classes', 'invoicing' ) ), $wpinv_euvat->get_all_classes() ),
363
+        if ($wpinv_euvat->allow_vat_classes()) {
364
+            echo wpinv_html_select(array(
365
+                    'options'          => array_merge(array('' => __('All VAT classes', 'invoicing')), $wpinv_euvat->get_all_classes()),
366 366
                     'name'             => 'vat_class',
367 367
                     'id'               => 'vat_class',
368
-                    'selected'         => ( isset( $_GET['vat_class'] ) ? $_GET['vat_class'] : '' ),
368
+                    'selected'         => (isset($_GET['vat_class']) ? $_GET['vat_class'] : ''),
369 369
                     'show_option_all'  => false,
370 370
                     'show_option_none' => false,
371 371
                     'class'            => 'gdmbx2-text-medium wpi_select2',
372
-                ) );
372
+                ));
373 373
         }
374 374
             
375
-        echo wpinv_html_select( array(
376
-                'options'          => array_merge( array( '' => __( 'All item types', 'invoicing' ) ), wpinv_get_item_types() ),
375
+        echo wpinv_html_select(array(
376
+                'options'          => array_merge(array('' => __('All item types', 'invoicing')), wpinv_get_item_types()),
377 377
                 'name'             => 'type',
378 378
                 'id'               => 'type',
379
-                'selected'         => ( isset( $_GET['type'] ) ? $_GET['type'] : '' ),
379
+                'selected'         => (isset($_GET['type']) ? $_GET['type'] : ''),
380 380
                 'show_option_all'  => false,
381 381
                 'show_option_none' => false,
382 382
                 'class'            => 'gdmbx2-text-medium',
383
-            ) );
383
+            ));
384 384
 
385
-        if ( isset( $_REQUEST['all_posts'] ) && '1' === $_REQUEST['all_posts'] ) {
385
+        if (isset($_REQUEST['all_posts']) && '1' === $_REQUEST['all_posts']) {
386 386
             echo '<input type="hidden" name="all_posts" value="1" />';
387 387
         }
388 388
     }
389 389
 }
390
-add_action( 'restrict_manage_posts', 'wpinv_add_items_filters', 100 );
390
+add_action('restrict_manage_posts', 'wpinv_add_items_filters', 100);
391 391
 
392
-function wpinv_send_invoice_after_save( $invoice ) {
393
-    if ( empty( $_POST['wpi_save_send'] ) ) {
392
+function wpinv_send_invoice_after_save($invoice) {
393
+    if (empty($_POST['wpi_save_send'])) {
394 394
         return;
395 395
     }
396 396
     
397
-    if ( !empty( $invoice->ID ) && !empty( $invoice->post_type ) && 'wpi_invoice' == $invoice->post_type ) {
398
-        wpinv_user_invoice_notification( $invoice->ID );
397
+    if (!empty($invoice->ID) && !empty($invoice->post_type) && 'wpi_invoice' == $invoice->post_type) {
398
+        wpinv_user_invoice_notification($invoice->ID);
399 399
     }
400 400
 }
401
-add_action( 'wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1 );
401
+add_action('wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1);
402 402
 
403
-function wpinv_send_register_new_user( $data, $postarr ) {
404
-    if ( current_user_can( 'manage_options' ) && !empty( $data['post_type'] ) && ( 'wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'] ) ) {
405
-        $is_new_user = !empty( $postarr['wpinv_new_user'] ) ? true : false;
406
-        $email = !empty( $postarr['wpinv_email'] ) && $postarr['wpinv_email'] && is_email( $postarr['wpinv_email'] ) ? $postarr['wpinv_email'] : NULL;
403
+function wpinv_send_register_new_user($data, $postarr) {
404
+    if (current_user_can('manage_options') && !empty($data['post_type']) && ('wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'])) {
405
+        $is_new_user = !empty($postarr['wpinv_new_user']) ? true : false;
406
+        $email = !empty($postarr['wpinv_email']) && $postarr['wpinv_email'] && is_email($postarr['wpinv_email']) ? $postarr['wpinv_email'] : NULL;
407 407
         
408
-        if ( $is_new_user && $email && !email_exists( $email ) ) {
409
-            $first_name = !empty( $postarr['wpinv_first_name'] ) ? sanitize_text_field( $postarr['wpinv_first_name'] ) : '';
410
-            $last_name = !empty( $postarr['wpinv_last_name'] ) ? sanitize_text_field( $postarr['wpinv_last_name'] ) : '';
411
-            $display_name = $first_name || $last_name ? trim( $first_name . ' ' . $last_name ) : '';
412
-            $user_nicename = $display_name ? trim( $display_name ) : $email;
413
-            $user_company = !empty( $postarr['wpinv_company'] ) ? sanitize_text_field( $postarr['wpinv_company'] ) : '';
408
+        if ($is_new_user && $email && !email_exists($email)) {
409
+            $first_name = !empty($postarr['wpinv_first_name']) ? sanitize_text_field($postarr['wpinv_first_name']) : '';
410
+            $last_name = !empty($postarr['wpinv_last_name']) ? sanitize_text_field($postarr['wpinv_last_name']) : '';
411
+            $display_name = $first_name || $last_name ? trim($first_name . ' ' . $last_name) : '';
412
+            $user_nicename = $display_name ? trim($display_name) : $email;
413
+            $user_company = !empty($postarr['wpinv_company']) ? sanitize_text_field($postarr['wpinv_company']) : '';
414 414
             
415
-            $user_login = sanitize_user( str_replace( ' ', '', $display_name ), true );
416
-            if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) {
415
+            $user_login = sanitize_user(str_replace(' ', '', $display_name), true);
416
+            if (!(validate_username($user_login) && !username_exists($user_login))) {
417 417
                 $new_user_login = strstr($email, '@', true);
418
-                if ( validate_username( $user_login ) && username_exists( $user_login ) ) {
419
-                    $user_login = sanitize_user($new_user_login, true );
418
+                if (validate_username($user_login) && username_exists($user_login)) {
419
+                    $user_login = sanitize_user($new_user_login, true);
420 420
                 }
421
-                if ( validate_username( $user_login ) && username_exists( $user_login ) ) {
422
-                    $user_append_text = rand(10,1000);
423
-                    $user_login = sanitize_user($new_user_login.$user_append_text, true );
421
+                if (validate_username($user_login) && username_exists($user_login)) {
422
+                    $user_append_text = rand(10, 1000);
423
+                    $user_login = sanitize_user($new_user_login . $user_append_text, true);
424 424
                 }
425 425
                 
426
-                if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) {
426
+                if (!(validate_username($user_login) && !username_exists($user_login))) {
427 427
                     $user_login = $email;
428 428
                 }
429 429
             }
430 430
             
431 431
             $userdata = array(
432 432
                 'user_login' => $user_login,
433
-                'user_pass' => wp_generate_password( 12, false ),
434
-                'user_email' => sanitize_text_field( $email ),
433
+                'user_pass' => wp_generate_password(12, false),
434
+                'user_email' => sanitize_text_field($email),
435 435
                 'first_name' => $first_name,
436 436
                 'last_name' => $last_name,
437
-                'user_nicename' => wpinv_utf8_substr( $user_nicename, 0, 50 ),
437
+                'user_nicename' => wpinv_utf8_substr($user_nicename, 0, 50),
438 438
                 'nickname' => $display_name,
439 439
                 'display_name' => $display_name,
440 440
             );
441 441
 
442
-            $userdata = apply_filters( 'wpinv_register_new_user_data', $userdata );
442
+            $userdata = apply_filters('wpinv_register_new_user_data', $userdata);
443 443
             
444
-            $new_user_id = wp_insert_user( $userdata );
444
+            $new_user_id = wp_insert_user($userdata);
445 445
             
446
-            if ( !is_wp_error( $new_user_id ) ) {
446
+            if (!is_wp_error($new_user_id)) {
447 447
                 $data['post_author'] = $new_user_id;
448 448
                 $_POST['post_author'] = $new_user_id;
449 449
                 $_POST['post_author_override'] = $new_user_id;
@@ -464,72 +464,72 @@  discard block
 block discarded – undo
464 464
                 
465 465
                 $meta = array();
466 466
                 ///$meta['_wpinv_user_id'] = $new_user_id;
467
-                foreach ( $meta_fields as $field ) {
468
-                    $meta['_wpinv_' . $field] = isset( $postarr['wpinv_' . $field] ) ? sanitize_text_field( $postarr['wpinv_' . $field] ) : '';
467
+                foreach ($meta_fields as $field) {
468
+                    $meta['_wpinv_' . $field] = isset($postarr['wpinv_' . $field]) ? sanitize_text_field($postarr['wpinv_' . $field]) : '';
469 469
                 }
470 470
                 
471
-                $meta = apply_filters( 'wpinv_register_new_user_meta', $meta, $new_user_id );
471
+                $meta = apply_filters('wpinv_register_new_user_meta', $meta, $new_user_id);
472 472
 
473 473
                 // Update user meta.
474
-                foreach ( $meta as $key => $value ) {
475
-                    update_user_meta( $new_user_id, $key, $value );
474
+                foreach ($meta as $key => $value) {
475
+                    update_user_meta($new_user_id, $key, $value);
476 476
                 }
477 477
                 
478
-                if ( function_exists( 'wp_send_new_user_notifications' ) ) {
478
+                if (function_exists('wp_send_new_user_notifications')) {
479 479
                     // Send email notifications related to the creation of new user.
480
-                    wp_send_new_user_notifications( $new_user_id, 'user' );
480
+                    wp_send_new_user_notifications($new_user_id, 'user');
481 481
                 }
482 482
             } else {
483
-                wpinv_error_log( $new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__ );
483
+                wpinv_error_log($new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__);
484 484
             }
485 485
         }
486 486
     }
487 487
     
488 488
     return $data;
489 489
 }
490
-add_filter( 'wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2 );
490
+add_filter('wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2);
491 491
 
492
-function wpinv_show_recurring_supported_gateways( $item_ID ) {
492
+function wpinv_show_recurring_supported_gateways($item_ID) {
493 493
     $all_gateways = wpinv_get_payment_gateways();
494 494
 
495
-    if ( !empty( $all_gateways ) ) {
495
+    if (!empty($all_gateways)) {
496 496
         $gateways = array();
497 497
 
498
-        foreach ( $all_gateways as $key => $gateway ) {
499
-            if ( wpinv_gateway_support_subscription( $key ) ) {
498
+        foreach ($all_gateways as $key => $gateway) {
499
+            if (wpinv_gateway_support_subscription($key)) {
500 500
                 $gateways[] = $gateway['admin_label'];
501 501
             }
502 502
         }
503 503
 
504
-        if ( !empty( $gateways ) ) {
504
+        if (!empty($gateways)) {
505 505
             ?>
506
-            <span class="description"><?php echo wp_sprintf( __( 'Recurring payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ); ?></span>
506
+            <span class="description"><?php echo wp_sprintf(__('Recurring payments only supported by: %s', 'invoicing'), implode(', ', $gateways)); ?></span>
507 507
             <?php
508 508
         }
509 509
     }
510 510
 }
511
-add_action( 'wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1 );
511
+add_action('wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1);
512 512
 
513
-function wpinv_post_updated_messages( $messages ) {
513
+function wpinv_post_updated_messages($messages) {
514 514
     global $post, $post_ID;
515 515
 
516 516
     $messages['wpi_discount'] = array(
517 517
         0   => '',
518
-        1   => __( 'Discount updated.', 'invoicing' ),
519
-        2   => __( 'Custom field updated.', 'invoicing' ),
520
-        3   => __( 'Custom field deleted.', 'invoicing' ),
521
-        4   => __( 'Discount updated.', 'invoicing' ),
522
-        5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
523
-        6   => __( 'Discount updated.', 'invoicing' ),
524
-        7   => __( 'Discount saved.', 'invoicing' ),
525
-        8   => __( 'Discount submitted.', 'invoicing' ),
526
-        9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
527
-        10  => __( 'Discount draft updated.', 'invoicing' ),
518
+        1   => __('Discount updated.', 'invoicing'),
519
+        2   => __('Custom field updated.', 'invoicing'),
520
+        3   => __('Custom field deleted.', 'invoicing'),
521
+        4   => __('Discount updated.', 'invoicing'),
522
+        5   => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int)$_GET['revision'], false)) : false,
523
+        6   => __('Discount updated.', 'invoicing'),
524
+        7   => __('Discount saved.', 'invoicing'),
525
+        8   => __('Discount submitted.', 'invoicing'),
526
+        9   => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
527
+        10  => __('Discount draft updated.', 'invoicing'),
528 528
     );
529 529
 
530 530
     return $messages;
531 531
 }
532
-add_filter( 'post_updated_messages', 'wpinv_post_updated_messages', 10, 1 );
532
+add_filter('post_updated_messages', 'wpinv_post_updated_messages', 10, 1);
533 533
 
534 534
 add_action('admin_init', 'admin_init_example_type');
535 535
 
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
 function admin_init_example_type() {
540 540
     global $typenow;
541 541
 
542
-    if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote' ) {
542
+    if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote') {
543 543
         add_filter('posts_search', 'posts_search_example_type', 10, 2);
544 544
     }
545 545
 }
@@ -554,9 +554,9 @@  discard block
 block discarded – undo
554 554
     global $wpdb;
555 555
 
556 556
     if ($query->is_main_query() && !empty($query->query['s'])) {
557
-        $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql( $query->query['s'] ) . "%' )";
558
-        if ( ! empty( $search ) ) {
559
-            $search = preg_replace( '/^ AND /', '', $search );
557
+        $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql($query->query['s']) . "%' )";
558
+        if (!empty($search)) {
559
+            $search = preg_replace('/^ AND /', '', $search);
560 560
             $search = " AND ( {$search} OR ( {$conditions_str} ) )";
561 561
         } else {
562 562
             $search = " AND ( {$conditions_str} )";
@@ -566,9 +566,9 @@  discard block
 block discarded – undo
566 566
     return $search;
567 567
 }
568 568
 
569
-add_action( 'admin_init', 'wpinv_reset_invoice_count' );
570
-function wpinv_reset_invoice_count(){
571
-    if(isset($_GET['reset_invoice_count']) && 1 == $_GET['reset_invoice_count'] && isset($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'reset_invoice_count')) {
569
+add_action('admin_init', 'wpinv_reset_invoice_count');
570
+function wpinv_reset_invoice_count() {
571
+    if (isset($_GET['reset_invoice_count']) && 1 == $_GET['reset_invoice_count'] && isset($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'reset_invoice_count')) {
572 572
         wpinv_update_option('invoice_sequence_start', 1);
573 573
         delete_option('wpinv_last_invoice_number');
574 574
         $url = add_query_arg(array('reset_invoice_done' => 1));
@@ -579,8 +579,8 @@  discard block
 block discarded – undo
579 579
 }
580 580
 
581 581
 add_action('admin_notices', 'wpinv_invoice_count_reset_message');
582
-function wpinv_invoice_count_reset_message(){
583
-    if(isset($_GET['reset_invoice_done']) && 1 == $_GET['reset_invoice_done']) {
582
+function wpinv_invoice_count_reset_message() {
583
+    if (isset($_GET['reset_invoice_done']) && 1 == $_GET['reset_invoice_done']) {
584 584
         $notice = __('Invoice number sequence reset successfully.', 'invoicing');
585 585
         ?>
586 586
         <div class="notice notice-success is-dismissible">
Please login to merge, or discard this patch.
includes/admin/html-admin-page-addons.php 3 patches
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 			</div>
127 127
 		</div>
128 128
 			<?php
129
-		}else{
129
+		} else{
130 130
 			$installed_plugins = get_plugins();
131 131
             $addon_obj = new WPInv_Admin_Addons();
132 132
 			if ($addons = $addon_obj->get_section_data( $current_tab ) ) :
@@ -151,14 +151,14 @@  discard block
 block discarded – undo
151 151
 										echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&width=770&height=660&TB_iframe=true" class="thickbox" >';
152 152
 										echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
153 153
 										echo '</a>';
154
-									}elseif(isset($addon->info->link) && substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com"){
154
+									} elseif(isset($addon->info->link) && substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com"){
155 155
 										if(defined('WP_EASY_UPDATES_ACTIVE')){
156 156
 											$url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpinvoicing.com&TB_iframe=true');
157
-										}else{
157
+										} else{
158 158
 											// if installed show activation link
159 159
 											if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){
160 160
 												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation';
161
-											}else{
161
+											} else{
162 162
 												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external';
163 163
 											}
164 164
 										}
Please login to merge, or discard this patch.
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 if ( ! defined( 'ABSPATH' ) ) {
7
-	exit;
7
+    exit;
8 8
 }
9 9
 add_ThickBox();
10 10
 ?>
@@ -14,18 +14,18 @@  discard block
 block discarded – undo
14 14
 	<?php if ( $tabs ){ ?>
15 15
 		<nav class="nav-tab-wrapper wpi-nav-tab-wrapper">
16 16
 			<?php
17
-			foreach ( $tabs as $name => $label ) {
18
-				echo '<a href="' . admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>';
19
-			}
20
-			do_action( 'wpi_addons_tabs' );
21
-			?>
17
+            foreach ( $tabs as $name => $label ) {
18
+                echo '<a href="' . admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>';
19
+            }
20
+            do_action( 'wpi_addons_tabs' );
21
+            ?>
22 22
 		</nav>
23 23
 
24 24
 		<?php
25 25
 
26
-		if($current_tab == 'membership'){
26
+        if($current_tab == 'membership'){
27 27
 
28
-			?>
28
+            ?>
29 29
 
30 30
 			<div class="wpi-membership-tab-conatiner">
31 31
 				<div class="membership-content">
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 					<h2><?php _e("Have a membership key?","invoicing");?></h2>
37 37
 					<p>
38 38
 						<?php
39
-						$wpeu_admin = new External_Updates_Admin('wpinvoicing.com','1');
40
-						echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership',array(95, 106, 108,12351));
41
-						?>
39
+                        $wpeu_admin = new External_Updates_Admin('wpinvoicing.com','1');
40
+                        echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership',array(95, 106, 108,12351));
41
+                        ?>
42 42
 					</p>
43 43
 				<?php }?>
44 44
 
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 							<div class="feature-list">
49 49
 								<ul>
50 50
 									<?php
51
-									$addon_obj = new WPInv_Admin_Addons();
52
-									if ($addons = $addon_obj->get_section_data( 'addons' ) ) {
53
-										foreach ( $addons as $addon ) {
54
-											echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>';
55
-										}
56
-									}
57
-									?>
51
+                                    $addon_obj = new WPInv_Admin_Addons();
52
+                                    if ($addons = $addon_obj->get_section_data( 'addons' ) ) {
53
+                                        foreach ( $addons as $addon ) {
54
+                                            echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>';
55
+                                        }
56
+                                    }
57
+                                    ?>
58 58
 									</ul>
59 59
 
60 60
 									<div class="feature-cta">
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
 									<h3><?php _e("Included Gateways:","invoicing");?></h3>
66 66
 									<ul>
67 67
 										<?php
68
-										if ($addons = $addon_obj->get_section_data( 'gateways' ) ) {
69
-											foreach ( $addons as $addon ) {
70
-												echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>';
71
-											}
72
-										}
73
-										?>
68
+                                        if ($addons = $addon_obj->get_section_data( 'gateways' ) ) {
69
+                                            foreach ( $addons as $addon ) {
70
+                                                echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>';
71
+                                            }
72
+                                        }
73
+                                        ?>
74 74
 								</ul>
75 75
 							</div>
76 76
 
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 						<div class="testimonial-content">
82 82
 							<div class="t-image">
83 83
 								<?php
84
-									echo '<img src="' . plugins_url( 'images/t-image2.png', dirname(__FILE__) ) . '" > ';
85
-								?>
84
+                                    echo '<img src="' . plugins_url( 'images/t-image2.png', dirname(__FILE__) ) . '" > ';
85
+                                ?>
86 86
 							</div>
87 87
 							<div class="t-content">
88 88
 								<p>
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 						<div class="testimonial-content">
102 102
 							<div class="t-image">
103 103
 								<?php
104
-									echo '<img src="' . plugins_url( 'images/t-image1.png', dirname(__FILE__) ) . '" > ';
105
-								?>
104
+                                    echo '<img src="' . plugins_url( 'images/t-image1.png', dirname(__FILE__) ) . '" > ';
105
+                                ?>
106 106
 							</div>
107 107
 							<div class="t-content">
108 108
 								<p>
@@ -126,20 +126,20 @@  discard block
 block discarded – undo
126 126
 			</div>
127 127
 		</div>
128 128
 			<?php
129
-		}else{
130
-			$installed_plugins = get_plugins();
129
+        }else{
130
+            $installed_plugins = get_plugins();
131 131
             $addon_obj = new WPInv_Admin_Addons();
132
-			if ($addons = $addon_obj->get_section_data( $current_tab ) ) :
133
-				?>
132
+            if ($addons = $addon_obj->get_section_data( $current_tab ) ) :
133
+                ?>
134 134
 				<ul class="wpi-products"><?php foreach ( $addons as $addon ) :
135 135
                         if(965==$addon->info->id){continue;}// don't show quote add on
136
-						?><li class="wpi-product">
136
+                        ?><li class="wpi-product">
137 137
 								<div class="wpi-product-title">
138 138
 									<h3><?php
139
-										if ( ! empty( $addon->info->excerpt) ){
140
-											echo wpi_help_tip( $addon->info->excerpt );
141
-										}
142
-										echo esc_html( $addon->info->title ); ?></h3>
139
+                                        if ( ! empty( $addon->info->excerpt) ){
140
+                                            echo wpi_help_tip( $addon->info->excerpt );
141
+                                        }
142
+                                        echo esc_html( $addon->info->title ); ?></h3>
143 143
 								</div>
144 144
 
145 145
 								<span class="wpi-product-image">
@@ -147,27 +147,27 @@  discard block
 block discarded – undo
147 147
 										<img src="<?php echo esc_attr( $addon->info->thumbnail ); ?>"/>
148 148
 									<?php endif;
149 149
 
150
-									if(isset($addon->info->link) && substr( $addon->info->link, 0, 21 ) === "https://wordpress.org"){
151
-										echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&width=770&height=660&TB_iframe=true" class="thickbox" >';
152
-										echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
153
-										echo '</a>';
154
-									}elseif(isset($addon->info->link) && substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com"){
155
-										if(defined('WP_EASY_UPDATES_ACTIVE')){
156
-											$url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpinvoicing.com&TB_iframe=true');
157
-										}else{
158
-											// if installed show activation link
159
-											if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){
160
-												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation';
161
-											}else{
162
-												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external';
163
-											}
164
-										}
165
-										echo '<a href="'.$url.'" class="thickbox">';
166
-										echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
167
-										echo '</a>';
168
-									}
169
-
170
-									?>
150
+                                    if(isset($addon->info->link) && substr( $addon->info->link, 0, 21 ) === "https://wordpress.org"){
151
+                                        echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&width=770&height=660&TB_iframe=true" class="thickbox" >';
152
+                                        echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
153
+                                        echo '</a>';
154
+                                    }elseif(isset($addon->info->link) && substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com"){
155
+                                        if(defined('WP_EASY_UPDATES_ACTIVE')){
156
+                                            $url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpinvoicing.com&TB_iframe=true');
157
+                                        }else{
158
+                                            // if installed show activation link
159
+                                            if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){
160
+                                                $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation';
161
+                                            }else{
162
+                                                $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external';
163
+                                            }
164
+                                        }
165
+                                        echo '<a href="'.$url.'" class="thickbox">';
166
+                                        echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
167
+                                        echo '</a>';
168
+                                    }
169
+
170
+                                    ?>
171 171
 
172 172
 								</span>
173 173
 
@@ -175,15 +175,15 @@  discard block
 block discarded – undo
175 175
 								<span class="wpi-product-button">
176 176
 									<?php
177 177
                                     $addon_obj->output_button( $addon );
178
-									?>
178
+                                    ?>
179 179
 								</span>
180 180
 
181 181
 								<span class="wpi-price"><?php //print_r($addon); //echo wp_kses_post( $addon->price ); ?></span></li><?php endforeach; ?></ul>
182 182
 			<?php endif;
183
-		}
183
+        }
184 184
 
185
-	}
186
-	?>
185
+    }
186
+    ?>
187 187
 
188 188
 
189 189
 	<div class="clearfix" ></div>
@@ -202,8 +202,8 @@  discard block
 block discarded – undo
202 202
 			<input class="wpeu-licence-key" type="text" placeholder="<?php _e("Enter your licence key",'invoicing');?>"> <button class="button-primary wpeu-licence-popup-button" ><?php _e("Install",'invoicing');?></button>
203 203
 			<br>
204 204
 			<?php
205
-			echo sprintf( __('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">','</a>','<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">','</a>' );
206
-			?>
205
+            echo sprintf( __('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">','</a>','<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">','</a>' );
206
+            ?>
207 207
 		</span>
208 208
 	</div>
209 209
 
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Admin View: Page - Addons
4 4
  *
5 5
  */
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if (!defined('ABSPATH')) {
7 7
 	exit;
8 8
 }
9 9
 add_ThickBox();
@@ -11,19 +11,19 @@  discard block
 block discarded – undo
11 11
 <div class="wrap wpi_addons_wrap">
12 12
 	<h1><?php echo get_admin_page_title(); ?></h1>
13 13
 
14
-	<?php if ( $tabs ){ ?>
14
+	<?php if ($tabs) { ?>
15 15
 		<nav class="nav-tab-wrapper wpi-nav-tab-wrapper">
16 16
 			<?php
17
-			foreach ( $tabs as $name => $label ) {
18
-				echo '<a href="' . admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>';
17
+			foreach ($tabs as $name => $label) {
18
+				echo '<a href="' . admin_url('admin.php?page=wpi-addons&tab=' . $name) . '" class="nav-tab ' . ($current_tab == $name ? 'nav-tab-active' : '') . '">' . $label . '</a>';
19 19
 			}
20
-			do_action( 'wpi_addons_tabs' );
20
+			do_action('wpi_addons_tabs');
21 21
 			?>
22 22
 		</nav>
23 23
 
24 24
 		<?php
25 25
 
26
-		if($current_tab == 'membership'){
26
+		if ($current_tab == 'membership') {
27 27
 
28 28
 			?>
29 29
 
@@ -32,42 +32,42 @@  discard block
 block discarded – undo
32 32
 <!--
33 33
 				<h2>With our WPInvoicing Membership you get access to all our products!</h2>
34 34
 				<p><a class="button button-primary" href="https://wpinvoicing.com/downloads/membership/">View Memberships</a></p>-->
35
-				<?php if(defined('WP_EASY_UPDATES_ACTIVE')){?>
36
-					<h2><?php _e("Have a membership key?","invoicing");?></h2>
35
+				<?php if (defined('WP_EASY_UPDATES_ACTIVE')) {?>
36
+					<h2><?php _e("Have a membership key?", "invoicing"); ?></h2>
37 37
 					<p>
38 38
 						<?php
39
-						$wpeu_admin = new External_Updates_Admin('wpinvoicing.com','1');
40
-						echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership',array(95, 106, 108,12351));
39
+						$wpeu_admin = new External_Updates_Admin('wpinvoicing.com', '1');
40
+						echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership', array(95, 106, 108, 12351));
41 41
 						?>
42 42
 					</p>
43 43
 				<?php }?>
44 44
 
45 45
 				<div class="membership-cta-contet">
46 46
 					<div class="main-cta">
47
-							<h2><?php _e("Membership benefits Include:","invoicing");?></h2>
47
+							<h2><?php _e("Membership benefits Include:", "invoicing"); ?></h2>
48 48
 							<div class="feature-list">
49 49
 								<ul>
50 50
 									<?php
51 51
 									$addon_obj = new WPInv_Admin_Addons();
52
-									if ($addons = $addon_obj->get_section_data( 'addons' ) ) {
53
-										foreach ( $addons as $addon ) {
54
-											echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>';
52
+									if ($addons = $addon_obj->get_section_data('addons')) {
53
+										foreach ($addons as $addon) {
54
+											echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html($addon->info->title) . '</li>';
55 55
 										}
56 56
 									}
57 57
 									?>
58 58
 									</ul>
59 59
 
60 60
 									<div class="feature-cta">
61
-										<h3><?php _e("Membership Starts from","invoicing");?></h3>
61
+										<h3><?php _e("Membership Starts from", "invoicing"); ?></h3>
62 62
 										<h4>$99</h4>
63
-										<a href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php _e("Buy Membership","invoicing");?></a>
63
+										<a href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php _e("Buy Membership", "invoicing"); ?></a>
64 64
 									</div>
65
-									<h3><?php _e("Included Gateways:","invoicing");?></h3>
65
+									<h3><?php _e("Included Gateways:", "invoicing"); ?></h3>
66 66
 									<ul>
67 67
 										<?php
68
-										if ($addons = $addon_obj->get_section_data( 'gateways' ) ) {
69
-											foreach ( $addons as $addon ) {
70
-												echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>';
68
+										if ($addons = $addon_obj->get_section_data('gateways')) {
69
+											foreach ($addons as $addon) {
70
+												echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html($addon->info->title) . '</li>';
71 71
 											}
72 72
 										}
73 73
 										?>
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 						<div class="testimonial-content">
82 82
 							<div class="t-image">
83 83
 								<?php
84
-									echo '<img src="' . plugins_url( 'images/t-image2.png', dirname(__FILE__) ) . '" > ';
84
+									echo '<img src="' . plugins_url('images/t-image2.png', dirname(__FILE__)) . '" > ';
85 85
 								?>
86 86
 							</div>
87 87
 							<div class="t-content">
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 						<div class="testimonial-content">
102 102
 							<div class="t-image">
103 103
 								<?php
104
-									echo '<img src="' . plugins_url( 'images/t-image1.png', dirname(__FILE__) ) . '" > ';
104
+									echo '<img src="' . plugins_url('images/t-image1.png', dirname(__FILE__)) . '" > ';
105 105
 								?>
106 106
 							</div>
107 107
 							<div class="t-content">
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
 						</div>
118 118
 					</div>
119 119
 					<div class="member-footer">
120
-						<a class="footer-btn" href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php _e("Buy Membership","invoicing");?></a>
121
-						<a class="footer-link" href="post-new.php?post_type=wpi_invoice"><?php _e("Create Invoice","invoicing");?></a>
120
+						<a class="footer-btn" href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php _e("Buy Membership", "invoicing"); ?></a>
121
+						<a class="footer-link" href="post-new.php?post_type=wpi_invoice"><?php _e("Create Invoice", "invoicing"); ?></a>
122 122
 					</div>
123 123
 				</div>
124 124
 
@@ -126,44 +126,44 @@  discard block
 block discarded – undo
126 126
 			</div>
127 127
 		</div>
128 128
 			<?php
129
-		}else{
129
+		} else {
130 130
 			$installed_plugins = get_plugins();
131 131
             $addon_obj = new WPInv_Admin_Addons();
132
-			if ($addons = $addon_obj->get_section_data( $current_tab ) ) :
132
+			if ($addons = $addon_obj->get_section_data($current_tab)) :
133 133
 				?>
134
-				<ul class="wpi-products"><?php foreach ( $addons as $addon ) :
135
-                        if(965==$addon->info->id){continue;}// don't show quote add on
134
+				<ul class="wpi-products"><?php foreach ($addons as $addon) :
135
+                        if (965 == $addon->info->id) {continue; }// don't show quote add on
136 136
 						?><li class="wpi-product">
137 137
 								<div class="wpi-product-title">
138 138
 									<h3><?php
139
-										if ( ! empty( $addon->info->excerpt) ){
140
-											echo wpi_help_tip( $addon->info->excerpt );
139
+										if (!empty($addon->info->excerpt)) {
140
+											echo wpi_help_tip($addon->info->excerpt);
141 141
 										}
142
-										echo esc_html( $addon->info->title ); ?></h3>
142
+										echo esc_html($addon->info->title); ?></h3>
143 143
 								</div>
144 144
 
145 145
 								<span class="wpi-product-image">
146
-									<?php if ( ! empty( $addon->info->thumbnail) ) : ?>
147
-										<img src="<?php echo esc_attr( $addon->info->thumbnail ); ?>"/>
146
+									<?php if (!empty($addon->info->thumbnail)) : ?>
147
+										<img src="<?php echo esc_attr($addon->info->thumbnail); ?>"/>
148 148
 									<?php endif;
149 149
 
150
-									if(isset($addon->info->link) && substr( $addon->info->link, 0, 21 ) === "https://wordpress.org"){
151
-										echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&width=770&height=660&TB_iframe=true" class="thickbox" >';
152
-										echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
150
+									if (isset($addon->info->link) && substr($addon->info->link, 0, 21) === "https://wordpress.org") {
151
+										echo '<a href="' . admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug) . '&width=770&height=660&TB_iframe=true" class="thickbox" >';
152
+										echo '<span class="wpi-product-info">' . __('More info', 'invoicing') . '</span>';
153 153
 										echo '</a>';
154
-									}elseif(isset($addon->info->link) && substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com"){
155
-										if(defined('WP_EASY_UPDATES_ACTIVE')){
156
-											$url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpinvoicing.com&TB_iframe=true');
157
-										}else{
154
+									}elseif (isset($addon->info->link) && substr($addon->info->link, 0, 23) === "https://wpinvoicing.com") {
155
+										if (defined('WP_EASY_UPDATES_ACTIVE')) {
156
+											$url = admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpinvoicing.com&TB_iframe=true');
157
+										} else {
158 158
 											// if installed show activation link
159
-											if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){
159
+											if (isset($installed_plugins['wp-easy-updates/external-updates.php'])) {
160 160
 												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation';
161
-											}else{
161
+											} else {
162 162
 												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external';
163 163
 											}
164 164
 										}
165
-										echo '<a href="'.$url.'" class="thickbox">';
166
-										echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
165
+										echo '<a href="' . $url . '" class="thickbox">';
166
+										echo '<span class="wpi-product-info">' . __('More info', 'invoicing') . '</span>';
167 167
 										echo '</a>';
168 168
 									}
169 169
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 
175 175
 								<span class="wpi-product-button">
176 176
 									<?php
177
-                                    $addon_obj->output_button( $addon );
177
+                                    $addon_obj->output_button($addon);
178 178
 									?>
179 179
 								</span>
180 180
 
@@ -188,21 +188,21 @@  discard block
 block discarded – undo
188 188
 
189 189
 	<div class="clearfix" ></div>
190 190
 
191
-	<?php if($current_tab =='addons'){ ?>
192
-	<p><?php printf( __( 'All of our Invoicing Addons can be found on WPInvoicing.com here: <a href="%s">Invoicing Addons</a>', 'invoicing' ), 'https://wpinvoicing.com/downloads/category/addons/' ); ?></p>
193
-	<?php } if($current_tab =='gateways'){  ?>
194
-    <p><?php printf( __( 'All of our Invoicing Payment Gateways can be found on WPInvoicing.com here: <a href="%s">Invoicing Payment Gateways</a>', 'invoicing' ), 'https://wpinvoicing.com/downloads/category/gateways/' ); ?></p>
191
+	<?php if ($current_tab == 'addons') { ?>
192
+	<p><?php printf(__('All of our Invoicing Addons can be found on WPInvoicing.com here: <a href="%s">Invoicing Addons</a>', 'invoicing'), 'https://wpinvoicing.com/downloads/category/addons/'); ?></p>
193
+	<?php } if ($current_tab == 'gateways') {  ?>
194
+    <p><?php printf(__('All of our Invoicing Payment Gateways can be found on WPInvoicing.com here: <a href="%s">Invoicing Payment Gateways</a>', 'invoicing'), 'https://wpinvoicing.com/downloads/category/gateways/'); ?></p>
195 195
     <?php } ?>
196 196
 
197
-	<div id="wpi-wpeu-required-activation" style="display:none;"><span class="wpi-notification "><?php printf( __("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s'>activate</a> it now.",'invoicing'),wp_nonce_url(admin_url('plugins.php?action=activate&plugin=wp-easy-updates/external-updates.php'), 'activate-plugin_wp-easy-updates/external-updates.php'));?></span></div>
198
-	<div id="wpi-wpeu-required-for-external" style="display:none;"><span class="wpi-notification "><?php printf(  __("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s' onclick='window.open(\"https://wpeasyupdates.com/wp-easy-updates.zip\", \"_blank\");' >download</a> and install it now.",'invoicing'),admin_url("plugin-install.php?tab=upload&wpeu-install=true"));?></span></div>
197
+	<div id="wpi-wpeu-required-activation" style="display:none;"><span class="wpi-notification "><?php printf(__("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s'>activate</a> it now.", 'invoicing'), wp_nonce_url(admin_url('plugins.php?action=activate&plugin=wp-easy-updates/external-updates.php'), 'activate-plugin_wp-easy-updates/external-updates.php')); ?></span></div>
198
+	<div id="wpi-wpeu-required-for-external" style="display:none;"><span class="wpi-notification "><?php printf(__("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s' onclick='window.open(\"https://wpeasyupdates.com/wp-easy-updates.zip\", \"_blank\");' >download</a> and install it now.", 'invoicing'), admin_url("plugin-install.php?tab=upload&wpeu-install=true")); ?></span></div>
199 199
 	<div id="wpeu-licence-popup" style="display:none;">
200 200
 		<span class="wpi-notification noti-white">
201
-			<h3 class="wpeu-licence-title"><?php _e("Licence key",'invoicing');?></h3>
202
-			<input class="wpeu-licence-key" type="text" placeholder="<?php _e("Enter your licence key",'invoicing');?>"> <button class="button-primary wpeu-licence-popup-button" ><?php _e("Install",'invoicing');?></button>
201
+			<h3 class="wpeu-licence-title"><?php _e("Licence key", 'invoicing'); ?></h3>
202
+			<input class="wpeu-licence-key" type="text" placeholder="<?php _e("Enter your licence key", 'invoicing'); ?>"> <button class="button-primary wpeu-licence-popup-button" ><?php _e("Install", 'invoicing'); ?></button>
203 203
 			<br>
204 204
 			<?php
205
-			echo sprintf( __('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">','</a>','<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">','</a>' );
205
+			echo sprintf(__('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>');
206 206
 			?>
207 207
 		</span>
208 208
 	</div>
Please login to merge, or discard this patch.