Passed
Pull Request — master (#227)
by Patrik
03:04
created
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/class-wpinv.php 1 patch
Spacing   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 class WPInv_Plugin {
15 15
     private static $instance;
16 16
     
17 17
     public static function run() {
18
-        if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) {
18
+        if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) {
19 19
             self::$instance = new WPInv_Plugin;
20 20
             self::$instance->includes();
21 21
             self::$instance->actions();
@@ -31,31 +31,31 @@  discard block
 block discarded – undo
31 31
     }
32 32
     
33 33
     public function define_constants() {
34
-        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
35
-        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
34
+        define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
35
+        define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
36 36
     }
37 37
     
38 38
     private function actions() {
39 39
         /* Internationalize the text strings used. */
40
-        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
40
+        add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
41 41
         
42 42
         /* Perform actions on admin initialization. */
43
-        add_action( 'admin_init', array( &$this, 'admin_init') );
44
-        add_action( 'init', array( &$this, 'init' ), 3 );
45
-        add_action( 'init', array( 'WPInv_Shortcodes', 'init' ) );
46
-        add_action( 'init', array( &$this, 'wpinv_actions' ) );
43
+        add_action('admin_init', array(&$this, 'admin_init'));
44
+        add_action('init', array(&$this, 'init'), 3);
45
+        add_action('init', array('WPInv_Shortcodes', 'init'));
46
+        add_action('init', array(&$this, 'wpinv_actions'));
47 47
         
48
-        if ( class_exists( 'BuddyPress' ) ) {
49
-            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
48
+        if (class_exists('BuddyPress')) {
49
+            add_action('bp_include', array(&$this, 'bp_invoicing_init'));
50 50
         }
51 51
 
52
-        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
52
+        add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
53 53
         
54
-        if ( is_admin() ) {
55
-            add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
56
-            add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) );
54
+        if (is_admin()) {
55
+            add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
56
+            add_action('admin_body_class', array(&$this, 'admin_body_class'));
57 57
         } else {
58
-            add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
58
+            add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
59 59
         }
60 60
         
61 61
         /**
@@ -65,16 +65,16 @@  discard block
 block discarded – undo
65 65
          *
66 66
          * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference.
67 67
          */
68
-        do_action_ref_array( 'wpinv_actions', array( &$this ) );
68
+        do_action_ref_array('wpinv_actions', array(&$this));
69 69
 
70
-        add_action( 'admin_init', array( &$this, 'activation_redirect') );
70
+        add_action('admin_init', array(&$this, 'activation_redirect'));
71 71
     }
72 72
     
73 73
     public function plugins_loaded() {
74 74
         /* Internationalize the text strings used. */
75 75
         $this->load_textdomain();
76 76
 
77
-        do_action( 'wpinv_loaded' );
77
+        do_action('wpinv_loaded');
78 78
     }
79 79
     
80 80
     /**
@@ -82,217 +82,217 @@  discard block
 block discarded – undo
82 82
      *
83 83
      * @since 1.0
84 84
      */
85
-    public function load_textdomain( $locale = NULL ) {
86
-        if ( empty( $locale ) ) {
87
-            $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
85
+    public function load_textdomain($locale = NULL) {
86
+        if (empty($locale)) {
87
+            $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
88 88
         }
89 89
 
90
-        $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
90
+        $locale = apply_filters('plugin_locale', $locale, 'invoicing');
91 91
         
92
-        unload_textdomain( 'invoicing' );
93
-        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
94
-        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
92
+        unload_textdomain('invoicing');
93
+        load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
94
+        load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
95 95
         
96 96
         /**
97 97
          * Define language constants.
98 98
          */
99
-        require_once( WPINV_PLUGIN_DIR . 'language.php' );
99
+        require_once(WPINV_PLUGIN_DIR . 'language.php');
100 100
     }
101 101
         
102 102
     public function includes() {
103 103
         global $wpinv_options;
104 104
         
105
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
105
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
106 106
         $wpinv_options = wpinv_get_settings();
107 107
         
108
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' );
109
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
110
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
111
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
112
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
113
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
114
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
115
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' );
116
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
117
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
118
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
119
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
120
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
121
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' );
122
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' );
123
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' );
124
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' );
125
-        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
126
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
127
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
128
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
129
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
130
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php' );
131
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
132
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
133
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
134
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
135
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' );
136
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
137
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' );
138
-        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
139
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
140
-        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
141
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
142
-        require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
108
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php');
109
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
110
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
111
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
112
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
113
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
114
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
115
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php');
116
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
117
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
118
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
119
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
120
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php');
121
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php');
122
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php');
123
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php');
124
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php');
125
+        require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php');
126
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php');
127
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
128
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
129
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
130
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php');
131
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php');
132
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php');
133
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php');
134
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php');
135
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php');
136
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php');
137
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php');
138
+        require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php');
139
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php');
140
+        require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php');
141
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php');
142
+        require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php');
143 143
 
144
-        if ( !class_exists( 'WPInv_EUVat' ) ) {
145
-            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
144
+        if (!class_exists('WPInv_EUVat')) {
145
+            require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
146 146
         }
147 147
         
148
-        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
149
-        if ( !empty( $gateways ) ) {
150
-            foreach ( $gateways as $gateway ) {
151
-                if ( $gateway == 'manual' ) {
148
+        $gateways = array_keys(wpinv_get_enabled_payment_gateways());
149
+        if (!empty($gateways)) {
150
+            foreach ($gateways as $gateway) {
151
+                if ($gateway == 'manual') {
152 152
                     continue;
153 153
                 }
154 154
                 
155 155
                 $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
156 156
                 
157
-                if ( file_exists( $gateway_file ) ) {
158
-                    require_once( $gateway_file );
157
+                if (file_exists($gateway_file)) {
158
+                    require_once($gateway_file);
159 159
                 }
160 160
             }
161 161
         }
162
-        require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' );
162
+        require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php');
163 163
         
164
-        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
165
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
166
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
167
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' );
164
+        if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
165
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php');
166
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
167
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php');
168 168
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' );
169
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' );
170
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' );
171
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
172
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' );
173
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
174
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
175
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
169
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php');
170
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php');
171
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
172
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php');
173
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
174
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php');
175
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php');
176 176
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
177 177
             // load the user class only on the users.php page
178 178
             global $pagenow;
179
-            if($pagenow=='users.php'){
179
+            if ($pagenow == 'users.php') {
180 180
                 new WPInv_Admin_Users();
181 181
             }
182 182
         }
183 183
         
184 184
         // include css inliner
185
-        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
186
-            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
185
+        if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
186
+            include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
187 187
         }
188 188
         
189
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
189
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
190 190
     }
191 191
     
192 192
     public function init() {
193 193
     }
194 194
     
195 195
     public function admin_init() {
196
-        add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) );
196
+        add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php'));
197 197
     }
198 198
 
199 199
     public function activation_redirect() {
200 200
         // Bail if no activation redirect
201
-        if ( !get_transient( '_wpinv_activation_redirect' ) ) {
201
+        if (!get_transient('_wpinv_activation_redirect')) {
202 202
             return;
203 203
         }
204 204
 
205 205
         // Delete the redirect transient
206
-        delete_transient( '_wpinv_activation_redirect' );
206
+        delete_transient('_wpinv_activation_redirect');
207 207
 
208 208
         // Bail if activating from network, or bulk
209
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
209
+        if (is_network_admin() || isset($_GET['activate-multi'])) {
210 210
             return;
211 211
         }
212 212
 
213
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
213
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
214 214
         exit;
215 215
     }
216 216
     
217 217
     public function enqueue_scripts() {
218
-        $suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
218
+        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
219 219
         
220
-        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION );
221
-        wp_enqueue_style( 'wpinv_front_style' );
220
+        wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION);
221
+        wp_enqueue_style('wpinv_front_style');
222 222
                
223 223
         // Register scripts
224
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
225
-        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  WPINV_VERSION );
224
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
225
+        wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), WPINV_VERSION);
226 226
 
227 227
         $localize                         = array();
228
-        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
229
-        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
228
+        $localize['ajax_url']             = admin_url('admin-ajax.php');
229
+        $localize['nonce']                = wp_create_nonce('wpinv-nonce');
230 230
         $localize['currency_symbol']      = wpinv_currency_symbol();
231 231
         $localize['currency_pos']         = wpinv_currency_position();
232 232
         $localize['thousand_sep']         = wpinv_thousands_separator();
233 233
         $localize['decimal_sep']          = wpinv_decimal_separator();
234 234
         $localize['decimals']             = wpinv_decimals();
235
-        $localize['txtComplete']          = __( 'Complete', 'invoicing' );
235
+        $localize['txtComplete']          = __('Complete', 'invoicing');
236 236
         $localize['UseTaxes']             = wpinv_use_taxes();
237
-        $localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
237
+        $localize['checkoutNonce']        = wp_create_nonce('wpinv_checkout_nonce');
238 238
 
239
-        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
239
+        $localize = apply_filters('wpinv_front_js_localize', $localize);
240 240
         
241
-        wp_enqueue_script( 'jquery-blockui' );
241
+        wp_enqueue_script('jquery-blockui');
242 242
         $autofill_api = wpinv_get_option('address_autofill_api');
243 243
         $autofill_active = wpinv_get_option('address_autofill_active');
244
-        if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
245
-            if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
246
-                wp_dequeue_script( 'google-maps-api' );
244
+        if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) {
245
+            if (wp_script_is('google-maps-api', 'enqueued')) {
246
+                wp_dequeue_script('google-maps-api');
247 247
             }
248
-            wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
249
-            wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
248
+            wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false);
249
+            wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true);
250 250
         }
