| @@ -8,7 +8,7 @@ discard block | ||
| 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 | ||
| 17 | 17 |  class GetPaid_Meta_Box_Item_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 item. | 
| @@ -270,35 +270,35 @@ discard block | ||
| 270 | 270 | } | 
| 271 | 271 | |
| 272 | 272 | /** | 
| 273 | - * Save meta box data. | |
| 274 | - * | |
| 275 | - * @param int $post_id | |
| 276 | - */ | |
| 277 | -	public static function save( $post_id ) { | |
| 273 | + * Save meta box data. | |
| 274 | + * | |
| 275 | + * @param int $post_id | |
| 276 | + */ | |
| 277 | +    public static function save( $post_id ) { | |
| 278 | 278 | |
| 279 | 279 | // Prepare the item. | 
| 280 | 280 | $item = new WPInv_Item( $post_id ); | 
| 281 | 281 | |
| 282 | 282 | // Load new data. | 
| 283 | 283 | $item->set_props( | 
| 284 | - array( | |
| 285 | - 'price' => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null, | |
| 286 | - 'vat_rule' => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null, | |
| 287 | - 'vat_class' => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null, | |
| 288 | - 'type' => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null, | |
| 289 | - 'is_dynamic_pricing' => ! empty( $_POST['wpinv_name_your_price'] ), | |
| 284 | + array( | |
| 285 | + 'price' => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null, | |
| 286 | + 'vat_rule' => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null, | |
| 287 | + 'vat_class' => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null, | |
| 288 | + 'type' => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null, | |
| 289 | + 'is_dynamic_pricing' => ! empty( $_POST['wpinv_name_your_price'] ), | |
| 290 | 290 | 'minimum_price' => isset( $_POST['wpinv_minimum_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_minimum_price'] ) : null, | 
| 291 | - 'is_recurring' => ! empty( $_POST['wpinv_is_recurring'] ), | |
| 292 | - 'recurring_period' => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null, | |
| 293 | - 'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1, | |
| 294 | - 'recurring_limit' => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null, | |
| 295 | - 'is_free_trial' => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null, | |
| 296 | - 'trial_period' => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null, | |
| 297 | - 'trial_interval' => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null, | |
| 298 | - ) | |
| 291 | + 'is_recurring' => ! empty( $_POST['wpinv_is_recurring'] ), | |
| 292 | + 'recurring_period' => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null, | |
| 293 | + 'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1, | |
| 294 | + 'recurring_limit' => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null, | |
| 295 | + 'is_free_trial' => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null, | |
| 296 | + 'trial_period' => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null, | |
| 297 | + 'trial_interval' => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null, | |
| 298 | + ) | |
| 299 | 299 | ); | 
| 300 | 300 | |
| 301 | - $item->save(); | |
| 302 | - do_action( 'getpaid_item_metabox_save', $post_id, $item ); | |
| 303 | - } | |
| 301 | + $item->save(); | |
| 302 | + do_action( 'getpaid_item_metabox_save', $post_id, $item ); | |
| 303 | + } | |
| 304 | 304 | } | 
| @@ -7,7 +7,7 @@ discard block | ||
| 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 | ||
| 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( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); | |
| 30 | +        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_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 | <style> | 
| 46 | 46 | #poststuff .input-group-text, | 
| 47 | 47 |              #poststuff .form-control { | 
| @@ -55,21 +55,21 @@ discard block | ||
| 55 | 55 | </style> | 
| 56 | 56 | <div class='bsui' style='max-width: 600px;padding-top: 10px;'> | 
| 57 | 57 | |
| 58 | - <?php do_action( 'wpinv_item_details_metabox_before_price', $item ); ?> | |
| 58 | +            <?php do_action('wpinv_item_details_metabox_before_price', $item); ?> | |
| 59 | 59 | <div class="form-group row"> | 
| 60 | - <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e( 'Item Price', 'invoicing' )?></span></label> | |
| 60 | +                <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e('Item Price', 'invoicing')?></span></label> | |
| 61 | 61 | <div class="col-sm-8"> | 
| 62 | 62 | <div class="row"> | 
| 63 | 63 | <div class="col-sm-4 getpaid-price-input"> | 
| 64 | 64 | <div class="input-group input-group-sm"> | 
| 65 | - <?php if( 'left' == $position ) : ?> | |
| 65 | +                                <?php if ('left' == $position) : ?> | |
| 66 | 66 | <div class="input-group-prepend"> | 
| 67 | 67 | <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> | 
| 68 | 68 | </div> | 
| 69 | 69 | <?php endif; ?> | 
| 70 | - <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_price( 'edit' ) ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control"> | |
| 70 | +                                <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_price('edit'))); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control"> | |
| 71 | 71 | |
| 72 | - <?php if( 'left' != $position ) : ?> | |
| 72 | +                                <?php if ('left' != $position) : ?> | |
| 73 | 73 | <div class="input-group-append"> | 
| 74 | 74 | <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> | 
| 75 | 75 | </div> | 
| @@ -79,10 +79,10 @@ discard block | ||
| 79 | 79 | </div> | 
| 80 | 80 | <div class="col-sm-4 wpinv_show_if_recurring"> | 
| 81 | 81 | <?php | 
| 82 | - _e( 'every' ); | |
| 82 | +                                _e('every'); | |
| 83 | 83 | echo " "; | 
| 84 | 84 | ?> | 
| 85 | - <input type="number" style="max-width: 60px;" value="<?php echo esc_attr( $item->get_recurring_interval( 'edit' ) ); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" /> | |
| 85 | +                            <input type="number" style="max-width: 60px;" value="<?php echo esc_attr($item->get_recurring_interval('edit')); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" /> | |
| 86 | 86 | </div> | 
| 87 | 87 | <div class="col-sm-4 wpinv_show_if_recurring"> | 
| 88 | 88 | <?php | 
| @@ -90,16 +90,16 @@ discard block | ||
| 90 | 90 | array( | 
| 91 | 91 | 'id' => 'wpinv_recurring_period', | 
| 92 | 92 | 'name' => 'wpinv_recurring_period', | 
| 93 | - 'label' => __( 'Period', 'invoicing' ), | |
| 94 | - 'placeholder' => __( 'Select Period', 'invoicing' ), | |
| 95 | - 'value' => $item->get_recurring_period( 'edit' ), | |
| 93 | +                                        'label'            => __('Period', 'invoicing'), | |
| 94 | +                                        'placeholder'      => __('Select Period', 'invoicing'), | |
| 95 | +                                        'value'            => $item->get_recurring_period('edit'), | |
| 96 | 96 | 'select2' => true, | 
| 97 | 97 | 'data-allow-clear' => 'false', | 
| 98 | 98 | 'options' => array( | 
| 99 | - 'D' => __( 'day(s)', 'invoicing' ), | |
| 100 | - 'W' => __( 'week(s)', 'invoicing' ), | |
| 101 | - 'M' => __( 'month(s)', 'invoicing' ), | |
| 102 | - 'Y' => __( 'year(s)', 'invoicing' ), | |
| 99 | +                                            'D'  => __('day(s)', 'invoicing'), | |
| 100 | +                                            'W'  => __('week(s)', 'invoicing'), | |
| 101 | +                                            'M'  => __('month(s)', 'invoicing'), | |
| 102 | +                                            'Y'  => __('year(s)', 'invoicing'), | |
| 103 | 103 | ) | 
| 104 | 104 | ) | 
| 105 | 105 | ); | 
| @@ -111,9 +111,9 @@ discard block | ||
| 111 | 111 | <?php | 
| 112 | 112 | |
| 113 | 113 | // Dynamic pricing. | 
| 114 | -                                if( $item->supports_dynamic_pricing() ) { | |
| 114 | +                                if ($item->supports_dynamic_pricing()) { | |
| 115 | 115 | |
| 116 | - do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item ); | |
| 116 | +                                    do_action('wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item); | |
| 117 | 117 | |
| 118 | 118 | // NYP toggle. | 
| 119 | 119 | echo aui()->input( | 
| @@ -121,31 +121,31 @@ discard block | ||
| 121 | 121 | 'id' => 'wpinv_name_your_price', | 
| 122 | 122 | 'name' => 'wpinv_name_your_price', | 
| 123 | 123 | 'type' => 'checkbox', | 
| 124 | - 'label' => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ), | |
| 124 | +                                            'label'       => apply_filters('wpinv_name_your_price_toggle_text', __('Let customers name their price', 'invoicing')), | |
| 125 | 125 | 'value' => '1', | 
| 126 | 126 | 'checked' => $item->user_can_set_their_price(), | 
| 127 | 127 | 'no_wrap' => true, | 
| 128 | 128 | ) | 
| 129 | 129 | ); | 
| 130 | 130 | |
| 131 | - do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item ); | |
| 131 | +                                    do_action('wpinv_item_details_metabox_dynamic_pricing_checkbox', $item); | |
| 132 | 132 | |
| 133 | 133 | } | 
| 134 | 134 | |
| 135 | 135 | // Subscriptions. | 
| 136 | - do_action( 'wpinv_item_details_metabox_before_subscription_checkbox', $item ); | |
| 136 | +                                do_action('wpinv_item_details_metabox_before_subscription_checkbox', $item); | |
| 137 | 137 | echo aui()->input( | 
| 138 | 138 | array( | 
| 139 | 139 | 'id' => 'wpinv_is_recurring', | 
| 140 | 140 | 'name' => 'wpinv_is_recurring', | 
| 141 | 141 | 'type' => 'checkbox', | 
| 142 | - 'label' => apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Charge customers a recurring amount for this item', 'invoicing' ) ), | |
| 142 | +                                        'label'       => apply_filters('wpinv_is_recurring_toggle_text', __('Charge customers a recurring amount for this item', 'invoicing')), | |
| 143 | 143 | 'value' => '1', | 
| 144 | 144 | 'checked' => $item->is_recurring(), | 
| 145 | 145 | 'no_wrap' => true, | 
| 146 | 146 | ) | 
| 147 | 147 | ); | 
| 148 | - do_action( 'wpinv_item_details_metabox_subscription_checkbox', $item ); | |
| 148 | +                                do_action('wpinv_item_details_metabox_subscription_checkbox', $item); | |
| 149 | 149 | |
| 150 | 150 | ?> | 
| 151 | 151 | <div class="wpinv_show_if_recurring"> | 
| @@ -155,30 +155,30 @@ discard block | ||
| 155 | 155 | </div> | 
| 156 | 156 | </div> | 
| 157 | 157 | <div class="col-sm-1 pt-2 pl-0"> | 
| 158 | - <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> | |
| 158 | +                    <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> | |
| 159 | 159 | </div> | 
| 160 | 160 | </div> | 
| 161 | - <?php do_action( 'wpinv_item_details_metabox_after_price', $item ); ?> | |
| 161 | +            <?php do_action('wpinv_item_details_metabox_after_price', $item); ?> | |
| 162 | 162 | |
| 163 | - <?php if( $item->supports_dynamic_pricing() ) : ?> | |
| 164 | - <?php do_action( 'wpinv_item_details_metabox_before_minimum_price', $item ); ?> | |
| 163 | + <?php if ($item->supports_dynamic_pricing()) : ?> | |
| 164 | +                <?php do_action('wpinv_item_details_metabox_before_minimum_price', $item); ?> | |
| 165 | 165 | <div class="wpinv_show_if_dynamic wpinv_minimum_price"> | 
| 166 | 166 | |
| 167 | 167 | <div class="form-group row"> | 
| 168 | 168 | <label for="wpinv_minimum_price" class="col-sm-3 col-form-label"> | 
| 169 | - <?php _e( 'Minimum Price', 'invoicing' );?> | |
| 169 | +                            <?php _e('Minimum Price', 'invoicing'); ?> | |
| 170 | 170 | </label> | 
| 171 | 171 | <div class="col-sm-8"> | 
| 172 | 172 | <div class="input-group input-group-sm"> | 
| 173 | - <?php if( 'left' == $position ) : ?> | |
| 173 | +                                <?php if ('left' == $position) : ?> | |
| 174 | 174 | <div class="input-group-prepend"> | 
| 175 | 175 | <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> | 
| 176 | 176 | </div> | 
| 177 | 177 | <?php endif; ?> | 
| 178 | 178 | |
| 179 | - <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_minimum_price( 'edit' ) ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control"> | |
| 179 | +                                <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_minimum_price('edit'))); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control"> | |
| 180 | 180 | |
| 181 | - <?php if( 'left' != $position ) : ?> | |
| 181 | +                                <?php if ('left' != $position) : ?> | |
| 182 | 182 | <div class="input-group-append"> | 
| 183 | 183 | <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> | 
| 184 | 184 | </div> | 
| @@ -187,45 +187,45 @@ discard block | ||
| 187 | 187 | </div> | 
| 188 | 188 | |
| 189 | 189 | <div class="col-sm-1 pt-2 pl-0"> | 
| 190 | - <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> | |
| 190 | +                            <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> | |
| 191 | 191 | </div> | 
| 192 | 192 | </div> | 
| 193 | 193 | |
| 194 | 194 | </div> | 
| 195 | - <?php do_action( 'wpinv_item_details_metabox_minimum_price', $item ); ?> | |
| 195 | +                <?php do_action('wpinv_item_details_metabox_minimum_price', $item); ?> | |
| 196 | 196 | <?php endif; ?> | 
| 197 | 197 | |
| 198 | - <?php do_action( 'wpinv_item_details_metabox_before_maximum_renewals', $item ); ?> | |
| 198 | +            <?php do_action('wpinv_item_details_metabox_before_maximum_renewals', $item); ?> | |
| 199 | 199 | <div class="wpinv_show_if_recurring wpinv_maximum_renewals"> | 
| 200 | 200 | |
| 201 | 201 | <div class="form-group row"> | 
| 202 | 202 | <label for="wpinv_recurring_limit" class="col-sm-3 col-form-label"> | 
| 203 | - <?php _e( 'Maximum Renewals', 'invoicing' );?> | |
| 203 | +                        <?php _e('Maximum Renewals', 'invoicing'); ?> | |
| 204 | 204 | </label> | 
| 205 | 205 | <div class="col-sm-8"> | 
| 206 | - <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%;" /> | |
| 206 | +                        <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%;" /> | |
| 207 | 207 | </div> | 
| 208 | 208 | <div class="col-sm-1 pt-2 pl-0"> | 
| 209 | - <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> | |
| 209 | +                        <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> | |
| 210 | 210 | </div> | 
| 211 | 211 | </div> | 
| 212 | 212 | |
| 213 | 213 | </div> | 
| 214 | - <?php do_action( 'wpinv_item_details_metabox_maximum_renewals', $item ); ?> | |
| 214 | +            <?php do_action('wpinv_item_details_metabox_maximum_renewals', $item); ?> | |
| 215 | 215 | |
| 216 | - <?php do_action( 'wpinv_item_details_metabox_before_free_trial', $item ); ?> | |
| 216 | +            <?php do_action('wpinv_item_details_metabox_before_free_trial', $item); ?> | |
| 217 | 217 | <div class="wpinv_show_if_recurring wpinv_free_trial"> | 
| 218 | 218 | |
| 219 | 219 | <div class="form-group row"> | 
| 220 | - <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php defined( 'GETPAID_PAID_TRIALS_VERSION' ) ? _e( 'Free/Paid Trial', 'invoicing' ) : _e( 'Free Trial', 'invoicing' )?></label> | |
| 220 | +                    <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php defined('GETPAID_PAID_TRIALS_VERSION') ? _e('Free/Paid Trial', 'invoicing') : _e('Free Trial', 'invoicing')?></label> | |
| 221 | 221 | |
| 222 | 222 | <div class="col-sm-8"> | 
| 223 | 223 | <div class="row"> | 
| 224 | 224 | <div class="col-sm-6"> | 
| 225 | - <?php $value = $item->has_free_trial() ? $item->get_trial_interval( 'edit' ) : 0;?> | |
| 225 | +                                <?php $value = $item->has_free_trial() ? $item->get_trial_interval('edit') : 0; ?> | |
| 226 | 226 | |
| 227 | 227 | <div> | 
| 228 | - <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr( $value ); ?>" > | |
| 228 | + <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr($value); ?>" > | |
| 229 | 229 | </div> | 
| 230 | 230 | </div> | 
| 231 | 231 | <div class="col-sm-6"> | 
| @@ -234,17 +234,17 @@ discard block | ||
| 234 | 234 | array( | 
| 235 | 235 | 'id' => 'wpinv_trial_period', | 
| 236 | 236 | 'name' => 'wpinv_trial_period', | 
| 237 | - 'label' => __( 'Trial Period', 'invoicing' ), | |
| 238 | - 'placeholder' => __( 'Trial Period', 'invoicing' ), | |
| 239 | - 'value' => $item->get_trial_period( 'edit' ), | |
| 237 | +                                            'label'            => __('Trial Period', 'invoicing'), | |
| 238 | +                                            'placeholder'      => __('Trial Period', 'invoicing'), | |
| 239 | +                                            'value'            => $item->get_trial_period('edit'), | |
| 240 | 240 | 'select2' => true, | 
| 241 | 241 | 'data-allow-clear' => 'false', | 
| 242 | 242 | 'no_wrap' => true, | 
| 243 | 243 | 'options' => array( | 
| 244 | - 'D' => __( 'day(s)', 'invoicing' ), | |
| 245 | - 'W' => __( 'week(s)', 'invoicing' ), | |
| 246 | - 'M' => __( 'month(s)', 'invoicing' ), | |
| 247 | - 'Y' => __( 'year(s)', 'invoicing' ), | |
| 244 | +                                                'D'  => __('day(s)', 'invoicing'), | |
| 245 | +                                                'W'  => __('week(s)', 'invoicing'), | |
| 246 | +                                                'M'  => __('month(s)', 'invoicing'), | |
| 247 | +                                                'Y'  => __('year(s)', 'invoicing'), | |
| 248 | 248 | ) | 
| 249 | 249 | ) | 
| 250 | 250 | ); | 
| @@ -255,15 +255,15 @@ discard block | ||
| 255 | 255 | </div> | 
| 256 | 256 | |
| 257 | 257 | <div class="col-sm-1 pt-2 pl-0"> | 
| 258 | - <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> | |
| 258 | +                        <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> | |
| 259 | 259 | </div> | 
| 260 | 260 | |
| 261 | 261 | </div> | 
| 262 | 262 | |
| 263 | 263 | </div> | 
| 264 | - <?php do_action( 'wpinv_item_details_metabox__free_trial', $item ); ?> | |
| 264 | +            <?php do_action('wpinv_item_details_metabox__free_trial', $item); ?> | |
| 265 | 265 | |
| 266 | - <?php do_action( 'wpinv_item_details_metabox_item_details', $item ); ?> | |
| 266 | +            <?php do_action('wpinv_item_details_metabox_item_details', $item); ?> | |
| 267 | 267 | </div> | 
| 268 | 268 | <?php | 
| 269 | 269 | |
| @@ -274,31 +274,31 @@ discard block | ||
| 274 | 274 | * | 
| 275 | 275 | * @param int $post_id | 
| 276 | 276 | */ | 
| 277 | -	public static function save( $post_id ) { | |
| 277 | +	public static function save($post_id) { | |
| 278 | 278 | |
| 279 | 279 | // Prepare the item. | 
| 280 | - $item = new WPInv_Item( $post_id ); | |
| 280 | + $item = new WPInv_Item($post_id); | |
| 281 | 281 | |
| 282 | 282 | // Load new data. | 
| 283 | 283 | $item->set_props( | 
| 284 | 284 | array( | 
| 285 | - 'price' => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null, | |
| 286 | - 'vat_rule' => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null, | |
| 287 | - 'vat_class' => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null, | |
| 288 | - 'type' => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null, | |
| 289 | - 'is_dynamic_pricing' => ! empty( $_POST['wpinv_name_your_price'] ), | |
| 290 | - 'minimum_price' => isset( $_POST['wpinv_minimum_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_minimum_price'] ) : null, | |
| 291 | - 'is_recurring' => ! empty( $_POST['wpinv_is_recurring'] ), | |
| 292 | - 'recurring_period' => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null, | |
| 293 | - 'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1, | |
| 294 | - 'recurring_limit' => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null, | |
| 295 | - 'is_free_trial' => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null, | |
| 296 | - 'trial_period' => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null, | |
| 297 | - 'trial_interval' => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null, | |
| 285 | + 'price' => isset($_POST['wpinv_item_price']) ? getpaid_standardize_amount($_POST['wpinv_item_price']) : null, | |
| 286 | + 'vat_rule' => isset($_POST['wpinv_vat_rules']) ? wpinv_clean($_POST['wpinv_vat_rules']) : null, | |
| 287 | + 'vat_class' => isset($_POST['wpinv_vat_class']) ? wpinv_clean($_POST['wpinv_vat_class']) : null, | |
| 288 | + 'type' => isset($_POST['wpinv_item_type']) ? wpinv_clean($_POST['wpinv_item_type']) : null, | |
| 289 | + 'is_dynamic_pricing' => !empty($_POST['wpinv_name_your_price']), | |
| 290 | + 'minimum_price' => isset($_POST['wpinv_minimum_price']) ? getpaid_standardize_amount($_POST['wpinv_minimum_price']) : null, | |
| 291 | + 'is_recurring' => !empty($_POST['wpinv_is_recurring']), | |
| 292 | + 'recurring_period' => isset($_POST['wpinv_recurring_period']) ? wpinv_clean($_POST['wpinv_recurring_period']) : null, | |
| 293 | + 'recurring_interval' => isset($_POST['wpinv_recurring_interval']) ? (int) $_POST['wpinv_recurring_interval'] : 1, | |
| 294 | + 'recurring_limit' => isset($_POST['wpinv_recurring_limit']) ? (int) $_POST['wpinv_recurring_limit'] : null, | |
| 295 | + 'is_free_trial' => isset($_POST['wpinv_trial_interval']) ? (0 != (int) $_POST['wpinv_trial_interval']) : null, | |
| 296 | + 'trial_period' => isset($_POST['wpinv_trial_period']) ? wpinv_clean($_POST['wpinv_trial_period']) : null, | |
| 297 | + 'trial_interval' => isset($_POST['wpinv_trial_interval']) ? (int) $_POST['wpinv_trial_interval'] : null, | |
| 298 | 298 | ) | 
| 299 | 299 | ); | 
| 300 | 300 | |
| 301 | 301 | $item->save(); | 
| 302 | - do_action( 'getpaid_item_metabox_save', $post_id, $item ); | |
| 302 | +		do_action('getpaid_item_metabox_save', $post_id, $item); | |
| 303 | 303 | } | 
| 304 | 304 | } | 
| @@ -8,7 +8,7 @@ discard block | ||
| 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 | ||
| 17 | 17 |  class GetPaid_Meta_Box_Discount_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 discount. | 
| @@ -396,35 +396,35 @@ discard block | ||
| 396 | 396 | } | 
| 397 | 397 | |
| 398 | 398 | /** | 
| 399 | - * Save meta box data. | |
| 400 | - * | |
| 401 | - * @param int $post_id | |
| 402 | - */ | |
| 403 | -	public static function save( $post_id ) { | |
| 399 | + * Save meta box data. | |
| 400 | + * | |
| 401 | + * @param int $post_id | |
| 402 | + */ | |
| 403 | +    public static function save( $post_id ) { | |
| 404 | 404 | |
| 405 | 405 | // Prepare the discount. | 
| 406 | 406 | $discount = new WPInv_Discount( $post_id ); | 
| 407 | 407 | |
| 408 | 408 | // Load new data. | 
| 409 | 409 | $discount->set_props( | 
| 410 | - array( | |
| 411 | - 'code' => isset( $_POST['wpinv_discount_code'] ) ? wpinv_clean( $_POST['wpinv_discount_code'] ) : null, | |
| 412 | - 'amount' => isset( $_POST['wpinv_discount_amount'] ) ? floatval( $_POST['wpinv_discount_amount'] ) : null, | |
| 413 | - 'start' => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null, | |
| 414 | - 'expiration' => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null, | |
| 415 | - 'is_single_use' => ! empty( $_POST['wpinv_discount_single_use'] ), | |
| 410 | + array( | |
| 411 | + 'code' => isset( $_POST['wpinv_discount_code'] ) ? wpinv_clean( $_POST['wpinv_discount_code'] ) : null, | |
| 412 | + 'amount' => isset( $_POST['wpinv_discount_amount'] ) ? floatval( $_POST['wpinv_discount_amount'] ) : null, | |
| 413 | + 'start' => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null, | |
| 414 | + 'expiration' => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null, | |
| 415 | + 'is_single_use' => ! empty( $_POST['wpinv_discount_single_use'] ), | |
| 416 | 416 | 'type' => isset( $_POST['wpinv_discount_type'] ) ? wpinv_clean( $_POST['wpinv_discount_type'] ) : null, | 
| 417 | - 'is_recurring' => ! empty( $_POST['wpinv_discount_recurring'] ), | |
| 418 | - 'items' => isset( $_POST['wpinv_discount_items'] ) ? wpinv_clean( $_POST['wpinv_discount_items'] ) : array(), | |
| 419 | - 'excluded_items' => isset( $_POST['wpinv_discount_excluded_items'] ) ? wpinv_clean( $_POST['wpinv_discount_excluded_items'] ) : array(), | |
| 417 | + 'is_recurring' => ! empty( $_POST['wpinv_discount_recurring'] ), | |
| 418 | + 'items' => isset( $_POST['wpinv_discount_items'] ) ? wpinv_clean( $_POST['wpinv_discount_items'] ) : array(), | |
| 419 | + 'excluded_items' => isset( $_POST['wpinv_discount_excluded_items'] ) ? wpinv_clean( $_POST['wpinv_discount_excluded_items'] ) : array(), | |
| 420 | 420 | 'required_items' => isset( $_POST['wpinv_discount_required_items'] ) ? wpinv_clean( $_POST['wpinv_discount_required_items'] ) : array(), | 
| 421 | - 'max_uses' => isset( $_POST['wpinv_discount_max_uses'] ) ? intval( $_POST['wpinv_discount_max_uses'] ) : null, | |
| 422 | - 'min_total' => isset( $_POST['wpinv_discount_min_total'] ) ? floatval( $_POST['wpinv_discount_min_total'] ) : null, | |
| 423 | - 'max_total' => isset( $_POST['wpinv_discount_max_total'] ) ? floatval( $_POST['wpinv_discount_max_total'] ) : null, | |
| 424 | - ) | |
| 421 | + 'max_uses' => isset( $_POST['wpinv_discount_max_uses'] ) ? intval( $_POST['wpinv_discount_max_uses'] ) : null, | |
| 422 | + 'min_total' => isset( $_POST['wpinv_discount_min_total'] ) ? floatval( $_POST['wpinv_discount_min_total'] ) : null, | |
| 423 | + 'max_total' => isset( $_POST['wpinv_discount_max_total'] ) ? floatval( $_POST['wpinv_discount_max_total'] ) : null, | |
| 424 | + ) | |
| 425 | 425 | ); | 
| 426 | 426 | |
| 427 | - $discount->save(); | |
| 428 | - do_action( 'getpaid_discount_metabox_save', $post_id, $discount ); | |
| 429 | - } | |
| 427 | + $discount->save(); | |
| 428 | + do_action( 'getpaid_discount_metabox_save', $post_id, $discount ); | |
| 429 | + } | |
| 430 | 430 | } | 
| @@ -7,7 +7,7 @@ discard block | ||
| 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,24 +21,24 @@ discard block | ||
| 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 discount. | 
| 27 | - $discount = new WPInv_Discount( $post ); | |
| 27 | + $discount = new WPInv_Discount($post); | |
| 28 | 28 | |
| 29 | 29 | // Nonce field. | 
| 30 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); | |
| 30 | +        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); | |
| 31 | 31 | |
| 32 | - do_action( 'wpinv_discount_form_top', $discount ); | |
| 32 | +        do_action('wpinv_discount_form_top', $discount); | |
| 33 | 33 | |
| 34 | 34 | // Set the currency position. | 
| 35 | 35 | $position = wpinv_currency_position(); | 
| 36 | 36 | |
| 37 | -        if ( $position == 'left_space' ) { | |
| 37 | +        if ($position == 'left_space') { | |
| 38 | 38 | $position = 'left'; | 
| 39 | 39 | } | 
| 40 | 40 | |
| 41 | -        if ( $position == 'right_space' ) { | |
| 41 | +        if ($position == 'right_space') { | |
| 42 | 42 | $position = 'right'; | 
| 43 | 43 | } | 
| 44 | 44 | |
| @@ -52,66 +52,66 @@ discard block | ||
| 52 | 52 | </style> | 
| 53 | 53 | <div class='bsui' style='max-width: 600px;padding-top: 10px;'> | 
| 54 | 54 | |
| 55 | - <?php do_action( 'wpinv_discount_form_first', $discount ); ?> | |
| 55 | +            <?php do_action('wpinv_discount_form_first', $discount); ?> | |
| 56 | 56 | |
| 57 | - <?php do_action( 'wpinv_discount_form_before_code', $discount ); ?> | |
| 57 | +            <?php do_action('wpinv_discount_form_before_code', $discount); ?> | |
| 58 | 58 | <div class="form-group row"> | 
| 59 | 59 | <label for="wpinv_discount_code" class="col-sm-3 col-form-label"> | 
| 60 | - <?php _e( 'Discount Code', 'invoicing' );?> | |
| 60 | +                    <?php _e('Discount Code', 'invoicing'); ?> | |
| 61 | 61 | </label> | 
| 62 | 62 | <div class="col-sm-8"> | 
| 63 | 63 | <div class="row"> | 
| 64 | 64 | <div class="col-sm-12 form-group"> | 
| 65 | - <input type="text" value="<?php echo esc_attr( $discount->get_code( 'edit' ) ); ?>" placeholder="SUMMER_SALE" name="wpinv_discount_code" id="wpinv_discount_code" style="width: 100%;" /> | |
| 65 | +                            <input type="text" value="<?php echo esc_attr($discount->get_code('edit')); ?>" placeholder="SUMMER_SALE" name="wpinv_discount_code" id="wpinv_discount_code" style="width: 100%;" /> | |
| 66 | 66 | </div> | 
| 67 | 67 | <div class="col-sm-12"> | 
| 68 | 68 | <?php | 
| 69 | - do_action( 'wpinv_discount_form_before_single_use', $discount ); | |
| 69 | +                                do_action('wpinv_discount_form_before_single_use', $discount); | |
| 70 | 70 | |
| 71 | 71 | echo aui()->input( | 
| 72 | 72 | array( | 
| 73 | 73 | 'id' => 'wpinv_discount_single_use', | 
| 74 | 74 | 'name' => 'wpinv_discount_single_use', | 
| 75 | 75 | 'type' => 'checkbox', | 
| 76 | - 'label' => __( 'Each customer can only use this discount once', 'invoicing' ), | |
| 76 | +                                        'label'       => __('Each customer can only use this discount once', 'invoicing'), | |
| 77 | 77 | 'value' => '1', | 
| 78 | 78 | 'checked' => $discount->is_single_use(), | 
| 79 | 79 | ) | 
| 80 | 80 | ); | 
| 81 | 81 | |
| 82 | - do_action( 'wpinv_discount_form_single_use', $discount ); | |
| 82 | +                                do_action('wpinv_discount_form_single_use', $discount); | |
| 83 | 83 | ?> | 
| 84 | 84 | </div> | 
| 85 | 85 | <div class="col-sm-12"> | 
| 86 | 86 | <?php | 
| 87 | - do_action( 'wpinv_discount_form_before_recurring', $discount ); | |
| 87 | +                                do_action('wpinv_discount_form_before_recurring', $discount); | |
| 88 | 88 | |
| 89 | 89 | echo aui()->input( | 
| 90 | 90 | array( | 
| 91 | 91 | 'id' => 'wpinv_discount_recurring', | 
| 92 | 92 | 'name' => 'wpinv_discount_recurring', | 
| 93 | 93 | 'type' => 'checkbox', | 
| 94 | - 'label' => __( 'Apply this discount to all recurring payments for subscriptions', 'invoicing' ), | |
| 94 | +                                        'label'       => __('Apply this discount to all recurring payments for subscriptions', 'invoicing'), | |
| 95 | 95 | 'value' => '1', | 
| 96 | 96 | 'checked' => $discount->is_recurring(), | 
| 97 | 97 | ) | 
| 98 | 98 | ); | 
| 99 | 99 | |
| 100 | - do_action( 'wpinv_discount_form_recurring', $discount ); | |
| 100 | +                                do_action('wpinv_discount_form_recurring', $discount); | |
| 101 | 101 | ?> | 
| 102 | 102 | </div> | 
| 103 | 103 | </div> | 
| 104 | 104 | </div> | 
| 105 | 105 | <div class="col-sm-1 pt-2 pl-0"> | 
| 106 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter a discount code such as 10OFF.', 'invoicing' ); ?>"></span> | |
| 106 | +                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter a discount code such as 10OFF.', 'invoicing'); ?>"></span> | |
| 107 | 107 | </div> | 
| 108 | 108 | </div> | 
| 109 | - <?php do_action( 'wpinv_discount_form_code', $discount ); ?> | |
| 109 | +            <?php do_action('wpinv_discount_form_code', $discount); ?> | |
| 110 | 110 | |
| 111 | - <?php do_action( 'wpinv_discount_form_before_type', $discount ); ?> | |
| 111 | +            <?php do_action('wpinv_discount_form_before_type', $discount); ?> | |
| 112 | 112 | <div class="form-group row"> | 
| 113 | 113 | <label for="wpinv_discount_type" class="col-sm-3 col-form-label"> | 
| 114 | - <?php _e( 'Discount Type', 'invoicing' );?> | |
| 114 | +                    <?php _e('Discount Type', 'invoicing'); ?> | |
| 115 | 115 | </label> | 
| 116 | 116 | <div class="col-sm-8"> | 
| 117 | 117 | <?php | 
| @@ -119,9 +119,9 @@ discard block | ||
| 119 | 119 | array( | 
| 120 | 120 | 'id' => 'wpinv_discount_type', | 
| 121 | 121 | 'name' => 'wpinv_discount_type', | 
| 122 | - 'label' => __( 'Discount Type', 'invoicing' ), | |
| 123 | - 'placeholder' => __( 'Select Discount Type', 'invoicing' ), | |
| 124 | - 'value' => $discount->get_type( 'edit' ), | |
| 122 | +                                'label'            => __('Discount Type', 'invoicing'), | |
| 123 | +                                'placeholder'      => __('Select Discount Type', 'invoicing'), | |
| 124 | +                                'value'            => $discount->get_type('edit'), | |
| 125 | 125 | 'select2' => true, | 
| 126 | 126 | 'data-allow-clear' => 'false', | 
| 127 | 127 | 'options' => wpinv_get_discount_types() | 
| @@ -130,19 +130,19 @@ discard block | ||
| 130 | 130 | ?> | 
| 131 | 131 | </div> | 
| 132 | 132 | <div class="col-sm-1 pt-2 pl-0"> | 
| 133 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Discount type.', 'invoicing' ); ?>"></span> | |
| 133 | +                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Discount type.', 'invoicing'); ?>"></span> | |
| 134 | 134 | </div> | 
| 135 | 135 | </div> | 
| 136 | - <?php do_action( 'wpinv_discount_form_type', $discount ); ?> | |
| 136 | +            <?php do_action('wpinv_discount_form_type', $discount); ?> | |
| 137 | 137 | |
| 138 | - <?php do_action( 'wpinv_discount_form_before_amount', $discount ); ?> | |
| 139 | - <div class="form-group row <?php echo esc_attr( $discount->get_type( 'edit' ) ); ?>" id="wpinv_discount_amount_wrap"> | |
| 138 | +            <?php do_action('wpinv_discount_form_before_amount', $discount); ?> | |
| 139 | +            <div class="form-group row <?php echo esc_attr($discount->get_type('edit')); ?>" id="wpinv_discount_amount_wrap"> | |
| 140 | 140 | <label for="wpinv_discount_amount" class="col-sm-3 col-form-label"> | 
| 141 | - <?php _e( 'Discount Amount', 'invoicing' );?> | |
| 141 | +                    <?php _e('Discount Amount', 'invoicing'); ?> | |
| 142 | 142 | </label> | 
| 143 | 143 | <div class="col-sm-8"> | 
| 144 | 144 | <div class="input-group input-group-sm"> | 
| 145 | - <?php if( 'left' == $position ) : ?> | |
| 145 | +                        <?php if ('left' == $position) : ?> | |
| 146 | 146 | <div class="input-group-prepend left wpinv-if-flat"> | 
| 147 | 147 | <span class="input-group-text"> | 
| 148 | 148 | <?php echo wpinv_currency_symbol(); ?> | 
| @@ -150,9 +150,9 @@ discard block | ||
| 150 | 150 | </div> | 
| 151 | 151 | <?php endif; ?> | 
| 152 | 152 | |
| 153 | - <input type="text" name="wpinv_discount_amount" id="wpinv_discount_amount" value="<?php echo esc_attr( $discount->get_amount( 'edit' ) ); ?>" placeholder="0" class="form-control"> | |
| 153 | +                        <input type="text" name="wpinv_discount_amount" id="wpinv_discount_amount" value="<?php echo esc_attr($discount->get_amount('edit')); ?>" placeholder="0" class="form-control"> | |
| 154 | 154 | |
| 155 | - <?php if( 'right' == $position ) : ?> | |
| 155 | +                        <?php if ('right' == $position) : ?> | |
| 156 | 156 | <div class="input-group-prepend left wpinv-if-flat"> | 
| 157 | 157 | <span class="input-group-text"> | 
| 158 | 158 | <?php echo wpinv_currency_symbol(); ?> | 
| @@ -165,15 +165,15 @@ discard block | ||
| 165 | 165 | </div> | 
| 166 | 166 | </div> | 
| 167 | 167 | <div class="col-sm-1 pt-2 pl-0"> | 
| 168 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?>"></span> | |
| 168 | +                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the discount value. Ex: 10', 'invoicing'); ?>"></span> | |
| 169 | 169 | </div> | 
| 170 | 170 | </div> | 
| 171 | - <?php do_action( 'wpinv_discount_form_amount', $discount ); ?> | |
| 171 | +            <?php do_action('wpinv_discount_form_amount', $discount); ?> | |
| 172 | 172 | |
| 173 | - <?php do_action( 'wpinv_discount_form_before_items', $discount ); ?> | |
| 173 | +            <?php do_action('wpinv_discount_form_before_items', $discount); ?> | |
| 174 | 174 | <div class="form-group row"> | 
| 175 | 175 | <label for="wpinv_discount_items" class="col-sm-3 col-form-label"> | 
| 176 | - <?php _e( 'Items', 'invoicing' );?> | |
| 176 | +                    <?php _e('Items', 'invoicing'); ?> | |
| 177 | 177 | </label> | 
| 178 | 178 | <div class="col-sm-8"> | 
| 179 | 179 | <?php | 
| @@ -181,9 +181,9 @@ discard block | ||
| 181 | 181 | array( | 
| 182 | 182 | 'id' => 'wpinv_discount_items', | 
| 183 | 183 | 'name' => 'wpinv_discount_items[]', | 
| 184 | - 'label' => __( 'Items', 'invoicing' ), | |
| 185 | - 'placeholder' => __( 'Select Items', 'invoicing' ), | |
| 186 | - 'value' => $discount->get_items( 'edit' ), | |
| 184 | +                                'label'            => __('Items', 'invoicing'), | |
| 185 | +                                'placeholder'      => __('Select Items', 'invoicing'), | |
| 186 | +                                'value'            => $discount->get_items('edit'), | |
| 187 | 187 | 'select2' => true, | 
| 188 | 188 | 'multiple' => true, | 
| 189 | 189 | 'data-allow-clear' => 'false', | 
| @@ -193,15 +193,15 @@ discard block | ||
| 193 | 193 | ?> | 
| 194 | 194 | </div> | 
| 195 | 195 | <div class="col-sm-1 pt-2 pl-0"> | 
| 196 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select the items that are allowed to use this discount or leave blank to use this discount all items.', 'invoicing' ); ?>"></span> | |
| 196 | +                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select the items that are allowed to use this discount or leave blank to use this discount all items.', 'invoicing'); ?>"></span> | |
| 197 | 197 | </div> | 
| 198 | 198 | </div> | 
| 199 | - <?php do_action( 'wpinv_discount_form_items', $discount ); ?> | |
| 199 | +            <?php do_action('wpinv_discount_form_items', $discount); ?> | |
| 200 | 200 | |
| 201 | - <?php do_action( 'wpinv_discount_form_before_excluded_items', $discount ); ?> | |
| 201 | +            <?php do_action('wpinv_discount_form_before_excluded_items', $discount); ?> | |
| 202 | 202 | <div class="form-group row"> | 
| 203 | 203 | <label for="wpinv_discount_excluded_items" class="col-sm-3 col-form-label"> | 
| 204 | - <?php _e( 'Excluded Items', 'invoicing' );?> | |
| 204 | +                    <?php _e('Excluded Items', 'invoicing'); ?> | |
| 205 | 205 | </label> | 
| 206 | 206 | <div class="col-sm-8"> | 
| 207 | 207 | <?php | 
| @@ -209,9 +209,9 @@ discard block | ||
| 209 | 209 | array( | 
| 210 | 210 | 'id' => 'wpinv_discount_excluded_items', | 
| 211 | 211 | 'name' => 'wpinv_discount_excluded_items[]', | 
| 212 | - 'label' => __( 'Excluded Items', 'invoicing' ), | |
| 213 | - 'placeholder' => __( 'Select Items', 'invoicing' ), | |
| 214 | - 'value' => $discount->get_excluded_items( 'edit' ), | |
| 212 | +                                'label'            => __('Excluded Items', 'invoicing'), | |
| 213 | +                                'placeholder'      => __('Select Items', 'invoicing'), | |
| 214 | +                                'value'            => $discount->get_excluded_items('edit'), | |
| 215 | 215 | 'select2' => true, | 
| 216 | 216 | 'multiple' => true, | 
| 217 | 217 | 'data-allow-clear' => 'false', | 
| @@ -221,15 +221,15 @@ discard block | ||
| 221 | 221 | ?> | 
| 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( 'Select all the items that are not allowed to use this discount.', 'invoicing' ); ?>"></span> | |
| 224 | +                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select all the items that are not allowed to use this discount.', 'invoicing'); ?>"></span> | |
| 225 | 225 | </div> | 
| 226 | 226 | </div> | 
| 227 | - <?php do_action( 'wpinv_discount_form_excluded_items', $discount ); ?> | |
| 227 | +            <?php do_action('wpinv_discount_form_excluded_items', $discount); ?> | |
| 228 | 228 | |
| 229 | - <?php do_action( 'wpinv_discount_form_before_required_items', $discount ); ?> | |
| 229 | +            <?php do_action('wpinv_discount_form_before_required_items', $discount); ?> | |
| 230 | 230 | <div class="form-group row"> | 
| 231 | 231 | <label for="wpinv_discount_required_items" class="col-sm-3 col-form-label"> | 
| 232 | - <?php _e( 'Required Items', 'invoicing' );?> | |
| 232 | +                    <?php _e('Required Items', 'invoicing'); ?> | |
| 233 | 233 | </label> | 
| 234 | 234 | <div class="col-sm-8"> | 
| 235 | 235 | <?php | 
| @@ -237,9 +237,9 @@ discard block | ||
| 237 | 237 | array( | 
| 238 | 238 | 'id' => 'wpinv_discount_required_items', | 
| 239 | 239 | 'name' => 'wpinv_discount_required_items[]', | 
| 240 | - 'label' => __( 'Required Items', 'invoicing' ), | |
| 241 | - 'placeholder' => __( 'Select Items', 'invoicing' ), | |
| 242 | - 'value' => $discount->get_required_items( 'edit' ), | |
| 240 | +                                'label'            => __('Required Items', 'invoicing'), | |
| 241 | +                                'placeholder'      => __('Select Items', 'invoicing'), | |
| 242 | +                                'value'            => $discount->get_required_items('edit'), | |
| 243 | 243 | 'select2' => true, | 
| 244 | 244 | 'multiple' => true, | 
| 245 | 245 | 'data-allow-clear' => 'false', | 
| @@ -249,15 +249,15 @@ discard block | ||
| 249 | 249 | ?> | 
| 250 | 250 | </div> | 
| 251 | 251 | <div class="col-sm-1 pt-2 pl-0"> | 
| 252 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select all the items that are required to be in the cart before using this discount.', 'invoicing' ); ?>"></span> | |
| 252 | +                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select all the items that are required to be in the cart before using this discount.', 'invoicing'); ?>"></span> | |
| 253 | 253 | </div> | 
| 254 | 254 | </div> | 
| 255 | - <?php do_action( 'wpinv_discount_form_required_items', $discount ); ?> | |
| 255 | +            <?php do_action('wpinv_discount_form_required_items', $discount); ?> | |
| 256 | 256 | |
| 257 | - <?php do_action( 'wpinv_discount_form_before_start', $discount ); ?> | |
| 257 | +            <?php do_action('wpinv_discount_form_before_start', $discount); ?> | |
| 258 | 258 | <div class="form-group row"> | 
| 259 | 259 | <label for="wpinv_discount_start" class="col-sm-3 col-form-label"> | 
| 260 | - <?php _e( 'Start Date', 'invoicing' );?> | |
| 260 | +                    <?php _e('Start Date', 'invoicing'); ?> | |
| 261 | 261 | </label> | 
| 262 | 262 | <div class="col-sm-8"> | 
| 263 | 263 | <?php | 
| @@ -266,10 +266,10 @@ discard block | ||
| 266 | 266 | 'type' => 'datepicker', | 
| 267 | 267 | 'id' => 'wpinv_discount_start', | 
| 268 | 268 | 'name' => 'wpinv_discount_start', | 
| 269 | - 'label' => __( 'Start Date', 'invoicing' ), | |
| 269 | +                                'label'       => __('Start Date', 'invoicing'), | |
| 270 | 270 | 'placeholder' => 'YYYY-MM-DD 00:00', | 
| 271 | 271 | 'class' => 'form-control-sm', | 
| 272 | - 'value' => $discount->get_start_date( 'edit' ), | |
| 272 | +                                'value'       => $discount->get_start_date('edit'), | |
| 273 | 273 | 'extra_attributes' => array( | 
| 274 | 274 | 'data-enable-time' => 'true', | 
| 275 | 275 | 'data-time_24hr' => 'true', | 
| @@ -280,15 +280,15 @@ discard block | ||
| 280 | 280 | ?> | 
| 281 | 281 | </div> | 
| 282 | 282 | <div class="col-sm-1 pt-2 pl-0"> | 
| 283 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?>"></span> | |
| 283 | +                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?>"></span> | |
| 284 | 284 | </div> | 
| 285 | 285 | </div> | 
| 286 | - <?php do_action( 'wpinv_discount_form_start', $discount ); ?> | |
| 286 | +            <?php do_action('wpinv_discount_form_start', $discount); ?> | |
| 287 | 287 | |
| 288 | - <?php do_action( 'wpinv_discount_form_before_expiration', $discount ); ?> | |
| 288 | +            <?php do_action('wpinv_discount_form_before_expiration', $discount); ?> | |
| 289 | 289 | <div class="form-group row"> | 
| 290 | 290 | <label for="wpinv_discount_expiration" class="col-sm-3 col-form-label"> | 
| 291 | - <?php _e( 'Expiration Date', 'invoicing' );?> | |
| 291 | +                    <?php _e('Expiration Date', 'invoicing'); ?> | |
| 292 | 292 | </label> | 
| 293 | 293 | <div class="col-sm-8"> | 
| 294 | 294 | <?php | 
| @@ -297,10 +297,10 @@ discard block | ||
| 297 | 297 | 'type' => 'datepicker', | 
| 298 | 298 | 'id' => 'wpinv_discount_expiration', | 
| 299 | 299 | 'name' => 'wpinv_discount_expiration', | 
| 300 | - 'label' => __( 'Expiration Date', 'invoicing' ), | |
| 300 | +                                'label'       => __('Expiration Date', 'invoicing'), | |
| 301 | 301 | 'placeholder' => 'YYYY-MM-DD 00:00', | 
| 302 | 302 | 'class' => 'form-control-sm', | 
| 303 | - 'value' => $discount->get_end_date( 'edit' ), | |
| 303 | +                                'value'       => $discount->get_end_date('edit'), | |
| 304 | 304 | 'extra_attributes' => array( | 
| 305 | 305 | 'data-enable-time' => 'true', | 
| 306 | 306 | 'data-time_24hr' => 'true', | 
| @@ -313,27 +313,27 @@ discard block | ||
| 313 | 313 | ?> | 
| 314 | 314 | </div> | 
| 315 | 315 | <div class="col-sm-1 pt-2 pl-0"> | 
| 316 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the date after which the discount will expire.', 'invoicing' ); ?>"></span> | |
| 316 | +                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the date after which the discount will expire.', 'invoicing'); ?>"></span> | |
| 317 | 317 | </div> | 
| 318 | 318 | </div> | 
| 319 | - <?php do_action( 'wpinv_discount_form_expiration', $discount ); ?> | |
| 319 | +            <?php do_action('wpinv_discount_form_expiration', $discount); ?> | |
| 320 | 320 | |
| 321 | - <?php do_action( 'wpinv_discount_form_before_min_total', $discount ); ?> | |
| 321 | +            <?php do_action('wpinv_discount_form_before_min_total', $discount); ?> | |
| 322 | 322 | <div class="form-group row"> | 
| 323 | 323 | <label for="wpinv_discount_min_total" class="col-sm-3 col-form-label"> | 
| 324 | - <?php _e( 'Minimum Amount', 'invoicing' );?> | |
| 324 | +                    <?php _e('Minimum Amount', 'invoicing'); ?> | |
| 325 | 325 | </label> | 
| 326 | 326 | <div class="col-sm-8"> | 
| 327 | 327 | <div class="input-group input-group-sm"> | 
| 328 | - <?php if( 'left' == $position ) : ?> | |
| 328 | +                        <?php if ('left' == $position) : ?> | |
| 329 | 329 | <div class="input-group-prepend"> | 
| 330 | 330 | <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span> | 
| 331 | 331 | </div> | 
| 332 | 332 | <?php endif; ?> | 
| 333 | 333 | |
| 334 | - <input type="text" name="wpinv_discount_min_total" id="wpinv_discount_min_total" value="<?php echo esc_attr( $discount->get_minimum_total( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'No minimum', 'invoicing' ); ?>" class="form-control"> | |
| 334 | +                        <input type="text" name="wpinv_discount_min_total" id="wpinv_discount_min_total" value="<?php echo esc_attr($discount->get_minimum_total('edit')); ?>" placeholder="<?php esc_attr_e('No minimum', 'invoicing'); ?>" class="form-control"> | |
| 335 | 335 | |
| 336 | - <?php if( 'left' != $position ) : ?> | |
| 336 | +                        <?php if ('left' != $position) : ?> | |
| 337 | 337 | <div class="input-group-append"> | 
| 338 | 338 | <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span> | 
| 339 | 339 | </div> | 
| @@ -341,27 +341,27 @@ discard block | ||
| 341 | 341 | </div> | 
| 342 | 342 | </div> | 
| 343 | 343 | <div class="col-sm-1 pt-2 pl-0"> | 
| 344 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the minimum amount (including taxes) required to use this discount.', 'invoicing' ); ?>"></span> | |
| 344 | +                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the minimum amount (including taxes) required to use this discount.', 'invoicing'); ?>"></span> | |
| 345 | 345 | </div> | 
| 346 | 346 | </div> | 
| 347 | - <?php do_action( 'wpinv_discount_form_min_total', $discount ); ?> | |
| 347 | +            <?php do_action('wpinv_discount_form_min_total', $discount); ?> | |
| 348 | 348 | |
| 349 | - <?php do_action( 'wpinv_discount_form_before_max_total', $discount ); ?> | |
| 349 | +            <?php do_action('wpinv_discount_form_before_max_total', $discount); ?> | |
| 350 | 350 | <div class="form-group row"> | 
| 351 | 351 | <label for="wpinv_discount_max_total" class="col-sm-3 col-form-label"> | 
| 352 | - <?php _e( 'Maximum Amount', 'invoicing' );?> | |
| 352 | +                    <?php _e('Maximum Amount', 'invoicing'); ?> | |
| 353 | 353 | </label> | 
| 354 | 354 | <div class="col-sm-8"> | 
| 355 | 355 | <div class="input-group input-group-sm"> | 
| 356 | - <?php if( 'left' == $position ) : ?> | |
| 356 | +                        <?php if ('left' == $position) : ?> | |
| 357 | 357 | <div class="input-group-prepend"> | 
| 358 | 358 | <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span> | 
| 359 | 359 | </div> | 
| 360 | 360 | <?php endif; ?> | 
| 361 | 361 | |
| 362 | - <input type="text" name="wpinv_discount_max_total" id="wpinv_discount_max_total" value="<?php echo esc_attr( $discount->get_maximum_total( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'No maximum', 'invoicing' ); ?>" class="form-control"> | |
| 362 | +                        <input type="text" name="wpinv_discount_max_total" id="wpinv_discount_max_total" value="<?php echo esc_attr($discount->get_maximum_total('edit')); ?>" placeholder="<?php esc_attr_e('No maximum', 'invoicing'); ?>" class="form-control"> | |
| 363 | 363 | |
| 364 | - <?php if( 'left' != $position ) : ?> | |
| 364 | +                        <?php if ('left' != $position) : ?> | |
| 365 | 365 | <div class="input-group-append"> | 
| 366 | 366 | <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span> | 
| 367 | 367 | </div> | 
| @@ -369,30 +369,30 @@ discard block | ||
| 369 | 369 | </div> | 
| 370 | 370 | </div> | 
| 371 | 371 | <div class="col-sm-1 pt-2 pl-0"> | 
| 372 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the maximum amount (including taxes) allowed when using this discount.', 'invoicing' ); ?>"></span> | |
| 372 | +                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the maximum amount (including taxes) allowed when using this discount.', 'invoicing'); ?>"></span> | |
| 373 | 373 | </div> | 
| 374 | 374 | </div> | 
| 375 | - <?php do_action( 'wpinv_discount_form_before_max_total', $discount ); ?> | |
| 375 | +            <?php do_action('wpinv_discount_form_before_max_total', $discount); ?> | |
| 376 | 376 | |
| 377 | - <?php do_action( 'wpinv_discount_form_before_max_uses', $discount ); ?> | |
| 377 | +            <?php do_action('wpinv_discount_form_before_max_uses', $discount); ?> | |
| 378 | 378 | <div class="form-group row"> | 
| 379 | 379 | <label for="wpinv_discount_max_uses" class="col-sm-3 col-form-label"> | 
| 380 | - <?php _e( 'Maximum Uses', 'invoicing' );?> | |
| 380 | +                    <?php _e('Maximum Uses', 'invoicing'); ?> | |
| 381 | 381 | </label> | 
| 382 | 382 | <div class="col-sm-8"> | 
| 383 | - <input type="text" value="<?php echo esc_attr( $discount->get_max_uses( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'Unlimited', 'invoicing' ); ?>" name="wpinv_discount_max_uses" id="wpinv_discount_max_uses" style="width: 100%;" /> | |
| 383 | +                    <input type="text" value="<?php echo esc_attr($discount->get_max_uses('edit')); ?>" placeholder="<?php esc_attr_e('Unlimited', 'invoicing'); ?>" name="wpinv_discount_max_uses" id="wpinv_discount_max_uses" style="width: 100%;" /> | |
| 384 | 384 | </div> | 
| 385 | 385 | <div class="col-sm-1 pt-2 pl-0"> | 
| 386 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the maximum number of times that this discount code can be used.', 'invoicing' ); ?>"></span> | |
| 386 | +                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the maximum number of times that this discount code can be used.', 'invoicing'); ?>"></span> | |
| 387 | 387 | </div> | 
| 388 | 388 | </div> | 
| 389 | - <?php do_action( 'wpinv_discount_form_max_uses', $discount ); ?> | |
| 389 | +            <?php do_action('wpinv_discount_form_max_uses', $discount); ?> | |
| 390 | 390 | |
| 391 | - <?php do_action( 'wpinv_discount_form_last', $discount ); ?> | |
| 391 | +            <?php do_action('wpinv_discount_form_last', $discount); ?> | |
| 392 | 392 | |
| 393 | 393 | </div> | 
| 394 | 394 | <?php | 
| 395 | - do_action( 'wpinv_discount_form_bottom', $post ); | |
| 395 | +        do_action('wpinv_discount_form_bottom', $post); | |
| 396 | 396 | } | 
| 397 | 397 | |
| 398 | 398 | /** | 
| @@ -400,31 +400,31 @@ discard block | ||
| 400 | 400 | * | 
| 401 | 401 | * @param int $post_id | 
| 402 | 402 | */ | 
| 403 | -	public static function save( $post_id ) { | |
| 403 | +	public static function save($post_id) { | |
| 404 | 404 | |
| 405 | 405 | // Prepare the discount. | 
| 406 | - $discount = new WPInv_Discount( $post_id ); | |
| 406 | + $discount = new WPInv_Discount($post_id); | |
| 407 | 407 | |
| 408 | 408 | // Load new data. | 
| 409 | 409 | $discount->set_props( | 
| 410 | 410 | array( | 
| 411 | - 'code' => isset( $_POST['wpinv_discount_code'] ) ? wpinv_clean( $_POST['wpinv_discount_code'] ) : null, | |
| 412 | - 'amount' => isset( $_POST['wpinv_discount_amount'] ) ? floatval( $_POST['wpinv_discount_amount'] ) : null, | |
| 413 | - 'start' => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null, | |
| 414 | - 'expiration' => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null, | |
| 415 | - 'is_single_use' => ! empty( $_POST['wpinv_discount_single_use'] ), | |
| 416 | - 'type' => isset( $_POST['wpinv_discount_type'] ) ? wpinv_clean( $_POST['wpinv_discount_type'] ) : null, | |
| 417 | - 'is_recurring' => ! empty( $_POST['wpinv_discount_recurring'] ), | |
| 418 | - 'items' => isset( $_POST['wpinv_discount_items'] ) ? wpinv_clean( $_POST['wpinv_discount_items'] ) : array(), | |
| 419 | - 'excluded_items' => isset( $_POST['wpinv_discount_excluded_items'] ) ? wpinv_clean( $_POST['wpinv_discount_excluded_items'] ) : array(), | |
| 420 | - 'required_items' => isset( $_POST['wpinv_discount_required_items'] ) ? wpinv_clean( $_POST['wpinv_discount_required_items'] ) : array(), | |
| 421 | - 'max_uses' => isset( $_POST['wpinv_discount_max_uses'] ) ? intval( $_POST['wpinv_discount_max_uses'] ) : null, | |
| 422 | - 'min_total' => isset( $_POST['wpinv_discount_min_total'] ) ? floatval( $_POST['wpinv_discount_min_total'] ) : null, | |
| 423 | - 'max_total' => isset( $_POST['wpinv_discount_max_total'] ) ? floatval( $_POST['wpinv_discount_max_total'] ) : null, | |
| 411 | + 'code' => isset($_POST['wpinv_discount_code']) ? wpinv_clean($_POST['wpinv_discount_code']) : null, | |
| 412 | + 'amount' => isset($_POST['wpinv_discount_amount']) ? floatval($_POST['wpinv_discount_amount']) : null, | |
| 413 | + 'start' => isset($_POST['wpinv_discount_start']) ? wpinv_clean($_POST['wpinv_discount_start']) : null, | |
| 414 | + 'expiration' => isset($_POST['wpinv_discount_expiration']) ? wpinv_clean($_POST['wpinv_discount_expiration']) : null, | |
| 415 | + 'is_single_use' => !empty($_POST['wpinv_discount_single_use']), | |
| 416 | + 'type' => isset($_POST['wpinv_discount_type']) ? wpinv_clean($_POST['wpinv_discount_type']) : null, | |
| 417 | + 'is_recurring' => !empty($_POST['wpinv_discount_recurring']), | |
| 418 | + 'items' => isset($_POST['wpinv_discount_items']) ? wpinv_clean($_POST['wpinv_discount_items']) : array(), | |
| 419 | + 'excluded_items' => isset($_POST['wpinv_discount_excluded_items']) ? wpinv_clean($_POST['wpinv_discount_excluded_items']) : array(), | |
| 420 | + 'required_items' => isset($_POST['wpinv_discount_required_items']) ? wpinv_clean($_POST['wpinv_discount_required_items']) : array(), | |
| 421 | + 'max_uses' => isset($_POST['wpinv_discount_max_uses']) ? intval($_POST['wpinv_discount_max_uses']) : null, | |
| 422 | + 'min_total' => isset($_POST['wpinv_discount_min_total']) ? floatval($_POST['wpinv_discount_min_total']) : null, | |
| 423 | + 'max_total' => isset($_POST['wpinv_discount_max_total']) ? floatval($_POST['wpinv_discount_max_total']) : null, | |
| 424 | 424 | ) | 
| 425 | 425 | ); | 
| 426 | 426 | |
| 427 | 427 | $discount->save(); | 
| 428 | - do_action( 'getpaid_discount_metabox_save', $post_id, $discount ); | |
| 428 | +		do_action('getpaid_discount_metabox_save', $post_id, $discount); | |
| 429 | 429 | } | 
| 430 | 430 | } | 
| @@ -5,110 +5,110 @@ discard block | ||
| 5 | 5 | */ | 
| 6 | 6 | |
| 7 | 7 |  if ( ! defined( 'ABSPATH' ) ) { | 
| 8 | - exit; // Exit if accessed directly | |
| 8 | + exit; // Exit if accessed directly | |
| 9 | 9 | } | 
| 10 | 10 | |
| 11 | 11 | if ( ! class_exists( 'GetPaid_Admin_Profile', false ) ) : | 
| 12 | 12 | |
| 13 | - /** | |
| 14 | - * GetPaid_Admin_Profile Class. | |
| 15 | - */ | |
| 16 | -	class GetPaid_Admin_Profile { | |
| 17 | - | |
| 18 | - /** | |
| 19 | - * Hook in tabs. | |
| 20 | - */ | |
| 21 | -		public function __construct() { | |
| 22 | - add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); | |
| 23 | - add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); | |
| 24 | - | |
| 25 | - add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) ); | |
| 26 | - add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) ); | |
| 27 | - } | |
| 28 | - | |
| 29 | - /** | |
| 30 | - * Get Address Fields for the edit user pages. | |
| 31 | - * | |
| 32 | - * @return array Fields to display which are filtered through invoicing_customer_meta_fields before being returned | |
| 33 | - */ | |
| 34 | -		public function get_customer_meta_fields() { | |
| 35 | - | |
| 36 | - $show_fields = apply_filters( | |
| 37 | - 'getpaid_customer_meta_fields', | |
| 38 | - array( | |
| 39 | - 'billing' => array( | |
| 40 | - 'title' => __( 'Billing Details (GetPaid)', 'invoicing' ), | |
| 41 | - 'fields' => array( | |
| 42 | - '_wpinv_first_name' => array( | |
| 43 | - 'label' => __( 'First name', 'invoicing' ), | |
| 44 | - 'description' => '', | |
| 45 | - ), | |
| 46 | - '_wpinv_last_name' => array( | |
| 47 | - 'label' => __( 'Last name', 'invoicing' ), | |
| 48 | - 'description' => '', | |
| 49 | - ), | |
| 50 | - '_wpinv_company' => array( | |
| 51 | - 'label' => __( 'Company', 'invoicing' ), | |
| 52 | - 'description' => '', | |
| 53 | - ), | |
| 54 | - '_wpinv_company_id' => array( | |
| 55 | - 'label' => __( 'Company ID', 'invoicing' ), | |
| 56 | - 'description' => '', | |
| 57 | - ), | |
| 58 | - '_wpinv_address' => array( | |
| 59 | - 'label' => __( 'Address', 'invoicing' ), | |
| 60 | - 'description' => '', | |
| 61 | - ), | |
| 62 | - '_wpinv_city' => array( | |
| 63 | - 'label' => __( 'City', 'invoicing' ), | |
| 64 | - 'description' => '', | |
| 65 | - ), | |
| 66 | - '_wpinv_zip' => array( | |
| 67 | - 'label' => __( 'Postcode / ZIP', 'invoicing' ), | |
| 68 | - 'description' => '', | |
| 69 | - ), | |
| 70 | - '_wpinv_country' => array( | |
| 71 | - 'label' => __( 'Country / Region', 'invoicing' ), | |
| 72 | - 'description' => '', | |
| 73 | - 'class' => 'getpaid_js_field-country', | |
| 74 | - 'type' => 'select', | |
| 75 | - 'options' => array( '' => __( 'Select a country / region…', 'invoicing' ) ) + wpinv_get_country_list(), | |
| 76 | - ), | |
| 77 | - '_wpinv_state' => array( | |
| 78 | - 'label' => __( 'State / County', 'invoicing' ), | |
| 79 | - 'description' => __( 'State / County or state code', 'invoicing' ), | |
| 80 | - 'class' => 'getpaid_js_field-state regular-text', | |
| 81 | - ), | |
| 82 | - '_wpinv_phone' => array( | |
| 83 | - 'label' => __( 'Phone', 'invoicing' ), | |
| 84 | - 'description' => '', | |
| 85 | - ), | |
| 86 | - '_wpinv_vat_number' => array( | |
| 87 | - 'label' => __( 'VAT Number', 'invoicing' ), | |
| 88 | - 'description' => '', | |
| 89 | - ), | |
| 90 | - ), | |
| 91 | - ), | |
| 92 | - ) | |
| 93 | - ); | |
| 94 | - return $show_fields; | |
| 95 | - } | |
| 96 | - | |
| 97 | - /** | |
| 98 | - * Show Address Fields on edit user pages. | |
| 99 | - * | |
| 100 | - * @param WP_User $user | |
| 101 | - */ | |
| 102 | -		public function add_customer_meta_fields( $user ) { | |
| 103 | - | |
| 104 | -			if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) { | |
| 105 | - return; | |
| 106 | - } | |
| 107 | - | |
| 108 | - $show_fields = $this->get_customer_meta_fields(); | |
| 109 | - | |
| 110 | - foreach ( $show_fields as $fieldset_key => $fieldset ) : | |
| 111 | - ?> | |
| 13 | + /** | |
| 14 | + * GetPaid_Admin_Profile Class. | |
| 15 | + */ | |
| 16 | +    class GetPaid_Admin_Profile { | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * Hook in tabs. | |
| 20 | + */ | |
| 21 | +        public function __construct() { | |
| 22 | + add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); | |
| 23 | + add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); | |
| 24 | + | |
| 25 | + add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) ); | |
| 26 | + add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) ); | |
| 27 | + } | |
| 28 | + | |
| 29 | + /** | |
| 30 | + * Get Address Fields for the edit user pages. | |
| 31 | + * | |
| 32 | + * @return array Fields to display which are filtered through invoicing_customer_meta_fields before being returned | |
| 33 | + */ | |
| 34 | +        public function get_customer_meta_fields() { | |
| 35 | + | |
| 36 | + $show_fields = apply_filters( | |
| 37 | + 'getpaid_customer_meta_fields', | |
| 38 | + array( | |
| 39 | + 'billing' => array( | |
| 40 | + 'title' => __( 'Billing Details (GetPaid)', 'invoicing' ), | |
| 41 | + 'fields' => array( | |
| 42 | + '_wpinv_first_name' => array( | |
| 43 | + 'label' => __( 'First name', 'invoicing' ), | |
| 44 | + 'description' => '', | |
| 45 | + ), | |
| 46 | + '_wpinv_last_name' => array( | |
| 47 | + 'label' => __( 'Last name', 'invoicing' ), | |
| 48 | + 'description' => '', | |
| 49 | + ), | |
| 50 | + '_wpinv_company' => array( | |
| 51 | + 'label' => __( 'Company', 'invoicing' ), | |
| 52 | + 'description' => '', | |
| 53 | + ), | |
| 54 | + '_wpinv_company_id' => array( | |
| 55 | + 'label' => __( 'Company ID', 'invoicing' ), | |
| 56 | + 'description' => '', | |
| 57 | + ), | |
| 58 | + '_wpinv_address' => array( | |
| 59 | + 'label' => __( 'Address', 'invoicing' ), | |
| 60 | + 'description' => '', | |
| 61 | + ), | |
| 62 | + '_wpinv_city' => array( | |
| 63 | + 'label' => __( 'City', 'invoicing' ), | |
| 64 | + 'description' => '', | |
| 65 | + ), | |
| 66 | + '_wpinv_zip' => array( | |
| 67 | + 'label' => __( 'Postcode / ZIP', 'invoicing' ), | |
| 68 | + 'description' => '', | |
| 69 | + ), | |
| 70 | + '_wpinv_country' => array( | |
| 71 | + 'label' => __( 'Country / Region', 'invoicing' ), | |
| 72 | + 'description' => '', | |
| 73 | + 'class' => 'getpaid_js_field-country', | |
| 74 | + 'type' => 'select', | |
| 75 | + 'options' => array( '' => __( 'Select a country / region…', 'invoicing' ) ) + wpinv_get_country_list(), | |
| 76 | + ), | |
| 77 | + '_wpinv_state' => array( | |
| 78 | + 'label' => __( 'State / County', 'invoicing' ), | |
| 79 | + 'description' => __( 'State / County or state code', 'invoicing' ), | |
| 80 | + 'class' => 'getpaid_js_field-state regular-text', | |
| 81 | + ), | |
| 82 | + '_wpinv_phone' => array( | |
| 83 | + 'label' => __( 'Phone', 'invoicing' ), | |
| 84 | + 'description' => '', | |
| 85 | + ), | |
| 86 | + '_wpinv_vat_number' => array( | |
| 87 | + 'label' => __( 'VAT Number', 'invoicing' ), | |
| 88 | + 'description' => '', | |
| 89 | + ), | |
| 90 | + ), | |
| 91 | + ), | |
| 92 | + ) | |
| 93 | + ); | |
| 94 | + return $show_fields; | |
| 95 | + } | |
| 96 | + | |
| 97 | + /** | |
| 98 | + * Show Address Fields on edit user pages. | |
| 99 | + * | |
| 100 | + * @param WP_User $user | |
| 101 | + */ | |
| 102 | +        public function add_customer_meta_fields( $user ) { | |
| 103 | + | |
| 104 | +            if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) { | |
| 105 | + return; | |
| 106 | + } | |
| 107 | + | |
| 108 | + $show_fields = $this->get_customer_meta_fields(); | |
| 109 | + | |
| 110 | + foreach ( $show_fields as $fieldset_key => $fieldset ) : | |
| 111 | + ?> | |
| 112 | 112 | <h2><?php echo $fieldset['title']; ?></h2> | 
| 113 | 113 | <table class="form-table" id="<?php echo esc_attr( 'getpaid-fieldset-' . $fieldset_key ); ?>"> | 
| 114 | 114 | <?php foreach ( $fieldset['fields'] as $key => $field ) : ?> | 
| @@ -120,9 +120,9 @@ discard block | ||
| 120 | 120 | <?php if ( ! empty( $field['type'] ) && 'select' === $field['type'] ) : ?> | 
| 121 | 121 | <select name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" class="<?php echo esc_attr( $field['class'] ); ?> wpi_select2" style="width: 25em;"> | 
| 122 | 122 | <?php | 
| 123 | - $selected = esc_attr( get_user_meta( $user->ID, $key, true ) ); | |
| 124 | - foreach ( $field['options'] as $option_key => $option_value ) : | |
| 125 | - ?> | |
| 123 | + $selected = esc_attr( get_user_meta( $user->ID, $key, true ) ); | |
| 124 | + foreach ( $field['options'] as $option_key => $option_value ) : | |
| 125 | + ?> | |
| 126 | 126 | <option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $selected, $option_key, true ); ?>><?php echo esc_html( $option_value ); ?></option> | 
| 127 | 127 | <?php endforeach; ?> | 
| 128 | 128 | </select> | 
| @@ -137,52 +137,52 @@ discard block | ||
| 137 | 137 | <?php endforeach; ?> | 
| 138 | 138 | </table> | 
| 139 | 139 | <?php | 
| 140 | - endforeach; | |
| 141 | - } | |
| 142 | - | |
| 143 | - /** | |
| 144 | - * Save Address Fields on edit user pages. | |
| 145 | - * | |
| 146 | - * @param int $user_id User ID of the user being saved | |
| 147 | - */ | |
| 148 | -		public function save_customer_meta_fields( $user_id ) { | |
| 149 | -			if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) { | |
| 150 | - return; | |
| 151 | - } | |
| 152 | - | |
| 153 | - $save_fields = $this->get_customer_meta_fields(); | |
| 154 | - | |
| 155 | -			foreach ( $save_fields as $fieldset ) { | |
| 156 | - | |
| 157 | -				foreach ( $fieldset['fields'] as $key => $field ) { | |
| 158 | - | |
| 159 | -					if ( isset( $field['type'] ) && 'checkbox' === $field['type'] ) { | |
| 160 | - update_user_meta( $user_id, $key, ! empty( $_POST[ $key ] ) ); | |
| 161 | -					} elseif ( isset( $_POST[ $key ] ) ) { | |
| 162 | - update_user_meta( $user_id, $key, wpinv_clean( $_POST[ $key ] ) ); | |
| 163 | - } | |
| 164 | - } | |
| 165 | - } | |
| 166 | - } | |
| 167 | - | |
| 168 | - /** | |
| 169 | - * Get user meta for a given key, with fallbacks to core user info for pre-existing fields. | |
| 170 | - * | |
| 171 | - * @since 3.1.0 | |
| 172 | - * @param int $user_id User ID of the user being edited | |
| 173 | - * @param string $key Key for user meta field | |
| 174 | - * @return string | |
| 175 | - */ | |
| 176 | -		protected function get_user_meta( $user_id, $key ) { | |
| 177 | - $value = get_user_meta( $user_id, $key, true ); | |
| 178 | - $existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' ); | |
| 179 | -			if ( ! $value && in_array( $key, $existing_fields ) ) { | |
| 180 | - $value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true ); | |
| 181 | - } | |
| 182 | - | |
| 183 | - return $value; | |
| 184 | - } | |
| 185 | - } | |
| 140 | + endforeach; | |
| 141 | + } | |
| 142 | + | |
| 143 | + /** | |
| 144 | + * Save Address Fields on edit user pages. | |
| 145 | + * | |
| 146 | + * @param int $user_id User ID of the user being saved | |
| 147 | + */ | |
| 148 | +        public function save_customer_meta_fields( $user_id ) { | |
| 149 | +            if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) { | |
| 150 | + return; | |
| 151 | + } | |
| 152 | + | |
| 153 | + $save_fields = $this->get_customer_meta_fields(); | |
| 154 | + | |
| 155 | +            foreach ( $save_fields as $fieldset ) { | |
| 156 | + | |
| 157 | +                foreach ( $fieldset['fields'] as $key => $field ) { | |
| 158 | + | |
| 159 | +                    if ( isset( $field['type'] ) && 'checkbox' === $field['type'] ) { | |
| 160 | + update_user_meta( $user_id, $key, ! empty( $_POST[ $key ] ) ); | |
| 161 | +                    } elseif ( isset( $_POST[ $key ] ) ) { | |
| 162 | + update_user_meta( $user_id, $key, wpinv_clean( $_POST[ $key ] ) ); | |
| 163 | + } | |
| 164 | + } | |
| 165 | + } | |
| 166 | + } | |
| 167 | + | |
| 168 | + /** | |
| 169 | + * Get user meta for a given key, with fallbacks to core user info for pre-existing fields. | |
| 170 | + * | |
| 171 | + * @since 3.1.0 | |
| 172 | + * @param int $user_id User ID of the user being edited | |
| 173 | + * @param string $key Key for user meta field | |
| 174 | + * @return string | |
| 175 | + */ | |
| 176 | +        protected function get_user_meta( $user_id, $key ) { | |
| 177 | + $value = get_user_meta( $user_id, $key, true ); | |
| 178 | + $existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' ); | |
| 179 | +            if ( ! $value && in_array( $key, $existing_fields ) ) { | |
| 180 | + $value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true ); | |
| 181 | + } | |
| 182 | + | |
| 183 | + return $value; | |
| 184 | + } | |
| 185 | + } | |
| 186 | 186 | |
| 187 | 187 | endif; | 
| 188 | 188 | |
| @@ -4,11 +4,11 @@ discard block | ||
| 4 | 4 | * | 
| 5 | 5 | */ | 
| 6 | 6 | |
| 7 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 7 | +if (!defined('ABSPATH')) { | |
| 8 | 8 | exit; // Exit if accessed directly | 
| 9 | 9 | } | 
| 10 | 10 | |
| 11 | -if ( ! class_exists( 'GetPaid_Admin_Profile', false ) ) : | |
| 11 | +if (!class_exists('GetPaid_Admin_Profile', false)) : | |
| 12 | 12 | |
| 13 | 13 | /** | 
| 14 | 14 | * GetPaid_Admin_Profile Class. | 
| @@ -19,11 +19,11 @@ discard block | ||
| 19 | 19 | * Hook in tabs. | 
| 20 | 20 | */ | 
| 21 | 21 |  		public function __construct() { | 
| 22 | - add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); | |
| 23 | - add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); | |
| 22 | +			add_action('show_user_profile', array($this, 'add_customer_meta_fields'), 100); | |
| 23 | +			add_action('edit_user_profile', array($this, 'add_customer_meta_fields'), 100); | |
| 24 | 24 | |
| 25 | - add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) ); | |
| 26 | - add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) ); | |
| 25 | +			add_action('personal_options_update', array($this, 'save_customer_meta_fields')); | |
| 26 | +			add_action('edit_user_profile_update', array($this, 'save_customer_meta_fields')); | |
| 27 | 27 | } | 
| 28 | 28 | |
| 29 | 29 | /** | 
| @@ -37,54 +37,54 @@ discard block | ||
| 37 | 37 | 'getpaid_customer_meta_fields', | 
| 38 | 38 | array( | 
| 39 | 39 | 'billing' => array( | 
| 40 | - 'title' => __( 'Billing Details (GetPaid)', 'invoicing' ), | |
| 40 | +						'title'  => __('Billing Details (GetPaid)', 'invoicing'), | |
| 41 | 41 | 'fields' => array( | 
| 42 | 42 | '_wpinv_first_name' => array( | 
| 43 | - 'label' => __( 'First name', 'invoicing' ), | |
| 43 | +								'label'       => __('First name', 'invoicing'), | |
| 44 | 44 | 'description' => '', | 
| 45 | 45 | ), | 
| 46 | 46 | '_wpinv_last_name' => array( | 
| 47 | - 'label' => __( 'Last name', 'invoicing' ), | |
| 47 | +								'label'       => __('Last name', 'invoicing'), | |
| 48 | 48 | 'description' => '', | 
| 49 | 49 | ), | 
| 50 | 50 | '_wpinv_company' => array( | 
| 51 | - 'label' => __( 'Company', 'invoicing' ), | |
| 51 | +								'label'       => __('Company', 'invoicing'), | |
| 52 | 52 | 'description' => '', | 
| 53 | 53 | ), | 
| 54 | 54 | '_wpinv_company_id' => array( | 
| 55 | - 'label' => __( 'Company ID', 'invoicing' ), | |
| 55 | +								'label'       => __('Company ID', 'invoicing'), | |
| 56 | 56 | 'description' => '', | 
| 57 | 57 | ), | 
| 58 | 58 | '_wpinv_address' => array( | 
| 59 | - 'label' => __( 'Address', 'invoicing' ), | |
| 59 | +								'label'       => __('Address', 'invoicing'), | |
| 60 | 60 | 'description' => '', | 
| 61 | 61 | ), | 
| 62 | 62 | '_wpinv_city' => array( | 
| 63 | - 'label' => __( 'City', 'invoicing' ), | |
| 63 | +								'label'       => __('City', 'invoicing'), | |
| 64 | 64 | 'description' => '', | 
| 65 | 65 | ), | 
| 66 | 66 | '_wpinv_zip' => array( | 
| 67 | - 'label' => __( 'Postcode / ZIP', 'invoicing' ), | |
| 67 | +								'label'       => __('Postcode / ZIP', 'invoicing'), | |
| 68 | 68 | 'description' => '', | 
| 69 | 69 | ), | 
| 70 | 70 | '_wpinv_country' => array( | 
| 71 | - 'label' => __( 'Country / Region', 'invoicing' ), | |
| 71 | +								'label'       => __('Country / Region', 'invoicing'), | |
| 72 | 72 | 'description' => '', | 
| 73 | 73 | 'class' => 'getpaid_js_field-country', | 
| 74 | 74 | 'type' => 'select', | 
| 75 | - 'options' => array( '' => __( 'Select a country / region…', 'invoicing' ) ) + wpinv_get_country_list(), | |
| 75 | +								'options'     => array('' => __('Select a country / region…', 'invoicing')) + wpinv_get_country_list(), | |
| 76 | 76 | ), | 
| 77 | 77 | '_wpinv_state' => array( | 
| 78 | - 'label' => __( 'State / County', 'invoicing' ), | |
| 79 | - 'description' => __( 'State / County or state code', 'invoicing' ), | |
| 78 | +								'label'       => __('State / County', 'invoicing'), | |
| 79 | +								'description' => __('State / County or state code', 'invoicing'), | |
| 80 | 80 | 'class' => 'getpaid_js_field-state regular-text', | 
| 81 | 81 | ), | 
| 82 | 82 | '_wpinv_phone' => array( | 
| 83 | - 'label' => __( 'Phone', 'invoicing' ), | |
| 83 | +								'label'       => __('Phone', 'invoicing'), | |
| 84 | 84 | 'description' => '', | 
| 85 | 85 | ), | 
| 86 | 86 | '_wpinv_vat_number' => array( | 
| 87 | - 'label' => __( 'VAT Number', 'invoicing' ), | |
| 87 | +								'label'       => __('VAT Number', 'invoicing'), | |
| 88 | 88 | 'description' => '', | 
| 89 | 89 | ), | 
| 90 | 90 | ), | 
| @@ -99,39 +99,39 @@ discard block | ||
| 99 | 99 | * | 
| 100 | 100 | * @param WP_User $user | 
| 101 | 101 | */ | 
| 102 | -		public function add_customer_meta_fields( $user ) { | |
| 102 | +		public function add_customer_meta_fields($user) { | |
| 103 | 103 | |
| 104 | -			if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) { | |
| 104 | +			if (!apply_filters('getpaid_current_user_can_edit_customer_meta_fields', current_user_can('manage_options'), $user->ID)) { | |
| 105 | 105 | return; | 
| 106 | 106 | } | 
| 107 | 107 | |
| 108 | 108 | $show_fields = $this->get_customer_meta_fields(); | 
| 109 | 109 | |
| 110 | - foreach ( $show_fields as $fieldset_key => $fieldset ) : | |
| 110 | + foreach ($show_fields as $fieldset_key => $fieldset) : | |
| 111 | 111 | ?> | 
| 112 | 112 | <h2><?php echo $fieldset['title']; ?></h2> | 
| 113 | - <table class="form-table" id="<?php echo esc_attr( 'getpaid-fieldset-' . $fieldset_key ); ?>"> | |
| 114 | - <?php foreach ( $fieldset['fields'] as $key => $field ) : ?> | |
| 113 | +				<table class="form-table" id="<?php echo esc_attr('getpaid-fieldset-' . $fieldset_key); ?>"> | |
| 114 | + <?php foreach ($fieldset['fields'] as $key => $field) : ?> | |
| 115 | 115 | <tr> | 
| 116 | 116 | <th> | 
| 117 | - <label for="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $field['label'] ); ?></label> | |
| 117 | + <label for="<?php echo esc_attr($key); ?>"><?php echo esc_html($field['label']); ?></label> | |
| 118 | 118 | </th> | 
| 119 | 119 | <td> | 
| 120 | - <?php if ( ! empty( $field['type'] ) && 'select' === $field['type'] ) : ?> | |
| 121 | - <select name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" class="<?php echo esc_attr( $field['class'] ); ?> wpi_select2" style="width: 25em;"> | |
| 120 | + <?php if (!empty($field['type']) && 'select' === $field['type']) : ?> | |
| 121 | + <select name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" class="<?php echo esc_attr($field['class']); ?> wpi_select2" style="width: 25em;"> | |
| 122 | 122 | <?php | 
| 123 | - $selected = esc_attr( get_user_meta( $user->ID, $key, true ) ); | |
| 124 | - foreach ( $field['options'] as $option_key => $option_value ) : | |
| 123 | + $selected = esc_attr(get_user_meta($user->ID, $key, true)); | |
| 124 | + foreach ($field['options'] as $option_key => $option_value) : | |
| 125 | 125 | ?> | 
| 126 | - <option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $selected, $option_key, true ); ?>><?php echo esc_html( $option_value ); ?></option> | |
| 126 | + <option value="<?php echo esc_attr($option_key); ?>" <?php selected($selected, $option_key, true); ?>><?php echo esc_html($option_value); ?></option> | |
| 127 | 127 | <?php endforeach; ?> | 
| 128 | 128 | </select> | 
| 129 | - <?php elseif ( ! empty( $field['type'] ) && 'checkbox' === $field['type'] ) : ?> | |
| 130 | - <input type="checkbox" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="1" class="<?php echo esc_attr( $field['class'] ); ?>" <?php checked( (int) get_user_meta( $user->ID, $key, true ), 1, true ); ?> /> | |
| 129 | + <?php elseif (!empty($field['type']) && 'checkbox' === $field['type']) : ?> | |
| 130 | + <input type="checkbox" name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" value="1" class="<?php echo esc_attr($field['class']); ?>" <?php checked((int) get_user_meta($user->ID, $key, true), 1, true); ?> /> | |
| 131 | 131 | <?php else : ?> | 
| 132 | - <input type="text" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $this->get_user_meta( $user->ID, $key ) ); ?>" class="<?php echo ( ! empty( $field['class'] ) ? esc_attr( $field['class'] ) : 'regular-text' ); ?>" /> | |
| 132 | + <input type="text" name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" value="<?php echo esc_attr($this->get_user_meta($user->ID, $key)); ?>" class="<?php echo (!empty($field['class']) ? esc_attr($field['class']) : 'regular-text'); ?>" /> | |
| 133 | 133 | <?php endif; ?> | 
| 134 | - <p class="description"><?php echo wp_kses_post( $field['description'] ); ?></p> | |
| 134 | + <p class="description"><?php echo wp_kses_post($field['description']); ?></p> | |
| 135 | 135 | </td> | 
| 136 | 136 | </tr> | 
| 137 | 137 | <?php endforeach; ?> | 
| @@ -145,21 +145,21 @@ discard block | ||
| 145 | 145 | * | 
| 146 | 146 | * @param int $user_id User ID of the user being saved | 
| 147 | 147 | */ | 
| 148 | -		public function save_customer_meta_fields( $user_id ) { | |
| 149 | -			if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) { | |
| 148 | +		public function save_customer_meta_fields($user_id) { | |
| 149 | +			if (!apply_filters('getpaid_current_user_can_edit_customer_meta_fields', current_user_can('manage_options'), $user_id)) { | |
| 150 | 150 | return; | 
| 151 | 151 | } | 
| 152 | 152 | |
| 153 | 153 | $save_fields = $this->get_customer_meta_fields(); | 
| 154 | 154 | |
| 155 | -			foreach ( $save_fields as $fieldset ) { | |
| 155 | +			foreach ($save_fields as $fieldset) { | |
| 156 | 156 | |
| 157 | -				foreach ( $fieldset['fields'] as $key => $field ) { | |
| 157 | +				foreach ($fieldset['fields'] as $key => $field) { | |
| 158 | 158 | |
| 159 | -					if ( isset( $field['type'] ) && 'checkbox' === $field['type'] ) { | |
| 160 | - update_user_meta( $user_id, $key, ! empty( $_POST[ $key ] ) ); | |
| 161 | -					} elseif ( isset( $_POST[ $key ] ) ) { | |
| 162 | - update_user_meta( $user_id, $key, wpinv_clean( $_POST[ $key ] ) ); | |
| 159 | +					if (isset($field['type']) && 'checkbox' === $field['type']) { | |
| 160 | + update_user_meta($user_id, $key, !empty($_POST[$key])); | |
| 161 | +					} elseif (isset($_POST[$key])) { | |
| 162 | + update_user_meta($user_id, $key, wpinv_clean($_POST[$key])); | |
| 163 | 163 | } | 
| 164 | 164 | } | 
| 165 | 165 | } | 
| @@ -173,11 +173,11 @@ discard block | ||
| 173 | 173 | * @param string $key Key for user meta field | 
| 174 | 174 | * @return string | 
| 175 | 175 | */ | 
| 176 | -		protected function get_user_meta( $user_id, $key ) { | |
| 177 | - $value = get_user_meta( $user_id, $key, true ); | |
| 178 | - $existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' ); | |
| 179 | -			if ( ! $value && in_array( $key, $existing_fields ) ) { | |
| 180 | - $value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true ); | |
| 176 | +		protected function get_user_meta($user_id, $key) { | |
| 177 | + $value = get_user_meta($user_id, $key, true); | |
| 178 | +			$existing_fields = array('_wpinv_first_name', '_wpinv_last_name'); | |
| 179 | +			if (!$value && in_array($key, $existing_fields)) { | |
| 180 | +				$value = get_user_meta($user_id, str_replace('_wpinv_', '', $key), true); | |
| 181 | 181 | } | 
| 182 | 182 | |
| 183 | 183 | return $value; |