Passed
Pull Request — master (#377)
by Brian
06:57
created
includes/admin/meta-boxes/class-getpaid-meta-box-item-details.php 1 patch
Spacing   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,27 +21,27 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the item.
27
-        $item = new WPInv_Item( $post );
27
+        $item = new WPInv_Item($post);
28 28
 
29 29
         // Nonce field.
30
-        wp_nonce_field( 'wpinv_item_meta_box_save', 'wpinv_vat_meta_box_nonce' );
30
+        wp_nonce_field('wpinv_item_meta_box_save', 'wpinv_vat_meta_box_nonce');
31 31
 
32 32
         // Set the currency position.
33 33
         $position = wpinv_currency_position();
34 34
 
35
-        if ( $position == 'left_space' ) {
35
+        if ($position == 'left_space') {
36 36
             $position = 'left';
37 37
         }
38 38
 
39
-        if ( $position == 'right_space' ) {
39
+        if ($position == 'right_space') {
40 40
             $position = 'right';
41 41
         }
42 42
 
43 43
         ?>
44
-        <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr( $item->get_type( 'edit' ) ); ?>" />
44
+        <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr($item->get_type('edit')); ?>" />
45 45
         <input type="hidden" id="_wpi_is_editable" value="<?php echo (int) $item->is_editable(); ?>" />
46 46
         <style>
47 47
             #poststuff .input-group-text,
@@ -51,21 +51,21 @@  discard block
 block discarded – undo
51 51
         </style>
52 52
         <div class='bsui' style='max-width: 600px;padding-top: 10px; max-width: 820px;'>
53 53
 
54
-            <?php do_action( 'wpinv_item_details_metabox_before_price', $item ); ?>
54
+            <?php do_action('wpinv_item_details_metabox_before_price', $item); ?>
55 55
             <div class="form-group row">
56
-                <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e( 'Item Price', 'invoicing' )?></span></label>
56
+                <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e('Item Price', 'invoicing')?></span></label>
57 57
                 <div class="col-sm-8">
58 58
                     <div class="row">
59 59
                         <div class="col-sm-4 getpaid-price-input">
60 60
                             <div class="input-group input-group-sm">
61
-                                <?php if( 'left' == $position ) : ?>
61
+                                <?php if ('left' == $position) : ?>
62 62
                                 <div class="input-group-prepend">
63 63
                                     <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
64 64
                                 </div>
65 65
                                 <?php endif; ?>
66
-                                <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr( $item->get_price( 'edit' ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control">
66
+                                <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr($item->get_price('edit')); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control">
67 67
 
68
-                                <?php if( 'left' != $position ) : ?>
68
+                                <?php if ('left' != $position) : ?>
69 69
                                 <div class="input-group-append">
70 70
                                     <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
71 71
                                 </div>
@@ -79,25 +79,25 @@  discard block
 block discarded – undo
79 79
                                     array(
80 80
                                         'id'               => 'wpinv_recurring_interval',
81 81
                                         'name'             => 'wpinv_recurring_interval',
82
-                                        'label'            => __( 'Interval', 'invoicing' ),
83
-                                        'placeholder'      => __( 'Select Interval', 'invoicing' ),
84
-                                        'value'            => $item->get_recurring_interval( 'edit' ),
82
+                                        'label'            => __('Interval', 'invoicing'),
83
+                                        'placeholder'      => __('Select Interval', 'invoicing'),
84
+                                        'value'            => $item->get_recurring_interval('edit'),
85 85
                                         'select2'          => true,
86 86
                                         'data-allow-clear' => 'false',
87 87
                                         'options'          => array(
88
-                                            '1'  => __( 'every', 'invoicing' ),
89
-                                            '2'  => __( 'every 2nd', 'invoicing' ),
90
-                                            '3'  => __( 'every 3rd', 'invoicing' ),
91
-                                            '4'  => __( 'every 4th', 'invoicing' ),
92
-                                            '5'  => __( 'every 5th', 'invoicing' ),
93
-                                            '6'  => __( 'every 6th', 'invoicing' ),
94
-                                            '8'  => __( 'every 8th', 'invoicing' ),
95
-                                            '9'  => __( 'every 9th', 'invoicing' ),
96
-                                            '10' => __( 'every 10th', 'invoicing' ),
97
-                                            '11' => __( 'every 11th', 'invoicing' ),
98
-                                            '12' => __( 'every 12th', 'invoicing' ),
99
-                                            '13' => __( 'every 13th', 'invoicing' ),
100
-                                            '14' => __( 'every 14th', 'invoicing' ),
88
+                                            '1'  => __('every', 'invoicing'),
89
+                                            '2'  => __('every 2nd', 'invoicing'),
90
+                                            '3'  => __('every 3rd', 'invoicing'),
91
+                                            '4'  => __('every 4th', 'invoicing'),
92
+                                            '5'  => __('every 5th', 'invoicing'),
93
+                                            '6'  => __('every 6th', 'invoicing'),
94
+                                            '8'  => __('every 8th', 'invoicing'),
95
+                                            '9'  => __('every 9th', 'invoicing'),
96
+                                            '10' => __('every 10th', 'invoicing'),
97
+                                            '11' => __('every 11th', 'invoicing'),
98
+                                            '12' => __('every 12th', 'invoicing'),
99
+                                            '13' => __('every 13th', 'invoicing'),
100
+                                            '14' => __('every 14th', 'invoicing'),
101 101
                                         )
102 102
                                     )
103 103
                                 );
@@ -109,16 +109,16 @@  discard block
 block discarded – undo
109 109
                                     array(
110 110
                                         'id'               => 'wpinv_recurring_period',
111 111
                                         'name'             => 'wpinv_recurring_period',
112
-                                        'label'            => __( 'Period', 'invoicing' ),
113
-                                        'placeholder'      => __( 'Select Period', 'invoicing' ),
114
-                                        'value'            => $item->get_recurring_period( 'edit' ),
112
+                                        'label'            => __('Period', 'invoicing'),
113
+                                        'placeholder'      => __('Select Period', 'invoicing'),
114
+                                        'value'            => $item->get_recurring_period('edit'),
115 115
                                         'select2'          => true,
116 116
                                         'data-allow-clear' => 'false',
117 117
                                         'options'     => array(
118
-                                            'D'  => __( 'day', 'invoicing' ),
119
-                                            'W'  => __( 'week', 'invoicing' ),
120
-                                            'M'  => __( 'month', 'invoicing' ),
121
-                                            'Y'  => __( 'year', 'invoicing' ),
118
+                                            'D'  => __('day', 'invoicing'),
119
+                                            'W'  => __('week', 'invoicing'),
120
+                                            'M'  => __('month', 'invoicing'),
121
+                                            'Y'  => __('year', 'invoicing'),
122 122
                                         )
123 123
                                     )
124 124
                                 );
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
                             <?php
131 131
 
132 132
                                 // Dynamic pricing.
133
-                                if( $item->supports_dynamic_pricing() ) {
133
+                                if ($item->supports_dynamic_pricing()) {
134 134
 
135
-                                    do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item );
135
+                                    do_action('wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item);
136 136
 
137 137
                                     // NYP toggle.
138 138
                                     echo aui()->input(
@@ -140,60 +140,60 @@  discard block
 block discarded – undo
140 140
                                             'id'          => 'wpinv_name_your_price',
141 141
                                             'name'        => 'wpinv_name_your_price',
142 142
                                             'type'        => 'checkbox',
143
-                                            'label'       => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ),
143
+                                            'label'       => apply_filters('wpinv_name_your_price_toggle_text', __('Let customers name their price', 'invoicing')),
144 144
                                             'value'       => '1',
145 145
                                             'checked'     => $item->user_can_set_their_price(),
146 146
                                             'no_wrap'     => true,
147 147
                                         )
148 148
                                     );
149 149
 
150
-                                    do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item );
150
+                                    do_action('wpinv_item_details_metabox_dynamic_pricing_checkbox', $item);
151 151
 
152 152
                                 }
153 153
 
154 154
                                 // Subscriptions.
155
-                                do_action( 'wpinv_item_details_metabox_before_subscription_checkbox', $item );
155
+                                do_action('wpinv_item_details_metabox_before_subscription_checkbox', $item);
156 156
                                 echo aui()->input(
157 157
                                     array(
158 158
                                         'id'          => 'wpinv_is_recurring',
159 159
                                         'name'        => 'wpinv_is_recurring',
160 160
                                         'type'        => 'checkbox',
161
-                                        'label'       => apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Charge customers a recurring amount for this item', 'invoicing' ) ),
161
+                                        'label'       => apply_filters('wpinv_is_recurring_toggle_text', __('Charge customers a recurring amount for this item', 'invoicing')),
162 162
                                         'value'       => '1',
163 163
                                         'checked'     => $item->is_recurring(),
164 164
                                         'no_wrap'     => true,
165 165
                                     )
166 166
                                 );
167
-                                do_action( 'wpinv_item_details_metabox_subscription_checkbox', $item );
167
+                                do_action('wpinv_item_details_metabox_subscription_checkbox', $item);
168 168
                             ?>
169 169
                         </div>
170 170
                     </div>
171 171
                 </div>
172 172
                 <div class="col-sm-1 pt-2 pl-0">
173
-                    <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e( 'Set the subscription price, billing interval and period.', 'invoicing' ); ?>"></span>
173
+                    <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e('Set the subscription price, billing interval and period.', 'invoicing'); ?>"></span>
174 174
                 </div>
175 175
             </div>
176
-            <?php do_action( 'wpinv_item_details_metabox_after_price', $item ); ?>
176
+            <?php do_action('wpinv_item_details_metabox_after_price', $item); ?>
177 177
 
178
-            <?php if( $item->supports_dynamic_pricing() ) : ?>
179
-                <?php do_action( 'wpinv_item_details_metabox_before_minimum_price', $item ); ?>
178
+            <?php if ($item->supports_dynamic_pricing()) : ?>
179
+                <?php do_action('wpinv_item_details_metabox_before_minimum_price', $item); ?>
180 180
                 <div class="wpinv_show_if_dynamic wpinv_minimum_price">
181 181
 
182 182
                     <div class="form-group row">
183 183
                         <label for="wpinv_minimum_price" class="col-sm-3 col-form-label">
184
-                            <?php _e( 'Minimum Price', 'invoicing' );?>
184
+                            <?php _e('Minimum Price', 'invoicing'); ?>
185 185
                         </label>
186 186
                         <div class="col-sm-8">
187 187
                             <div class="input-group input-group-sm">
188
-                                <?php if( 'left' == $position ) : ?>
188
+                                <?php if ('left' == $position) : ?>
189 189
                                     <div class="input-group-prepend">
190 190
                                         <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
191 191
                                     </div>
192 192
                                 <?php endif; ?>
193 193
 
194
-                                <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr( $item->get_minimum_price( 'edit' ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control">
194
+                                <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr($item->get_minimum_price('edit')); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control">
195 195
 
196
-                                <?php if( 'left' != $position ) : ?>
196
+                                <?php if ('left' != $position) : ?>
197 197
                                     <div class="input-group-append">
198 198
                                         <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
199 199
                                     </div>
@@ -202,45 +202,45 @@  discard block
 block discarded – undo
202 202
                         </div>
203 203
 
204 204
                         <div class="col-sm-1 pt-2 pl-0">
205
-                            <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the minimum amount that users are allowed to set', 'invoicing' ); ?>"></span>
205
+                            <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the minimum amount that users are allowed to set', 'invoicing'); ?>"></span>
206 206
                         </div>
207 207
                     </div>
208 208
 
209 209
                 </div>
210
-                <?php do_action( 'wpinv_item_details_metabox_minimum_price', $item ); ?>
210
+                <?php do_action('wpinv_item_details_metabox_minimum_price', $item); ?>
211 211
             <?php endif; ?>
212 212
 
213
-            <?php do_action( 'wpinv_item_details_metabox_before_maximum_renewals', $item ); ?>
213
+            <?php do_action('wpinv_item_details_metabox_before_maximum_renewals', $item); ?>
214 214
             <div class="wpinv_show_if_recurring wpinv_maximum_renewals">
215 215
 
216 216
                 <div class="form-group row">
217 217
                     <label for="wpinv_recurring_limit" class="col-sm-3 col-form-label">
218
-                        <?php _e( 'Maximum Renewals', 'invoicing' );?>
218
+                        <?php _e('Maximum Renewals', 'invoicing'); ?>
219 219
                     </label>
220 220
                     <div class="col-sm-8">
221
-                        <input type="number" value="<?php echo esc_attr( $item->get_recurring_limit( 'edit' ) ); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" />
221
+                        <input type="number" value="<?php echo esc_attr($item->get_recurring_limit('edit')); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" />
222 222
                     </div>
223 223
                     <div class="col-sm-1 pt-2 pl-0">
224
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing' ); ?>"></span>
224
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing'); ?>"></span>
225 225
                     </div>
226 226
                 </div>
227 227
 
228 228
             </div>
229
-            <?php do_action( 'wpinv_item_details_metabox_maximum_renewals', $item ); ?>
229
+            <?php do_action('wpinv_item_details_metabox_maximum_renewals', $item); ?>
230 230
 
231
-            <?php do_action( 'wpinv_item_details_metabox_before_free_trial', $item ); ?>
231
+            <?php do_action('wpinv_item_details_metabox_before_free_trial', $item); ?>
232 232
             <div class="wpinv_show_if_recurring wpinv_free_trial">
233 233
 
234 234
                 <div class="form-group row">
235
-                    <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php _e( 'Free Trial', 'invoicing' )?></label>
235
+                    <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php _e('Free Trial', 'invoicing')?></label>
236 236
 
237 237
                     <div class="col-sm-8">
238 238
                         <div class="row">
239 239
                             <div class="col-sm-6">
240
-                                <?php $value = $item->has_free_trial() ? $item->get_trial_interval( 'edit' ) : 0;?>
240
+                                <?php $value = $item->has_free_trial() ? $item->get_trial_interval('edit') : 0; ?>
241 241
 
242 242
                                 <div>
243
-                                    <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr( $value ); ?>" >
243
+                                    <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr($value); ?>" >
244 244
                                 </div>
245 245
                             </div>
246 246
                             <div class="col-sm-6">
@@ -249,17 +249,17 @@  discard block
 block discarded – undo
249 249
                                         array(
250 250
                                             'id'               => 'wpinv_trial_period',
251 251
                                             'name'             => 'wpinv_trial_period',
252
-                                            'label'            => __( 'Trial Period', 'invoicing' ),
253
-                                            'placeholder'      => __( 'Trial Period', 'invoicing' ),
254
-                                            'value'            => $item->get_recurring_period( 'edit' ),
252
+                                            'label'            => __('Trial Period', 'invoicing'),
253
+                                            'placeholder'      => __('Trial Period', 'invoicing'),
254
+                                            'value'            => $item->get_recurring_period('edit'),
255 255
                                             'select2'          => true,
256 256
                                             'data-allow-clear' => 'false',
257 257
                                             'no_wrap'          => true,
258 258
                                             'options'          => array(
259
-                                                'D'  => __( 'day(s)', 'invoicing' ),
260
-                                                'W'  => __( 'week(s)', 'invoicing' ),
261
-                                                'M'  => __( 'month(s)', 'invoicing' ),
262
-                                                'Y'  => __( 'year(s)', 'invoicing' ),
259
+                                                'D'  => __('day(s)', 'invoicing'),
260
+                                                'W'  => __('week(s)', 'invoicing'),
261
+                                                'M'  => __('month(s)', 'invoicing'),
262
+                                                'Y'  => __('year(s)', 'invoicing'),
263 263
                                             )
264 264
                                         )
265 265
                                     );
@@ -270,15 +270,15 @@  discard block
 block discarded – undo
270 270
                     </div>
271 271
 
272 272
                     <div class="col-sm-1 pt-2 pl-0">
273
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'An optional period of time to wait before charging the first recurring payment.', 'invoicing' ); ?>"></span>
273
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('An optional period of time to wait before charging the first recurring payment.', 'invoicing'); ?>"></span>
274 274
                     </div>
275 275
 
276 276
                 </div>
277 277
 
278 278
             </div>
279
-            <?php do_action( 'wpinv_item_details_metabox__free_trial', $item ); ?>
279
+            <?php do_action('wpinv_item_details_metabox__free_trial', $item); ?>
280 280
 
281
-            <?php do_action( 'wpinv_item_details_metabox_item_details', $item ); ?>
281
+            <?php do_action('wpinv_item_details_metabox_item_details', $item); ?>
282 282
         </div>
283 283
         <?php
284 284
 
@@ -289,36 +289,36 @@  discard block
 block discarded – undo
289 289
 	 *
290 290
 	 * @param int $post_id
291 291
 	 */
292
-	public static function save( $post_id ) {
292
+	public static function save($post_id) {
293 293
 
294 294
         // verify nonce
295
-        if ( ! isset( $_POST['wpinv_vat_meta_box_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save' ) ) {
295
+        if (!isset($_POST['wpinv_vat_meta_box_nonce']) || !wp_verify_nonce($_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save')) {
296 296
             return;
297 297
         }
298 298
 
299 299
         // Prepare the item.
300
-        $item = new WPInv_Item( $post_id );
300
+        $item = new WPInv_Item($post_id);
301 301
 
302 302
         // Load new data.
303 303
         $item->set_props(
304 304
 			array(
305
-				'price'                => isset( $_POST['wpinv_item_price'] ) ? (float) $_POST['wpinv_item_price'] : null,
306
-				'vat_rule'             => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
307
-				'vat_class'            => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
308
-				'type'                 => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
309
-				'is_dynamic_pricing'   => isset( $_POST['wpinv_name_your_price'] ),
310
-                'minimum_price'        => isset( $_POST['wpinv_minimum_price'] ) ? (float) $_POST['wpinv_minimum_price'] : null,
311
-				'is_recurring'         => isset( $_POST['wpinv_is_recurring'] ),
312
-				'recurring_period'     => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
313
-				'recurring_interval'   => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : null,
314
-				'recurring_limit'      => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
315
-				'is_free_trial'        => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
316
-				'trial_period'         => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
317
-				'trial_interval'       => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
305
+				'price'                => isset($_POST['wpinv_item_price']) ? (float) $_POST['wpinv_item_price'] : null,
306
+				'vat_rule'             => isset($_POST['wpinv_vat_rules']) ? wpinv_clean($_POST['wpinv_vat_rules']) : null,
307
+				'vat_class'            => isset($_POST['wpinv_vat_class']) ? wpinv_clean($_POST['wpinv_vat_class']) : null,
308
+				'type'                 => isset($_POST['wpinv_item_type']) ? wpinv_clean($_POST['wpinv_item_type']) : null,
309
+				'is_dynamic_pricing'   => isset($_POST['wpinv_name_your_price']),
310
+                'minimum_price'        => isset($_POST['wpinv_minimum_price']) ? (float) $_POST['wpinv_minimum_price'] : null,
311
+				'is_recurring'         => isset($_POST['wpinv_is_recurring']),
312
+				'recurring_period'     => isset($_POST['wpinv_recurring_period']) ? wpinv_clean($_POST['wpinv_recurring_period']) : null,
313
+				'recurring_interval'   => isset($_POST['wpinv_recurring_interval']) ? (int) $_POST['wpinv_recurring_interval'] : null,
314
+				'recurring_limit'      => isset($_POST['wpinv_recurring_limit']) ? (int) $_POST['wpinv_recurring_limit'] : null,
315
+				'is_free_trial'        => isset($_POST['wpinv_trial_interval']) ? (0 != (int) $_POST['wpinv_trial_interval']) : null,
316
+				'trial_period'         => isset($_POST['wpinv_trial_period']) ? wpinv_clean($_POST['wpinv_trial_period']) : null,
317
+				'trial_interval'       => isset($_POST['wpinv_trial_interval']) ? (int) $_POST['wpinv_trial_interval'] : null,
318 318
 			)
319 319
         );
320 320
 
321 321
 		$item->save();
322
-		do_action( 'getpaid_item_metabox_save', $post_id, $item );
322
+		do_action('getpaid_item_metabox_save', $post_id, $item);
323 323
 	}
324 324
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-address.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Invoice_Address {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the invoice.
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the invoice.
27
-        $invoice = new WPInv_Invoice( $post );
27
+        $invoice = new WPInv_Invoice($post);
28 28
 
29
-        wp_nonce_field( 'wpinv_save_invoice', 'wpinv_save_invoice' )
29
+        wp_nonce_field('wpinv_save_invoice', 'wpinv_save_invoice')
30 30
 
31 31
         ?>
32 32
 
@@ -42,13 +42,13 @@  discard block
 block discarded – undo
42 42
                         <div class="col-12 col-sm-6">
43 43
                             <div id="getpaid-invoice-user-id-wrapper" class="form-group">
44 44
                                 <div>
45
-                                    <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label>
45
+                                    <label for="post_author_override"><?php _e('Customer', 'invoicing'); ?></label>
46 46
                                 </div>
47 47
                                 <?php 
48 48
                                     wpinv_dropdown_users(
49 49
                                         array(
50 50
                                             'name'             => 'post_author_override',
51
-                                            'selected'         => $invoice->get_id() ? $invoice->get_user_id( 'edit' ) : get_current_user_id(),
51
+                                            'selected'         => $invoice->get_id() ? $invoice->get_user_id('edit') : get_current_user_id(),
52 52
                                             'include_selected' => true,
53 53
                                             'show'             => 'display_name_with_email',
54 54
                                             'orderby'          => 'user_email',
@@ -66,29 +66,29 @@  discard block
 block discarded – undo
66 66
                                             'type'        => 'email',
67 67
                                             'id'          => 'getpaid-invoice-new-user-email',
68 68
                                             'name'        => 'wpinv_email',
69
-                                            'label'       => __( 'Email', 'invoicing' ) . '<span class="required">*</span>',
69
+                                            'label'       => __('Email', 'invoicing') . '<span class="required">*</span>',
70 70
                                             'label_type'  => 'vertical',
71 71
                                             'placeholder' => '[email protected]',
72 72
                                             'class'       => 'form-control-sm',
73
-                                            'value'       => $invoice->get_state( 'edit' ),
73
+                                            'value'       => $invoice->get_state('edit'),
74 74
                                         )
75 75
                                     );
76 76
                                 ?>
77 77
                             </div>
78 78
                         </div>
79 79
                         <div class="col-12 col-sm-6 form-group mt-sm-4">
80
-                            <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?>
80
+                            <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?>
81 81
                                 <a id="getpaid-invoice-fill-user-details" class="button button-small button-secondary" href="javascript:void(0)">
82 82
                                     <i aria-hidden="true" class="fa fa-refresh"></i>
83
-                                    <?php _e( 'Fill User Details', 'invoicing' );?>
83
+                                    <?php _e('Fill User Details', 'invoicing'); ?>
84 84
                                 </a>
85 85
                                 <a id="getpaid-invoice-create-new-user-button" class="button button-small button-secondary" href="javascript:void(0)">
86 86
                                     <i aria-hidden="true" class="fa fa-plus"></i>
87
-                                    <?php _e( 'Add New User', 'invoicing' );?>
87
+                                    <?php _e('Add New User', 'invoicing'); ?>
88 88
                                 </a>
89 89
                                 <a id="getpaid-invoice-cancel-create-new-user" class="button button-small button-secondary d-none" href="javascript:void(0)">
90 90
                                     <i aria-hidden="true" class="fa fa-close"></i>
91
-                                    <?php _e( 'Cancel', 'invoicing' );?>
91
+                                    <?php _e('Cancel', 'invoicing'); ?>
92 92
                                 </a>
93 93
                             <?php endif; ?>
94 94
                         </div>
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
                                         'type'        => 'text',
102 102
                                         'id'          => 'wpinv_first_name',
103 103
                                         'name'        => 'wpinv_first_name',
104
-                                        'label'       => __( 'First Name', 'invoicing' ),
104
+                                        'label'       => __('First Name', 'invoicing'),
105 105
                                         'label_type'  => 'vertical',
106 106
                                         'placeholder' => 'Jane',
107 107
                                         'class'       => 'form-control-sm',
108
-                                        'value'       => $invoice->get_first_name( 'edit' ),
108
+                                        'value'       => $invoice->get_first_name('edit'),
109 109
                                     )
110 110
                                 );
111 111
                             ?>
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
                                         'type'        => 'text',
118 118
                                         'id'          => 'wpinv_last_name',
119 119
                                         'name'        => 'wpinv_last_name',
120
-                                        'label'       => __( 'Last Name', 'invoicing' ),
120
+                                        'label'       => __('Last Name', 'invoicing'),
121 121
                                         'label_type'  => 'vertical',
122 122
                                         'placeholder' => 'Doe',
123 123
                                         'class'       => 'form-control-sm',
124
-                                        'value'       => $invoice->get_last_name( 'edit' ),
124
+                                        'value'       => $invoice->get_last_name('edit'),
125 125
                                     )
126 126
                                 );
127 127
                             ?>
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
                                         'type'        => 'text',
137 137
                                         'id'          => 'wpinv_company',
138 138
                                         'name'        => 'wpinv_company',
139
-                                        'label'       => __( 'Company', 'invoicing' ),
139
+                                        'label'       => __('Company', 'invoicing'),
140 140
                                         'label_type'  => 'vertical',
141 141
                                         'placeholder' => 'Acme Corporation',
142 142
                                         'class'       => 'form-control-sm',
143
-                                        'value'       => $invoice->get_company( 'edit' ),
143
+                                        'value'       => $invoice->get_company('edit'),
144 144
                                     )
145 145
                                 );