251 251
 
252
-        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
253
-        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
252
+        wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
253
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
254 254
 
255
-        wp_enqueue_script( 'wpinv-front-script' );
256
-        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
255
+        wp_enqueue_script('wpinv-front-script');
256
+        wp_localize_script('wpinv-front-script', 'WPInv', $localize);
257 257
     }
258 258
 
259 259
     public function admin_enqueue_scripts() {
260 260
         global $post, $pagenow;
261 261
         
262 262
         $post_type  = wpinv_admin_post_type();
263
-        $suffix     = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
264
-        $page       = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : '';
263
+        $suffix     = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
264
+        $page       = isset($_GET['page']) ? strtolower($_GET['page']) : '';
265 265
 
266 266
         $jquery_ui_css = false;
267
-        if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) {
267
+        if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
268 268
             $jquery_ui_css = true;
269
-        } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) {
269
+        } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') {
270 270
             $jquery_ui_css = true;
271 271
         }
272
-        if ( $jquery_ui_css ) {
273
-            wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
274
-            wp_enqueue_style( 'jquery-ui-css' );
272
+        if ($jquery_ui_css) {
273
+            wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16');
274
+            wp_enqueue_style('jquery-ui-css');
275 275
         }
276 276
 
277
-        wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
278
-        wp_enqueue_style( 'wpinv_meta_box_style' );
277
+        wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
278
+        wp_enqueue_style('wpinv_meta_box_style');
279 279
         
280
-        wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION );
281
-        wp_enqueue_style( 'wpinv_admin_style' );
280
+        wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION);
281
+        wp_enqueue_style('wpinv_admin_style');
282 282
 
