Passed
Push — master ( c90a51...25dd78 )
by Brian
05:26
created

getpaid_remove_action_link()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 7
rs 10
1
<?php
2
// MUST have WordPress.
3
if ( !defined( 'WPINC' ) ) {
4
    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
5
}
6
7
function wpinv_add_meta_boxes( $post_type, $post ) {
8
    global $wpi_mb_invoice;
9
    if ( $post_type == 'wpi_invoice' && !empty( $post->ID ) ) {
10
        $wpi_mb_invoice = wpinv_get_invoice( $post->ID );
11
    }
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' );
15
    }
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' );
19
    }
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' );
23
    }
24
    
25
    add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default' );
26
    add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default' );
27
28
    add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' );
29
    add_meta_box( 'wpinv-payment-form-shortcode', __( 'Shortcode', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_shortcode', 'wpi_payment_form', 'side' );
30
   
31
    add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high' );
32
    add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'WPInv_Meta_Box_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
    
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
    }
38
39
	remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal');
40
}
41
add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 );
42
43
function wpinv_save_meta_boxes( $post_id, $post, $update = false ) {
0 ignored issues
show
Unused Code introduced by
The parameter $update is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

43
function wpinv_save_meta_boxes( $post_id, $post, /** @scrutinizer ignore-unused */ $update = false ) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
44
    remove_action( 'save_post', __FUNCTION__ );
45
    
46
    // $post_id and $post are required
47
    if ( empty( $post_id ) || empty( $post ) ) {
48
        return;
49
    }
50
        
51
    if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) {
52
        return;
53
    }
54
    
55
    // Dont' save meta boxes for revisions or autosaves
56
    if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
57
        return;
58
    }
59
        
60
    if ( $post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote' ) {
61
        if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
62
            return;
63
        }
64
    
65
        if ( isset( $_POST['wpinv_save_invoice'] ) && wp_verify_nonce( $_POST['wpinv_save_invoice'], 'wpinv_save_invoice' ) ) {
66
            WPInv_Meta_Box_Items::save( $post_id, $_POST, $post );
67
        }
