@@ -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_Invoice_Payment_Meta { |
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | - * Output the metabox. |
|
| 21 | - * |
|
| 22 | - * @param WP_Post $post |
|
| 23 | - */ |
|
| 20 | + * Output the metabox. |
|
| 21 | + * |
|
| 22 | + * @param WP_Post $post |
|
| 23 | + */ |
|
| 24 | 24 | public static function output( $post ) { |
| 25 | 25 | |
| 26 | 26 | // Prepare the invoice. |
@@ -42,9 +42,9 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | if ( $invoice->is_draft() ) { |
| 44 | 44 | |
| 45 | - // Set gateway. |
|
| 46 | - echo aui()->select( |
|
| 47 | - array( |
|
| 45 | + // Set gateway. |
|
| 46 | + echo aui()->select( |
|
| 47 | + array( |
|
| 48 | 48 | 'id' => 'wpinv_gateway', |
| 49 | 49 | 'name' => 'wpinv_gateway', |
| 50 | 50 | 'label' => __( 'Gateway:', 'invoicing' ), |
@@ -54,143 +54,143 @@ discard block |
||
| 54 | 54 | 'select2' => true, |
| 55 | 55 | 'data-allow-clear' => 'false', |
| 56 | 56 | 'options' => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ), |
| 57 | - ) |
|
| 58 | - ); |
|
| 57 | + ) |
|
| 58 | + ); |
|
| 59 | 59 | |
| 60 | 60 | } else { |
| 61 | - // Invoice key. |
|
| 62 | - echo aui()->input( |
|
| 63 | - array( |
|
| 61 | + // Invoice key. |
|
| 62 | + echo aui()->input( |
|
| 63 | + array( |
|
| 64 | 64 | 'type' => 'text', |
| 65 | 65 | 'id' => 'wpinv_key', |
| 66 | 66 | 'name' => 'wpinv_key', |
| 67 | 67 | 'label' => sprintf( |
| 68 | - __( '%s Key:', 'invoicing' ), |
|
| 69 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 68 | + __( '%s Key:', 'invoicing' ), |
|
| 69 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 70 | 70 | ), |
| 71 | 71 | 'label_type' => 'vertical', |
| 72 | 72 | 'class' => 'form-control-sm', |
| 73 | 73 | 'value' => $invoice->get_key( 'edit' ), |
| 74 | 74 | 'extra_attributes' => array( |
| 75 | - 'onclick' => 'this.select();', |
|
| 76 | - 'readonly' => 'true', |
|
| 75 | + 'onclick' => 'this.select();', |
|
| 76 | + 'readonly' => 'true', |
|
| 77 | 77 | ), |
| 78 | - ) |
|
| 79 | - ); |
|
| 78 | + ) |
|
| 79 | + ); |
|
| 80 | 80 | |
| 81 | - // View URL. |
|
| 82 | - echo aui()->input( |
|
| 83 | - array( |
|
| 81 | + // View URL. |
|
| 82 | + echo aui()->input( |
|
| 83 | + array( |
|
| 84 | 84 | 'type' => 'text', |
| 85 | 85 | 'id' => 'wpinv_view_url', |
| 86 | 86 | 'name' => 'wpinv_view_url', |
| 87 | 87 | 'label' => sprintf( |
| 88 | - __( '%s URL:', 'invoicing' ), |
|
| 89 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 88 | + __( '%s URL:', 'invoicing' ), |
|
| 89 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 90 | 90 | ) . ' <a href="' . esc_url_raw( $invoice->get_view_url() ) . '" title="' . __( 'View invoice', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>', |
| 91 | 91 | 'label_type' => 'vertical', |
| 92 | 92 | 'class' => 'form-control-sm', |
| 93 | 93 | 'value' => $invoice->get_view_url(), |
| 94 | 94 | 'extra_attributes' => array( |
| 95 | - 'onclick' => 'this.select();', |
|
| 96 | - 'readonly' => 'true', |
|
| 95 | + 'onclick' => 'this.select();', |
|
| 96 | + 'readonly' => 'true', |
|
| 97 | 97 | ), |
| 98 | - ) |
|
| 99 | - ); |
|
| 100 | - |
|
| 101 | - // If the invoice is paid... |
|
| 102 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 103 | - |
|
| 104 | - // Gateway. |
|
| 105 | - echo aui()->input( |
|
| 106 | - array( |
|
| 107 | - 'type' => 'text', |
|
| 108 | - 'id' => 'wpinv_gateway', |
|
| 109 | - 'name' => '', |
|
| 110 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
| 111 | - 'label_type' => 'vertical', |
|
| 112 | - 'class' => 'form-control-sm', |
|
| 113 | - 'value' => wpinv_get_gateway_admin_label( $invoice->get_gateway( 'edit' ) ), |
|
| 114 | - 'extra_attributes' => array( |
|
| 115 | - 'onclick' => 'this.select();', |
|
| 116 | - 'readonly' => 'true', |
|
| 117 | - ), |
|
| 118 | - ) |
|
| 119 | - ); |
|
| 120 | - |
|
| 121 | - // Transaction ID. |
|
| 122 | - $transaction_url = $invoice->get_transaction_url(); |
|
| 123 | - echo aui()->input( |
|
| 124 | - array( |
|
| 125 | - 'type' => 'text', |
|
| 126 | - 'id' => 'wpinv_transaction_id', |
|
| 127 | - 'name' => 'wpinv_transaction_id', |
|
| 128 | - 'label' => __( 'Transaction ID:', 'invoicing' ) . ( $transaction_url ? ' <a href="' . esc_url( $transaction_url ) . '" title="' . __( 'View details', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>' : '' ), |
|
| 129 | - 'label_type' => 'vertical', |
|
| 130 | - 'class' => 'form-control-sm', |
|
| 131 | - 'value' => $invoice->get_transaction_id( 'edit' ), |
|
| 132 | - 'help_text' => apply_filters( 'wpinv_invoice_transaction_link_' . $invoice->get_gateway( 'edit' ), '', $invoice->get_transaction_id(), $invoice ), |
|
| 133 | - 'extra_attributes' => array( |
|
| 134 | - 'onclick' => 'this.select();', |
|
| 135 | - 'readonly' => 'true', |
|
| 136 | - ), |
|
| 137 | - ) |
|
| 138 | - ); |
|
| 139 | - |
|
| 140 | - // Currency. |
|
| 141 | - echo aui()->input( |
|
| 142 | - array( |
|
| 143 | - 'type' => 'text', |
|
| 144 | - 'id' => 'wpinv_currency', |
|
| 145 | - 'name' => 'wpinv_currency', |
|
| 146 | - 'label' => __( 'Currency:', 'invoicing' ), |
|
| 147 | - 'label_type' => 'vertical', |
|
| 148 | - 'class' => 'form-control-sm', |
|
| 149 | - 'value' => $invoice->get_currency( 'edit' ), |
|
| 150 | - 'extra_attributes' => array( |
|
| 151 | - 'onclick' => 'this.select();', |
|
| 152 | - 'readonly' => 'true', |
|
| 153 | - ), |
|
| 154 | - ) |
|
| 155 | - ); |
|
| 156 | - |
|
| 157 | - } else { |
|
| 158 | - |
|
| 159 | - if ( 'wpi_invoice' == $invoice->get_post_type() ) { |
|
| 160 | - |
|
| 161 | - // Payment URL. |
|
| 162 | - echo aui()->input( |
|
| 163 | - array( |
|
| 164 | - 'type' => 'text', |
|
| 165 | - 'id' => 'wpinv_payment_url', |
|
| 166 | - 'name' => 'wpinv_payment_url', |
|
| 167 | - 'label' => __( 'Payment URL:', 'invoicing' ), |
|
| 168 | - 'label_type' => 'vertical', |
|
| 169 | - 'class' => 'form-control-sm', |
|
| 170 | - 'value' => $invoice->get_checkout_payment_url(), |
|
| 171 | - 'extra_attributes' => array( |
|
| 172 | - 'onclick' => 'this.select();', |
|
| 173 | - 'readonly' => 'true', |
|
| 174 | - ), |
|
| 175 | - ) |
|
| 176 | - ); |
|
| 177 | - |
|
| 178 | - // Set gateway. |
|
| 179 | - echo aui()->select( |
|
| 180 | - array( |
|
| 181 | - 'id' => 'wpinv_gateway', |
|
| 182 | - 'name' => 'wpinv_gateway', |
|
| 183 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
| 184 | - 'label_type' => 'vertical', |
|
| 185 | - 'placeholder' => __( 'Select Gateway', 'invoicing' ), |
|
| 186 | - 'value' => $invoice->get_gateway( 'edit' ), |
|
| 187 | - 'select2' => true, |
|
| 188 | - 'data-allow-clear' => 'false', |
|
| 189 | - 'options' => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ), |
|
| 190 | - ) |
|
| 191 | - ); |
|
| 192 | - |
|
| 193 | - } |
|
| 98 | + ) |
|
| 99 | + ); |
|
| 100 | + |
|
| 101 | + // If the invoice is paid... |
|
| 102 | + if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 103 | + |
|
| 104 | + // Gateway. |
|
| 105 | + echo aui()->input( |
|
| 106 | + array( |
|
| 107 | + 'type' => 'text', |
|
| 108 | + 'id' => 'wpinv_gateway', |
|
| 109 | + 'name' => '', |
|
| 110 | + 'label' => __( 'Gateway:', 'invoicing' ), |
|
| 111 | + 'label_type' => 'vertical', |
|
| 112 | + 'class' => 'form-control-sm', |
|
| 113 | + 'value' => wpinv_get_gateway_admin_label( $invoice->get_gateway( 'edit' ) ), |
|
| 114 | + 'extra_attributes' => array( |
|
| 115 | + 'onclick' => 'this.select();', |
|
| 116 | + 'readonly' => 'true', |
|
| 117 | + ), |
|
| 118 | + ) |
|
| 119 | + ); |
|
| 120 | + |
|
| 121 | + // Transaction ID. |
|
| 122 | + $transaction_url = $invoice->get_transaction_url(); |
|
| 123 | + echo aui()->input( |
|
| 124 | + array( |
|
| 125 | + 'type' => 'text', |
|
| 126 | + 'id' => 'wpinv_transaction_id', |
|
| 127 | + 'name' => 'wpinv_transaction_id', |
|
| 128 | + 'label' => __( 'Transaction ID:', 'invoicing' ) . ( $transaction_url ? ' <a href="' . esc_url( $transaction_url ) . '" title="' . __( 'View details', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>' : '' ), |
|
| 129 | + 'label_type' => 'vertical', |
|
| 130 | + 'class' => 'form-control-sm', |
|
| 131 | + 'value' => $invoice->get_transaction_id( 'edit' ), |
|
| 132 | + 'help_text' => apply_filters( 'wpinv_invoice_transaction_link_' . $invoice->get_gateway( 'edit' ), '', $invoice->get_transaction_id(), $invoice ), |
|
| 133 | + 'extra_attributes' => array( |
|
| 134 | + 'onclick' => 'this.select();', |
|
| 135 | + 'readonly' => 'true', |
|
| 136 | + ), |
|
| 137 | + ) |
|
| 138 | + ); |
|
| 139 | + |
|
| 140 | + // Currency. |
|
| 141 | + echo aui()->input( |
|
| 142 | + array( |
|
| 143 | + 'type' => 'text', |
|
| 144 | + 'id' => 'wpinv_currency', |
|
| 145 | + 'name' => 'wpinv_currency', |
|
| 146 | + 'label' => __( 'Currency:', 'invoicing' ), |
|
| 147 | + 'label_type' => 'vertical', |
|
| 148 | + 'class' => 'form-control-sm', |
|
| 149 | + 'value' => $invoice->get_currency( 'edit' ), |
|
| 150 | + 'extra_attributes' => array( |
|
| 151 | + 'onclick' => 'this.select();', |
|
| 152 | + 'readonly' => 'true', |
|
| 153 | + ), |
|
| 154 | + ) |
|
| 155 | + ); |
|
| 156 | + |
|
| 157 | + } else { |
|
| 158 | + |
|
| 159 | + if ( 'wpi_invoice' == $invoice->get_post_type() ) { |
|
| 160 | + |
|
| 161 | + // Payment URL. |
|
| 162 | + echo aui()->input( |
|
| 163 | + array( |
|
| 164 | + 'type' => 'text', |
|
| 165 | + 'id' => 'wpinv_payment_url', |
|
| 166 | + 'name' => 'wpinv_payment_url', |
|
| 167 | + 'label' => __( 'Payment URL:', 'invoicing' ), |
|
| 168 | + 'label_type' => 'vertical', |
|
| 169 | + 'class' => 'form-control-sm', |
|
| 170 | + 'value' => $invoice->get_checkout_payment_url(), |
|
| 171 | + 'extra_attributes' => array( |
|
| 172 | + 'onclick' => 'this.select();', |
|
| 173 | + 'readonly' => 'true', |
|
| 174 | + ), |
|
| 175 | + ) |
|
| 176 | + ); |
|
| 177 | + |
|
| 178 | + // Set gateway. |
|
| 179 | + echo aui()->select( |
|
| 180 | + array( |
|
| 181 | + 'id' => 'wpinv_gateway', |
|
| 182 | + 'name' => 'wpinv_gateway', |
|
| 183 | + 'label' => __( 'Gateway:', 'invoicing' ), |
|
| 184 | + 'label_type' => 'vertical', |
|
| 185 | + 'placeholder' => __( 'Select Gateway', 'invoicing' ), |
|
| 186 | + 'value' => $invoice->get_gateway( 'edit' ), |
|
| 187 | + 'select2' => true, |
|
| 188 | + 'data-allow-clear' => 'false', |
|
| 189 | + 'options' => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ), |
|
| 190 | + ) |
|
| 191 | + ); |
|
| 192 | + |
|
| 193 | + } |
|
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | ?> |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | - exit; // Exit if accessed directly |
|
| 10 | + exit; // Exit if accessed directly |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | /** |
@@ -15,22 +15,22 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | class GetPaid_Meta_Box_Invoice_Shipping_Address { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Output the metabox. |
|
| 20 | - * |
|
| 21 | - * @param WP_Post $post |
|
| 22 | - */ |
|
| 23 | - public static function output( $post ) { |
|
| 18 | + /** |
|
| 19 | + * Output the metabox. |
|
| 20 | + * |
|
| 21 | + * @param WP_Post $post |
|
| 22 | + */ |
|
| 23 | + public static function output( $post ) { |
|
| 24 | 24 | |
| 25 | - // Retrieve shipping address. |
|
| 26 | - $shipping_address = get_post_meta( $post->ID, 'shipping_address', true ); |
|
| 25 | + // Retrieve shipping address. |
|
| 26 | + $shipping_address = get_post_meta( $post->ID, 'shipping_address', true ); |
|
| 27 | 27 | |
| 28 | - // Abort if it is invalid. |
|
| 29 | - if ( ! is_array( $shipping_address ) ) { |
|
| 30 | - return; |
|
| 31 | - } |
|
| 28 | + // Abort if it is invalid. |
|
| 29 | + if ( ! is_array( $shipping_address ) ) { |
|
| 30 | + return; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - ?> |
|
| 33 | + ?> |
|
| 34 | 34 | |
| 35 | 35 | <div class="bsui"> |
| 36 | 36 | |
@@ -68,31 +68,31 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | <?php |
| 70 | 70 | |
| 71 | - } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Prepares a value. |
|
| 75 | - * |
|
| 76 | - * @param array $address |
|
| 77 | - * @param string $key |
|
| 78 | - * @return string |
|
| 79 | - */ |
|
| 80 | - public static function prepare_for_display( $address, $key ) { |
|
| 73 | + /** |
|
| 74 | + * Prepares a value. |
|
| 75 | + * |
|
| 76 | + * @param array $address |
|
| 77 | + * @param string $key |
|
| 78 | + * @return string |
|
| 79 | + */ |
|
| 80 | + public static function prepare_for_display( $address, $key ) { |
|
| 81 | 81 | |
| 82 | - // Prepare the value. |
|
| 83 | - $value = $address[ $key ]; |
|
| 82 | + // Prepare the value. |
|
| 83 | + $value = $address[ $key ]; |
|
| 84 | 84 | |
| 85 | - if ( $key == 'country' ) { |
|
| 86 | - $value = wpinv_country_name( $value ); |
|
| 87 | - } |
|
| 85 | + if ( $key == 'country' ) { |
|
| 86 | + $value = wpinv_country_name( $value ); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - if ( $key == 'state' ) { |
|
| 90 | - $country = isset( $address['country'] ) ? $address['country'] : wpinv_get_default_country(); |
|
| 91 | - $value = wpinv_state_name( $value, $country ); |
|
| 92 | - } |
|
| 89 | + if ( $key == 'state' ) { |
|
| 90 | + $country = isset( $address['country'] ) ? $address['country'] : wpinv_get_default_country(); |
|
| 91 | + $value = wpinv_state_name( $value, $country ); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - return esc_html( $value ); |
|
| 94 | + return esc_html( $value ); |
|
| 95 | 95 | |
| 96 | - } |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | 98 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 | |
@@ -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; |
@@ -24,14 +24,14 @@ discard block |
||
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | - * Highlights sub menus. |
|
| 28 | - */ |
|
| 29 | - public function set_admin_menu_class() { |
|
| 30 | - global $current_screen, $parent_file, $submenu_file; |
|
| 27 | + * Highlights sub menus. |
|
| 28 | + */ |
|
| 29 | + public function set_admin_menu_class() { |
|
| 30 | + global $current_screen, $parent_file, $submenu_file; |
|
| 31 | 31 | |
| 32 | 32 | if ( ! empty( $current_screen->id ) && in_array( $current_screen->id, array( 'wpi_discount', 'wpi_payment_form', 'wpi_invoice' ) ) ) { |
| 33 | - $parent_file = 'wpinv'; |
|
| 34 | - $submenu_file = 'edit.php?post_type=' . $current_screen->id; |
|
| 33 | + $parent_file = 'wpinv'; |
|
| 34 | + $submenu_file = 'edit.php?post_type=' . $current_screen->id; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | } |
@@ -165,8 +165,8 @@ discard block |
||
| 165 | 165 | foreach ( wpinv_get_settings_tabs() as $tab_id => $tab_name ) { |
| 166 | 166 | $tab_url = add_query_arg( |
| 167 | 167 | array( |
| 168 | - 'settings-updated' => false, |
|
| 169 | - 'tab' => $tab_id, |
|
| 168 | + 'settings-updated' => false, |
|
| 169 | + 'tab' => $tab_id, |
|
| 170 | 170 | ), |
| 171 | 171 | 'admin.php?page=wpinv-settings' |
| 172 | 172 | ); |
@@ -193,9 +193,9 @@ discard block |
||
| 193 | 193 | $number++; |
| 194 | 194 | $tab_url = add_query_arg( |
| 195 | 195 | array( |
| 196 | - 'settings-updated' => false, |
|
| 197 | - 'tab' => $active_tab, |
|
| 198 | - 'section' => $section_id, |
|
| 196 | + 'settings-updated' => false, |
|
| 197 | + 'tab' => $active_tab, |
|
| 198 | + 'section' => $section_id, |
|
| 199 | 199 | ), |
| 200 | 200 | admin_url( 'admin.php?page=wpinv-settings' ) |
| 201 | 201 | ); |