283
-        $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) );
284
-        if ( $page == 'wpinv-subscriptions' ) {
285
-            wp_enqueue_script( 'jquery-ui-datepicker' );
283
+        $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php'));
284
+        if ($page == 'wpinv-subscriptions') {
285
+            wp_enqueue_script('jquery-ui-datepicker');
286 286
         }
287 287
         
288
-        if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) {
289
-            wp_enqueue_script( 'jquery-ui-datepicker' );
288
+        if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) {
289
+            wp_enqueue_script('jquery-ui-datepicker');
290 290
         }
291 291
 
292
-        wp_enqueue_style( 'wp-color-picker' );
293
-        wp_enqueue_script( 'wp-color-picker' );
292
+        wp_enqueue_style('wp-color-picker');
293
+        wp_enqueue_script('wp-color-picker');
294 294
         
295
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
295
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
296 296
 
297 297
         if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
298 298
             $autofill_api = wpinv_get_option('address_autofill_api');
@@ -303,20 +303,20 @@  discard block
 block discarded – undo
303 303
             }
304 304
         }
305 305
 
306
-        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
307
-        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
306
+        wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
307
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
308 308
 
309
-        wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ),  WPINV_VERSION );
310
-        wp_enqueue_script( 'wpinv-admin-script' );
309
+        wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION);
310
+        wp_enqueue_script('wpinv-admin-script');
311 311
         
