@@ -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 | } |
@@ -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. |
@@ -113,11 +113,11 @@ discard block |
||
| 113 | 113 | // Dynamic pricing. |
| 114 | 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 | - // NYP toggle. |
|
| 119 | - echo aui()->input( |
|
| 120 | - array( |
|
| 118 | + // NYP toggle. |
|
| 119 | + echo aui()->input( |
|
| 120 | + array( |
|
| 121 | 121 | 'id' => 'wpinv_name_your_price', |
| 122 | 122 | 'name' => 'wpinv_name_your_price', |
| 123 | 123 | 'type' => 'checkbox', |
@@ -125,10 +125,10 @@ discard block |
||
| 125 | 125 | 'value' => '1', |
| 126 | 126 | 'checked' => $item->user_can_set_their_price(), |
| 127 | 127 | 'no_wrap' => true, |
| 128 | - ) |
|
| 129 | - ); |
|
| 128 | + ) |
|
| 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 | |
@@ -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 | } |
@@ -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,20 +21,20 @@ 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 | ?> |
| 30 | 30 | |
| 31 | 31 | <div class='bsui' style='padding-top: 10px;'> |
| 32 | - <?php do_action( 'wpinv_item_before_info_metabox', $item ); ?> |
|
| 32 | + <?php do_action('wpinv_item_before_info_metabox', $item); ?> |
|
| 33 | 33 | |
| 34 | 34 | <div class="wpinv_item_type form-group row"> |
| 35 | 35 | <label for="wpinv_item_type" class="col-sm-12 col-form-label"> |
| 36 | - <?php _e( 'Item Type', 'invoicing' ); ?> |
|
| 37 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php echo esc_attr( self::get_tooltip( $post ) ); ?>"></span> |
|
| 36 | + <?php _e('Item Type', 'invoicing'); ?> |
|
| 37 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php echo esc_attr(self::get_tooltip($post)); ?>"></span> |
|
| 38 | 38 | </label> |
| 39 | 39 | |
| 40 | 40 | <div class="col-sm-12"> |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | array( |
| 45 | 45 | 'id' => 'wpinv_item_type', |
| 46 | 46 | 'name' => 'wpinv_item_type', |
| 47 | - 'placeholder' => __( 'Select item type', 'invoicing' ), |
|
| 48 | - 'value' => $item->get_type( 'edit' ), |
|
| 47 | + 'placeholder' => __('Select item type', 'invoicing'), |
|
| 48 | + 'value' => $item->get_type('edit'), |
|
| 49 | 49 | 'select2' => true, |
| 50 | 50 | 'data-allow-clear' => 'false', |
| 51 | 51 | 'no_wrap' => true, |
@@ -57,59 +57,59 @@ discard block |
||
| 57 | 57 | </div> |
| 58 | 58 | </div> |
| 59 | 59 | |
| 60 | - <?php if ( 'fee' === $item->get_type( 'edit' ) || 'custom' === $item->get_type( 'edit' ) ) : ?> |
|
| 60 | + <?php if ('fee' === $item->get_type('edit') || 'custom' === $item->get_type('edit')) : ?> |
|
| 61 | 61 | |
| 62 | 62 | <div class="wpinv_item_shortcode form-group row"> |
| 63 | 63 | <label for="wpinv_item_shortcode" class="col-sm-12 col-form-label"> |
| 64 | - <?php _e( 'Payment Form Shortcode', 'invoicing' ); ?> |
|
| 65 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a payment form', 'invoicing' ); ?>"></span> |
|
| 64 | + <?php _e('Payment Form Shortcode', 'invoicing'); ?> |
|
| 65 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a payment form', 'invoicing'); ?>"></span> |
|
| 66 | 66 | </label> |
| 67 | 67 | |
| 68 | 68 | <div class="col-sm-12"> |
| 69 | - <input onClick="this.select()" type="text" id="wpinv_item_shortcode" value="[getpaid item=<?php echo esc_attr( $item->get_id() ); ?>]" style="width: 100%;" readonly/> |
|
| 69 | + <input onClick="this.select()" type="text" id="wpinv_item_shortcode" value="[getpaid item=<?php echo esc_attr($item->get_id()); ?>]" style="width: 100%;" readonly/> |
|
| 70 | 70 | </div> |
| 71 | 71 | </div> |
| 72 | 72 | |
| 73 | 73 | <div class="wpinv_item_buy_shortcode form-group row"> |
| 74 | 74 | <label for="wpinv_item_button_shortcode" class="col-sm-12 col-form-label"> |
| 75 | - <?php _e( 'Payment Button Shortcode', 'invoicing' ); ?> |
|
| 76 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a buy now button', 'invoicing' ); ?>"></span> |
|
| 75 | + <?php _e('Payment Button Shortcode', 'invoicing'); ?> |
|
| 76 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a buy now button', 'invoicing'); ?>"></span> |
|
| 77 | 77 | </label> |
| 78 | 78 | |
| 79 | 79 | <div class="col-sm-12"> |
| 80 | - <input onClick="this.select()" type="text" id="wpinv_item_button_shortcode" value="[getpaid item=<?php echo esc_attr( $item->get_id() ); ?> button='Buy Now']" style="width: 100%;" readonly/> |
|
| 80 | + <input onClick="this.select()" type="text" id="wpinv_item_button_shortcode" value="[getpaid item=<?php echo esc_attr($item->get_id()); ?> button='Buy Now']" style="width: 100%;" readonly/> |
|
| 81 | 81 | <small class="form-text text-muted"> |
| 82 | - <?php _e( 'Or use the following URL in a link:', 'invoicing' ); ?> |
|
| 83 | - <code>#getpaid-item-<?php echo intval( $item->get_id() ); ?>|0</code> |
|
| 82 | + <?php _e('Or use the following URL in a link:', 'invoicing'); ?> |
|
| 83 | + <code>#getpaid-item-<?php echo intval($item->get_id()); ?>|0</code> |
|
| 84 | 84 | </small> |
| 85 | 85 | </div> |
| 86 | 86 | </div> |
| 87 | 87 | |
| 88 | 88 | <div class="wpinv_item_buy_url form-group row"> |
| 89 | 89 | <label for="wpinv_item_buy_url" class="col-sm-12 col-form-label"> |
| 90 | - <?php _e( 'Direct Payment URL', 'invoicing' ); ?> |
|
| 91 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'You can use this in an iFrame to embed the payment form on another website', 'invoicing' ); ?>"></span> |
|
| 90 | + <?php _e('Direct Payment URL', 'invoicing'); ?> |
|
| 91 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('You can use this in an iFrame to embed the payment form on another website', 'invoicing'); ?>"></span> |
|
| 92 | 92 | </label> |
| 93 | 93 | |
| 94 | 94 | <div class="col-sm-12"> |
| 95 | - <input onClick="this.select()" type="text" id="wpinv_item_buy_url" value="<?php echo esc_url( getpaid_embed_url( false, $item->get_id() . '|0' ) ); ?>" style="width: 100%;" readonly/> |
|
| 95 | + <input onClick="this.select()" type="text" id="wpinv_item_buy_url" value="<?php echo esc_url(getpaid_embed_url(false, $item->get_id() . '|0')); ?>" style="width: 100%;" readonly/> |
|
| 96 | 96 | </div> |
| 97 | 97 | </div> |
| 98 | 98 | |
| 99 | 99 | <?php endif; ?> |
| 100 | 100 | |
| 101 | 101 | <div class="wpinv_item_custom_id form-group"> |
| 102 | - <?php _e( 'Custom ID', 'invoicing' ); ?> — <?php echo esc_html( $item->get_custom_id() ); ?> |
|
| 102 | + <?php _e('Custom ID', 'invoicing'); ?> — <?php echo esc_html($item->get_custom_id()); ?> |
|
| 103 | 103 | </div> |
| 104 | 104 | |
| 105 | - <?php do_action( 'wpinv_meta_values_metabox_before', $post ); ?> |
|
| 106 | - <?php foreach ( apply_filters( 'wpinv_show_meta_values_for_keys', array() ) as $meta_key ) : ?> |
|
| 105 | + <?php do_action('wpinv_meta_values_metabox_before', $post); ?> |
|
| 106 | + <?php foreach (apply_filters('wpinv_show_meta_values_for_keys', array()) as $meta_key) : ?> |
|
| 107 | 107 | <div class="wpinv_item_custom_id form-group"> |
| 108 | - <?php echo esc_html( $meta_key ); ?> — <?php echo esc_html( get_post_meta( $item->get_id(), '_wpinv_' . $meta_key, true ) ); ?> |
|
| 108 | + <?php echo esc_html($meta_key); ?> — <?php echo esc_html(get_post_meta($item->get_id(), '_wpinv_' . $meta_key, true)); ?> |
|
| 109 | 109 | </div> |
| 110 | 110 | <?php endforeach; ?> |
| 111 | - <?php do_action( 'wpinv_meta_values_metabox_after', $post ); ?> |
|
| 112 | - <?php do_action( 'wpinv_item_info_metabox', $item ); ?> |
|
| 111 | + <?php do_action('wpinv_meta_values_metabox_after', $post); ?> |
|
| 112 | + <?php do_action('wpinv_item_info_metabox', $item); ?> |
|
| 113 | 113 | </div> |
| 114 | 114 | <?php |
| 115 | 115 | |
@@ -119,16 +119,16 @@ discard block |
||
| 119 | 119 | * Returns item type tolltip. |
| 120 | 120 | * |
| 121 | 121 | */ |
| 122 | - public static function get_tooltip( $post ) { |
|
| 122 | + public static function get_tooltip($post) { |
|
| 123 | 123 | |
| 124 | 124 | ob_start(); |
| 125 | 125 | ?> |
| 126 | 126 | |
| 127 | - <?php _e( 'Standard: Standard item type', 'invoicing' ); ?> |
|
| 128 | - <?php _e( 'Fee: Like Registration Fee, Sign up Fee etc', 'invoicing' ); ?> |
|
| 127 | + <?php _e('Standard: Standard item type', 'invoicing'); ?> |
|
| 128 | + <?php _e('Fee: Like Registration Fee, Sign up Fee etc', 'invoicing'); ?> |
|
| 129 | 129 | |
| 130 | 130 | <?php |
| 131 | - do_action( 'wpinv_item_info_metabox_after', $post ); |
|
| 131 | + do_action('wpinv_item_info_metabox_after', $post); |
|
| 132 | 132 | |
| 133 | 133 | return ob_get_clean(); |
| 134 | 134 | |
@@ -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,54 +21,54 @@ 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 form. |
| 27 | - $form = new GetPaid_Payment_Form( $post ); |
|
| 27 | + $form = new GetPaid_Payment_Form($post); |
|
| 28 | 28 | |
| 29 | 29 | ?> |
| 30 | 30 | |
| 31 | 31 | <div class='bsui' style='padding-top: 10px;'> |
| 32 | - <?php do_action( 'wpinv_payment_form_before_info_metabox', $form ); ?> |
|
| 32 | + <?php do_action('wpinv_payment_form_before_info_metabox', $form); ?> |
|
| 33 | 33 | |
| 34 | 34 | <div class="wpinv_payment_form_shortcode form-group row"> |
| 35 | 35 | <label for="wpinv_payment_form_shortcode" class="col-sm-12 col-form-label"> |
| 36 | - <?php _e( 'Payment Form Shortcode', 'invoicing' ); ?> |
|
| 37 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a payment form', 'invoicing' ); ?>"></span> |
|
| 36 | + <?php _e('Payment Form Shortcode', 'invoicing'); ?> |
|
| 37 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a payment form', 'invoicing'); ?>"></span> |
|
| 38 | 38 | </label> |
| 39 | 39 | |
| 40 | 40 | <div class="col-sm-12"> |
| 41 | - <input onClick="this.select()" type="text" id="wpinv_payment_form_shortcode" value="[getpaid form=<?php echo esc_attr( $form->get_id() ); ?>]" style="width: 100%;" /> |
|
| 41 | + <input onClick="this.select()" type="text" id="wpinv_payment_form_shortcode" value="[getpaid form=<?php echo esc_attr($form->get_id()); ?>]" style="width: 100%;" /> |
|
| 42 | 42 | </div> |
| 43 | 43 | </div> |
| 44 | 44 | |
| 45 | 45 | <div class="wpinv_payment_form_buy_shortcode form-group row"> |
| 46 | 46 | <label for="wpinv_payment_form_buy_shortcode" class="col-sm-12 col-form-label"> |
| 47 | - <?php _e( 'Payment Button Shortcode', 'invoicing' ); ?> |
|
| 48 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a buy now button', 'invoicing' ); ?>"></span> |
|
| 47 | + <?php _e('Payment Button Shortcode', 'invoicing'); ?> |
|
| 48 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a buy now button', 'invoicing'); ?>"></span> |
|
| 49 | 49 | </label> |
| 50 | 50 | |
| 51 | 51 | <div class="col-sm-12"> |
| 52 | - <input onClick="this.select()" type="text" id="wpinv_payment_form_buy_shortcode" value="[getpaid form=<?php echo esc_attr( $form->get_id() ); ?> button='Buy Now']" style="width: 100%;" /> |
|
| 52 | + <input onClick="this.select()" type="text" id="wpinv_payment_form_buy_shortcode" value="[getpaid form=<?php echo esc_attr($form->get_id()); ?> button='Buy Now']" style="width: 100%;" /> |
|
| 53 | 53 | <small class="form-text text-muted"> |
| 54 | - <?php _e( 'Or use the following URL in a link:', 'invoicing' ); ?> |
|
| 55 | - <code>#getpaid-form-<?php echo intval( $form->get_id() ); ?></code> |
|
| 54 | + <?php _e('Or use the following URL in a link:', 'invoicing'); ?> |
|
| 55 | + <code>#getpaid-form-<?php echo intval($form->get_id()); ?></code> |
|
| 56 | 56 | </small> |
| 57 | 57 | </div> |
| 58 | 58 | </div> |
| 59 | 59 | |
| 60 | 60 | <div class="wpinv_item_buy_url form-group row"> |
| 61 | 61 | <label for="wpinv_item_buy_url" class="col-sm-12 col-form-label"> |
| 62 | - <?php _e( 'Direct Payment URL', 'invoicing' ); ?> |
|
| 63 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'You can use this in an iFrame to embed the payment form on another website', 'invoicing' ); ?>"></span> |
|
| 62 | + <?php _e('Direct Payment URL', 'invoicing'); ?> |
|
| 63 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('You can use this in an iFrame to embed the payment form on another website', 'invoicing'); ?>"></span> |
|
| 64 | 64 | </label> |
| 65 | 65 | |
| 66 | 66 | <div class="col-sm-12"> |
| 67 | - <input onClick="this.select()" type="text" id="wpinv_item_buy_url" value="<?php echo esc_url( getpaid_embed_url( $form->get_id(), false ) ); ?>" style="width: 100%;" readonly/> |
|
| 67 | + <input onClick="this.select()" type="text" id="wpinv_item_buy_url" value="<?php echo esc_url(getpaid_embed_url($form->get_id(), false)); ?>" style="width: 100%;" readonly/> |
|
| 68 | 68 | </div> |
| 69 | 69 | </div> |
| 70 | 70 | |
| 71 | - <?php do_action( 'wpinv_payment_form_info_metabox', $form ); ?> |
|
| 71 | + <?php do_action('wpinv_payment_form_info_metabox', $form); ?> |
|
| 72 | 72 | </div> |
| 73 | 73 | <?php |
| 74 | 74 | |
@@ -1,38 +1,38 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // MUST have WordPress. |
| 3 | -if ( ! defined( 'WPINC' ) ) { |
|
| 4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 3 | +if (!defined('WPINC')) { |
|
| 4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | class WPInv_Meta_Box_Notes { |
| 8 | - public static function output( $post ) { |
|
| 8 | + public static function output($post) { |
|
| 9 | 9 | global $post; |
| 10 | 10 | |
| 11 | - $notes = wpinv_get_invoice_notes( $post->ID ); |
|
| 11 | + $notes = wpinv_get_invoice_notes($post->ID); |
|
| 12 | 12 | |
| 13 | 13 | echo '<ul class="invoice_notes">'; |
| 14 | 14 | |
| 15 | - if ( $notes ) { |
|
| 16 | - foreach ( $notes as $note ) { |
|
| 17 | - wpinv_get_invoice_note_line_item( $note ); |
|
| 15 | + if ($notes) { |
|
| 16 | + foreach ($notes as $note) { |
|
| 17 | + wpinv_get_invoice_note_line_item($note); |
|
| 18 | 18 | } |
| 19 | 19 | } else { |
| 20 | - echo '<li>' . __( 'There are no notes yet.', 'invoicing' ) . '</li>'; |
|
| 20 | + echo '<li>' . __('There are no notes yet.', 'invoicing') . '</li>'; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | echo '</ul>'; |
| 24 | 24 | ?> |
| 25 | 25 | <div class="add_note"> |
| 26 | - <h4><?php _e( 'Add note', 'invoicing' ); ?></h4> |
|
| 26 | + <h4><?php _e('Add note', 'invoicing'); ?></h4> |
|
| 27 | 27 | <p> |
| 28 | 28 | <textarea type="text" name="invoice_note" id="add_invoice_note" class="input-text" cols="20" rows="5"></textarea> |
| 29 | 29 | </p> |
| 30 | 30 | <p> |
| 31 | 31 | <select name="invoice_note_type" id="invoice_note_type" class="regular-text"> |
| 32 | - <option value=""><?php _e( 'Private note', 'invoicing' ); ?></option> |
|
| 33 | - <option value="customer"><?php _e( 'Note to customer', 'invoicing' ); ?></option> |
|
| 32 | + <option value=""><?php _e('Private note', 'invoicing'); ?></option> |
|
| 33 | + <option value="customer"><?php _e('Note to customer', 'invoicing'); ?></option> |
|
| 34 | 34 | </select> |
| 35 | - <a href="#" class="add_note button"><?php _e( 'Add', 'invoicing' ); ?></a> <span class="description"><?php _e( 'Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing' ); ?></span> |
|
| 35 | + <a href="#" class="add_note button"><?php _e('Add', 'invoicing'); ?></a> <span class="description"><?php _e('Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing'); ?></span> |
|
| 36 | 36 | </p> |
| 37 | 37 | </div> |
| 38 | 38 | <?php |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | // Load WP_List_Table if not loaded |
| 13 | 13 | if ( ! class_exists( 'WP_List_Table' ) ) { |
| 14 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
| 14 | + require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -23,369 +23,369 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | class WPInv_Customers_Table extends WP_List_Table { |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @var int Number of items per page |
|
| 28 | - * @since 1.0.19 |
|
| 29 | - */ |
|
| 30 | - public $per_page = 10; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * @var int Number of items |
|
| 34 | - * @since 1.0.19 |
|
| 35 | - */ |
|
| 36 | - public $total = 0; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Get things started |
|
| 40 | - * |
|
| 41 | - * @since 1.0.19 |
|
| 42 | - * @see WP_List_Table::__construct() |
|
| 43 | - */ |
|
| 44 | - public function __construct() { |
|
| 45 | - |
|
| 46 | - // Set parent defaults |
|
| 47 | - parent::__construct( |
|
| 26 | + /** |
|
| 27 | + * @var int Number of items per page |
|
| 28 | + * @since 1.0.19 |
|
| 29 | + */ |
|
| 30 | + public $per_page = 10; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * @var int Number of items |
|
| 34 | + * @since 1.0.19 |
|
| 35 | + */ |
|
| 36 | + public $total = 0; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Get things started |
|
| 40 | + * |
|
| 41 | + * @since 1.0.19 |
|
| 42 | + * @see WP_List_Table::__construct() |
|
| 43 | + */ |
|
| 44 | + public function __construct() { |
|
| 45 | + |
|
| 46 | + // Set parent defaults |
|
| 47 | + parent::__construct( |
|
| 48 | 48 | array( |
| 49 | - 'singular' => 'id', |
|
| 50 | - 'plural' => 'ids', |
|
| 51 | - 'ajax' => false, |
|
| 49 | + 'singular' => 'id', |
|
| 50 | + 'plural' => 'ids', |
|
| 51 | + 'ajax' => false, |
|
| 52 | 52 | ) |
| 53 | 53 | ); |
| 54 | 54 | |
| 55 | - } |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Gets the name of the primary column. |
|
| 59 | - * |
|
| 60 | - * @since 1.0.19 |
|
| 61 | - * @access protected |
|
| 62 | - * |
|
| 63 | - * @return string Name of the primary column. |
|
| 64 | - */ |
|
| 65 | - protected function get_primary_column_name() { |
|
| 66 | - return 'name'; |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * This function renders most of the columns in the list table. |
|
| 71 | - * |
|
| 72 | - * @since 1.0.19 |
|
| 73 | - * |
|
| 74 | - * @param WP_User $item |
|
| 75 | - * @param string $column_name The name of the column |
|
| 76 | - * |
|
| 77 | - * @return string Column Name |
|
| 78 | - */ |
|
| 79 | - public function column_default( $item, $column_name ) { |
|
| 80 | - $value = esc_html( get_user_meta( $item->ID, '_wpinv_' . $column_name, true ) ); |
|
| 81 | - return apply_filters( 'wpinv_customers_table_column' . $column_name, $value, $item ); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * Displays the country column. |
|
| 86 | - * |
|
| 87 | - * @since 1.0.19 |
|
| 88 | - * |
|
| 89 | - * @param WP_User $user |
|
| 90 | - * |
|
| 91 | - * @return string Column Name |
|
| 92 | - */ |
|
| 93 | - public function column_country( $user ) { |
|
| 94 | - $country = wpinv_sanitize_country( $user->_wpinv_country ); |
|
| 95 | - if ( $country ) { |
|
| 96 | - $country = wpinv_country_name( $country ); |
|
| 97 | - } |
|
| 98 | - return esc_html( $country ); |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * Displays the state column. |
|
| 103 | - * |
|
| 104 | - * @since 1.0.19 |
|
| 105 | - * |
|
| 106 | - * @param WP_User $user |
|
| 107 | - * |
|
| 108 | - * @return string Column Name |
|
| 109 | - */ |
|
| 110 | - public function column_state( $user ) { |
|
| 111 | - $country = wpinv_sanitize_country( $user->_wpinv_country ); |
|
| 112 | - $state = $user->_wpinv_state; |
|
| 113 | - if ( $state ) { |
|
| 114 | - $state = wpinv_state_name( $state, $country ); |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - return esc_html( $state ); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * Displays the signup column. |
|
| 122 | - * |
|
| 123 | - * @since 1.0.19 |
|
| 124 | - * |
|
| 125 | - * @param WP_User $user |
|
| 126 | - * |
|
| 127 | - * @return string Column Name |
|
| 128 | - */ |
|
| 129 | - public function column_signup( $user ) { |
|
| 130 | - return getpaid_format_date_value( $user->user_registered ); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * Displays the total spent column. |
|
| 135 | - * |
|
| 136 | - * @since 1.0.19 |
|
| 137 | - * |
|
| 138 | - * @param WP_User $user |
|
| 139 | - * |
|
| 140 | - * @return string Column Name |
|
| 141 | - */ |
|
| 142 | - public function column_total( $user ) { |
|
| 143 | - return wpinv_price( $this->column_total_raw( $user ) ); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * Displays the total spent column. |
|
| 148 | - * |
|
| 149 | - * @since 1.0.19 |
|
| 150 | - * |
|
| 151 | - * @param WP_User $user |
|
| 152 | - * |
|
| 153 | - * @return float |
|
| 154 | - */ |
|
| 155 | - public function column_total_raw( $user ) { |
|
| 156 | - |
|
| 157 | - $args = array( |
|
| 158 | - 'data' => array( |
|
| 159 | - |
|
| 160 | - 'total' => array( |
|
| 161 | - 'type' => 'invoice_data', |
|
| 162 | - 'function' => 'SUM', |
|
| 163 | - 'name' => 'total_sales', |
|
| 164 | - ), |
|
| 165 | - |
|
| 166 | - ), |
|
| 167 | - 'where' => array( |
|
| 168 | - |
|
| 169 | - 'author' => array( |
|
| 170 | - 'type' => 'post_data', |
|
| 171 | - 'value' => absint( $user->ID ), |
|
| 172 | - 'key' => 'posts.post_author', |
|
| 173 | - 'operator' => '=', |
|
| 174 | - ), |
|
| 175 | - |
|
| 176 | - ), |
|
| 177 | - 'query_type' => 'get_var', |
|
| 178 | - 'invoice_status' => array( 'wpi-renewal', 'wpi-processing', 'publish' ), |
|
| 179 | - ); |
|
| 180 | - |
|
| 181 | - return wpinv_round_amount( GetPaid_Reports_Helper::get_invoice_report_data( $args ) ); |
|
| 182 | - |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - /** |
|
| 186 | - * Displays the total spent column. |
|
| 187 | - * |
|
| 188 | - * @since 1.0.19 |
|
| 189 | - * |
|
| 190 | - * @param WP_User $user |
|
| 191 | - * |
|
| 192 | - * @return string Column Name |
|
| 193 | - */ |
|
| 194 | - public function column_invoices( $user ) { |
|
| 195 | - |
|
| 196 | - $args = array( |
|
| 197 | - 'data' => array( |
|
| 198 | - |
|
| 199 | - 'ID' => array( |
|
| 200 | - 'type' => 'post_data', |
|
| 201 | - 'function' => 'COUNT', |
|
| 202 | - 'name' => 'count', |
|
| 203 | - 'distinct' => true, |
|
| 204 | - ), |
|
| 205 | - |
|
| 206 | - ), |
|
| 207 | - 'where' => array( |
|
| 208 | - |
|
| 209 | - 'author' => array( |
|
| 210 | - 'type' => 'post_data', |
|
| 211 | - 'value' => absint( $user->ID ), |
|
| 212 | - 'key' => 'posts.post_author', |
|
| 213 | - 'operator' => '=', |
|
| 214 | - ), |
|
| 215 | - |
|
| 216 | - ), |
|
| 217 | - 'query_type' => 'get_var', |
|
| 218 | - 'invoice_status' => array_keys( wpinv_get_invoice_statuses() ), |
|
| 219 | - ); |
|
| 220 | - |
|
| 221 | - return absint( GetPaid_Reports_Helper::get_invoice_report_data( $args ) ); |
|
| 222 | - |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - /** |
|
| 226 | - * Generates content for a single row of the table |
|
| 227 | - * @since 1.0.19 |
|
| 228 | - * |
|
| 229 | - * @param int $item The user id. |
|
| 230 | - */ |
|
| 231 | - public function single_row( $item ) { |
|
| 232 | - $item = get_user_by( 'id', $item ); |
|
| 233 | - |
|
| 234 | - if ( empty( $item ) ) { |
|
| 235 | - return; |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - echo '<tr>'; |
|
| 239 | - $this->single_row_columns( $item ); |
|
| 240 | - echo '</tr>'; |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - /** |
|
| 244 | - * Displays the customers name |
|
| 245 | - * |
|
| 246 | - * @param WP_User $customer customer. |
|
| 247 | - * @return string |
|
| 248 | - */ |
|
| 249 | - public function column_name( $customer ) { |
|
| 250 | - |
|
| 251 | - // Customer view URL. |
|
| 252 | - $view_url = esc_url( add_query_arg( 'user_id', $customer->ID, admin_url( 'user-edit.php' ) ) ); |
|
| 253 | - $row_actions = $this->row_actions( |
|
| 254 | - array( |
|
| 255 | - 'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>', |
|
| 256 | - ) |
|
| 257 | - ); |
|
| 258 | - |
|
| 259 | - // Get user's address. |
|
| 260 | - $address = wpinv_get_user_address( $customer->ID ); |
|
| 261 | - |
|
| 262 | - // Customer email address. |
|
| 263 | - $email = sanitize_email( $customer->user_email ); |
|
| 264 | - |
|
| 265 | - // Customer's avatar. |
|
| 266 | - $avatar = esc_url( get_avatar_url( $email ) ); |
|
| 267 | - $avatar = "<img src='$avatar' height='32' width='32'/>"; |
|
| 268 | - |
|
| 269 | - // Customer's name. |
|
| 270 | - $name = esc_html( "{$address['first_name']} {$address['last_name']}" ); |
|
| 271 | - |
|
| 272 | - if ( ! empty( $name ) ) { |
|
| 273 | - $name = "<div style='overflow: hidden;height: 18px;'>$name</div>"; |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - $email = "<div class='row-title'><a href='$view_url'>$email</a></div>"; |
|
| 277 | - |
|
| 278 | - return "<div style='display: flex;'><div>$avatar</div><div style='margin-left: 10px;'>$name<strong>$email</strong>$row_actions</div></div>"; |
|
| 279 | - |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - /** |
|
| 283 | - * Retrieve the table columns |
|
| 284 | - * |
|
| 285 | - * @since 1.0.19 |
|
| 286 | - * @return array $columns Array of all the list table columns |
|
| 287 | - */ |
|
| 288 | - public function get_columns() { |
|
| 289 | - |
|
| 290 | - $columns = array( |
|
| 291 | - 'name' => __( 'Name', 'invoicing' ), |
|
| 292 | - 'country' => __( 'Country', 'invoicing' ), |
|
| 293 | - 'state' => __( 'State', 'invoicing' ), |
|
| 294 | - 'city' => __( 'City', 'invoicing' ), |
|
| 295 | - 'zip' => __( 'ZIP', 'invoicing' ), |
|
| 296 | - 'address' => __( 'Address', 'invoicing' ), |
|
| 297 | - 'phone' => __( 'Phone', 'invoicing' ), |
|
| 298 | - 'company' => __( 'Company', 'invoicing' ), |
|
| 299 | - 'invoices' => __( 'Invoices', 'invoicing' ), |
|
| 300 | - 'total' => __( 'Total Spend', 'invoicing' ), |
|
| 301 | - 'signup' => __( 'Date created', 'invoicing' ), |
|
| 302 | - ); |
|
| 303 | - return apply_filters( 'wpinv_customers_table_columns', $columns ); |
|
| 304 | - |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - /** |
|
| 308 | - * Retrieve the current page number |
|
| 309 | - * |
|
| 310 | - * @since 1.0.19 |
|
| 311 | - * @return int Current page number |
|
| 312 | - */ |
|
| 313 | - public function get_paged() { |
|
| 314 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - /** |
|
| 318 | - * Returns bulk actions. |
|
| 319 | - * |
|
| 320 | - * @since 1.0.19 |
|
| 321 | - * @return void |
|
| 322 | - */ |
|
| 323 | - public function bulk_actions( $which = '' ) { |
|
| 324 | - return array(); |
|
| 325 | - } |
|
| 326 | - |
|
| 327 | - /** |
|
| 328 | - * Prepares the display query |
|
| 329 | - */ |
|
| 330 | - public function prepare_query() { |
|
| 331 | - global $wpdb; |
|
| 332 | - |
|
| 333 | - $post_types = ''; |
|
| 334 | - |
|
| 335 | - foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
| 336 | - $post_types .= $wpdb->prepare( 'post_type=%s OR ', $post_type ); |
|
| 337 | - } |
|
| 338 | - |
|
| 339 | - $post_types = rtrim( $post_types, ' OR' ); |
|
| 340 | - |
|
| 341 | - // Maybe search. |
|
| 342 | - if ( ! empty( $_POST['s'] ) ) { |
|
| 343 | - $users = get_users( |
|
| 344 | - array( |
|
| 345 | - 'search' => '*' . sanitize_text_field( urldecode( $_POST['s'] ) ) . '*', |
|
| 346 | - 'search_columns' => array( 'user_login', 'user_email', 'display_name' ), |
|
| 347 | - 'fields' => 'ID', |
|
| 348 | - ) |
|
| 349 | - ); |
|
| 350 | - |
|
| 351 | - $users = implode( ', ', $users ); |
|
| 352 | - $post_types = "($post_types) AND ( post_author IN ( $users ) )"; |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - // Users with invoices. |
|
| 356 | - $customers = $wpdb->get_col( |
|
| 357 | - $wpdb->prepare( |
|
| 358 | - "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types LIMIT %d,%d", |
|
| 359 | - $this->get_paged() * 10 - 10, |
|
| 360 | - $this->per_page |
|
| 361 | - ) |
|
| 362 | - ); |
|
| 363 | - |
|
| 364 | - $this->items = $customers; |
|
| 365 | - $this->total = (int) $wpdb->get_var( "SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts WHERE $post_types" ); |
|
| 366 | - |
|
| 367 | - } |
|
| 368 | - |
|
| 369 | - /** |
|
| 370 | - * Setup the final data for the table |
|
| 371 | - * |
|
| 372 | - * @since 1.0.19 |
|
| 373 | - * @return void |
|
| 374 | - */ |
|
| 375 | - public function prepare_items() { |
|
| 376 | - $columns = $this->get_columns(); |
|
| 377 | - $hidden = array(); // No hidden columns |
|
| 378 | - $sortable = $this->get_sortable_columns(); |
|
| 379 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
| 380 | - $this->prepare_query(); |
|
| 381 | - |
|
| 382 | - $this->set_pagination_args( |
|
| 383 | - array( |
|
| 384 | - 'total_items' => $this->total, |
|
| 385 | - 'per_page' => $this->per_page, |
|
| 386 | - 'total_pages' => ceil( $this->total / $this->per_page ), |
|
| 387 | - ) |
|
| 388 | - ); |
|
| 389 | - |
|
| 390 | - } |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Gets the name of the primary column. |
|
| 59 | + * |
|
| 60 | + * @since 1.0.19 |
|
| 61 | + * @access protected |
|
| 62 | + * |
|
| 63 | + * @return string Name of the primary column. |
|
| 64 | + */ |
|
| 65 | + protected function get_primary_column_name() { |
|
| 66 | + return 'name'; |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * This function renders most of the columns in the list table. |
|
| 71 | + * |
|
| 72 | + * @since 1.0.19 |
|
| 73 | + * |
|
| 74 | + * @param WP_User $item |
|
| 75 | + * @param string $column_name The name of the column |
|
| 76 | + * |
|
| 77 | + * @return string Column Name |
|
| 78 | + */ |
|
| 79 | + public function column_default( $item, $column_name ) { |
|
| 80 | + $value = esc_html( get_user_meta( $item->ID, '_wpinv_' . $column_name, true ) ); |
|
| 81 | + return apply_filters( 'wpinv_customers_table_column' . $column_name, $value, $item ); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * Displays the country column. |
|
| 86 | + * |
|
| 87 | + * @since 1.0.19 |
|
| 88 | + * |
|
| 89 | + * @param WP_User $user |
|
| 90 | + * |
|
| 91 | + * @return string Column Name |
|
| 92 | + */ |
|
| 93 | + public function column_country( $user ) { |
|
| 94 | + $country = wpinv_sanitize_country( $user->_wpinv_country ); |
|
| 95 | + if ( $country ) { |
|
| 96 | + $country = wpinv_country_name( $country ); |
|
| 97 | + } |
|
| 98 | + return esc_html( $country ); |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * Displays the state column. |
|
| 103 | + * |
|
| 104 | + * @since 1.0.19 |
|
| 105 | + * |
|
| 106 | + * @param WP_User $user |
|
| 107 | + * |
|
| 108 | + * @return string Column Name |
|
| 109 | + */ |
|
| 110 | + public function column_state( $user ) { |
|
| 111 | + $country = wpinv_sanitize_country( $user->_wpinv_country ); |
|
| 112 | + $state = $user->_wpinv_state; |
|
| 113 | + if ( $state ) { |
|
| 114 | + $state = wpinv_state_name( $state, $country ); |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + return esc_html( $state ); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * Displays the signup column. |
|
| 122 | + * |
|
| 123 | + * @since 1.0.19 |
|
| 124 | + * |
|
| 125 | + * @param WP_User $user |
|
| 126 | + * |
|
| 127 | + * @return string Column Name |
|
| 128 | + */ |
|
| 129 | + public function column_signup( $user ) { |
|
| 130 | + return getpaid_format_date_value( $user->user_registered ); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * Displays the total spent column. |
|
| 135 | + * |
|
| 136 | + * @since 1.0.19 |
|
| 137 | + * |
|
| 138 | + * @param WP_User $user |
|
| 139 | + * |
|
| 140 | + * @return string Column Name |
|
| 141 | + */ |
|
| 142 | + public function column_total( $user ) { |
|
| 143 | + return wpinv_price( $this->column_total_raw( $user ) ); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * Displays the total spent column. |
|
| 148 | + * |
|
| 149 | + * @since 1.0.19 |
|
| 150 | + * |
|
| 151 | + * @param WP_User $user |
|
| 152 | + * |
|
| 153 | + * @return float |
|
| 154 | + */ |
|
| 155 | + public function column_total_raw( $user ) { |
|
| 156 | + |
|
| 157 | + $args = array( |
|
| 158 | + 'data' => array( |
|
| 159 | + |
|
| 160 | + 'total' => array( |
|
| 161 | + 'type' => 'invoice_data', |
|
| 162 | + 'function' => 'SUM', |
|
| 163 | + 'name' => 'total_sales', |
|
| 164 | + ), |
|
| 165 | + |
|
| 166 | + ), |
|
| 167 | + 'where' => array( |
|
| 168 | + |
|
| 169 | + 'author' => array( |
|
| 170 | + 'type' => 'post_data', |
|
| 171 | + 'value' => absint( $user->ID ), |
|
| 172 | + 'key' => 'posts.post_author', |
|
| 173 | + 'operator' => '=', |
|
| 174 | + ), |
|
| 175 | + |
|
| 176 | + ), |
|
| 177 | + 'query_type' => 'get_var', |
|
| 178 | + 'invoice_status' => array( 'wpi-renewal', 'wpi-processing', 'publish' ), |
|
| 179 | + ); |
|
| 180 | + |
|
| 181 | + return wpinv_round_amount( GetPaid_Reports_Helper::get_invoice_report_data( $args ) ); |
|
| 182 | + |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + /** |
|
| 186 | + * Displays the total spent column. |
|
| 187 | + * |
|
| 188 | + * @since 1.0.19 |
|
| 189 | + * |
|
| 190 | + * @param WP_User $user |
|
| 191 | + * |
|
| 192 | + * @return string Column Name |
|
| 193 | + */ |
|
| 194 | + public function column_invoices( $user ) { |
|
| 195 | + |
|
| 196 | + $args = array( |
|
| 197 | + 'data' => array( |
|
| 198 | + |
|
| 199 | + 'ID' => array( |
|
| 200 | + 'type' => 'post_data', |
|
| 201 | + 'function' => 'COUNT', |
|
| 202 | + 'name' => 'count', |
|
| 203 | + 'distinct' => true, |
|
| 204 | + ), |
|
| 205 | + |
|
| 206 | + ), |
|
| 207 | + 'where' => array( |
|
| 208 | + |
|
| 209 | + 'author' => array( |
|
| 210 | + 'type' => 'post_data', |
|
| 211 | + 'value' => absint( $user->ID ), |
|
| 212 | + 'key' => 'posts.post_author', |
|
| 213 | + 'operator' => '=', |
|
| 214 | + ), |
|
| 215 | + |
|
| 216 | + ), |
|
| 217 | + 'query_type' => 'get_var', |
|
| 218 | + 'invoice_status' => array_keys( wpinv_get_invoice_statuses() ), |
|
| 219 | + ); |
|
| 220 | + |
|
| 221 | + return absint( GetPaid_Reports_Helper::get_invoice_report_data( $args ) ); |
|
| 222 | + |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + /** |
|
| 226 | + * Generates content for a single row of the table |
|
| 227 | + * @since 1.0.19 |
|
| 228 | + * |
|
| 229 | + * @param int $item The user id. |
|
| 230 | + */ |
|
| 231 | + public function single_row( $item ) { |
|
| 232 | + $item = get_user_by( 'id', $item ); |
|
| 233 | + |
|
| 234 | + if ( empty( $item ) ) { |
|
| 235 | + return; |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + echo '<tr>'; |
|
| 239 | + $this->single_row_columns( $item ); |
|
| 240 | + echo '</tr>'; |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * Displays the customers name |
|
| 245 | + * |
|
| 246 | + * @param WP_User $customer customer. |
|
| 247 | + * @return string |
|
| 248 | + */ |
|
| 249 | + public function column_name( $customer ) { |
|
| 250 | + |
|
| 251 | + // Customer view URL. |
|
| 252 | + $view_url = esc_url( add_query_arg( 'user_id', $customer->ID, admin_url( 'user-edit.php' ) ) ); |
|
| 253 | + $row_actions = $this->row_actions( |
|
| 254 | + array( |
|
| 255 | + 'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>', |
|
| 256 | + ) |
|
| 257 | + ); |
|
| 258 | + |
|
| 259 | + // Get user's address. |
|
| 260 | + $address = wpinv_get_user_address( $customer->ID ); |
|
| 261 | + |
|
| 262 | + // Customer email address. |
|
| 263 | + $email = sanitize_email( $customer->user_email ); |
|
| 264 | + |
|
| 265 | + // Customer's avatar. |
|
| 266 | + $avatar = esc_url( get_avatar_url( $email ) ); |
|
| 267 | + $avatar = "<img src='$avatar' height='32' width='32'/>"; |
|
| 268 | + |
|
| 269 | + // Customer's name. |
|
| 270 | + $name = esc_html( "{$address['first_name']} {$address['last_name']}" ); |
|
| 271 | + |
|
| 272 | + if ( ! empty( $name ) ) { |
|
| 273 | + $name = "<div style='overflow: hidden;height: 18px;'>$name</div>"; |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + $email = "<div class='row-title'><a href='$view_url'>$email</a></div>"; |
|
| 277 | + |
|
| 278 | + return "<div style='display: flex;'><div>$avatar</div><div style='margin-left: 10px;'>$name<strong>$email</strong>$row_actions</div></div>"; |
|
| 279 | + |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + /** |
|
| 283 | + * Retrieve the table columns |
|
| 284 | + * |
|
| 285 | + * @since 1.0.19 |
|
| 286 | + * @return array $columns Array of all the list table columns |
|
| 287 | + */ |
|
| 288 | + public function get_columns() { |
|
| 289 | + |
|
| 290 | + $columns = array( |
|
| 291 | + 'name' => __( 'Name', 'invoicing' ), |
|
| 292 | + 'country' => __( 'Country', 'invoicing' ), |
|
| 293 | + 'state' => __( 'State', 'invoicing' ), |
|
| 294 | + 'city' => __( 'City', 'invoicing' ), |
|
| 295 | + 'zip' => __( 'ZIP', 'invoicing' ), |
|
| 296 | + 'address' => __( 'Address', 'invoicing' ), |
|
| 297 | + 'phone' => __( 'Phone', 'invoicing' ), |
|
| 298 | + 'company' => __( 'Company', 'invoicing' ), |
|
| 299 | + 'invoices' => __( 'Invoices', 'invoicing' ), |
|
| 300 | + 'total' => __( 'Total Spend', 'invoicing' ), |
|
| 301 | + 'signup' => __( 'Date created', 'invoicing' ), |
|
| 302 | + ); |
|
| 303 | + return apply_filters( 'wpinv_customers_table_columns', $columns ); |
|
| 304 | + |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + /** |
|
| 308 | + * Retrieve the current page number |
|
| 309 | + * |
|
| 310 | + * @since 1.0.19 |
|
| 311 | + * @return int Current page number |
|
| 312 | + */ |
|
| 313 | + public function get_paged() { |
|
| 314 | + return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + /** |
|
| 318 | + * Returns bulk actions. |
|
| 319 | + * |
|
| 320 | + * @since 1.0.19 |
|
| 321 | + * @return void |
|
| 322 | + */ |
|
| 323 | + public function bulk_actions( $which = '' ) { |
|
| 324 | + return array(); |
|
| 325 | + } |
|
| 326 | + |
|
| 327 | + /** |
|
| 328 | + * Prepares the display query |
|
| 329 | + */ |
|
| 330 | + public function prepare_query() { |
|
| 331 | + global $wpdb; |
|
| 332 | + |
|
| 333 | + $post_types = ''; |
|
| 334 | + |
|
| 335 | + foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
| 336 | + $post_types .= $wpdb->prepare( 'post_type=%s OR ', $post_type ); |
|
| 337 | + } |
|
| 338 | + |
|
| 339 | + $post_types = rtrim( $post_types, ' OR' ); |
|
| 340 | + |
|
| 341 | + // Maybe search. |
|
| 342 | + if ( ! empty( $_POST['s'] ) ) { |
|
| 343 | + $users = get_users( |
|
| 344 | + array( |
|
| 345 | + 'search' => '*' . sanitize_text_field( urldecode( $_POST['s'] ) ) . '*', |
|
| 346 | + 'search_columns' => array( 'user_login', 'user_email', 'display_name' ), |
|
| 347 | + 'fields' => 'ID', |
|
| 348 | + ) |
|
| 349 | + ); |
|
| 350 | + |
|
| 351 | + $users = implode( ', ', $users ); |
|
| 352 | + $post_types = "($post_types) AND ( post_author IN ( $users ) )"; |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + // Users with invoices. |
|
| 356 | + $customers = $wpdb->get_col( |
|
| 357 | + $wpdb->prepare( |
|
| 358 | + "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types LIMIT %d,%d", |
|
| 359 | + $this->get_paged() * 10 - 10, |
|
| 360 | + $this->per_page |
|
| 361 | + ) |
|
| 362 | + ); |
|
| 363 | + |
|
| 364 | + $this->items = $customers; |
|
| 365 | + $this->total = (int) $wpdb->get_var( "SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts WHERE $post_types" ); |
|
| 366 | + |
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + /** |
|
| 370 | + * Setup the final data for the table |
|
| 371 | + * |
|
| 372 | + * @since 1.0.19 |
|
| 373 | + * @return void |
|
| 374 | + */ |
|
| 375 | + public function prepare_items() { |
|
| 376 | + $columns = $this->get_columns(); |
|
| 377 | + $hidden = array(); // No hidden columns |
|
| 378 | + $sortable = $this->get_sortable_columns(); |
|
| 379 | + $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
| 380 | + $this->prepare_query(); |
|
| 381 | + |
|
| 382 | + $this->set_pagination_args( |
|
| 383 | + array( |
|
| 384 | + 'total_items' => $this->total, |
|
| 385 | + 'per_page' => $this->per_page, |
|
| 386 | + 'total_pages' => ceil( $this->total / $this->per_page ), |
|
| 387 | + ) |
|
| 388 | + ); |
|
| 389 | + |
|
| 390 | + } |
|
| 391 | 391 | } |
@@ -5,12 +5,12 @@ discard block |
||
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | 7 | // Exit if accessed directly |
| 8 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 8 | +if (!defined('ABSPATH')) { |
|
| 9 | 9 | exit; |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | // Load WP_List_Table if not loaded |
| 13 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
| 13 | +if (!class_exists('WP_List_Table')) { |
|
| 14 | 14 | require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -76,9 +76,9 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @return string Column Name |
| 78 | 78 | */ |
| 79 | - public function column_default( $item, $column_name ) { |
|
| 80 | - $value = esc_html( get_user_meta( $item->ID, '_wpinv_' . $column_name, true ) ); |
|
| 81 | - return apply_filters( 'wpinv_customers_table_column' . $column_name, $value, $item ); |
|
| 79 | + public function column_default($item, $column_name) { |
|
| 80 | + $value = esc_html(get_user_meta($item->ID, '_wpinv_' . $column_name, true)); |
|
| 81 | + return apply_filters('wpinv_customers_table_column' . $column_name, $value, $item); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -90,12 +90,12 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @return string Column Name |
| 92 | 92 | */ |
| 93 | - public function column_country( $user ) { |
|
| 94 | - $country = wpinv_sanitize_country( $user->_wpinv_country ); |
|
| 95 | - if ( $country ) { |
|
| 96 | - $country = wpinv_country_name( $country ); |
|
| 93 | + public function column_country($user) { |
|
| 94 | + $country = wpinv_sanitize_country($user->_wpinv_country); |
|
| 95 | + if ($country) { |
|
| 96 | + $country = wpinv_country_name($country); |
|
| 97 | 97 | } |
| 98 | - return esc_html( $country ); |
|
| 98 | + return esc_html($country); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -107,14 +107,14 @@ discard block |
||
| 107 | 107 | * |
| 108 | 108 | * @return string Column Name |
| 109 | 109 | */ |
| 110 | - public function column_state( $user ) { |
|
| 111 | - $country = wpinv_sanitize_country( $user->_wpinv_country ); |
|
| 110 | + public function column_state($user) { |
|
| 111 | + $country = wpinv_sanitize_country($user->_wpinv_country); |
|
| 112 | 112 | $state = $user->_wpinv_state; |
| 113 | - if ( $state ) { |
|
| 114 | - $state = wpinv_state_name( $state, $country ); |
|
| 113 | + if ($state) { |
|
| 114 | + $state = wpinv_state_name($state, $country); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - return esc_html( $state ); |
|
| 117 | + return esc_html($state); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
@@ -126,8 +126,8 @@ discard block |
||
| 126 | 126 | * |
| 127 | 127 | * @return string Column Name |
| 128 | 128 | */ |
| 129 | - public function column_signup( $user ) { |
|
| 130 | - return getpaid_format_date_value( $user->user_registered ); |
|
| 129 | + public function column_signup($user) { |
|
| 130 | + return getpaid_format_date_value($user->user_registered); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | * |
| 140 | 140 | * @return string Column Name |
| 141 | 141 | */ |
| 142 | - public function column_total( $user ) { |
|
| 143 | - return wpinv_price( $this->column_total_raw( $user ) ); |
|
| 142 | + public function column_total($user) { |
|
| 143 | + return wpinv_price($this->column_total_raw($user)); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * |
| 153 | 153 | * @return float |
| 154 | 154 | */ |
| 155 | - public function column_total_raw( $user ) { |
|
| 155 | + public function column_total_raw($user) { |
|
| 156 | 156 | |
| 157 | 157 | $args = array( |
| 158 | 158 | 'data' => array( |
@@ -168,17 +168,17 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | 'author' => array( |
| 170 | 170 | 'type' => 'post_data', |
| 171 | - 'value' => absint( $user->ID ), |
|
| 171 | + 'value' => absint($user->ID), |
|
| 172 | 172 | 'key' => 'posts.post_author', |
| 173 | 173 | 'operator' => '=', |
| 174 | 174 | ), |
| 175 | 175 | |
| 176 | 176 | ), |
| 177 | 177 | 'query_type' => 'get_var', |
| 178 | - 'invoice_status' => array( 'wpi-renewal', 'wpi-processing', 'publish' ), |
|
| 178 | + 'invoice_status' => array('wpi-renewal', 'wpi-processing', 'publish'), |
|
| 179 | 179 | ); |
| 180 | 180 | |
| 181 | - return wpinv_round_amount( GetPaid_Reports_Helper::get_invoice_report_data( $args ) ); |
|
| 181 | + return wpinv_round_amount(GetPaid_Reports_Helper::get_invoice_report_data($args)); |
|
| 182 | 182 | |
| 183 | 183 | } |
| 184 | 184 | |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | * |
| 192 | 192 | * @return string Column Name |
| 193 | 193 | */ |
| 194 | - public function column_invoices( $user ) { |
|
| 194 | + public function column_invoices($user) { |
|
| 195 | 195 | |
| 196 | 196 | $args = array( |
| 197 | 197 | 'data' => array( |
@@ -208,17 +208,17 @@ discard block |
||
| 208 | 208 | |
| 209 | 209 | 'author' => array( |
| 210 | 210 | 'type' => 'post_data', |
| 211 | - 'value' => absint( $user->ID ), |
|
| 211 | + 'value' => absint($user->ID), |
|
| 212 | 212 | 'key' => 'posts.post_author', |
| 213 | 213 | 'operator' => '=', |
| 214 | 214 | ), |
| 215 | 215 | |
| 216 | 216 | ), |
| 217 | 217 | 'query_type' => 'get_var', |
| 218 | - 'invoice_status' => array_keys( wpinv_get_invoice_statuses() ), |
|
| 218 | + 'invoice_status' => array_keys(wpinv_get_invoice_statuses()), |
|
| 219 | 219 | ); |
| 220 | 220 | |
| 221 | - return absint( GetPaid_Reports_Helper::get_invoice_report_data( $args ) ); |
|
| 221 | + return absint(GetPaid_Reports_Helper::get_invoice_report_data($args)); |
|
| 222 | 222 | |
| 223 | 223 | } |
| 224 | 224 | |
@@ -228,15 +228,15 @@ discard block |
||
| 228 | 228 | * |
| 229 | 229 | * @param int $item The user id. |
| 230 | 230 | */ |
| 231 | - public function single_row( $item ) { |
|
| 232 | - $item = get_user_by( 'id', $item ); |
|
| 231 | + public function single_row($item) { |
|
| 232 | + $item = get_user_by('id', $item); |
|
| 233 | 233 | |
| 234 | - if ( empty( $item ) ) { |
|
| 234 | + if (empty($item)) { |
|
| 235 | 235 | return; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | echo '<tr>'; |
| 239 | - $this->single_row_columns( $item ); |
|
| 239 | + $this->single_row_columns($item); |
|
| 240 | 240 | echo '</tr>'; |
| 241 | 241 | } |
| 242 | 242 | |
@@ -246,30 +246,30 @@ discard block |
||
| 246 | 246 | * @param WP_User $customer customer. |
| 247 | 247 | * @return string |
| 248 | 248 | */ |
| 249 | - public function column_name( $customer ) { |
|
| 249 | + public function column_name($customer) { |
|
| 250 | 250 | |
| 251 | 251 | // Customer view URL. |
| 252 | - $view_url = esc_url( add_query_arg( 'user_id', $customer->ID, admin_url( 'user-edit.php' ) ) ); |
|
| 252 | + $view_url = esc_url(add_query_arg('user_id', $customer->ID, admin_url('user-edit.php'))); |
|
| 253 | 253 | $row_actions = $this->row_actions( |
| 254 | 254 | array( |
| 255 | - 'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>', |
|
| 255 | + 'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __('Edit Details', 'invoicing') . '</a>', |
|
| 256 | 256 | ) |
| 257 | 257 | ); |
| 258 | 258 | |
| 259 | 259 | // Get user's address. |
| 260 | - $address = wpinv_get_user_address( $customer->ID ); |
|
| 260 | + $address = wpinv_get_user_address($customer->ID); |
|
| 261 | 261 | |
| 262 | 262 | // Customer email address. |
| 263 | - $email = sanitize_email( $customer->user_email ); |
|
| 263 | + $email = sanitize_email($customer->user_email); |
|
| 264 | 264 | |
| 265 | 265 | // Customer's avatar. |
| 266 | - $avatar = esc_url( get_avatar_url( $email ) ); |
|
| 266 | + $avatar = esc_url(get_avatar_url($email)); |
|
| 267 | 267 | $avatar = "<img src='$avatar' height='32' width='32'/>"; |
| 268 | 268 | |
| 269 | 269 | // Customer's name. |
| 270 | - $name = esc_html( "{$address['first_name']} {$address['last_name']}" ); |
|
| 270 | + $name = esc_html("{$address['first_name']} {$address['last_name']}"); |
|
| 271 | 271 | |
| 272 | - if ( ! empty( $name ) ) { |
|
| 272 | + if (!empty($name)) { |
|
| 273 | 273 | $name = "<div style='overflow: hidden;height: 18px;'>$name</div>"; |
| 274 | 274 | } |
| 275 | 275 | |
@@ -288,19 +288,19 @@ discard block |
||
| 288 | 288 | public function get_columns() { |
| 289 | 289 | |
| 290 | 290 | $columns = array( |
| 291 | - 'name' => __( 'Name', 'invoicing' ), |
|
| 292 | - 'country' => __( 'Country', 'invoicing' ), |
|
| 293 | - 'state' => __( 'State', 'invoicing' ), |
|
| 294 | - 'city' => __( 'City', 'invoicing' ), |
|
| 295 | - 'zip' => __( 'ZIP', 'invoicing' ), |
|
| 296 | - 'address' => __( 'Address', 'invoicing' ), |
|
| 297 | - 'phone' => __( 'Phone', 'invoicing' ), |
|
| 298 | - 'company' => __( 'Company', 'invoicing' ), |
|
| 299 | - 'invoices' => __( 'Invoices', 'invoicing' ), |
|
| 300 | - 'total' => __( 'Total Spend', 'invoicing' ), |
|
| 301 | - 'signup' => __( 'Date created', 'invoicing' ), |
|
| 291 | + 'name' => __('Name', 'invoicing'), |
|
| 292 | + 'country' => __('Country', 'invoicing'), |
|
| 293 | + 'state' => __('State', 'invoicing'), |
|
| 294 | + 'city' => __('City', 'invoicing'), |
|
| 295 | + 'zip' => __('ZIP', 'invoicing'), |
|
| 296 | + 'address' => __('Address', 'invoicing'), |
|
| 297 | + 'phone' => __('Phone', 'invoicing'), |
|
| 298 | + 'company' => __('Company', 'invoicing'), |
|
| 299 | + 'invoices' => __('Invoices', 'invoicing'), |
|
| 300 | + 'total' => __('Total Spend', 'invoicing'), |
|
| 301 | + 'signup' => __('Date created', 'invoicing'), |
|
| 302 | 302 | ); |
| 303 | - return apply_filters( 'wpinv_customers_table_columns', $columns ); |
|
| 303 | + return apply_filters('wpinv_customers_table_columns', $columns); |
|
| 304 | 304 | |
| 305 | 305 | } |
| 306 | 306 | |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | * @return int Current page number |
| 312 | 312 | */ |
| 313 | 313 | public function get_paged() { |
| 314 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
| 314 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | /** |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | * @since 1.0.19 |
| 321 | 321 | * @return void |
| 322 | 322 | */ |
| 323 | - public function bulk_actions( $which = '' ) { |
|
| 323 | + public function bulk_actions($which = '') { |
|
| 324 | 324 | return array(); |
| 325 | 325 | } |
| 326 | 326 | |
@@ -332,23 +332,23 @@ discard block |
||
| 332 | 332 | |
| 333 | 333 | $post_types = ''; |
| 334 | 334 | |
| 335 | - foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
| 336 | - $post_types .= $wpdb->prepare( 'post_type=%s OR ', $post_type ); |
|
| 335 | + foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) { |
|
| 336 | + $post_types .= $wpdb->prepare('post_type=%s OR ', $post_type); |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | - $post_types = rtrim( $post_types, ' OR' ); |
|
| 339 | + $post_types = rtrim($post_types, ' OR'); |
|
| 340 | 340 | |
| 341 | 341 | // Maybe search. |
| 342 | - if ( ! empty( $_POST['s'] ) ) { |
|
| 342 | + if (!empty($_POST['s'])) { |
|
| 343 | 343 | $users = get_users( |
| 344 | 344 | array( |
| 345 | - 'search' => '*' . sanitize_text_field( urldecode( $_POST['s'] ) ) . '*', |
|
| 346 | - 'search_columns' => array( 'user_login', 'user_email', 'display_name' ), |
|
| 345 | + 'search' => '*' . sanitize_text_field(urldecode($_POST['s'])) . '*', |
|
| 346 | + 'search_columns' => array('user_login', 'user_email', 'display_name'), |
|
| 347 | 347 | 'fields' => 'ID', |
| 348 | 348 | ) |
| 349 | 349 | ); |
| 350 | 350 | |
| 351 | - $users = implode( ', ', $users ); |
|
| 351 | + $users = implode(', ', $users); |
|
| 352 | 352 | $post_types = "($post_types) AND ( post_author IN ( $users ) )"; |
| 353 | 353 | } |
| 354 | 354 | |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | ); |
| 363 | 363 | |
| 364 | 364 | $this->items = $customers; |
| 365 | - $this->total = (int) $wpdb->get_var( "SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts WHERE $post_types" ); |
|
| 365 | + $this->total = (int) $wpdb->get_var("SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts WHERE $post_types"); |
|
| 366 | 366 | |
| 367 | 367 | } |
| 368 | 368 | |
@@ -376,14 +376,14 @@ discard block |
||
| 376 | 376 | $columns = $this->get_columns(); |
| 377 | 377 | $hidden = array(); // No hidden columns |
| 378 | 378 | $sortable = $this->get_sortable_columns(); |
| 379 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
| 379 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
| 380 | 380 | $this->prepare_query(); |
| 381 | 381 | |
| 382 | 382 | $this->set_pagination_args( |
| 383 | 383 | array( |
| 384 | 384 | 'total_items' => $this->total, |
| 385 | 385 | 'per_page' => $this->per_page, |
| 386 | - 'total_pages' => ceil( $this->total / $this->per_page ), |
|
| 386 | + 'total_pages' => ceil($this->total / $this->per_page), |
|
| 387 | 387 | ) |
| 388 | 388 | ); |
| 389 | 389 | |
@@ -192,13 +192,13 @@ discard block |
||
| 192 | 192 | $name = isset( $option['name'] ) ? $option['name'] : ''; |
| 193 | 193 | $cb = "wpinv_{$option['type']}_callback"; |
| 194 | 194 | $section = "wpinv_settings_{$tab}_$section"; |
| 195 | - $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page']; |
|
| 195 | + $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page']; |
|
| 196 | 196 | |
| 197 | - if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) { |
|
| 198 | - $tip = wpinv_clean( $option['desc'] ); |
|
| 199 | - $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
|
| 200 | - unset( $option['desc'] ); |
|
| 201 | - } |
|
| 197 | + if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) { |
|
| 198 | + $tip = wpinv_clean( $option['desc'] ); |
|
| 199 | + $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
|
| 200 | + unset( $option['desc'] ); |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | 203 | // Loop through all tabs. |
| 204 | 204 | add_settings_field( |
@@ -225,9 +225,9 @@ discard block |
||
| 225 | 225 | 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
| 226 | 226 | 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
| 227 | 227 | 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
| 228 | - 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
| 229 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
| 230 | - 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
| 228 | + 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
| 229 | + 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
| 230 | + 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
| 231 | 231 | 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
| 232 | 232 | 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
| 233 | 233 | ) |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | * @return array |
| 242 | 242 | */ |
| 243 | 243 | function wpinv_get_registered_settings() { |
| 244 | - return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
| 244 | + return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
@@ -260,18 +260,18 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | function wpinv_settings_sanitize( $input = array() ) { |
| 262 | 262 | |
| 263 | - $wpinv_options = wpinv_get_options(); |
|
| 264 | - $raw_referrer = wp_get_raw_referer(); |
|
| 263 | + $wpinv_options = wpinv_get_options(); |
|
| 264 | + $raw_referrer = wp_get_raw_referer(); |
|
| 265 | 265 | |
| 266 | 266 | if ( empty( $raw_referrer ) ) { |
| 267 | - return array_merge( $wpinv_options, $input ); |
|
| 267 | + return array_merge( $wpinv_options, $input ); |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | wp_parse_str( $raw_referrer, $referrer ); |
| 271 | 271 | |
| 272 | - if ( in_array( 'gp-setup', $referrer ) ) { |
|
| 273 | - return array_merge( $wpinv_options, $input ); |
|
| 274 | - } |
|
| 272 | + if ( in_array( 'gp-setup', $referrer ) ) { |
|
| 273 | + return array_merge( $wpinv_options, $input ); |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | 276 | $settings = wpinv_get_registered_settings(); |
| 277 | 277 | $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
@@ -293,10 +293,10 @@ discard block |
||
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | // General filter |
| 296 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
| 296 | + $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
| 297 | 297 | |
| 298 | - // Key specific filter. |
|
| 299 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
| 298 | + // Key specific filter. |
|
| 299 | + $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | // Loop through the whitelist and unset any that are empty for the tab being saved |
@@ -339,14 +339,14 @@ discard block |
||
| 339 | 339 | |
| 340 | 340 | foreach ( $new_rates as $rate ) { |
| 341 | 341 | |
| 342 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
| 343 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
| 344 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
| 345 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
| 346 | - $rate['global'] = empty( $rate['state'] ); |
|
| 347 | - $tax_rates[] = $rate; |
|
| 342 | + $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
| 343 | + $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
| 344 | + $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
| 345 | + $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
| 346 | + $rate['global'] = empty( $rate['state'] ); |
|
| 347 | + $tax_rates[] = $rate; |
|
| 348 | 348 | |
| 349 | - } |
|
| 349 | + } |
|
| 350 | 350 | |
| 351 | 351 | update_option( 'wpinv_tax_rates', $tax_rates ); |
| 352 | 352 | |
@@ -359,11 +359,11 @@ discard block |
||
| 359 | 359 | $tabs['general'] = __( 'General', 'invoicing' ); |
| 360 | 360 | $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
| 361 | 361 | $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
| 362 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
| 362 | + $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
| 363 | 363 | |
| 364 | - if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
| 365 | - $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
| 366 | - } |
|
| 364 | + if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
| 365 | + $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
| 366 | + } |
|
| 367 | 367 | |
| 368 | 368 | $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
| 369 | 369 | $tabs['misc'] = __( 'Misc', 'invoicing' ); |
@@ -394,52 +394,52 @@ discard block |
||
| 394 | 394 | 'general' => apply_filters( |
| 395 | 395 | 'wpinv_settings_sections_general', |
| 396 | 396 | array( |
| 397 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
| 398 | - 'page_section' => __( 'Page Settings', 'invoicing' ), |
|
| 399 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
| 400 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
| 397 | + 'main' => __( 'General Settings', 'invoicing' ), |
|
| 398 | + 'page_section' => __( 'Page Settings', 'invoicing' ), |
|
| 399 | + 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
| 400 | + 'labels' => __( 'Label Texts', 'invoicing' ), |
|
| 401 | 401 | ) |
| 402 | 402 | ), |
| 403 | 403 | 'gateways' => apply_filters( |
| 404 | 404 | 'wpinv_settings_sections_gateways', |
| 405 | 405 | array( |
| 406 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
| 406 | + 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
| 407 | 407 | ) |
| 408 | 408 | ), |
| 409 | 409 | 'taxes' => apply_filters( |
| 410 | 410 | 'wpinv_settings_sections_taxes', |
| 411 | 411 | array( |
| 412 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
| 413 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
| 414 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ), |
|
| 412 | + 'main' => __( 'Tax Settings', 'invoicing' ), |
|
| 413 | + 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
| 414 | + 'vat' => __( 'EU VAT Settings', 'invoicing' ), |
|
| 415 | 415 | ) |
| 416 | 416 | ), |
| 417 | 417 | 'emails' => apply_filters( |
| 418 | 418 | 'wpinv_settings_sections_emails', |
| 419 | 419 | array( |
| 420 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
| 420 | + 'main' => __( 'Email Settings', 'invoicing' ), |
|
| 421 | 421 | ) |
| 422 | 422 | ), |
| 423 | 423 | |
| 424 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
| 424 | + 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
| 425 | 425 | |
| 426 | 426 | 'privacy' => apply_filters( |
| 427 | 427 | 'wpinv_settings_sections_privacy', |
| 428 | 428 | array( |
| 429 | - 'main' => __( 'Privacy policy', 'invoicing' ), |
|
| 429 | + 'main' => __( 'Privacy policy', 'invoicing' ), |
|
| 430 | 430 | ) |
| 431 | 431 | ), |
| 432 | 432 | 'misc' => apply_filters( |
| 433 | 433 | 'wpinv_settings_sections_misc', |
| 434 | 434 | array( |
| 435 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
| 436 | - 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
| 435 | + 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
| 436 | + 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
| 437 | 437 | ) |
| 438 | 438 | ), |
| 439 | 439 | 'tools' => apply_filters( |
| 440 | 440 | 'wpinv_settings_sections_tools', |
| 441 | 441 | array( |
| 442 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
| 442 | + 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
| 443 | 443 | ) |
| 444 | 444 | ), |
| 445 | 445 | ); |
@@ -450,46 +450,46 @@ discard block |
||
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | function wpinv_get_pages( $with_slug = false, $default_label = null ) { |
| 453 | - $pages_options = array(); |
|
| 453 | + $pages_options = array(); |
|
| 454 | 454 | |
| 455 | - if ( $default_label !== null && $default_label !== false ) { |
|
| 456 | - $pages_options = array( '' => $default_label ); // Blank option |
|
| 457 | - } |
|
| 455 | + if ( $default_label !== null && $default_label !== false ) { |
|
| 456 | + $pages_options = array( '' => $default_label ); // Blank option |
|
| 457 | + } |
|
| 458 | 458 | |
| 459 | - $pages = get_pages(); |
|
| 460 | - if ( $pages ) { |
|
| 461 | - foreach ( $pages as $page ) { |
|
| 462 | - $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
| 459 | + $pages = get_pages(); |
|
| 460 | + if ( $pages ) { |
|
| 461 | + foreach ( $pages as $page ) { |
|
| 462 | + $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
| 463 | 463 | $pages_options[ $page->ID ] = $title; |
| 464 | - } |
|
| 465 | - } |
|
| 464 | + } |
|
| 465 | + } |
|
| 466 | 466 | |
| 467 | - return $pages_options; |
|
| 467 | + return $pages_options; |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | function wpinv_header_callback( $args ) { |
| 471 | - if ( ! empty( $args['desc'] ) ) { |
|
| 471 | + if ( ! empty( $args['desc'] ) ) { |
|
| 472 | 472 | echo wp_kses_post( $args['desc'] ); |
| 473 | 473 | } |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | function wpinv_hidden_callback( $args ) { |
| 477 | 477 | |
| 478 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 479 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 478 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 479 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 480 | 480 | |
| 481 | - if ( isset( $args['set_value'] ) ) { |
|
| 482 | - $value = $args['set_value']; |
|
| 483 | - } |
|
| 481 | + if ( isset( $args['set_value'] ) ) { |
|
| 482 | + $value = $args['set_value']; |
|
| 483 | + } |
|
| 484 | 484 | |
| 485 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 486 | - $args['readonly'] = true; |
|
| 487 | - $name = ''; |
|
| 488 | - } else { |
|
| 489 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 490 | - } |
|
| 485 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 486 | + $args['readonly'] = true; |
|
| 487 | + $name = ''; |
|
| 488 | + } else { |
|
| 489 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 490 | + } |
|
| 491 | 491 | |
| 492 | - echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
| 492 | + echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
| 493 | 493 | |
| 494 | 494 | } |
| 495 | 495 | |
@@ -498,12 +498,12 @@ discard block |
||
| 498 | 498 | */ |
| 499 | 499 | function wpinv_checkbox_callback( $args ) { |
| 500 | 500 | |
| 501 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 502 | - $std = wpinv_get_option( $args['id'], $std ); |
|
| 503 | - $id = esc_attr( $args['id'] ); |
|
| 501 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 502 | + $std = wpinv_get_option( $args['id'], $std ); |
|
| 503 | + $id = esc_attr( $args['id'] ); |
|
| 504 | 504 | |
| 505 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
| 506 | - ?> |
|
| 505 | + getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
| 506 | + ?> |
|
| 507 | 507 | <fieldset> |
| 508 | 508 | <label> |
| 509 | 509 | <input id="wpinv-settings-<?php echo esc_attr( $id ); ?>" name="wpinv_settings[<?php echo esc_attr( $id ); ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox"> |
@@ -515,75 +515,75 @@ discard block |
||
| 515 | 515 | |
| 516 | 516 | function wpinv_multicheck_callback( $args ) { |
| 517 | 517 | |
| 518 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 519 | - $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
| 518 | + $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 519 | + $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
| 520 | 520 | |
| 521 | - if ( ! empty( $args['options'] ) ) { |
|
| 521 | + if ( ! empty( $args['options'] ) ) { |
|
| 522 | 522 | |
| 523 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
| 524 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 523 | + $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
| 524 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 525 | 525 | |
| 526 | - echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
|
| 526 | + echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
|
| 527 | 527 | foreach ( $args['options'] as $key => $option ) : |
| 528 | - $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) ); |
|
| 529 | - if ( in_array( $sanitize_key, $value ) ) { |
|
| 530 | - $enabled = $sanitize_key; |
|
| 531 | - } else { |
|
| 532 | - $enabled = null; |
|
| 533 | - } |
|
| 534 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
| 535 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
| 536 | - endforeach; |
|
| 537 | - echo '</div>'; |
|
| 538 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 539 | - } |
|
| 528 | + $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) ); |
|
| 529 | + if ( in_array( $sanitize_key, $value ) ) { |
|
| 530 | + $enabled = $sanitize_key; |
|
| 531 | + } else { |
|
| 532 | + $enabled = null; |
|
| 533 | + } |
|
| 534 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
| 535 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
| 536 | + endforeach; |
|
| 537 | + echo '</div>'; |
|
| 538 | + echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 539 | + } |
|
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | function wpinv_payment_icons_callback( $args ) { |
| 543 | 543 | |
| 544 | 544 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 545 | - $value = wpinv_get_option( $args['id'], false ); |
|
| 545 | + $value = wpinv_get_option( $args['id'], false ); |
|
| 546 | 546 | |
| 547 | - if ( ! empty( $args['options'] ) ) { |
|
| 548 | - foreach ( $args['options'] as $key => $option ) { |
|
| 547 | + if ( ! empty( $args['options'] ) ) { |
|
| 548 | + foreach ( $args['options'] as $key => $option ) { |
|
| 549 | 549 | $sanitize_key = wpinv_sanitize_key( $key ); |
| 550 | 550 | |
| 551 | - if ( empty( $value ) ) { |
|
| 552 | - $enabled = $option; |
|
| 553 | - } else { |
|
| 554 | - $enabled = null; |
|
| 555 | - } |
|
| 556 | - |
|
| 557 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
| 558 | - |
|
| 559 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
| 560 | - |
|
| 561 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
| 562 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 563 | - } else { |
|
| 564 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
| 565 | - |
|
| 566 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
| 567 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
| 568 | - } else { |
|
| 569 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
| 570 | - $content_dir = WP_CONTENT_DIR; |
|
| 571 | - |
|
| 572 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
| 573 | - // Replaces backslashes with forward slashes for Windows systems |
|
| 574 | - $image = wp_normalize_path( $image ); |
|
| 575 | - $content_dir = wp_normalize_path( $content_dir ); |
|
| 576 | - } |
|
| 577 | - |
|
| 578 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
| 579 | - } |
|
| 580 | - |
|
| 581 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 582 | - } |
|
| 583 | - echo $option . '</label>'; |
|
| 584 | - } |
|
| 585 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 586 | - } |
|
| 551 | + if ( empty( $value ) ) { |
|
| 552 | + $enabled = $option; |
|
| 553 | + } else { |
|
| 554 | + $enabled = null; |
|
| 555 | + } |
|
| 556 | + |
|
| 557 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
| 558 | + |
|
| 559 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
| 560 | + |
|
| 561 | + if ( wpinv_string_is_image_url( $key ) ) { |
|
| 562 | + echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 563 | + } else { |
|
| 564 | + $card = strtolower( str_replace( ' ', '', $option ) ); |
|
| 565 | + |
|
| 566 | + if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
| 567 | + $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
| 568 | + } else { |
|
| 569 | + $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
| 570 | + $content_dir = WP_CONTENT_DIR; |
|
| 571 | + |
|
| 572 | + if ( function_exists( 'wp_normalize_path' ) ) { |
|
| 573 | + // Replaces backslashes with forward slashes for Windows systems |
|
| 574 | + $image = wp_normalize_path( $image ); |
|
| 575 | + $content_dir = wp_normalize_path( $content_dir ); |
|
| 576 | + } |
|
| 577 | + |
|
| 578 | + $image = str_replace( $content_dir, content_url(), $image ); |
|
| 579 | + } |
|
| 580 | + |
|
| 581 | + echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 582 | + } |
|
| 583 | + echo $option . '</label>'; |
|
| 584 | + } |
|
| 585 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 586 | + } |
|
| 587 | 587 | } |
| 588 | 588 | |
| 589 | 589 | /** |
@@ -591,9 +591,9 @@ discard block |
||
| 591 | 591 | */ |
| 592 | 592 | function wpinv_radio_callback( $args ) { |
| 593 | 593 | |
| 594 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 595 | - $std = wpinv_get_option( $args['id'], $std ); |
|
| 596 | - ?> |
|
| 594 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 595 | + $std = wpinv_get_option( $args['id'], $std ); |
|
| 596 | + ?> |
|
| 597 | 597 | <fieldset> |
| 598 | 598 | <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
| 599 | 599 | <?php foreach ( $args['options'] as $key => $option ) : ?> |
@@ -607,7 +607,7 @@ discard block |
||
| 607 | 607 | </ul> |
| 608 | 608 | </fieldset> |
| 609 | 609 | <?php |
| 610 | - getpaid_settings_description_callback( $args ); |
|
| 610 | + getpaid_settings_description_callback( $args ); |
|
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | /** |
@@ -615,10 +615,10 @@ discard block |
||
| 615 | 615 | */ |
| 616 | 616 | function getpaid_settings_description_callback( $args ) { |
| 617 | 617 | |
| 618 | - if ( ! empty( $args['desc'] ) ) { |
|
| 619 | - $description = wp_kses_post( $args['desc'] ); |
|
| 620 | - echo "<p class='description'>$description</p>"; |
|
| 621 | - } |
|
| 618 | + if ( ! empty( $args['desc'] ) ) { |
|
| 619 | + $description = wp_kses_post( $args['desc'] ); |
|
| 620 | + echo "<p class='description'>$description</p>"; |
|
| 621 | + } |
|
| 622 | 622 | |
| 623 | 623 | } |
| 624 | 624 | |
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | */ |
| 628 | 628 | function wpinv_gateways_callback() { |
| 629 | 629 | |
| 630 | - ?> |
|
| 630 | + ?> |
|
| 631 | 631 | </td> |
| 632 | 632 | </tr> |
| 633 | 633 | <tr class="bsui"> |
@@ -641,22 +641,22 @@ discard block |
||
| 641 | 641 | |
| 642 | 642 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 643 | 643 | $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
| 644 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 645 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 644 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 645 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 646 | 646 | |
| 647 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >'; |
|
| 647 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >'; |
|
| 648 | 648 | |
| 649 | - foreach ( $args['options'] as $key => $option ) : |
|
| 650 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 649 | + foreach ( $args['options'] as $key => $option ) : |
|
| 650 | + if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 651 | 651 | $selected = selected( $key, $args['selected'], false ); |
| 652 | 652 | } else { |
| 653 | 653 | $selected = selected( $key, $value, false ); |
| 654 | 654 | } |
| 655 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
| 656 | - endforeach; |
|
| 655 | + echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
| 656 | + endforeach; |
|
| 657 | 657 | |
| 658 | - echo '</select>'; |
|
| 659 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 658 | + echo '</select>'; |
|
| 659 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 660 | 660 | } |
| 661 | 661 | |
| 662 | 662 | /** |
@@ -667,29 +667,29 @@ discard block |
||
| 667 | 667 | */ |
| 668 | 668 | function wpinv_settings_attrs_helper( $args ) { |
| 669 | 669 | |
| 670 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 671 | - $id = esc_attr( $args['id'] ); |
|
| 672 | - $placeholder = esc_attr( $args['placeholder'] ); |
|
| 670 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 671 | + $id = esc_attr( $args['id'] ); |
|
| 672 | + $placeholder = esc_attr( $args['placeholder'] ); |
|
| 673 | 673 | |
| 674 | - if ( ! empty( $args['faux'] ) ) { |
|
| 675 | - $args['readonly'] = true; |
|
| 676 | - $name = ''; |
|
| 677 | - } else { |
|
| 678 | - $value = wpinv_get_option( $args['id'], $value ); |
|
| 679 | - $name = "wpinv_settings[$id]"; |
|
| 680 | - } |
|
| 674 | + if ( ! empty( $args['faux'] ) ) { |
|
| 675 | + $args['readonly'] = true; |
|
| 676 | + $name = ''; |
|
| 677 | + } else { |
|
| 678 | + $value = wpinv_get_option( $args['id'], $value ); |
|
| 679 | + $name = "wpinv_settings[$id]"; |
|
| 680 | + } |
|
| 681 | 681 | |
| 682 | - $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
| 683 | - $class = esc_attr( $args['class'] ); |
|
| 684 | - $style = esc_attr( $args['style'] ); |
|
| 685 | - $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
| 682 | + $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
| 683 | + $class = esc_attr( $args['class'] ); |
|
| 684 | + $style = esc_attr( $args['style'] ); |
|
| 685 | + $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
| 686 | 686 | |
| 687 | - $onchange = ''; |
|
| 687 | + $onchange = ''; |
|
| 688 | 688 | if ( ! empty( $args['onchange'] ) ) { |
| 689 | 689 | $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
| 690 | - } |
|
| 690 | + } |
|
| 691 | 691 | |
| 692 | - return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
|
| 692 | + return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
|
| 693 | 693 | } |
| 694 | 694 | |
| 695 | 695 | /** |
@@ -697,9 +697,9 @@ discard block |
||
| 697 | 697 | */ |
| 698 | 698 | function wpinv_text_callback( $args ) { |
| 699 | 699 | |
| 700 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 700 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 701 | 701 | |
| 702 | - ?> |
|
| 702 | + ?> |
|
| 703 | 703 | <label style="width: 100%;"> |
| 704 | 704 | <input type="text" <?php echo wpinv_settings_attrs_helper( $args ); ?>> |
| 705 | 705 | <?php echo wp_kses_post( $desc ); ?> |
@@ -713,10 +713,10 @@ discard block |
||
| 713 | 713 | */ |
| 714 | 714 | function wpinv_number_callback( $args ) { |
| 715 | 715 | |
| 716 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 717 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
| 716 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 717 | + $attr = wpinv_settings_attrs_helper( $args ); |
|
| 718 | 718 | |
| 719 | - ?> |
|
| 719 | + ?> |
|
| 720 | 720 | <label style="width: 100%;"> |
| 721 | 721 | <input type="number" step="<?php echo floatval( $args['step'] ); ?>" max="<?php echo intval( $args['max'] ); ?>" min="<?php echo intval( $args['min'] ); ?>" <?php echo $attr; ?>> |
| 722 | 722 | <?php echo wp_kses_post( $desc ); ?> |
@@ -728,34 +728,34 @@ discard block |
||
| 728 | 728 | function wpinv_textarea_callback( $args ) { |
| 729 | 729 | |
| 730 | 730 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 731 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 732 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 731 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 732 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 733 | 733 | |
| 734 | 734 | $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
| 735 | 735 | $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
| 736 | 736 | |
| 737 | - echo '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 738 | - echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 737 | + echo '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 738 | + echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 739 | 739 | |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | 742 | function wpinv_password_callback( $args ) { |
| 743 | 743 | |
| 744 | 744 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 745 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 746 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 745 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 746 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 747 | 747 | |
| 748 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 749 | - echo '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
| 750 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 748 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 749 | + echo '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
| 750 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 751 | 751 | |
| 752 | 752 | } |
| 753 | 753 | |
| 754 | 754 | function wpinv_missing_callback( $args ) { |
| 755 | - printf( |
|
| 756 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
| 757 | - '<strong>' . $args['id'] . '</strong>' |
|
| 758 | - ); |
|
| 755 | + printf( |
|
| 756 | + __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
| 757 | + '<strong>' . $args['id'] . '</strong>' |
|
| 758 | + ); |
|
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | /** |
@@ -763,14 +763,14 @@ discard block |
||
| 763 | 763 | */ |
| 764 | 764 | function wpinv_select_callback( $args ) { |
| 765 | 765 | |
| 766 | - $desc = wp_kses_post( $args['desc'] ); |
|
| 767 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 768 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
| 769 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 770 | - $value = wpinv_get_option( $args['id'], $value ); |
|
| 771 | - $rand = uniqid( 'random_id' ); |
|
| 766 | + $desc = wp_kses_post( $args['desc'] ); |
|
| 767 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 768 | + $attr = wpinv_settings_attrs_helper( $args ); |
|
| 769 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 770 | + $value = wpinv_get_option( $args['id'], $value ); |
|
| 771 | + $rand = uniqid( 'random_id' ); |
|
| 772 | 772 | |
| 773 | - ?> |
|
| 773 | + ?> |
|
| 774 | 774 | <label style="width: 100%;"> |
| 775 | 775 | <select <?php echo $attr; ?> data-allow-clear="true"> |
| 776 | 776 | <?php foreach ( $args['options'] as $option => $name ) : ?> |
@@ -803,50 +803,50 @@ discard block |
||
| 803 | 803 | function wpinv_color_select_callback( $args ) { |
| 804 | 804 | |
| 805 | 805 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 806 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 807 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 806 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 807 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 808 | 808 | |
| 809 | - echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
| 809 | + echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
| 810 | 810 | |
| 811 | - foreach ( $args['options'] as $option => $color ) { |
|
| 812 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>'; |
|
| 813 | - } |
|
| 811 | + foreach ( $args['options'] as $option => $color ) { |
|
| 812 | + echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>'; |
|
| 813 | + } |
|
| 814 | 814 | |
| 815 | - echo '</select>'; |
|
| 816 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 815 | + echo '</select>'; |
|
| 816 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 817 | 817 | |
| 818 | 818 | } |
| 819 | 819 | |
| 820 | 820 | function wpinv_rich_editor_callback( $args ) { |
| 821 | - global $wp_version; |
|
| 821 | + global $wp_version; |
|
| 822 | 822 | |
| 823 | 823 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 824 | 824 | |
| 825 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 826 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 825 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 826 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 827 | 827 | |
| 828 | - if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
| 829 | - $value = $std; |
|
| 830 | - } |
|
| 828 | + if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
| 829 | + $value = $std; |
|
| 830 | + } |
|
| 831 | 831 | |
| 832 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
| 832 | + $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
| 833 | 833 | |
| 834 | - echo '<div class="getpaid-settings-editor-input">'; |
|
| 835 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
| 836 | - wp_editor( |
|
| 834 | + echo '<div class="getpaid-settings-editor-input">'; |
|
| 835 | + if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
| 836 | + wp_editor( |
|
| 837 | 837 | stripslashes( $value ), |
| 838 | 838 | 'wpinv_settings_' . esc_attr( $args['id'] ), |
| 839 | 839 | array( |
| 840 | - 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', |
|
| 841 | - 'textarea_rows' => absint( $rows ), |
|
| 842 | - 'media_buttons' => false, |
|
| 840 | + 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', |
|
| 841 | + 'textarea_rows' => absint( $rows ), |
|
| 842 | + 'media_buttons' => false, |
|
| 843 | 843 | ) |
| 844 | 844 | ); |
| 845 | - } else { |
|
| 846 | - echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 847 | - } |
|
| 845 | + } else { |
|
| 846 | + echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 847 | + } |
|
| 848 | 848 | |
| 849 | - echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 849 | + echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 850 | 850 | |
| 851 | 851 | } |
| 852 | 852 | |
@@ -854,51 +854,51 @@ discard block |
||
| 854 | 854 | |
| 855 | 855 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 856 | 856 | |
| 857 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 858 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 857 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 858 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 859 | 859 | |
| 860 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 861 | - echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 862 | - echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
| 863 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 860 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 861 | + echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 862 | + echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
| 863 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 864 | 864 | |
| 865 | 865 | } |
| 866 | 866 | |
| 867 | 867 | function wpinv_color_callback( $args ) { |
| 868 | 868 | |
| 869 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 870 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 869 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 870 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 871 | 871 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 872 | 872 | |
| 873 | - echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />'; |
|
| 874 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 873 | + echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />'; |
|
| 874 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 875 | 875 | |
| 876 | 876 | } |
| 877 | 877 | |
| 878 | 878 | function wpinv_country_states_callback( $args ) { |
| 879 | 879 | |
| 880 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 881 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 880 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 881 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 882 | 882 | |
| 883 | 883 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 884 | 884 | |
| 885 | - if ( isset( $args['placeholder'] ) ) { |
|
| 886 | - $placeholder = $args['placeholder']; |
|
| 887 | - } else { |
|
| 888 | - $placeholder = ''; |
|
| 889 | - } |
|
| 885 | + if ( isset( $args['placeholder'] ) ) { |
|
| 886 | + $placeholder = $args['placeholder']; |
|
| 887 | + } else { |
|
| 888 | + $placeholder = ''; |
|
| 889 | + } |
|
| 890 | 890 | |
| 891 | - $states = wpinv_get_country_states(); |
|
| 891 | + $states = wpinv_get_country_states(); |
|
| 892 | 892 | |
| 893 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
| 894 | - echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
| 893 | + $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
| 894 | + echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
| 895 | 895 | |
| 896 | - foreach ( $states as $option => $name ) { |
|
| 897 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>'; |
|
| 898 | - } |
|
| 896 | + foreach ( $states as $option => $name ) { |
|
| 897 | + echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>'; |
|
| 898 | + } |
|
| 899 | 899 | |
| 900 | - echo '</select>'; |
|
| 901 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 900 | + echo '</select>'; |
|
| 901 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 902 | 902 | |
| 903 | 903 | } |
| 904 | 904 | |
@@ -907,7 +907,7 @@ discard block |
||
| 907 | 907 | */ |
| 908 | 908 | function wpinv_tax_rates_callback() { |
| 909 | 909 | |
| 910 | - ?> |
|
| 910 | + ?> |
|
| 911 | 911 | </td> |
| 912 | 912 | </tr> |
| 913 | 913 | <tr class="bsui"> |
@@ -922,17 +922,17 @@ discard block |
||
| 922 | 922 | * Displays a tax rate' edit row. |
| 923 | 923 | */ |
| 924 | 924 | function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) { |
| 925 | - ob_start(); |
|
| 925 | + ob_start(); |
|
| 926 | 926 | |
| 927 | - $key = sanitize_key( $key ); |
|
| 928 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
| 929 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
| 927 | + $key = sanitize_key( $key ); |
|
| 928 | + $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
| 929 | + include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
| 930 | 930 | |
| 931 | - if ( $echo ) { |
|
| 932 | - echo ob_get_clean(); |
|
| 933 | - } else { |
|
| 934 | - return ob_get_clean(); |
|
| 935 | - } |
|
| 931 | + if ( $echo ) { |
|
| 932 | + echo ob_get_clean(); |
|
| 933 | + } else { |
|
| 934 | + return ob_get_clean(); |
|
| 935 | + } |
|
| 936 | 936 | |
| 937 | 937 | } |
| 938 | 938 | |
@@ -965,14 +965,14 @@ discard block |
||
| 965 | 965 | <td> |
| 966 | 966 | <a href=" |
| 967 | 967 | <?php |
| 968 | - echo esc_url( |
|
| 969 | - wp_nonce_url( |
|
| 970 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
| 971 | - 'getpaid-nonce', |
|
| 972 | - 'getpaid-nonce' |
|
| 973 | - ) |
|
| 974 | - ); |
|
| 975 | - ?> |
|
| 968 | + echo esc_url( |
|
| 969 | + wp_nonce_url( |
|
| 970 | + add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
| 971 | + 'getpaid-nonce', |
|
| 972 | + 'getpaid-nonce' |
|
| 973 | + ) |
|
| 974 | + ); |
|
| 975 | + ?> |
|
| 976 | 976 | " class="button button-primary"><?php _e( 'Run', 'invoicing' ); ?></a> |
| 977 | 977 | </td> |
| 978 | 978 | </tr> |
@@ -984,14 +984,14 @@ discard block |
||
| 984 | 984 | <td> |
| 985 | 985 | <a href=" |
| 986 | 986 | <?php |
| 987 | - echo esc_url( |
|
| 988 | - wp_nonce_url( |
|
| 989 | - add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
| 990 | - 'getpaid-nonce', |
|
| 991 | - 'getpaid-nonce' |
|
| 992 | - ) |
|
| 993 | - ); |
|
| 994 | - ?> |
|
| 987 | + echo esc_url( |
|
| 988 | + wp_nonce_url( |
|
| 989 | + add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
| 990 | + 'getpaid-nonce', |
|
| 991 | + 'getpaid-nonce' |
|
| 992 | + ) |
|
| 993 | + ); |
|
| 994 | + ?> |
|
| 995 | 995 | " class="button button-primary"><?php _e( 'Run', 'invoicing' ); ?></a> |
| 996 | 996 | </td> |
| 997 | 997 | </tr> |
@@ -1003,14 +1003,14 @@ discard block |
||
| 1003 | 1003 | <td> |
| 1004 | 1004 | <a href=" |
| 1005 | 1005 | <?php |
| 1006 | - echo esc_url( |
|
| 1007 | - wp_nonce_url( |
|
| 1008 | - add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
| 1009 | - 'getpaid-nonce', |
|
| 1010 | - 'getpaid-nonce' |
|
| 1011 | - ) |
|
| 1012 | - ); |
|
| 1013 | - ?> |
|
| 1006 | + echo esc_url( |
|
| 1007 | + wp_nonce_url( |
|
| 1008 | + add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
| 1009 | + 'getpaid-nonce', |
|
| 1010 | + 'getpaid-nonce' |
|
| 1011 | + ) |
|
| 1012 | + ); |
|
| 1013 | + ?> |
|
| 1014 | 1014 | " class="button button-primary"><?php _e( 'Run', 'invoicing' ); ?></a> |
| 1015 | 1015 | </td> |
| 1016 | 1016 | </tr> |
@@ -1023,14 +1023,14 @@ discard block |
||
| 1023 | 1023 | <td> |
| 1024 | 1024 | <a href=" |
| 1025 | 1025 | <?php |
| 1026 | - echo esc_url( |
|
| 1027 | - wp_nonce_url( |
|
| 1028 | - add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
| 1029 | - 'getpaid-nonce', |
|
| 1030 | - 'getpaid-nonce' |
|
| 1031 | - ) |
|
| 1032 | - ); |
|
| 1033 | - ?> |
|
| 1026 | + echo esc_url( |
|
| 1027 | + wp_nonce_url( |
|
| 1028 | + add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
| 1029 | + 'getpaid-nonce', |
|
| 1030 | + 'getpaid-nonce' |
|
| 1031 | + ) |
|
| 1032 | + ); |
|
| 1033 | + ?> |
|
| 1034 | 1034 | " class="button button-primary"><?php _e( 'Run', 'invoicing' ); ?></a> |
| 1035 | 1035 | </td> |
| 1036 | 1036 | </tr> |
@@ -1043,8 +1043,8 @@ discard block |
||
| 1043 | 1043 | <td> |
| 1044 | 1044 | <a href=" |
| 1045 | 1045 | <?php |
| 1046 | - echo esc_url( admin_url( 'index.php?page=gp-setup' ) ); |
|
| 1047 | - ?> |
|
| 1046 | + echo esc_url( admin_url( 'index.php?page=gp-setup' ) ); |
|
| 1047 | + ?> |
|
| 1048 | 1048 | " class="button button-primary"><?php _e( 'Launch', 'invoicing' ); ?></a> |
| 1049 | 1049 | </td> |
| 1050 | 1050 | </tr> |
@@ -1059,19 +1059,19 @@ discard block |
||
| 1059 | 1059 | |
| 1060 | 1060 | |
| 1061 | 1061 | function wpinv_descriptive_text_callback( $args ) { |
| 1062 | - echo wp_kses_post( $args['desc'] ); |
|
| 1062 | + echo wp_kses_post( $args['desc'] ); |
|
| 1063 | 1063 | } |
| 1064 | 1064 | |
| 1065 | 1065 | function wpinv_raw_html_callback( $args ) { |
| 1066 | - echo $args['desc']; |
|
| 1066 | + echo $args['desc']; |
|
| 1067 | 1067 | } |
| 1068 | 1068 | |
| 1069 | 1069 | function wpinv_hook_callback( $args ) { |
| 1070 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
| 1070 | + do_action( 'wpinv_' . $args['id'], $args ); |
|
| 1071 | 1071 | } |
| 1072 | 1072 | |
| 1073 | 1073 | function wpinv_set_settings_cap() { |
| 1074 | - return wpinv_get_capability(); |
|
| 1074 | + return wpinv_get_capability(); |
|
| 1075 | 1075 | } |
| 1076 | 1076 | add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
| 1077 | 1077 | |
@@ -1095,15 +1095,15 @@ discard block |
||
| 1095 | 1095 | */ |
| 1096 | 1096 | function wpinv_get_merge_tags_help_text( $subscription = false ) { |
| 1097 | 1097 | |
| 1098 | - $url = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f'; |
|
| 1099 | - $link = sprintf( |
|
| 1100 | - '<strong><a href="%s" target="_blank">%s</a></strong>', |
|
| 1101 | - $url, |
|
| 1102 | - esc_html__( 'View available merge tags.', 'wpinv-quotes' ) |
|
| 1103 | - ); |
|
| 1098 | + $url = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f'; |
|
| 1099 | + $link = sprintf( |
|
| 1100 | + '<strong><a href="%s" target="_blank">%s</a></strong>', |
|
| 1101 | + $url, |
|
| 1102 | + esc_html__( 'View available merge tags.', 'wpinv-quotes' ) |
|
| 1103 | + ); |
|
| 1104 | 1104 | |
| 1105 | - $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
| 1105 | + $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
| 1106 | 1106 | |
| 1107 | - return "$description $link"; |
|
| 1107 | + return "$description $link"; |
|
| 1108 | 1108 | |
| 1109 | 1109 | } |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @since 1.0.0 |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -defined( 'ABSPATH' ) || exit; |
|
| 9 | +defined('ABSPATH') || exit; |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * Retrieves all default settings. |
@@ -16,13 +16,13 @@ discard block |
||
| 16 | 16 | function wpinv_get_settings() { |
| 17 | 17 | $defaults = array(); |
| 18 | 18 | |
| 19 | - foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) { |
|
| 19 | + foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) { |
|
| 20 | 20 | |
| 21 | - foreach ( array_values( $tab_settings ) as $section_settings ) { |
|
| 21 | + foreach (array_values($tab_settings) as $section_settings) { |
|
| 22 | 22 | |
| 23 | - foreach ( $section_settings as $key => $setting ) { |
|
| 24 | - if ( isset( $setting['std'] ) ) { |
|
| 25 | - $defaults[ $key ] = $setting['std']; |
|
| 23 | + foreach ($section_settings as $key => $setting) { |
|
| 24 | + if (isset($setting['std'])) { |
|
| 25 | + $defaults[$key] = $setting['std']; |
|
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | } |
@@ -41,12 +41,12 @@ discard block |
||
| 41 | 41 | global $wpinv_options; |
| 42 | 42 | |
| 43 | 43 | // Try fetching the saved options. |
| 44 | - if ( empty( $wpinv_options ) ) { |
|
| 45 | - $wpinv_options = get_option( 'wpinv_settings' ); |
|
| 44 | + if (empty($wpinv_options)) { |
|
| 45 | + $wpinv_options = get_option('wpinv_settings'); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | // If that fails, don't fetch the default settings to prevent a loop. |
| 49 | - if ( ! is_array( $wpinv_options ) ) { |
|
| 49 | + if (!is_array($wpinv_options)) { |
|
| 50 | 50 | $wpinv_options = array(); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -60,13 +60,13 @@ discard block |
||
| 60 | 60 | * @param mixed $default The default value to use if the setting has not been set. |
| 61 | 61 | * @return mixed |
| 62 | 62 | */ |
| 63 | -function wpinv_get_option( $key = '', $default = false ) { |
|
| 63 | +function wpinv_get_option($key = '', $default = false) { |
|
| 64 | 64 | |
| 65 | 65 | $options = wpinv_get_options(); |
| 66 | - $value = isset( $options[ $key ] ) ? $options[ $key ] : $default; |
|
| 67 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
| 66 | + $value = isset($options[$key]) ? $options[$key] : $default; |
|
| 67 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
| 68 | 68 | |
| 69 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
| 69 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -75,11 +75,11 @@ discard block |
||
| 75 | 75 | * @param array $options the new options. |
| 76 | 76 | * @return bool |
| 77 | 77 | */ |
| 78 | -function wpinv_update_options( $options ) { |
|
| 78 | +function wpinv_update_options($options) { |
|
| 79 | 79 | global $wpinv_options; |
| 80 | 80 | |
| 81 | 81 | // update the option. |
| 82 | - if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) { |
|
| 82 | + if (is_array($options) && update_option('wpinv_settings', $options)) { |
|
| 83 | 83 | $wpinv_options = $options; |
| 84 | 84 | return true; |
| 85 | 85 | } |
@@ -94,24 +94,24 @@ discard block |
||
| 94 | 94 | * @param mixed $value The setting value. |
| 95 | 95 | * @return bool |
| 96 | 96 | */ |
| 97 | -function wpinv_update_option( $key = '', $value = false ) { |
|
| 97 | +function wpinv_update_option($key = '', $value = false) { |
|
| 98 | 98 | |
| 99 | 99 | // If no key, exit. |
| 100 | - if ( empty( $key ) ) { |
|
| 100 | + if (empty($key)) { |
|
| 101 | 101 | return false; |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | // Maybe delete the option instead. |
| 105 | - if ( is_null( $value ) ) { |
|
| 106 | - return wpinv_delete_option( $key ); |
|
| 105 | + if (is_null($value)) { |
|
| 106 | + return wpinv_delete_option($key); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | // Prepare the new options. |
| 110 | 110 | $options = wpinv_get_options(); |
| 111 | - $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key ); |
|
| 111 | + $options[$key] = apply_filters('wpinv_update_option', $value, $key); |
|
| 112 | 112 | |
| 113 | 113 | // Save the new options. |
| 114 | - return wpinv_update_options( $options ); |
|
| 114 | + return wpinv_update_options($options); |
|
| 115 | 115 | |
| 116 | 116 | } |
| 117 | 117 | |
@@ -121,18 +121,18 @@ discard block |
||
| 121 | 121 | * @param string $key the setting key. |
| 122 | 122 | * @return bool |
| 123 | 123 | */ |
| 124 | -function wpinv_delete_option( $key = '' ) { |
|
| 124 | +function wpinv_delete_option($key = '') { |
|
| 125 | 125 | |
| 126 | 126 | // If no key, exit |
| 127 | - if ( empty( $key ) ) { |
|
| 127 | + if (empty($key)) { |
|
| 128 | 128 | return false; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | $options = wpinv_get_options(); |
| 132 | 132 | |
| 133 | - if ( isset( $options[ $key ] ) ) { |
|
| 134 | - unset( $options[ $key ] ); |
|
| 135 | - return wpinv_update_options( $options ); |
|
| 133 | + if (isset($options[$key])) { |
|
| 134 | + unset($options[$key]); |
|
| 135 | + return wpinv_update_options($options); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | return true; |
@@ -146,14 +146,14 @@ discard block |
||
| 146 | 146 | function wpinv_register_settings() { |
| 147 | 147 | |
| 148 | 148 | // Loop through all tabs. |
| 149 | - foreach ( wpinv_get_registered_settings() as $tab => $sections ) { |
|
| 149 | + foreach (wpinv_get_registered_settings() as $tab => $sections) { |
|
| 150 | 150 | |
| 151 | 151 | // In each tab, loop through sections. |
| 152 | - foreach ( $sections as $section => $settings ) { |
|
| 152 | + foreach ($sections as $section => $settings) { |
|
| 153 | 153 | |
| 154 | 154 | // Check for backwards compatibility |
| 155 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
| 156 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
| 155 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
| 156 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
| 157 | 157 | $section = 'main'; |
| 158 | 158 | $settings = $sections; |
| 159 | 159 | } |
@@ -166,18 +166,18 @@ discard block |
||
| 166 | 166 | 'wpinv_settings_' . $tab . '_' . $section |
| 167 | 167 | ); |
| 168 | 168 | |
| 169 | - foreach ( $settings as $option ) { |
|
| 170 | - if ( ! empty( $option['id'] ) ) { |
|
| 171 | - wpinv_register_settings_option( $tab, $section, $option ); |
|
| 169 | + foreach ($settings as $option) { |
|
| 170 | + if (!empty($option['id'])) { |
|
| 171 | + wpinv_register_settings_option($tab, $section, $option); |
|
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | // Creates our settings in the options table. |
| 178 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
| 178 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
| 179 | 179 | } |
| 180 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
| 180 | +add_action('admin_init', 'wpinv_register_settings'); |
|
| 181 | 181 | |
| 182 | 182 | /** |
| 183 | 183 | * Register a single settings option. |
@@ -187,49 +187,49 @@ discard block |
||
| 187 | 187 | * @param string $option |
| 188 | 188 | * |
| 189 | 189 | */ |
| 190 | -function wpinv_register_settings_option( $tab, $section, $option ) { |
|
| 190 | +function wpinv_register_settings_option($tab, $section, $option) { |
|
| 191 | 191 | |
| 192 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
| 192 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
| 193 | 193 | $cb = "wpinv_{$option['type']}_callback"; |
| 194 | 194 | $section = "wpinv_settings_{$tab}_$section"; |
| 195 | - $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page']; |
|
| 195 | + $is_wizzard = is_admin() && isset($_GET['page']) && 'gp-setup' == $_GET['page']; |
|
| 196 | 196 | |
| 197 | - if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) { |
|
| 198 | - $tip = wpinv_clean( $option['desc'] ); |
|
| 197 | + if (isset($option['desc']) && (!$is_wizzard && !empty($option['help-tip']))) { |
|
| 198 | + $tip = wpinv_clean($option['desc']); |
|
| 199 | 199 | $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
| 200 | - unset( $option['desc'] ); |
|
| 200 | + unset($option['desc']); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | // Loop through all tabs. |
| 204 | 204 | add_settings_field( |
| 205 | 205 | 'wpinv_settings[' . $option['id'] . ']', |
| 206 | 206 | $name, |
| 207 | - function_exists( $cb ) ? $cb : 'wpinv_missing_callback', |
|
| 207 | + function_exists($cb) ? $cb : 'wpinv_missing_callback', |
|
| 208 | 208 | $section, |
| 209 | 209 | $section, |
| 210 | 210 | array( |
| 211 | 211 | 'section' => $section, |
| 212 | - 'id' => isset( $option['id'] ) ? $option['id'] : uniqid( 'wpinv-' ), |
|
| 213 | - 'desc' => isset( $option['desc'] ) ? $option['desc'] : '', |
|
| 212 | + 'id' => isset($option['id']) ? $option['id'] : uniqid('wpinv-'), |
|
| 213 | + 'desc' => isset($option['desc']) ? $option['desc'] : '', |
|
| 214 | 214 | 'name' => $name, |
| 215 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
| 216 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
| 217 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
| 218 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
| 219 | - 'min' => isset( $option['min'] ) ? $option['min'] : 0, |
|
| 220 | - 'max' => isset( $option['max'] ) ? $option['max'] : 999999, |
|
| 221 | - 'step' => isset( $option['step'] ) ? $option['step'] : 1, |
|
| 222 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
| 223 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
| 224 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
| 225 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
| 226 | - 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
|
| 227 | - 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
|
| 228 | - 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
| 229 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
| 230 | - 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
| 231 | - 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
| 232 | - 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
| 215 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
| 216 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
| 217 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
| 218 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
| 219 | + 'min' => isset($option['min']) ? $option['min'] : 0, |
|
| 220 | + 'max' => isset($option['max']) ? $option['max'] : 999999, |
|
| 221 | + 'step' => isset($option['step']) ? $option['step'] : 1, |
|
| 222 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
| 223 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
| 224 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
| 225 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
| 226 | + 'onchange' => isset($option['onchange']) ? $option['onchange'] : '', |
|
| 227 | + 'custom' => isset($option['custom']) ? $option['custom'] : '', |
|
| 228 | + 'default_content' => isset($option['default_content']) ? $option['default_content'] : '', |
|
| 229 | + 'class' => isset($option['class']) ? $option['class'] : '', |
|
| 230 | + 'style' => isset($option['style']) ? $option['style'] : '', |
|
| 231 | + 'cols' => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
| 232 | + 'rows' => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
| 233 | 233 | ) |
| 234 | 234 | ); |
| 235 | 235 | |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | * @return array |
| 242 | 242 | */ |
| 243 | 243 | function wpinv_get_registered_settings() { |
| 244 | - return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
| 244 | + return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings'))); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | * @return array |
| 251 | 251 | */ |
| 252 | 252 | function getpaid_get_integration_settings() { |
| 253 | - return apply_filters( 'getpaid_integration_settings', array() ); |
|
| 253 | + return apply_filters('getpaid_integration_settings', array()); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /** |
@@ -258,126 +258,126 @@ discard block |
||
| 258 | 258 | * |
| 259 | 259 | * @return array |
| 260 | 260 | */ |
| 261 | -function wpinv_settings_sanitize( $input = array() ) { |
|
| 261 | +function wpinv_settings_sanitize($input = array()) { |
|
| 262 | 262 | |
| 263 | 263 | $wpinv_options = wpinv_get_options(); |
| 264 | 264 | $raw_referrer = wp_get_raw_referer(); |
| 265 | 265 | |
| 266 | - if ( empty( $raw_referrer ) ) { |
|
| 267 | - return array_merge( $wpinv_options, $input ); |
|
| 266 | + if (empty($raw_referrer)) { |
|
| 267 | + return array_merge($wpinv_options, $input); |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - wp_parse_str( $raw_referrer, $referrer ); |
|
| 270 | + wp_parse_str($raw_referrer, $referrer); |
|
| 271 | 271 | |
| 272 | - if ( in_array( 'gp-setup', $referrer ) ) { |
|
| 273 | - return array_merge( $wpinv_options, $input ); |
|
| 272 | + if (in_array('gp-setup', $referrer)) { |
|
| 273 | + return array_merge($wpinv_options, $input); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | $settings = wpinv_get_registered_settings(); |
| 277 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
| 278 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
| 277 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
| 278 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
| 279 | 279 | |
| 280 | 280 | $input = $input ? $input : array(); |
| 281 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
| 282 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
| 281 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
| 282 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
| 283 | 283 | |
| 284 | 284 | // Loop through each setting being saved and pass it through a sanitization filter |
| 285 | - foreach ( $input as $key => $value ) { |
|
| 285 | + foreach ($input as $key => $value) { |
|
| 286 | 286 | |
| 287 | 287 | // Get the setting type (checkbox, select, etc) |
| 288 | - $type = isset( $settings[ $tab ][ $section ][ $key ]['type'] ) ? $settings[ $tab ][ $section ][ $key ]['type'] : false; |
|
| 288 | + $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false; |
|
| 289 | 289 | |
| 290 | - if ( $type ) { |
|
| 290 | + if ($type) { |
|
| 291 | 291 | // Field type specific filter |
| 292 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$type", $value, $key ); |
|
| 292 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$type", $value, $key); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | // General filter |
| 296 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
| 296 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
| 297 | 297 | |
| 298 | 298 | // Key specific filter. |
| 299 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
| 299 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | // Loop through the whitelist and unset any that are empty for the tab being saved |
| 303 | - $main_settings = isset( $settings[ $tab ] ) ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
| 304 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
| 303 | + $main_settings = isset($settings[$tab]) ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
| 304 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
| 305 | 305 | |
| 306 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
| 306 | + $found_settings = array_merge($main_settings, $section_settings); |
|
| 307 | 307 | |
| 308 | - if ( ! empty( $found_settings ) ) { |
|
| 309 | - foreach ( $found_settings as $key => $value ) { |
|
| 308 | + if (!empty($found_settings)) { |
|
| 309 | + foreach ($found_settings as $key => $value) { |
|
| 310 | 310 | |
| 311 | 311 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
| 312 | - if ( is_numeric( $key ) ) { |
|
| 312 | + if (is_numeric($key)) { |
|
| 313 | 313 | $key = $value['id']; |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) { |
|
| 317 | - unset( $wpinv_options[ $key ] ); |
|
| 316 | + if (!isset($input[$key]) && isset($wpinv_options[$key])) { |
|
| 317 | + unset($wpinv_options[$key]); |
|
| 318 | 318 | } |
| 319 | 319 | } |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | // Merge our new settings with the existing |
| 323 | - $output = array_merge( $wpinv_options, $input ); |
|
| 323 | + $output = array_merge($wpinv_options, $input); |
|
| 324 | 324 | |
| 325 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
| 325 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
| 326 | 326 | |
| 327 | 327 | return $output; |
| 328 | 328 | } |
| 329 | -add_filter( 'wpinv_settings_sanitize_text', 'trim', 10, 1 ); |
|
| 330 | -add_filter( 'wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount' ); |
|
| 329 | +add_filter('wpinv_settings_sanitize_text', 'trim', 10, 1); |
|
| 330 | +add_filter('wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount'); |
|
| 331 | 331 | |
| 332 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
| 333 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 332 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
| 333 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 334 | 334 | return $input; |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | - $new_rates = ! empty( $_POST['tax_rates'] ) ? wp_kses_post_deep( array_values( $_POST['tax_rates'] ) ) : array(); |
|
| 337 | + $new_rates = !empty($_POST['tax_rates']) ? wp_kses_post_deep(array_values($_POST['tax_rates'])) : array(); |
|
| 338 | 338 | $tax_rates = array(); |
| 339 | 339 | |
| 340 | - foreach ( $new_rates as $rate ) { |
|
| 340 | + foreach ($new_rates as $rate) { |
|
| 341 | 341 | |
| 342 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
| 343 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
| 344 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
| 345 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
| 346 | - $rate['global'] = empty( $rate['state'] ); |
|
| 342 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate']); |
|
| 343 | + $rate['name'] = sanitize_text_field($rate['name']); |
|
| 344 | + $rate['state'] = sanitize_text_field($rate['state']); |
|
| 345 | + $rate['country'] = sanitize_text_field($rate['country']); |
|
| 346 | + $rate['global'] = empty($rate['state']); |
|
| 347 | 347 | $tax_rates[] = $rate; |
| 348 | 348 | |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
| 351 | + update_option('wpinv_tax_rates', $tax_rates); |
|
| 352 | 352 | |
| 353 | 353 | return $input; |
| 354 | 354 | } |
| 355 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
| 355 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
| 356 | 356 | |
| 357 | 357 | function wpinv_get_settings_tabs() { |
| 358 | 358 | $tabs = array(); |
| 359 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
| 360 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
| 361 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
| 362 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
| 359 | + $tabs['general'] = __('General', 'invoicing'); |
|
| 360 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
| 361 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
| 362 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
| 363 | 363 | |
| 364 | - if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
| 365 | - $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
| 364 | + if (count(getpaid_get_integration_settings()) > 0) { |
|
| 365 | + $tabs['integrations'] = __('Integrations', 'invoicing'); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
|
| 369 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
| 370 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
| 368 | + $tabs['privacy'] = __('Privacy', 'invoicing'); |
|
| 369 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
| 370 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
| 371 | 371 | |
| 372 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
| 372 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
| 375 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
| 376 | 376 | $tabs = false; |
| 377 | 377 | $sections = wpinv_get_registered_settings_sections(); |
| 378 | 378 | |
| 379 | - if ( $tab && ! empty( $sections[ $tab ] ) ) { |
|
| 380 | - $tabs = $sections[ $tab ]; |
|
| 379 | + if ($tab && !empty($sections[$tab])) { |
|
| 380 | + $tabs = $sections[$tab]; |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | return $tabs; |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | function wpinv_get_registered_settings_sections() { |
| 387 | 387 | static $sections = false; |
| 388 | 388 | |
| 389 | - if ( false !== $sections ) { |
|
| 389 | + if (false !== $sections) { |
|
| 390 | 390 | return $sections; |
| 391 | 391 | } |
| 392 | 392 | |
@@ -394,161 +394,161 @@ discard block |
||
| 394 | 394 | 'general' => apply_filters( |
| 395 | 395 | 'wpinv_settings_sections_general', |
| 396 | 396 | array( |
| 397 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
| 398 | - 'page_section' => __( 'Page Settings', 'invoicing' ), |
|
| 399 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
| 400 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
| 397 | + 'main' => __('General Settings', 'invoicing'), |
|
| 398 | + 'page_section' => __('Page Settings', 'invoicing'), |
|
| 399 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
| 400 | + 'labels' => __('Label Texts', 'invoicing'), |
|
| 401 | 401 | ) |
| 402 | 402 | ), |
| 403 | 403 | 'gateways' => apply_filters( |
| 404 | 404 | 'wpinv_settings_sections_gateways', |
| 405 | 405 | array( |
| 406 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
| 406 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
| 407 | 407 | ) |
| 408 | 408 | ), |
| 409 | 409 | 'taxes' => apply_filters( |
| 410 | 410 | 'wpinv_settings_sections_taxes', |
| 411 | 411 | array( |
| 412 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
| 413 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
| 414 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ), |
|
| 412 | + 'main' => __('Tax Settings', 'invoicing'), |
|
| 413 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
| 414 | + 'vat' => __('EU VAT Settings', 'invoicing'), |
|
| 415 | 415 | ) |
| 416 | 416 | ), |
| 417 | 417 | 'emails' => apply_filters( |
| 418 | 418 | 'wpinv_settings_sections_emails', |
| 419 | 419 | array( |
| 420 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
| 420 | + 'main' => __('Email Settings', 'invoicing'), |
|
| 421 | 421 | ) |
| 422 | 422 | ), |
| 423 | 423 | |
| 424 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
| 424 | + 'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'), |
|
| 425 | 425 | |
| 426 | 426 | 'privacy' => apply_filters( |
| 427 | 427 | 'wpinv_settings_sections_privacy', |
| 428 | 428 | array( |
| 429 | - 'main' => __( 'Privacy policy', 'invoicing' ), |
|
| 429 | + 'main' => __('Privacy policy', 'invoicing'), |
|
| 430 | 430 | ) |
| 431 | 431 | ), |
| 432 | 432 | 'misc' => apply_filters( |
| 433 | 433 | 'wpinv_settings_sections_misc', |
| 434 | 434 | array( |
| 435 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
| 436 | - 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
| 435 | + 'main' => __('Miscellaneous', 'invoicing'), |
|
| 436 | + 'custom-css' => __('Custom CSS', 'invoicing'), |
|
| 437 | 437 | ) |
| 438 | 438 | ), |
| 439 | 439 | 'tools' => apply_filters( |
| 440 | 440 | 'wpinv_settings_sections_tools', |
| 441 | 441 | array( |
| 442 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
| 442 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
| 443 | 443 | ) |
| 444 | 444 | ), |
| 445 | 445 | ); |
| 446 | 446 | |
| 447 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
| 447 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
| 448 | 448 | |
| 449 | 449 | return $sections; |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | -function wpinv_get_pages( $with_slug = false, $default_label = null ) { |
|
| 452 | +function wpinv_get_pages($with_slug = false, $default_label = null) { |
|
| 453 | 453 | $pages_options = array(); |
| 454 | 454 | |
| 455 | - if ( $default_label !== null && $default_label !== false ) { |
|
| 456 | - $pages_options = array( '' => $default_label ); // Blank option |
|
| 455 | + if ($default_label !== null && $default_label !== false) { |
|
| 456 | + $pages_options = array('' => $default_label); // Blank option |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | $pages = get_pages(); |
| 460 | - if ( $pages ) { |
|
| 461 | - foreach ( $pages as $page ) { |
|
| 460 | + if ($pages) { |
|
| 461 | + foreach ($pages as $page) { |
|
| 462 | 462 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
| 463 | - $pages_options[ $page->ID ] = $title; |
|
| 463 | + $pages_options[$page->ID] = $title; |
|
| 464 | 464 | } |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | return $pages_options; |
| 468 | 468 | } |
| 469 | 469 | |
| 470 | -function wpinv_header_callback( $args ) { |
|
| 471 | - if ( ! empty( $args['desc'] ) ) { |
|
| 472 | - echo wp_kses_post( $args['desc'] ); |
|
| 470 | +function wpinv_header_callback($args) { |
|
| 471 | + if (!empty($args['desc'])) { |
|
| 472 | + echo wp_kses_post($args['desc']); |
|
| 473 | 473 | } |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | -function wpinv_hidden_callback( $args ) { |
|
| 476 | +function wpinv_hidden_callback($args) { |
|
| 477 | 477 | |
| 478 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 479 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 478 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 479 | + $value = wpinv_get_option($args['id'], $std); |
|
| 480 | 480 | |
| 481 | - if ( isset( $args['set_value'] ) ) { |
|
| 481 | + if (isset($args['set_value'])) { |
|
| 482 | 482 | $value = $args['set_value']; |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 485 | + if (isset($args['faux']) && true === $args['faux']) { |
|
| 486 | 486 | $args['readonly'] = true; |
| 487 | - $name = ''; |
|
| 487 | + $name = ''; |
|
| 488 | 488 | } else { |
| 489 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 489 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
| 490 | 490 | } |
| 491 | 491 | |
| 492 | - echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
| 492 | + echo '<input type="hidden" id="wpinv_settings[' . esc_attr($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />'; |
|
| 493 | 493 | |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | /** |
| 497 | 497 | * Displays a checkbox settings callback. |
| 498 | 498 | */ |
| 499 | -function wpinv_checkbox_callback( $args ) { |
|
| 499 | +function wpinv_checkbox_callback($args) { |
|
| 500 | 500 | |
| 501 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 502 | - $std = wpinv_get_option( $args['id'], $std ); |
|
| 503 | - $id = esc_attr( $args['id'] ); |
|
| 501 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 502 | + $std = wpinv_get_option($args['id'], $std); |
|
| 503 | + $id = esc_attr($args['id']); |
|
| 504 | 504 | |
| 505 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
| 505 | + getpaid_hidden_field("wpinv_settings[$id]", '0'); |
|
| 506 | 506 | ?> |
| 507 | 507 | <fieldset> |
| 508 | 508 | <label> |
| 509 | - <input id="wpinv-settings-<?php echo esc_attr( $id ); ?>" name="wpinv_settings[<?php echo esc_attr( $id ); ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox"> |
|
| 510 | - <?php echo wp_kses_post( $args['desc'] ); ?> |
|
| 509 | + <input id="wpinv-settings-<?php echo esc_attr($id); ?>" name="wpinv_settings[<?php echo esc_attr($id); ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox"> |
|
| 510 | + <?php echo wp_kses_post($args['desc']); ?> |
|
| 511 | 511 | </label> |
| 512 | 512 | </fieldset> |
| 513 | 513 | <?php |
| 514 | 514 | } |
| 515 | 515 | |
| 516 | -function wpinv_multicheck_callback( $args ) { |
|
| 516 | +function wpinv_multicheck_callback($args) { |
|
| 517 | 517 | |
| 518 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 519 | - $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
| 518 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 519 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
| 520 | 520 | |
| 521 | - if ( ! empty( $args['options'] ) ) { |
|
| 521 | + if (!empty($args['options'])) { |
|
| 522 | 522 | |
| 523 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
| 524 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 523 | + $std = isset($args['std']) ? $args['std'] : array(); |
|
| 524 | + $value = wpinv_get_option($args['id'], $std); |
|
| 525 | 525 | |
| 526 | 526 | echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
| 527 | - foreach ( $args['options'] as $key => $option ) : |
|
| 528 | - $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) ); |
|
| 529 | - if ( in_array( $sanitize_key, $value ) ) { |
|
| 527 | + foreach ($args['options'] as $key => $option) : |
|
| 528 | + $sanitize_key = esc_attr(wpinv_sanitize_key($key)); |
|
| 529 | + if (in_array($sanitize_key, $value)) { |
|
| 530 | 530 | $enabled = $sanitize_key; |
| 531 | 531 | } else { |
| 532 | 532 | $enabled = null; |
| 533 | 533 | } |
| 534 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
| 535 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
| 534 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/> '; |
|
| 535 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>'; |
|
| 536 | 536 | endforeach; |
| 537 | 537 | echo '</div>'; |
| 538 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 538 | + echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>'; |
|
| 539 | 539 | } |
| 540 | 540 | } |
| 541 | 541 | |
| 542 | -function wpinv_payment_icons_callback( $args ) { |
|
| 542 | +function wpinv_payment_icons_callback($args) { |
|
| 543 | 543 | |
| 544 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 545 | - $value = wpinv_get_option( $args['id'], false ); |
|
| 544 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 545 | + $value = wpinv_get_option($args['id'], false); |
|
| 546 | 546 | |
| 547 | - if ( ! empty( $args['options'] ) ) { |
|
| 548 | - foreach ( $args['options'] as $key => $option ) { |
|
| 549 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 547 | + if (!empty($args['options'])) { |
|
| 548 | + foreach ($args['options'] as $key => $option) { |
|
| 549 | + $sanitize_key = wpinv_sanitize_key($key); |
|
| 550 | 550 | |
| 551 | - if ( empty( $value ) ) { |
|
| 551 | + if (empty($value)) { |
|
| 552 | 552 | $enabled = $option; |
| 553 | 553 | } else { |
| 554 | 554 | $enabled = null; |
@@ -556,67 +556,67 @@ discard block |
||
| 556 | 556 | |
| 557 | 557 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
| 558 | 558 | |
| 559 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
| 559 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/> '; |
|
| 560 | 560 | |
| 561 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
| 562 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 561 | + if (wpinv_string_is_image_url($key)) { |
|
| 562 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 563 | 563 | } else { |
| 564 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
| 564 | + $card = strtolower(str_replace(' ', '', $option)); |
|
| 565 | 565 | |
| 566 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
| 567 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
| 566 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
| 567 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
| 568 | 568 | } else { |
| 569 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
| 569 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
| 570 | 570 | $content_dir = WP_CONTENT_DIR; |
| 571 | 571 | |
| 572 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
| 572 | + if (function_exists('wp_normalize_path')) { |
|
| 573 | 573 | // Replaces backslashes with forward slashes for Windows systems |
| 574 | - $image = wp_normalize_path( $image ); |
|
| 575 | - $content_dir = wp_normalize_path( $content_dir ); |
|
| 574 | + $image = wp_normalize_path($image); |
|
| 575 | + $content_dir = wp_normalize_path($content_dir); |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
| 578 | + $image = str_replace($content_dir, content_url(), $image); |
|
| 579 | 579 | } |
| 580 | 580 | |
| 581 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 581 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 582 | 582 | } |
| 583 | 583 | echo $option . '</label>'; |
| 584 | 584 | } |
| 585 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 585 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
| 586 | 586 | } |
| 587 | 587 | } |
| 588 | 588 | |
| 589 | 589 | /** |
| 590 | 590 | * Displays a radio settings field. |
| 591 | 591 | */ |
| 592 | -function wpinv_radio_callback( $args ) { |
|
| 592 | +function wpinv_radio_callback($args) { |
|
| 593 | 593 | |
| 594 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 595 | - $std = wpinv_get_option( $args['id'], $std ); |
|
| 594 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 595 | + $std = wpinv_get_option($args['id'], $std); |
|
| 596 | 596 | ?> |
| 597 | 597 | <fieldset> |
| 598 | - <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
|
| 599 | - <?php foreach ( $args['options'] as $key => $option ) : ?> |
|
| 598 | + <ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;"> |
|
| 599 | + <?php foreach ($args['options'] as $key => $option) : ?> |
|
| 600 | 600 | <li> |
| 601 | 601 | <label> |
| 602 | - <input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio"> |
|
| 603 | - <?php echo wp_kses_post( $option ); ?> |
|
| 602 | + <input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio"> |
|
| 603 | + <?php echo wp_kses_post($option); ?> |
|
| 604 | 604 | </label> |
| 605 | 605 | </li> |
| 606 | 606 | <?php endforeach; ?> |
| 607 | 607 | </ul> |
| 608 | 608 | </fieldset> |
| 609 | 609 | <?php |
| 610 | - getpaid_settings_description_callback( $args ); |
|
| 610 | + getpaid_settings_description_callback($args); |
|
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | /** |
| 614 | 614 | * Displays a description if available. |
| 615 | 615 | */ |
| 616 | -function getpaid_settings_description_callback( $args ) { |
|
| 616 | +function getpaid_settings_description_callback($args) { |
|
| 617 | 617 | |
| 618 | - if ( ! empty( $args['desc'] ) ) { |
|
| 619 | - $description = wp_kses_post( $args['desc'] ); |
|
| 618 | + if (!empty($args['desc'])) { |
|
| 619 | + $description = wp_kses_post($args['desc']); |
|
| 620 | 620 | echo "<p class='description'>$description</p>"; |
| 621 | 621 | } |
| 622 | 622 | |
@@ -632,31 +632,31 @@ discard block |
||
| 632 | 632 | </tr> |
| 633 | 633 | <tr class="bsui"> |
| 634 | 634 | <td colspan="2" class="p-0"> |
| 635 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-gateways-edit.php'; ?> |
|
| 635 | + <?php include plugin_dir_path(__FILE__) . 'views/html-gateways-edit.php'; ?> |
|
| 636 | 636 | |
| 637 | 637 | <?php |
| 638 | 638 | } |
| 639 | 639 | |
| 640 | -function wpinv_gateway_select_callback( $args ) { |
|
| 640 | +function wpinv_gateway_select_callback($args) { |
|
| 641 | 641 | |
| 642 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 643 | - $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
| 644 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 645 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 642 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 643 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
| 644 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 645 | + $value = wpinv_get_option($args['id'], $std); |
|
| 646 | 646 | |
| 647 | 647 | echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >'; |
| 648 | 648 | |
| 649 | - foreach ( $args['options'] as $key => $option ) : |
|
| 650 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 651 | - $selected = selected( $key, $args['selected'], false ); |
|
| 649 | + foreach ($args['options'] as $key => $option) : |
|
| 650 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
| 651 | + $selected = selected($key, $args['selected'], false); |
|
| 652 | 652 | } else { |
| 653 | - $selected = selected( $key, $value, false ); |
|
| 653 | + $selected = selected($key, $value, false); |
|
| 654 | 654 | } |
| 655 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
| 655 | + echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>'; |
|
| 656 | 656 | endforeach; |
| 657 | 657 | |
| 658 | 658 | echo '</select>'; |
| 659 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 659 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 660 | 660 | } |
| 661 | 661 | |
| 662 | 662 | /** |
@@ -665,28 +665,28 @@ discard block |
||
| 665 | 665 | * @param array $args |
| 666 | 666 | * @return string |
| 667 | 667 | */ |
| 668 | -function wpinv_settings_attrs_helper( $args ) { |
|
| 668 | +function wpinv_settings_attrs_helper($args) { |
|
| 669 | 669 | |
| 670 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 671 | - $id = esc_attr( $args['id'] ); |
|
| 672 | - $placeholder = esc_attr( $args['placeholder'] ); |
|
| 670 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 671 | + $id = esc_attr($args['id']); |
|
| 672 | + $placeholder = esc_attr($args['placeholder']); |
|
| 673 | 673 | |
| 674 | - if ( ! empty( $args['faux'] ) ) { |
|
| 674 | + if (!empty($args['faux'])) { |
|
| 675 | 675 | $args['readonly'] = true; |
| 676 | 676 | $name = ''; |
| 677 | 677 | } else { |
| 678 | - $value = wpinv_get_option( $args['id'], $value ); |
|
| 678 | + $value = wpinv_get_option($args['id'], $value); |
|
| 679 | 679 | $name = "wpinv_settings[$id]"; |
| 680 | 680 | } |
| 681 | 681 | |
| 682 | - $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
| 683 | - $class = esc_attr( $args['class'] ); |
|
| 684 | - $style = esc_attr( $args['style'] ); |
|
| 685 | - $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
| 682 | + $value = is_scalar($value) ? esc_attr($value) : ''; |
|
| 683 | + $class = esc_attr($args['class']); |
|
| 684 | + $style = esc_attr($args['style']); |
|
| 685 | + $readonly = empty($args['readonly']) ? '' : 'readonly onclick="this.select()"'; |
|
| 686 | 686 | |
| 687 | 687 | $onchange = ''; |
| 688 | - if ( ! empty( $args['onchange'] ) ) { |
|
| 689 | - $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
| 688 | + if (!empty($args['onchange'])) { |
|
| 689 | + $onchange = ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
@@ -695,14 +695,14 @@ discard block |
||
| 695 | 695 | /** |
| 696 | 696 | * Displays a text input settings callback. |
| 697 | 697 | */ |
| 698 | -function wpinv_text_callback( $args ) { |
|
| 698 | +function wpinv_text_callback($args) { |
|
| 699 | 699 | |
| 700 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 700 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
| 701 | 701 | |
| 702 | 702 | ?> |
| 703 | 703 | <label style="width: 100%;"> |
| 704 | - <input type="text" <?php echo wpinv_settings_attrs_helper( $args ); ?>> |
|
| 705 | - <?php echo wp_kses_post( $desc ); ?> |
|
| 704 | + <input type="text" <?php echo wpinv_settings_attrs_helper($args); ?>> |
|
| 705 | + <?php echo wp_kses_post($desc); ?> |
|
| 706 | 706 | </label> |
| 707 | 707 | <?php |
| 708 | 708 | |
@@ -711,49 +711,49 @@ discard block |
||
| 711 | 711 | /** |
| 712 | 712 | * Displays a number input settings callback. |
| 713 | 713 | */ |
| 714 | -function wpinv_number_callback( $args ) { |
|
| 714 | +function wpinv_number_callback($args) { |
|
| 715 | 715 | |
| 716 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 717 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
| 716 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
| 717 | + $attr = wpinv_settings_attrs_helper($args); |
|
| 718 | 718 | |
| 719 | 719 | ?> |
| 720 | 720 | <label style="width: 100%;"> |
| 721 | - <input type="number" step="<?php echo floatval( $args['step'] ); ?>" max="<?php echo intval( $args['max'] ); ?>" min="<?php echo intval( $args['min'] ); ?>" <?php echo $attr; ?>> |
|
| 722 | - <?php echo wp_kses_post( $desc ); ?> |
|
| 721 | + <input type="number" step="<?php echo floatval($args['step']); ?>" max="<?php echo intval($args['max']); ?>" min="<?php echo intval($args['min']); ?>" <?php echo $attr; ?>> |
|
| 722 | + <?php echo wp_kses_post($desc); ?> |
|
| 723 | 723 | </label> |
| 724 | 724 | <?php |
| 725 | 725 | |
| 726 | 726 | } |
| 727 | 727 | |
| 728 | -function wpinv_textarea_callback( $args ) { |
|
| 728 | +function wpinv_textarea_callback($args) { |
|
| 729 | 729 | |
| 730 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 731 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 732 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 730 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 731 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 732 | + $value = wpinv_get_option($args['id'], $std); |
|
| 733 | 733 | |
| 734 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 735 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
| 734 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 735 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
| 736 | 736 | |
| 737 | - echo '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 738 | - echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 737 | + echo '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
| 738 | + echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 739 | 739 | |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | -function wpinv_password_callback( $args ) { |
|
| 742 | +function wpinv_password_callback($args) { |
|
| 743 | 743 | |
| 744 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 745 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 746 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 744 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 745 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 746 | + $value = wpinv_get_option($args['id'], $std); |
|
| 747 | 747 | |
| 748 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 749 | - echo '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
| 750 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 748 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 749 | + echo '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>'; |
|
| 750 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 751 | 751 | |
| 752 | 752 | } |
| 753 | 753 | |
| 754 | -function wpinv_missing_callback( $args ) { |
|
| 754 | +function wpinv_missing_callback($args) { |
|
| 755 | 755 | printf( |
| 756 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
| 756 | + __('The callback function used for the %s setting is missing.', 'invoicing'), |
|
| 757 | 757 | '<strong>' . $args['id'] . '</strong>' |
| 758 | 758 | ); |
| 759 | 759 | } |
@@ -761,35 +761,35 @@ discard block |
||
| 761 | 761 | /** |
| 762 | 762 | * Displays a number input settings callback. |
| 763 | 763 | */ |
| 764 | -function wpinv_select_callback( $args ) { |
|
| 764 | +function wpinv_select_callback($args) { |
|
| 765 | 765 | |
| 766 | - $desc = wp_kses_post( $args['desc'] ); |
|
| 767 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 768 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
| 769 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 770 | - $value = wpinv_get_option( $args['id'], $value ); |
|
| 771 | - $rand = uniqid( 'random_id' ); |
|
| 766 | + $desc = wp_kses_post($args['desc']); |
|
| 767 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
| 768 | + $attr = wpinv_settings_attrs_helper($args); |
|
| 769 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 770 | + $value = wpinv_get_option($args['id'], $value); |
|
| 771 | + $rand = uniqid('random_id'); |
|
| 772 | 772 | |
| 773 | 773 | ?> |
| 774 | 774 | <label style="width: 100%;"> |
| 775 | 775 | <select <?php echo $attr; ?> data-allow-clear="true"> |
| 776 | - <?php foreach ( $args['options'] as $option => $name ) : ?> |
|
| 777 | - <option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( $option, $value ); ?>><?php echo wpinv_clean( $name ); ?></option> |
|
| 776 | + <?php foreach ($args['options'] as $option => $name) : ?> |
|
| 777 | + <option value="<?php echo esc_attr($option); ?>" <?php echo selected($option, $value); ?>><?php echo wpinv_clean($name); ?></option> |
|
| 778 | 778 | <?php endforeach; ?> |
| 779 | 779 | </select> |
| 780 | 780 | |
| 781 | - <?php if ( substr( $args['id'], -5 ) === '_page' && is_numeric( $value ) ) : ?> |
|
| 782 | - <a href="<?php echo get_edit_post_link( $value ); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php _e( 'Edit Page', 'invoicing' ); ?></a> |
|
| 781 | + <?php if (substr($args['id'], -5) === '_page' && is_numeric($value)) : ?> |
|
| 782 | + <a href="<?php echo get_edit_post_link($value); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php _e('Edit Page', 'invoicing'); ?></a> |
|
| 783 | 783 | <?php endif; ?> |
| 784 | 784 | |
| 785 | - <?php if ( substr( $args['id'], -5 ) === '_page' && ! empty( $args['default_content'] ) ) : ?> |
|
| 786 | - <a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php _e( 'View Default Content', 'invoicing' ); ?></a> |
|
| 785 | + <?php if (substr($args['id'], -5) === '_page' && !empty($args['default_content'])) : ?> |
|
| 786 | + <a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php _e('View Default Content', 'invoicing'); ?></a> |
|
| 787 | 787 | <div id='<?php echo $rand; ?>' style='display:none;'> |
| 788 | 788 | <div> |
| 789 | - <h3><?php _e( 'Original Content', 'invoicing' ); ?></h3> |
|
| 790 | - <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines( wp_kses_post( $args['default_content'] ) ); ?></textarea> |
|
| 791 | - <h3><?php _e( 'Current Content', 'invoicing' ); ?></h3> |
|
| 792 | - <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post( $value ); echo empty( $_post ) ? '' : gepaid_trim_lines( wp_kses_post( $_post->post_content ) ); ?></textarea> |
|
| 789 | + <h3><?php _e('Original Content', 'invoicing'); ?></h3> |
|
| 790 | + <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines(wp_kses_post($args['default_content'])); ?></textarea> |
|
| 791 | + <h3><?php _e('Current Content', 'invoicing'); ?></h3> |
|
| 792 | + <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post($value); echo empty($_post) ? '' : gepaid_trim_lines(wp_kses_post($_post->post_content)); ?></textarea> |
|
| 793 | 793 | </div> |
| 794 | 794 | </div> |
| 795 | 795 | <?php endif; ?> |
@@ -800,89 +800,89 @@ discard block |
||
| 800 | 800 | |
| 801 | 801 | } |
| 802 | 802 | |
| 803 | -function wpinv_color_select_callback( $args ) { |
|
| 803 | +function wpinv_color_select_callback($args) { |
|
| 804 | 804 | |
| 805 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 806 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 807 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 805 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 806 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 807 | + $value = wpinv_get_option($args['id'], $std); |
|
| 808 | 808 | |
| 809 | - echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
| 809 | + echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
| 810 | 810 | |
| 811 | - foreach ( $args['options'] as $option => $color ) { |
|
| 812 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>'; |
|
| 811 | + foreach ($args['options'] as $option => $color) { |
|
| 812 | + echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($color['label']) . '</option>'; |
|
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | echo '</select>'; |
| 816 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 816 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 817 | 817 | |
| 818 | 818 | } |
| 819 | 819 | |
| 820 | -function wpinv_rich_editor_callback( $args ) { |
|
| 820 | +function wpinv_rich_editor_callback($args) { |
|
| 821 | 821 | global $wp_version; |
| 822 | 822 | |
| 823 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 823 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 824 | 824 | |
| 825 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 826 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 825 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 826 | + $value = wpinv_get_option($args['id'], $std); |
|
| 827 | 827 | |
| 828 | - if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
| 828 | + if (!empty($args['allow_blank']) && empty($value)) { |
|
| 829 | 829 | $value = $std; |
| 830 | 830 | } |
| 831 | 831 | |
| 832 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
| 832 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
| 833 | 833 | |
| 834 | 834 | echo '<div class="getpaid-settings-editor-input">'; |
| 835 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
| 835 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
| 836 | 836 | wp_editor( |
| 837 | - stripslashes( $value ), |
|
| 838 | - 'wpinv_settings_' . esc_attr( $args['id'] ), |
|
| 837 | + stripslashes($value), |
|
| 838 | + 'wpinv_settings_' . esc_attr($args['id']), |
|
| 839 | 839 | array( |
| 840 | - 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', |
|
| 841 | - 'textarea_rows' => absint( $rows ), |
|
| 840 | + 'textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', |
|
| 841 | + 'textarea_rows' => absint($rows), |
|
| 842 | 842 | 'media_buttons' => false, |
| 843 | 843 | ) |
| 844 | 844 | ); |
| 845 | 845 | } else { |
| 846 | - echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 846 | + echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
| 847 | 847 | } |
| 848 | 848 | |
| 849 | - echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 849 | + echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 850 | 850 | |
| 851 | 851 | } |
| 852 | 852 | |
| 853 | -function wpinv_upload_callback( $args ) { |
|
| 853 | +function wpinv_upload_callback($args) { |
|
| 854 | 854 | |
| 855 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 855 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 856 | 856 | |
| 857 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 858 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 857 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 858 | + $value = wpinv_get_option($args['id'], $std); |
|
| 859 | 859 | |
| 860 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 861 | - echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 862 | - echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
| 863 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 860 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 861 | + echo '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
| 862 | + echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>'; |
|
| 863 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 864 | 864 | |
| 865 | 865 | } |
| 866 | 866 | |
| 867 | -function wpinv_color_callback( $args ) { |
|
| 867 | +function wpinv_color_callback($args) { |
|
| 868 | 868 | |
| 869 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 870 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 871 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 869 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 870 | + $value = wpinv_get_option($args['id'], $std); |
|
| 871 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 872 | 872 | |
| 873 | - echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />'; |
|
| 874 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 873 | + echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($std) . '" />'; |
|
| 874 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 875 | 875 | |
| 876 | 876 | } |
| 877 | 877 | |
| 878 | -function wpinv_country_states_callback( $args ) { |
|
| 878 | +function wpinv_country_states_callback($args) { |
|
| 879 | 879 | |
| 880 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 881 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 880 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 881 | + $value = wpinv_get_option($args['id'], $std); |
|
| 882 | 882 | |
| 883 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 883 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 884 | 884 | |
| 885 | - if ( isset( $args['placeholder'] ) ) { |
|
| 885 | + if (isset($args['placeholder'])) { |
|
| 886 | 886 | $placeholder = $args['placeholder']; |
| 887 | 887 | } else { |
| 888 | 888 | $placeholder = ''; |
@@ -890,15 +890,15 @@ discard block |
||
| 890 | 890 | |
| 891 | 891 | $states = wpinv_get_country_states(); |
| 892 | 892 | |
| 893 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
| 894 | - echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
| 893 | + $class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
| 894 | + echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
| 895 | 895 | |
| 896 | - foreach ( $states as $option => $name ) { |
|
| 897 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>'; |
|
| 896 | + foreach ($states as $option => $name) { |
|
| 897 | + echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($name) . '</option>'; |
|
| 898 | 898 | } |
| 899 | 899 | |
| 900 | 900 | echo '</select>'; |
| 901 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 901 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 902 | 902 | |
| 903 | 903 | } |
| 904 | 904 | |
@@ -912,7 +912,7 @@ discard block |
||
| 912 | 912 | </tr> |
| 913 | 913 | <tr class="bsui"> |
| 914 | 914 | <td colspan="2" class="p-0"> |
| 915 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?> |
|
| 915 | + <?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?> |
|
| 916 | 916 | |
| 917 | 917 | <?php |
| 918 | 918 | |
@@ -921,14 +921,14 @@ discard block |
||
| 921 | 921 | /** |
| 922 | 922 | * Displays a tax rate' edit row. |
| 923 | 923 | */ |
| 924 | -function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) { |
|
| 924 | +function wpinv_tax_rate_callback($tax_rate, $key, $echo = true) { |
|
| 925 | 925 | ob_start(); |
| 926 | 926 | |
| 927 | - $key = sanitize_key( $key ); |
|
| 928 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
| 929 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
| 927 | + $key = sanitize_key($key); |
|
| 928 | + $tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate']; |
|
| 929 | + include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php'; |
|
| 930 | 930 | |
| 931 | - if ( $echo ) { |
|
| 931 | + if ($echo) { |
|
| 932 | 932 | echo ob_get_clean(); |
| 933 | 933 | } else { |
| 934 | 934 | return ob_get_clean(); |
@@ -937,154 +937,154 @@ discard block |
||
| 937 | 937 | } |
| 938 | 938 | |
| 939 | 939 | |
| 940 | -function wpinv_tools_callback( $args ) { |
|
| 940 | +function wpinv_tools_callback($args) { |
|
| 941 | 941 | ob_start(); |
| 942 | 942 | ?> |
| 943 | 943 | </td><tr> |
| 944 | 944 | <td colspan="2" class="wpinv_tools_tdbox"> |
| 945 | 945 | <?php |
| 946 | - if ( $args['desc'] ) { |
|
| 946 | + if ($args['desc']) { |
|
| 947 | 947 | ?> |
| 948 | 948 | <p><?php echo $args['desc']; ?></p><?php } ?> |
| 949 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
| 949 | + <?php do_action('wpinv_tools_before'); ?> |
|
| 950 | 950 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
| 951 | 951 | <thead> |
| 952 | 952 | <tr> |
| 953 | - <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th> |
|
| 954 | - <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th> |
|
| 955 | - <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th> |
|
| 953 | + <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th> |
|
| 954 | + <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th> |
|
| 955 | + <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th> |
|
| 956 | 956 | </tr> |
| 957 | 957 | </thead> |
| 958 | 958 | |
| 959 | 959 | <tbody> |
| 960 | 960 | <tr> |
| 961 | - <td><?php _e( 'Check Pages', 'invoicing' ); ?></td> |
|
| 961 | + <td><?php _e('Check Pages', 'invoicing'); ?></td> |
|
| 962 | 962 | <td> |
| 963 | - <small><?php _e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small> |
|
| 963 | + <small><?php _e('Creates any missing GetPaid pages.', 'invoicing'); ?></small> |
|
| 964 | 964 | </td> |
| 965 | 965 | <td> |
| 966 | 966 | <a href=" |
| 967 | 967 | <?php |
| 968 | 968 | echo esc_url( |
| 969 | 969 | wp_nonce_url( |
| 970 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
| 970 | + add_query_arg('getpaid-admin-action', 'create_missing_pages'), |
|
| 971 | 971 | 'getpaid-nonce', |
| 972 | 972 | 'getpaid-nonce' |
| 973 | 973 | ) |
| 974 | 974 | ); |
| 975 | 975 | ?> |
| 976 | - " class="button button-primary"><?php _e( 'Run', 'invoicing' ); ?></a> |
|
| 976 | + " class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
| 977 | 977 | </td> |
| 978 | 978 | </tr> |
| 979 | 979 | <tr> |
| 980 | - <td><?php _e( 'Create Database Tables', 'invoicing' ); ?></td> |
|
| 980 | + <td><?php _e('Create Database Tables', 'invoicing'); ?></td> |
|
| 981 | 981 | <td> |
| 982 | - <small><?php _e( 'Run this tool to create any missing database tables.', 'invoicing' ); ?></small> |
|
| 982 | + <small><?php _e('Run this tool to create any missing database tables.', 'invoicing'); ?></small> |
|
| 983 | 983 | </td> |
| 984 | 984 | <td> |
| 985 | 985 | <a href=" |
| 986 | 986 | <?php |
| 987 | 987 | echo esc_url( |
| 988 | 988 | wp_nonce_url( |
| 989 | - add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
| 989 | + add_query_arg('getpaid-admin-action', 'create_missing_tables'), |
|
| 990 | 990 | 'getpaid-nonce', |
| 991 | 991 | 'getpaid-nonce' |
| 992 | 992 | ) |
| 993 | 993 | ); |
| 994 | 994 | ?> |
| 995 | - " class="button button-primary"><?php _e( 'Run', 'invoicing' ); ?></a> |
|
| 995 | + " class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
| 996 | 996 | </td> |
| 997 | 997 | </tr> |
| 998 | 998 | <tr> |
| 999 | - <td><?php _e( 'Migrate old invoices', 'invoicing' ); ?></td> |
|
| 999 | + <td><?php _e('Migrate old invoices', 'invoicing'); ?></td> |
|
| 1000 | 1000 | <td> |
| 1001 | - <small><?php _e( 'If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing' ); ?></small> |
|
| 1001 | + <small><?php _e('If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing'); ?></small> |
|
| 1002 | 1002 | </td> |
| 1003 | 1003 | <td> |
| 1004 | 1004 | <a href=" |
| 1005 | 1005 | <?php |
| 1006 | 1006 | echo esc_url( |
| 1007 | 1007 | wp_nonce_url( |
| 1008 | - add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
| 1008 | + add_query_arg('getpaid-admin-action', 'migrate_old_invoices'), |
|
| 1009 | 1009 | 'getpaid-nonce', |
| 1010 | 1010 | 'getpaid-nonce' |
| 1011 | 1011 | ) |
| 1012 | 1012 | ); |
| 1013 | 1013 | ?> |
| 1014 | - " class="button button-primary"><?php _e( 'Run', 'invoicing' ); ?></a> |
|
| 1014 | + " class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
| 1015 | 1015 | </td> |
| 1016 | 1016 | </tr> |
| 1017 | 1017 | |
| 1018 | 1018 | <tr> |
| 1019 | - <td><?php _e( 'Recalculate Discounts', 'invoicing' ); ?></td> |
|
| 1019 | + <td><?php _e('Recalculate Discounts', 'invoicing'); ?></td> |
|
| 1020 | 1020 | <td> |
| 1021 | - <small><?php _e( 'Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing' ); ?></small> |
|
| 1021 | + <small><?php _e('Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing'); ?></small> |
|
| 1022 | 1022 | </td> |
| 1023 | 1023 | <td> |
| 1024 | 1024 | <a href=" |
| 1025 | 1025 | <?php |
| 1026 | 1026 | echo esc_url( |
| 1027 | 1027 | wp_nonce_url( |
| 1028 | - add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
| 1028 | + add_query_arg('getpaid-admin-action', 'recalculate_discounts'), |
|
| 1029 | 1029 | 'getpaid-nonce', |
| 1030 | 1030 | 'getpaid-nonce' |
| 1031 | 1031 | ) |
| 1032 | 1032 | ); |
| 1033 | 1033 | ?> |
| 1034 | - " class="button button-primary"><?php _e( 'Run', 'invoicing' ); ?></a> |
|
| 1034 | + " class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
| 1035 | 1035 | </td> |
| 1036 | 1036 | </tr> |
| 1037 | 1037 | |
| 1038 | 1038 | <tr> |
| 1039 | - <td><?php _e( 'Set-up Wizard', 'invoicing' ); ?></td> |
|
| 1039 | + <td><?php _e('Set-up Wizard', 'invoicing'); ?></td> |
|
| 1040 | 1040 | <td> |
| 1041 | - <small><?php _e( 'Launch the quick set-up wizard.', 'invoicing' ); ?></small> |
|
| 1041 | + <small><?php _e('Launch the quick set-up wizard.', 'invoicing'); ?></small> |
|
| 1042 | 1042 | </td> |
| 1043 | 1043 | <td> |
| 1044 | 1044 | <a href=" |
| 1045 | 1045 | <?php |
| 1046 | - echo esc_url( admin_url( 'index.php?page=gp-setup' ) ); |
|
| 1046 | + echo esc_url(admin_url('index.php?page=gp-setup')); |
|
| 1047 | 1047 | ?> |
| 1048 | - " class="button button-primary"><?php _e( 'Launch', 'invoicing' ); ?></a> |
|
| 1048 | + " class="button button-primary"><?php _e('Launch', 'invoicing'); ?></a> |
|
| 1049 | 1049 | </td> |
| 1050 | 1050 | </tr> |
| 1051 | 1051 | |
| 1052 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
| 1052 | + <?php do_action('wpinv_tools_row'); ?> |
|
| 1053 | 1053 | </tbody> |
| 1054 | 1054 | </table> |
| 1055 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
| 1055 | + <?php do_action('wpinv_tools_after'); ?> |
|
| 1056 | 1056 | <?php |
| 1057 | 1057 | echo ob_get_clean(); |
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | 1060 | |
| 1061 | -function wpinv_descriptive_text_callback( $args ) { |
|
| 1062 | - echo wp_kses_post( $args['desc'] ); |
|
| 1061 | +function wpinv_descriptive_text_callback($args) { |
|
| 1062 | + echo wp_kses_post($args['desc']); |
|
| 1063 | 1063 | } |
| 1064 | 1064 | |
| 1065 | -function wpinv_raw_html_callback( $args ) { |
|
| 1065 | +function wpinv_raw_html_callback($args) { |
|
| 1066 | 1066 | echo $args['desc']; |
| 1067 | 1067 | } |
| 1068 | 1068 | |
| 1069 | -function wpinv_hook_callback( $args ) { |
|
| 1070 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
| 1069 | +function wpinv_hook_callback($args) { |
|
| 1070 | + do_action('wpinv_' . $args['id'], $args); |
|
| 1071 | 1071 | } |
| 1072 | 1072 | |
| 1073 | 1073 | function wpinv_set_settings_cap() { |
| 1074 | 1074 | return wpinv_get_capability(); |
| 1075 | 1075 | } |
| 1076 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
| 1076 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
| 1077 | 1077 | |
| 1078 | 1078 | |
| 1079 | -function wpinv_on_update_settings( $old_value, $value, $option ) { |
|
| 1080 | - $old = ! empty( $old_value['remove_data_on_unistall'] ) ? 1 : ''; |
|
| 1081 | - $new = ! empty( $value['remove_data_on_unistall'] ) ? 1 : ''; |
|
| 1079 | +function wpinv_on_update_settings($old_value, $value, $option) { |
|
| 1080 | + $old = !empty($old_value['remove_data_on_unistall']) ? 1 : ''; |
|
| 1081 | + $new = !empty($value['remove_data_on_unistall']) ? 1 : ''; |
|
| 1082 | 1082 | |
| 1083 | - if ( $old != $new ) { |
|
| 1084 | - update_option( 'wpinv_remove_data_on_invoice_unistall', $new ); |
|
| 1083 | + if ($old != $new) { |
|
| 1084 | + update_option('wpinv_remove_data_on_invoice_unistall', $new); |
|
| 1085 | 1085 | } |
| 1086 | 1086 | } |
| 1087 | -add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 ); |
|
| 1087 | +add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3); |
|
| 1088 | 1088 | |
| 1089 | 1089 | /** |
| 1090 | 1090 | * Returns the merge tags help text. |
@@ -1093,16 +1093,16 @@ discard block |
||
| 1093 | 1093 | * |
| 1094 | 1094 | * @return string |
| 1095 | 1095 | */ |
| 1096 | -function wpinv_get_merge_tags_help_text( $subscription = false ) { |
|
| 1096 | +function wpinv_get_merge_tags_help_text($subscription = false) { |
|
| 1097 | 1097 | |
| 1098 | 1098 | $url = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f'; |
| 1099 | 1099 | $link = sprintf( |
| 1100 | 1100 | '<strong><a href="%s" target="_blank">%s</a></strong>', |
| 1101 | 1101 | $url, |
| 1102 | - esc_html__( 'View available merge tags.', 'wpinv-quotes' ) |
|
| 1102 | + esc_html__('View available merge tags.', 'wpinv-quotes') |
|
| 1103 | 1103 | ); |
| 1104 | 1104 | |
| 1105 | - $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
| 1105 | + $description = esc_html__('The content of the email (Merge Tags and HTML are allowed).', 'invoicing'); |
|
| 1106 | 1106 | |
| 1107 | 1107 | return "$description $link"; |
| 1108 | 1108 | |
@@ -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 esc_html( $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 | - <h2><?php echo esc_html( $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 ) : ?> |
|
| 112 | + <h2><?php echo esc_html($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) : ?> |
|
| 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; |
@@ -57,8 +57,8 @@ discard block |
||
| 57 | 57 | 'getpaid-nonce', |
| 58 | 58 | 'getpaid-nonce' |
| 59 | 59 | ); |
| 60 | - $anchor = __( 'Deactivate', 'invoicing' ); |
|
| 61 | - $title = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' ); |
|
| 60 | + $anchor = __( 'Deactivate', 'invoicing' ); |
|
| 61 | + $title = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' ); |
|
| 62 | 62 | $row_actions['deactivate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
| 63 | 63 | |
| 64 | 64 | } elseif ( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) ) { |
@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | 'getpaid-nonce', |
| 74 | 74 | 'getpaid-nonce' |
| 75 | 75 | ); |
| 76 | - $anchor = __( 'Activate', 'invoicing' ); |
|
| 77 | - $title = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' ); |
|
| 76 | + $anchor = __( 'Activate', 'invoicing' ); |
|
| 77 | + $title = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' ); |
|
| 78 | 78 | $row_actions['activate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
| 79 | 79 | |
| 80 | 80 | } |
@@ -91,8 +91,8 @@ discard block |
||
| 91 | 91 | 'getpaid-nonce' |
| 92 | 92 | ) |
| 93 | 93 | ); |
| 94 | - $anchor = __( 'Delete', 'invoicing' ); |
|
| 95 | - $title = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' ); |
|
| 94 | + $anchor = __( 'Delete', 'invoicing' ); |
|
| 95 | + $title = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' ); |
|
| 96 | 96 | $row_actions['delete'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
| 97 | 97 | |
| 98 | 98 | $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount ); |
@@ -118,13 +118,13 @@ discard block |
||
| 118 | 118 | $types = wpinv_get_discount_types(); |
| 119 | 119 | |
| 120 | 120 | foreach ( $types as $name => $type ) { |
| 121 | - echo '<option value="' . esc_attr( $name ) . '"'; |
|
| 121 | + echo '<option value="' . esc_attr( $name ) . '"'; |
|
| 122 | 122 | |
| 123 | - if ( isset( $_GET['discount_type'] ) ) { |
|
| 124 | - selected( $name, sanitize_text_field( $_GET['discount_type'] ) ); |
|
| 123 | + if ( isset( $_GET['discount_type'] ) ) { |
|
| 124 | + selected( $name, sanitize_text_field( $_GET['discount_type'] ) ); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
|
| 127 | + echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
|
| 128 | 128 | } |
| 129 | 129 | ?> |
| 130 | 130 | </select> |
@@ -151,15 +151,15 @@ discard block |
||
| 151 | 151 | // Filter vat rule type |
| 152 | 152 | if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) { |
| 153 | 153 | $meta_query[] = array( |
| 154 | - 'key' => '_wpi_discount_type', |
|
| 155 | - 'value' => sanitize_key( urldecode( $_GET['discount_type'] ) ), |
|
| 156 | - 'compare' => '=', |
|
| 157 | - ); |
|
| 158 | - } |
|
| 154 | + 'key' => '_wpi_discount_type', |
|
| 155 | + 'value' => sanitize_key( urldecode( $_GET['discount_type'] ) ), |
|
| 156 | + 'compare' => '=', |
|
| 157 | + ); |
|
| 158 | + } |
|
| 159 | 159 | |
| 160 | 160 | if ( ! empty( $meta_query ) ) { |
| 161 | 161 | $vars['meta_query'] = $meta_query; |
| 162 | - } |
|
| 162 | + } |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | return $vars; |
@@ -1,51 +1,51 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // MUST have WordPress. |
| 3 | -if ( ! defined( 'WPINC' ) ) { |
|
| 4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 3 | +if (!defined('WPINC')) { |
|
| 4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | -add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' ); |
|
| 8 | -function wpinv_discount_custom_column( $column ) { |
|
| 7 | +add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column'); |
|
| 8 | +function wpinv_discount_custom_column($column) { |
|
| 9 | 9 | global $post; |
| 10 | 10 | |
| 11 | - $discount = new WPInv_Discount( $post ); |
|
| 11 | + $discount = new WPInv_Discount($post); |
|
| 12 | 12 | |
| 13 | - switch ( $column ) { |
|
| 13 | + switch ($column) { |
|
| 14 | 14 | case 'code': |
| 15 | - echo esc_html( $discount->get_code() ); |
|
| 15 | + echo esc_html($discount->get_code()); |
|
| 16 | 16 | break; |
| 17 | 17 | case 'amount': |
| 18 | - echo wp_kses_post( $discount->get_formatted_amount() ); |
|
| 18 | + echo wp_kses_post($discount->get_formatted_amount()); |
|
| 19 | 19 | break; |
| 20 | 20 | case 'usage': |
| 21 | - echo wp_kses_post( $discount->get_usage() ); |
|
| 21 | + echo wp_kses_post($discount->get_usage()); |
|
| 22 | 22 | break; |
| 23 | 23 | case 'start_date': |
| 24 | - echo wp_kses_post( getpaid_format_date_value( $discount->get_start_date() ) ); |
|
| 24 | + echo wp_kses_post(getpaid_format_date_value($discount->get_start_date())); |
|
| 25 | 25 | break; |
| 26 | 26 | case 'expiry_date': |
| 27 | - echo wp_kses_post( getpaid_format_date_value( $discount->get_expiration_date(), __( 'Never', 'invoicing' ) ) ); |
|
| 27 | + echo wp_kses_post(getpaid_format_date_value($discount->get_expiration_date(), __('Never', 'invoicing'))); |
|
| 28 | 28 | break; |
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | -add_filter( 'post_row_actions', 'wpinv_post_row_actions', 90, 2 ); |
|
| 33 | -function wpinv_post_row_actions( $actions, $post ) { |
|
| 34 | - $post_type = ! empty( $post->post_type ) ? $post->post_type : ''; |
|
| 32 | +add_filter('post_row_actions', 'wpinv_post_row_actions', 90, 2); |
|
| 33 | +function wpinv_post_row_actions($actions, $post) { |
|
| 34 | + $post_type = !empty($post->post_type) ? $post->post_type : ''; |
|
| 35 | 35 | |
| 36 | - if ( $post_type == 'wpi_discount' ) { |
|
| 37 | - $actions = wpinv_discount_row_actions( $post, $actions ); |
|
| 36 | + if ($post_type == 'wpi_discount') { |
|
| 37 | + $actions = wpinv_discount_row_actions($post, $actions); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | return $actions; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | -function wpinv_discount_row_actions( $discount, $row_actions ) { |
|
| 44 | - $row_actions = array(); |
|
| 45 | - $edit_link = get_edit_post_link( $discount->ID ); |
|
| 46 | - $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>'; |
|
| 43 | +function wpinv_discount_row_actions($discount, $row_actions) { |
|
| 44 | + $row_actions = array(); |
|
| 45 | + $edit_link = get_edit_post_link($discount->ID); |
|
| 46 | + $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>'; |
|
| 47 | 47 | |
| 48 | - if ( in_array( strtolower( $discount->post_status ), array( 'publish' ) ) ) { |
|
| 48 | + if (in_array(strtolower($discount->post_status), array('publish'))) { |
|
| 49 | 49 | |
| 50 | 50 | $url = wp_nonce_url( |
| 51 | 51 | add_query_arg( |
@@ -57,13 +57,13 @@ discard block |
||
| 57 | 57 | 'getpaid-nonce', |
| 58 | 58 | 'getpaid-nonce' |
| 59 | 59 | ); |
| 60 | - $anchor = __( 'Deactivate', 'invoicing' ); |
|
| 61 | - $title = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' ); |
|
| 60 | + $anchor = __('Deactivate', 'invoicing'); |
|
| 61 | + $title = esc_attr__('Are you sure you want to deactivate this discount?', 'invoicing'); |
|
| 62 | 62 | $row_actions['deactivate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
| 63 | 63 | |
| 64 | - } elseif ( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) ) { |
|
| 64 | + } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) { |
|
| 65 | 65 | |
| 66 | - $url = wp_nonce_url( |
|
| 66 | + $url = wp_nonce_url( |
|
| 67 | 67 | add_query_arg( |
| 68 | 68 | array( |
| 69 | 69 | 'getpaid-admin-action' => 'activate_discount', |
@@ -73,13 +73,13 @@ discard block |
||
| 73 | 73 | 'getpaid-nonce', |
| 74 | 74 | 'getpaid-nonce' |
| 75 | 75 | ); |
| 76 | - $anchor = __( 'Activate', 'invoicing' ); |
|
| 77 | - $title = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' ); |
|
| 76 | + $anchor = __('Activate', 'invoicing'); |
|
| 77 | + $title = esc_attr__('Are you sure you want to activate this discount?', 'invoicing'); |
|
| 78 | 78 | $row_actions['activate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
| 79 | 79 | |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - $url = esc_url( |
|
| 82 | + $url = esc_url( |
|
| 83 | 83 | wp_nonce_url( |
| 84 | 84 | add_query_arg( |
| 85 | 85 | array( |
@@ -91,11 +91,11 @@ discard block |
||
| 91 | 91 | 'getpaid-nonce' |
| 92 | 92 | ) |
| 93 | 93 | ); |
| 94 | - $anchor = __( 'Delete', 'invoicing' ); |
|
| 95 | - $title = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' ); |
|
| 94 | + $anchor = __('Delete', 'invoicing'); |
|
| 95 | + $title = esc_attr__('Are you sure you want to delete this discount?', 'invoicing'); |
|
| 96 | 96 | $row_actions['delete'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
| 97 | 97 | |
| 98 | - $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount ); |
|
| 98 | + $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount); |
|
| 99 | 99 | |
| 100 | 100 | return $row_actions; |
| 101 | 101 | } |
@@ -103,68 +103,68 @@ discard block |
||
| 103 | 103 | function wpinv_restrict_manage_posts() { |
| 104 | 104 | global $typenow; |
| 105 | 105 | |
| 106 | - if ( 'wpi_discount' == $typenow ) { |
|
| 106 | + if ('wpi_discount' == $typenow) { |
|
| 107 | 107 | wpinv_discount_filters(); |
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | -add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 ); |
|
| 110 | +add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10); |
|
| 111 | 111 | |
| 112 | 112 | function wpinv_discount_filters() { |
| 113 | 113 | |
| 114 | 114 | ?> |
| 115 | 115 | <select name="discount_type" id="dropdown_wpinv_discount_type"> |
| 116 | - <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option> |
|
| 116 | + <option value=""><?php _e('Show all types', 'invoicing'); ?></option> |
|
| 117 | 117 | <?php |
| 118 | 118 | $types = wpinv_get_discount_types(); |
| 119 | 119 | |
| 120 | - foreach ( $types as $name => $type ) { |
|
| 121 | - echo '<option value="' . esc_attr( $name ) . '"'; |
|
| 120 | + foreach ($types as $name => $type) { |
|
| 121 | + echo '<option value="' . esc_attr($name) . '"'; |
|
| 122 | 122 | |
| 123 | - if ( isset( $_GET['discount_type'] ) ) { |
|
| 124 | - selected( $name, sanitize_text_field( $_GET['discount_type'] ) ); |
|
| 123 | + if (isset($_GET['discount_type'])) { |
|
| 124 | + selected($name, sanitize_text_field($_GET['discount_type'])); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
|
| 127 | + echo '>' . esc_html__($type, 'invoicing') . '</option>'; |
|
| 128 | 128 | } |
| 129 | 129 | ?> |
| 130 | 130 | </select> |
| 131 | 131 | <?php |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | -function wpinv_request( $vars ) { |
|
| 134 | +function wpinv_request($vars) { |
|
| 135 | 135 | global $typenow, $wp_post_statuses; |
| 136 | 136 | |
| 137 | - if ( getpaid_is_invoice_post_type( $typenow ) ) { |
|
| 138 | - if ( ! isset( $vars['post_status'] ) ) { |
|
| 139 | - $post_statuses = wpinv_get_invoice_statuses( false, false, $typenow ); |
|
| 137 | + if (getpaid_is_invoice_post_type($typenow)) { |
|
| 138 | + if (!isset($vars['post_status'])) { |
|
| 139 | + $post_statuses = wpinv_get_invoice_statuses(false, false, $typenow); |
|
| 140 | 140 | |
| 141 | - foreach ( $post_statuses as $status => $value ) { |
|
| 142 | - if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) { |
|
| 143 | - unset( $post_statuses[ $status ] ); |
|
| 141 | + foreach ($post_statuses as $status => $value) { |
|
| 142 | + if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) { |
|
| 143 | + unset($post_statuses[$status]); |
|
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - $vars['post_status'] = array_keys( $post_statuses ); |
|
| 147 | + $vars['post_status'] = array_keys($post_statuses); |
|
| 148 | 148 | } |
| 149 | -} elseif ( 'wpi_discount' == $typenow ) { |
|
| 150 | - $meta_query = ! empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
| 149 | +} elseif ('wpi_discount' == $typenow) { |
|
| 150 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
| 151 | 151 | // Filter vat rule type |
| 152 | - if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) { |
|
| 152 | + if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') { |
|
| 153 | 153 | $meta_query[] = array( |
| 154 | 154 | 'key' => '_wpi_discount_type', |
| 155 | - 'value' => sanitize_key( urldecode( $_GET['discount_type'] ) ), |
|
| 155 | + 'value' => sanitize_key(urldecode($_GET['discount_type'])), |
|
| 156 | 156 | 'compare' => '=', |
| 157 | 157 | ); |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - if ( ! empty( $meta_query ) ) { |
|
| 160 | + if (!empty($meta_query)) { |
|
| 161 | 161 | $vars['meta_query'] = $meta_query; |
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | return $vars; |
| 166 | 166 | } |
| 167 | -add_filter( 'request', 'wpinv_request' ); |
|
| 167 | +add_filter('request', 'wpinv_request'); |
|
| 168 | 168 | |
| 169 | 169 | /** |
| 170 | 170 | * Create a page and store the ID in an option. |
@@ -176,61 +176,61 @@ discard block |
||
| 176 | 176 | * @param int $post_parent (default: 0) Parent for the new page |
| 177 | 177 | * @return int page ID |
| 178 | 178 | */ |
| 179 | -function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) { |
|
| 179 | +function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) { |
|
| 180 | 180 | global $wpdb; |
| 181 | 181 | |
| 182 | - $option_value = wpinv_get_option( $option ); |
|
| 182 | + $option_value = wpinv_get_option($option); |
|
| 183 | 183 | |
| 184 | - if ( ! empty( $option_value ) && ( $page_object = get_post( $option_value ) ) ) { |
|
| 185 | - if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) { |
|
| 184 | + if (!empty($option_value) && ($page_object = get_post($option_value))) { |
|
| 185 | + if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) { |
|
| 186 | 186 | // Valid page is already in place |
| 187 | 187 | return $page_object->ID; |
| 188 | 188 | } |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - if ( ! empty( $post_parent ) ) { |
|
| 192 | - $page = get_page_by_path( $post_parent ); |
|
| 193 | - if ( $page ) { |
|
| 191 | + if (!empty($post_parent)) { |
|
| 192 | + $page = get_page_by_path($post_parent); |
|
| 193 | + if ($page) { |
|
| 194 | 194 | $post_parent = $page->ID; |
| 195 | 195 | } else { |
| 196 | 196 | $post_parent = ''; |
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - if ( strlen( $page_content ) > 0 ) { |
|
| 200 | + if (strlen($page_content) > 0) { |
|
| 201 | 201 | // Search for an existing page with the specified page content (typically a shortcode) |
| 202 | - $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); |
|
| 202 | + $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%")); |
|
| 203 | 203 | } else { |
| 204 | 204 | // Search for an existing page with the specified page slug |
| 205 | - $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug ) ); |
|
| 205 | + $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug)); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content ); |
|
| 208 | + $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content); |
|
| 209 | 209 | |
| 210 | - if ( $valid_page_found ) { |
|
| 211 | - if ( $option ) { |
|
| 212 | - wpinv_update_option( $option, $valid_page_found ); |
|
| 210 | + if ($valid_page_found) { |
|
| 211 | + if ($option) { |
|
| 212 | + wpinv_update_option($option, $valid_page_found); |
|
| 213 | 213 | } |
| 214 | 214 | return $valid_page_found; |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | // Search for a matching valid trashed page |
| 218 | - if ( strlen( $page_content ) > 0 ) { |
|
| 218 | + if (strlen($page_content) > 0) { |
|
| 219 | 219 | // Search for an existing page with the specified page content (typically a shortcode) |
| 220 | - $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); |
|
| 220 | + $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%")); |
|
| 221 | 221 | } else { |
| 222 | 222 | // Search for an existing page with the specified page slug |
| 223 | - $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) ); |
|
| 223 | + $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug)); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - if ( $trashed_page_found ) { |
|
| 226 | + if ($trashed_page_found) { |
|
| 227 | 227 | $page_id = $trashed_page_found; |
| 228 | 228 | $page_data = array( |
| 229 | 229 | 'ID' => $page_id, |
| 230 | 230 | 'post_status' => 'publish', |
| 231 | 231 | 'post_parent' => $post_parent, |
| 232 | 232 | ); |
| 233 | - wp_update_post( $page_data ); |
|
| 233 | + wp_update_post($page_data); |
|
| 234 | 234 | } else { |
| 235 | 235 | $page_data = array( |
| 236 | 236 | 'post_status' => 'publish', |
@@ -242,11 +242,11 @@ discard block |
||
| 242 | 242 | 'post_parent' => $post_parent, |
| 243 | 243 | 'comment_status' => 'closed', |
| 244 | 244 | ); |
| 245 | - $page_id = wp_insert_post( $page_data ); |
|
| 245 | + $page_id = wp_insert_post($page_data); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - if ( $option ) { |
|
| 249 | - wpinv_update_option( $option, (int) $page_id ); |
|
| 248 | + if ($option) { |
|
| 249 | + wpinv_update_option($option, (int) $page_id); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | return $page_id; |
@@ -259,11 +259,11 @@ discard block |
||
| 259 | 259 | * |
| 260 | 260 | * @return array |
| 261 | 261 | */ |
| 262 | -function wpinv_add_aui_screens( $screen_ids ) { |
|
| 262 | +function wpinv_add_aui_screens($screen_ids) { |
|
| 263 | 263 | |
| 264 | 264 | // load on these pages if set |
| 265 | - $screen_ids = array_merge( $screen_ids, wpinv_get_screen_ids() ); |
|
| 265 | + $screen_ids = array_merge($screen_ids, wpinv_get_screen_ids()); |
|
| 266 | 266 | |
| 267 | 267 | return $screen_ids; |
| 268 | 268 | } |
| 269 | -add_filter( 'aui_screen_ids', 'wpinv_add_aui_screens' ); |
|
| 269 | +add_filter('aui_screen_ids', 'wpinv_add_aui_screens'); |
|