146 146
                             ?>
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
                                         'type'        => 'text',
153 153
                                         'id'          => 'wpinv_vat_number',
154 154
                                         'name'        => 'wpinv_vat_number',
155
-                                        'label'       => __( 'Vat Number', 'invoicing' ),
155
+                                        'label'       => __('Vat Number', 'invoicing'),
156 156
                                         'label_type'  => 'vertical',
157 157
                                         'placeholder' => '1234567890',
158 158
                                         'class'       => 'form-control-sm',
159
-                                        'value'       => $invoice->get_vat_number( 'edit' ),
159
+                                        'value'       => $invoice->get_vat_number('edit'),
160 160
                                     )
161 161
                                 );
162 162
                             ?>
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
                                         'type'        => 'text',
172 172
                                         'id'          => 'wpinv_address',
173 173
                                         'name'        => 'wpinv_address',
174
-                                        'label'       => __( 'Address', 'invoicing' ),
174
+                                        'label'       => __('Address', 'invoicing'),
175 175
                                         'label_type'  => 'vertical',
176 176
                                         'placeholder' => 'Blekersdijk 295',
177 177
                                         'class'       => 'form-control-sm',
178
-                                        'value'       => $invoice->get_address( 'edit' ),
178
+                                        'value'       => $invoice->get_address('edit'),
179 179
                                     )