312 312
         $localize                               = array();
313
-        $localize['ajax_url']                   = admin_url( 'admin-ajax.php' );
314
-        $localize['post_ID']                    = isset( $post->ID ) ? $post->ID : '';
315
-        $localize['wpinv_nonce']                = wp_create_nonce( 'wpinv-nonce' );
316
-        $localize['add_invoice_note_nonce']     = wp_create_nonce( 'add-invoice-note' );
317
-        $localize['delete_invoice_note_nonce']  = wp_create_nonce( 'delete-invoice-note' );
318
-        $localize['invoice_item_nonce']         = wp_create_nonce( 'invoice-item' );
319
-        $localize['billing_details_nonce']      = wp_create_nonce( 'get-billing-details' );
313
+        $localize['ajax_url']                   = admin_url('admin-ajax.php');
314
+        $localize['post_ID']                    = isset($post->ID) ? $post->ID : '';
315
+        $localize['wpinv_nonce']                = wp_create_nonce('wpinv-nonce');
316
+        $localize['add_invoice_note_nonce']     = wp_create_nonce('add-invoice-note');
317
+        $localize['delete_invoice_note_nonce']  = wp_create_nonce('delete-invoice-note');
318
+        $localize['invoice_item_nonce']         = wp_create_nonce('invoice-item');
319
+        $localize['billing_details_nonce']      = wp_create_nonce('get-billing-details');
320 320
         $localize['tax']                        = wpinv_tax_amount();
321 321
         $localize['discount']                   = wpinv_discount_amount();
322 322
         $localize['currency_symbol']            = wpinv_currency_symbol();
@@ -324,69 +324,69 @@  discard block
 block discarded – undo
324 324
         $localize['thousand_sep']               = wpinv_thousands_separator();
325 325
         $localize['decimal_sep']                = wpinv_decimal_separator();
326 326
         $localize['decimals']                   = wpinv_decimals();
327
-        $localize['save_invoice']               = __( 'Save Invoice', 'invoicing' );
328
-        $localize['status_publish']             = wpinv_status_nicename( 'publish' );
329
-        $localize['status_pending']             = wpinv_status_nicename( 'wpi-pending' );
330
-        $localize['delete_tax_rate']            = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' );
331
-        $localize['OneItemMin']                 = __( 'Invoice must contain at least one item', 'invoicing' );
332
-        $localize['DeleteInvoiceItem']          = __( 'Are you sure you wish to delete this item?', 'invoicing' );
333
-        $localize['FillBillingDetails']         = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' );
334
-        $localize['confirmCalcTotals']          = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' );
335
-        $localize['AreYouSure']                 = __( 'Are you sure?', 'invoicing' );
336
-        $localize['emptyInvoice']               = __( 'Add at least one item to save invoice!', 'invoicing' );
337
-        $localize['errDeleteItem']              = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' );
338
-        $localize['delete_subscription']        = __( 'Are you sure you want to delete this subscription?', 'invoicing' );
339
-        $localize['action_edit']                = __( 'Edit', 'invoicing' );
340
-        $localize['action_cancel']              = __( 'Cancel', 'invoicing' );
327
+        $localize['save_invoice']               = __('Save Invoice', 'invoicing');
328
+        $localize['status_publish']             = wpinv_status_nicename('publish');
329
+        $localize['status_pending']             = wpinv_status_nicename('wpi-pending');
330
+        $localize['delete_tax_rate']            = __('Are you sure you wish to delete this tax rate?', 'invoicing');
331
+        $localize['OneItemMin']                 = __('Invoice must contain at least one item', 'invoicing');
332
+        $localize['DeleteInvoiceItem']          = __('Are you sure you wish to delete this item?', 'invoicing');
333
+        $localize['FillBillingDetails']         = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing');
334
+        $localize['confirmCalcTotals']          = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing');
335
+        $localize['AreYouSure']                 = __('Are you sure?', 'invoicing');
336
+        $localize['emptyInvoice']               = __('Add at least one item to save invoice!', 'invoicing');
337
+        $localize['errDeleteItem']              = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing');
338
+        $localize['delete_subscription']        = __('Are you sure you want to delete this subscription?', 'invoicing');
339
+        $localize['action_edit']                = __('Edit', 'invoicing');
340
+        $localize['action_cancel']              = __('Cancel', 'invoicing');
341 341
 