68
    } else if ( $post->post_type == 'wpi_item' ) {
69
        // verify nonce
70
        if ( isset( $_POST['wpinv_vat_meta_box_nonce'] ) && wp_verify_nonce( $_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save' ) ) {
71
            $fields                                 = array();
72
            $fields['_wpinv_price']              = 'wpinv_item_price';
73
            $fields['_wpinv_vat_class']          = 'wpinv_vat_class';
74
            $fields['_wpinv_vat_rule']           = 'wpinv_vat_rules';
75
            $fields['_wpinv_type']               = 'wpinv_item_type';
76
            $fields['_wpinv_is_recurring']       = 'wpinv_is_recurring';
77
            $fields['_wpinv_recurring_period']   = 'wpinv_recurring_period';
78
            $fields['_wpinv_recurring_interval'] = 'wpinv_recurring_interval';
79
            $fields['_wpinv_recurring_limit']    = 'wpinv_recurring_limit';
80
            $fields['_wpinv_free_trial']         = 'wpinv_free_trial';
81
            $fields['_wpinv_trial_period']       = 'wpinv_trial_period';
82
            $fields['_wpinv_trial_interval']     = 'wpinv_trial_interval';
83
            $fields['_wpinv_dynamic_pricing']    = 'wpinv_name_your_price';
84
            $fields['_minimum_price']            = 'wpinv_minimum_price';
85
            
86
            if ( !isset( $_POST['wpinv_is_recurring'] ) ) {
87
                $_POST['wpinv_is_recurring'] = 0;
88
            }
89
90
            if ( !isset( $_POST['wpinv_name_your_price'] ) ) {
91
                $_POST['wpinv_name_your_price'] = 0;
92
            }
93
            
94
            if ( !isset( $_POST['wpinv_free_trial'] ) || empty( $_POST['wpinv_is_recurring'] ) ) {
95
                $_POST['wpinv_free_trial'] = 0;
96
            }
97
            
98
            foreach ( $fields as $field => $name ) {
99
                if ( isset( $_POST[ $name ] ) ) {
100
                    $allowed = apply_filters( 'wpinv_item_allowed_save_meta_value', true, $field, $post_id );
101
102
                    if ( !$allowed ) {
103
                        continue;
104
                    }
105
106
                    if ( $field == '_wpinv_price' ) {
107
                        $value = wpinv_sanitize_amount( $_POST[ $name ] );
108
                    } else {
109
                        $value = is_string( $_POST[ $name ] ) ? sanitize_text_field( $_POST[ $name ] ) : $_POST[ $name ];
110
                    }
111
                    
112
                    $value = apply_filters( 'wpinv_item_metabox_save_' . $field, $value, $name );
113
                    update_post_meta( $post_id, $field, $value );
114
                }
115
            }
116
            
117
            if ( !get_post_meta( $post_id, '_wpinv_custom_id', true ) ) {
118
                update_post_meta( $post_id, '_wpinv_custom_id', $post_id );
119
            }
120
        }
121
    }
122
}
123
add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 );
124
125
function wpinv_register_item_meta_boxes() {    
126
    global $wpinv_euvat;
127
    
128
    add_meta_box( 'wpinv_field_prices', __( 'Item Price', 'invoicing' ), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high' );
129
130
    if ( $wpinv_euvat->allow_vat_rules() ) {
131
        add_meta_box( 'wpinv_field_vat_rules', __( 'VAT rules type to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high' );
132
    }
133
    
134
    if ( $wpinv_euvat->allow_vat_classes() ) {
135
        add_meta_box( 'wpinv_field_vat_classes', __( 'VAT rates class to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high' );
136
    }
137
    
138
    add_meta_box( 'wpinv_field_item_shortcode', __( 'Shortcode', 'invoicing' ), 'WPInv_Meta_Box_Items::shortcode', 'wpi_item', 'side', 'core' );
139
    add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core' );
140
    add_meta_box( 'wpinv_field_meta_values', __( 'Item Meta Values', 'invoicing' ), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core' );
141
}
142
143
function wpinv_register_discount_meta_boxes() {
144
    add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' );
145
}
146
147
function wpinv_discount_metabox_details( $post ) {
148
    $discount_id    = $post->ID;
149
    $discount       = wpinv_get_discount( $discount_id );
0 ignored issues
show
Unused Code introduced by
The assignment to $discount is dead and can be removed.
Loading history...
150
    
151
    $type               = wpinv_get_discount_type( $discount_id );
152
    $item_reqs          = wpinv_get_discount_item_reqs( $discount_id );
153
    $excluded_items     = wpinv_get_discount_excluded_items( $discount_id );
154
    $min_total          = wpinv_get_discount_min_total( $discount_id );
155
    $max_total          = wpinv_get_discount_max_total( $discount_id );
156
    $max_uses           = wpinv_get_discount_max_uses( $discount_id );
157
    $single_use         = wpinv_discount_is_single_use( $discount_id );
158
    $recurring          = (bool)wpinv_discount_is_recurring( $discount_id );
159
    $start_date         = wpinv_get_discount_start_date( $discount_id );
160
    $expiration_date    = wpinv_get_discount_expiration( $discount_id );
161
    
162
    if ( ! empty( $start_date ) && strpos( $start_date, '0000' ) === false ) {
163
        $start_time         = strtotime( $start_date );
164
        $start_h            = date_i18n( 'H', $start_time );
165
        $start_m            = date_i18n( 'i', $start_time );
166
        $start_date         = date_i18n( 'Y-m-d', $start_time );
167
    } else {
168
        $start_h            = '00';
169
        $start_m            = '00';
170
    }
171
172
    if ( ! empty( $expiration_date ) && strpos( $expiration_date, '0000' ) === false ) {
173
        $expiration_time    = strtotime( $expiration_date );
174
        $expiration_h       = date_i18n( 'H', $expiration_time );
175
        $expiration_m       = date_i18n( 'i', $expiration_time );
176
        $expiration_date    = date_i18n( 'Y-m-d', $expiration_time );
177
    } else {
178
        $expiration_h       = '23';
179
        $expiration_m       = '59';
180
    }
181
    
182
    $min_total          = $min_total > 0 ? $min_total : '';
183
    $max_total          = $max_total > 0 ? $max_total : '';
184
    $max_uses           = $max_uses > 0 ? $max_uses : '';
185
?>
186
<?php do_action( 'wpinv_discount_form_top', $post ); ?>
187
<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?>
188
<table class="form-table wpi-form-table">
189
    <tbody>
190
        <?php do_action( 'wpinv_discount_form_first', $post ); ?>
191
        <?php do_action( 'wpinv_discount_form_before_code', $post ); ?>
192
        <tr>
193
            <th valign="top" scope="row">
194
                <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label>
195
            </th>
196
            <td>
197
                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required>
0 ignored issues
show
Bug introduced by
It seems like wpinv_get_discount_code($discount_id) can also be of type false; however, parameter $text of esc_attr() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

197
                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( /** @scrutinizer ignore-type */ wpinv_get_discount_code( $discount_id ) ); ?>" required>
Loading history...
198
                <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p>
199
            </td>
200
        </tr>
201
        <?php do_action( 'wpinv_discount_form_before_type', $post ); ?>
202
        <tr>
203
            <th valign="top" scope="row">
204
                <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label>
205
            </th>
206
            <td>
207
                <select id="wpinv_discount_type" name="type" class="medium-text wpi_select2">
208
                    <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?>
209
                    <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option>
210
                    <?php } ?>
211
                </select>
212
                <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p>
213
            </td>
214
        </tr>
215
        <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?>
216
        <tr>
217
            <th valign="top" scope="row">
218
                <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label>
219
            </th>
220
            <td>
221
                <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr( wpinv_get_discount_amount( $discount_id ) ); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol() ;?></font>
222
                <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p>
223
                <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p>
224
            </td>
225
        </tr>
226
        <?php do_action( 'wpinv_discount_form_before_items', $post ); ?>
227
        <tr>
228
            <th valign="top" scope="row">
229
                <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label>
230
            </th>
231
            <td>
232
                <p><?php echo wpinv_item_dropdown( array(
233
                        'name'              => 'items[]',
234
                        'id'                => 'items',
235
                        'selected'          => $item_reqs,
236
                        'multiple'          => true,
237
                        'class'             => 'medium-text wpi_select2',
238
                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
239
                        'show_recurring'    => true,
240
                    ) ); ?>
241
                </p>
242
                <p class="description"><?php _e( 'Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing' ); ?></p>
243
            </td>
244
        </tr>
245
        <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?>
246
        <tr>
247
            <th valign="top" scope="row">
248
                <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label>
249
            </th>
250
            <td>
251
                <p><?php echo wpinv_item_dropdown( array(
252
                        'name'              => 'excluded_items[]',
253
                        'id'                => 'excluded_items',
254
                        'selected'          => $excluded_items,
255
                        'multiple'          => true,
256
                        'class'             => 'medium-text wpi_select2',
257
                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
258
                        'show_recurring'    => true,
259
                    ) ); ?>
260
                </p>
261
                <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p>
262
            </td>
263
        </tr>
264
        <?php do_action( 'wpinv_discount_form_before_start', $post ); ?>
265
        <tr>
266
            <th valign="top" scope="row">
267
                <label for="wpinv_discount_start"><?php _e( 'Start Date', 'invoicing' ); ?></label>
268
            </th>
269
            <td>
270
                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr( $start_date ); ?>"> @ <select id="wpinv_discount_start_h" name="start_h">
271
                    <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
272
                    <option value="<?php echo $value;?>" <?php selected( $value, $start_h ); ?>><?php echo $value;?></option>
273
                    <?php } ?>
274
                </select> : <select id="wpinv_discount_start_m" name="start_m">
275
                    <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
276
                    <option value="<?php echo $value;?>" <?php selected( $value, $start_m ); ?>><?php echo $value;?></option>
277
                    <?php } ?>
278
                </select>
279
                <p class="description"><?php _e( 'Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?></p>
280
            </td>
281
        </tr>
282
        <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?>
283
        <tr>
284
            <th valign="top" scope="row">
285
                <label for="wpinv_discount_expiration"><?php _e( 'Expiration Date', 'invoicing' ); ?></label>
286
            </th>
287
            <td>
288
                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr( $expiration_date ); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h">
289
                    <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
290
                    <option value="<?php echo $value;?>" <?php selected( $value, $expiration_h ); ?>><?php echo $value;?></option>
291
                    <?php } ?>
292
                </select> : <select id="wpinv_discount_expiration_m" name="expiration_m">
293
                    <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
294
                    <option value="<?php echo $value;?>" <?php selected( $value, $expiration_m ); ?>><?php echo $value;?></option>
295
                    <?php } ?>
296
                </select>
297
                <p class="description"><?php _e( 'Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing' ); ?></p>
298
            </td>
299
        </tr>
300
        <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?>
301
        <tr>
302
            <th valign="top" scope="row">
303
                <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label>
304
            </th>
305
            <td>
306
                <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>">
307
                <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
308
            </td>
309
        </tr>
310
        <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?>
311
        <tr>
312
            <th valign="top" scope="row">
313
                <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label>
314
            </th>
315
            <td>
316
                <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>">
317
                <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
318
            </td>
319
        </tr>
320
        <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?>
321
        <tr>
322
            <th valign="top" scope="row">
323
                <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label>
324
            </th>
325
            <td>
326
                <select id="wpinv_discount_recurring" name="recurring" class="medium-text wpi_select2">
327
                    <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option>
328
                    <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option>
329
                </select>
330
                <p class="description"><?php _e( '<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing' ); ?></p>
331
            </td>
332
        </tr>
333
        <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?>
334
        <tr>
335
            <th valign="top" scope="row">
336
                <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label>
337
            </th>
338
            <td>
339
                <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>">
340
                <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p>
341
            </td>
342
        </tr>
343
        <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?>
344
        <tr>
345
            <th valign="top" scope="row">
346
                <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label>
347
            </th>
348
            <td>
349
                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>>
350
                <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span>
351
            </td>
352
        </tr>
353
        <?php do_action( 'wpinv_discount_form_last', $post ); ?>
354
    </tbody>
355
</table>
356
<?php do_action( 'wpinv_discount_form_bottom', $post ); ?>
357
    <?php
358
}
359
360
function wpinv_discount_metabox_save( $post_id, $post, $update = false ) {
361
    $post_type = !empty( $post ) ? $post->post_type : '';
362
    
363
    if ( $post_type != 'wpi_discount' ) {
364
        return;
365
    }
366
    
367
    if ( !isset( $_POST['wpinv_discount_metabox_nonce'] ) || ( isset( $_POST['wpinv_discount_metabox_nonce'] ) && !wp_verify_nonce( $_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce' ) ) ) {
368
        return;
369
    }
370
    
371
    if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
372
        return;
373
    }
374
    
375
    if ( !current_user_can( wpinv_get_capability(), $post_id ) ) {
376
        return;
377
    }
378
    
379
    if ( !empty( $_POST['start'] ) && isset( $_POST['start_h'] ) && isset( $_POST['start_m'] ) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '' ) {
380
        $_POST['start'] = $_POST['start'] . ' ' . $_POST['start_h'] . ':' . $_POST['start_m'];
381
    }
382
383
    if ( !empty( $_POST['expiration'] ) && isset( $_POST['expiration_h'] ) && isset( $_POST['expiration_m'] ) ) {
384
        $_POST['expiration'] = $_POST['expiration'] . ' ' . $_POST['expiration_h'] . ':' . $_POST['expiration_m'];
385
    }
386
    
387
    return /** @scrutinizer ignore-call */ wpinv_store_discount( $post_id, $_POST, $post, $update );
388
}
389
add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 );
390
391
/**
392
 * Remove trash link from the default form.
393
 */
394
function getpaid_remove_action_link( $actions, $post ) {
395
    $post = get_post( $post );
396
    if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) {
397
        unset( $actions['trash'] );
398
        unset( $actions['inline hide-if-no-js'] );
399
    }
400
    return $actions;
401
}
402
add_filter( 'post_row_actions', 'getpaid_remove_action_link', 10, 2 );
403