Passed
Pull Request — master (#47)
by Kiran
04:02
created
includes/class-wpinv-api.php 2 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -47,6 +47,9 @@  discard block
 block discarded – undo
47 47
         }
48 48
     }
49 49
     
50
+    /**
51
+     * @param integer $code
52
+     */
50 53
     public function send_status( $code ) {
51 54
         status_header( $code );
52 55
     }
@@ -195,6 +198,11 @@  discard block
 block discarded – undo
195 198
 class WPInv_API_Exception extends Exception {
196 199
     protected $error_code;
197 200
 
201
+    /**
202
+     * @param string $error_code
203
+     * @param string $error_message
204
+     * @param integer $http_status_code
205
+     */
198 206
     public function __construct( $error_code, $error_message, $http_status_code ) {
199 207
         $this->error_code = $error_code;
200 208
         parent::__construct( $error_message, $http_status_code );
Please login to merge, or discard this patch.
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -7,51 +7,51 @@  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_API {
15 15
     protected $post_type = 'wpi_invoice';
16 16
     
17
-    public function __construct( $params = array() ) {
17
+    public function __construct($params = array()) {
18 18
     }
19
-    public function insert_invoice( $data ) {
19
+    public function insert_invoice($data) {
20 20
         global $wpdb;
21 21
         //wpinv_transaction_query( 'start' );
22 22
 
23 23
         try {
24
-            if ( empty( $data['invoice'] ) ) {
25
-                throw new WPInv_API_Exception( 'wpinv_api_missing_invoice_data', sprintf( __( 'No %1$s data specified to create %1$s', 'invoicing' ), 'invoice' ), 400 );
24
+            if (empty($data['invoice'])) {
25
+                throw new WPInv_API_Exception('wpinv_api_missing_invoice_data', sprintf(__('No %1$s data specified to create %1$s', 'invoicing'), 'invoice'), 400);
26 26
             }
27 27
 
28
-            $data = apply_filters( 'wpinv_api_create_invoice_data', $data['invoice'], $this );
28
+            $data = apply_filters('wpinv_api_create_invoice_data', $data['invoice'], $this);
29 29
 
30
-            $invoice = wpinv_insert_invoice( $data, true );
31
-            if ( empty( $invoice->ID ) || is_wp_error( $invoice ) ) {
32
-                throw new WPInv_API_Exception( 'wpinv_api_cannot_create_invoice', sprintf( __( 'Cannot create invoice: %s', 'invoicing' ), implode( ', ', $invoice->get_error_messages() ) ), 400 );
30
+            $invoice = wpinv_insert_invoice($data, true);
31
+            if (empty($invoice->ID) || is_wp_error($invoice)) {
32
+                throw new WPInv_API_Exception('wpinv_api_cannot_create_invoice', sprintf(__('Cannot create invoice: %s', 'invoicing'), implode(', ', $invoice->get_error_messages())), 400);
33 33
             }
34 34
 
35 35
             // HTTP 201 Created
36
-            $this->send_status( 201 );
36
+            $this->send_status(201);
37 37
 
38
-            do_action( 'wpinv_api_create_invoice', $invoice->ID, $data, $this );
38
+            do_action('wpinv_api_create_invoice', $invoice->ID, $data, $this);
39 39
 
40 40
             //wpinv_transaction_query( 'commit' );
41 41
 
42
-            return wpinv_get_invoice( $invoice->ID );
43
-        } catch ( WPInv_API_Exception $e ) {
42
+            return wpinv_get_invoice($invoice->ID);
43
+        } catch (WPInv_API_Exception $e) {
44 44
             //wpinv_transaction_query( 'rollback' );
45 45
 
46
-            return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
46
+            return new WP_Error($e->getErrorCode(), $e->getMessage(), array('status' => $e->getCode()));
47 47
         }
48 48
     }
49 49
     
50
-    public function send_status( $code ) {
51
-        status_header( $code );
50
+    public function send_status($code) {
51
+        status_header($code);
52 52
     }
53 53
     
54
-    protected function set_billing_details( $invoice, $data ) {
54
+    protected function set_billing_details($invoice, $data) {
55 55
         $address_fields = array(
56 56
             'user_id',
57 57
             'first_name',
@@ -70,66 +70,66 @@  discard block
 block discarded – undo
70 70
         $billing_details = array();
71 71
         $user_id = $invoice->get_user_id();
72 72
         
73
-        foreach ( $address_fields as $field ) {
74
-            if ( isset( $data['billing_details'][ $field ] ) ) {
75
-                $value = sanitize_text_field( $data['billing_details'][ $field ] );
73
+        foreach ($address_fields as $field) {
74
+            if (isset($data['billing_details'][$field])) {
75
+                $value = sanitize_text_field($data['billing_details'][$field]);
76 76
                 
77
-                if ( $field == 'country' && empty( $value ) ) {
78
-                    if ( !empty( $invoice->country ) ) {
77
+                if ($field == 'country' && empty($value)) {
78
+                    if (!empty($invoice->country)) {
79 79
                         $value = $invoice->country;
80 80
                     } else {
81
-                        $value = wpinv_default_billing_country( '', $user_id );
81
+                        $value = wpinv_default_billing_country('', $user_id);
82 82
                     }
83 83
                 }
84 84
                 
85
-                if ( $field == 'state' && empty( $value ) ) {
86
-                    if ( !empty( $invoice->state ) ) {
85
+                if ($field == 'state' && empty($value)) {
86
+                    if (!empty($invoice->state)) {
87 87
                         $value = $invoice->state;
88 88
                     } else {
89 89
                         $value = wpinv_get_default_state();
90 90
                     }
91 91
                 }
92 92
                 
93
-                $invoice->set( $field, $value );
93
+                $invoice->set($field, $value);
94 94
                 
95
-                update_post_meta( $invoice->ID, '_wpinv_' . $field, $value );
95
+                update_post_meta($invoice->ID, '_wpinv_' . $field, $value);
96 96
             }
97 97
         }
98 98
         
99 99
         return $invoice;
100 100
     }
101 101
     
102
-    protected function set_discount( $invoice, $data ) {
103
-        if ( isset( $data['discount'] ) ) {
104
-            $invoice->set( 'discount', wpinv_round_amount( $data['discount'] ) );
102
+    protected function set_discount($invoice, $data) {
103
+        if (isset($data['discount'])) {
104
+            $invoice->set('discount', wpinv_round_amount($data['discount']));
105 105
             
106
-            update_post_meta( $invoice->ID, '_wpinv_discount', wpinv_round_amount( $data['discount'] ) );
106
+            update_post_meta($invoice->ID, '_wpinv_discount', wpinv_round_amount($data['discount']));
107 107
             
108
-            if ( isset( $data['discount_code'] ) ) {
109
-                $invoice->set( 'discount_code', $data['discount_code'] );
108
+            if (isset($data['discount_code'])) {
109
+                $invoice->set('discount_code', $data['discount_code']);
110 110
                 
111
-                update_post_meta( $invoice->ID, '_wpinv_discount_code', $data['discount_code'] );
111
+                update_post_meta($invoice->ID, '_wpinv_discount_code', $data['discount_code']);
112 112
             }
113 113
         }
114 114
         
115 115
         return $invoice;
116 116
     }
117 117
     
118
-    protected function set_items( $invoice, $data ) {
119
-        if ( !empty( $data['items'] ) && is_array( $data['items'] ) ) {
118
+    protected function set_items($invoice, $data) {
119
+        if (!empty($data['items']) && is_array($data['items'])) {
120 120
             $items_array = array();
121 121
            
122
-            if ( !empty( $invoice->country ) ) {
122
+            if (!empty($invoice->country)) {
123 123
                 $country = $invoice->country;
124
-            } else if ( !empty( $data['billing_details']['country'] ) ) {
124
+            } else if (!empty($data['billing_details']['country'])) {
125 125
                 $country = $data['billing_details']['country'];
126 126
             } else {
127
-                $country = wpinv_default_billing_country( '', $invoice->get_user_id() );
127
+                $country = wpinv_default_billing_country('', $invoice->get_user_id());
128 128
             }
129 129
             
130
-            if ( !empty( $invoice->state ) ) {
130
+            if (!empty($invoice->state)) {
131 131
                 $state = $invoice->state;
132
-            } else if ( !empty( $data['billing_details']['state'] ) ) {
132
+            } else if (!empty($data['billing_details']['state'])) {
133 133
                 $state = $data['billing_details']['state'];
134 134
             } else {
135 135
                 $state = wpinv_get_default_state();
@@ -138,54 +138,54 @@  discard block
 block discarded – undo
138 138
             $_POST['country']   = $country;
139 139
             $_POST['state']     = $state;
140 140
             
141
-            $rate = wpinv_get_tax_rate( $country, $state, 'global' );
141
+            $rate = wpinv_get_tax_rate($country, $state, 'global');
142 142
             
143 143
             $total_tax = 0;
144
-            foreach ( $data['items'] as $item ) {
145
-                $id                 = isset( $item['id'] ) ? sanitize_text_field( $item['id'] ) : '';
146
-                $title              = isset( $item['title'] ) ? sanitize_text_field( $item['title'] ) : '';
147
-                $desc               = isset( $item['description'] ) ? sanitize_text_field( $item['description'] ) : '';
148
-                $amount             = isset( $item['amount'] ) ? wpinv_round_amount( $item['amount'] ) : 0;
144
+            foreach ($data['items'] as $item) {
145
+                $id                 = isset($item['id']) ? sanitize_text_field($item['id']) : '';
146
+                $title              = isset($item['title']) ? sanitize_text_field($item['title']) : '';
147
+                $desc               = isset($item['description']) ? sanitize_text_field($item['description']) : '';
148
+                $amount             = isset($item['amount']) ? wpinv_round_amount($item['amount']) : 0;
149 149
                 
150
-                if ( !empty( $item['vat_rates_class'] ) ) {
150
+                if (!empty($item['vat_rates_class'])) {
151 151
                     $vat_rates_class = $item['vat_rates_class'];
152 152
                 } else {
153 153
                     $vat_rates_class = '_standard';
154 154
                 }
155
-                $vat_rate = wpinv_get_tax_rate( $country, $state, $id );
155
+                $vat_rate = wpinv_get_tax_rate($country, $state, $id);
156 156
                 
157
-                $tax = $amount > 0 ? ( $amount * 0.01 * (float)$vat_rate ) : 0;
157
+                $tax = $amount > 0 ? ($amount * 0.01 * (float)$vat_rate) : 0;
158 158
                 $total_tax += $tax;
159 159
                 
160 160
                 $items_array[] = array(
161 161
                     'id'                => $id,
162
-                    'title'             => esc_html( $title ),
163
-                    'description'       => esc_html( $desc ),
164
-                    'amount'            => $amount > 0 ? wpinv_round_amount( $amount ) : 0,
165
-                    'subtotal'          => $amount > 0 ? wpinv_round_amount( $amount ) : 0,
162
+                    'title'             => esc_html($title),
163
+                    'description'       => esc_html($desc),
164
+                    'amount'            => $amount > 0 ? wpinv_round_amount($amount) : 0,
165
+                    'subtotal'          => $amount > 0 ? wpinv_round_amount($amount) : 0,
166 166
                     'vat_rates_class'   => $vat_rates_class,
167 167
                     'vat_rate'          => $vat_rate,
168
-                    'tax'               => $tax > 0 ? wpinv_round_amount( $tax ) : 0,
168
+                    'tax'               => $tax > 0 ? wpinv_round_amount($tax) : 0,
169 169
                 );
170 170
             }
171 171
 
172
-            update_post_meta( $invoice->ID, '_wpinv_tax', wpinv_round_amount( $total_tax ) );
173
-            $invoice->set( 'tax', wpinv_round_amount( $total_tax ) );
172
+            update_post_meta($invoice->ID, '_wpinv_tax', wpinv_round_amount($total_tax));
173
+            $invoice->set('tax', wpinv_round_amount($total_tax));
174 174
             
175
-            $items_array = apply_filters( 'wpinv_save_invoice_items', $items_array, $data['items'], $invoice );
175
+            $items_array = apply_filters('wpinv_save_invoice_items', $items_array, $data['items'], $invoice);
176 176
             
177
-            $invoice->set( 'items', $items_array );
178
-            update_post_meta( $invoice->ID, '_wpinv_items', $items_array );
177
+            $invoice->set('items', $items_array);
178
+            update_post_meta($invoice->ID, '_wpinv_items', $items_array);
179 179
         }
180 180
         
181 181
         return $invoice;
182 182
     }
183 183
     
184
-    protected function set_invoice_meta( $invoice_id, $invoice_meta ) {
185
-        foreach ( $invoice_meta as $meta_key => $meta_value ) {
184
+    protected function set_invoice_meta($invoice_id, $invoice_meta) {
185
+        foreach ($invoice_meta as $meta_key => $meta_value) {
186 186
 
187
-            if ( is_string( $meta_key) && ! is_protected_meta( $meta_key ) && is_scalar( $meta_value ) ) {
188
-                update_post_meta( $invoice_id, $meta_key, $meta_value );
187
+            if (is_string($meta_key) && !is_protected_meta($meta_key) && is_scalar($meta_value)) {
188
+                update_post_meta($invoice_id, $meta_key, $meta_value);
189 189
             }
190 190
         }
191 191
     }
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
 class WPInv_API_Exception extends Exception {
196 196
     protected $error_code;
197 197
 
198
-    public function __construct( $error_code, $error_message, $http_status_code ) {
198
+    public function __construct($error_code, $error_message, $http_status_code) {
199 199
         $this->error_code = $error_code;
200
-        parent::__construct( $error_message, $http_status_code );
200
+        parent::__construct($error_message, $http_status_code);
201 201
     }
202 202
 
203 203
     public function getErrorCode() {
Please login to merge, or discard this patch.
includes/class-wpinv.php 1 patch
Spacing   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 class WPInv_Plugin {
15 15
     private static $instance;
16 16
     
17 17
     public static function run() {
18
-        if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) {
18
+        if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) {
19 19
             self::$instance = new WPInv_Plugin;
20 20
             self::$instance->includes();
21 21
             self::$instance->actions();
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
             self::$instance->reports    = new WPInv_Reports();
24 24
         }
25 25
         
26
-        do_action( 'wpinv_loaded' );
26
+        do_action('wpinv_loaded');
27 27
         
28 28
         return self::$instance;
29 29
     }
@@ -33,31 +33,31 @@  discard block
 block discarded – undo
33 33
     }
34 34
     
35 35
     public function define_constants() {
36
-        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
37
-        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
36
+        define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
37
+        define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
38 38
     }
39 39
     
40 40
     private function actions() {
41 41
         /* Internationalize the text strings used. */
42
-        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
42
+        add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
43 43
         
44 44
         /* Perform actions on admin initialization. */
45
-        add_action( 'admin_init', array( &$this, 'admin_init') );
46
-        add_action( 'init', array( &$this, 'init' ), 3 );
47
-        add_action( 'init', array( 'WPInv_Shortcodes', 'init' ) );
48
-        add_action( 'init', array( &$this, 'wpinv_actions' ) );
45
+        add_action('admin_init', array(&$this, 'admin_init'));
46
+        add_action('init', array(&$this, 'init'), 3);
47
+        add_action('init', array('WPInv_Shortcodes', 'init'));
48
+        add_action('init', array(&$this, 'wpinv_actions'));
49 49
         
50
-        if ( class_exists( 'BuddyPress' ) ) {
51
-            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
50
+        if (class_exists('BuddyPress')) {
51
+            add_action('bp_include', array(&$this, 'bp_invoicing_init'));
52 52
         }
53 53
 
54
-        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
54
+        add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
55 55
         
56
-        if ( is_admin() ) {
57
-            add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
58
-            add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) );
56
+        if (is_admin()) {
57
+            add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
58
+            add_action('admin_body_class', array(&$this, 'admin_body_class'));
59 59
         } else {
60
-            add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
60
+            add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
61 61
         }
62 62
         
63 63
         /**
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
          *
68 68
          * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference.
69 69
          */
70
-        do_action_ref_array( 'wpinv_actions', array( &$this ) );
70
+        do_action_ref_array('wpinv_actions', array(&$this));
71 71
 
72
-        add_action( 'admin_init', array( &$this, 'activation_redirect') );
72
+        add_action('admin_init', array(&$this, 'activation_redirect'));
73 73
     }
74 74
     
75 75
     public function plugins_loaded() {
@@ -83,193 +83,193 @@  discard block
 block discarded – undo
83 83
      * @since 1.0
84 84
      */
85 85
     public function load_textdomain() {
86
-        $locale = apply_filters( 'plugin_locale', get_locale(), 'invoicing' );
86
+        $locale = apply_filters('plugin_locale', get_locale(), 'invoicing');
87 87
         
88
-        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
89
-        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
88
+        load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
89
+        load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
90 90
         
91 91
         /**
92 92
          * Define language constants.
93 93
          */
94
-        require_once( WPINV_PLUGIN_DIR . 'language.php' );
94
+        require_once(WPINV_PLUGIN_DIR . 'language.php');
95 95
     }
96 96
         
97 97
     public function includes() {
98 98
         global $wpinv_options;
99 99
         
100
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
100
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
101 101
         $wpinv_options = wpinv_get_settings();
102 102
         
103
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' );
104
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
105
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
106
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
107
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
108
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
109
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
110
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' );
111
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
112
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
113
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
114
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
115
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
116
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gd-functions.php' );
117
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' );
103
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php');
104
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
105
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
106
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
107
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
108
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
109
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
110
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php');
111
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
112
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
113
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
114
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
115
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php');
116
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gd-functions.php');
117
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php');
118 118
         //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
119 119
         //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
120
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' );
120
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php');
121 121
         //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscription.php' );
122
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' );
123
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' );
124
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php' );
125
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
126
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
127
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
128
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php' );
129
-        if ( !class_exists( 'Geodir_EUVat' ) ) {
130
-            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
122
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php');
123
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php');
124
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php');
125
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
126
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
127
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
128
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php');
129
+        if (!class_exists('Geodir_EUVat')) {
130
+            require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
131 131
         }
132 132
         
133
-        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
134
-        if ( !empty( $gateways ) ) {
135
-            foreach ( $gateways as $gateway ) {
136
-                if ( $gateway == 'manual' ) {
133
+        $gateways = array_keys(wpinv_get_enabled_payment_gateways());
134
+        if (!empty($gateways)) {
135
+            foreach ($gateways as $gateway) {
136
+                if ($gateway == 'manual') {
137 137
                     continue;
138 138
                 }
139 139
                 
140 140
                 $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
141 141
                 
142
-                if ( file_exists( $gateway_file ) ) {
143
-                    require_once( $gateway_file );
142
+                if (file_exists($gateway_file)) {
143
+                    require_once($gateway_file);
144 144
                 }
145 145
             }
146 146
         }
147
-        require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' );
148
-        
149
-        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
150
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
151
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
152
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' );
153
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' );
154
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' );
155
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' );
156
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
157
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' );
158
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
147
+        require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php');
148
+        
149
+        if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
150
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php');
151
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
152
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php');
153
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php');
154
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php');
155
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php');
156
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
157
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php');
158
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
159 159
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
160 160
         }
161 161
         
162 162
         // include css inliner
163
-        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
164
-            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
163
+        if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
164
+            include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
165 165
         }
166 166
         
167
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
167
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
168 168
     }
169 169
     
170 170
     public function init() {
171 171
     }
172 172
     
173 173
     public function admin_init() {
174
-        if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) {
174
+        if (!(defined('DOING_AJAX') && DOING_AJAX)) {
175 175
         }
176 176
         
177
-        add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) );
177
+        add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php'));
178 178
     }
179 179
 
180 180
     public function activation_redirect() {
181 181
         // Bail if no activation redirect
182
-        if ( !get_transient( '_wpinv_activation_redirect' ) ) {
182
+        if (!get_transient('_wpinv_activation_redirect')) {
183 183
             return;
184 184
         }
185 185
 
186 186
         // Delete the redirect transient
187
-        delete_transient( '_wpinv_activation_redirect' );
187
+        delete_transient('_wpinv_activation_redirect');
188 188
 
189 189
         // Bail if activating from network, or bulk
190
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
190
+        if (is_network_admin() || isset($_GET['activate-multi'])) {
191 191
             return;
192 192
         }
193 193
 
194
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
194
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
195 195
         exit;
196 196
     }
197 197
     
198 198
     public function enqueue_scripts() {
199
-        $suffix       = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
199
+        $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
200 200
         
201
-        wp_deregister_style( 'font-awesome' );
202
-        wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' );
203
-        wp_enqueue_style( 'font-awesome' );
201
+        wp_deregister_style('font-awesome');
202
+        wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0');
203
+        wp_enqueue_style('font-awesome');
204 204
         
205
-        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION );
206
-        wp_enqueue_style( 'wpinv_front_style' );
205
+        wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION);
206
+        wp_enqueue_style('wpinv_front_style');
207 207
                
208 208
         // Register scripts
209
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
210
-        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array( 'jquery', 'wpinv-vat-script' ),  WPINV_VERSION );
209
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
210
+        wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array('jquery', 'wpinv-vat-script'), WPINV_VERSION);
211 211
         
212 212
         $localize                         = array();
213
-        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
214
-        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
213
+        $localize['ajax_url']             = admin_url('admin-ajax.php');
214
+        $localize['nonce']                = wp_create_nonce('wpinv-nonce');
215 215
         $localize['currency_symbol']      = wpinv_currency_symbol();
216 216
         $localize['currency_pos']         = wpinv_currency_position();
217 217
         $localize['thousand_sep']         = wpinv_thousands_separator();
218 218
         $localize['decimal_sep']          = wpinv_decimal_separator();
219 219
         $localize['decimals']             = wpinv_decimals();
220 220
         
221
-        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
221
+        $localize = apply_filters('wpinv_front_js_localize', $localize);
222 222
         
223
-        wp_enqueue_script( 'jquery-blockui' );
224
-        wp_enqueue_script( 'wpinv-front-script' );
225
-        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
223
+        wp_enqueue_script('jquery-blockui');
224
+        wp_enqueue_script('wpinv-front-script');
225
+        wp_localize_script('wpinv-front-script', 'WPInv', $localize);
226 226
     }
227 227
     
228 228
     public function admin_enqueue_scripts() {
229 229
         global $post, $pagenow;
230 230
         
231 231
         $post_type  = wpinv_admin_post_type();
232
-        $suffix     = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
232
+        $suffix     = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
233 233
         
234
-        wp_deregister_style( 'font-awesome' );
235
-        wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' );
236
-        wp_enqueue_style( 'font-awesome' );
234
+        wp_deregister_style('font-awesome');
235
+        wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0');
236
+        wp_enqueue_style('font-awesome');
237 237
         
238
-        wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
239
-        wp_enqueue_style( 'jquery-ui-css' );
238
+        wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16');
239
+        wp_enqueue_style('jquery-ui-css');
240 240
         
241
-        wp_register_style( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2' );
242
-        wp_enqueue_style( 'jquery-chosen' );
241
+        wp_register_style('jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2');
242
+        wp_enqueue_style('jquery-chosen');
243 243
 
244
-        wp_register_script( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array( 'jquery' ), '1.6.2' );
245
-        wp_enqueue_script( 'jquery-chosen' );
244
+        wp_register_script('jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array('jquery'), '1.6.2');
245
+        wp_enqueue_script('jquery-chosen');
246 246
         
247
-        wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
248
-        wp_enqueue_style( 'wpinv_meta_box_style' );
247
+        wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
248
+        wp_enqueue_style('wpinv_meta_box_style');
249 249
         
250
-        wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION );
251
-        wp_enqueue_style( 'wpinv_admin_style' );
250
+        wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION);
251
+        wp_enqueue_style('wpinv_admin_style');
252 252
         
253
-        if ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) {
254
-            wp_enqueue_script( 'jquery-ui-datepicker' );
253
+        if ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
254
+            wp_enqueue_script('jquery-ui-datepicker');
255 255
         }
256 256
 
257
-        wp_enqueue_style( 'wp-color-picker' );
258
-        wp_enqueue_script( 'wp-color-picker' );
257
+        wp_enqueue_style('wp-color-picker');
258
+        wp_enqueue_script('wp-color-picker');
259 259
         
260
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
260
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
261 261
         
262
-        wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui' ),  WPINV_VERSION );
263
-        wp_enqueue_script( 'wpinv-admin-script' );
262
+        wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array('jquery', 'jquery-blockui'), WPINV_VERSION);
263
+        wp_enqueue_script('wpinv-admin-script');
264 264
         
265 265
         $localize                               = array();
266
-        $localize['ajax_url']                   = admin_url( 'admin-ajax.php' );
267
-        $localize['post_ID']                    = isset( $post->ID ) ? $post->ID : '';
268
-        $localize['wpinv_nonce']                = wp_create_nonce( 'wpinv-nonce' );
269
-        $localize['add_invoice_note_nonce']     = wp_create_nonce( 'add-invoice-note' );
270
-        $localize['delete_invoice_note_nonce']  = wp_create_nonce( 'delete-invoice-note' );
271
-        $localize['invoice_item_nonce']         = wp_create_nonce( 'invoice-item' );
272
-        $localize['billing_details_nonce']      = wp_create_nonce( 'get-billing-details' );
266
+        $localize['ajax_url']                   = admin_url('admin-ajax.php');
267
+        $localize['post_ID']                    = isset($post->ID) ? $post->ID : '';
268
+        $localize['wpinv_nonce']                = wp_create_nonce('wpinv-nonce');
269
+        $localize['add_invoice_note_nonce']     = wp_create_nonce('add-invoice-note');
270
+        $localize['delete_invoice_note_nonce']  = wp_create_nonce('delete-invoice-note');
271
+        $localize['invoice_item_nonce']         = wp_create_nonce('invoice-item');
272
+        $localize['billing_details_nonce']      = wp_create_nonce('get-billing-details');
273 273
         $localize['tax']                        = wpinv_tax_amount();
274 274
         $localize['discount']                   = wpinv_discount_amount();
275 275
         $localize['currency_symbol']            = wpinv_currency_symbol();
@@ -277,55 +277,55 @@  discard block
 block discarded – undo
277 277
         $localize['thousand_sep']               = wpinv_thousands_separator();
278 278
         $localize['decimal_sep']                = wpinv_decimal_separator();
279 279
         $localize['decimals']                   = wpinv_decimals();
280
-        $localize['save_invoice']               = __( 'Save Invoice', 'invoicing' );
281
-        $localize['status_publish']             = wpinv_status_nicename( 'publish' );
282
-        $localize['status_pending']             = wpinv_status_nicename( 'pending' );
283
-        $localize['delete_tax_rate']            = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' );
284
-        $localize['OneItemMin']                 = __( 'Invoice must contain at least one item', 'invoicing' );
285
-        $localize['DeleteInvoiceItem']          = __( 'Are you sure you wish to delete this item?', 'invoicing' );
286
-        $localize['FillBillingDetails']         = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' );
287
-        $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' );
288
-        $localize['AreYouSure']                 = __( 'Are you sure?', 'invoicing' );
289
-        $localize['hasGD']                      = wpinv_gd_active();;
280
+        $localize['save_invoice']               = __('Save Invoice', 'invoicing');
281
+        $localize['status_publish']             = wpinv_status_nicename('publish');
282
+        $localize['status_pending']             = wpinv_status_nicename('pending');
283
+        $localize['delete_tax_rate']            = __('Are you sure you wish to delete this tax rate?', 'invoicing');
284
+        $localize['OneItemMin']                 = __('Invoice must contain at least one item', 'invoicing');
285
+        $localize['DeleteInvoiceItem']          = __('Are you sure you wish to delete this item?', 'invoicing');
286
+        $localize['FillBillingDetails']         = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing');
287
+        $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');
288
+        $localize['AreYouSure']                 = __('Are you sure?', 'invoicing');
289
+        $localize['hasGD']                      = wpinv_gd_active(); ;
290 290
         $localize['hasPM']                      = wpinv_pm_active();
291
-        $localize['emptyInvoice']               = __( 'Add atleast one item to save invoice!', 'invoicing' );
292
-        $localize['deletePackage']              = __( 'GD package items should be deleted from GD payment manager only, otherwise it will break invoices that created with this package!', 'invoicing' );
293
-        $localize['deletePackages']             = __( 'GD package items should be deleted from GD payment manager only', 'invoicing' );
294
-        $localize['deleteInvoiceFirst']         = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' );
291
+        $localize['emptyInvoice']               = __('Add atleast one item to save invoice!', 'invoicing');
292
+        $localize['deletePackage']              = __('GD package items should be deleted from GD payment manager only, otherwise it will break invoices that created with this package!', 'invoicing');
293
+        $localize['deletePackages']             = __('GD package items should be deleted from GD payment manager only', 'invoicing');
294
+        $localize['deleteInvoiceFirst']         = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing');
295 295
         
296
-        wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize );
296
+        wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize);
297 297
     }
298 298
     
299
-    public function admin_body_class( $classes ) {
299
+    public function admin_body_class($classes) {
300 300
         global $pagenow;
301 301
         
302
-        $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
302
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
303 303
 
304 304
         $add_class = false;
305
-        if ( $pagenow == 'admin.php' && $page ) {
306
-            $add_class = strpos( $page, 'wpinv-' );
305
+        if ($pagenow == 'admin.php' && $page) {
306
+            $add_class = strpos($page, 'wpinv-');
307 307
         }
308 308
         
309 309
         $settings_class = array();
310
-        if ( $page == 'wpinv-settings' ) {
311
-            if ( !empty( $_REQUEST['tab'] ) ) {
312
-                $settings_class[] = sanitize_text_field( $_REQUEST['tab'] );
310
+        if ($page == 'wpinv-settings') {
311
+            if (!empty($_REQUEST['tab'])) {
312
+                $settings_class[] = sanitize_text_field($_REQUEST['tab']);
313 313
             }
314 314
             
315
-            if ( !empty( $_REQUEST['section'] ) ) {
316
-                $settings_class[] = sanitize_text_field( $_REQUEST['section'] );
315
+            if (!empty($_REQUEST['section'])) {
316
+                $settings_class[] = sanitize_text_field($_REQUEST['section']);
317 317
             }
318 318
             
319
-            $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main';
319
+            $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main';
320 320
         }
321 321
         
322
-        if ( !empty( $settings_class ) ) {
323
-            $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) );
322
+        if (!empty($settings_class)) {
323
+            $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-'));
324 324
         }
325 325
         
326 326
         $post_type = wpinv_admin_post_type();
327 327
         
328
-        if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) {
328
+        if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) {
329 329
             return $classes .= ' wpinv';
330 330
         } else {
331 331
             return $classes;
@@ -337,26 +337,26 @@  discard block
 block discarded – undo
337 337
     public function admin_print_scripts_edit_php() {
338 338
         $post_type = wpinv_admin_post_type();
339 339
         
340
-        if ( $post_type == 'wpi_item' ) {
341
-            wp_enqueue_script( 'wpinv-inline-edit-post', WPINV_PLUGIN_URL . 'assets/js/quick-edit.js', array( 'jquery', 'inline-edit-post' ), '', true );
340
+        if ($post_type == 'wpi_item') {
341
+            wp_enqueue_script('wpinv-inline-edit-post', WPINV_PLUGIN_URL . 'assets/js/quick-edit.js', array('jquery', 'inline-edit-post'), '', true);
342 342
         }
343 343
     }
344 344
     
345 345
     public function wpinv_actions() {
346
-        if ( isset( $_REQUEST['wpi_action'] ) ) {
347
-            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
346
+        if (isset($_REQUEST['wpi_action'])) {
347
+            do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
348 348
         }
349 349
     }
350 350
     
351
-    public function pre_get_posts( $wp_query ) {
352
-        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() ) {
353
-            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
351
+    public function pre_get_posts($wp_query) {
352
+        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()) {
353
+            $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
354 354
         }
355 355
         
356 356
         return $wp_query;
357 357
     }
358 358
     
359 359
     public function bp_invoicing_init() {
360
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
360
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
361 361
     }
362 362
 }
363 363
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wpinv-notes.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit; // Exit if accessed directly
4 4
 }
5 5
 
@@ -14,73 +14,73 @@  discard block
 block discarded – undo
14 14
     }
15 15
     
16 16
     public function init() {
17
-        do_action( 'wpinv_class_notes_init', $this );
17
+        do_action('wpinv_class_notes_init', $this);
18 18
     }
19 19
     
20 20
     public function includes() {
21
-        do_action( 'wpinv_class_notes_includes', $this );
21
+        do_action('wpinv_class_notes_includes', $this);
22 22
     }
23 23
     
24 24
     public function actions() {
25 25
         // Secure inovice notes
26
-        add_action( 'pre_get_comments', array( $this, 'set_invoice_note_type' ), 11, 1 );
26
+        add_action('pre_get_comments', array($this, 'set_invoice_note_type'), 11, 1);
27 27
         
28 28
         // Count comments
29
-        add_filter( 'wp_count_comments', array( $this, 'wp_count_comments' ), 11, 2 );
29
+        add_filter('wp_count_comments', array($this, 'wp_count_comments'), 11, 2);
30 30
         
31 31
         // Delete comments count cache whenever there is a new comment or a comment status changes
32
-        add_action( 'wp_insert_comment', array( $this, 'delete_comments_count_cache' ) );
33
-        add_action( 'wp_set_comment_status', array( $this, 'delete_comments_count_cache' ) );
32
+        add_action('wp_insert_comment', array($this, 'delete_comments_count_cache'));
33
+        add_action('wp_set_comment_status', array($this, 'delete_comments_count_cache'));
34 34
         
35
-        do_action( 'wpinv_class_notes_actions', $this );
35
+        do_action('wpinv_class_notes_actions', $this);
36 36
     }
37 37
         
38
-    public function set_invoice_note_type( $query ) {
39
-        $post_ID        = !empty( $query->query_vars['post_ID'] ) ? $query->query_vars['post_ID'] : $query->query_vars['post_id'];
38
+    public function set_invoice_note_type($query) {
39
+        $post_ID = !empty($query->query_vars['post_ID']) ? $query->query_vars['post_ID'] : $query->query_vars['post_id'];
40 40
         
41
-        if ( $post_ID && get_post_type( $post_ID ) == $this->invoice_post_type ) {
41
+        if ($post_ID && get_post_type($post_ID) == $this->invoice_post_type) {
42 42
             $query->query_vars['type__in']      = $this->comment_type;
43 43
             $query->query_vars['type__not_in']  = '';
44 44
         } else {        
45
-            if ( isset( $query->query_vars['type__in'] ) && $type_in = $query->query_vars['type__in'] ) {
46
-                if ( is_array( $type_in ) && in_array( $this->comment_type, $type_in ) ) {
47
-                    $key = array_search( $this->comment_type, $type_in );
48
-                    unset( $query->query_vars['type__in'][$key] );
49
-                } else if ( !is_array( $type_in ) && $type_in == $this->comment_type ) {
45
+            if (isset($query->query_vars['type__in']) && $type_in = $query->query_vars['type__in']) {
46
+                if (is_array($type_in) && in_array($this->comment_type, $type_in)) {
47
+                    $key = array_search($this->comment_type, $type_in);
48
+                    unset($query->query_vars['type__in'][$key]);
49
+                } else if (!is_array($type_in) && $type_in == $this->comment_type) {
50 50
                     $query->query_vars['type__in'] = '';
51 51
                 }
52 52
             }
53 53
             
54
-            if ( isset( $query->query_vars['type__not_in'] ) && $type_not_in = $query->query_vars['type__not_in'] ) {
55
-                if ( is_array( $type_not_in ) && !in_array( $this->comment_type, $type_not_in ) ) {
54
+            if (isset($query->query_vars['type__not_in']) && $type_not_in = $query->query_vars['type__not_in']) {
55
+                if (is_array($type_not_in) && !in_array($this->comment_type, $type_not_in)) {
56 56
                     $query->query_vars['type__not_in'][] = $this->comment_type;
57
-                } else if ( !is_array( $type_not_in ) && $type_not_in != $this->comment_type ) {
57
+                } else if (!is_array($type_not_in) && $type_not_in != $this->comment_type) {
58 58
                     $query->query_vars['type__not_in'] = (array)$query->query_vars['type__not_in'];
59 59
                     $query->query_vars['type__not_in'][] = $this->comment_type;
60 60
                 }
61 61
             } else {
62
-                $query->query_vars['type__not_in']  = $this->comment_type;
62
+                $query->query_vars['type__not_in'] = $this->comment_type;
63 63
             }
64 64
         }
65 65
         
66 66
         return $query;
67 67
     }
68 68
     
69
-    public function get_invoice_notes( $invoice_id = 0, $type = '' ) {
69
+    public function get_invoice_notes($invoice_id = 0, $type = '') {
70 70
         $args = array( 
71 71
             'post_id'   => $invoice_id,
72 72
             'orderby'   => 'comment_ID',
73 73
             'order'     => 'DESC',
74 74
         );
75 75
         
76
-        if ( $type == 'customer' ) {
76
+        if ($type == 'customer') {
77 77
             $args['meta_key']   = '_wpi_customer_note';
78 78
             $args['meta_value'] = 1;
79 79
         }
80 80
         
81
-        $args   = apply_filters( 'wpinv_invoice_notes_args', $args, $this, $invoice_id, $type );
81
+        $args = apply_filters('wpinv_invoice_notes_args', $args, $this, $invoice_id, $type);
82 82
         
83
-        return get_comments( $args );
83
+        return get_comments($args);
84 84
     }
85 85
     
86 86
     /**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      * @return void
92 92
      */
93 93
     public function delete_comments_count_cache() {
94
-        delete_transient( 'wpinv_count_comments' );
94
+        delete_transient('wpinv_count_comments');
95 95
     }
96 96
     
97 97
     /**
@@ -102,16 +102,16 @@  discard block
 block discarded – undo
102 102
      * @param  int    $post_id Post ID.
103 103
      * @return object
104 104
      */
105
-    public function wp_count_comments( $stats, $post_id ) {
105
+    public function wp_count_comments($stats, $post_id) {
106 106
         global $wpdb;
107 107
 
108
-        if ( 0 === $post_id ) {
109
-            $stats = get_transient( 'wpinv_count_comments' );
108
+        if (0 === $post_id) {
109
+            $stats = get_transient('wpinv_count_comments');
110 110
 
111
-            if ( ! $stats ) {
111
+            if (!$stats) {
112 112
                 $stats = array();
113 113
 
114
-                $count = $wpdb->get_results( "SELECT comment_approved, COUNT(*) AS num_comments FROM {$wpdb->comments} WHERE comment_type NOT IN ('" . $this->comment_type . "') GROUP BY comment_approved", ARRAY_A );
114
+                $count = $wpdb->get_results("SELECT comment_approved, COUNT(*) AS num_comments FROM {$wpdb->comments} WHERE comment_type NOT IN ('" . $this->comment_type . "') GROUP BY comment_approved", ARRAY_A);
115 115
 
116 116
                 $total = 0;
117 117
                 $approved = array(
@@ -122,26 +122,26 @@  discard block
 block discarded – undo
122 122
                     'post-trashed' => 'post-trashed',
123 123
                 );
124 124
 
125
-                foreach ( (array) $count as $row ) {
125
+                foreach ((array)$count as $row) {
126 126
                     // Do not count post-trashed toward totals.
127
-                    if ( 'post-trashed' !== $row['comment_approved'] && 'trash' !== $row['comment_approved'] ) {
127
+                    if ('post-trashed' !== $row['comment_approved'] && 'trash' !== $row['comment_approved']) {
128 128
                         $total += $row['num_comments'];
129 129
                     }
130
-                    if ( isset( $approved[ $row['comment_approved'] ] ) ) {
131
-                        $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
130
+                    if (isset($approved[$row['comment_approved']])) {
131
+                        $stats[$approved[$row['comment_approved']]] = $row['num_comments'];
132 132
                     }
133 133
                 }
134 134
 
135 135
                 $stats['total_comments'] = $total;
136 136
                 $stats['all'] = $total;
137
-                foreach ( $approved as $key ) {
138
-                    if ( empty( $stats[ $key ] ) ) {
139
-                        $stats[ $key ] = 0;
137
+                foreach ($approved as $key) {
138
+                    if (empty($stats[$key])) {
139
+                        $stats[$key] = 0;
140 140
                     }
141 141
                 }
142 142
 
143
-                $stats = (object) $stats;
144
-                set_transient( 'wpinv_count_comments', $stats );
143
+                $stats = (object)$stats;
144
+                set_transient('wpinv_count_comments', $stats);
145 145
             }
146 146
         }
147 147
 
Please login to merge, or discard this patch.
includes/class-wpinv-db.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit; // Exit if accessed directly
4 4
 }
5 5
 
@@ -21,108 +21,108 @@  discard block
 block discarded – undo
21 21
         return array();
22 22
     }
23 23
 
24
-    public function get( $row_id ) {
24
+    public function get($row_id) {
25 25
         global $wpdb;
26
-        return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1", $row_id ) );
26
+        return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1", $row_id));
27 27
     }
28 28
 
29
-    public function get_by( $column, $row_id ) {
29
+    public function get_by($column, $row_id) {
30 30
         global $wpdb;
31
-        $column = esc_sql( $column );
32
-        return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1", $row_id ) );
31
+        $column = esc_sql($column);
32
+        return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1", $row_id));
33 33
     }
34 34
 
35
-    public function get_column( $column, $row_id ) {
35
+    public function get_column($column, $row_id) {
36 36
         global $wpdb;
37
-        $column = esc_sql( $column );
38
-        return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1", $row_id ) );
37
+        $column = esc_sql($column);
38
+        return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1", $row_id));
39 39
     }
40 40
 
41
-    public function get_column_by( $column, $column_where, $column_value ) {
41
+    public function get_column_by($column, $column_where, $column_value) {
42 42
         global $wpdb;
43
-        $column_where = esc_sql( $column_where );
44
-        $column       = esc_sql( $column );
45
-        return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1", $column_value ) );
43
+        $column_where = esc_sql($column_where);
44
+        $column       = esc_sql($column);
45
+        return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1", $column_value));
46 46
     }
47 47
 
48
-    public function insert( $data, $type = '' ) {
48
+    public function insert($data, $type = '') {
49 49
         global $wpdb;
50 50
 
51
-        $data = wp_parse_args( $data, $this->get_column_defaults() );
51
+        $data = wp_parse_args($data, $this->get_column_defaults());
52 52
 
53
-        do_action( 'wpinv_pre_insert_' . $type, $data );
53
+        do_action('wpinv_pre_insert_' . $type, $data);
54 54
 
55 55
         $column_formats = $this->get_columns();
56 56
 
57
-        $data = array_change_key_case( $data );
57
+        $data = array_change_key_case($data);
58 58
 
59
-        $data = array_intersect_key( $data, $column_formats );
59
+        $data = array_intersect_key($data, $column_formats);
60 60
 
61
-        $data_keys = array_keys( $data );
62
-        $column_formats = array_merge( array_flip( $data_keys ), $column_formats );
61
+        $data_keys = array_keys($data);
62
+        $column_formats = array_merge(array_flip($data_keys), $column_formats);
63 63
 
64
-        $wpdb->insert( $this->table_name, $data, $column_formats );
64
+        $wpdb->insert($this->table_name, $data, $column_formats);
65 65
         $wpdb_insert_id = $wpdb->insert_id;
66 66
 
67
-        do_action( 'wpinv_post_insert_' . $type, $wpdb_insert_id, $data );
67
+        do_action('wpinv_post_insert_' . $type, $wpdb_insert_id, $data);
68 68
 
69 69
         return $wpdb_insert_id;
70 70
     }
71 71
 
72
-    public function update( $row_id, $data = array(), $where = '' ) {
72
+    public function update($row_id, $data = array(), $where = '') {
73 73
         global $wpdb;
74 74
 
75
-        $row_id = absint( $row_id );
75
+        $row_id = absint($row_id);
76 76
 
77
-        if( empty( $row_id ) ) {
77
+        if (empty($row_id)) {
78 78
             return false;
79 79
         }
80 80
 
81
-        if( empty( $where ) ) {
81
+        if (empty($where)) {
82 82
             $where = $this->primary_key;
83 83
         }
84 84
 
85 85
         $column_formats = $this->get_columns();
86 86
 
87
-        $data = array_change_key_case( $data );
87
+        $data = array_change_key_case($data);
88 88
 
89
-        $data = array_intersect_key( $data, $column_formats );
89
+        $data = array_intersect_key($data, $column_formats);
90 90
 
91
-        $data_keys = array_keys( $data );
92
-        $column_formats = array_merge( array_flip( $data_keys ), $column_formats );
91
+        $data_keys = array_keys($data);
92
+        $column_formats = array_merge(array_flip($data_keys), $column_formats);
93 93
 
94
-        if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) {
94
+        if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) {
95 95
             return false;
96 96
         }
97 97
 
98 98
         return true;
99 99
     }
100 100
 
101
-    public function delete( $row_id = 0 ) {
101
+    public function delete($row_id = 0) {
102 102
         global $wpdb;
103 103
 
104
-        $row_id = absint( $row_id );
104
+        $row_id = absint($row_id);
105 105
 
106
-        if( empty( $row_id ) ) {
106
+        if (empty($row_id)) {
107 107
             return false;
108 108
         }
109 109
 
110
-        if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) {
110
+        if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) {
111 111
             return false;
112 112
         }
113 113
 
114 114
         return true;
115 115
     }
116 116
 
117
-    public function table_exists( $table ) {
117
+    public function table_exists($table) {
118 118
         global $wpdb;
119
-        $table = sanitize_text_field( $table );
119
+        $table = sanitize_text_field($table);
120 120
 
121
-        return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table;
121
+        return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table;
122 122
     }
123 123
 
124 124
     public function installed() {
125
-        return $this->table_exists( $this->table_name );
125
+        return $this->table_exists($this->table_name);
126 126
     }
127 127
 
128 128
 }
Please login to merge, or discard this patch.
includes/class-wpinv-subscription.php 1 patch
Spacing   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit; // Exit if accessed directly
4 4
 }
5 5
 
@@ -27,60 +27,60 @@  discard block
 block discarded – undo
27 27
     public $user;
28 28
     public $post_type;
29 29
 
30
-    function __construct( $id_or_object = 0, $by_profile_id = false ) {
30
+    function __construct($id_or_object = 0, $by_profile_id = false) {
31 31
         $this->subscriptions_db = new WPInv_Subscriptions_DB;
32 32
 
33
-        if ( $by_profile_id ) {
34
-            $subscription = $this->subscriptions_db->get_by( 'profile_id', $id_or_object );
33
+        if ($by_profile_id) {
34
+            $subscription = $this->subscriptions_db->get_by('profile_id', $id_or_object);
35 35
 
36
-            if ( empty( $subscription ) ) {
36
+            if (empty($subscription)) {
37 37
                 return false;
38 38
             }
39 39
 
40 40
             $id_or_object = $subscription;
41 41
         }
42 42
 
43
-        return $this->setup_subscription( $id_or_object );
43
+        return $this->setup_subscription($id_or_object);
44 44
     }
45 45
 
46
-    private function setup_subscription( $id_or_object = 0 ) {
47
-        if ( empty( $id_or_object ) ) {
46
+    private function setup_subscription($id_or_object = 0) {
47
+        if (empty($id_or_object)) {
48 48
             return false;
49 49
         }
50 50
 
51
-        if ( is_numeric( $id_or_object ) ) {
52
-            $subscription = $this->subscriptions_db->get( $id_or_object );
53
-        } elseif ( is_object( $id_or_object ) ) {
51
+        if (is_numeric($id_or_object)) {
52
+            $subscription = $this->subscriptions_db->get($id_or_object);
53
+        } elseif (is_object($id_or_object)) {
54 54
             $subscription = $id_or_object;
55 55
         }
56 56
 
57
-        if ( empty( $subscription ) ) {
57
+        if (empty($subscription)) {
58 58
             return false;
59 59
         }
60 60
 
61
-        foreach( $subscription as $key => $value ) {
61
+        foreach ($subscription as $key => $value) {
62 62
             $this->$key = $value;
63 63
         }
64 64
 
65
-        $this->post_type = get_post_type( $this->parent_invoice_id );
66
-        $this->user = get_user_by( 'id', $this->user_id );
67
-        $this->gateway = wpinv_get_payment_gateway( $this->parent_invoice_id );
65
+        $this->post_type = get_post_type($this->parent_invoice_id);
66
+        $this->user = get_user_by('id', $this->user_id);
67
+        $this->gateway = wpinv_get_payment_gateway($this->parent_invoice_id);
68 68
 
69
-        do_action( 'wpinv_recurring_setup_subscription', $this );
69
+        do_action('wpinv_recurring_setup_subscription', $this);
70 70
 
71 71
         return $this;
72 72
     }
73 73
 
74
-    public function __get( $key ) {
75
-        if ( method_exists( $this, 'get_' . $key ) ) {
76
-            return call_user_func( array( $this, 'get_' . $key ) );
74
+    public function __get($key) {
75
+        if (method_exists($this, 'get_' . $key)) {
76
+            return call_user_func(array($this, 'get_' . $key));
77 77
         } else {
78
-            return new WP_Error( 'wpinv-subscription-invalid-property', sprintf( __( 'Can\'t get property %s', 'invoicing' ), $key ) );
78
+            return new WP_Error('wpinv-subscription-invalid-property', sprintf(__('Can\'t get property %s', 'invoicing'), $key));
79 79
         }
80 80
     }
81 81
 
82
-    public function create( $data = array() ) {
83
-        if ( $this->id != 0 ) {
82
+    public function create($data = array()) {
83
+        if ($this->id != 0) {
84 84
             return false;
85 85
         }
86 86
 
@@ -101,37 +101,37 @@  discard block
 block discarded – undo
101 101
             'profile_id'        => '',
102 102
         );
103 103
 
104
-        $args = wp_parse_args( $data, $defaults );
104
+        $args = wp_parse_args($data, $defaults);
105 105
 
106
-        if ( $args['expiration'] && strtotime( 'NOW', current_time( 'timestamp' ) ) > strtotime( $args['expiration'], current_time( 'timestamp' ) ) ) {
107
-            if ( 'active' == $args['status'] || 'trialling' == $args['status'] ) {
106
+        if ($args['expiration'] && strtotime('NOW', current_time('timestamp')) > strtotime($args['expiration'], current_time('timestamp'))) {
107
+            if ('active' == $args['status'] || 'trialling' == $args['status']) {
108 108
                 $args['status'] = 'expired';
109 109
             }
110 110
         }
111 111
 
112
-        do_action( 'wpinv_subscription_pre_create', $args );
112
+        do_action('wpinv_subscription_pre_create', $args);
113 113
 
114
-        $id = $this->subscriptions_db->insert( $args, 'subscription' );
114
+        $id = $this->subscriptions_db->insert($args, 'subscription');
115 115
 
116
-        do_action( 'wpinv_subscription_post_create', $id, $args );
116
+        do_action('wpinv_subscription_post_create', $id, $args);
117 117
 
118
-        return $this->setup_subscription( $id );
118
+        return $this->setup_subscription($id);
119 119
     }
120 120
 
121
-    public function update( $args = array() ) {
122
-        if ( isset( $args['status'] ) && strtolower( $this->status ) !== strtolower( $args['status'] ) ) {
123
-            $this->add_note( sprintf( __( 'Status changed from %s to %s', 'invoicing' ), $this->status, $args['status'] ) );
121
+    public function update($args = array()) {
122
+        if (isset($args['status']) && strtolower($this->status) !== strtolower($args['status'])) {
123
+            $this->add_note(sprintf(__('Status changed from %s to %s', 'invoicing'), $this->status, $args['status']));
124 124
         }
125 125
 
126
-        $ret = $this->subscriptions_db->update( $this->id, $args );
126
+        $ret = $this->subscriptions_db->update($this->id, $args);
127 127
 
128
-        do_action( 'wpinv_recurring_update_subscription', $this->id, $args, $this );
128
+        do_action('wpinv_recurring_update_subscription', $this->id, $args, $this);
129 129
 
130 130
         return $ret;
131 131
     }
132 132
 
133 133
     public function delete() {
134
-        return $this->subscriptions_db->delete( $this->id );
134
+        return $this->subscriptions_db->delete($this->id);
135 135
     }
136 136
 
137 137
     public function get_original_invoice_id() {
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     }
140 140
 
141 141
     public function get_child_invoices() {
142
-        $invoices = wpinv_get_invoices( array(
142
+        $invoices = wpinv_get_invoices(array(
143 143
             'post_parent'    => (int)$this->parent_invoice_id,
144 144
             'posts_per_page' => '999',
145 145
             'post_status'    => 'any',
@@ -148,19 +148,19 @@  discard block
 block discarded – undo
148 148
             'meta_value'     => $this->id,
149 149
             'orderby'        => 'ID',
150 150
             'order'          => 'DESC',
151
-        ) );
151
+        ));
152 152
 
153 153
         return (array)$invoices;
154 154
     }
155 155
 
156 156
     public function get_total_invoices() {
157
-        return count( $this->get_child_invoices() ) + 1;
157
+        return count($this->get_child_invoices()) + 1;
158 158
     }
159 159
 
160 160
     public function get_times_billed() {
161 161
         $times_billed = $this->get_total_invoices();
162 162
 
163
-        if ( ! empty( $this->trial_period ) ) {
163
+        if (!empty($this->trial_period)) {
164 164
             $times_billed -= 1;
165 165
         }
166 166
 
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
     public function get_lifetime_value() {
171 171
         $amount = 0.00;
172 172
 
173
-        $parent_invoice   = new WPInv_Invoice( $this->parent_invoice_id );
174
-        $ignored_statuses = array( 'wpi-refunded', 'pending', 'wpi-cancelled', 'wpi-failed' );
173
+        $parent_invoice   = new WPInv_Invoice($this->parent_invoice_id);
174
+        $ignored_statuses = array('wpi-refunded', 'pending', 'wpi-cancelled', 'wpi-failed');
175 175
 
176
-        if ( false === in_array( $parent_invoice->status, $ignored_statuses ) ) {
177
-            foreach ( $parent_invoice->cart_details as $cart_item ) {
178
-                if ( (int) $this->item_id === (int) $cart_item['id'] ) {
176
+        if (false === in_array($parent_invoice->status, $ignored_statuses)) {
177
+            foreach ($parent_invoice->cart_details as $cart_item) {
178
+                if ((int)$this->item_id === (int)$cart_item['id']) {
179 179
                     $amount += $cart_item['price'];
180 180
                     break;
181 181
                 }
@@ -184,11 +184,11 @@  discard block
 block discarded – undo
184 184
 
185 185
         $children = $this->get_child_invoices();
186 186
 
187
-        if ( $children ) {
188
-            foreach( $children as $child ) {
189
-                $child_invoice = new WPInv_Invoice( $child->ID );
187
+        if ($children) {
188
+            foreach ($children as $child) {
189
+                $child_invoice = new WPInv_Invoice($child->ID);
190 190
                 
191
-                if ( 'wpi-refunded' === $child_invoice->status ) {
191
+                if ('wpi-refunded' === $child_invoice->status) {
192 192
                     continue;
193 193
                 }
194 194
 
@@ -199,46 +199,46 @@  discard block
 block discarded – undo
199 199
         return $amount;
200 200
     }
201 201
 
202
-    public function add_invoice( $args = array() ) {
203
-        $args = wp_parse_args( $args, array(
202
+    public function add_invoice($args = array()) {
203
+        $args = wp_parse_args($args, array(
204 204
             'amount'         => '',
205 205
             'transaction_id' => '',
206 206
             'gateway'        => ''
207
-        ) );
207
+        ));
208 208
 
209
-        if ( wpinv_payment_exists( $args['transaction_id'] ) ) {
209
+        if (wpinv_payment_exists($args['transaction_id'])) {
210 210
             return false;
211 211
         }
212 212
         
213
-        $parent_invoice = wpinv_get_invoice( $this->parent_invoice_id );
214
-        if ( empty( $parent_invoice ) ) {
213
+        $parent_invoice = wpinv_get_invoice($this->parent_invoice_id);
214
+        if (empty($parent_invoice)) {
215 215
             return;
216 216
         }
217 217
         
218 218
         $invoice = new WPInv_Invoice();
219
-        $invoice->set( 'parent_invoice', $this->parent_invoice_id );
220
-        $invoice->set( 'currency', $parent_invoice->get_currency() );
221
-        $invoice->set( 'transaction_id', $args['transaction_id'] );
222
-        $invoice->set( 'key', $parent_invoice->get_key() );
223
-        $invoice->set( 'ip', $parent_invoice->ip );
224
-        $invoice->set( 'user_id', $parent_invoice->get_user_id() );
225
-        $invoice->set( 'first_name', $parent_invoice->get_first_name() );
226
-        $invoice->set( 'last_name', $parent_invoice->get_last_name() );
227
-        $invoice->set( 'phone', $parent_invoice->phone );
228
-        $invoice->set( 'address', $parent_invoice->address );
229
-        $invoice->set( 'city', $parent_invoice->city );
230
-        $invoice->set( 'country', $parent_invoice->country );
231
-        $invoice->set( 'state', $parent_invoice->state );
232
-        $invoice->set( 'zip', $parent_invoice->zip );
233
-        $invoice->set( 'company', $parent_invoice->company );
234
-        $invoice->set( 'vat_number', $parent_invoice->vat_number );
235
-        $invoice->set( 'vat_rate', $parent_invoice->vat_rate );
236
-        $invoice->set( 'adddress_confirmed', $parent_invoice->adddress_confirmed );
237
-
238
-        if ( empty( $args['gateway'] ) ) {
239
-            $invoice->set( 'gateway', $parent_invoice->get_gateway() );
219
+        $invoice->set('parent_invoice', $this->parent_invoice_id);
220
+        $invoice->set('currency', $parent_invoice->get_currency());
221
+        $invoice->set('transaction_id', $args['transaction_id']);
222
+        $invoice->set('key', $parent_invoice->get_key());
223
+        $invoice->set('ip', $parent_invoice->ip);
224
+        $invoice->set('user_id', $parent_invoice->get_user_id());
225
+        $invoice->set('first_name', $parent_invoice->get_first_name());
226
+        $invoice->set('last_name', $parent_invoice->get_last_name());
227
+        $invoice->set('phone', $parent_invoice->phone);
228
+        $invoice->set('address', $parent_invoice->address);
229
+        $invoice->set('city', $parent_invoice->city);
230
+        $invoice->set('country', $parent_invoice->country);
231
+        $invoice->set('state', $parent_invoice->state);
232
+        $invoice->set('zip', $parent_invoice->zip);
233
+        $invoice->set('company', $parent_invoice->company);
234
+        $invoice->set('vat_number', $parent_invoice->vat_number);
235
+        $invoice->set('vat_rate', $parent_invoice->vat_rate);
236
+        $invoice->set('adddress_confirmed', $parent_invoice->adddress_confirmed);
237
+
238
+        if (empty($args['gateway'])) {
239
+            $invoice->set('gateway', $parent_invoice->get_gateway());
240 240
         } else {
241
-            $invoice->set( 'gateway', $args['gateway'] );
241
+            $invoice->set('gateway', $args['gateway']);
242 242
         }
243 243
         
244 244
         $recurring_details = $parent_invoice->get_recurring_details();
@@ -246,11 +246,11 @@  discard block
 block discarded – undo
246 246
         // increase the earnings for each item in the subscription
247 247
         $items = $recurring_details['cart_details'];
248 248
         
249
-        if ( $items ) {        
249
+        if ($items) {        
250 250
             $add_items      = array();
251 251
             $cart_details   = array();
252 252
             
253
-            foreach ( $items as $item ) {
253
+            foreach ($items as $item) {
254 254
                 $add_item             = array();
255 255
                 $add_item['id']       = $item['id'];
256 256
                 $add_item['quantity'] = $item['quantity'];
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
                 break;
261 261
             }
262 262
             
263
-            $invoice->set( 'items', $add_items );
263
+            $invoice->set('items', $add_items);
264 264
             $invoice->cart_details = $cart_details;
265 265
         }
266 266
         
@@ -270,70 +270,70 @@  discard block
 block discarded – undo
270 270
         $tax                = $recurring_details['tax'];
271 271
         $discount           = $recurring_details['discount'];
272 272
         
273
-        if ( $discount > 0 ) {
274
-            $invoice->set( 'discount_code', $parent_invoice->discount_code );
273
+        if ($discount > 0) {
274
+            $invoice->set('discount_code', $parent_invoice->discount_code);
275 275
         }
276 276
         
277
-        $invoice->subtotal = wpinv_round_amount( $subtotal );
278
-        $invoice->tax      = wpinv_round_amount( $tax );
279
-        $invoice->discount = wpinv_round_amount( $discount );
280
-        $invoice->total    = wpinv_round_amount( $total );
277
+        $invoice->subtotal = wpinv_round_amount($subtotal);
278
+        $invoice->tax      = wpinv_round_amount($tax);
279
+        $invoice->discount = wpinv_round_amount($discount);
280
+        $invoice->total    = wpinv_round_amount($total);
281 281
         $invoice->save();
282
-        $invoice->update_meta( '_wpinv_subscription_id', $this->id );
282
+        $invoice->update_meta('_wpinv_subscription_id', $this->id);
283 283
         
284
-        wpinv_update_payment_status( $invoice->ID, 'publish' );
284
+        wpinv_update_payment_status($invoice->ID, 'publish');
285 285
         sleep(1);
286
-        wpinv_update_payment_status( $invoice->ID, 'wpi-renewal' );
286
+        wpinv_update_payment_status($invoice->ID, 'wpi-renewal');
287 287
         
288
-        do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $parent_invoice, $this );
289
-        do_action( 'wpinv_recurring_record_payment', $invoice->ID, $this->parent_invoice_id, $total, $this );
288
+        do_action('wpinv_recurring_add_subscription_payment', $invoice, $parent_invoice, $this);
289
+        do_action('wpinv_recurring_record_payment', $invoice->ID, $this->parent_invoice_id, $total, $this);
290 290
 
291 291
         return $invoice;
292 292
     }
293 293
 
294 294
     public function get_transaction_id() {
295
-        if ( empty( $this->transaction_id ) ) {
296
-            $txn_id = wpinv_get_payment_transaction_id( $this->parent_invoice_id );
295
+        if (empty($this->transaction_id)) {
296
+            $txn_id = wpinv_get_payment_transaction_id($this->parent_invoice_id);
297 297
 
298
-            if ( ! empty( $txn_id ) && (int) $this->parent_invoice_id !== (int) $txn_id ) {
299
-                $this->set_transaction_id( $txn_id );
298
+            if (!empty($txn_id) && (int)$this->parent_invoice_id !== (int)$txn_id) {
299
+                $this->set_transaction_id($txn_id);
300 300
             }
301 301
         }
302 302
 
303 303
         return $this->transaction_id;
304 304
     }
305 305
 
306
-    public function set_transaction_id( $txn_id = '' ) {
307
-        $this->update( array( 'transaction_id' => $txn_id ) );
306
+    public function set_transaction_id($txn_id = '') {
307
+        $this->update(array('transaction_id' => $txn_id));
308 308
         $this->transaction_id = $txn_id;
309 309
     }
310 310
 
311 311
     public function renew() {
312 312
         $expires = $this->get_expiration_time();
313 313
 
314
-        if ( $expires > current_time( 'timestamp' ) && $this->is_active() ) {
314
+        if ($expires > current_time('timestamp') && $this->is_active()) {
315 315
             $base_date  = $expires;
316 316
         } else {
317
-            $base_date  = current_time( 'timestamp' );
317
+            $base_date  = current_time('timestamp');
318 318
         }
319 319
 
320
-        $last_day = cal_days_in_month( CAL_GREGORIAN, date_i18n( 'n', $base_date ), date_i18n( 'Y', $base_date ) );
320
+        $last_day = cal_days_in_month(CAL_GREGORIAN, date_i18n('n', $base_date), date_i18n('Y', $base_date));
321 321
 
322 322
         $interval = isset($this->interval) ? $this->interval : 1;
323
-        $expiration = date_i18n( 'Y-m-d H:i:s', strtotime( '+' . $interval . ' ' . $this->period  . ' 23:59:59', $base_date ) );
323
+        $expiration = date_i18n('Y-m-d H:i:s', strtotime('+' . $interval . ' ' . $this->period . ' 23:59:59', $base_date));
324 324
 
325
-        if ( date_i18n( 'j', $base_date ) == $last_day && 'day' != $this->period ) {
326
-            $expiration = date_i18n( 'Y-m-d H:i:s', strtotime( $expiration . ' +2 days' ) );
325
+        if (date_i18n('j', $base_date) == $last_day && 'day' != $this->period) {
326
+            $expiration = date_i18n('Y-m-d H:i:s', strtotime($expiration . ' +2 days'));
327 327
         }
328 328
 
329
-        $expiration  = apply_filters( 'wpinv_subscription_renewal_expiration', $expiration, $this->id, $this );
329
+        $expiration = apply_filters('wpinv_subscription_renewal_expiration', $expiration, $this->id, $this);
330 330
 
331
-        do_action( 'wpinv_subscription_pre_renew', $this->id, $expiration, $this );
331
+        do_action('wpinv_subscription_pre_renew', $this->id, $expiration, $this);
332 332
 
333 333
         $this->status = 'active';
334 334
         $times_billed = $this->get_times_billed();
335 335
 
336
-        if ( $this->bill_times > 0 && $times_billed >= $this->bill_times ) {
336
+        if ($this->bill_times > 0 && $times_billed >= $this->bill_times) {
337 337
             $this->complete();
338 338
             $this->status = 'completed';
339 339
         }
@@ -343,14 +343,14 @@  discard block
 block discarded – undo
343 343
             'status'     => $this->status,
344 344
         );
345 345
 
346
-        $this->update( $args );
346
+        $this->update($args);
347 347
 
348
-        do_action( 'wpinv_subscription_post_renew', $this->id, $expiration, $this );
349
-        do_action( 'wpinv_recurring_set_subscription_status', $this->id, $this->status, $this );
348
+        do_action('wpinv_subscription_post_renew', $this->id, $expiration, $this);
349
+        do_action('wpinv_recurring_set_subscription_status', $this->id, $this->status, $this);
350 350
     }
351 351
 
352 352
     public function complete() {
353
-        if ( 'cancelled' === $this->status ) {
353
+        if ('cancelled' === $this->status) {
354 354
             return;
355 355
         }
356 356
 
@@ -358,20 +358,20 @@  discard block
 block discarded – undo
358 358
             'status' => 'completed'
359 359
         );
360 360
 
361
-        if ( $this->subscriptions_db->update( $this->id, $args ) ) {
362
-            $this->add_note( sprintf( __( 'Status changed from %s to %s', 'invoicing' ), $this->status, 'completed' ) );
361
+        if ($this->subscriptions_db->update($this->id, $args)) {
362
+            $this->add_note(sprintf(__('Status changed from %s to %s', 'invoicing'), $this->status, 'completed'));
363 363
 
364 364
             $this->status = 'completed';
365 365
 
366
-            do_action( 'wpinv_subscription_completed', $this->id, $this );
366
+            do_action('wpinv_subscription_completed', $this->id, $this);
367 367
         }
368 368
     }
369 369
 
370
-    public function expire( $check_expiration = false ) {
370
+    public function expire($check_expiration = false) {
371 371
         $expiration = $this->expiration;
372 372
 
373
-        if ( $check_expiration && $this->check_expiration() ) {
374
-            if ( $expiration < $this->get_expiration() && current_time( 'timestamp' ) < $this->get_expiration_time() ) {
373
+        if ($check_expiration && $this->check_expiration()) {
374
+            if ($expiration < $this->get_expiration() && current_time('timestamp') < $this->get_expiration_time()) {
375 375
                 return false;
376 376
             }
377 377
         }
@@ -380,12 +380,12 @@  discard block
 block discarded – undo
380 380
             'status' => 'expired'
381 381
         );
382 382
 
383
-        if ( $this->subscriptions_db->update( $this->id, $args ) ) {
384
-            $this->add_note( sprintf( __( 'Status changed from %s to %s', 'invoicing' ), $this->status, 'expired' ) );
383
+        if ($this->subscriptions_db->update($this->id, $args)) {
384
+            $this->add_note(sprintf(__('Status changed from %s to %s', 'invoicing'), $this->status, 'expired'));
385 385
 
386 386
             $this->status = 'expired';
387 387
 
388
-            do_action( 'wpinv_subscription_expired', $this->id, $this );
388
+            do_action('wpinv_subscription_expired', $this->id, $this);
389 389
         }
390 390
     }
391 391
 
@@ -394,17 +394,17 @@  discard block
 block discarded – undo
394 394
             'status' => 'failing'
395 395
         );
396 396
 
397
-        if ( $this->subscriptions_db->update( $this->id, $args ) ) {
398
-            $this->add_note( sprintf( __( 'Status changed from %s to %s', 'invoicing' ), $this->status, 'failing' ) );
397
+        if ($this->subscriptions_db->update($this->id, $args)) {
398
+            $this->add_note(sprintf(__('Status changed from %s to %s', 'invoicing'), $this->status, 'failing'));
399 399
 
400 400
             $this->status = 'failing';
401 401
 
402
-            do_action( 'wpinv_subscription_failing', $this->id, $this );
402
+            do_action('wpinv_subscription_failing', $this->id, $this);
403 403
         }
404 404
     }
405 405
 
406 406
     public function cancel() {
407
-        if ( 'cancelled' === $this->status ) {
407
+        if ('cancelled' === $this->status) {
408 408
             return;
409 409
         }
410 410
 
@@ -412,108 +412,108 @@  discard block
 block discarded – undo
412 412
             'status' => 'cancelled'
413 413
         );
414 414
 
415
-        if ( $this->subscriptions_db->update( $this->id, $args ) ) {
416
-            if ( is_user_logged_in() ) {
417
-                $userdata = get_userdata( get_current_user_id() );
415
+        if ($this->subscriptions_db->update($this->id, $args)) {
416
+            if (is_user_logged_in()) {
417
+                $userdata = get_userdata(get_current_user_id());
418 418
                 $user     = $userdata->user_login;
419 419
             } else {
420
-                $user = __( 'gateway', 'invoicing' );
420
+                $user = __('gateway', 'invoicing');
421 421
             }
422 422
 
423
-            $note = sprintf( __( 'Subscription #%d cancelled by %s', 'invoicing' ), $this->id, $user );
424
-            $this->add_note( $note );
423
+            $note = sprintf(__('Subscription #%d cancelled by %s', 'invoicing'), $this->id, $user);
424
+            $this->add_note($note);
425 425
             $this->status = 'cancelled';
426 426
 
427
-            do_action( 'wpinv_subscription_cancelled', $this->id, $this );
427
+            do_action('wpinv_subscription_cancelled', $this->id, $this);
428 428
         }
429 429
     }
430 430
 
431 431
     public function can_cancel() {
432
-        return apply_filters( 'wpinv_subscription_can_cancel', false, $this );
432
+        return apply_filters('wpinv_subscription_can_cancel', false, $this);
433 433
     }
434 434
 
435 435
     public function get_cancel_url() {
436
-        $url = wp_nonce_url( add_query_arg( array( 'wpi_action' => 'cancel_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-cancel' );
436
+        $url = wp_nonce_url(add_query_arg(array('wpi_action' => 'cancel_subscription', 'sub_id' => $this->id)), 'wpinv-recurring-cancel');
437 437
 
438
-        return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
438
+        return apply_filters('wpinv_subscription_cancel_url', $url, $this);
439 439
     }
440 440
 
441 441
     public function can_renew() {
442
-        return apply_filters( 'wpinv_subscription_can_renew', false, $this );
442
+        return apply_filters('wpinv_subscription_can_renew', false, $this);
443 443
     }
444 444
 
445 445
     public function get_renew_url() {
446
-        $url = wp_nonce_url( add_query_arg( array( 'wpi_action' => 'renew_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-renew' );
446
+        $url = wp_nonce_url(add_query_arg(array('wpi_action' => 'renew_subscription', 'sub_id' => $this->id)), 'wpinv-recurring-renew');
447 447
 
448
-        return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
448
+        return apply_filters('wpinv_subscription_renew_url', $url, $this);
449 449
     }
450 450
 
451 451
     public function can_update() {
452
-        return apply_filters( 'wpinv_subscription_can_update', false, $this );
452
+        return apply_filters('wpinv_subscription_can_update', false, $this);
453 453
     }
454 454
 
455 455
     public function get_update_url() {
456
-        $url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->id ) );
456
+        $url = add_query_arg(array('action' => 'update', 'subscription_id' => $this->id));
457 457
 
458
-        return apply_filters( 'wpinv_subscription_update_url', $url, $this );
458
+        return apply_filters('wpinv_subscription_update_url', $url, $this);
459 459
     }
460 460
 
461 461
     public function is_active() {
462 462
         $ret = false;
463 463
 
464
-        if ( ! $this->is_expired() && ( $this->status == 'active' || $this->status == 'cancelled' || $this->status == 'trialling' ) ) {
464
+        if (!$this->is_expired() && ($this->status == 'active' || $this->status == 'cancelled' || $this->status == 'trialling')) {
465 465
             $ret = true;
466 466
         }
467 467
 
468
-        return apply_filters( 'wpinv_subscription_is_active', $ret, $this->id, $this );
468
+        return apply_filters('wpinv_subscription_is_active', $ret, $this->id, $this);
469 469
     }
470 470
 
471 471
     public function is_expired() {
472 472
         $ret = false;
473 473
 
474
-        if ( $this->status == 'expired' ) {
474
+        if ($this->status == 'expired') {
475 475
             $ret = true;
476
-        } elseif ( 'active' === $this->status || 'cancelled' === $this->status || $this->status == 'trialling'  ) {
476
+        } elseif ('active' === $this->status || 'cancelled' === $this->status || $this->status == 'trialling') {
477 477
             $ret        = false;
478 478
             $expiration = $this->get_expiration_time();
479 479
 
480
-            if ( $expiration && strtotime( 'NOW', current_time( 'timestamp' ) ) > $expiration ) {
480
+            if ($expiration && strtotime('NOW', current_time('timestamp')) > $expiration) {
481 481
                 $ret = true;
482 482
 
483
-                if ( 'active' === $this->status || $this->status == 'trialling'  ) {
483
+                if ('active' === $this->status || $this->status == 'trialling') {
484 484
                     $this->expire();
485 485
                 }
486 486
             }
487 487
         }
488 488
 
489
-        return apply_filters( 'wpinv_subscription_is_expired', $ret, $this->id, $this );
489
+        return apply_filters('wpinv_subscription_is_expired', $ret, $this->id, $this);
490 490
     }
491 491
 
492
-    public function get_expiration( $check_gateway = true ) {
492
+    public function get_expiration($check_gateway = true) {
493 493
         return $this->expiration;
494 494
     }
495 495
 
496 496
     public function check_expiration() {
497
-        $ret   = false;
497
+        $ret = false;
498 498
         
499
-        $expiration = apply_filters( 'wpinv_subscription_ ' . $this->gateway . '_get_expiration', NULL, $this->id, $this );
499
+        $expiration = apply_filters('wpinv_subscription_ ' . $this->gateway . '_get_expiration', NULL, $this->id, $this);
500 500
         
501
-        $class = edd_recurring()->get_gateway_class( $this->gateway );
501
+        $class = edd_recurring()->get_gateway_class($this->gateway);
502 502
 
503
-        if ( $class && class_exists( $class ) ) {
503
+        if ($class && class_exists($class)) {
504 504
             $gateway = new $class;
505 505
 
506
-            if ( is_callable( array( $gateway, 'get_expiration' ) ) ) {
507
-                $expiration = $gateway->get_expiration( $this );
506
+            if (is_callable(array($gateway, 'get_expiration'))) {
507
+                $expiration = $gateway->get_expiration($this);
508 508
 
509
-                if ( ! is_wp_error( $expiration ) && $this->get_expiration_time() < strtotime( $expiration, current_time( 'timestamp' ) ) ) {
510
-                    $this->update( array( 'expiration' => $expiration ) );
509
+                if (!is_wp_error($expiration) && $this->get_expiration_time() < strtotime($expiration, current_time('timestamp'))) {
510
+                    $this->update(array('expiration' => $expiration));
511 511
                     $this->expiration = $expiration;
512 512
                     $ret = true;
513 513
 
514
-                    $this->add_note( sprintf( __( 'Expiration synced with gateway and updated to %s', 'invoicing' ), $expiration ) );
514
+                    $this->add_note(sprintf(__('Expiration synced with gateway and updated to %s', 'invoicing'), $expiration));
515 515
 
516
-                    do_action( 'edd_recurring_check_expiration', $this, $expiration );
516
+                    do_action('edd_recurring_check_expiration', $this, $expiration);
517 517
                 }
518 518
             }
519 519
         }
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
     }
523 523
 
524 524
     public function get_expiration_time() {
525
-        return strtotime( $this->expiration, current_time( 'timestamp' ) );
525
+        return strtotime($this->expiration, current_time('timestamp'));
526 526
     }
527 527
 
528 528
     public function get_status() {
@@ -532,36 +532,36 @@  discard block
 block discarded – undo
532 532
     }
533 533
 
534 534
     public function get_status_label() {
535
-        switch( $this->get_status() ) {
535
+        switch ($this->get_status()) {
536 536
             case 'active' :
537
-                $status = __( 'Active', 'invoicing' );
537
+                $status = __('Active', 'invoicing');
538 538
                 break;
539 539
             case 'cancelled' :
540
-                $status = __( 'Cancelled', 'invoicing' );
540
+                $status = __('Cancelled', 'invoicing');
541 541
                 break;
542 542
             case 'completed' :
543
-                $status = __( 'Completed', 'invoicing' );
543
+                $status = __('Completed', 'invoicing');
544 544
                 break;
545 545
             case 'expired' :
546
-                $status = __( 'Expired', 'invoicing' );
546
+                $status = __('Expired', 'invoicing');
547 547
                 break;
548 548
             case 'failing' :
549
-                $status = __( 'Failing', 'invoicing' );
549
+                $status = __('Failing', 'invoicing');
550 550
                 break;
551 551
             case 'pending' :
552
-                $status = __( 'Pending', 'invoicing' );
552
+                $status = __('Pending', 'invoicing');
553 553
                 break;
554 554
             case 'stopped' :
555
-                $status = __( 'Stopped', 'invoicing' );
555
+                $status = __('Stopped', 'invoicing');
556 556
                 break;
557 557
             case 'trialling' :
558
-                $status = __( 'Trialling', 'invoicing' );
558
+                $status = __('Trialling', 'invoicing');
559 559
                 break;
560 560
             default:
561 561
                 $status = $this->get_status();
562 562
                 
563
-                if ( $status ) {
564
-                    $status = __( wpinv_utf8_ucfirst( $status ), 'invoicing' );
563
+                if ($status) {
564
+                    $status = __(wpinv_utf8_ucfirst($status), 'invoicing');
565 565
                 }
566 566
                 break;
567 567
         }
@@ -569,57 +569,57 @@  discard block
 block discarded – undo
569 569
         return $status;
570 570
     }
571 571
 
572
-    public function get_notes( $length = 20, $paged = 1 ) {
573
-        $length = is_numeric( $length ) ? $length : 20;
574
-        $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0;
572
+    public function get_notes($length = 20, $paged = 1) {
573
+        $length = is_numeric($length) ? $length : 20;
574
+        $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0;
575 575
 
576 576
         $all_notes   = $this->get_raw_notes();
577
-        $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
577
+        $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
578 578
 
579
-        $desired_notes = array_slice( $notes_array, $offset, $length );
579
+        $desired_notes = array_slice($notes_array, $offset, $length);
580 580
 
581 581
         return $desired_notes;
582 582
     }
583 583
 
584 584
     public function get_notes_count() {
585 585
         $all_notes = $this->get_raw_notes();
586
-        $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
586
+        $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
587 587
 
588
-        return count( $notes_array );
588
+        return count($notes_array);
589 589
     }
590 590
 
591
-    public function add_note( $note = '' ) {
592
-        $note = trim( $note );
593
-        if ( empty( $note ) ) {
591
+    public function add_note($note = '') {
592
+        $note = trim($note);
593
+        if (empty($note)) {
594 594
             return false;
595 595
         }
596 596
 
597 597
         $notes = $this->get_raw_notes();
598 598
 
599
-        if ( empty( $notes ) ) {
599
+        if (empty($notes)) {
600 600
             $notes = '';
601 601
         }
602 602
 
603
-        $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note;
604
-        $new_note    = apply_filters( 'edd_subscription_add_note_string', $note_string );
603
+        $note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')) . ' - ' . $note;
604
+        $new_note    = apply_filters('edd_subscription_add_note_string', $note_string);
605 605
         $notes      .= "\n\n" . $new_note;
606 606
 
607
-        do_action( 'edd_subscription_pre_add_note', $new_note, $this->id );
607
+        do_action('edd_subscription_pre_add_note', $new_note, $this->id);
608 608
 
609
-        $updated = $this->update( array( 'notes' => $notes ) );
609
+        $updated = $this->update(array('notes' => $notes));
610 610
 
611
-        if ( $updated ) {
611
+        if ($updated) {
612 612
             $this->notes = $this->get_notes();
613 613
         }
614 614
 
615
-        do_action( 'edd_subscription_post_add_note', $this->notes, $new_note, $this->id );
615
+        do_action('edd_subscription_post_add_note', $this->notes, $new_note, $this->id);
616 616
 
617 617
         return $new_note;
618 618
     }
619 619
 
620 620
     private function get_raw_notes() {
621
-        $all_notes = $this->subscriptions_db->get_column( 'notes', $this->id );
621
+        $all_notes = $this->subscriptions_db->get_column('notes', $this->id);
622 622
 
623
-        return (string) $all_notes;
623
+        return (string)$all_notes;
624 624
     }
625 625
 }
Please login to merge, or discard this patch.
includes/admin/wpinv-upgrade-functions.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -11,37 +11,37 @@
 block discarded – undo
11 11
  * @since 1.0.0
12 12
 */
13 13
 function wpinv_automatic_upgrade() {
14
-    $wpi_version = get_option( 'wpinv_version' );
14
+    $wpi_version = get_option('wpinv_version');
15 15
     
16
-    if ( $wpi_version == WPINV_VERSION ) {
16
+    if ($wpi_version == WPINV_VERSION) {
17 17
         return;
18 18
     }
19 19
     
20
-    if ( version_compare( $wpi_version, '0.0.5', '<' ) ) {
20
+    if (version_compare($wpi_version, '0.0.5', '<')) {
21 21
         wpinv_v005_upgrades();
22 22
     }
23 23
     
24
-    update_option( 'wpinv_version', WPINV_VERSION );
24
+    update_option('wpinv_version', WPINV_VERSION);
25 25
 }
26
-add_action( 'admin_init', 'wpinv_automatic_upgrade' );
26
+add_action('admin_init', 'wpinv_automatic_upgrade');
27 27
 
28 28
 function wpinv_v005_upgrades() {
29 29
     global $wpdb;
30 30
     
31 31
     // Invoices status
32
-    $wpdb->query( "UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
32
+    $wpdb->query("UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
33 33
     
34 34
     // Item meta key changes
35 35
     $query = "SELECT DISTINCT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
36
-    $results = $wpdb->get_results( $query );
36
+    $results = $wpdb->get_results($query);
37 37
     
38
-    if ( !empty( $results ) ) {
39
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
40
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
41
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
38
+    if (!empty($results)) {
39
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )");
40
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'");
41
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'");
42 42
         
43
-        foreach ( $results as $row ) {
44
-            clean_post_cache( $row->post_id );
43
+        foreach ($results as $row) {
44
+            clean_post_cache($row->post_id);
45 45
         }
46 46
     }
47 47
 }
48 48
\ 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   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Items {
8
-    public static function output( $post ) {        
8
+    public static function output($post) {        
9 9
         global $wpinv_euvat, $ajax_cart_details;
10 10
         
11
-        $post_id            = !empty( $post->ID ) ? $post->ID : 0;
12
-        $invoice            = new WPInv_Invoice( $post_id );
11
+        $post_id            = !empty($post->ID) ? $post->ID : 0;
12
+        $invoice            = new WPInv_Invoice($post_id);
13 13
         $ajax_cart_details  = $invoice->get_cart_details();
14
-        $subtotal           = $invoice->get_subtotal( true );
14
+        $subtotal           = $invoice->get_subtotal(true);
15 15
         $discount_raw       = $invoice->get_discount();
16
-        $discount           = wpinv_price( $discount_raw, $invoice->get_currency() );
16
+        $discount           = wpinv_price($discount_raw, $invoice->get_currency());
17 17
         $discounts          = $discount_raw > 0 ? $invoice->get_discounts() : '';
18
-        $tax                = $invoice->get_tax( true );
19
-        $total              = $invoice->get_total( true );
18
+        $tax                = $invoice->get_tax(true);
19
+        $total              = $invoice->get_total(true);
20 20
         $item_quantities    = wpinv_item_quantities_enabled();
21 21
         $use_taxes          = wpinv_use_taxes();
22 22
         $item_types         = wpinv_get_item_types();
@@ -29,17 +29,17 @@  discard block
 block discarded – undo
29 29
         }
30 30
         
31 31
         $cols = 5;
32
-        if ( $item_quantities ) {
32
+        if ($item_quantities) {
33 33
             $cols++;
34 34
         }
35
-        if ( $use_taxes ) {
35
+        if ($use_taxes) {
36 36
             $cols++;
37 37
         }
38 38
         $class = '';
39
-        if ( $invoice->is_paid() ) {
39
+        if ($invoice->is_paid()) {
40 40
             $class .= ' wpinv-paid';
41 41
         }
42
-        if ( $is_recurring ) {
42
+        if ($is_recurring) {
43 43
             $class .= ' wpi-recurring';
44 44
         }
45 45
         ?>
@@ -47,21 +47,21 @@  discard block
 block discarded – undo
47 47
             <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0">
48 48
                 <thead>
49 49
                     <tr>
50
-                        <th class="id"><?php _e( 'ID', 'invoicing' );?></th>
51
-                        <th class="title"><?php _e( 'Item', 'invoicing' );?></th>
52
-                        <th class="price"><?php _e( 'Price', 'invoicing' );?></th>
53
-                        <?php if ( $item_quantities ) { ?>
54
-                        <th class="qty"><?php _e( 'Qty', 'invoicing' );?></th>
50
+                        <th class="id"><?php _e('ID', 'invoicing'); ?></th>
51
+                        <th class="title"><?php _e('Item', 'invoicing'); ?></th>
52
+                        <th class="price"><?php _e('Price', 'invoicing'); ?></th>
53
+                        <?php if ($item_quantities) { ?>
54
+                        <th class="qty"><?php _e('Qty', 'invoicing'); ?></th>
55 55
                         <?php } ?>
56
-                        <th class="total"><?php _e( 'Total', 'invoicing' );?></th>
57
-                        <?php if ( $use_taxes ) { ?>
58
-                        <th class="tax"><?php _e( 'Tax (%)', 'invoicing' );?></th>
56
+                        <th class="total"><?php _e('Total', 'invoicing'); ?></th>
57
+                        <?php if ($use_taxes) { ?>
58
+                        <th class="tax"><?php _e('Tax (%)', 'invoicing'); ?></th>
59 59
                         <?php } ?>
60 60
                         <th class="action"></th>
61 61
                     </tr>
62 62
                 </thead>
63 63
                 <tbody class="wpinv-line-items">
64
-                    <?php echo wpinv_admin_get_line_items( $invoice ); ?>
64
+                    <?php echo wpinv_admin_get_line_items($invoice); ?>
65 65
                 </tbody>
66 66
                 <tfoot class="wpinv-totals">
67 67
                     <tr>
@@ -73,44 +73,44 @@  discard block
 block discarded – undo
73 73
                                         </td>
74 74
                                         <td class="title">
75 75
                                             <input type="text" class="regular-text" placeholder="Item name" value="" name="_wpinv_quick[name]">
76
-                                            <?php if ( $wpinv_euvat->allow_vat_rules() ) { ?>
76
+                                            <?php if ($wpinv_euvat->allow_vat_rules()) { ?>
77 77
                                             <div class="wp-clearfix">
78 78
                                                 <label class="wpi-vat-rule">
79
-                                                    <span class="title"><?php _e( 'VAT rule type', 'invoicing' );?></span>
79
+                                                    <span class="title"><?php _e('VAT rule type', 'invoicing'); ?></span>
80 80
                                                     <span class="input-text-wrap">
81
-                                                        <?php echo wpinv_html_select( array(
81
+                                                        <?php echo wpinv_html_select(array(
82 82
                                                             'options'          => $wpinv_euvat->get_rules(),
83 83
                                                             'name'             => '_wpinv_quick[vat_rule]',
84 84
                                                             'id'               => '_wpinv_quick_vat_rule',
85 85
                                                             'show_option_all'  => false,
86 86
                                                             'show_option_none' => false,
87 87
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-rule',
88
-                                                        ) ); ?>
88
+                                                        )); ?>
89 89
                                                     </span>
90 90
                                                 </label>
91 91
                                             </div>
92
-                                            <?php } if ( $wpinv_euvat->allow_vat_classes() ) { ?>
92
+                                            <?php } if ($wpinv_euvat->allow_vat_classes()) { ?>
93 93
                                             <div class="wp-clearfix">
94 94
                                                 <label class="wpi-vat-class">
95
-                                                    <span class="title"><?php _e( 'VAT class', 'invoicing' );?></span>
95
+                                                    <span class="title"><?php _e('VAT class', 'invoicing'); ?></span>
96 96
                                                     <span class="input-text-wrap">
97
-                                                        <?php echo wpinv_html_select( array(
97
+                                                        <?php echo wpinv_html_select(array(
98 98
                                                             'options'          => $wpinv_euvat->get_all_classes(),
99 99
                                                             'name'             => '_wpinv_quick[vat_class]',
100 100
                                                             'id'               => '_wpinv_quick_vat_class',
101 101
                                                             'show_option_all'  => false,
102 102
                                                             'show_option_none' => false,
103 103
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-class',
104
-                                                        ) ); ?>
104
+                                                        )); ?>
105 105
                                                     </span>
106 106
                                                 </label>
107 107
                                             </div>
108 108
                                             <?php } ?>
109 109
                                             <div class="wp-clearfix">
110 110
                                                 <label class="wpi-item-type">
111
-                                                    <span class="title"><?php _e( 'Item type', 'invoicing' );?></span>
111
+                                                    <span class="title"><?php _e('Item type', 'invoicing'); ?></span>
112 112
                                                     <span class="input-text-wrap">
113
-                                                        <?php echo wpinv_html_select( array(
113
+                                                        <?php echo wpinv_html_select(array(
114 114
                                                             'options'          => $item_types,
115 115
                                                             'name'             => '_wpinv_quick[type]',
116 116
                                                             'id'               => '_wpinv_quick_type',
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
                                                             'show_option_all'  => false,
119 119
                                                             'show_option_none' => false,
120 120
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-type',
121
-                                                        ) ); ?>
121
+                                                        )); ?>
122 122
                                                     </span>
123 123
                                                 </label>
124 124
                                             </div>
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
                                             </div>
132 132
                                         </td>
133 133
                                         <td class="price"><input type="text" placeholder="0.00" class="wpi-field-price wpi-price" name="_wpinv_quick[price]" /></td>
134
-                                        <?php if ( $item_quantities ) { ?>
134
+                                        <?php if ($item_quantities) { ?>
135 135
                                         <td class="qty"><input type="number" class="small-text" step="1" min="1" value="1" name="_wpinv_quick[qty]" /></td>
136 136
                                         <?php } ?>
137 137
                                         <td class="total"></td>
138
-                                        <?php if ( $use_taxes ) { ?>
138
+                                        <?php if ($use_taxes) { ?>
139 139
                                         <td class="tax"></td>
140 140
                                         <?php } ?>
141 141
                                         <td class="action"></td>
@@ -148,29 +148,29 @@  discard block
 block discarded – undo
148 148
                         <td colspan="<?php echo $cols; ?>"></td>
149 149
                     </tr>
150 150
                     <tr class="totals">
151
-                        <td colspan="<?php echo ( $cols - 4 ); ?>"></td>
151
+                        <td colspan="<?php echo ($cols - 4); ?>"></td>
152 152
                         <td colspan="4">
153 153
                             <table cellspacing="0" cellpadding="0">
154 154
                                 <tr class="subtotal">
155
-                                    <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td>
156
-                                    <td class="total"><?php echo $subtotal;?></td>
155
+                                    <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td>
156
+                                    <td class="total"><?php echo $subtotal; ?></td>
157 157
                                     <td class="action"></td>
158 158
                                 </tr>
159 159
                                 <tr class="discount">
160
-                                    <td class="name"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice->ID ) ); ?>:</td>
161
-                                    <td class="total"><?php echo wpinv_discount( $invoice->ID, true, true ); ?></td>
160
+                                    <td class="name"><?php wpinv_get_discount_label(wpinv_discount_code($invoice->ID)); ?>:</td>
161
+                                    <td class="total"><?php echo wpinv_discount($invoice->ID, true, true); ?></td>
162 162
                                     <td class="action"></td>
163 163
                                 </tr>
164
-                                <?php if ( $use_taxes ) { ?>
164
+                                <?php if ($use_taxes) { ?>
165 165
                                 <tr class="tax">
166
-                                    <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td>
167
-                                    <td class="total"><?php echo $tax;?></td>
166
+                                    <td class="name"><?php _e('Tax:', 'invoicing'); ?></td>
167
+                                    <td class="total"><?php echo $tax; ?></td>
168 168
                                     <td class="action"></td>
169 169
                                 </tr>
170 170
                                 <?php } ?>
171 171
                                 <tr class="total">
172
-                                    <td class="name"><?php _e( 'Invoice Total:', 'invoicing' );?></td>
173
-                                    <td class="total"><?php echo $total;?></td>
172
+                                    <td class="name"><?php _e('Invoice Total:', 'invoicing'); ?></td>
173
+                                    <td class="total"><?php echo $total; ?></td>
174 174
                                     <td class="action"></td>
175 175
                                 </tr>
176 176
                             </table>
@@ -180,89 +180,89 @@  discard block
 block discarded – undo
180 180
             </table>
181 181
             <div class="wpinv-actions">
182 182
                 <?php
183
-                    if ( !$invoice->is_paid() ) {
184
-                    if ( !$invoice->is_recurring() ) {
185
-                    echo wpinv_item_dropdown( array(
183
+                    if (!$invoice->is_paid()) {
184
+                    if (!$invoice->is_recurring()) {
185
+                    echo wpinv_item_dropdown(array(
186 186
                         'name'             => 'wpinv_invoice_item',
187 187
                         'id'               => 'wpinv_invoice_item',
188 188
                         'with_packages'    => false,
189 189
                         'show_recurring'   => true,
190
-                    ) );
190
+                    ));
191 191
                     ?>
192
-                <input type="button" value="<?php echo sprintf(esc_attr__( 'Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e( 'Create new item', 'invoicing' );?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e( 'Recalculate Totals', 'invoicing' );?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">
192
+                <input type="button" value="<?php echo sprintf(esc_attr__('Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e('Create new item', 'invoicing'); ?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e('Recalculate Totals', 'invoicing'); ?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">
193 193
                     <?php } ?>
194
-                <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?>
194
+                <?php do_action('wpinv_invoice_items_actions', $invoice); ?>
195 195
             </div>
196 196
         </div>
197 197
         <?php
198 198
     }
199 199
     
200
-    public static function prices( $post ) {        
200
+    public static function prices($post) {        
201 201
         $symbol         = wpinv_currency_symbol();
202 202
         $position       = wpinv_currency_position();
203
-        $item           = new WPInv_Item( $post->ID );
203
+        $item           = new WPInv_Item($post->ID);
204 204
         
205 205
         $price          = $item->get_price();
206 206
         $is_recurring   = $item->is_recurring();
207 207
         $period         = $item->get_recurring_period();
208
-        $interval       = absint( $item->get_recurring_interval() );
209
-        $times          = absint( $item->get_recurring_limit() );
208
+        $interval       = absint($item->get_recurring_interval());
209
+        $times          = absint($item->get_recurring_limit());
210 210
         $free_trial     = $item->has_free_trial();
211 211
         $trial_interval = $item->get_trial_interval();
212 212
         $trial_period   = $item->get_trial_period();
213 213
         
214 214
         $intervals      = array();
215
-        for ( $i = 1; $i <= 90; $i++ ) {
215
+        for ($i = 1; $i <= 90; $i++) {
216 216
             $intervals[$i] = $i;
217 217
         }
218 218
         
219
-        $interval       = $interval > 0 ? $interval : 1;
219
+        $interval = $interval > 0 ? $interval : 1;
220 220
         
221 221
         $class = $is_recurring ? 'wpinv-recurring-y' : 'wpinv-recurring-n';
222 222
         ?>
223
-        <p class="wpinv-row-prices"><?php echo ( $position != 'right' ? $symbol . '&nbsp;' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $price;?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled( $item->is_package(), true ); ?> /><?php echo ( $position == 'right' ? '&nbsp;' . $symbol : '' );?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce( 'wpinv_item_meta_box_save' ) ;?>" />
224
-        <?php if ( $item->is_package() ) { ?>
225
-        <span class="description"><?php _e( 'GD package item price can be edited only from GD payment manager.', 'invoicing' ); ?></span>
223
+        <p class="wpinv-row-prices"><?php echo ($position != 'right' ? $symbol . '&nbsp;' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $price; ?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled($item->is_package(), true); ?> /><?php echo ($position == 'right' ? '&nbsp;' . $symbol : ''); ?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce('wpinv_item_meta_box_save'); ?>" />
224
+        <?php if ($item->is_package()) { ?>
225
+        <span class="description"><?php _e('GD package item price can be edited only from GD payment manager.', 'invoicing'); ?></span>
226 226
         <?php } ?>
227 227
         </p>
228 228
         <p class="wpinv-row-is-recurring">
229 229
             <label for="wpinv_is_recurring">
230
-                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked( 1, $is_recurring ); ?> />
231
-                <?php echo apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Is Recurring Item?', 'invoicing' ) ); ?>
230
+                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked(1, $is_recurring); ?> />
231
+                <?php echo apply_filters('wpinv_is_recurring_toggle_text', __('Is Recurring Item?', 'invoicing')); ?>
232 232
             </label>
233 233
         </p>
234
-        <p class="wpinv-row-recurring-fields <?php echo $class;?>">
235
-                <label class="wpinv-period" for="wpinv_recurring_period"><?php _e( 'Recurring', 'invoicing' );?> <select class="wpinv-select " id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e( 'day(s)', 'invoicing' ); ?>" <?php selected( 'D', $period );?>><?php _e( 'Daily', 'invoicing' ); ?></option><option value="W" data-text="<?php esc_attr_e( 'week(s)', 'invoicing' ); ?>" <?php selected( 'W', $period );?>><?php _e( 'Weekly', 'invoicing' ); ?></option><option value="M" data-text="<?php esc_attr_e( 'month(s)', 'invoicing' ); ?>" <?php selected( 'M', $period );?>><?php _e( 'Monthly', 'invoicing' ); ?></option><option value="Y" data-text="<?php esc_attr_e( 'year(s)', 'invoicing' ); ?>" <?php selected( 'Y', $period );?>><?php _e( 'Yearly', 'invoicing' ); ?></option></select></label>
236
-                <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e( 'at every', 'invoicing' );?> <?php echo wpinv_html_select( array(
234
+        <p class="wpinv-row-recurring-fields <?php echo $class; ?>">
235
+                <label class="wpinv-period" for="wpinv_recurring_period"><?php _e('Recurring', 'invoicing'); ?> <select class="wpinv-select " id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e('day(s)', 'invoicing'); ?>" <?php selected('D', $period); ?>><?php _e('Daily', 'invoicing'); ?></option><option value="W" data-text="<?php esc_attr_e('week(s)', 'invoicing'); ?>" <?php selected('W', $period); ?>><?php _e('Weekly', 'invoicing'); ?></option><option value="M" data-text="<?php esc_attr_e('month(s)', 'invoicing'); ?>" <?php selected('M', $period); ?>><?php _e('Monthly', 'invoicing'); ?></option><option value="Y" data-text="<?php esc_attr_e('year(s)', 'invoicing'); ?>" <?php selected('Y', $period); ?>><?php _e('Yearly', 'invoicing'); ?></option></select></label>
236
+                <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e('at every', 'invoicing'); ?> <?php echo wpinv_html_select(array(
237 237
                     'options'          => $intervals,
238 238
                     'name'             => 'wpinv_recurring_interval',
239 239
                     'id'               => 'wpinv_recurring_interval',
240 240
                     'selected'         => $interval,
241 241
                     'show_option_all'  => false,
242 242
                     'show_option_none' => false
243
-                ) ); ?> <span id="wpinv_interval_text"><?php _e( 'day(s)', 'invoicing' );?></span></label>
244
-                <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e( 'for', 'invoicing' );?> <input class="small-text" type="number" value="<?php echo $times;?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e( 'time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing' );?></label>
243
+                )); ?> <span id="wpinv_interval_text"><?php _e('day(s)', 'invoicing'); ?></span></label>
244
+                <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e('for', 'invoicing'); ?> <input class="small-text" type="number" value="<?php echo $times; ?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e('time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing'); ?></label>
245 245
                 <span class="clear wpi-trial-clr"></span>
246 246
                 <label class="wpinv-free-trial" for="wpinv_free_trial">
247
-                    <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked( true, (bool)$free_trial ); ?> /> 
248
-                    <?php echo __( 'Offer free trial for', 'invoicing' ); ?>
247
+                    <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked(true, (bool)$free_trial); ?> /> 
248
+                    <?php echo __('Offer free trial for', 'invoicing'); ?>
249 249
                 </label>
250 250
                 <label class="wpinv-trial-interval" for="wpinv_trial_interval">
251
-                    <input class="small-text" type="number" value="<?php echo $trial_interval;?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected( 'D', $trial_period );?>><?php _e( 'day(s)', 'invoicing' ); ?></option><option value="W" <?php selected( 'W', $trial_period );?>><?php _e( 'week(s)', 'invoicing' ); ?></option><option value="M" <?php selected( 'M', $trial_period );?>><?php _e( 'month(s)', 'invoicing' ); ?></option><option value="Y" <?php selected( 'Y', $trial_period );?>><?php _e( 'year(s)', 'invoicing' ); ?></option></select>
251
+                    <input class="small-text" type="number" value="<?php echo $trial_interval; ?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected('D', $trial_period); ?>><?php _e('day(s)', 'invoicing'); ?></option><option value="W" <?php selected('W', $trial_period); ?>><?php _e('week(s)', 'invoicing'); ?></option><option value="M" <?php selected('M', $trial_period); ?>><?php _e('month(s)', 'invoicing'); ?></option><option value="Y" <?php selected('Y', $trial_period); ?>><?php _e('year(s)', 'invoicing'); ?></option></select>
252 252
                 </label>
253 253
         </p>
254
-        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type( $post->ID ); ?>" />
255
-        <?php do_action( 'wpinv_item_price_field', $post->ID ); ?>
254
+        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type($post->ID); ?>" />
255
+        <?php do_action('wpinv_item_price_field', $post->ID); ?>
256 256
         <?php
257 257
     }
258 258
     
259
-    public static function vat_rules( $post ) {
259
+    public static function vat_rules($post) {
260 260
         global $wpinv_euvat;
261 261
         
262
-        $rule_type = $wpinv_euvat->get_item_rule( $post->ID );
262
+        $rule_type = $wpinv_euvat->get_item_rule($post->ID);
263 263
         ?>
264
-        <p><label for="wpinv_vat_rules"><strong><?php _e( 'Select how VAT rules will be applied:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
265
-        <?php echo wpinv_html_select( array(
264
+        <p><label for="wpinv_vat_rules"><strong><?php _e('Select how VAT rules will be applied:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
265
+        <?php echo wpinv_html_select(array(
266 266
                     'options'          => $wpinv_euvat->get_rules(),
267 267
                     'name'             => 'wpinv_vat_rules',
268 268
                     'id'               => 'wpinv_vat_rules',
@@ -270,19 +270,19 @@  discard block
 block discarded – undo
270 270
                     'show_option_all'  => false,
271 271
                     'show_option_none' => false,
272 272
                     'class'            => 'gdmbx2-text-medium wpinv-vat-rules',
273
-                ) ); ?>
273
+                )); ?>
274 274
         </p>
275
-        <p class="wpi-m0"><?php _e( 'When you select physical product rules, only consumers and businesses in your country will be charged VAT.  The VAT rate used will be the rate in your country.', 'invoicing' ); ?></p>
276
-        <p class="wpi-m0"><?php _e( 'If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer.  Only businesses in your country will be charged VAT.', 'invoicing' ); ?></p>
275
+        <p class="wpi-m0"><?php _e('When you select physical product rules, only consumers and businesses in your country will be charged VAT.  The VAT rate used will be the rate in your country.', 'invoicing'); ?></p>
276
+        <p class="wpi-m0"><?php _e('If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer.  Only businesses in your country will be charged VAT.', 'invoicing'); ?></p>
277 277
         <?php
278 278
     }
279 279
     
280
-    public static function vat_classes( $post ) {
280
+    public static function vat_classes($post) {
281 281
         global $wpinv_euvat;
282 282
         
283
-        $vat_class = $wpinv_euvat->get_item_class( $post->ID );
283
+        $vat_class = $wpinv_euvat->get_item_class($post->ID);
284 284
         ?>
285
-        <p><?php echo wpinv_html_select( array(
285
+        <p><?php echo wpinv_html_select(array(
286 286
                     'options'          => $wpinv_euvat->get_all_classes(),
287 287
                     'name'             => 'wpinv_vat_class',
288 288
                     'id'               => 'wpinv_vat_class',
@@ -290,18 +290,18 @@  discard block
 block discarded – undo
290 290
                     'show_option_all'  => false,
291 291
                     'show_option_none' => false,
292 292
                     'class'            => 'gdmbx2-text-medium wpinv-vat-class',
293
-                ) ); ?>
293
+                )); ?>
294 294
         </p>
295
-        <p class="wpi-m0"><?php _e( 'Select the VAT rate class to use for this invoice item.', 'invoicing' ); ?></p>
295
+        <p class="wpi-m0"><?php _e('Select the VAT rate class to use for this invoice item.', 'invoicing'); ?></p>
296 296
         <?php
297 297
     }
298 298
     
299
-    public static function item_info( $post ) {
300
-        $item_type = wpinv_get_item_type( $post->ID );
301
-        do_action( 'wpinv_item_info_metabox_before', $post );
299
+    public static function item_info($post) {
300
+        $item_type = wpinv_get_item_type($post->ID);
301
+        do_action('wpinv_item_info_metabox_before', $post);
302 302
         ?>
303
-        <p><label for="wpinv_item_type"><strong><?php _e( 'Type:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
304
-        <?php echo wpinv_html_select( array(
303
+        <p><label for="wpinv_item_type"><strong><?php _e('Type:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
304
+        <?php echo wpinv_html_select(array(
305 305
                     'options'          => wpinv_get_item_types(),
306 306
                     'name'             => 'wpinv_item_type',
307 307
                     'id'               => 'wpinv_item_type',
@@ -310,114 +310,114 @@  discard block
 block discarded – undo
310 310
                     'show_option_none' => false,
311 311
                     'class'            => 'gdmbx2-text-medium wpinv-item-type',
312 312
                     //'disabled'         => $item_type == 'package' ? true : false,
313
-                ) ); ?>
313
+                )); ?>
314 314
         </p>
315
-        <p class="wpi-m0"><?php _e( 'Select item type.', 'invoicing' );?><br><?php _e( 'Standard: standard item type', 'invoicing' );?><br><?php _e( 'Fee: like Registration Fee, Signup Fee etc.', 'invoicing' );?></p>
315
+        <p class="wpi-m0"><?php _e('Select item type.', 'invoicing'); ?><br><?php _e('Standard: standard item type', 'invoicing'); ?><br><?php _e('Fee: like Registration Fee, Signup Fee etc.', 'invoicing'); ?></p>
316 316
         <?php
317
-        do_action( 'wpinv_item_info_metabox_after', $post );
317
+        do_action('wpinv_item_info_metabox_after', $post);
318 318
     }
319 319
     
320
-    public static function meta_values( $post ) {
321
-        $meta_keys = apply_filters( 'wpinv_show_meta_values_for_keys', array(
320
+    public static function meta_values($post) {
321
+        $meta_keys = apply_filters('wpinv_show_meta_values_for_keys', array(
322 322
             'type',
323 323
             'custom_id'
324
-        ) );
324
+        ));
325 325
         
326
-        if ( empty( $meta_keys ) ) {
326
+        if (empty($meta_keys)) {
327 327
             return;
328 328
         }
329 329
         
330
-        do_action( 'wpinv_meta_values_metabox_before', $post );
330
+        do_action('wpinv_meta_values_metabox_before', $post);
331 331
         
332
-        foreach ( $meta_keys as $meta_key ) {
332
+        foreach ($meta_keys as $meta_key) {
333 333
             ?>
334
-            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta( $post->ID, '_wpinv_' . $meta_key, true ); ?></label></p>
334
+            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta($post->ID, '_wpinv_' . $meta_key, true); ?></label></p>
335 335
             <?php 
336 336
         }
337 337
         
338
-        do_action( 'wpinv_meta_values_metabox_after', $post );
338
+        do_action('wpinv_meta_values_metabox_after', $post);
339 339
     }
340 340
     
341
-    public static function save( $post_id, $data, $post ) {
342
-        $invoice        = new WPInv_Invoice( $post_id );
341
+    public static function save($post_id, $data, $post) {
342
+        $invoice        = new WPInv_Invoice($post_id);
343 343
         
344 344
         // Billing
345
-        $first_name     = sanitize_text_field( $data['wpinv_first_name'] );
346
-        $last_name      = sanitize_text_field( $data['wpinv_last_name'] );
347
-        $company        = sanitize_text_field( $data['wpinv_company'] );
348
-        $vat_number     = sanitize_text_field( $data['wpinv_vat_number'] );
349
-        $phone          = sanitize_text_field( $data['wpinv_phone'] );
350
-        $address        = sanitize_text_field( $data['wpinv_address'] );
351
-        $city           = sanitize_text_field( $data['wpinv_city'] );
352
-        $zip            = sanitize_text_field( $data['wpinv_zip'] );
353
-        $country        = sanitize_text_field( $data['wpinv_country'] );
354
-        $state          = sanitize_text_field( $data['wpinv_state'] );
345
+        $first_name     = sanitize_text_field($data['wpinv_first_name']);
346
+        $last_name      = sanitize_text_field($data['wpinv_last_name']);
347
+        $company        = sanitize_text_field($data['wpinv_company']);
348
+        $vat_number     = sanitize_text_field($data['wpinv_vat_number']);
349
+        $phone          = sanitize_text_field($data['wpinv_phone']);
350
+        $address        = sanitize_text_field($data['wpinv_address']);
351
+        $city           = sanitize_text_field($data['wpinv_city']);
352
+        $zip            = sanitize_text_field($data['wpinv_zip']);
353
+        $country        = sanitize_text_field($data['wpinv_country']);
354
+        $state          = sanitize_text_field($data['wpinv_state']);
355 355
         
356 356
         // Details
357
-        $status         = sanitize_text_field( $data['wpinv_status'] );
358
-        $old_status     = !empty( $data['original_post_status'] ) ? sanitize_text_field( $data['original_post_status'] ) : $status;
359
-        $number         = sanitize_text_field( $data['wpinv_number'] );
360
-        $due_date       = isset( $data['wpinv_due_date'] ) ? sanitize_text_field( $data['wpinv_due_date'] ) : '';
357
+        $status         = sanitize_text_field($data['wpinv_status']);
358
+        $old_status     = !empty($data['original_post_status']) ? sanitize_text_field($data['original_post_status']) : $status;
359
+        $number         = sanitize_text_field($data['wpinv_number']);
360
+        $due_date       = isset($data['wpinv_due_date']) ? sanitize_text_field($data['wpinv_due_date']) : '';
361 361
         //$discounts      = sanitize_text_field( $data['wpinv_discounts'] );
362 362
         //$discount       = sanitize_text_field( $data['wpinv_discount'] );
363 363
         
364
-        $ip             = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
364
+        $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
365 365
         
366
-        $invoice->set( 'due_date', $due_date );
367
-        $invoice->set( 'first_name', $first_name );
368
-        $invoice->set( 'last_name', $last_name );
369
-        $invoice->set( 'company', $company );
370
-        $invoice->set( 'vat_number', $vat_number );
371
-        $invoice->set( 'phone', $phone );
372
-        $invoice->set( 'address', $address );
373
-        $invoice->set( 'city', $city );
374
-        $invoice->set( 'zip', $zip );
375
-        $invoice->set( 'country', $country );
376
-        $invoice->set( 'state', $state );
377
-        $invoice->set( 'status', $status );
378
-        $invoice->set( 'number', $number );
366
+        $invoice->set('due_date', $due_date);
367
+        $invoice->set('first_name', $first_name);
368
+        $invoice->set('last_name', $last_name);
369
+        $invoice->set('company', $company);
370
+        $invoice->set('vat_number', $vat_number);
371
+        $invoice->set('phone', $phone);
372
+        $invoice->set('address', $address);
373
+        $invoice->set('city', $city);
374
+        $invoice->set('zip', $zip);
375
+        $invoice->set('country', $country);
376
+        $invoice->set('state', $state);
377
+        $invoice->set('status', $status);
378
+        $invoice->set('number', $number);
379 379
         //$invoice->set( 'discounts', $discounts );
380 380
         //$invoice->set( 'discount', $discount );
381
-        $invoice->set( 'ip', $ip );
381
+        $invoice->set('ip', $ip);
382 382
         $invoice->old_status = $_POST['original_post_status'];
383 383
         $invoice->currency = wpinv_get_currency();
384
-        if ( !empty( $data['wpinv_gateway'] ) ) {
385
-            $invoice->set( 'gateway', sanitize_text_field( $data['wpinv_gateway'] ) );
384
+        if (!empty($data['wpinv_gateway'])) {
385
+            $invoice->set('gateway', sanitize_text_field($data['wpinv_gateway']));
386 386
         }
387 387
         $saved = $invoice->save();
388 388
         
389 389
         // Check for payment notes
390
-        if ( !empty( $data['invoice_note'] ) ) {
391
-            $note               = wp_kses( $data['invoice_note'], array() );
392
-            $note_type          = sanitize_text_field( $data['invoice_note_type'] );
390
+        if (!empty($data['invoice_note'])) {
391
+            $note               = wp_kses($data['invoice_note'], array());
392
+            $note_type          = sanitize_text_field($data['invoice_note_type']);
393 393
             $is_customer_note   = $note_type == 'customer' ? 1 : 0;
394 394
         
395
-            wpinv_insert_payment_note( $invoice->ID, $note, $is_customer_note );
395
+            wpinv_insert_payment_note($invoice->ID, $note, $is_customer_note);
396 396
         }
397 397
         
398 398
         // Update user address if empty.
399
-        if ( $saved && !empty( $invoice ) ) {
400
-            if ( $user_id = $invoice->get_user_id() ) {
401
-                $user_address = wpinv_get_user_address( $user_id, false );
399
+        if ($saved && !empty($invoice)) {
400
+            if ($user_id = $invoice->get_user_id()) {
401
+                $user_address = wpinv_get_user_address($user_id, false);
402 402
                 
403 403
                 if (empty($user_address['first_name'])) {
404
-                    update_user_meta( $user_id, '_wpinv_first_name', $first_name );
405
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
404
+                    update_user_meta($user_id, '_wpinv_first_name', $first_name);
405
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
406 406
                 } else if (empty($user_address['last_name']) && $user_address['first_name'] == $first_name) {
407
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
407
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
408 408
                 }
409 409
                 
410 410
                 if (empty($user_address['address']) || empty($user_address['city']) || empty($user_address['state']) || empty($user_address['country'])) {
411
-                    update_user_meta( $user_id, '_wpinv_address', $address );
412
-                    update_user_meta( $user_id, '_wpinv_city', $city );
413
-                    update_user_meta( $user_id, '_wpinv_state', $state );
414
-                    update_user_meta( $user_id, '_wpinv_country', $country );
415
-                    update_user_meta( $user_id, '_wpinv_zip', $zip );
416
-                    update_user_meta( $user_id, '_wpinv_phone', $phone );
411
+                    update_user_meta($user_id, '_wpinv_address', $address);
412
+                    update_user_meta($user_id, '_wpinv_city', $city);
413
+                    update_user_meta($user_id, '_wpinv_state', $state);
414
+                    update_user_meta($user_id, '_wpinv_country', $country);
415
+                    update_user_meta($user_id, '_wpinv_zip', $zip);
416
+                    update_user_meta($user_id, '_wpinv_phone', $phone);
417 417
                 }
418 418
             }
419 419
             
420
-            do_action( 'wpinv_invoice_metabox_saved', $invoice );
420
+            do_action('wpinv_invoice_metabox_saved', $invoice);
421 421
         }
422 422
         
423 423
         return $saved;
Please login to merge, or discard this patch.
includes/admin/subscriptions.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@
 block discarded – undo
10 10
     ?>
11 11
     <div class="wrap">
12 12
         <h1>
13
-            <?php _e( 'Subscriptions', 'invoicing' ); ?>
14
-            <a href="<?php echo esc_url( add_query_arg( array( 'wpi_action' => 'add_subscription' ) ) ); ?>" class="add-new-h2"><?php _e( 'Add New', 'invoicing' ); ?></a>
13
+            <?php _e('Subscriptions', 'invoicing'); ?>
14
+            <a href="<?php echo esc_url(add_query_arg(array('wpi_action' => 'add_subscription'))); ?>" class="add-new-h2"><?php _e('Add New', 'invoicing'); ?></a>
15 15
         </h1>
16 16
         <?php
17 17
         //$subscribers_table = new EDD_Subscription_Reports_Table();
Please login to merge, or discard this patch.
includes/admin/admin-meta-boxes.php 1 patch
Spacing   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -1,65 +1,65 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7
-function wpinv_add_meta_boxes( $post_type, $post ) {
7
+function wpinv_add_meta_boxes($post_type, $post) {
8 8
     global $wpi_mb_invoice;
9
-    if ( $post_type == 'wpi_invoice' && !empty( $post->ID ) ) {
10
-        $wpi_mb_invoice = wpinv_get_invoice( $post->ID );
9
+    if ($post_type == 'wpi_invoice' && !empty($post->ID)) {
10
+        $wpi_mb_invoice = wpinv_get_invoice($post->ID);
11 11
     }
12 12
     
13
-    if ( !empty( $wpi_mb_invoice ) && !$wpi_mb_invoice->has_status( array( 'draft', 'auto-draft' ) ) ) {
14
-        add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high' );
13
+    if (!empty($wpi_mb_invoice) && !$wpi_mb_invoice->has_status(array('draft', 'auto-draft'))) {
14
+        add_meta_box('wpinv-mb-resend-invoice', __('Resend Invoice', 'invoicing'), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high');
15 15
     }
16 16
     
17
-    if ( !empty( $wpi_mb_invoice ) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent() ) {
18
-        add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscriptions', 'invoicing' ), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high' );
17
+    if (!empty($wpi_mb_invoice) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent()) {
18
+        add_meta_box('wpinv-mb-subscriptions', __('Subscriptions', 'invoicing'), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high');
19 19
     }
20 20
     
21
-    if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) {
22
-        add_meta_box( 'wpinv-mb-renewals', __( 'Renewal Payment', 'invoicing' ), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high' );
21
+    if (wpinv_is_subscription_payment($wpi_mb_invoice)) {
22
+        add_meta_box('wpinv-mb-renewals', __('Renewal Payment', 'invoicing'), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high');
23 23
     }
24 24
     
25
-    add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default' );
26
-    add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default' );
25
+    add_meta_box('wpinv-details', __('Invoice Details', 'invoicing'), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default');
26
+    add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default');
27 27
    
28
-    add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high' );
29
-    add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high' );
30
-    add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' );
28
+    add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high');
29
+    add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high');
30
+    add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high');
31 31
 }
32
-add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 );
32
+add_action('add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2);
33 33
 
34
-function wpinv_save_meta_boxes( $post_id, $post, $update = false ) {
35
-    remove_action( 'save_post', __FUNCTION__ );
34
+function wpinv_save_meta_boxes($post_id, $post, $update = false) {
35
+    remove_action('save_post', __FUNCTION__);
36 36
     
37 37
     // $post_id and $post are required
38
-    if ( empty( $post_id ) || empty( $post ) ) {
38
+    if (empty($post_id) || empty($post)) {
39 39
         return;
40 40
     }
41 41
         
42
-    if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) {
42
+    if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) {
43 43
         return;
44 44
     }
45 45
     
46 46
     // Dont' save meta boxes for revisions or autosaves
47
-    if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
47
+    if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
48 48
         return;
49 49
     }
50 50
         
51
-    if ( $post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote' ) {
52
-        if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
51
+    if ($post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote') {
52
+        if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
53 53
             return;
54 54
         }
55 55
     
56
-        if ( isset( $_POST['wpinv_save_invoice'] ) && wp_verify_nonce( $_POST['wpinv_save_invoice'], 'wpinv_save_invoice' ) ) {
57
-            WPInv_Meta_Box_Items::save( $post_id, $_POST, $post );
56
+        if (isset($_POST['wpinv_save_invoice']) && wp_verify_nonce($_POST['wpinv_save_invoice'], 'wpinv_save_invoice')) {
57
+            WPInv_Meta_Box_Items::save($post_id, $_POST, $post);
58 58
         }
59
-    } else if ( $post->post_type == 'wpi_item' ) {
59
+    } else if ($post->post_type == 'wpi_item') {
60 60
         // verify nonce
61
-        if ( isset( $_POST['wpinv_vat_meta_box_nonce'] ) && wp_verify_nonce( $_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save' ) ) {
62
-            $fields                                 = array();
61
+        if (isset($_POST['wpinv_vat_meta_box_nonce']) && wp_verify_nonce($_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save')) {
62
+            $fields = array();
63 63
             $fields['_wpinv_price']              = 'wpinv_item_price';
64 64
             $fields['_wpinv_vat_class']          = 'wpinv_vat_class';
65 65
             $fields['_wpinv_vat_rule']           = 'wpinv_vat_rules';
@@ -72,296 +72,296 @@  discard block
 block discarded – undo
72 72
             $fields['_wpinv_trial_period']       = 'wpinv_trial_period';
73 73
             $fields['_wpinv_trial_interval']     = 'wpinv_trial_interval';
74 74
             
75
-            if ( !isset( $_POST['wpinv_is_recurring'] ) ) {
75
+            if (!isset($_POST['wpinv_is_recurring'])) {
76 76
                 $_POST['wpinv_is_recurring'] = 0;
77 77
             }
78 78
             
79
-            if ( !isset( $_POST['wpinv_free_trial'] ) || empty( $_POST['wpinv_is_recurring'] ) ) {
79
+            if (!isset($_POST['wpinv_free_trial']) || empty($_POST['wpinv_is_recurring'])) {
80 80
                 $_POST['wpinv_free_trial'] = 0;
81 81
             }
82 82
             
83
-            foreach ( $fields as $field => $name ) {
84
-                if ( isset( $_POST[ $name ] ) ) {
85
-                    if ( $field == '_wpinv_price' ) {
86
-                        if ( get_post_meta( $post_id, '_wpinv_type', true ) === 'package' ) {
87
-                            $value = wpinv_sanitize_amount( get_post_meta( $post_id, '_wpinv_price', true ) ); // Don't allow edit GD package item price.
83
+            foreach ($fields as $field => $name) {
84
+                if (isset($_POST[$name])) {
85
+                    if ($field == '_wpinv_price') {
86
+                        if (get_post_meta($post_id, '_wpinv_type', true) === 'package') {
87
+                            $value = wpinv_sanitize_amount(get_post_meta($post_id, '_wpinv_price', true)); // Don't allow edit GD package item price.
88 88
                         } else {
89
-                            $value = wpinv_sanitize_amount( $_POST[ $name ] );
89
+                            $value = wpinv_sanitize_amount($_POST[$name]);
90 90
                         }
91 91
                     } else {
92
-                        $value = is_string( $_POST[ $name ] ) ? sanitize_text_field( $_POST[ $name ] ) : $_POST[ $name ];
92
+                        $value = is_string($_POST[$name]) ? sanitize_text_field($_POST[$name]) : $_POST[$name];
93 93
                     }
94 94
                     
95
-                    $value = apply_filters( 'wpinv_item_metabox_save_' . $field, $value, $name );
96
-                    update_post_meta( $post_id, $field, $value );
95
+                    $value = apply_filters('wpinv_item_metabox_save_' . $field, $value, $name);
96
+                    update_post_meta($post_id, $field, $value);
97 97
                 }
98 98
             }
99 99
             
100
-            if ( !get_post_meta( $post_id, '_wpinv_custom_id', true ) ) {
101
-                update_post_meta( $post_id, '_wpinv_custom_id', $post_id );
100
+            if (!get_post_meta($post_id, '_wpinv_custom_id', true)) {
101
+                update_post_meta($post_id, '_wpinv_custom_id', $post_id);
102 102
             }
103 103
         }
104 104
     }
105 105
 }
106
-add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 );
106
+add_action('save_post', 'wpinv_save_meta_boxes', 10, 3);
107 107
 
108
-function wpinv_bulk_and_quick_edit_save( $post_id, $post, $update = false ) {
109
-    if ( !( !empty( $_POST['action'] ) && $_POST['action'] == 'inline-save' ) ) {
108
+function wpinv_bulk_and_quick_edit_save($post_id, $post, $update = false) {
109
+    if (!(!empty($_POST['action']) && $_POST['action'] == 'inline-save')) {
110 110
         return;
111 111
     }
112 112
     
113 113
     // $post_id and $post are required
114
-    if ( empty( $post_id ) || empty( $post ) ) {
114
+    if (empty($post_id) || empty($post)) {
115 115
         return;
116 116
     }
117 117
         
118
-    if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) {
118
+    if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) {
119 119
         return;
120 120
     }
121 121
     
122 122
     // Dont' save meta boxes for revisions or autosaves
123
-    if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
123
+    if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
124 124
         return;
125 125
     }
126 126
 
127
-    if ( $post->post_type == 'wpi_item' ) {
127
+    if ($post->post_type == 'wpi_item') {
128 128
         // verify nonce
129
-        if ( isset( $_POST['_wpinv_item_price'] ) && get_post_meta( $post->ID, '_wpinv_type', true ) !== 'package' ) {
130
-            update_post_meta( $post_id, '_wpinv_price', wpinv_sanitize_amount( $_POST['_wpinv_item_price'] ) );
129
+        if (isset($_POST['_wpinv_item_price']) && get_post_meta($post->ID, '_wpinv_type', true) !== 'package') {
130
+            update_post_meta($post_id, '_wpinv_price', wpinv_sanitize_amount($_POST['_wpinv_item_price']));
131 131
         }
132 132
         
133
-        if ( isset( $_POST['_wpinv_vat_class'] ) ) {
134
-            update_post_meta( $post_id, '_wpinv_vat_class', sanitize_text_field( $_POST['_wpinv_vat_class'] ) );
133
+        if (isset($_POST['_wpinv_vat_class'])) {
134
+            update_post_meta($post_id, '_wpinv_vat_class', sanitize_text_field($_POST['_wpinv_vat_class']));
135 135
         }
136 136
 
137
-        if ( isset( $_POST['_wpinv_vat_rules'] ) ) {
138
-            update_post_meta( $post_id, '_wpinv_vat_rule', sanitize_text_field( $_POST['_wpinv_vat_rules'] ) );
137
+        if (isset($_POST['_wpinv_vat_rules'])) {
138
+            update_post_meta($post_id, '_wpinv_vat_rule', sanitize_text_field($_POST['_wpinv_vat_rules']));
139 139
         }
140 140
         
141
-        if ( isset( $_POST['_wpinv_item_type'] ) ) {
142
-            update_post_meta( $post_id, '_wpinv_type', sanitize_text_field( $_POST['_wpinv_item_type'] ) );
141
+        if (isset($_POST['_wpinv_item_type'])) {
142
+            update_post_meta($post_id, '_wpinv_type', sanitize_text_field($_POST['_wpinv_item_type']));
143 143
         }
144 144
     }
145 145
 }
146
-add_action( 'save_post', 'wpinv_bulk_and_quick_edit_save', 10, 3 );
146
+add_action('save_post', 'wpinv_bulk_and_quick_edit_save', 10, 3);
147 147
 
148 148
 function wpinv_register_item_meta_boxes() {    
149 149
     global $wpinv_euvat;
150 150
     
151
-    add_meta_box( 'wpinv_field_prices', __( 'Item Price', 'invoicing' ), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high' );
151
+    add_meta_box('wpinv_field_prices', __('Item Price', 'invoicing'), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high');
152 152
 
153
-    if ( $wpinv_euvat->allow_vat_rules() ) {
154
-        add_meta_box( 'wpinv_field_vat_rules', __( 'VAT rules type to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high' );
153
+    if ($wpinv_euvat->allow_vat_rules()) {
154
+        add_meta_box('wpinv_field_vat_rules', __('VAT rules type to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high');
155 155
     }
156 156
     
157
-    if ( $wpinv_euvat->allow_vat_classes() ) {
158
-        add_meta_box( 'wpinv_field_vat_classes', __( 'VAT rates class to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high' );
157
+    if ($wpinv_euvat->allow_vat_classes()) {
158
+        add_meta_box('wpinv_field_vat_classes', __('VAT rates class to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high');
159 159
     }
160 160
     
161
-    add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core' );
162
-    add_meta_box( 'wpinv_field_meta_values', __( 'Item Meta Values', 'invoicing' ), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core' );
161
+    add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core');
162
+    add_meta_box('wpinv_field_meta_values', __('Item Meta Values', 'invoicing'), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core');
163 163
 }
164 164
 
165 165
 function wpinv_register_discount_meta_boxes() {
166
-    add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' );
166
+    add_meta_box('wpinv_discount_fields', __('Discount Details', 'invoicing'), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high');
167 167
 }
168 168
 
169
-function wpinv_discount_metabox_details( $post ) {
169
+function wpinv_discount_metabox_details($post) {
170 170
     $discount_id    = $post->ID;
171
-    $discount       = wpinv_get_discount( $discount_id );
171
+    $discount       = wpinv_get_discount($discount_id);
172 172
     
173
-    $type           = wpinv_get_discount_type( $discount_id );
174
-    $item_reqs      = wpinv_get_discount_item_reqs( $discount_id );
175
-    $excluded_items = wpinv_get_discount_excluded_items( $discount_id );
176
-    $min_total      = wpinv_get_discount_min_total( $discount_id );
177
-    $max_total      = wpinv_get_discount_max_total( $discount_id );
178
-    $max_uses       = wpinv_get_discount_max_uses( $discount_id );
179
-    $single_use     = wpinv_discount_is_single_use( $discount_id );
180
-    $recurring      = (bool)wpinv_discount_is_recurring( $discount_id );
173
+    $type           = wpinv_get_discount_type($discount_id);
174
+    $item_reqs      = wpinv_get_discount_item_reqs($discount_id);
175
+    $excluded_items = wpinv_get_discount_excluded_items($discount_id);
176
+    $min_total      = wpinv_get_discount_min_total($discount_id);
177
+    $max_total      = wpinv_get_discount_max_total($discount_id);
178
+    $max_uses       = wpinv_get_discount_max_uses($discount_id);
179
+    $single_use     = wpinv_discount_is_single_use($discount_id);
180
+    $recurring      = (bool)wpinv_discount_is_recurring($discount_id);
181 181
     
182 182
     $min_total      = $min_total > 0 ? $min_total : '';
183 183
     $max_total      = $max_total > 0 ? $max_total : '';
184 184
     $max_uses       = $max_uses > 0 ? $max_uses : '';
185 185
 ?>
186
-<?php do_action( 'wpinv_discount_form_top', $post ); ?>
187
-<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?>
186
+<?php do_action('wpinv_discount_form_top', $post); ?>
187
+<?php wp_nonce_field('wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce'); ;?>
188 188
 <table class="form-table wpi-form-table">
189 189
     <tbody>
190
-        <?php do_action( 'wpinv_discount_form_first', $post ); ?>
191
-        <?php do_action( 'wpinv_discount_form_before_code', $post ); ?>
190
+        <?php do_action('wpinv_discount_form_first', $post); ?>
191
+        <?php do_action('wpinv_discount_form_before_code', $post); ?>
192 192
         <tr>
193 193
             <th valign="top" scope="row">
194
-                <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label>
194
+                <label for="wpinv_discount_code"><?php _e('Discount Code', 'invoicing'); ?></label>
195 195
             </th>
196 196
             <td>
197
-                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required>
198
-                <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p>
197
+                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr(wpinv_get_discount_code($discount_id)); ?>" required>
198
+                <p class="description"><?php _e('Enter a code for this discount, such as 10OFF', 'invoicing'); ?></p>
199 199
             </td>
200 200
         </tr>
201
-        <?php do_action( 'wpinv_discount_form_before_type', $post ); ?>
201
+        <?php do_action('wpinv_discount_form_before_type', $post); ?>
202 202
         <tr>
203 203
             <th valign="top" scope="row">
204
-                <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label>
204
+                <label for="wpinv_discount_type"><?php _e('Discount Type', 'invoicing'); ?></label>
205 205
             </th>
206 206
             <td>
207 207
                 <select id="wpinv_discount_type" name="type" class="medium-text">
208
-                    <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?>
209
-                    <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option>
208
+                    <?php foreach (wpinv_get_discount_types() as $value => $label) { ?>
209
+                    <option value="<?php echo $value; ?>" <?php selected($type, $value); ?>><?php echo $label; ?></option>
210 210
                     <?php } ?>
211 211
                 </select>
212
-                <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p>
212
+                <p class="description"><?php _e('The kind of discount to apply for this discount.', 'invoicing'); ?></p>
213 213
             </td>
214 214
         </tr>
215
-        <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?>
215
+        <?php do_action('wpinv_discount_form_before_amount', $post); ?>
216 216
         <tr>
217 217
             <th valign="top" scope="row">
218
-                <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label>
218
+                <label for="wpinv_discount_amount"><?php _e('Amount', 'invoicing'); ?></label>
219 219
             </th>
220 220
             <td>
221
-                <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>
222
-                <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p>
223
-                <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p>
221
+                <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>
222
+                <p style="display:none;" class="description"><?php _e('Enter the discount amount in USD', 'invoicing'); ?></p>
223
+                <p class="description"><?php _e('Enter the discount value. Ex: 10', 'invoicing'); ?></p>
224 224
             </td>
225 225
         </tr>
226
-        <?php do_action( 'wpinv_discount_form_before_items', $post ); ?>
226
+        <?php do_action('wpinv_discount_form_before_items', $post); ?>
227 227
         <tr>
228 228
             <th valign="top" scope="row">
229
-                <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label>
229
+                <label for="wpinv_discount_items"><?php _e('Items', 'invoicing'); ?></label>
230 230
             </th>
231 231
             <td>
232
-                <p><?php echo wpinv_item_dropdown( array(
232
+                <p><?php echo wpinv_item_dropdown(array(
233 233
                         'name'              => 'items[]',
234 234
                         'id'                => 'items',
235 235
                         'selected'          => $item_reqs,
236 236
                         'multiple'          => true,
237 237
                         'chosen'            => true,
238 238
                         'class'             => 'medium-text',
239
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
239
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
240 240
                         'show_recurring'    => true,
241
-                    ) ); ?>
241
+                    )); ?>
242 242
                 </p>
243
-                <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>
243
+                <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>
244 244
             </td>
245 245
         </tr>
246
-        <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?>
246
+        <?php do_action('wpinv_discount_form_before_excluded_items', $post); ?>
247 247
         <tr>
248 248
             <th valign="top" scope="row">
249
-                <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label>
249
+                <label for="wpinv_discount_excluded_items"><?php _e('Excluded Items', 'invoicing'); ?></label>
250 250
             </th>
251 251
             <td>
252
-                <p><?php echo wpinv_item_dropdown( array(
252
+                <p><?php echo wpinv_item_dropdown(array(
253 253
                         'name'              => 'excluded_items[]',
254 254
                         'id'                => 'excluded_items',
255 255
                         'selected'          => $excluded_items,
256 256
                         'multiple'          => true,
257 257
                         'chosen'            => true,
258 258
                         'class'             => 'medium-text',
259
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
259
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
260 260
                         'show_recurring'    => true,
261
-                    ) ); ?>
261
+                    )); ?>
262 262
                 </p>
263
-                <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p>
263
+                <p class="description"><?php _e('Items which are NOT allowed to use this discount.', 'invoicing'); ?></p>
264 264
             </td>
265 265
         </tr>
266
-        <?php do_action( 'wpinv_discount_form_before_start', $post ); ?>
266
+        <?php do_action('wpinv_discount_form_before_start', $post); ?>
267 267
         <tr>
268 268
             <th valign="top" scope="row">
269
-                <label for="wpinv_discount_start"><?php _e( 'Start date', 'invoicing' ); ?></label>
269
+                <label for="wpinv_discount_start"><?php _e('Start date', 'invoicing'); ?></label>
270 270
             </th>
271 271
             <td>
272
-                <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr( wpinv_get_discount_start_date( $discount_id ) ); ?>">
273
-                <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
+                <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr(wpinv_get_discount_start_date($discount_id)); ?>">
273
+                <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>
274 274
             </td>
275 275
         </tr>
276
-        <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?>
276
+        <?php do_action('wpinv_discount_form_before_expiration', $post); ?>
277 277
         <tr>
278 278
             <th valign="top" scope="row">
279
-                <label for="wpinv_discount_expiration"><?php _e( 'Expiration date', 'invoicing' ); ?></label>
279
+                <label for="wpinv_discount_expiration"><?php _e('Expiration date', 'invoicing'); ?></label>
280 280
             </th>
281 281
             <td>
282
-                <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr( wpinv_get_discount_expiration( $discount_id ) ); ?>">
283
-                <p class="description"><?php _e( 'Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing' ); ?></p>
282
+                <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr(wpinv_get_discount_expiration($discount_id)); ?>">
283
+                <p class="description"><?php _e('Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing'); ?></p>
284 284
             </td>
285 285
         </tr>
286
-        <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?>
286
+        <?php do_action('wpinv_discount_form_before_min_total', $post); ?>
287 287
         <tr>
288 288
             <th valign="top" scope="row">
289
-                <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label>
289
+                <label for="wpinv_discount_min_total"><?php _e('Minimum Amount', 'invoicing'); ?></label>
290 290
             </th>
291 291
             <td>
292 292
                 <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>">
293
-                <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
293
+                <p class="description"><?php _e('This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
294 294
             </td>
295 295
         </tr>
296
-        <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?>
296
+        <?php do_action('wpinv_discount_form_before_max_total', $post); ?>
297 297
         <tr>
298 298
             <th valign="top" scope="row">
299
-                <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label>
299
+                <label for="wpinv_discount_max_total"><?php _e('Maximum Amount', 'invoicing'); ?></label>
300 300
             </th>
301 301
             <td>
302 302
                 <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>">
303
-                <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
303
+                <p class="description"><?php _e('This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
304 304
             </td>
305 305
         </tr>
306
-        <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?>
306
+        <?php do_action('wpinv_discount_form_before_recurring', $post); ?>
307 307
         <tr>
308 308
             <th valign="top" scope="row">
309
-                <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label>
309
+                <label for="wpinv_discount_recurring"><?php _e('For recurring apply to', 'invoicing'); ?></label>
310 310
             </th>
311 311
             <td>
312 312
                 <select id="wpinv_discount_recurring" name="recurring" class="medium-text">
313
-                    <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option>
314
-                    <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option>
313
+                    <option value="0" <?php selected(false, $recurring); ?>><?php _e('All payments', 'invoicing'); ?></option>
314
+                    <option value="1" <?php selected(true, $recurring); ?>><?php _e('First payment only', 'invoicing'); ?></option>
315 315
                 </select>
316
-                <p class="description"><?php _e( '<b>All payments:</b> apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> apply this discount to only first payment of the recurring invoice.', 'invoicing' ); ?></p>
316
+                <p class="description"><?php _e('<b>All payments:</b> apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> apply this discount to only first payment of the recurring invoice.', 'invoicing'); ?></p>
317 317
             </td>
318 318
         </tr>
319
-        <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?>
319
+        <?php do_action('wpinv_discount_form_before_max_uses', $post); ?>
320 320
         <tr>
321 321
             <th valign="top" scope="row">
322
-                <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label>
322
+                <label for="wpinv_discount_max_uses"><?php _e('Max Uses', 'invoicing'); ?></label>
323 323
             </th>
324 324
             <td>
325 325
                 <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>">
326
-                <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p>
326
+                <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing'); ?></p>
327 327
             </td>
328 328
         </tr>
329
-        <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?>
329
+        <?php do_action('wpinv_discount_form_before_single_use', $post); ?>
330 330
         <tr>
331 331
             <th valign="top" scope="row">
332
-                <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label>
332
+                <label for="wpinv_discount_single_use"><?php _e('Use Once Per User', 'invoicing'); ?></label>
333 333
             </th>
334 334
             <td>
335
-                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>>
336
-                <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span>
335
+                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked(true, $single_use); ?>>
336
+                <span class="description"><?php _e('Limit this discount to a single use per user?', 'invoicing'); ?></span>
337 337
             </td>
338 338
         </tr>
339
-        <?php do_action( 'wpinv_discount_form_last', $post ); ?>
339
+        <?php do_action('wpinv_discount_form_last', $post); ?>
340 340
     </tbody>
341 341
 </table>
342
-<?php do_action( 'wpinv_discount_form_bottom', $post ); ?>
342
+<?php do_action('wpinv_discount_form_bottom', $post); ?>
343 343
     <?php
344 344
 }
345 345
 
346
-function wpinv_discount_metabox_save( $post_id, $post, $update = false ) {
347
-    $post_type = !empty( $post ) ? $post->post_type : '';
346
+function wpinv_discount_metabox_save($post_id, $post, $update = false) {
347
+    $post_type = !empty($post) ? $post->post_type : '';
348 348
     
349
-    if ( $post_type != 'wpi_discount' ) {
349
+    if ($post_type != 'wpi_discount') {
350 350
         return;
351 351
     }
352 352
     
353
-    if ( !isset( $_POST['wpinv_discount_metabox_nonce'] ) || ( isset( $_POST['wpinv_discount_metabox_nonce'] ) && !wp_verify_nonce( $_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce' ) ) ) {
353
+    if (!isset($_POST['wpinv_discount_metabox_nonce']) || (isset($_POST['wpinv_discount_metabox_nonce']) && !wp_verify_nonce($_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce'))) {
354 354
         return;
355 355
     }
356 356
     
357
-    if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
357
+    if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
358 358
         return;
359 359
     }
360 360
     
361
-    if ( !current_user_can( 'manage_options', $post_id ) ) {
361
+    if (!current_user_can('manage_options', $post_id)) {
362 362
         return;
363 363
     }
364 364
     
365
-    return wpinv_store_discount( $post_id, $_POST, $post, $update );
365
+    return wpinv_store_discount($post_id, $_POST, $post, $update);
366 366
 }
367
-add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 );
368 367
\ No newline at end of file
368
+add_action('save_post', 'wpinv_discount_metabox_save', 10, 3);
369 369
\ No newline at end of file
Please login to merge, or discard this patch.