342
-        $localize = apply_filters( 'wpinv_admin_js_localize', $localize );
342
+        $localize = apply_filters('wpinv_admin_js_localize', $localize);
343 343
 
344
-        wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize );
344
+        wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize);
345 345
 
346
-        if ( $page == 'wpinv-subscriptions' ) {
347
-            wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
348
-            wp_enqueue_script( 'wpinv-sub-admin-script' );
346
+        if ($page == 'wpinv-subscriptions') {
347
+            wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION);
348
+            wp_enqueue_script('wpinv-sub-admin-script');
349 349
         }
350 350
     }
351 351
     
352
-    public function admin_body_class( $classes ) {
352
+    public function admin_body_class($classes) {
353 353
         global $pagenow, $post, $current_screen;
354 354
         
355
-        if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote' ) ) {
355
+        if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote')) {
356 356
             $classes .= ' wpinv-cpt';
357 357
         }
358 358
         
359
-        $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
359
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
360 360
 
361
-        $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false;
362
-        if ( $add_class ) {
363
-            $classes .= ' wpi-' . wpinv_sanitize_key( $page );
361
+        $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false;
362
+        if ($add_class) {
363
+            $classes .= ' wpi-' . wpinv_sanitize_key($page);
364 364
         }
365 365
         
366 366
         $settings_class = array();
367
-        if ( $page == 'wpinv-settings' ) {
368
-            if ( !empty( $_REQUEST['tab'] ) ) {
369
-                $settings_class[] = sanitize_text_field( $_REQUEST['tab'] );
367
+        if ($page == 'wpinv-settings') {
368
+            if (!empty($_REQUEST['tab'])) {
369
+                $settings_class[] = sanitize_text_field($_REQUEST['tab']);
370 370
             }
371 371
             
372
-            if ( !empty( $_REQUEST['section'] ) ) {
373
-                $settings_class[] = sanitize_text_field( $_REQUEST['section'] );
372
+            if (!empty($_REQUEST['section'])) {
373
+                $settings_class[] = sanitize_text_field($_REQUEST['section']);
374 374
             }
375 375
             
376
-            $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main';
376
+            $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main';
377 377
         }
378 378
         
379
-        if ( !empty( $settings_class ) ) {
380
-            $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) );
379
+        if (!empty($settings_class)) {
380
+            $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-'));
381 381
         }
382 382
         
383 383
         $post_type = wpinv_admin_post_type();
384 384
 
385
-        if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) {
385
+        if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) {
386 386
             return $classes .= ' wpinv';
387 387
         }
388 388
         
389
-        if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) {
389
+        if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) {
390 390
             $classes .= ' wpi-editable-n';
391 391
         }
392 392
 
@@ -398,20 +398,20 @@  discard block
 block discarded – undo
398 398
     }
399 399
     
400 400
     public function wpinv_actions() {
401
-        if ( isset( $_REQUEST['wpi_action'] ) ) {
402
-            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
401
+        if (isset($_REQUEST['wpi_action'])) {
402
+            do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
403 403
         }
404 404
     }
405 405
     
406
-    public function pre_get_posts( $wp_query ) {
407
-        if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
408
-            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
406
+    public function pre_get_posts($wp_query) {
407
+        if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
408
+            $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
409 409
         }
410 410
         
411 411
         return $wp_query;
412 412
     }
413 413
     
414 414
     public function bp_invoicing_init() {
415
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
415
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
416 416
     }
417 417
 }
418 418
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/admin-meta-boxes.php 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.