180 180
                                 );
181 181
                             ?>
@@ -187,11 +187,11 @@  discard block
 block discarded – undo
187 187
                                         'type'        => 'text',
188 188
                                         'id'          => 'wpinv_city',
189 189
                                         'name'        => 'wpinv_city',
190
-                                        'label'       => __( 'City', 'invoicing' ),
190
+                                        'label'       => __('City', 'invoicing'),
191 191
                                         'label_type'  => 'vertical',
192 192
                                         'placeholder' => 'Dolembreux',
193 193
                                         'class'       => 'form-control-sm',
194
-                                        'value'       => $invoice->get_vat_number( 'edit' ),
194
+                                        'value'       => $invoice->get_vat_number('edit'),
195 195
                                     )
196 196
                                 );
197 197
                             ?>
@@ -205,11 +205,11 @@  discard block
 block discarded – undo
205 205
                                     array(
206 206
                                         'id'          => 'wpinv_country',
207 207
                                         'name'        => 'wpinv_country',
208
-                                        'label'       => __( 'Country', 'invoicing' ),
208
+                                        'label'       => __('Country', 'invoicing'),
209 209
                                         'label_type'  => 'vertical',
210
-                                        'placeholder' => __( 'Choose a country', 'invoicing' ),
210
+                                        'placeholder' => __('Choose a country', 'invoicing'),
211 211
                                         'class'       => 'form-control-sm',
212
-                                        'value'       => $invoice->get_country( 'edit' ),
212
+                                        'value'       => $invoice->get_country('edit'),
213 213
                                         'options'     => wpinv_get_country_list(),
214 214
                                         'data-allow-clear' => 'false',
215 215
                                         'select2'          => true,
@@ -220,20 +220,20 @@  discard block
 block discarded – undo
220 220
                         <div class="col-12 col-sm-6">
221 221
                             <?php
222 222
 
223
-                                $states = wpinv_get_country_states( $invoice->get_country( 'edit' ) );
223
+                                $states = wpinv_get_country_states($invoice->get_country('edit'));
224 224
 
225
-                                if ( empty( $states ) ) {
225
+                                if (empty($states)) {
226 226
 
227 227
                                     echo aui()->input(
228 228
                                         array(
229 229
                                             'type'        => 'text',
230 230
                                             'id'          => 'wpinv_state',
231 231
                                             'name'        => 'wpinv_state',
232
-                                            'label'       => __( 'State', 'invoicing' ),
232
+                                            'label'       => __('State', 'invoicing'),
233 233
                                             'label_type'  => 'vertical',
234 234
                                             'placeholder' => 'Liège',
235 235
                                             'class'       => 'form-control-sm',
236
-                                            'value'       => $invoice->get_state( 'edit' ),
236
+                                            'value'       => $invoice->get_state('edit'),
237 237
                                         )
238 238
                                     );
239 239
 
@@ -243,11 +243,11 @@  discard block
 block discarded – undo
243 243
                                         array(
244 244
                                             'id'          => 'wpinv_state',
245 245
                                             'name'        => 'wpinv_state',
246
-                                            'label'       => __( 'State', 'invoicing' ),
246
+                                            'label'       => __('State', 'invoicing'),
247 247
                                             'label_type'  => 'vertical',
248
-                                            'placeholder' => __( 'Select a state', 'invoicing' ),
248
+                                            'placeholder' => __('Select a state', 'invoicing'),
249 249
                                             'class'       => 'form-control-sm',
250
-                                            'value'       => $invoice->get_state( 'edit' ),
250
+                                            'value'       => $invoice->get_state('edit'),
251 251
                                             'options'     => $states,
252 252
                                             'data-allow-clear' => 'false',
253 253
                                             'select2'          => true,
@@ -268,11 +268,11 @@  discard block
 block discarded – undo
268 268
                                         'type'        => 'text',
269 269
                                         'id'          => 'wpinv_zip',
270 270
                                         'name'        => 'wpinv_zip',
271
-                                        'label'       => __( 'Zip / Postal Code', 'invoicing' ),
271
+                                        'label'       => __('Zip / Postal Code', 'invoicing'),
272 272
                                         'label_type'  => 'vertical',
273 273
                                         'placeholder' => '4140',
274 274
                                         'class'       => 'form-control-sm',
275
-                                        'value'       => $invoice->get_zip( 'edit' ),
275
+                                        'value'       => $invoice->get_zip('edit'),
276 276
                                     )
277 277
                                 );
278 278
                             ?>
@@ -284,11 +284,11 @@  discard block
 block discarded – undo
284 284
                                         'type'        => 'text',
285 285
                                         'id'          => 'wpinv_phone',
286 286
                                         'name'        => 'wpinv_phone',
287
-                                        'label'       => __( 'Phone', 'invoicing' ),
287
+                                        'label'       => __('Phone', 'invoicing'),
288 288
                                         'label_type'  => 'vertical',
289 289
                                         'placeholder' => '0493 18 45822',
290 290
                                         'class'       => 'form-control-sm',
291
-                                        'value'       => $invoice->get_phone( 'edit' ),
291
+                                        'value'       => $invoice->get_phone('edit'),
292 292
                                     )
293 293
                                 );
