@@ -8,18 +8,18 @@ |
||
| 8 | 8 | * @var WPInv_Subscription $object |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | 13 | $invoice = $object->get_parent_payment(); |
| 14 | 14 | |
| 15 | 15 | // Print the email header. |
| 16 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
| 16 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
| 17 | 17 | |
| 18 | 18 | // Generate the custom message body. |
| 19 | 19 | echo $message_body; |
| 20 | 20 | |
| 21 | 21 | // Print the billing details. |
| 22 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
| 22 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
| 23 | 23 | |
| 24 | 24 | // Print the email footer. |
| 25 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
| 25 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
@@ -8,24 +8,24 @@ |
||
| 8 | 8 | * @var WPInv_Subscription $object |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | 13 | $invoice = $object->get_parent_payment(); |
| 14 | 14 | |
| 15 | 15 | // Print the email header. |
| 16 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
| 16 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
| 17 | 17 | |
| 18 | 18 | // Generate the custom message body. |
| 19 | 19 | echo $message_body; |
| 20 | 20 | |
| 21 | 21 | // Print invoice details. |
| 22 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
| 22 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
| 23 | 23 | |
| 24 | 24 | // Print invoice items. |
| 25 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
| 25 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
| 26 | 26 | |
| 27 | 27 | // Print the billing details. |
| 28 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
| 28 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
| 29 | 29 | |
| 30 | 30 | // Print the email footer. |
| 31 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
| 31 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
@@ -8,18 +8,18 @@ |
||
| 8 | 8 | * @var WPInv_Subscription $object |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | 13 | $invoice = $object->get_parent_payment(); |
| 14 | 14 | |
| 15 | 15 | // Print the email header. |
| 16 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
| 16 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
| 17 | 17 | |
| 18 | 18 | // Generate the custom message body. |
| 19 | 19 | echo $message_body; |
| 20 | 20 | |
| 21 | 21 | // Print the billing details. |
| 22 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
| 22 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
| 23 | 23 | |
| 24 | 24 | // Print the email footer. |
| 25 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
| 25 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
@@ -8,18 +8,18 @@ |
||
| 8 | 8 | * @var WPInv_Subscription $object |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | 13 | $invoice = $object->get_parent_payment(); |
| 14 | 14 | |
| 15 | 15 | // Print the email header. |
| 16 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
| 16 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
| 17 | 17 | |
| 18 | 18 | // Generate the custom message body. |
| 19 | 19 | echo $message_body; |
| 20 | 20 | |
| 21 | 21 | // Print the billing details. |
| 22 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
| 22 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
| 23 | 23 | |
| 24 | 24 | // Print the email footer. |
| 25 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
| 25 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
@@ -8,18 +8,18 @@ |
||
| 8 | 8 | * @var WPInv_Subscription $object |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | 13 | $invoice = $object->get_parent_payment(); |
| 14 | 14 | |
| 15 | 15 | // Print the email header. |
| 16 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
| 16 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
| 17 | 17 | |
| 18 | 18 | // Generate the custom message body. |
| 19 | 19 | echo $message_body; |
| 20 | 20 | |
| 21 | 21 | // Print the billing details. |
| 22 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
| 22 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
| 23 | 23 | |
| 24 | 24 | // Print the email footer. |
| 25 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
| 25 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
@@ -7,55 +7,55 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | // Fetch the invoice. |
| 13 | -$invoice = new WPInv_Invoice( $invoice ); |
|
| 13 | +$invoice = new WPInv_Invoice($invoice); |
|
| 14 | 14 | |
| 15 | 15 | // @deprecated |
| 16 | -do_action( 'wpinv_success_content_before', $invoice ); |
|
| 17 | -do_action( 'wpinv_before_receipt', $invoice ); |
|
| 16 | +do_action('wpinv_success_content_before', $invoice); |
|
| 17 | +do_action('wpinv_before_receipt', $invoice); |
|
| 18 | 18 | |
| 19 | 19 | wpinv_print_errors(); |
| 20 | 20 | |
| 21 | 21 | // Prepare header text. |
| 22 | -if ( $invoice->is_paid() ) { |
|
| 22 | +if ($invoice->is_paid()) { |
|
| 23 | 23 | |
| 24 | 24 | $alert = aui()->alert( |
| 25 | 25 | array( |
| 26 | 26 | 'type' => 'success', |
| 27 | - 'content' => __( 'Thank you for your payment!', 'invoicing' ), |
|
| 27 | + 'content' => __('Thank you for your payment!', 'invoicing'), |
|
| 28 | 28 | ) |
| 29 | 29 | ); |
| 30 | 30 | |
| 31 | -} else if ( $invoice->is_refunded() ) { |
|
| 31 | +} else if ($invoice->is_refunded()) { |
|
| 32 | 32 | |
| 33 | 33 | $alert = aui()->alert( |
| 34 | 34 | array( |
| 35 | 35 | 'type' => 'info', |
| 36 | - 'content' => __( 'This invoice was refunded.', 'invoicing' ), |
|
| 36 | + 'content' => __('This invoice was refunded.', 'invoicing'), |
|
| 37 | 37 | ) |
| 38 | 38 | ); |
| 39 | 39 | |
| 40 | -} else if ( $invoice->is_held() ) { |
|
| 40 | +} else if ($invoice->is_held()) { |
|
| 41 | 41 | |
| 42 | 42 | $alert = aui()->alert( |
| 43 | 43 | array( |
| 44 | 44 | 'type' => 'info', |
| 45 | - 'content' => __( 'This invoice will be processed as soon we verify your payment.', 'invoicing' ), |
|
| 45 | + 'content' => __('This invoice will be processed as soon we verify your payment.', 'invoicing'), |
|
| 46 | 46 | ) |
| 47 | 47 | ); |
| 48 | 48 | |
| 49 | -} else if ( $invoice->needs_payment() ) { |
|
| 49 | +} else if ($invoice->needs_payment()) { |
|
| 50 | 50 | |
| 51 | - if ( $invoice->is_due() ) { |
|
| 51 | + if ($invoice->is_due()) { |
|
| 52 | 52 | |
| 53 | 53 | $alert = aui()->alert( |
| 54 | 54 | array( |
| 55 | 55 | 'type' => 'danger', |
| 56 | 56 | 'content' => sprintf( |
| 57 | - __( 'This invoice was due on %.', 'invoicing' ), |
|
| 58 | - getpaid_format_date_value( $invoice->get_due_date() ) |
|
| 57 | + __('This invoice was due on %.', 'invoicing'), |
|
| 58 | + getpaid_format_date_value($invoice->get_due_date()) |
|
| 59 | 59 | ), |
| 60 | 60 | ) |
| 61 | 61 | ); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $alert = aui()->alert( |
| 66 | 66 | array( |
| 67 | 67 | 'type' => 'warning', |
| 68 | - 'content' => __( 'This invoice needs payment.', 'invoicing' ), |
|
| 68 | + 'content' => __('This invoice needs payment.', 'invoicing'), |
|
| 69 | 69 | ) |
| 70 | 70 | ); |
| 71 | 71 | |
@@ -80,19 +80,19 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | 'pay' => array( |
| 82 | 82 | 'url' => $invoice->get_checkout_payment_url(), |
| 83 | - 'name' => __( 'Pay For Invoice', 'invoicing' ), |
|
| 83 | + 'name' => __('Pay For Invoice', 'invoicing'), |
|
| 84 | 84 | 'class' => 'btn-success', |
| 85 | 85 | ), |
| 86 | 86 | |
| 87 | 87 | 'view' => array( |
| 88 | 88 | 'url' => $invoice->get_view_url(), |
| 89 | - 'name' => __( 'View Invoice', 'invoicing' ), |
|
| 89 | + 'name' => __('View Invoice', 'invoicing'), |
|
| 90 | 90 | 'class' => 'btn-primary', |
| 91 | 91 | ), |
| 92 | 92 | |
| 93 | 93 | 'history' => array( |
| 94 | 94 | 'url' => wpinv_get_history_page_uri(), |
| 95 | - 'name' => __( 'Invoice History', 'invoicing' ), |
|
| 95 | + 'name' => __('Invoice History', 'invoicing'), |
|
| 96 | 96 | 'class' => 'btn-warning', |
| 97 | 97 | ), |
| 98 | 98 | |
@@ -101,12 +101,12 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | ); |
| 103 | 103 | |
| 104 | -if ( ( ! $invoice->needs_payment() || $invoice->is_held() ) && isset( $actions['pay'] ) ) { |
|
| 105 | - unset( $actions['pay'] ); |
|
| 104 | +if ((!$invoice->needs_payment() || $invoice->is_held()) && isset($actions['pay'])) { |
|
| 105 | + unset($actions['pay']); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | -if ( ! is_user_logged_in() && isset( $actions['history'] ) ) { |
|
| 109 | - unset( $actions['history'] ); |
|
| 108 | +if (!is_user_logged_in() && isset($actions['history'])) { |
|
| 109 | + unset($actions['history']); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | ?> |
@@ -115,19 +115,19 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | <?php |
| 117 | 117 | |
| 118 | - do_action( 'wpinv_receipt_start', $invoice ); |
|
| 118 | + do_action('wpinv_receipt_start', $invoice); |
|
| 119 | 119 | |
| 120 | - if ( ! empty( $actions ) ) { |
|
| 120 | + if (!empty($actions)) { |
|
| 121 | 121 | |
| 122 | 122 | echo '<div class="wpinv-receipt-actions text-right mt-1 mb-4">'; |
| 123 | 123 | |
| 124 | - foreach ( $actions as $key => $action ) { |
|
| 124 | + foreach ($actions as $key => $action) { |
|
| 125 | 125 | |
| 126 | - $key = sanitize_html_class( $key ); |
|
| 127 | - $class = empty( $action['class'] ) ? 'btn-dark' : sanitize_html_class( $action['class'] ); |
|
| 128 | - $url = empty( $action['url'] ) ? '#' : esc_url( $action['url'] ); |
|
| 129 | - $attrs = empty( $action['attrs'] ) ? '' : $action['attrs']; |
|
| 130 | - $anchor = sanitize_text_field( $action['name'] ); |
|
| 126 | + $key = sanitize_html_class($key); |
|
| 127 | + $class = empty($action['class']) ? 'btn-dark' : sanitize_html_class($action['class']); |
|
| 128 | + $url = empty($action['url']) ? '#' : esc_url($action['url']); |
|
| 129 | + $attrs = empty($action['attrs']) ? '' : $action['attrs']; |
|
| 130 | + $anchor = sanitize_text_field($action['name']); |
|
| 131 | 131 | |
| 132 | 132 | echo "<a href='$url' class='btn btn-sm ml-1 $class $key' $attrs>$anchor</a>"; |
| 133 | 133 | } |
@@ -143,20 +143,20 @@ discard block |
||
| 143 | 143 | <div class="wpinv-receipt-details"> |
| 144 | 144 | |
| 145 | 145 | <h4 class="wpinv-details-t mb-3 mt-3"> |
| 146 | - <?php echo apply_filters( 'wpinv_receipt_details_title', __( 'Invoice Details', 'invoicing' ), $invoice ); ?> |
|
| 146 | + <?php echo apply_filters('wpinv_receipt_details_title', __('Invoice Details', 'invoicing'), $invoice); ?> |
|
| 147 | 147 | </h4> |
| 148 | 148 | |
| 149 | - <?php getpaid_invoice_meta( $invoice ); ?> |
|
| 149 | + <?php getpaid_invoice_meta($invoice); ?> |
|
| 150 | 150 | |
| 151 | 151 | </div> |
| 152 | 152 | |
| 153 | 153 | |
| 154 | - <?php do_action( 'wpinv_receipt_end', $invoice ); ?> |
|
| 154 | + <?php do_action('wpinv_receipt_end', $invoice); ?> |
|
| 155 | 155 | |
| 156 | 156 | </div> |
| 157 | 157 | |
| 158 | 158 | <?php |
| 159 | 159 | |
| 160 | 160 | // @deprecated |
| 161 | -do_action( 'wpinv_success_content_after', $invoice ); |
|
| 162 | -do_action( 'wpinv_after_receipt', $invoice ); |
|
| 161 | +do_action('wpinv_success_content_after', $invoice); |
|
| 162 | +do_action('wpinv_after_receipt', $invoice); |
|
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | 11 | exit; |
| 12 | 12 | } |
| 13 | 13 | |
@@ -24,40 +24,40 @@ discard block |
||
| 24 | 24 | * @param Array $assoc_args Key value arguments stored in associated array format. |
| 25 | 25 | * @since 1.0.13 |
| 26 | 26 | */ |
| 27 | - public function insert_invoice( $args, $assoc_args ) { |
|
| 27 | + public function insert_invoice($args, $assoc_args) { |
|
| 28 | 28 | |
| 29 | 29 | // Fetch invoice data from the args |
| 30 | - $invoice_data = wp_unslash( $assoc_args ); |
|
| 30 | + $invoice_data = wp_unslash($assoc_args); |
|
| 31 | 31 | |
| 32 | 32 | // Abort if no invoice data is provided |
| 33 | - if( empty( $invoice_data ) ) { |
|
| 34 | - return WP_CLI::error( __( 'Invoice data not provided', 'invoicing' ) ); |
|
| 33 | + if (empty($invoice_data)) { |
|
| 34 | + return WP_CLI::error(__('Invoice data not provided', 'invoicing')); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | //Cart details |
| 38 | - if( !empty( $invoice_data['cart_details'] ) ) { |
|
| 39 | - $invoice_data['cart_details'] = json_decode( $invoice_data['cart_details'], true ); |
|
| 38 | + if (!empty($invoice_data['cart_details'])) { |
|
| 39 | + $invoice_data['cart_details'] = json_decode($invoice_data['cart_details'], true); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | //User details |
| 43 | - if( !empty( $invoice_data['user_info'] ) ) { |
|
| 44 | - $invoice_data['user_info'] = json_decode( $invoice_data['user_info'], true ); |
|
| 43 | + if (!empty($invoice_data['user_info'])) { |
|
| 44 | + $invoice_data['user_info'] = json_decode($invoice_data['user_info'], true); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | //Payment info |
| 48 | - if( !empty( $invoice_data['payment_details'] ) ) { |
|
| 49 | - $invoice_data['payment_details'] = json_decode( $invoice_data['payment_details'], true ); |
|
| 48 | + if (!empty($invoice_data['payment_details'])) { |
|
| 49 | + $invoice_data['payment_details'] = json_decode($invoice_data['payment_details'], true); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // Try creating the invoice |
| 53 | - $invoice = wpinv_insert_invoice( $invoice_data, true ); |
|
| 53 | + $invoice = wpinv_insert_invoice($invoice_data, true); |
|
| 54 | 54 | |
| 55 | - if ( is_wp_error( $invoice ) ) { |
|
| 56 | - return WP_CLI::error( $invoice->get_error_message() ); |
|
| 55 | + if (is_wp_error($invoice)) { |
|
| 56 | + return WP_CLI::error($invoice->get_error_message()); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - $message = sprintf( __( 'Invoice %s created', 'invoicing' ), $invoice->get_id() ); |
|
| 60 | - WP_CLI::success( $message ); |
|
| 59 | + $message = sprintf(__('Invoice %s created', 'invoicing'), $invoice->get_id()); |
|
| 60 | + WP_CLI::success($message); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | |
@@ -8,23 +8,23 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | 13 | ?> |
| 14 | 14 | |
| 15 | 15 | <div class='form-group'> |
| 16 | - <label :for="active_form_element.id + '_edit_heading'"><?php esc_html_e( 'Heading', 'invoicing' ) ?></label> |
|
| 16 | + <label :for="active_form_element.id + '_edit_heading'"><?php esc_html_e('Heading', 'invoicing') ?></label> |
|
| 17 | 17 | <input :id="active_form_element.id + '_edit_heading'" v-model='active_form_element.text' class='form-control' type='text' /> |
| 18 | 18 | </div> |
| 19 | 19 | |
| 20 | 20 | <div class='form-group'> |
| 21 | - <label :for="active_form_element.id + '_edit_level'"><?php esc_html_e( 'Select Heading Level', 'invoicing' ) ?></label> |
|
| 21 | + <label :for="active_form_element.id + '_edit_level'"><?php esc_html_e('Select Heading Level', 'invoicing') ?></label> |
|
| 22 | 22 | <select class='form-control custom-select' :id="active_form_element.id + '_edit_level'" v-model='active_form_element.level'> |
| 23 | - <option value='h1'><?php esc_html_e( 'H1', 'invoicing' ); ?></option> |
|
| 24 | - <option value='h2'><?php esc_html_e( 'H2', 'invoicing' ); ?></option> |
|
| 25 | - <option value='h3'><?php esc_html_e( 'H3', 'invoicing' ); ?></option> |
|
| 26 | - <option value='h4'><?php esc_html_e( 'H4', 'invoicing' ); ?></option> |
|
| 27 | - <option value='h5'><?php esc_html_e( 'H5', 'invoicing' ); ?></option> |
|
| 28 | - <option value='h6'><?php esc_html_e( 'H6', 'invoicing' ); ?></option> |
|
| 23 | + <option value='h1'><?php esc_html_e('H1', 'invoicing'); ?></option> |
|
| 24 | + <option value='h2'><?php esc_html_e('H2', 'invoicing'); ?></option> |
|
| 25 | + <option value='h3'><?php esc_html_e('H3', 'invoicing'); ?></option> |
|
| 26 | + <option value='h4'><?php esc_html_e('H4', 'invoicing'); ?></option> |
|
| 27 | + <option value='h5'><?php esc_html_e('H5', 'invoicing'); ?></option> |
|
| 28 | + <option value='h6'><?php esc_html_e('H6', 'invoicing'); ?></option> |
|
| 29 | 29 | </select> |
| 30 | 30 | </div> |
@@ -15,136 +15,136 @@ |
||
| 15 | 15 | class WPInv_REST_Invoice_Controller extends GetPaid_REST_Posts_Controller { |
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | - * Post type. |
|
| 19 | - * |
|
| 20 | - * @var string |
|
| 21 | - */ |
|
| 22 | - protected $post_type = 'wpi_invoice'; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * The base of this controller's route. |
|
| 26 | - * |
|
| 27 | - * @since 1.0.13 |
|
| 28 | - * @var string |
|
| 29 | - */ |
|
| 30 | - protected $rest_base = 'invoices'; |
|
| 31 | - |
|
| 32 | - /** Contains this controller's class name. |
|
| 33 | - * |
|
| 34 | - * @var string |
|
| 35 | - */ |
|
| 36 | - public $crud_class = 'WPInv_Invoice'; |
|
| 18 | + * Post type. |
|
| 19 | + * |
|
| 20 | + * @var string |
|
| 21 | + */ |
|
| 22 | + protected $post_type = 'wpi_invoice'; |
|
| 37 | 23 | |
| 38 | 24 | /** |
| 39 | - * Retrieves the query params for the invoices collection. |
|
| 40 | - * |
|
| 41 | - * @since 1.0.13 |
|
| 42 | - * |
|
| 43 | - * @return array Collection parameters. |
|
| 44 | - */ |
|
| 45 | - public function get_collection_params() { |
|
| 46 | - |
|
| 47 | - $params = array_merge( |
|
| 48 | - |
|
| 49 | - parent::get_collection_params(), |
|
| 50 | - |
|
| 51 | - array( |
|
| 52 | - |
|
| 53 | - |
|
| 54 | - 'customers' => array( |
|
| 55 | - 'description' => __( 'Limit result set to invoices for specific user ids.', 'invoicing' ), |
|
| 56 | - 'type' => 'array', |
|
| 57 | - 'items' => array( |
|
| 58 | - 'type' => 'integer', |
|
| 59 | - ), |
|
| 60 | - 'default' => array(), |
|
| 61 | - 'sanitize_callback' => 'wp_parse_id_list', |
|
| 62 | - ), |
|
| 63 | - |
|
| 64 | - 'exclude_customers' => array( |
|
| 65 | - 'description' => __( 'Exclude invoices to specific users.', 'invoicing' ), |
|
| 66 | - 'type' => 'array', |
|
| 67 | - 'items' => array( |
|
| 68 | - 'type' => 'integer', |
|
| 69 | - ), |
|
| 70 | - 'default' => array(), |
|
| 71 | - 'sanitize_callback' => 'wp_parse_id_list', |
|
| 72 | - ), |
|
| 73 | - |
|
| 74 | - 'parent' => array( |
|
| 75 | - 'description' => __( 'Limit result set to those of particular parent IDs.', 'invoicing' ), |
|
| 76 | - 'type' => 'array', |
|
| 77 | - 'items' => array( |
|
| 78 | - 'type' => 'integer', |
|
| 79 | - ), |
|
| 80 | - 'sanitize_callback' => 'wp_parse_id_list', |
|
| 81 | - 'default' => array(), |
|
| 82 | - ), |
|
| 83 | - |
|
| 84 | - 'parent_exclude' => array( |
|
| 85 | - 'description' => __( 'Limit result set to all items except those of a particular parent ID.', 'invoicing' ), |
|
| 86 | - 'type' => 'array', |
|
| 87 | - 'items' => array( |
|
| 88 | - 'type' => 'integer', |
|
| 89 | - ), |
|
| 90 | - 'sanitize_callback' => 'wp_parse_id_list', |
|
| 91 | - 'default' => array(), |
|
| 92 | - ), |
|
| 93 | - |
|
| 94 | - ) |
|
| 95 | - |
|
| 96 | - ); |
|
| 97 | - |
|
| 98 | - // Filter collection parameters for the invoices controller. |
|
| 99 | - return apply_filters( 'getpaid_rest_invoices_collection_params', $params, $this ); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * Determine the allowed query_vars for a get_items() response and |
|
| 104 | - * prepare for WP_Query. |
|
| 105 | - * |
|
| 106 | - * @param array $prepared_args Prepared arguments. |
|
| 107 | - * @param WP_REST_Request $request Request object. |
|
| 108 | - * @return array $query_args |
|
| 109 | - */ |
|
| 110 | - protected function prepare_items_query( $prepared_args = array(), $request = null ) { |
|
| 111 | - |
|
| 112 | - $query_args = parent::prepare_items_query( $prepared_args ); |
|
| 113 | - |
|
| 114 | - // Retrieve invoices for specific customers. |
|
| 115 | - if ( ! empty( $request['customers'] ) ) { |
|
| 116 | - $query_args['author__in'] = $request['customers']; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - // Skip invoices for specific customers. |
|
| 120 | - if ( ! empty( $request['exclude_customers'] ) ) { |
|
| 121 | - $query_args['author__not_in'] = $request['exclude_customers']; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return apply_filters( 'getpaid_rest_invoices_prepare_items_query', $query_args, $request, $this ); |
|
| 125 | - |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * Retrieves a valid list of post statuses. |
|
| 130 | - * |
|
| 131 | - * @since 1.0.15 |
|
| 132 | - * |
|
| 133 | - * @return array A list of registered item statuses. |
|
| 134 | - */ |
|
| 135 | - public function get_post_statuses() { |
|
| 136 | - return array_keys( wpinv_get_invoice_statuses( true, false, $this->post_type ) ); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * Saves a single invoice. |
|
| 141 | - * |
|
| 142 | - * @param WPInv_Invoice $invoice Invoice to save. |
|
| 143 | - * @return WP_Error|WPInv_Invoice |
|
| 144 | - */ |
|
| 145 | - protected function save_object( $invoice ) { |
|
| 146 | - $invoice->recalculate_total(); |
|
| 147 | - return parent::save_object( $invoice ); |
|
| 148 | - } |
|
| 25 | + * The base of this controller's route. |
|
| 26 | + * |
|
| 27 | + * @since 1.0.13 |
|
| 28 | + * @var string |
|
| 29 | + */ |
|
| 30 | + protected $rest_base = 'invoices'; |
|
| 31 | + |
|
| 32 | + /** Contains this controller's class name. |
|
| 33 | + * |
|
| 34 | + * @var string |
|
| 35 | + */ |
|
| 36 | + public $crud_class = 'WPInv_Invoice'; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Retrieves the query params for the invoices collection. |
|
| 40 | + * |
|
| 41 | + * @since 1.0.13 |
|
| 42 | + * |
|
| 43 | + * @return array Collection parameters. |
|
| 44 | + */ |
|
| 45 | + public function get_collection_params() { |
|
| 46 | + |
|
| 47 | + $params = array_merge( |
|
| 48 | + |
|
| 49 | + parent::get_collection_params(), |
|
| 50 | + |
|
| 51 | + array( |
|
| 52 | + |
|
| 53 | + |
|
| 54 | + 'customers' => array( |
|
| 55 | + 'description' => __( 'Limit result set to invoices for specific user ids.', 'invoicing' ), |
|
| 56 | + 'type' => 'array', |
|
| 57 | + 'items' => array( |
|
| 58 | + 'type' => 'integer', |
|
| 59 | + ), |
|
| 60 | + 'default' => array(), |
|
| 61 | + 'sanitize_callback' => 'wp_parse_id_list', |
|
| 62 | + ), |
|
| 63 | + |
|
| 64 | + 'exclude_customers' => array( |
|
| 65 | + 'description' => __( 'Exclude invoices to specific users.', 'invoicing' ), |
|
| 66 | + 'type' => 'array', |
|
| 67 | + 'items' => array( |
|
| 68 | + 'type' => 'integer', |
|
| 69 | + ), |
|
| 70 | + 'default' => array(), |
|
| 71 | + 'sanitize_callback' => 'wp_parse_id_list', |
|
| 72 | + ), |
|
| 73 | + |
|
| 74 | + 'parent' => array( |
|
| 75 | + 'description' => __( 'Limit result set to those of particular parent IDs.', 'invoicing' ), |
|
| 76 | + 'type' => 'array', |
|
| 77 | + 'items' => array( |
|
| 78 | + 'type' => 'integer', |
|
| 79 | + ), |
|
| 80 | + 'sanitize_callback' => 'wp_parse_id_list', |
|
| 81 | + 'default' => array(), |
|
| 82 | + ), |
|
| 83 | + |
|
| 84 | + 'parent_exclude' => array( |
|
| 85 | + 'description' => __( 'Limit result set to all items except those of a particular parent ID.', 'invoicing' ), |
|
| 86 | + 'type' => 'array', |
|
| 87 | + 'items' => array( |
|
| 88 | + 'type' => 'integer', |
|
| 89 | + ), |
|
| 90 | + 'sanitize_callback' => 'wp_parse_id_list', |
|
| 91 | + 'default' => array(), |
|
| 92 | + ), |
|
| 93 | + |
|
| 94 | + ) |
|
| 95 | + |
|
| 96 | + ); |
|
| 97 | + |
|
| 98 | + // Filter collection parameters for the invoices controller. |
|
| 99 | + return apply_filters( 'getpaid_rest_invoices_collection_params', $params, $this ); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * Determine the allowed query_vars for a get_items() response and |
|
| 104 | + * prepare for WP_Query. |
|
| 105 | + * |
|
| 106 | + * @param array $prepared_args Prepared arguments. |
|
| 107 | + * @param WP_REST_Request $request Request object. |
|
| 108 | + * @return array $query_args |
|
| 109 | + */ |
|
| 110 | + protected function prepare_items_query( $prepared_args = array(), $request = null ) { |
|
| 111 | + |
|
| 112 | + $query_args = parent::prepare_items_query( $prepared_args ); |
|
| 113 | + |
|
| 114 | + // Retrieve invoices for specific customers. |
|
| 115 | + if ( ! empty( $request['customers'] ) ) { |
|
| 116 | + $query_args['author__in'] = $request['customers']; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + // Skip invoices for specific customers. |
|
| 120 | + if ( ! empty( $request['exclude_customers'] ) ) { |
|
| 121 | + $query_args['author__not_in'] = $request['exclude_customers']; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + return apply_filters( 'getpaid_rest_invoices_prepare_items_query', $query_args, $request, $this ); |
|
| 125 | + |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + /** |
|
| 129 | + * Retrieves a valid list of post statuses. |
|
| 130 | + * |
|
| 131 | + * @since 1.0.15 |
|
| 132 | + * |
|
| 133 | + * @return array A list of registered item statuses. |
|
| 134 | + */ |
|
| 135 | + public function get_post_statuses() { |
|
| 136 | + return array_keys( wpinv_get_invoice_statuses( true, false, $this->post_type ) ); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * Saves a single invoice. |
|
| 141 | + * |
|
| 142 | + * @param WPInv_Invoice $invoice Invoice to save. |
|
| 143 | + * @return WP_Error|WPInv_Invoice |
|
| 144 | + */ |
|
| 145 | + protected function save_object( $invoice ) { |
|
| 146 | + $invoice->recalculate_total(); |
|
| 147 | + return parent::save_object( $invoice ); |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | 150 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * @version 1.0.19 |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -defined( 'ABSPATH' ) || exit; |
|
| 8 | +defined('ABSPATH') || exit; |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * REST API invoices controller class. |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | |
| 54 | 54 | 'customers' => array( |
| 55 | - 'description' => __( 'Limit result set to invoices for specific user ids.', 'invoicing' ), |
|
| 55 | + 'description' => __('Limit result set to invoices for specific user ids.', 'invoicing'), |
|
| 56 | 56 | 'type' => 'array', |
| 57 | 57 | 'items' => array( |
| 58 | 58 | 'type' => 'integer', |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | ), |
| 63 | 63 | |
| 64 | 64 | 'exclude_customers' => array( |
| 65 | - 'description' => __( 'Exclude invoices to specific users.', 'invoicing' ), |
|
| 65 | + 'description' => __('Exclude invoices to specific users.', 'invoicing'), |
|
| 66 | 66 | 'type' => 'array', |
| 67 | 67 | 'items' => array( |
| 68 | 68 | 'type' => 'integer', |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | ), |
| 73 | 73 | |
| 74 | 74 | 'parent' => array( |
| 75 | - 'description' => __( 'Limit result set to those of particular parent IDs.', 'invoicing' ), |
|
| 75 | + 'description' => __('Limit result set to those of particular parent IDs.', 'invoicing'), |
|
| 76 | 76 | 'type' => 'array', |
| 77 | 77 | 'items' => array( |
| 78 | 78 | 'type' => 'integer', |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | ), |
| 83 | 83 | |
| 84 | 84 | 'parent_exclude' => array( |
| 85 | - 'description' => __( 'Limit result set to all items except those of a particular parent ID.', 'invoicing' ), |
|
| 85 | + 'description' => __('Limit result set to all items except those of a particular parent ID.', 'invoicing'), |
|
| 86 | 86 | 'type' => 'array', |
| 87 | 87 | 'items' => array( |
| 88 | 88 | 'type' => 'integer', |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | ); |
| 97 | 97 | |
| 98 | 98 | // Filter collection parameters for the invoices controller. |
| 99 | - return apply_filters( 'getpaid_rest_invoices_collection_params', $params, $this ); |
|
| 99 | + return apply_filters('getpaid_rest_invoices_collection_params', $params, $this); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -107,21 +107,21 @@ discard block |
||
| 107 | 107 | * @param WP_REST_Request $request Request object. |
| 108 | 108 | * @return array $query_args |
| 109 | 109 | */ |
| 110 | - protected function prepare_items_query( $prepared_args = array(), $request = null ) { |
|
| 110 | + protected function prepare_items_query($prepared_args = array(), $request = null) { |
|
| 111 | 111 | |
| 112 | - $query_args = parent::prepare_items_query( $prepared_args ); |
|
| 112 | + $query_args = parent::prepare_items_query($prepared_args); |
|
| 113 | 113 | |
| 114 | 114 | // Retrieve invoices for specific customers. |
| 115 | - if ( ! empty( $request['customers'] ) ) { |
|
| 115 | + if (!empty($request['customers'])) { |
|
| 116 | 116 | $query_args['author__in'] = $request['customers']; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // Skip invoices for specific customers. |
| 120 | - if ( ! empty( $request['exclude_customers'] ) ) { |
|
| 120 | + if (!empty($request['exclude_customers'])) { |
|
| 121 | 121 | $query_args['author__not_in'] = $request['exclude_customers']; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - return apply_filters( 'getpaid_rest_invoices_prepare_items_query', $query_args, $request, $this ); |
|
| 124 | + return apply_filters('getpaid_rest_invoices_prepare_items_query', $query_args, $request, $this); |
|
| 125 | 125 | |
| 126 | 126 | } |
| 127 | 127 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | * @return array A list of registered item statuses. |
| 134 | 134 | */ |
| 135 | 135 | public function get_post_statuses() { |
| 136 | - return array_keys( wpinv_get_invoice_statuses( true, false, $this->post_type ) ); |
|
| 136 | + return array_keys(wpinv_get_invoice_statuses(true, false, $this->post_type)); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -142,9 +142,9 @@ discard block |
||
| 142 | 142 | * @param WPInv_Invoice $invoice Invoice to save. |
| 143 | 143 | * @return WP_Error|WPInv_Invoice |
| 144 | 144 | */ |
| 145 | - protected function save_object( $invoice ) { |
|
| 145 | + protected function save_object($invoice) { |
|
| 146 | 146 | $invoice->recalculate_total(); |
| 147 | - return parent::save_object( $invoice ); |
|
| 147 | + return parent::save_object($invoice); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | } |