@@ -19,28 +19,28 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | function getpaid_get_customers( $args = array(), $return = 'results' ) { |
| 21 | 21 | |
| 22 | - // Do not retrieve all fields if we just want the count. |
|
| 23 | - if ( 'count' === $return ) { |
|
| 24 | - $args['fields'] = 'id'; |
|
| 25 | - $args['number'] = 1; |
|
| 26 | - } |
|
| 22 | + // Do not retrieve all fields if we just want the count. |
|
| 23 | + if ( 'count' === $return ) { |
|
| 24 | + $args['fields'] = 'id'; |
|
| 25 | + $args['number'] = 1; |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - // Do not count all matches if we just want the results. |
|
| 29 | - if ( 'results' === $return ) { |
|
| 30 | - $args['count_total'] = false; |
|
| 31 | - } |
|
| 28 | + // Do not count all matches if we just want the results. |
|
| 29 | + if ( 'results' === $return ) { |
|
| 30 | + $args['count_total'] = false; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - $query = new GetPaid_Customers_Query( $args ); |
|
| 33 | + $query = new GetPaid_Customers_Query( $args ); |
|
| 34 | 34 | |
| 35 | - if ( 'results' === $return ) { |
|
| 36 | - return $query->get_results(); |
|
| 37 | - } |
|
| 35 | + if ( 'results' === $return ) { |
|
| 36 | + return $query->get_results(); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - if ( 'count' === $return ) { |
|
| 40 | - return $query->get_total(); |
|
| 41 | - } |
|
| 39 | + if ( 'count' === $return ) { |
|
| 40 | + return $query->get_total(); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - return $query; |
|
| 43 | + return $query; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -106,11 +106,11 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) { |
| 108 | 108 | |
| 109 | - if ( current_user_can( 'manage_options' ) ) { |
|
| 110 | - return 'manage_options'; |
|
| 111 | - }; |
|
| 109 | + if ( current_user_can( 'manage_options' ) ) { |
|
| 110 | + return 'manage_options'; |
|
| 111 | + }; |
|
| 112 | 112 | |
| 113 | - return $capalibilty; |
|
| 113 | + return $capalibilty; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -133,9 +133,9 @@ discard block |
||
| 133 | 133 | * @return bool Whether the current user has the given capability. |
| 134 | 134 | */ |
| 135 | 135 | function wpinv_current_user_can( $capability, $args = array() ) { |
| 136 | - $can = wpinv_current_user_can_manage_invoicing(); |
|
| 136 | + $can = wpinv_current_user_can_manage_invoicing(); |
|
| 137 | 137 | |
| 138 | - return apply_filters( 'getpaid_current_user_can', $can, $capability, $args ); |
|
| 138 | + return apply_filters( 'getpaid_current_user_can', $can, $capability, $args ); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -149,10 +149,10 @@ discard block |
||
| 149 | 149 | // Prepare user values. |
| 150 | 150 | $prefix = preg_replace( '/\s+/', '', $prefix ); |
| 151 | 151 | $prefix = empty( $prefix ) ? $email : $prefix; |
| 152 | - $args = array( |
|
| 153 | - 'user_login' => wpinv_generate_user_name( $prefix ), |
|
| 154 | - 'user_pass' => wp_generate_password(), |
|
| 155 | - 'user_email' => $email, |
|
| 152 | + $args = array( |
|
| 153 | + 'user_login' => wpinv_generate_user_name( $prefix ), |
|
| 154 | + 'user_pass' => wp_generate_password(), |
|
| 155 | + 'user_email' => $email, |
|
| 156 | 156 | 'role' => 'subscriber', |
| 157 | 157 | ); |
| 158 | 158 | |
@@ -169,16 +169,16 @@ discard block |
||
| 169 | 169 | function wpinv_generate_user_name( $prefix = '' ) { |
| 170 | 170 | |
| 171 | 171 | // If prefix is an email, retrieve the part before the email. |
| 172 | - $prefix = strtok( $prefix, '@' ); |
|
| 172 | + $prefix = strtok( $prefix, '@' ); |
|
| 173 | 173 | $prefix = trim( $prefix, '.' ); |
| 174 | 174 | |
| 175 | - // Sanitize the username. |
|
| 176 | - $prefix = sanitize_user( $prefix, true ); |
|
| 175 | + // Sanitize the username. |
|
| 176 | + $prefix = sanitize_user( $prefix, true ); |
|
| 177 | 177 | |
| 178 | - $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
| 179 | - if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
| 180 | - $prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
| 181 | - } |
|
| 178 | + $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
| 179 | + if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
| 180 | + $prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | 183 | $username = $prefix; |
| 184 | 184 | $postfix = 2; |
@@ -317,43 +317,43 @@ discard block |
||
| 317 | 317 | |
| 318 | 318 | $value = $customer->get( $key ); |
| 319 | 319 | |
| 320 | - // Display the country. |
|
| 321 | - if ( 'country' == $key ) { |
|
| 322 | - |
|
| 323 | - aui()->select( |
|
| 324 | - array( |
|
| 325 | - 'options' => wpinv_get_country_list(), |
|
| 326 | - 'name' => 'getpaid_address[' . esc_attr( $key ) . ']', |
|
| 327 | - 'id' => 'wpinv-' . sanitize_html_class( $key ), |
|
| 328 | - 'value' => sanitize_text_field( $value ), |
|
| 329 | - 'placeholder' => $label, |
|
| 330 | - 'label' => wp_kses_post( $label ), |
|
| 331 | - 'label_type' => 'vertical', |
|
| 332 | - 'class' => 'getpaid-address-field', |
|
| 320 | + // Display the country. |
|
| 321 | + if ( 'country' == $key ) { |
|
| 322 | + |
|
| 323 | + aui()->select( |
|
| 324 | + array( |
|
| 325 | + 'options' => wpinv_get_country_list(), |
|
| 326 | + 'name' => 'getpaid_address[' . esc_attr( $key ) . ']', |
|
| 327 | + 'id' => 'wpinv-' . sanitize_html_class( $key ), |
|
| 328 | + 'value' => sanitize_text_field( $value ), |
|
| 329 | + 'placeholder' => $label, |
|
| 330 | + 'label' => wp_kses_post( $label ), |
|
| 331 | + 'label_type' => 'vertical', |
|
| 332 | + 'class' => 'getpaid-address-field', |
|
| 333 | 333 | ), |
| 334 | 334 | true |
| 335 | - ); |
|
| 335 | + ); |
|
| 336 | 336 | |
| 337 | - } |
|
| 337 | + } |
|
| 338 | 338 | |
| 339 | - // Display the state. |
|
| 340 | - elseif ( 'state' == $key ) { |
|
| 339 | + // Display the state. |
|
| 340 | + elseif ( 'state' == $key ) { |
|
| 341 | 341 | |
| 342 | - getpaid_get_states_select_markup( |
|
| 342 | + getpaid_get_states_select_markup( |
|
| 343 | 343 | $customer->get( 'country' ), |
| 344 | - $value, |
|
| 345 | - $label, |
|
| 346 | - $label, |
|
| 347 | - '', |
|
| 348 | - false, |
|
| 349 | - '', |
|
| 350 | - 'getpaid_address[' . esc_attr( $key ) . ']', |
|
| 344 | + $value, |
|
| 345 | + $label, |
|
| 346 | + $label, |
|
| 347 | + '', |
|
| 348 | + false, |
|
| 349 | + '', |
|
| 350 | + 'getpaid_address[' . esc_attr( $key ) . ']', |
|
| 351 | 351 | true |
| 352 | - ); |
|
| 352 | + ); |
|
| 353 | 353 | |
| 354 | 354 | } else { |
| 355 | 355 | |
| 356 | - aui()->input( |
|
| 356 | + aui()->input( |
|
| 357 | 357 | array( |
| 358 | 358 | 'name' => 'getpaid_address[' . esc_attr( $key ) . ']', |
| 359 | 359 | 'id' => 'wpinv-' . sanitize_html_class( $key ), |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | 'class' => 'getpaid-address-field', |
| 366 | 366 | ), |
| 367 | 367 | true |
| 368 | - ); |
|
| 368 | + ); |
|
| 369 | 369 | |
| 370 | 370 | } |
| 371 | 371 | } |
@@ -509,7 +509,7 @@ discard block |
||
| 509 | 509 | function getpaid_allowed_html() { |
| 510 | 510 | $allowed_html = wp_kses_allowed_html( 'post' ); |
| 511 | 511 | |
| 512 | - // form fields |
|
| 512 | + // form fields |
|
| 513 | 513 | $allowed_html['form'] = array( |
| 514 | 514 | 'action' => true, |
| 515 | 515 | 'accept' => true, |
@@ -521,12 +521,12 @@ discard block |
||
| 521 | 521 | ); |
| 522 | 522 | |
| 523 | 523 | // - input |
| 524 | - $allowed_html['input'] = array( |
|
| 525 | - 'class' => array(), |
|
| 526 | - 'id' => array(), |
|
| 527 | - 'name' => array(), |
|
| 528 | - 'value' => array(), |
|
| 529 | - 'type' => array(), |
|
| 524 | + $allowed_html['input'] = array( |
|
| 525 | + 'class' => array(), |
|
| 526 | + 'id' => array(), |
|
| 527 | + 'name' => array(), |
|
| 528 | + 'value' => array(), |
|
| 529 | + 'type' => array(), |
|
| 530 | 530 | 'placeholder' => array(), |
| 531 | 531 | 'autocomplete' => array(), |
| 532 | 532 | 'autofocus' => array(), |
@@ -540,33 +540,33 @@ discard block |
||
| 540 | 540 | 'max' => array(), |
| 541 | 541 | 'step' => array(), |
| 542 | 542 | 'size' => array(), |
| 543 | - ); |
|
| 543 | + ); |
|
| 544 | 544 | |
| 545 | 545 | // - input |
| 546 | - $allowed_html['textarea'] = array( |
|
| 547 | - 'class' => array(), |
|
| 548 | - 'id' => array(), |
|
| 549 | - 'name' => array(), |
|
| 550 | - 'value' => array(), |
|
| 551 | - ); |
|
| 552 | - |
|
| 553 | - // select |
|
| 554 | - $allowed_html['select'] = array( |
|
| 555 | - 'class' => array(), |
|
| 556 | - 'id' => array(), |
|
| 557 | - 'name' => array(), |
|
| 546 | + $allowed_html['textarea'] = array( |
|
| 547 | + 'class' => array(), |
|
| 548 | + 'id' => array(), |
|
| 549 | + 'name' => array(), |
|
| 550 | + 'value' => array(), |
|
| 551 | + ); |
|
| 552 | + |
|
| 553 | + // select |
|
| 554 | + $allowed_html['select'] = array( |
|
| 555 | + 'class' => array(), |
|
| 556 | + 'id' => array(), |
|
| 557 | + 'name' => array(), |
|
| 558 | 558 | 'autocomplete' => array(), |
| 559 | 559 | 'multiple' => array(), |
| 560 | - ); |
|
| 560 | + ); |
|
| 561 | 561 | |
| 562 | - // select options |
|
| 563 | - $allowed_html['option'] = array( |
|
| 564 | - 'selected' => array(), |
|
| 562 | + // select options |
|
| 563 | + $allowed_html['option'] = array( |
|
| 564 | + 'selected' => array(), |
|
| 565 | 565 | 'disabled' => array(), |
| 566 | 566 | 'value' => array(), |
| 567 | - ); |
|
| 567 | + ); |
|
| 568 | 568 | |
| 569 | - return $allowed_html; |
|
| 569 | + return $allowed_html; |
|
| 570 | 570 | |
| 571 | 571 | } |
| 572 | 572 | |
@@ -870,14 +870,14 @@ discard block |
||
| 870 | 870 | * @param WP_User $user WP_User object of the user to delete. |
| 871 | 871 | */ |
| 872 | 872 | function getpaid_delete_user_data( $user_id, $reassign, $user ) { |
| 873 | - global $wpdb; |
|
| 874 | - |
|
| 875 | - // Delete customer data. |
|
| 876 | - $wpdb->delete( |
|
| 877 | - $wpdb->prefix . 'getpaid_customers', |
|
| 878 | - array( |
|
| 879 | - 'user_id' => (int) $user_id, |
|
| 880 | - ) |
|
| 881 | - ); |
|
| 873 | + global $wpdb; |
|
| 874 | + |
|
| 875 | + // Delete customer data. |
|
| 876 | + $wpdb->delete( |
|
| 877 | + $wpdb->prefix . 'getpaid_customers', |
|
| 878 | + array( |
|
| 879 | + 'user_id' => (int) $user_id, |
|
| 880 | + ) |
|
| 881 | + ); |
|
| 882 | 882 | } |
| 883 | 883 | add_action( 'delete_user', 'getpaid_delete_user_data', 10, 3 ); |
| 884 | 884 | \ No newline at end of file |
@@ -12,257 +12,257 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class GetPaid_Payment_Form_Submission_Taxes { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Submission taxes. |
|
| 17 | - * @var array |
|
| 18 | - */ |
|
| 19 | - public $taxes = array(); |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * Whether or not we should skip the taxes. |
|
| 23 | - * @var bool |
|
| 24 | - */ |
|
| 25 | - protected $skip_taxes = false; |
|
| 15 | + /** |
|
| 16 | + * Submission taxes. |
|
| 17 | + * @var array |
|
| 18 | + */ |
|
| 19 | + public $taxes = array(); |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * Whether or not we should skip the taxes. |
|
| 23 | + * @var bool |
|
| 24 | + */ |
|
| 25 | + protected $skip_taxes = false; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * Class constructor |
|
| 29 | + * |
|
| 30 | + * @param GetPaid_Payment_Form_Submission $submission |
|
| 31 | + */ |
|
| 32 | + public function __construct( $submission ) { |
|
| 33 | + // Validate VAT number. |
|
| 34 | + $this->validate_vat( $submission ); |
|
| 35 | + |
|
| 36 | + if ( $this->skip_taxes ) { |
|
| 37 | + return; |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + foreach ( $submission->get_items() as $item ) { |
|
| 41 | + $this->process_item_tax( $item, $submission ); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + // Process any existing invoice taxes. |
|
| 45 | + if ( $submission->has_invoice() ) { |
|
| 46 | + $invoice = $submission->get_invoice(); |
|
| 47 | + $invoice = $this->refresh_totals( $invoice, $submission ); |
|
| 48 | + |
|
| 49 | + $this->taxes = array_replace( $invoice->get_taxes(), $this->taxes ); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Maybe process tax. |
|
| 55 | + * |
|
| 56 | + * @since 1.0.19 |
|
| 57 | + * @param GetPaid_Form_Item $item |
|
| 58 | + * @param GetPaid_Payment_Form_Submission $submission |
|
| 59 | + */ |
|
| 60 | + public function process_item_tax( $item, $submission ) { |
|
| 61 | + |
|
| 62 | + $rates = getpaid_get_item_tax_rates( $item, $submission->country, $submission->state ); |
|
| 63 | + $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
| 64 | + $taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates ); |
|
| 65 | + $r_taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates ); |
|
| 66 | + |
|
| 67 | + foreach ( $taxes as $name => $amount ) { |
|
| 68 | + $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0; |
|
| 69 | + $tax = getpaid_prepare_item_tax( $item, $name, $amount, $recurring ); |
|
| 70 | + |
|
| 71 | + $item->item_tax += wpinv_sanitize_amount( $tax['initial_tax'] ); |
|
| 72 | + |
|
| 73 | + if ( ! isset( $this->taxes[ $name ] ) ) { |
|
| 74 | + $this->taxes[ $name ] = $tax; |
|
| 75 | + continue; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + $this->taxes[ $name ]['initial_tax'] += $tax['initial_tax']; |
|
| 79 | + $this->taxes[ $name ]['recurring_tax'] += $tax['recurring_tax']; |
|
| 80 | + |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + } |
|
| 26 | 84 | |
| 27 | 85 | /** |
| 28 | - * Class constructor |
|
| 29 | - * |
|
| 30 | - * @param GetPaid_Payment_Form_Submission $submission |
|
| 31 | - */ |
|
| 32 | - public function __construct( $submission ) { |
|
| 33 | - // Validate VAT number. |
|
| 34 | - $this->validate_vat( $submission ); |
|
| 35 | - |
|
| 36 | - if ( $this->skip_taxes ) { |
|
| 37 | - return; |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - foreach ( $submission->get_items() as $item ) { |
|
| 41 | - $this->process_item_tax( $item, $submission ); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - // Process any existing invoice taxes. |
|
| 45 | - if ( $submission->has_invoice() ) { |
|
| 46 | - $invoice = $submission->get_invoice(); |
|
| 47 | - $invoice = $this->refresh_totals( $invoice, $submission ); |
|
| 48 | - |
|
| 49 | - $this->taxes = array_replace( $invoice->get_taxes(), $this->taxes ); |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * Maybe process tax. |
|
| 55 | - * |
|
| 56 | - * @since 1.0.19 |
|
| 57 | - * @param GetPaid_Form_Item $item |
|
| 58 | - * @param GetPaid_Payment_Form_Submission $submission |
|
| 59 | - */ |
|
| 60 | - public function process_item_tax( $item, $submission ) { |
|
| 61 | - |
|
| 62 | - $rates = getpaid_get_item_tax_rates( $item, $submission->country, $submission->state ); |
|
| 63 | - $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
| 64 | - $taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates ); |
|
| 65 | - $r_taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates ); |
|
| 66 | - |
|
| 67 | - foreach ( $taxes as $name => $amount ) { |
|
| 68 | - $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0; |
|
| 69 | - $tax = getpaid_prepare_item_tax( $item, $name, $amount, $recurring ); |
|
| 70 | - |
|
| 71 | - $item->item_tax += wpinv_sanitize_amount( $tax['initial_tax'] ); |
|
| 72 | - |
|
| 73 | - if ( ! isset( $this->taxes[ $name ] ) ) { |
|
| 74 | - $this->taxes[ $name ] = $tax; |
|
| 75 | - continue; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - $this->taxes[ $name ]['initial_tax'] += $tax['initial_tax']; |
|
| 79 | - $this->taxes[ $name ]['recurring_tax'] += $tax['recurring_tax']; |
|
| 80 | - |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * Checks if the submission has a digital item. |
|
| 87 | - * |
|
| 88 | - * @param GetPaid_Payment_Form_Submission $submission |
|
| 89 | - * @since 1.0.19 |
|
| 90 | - * @return bool |
|
| 91 | - */ |
|
| 92 | - public function has_digital_item( $submission ) { |
|
| 93 | - |
|
| 94 | - foreach ( $submission->get_items() as $item ) { |
|
| 95 | - |
|
| 96 | - if ( 'digital' == $item->get_vat_rule() ) { |
|
| 97 | - return true; |
|
| 98 | - } |
|
| 86 | + * Checks if the submission has a digital item. |
|
| 87 | + * |
|
| 88 | + * @param GetPaid_Payment_Form_Submission $submission |
|
| 89 | + * @since 1.0.19 |
|
| 90 | + * @return bool |
|
| 91 | + */ |
|
| 92 | + public function has_digital_item( $submission ) { |
|
| 93 | + |
|
| 94 | + foreach ( $submission->get_items() as $item ) { |
|
| 95 | + |
|
| 96 | + if ( 'digital' == $item->get_vat_rule() ) { |
|
| 97 | + return true; |
|
| 98 | + } |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - return false; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * Checks if this is an eu store. |
|
| 106 | - * |
|
| 107 | - * @since 1.0.19 |
|
| 108 | - * @return bool |
|
| 109 | - */ |
|
| 110 | - public static function is_eu_store() { |
|
| 111 | - return self::is_eu_country( wpinv_get_default_country() ); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * Checks if this is an eu country. |
|
| 116 | - * |
|
| 117 | - * @param string $country |
|
| 118 | - * @since 1.0.19 |
|
| 119 | - * @return bool |
|
| 120 | - */ |
|
| 121 | - public static function is_eu_country( $country ) { |
|
| 122 | - return getpaid_is_eu_state( $country ); |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * Checks if this is an eu purchase. |
|
| 127 | - * |
|
| 128 | - * @param string $customer_country |
|
| 129 | - * @since 1.0.19 |
|
| 130 | - * @return bool |
|
| 131 | - */ |
|
| 132 | - public static function is_eu_transaction( $customer_country ) { |
|
| 133 | - return self::is_eu_country( $customer_country ) && self::is_eu_store(); |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * Retrieves the vat number. |
|
| 138 | - * |
|
| 139 | - * @param GetPaid_Payment_Form_Submission $submission |
|
| 140 | - * @since 1.0.19 |
|
| 141 | - * @return string |
|
| 142 | - */ |
|
| 143 | - public function get_vat_number( $submission ) { |
|
| 144 | - |
|
| 145 | - // Retrieve from the posted number. |
|
| 146 | - $vat_number = $submission->get_field( 'wpinv_vat_number', 'billing' ); |
|
| 147 | - if ( ! is_null( $vat_number ) ) { |
|
| 148 | - return wpinv_clean( $vat_number ); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : ''; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * Retrieves the company. |
|
| 156 | - * |
|
| 157 | - * @param GetPaid_Payment_Form_Submission $submission |
|
| 158 | - * @since 1.0.19 |
|
| 159 | - * @return string |
|
| 160 | - */ |
|
| 161 | - public function get_company( $submission ) { |
|
| 162 | - |
|
| 163 | - // Retrieve from the posted data. |
|
| 164 | - $company = $submission->get_field( 'wpinv_company', 'billing' ); |
|
| 165 | - if ( ! empty( $company ) ) { |
|
| 166 | - return wpinv_clean( $company ); |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - // Retrieve from the invoice. |
|
| 170 | - return $submission->has_invoice() ? $submission->get_invoice()->get_company() : ''; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - /** |
|
| 174 | - * Checks if we require a VAT number. |
|
| 175 | - * |
|
| 176 | - * @param bool $ip_in_eu Whether the customer IP is from the EU |
|
| 177 | - * @param bool $country_in_eu Whether the customer country is from the EU |
|
| 178 | - * @since 1.0.19 |
|
| 179 | - * @return string |
|
| 180 | - */ |
|
| 181 | - public function requires_vat( $ip_in_eu, $country_in_eu ) { |
|
| 182 | - |
|
| 183 | - $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' ); |
|
| 184 | - $prevent_b2c = ! empty( $prevent_b2c ); |
|
| 185 | - $is_eu = $ip_in_eu || $country_in_eu; |
|
| 186 | - |
|
| 187 | - return $prevent_b2c && $is_eu; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * Validate VAT data. |
|
| 192 | - * |
|
| 193 | - * @param GetPaid_Payment_Form_Submission $submission |
|
| 194 | - * @since 1.0.19 |
|
| 195 | - */ |
|
| 196 | - public function validate_vat( $submission ) { |
|
| 197 | - |
|
| 198 | - $in_eu = $this->is_eu_transaction( $submission->country ); |
|
| 199 | - |
|
| 200 | - // Abort if we are not validating vat numbers. |
|
| 201 | - if ( ! $in_eu ) { |
|
| 101 | + return false; |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * Checks if this is an eu store. |
|
| 106 | + * |
|
| 107 | + * @since 1.0.19 |
|
| 108 | + * @return bool |
|
| 109 | + */ |
|
| 110 | + public static function is_eu_store() { |
|
| 111 | + return self::is_eu_country( wpinv_get_default_country() ); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * Checks if this is an eu country. |
|
| 116 | + * |
|
| 117 | + * @param string $country |
|
| 118 | + * @since 1.0.19 |
|
| 119 | + * @return bool |
|
| 120 | + */ |
|
| 121 | + public static function is_eu_country( $country ) { |
|
| 122 | + return getpaid_is_eu_state( $country ); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * Checks if this is an eu purchase. |
|
| 127 | + * |
|
| 128 | + * @param string $customer_country |
|
| 129 | + * @since 1.0.19 |
|
| 130 | + * @return bool |
|
| 131 | + */ |
|
| 132 | + public static function is_eu_transaction( $customer_country ) { |
|
| 133 | + return self::is_eu_country( $customer_country ) && self::is_eu_store(); |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * Retrieves the vat number. |
|
| 138 | + * |
|
| 139 | + * @param GetPaid_Payment_Form_Submission $submission |
|
| 140 | + * @since 1.0.19 |
|
| 141 | + * @return string |
|
| 142 | + */ |
|
| 143 | + public function get_vat_number( $submission ) { |
|
| 144 | + |
|
| 145 | + // Retrieve from the posted number. |
|
| 146 | + $vat_number = $submission->get_field( 'wpinv_vat_number', 'billing' ); |
|
| 147 | + if ( ! is_null( $vat_number ) ) { |
|
| 148 | + return wpinv_clean( $vat_number ); |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : ''; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * Retrieves the company. |
|
| 156 | + * |
|
| 157 | + * @param GetPaid_Payment_Form_Submission $submission |
|
| 158 | + * @since 1.0.19 |
|
| 159 | + * @return string |
|
| 160 | + */ |
|
| 161 | + public function get_company( $submission ) { |
|
| 162 | + |
|
| 163 | + // Retrieve from the posted data. |
|
| 164 | + $company = $submission->get_field( 'wpinv_company', 'billing' ); |
|
| 165 | + if ( ! empty( $company ) ) { |
|
| 166 | + return wpinv_clean( $company ); |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + // Retrieve from the invoice. |
|
| 170 | + return $submission->has_invoice() ? $submission->get_invoice()->get_company() : ''; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + /** |
|
| 174 | + * Checks if we require a VAT number. |
|
| 175 | + * |
|
| 176 | + * @param bool $ip_in_eu Whether the customer IP is from the EU |
|
| 177 | + * @param bool $country_in_eu Whether the customer country is from the EU |
|
| 178 | + * @since 1.0.19 |
|
| 179 | + * @return string |
|
| 180 | + */ |
|
| 181 | + public function requires_vat( $ip_in_eu, $country_in_eu ) { |
|
| 182 | + |
|
| 183 | + $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' ); |
|
| 184 | + $prevent_b2c = ! empty( $prevent_b2c ); |
|
| 185 | + $is_eu = $ip_in_eu || $country_in_eu; |
|
| 186 | + |
|
| 187 | + return $prevent_b2c && $is_eu; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * Validate VAT data. |
|
| 192 | + * |
|
| 193 | + * @param GetPaid_Payment_Form_Submission $submission |
|
| 194 | + * @since 1.0.19 |
|
| 195 | + */ |
|
| 196 | + public function validate_vat( $submission ) { |
|
| 197 | + |
|
| 198 | + $in_eu = $this->is_eu_transaction( $submission->country ); |
|
| 199 | + |
|
| 200 | + // Abort if we are not validating vat numbers. |
|
| 201 | + if ( ! $in_eu ) { |
|
| 202 | 202 | return; |
| 203 | - } |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | - // Prepare variables. |
|
| 206 | - $vat_number = $this->get_vat_number( $submission ); |
|
| 207 | - $ip_country = getpaid_get_ip_country(); |
|
| 205 | + // Prepare variables. |
|
| 206 | + $vat_number = $this->get_vat_number( $submission ); |
|
| 207 | + $ip_country = getpaid_get_ip_country(); |
|
| 208 | 208 | $is_eu = $this->is_eu_country( $submission->country ); |
| 209 | 209 | $is_ip_eu = $this->is_eu_country( $ip_country ); |
| 210 | 210 | |
| 211 | - // Maybe abort early for initial fetches. |
|
| 212 | - if ( $submission->is_initial_fetch() && empty( $vat_number ) ) { |
|
| 213 | - return; |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - // If we're preventing business to consumer purchases, |
|
| 217 | - if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) { |
|
| 218 | - |
|
| 219 | - // Ensure that a vat number has been specified. |
|
| 220 | - throw new GetPaid_Payment_Exception( '.getpaid-error-billingwpinv_vat_number.getpaid-custom-payment-form-errors', __( 'Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing' ) ); |
|
| 221 | - |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - if ( empty( $vat_number ) ) { |
|
| 225 | - return; |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - if ( wpinv_should_validate_vat_number() && ! wpinv_validate_vat_number( $vat_number, $submission->country ) ) { |
|
| 229 | - throw new GetPaid_Payment_Exception( '.getpaid-error-billingwpinv_vat_number.getpaid-custom-payment-form-errors', __( 'Your VAT number is invalid', 'invoicing' ) ); |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - if ( wpinv_default_billing_country() == $submission->country && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) { |
|
| 233 | - return; |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - $this->skip_taxes = true; |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - /** |
|
| 240 | - * Refresh totals if country or region changed in payment form. |
|
| 241 | - * |
|
| 242 | - * @since 2.8.8 |
|
| 243 | - * |
|
| 244 | - * @param object $invoice Invoice object. |
|
| 245 | - * @param GetPaid_Payment_Form_Submission $submission Payment form submission object. |
|
| 246 | - * @return object Invoice object. |
|
| 247 | - */ |
|
| 248 | - public function refresh_totals( $invoice, $submission ) { |
|
| 249 | - if ( ! ( ! empty( $_POST['action'] ) && ( $_POST['action'] == 'wpinv_payment_form_refresh_prices' || $_POST['action'] == 'wpinv_payment_form' ) && isset( $_POST['billing']['wpinv_country'] ) ) ) { |
|
| 250 | - return $invoice; |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - if ( ! ( ! $invoice->is_paid() && ! $invoice->is_refunded() && ! $invoice->is_held() ) ) { |
|
| 254 | - return $invoice; |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - // Maybe check the country, state. |
|
| 258 | - if ( $submission->country != $invoice->get_country() || $submission->state != $invoice->get_state() ) { |
|
| 259 | - $invoice->set_country( sanitize_text_field( $submission->country ) ); |
|
| 260 | - $invoice->set_state( sanitize_text_field( $submission->state ) ); |
|
| 261 | - |
|
| 262 | - // Recalculate totals. |
|
| 263 | - $invoice->recalculate_total(); |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - return $invoice; |
|
| 267 | - } |
|
| 211 | + // Maybe abort early for initial fetches. |
|
| 212 | + if ( $submission->is_initial_fetch() && empty( $vat_number ) ) { |
|
| 213 | + return; |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + // If we're preventing business to consumer purchases, |
|
| 217 | + if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) { |
|
| 218 | + |
|
| 219 | + // Ensure that a vat number has been specified. |
|
| 220 | + throw new GetPaid_Payment_Exception( '.getpaid-error-billingwpinv_vat_number.getpaid-custom-payment-form-errors', __( 'Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing' ) ); |
|
| 221 | + |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + if ( empty( $vat_number ) ) { |
|
| 225 | + return; |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + if ( wpinv_should_validate_vat_number() && ! wpinv_validate_vat_number( $vat_number, $submission->country ) ) { |
|
| 229 | + throw new GetPaid_Payment_Exception( '.getpaid-error-billingwpinv_vat_number.getpaid-custom-payment-form-errors', __( 'Your VAT number is invalid', 'invoicing' ) ); |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + if ( wpinv_default_billing_country() == $submission->country && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) { |
|
| 233 | + return; |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + $this->skip_taxes = true; |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + /** |
|
| 240 | + * Refresh totals if country or region changed in payment form. |
|
| 241 | + * |
|
| 242 | + * @since 2.8.8 |
|
| 243 | + * |
|
| 244 | + * @param object $invoice Invoice object. |
|
| 245 | + * @param GetPaid_Payment_Form_Submission $submission Payment form submission object. |
|
| 246 | + * @return object Invoice object. |
|
| 247 | + */ |
|
| 248 | + public function refresh_totals( $invoice, $submission ) { |
|
| 249 | + if ( ! ( ! empty( $_POST['action'] ) && ( $_POST['action'] == 'wpinv_payment_form_refresh_prices' || $_POST['action'] == 'wpinv_payment_form' ) && isset( $_POST['billing']['wpinv_country'] ) ) ) { |
|
| 250 | + return $invoice; |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + if ( ! ( ! $invoice->is_paid() && ! $invoice->is_refunded() && ! $invoice->is_held() ) ) { |
|
| 254 | + return $invoice; |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + // Maybe check the country, state. |
|
| 258 | + if ( $submission->country != $invoice->get_country() || $submission->state != $invoice->get_state() ) { |
|
| 259 | + $invoice->set_country( sanitize_text_field( $submission->country ) ); |
|
| 260 | + $invoice->set_state( sanitize_text_field( $submission->state ) ); |
|
| 261 | + |
|
| 262 | + // Recalculate totals. |
|
| 263 | + $invoice->recalculate_total(); |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + return $invoice; |
|
| 267 | + } |
|
| 268 | 268 | } |
@@ -57,21 +57,21 @@ discard block |
||
| 57 | 57 | $args = wp_parse_args( |
| 58 | 58 | $args, |
| 59 | 59 | array( |
| 60 | - 'status' => array( 'publish' ), |
|
| 61 | - 'limit' => get_option( 'posts_per_page' ), |
|
| 62 | - 'page' => 1, |
|
| 63 | - 'exclude' => array(), |
|
| 64 | - 'orderby' => 'date', |
|
| 65 | - 'order' => 'DESC', |
|
| 66 | - 'type' => wpinv_item_types(), |
|
| 67 | - 'meta_query' => array( |
|
| 60 | + 'status' => array( 'publish' ), |
|
| 61 | + 'limit' => get_option( 'posts_per_page' ), |
|
| 62 | + 'page' => 1, |
|
| 63 | + 'exclude' => array(), |
|
| 64 | + 'orderby' => 'date', |
|
| 65 | + 'order' => 'DESC', |
|
| 66 | + 'type' => wpinv_item_types(), |
|
| 67 | + 'meta_query' => array( |
|
| 68 | 68 | array( |
| 69 | 69 | 'key' => '_wpinv_one_time', |
| 70 | 70 | 'compare' => 'NOT EXISTS', |
| 71 | 71 | ), |
| 72 | 72 | ), |
| 73 | - 'return' => 'objects', |
|
| 74 | - 'paginate' => false, |
|
| 73 | + 'return' => 'objects', |
|
| 74 | + 'paginate' => false, |
|
| 75 | 75 | ) |
| 76 | 76 | ); |
| 77 | 77 | |
@@ -211,9 +211,9 @@ discard block |
||
| 211 | 211 | |
| 212 | 212 | function wpinv_get_item_types() { |
| 213 | 213 | $item_types = array( |
| 214 | - 'custom' => __( 'Standard', 'invoicing' ), |
|
| 215 | - 'fee' => __( 'Fee', 'invoicing' ), |
|
| 216 | - ); |
|
| 214 | + 'custom' => __( 'Standard', 'invoicing' ), |
|
| 215 | + 'fee' => __( 'Fee', 'invoicing' ), |
|
| 216 | + ); |
|
| 217 | 217 | return apply_filters( 'wpinv_get_item_types', $item_types ); |
| 218 | 218 | } |
| 219 | 219 | |
@@ -255,16 +255,16 @@ discard block |
||
| 255 | 255 | $args = array(); |
| 256 | 256 | if ( $post_ids ) { |
| 257 | 257 | $args = array( |
| 258 | - 'fields' => 'ids', |
|
| 259 | - ); |
|
| 258 | + 'fields' => 'ids', |
|
| 259 | + ); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | $args = array_merge( |
| 263 | 263 | $args, |
| 264 | 264 | array( |
| 265 | 265 | 'post_type' => 'wpi_item', |
| 266 | - 'orderby' => 'rand', |
|
| 267 | - 'post_count' => $num, |
|
| 266 | + 'orderby' => 'rand', |
|
| 267 | + 'post_count' => $num, |
|
| 268 | 268 | 'meta_query' => array( |
| 269 | 269 | array( |
| 270 | 270 | 'key' => '_wpinv_one_time', |
@@ -439,10 +439,10 @@ discard block |
||
| 439 | 439 | $bill_times_less = $bill_times - 1; |
| 440 | 440 | |
| 441 | 441 | if ( ! empty( $bill_times ) ) { |
| 442 | - $bill_times = $item->get_recurring_interval() * $bill_times; |
|
| 442 | + $bill_times = $item->get_recurring_interval() * $bill_times; |
|
| 443 | 443 | $bill_times_less = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times - $item->get_recurring_interval() ); |
| 444 | - $bill_times = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times ); |
|
| 445 | - } |
|
| 444 | + $bill_times = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times ); |
|
| 445 | + } |
|
| 446 | 446 | |
| 447 | 447 | if ( $item instanceof GetPaid_Form_Item && false === $_initial_price ) { |
| 448 | 448 | $initial_price = wpinv_price( $item->get_sub_total(), $currency ); |
@@ -587,19 +587,19 @@ discard block |
||
| 587 | 587 | * @return bool Whether the item type supports the given feature. |
| 588 | 588 | */ |
| 589 | 589 | function getpaid_item_type_supports( $item_type, $feature, $item_ID = 0 ) { |
| 590 | - $supports = false; |
|
| 590 | + $supports = false; |
|
| 591 | 591 | |
| 592 | - if ( ! is_scalar( $item_type ) ) { |
|
| 593 | - return $supports; |
|
| 594 | - } |
|
| 592 | + if ( ! is_scalar( $item_type ) ) { |
|
| 593 | + return $supports; |
|
| 594 | + } |
|
| 595 | 595 | |
| 596 | - switch ( $feature ) { |
|
| 597 | - case 'buy_now': |
|
| 598 | - if ( '' === $item_type || 'fee' === $item_type || 'custom' === $item_type ) { |
|
| 599 | - $supports = true; |
|
| 600 | - } |
|
| 601 | - break; |
|
| 602 | - } |
|
| 596 | + switch ( $feature ) { |
|
| 597 | + case 'buy_now': |
|
| 598 | + if ( '' === $item_type || 'fee' === $item_type || 'custom' === $item_type ) { |
|
| 599 | + $supports = true; |
|
| 600 | + } |
|
| 601 | + break; |
|
| 602 | + } |
|
| 603 | 603 | |
| 604 | - return apply_filters( 'getpaid_item_type_supports', $supports, $item_type, $feature, $item_ID ); |
|
| 604 | + return apply_filters( 'getpaid_item_type_supports', $supports, $item_type, $feature, $item_ID ); |
|
| 605 | 605 | } |
| 606 | 606 | \ No newline at end of file |
@@ -5,129 +5,129 @@ 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 | - if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) { |
|
| 104 | - return; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - $show_fields = $this->get_customer_meta_fields(); |
|
| 108 | - |
|
| 109 | - $customer = getpaid_get_customer_by_user_id( (int) $user->ID ); |
|
| 110 | - |
|
| 111 | - foreach ( $show_fields as $fieldset_key => $fieldset ) : |
|
| 112 | - if ( ! wpinv_use_taxes() && isset( $fieldset['fields']['_wpinv_vat_number'] ) ) { |
|
| 113 | - unset( $fieldset['fields']['_wpinv_vat_number'] ); |
|
| 114 | - } |
|
| 115 | - ?> |
|
| 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 | + if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) { |
|
| 104 | + return; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + $show_fields = $this->get_customer_meta_fields(); |
|
| 108 | + |
|
| 109 | + $customer = getpaid_get_customer_by_user_id( (int) $user->ID ); |
|
| 110 | + |
|
| 111 | + foreach ( $show_fields as $fieldset_key => $fieldset ) : |
|
| 112 | + if ( ! wpinv_use_taxes() && isset( $fieldset['fields']['_wpinv_vat_number'] ) ) { |
|
| 113 | + unset( $fieldset['fields']['_wpinv_vat_number'] ); |
|
| 114 | + } |
|
| 115 | + ?> |
|
| 116 | 116 | <h2><?php echo esc_html( $fieldset['title'] ); ?></h2> |
| 117 | 117 | <table class="form-table" id="<?php echo esc_attr( 'getpaid-fieldset-' . $fieldset_key ); ?>"> |
| 118 | 118 | <?php foreach ( $fieldset['fields'] as $key => $field ) : |
| 119 | - if ( ! empty( $customer ) ) { |
|
| 120 | - if ( strpos( $key, '_wpinv_' ) === 0 ) { |
|
| 121 | - $save_key = substr( $key , 7 ); |
|
| 122 | - } else { |
|
| 123 | - $save_key = $key; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - $value = $customer->get( $save_key ); |
|
| 127 | - } else { |
|
| 128 | - $value = $this->get_user_meta( $user->ID, $key ); |
|
| 129 | - } |
|
| 130 | - ?> |
|
| 119 | + if ( ! empty( $customer ) ) { |
|
| 120 | + if ( strpos( $key, '_wpinv_' ) === 0 ) { |
|
| 121 | + $save_key = substr( $key , 7 ); |
|
| 122 | + } else { |
|
| 123 | + $save_key = $key; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + $value = $customer->get( $save_key ); |
|
| 127 | + } else { |
|
| 128 | + $value = $this->get_user_meta( $user->ID, $key ); |
|
| 129 | + } |
|
| 130 | + ?> |
|
| 131 | 131 | <tr> |
| 132 | 132 | <th> |
| 133 | 133 | <label for="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $field['label'] ); ?></label> |
@@ -150,75 +150,75 @@ discard block |
||
| 150 | 150 | <?php endforeach; ?> |
| 151 | 151 | </table> |
| 152 | 152 | <?php |
| 153 | - endforeach; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * Save Address Fields on edit user pages. |
|
| 158 | - * |
|
| 159 | - * @param int $user_id User ID of the user being saved |
|
| 160 | - */ |
|
| 161 | - public function save_customer_meta_fields( $user_id ) { |
|
| 162 | - if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) { |
|
| 163 | - return; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - $save_fields = $this->get_customer_meta_fields(); |
|
| 167 | - $save_data = array(); |
|
| 168 | - |
|
| 169 | - foreach ( $save_fields as $fieldset ) { |
|
| 170 | - foreach ( $fieldset['fields'] as $key => $field ) { |
|
| 171 | - if ( strpos( $key, '_wpinv_' ) === 0 ) { |
|
| 172 | - $save_key = substr( $key , 7 ); |
|
| 173 | - } else { |
|
| 174 | - $save_key = $key; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - if ( $save_key && isset( $field['type'] ) && 'checkbox' === $field['type'] ) { |
|
| 178 | - $save_data[ $save_key ] = ! empty( $_POST[ $key ] ) ? true : false; |
|
| 179 | - } else if ( $save_key && isset( $_POST[ $key ] ) ) { |
|
| 180 | - $save_data[ $save_key ] = wpinv_clean( $_POST[ $key ] ); |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - if ( empty( $save_data ) ) { |
|
| 186 | - return; |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - $customer = getpaid_get_customer_by_user_id( (int) $user_id ); |
|
| 190 | - |
|
| 191 | - if ( empty( $customer ) ) { |
|
| 192 | - $customer = new GetPaid_Customer( 0 ); |
|
| 193 | - $customer->clone_user( (int) $user_id ); |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - foreach ( $save_data as $key => $value ) { |
|
| 197 | - $customer->set( $key, $value ); |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - $customer->save(); |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - /** |
|
| 204 | - * Get user meta for a given key, with fallbacks to core user info for pre-existing fields. |
|
| 205 | - * |
|
| 206 | - * @since 3.1.0 |
|
| 207 | - * @param int $user_id User ID of the user being edited |
|
| 208 | - * @param string $key Key for user meta field |
|
| 209 | - * @return string |
|
| 210 | - */ |
|
| 211 | - protected function get_user_meta( $user_id, $key ) { |
|
| 212 | - $value = get_user_meta( $user_id, $key, true ); |
|
| 213 | - $existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' ); |
|
| 214 | - |
|
| 215 | - if ( ! $value && in_array( $key, $existing_fields ) ) { |
|
| 216 | - $value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true ); |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - return $value; |
|
| 220 | - } |
|
| 221 | - } |
|
| 153 | + endforeach; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * Save Address Fields on edit user pages. |
|
| 158 | + * |
|
| 159 | + * @param int $user_id User ID of the user being saved |
|
| 160 | + */ |
|
| 161 | + public function save_customer_meta_fields( $user_id ) { |
|
| 162 | + if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) { |
|
| 163 | + return; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + $save_fields = $this->get_customer_meta_fields(); |
|
| 167 | + $save_data = array(); |
|
| 168 | + |
|
| 169 | + foreach ( $save_fields as $fieldset ) { |
|
| 170 | + foreach ( $fieldset['fields'] as $key => $field ) { |
|
| 171 | + if ( strpos( $key, '_wpinv_' ) === 0 ) { |
|
| 172 | + $save_key = substr( $key , 7 ); |
|
| 173 | + } else { |
|
| 174 | + $save_key = $key; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + if ( $save_key && isset( $field['type'] ) && 'checkbox' === $field['type'] ) { |
|
| 178 | + $save_data[ $save_key ] = ! empty( $_POST[ $key ] ) ? true : false; |
|
| 179 | + } else if ( $save_key && isset( $_POST[ $key ] ) ) { |
|
| 180 | + $save_data[ $save_key ] = wpinv_clean( $_POST[ $key ] ); |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + if ( empty( $save_data ) ) { |
|
| 186 | + return; |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + $customer = getpaid_get_customer_by_user_id( (int) $user_id ); |
|
| 190 | + |
|
| 191 | + if ( empty( $customer ) ) { |
|
| 192 | + $customer = new GetPaid_Customer( 0 ); |
|
| 193 | + $customer->clone_user( (int) $user_id ); |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + foreach ( $save_data as $key => $value ) { |
|
| 197 | + $customer->set( $key, $value ); |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + $customer->save(); |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + /** |
|
| 204 | + * Get user meta for a given key, with fallbacks to core user info for pre-existing fields. |
|
| 205 | + * |
|
| 206 | + * @since 3.1.0 |
|
| 207 | + * @param int $user_id User ID of the user being edited |
|
| 208 | + * @param string $key Key for user meta field |
|
| 209 | + * @return string |
|
| 210 | + */ |
|
| 211 | + protected function get_user_meta( $user_id, $key ) { |
|
| 212 | + $value = get_user_meta( $user_id, $key, true ); |
|
| 213 | + $existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' ); |
|
| 214 | + |
|
| 215 | + if ( ! $value && in_array( $key, $existing_fields ) ) { |
|
| 216 | + $value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true ); |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + return $value; |
|
| 220 | + } |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | 223 | endif; |
| 224 | 224 | |
@@ -14,76 +14,76 @@ |
||
| 14 | 14 | * @return array|mixed|string|string[] |
| 15 | 15 | */ |
| 16 | 16 | function aui_bs_convert_sd_output( $output, $instance = '', $args = '', $sd = '' ) { |
| 17 | - global $aui_bs5; |
|
| 17 | + global $aui_bs5; |
|
| 18 | 18 | |
| 19 | - if ( $aui_bs5 ) { |
|
| 20 | - $convert = array( |
|
| 21 | - '"ml-' => '"ms-', |
|
| 22 | - '"mr-' => '"me-', |
|
| 23 | - '"pl-' => '"ps-', |
|
| 24 | - '"pr-' => '"pe-', |
|
| 25 | - "'ml-" => "'ms-", |
|
| 26 | - "'mr-" => "'me-", |
|
| 27 | - "'pl-" => "'ps-", |
|
| 28 | - "'pr-" => "'pe-", |
|
| 29 | - ' ml-' => ' ms-', |
|
| 30 | - ' mr-' => ' me-', |
|
| 31 | - ' pl-' => ' ps-', |
|
| 32 | - ' pr-' => ' pe-', |
|
| 33 | - '.ml-' => '.ms-', |
|
| 34 | - '.mr-' => '.me-', |
|
| 35 | - '.pl-' => '.ps-', |
|
| 36 | - '.pr-' => '.pe-', |
|
| 37 | - ' form-row' => ' row', |
|
| 38 | - ' embed-responsive-item' => '', |
|
| 39 | - ' embed-responsive' => ' ratio', |
|
| 40 | - '-1by1' => '-1x1', |
|
| 41 | - '-4by3' => '-4x3', |
|
| 42 | - '-16by9' => '-16x9', |
|
| 43 | - '-21by9' => '-21x9', |
|
| 44 | - 'geodir-lightbox-image' => 'aui-lightbox-image', |
|
| 45 | - 'geodir-lightbox-iframe' => 'aui-lightbox-iframe', |
|
| 46 | - ' badge-' => ' text-bg-', |
|
| 47 | - 'form-group' => 'mb-3', |
|
| 48 | - 'custom-select' => 'form-select', |
|
| 49 | - 'float-left' => 'float-start', |
|
| 50 | - 'float-right' => 'float-end', |
|
| 51 | - 'text-left' => 'text-start', |
|
| 52 | - 'text-sm-left' => 'text-sm-start', |
|
| 53 | - 'text-md-left' => 'text-md-start', |
|
| 54 | - 'text-lg-left' => 'text-lg-start', |
|
| 55 | - 'text-right' => 'text-end', |
|
| 56 | - 'text-sm-right' => 'text-sm-end', |
|
| 57 | - 'text-md-right' => 'text-md-end', |
|
| 58 | - 'text-lg-right' => 'text-lg-end', |
|
| 59 | - 'border-right' => 'border-end', |
|
| 60 | - 'border-left' => 'border-start', |
|
| 61 | - 'font-weight-' => 'fw-', |
|
| 62 | - 'btn-block' => 'w-100', |
|
| 63 | - 'rounded-left' => 'rounded-start', |
|
| 64 | - 'rounded-right' => 'rounded-end', |
|
| 65 | - 'font-italic' => 'fst-italic', |
|
| 19 | + if ( $aui_bs5 ) { |
|
| 20 | + $convert = array( |
|
| 21 | + '"ml-' => '"ms-', |
|
| 22 | + '"mr-' => '"me-', |
|
| 23 | + '"pl-' => '"ps-', |
|
| 24 | + '"pr-' => '"pe-', |
|
| 25 | + "'ml-" => "'ms-", |
|
| 26 | + "'mr-" => "'me-", |
|
| 27 | + "'pl-" => "'ps-", |
|
| 28 | + "'pr-" => "'pe-", |
|
| 29 | + ' ml-' => ' ms-', |
|
| 30 | + ' mr-' => ' me-', |
|
| 31 | + ' pl-' => ' ps-', |
|
| 32 | + ' pr-' => ' pe-', |
|
| 33 | + '.ml-' => '.ms-', |
|
| 34 | + '.mr-' => '.me-', |
|
| 35 | + '.pl-' => '.ps-', |
|
| 36 | + '.pr-' => '.pe-', |
|
| 37 | + ' form-row' => ' row', |
|
| 38 | + ' embed-responsive-item' => '', |
|
| 39 | + ' embed-responsive' => ' ratio', |
|
| 40 | + '-1by1' => '-1x1', |
|
| 41 | + '-4by3' => '-4x3', |
|
| 42 | + '-16by9' => '-16x9', |
|
| 43 | + '-21by9' => '-21x9', |
|
| 44 | + 'geodir-lightbox-image' => 'aui-lightbox-image', |
|
| 45 | + 'geodir-lightbox-iframe' => 'aui-lightbox-iframe', |
|
| 46 | + ' badge-' => ' text-bg-', |
|
| 47 | + 'form-group' => 'mb-3', |
|
| 48 | + 'custom-select' => 'form-select', |
|
| 49 | + 'float-left' => 'float-start', |
|
| 50 | + 'float-right' => 'float-end', |
|
| 51 | + 'text-left' => 'text-start', |
|
| 52 | + 'text-sm-left' => 'text-sm-start', |
|
| 53 | + 'text-md-left' => 'text-md-start', |
|
| 54 | + 'text-lg-left' => 'text-lg-start', |
|
| 55 | + 'text-right' => 'text-end', |
|
| 56 | + 'text-sm-right' => 'text-sm-end', |
|
| 57 | + 'text-md-right' => 'text-md-end', |
|
| 58 | + 'text-lg-right' => 'text-lg-end', |
|
| 59 | + 'border-right' => 'border-end', |
|
| 60 | + 'border-left' => 'border-start', |
|
| 61 | + 'font-weight-' => 'fw-', |
|
| 62 | + 'btn-block' => 'w-100', |
|
| 63 | + 'rounded-left' => 'rounded-start', |
|
| 64 | + 'rounded-right' => 'rounded-end', |
|
| 65 | + 'font-italic' => 'fst-italic', |
|
| 66 | 66 | |
| 67 | 67 | // 'custom-control custom-checkbox' => 'form-check', |
| 68 | - // data |
|
| 69 | - ' data-toggle=' => ' data-bs-toggle=', |
|
| 70 | - 'data-ride=' => 'data-bs-ride=', |
|
| 71 | - 'data-controlnav=' => 'data-bs-controlnav=', |
|
| 72 | - 'data-slide=' => 'data-bs-slide=', |
|
| 73 | - 'data-slide-to=' => 'data-bs-slide-to=', |
|
| 74 | - 'data-target=' => 'data-bs-target=', |
|
| 75 | - 'data-dismiss="modal"' => 'data-bs-dismiss="modal"', |
|
| 76 | - 'class="close"' => 'class="btn-close"', |
|
| 77 | - '<span aria-hidden="true">×</span>' => '', |
|
| 78 | - ); |
|
| 79 | - $output = str_replace( |
|
| 80 | - array_keys( $convert ), |
|
| 81 | - array_values( $convert ), |
|
| 82 | - $output |
|
| 83 | - ); |
|
| 84 | - } |
|
| 68 | + // data |
|
| 69 | + ' data-toggle=' => ' data-bs-toggle=', |
|
| 70 | + 'data-ride=' => 'data-bs-ride=', |
|
| 71 | + 'data-controlnav=' => 'data-bs-controlnav=', |
|
| 72 | + 'data-slide=' => 'data-bs-slide=', |
|
| 73 | + 'data-slide-to=' => 'data-bs-slide-to=', |
|
| 74 | + 'data-target=' => 'data-bs-target=', |
|
| 75 | + 'data-dismiss="modal"' => 'data-bs-dismiss="modal"', |
|
| 76 | + 'class="close"' => 'class="btn-close"', |
|
| 77 | + '<span aria-hidden="true">×</span>' => '', |
|
| 78 | + ); |
|
| 79 | + $output = str_replace( |
|
| 80 | + array_keys( $convert ), |
|
| 81 | + array_values( $convert ), |
|
| 82 | + $output |
|
| 83 | + ); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - return $output; |
|
| 86 | + return $output; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | add_filter( 'wp_super_duper_widget_output', 'aui_bs_convert_sd_output', 10, 4 ); //$output, $instance, $args, $this |
@@ -15,12 +15,12 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | 17 | if ( ! defined( 'ABSPATH' ) ) { |
| 18 | - exit; |
|
| 18 | + exit; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | if ( ! class_exists( 'WP_Super_Duper' ) ) { |
| 22 | - // include the class if needed |
|
| 23 | - include_once( dirname( __FILE__ ) . "/wp-super-duper.php" ); |
|
| 22 | + // include the class if needed |
|
| 23 | + include_once( dirname( __FILE__ ) . "/wp-super-duper.php" ); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /* |
@@ -35,5 +35,5 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | if ( ! function_exists( 'sd_get_class_build_keys' ) ) { |
| 38 | - include_once( dirname( __FILE__ ) . "/sd-functions.php" ); |
|
| 38 | + include_once( dirname( __FILE__ ) . "/sd-functions.php" ); |
|
| 39 | 39 | } |
| 40 | 40 | \ No newline at end of file |
@@ -3,114 +3,114 @@ discard block |
||
| 3 | 3 | class SD_Hello_World extends WP_Super_Duper { |
| 4 | 4 | |
| 5 | 5 | |
| 6 | - public $arguments; |
|
| 7 | - |
|
| 8 | - /** |
|
| 9 | - * Sets up the widgets name etc |
|
| 10 | - */ |
|
| 11 | - public function __construct() { |
|
| 12 | - |
|
| 13 | - $options = array( |
|
| 14 | - 'textdomain' => 'super-duper', |
|
| 15 | - // textdomain of the plugin/theme (used to prefix the Gutenberg block) |
|
| 16 | - 'block-icon' => 'fas fa-globe-americas', |
|
| 17 | - // Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right |
|
| 18 | - // OR font-awesome 5 class name: fas fa-globe-americas |
|
| 19 | - 'block-category' => 'widgets', |
|
| 20 | - // the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'. |
|
| 21 | - 'block-keywords' => "['hello','world']", |
|
| 22 | - // used in the block search, MAX 3 |
|
| 23 | - 'block-output' => array( // the block visual output elements as an array |
|
| 6 | + public $arguments; |
|
| 7 | + |
|
| 8 | + /** |
|
| 9 | + * Sets up the widgets name etc |
|
| 10 | + */ |
|
| 11 | + public function __construct() { |
|
| 12 | + |
|
| 13 | + $options = array( |
|
| 14 | + 'textdomain' => 'super-duper', |
|
| 15 | + // textdomain of the plugin/theme (used to prefix the Gutenberg block) |
|
| 16 | + 'block-icon' => 'fas fa-globe-americas', |
|
| 17 | + // Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right |
|
| 18 | + // OR font-awesome 5 class name: fas fa-globe-americas |
|
| 19 | + 'block-category' => 'widgets', |
|
| 20 | + // the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'. |
|
| 21 | + 'block-keywords' => "['hello','world']", |
|
| 22 | + // used in the block search, MAX 3 |
|
| 23 | + 'block-output' => array( // the block visual output elements as an array |
|
| 24 | 24 | // array( |
| 25 | 25 | // 'element' => 'p', |
| 26 | 26 | // 'title' => __( 'Placeholder', 'ayecode-connect' ), |
| 27 | 27 | // 'class' => '[%className%]', |
| 28 | 28 | // 'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%] |
| 29 | 29 | // ) |
| 30 | - array( |
|
| 31 | - 'element' => 'BlocksProps', |
|
| 32 | - 'inner_element' => 'p', |
|
| 33 | - 'blockProps' => array( |
|
| 34 | - 'className' => '[%WrapClass%]', |
|
| 30 | + array( |
|
| 31 | + 'element' => 'BlocksProps', |
|
| 32 | + 'inner_element' => 'p', |
|
| 33 | + 'blockProps' => array( |
|
| 34 | + 'className' => '[%WrapClass%]', |
|
| 35 | 35 | // 'content' => 'Hello: [%after_text%]' |
| 36 | 36 | // 'if_dangerouslySetInnerHTML' => '{__html: blockstrap_build_shape(props.attributes) }', |
| 37 | - ), |
|
| 38 | - 'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%] |
|
| 39 | - |
|
| 40 | - |
|
| 41 | - ), |
|
| 42 | - ), |
|
| 43 | - 'block-wrap' => '', // You can specify the type of element to wrap the block `div` or `span` etc.. Or blank for no wrap at all. |
|
| 44 | - 'class_name' => __CLASS__, |
|
| 45 | - // The calling class name |
|
| 46 | - 'base_id' => 'hello_world', |
|
| 47 | - // this is used as the widget id and the shortcode id. |
|
| 48 | - 'name' => __( 'Hello World', 'ayecode-connect' ), |
|
| 49 | - // the name of the widget/block |
|
| 50 | - 'widget_ops' => array( |
|
| 51 | - 'classname' => 'hello-world-class', |
|
| 52 | - // widget class |
|
| 53 | - 'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'ayecode-connect' ), |
|
| 54 | - // widget description |
|
| 55 | - ), |
|
| 56 | - 'no_wrap' => true, // This will prevent the widget being wrapped in the containing widget class div. |
|
| 57 | - 'arguments' => array( // these are the arguments that will be used in the widget, shortcode and block settings. |
|
| 58 | - 'after_text' => array( // this is the input name='' |
|
| 59 | - 'title' => __( 'Text after hello:', 'ayecode-connect' ), |
|
| 60 | - // input title |
|
| 61 | - 'desc' => __( 'This is the text that will appear after `Hello:`.', 'ayecode-connect' ), |
|
| 62 | - // input description |
|
| 63 | - 'type' => 'text', |
|
| 64 | - // the type of input, test, select, checkbox etc. |
|
| 65 | - 'placeholder' => 'World', |
|
| 66 | - // the input placeholder text. |
|
| 67 | - 'desc_tip' => true, |
|
| 68 | - // if the input should show the widget description text as a tooltip. |
|
| 69 | - 'default' => 'World', |
|
| 70 | - // the input default value. |
|
| 71 | - 'advanced' => false |
|
| 72 | - // not yet implemented |
|
| 73 | - ), |
|
| 74 | - ) |
|
| 75 | - ); |
|
| 76 | - |
|
| 77 | - parent::__construct( $options ); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * This is the output function for the widget, shortcode and block (front end). |
|
| 83 | - * |
|
| 84 | - * @param array $args The arguments values. |
|
| 85 | - * @param array $widget_args The widget arguments when used. |
|
| 86 | - * @param string $content The shortcode content argument |
|
| 87 | - * |
|
| 88 | - * @return string |
|
| 89 | - */ |
|
| 90 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * @var string $after_text |
|
| 94 | - * @var string $another_input This is added by filter below. |
|
| 95 | - */ |
|
| 96 | - extract( $args, EXTR_SKIP ); |
|
| 97 | - |
|
| 98 | - /* |
|
| 37 | + ), |
|
| 38 | + 'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%] |
|
| 39 | + |
|
| 40 | + |
|
| 41 | + ), |
|
| 42 | + ), |
|
| 43 | + 'block-wrap' => '', // You can specify the type of element to wrap the block `div` or `span` etc.. Or blank for no wrap at all. |
|
| 44 | + 'class_name' => __CLASS__, |
|
| 45 | + // The calling class name |
|
| 46 | + 'base_id' => 'hello_world', |
|
| 47 | + // this is used as the widget id and the shortcode id. |
|
| 48 | + 'name' => __( 'Hello World', 'ayecode-connect' ), |
|
| 49 | + // the name of the widget/block |
|
| 50 | + 'widget_ops' => array( |
|
| 51 | + 'classname' => 'hello-world-class', |
|
| 52 | + // widget class |
|
| 53 | + 'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'ayecode-connect' ), |
|
| 54 | + // widget description |
|
| 55 | + ), |
|
| 56 | + 'no_wrap' => true, // This will prevent the widget being wrapped in the containing widget class div. |
|
| 57 | + 'arguments' => array( // these are the arguments that will be used in the widget, shortcode and block settings. |
|
| 58 | + 'after_text' => array( // this is the input name='' |
|
| 59 | + 'title' => __( 'Text after hello:', 'ayecode-connect' ), |
|
| 60 | + // input title |
|
| 61 | + 'desc' => __( 'This is the text that will appear after `Hello:`.', 'ayecode-connect' ), |
|
| 62 | + // input description |
|
| 63 | + 'type' => 'text', |
|
| 64 | + // the type of input, test, select, checkbox etc. |
|
| 65 | + 'placeholder' => 'World', |
|
| 66 | + // the input placeholder text. |
|
| 67 | + 'desc_tip' => true, |
|
| 68 | + // if the input should show the widget description text as a tooltip. |
|
| 69 | + 'default' => 'World', |
|
| 70 | + // the input default value. |
|
| 71 | + 'advanced' => false |
|
| 72 | + // not yet implemented |
|
| 73 | + ), |
|
| 74 | + ) |
|
| 75 | + ); |
|
| 76 | + |
|
| 77 | + parent::__construct( $options ); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * This is the output function for the widget, shortcode and block (front end). |
|
| 83 | + * |
|
| 84 | + * @param array $args The arguments values. |
|
| 85 | + * @param array $widget_args The widget arguments when used. |
|
| 86 | + * @param string $content The shortcode content argument |
|
| 87 | + * |
|
| 88 | + * @return string |
|
| 89 | + */ |
|
| 90 | + public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * @var string $after_text |
|
| 94 | + * @var string $another_input This is added by filter below. |
|
| 95 | + */ |
|
| 96 | + extract( $args, EXTR_SKIP ); |
|
| 97 | + |
|
| 98 | + /* |
|
| 99 | 99 | * This value is added by filter so might not exist if filter is removed so we check. |
| 100 | 100 | */ |
| 101 | - if ( ! isset( $another_input ) ) { |
|
| 102 | - $another_input = ''; |
|
| 103 | - } |
|
| 101 | + if ( ! isset( $another_input ) ) { |
|
| 102 | + $another_input = ''; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - return "Helllo: " . $after_text . "" . $another_input; |
|
| 105 | + return "Helllo: " . $after_text . "" . $another_input; |
|
| 106 | 106 | |
| 107 | - } |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | // register it. |
| 112 | 112 | add_action( 'widgets_init', function () { |
| 113 | - register_widget( 'SD_Hello_World' ); |
|
| 113 | + register_widget( 'SD_Hello_World' ); |
|
| 114 | 114 | } ); |
| 115 | 115 | |
| 116 | 116 | |
@@ -123,26 +123,26 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | function _my_extra_arguments( $options ) { |
| 125 | 125 | |
| 126 | - /* |
|
| 126 | + /* |
|
| 127 | 127 | * Add a new input option. |
| 128 | 128 | */ |
| 129 | - $options['arguments']['another_input'] = array( |
|
| 130 | - 'name' => 'another_input', // this is the input name='' |
|
| 131 | - 'title' => __( 'Another input:', 'ayecode-connect' ), // input title |
|
| 132 | - 'desc' => __( 'This is an input added via filter.', 'ayecode-connect' ), // input description |
|
| 133 | - 'type' => 'text', // the type of input, test, select, checkbox etc. |
|
| 134 | - 'placeholder' => 'Placeholder text', // the input placeholder text. |
|
| 135 | - 'desc_tip' => true, // if the input should show the widget description text as a tooltip. |
|
| 136 | - 'default' => '', // the input default value. |
|
| 137 | - 'advanced' => false // not yet implemented |
|
| 138 | - ); |
|
| 139 | - |
|
| 140 | - /* |
|
| 129 | + $options['arguments']['another_input'] = array( |
|
| 130 | + 'name' => 'another_input', // this is the input name='' |
|
| 131 | + 'title' => __( 'Another input:', 'ayecode-connect' ), // input title |
|
| 132 | + 'desc' => __( 'This is an input added via filter.', 'ayecode-connect' ), // input description |
|
| 133 | + 'type' => 'text', // the type of input, test, select, checkbox etc. |
|
| 134 | + 'placeholder' => 'Placeholder text', // the input placeholder text. |
|
| 135 | + 'desc_tip' => true, // if the input should show the widget description text as a tooltip. |
|
| 136 | + 'default' => '', // the input default value. |
|
| 137 | + 'advanced' => false // not yet implemented |
|
| 138 | + ); |
|
| 139 | + |
|
| 140 | + /* |
|
| 141 | 141 | * Output the new option in the block output also. |
| 142 | 142 | */ |
| 143 | - $options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]";; |
|
| 143 | + $options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]";; |
|
| 144 | 144 | |
| 145 | - return $options; |
|
| 145 | + return $options; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | //add_filter( 'wp_super_duper_options_hello_world', '_my_extra_arguments' ); |
| 149 | 149 | \ No newline at end of file |
@@ -14,143 +14,143 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | class WPInv_Subscriptions_Widget extends WP_Super_Duper { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Register the widget with WordPress. |
|
| 19 | - * |
|
| 20 | - */ |
|
| 21 | - public function __construct() { |
|
| 22 | - |
|
| 23 | - $options = array( |
|
| 24 | - 'textdomain' => 'invoicing', |
|
| 25 | - 'block-icon' => 'controls-repeat', |
|
| 26 | - 'block-category' => 'widgets', |
|
| 27 | - 'block-keywords' => "['invoicing','subscriptions', 'getpaid']", |
|
| 28 | - 'class_name' => __CLASS__, |
|
| 29 | - 'base_id' => 'wpinv_subscriptions', |
|
| 30 | - 'name' => __( 'GetPaid > Subscriptions', 'invoicing' ), |
|
| 31 | - 'widget_ops' => array( |
|
| 32 | - 'classname' => 'getpaid-subscriptions bsui', |
|
| 33 | - 'description' => esc_html__( "Displays the current user's subscriptions.", 'invoicing' ), |
|
| 34 | - ), |
|
| 35 | - 'arguments' => array( |
|
| 36 | - 'title' => array( |
|
| 37 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
| 38 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
| 39 | - 'type' => 'text', |
|
| 40 | - 'desc_tip' => true, |
|
| 41 | - 'default' => '', |
|
| 42 | - 'advanced' => false, |
|
| 43 | - ), |
|
| 44 | - ), |
|
| 45 | - |
|
| 46 | - ); |
|
| 47 | - |
|
| 48 | - parent::__construct( $options ); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * Retrieves current user's subscriptions. |
|
| 53 | - * |
|
| 54 | - * @return GetPaid_Subscriptions_Query |
|
| 55 | - */ |
|
| 56 | - public function get_subscriptions() { |
|
| 57 | - |
|
| 58 | - // Prepare license args. |
|
| 59 | - $args = array( |
|
| 60 | - 'customer_in' => get_current_user_id(), |
|
| 61 | - 'paged' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
| 62 | - ); |
|
| 63 | - |
|
| 64 | - return new GetPaid_Subscriptions_Query( $args ); |
|
| 65 | - |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * The Super block output function. |
|
| 70 | - * |
|
| 71 | - * @param array $args |
|
| 72 | - * @param array $widget_args |
|
| 73 | - * @param string $content |
|
| 74 | - * |
|
| 75 | - * @return mixed|string|bool |
|
| 76 | - */ |
|
| 77 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 78 | - |
|
| 79 | - // Ensure that the user is logged in. |
|
| 80 | - if ( ! is_user_logged_in() ) { |
|
| 81 | - |
|
| 82 | - return aui()->alert( |
|
| 83 | - array( |
|
| 84 | - 'content' => wp_kses_post( __( 'You need to log-in or create an account to view this section.', 'invoicing' ) ), |
|
| 85 | - 'type' => 'error', |
|
| 86 | - ) |
|
| 87 | - ); |
|
| 88 | - |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - // Are we displaying a single subscription? |
|
| 92 | - if ( isset( $_GET['subscription'] ) ) { |
|
| 93 | - return $this->display_single_subscription( intval( $_GET['subscription'] ) ); |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - // Retrieve the user's subscriptions. |
|
| 97 | - $subscriptions = $this->get_subscriptions(); |
|
| 98 | - |
|
| 99 | - // Start the output buffer. |
|
| 100 | - ob_start(); |
|
| 101 | - |
|
| 102 | - // Backwards compatibility. |
|
| 103 | - do_action( 'wpinv_before_user_subscriptions' ); |
|
| 104 | - |
|
| 105 | - // Display errors and notices. |
|
| 106 | - wpinv_print_errors(); |
|
| 107 | - |
|
| 108 | - do_action( 'getpaid_license_manager_before_subscriptions', $subscriptions ); |
|
| 109 | - |
|
| 110 | - // Print the table header. |
|
| 111 | - $this->print_table_header(); |
|
| 112 | - |
|
| 113 | - // Print table body. |
|
| 114 | - $this->print_table_body( $subscriptions->get_results() ); |
|
| 115 | - |
|
| 116 | - // Print table footer. |
|
| 117 | - $this->print_table_footer(); |
|
| 118 | - |
|
| 119 | - // Print the navigation. |
|
| 120 | - $this->print_navigation( $subscriptions->get_total() ); |
|
| 121 | - |
|
| 122 | - // Backwards compatibility. |
|
| 123 | - do_action( 'wpinv_after_user_subscriptions' ); |
|
| 124 | - |
|
| 125 | - // Return the output. |
|
| 126 | - return ob_get_clean(); |
|
| 127 | - |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * Retrieves the subscription columns. |
|
| 132 | - * |
|
| 133 | - * @return array |
|
| 134 | - */ |
|
| 135 | - public function get_subscriptions_table_columns() { |
|
| 17 | + /** |
|
| 18 | + * Register the widget with WordPress. |
|
| 19 | + * |
|
| 20 | + */ |
|
| 21 | + public function __construct() { |
|
| 22 | + |
|
| 23 | + $options = array( |
|
| 24 | + 'textdomain' => 'invoicing', |
|
| 25 | + 'block-icon' => 'controls-repeat', |
|
| 26 | + 'block-category' => 'widgets', |
|
| 27 | + 'block-keywords' => "['invoicing','subscriptions', 'getpaid']", |
|
| 28 | + 'class_name' => __CLASS__, |
|
| 29 | + 'base_id' => 'wpinv_subscriptions', |
|
| 30 | + 'name' => __( 'GetPaid > Subscriptions', 'invoicing' ), |
|
| 31 | + 'widget_ops' => array( |
|
| 32 | + 'classname' => 'getpaid-subscriptions bsui', |
|
| 33 | + 'description' => esc_html__( "Displays the current user's subscriptions.", 'invoicing' ), |
|
| 34 | + ), |
|
| 35 | + 'arguments' => array( |
|
| 36 | + 'title' => array( |
|
| 37 | + 'title' => __( 'Widget title', 'invoicing' ), |
|
| 38 | + 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
| 39 | + 'type' => 'text', |
|
| 40 | + 'desc_tip' => true, |
|
| 41 | + 'default' => '', |
|
| 42 | + 'advanced' => false, |
|
| 43 | + ), |
|
| 44 | + ), |
|
| 45 | + |
|
| 46 | + ); |
|
| 47 | + |
|
| 48 | + parent::__construct( $options ); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * Retrieves current user's subscriptions. |
|
| 53 | + * |
|
| 54 | + * @return GetPaid_Subscriptions_Query |
|
| 55 | + */ |
|
| 56 | + public function get_subscriptions() { |
|
| 57 | + |
|
| 58 | + // Prepare license args. |
|
| 59 | + $args = array( |
|
| 60 | + 'customer_in' => get_current_user_id(), |
|
| 61 | + 'paged' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
| 62 | + ); |
|
| 63 | + |
|
| 64 | + return new GetPaid_Subscriptions_Query( $args ); |
|
| 65 | + |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * The Super block output function. |
|
| 70 | + * |
|
| 71 | + * @param array $args |
|
| 72 | + * @param array $widget_args |
|
| 73 | + * @param string $content |
|
| 74 | + * |
|
| 75 | + * @return mixed|string|bool |
|
| 76 | + */ |
|
| 77 | + public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 78 | + |
|
| 79 | + // Ensure that the user is logged in. |
|
| 80 | + if ( ! is_user_logged_in() ) { |
|
| 81 | + |
|
| 82 | + return aui()->alert( |
|
| 83 | + array( |
|
| 84 | + 'content' => wp_kses_post( __( 'You need to log-in or create an account to view this section.', 'invoicing' ) ), |
|
| 85 | + 'type' => 'error', |
|
| 86 | + ) |
|
| 87 | + ); |
|
| 88 | + |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + // Are we displaying a single subscription? |
|
| 92 | + if ( isset( $_GET['subscription'] ) ) { |
|
| 93 | + return $this->display_single_subscription( intval( $_GET['subscription'] ) ); |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + // Retrieve the user's subscriptions. |
|
| 97 | + $subscriptions = $this->get_subscriptions(); |
|
| 98 | + |
|
| 99 | + // Start the output buffer. |
|
| 100 | + ob_start(); |
|
| 101 | + |
|
| 102 | + // Backwards compatibility. |
|
| 103 | + do_action( 'wpinv_before_user_subscriptions' ); |
|
| 104 | + |
|
| 105 | + // Display errors and notices. |
|
| 106 | + wpinv_print_errors(); |
|
| 107 | + |
|
| 108 | + do_action( 'getpaid_license_manager_before_subscriptions', $subscriptions ); |
|
| 109 | + |
|
| 110 | + // Print the table header. |
|
| 111 | + $this->print_table_header(); |
|
| 112 | + |
|
| 113 | + // Print table body. |
|
| 114 | + $this->print_table_body( $subscriptions->get_results() ); |
|
| 115 | + |
|
| 116 | + // Print table footer. |
|
| 117 | + $this->print_table_footer(); |
|
| 118 | + |
|
| 119 | + // Print the navigation. |
|
| 120 | + $this->print_navigation( $subscriptions->get_total() ); |
|
| 121 | + |
|
| 122 | + // Backwards compatibility. |
|
| 123 | + do_action( 'wpinv_after_user_subscriptions' ); |
|
| 124 | + |
|
| 125 | + // Return the output. |
|
| 126 | + return ob_get_clean(); |
|
| 127 | + |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * Retrieves the subscription columns. |
|
| 132 | + * |
|
| 133 | + * @return array |
|
| 134 | + */ |
|
| 135 | + public function get_subscriptions_table_columns() { |
|
| 136 | 136 | |
| 137 | - $columns = array( |
|
| 138 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 139 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 140 | - 'renewal-date' => __( 'Next payment', 'invoicing' ), |
|
| 141 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 142 | - ); |
|
| 137 | + $columns = array( |
|
| 138 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 139 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
| 140 | + 'renewal-date' => __( 'Next payment', 'invoicing' ), |
|
| 141 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 142 | + ); |
|
| 143 | 143 | |
| 144 | - return apply_filters( 'getpaid_frontend_subscriptions_table_columns', $columns ); |
|
| 145 | - } |
|
| 144 | + return apply_filters( 'getpaid_frontend_subscriptions_table_columns', $columns ); |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - /** |
|
| 148 | - * Displays the table header. |
|
| 149 | - * |
|
| 150 | - */ |
|
| 151 | - public function print_table_header() { |
|
| 147 | + /** |
|
| 148 | + * Displays the table header. |
|
| 149 | + * |
|
| 150 | + */ |
|
| 151 | + public function print_table_header() { |
|
| 152 | 152 | |
| 153 | - ?> |
|
| 153 | + ?> |
|
| 154 | 154 | |
| 155 | 155 | <table class="table table-bordered table-striped"> |
| 156 | 156 | |
@@ -166,122 +166,122 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | <?php |
| 168 | 168 | |
| 169 | - } |
|
| 169 | + } |
|
| 170 | 170 | |
| 171 | - /** |
|
| 172 | - * Displays the table body. |
|
| 173 | - * |
|
| 174 | - * @param WPInv_Subscription[] $subscriptions |
|
| 175 | - */ |
|
| 176 | - public function print_table_body( $subscriptions ) { |
|
| 171 | + /** |
|
| 172 | + * Displays the table body. |
|
| 173 | + * |
|
| 174 | + * @param WPInv_Subscription[] $subscriptions |
|
| 175 | + */ |
|
| 176 | + public function print_table_body( $subscriptions ) { |
|
| 177 | 177 | |
| 178 | - if ( empty( $subscriptions ) ) { |
|
| 179 | - $this->print_table_body_no_subscriptions(); |
|
| 180 | - } else { |
|
| 181 | - $this->print_table_body_subscriptions( $subscriptions ); |
|
| 182 | - } |
|
| 178 | + if ( empty( $subscriptions ) ) { |
|
| 179 | + $this->print_table_body_no_subscriptions(); |
|
| 180 | + } else { |
|
| 181 | + $this->print_table_body_subscriptions( $subscriptions ); |
|
| 182 | + } |
|
| 183 | 183 | |
| 184 | - } |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | - /** |
|
| 187 | - * Displays the table body if no subscriptions were found. |
|
| 188 | - * |
|
| 189 | - */ |
|
| 190 | - public function print_table_body_no_subscriptions() { |
|
| 186 | + /** |
|
| 187 | + * Displays the table body if no subscriptions were found. |
|
| 188 | + * |
|
| 189 | + */ |
|
| 190 | + public function print_table_body_no_subscriptions() { |
|
| 191 | 191 | |
| 192 | - ?> |
|
| 192 | + ?> |
|
| 193 | 193 | <tbody> |
| 194 | 194 | |
| 195 | 195 | <tr> |
| 196 | 196 | <td colspan="<?php echo count( $this->get_subscriptions_table_columns() ); ?>"> |
| 197 | 197 | |
| 198 | 198 | <?php |
| 199 | - aui()->alert( |
|
| 200 | - array( |
|
| 201 | - 'content' => wp_kses_post( __( 'No subscriptions found.', 'invoicing' ) ), |
|
| 202 | - 'type' => 'warning', |
|
| 203 | - ), |
|
| 199 | + aui()->alert( |
|
| 200 | + array( |
|
| 201 | + 'content' => wp_kses_post( __( 'No subscriptions found.', 'invoicing' ) ), |
|
| 202 | + 'type' => 'warning', |
|
| 203 | + ), |
|
| 204 | 204 | true |
| 205 | - ); |
|
| 206 | - ?> |
|
| 205 | + ); |
|
| 206 | + ?> |
|
| 207 | 207 | |
| 208 | 208 | </td> |
| 209 | 209 | </tr> |
| 210 | 210 | |
| 211 | 211 | </tbody> |
| 212 | 212 | <?php |
| 213 | - } |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - /** |
|
| 216 | - * Displays the table body if subscriptions were found. |
|
| 217 | - * |
|
| 218 | - * @param WPInv_Subscription[] $subscriptions |
|
| 219 | - */ |
|
| 220 | - public function print_table_body_subscriptions( $subscriptions ) { |
|
| 215 | + /** |
|
| 216 | + * Displays the table body if subscriptions were found. |
|
| 217 | + * |
|
| 218 | + * @param WPInv_Subscription[] $subscriptions |
|
| 219 | + */ |
|
| 220 | + public function print_table_body_subscriptions( $subscriptions ) { |
|
| 221 | 221 | |
| 222 | - ?> |
|
| 222 | + ?> |
|
| 223 | 223 | <tbody> |
| 224 | 224 | |
| 225 | 225 | <?php foreach ( $subscriptions as $subscription ) : ?> |
| 226 | 226 | <tr class="getpaid-subscriptions-table-row subscription-<?php echo (int) $subscription->get_id(); ?>"> |
| 227 | 227 | <?php |
| 228 | - wpinv_get_template( |
|
| 229 | - 'subscriptions/subscriptions-table-row.php', |
|
| 230 | - array( |
|
| 231 | - 'subscription' => $subscription, |
|
| 232 | - 'widget' => $this, |
|
| 233 | - ) |
|
| 234 | - ); |
|
| 235 | - ?> |
|
| 228 | + wpinv_get_template( |
|
| 229 | + 'subscriptions/subscriptions-table-row.php', |
|
| 230 | + array( |
|
| 231 | + 'subscription' => $subscription, |
|
| 232 | + 'widget' => $this, |
|
| 233 | + ) |
|
| 234 | + ); |
|
| 235 | + ?> |
|
| 236 | 236 | </tr> |
| 237 | 237 | <?php endforeach; ?> |
| 238 | 238 | |
| 239 | 239 | </tbody> |
| 240 | 240 | <?php |
| 241 | - } |
|
| 242 | - |
|
| 243 | - /** |
|
| 244 | - * Adds row actions to a column |
|
| 245 | - * |
|
| 246 | - * @param string $content column content |
|
| 247 | - * @param WPInv_Subscription $subscription |
|
| 248 | - * @since 1.0.0 |
|
| 249 | - * @return string |
|
| 250 | - */ |
|
| 251 | - public function add_row_actions( $content, $subscription ) { |
|
| 252 | - |
|
| 253 | - // Prepare row actions. |
|
| 254 | - $actions = array(); |
|
| 255 | - |
|
| 256 | - // View subscription action. |
|
| 257 | - $view_url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
| 258 | - $view_url = esc_url( add_query_arg( 'subscription', (int) $subscription->get_id(), $view_url ) ); |
|
| 259 | - $actions['view'] = "<a href='$view_url' class='text-decoration-none'>" . __( 'Manage Subscription', 'invoicing' ) . '</a>'; |
|
| 260 | - |
|
| 261 | - // Filter the actions. |
|
| 262 | - $actions = apply_filters( 'getpaid_subscriptions_table_subscription_actions', $actions, $subscription ); |
|
| 263 | - |
|
| 264 | - $sanitized = array(); |
|
| 265 | - foreach ( $actions as $key => $action ) { |
|
| 266 | - $key = sanitize_html_class( $key ); |
|
| 267 | - $action = wp_kses_post( $action ); |
|
| 268 | - $sanitized[] = "<span class='$key'>$action</span>"; |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - $row_actions = "<small class='form-text getpaid-subscription-item-actions'>"; |
|
| 272 | - $row_actions .= implode( ' | ', $sanitized ); |
|
| 273 | - $row_actions .= '</small>'; |
|
| 274 | - |
|
| 275 | - return $content . $row_actions; |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - /** |
|
| 279 | - * Displays the table footer. |
|
| 280 | - * |
|
| 281 | - */ |
|
| 282 | - public function print_table_footer() { |
|
| 283 | - |
|
| 284 | - ?> |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * Adds row actions to a column |
|
| 245 | + * |
|
| 246 | + * @param string $content column content |
|
| 247 | + * @param WPInv_Subscription $subscription |
|
| 248 | + * @since 1.0.0 |
|
| 249 | + * @return string |
|
| 250 | + */ |
|
| 251 | + public function add_row_actions( $content, $subscription ) { |
|
| 252 | + |
|
| 253 | + // Prepare row actions. |
|
| 254 | + $actions = array(); |
|
| 255 | + |
|
| 256 | + // View subscription action. |
|
| 257 | + $view_url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
| 258 | + $view_url = esc_url( add_query_arg( 'subscription', (int) $subscription->get_id(), $view_url ) ); |
|
| 259 | + $actions['view'] = "<a href='$view_url' class='text-decoration-none'>" . __( 'Manage Subscription', 'invoicing' ) . '</a>'; |
|
| 260 | + |
|
| 261 | + // Filter the actions. |
|
| 262 | + $actions = apply_filters( 'getpaid_subscriptions_table_subscription_actions', $actions, $subscription ); |
|
| 263 | + |
|
| 264 | + $sanitized = array(); |
|
| 265 | + foreach ( $actions as $key => $action ) { |
|
| 266 | + $key = sanitize_html_class( $key ); |
|
| 267 | + $action = wp_kses_post( $action ); |
|
| 268 | + $sanitized[] = "<span class='$key'>$action</span>"; |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + $row_actions = "<small class='form-text getpaid-subscription-item-actions'>"; |
|
| 272 | + $row_actions .= implode( ' | ', $sanitized ); |
|
| 273 | + $row_actions .= '</small>'; |
|
| 274 | + |
|
| 275 | + return $content . $row_actions; |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + /** |
|
| 279 | + * Displays the table footer. |
|
| 280 | + * |
|
| 281 | + */ |
|
| 282 | + public function print_table_footer() { |
|
| 283 | + |
|
| 284 | + ?> |
|
| 285 | 285 | |
| 286 | 286 | <tfoot> |
| 287 | 287 | <tr> |
@@ -296,145 +296,145 @@ discard block |
||
| 296 | 296 | </table> |
| 297 | 297 | <?php |
| 298 | 298 | |
| 299 | - } |
|
| 299 | + } |
|
| 300 | 300 | |
| 301 | - /** |
|
| 302 | - * Displays the navigation. |
|
| 303 | - * |
|
| 304 | - * @param int $total |
|
| 305 | - */ |
|
| 306 | - public function print_navigation( $total ) { |
|
| 301 | + /** |
|
| 302 | + * Displays the navigation. |
|
| 303 | + * |
|
| 304 | + * @param int $total |
|
| 305 | + */ |
|
| 306 | + public function print_navigation( $total ) { |
|
| 307 | 307 | |
| 308 | - if ( $total < 1 ) { |
|
| 308 | + if ( $total < 1 ) { |
|
| 309 | 309 | |
| 310 | - // Out-of-bounds, run the query again without LIMIT for total count. |
|
| 311 | - $args = array( |
|
| 312 | - 'customer_in' => get_current_user_id(), |
|
| 313 | - 'fields' => 'id', |
|
| 314 | - ); |
|
| 310 | + // Out-of-bounds, run the query again without LIMIT for total count. |
|
| 311 | + $args = array( |
|
| 312 | + 'customer_in' => get_current_user_id(), |
|
| 313 | + 'fields' => 'id', |
|
| 314 | + ); |
|
| 315 | 315 | |
| 316 | - $count_query = new GetPaid_Subscriptions_Query( $args ); |
|
| 317 | - $total = $count_query->get_total(); |
|
| 318 | - } |
|
| 316 | + $count_query = new GetPaid_Subscriptions_Query( $args ); |
|
| 317 | + $total = $count_query->get_total(); |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | - // Abort if we do not have pages. |
|
| 321 | - if ( 2 > $total ) { |
|
| 322 | - return; |
|
| 323 | - } |
|
| 320 | + // Abort if we do not have pages. |
|
| 321 | + if ( 2 > $total ) { |
|
| 322 | + return; |
|
| 323 | + } |
|
| 324 | 324 | |
| 325 | - ?> |
|
| 325 | + ?> |
|
| 326 | 326 | |
| 327 | 327 | <div class="getpaid-subscriptions-pagination"> |
| 328 | 328 | <?php |
| 329 | - $big = 999999; |
|
| 330 | - |
|
| 331 | - echo wp_kses_post( |
|
| 332 | - getpaid_paginate_links( |
|
| 333 | - array( |
|
| 334 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
| 335 | - 'format' => '?paged=%#%', |
|
| 336 | - 'total' => (int) ceil( $total / 10 ), |
|
| 337 | - ) |
|
| 338 | - ) |
|
| 339 | - ); |
|
| 340 | - ?> |
|
| 329 | + $big = 999999; |
|
| 330 | + |
|
| 331 | + echo wp_kses_post( |
|
| 332 | + getpaid_paginate_links( |
|
| 333 | + array( |
|
| 334 | + 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
| 335 | + 'format' => '?paged=%#%', |
|
| 336 | + 'total' => (int) ceil( $total / 10 ), |
|
| 337 | + ) |
|
| 338 | + ) |
|
| 339 | + ); |
|
| 340 | + ?> |
|
| 341 | 341 | </div> |
| 342 | 342 | |
| 343 | 343 | <?php |
| 344 | - } |
|
| 345 | - |
|
| 346 | - /** |
|
| 347 | - * Returns a single subscription's columns. |
|
| 348 | - * |
|
| 349 | - * @param WPInv_Subscription $subscription |
|
| 350 | - * |
|
| 351 | - * @return array |
|
| 352 | - */ |
|
| 353 | - public function get_single_subscription_columns( $subscription ) { |
|
| 354 | - |
|
| 355 | - // Prepare subscription detail columns. |
|
| 356 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() ); |
|
| 357 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
| 358 | - $fields = apply_filters( |
|
| 359 | - 'getpaid_single_subscription_details_fields', |
|
| 360 | - array( |
|
| 361 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 362 | - 'initial_amount' => __( 'Initial amount', 'invoicing' ), |
|
| 363 | - 'recurring_amount' => __( 'Recurring amount', 'invoicing' ), |
|
| 364 | - 'start_date' => __( 'Start date', 'invoicing' ), |
|
| 365 | - 'expiry_date' => __( 'Next payment', 'invoicing' ), |
|
| 366 | - 'payments' => __( 'Payments', 'invoicing' ), |
|
| 367 | - 'item' => $items_count > 1 ? __( 'Items', $items_count, 'invoicing' ) : __( 'Item', 'invoicing' ) |
|
| 368 | - ), |
|
| 369 | - $subscription, |
|
| 370 | - $items_count |
|
| 371 | - ); |
|
| 372 | - |
|
| 373 | - if ( isset( $fields['expiry_date'] ) ) { |
|
| 374 | - |
|
| 375 | - if ( ! $subscription->is_active() || $subscription->is_last_renewal() ) { |
|
| 376 | - $fields['expiry_date'] = __( 'End date', 'invoicing' ); |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - if ( 'pending' === $subscription->get_status() ) { |
|
| 380 | - unset( $fields['expiry_date'] ); |
|
| 381 | - } |
|
| 382 | - } |
|
| 383 | - |
|
| 384 | - if ( isset( $fields['start_date'] ) && 'pending' === $subscription->get_status() ) { |
|
| 385 | - unset( $fields['start_date'] ); |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - if ( $subscription->get_initial_amount() === $subscription->get_recurring_amount() ) { |
|
| 389 | - unset( $fields['initial_amount'] ); |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - return $fields; |
|
| 393 | - } |
|
| 394 | - |
|
| 395 | - /** |
|
| 396 | - * Displays a single subscription. |
|
| 397 | - * |
|
| 398 | - * @param string $subscription |
|
| 399 | - * |
|
| 400 | - * @return string |
|
| 401 | - */ |
|
| 402 | - public function display_single_subscription( $subscription ) { |
|
| 403 | - |
|
| 404 | - // Fetch the subscription. |
|
| 405 | - $subscription = new WPInv_Subscription( (int) $subscription ); |
|
| 406 | - |
|
| 407 | - if ( ! $subscription->exists() ) { |
|
| 408 | - |
|
| 409 | - return aui()->alert( |
|
| 410 | - array( |
|
| 411 | - 'content' => wp_kses_post( __( 'Subscription not found.', 'invoicing' ) ), |
|
| 412 | - 'type' => 'error', |
|
| 413 | - ) |
|
| 414 | - ); |
|
| 415 | - |
|
| 416 | - } |
|
| 417 | - |
|
| 418 | - // Ensure that the user owns this subscription key. |
|
| 419 | - if ( get_current_user_id() != $subscription->get_customer_id() && ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 420 | - |
|
| 421 | - return aui()->alert( |
|
| 422 | - array( |
|
| 423 | - 'content' => wp_kses_post( __( 'You do not have permission to view this subscription. Ensure that you are logged in to the account that owns the subscription.', 'invoicing' ) ), |
|
| 424 | - 'type' => 'error', |
|
| 425 | - ) |
|
| 426 | - ); |
|
| 427 | - |
|
| 428 | - } |
|
| 429 | - |
|
| 430 | - return wpinv_get_template_html( |
|
| 431 | - 'subscriptions/subscription-details.php', |
|
| 432 | - array( |
|
| 433 | - 'subscription' => $subscription, |
|
| 434 | - 'widget' => $this, |
|
| 435 | - ) |
|
| 436 | - ); |
|
| 437 | - |
|
| 438 | - } |
|
| 344 | + } |
|
| 345 | + |
|
| 346 | + /** |
|
| 347 | + * Returns a single subscription's columns. |
|
| 348 | + * |
|
| 349 | + * @param WPInv_Subscription $subscription |
|
| 350 | + * |
|
| 351 | + * @return array |
|
| 352 | + */ |
|
| 353 | + public function get_single_subscription_columns( $subscription ) { |
|
| 354 | + |
|
| 355 | + // Prepare subscription detail columns. |
|
| 356 | + $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() ); |
|
| 357 | + $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
| 358 | + $fields = apply_filters( |
|
| 359 | + 'getpaid_single_subscription_details_fields', |
|
| 360 | + array( |
|
| 361 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 362 | + 'initial_amount' => __( 'Initial amount', 'invoicing' ), |
|
| 363 | + 'recurring_amount' => __( 'Recurring amount', 'invoicing' ), |
|
| 364 | + 'start_date' => __( 'Start date', 'invoicing' ), |
|
| 365 | + 'expiry_date' => __( 'Next payment', 'invoicing' ), |
|
| 366 | + 'payments' => __( 'Payments', 'invoicing' ), |
|
| 367 | + 'item' => $items_count > 1 ? __( 'Items', $items_count, 'invoicing' ) : __( 'Item', 'invoicing' ) |
|
| 368 | + ), |
|
| 369 | + $subscription, |
|
| 370 | + $items_count |
|
| 371 | + ); |
|
| 372 | + |
|
| 373 | + if ( isset( $fields['expiry_date'] ) ) { |
|
| 374 | + |
|
| 375 | + if ( ! $subscription->is_active() || $subscription->is_last_renewal() ) { |
|
| 376 | + $fields['expiry_date'] = __( 'End date', 'invoicing' ); |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + if ( 'pending' === $subscription->get_status() ) { |
|
| 380 | + unset( $fields['expiry_date'] ); |
|
| 381 | + } |
|
| 382 | + } |
|
| 383 | + |
|
| 384 | + if ( isset( $fields['start_date'] ) && 'pending' === $subscription->get_status() ) { |
|
| 385 | + unset( $fields['start_date'] ); |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + if ( $subscription->get_initial_amount() === $subscription->get_recurring_amount() ) { |
|
| 389 | + unset( $fields['initial_amount'] ); |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + return $fields; |
|
| 393 | + } |
|
| 394 | + |
|
| 395 | + /** |
|
| 396 | + * Displays a single subscription. |
|
| 397 | + * |
|
| 398 | + * @param string $subscription |
|
| 399 | + * |
|
| 400 | + * @return string |
|
| 401 | + */ |
|
| 402 | + public function display_single_subscription( $subscription ) { |
|
| 403 | + |
|
| 404 | + // Fetch the subscription. |
|
| 405 | + $subscription = new WPInv_Subscription( (int) $subscription ); |
|
| 406 | + |
|
| 407 | + if ( ! $subscription->exists() ) { |
|
| 408 | + |
|
| 409 | + return aui()->alert( |
|
| 410 | + array( |
|
| 411 | + 'content' => wp_kses_post( __( 'Subscription not found.', 'invoicing' ) ), |
|
| 412 | + 'type' => 'error', |
|
| 413 | + ) |
|
| 414 | + ); |
|
| 415 | + |
|
| 416 | + } |
|
| 417 | + |
|
| 418 | + // Ensure that the user owns this subscription key. |
|
| 419 | + if ( get_current_user_id() != $subscription->get_customer_id() && ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 420 | + |
|
| 421 | + return aui()->alert( |
|
| 422 | + array( |
|
| 423 | + 'content' => wp_kses_post( __( 'You do not have permission to view this subscription. Ensure that you are logged in to the account that owns the subscription.', 'invoicing' ) ), |
|
| 424 | + 'type' => 'error', |
|
| 425 | + ) |
|
| 426 | + ); |
|
| 427 | + |
|
| 428 | + } |
|
| 429 | + |
|
| 430 | + return wpinv_get_template_html( |
|
| 431 | + 'subscriptions/subscription-details.php', |
|
| 432 | + array( |
|
| 433 | + 'subscription' => $subscription, |
|
| 434 | + 'widget' => $this, |
|
| 435 | + ) |
|
| 436 | + ); |
|
| 437 | + |
|
| 438 | + } |
|
| 439 | 439 | |
| 440 | 440 | } |
@@ -21,20 +21,20 @@ |
||
| 21 | 21 | |
| 22 | 22 | foreach ( $file_types as $file_type ) { |
| 23 | 23 | |
| 24 | - if ( isset( $all_types[ $file_type ] ) ) { |
|
| 25 | - $types[] = $all_types[ $file_type ]; |
|
| 26 | - $file_type = explode( '|', $file_type ); |
|
| 24 | + if ( isset( $all_types[ $file_type ] ) ) { |
|
| 25 | + $types[] = $all_types[ $file_type ]; |
|
| 26 | + $file_type = explode( '|', $file_type ); |
|
| 27 | 27 | |
| 28 | - foreach ( $file_type as $type ) { |
|
| 29 | - $type = trim( $type ); |
|
| 30 | - $types[] = ".$type"; |
|
| 31 | - $_types[] = $type; |
|
| 32 | - } |
|
| 28 | + foreach ( $file_type as $type ) { |
|
| 29 | + $type = trim( $type ); |
|
| 30 | + $types[] = ".$type"; |
|
| 31 | + $_types[] = $type; |
|
| 32 | + } |
|
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | if ( ! empty( $required ) ) { |
| 37 | - $label .= "<span class='text-danger'> *</span>"; |
|
| 37 | + $label .= "<span class='text-danger'> *</span>"; |
|
| 38 | 38 | } |
| 39 | 39 | ?> |
| 40 | 40 | <label><span v-html="form_element.label"></span></label> |