294 294
                             ?>
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-payment-meta.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Invoice_Payment_Meta {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the invoice.
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the invoice.
27
-        $invoice = new WPInv_Invoice( $post );
27
+        $invoice = new WPInv_Invoice($post);
28 28
 
29 29
         ?>
30 30
 
@@ -45,10 +45,10 @@  discard block
 block discarded – undo
45 45
                                 'type'        => 'text',
46 46
                                 'id'          => 'wpinv_key',
47 47
                                 'name'        => 'wpinv_key',
48
-                                'label'       => __( 'Invoice Key:', 'invoicing' ),
48
+                                'label'       => __('Invoice Key:', 'invoicing'),
49 49
                                 'label_type'  => 'vertical',
50 50
                                 'class'       => 'form-control-sm',
51
-                                'value'       => $invoice->get_key( 'edit' ),
51
+                                'value'       => $invoice->get_key('edit'),
52 52
                                 'extra_attributes' => array(
53 53
                                     'onclick'  => 'this.select();',
54 54
                                     'readonly' => 'true',
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
                                 'type'        => 'text',
63 63
                                 'id'          => 'wpinv_view_url',
64 64
                                 'name'        => 'wpinv_view_url',
65
-                                'label'       => __( 'Invoice URL:', 'invoicing' ),
65
+                                'label'       => __('Invoice URL:', 'invoicing'),
66 66
                                 'label_type'  => 'vertical',
67 67
                                 'class'       => 'form-control-sm',
68 68
                                 'value'       => $invoice->get_view_url(),
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
                         );
75 75
 
76 76
                         // If the invoice is paid...
77
-                        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
77
+                        if ($invoice->is_paid() || $invoice->is_refunded()) {
78 78
 
79 79
                             // Payment date.
80 80
                             echo aui()->input(
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
                                     'type'        => 'datepicker',
83 83
                                     'id'          => 'wpinv_date_completed',
84 84
                                     'name'        => 'date_completed',
85
-                                    'label'       => __( 'Payment Date:', 'invoicing' ),
85
+                                    'label'       => __('Payment Date:', 'invoicing'),
86 86
                                     'label_type'  => 'vertical',
87 87
                                     'placeholder' => 'YYYY-MM-DD 00:00',
88 88
                                     'class'       => 'form-control-sm',
89
-                                    'value'       => $invoice->get_date_completed( 'edit' ),
89
+                                    'value'       => $invoice->get_date_completed('edit'),
90 90
                                     'extra_attributes' => array(
91 91
                                         'data-enable-time' => 'true',
92 92
                                         'data-time_24hr'   => 'true',
@@ -101,10 +101,10 @@  discard block
 block discarded – undo
101 101
                                     'type'        => 'text',
102 102
                                     'id'          => 'wpinv_gateway',
103 103
                                     'name'        => 'wpinv_gateway',
104
-                                    'label'       => __( 'Gateway:', 'invoicing' ),
104
+                                    'label'       => __('Gateway:', 'invoicing'),
105 105
                                     'label_type'  => 'vertical',
106 106
                                     'class'       => 'form-control-sm',
107
-                                    'value'       => wpinv_get_gateway_admin_label( $invoice->get_gateway( 'edit' ) ),
107
+                                    'value'       => wpinv_get_gateway_admin_label($invoice->get_gateway('edit')),
108 108
                                     'extra_attributes' => array(
109 109
                                         'onclick'  => 'this.select();',
110 110
                                         'readonly' => 'true',
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
                                     'type'        => 'text',
119 119
                                     'id'          => 'wpinv_transaction_id',
120 120
                                     'name'        => 'wpinv_transaction_id',
121
-                                    'label'       => __( 'Transaction ID:', 'invoicing' ),
121
+                                    'label'       => __('Transaction ID:', 'invoicing'),
122 122
                                     'label_type'  => 'vertical',
123 123
                                     'class'       => 'form-control-sm',
124
-                                    'value'       => $invoice->get_transaction_id( 'edit' ),
125
-                                    'help_text'   => apply_filters( 'wpinv_invoice_transaction_link_' . $invoice->get_gateway( 'edit' ), $invoice->get_transaction_id(), $invoice ),
124
+                                    'value'       => $invoice->get_transaction_id('edit'),
125
+                                    'help_text'   => apply_filters('wpinv_invoice_transaction_link_' . $invoice->get_gateway('edit'), $invoice->get_transaction_id(), $invoice),
126 126
                                     'extra_attributes' => array(
127 127
                                         'onclick'  => 'this.select();',
128 128
                                         'readonly' => 'true',
@@ -136,10 +136,10 @@  discard block
 block discarded – undo
136 136
                                     'type'        => 'text',
137 137
                                     'id'          => 'wpinv_currency',
138 138
                                     'name'        => 'wpinv_currency',
139
-                                    'label'       => __( 'Currency:', 'invoicing' ),
139
+                                    'label'       => __('Currency:', 'invoicing'),
140 140
                                     'label_type'  => 'vertical',
141 141
                                     'class'       => 'form-control-sm',
142
-                                    'value'       => $invoice->get_currency( 'edit' ),
142
+                                    'value'       => $invoice->get_currency('edit'),
143 143
                                     'extra_attributes' => array(
144 144
                                         'onclick'  => 'this.select();',
145 145
                                         'readonly' => 'true',
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
                                     'type'        => 'text',
156 156
                                     'id'          => 'wpinv_payment_url',
157 157
                                     'name'        => 'wpinv_payment_url',
158
-                                    'label'       => __( 'Payment URL:', 'invoicing' ),
158
+                                    'label'       => __('Payment URL:', 'invoicing'),
159 159
                                     'label_type'  => 'vertical',
160 160
                                     'class'       => 'form-control-sm',
161 161
                                     'value'       => $invoice->get_checkout_payment_url(),
@@ -171,13 +171,13 @@  discard block
 block discarded – undo
171 171
                                 array(
172 172
                                     'id'               => 'wpinv_gateway',
173 173
                                     'name'             => 'wpinv_gateway',
174
-                                    'label'            => __( 'Gateway:', 'invoicing' ),
174
+                                    'label'            => __('Gateway:', 'invoicing'),
175 175
                                     'label_type'       => 'vertical',
176
-                                    'placeholder'      => __( 'Select Gateway', 'invoicing' ),
177
-                                    'value'            => $invoice->get_gateway( 'edit' ),
176
+                                    'placeholder'      => __('Select Gateway', 'invoicing'),
177
+                                    'value'            => $invoice->get_gateway('edit'),
178 178
                                     'select2'          => true,
179 179
                                     'data-allow-clear' => 'false',
180
-                                    'options'          => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ),
180
+                                    'options'          => wp_list_pluck(wpinv_get_enabled_payment_gateways(true), 'admin_label'),
181 181
                                 )
182 182
                             );
183 183
 
@@ -186,11 +186,11 @@  discard block
 block discarded – undo
186 186
                                 array(
187 187
                                     'id'          => 'wpinv_currency',
188 188
                                     'name'        => 'wpinv_currency',
189
-                                    'label'       => __( 'Currency', 'invoicing' ),
189
+                                    'label'       => __('Currency', 'invoicing'),
190 190
                                     'label_type'  => 'vertical',
191
-                                    'placeholder' => __( 'Select Invoice Currency', 'invoicing' ),
191
+                                    'placeholder' => __('Select Invoice Currency', 'invoicing'),
192 192
                                     'class'       => 'form-control-sm',
193
-                                    'value'       => $invoice->get_currency( 'edit' ),
193
+                                    'value'       => $invoice->get_currency('edit'),
194 194
                                     'required'    => false,
195 195
                                     'data-allow-clear' => 'false',
196 196
                                     'select2'          => true,
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-invoice-details.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -1,93 +1,93 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Details {
8 8
     
9
-    public static function resend_invoice( $post ) {
9
+    public static function resend_invoice($post) {
10 10
         global $wpi_mb_invoice;
11 11
         
12
-        if ( empty( $wpi_mb_invoice ) ) {
12
+        if (empty($wpi_mb_invoice)) {
13 13
             return;
14 14
         }
15 15
         
16 16
         $text = array(
17
-            'message'       => esc_attr__( 'This will send a copy of the invoice to the customer&#8217;s email address.', 'invoicing' ),
18
-            'button_text'   =>  __( 'Resend Invoice', 'invoicing' ),
17
+            'message'       => esc_attr__('This will send a copy of the invoice to the customer&#8217;s email address.', 'invoicing'),
18
+            'button_text'   =>  __('Resend Invoice', 'invoicing'),
19 19
         );
20 20
             
21 21
         $text = apply_filters('wpinv_resend_invoice_metabox_text', $text);
22
-        do_action( 'wpinv_metabox_resend_invoice_before', $wpi_mb_invoice );
22
+        do_action('wpinv_metabox_resend_invoice_before', $wpi_mb_invoice);
23 23
 
24
-        if ( $email = $wpi_mb_invoice->get_email() ) {
24
+        if ($email = $wpi_mb_invoice->get_email()) {
25 25
             $email_actions = array();
26
-            $email_actions['email_url']      = remove_query_arg( 'wpinv-message', add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) );
27
-            $email_actions['reminder_url']   = add_query_arg( array( 'wpi_action' => 'send_reminder', 'invoice_id' => $post->ID ) );
26
+            $email_actions['email_url']      = remove_query_arg('wpinv-message', add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID)));
27
+            $email_actions['reminder_url']   = add_query_arg(array('wpi_action' => 'send_reminder', 'invoice_id' => $post->ID));
28 28
             
29
-            $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions );
29
+            $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions);
30 30
         ?>
31 31
         <p class="wpi-meta-row wpi-resend-info"><?php echo $text['message']; ?></p>
32
-        <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url( $email_actions['email_url'] ); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p>
33
-        <?php if ( wpinv_get_option( 'overdue_active' ) && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ( $due_date = $wpi_mb_invoice->get_due_date() ) ) { ?>
34
-        <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e( 'Send overdue reminder notification to customer', 'invoicing' ); ?>" href="<?php echo esc_url( $email_actions['reminder_url'] ); ?>" class="button button-secondary"><?php esc_attr_e( 'Send Reminder', 'invoicing' ); ?></a></p>
32
+        <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url($email_actions['email_url']); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p>
33
+        <?php if (wpinv_get_option('overdue_active') && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ($due_date = $wpi_mb_invoice->get_due_date())) { ?>
34
+        <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e('Send overdue reminder notification to customer', 'invoicing'); ?>" href="<?php echo esc_url($email_actions['reminder_url']); ?>" class="button button-secondary"><?php esc_attr_e('Send Reminder', 'invoicing'); ?></a></p>
35 35
         <?php } ?>
36 36
         <?php
37 37
         }
38 38
         
39
-        do_action( 'wpinv_metabox_resend_invoice_after', $wpi_mb_invoice );
39
+        do_action('wpinv_metabox_resend_invoice_after', $wpi_mb_invoice);
40 40
     }
41 41
     
42
-    public static function subscriptions( $post ) {
43
-        $invoice = wpinv_get_invoice( $post->ID );
42
+    public static function subscriptions($post) {
43
+        $invoice = wpinv_get_invoice($post->ID);
44 44
 
45
-        if ( ! empty( $invoice ) && $invoice->is_recurring() && $invoice->is_parent() ) {
46
-            $subscription = wpinv_get_subscription( $invoice );
45
+        if (!empty($invoice) && $invoice->is_recurring() && $invoice->is_parent()) {
46
+            $subscription = wpinv_get_subscription($invoice);
47 47
 
48
-            if ( empty( $subscription ) ) {
48
+            if (empty($subscription)) {
49 49
                 ?>
50
-                <p class="wpi-meta-row"><?php echo wp_sprintf( __( 'New Subscription will be created when customer will checkout and pay the invoice. Go to: %sSubscriptions%s', 'invoicing' ), '<a href="' . admin_url( 'admin.php?page=wpinv-subscriptions' ).'">', '</a>' ); ?></p>
50
+                <p class="wpi-meta-row"><?php echo wp_sprintf(__('New Subscription will be created when customer will checkout and pay the invoice. Go to: %sSubscriptions%s', 'invoicing'), '<a href="' . admin_url('admin.php?page=wpinv-subscriptions') . '">', '</a>'); ?></p>
51 51
                 <?php
52 52
                 return;
53 53
             }
54
-            $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $subscription->period, $subscription->frequency );
55
-            $billing = wpinv_price(wpinv_format_amount( $subscription->recurring_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) ) . ' / ' . $frequency;
56
-            $initial = wpinv_price(wpinv_format_amount( $subscription->initial_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) );
54
+            $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($subscription->period, $subscription->frequency);
55
+            $billing = wpinv_price(wpinv_format_amount($subscription->recurring_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id)) . ' / ' . $frequency;
56
+            $initial = wpinv_price(wpinv_format_amount($subscription->initial_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id));
57 57
             $payments = $subscription->get_child_payments();
58 58
             ?>
59 59
             <p class="wpi-meta-row wpi-sub-label <?php echo 'status-' . $subscription->status; ?>"><?php _e('Recurring Payment', 'invoicing'); ?></p>
60
-            <?php if ( ! empty( $subscription ) && ! empty( $subscription->id ) ) { ?>
60
+            <?php if (!empty($subscription) && !empty($subscription->id)) { ?>
61 61
                 <p class="wpi-meta-row wpi-sub-id">
62
-                    <label><?php _e( 'Subscription ID:', 'invoicing' ); ?> </label><a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $subscription->id ) ); ?>" title="<?php esc_attr_e( 'View or edit subscription', 'invoicing' ); ?>" target="_blank"><?php echo $subscription->id; ?></a></p>
62
+                    <label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $subscription->id)); ?>" title="<?php esc_attr_e('View or edit subscription', 'invoicing'); ?>" target="_blank"><?php echo $subscription->id; ?></a></p>
63 63
             <?php } ?>
64 64
             <p class="wpi-meta-row wpi-bill-cycle">
65
-                <label><?php _e( 'Billing Cycle:', 'invoicing'); ?> </label><?php printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); ?>
65
+                <label><?php _e('Billing Cycle:', 'invoicing'); ?> </label><?php printf(_x('%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing'), $initial, $billing); ?>
66 66
             </p>
67 67
             <p class="wpi-meta-row wpi-billed-times">
68
-                <label><?php _e( 'Times Billed:', 'invoicing' ); ?> </label><?php echo $subscription->get_times_billed() . ' / ' . ( ( $subscription->bill_times == 0 ) ? 'Until Cancelled' : $subscription->bill_times ); ?>
68
+                <label><?php _e('Times Billed:', 'invoicing'); ?> </label><?php echo $subscription->get_times_billed() . ' / ' . (($subscription->bill_times == 0) ? 'Until Cancelled' : $subscription->bill_times); ?>
69 69
             </p>
70 70
             <p class="wpi-meta-row wpi-start-date">
71
-                <label><?php _e( 'Start Date:', 'invoicing' ); ?> </label><?php echo date_i18n( get_option( 'date_format' ), strtotime( $subscription->created, current_time( 'timestamp' ) ) ); ?>
71
+                <label><?php _e('Start Date:', 'invoicing'); ?> </label><?php echo date_i18n(get_option('date_format'), strtotime($subscription->created, current_time('timestamp'))); ?>
72 72
             </p>
73 73
             <p class="wpi-meta-row wpi-end-date">
74
-                <label><?php echo ( 'trialling' == $subscription->status ? __( 'Trialling Until:', 'invoicing' ) : __( 'Expiration Date:', 'invoicing' ) ); ?> </label><?php echo date_i18n( get_option( 'date_format' ), strtotime( $subscription->expiration, current_time( 'timestamp' ) ) ); ?>
74
+                <label><?php echo ('trialling' == $subscription->status ? __('Trialling Until:', 'invoicing') : __('Expiration Date:', 'invoicing')); ?> </label><?php echo date_i18n(get_option('date_format'), strtotime($subscription->expiration, current_time('timestamp'))); ?>
75 75
             </p>
76
-            <?php if ( $subscription->status ) { ?>
76
+            <?php if ($subscription->status) { ?>
77 77
                 <p class="wpi-meta-row wpi-sub-status">
78
-                    <label><?php _e( 'Subscription Status:', 'invoicing'); ?> </label><?php echo $subscription->get_status_label(); ?>
78
+                    <label><?php _e('Subscription Status:', 'invoicing'); ?> </label><?php echo $subscription->get_status_label(); ?>
79 79
                 </p>
80 80
             <?php } ?>
81
-            <?php if ( !empty( $payments ) ) { ?>
82
-                <p><strong><?php _e( 'Renewal Payments:', 'invoicing' ); ?></strong></p>
81
+            <?php if (!empty($payments)) { ?>
82
+                <p><strong><?php _e('Renewal Payments:', 'invoicing'); ?></strong></p>
83 83
                 <ul id="wpi-sub-payments">
84
-                <?php foreach ( $payments as $payment ) {
84
+                <?php foreach ($payments as $payment) {
85 85
                     $invoice_id = $payment->ID;
86 86
                     ?>
87 87
                     <li>
88
-                        <a href="<?php echo esc_url( get_edit_post_link( $invoice_id ) ); ?>"><?php echo wpinv_get_invoice_number( $invoice_id ); ?></a>&nbsp;&ndash;&nbsp;
89
-                        <span><?php echo wpinv_get_invoice_date( $invoice_id ); ?>&nbsp;&ndash;&nbsp;</span>
90
-                        <span><?php echo wpinv_payment_total( $invoice_id, true ); ?></span>
88
+                        <a href="<?php echo esc_url(get_edit_post_link($invoice_id)); ?>"><?php echo wpinv_get_invoice_number($invoice_id); ?></a>&nbsp;&ndash;&nbsp;
89
+                        <span><?php echo wpinv_get_invoice_date($invoice_id); ?>&nbsp;&ndash;&nbsp;</span>
90
+                        <span><?php echo wpinv_payment_total($invoice_id, true); ?></span>
91 91
                     </li>
92 92
                 <?php } ?>
93 93
                 </ul>
@@ -95,16 +95,16 @@  discard block
 block discarded – undo
95 95
         }
96 96
     }
97 97
     
98
-    public static function renewals( $post ) {
99
-        $invoice = wpinv_get_invoice( $post->ID );
98
+    public static function renewals($post) {
99
+        $invoice = wpinv_get_invoice($post->ID);
100 100
         
101
-        if ( wpinv_is_subscription_payment( $invoice ) ) {
102
-            $parent_url = get_edit_post_link( $invoice->parent_invoice );
103
-            $parent_id  = wpinv_get_invoice_number( $invoice->parent_invoice );
104
-            $subscription = wpinv_get_subscription( $invoice );
101
+        if (wpinv_is_subscription_payment($invoice)) {
102
+            $parent_url = get_edit_post_link($invoice->parent_invoice);
103
+            $parent_id  = wpinv_get_invoice_number($invoice->parent_invoice);
104
+            $subscription = wpinv_get_subscription($invoice);
105 105
         ?>
106
-        <?php if ( ! empty( $subscription ) ) { ?><p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $subscription->id ) ); ?>" title="<?php esc_attr_e( 'View or edit subscription', 'invoicing' ); ?>" target="_blank"><?php echo $subscription->id; ?></a></p><?php } ?>
107
-        <p class="wpi-meta-row wpi-parent-id"><label><?php _e( 'Parent Invoice:', 'invoicing' );?> </label><a href="<?php echo esc_url( $parent_url ); ?>"><?php echo $parent_id; ?></a></p>
106
+        <?php if (!empty($subscription)) { ?><p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $subscription->id)); ?>" title="<?php esc_attr_e('View or edit subscription', 'invoicing'); ?>" target="_blank"><?php echo $subscription->id; ?></a></p><?php } ?>
107
+        <p class="wpi-meta-row wpi-parent-id"><label><?php _e('Parent Invoice:', 'invoicing'); ?> </label><a href="<?php echo esc_url($parent_url); ?>"><?php echo $parent_id; ?></a></p>
108 108
         <?php
109 109
         }
110 110
     }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-details.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Invoice_Details {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the invoice.
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,13 +21,13 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the invoice.
27
-        $invoice = new WPInv_Invoice( $post );
27
+        $invoice = new WPInv_Invoice($post);
28 28
 
29 29
         // Nonce field.
30
-        wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ;
30
+        wp_nonce_field('wpinv_details', 'wpinv_details_nonce');
31 31
 
32 32
 
33 33
         ?>
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
 
47 47
                 <div class="bsui" style="margin-top: 1.5rem" id="gdmbx2-metabox-wpinv_details">
48 48
 
49
-                    <?php if ( ! $invoice->is_draft() ) : ?>
49
+                    <?php if (!$invoice->is_draft()) : ?>
50 50
                         <div class="form-group">
51
-                            <strong><?php _e( 'Viewed by Customer:', 'invoicing' );?></strong>
52
-                            <?php ( $invoice->get_is_viewed() ) ? _e( 'Yes', 'invoicing' ) : _e( 'No', 'invoicing' ); ?>
51
+                            <strong><?php _e('Viewed by Customer:', 'invoicing'); ?></strong>
52
+                            <?php ($invoice->get_is_viewed()) ? _e('Yes', 'invoicing') : _e('No', 'invoicing'); ?>
53 53
                         </div>
54 54
                     <?php endif; ?>
55 55
 
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
                                 'type'        => 'datepicker',
62 62
                                 'id'          => 'wpinv_date_created',
63 63
                                 'name'        => 'date_created',
64
-                                'label'       => __( 'Invoice Date:', 'invoicing' ) . getpaid_get_help_tip( __( 'The date this invoice was created. This allows you to backdate an invoice.', 'invoicing' ) ),
64
+                                'label'       => __('Invoice Date:', 'invoicing') . getpaid_get_help_tip(__('The date this invoice was created. This allows you to backdate an invoice.', 'invoicing')),
65 65
                                 'label_type'  => 'vertical',
66 66
                                 'placeholder' => 'YYYY-MM-DD 00:00',
67 67
                                 'class'       => 'form-control-sm',
68
-                                'value'       => $invoice->get_date_created( 'edit' ),
68
+                                'value'       => $invoice->get_date_created('edit'),
69 69
                                 'extra_attributes' => array(
70 70
                                     'data-enable-time' => 'true',
71 71
                                     'data-time_24hr'   => 'true',
@@ -76,37 +76,37 @@  discard block
 block discarded – undo
76 76
                         );
77 77
 
78 78
                         // Due date.
79
-                        if ( $invoice->is_type( 'invoice' ) && wpinv_get_option( 'overdue_active' ) && ( $invoice->needs_payment() || $invoice->is_draft() ) ) {
79
+                        if ($invoice->is_type('invoice') && wpinv_get_option('overdue_active') && ($invoice->needs_payment() || $invoice->is_draft())) {
80 80
 
81 81
                             echo aui()->input(
82 82
                                 array(
83 83
                                     'type'        => 'text',
84 84
                                     'id'          => 'wpinv_due_date',
85 85
                                     'name'        => 'wpinv_due_date',
86
-                                    'label'       => __( 'Due Date:', 'invoicing' ) . getpaid_get_help_tip( __( 'Leave blank to disable automated reminder emails for this invoice.', 'invoicing' ) ),
86
+                                    'label'       => __('Due Date:', 'invoicing') . getpaid_get_help_tip(__('Leave blank to disable automated reminder emails for this invoice.', 'invoicing')),
87 87
                                     'label_type'  => 'vertical',
88
-                                    'placeholder' => __( 'No due date', 'invoicing' ),
88
+                                    'placeholder' => __('No due date', 'invoicing'),
89 89
                                     'class'       => 'form-control-sm',
90
-                                    'value'       => $invoice->get_due_date( 'edit' ),
90
+                                    'value'       => $invoice->get_due_date('edit'),
91 91
                                 )
92 92
                             );
93 93
 
94 94
                         }
95 95
 
96
-                        do_action( 'wpinv_meta_box_details_after_due_date', $invoice->get_id() );
96
+                        do_action('wpinv_meta_box_details_after_due_date', $invoice->get_id());
97 97
                         
98 98
                         // Status.
99 99
                         echo aui()->select(
100 100
                             array(
101 101
                                 'id'               => 'wpinv_status',
102 102
                                 'name'             => 'wpinv_status',
103
-                                'label'            => __( 'Invoice Status:', 'invoicing' ),
103
+                                'label'            => __('Invoice Status:', 'invoicing'),
104 104
                                 'label_type'       => 'vertical',
105
-                                'placeholder'      => __( 'Select Status', 'invoicing' ),
106
-                                'value'            => $invoice->get_status( 'edit' ),
105
+                                'placeholder'      => __('Select Status', 'invoicing'),
106
+                                'value'            => $invoice->get_status('edit'),
107 107
                                 'select2'          => true,
108 108
                                 'data-allow-clear' => 'false',
109
-                                'options'          => wpinv_get_invoice_statuses( true )
109
+                                'options'          => wpinv_get_invoice_statuses(true)
110 110
                             )
111 111
                         );
112 112
 
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
                                 'type'        => 'text',
117 117
                                 'id'          => 'wpinv_number',
118 118
                                 'name'        => 'wpinv_number',
119
-                                'label'       => __( 'Invoice Number:', 'invoicing' ) . getpaid_get_help_tip( __( 'Each invoice number must be unique.', 'invoicing' ) ),
119
+                                'label'       => __('Invoice Number:', 'invoicing') . getpaid_get_help_tip(__('Each invoice number must be unique.', 'invoicing')),
120 120
                                 'label_type'  => 'vertical',
121
-                                'placeholder' => __( 'Autogenerate', 'invoicing' ),
121
+                                'placeholder' => __('Autogenerate', 'invoicing'),
122 122
                                 'class'       => 'form-control-sm',
123
-                                'value'       => $invoice->get_number( 'edit' ),
123
+                                'value'       => $invoice->get_number('edit'),
124 124
                             )
125 125
                         );
126 126
 
@@ -130,25 +130,25 @@  discard block
 block discarded – undo
130 130
                                 'type'        => 'text',
131 131
                                 'id'          => 'wpinv_cc',
132 132
                                 'name'        => 'wpinv_cc',
133
-                                'label'       => __( 'Email CC:', 'invoicing' ) . getpaid_get_help_tip( __( 'Enter a comma separated list of other emails that should be notified about the invoice.', 'invoicing' ) ),
133
+                                'label'       => __('Email CC:', 'invoicing') . getpaid_get_help_tip(__('Enter a comma separated list of other emails that should be notified about the invoice.', 'invoicing')),
134 134
                                 'label_type'  => 'vertical',
135
-                                'placeholder' => __( '[email protected], [email protected]', 'invoicing' ),
135
+                                'placeholder' => __('[email protected], [email protected]', 'invoicing'),
136 136
                                 'class'       => 'form-control-sm',
137
-                                'value'       => $invoice->get_email_cc( 'edit' ),
137
+                                'value'       => $invoice->get_email_cc('edit'),
138 138
                             )
139 139
                         );
140 140
 
141
-                        do_action( 'wpinv_meta_box_details_inner', $invoice->get_id() );
141
+                        do_action('wpinv_meta_box_details_inner', $invoice->get_id());
142 142
 
143 143
                         // Disable taxes.
144
-                        if ( wpinv_use_taxes() && ! ( $invoice->is_paid() || $invoice->is_refunded() ) ) {
144
+                        if (wpinv_use_taxes() && !($invoice->is_paid() || $invoice->is_refunded())) {
145 145
 
146 146
                             echo aui()->input(
147 147
                                 array(
148 148
                                     'id'          => 'wpinv_taxable',
149 149
                                     'name'        => 'disable_taxes',
150 150
                                     'type'        => 'checkbox',
151
-                                    'label'       => __( 'Disable taxes', 'invoicing' ),
151
+                                    'label'       => __('Disable taxes', 'invoicing'),
152 152
                                     'value'       => '1',
153 153
                                     'checked'     => (bool) $invoice->get_disable_taxes(),
154 154
                                 )
@@ -157,17 +157,17 @@  discard block
 block discarded – undo
157 157
                         }
158 158
 
159 159
                         // Apply a discount.
160
-                        if ( $invoice->get_discount_code( 'edit' ) ) {
160
+                        if ($invoice->get_discount_code('edit')) {
161 161
 
162 162
                             echo aui()->input(
163 163
                                 array(
164 164
                                     'type'        => 'text',
165 165
                                     'id'          => 'wpinv_discount_code',
166 166
                                     'name'        => 'wpinv_discount_code',
167
-                                    'label'       => __( 'Discount Code:', 'invoicing' ),
167
+                                    'label'       => __('Discount Code:', 'invoicing'),
168 168
                                     'label_type'  => 'vertical',
169 169
                                     'class'       => 'form-control-sm',
170
-                                    'value'       => $invoice->get_discount_code( 'edit' ),
170
+                                    'value'       => $invoice->get_discount_code('edit'),
171 171
                                     'extra_attributes' => array(
172 172
                                         'onclick'  => 'this.select();',
173 173
                                         'readonly' => 'true',
Please login to merge, or discard this patch.
includes/admin/admin-meta-boxes.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -1,68 +1,68 @@  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' ), 'GetPaid_Meta_Box_Invoice_Details::output', 'wpi_invoice', 'side', 'default' );
26
-    add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', 'wpi_invoice', 'side', 'default' );
25
+    add_meta_box('wpinv-details', __('Invoice Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Details::output', 'wpi_invoice', 'side', 'default');
26
+    add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', 'wpi_invoice', 'side', 'default');
27 27
 
28
-    add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' );
29
-    add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' );
28
+    add_meta_box('wpinv-payment-form-design', __('Payment Form', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal');
29
+    add_meta_box('wpinv-payment-form-info', __('Details', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side');
30 30
    
31
-    add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', 'wpi_invoice', 'normal', 'high' );
32
-    add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Items::output', 'wpi_invoice', 'normal', 'high' );
33
-    add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' );
31
+    add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Address::output', 'wpi_invoice', 'normal', 'high');
32
+    add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Items::output', 'wpi_invoice', 'normal', 'high');
33
+    add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high');
34 34
     
35
-    if ( ! empty( $post->ID ) && get_post_meta( $post->ID, 'payment_form_data', true ) ) {
36
-        add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high' );
35
+    if (!empty($post->ID) && get_post_meta($post->ID, 'payment_form_data', true)) {
36
+        add_meta_box('wpinv-invoice-payment-form-details', __('Payment Form Details', 'invoicing'), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high');
37 37
     }
38 38
 
39 39
 	remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal');
40 40
 }
41
-add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 );
41
+add_action('add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2);
42 42
 
43 43
 /**
44 44
  * Saves meta boxes.
45 45
  */
46
-function wpinv_save_meta_boxes( $post_id, $post ) {
47
-    remove_action( 'save_post', __FUNCTION__ );
46
+function wpinv_save_meta_boxes($post_id, $post) {
47
+    remove_action('save_post', __FUNCTION__);
48 48
 
49 49
     // $post_id and $post are required.
50
-    if ( empty( $post_id ) || empty( $post ) ) {
50
+    if (empty($post_id) || empty($post)) {
51 51
         return;
52 52
     }
53 53
 
54 54
     // Ensure that this user can edit the post.
55
-    if ( ! current_user_can( 'edit_post', $post_id ) ) {
55
+    if (!current_user_can('edit_post', $post_id)) {
56 56
         return;
57 57
     }
58 58
 
59 59
     // Dont' save meta boxes for revisions or autosaves
60
-    if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
60
+    if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
61 61
         return;
62 62
     }
63 63
 
64 64
     // Do not save for ajax requests.
65
-    if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
65
+    if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
66 66
         return;
67 67
     }
68 68
 
@@ -75,46 +75,46 @@  discard block
 block discarded – undo
75 75
     );
76 76
 
77 77
     // Is this our post type?
78
-    if ( empty( $post->post_type ) || ! isset( $post_types_map[ $post->post_type ] ) ) {
78
+    if (empty($post->post_type) || !isset($post_types_map[$post->post_type])) {
79 79
         return;
80 80
     }
81 81
 
82 82
     // Save the post.
83
-    $class = $post_types_map[ $post->post_type ];
84
-    $class::save( $post_id, $_POST, $post );
83
+    $class = $post_types_map[$post->post_type];
84
+    $class::save($post_id, $_POST, $post);
85 85
 
86 86
 }
87
-add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 );
87
+add_action('save_post', 'wpinv_save_meta_boxes', 10, 3);
88 88
 
89 89
 function wpinv_register_item_meta_boxes() {    
90 90
     global $wpinv_euvat;
91 91
 
92 92
     // Item details metabox.
93
-    add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' );
93
+    add_meta_box('wpinv_item_details', __('Item Details', 'invoicing'), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high');
94 94
 
95 95
     // If taxes are enabled, register the tax metabox.
96
-    if ( $wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes() ) {
97
-        add_meta_box( 'wpinv_item_vat', __( 'VAT / Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' );
96
+    if ($wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes()) {
97
+        add_meta_box('wpinv_item_vat', __('VAT / Tax', 'invoicing'), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high');
98 98
     }
99 99
 
100 100
     // Item info.
101
-    add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' );
101
+    add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core');
102 102
     
103 103
 }
104 104
 
105 105
 function wpinv_register_discount_meta_boxes() {
106
-    add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' );
106
+    add_meta_box('wpinv_discount_details', __('Discount Details', 'invoicing'), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high');
107 107
 }
108 108
 
109 109
 /**
110 110
  * Remove trash link from the default form.
111 111
  */
112
-function getpaid_remove_action_link( $actions, $post ) {
113
-    $post = get_post( $post );
114
-    if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) {
115
-        unset( $actions['trash'] );
116
-        unset( $actions['inline hide-if-no-js'] );
112
+function getpaid_remove_action_link($actions, $post) {
113
+    $post = get_post($post);
114
+    if ('wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form()) {
115
+        unset($actions['trash']);
116
+        unset($actions['inline hide-if-no-js']);
117 117
     }
118 118
     return $actions;
119 119
 }
120
-add_filter( 'post_row_actions', 'getpaid_remove_action_link', 10, 2 );
120
+add_filter('post_row_actions', 'getpaid_remove_action_link', 10, 2);
Please login to merge, or discard this patch.