@@ -7,63 +7,63 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | -$label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
| 13 | -$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) ); |
|
| 14 | -if ( ! empty( $required ) ) { |
|
| 12 | +$label = empty($label) ? '' : wp_kses_post($label); |
|
| 13 | +$label_class = sanitize_key(preg_replace('/[^A-Za-z0-9_-]/', '-', $label)); |
|
| 14 | +if (!empty($required)) { |
|
| 15 | 15 | $label .= "<span class='text-danger'> *</span>"; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | $disable_dates = array(); |
| 19 | 19 | |
| 20 | -if ( ! empty( $disabled_dates ) ) { |
|
| 21 | - $disabled_dates = preg_replace( '/\s+/', '', $disabled_dates ); |
|
| 22 | - $disabled_dates = str_ireplace( 'today', current_time( 'Y-m-d' ), $disabled_dates ); |
|
| 23 | - $disabled_dates = array_filter( explode( ',', $disabled_dates ) ); |
|
| 20 | +if (!empty($disabled_dates)) { |
|
| 21 | + $disabled_dates = preg_replace('/\s+/', '', $disabled_dates); |
|
| 22 | + $disabled_dates = str_ireplace('today', current_time('Y-m-d'), $disabled_dates); |
|
| 23 | + $disabled_dates = array_filter(explode(',', $disabled_dates)); |
|
| 24 | 24 | |
| 25 | - foreach ( $disabled_dates as $disabled_date ) { |
|
| 25 | + foreach ($disabled_dates as $disabled_date) { |
|
| 26 | 26 | |
| 27 | - $disabled_date = trim( $disabled_date ); |
|
| 27 | + $disabled_date = trim($disabled_date); |
|
| 28 | 28 | |
| 29 | - if ( false === strpos( $disabled_date, '|' ) ) { |
|
| 29 | + if (false === strpos($disabled_date, '|')) { |
|
| 30 | 30 | $disable_dates[] = $disabled_date; |
| 31 | 31 | continue; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - $disabled_date = explode( '|', $disabled_date ); |
|
| 34 | + $disabled_date = explode('|', $disabled_date); |
|
| 35 | 35 | $disable_dates[] = array( |
| 36 | - 'from' => trim( $disabled_date[0] ), |
|
| 37 | - 'to' => trim( $disabled_date[1] ), |
|
| 36 | + 'from' => trim($disabled_date[0]), |
|
| 37 | + 'to' => trim($disabled_date[1]), |
|
| 38 | 38 | ); |
| 39 | 39 | |
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | $options = array( |
| 44 | - 'data-default-date' => empty( $default_date ) ? false : $default_date, |
|
| 45 | - 'data-min-date' => empty( $min_date ) ? false : $min_date, |
|
| 46 | - 'data-max-date' => empty( $max_date ) ? false : $max_date, |
|
| 47 | - 'data-mode' => empty( $mode ) ? 'single' : $mode, |
|
| 48 | - 'data-alt-format' => get_option( 'date_format', 'F j, Y' ), |
|
| 44 | + 'data-default-date' => empty($default_date) ? false : $default_date, |
|
| 45 | + 'data-min-date' => empty($min_date) ? false : $min_date, |
|
| 46 | + 'data-max-date' => empty($max_date) ? false : $max_date, |
|
| 47 | + 'data-mode' => empty($mode) ? 'single' : $mode, |
|
| 48 | + 'data-alt-format' => get_option('date_format', 'F j, Y'), |
|
| 49 | 49 | 'data-date-format' => 'Y-m-d', |
| 50 | 50 | 'data-alt-input' => 'true', |
| 51 | - 'data-disable_alt' => empty( $disabled_dates ) ? false : wp_json_encode( $disable_dates ), |
|
| 52 | - 'data-disable_days_alt' => empty( $disable_days ) ? false : wp_json_encode( wp_parse_id_list( $disable_days ) ), |
|
| 51 | + 'data-disable_alt' => empty($disabled_dates) ? false : wp_json_encode($disable_dates), |
|
| 52 | + 'data-disable_days_alt' => empty($disable_days) ? false : wp_json_encode(wp_parse_id_list($disable_days)), |
|
| 53 | 53 | ); |
| 54 | 54 | |
| 55 | 55 | aui()->input( |
| 56 | 56 | array( |
| 57 | - 'name' => esc_attr( $id ), |
|
| 58 | - 'id' => esc_attr( $element_id ), |
|
| 59 | - 'placeholder' => empty( $placeholder ) ? '' : esc_attr( $placeholder ), |
|
| 60 | - 'required' => ! empty( $required ), |
|
| 57 | + 'name' => esc_attr($id), |
|
| 58 | + 'id' => esc_attr($element_id), |
|
| 59 | + 'placeholder' => empty($placeholder) ? '' : esc_attr($placeholder), |
|
| 60 | + 'required' => !empty($required), |
|
| 61 | 61 | 'label' => $label, |
| 62 | 62 | 'label_type' => 'vertical', |
| 63 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
| 63 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
| 64 | 64 | 'type' => 'datepicker', |
| 65 | 65 | 'class' => $label_class . ' getpaid-init-flatpickr flatpickr-input', |
| 66 | - 'extra_attributes' => array_filter( apply_filters( 'getpaid_date_field_attributes', $options ) ), |
|
| 66 | + 'extra_attributes' => array_filter(apply_filters('getpaid_date_field_attributes', $options)), |
|
| 67 | 67 | 'value' => $query_value, |
| 68 | 68 | ), |
| 69 | 69 | true |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -defined( 'ABSPATH' ) || exit; |
|
| 8 | +defined('ABSPATH') || exit; |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * GetPaid_Reports_Export Class. |
@@ -19,8 +19,8 @@ discard block |
||
| 19 | 19 | public function display() { |
| 20 | 20 | |
| 21 | 21 | echo "<div class='row mt-4' style='max-width: 920px;' >"; |
| 22 | - foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
| 23 | - $this->display_post_type_export( $post_type ); |
|
| 22 | + foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) { |
|
| 23 | + $this->display_post_type_export($post_type); |
|
| 24 | 24 | } |
| 25 | 25 | $this->display_subscription_export(); |
| 26 | 26 | echo '</div>'; |
@@ -31,13 +31,13 @@ discard block |
||
| 31 | 31 | * Retrieves the download url. |
| 32 | 32 | * |
| 33 | 33 | */ |
| 34 | - public function get_download_url( $post_type ) { |
|
| 34 | + public function get_download_url($post_type) { |
|
| 35 | 35 | |
| 36 | 36 | return wp_nonce_url( |
| 37 | 37 | add_query_arg( |
| 38 | 38 | array( |
| 39 | 39 | 'getpaid-admin-action' => 'export_invoices', |
| 40 | - 'post_type' => urlencode( $post_type ), |
|
| 40 | + 'post_type' => urlencode($post_type), |
|
| 41 | 41 | ) |
| 42 | 42 | ), |
| 43 | 43 | 'getpaid-nonce', |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * Displays a single post type export card. |
| 51 | 51 | * |
| 52 | 52 | */ |
| 53 | - public function display_post_type_export( $post_type ) { |
|
| 53 | + public function display_post_type_export($post_type) { |
|
| 54 | 54 | |
| 55 | 55 | ?> |
| 56 | 56 | |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | <strong> |
| 62 | 62 | <?php |
| 63 | 63 | printf( |
| 64 | - esc_html__( 'Export %s', 'invoicing' ), |
|
| 65 | - esc_html( getpaid_get_post_type_label( $post_type ) ) |
|
| 64 | + esc_html__('Export %s', 'invoicing'), |
|
| 65 | + esc_html(getpaid_get_post_type_label($post_type)) |
|
| 66 | 66 | ); |
| 67 | 67 | ?> |
| 68 | 68 | </strong> |
@@ -70,14 +70,14 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | <div class="card-body"> |
| 72 | 72 | |
| 73 | - <form method="post" action="<?php echo esc_url( $this->get_download_url( $post_type ) ); ?>"> |
|
| 73 | + <form method="post" action="<?php echo esc_url($this->get_download_url($post_type)); ?>"> |
|
| 74 | 74 | |
| 75 | 75 | <?php |
| 76 | - $this->generate_from_date( $post_type ); |
|
| 77 | - $this->generate_to_date( $post_type ); |
|
| 78 | - $this->generate_post_status_select( $post_type ); |
|
| 79 | - $this->generate_file_type_select( $post_type ); |
|
| 80 | - submit_button( __( 'Download', 'invoicing' ) ); |
|
| 76 | + $this->generate_from_date($post_type); |
|
| 77 | + $this->generate_to_date($post_type); |
|
| 78 | + $this->generate_post_status_select($post_type); |
|
| 79 | + $this->generate_file_type_select($post_type); |
|
| 80 | + submit_button(__('Download', 'invoicing')); |
|
| 81 | 81 | ?> |
| 82 | 82 | |
| 83 | 83 | </form> |
@@ -95,14 +95,14 @@ discard block |
||
| 95 | 95 | * Generates the from date input field. |
| 96 | 96 | * |
| 97 | 97 | */ |
| 98 | - public function generate_from_date( $post_type ) { |
|
| 98 | + public function generate_from_date($post_type) { |
|
| 99 | 99 | |
| 100 | 100 | aui()->input( |
| 101 | 101 | array( |
| 102 | 102 | 'type' => 'datepicker', |
| 103 | - 'id' => esc_attr( "$post_type-from_date" ), |
|
| 103 | + 'id' => esc_attr("$post_type-from_date"), |
|
| 104 | 104 | 'name' => 'from_date', |
| 105 | - 'label' => __( 'From Date', 'invoicing' ), |
|
| 105 | + 'label' => __('From Date', 'invoicing'), |
|
| 106 | 106 | 'label_type' => 'vertical', |
| 107 | 107 | 'placeholder' => 'YYYY-MM-DD', |
| 108 | 108 | 'extra_attributes' => array( |
@@ -119,14 +119,14 @@ discard block |
||
| 119 | 119 | * Generates the to date input field. |
| 120 | 120 | * |
| 121 | 121 | */ |
| 122 | - public function generate_to_date( $post_type ) { |
|
| 122 | + public function generate_to_date($post_type) { |
|
| 123 | 123 | |
| 124 | 124 | aui()->input( |
| 125 | 125 | array( |
| 126 | 126 | 'type' => 'datepicker', |
| 127 | - 'id' => esc_attr( "$post_type-to_date" ), |
|
| 127 | + 'id' => esc_attr("$post_type-to_date"), |
|
| 128 | 128 | 'name' => 'to_date', |
| 129 | - 'label' => __( 'To Date', 'invoicing' ), |
|
| 129 | + 'label' => __('To Date', 'invoicing'), |
|
| 130 | 130 | 'label_type' => 'vertical', |
| 131 | 131 | 'placeholder' => 'YYYY-MM-DD', |
| 132 | 132 | 'extra_attributes' => array( |
@@ -142,20 +142,20 @@ discard block |
||
| 142 | 142 | * Generates the to post status select field. |
| 143 | 143 | * |
| 144 | 144 | */ |
| 145 | - public function generate_post_status_select( $post_type ) { |
|
| 145 | + public function generate_post_status_select($post_type) { |
|
| 146 | 146 | |
| 147 | - if ( 'subscriptions' === $post_type ) { |
|
| 147 | + if ('subscriptions' === $post_type) { |
|
| 148 | 148 | $options = getpaid_get_subscription_statuses(); |
| 149 | 149 | } else { |
| 150 | - $options = wpinv_get_invoice_statuses( true, false, $post_type ); |
|
| 150 | + $options = wpinv_get_invoice_statuses(true, false, $post_type); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | aui()->select( |
| 154 | 154 | array( |
| 155 | 155 | 'name' => 'status', |
| 156 | - 'id' => esc_attr( "$post_type-status" ), |
|
| 157 | - 'placeholder' => __( 'All Statuses', 'invoicing' ), |
|
| 158 | - 'label' => __( 'Status', 'invoicing' ), |
|
| 156 | + 'id' => esc_attr("$post_type-status"), |
|
| 157 | + 'placeholder' => __('All Statuses', 'invoicing'), |
|
| 158 | + 'label' => __('Status', 'invoicing'), |
|
| 159 | 159 | 'label_type' => 'vertical', |
| 160 | 160 | 'label_class' => 'd-block', |
| 161 | 161 | 'options' => $options, |
@@ -169,21 +169,21 @@ discard block |
||
| 169 | 169 | * Generates the to file type select field. |
| 170 | 170 | * |
| 171 | 171 | */ |
| 172 | - public function generate_file_type_select( $post_type ) { |
|
| 172 | + public function generate_file_type_select($post_type) { |
|
| 173 | 173 | |
| 174 | 174 | aui()->select( |
| 175 | 175 | array( |
| 176 | 176 | 'name' => 'file_type', |
| 177 | - 'id' => esc_attr( "$post_type-file_type" ), |
|
| 178 | - 'placeholder' => __( 'Select File Type', 'invoicing' ), |
|
| 179 | - 'label' => __( 'Export File', 'invoicing' ), |
|
| 177 | + 'id' => esc_attr("$post_type-file_type"), |
|
| 178 | + 'placeholder' => __('Select File Type', 'invoicing'), |
|
| 179 | + 'label' => __('Export File', 'invoicing'), |
|
| 180 | 180 | 'label_type' => 'vertical', |
| 181 | 181 | 'label_class' => 'd-block', |
| 182 | 182 | 'value' => 'csv', |
| 183 | 183 | 'options' => array( |
| 184 | - 'csv' => __( 'CSV', 'invoicing' ), |
|
| 185 | - 'xml' => __( 'XML', 'invoicing' ), |
|
| 186 | - 'json' => __( 'JSON', 'invoicing' ), |
|
| 184 | + 'csv' => __('CSV', 'invoicing'), |
|
| 185 | + 'xml' => __('XML', 'invoicing'), |
|
| 186 | + 'json' => __('JSON', 'invoicing'), |
|
| 187 | 187 | ), |
| 188 | 188 | ), |
| 189 | 189 | true |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * Displays a field's markup. |
| 196 | 196 | * |
| 197 | 197 | */ |
| 198 | - public function display_markup( $markup ) { |
|
| 198 | + public function display_markup($markup) { |
|
| 199 | 199 | |
| 200 | 200 | echo wp_kses( |
| 201 | 201 | str_replace( |
@@ -224,20 +224,20 @@ discard block |
||
| 224 | 224 | |
| 225 | 225 | <div class="card-header"> |
| 226 | 226 | <strong> |
| 227 | - <?php esc_html_e( 'Export Subscriptions', 'invoicing' ); ?> |
|
| 227 | + <?php esc_html_e('Export Subscriptions', 'invoicing'); ?> |
|
| 228 | 228 | </strong> |
| 229 | 229 | </div> |
| 230 | 230 | |
| 231 | 231 | <div class="card-body"> |
| 232 | 232 | |
| 233 | - <form method="post" action="<?php echo esc_url( $this->get_download_url( 'subscriptions' ) ); ?>"> |
|
| 233 | + <form method="post" action="<?php echo esc_url($this->get_download_url('subscriptions')); ?>"> |
|
| 234 | 234 | |
| 235 | 235 | <?php |
| 236 | - $this->generate_from_date( 'subscriptions' ); |
|
| 237 | - $this->generate_to_date( 'subscriptions' ); |
|
| 238 | - $this->generate_post_status_select( 'subscriptions' ); |
|
| 239 | - $this->generate_file_type_select( 'subscriptions' ); |
|
| 240 | - submit_button( __( 'Download', 'invoicing' ) ); |
|
| 236 | + $this->generate_from_date('subscriptions'); |
|
| 237 | + $this->generate_to_date('subscriptions'); |
|
| 238 | + $this->generate_post_status_select('subscriptions'); |
|
| 239 | + $this->generate_file_type_select('subscriptions'); |
|
| 240 | + submit_button(__('Download', 'invoicing')); |
|
| 241 | 241 | ?> |
| 242 | 242 | |
| 243 | 243 | </form> |
@@ -97,9 +97,9 @@ discard block |
||
| 97 | 97 | * |
| 98 | 98 | * @param null|string|array $query Optional. The query variables. |
| 99 | 99 | */ |
| 100 | - public function __construct( $query = null ) { |
|
| 101 | - if ( ! is_null( $query ) ) { |
|
| 102 | - $this->prepare_query( $query ); |
|
| 100 | + public function __construct($query = null) { |
|
| 101 | + if (!is_null($query)) { |
|
| 102 | + $this->prepare_query($query); |
|
| 103 | 103 | $this->query(); |
| 104 | 104 | } |
| 105 | 105 | } |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * @param string|array $args Query vars, as passed to `GetPaid_Subscriptions_Query`. |
| 113 | 113 | * @return array Complete query variables with undefined ones filled in with defaults. |
| 114 | 114 | */ |
| 115 | - public static function fill_query_vars( $args ) { |
|
| 115 | + public static function fill_query_vars($args) { |
|
| 116 | 116 | $defaults = array( |
| 117 | 117 | 'status' => 'all', |
| 118 | 118 | 'customer_in' => array(), |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | 'fields' => 'all', |
| 131 | 131 | ); |
| 132 | 132 | |
| 133 | - return wp_parse_args( $args, $defaults ); |
|
| 133 | + return wp_parse_args($args, $defaults); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -182,45 +182,45 @@ discard block |
||
| 182 | 182 | * Use 'all' for all fields. Default 'all'. |
| 183 | 183 | * } |
| 184 | 184 | */ |
| 185 | - public function prepare_query( $query = array() ) { |
|
| 185 | + public function prepare_query($query = array()) { |
|
| 186 | 186 | global $wpdb; |
| 187 | 187 | |
| 188 | - if ( empty( $this->query_vars ) || ! empty( $query ) ) { |
|
| 188 | + if (empty($this->query_vars) || !empty($query)) { |
|
| 189 | 189 | $this->query_limit = null; |
| 190 | - $this->query_vars = $this->fill_query_vars( $query ); |
|
| 190 | + $this->query_vars = $this->fill_query_vars($query); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - if ( ! empty( $this->query_vars['fields'] ) && 'all' !== $this->query_vars['fields'] ) { |
|
| 194 | - $this->query_vars['fields'] = wpinv_parse_list( $this->query_vars['fields'] ); |
|
| 193 | + if (!empty($this->query_vars['fields']) && 'all' !== $this->query_vars['fields']) { |
|
| 194 | + $this->query_vars['fields'] = wpinv_parse_list($this->query_vars['fields']); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - do_action( 'getpaid_pre_get_subscriptions', array( &$this ) ); |
|
| 197 | + do_action('getpaid_pre_get_subscriptions', array(&$this)); |
|
| 198 | 198 | |
| 199 | 199 | // Ensure that query vars are filled after 'getpaid_pre_get_subscriptions'. |
| 200 | - $qv =& $this->query_vars; |
|
| 201 | - $qv = $this->fill_query_vars( $qv ); |
|
| 200 | + $qv = & $this->query_vars; |
|
| 201 | + $qv = $this->fill_query_vars($qv); |
|
| 202 | 202 | $table = $wpdb->prefix . 'wpinv_subscriptions'; |
| 203 | 203 | $this->query_from = "FROM $table"; |
| 204 | 204 | |
| 205 | 205 | // Prepare query fields. |
| 206 | - $this->prepare_query_fields( $qv, $table ); |
|
| 206 | + $this->prepare_query_fields($qv, $table); |
|
| 207 | 207 | |
| 208 | 208 | // Prepare query where. |
| 209 | - $this->prepare_query_where( $qv, $table ); |
|
| 209 | + $this->prepare_query_where($qv, $table); |
|
| 210 | 210 | |
| 211 | 211 | // Prepare query order. |
| 212 | - $this->prepare_query_order( $qv, $table ); |
|
| 212 | + $this->prepare_query_order($qv, $table); |
|
| 213 | 213 | |
| 214 | 214 | // limit |
| 215 | - if ( isset( $qv['number'] ) && $qv['number'] > 0 ) { |
|
| 216 | - if ( $qv['offset'] ) { |
|
| 217 | - $this->query_limit = $wpdb->prepare( 'LIMIT %d, %d', $qv['offset'], $qv['number'] ); |
|
| 215 | + if (isset($qv['number']) && $qv['number'] > 0) { |
|
| 216 | + if ($qv['offset']) { |
|
| 217 | + $this->query_limit = $wpdb->prepare('LIMIT %d, %d', $qv['offset'], $qv['number']); |
|
| 218 | 218 | } else { |
| 219 | - $this->query_limit = $wpdb->prepare( 'LIMIT %d, %d', $qv['number'] * ( $qv['paged'] - 1 ), $qv['number'] ); |
|
| 219 | + $this->query_limit = $wpdb->prepare('LIMIT %d, %d', $qv['number'] * ($qv['paged'] - 1), $qv['number']); |
|
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - do_action_ref_array( 'getpaid_after_subscriptions_query', array( &$this ) ); |
|
| 223 | + do_action_ref_array('getpaid_after_subscriptions_query', array(&$this)); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
@@ -231,22 +231,22 @@ discard block |
||
| 231 | 231 | * @param array $qv Query vars. |
| 232 | 232 | * @param string $table Table name. |
| 233 | 233 | */ |
| 234 | - protected function prepare_query_fields( &$qv, $table ) { |
|
| 234 | + protected function prepare_query_fields(&$qv, $table) { |
|
| 235 | 235 | |
| 236 | - if ( is_array( $qv['fields'] ) ) { |
|
| 237 | - $qv['fields'] = array_unique( $qv['fields'] ); |
|
| 236 | + if (is_array($qv['fields'])) { |
|
| 237 | + $qv['fields'] = array_unique($qv['fields']); |
|
| 238 | 238 | |
| 239 | 239 | $query_fields = array(); |
| 240 | - foreach ( $qv['fields'] as $field ) { |
|
| 241 | - $field = sanitize_key( $field ); |
|
| 240 | + foreach ($qv['fields'] as $field) { |
|
| 241 | + $field = sanitize_key($field); |
|
| 242 | 242 | $query_fields[] = "$table.`$field`"; |
| 243 | 243 | } |
| 244 | - $this->query_fields = implode( ',', $query_fields ); |
|
| 244 | + $this->query_fields = implode(',', $query_fields); |
|
| 245 | 245 | } else { |
| 246 | 246 | $this->query_fields = "$table.*"; |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - if ( isset( $qv['count_total'] ) && $qv['count_total'] ) { |
|
| 249 | + if (isset($qv['count_total']) && $qv['count_total']) { |
|
| 250 | 250 | $this->query_fields = 'SQL_CALC_FOUND_ROWS ' . $this->query_fields; |
| 251 | 251 | } |
| 252 | 252 | |
@@ -260,58 +260,58 @@ discard block |
||
| 260 | 260 | * @param array $qv Query vars. |
| 261 | 261 | * @param string $table Table name. |
| 262 | 262 | */ |
| 263 | - protected function prepare_query_where( &$qv, $table ) { |
|
| 263 | + protected function prepare_query_where(&$qv, $table) { |
|
| 264 | 264 | global $wpdb; |
| 265 | 265 | $this->query_where = 'WHERE 1=1'; |
| 266 | 266 | |
| 267 | 267 | // Status. |
| 268 | - if ( 'all' !== $qv['status'] ) { |
|
| 269 | - $statuses = wpinv_clean( wpinv_parse_list( $qv['status'] ) ); |
|
| 270 | - $prepared_statuses = join( ',', array_fill( 0, count( $statuses ), '%s' ) ); |
|
| 271 | - $this->query_where .= $wpdb->prepare( " AND $table.`status` IN ( $prepared_statuses )", $statuses ); |
|
| 268 | + if ('all' !== $qv['status']) { |
|
| 269 | + $statuses = wpinv_clean(wpinv_parse_list($qv['status'])); |
|
| 270 | + $prepared_statuses = join(',', array_fill(0, count($statuses), '%s')); |
|
| 271 | + $this->query_where .= $wpdb->prepare(" AND $table.`status` IN ( $prepared_statuses )", $statuses); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - if ( ! empty( $qv['customer_in'] ) ) { |
|
| 275 | - $customer_in = implode( ',', wp_parse_id_list( $qv['customer_in'] ) ); |
|
| 274 | + if (!empty($qv['customer_in'])) { |
|
| 275 | + $customer_in = implode(',', wp_parse_id_list($qv['customer_in'])); |
|
| 276 | 276 | $this->query_where .= " AND $table.`customer_id` IN ($customer_in)"; |
| 277 | - } elseif ( ! empty( $qv['customer_not_in'] ) ) { |
|
| 278 | - $customer_not_in = implode( ',', wp_parse_id_list( $qv['customer_not_in'] ) ); |
|
| 277 | + } elseif (!empty($qv['customer_not_in'])) { |
|
| 278 | + $customer_not_in = implode(',', wp_parse_id_list($qv['customer_not_in'])); |
|
| 279 | 279 | $this->query_where .= " AND $table.`customer_id` NOT IN ($customer_not_in)"; |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | - if ( ! empty( $qv['product_in'] ) ) { |
|
| 283 | - $product_in = implode( ',', wp_parse_id_list( $qv['product_in'] ) ); |
|
| 282 | + if (!empty($qv['product_in'])) { |
|
| 283 | + $product_in = implode(',', wp_parse_id_list($qv['product_in'])); |
|
| 284 | 284 | $this->query_where .= " AND $table.`product_id` IN ($product_in)"; |
| 285 | - } elseif ( ! empty( $qv['product_not_in'] ) ) { |
|
| 286 | - $product_not_in = implode( ',', wp_parse_id_list( $qv['product_not_in'] ) ); |
|
| 285 | + } elseif (!empty($qv['product_not_in'])) { |
|
| 286 | + $product_not_in = implode(',', wp_parse_id_list($qv['product_not_in'])); |
|
| 287 | 287 | $this->query_where .= " AND $table.`product_id` NOT IN ($product_not_in)"; |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - if ( ! empty( $qv['invoice_in'] ) ) { |
|
| 291 | - $invoice_in = implode( ',', wp_parse_id_list( $qv['invoice_in'] ) ); |
|
| 290 | + if (!empty($qv['invoice_in'])) { |
|
| 291 | + $invoice_in = implode(',', wp_parse_id_list($qv['invoice_in'])); |
|
| 292 | 292 | $this->query_where .= " AND $table.`parent_payment_id` IN ($invoice_in)"; |
| 293 | - } elseif ( ! empty( $qv['invoice_not_in'] ) ) { |
|
| 294 | - $invoice_not_in = implode( ',', wp_parse_id_list( $qv['invoice_not_in'] ) ); |
|
| 293 | + } elseif (!empty($qv['invoice_not_in'])) { |
|
| 294 | + $invoice_not_in = implode(',', wp_parse_id_list($qv['invoice_not_in'])); |
|
| 295 | 295 | $this->query_where .= " AND $table.`parent_payment_id` NOT IN ($invoice_not_in)"; |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - if ( ! empty( $qv['include'] ) ) { |
|
| 299 | - $include = implode( ',', wp_parse_id_list( $qv['include'] ) ); |
|
| 298 | + if (!empty($qv['include'])) { |
|
| 299 | + $include = implode(',', wp_parse_id_list($qv['include'])); |
|
| 300 | 300 | $this->query_where .= " AND $table.`id` IN ($include)"; |
| 301 | - } elseif ( ! empty( $qv['exclude'] ) ) { |
|
| 302 | - $exclude = implode( ',', wp_parse_id_list( $qv['exclude'] ) ); |
|
| 301 | + } elseif (!empty($qv['exclude'])) { |
|
| 302 | + $exclude = implode(',', wp_parse_id_list($qv['exclude'])); |
|
| 303 | 303 | $this->query_where .= " AND $table.`id` NOT IN ($exclude)"; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | // Date queries are allowed for the subscription creation date. |
| 307 | - if ( ! empty( $qv['date_created_query'] ) && is_array( $qv['date_created_query'] ) ) { |
|
| 308 | - $date_created_query = new WP_Date_Query( $qv['date_created_query'], "$table.created" ); |
|
| 307 | + if (!empty($qv['date_created_query']) && is_array($qv['date_created_query'])) { |
|
| 308 | + $date_created_query = new WP_Date_Query($qv['date_created_query'], "$table.created"); |
|
| 309 | 309 | $this->query_where .= $date_created_query->get_sql(); |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | // Date queries are also allowed for the subscription expiration date. |
| 313 | - if ( ! empty( $qv['date_expires_query'] ) && is_array( $qv['date_expires_query'] ) ) { |
|
| 314 | - $date_expires_query = new WP_Date_Query( $qv['date_expires_query'], "$table.expiration" ); |
|
| 313 | + if (!empty($qv['date_expires_query']) && is_array($qv['date_expires_query'])) { |
|
| 314 | + $date_expires_query = new WP_Date_Query($qv['date_expires_query'], "$table.expiration"); |
|
| 315 | 315 | $this->query_where .= $date_expires_query->get_sql(); |
| 316 | 316 | } |
| 317 | 317 | |
@@ -325,24 +325,24 @@ discard block |
||
| 325 | 325 | * @param array $qv Query vars. |
| 326 | 326 | * @param string $table Table name. |
| 327 | 327 | */ |
| 328 | - protected function prepare_query_order( &$qv, $table ) { |
|
| 328 | + protected function prepare_query_order(&$qv, $table) { |
|
| 329 | 329 | |
| 330 | 330 | // sorting. |
| 331 | - $qv['order'] = isset( $qv['order'] ) ? strtoupper( $qv['order'] ) : ''; |
|
| 332 | - $order = $this->parse_order( $qv['order'] ); |
|
| 331 | + $qv['order'] = isset($qv['order']) ? strtoupper($qv['order']) : ''; |
|
| 332 | + $order = $this->parse_order($qv['order']); |
|
| 333 | 333 | |
| 334 | 334 | // Default order is by 'id' (latest subscriptions). |
| 335 | - if ( empty( $qv['orderby'] ) ) { |
|
| 336 | - $qv['orderby'] = array( 'id' ); |
|
| 335 | + if (empty($qv['orderby'])) { |
|
| 336 | + $qv['orderby'] = array('id'); |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | // 'orderby' values may be an array, comma- or space-separated list. |
| 340 | - $ordersby = array_filter( wpinv_parse_list( $qv['orderby'] ) ); |
|
| 340 | + $ordersby = array_filter(wpinv_parse_list($qv['orderby'])); |
|
| 341 | 341 | |
| 342 | 342 | $orderby_array = array(); |
| 343 | - foreach ( $ordersby as $_key => $_value ) { |
|
| 343 | + foreach ($ordersby as $_key => $_value) { |
|
| 344 | 344 | |
| 345 | - if ( is_int( $_key ) ) { |
|
| 345 | + if (is_int($_key)) { |
|
| 346 | 346 | // Integer key means this is a flat array of 'orderby' fields. |
| 347 | 347 | $_orderby = $_value; |
| 348 | 348 | $_order = $order; |
@@ -352,19 +352,19 @@ discard block |
||
| 352 | 352 | $_order = $_value; |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | - $parsed = $this->parse_orderby( $_orderby, $table ); |
|
| 355 | + $parsed = $this->parse_orderby($_orderby, $table); |
|
| 356 | 356 | |
| 357 | - if ( $parsed ) { |
|
| 358 | - $orderby_array[] = $parsed . ' ' . $this->parse_order( $_order ); |
|
| 357 | + if ($parsed) { |
|
| 358 | + $orderby_array[] = $parsed . ' ' . $this->parse_order($_order); |
|
| 359 | 359 | } |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | // If no valid clauses were found, order by id. |
| 363 | - if ( empty( $orderby_array ) ) { |
|
| 363 | + if (empty($orderby_array)) { |
|
| 364 | 364 | $orderby_array[] = "id $order"; |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | - $this->query_orderby = 'ORDER BY ' . implode( ', ', $orderby_array ); |
|
| 367 | + $this->query_orderby = 'ORDER BY ' . implode(', ', $orderby_array); |
|
| 368 | 368 | |
| 369 | 369 | } |
| 370 | 370 | |
@@ -378,34 +378,34 @@ discard block |
||
| 378 | 378 | public function query() { |
| 379 | 379 | global $wpdb; |
| 380 | 380 | |
| 381 | - $qv =& $this->query_vars; |
|
| 381 | + $qv = & $this->query_vars; |
|
| 382 | 382 | |
| 383 | 383 | // Return a non-null value to bypass the default GetPaid subscriptions query and remember to set the |
| 384 | 384 | // total_subscriptions property. |
| 385 | - $this->results = apply_filters_ref_array( 'getpaid_subscriptions_pre_query', array( null, &$this ) ); |
|
| 385 | + $this->results = apply_filters_ref_array('getpaid_subscriptions_pre_query', array(null, &$this)); |
|
| 386 | 386 | |
| 387 | - if ( null === $this->results ) { |
|
| 387 | + if (null === $this->results) { |
|
| 388 | 388 | $this->request = "SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit"; |
| 389 | 389 | |
| 390 | - if ( ( is_array( $qv['fields'] ) && 1 != count( $qv['fields'] ) ) || 'all' == $qv['fields'] ) { |
|
| 391 | - $this->results = $wpdb->get_results( $this->request ); |
|
| 390 | + if ((is_array($qv['fields']) && 1 != count($qv['fields'])) || 'all' == $qv['fields']) { |
|
| 391 | + $this->results = $wpdb->get_results($this->request); |
|
| 392 | 392 | } else { |
| 393 | - $this->results = $wpdb->get_col( $this->request ); |
|
| 393 | + $this->results = $wpdb->get_col($this->request); |
|
| 394 | 394 | } |
| 395 | 395 | |
| 396 | - if ( isset( $qv['count_total'] ) && $qv['count_total'] ) { |
|
| 397 | - $found_subscriptions_query = apply_filters( 'getpaid_found_subscriptions_query', 'SELECT FOUND_ROWS()', $this ); |
|
| 398 | - $this->total_subscriptions = (int) $wpdb->get_var( $found_subscriptions_query ); |
|
| 396 | + if (isset($qv['count_total']) && $qv['count_total']) { |
|
| 397 | + $found_subscriptions_query = apply_filters('getpaid_found_subscriptions_query', 'SELECT FOUND_ROWS()', $this); |
|
| 398 | + $this->total_subscriptions = (int) $wpdb->get_var($found_subscriptions_query); |
|
| 399 | 399 | } |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | - if ( 'all' == $qv['fields'] ) { |
|
| 403 | - foreach ( $this->results as $key => $subscription ) { |
|
| 404 | - $this->set_cache( $subscription->id, $subscription, 'getpaid_subscriptions' ); |
|
| 405 | - $this->set_cache( $subscription->profile_id, $subscription->id, 'getpaid_subscription_profile_ids_to_subscription_ids' ); |
|
| 406 | - $this->set_cache( $subscription->transaction_id, $subscription->id, 'getpaid_subscription_transaction_ids_to_subscription_ids' ); |
|
| 407 | - $this->set_cache( $subscription->transaction_id, $subscription->id, 'getpaid_subscription_transaction_ids_to_subscription_ids' ); |
|
| 408 | - $this->results[ $key ] = new WPInv_Subscription( $subscription ); |
|
| 402 | + if ('all' == $qv['fields']) { |
|
| 403 | + foreach ($this->results as $key => $subscription) { |
|
| 404 | + $this->set_cache($subscription->id, $subscription, 'getpaid_subscriptions'); |
|
| 405 | + $this->set_cache($subscription->profile_id, $subscription->id, 'getpaid_subscription_profile_ids_to_subscription_ids'); |
|
| 406 | + $this->set_cache($subscription->transaction_id, $subscription->id, 'getpaid_subscription_transaction_ids_to_subscription_ids'); |
|
| 407 | + $this->set_cache($subscription->transaction_id, $subscription->id, 'getpaid_subscription_transaction_ids_to_subscription_ids'); |
|
| 408 | + $this->results[$key] = new WPInv_Subscription($subscription); |
|
| 409 | 409 | } |
| 410 | 410 | } |
| 411 | 411 | |
@@ -420,13 +420,13 @@ discard block |
||
| 420 | 420 | * @param integer $expire |
| 421 | 421 | * @return boolean |
| 422 | 422 | */ |
| 423 | - public function set_cache( $key, $data, $group = '', $expire = 0 ) { |
|
| 423 | + public function set_cache($key, $data, $group = '', $expire = 0) { |
|
| 424 | 424 | |
| 425 | - if ( empty( $key ) ) { |
|
| 425 | + if (empty($key)) { |
|
| 426 | 426 | return false; |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - wp_cache_set( $key, $data, $group, $expire ); |
|
| 429 | + wp_cache_set($key, $data, $group, $expire); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | /** |
@@ -437,9 +437,9 @@ discard block |
||
| 437 | 437 | * @param string $query_var Query variable key. |
| 438 | 438 | * @return mixed |
| 439 | 439 | */ |
| 440 | - public function get( $query_var ) { |
|
| 441 | - if ( isset( $this->query_vars[ $query_var ] ) ) { |
|
| 442 | - return $this->query_vars[ $query_var ]; |
|
| 440 | + public function get($query_var) { |
|
| 441 | + if (isset($this->query_vars[$query_var])) { |
|
| 442 | + return $this->query_vars[$query_var]; |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | return null; |
@@ -453,8 +453,8 @@ discard block |
||
| 453 | 453 | * @param string $query_var Query variable key. |
| 454 | 454 | * @param mixed $value Query variable value. |
| 455 | 455 | */ |
| 456 | - public function set( $query_var, $value ) { |
|
| 457 | - $this->query_vars[ $query_var ] = $value; |
|
| 456 | + public function set($query_var, $value) { |
|
| 457 | + $this->query_vars[$query_var] = $value; |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | /** |
@@ -488,16 +488,16 @@ discard block |
||
| 488 | 488 | * @param string $table The current table. |
| 489 | 489 | * @return string Value to use in the ORDER clause, if `$orderby` is valid. |
| 490 | 490 | */ |
| 491 | - protected function parse_orderby( $orderby, $table ) { |
|
| 491 | + protected function parse_orderby($orderby, $table) { |
|
| 492 | 492 | |
| 493 | 493 | $_orderby = ''; |
| 494 | - if ( in_array( $orderby, array( 'customer_id', 'frequency', 'period', 'initial_amount', 'recurring_amount', 'bill_times', 'transaction_id', 'parent_payment_id', 'product_id', 'created', 'expiration', 'trial_period', 'status', 'profile_id' ) ) ) { |
|
| 494 | + if (in_array($orderby, array('customer_id', 'frequency', 'period', 'initial_amount', 'recurring_amount', 'bill_times', 'transaction_id', 'parent_payment_id', 'product_id', 'created', 'expiration', 'trial_period', 'status', 'profile_id'))) { |
|
| 495 | 495 | $_orderby = "$table.`$orderby`"; |
| 496 | - } elseif ( 'id' === strtolower( $orderby ) ) { |
|
| 496 | + } elseif ('id' === strtolower($orderby)) { |
|
| 497 | 497 | $_orderby = "$table.id"; |
| 498 | - } elseif ( 'include' === $orderby && ! empty( $this->query_vars['include'] ) ) { |
|
| 499 | - $include = wp_parse_id_list( $this->query_vars['include'] ); |
|
| 500 | - $include_sql = implode( ',', $include ); |
|
| 498 | + } elseif ('include' === $orderby && !empty($this->query_vars['include'])) { |
|
| 499 | + $include = wp_parse_id_list($this->query_vars['include']); |
|
| 500 | + $include_sql = implode(',', $include); |
|
| 501 | 501 | $_orderby = "FIELD( $table.id, $include_sql )"; |
| 502 | 502 | } |
| 503 | 503 | |
@@ -512,12 +512,12 @@ discard block |
||
| 512 | 512 | * @param string $order The 'order' query variable. |
| 513 | 513 | * @return string The sanitized 'order' query variable. |
| 514 | 514 | */ |
| 515 | - protected function parse_order( $order ) { |
|
| 516 | - if ( ! is_string( $order ) || empty( $order ) ) { |
|
| 515 | + protected function parse_order($order) { |
|
| 516 | + if (!is_string($order) || empty($order)) { |
|
| 517 | 517 | return 'DESC'; |
| 518 | 518 | } |
| 519 | 519 | |
| 520 | - if ( 'ASC' === strtoupper( $order ) ) { |
|
| 520 | + if ('ASC' === strtoupper($order)) { |
|
| 521 | 521 | return 'ASC'; |
| 522 | 522 | } else { |
| 523 | 523 | return 'DESC'; |
@@ -9,9 +9,9 @@ discard block |
||
| 9 | 9 | * @var array $fee |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -defined( 'ABSPATH' ) || exit; |
|
| 12 | +defined('ABSPATH') || exit; |
|
| 13 | 13 | |
| 14 | -do_action( 'getpaid_before_invoice_fee_item', $invoice, $fee ); |
|
| 14 | +do_action('getpaid_before_invoice_fee_item', $invoice, $fee); |
|
| 15 | 15 | |
| 16 | 16 | ?> |
| 17 | 17 | |
@@ -19,64 +19,64 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | <div class="form-row row"> |
| 21 | 21 | |
| 22 | - <?php foreach ( array_keys( $columns ) as $column ) : ?> |
|
| 22 | + <?php foreach (array_keys($columns) as $column) : ?> |
|
| 23 | 23 | |
| 24 | - <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm'; ?> getpaid-invoice-item-<?php echo esc_attr( $column ); ?>"> |
|
| 24 | + <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm'; ?> getpaid-invoice-item-<?php echo esc_attr($column); ?>"> |
|
| 25 | 25 | |
| 26 | 26 | <?php |
| 27 | 27 | |
| 28 | 28 | // Fires before printing a fee item column. |
| 29 | - do_action( "getpaid_invoice_fee_item_before_$column", $fee, $invoice ); |
|
| 29 | + do_action("getpaid_invoice_fee_item_before_$column", $fee, $invoice); |
|
| 30 | 30 | |
| 31 | 31 | // Item name. |
| 32 | - if ( 'name' == $column ) { |
|
| 32 | + if ('name' == $column) { |
|
| 33 | 33 | |
| 34 | 34 | // Display the name. |
| 35 | - echo '<div class="mb-1">' . esc_html( $fee['name'] ) . '</div>'; |
|
| 35 | + echo '<div class="mb-1">' . esc_html($fee['name']) . '</div>'; |
|
| 36 | 36 | |
| 37 | 37 | // And an optional description. |
| 38 | - $description = empty( $fee['description'] ) ? esc_html__( 'Fee', 'invoicing' ) : esc_html( $fee['description'] ); |
|
| 39 | - echo wp_kses_post( "<small class='form-text text-muted pr-2 m-0'>$description</small>" ); |
|
| 38 | + $description = empty($fee['description']) ? esc_html__('Fee', 'invoicing') : esc_html($fee['description']); |
|
| 39 | + echo wp_kses_post("<small class='form-text text-muted pr-2 m-0'>$description</small>"); |
|
| 40 | 40 | |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // Item price. |
| 44 | - if ( 'price' == $column ) { |
|
| 44 | + if ('price' == $column) { |
|
| 45 | 45 | |
| 46 | 46 | // Display the item price (or recurring price if this is a renewal invoice) |
| 47 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
| 48 | - wpinv_the_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
| 47 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
| 48 | + wpinv_the_price($fee['recurring_fee'], $invoice->get_currency()); |
|
| 49 | 49 | } else { |
| 50 | - wpinv_the_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
| 50 | + wpinv_the_price($fee['initial_fee'], $invoice->get_currency()); |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // Item quantity. |
| 55 | - if ( 'quantity' == $column ) { |
|
| 55 | + if ('quantity' == $column) { |
|
| 56 | 56 | echo '—'; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | // Item tax. |
| 60 | - if ( 'tax_rate' == $column ) { |
|
| 60 | + if ('tax_rate' == $column) { |
|
| 61 | 61 | echo '—'; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // Item sub total. |
| 65 | - if ( 'subtotal' == $column ) { |
|
| 65 | + if ('subtotal' == $column) { |
|
| 66 | 66 | |
| 67 | 67 | // Display the item price (or recurring price if this is a renewal invoice) |
| 68 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
| 69 | - wpinv_the_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
| 68 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
| 69 | + wpinv_the_price($fee['recurring_fee'], $invoice->get_currency()); |
|
| 70 | 70 | } else { |
| 71 | - wpinv_the_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
| 71 | + wpinv_the_price($fee['initial_fee'], $invoice->get_currency()); |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | // Fires when printing a fee item column. |
| 76 | - do_action( "getpaid_invoice_fee_item_$column", $fee, $invoice ); |
|
| 76 | + do_action("getpaid_invoice_fee_item_$column", $fee, $invoice); |
|
| 77 | 77 | |
| 78 | 78 | // Fires after printing a fee item column. |
| 79 | - do_action( "getpaid_invoice_fee_item_after_$column", $fee, $invoice ); |
|
| 79 | + do_action("getpaid_invoice_fee_item_after_$column", $fee, $invoice); |
|
| 80 | 80 | |
| 81 | 81 | ?> |
| 82 | 82 | |
@@ -10,104 +10,104 @@ |
||
| 10 | 10 | * @var array $columns |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | -defined( 'ABSPATH' ) || exit; |
|
| 13 | +defined('ABSPATH') || exit; |
|
| 14 | 14 | |
| 15 | -do_action( 'getpaid_before_invoice_line_item', $invoice, $item ); |
|
| 15 | +do_action('getpaid_before_invoice_line_item', $invoice, $item); |
|
| 16 | 16 | |
| 17 | 17 | ?> |
| 18 | 18 | |
| 19 | -<div class='getpaid-invoice-item item-<?php echo (int) $item->get_id(); ?> item-type-<?php echo esc_attr( $item->get_type() ); ?> border-bottom'> |
|
| 19 | +<div class='getpaid-invoice-item item-<?php echo (int) $item->get_id(); ?> item-type-<?php echo esc_attr($item->get_type()); ?> border-bottom'> |
|
| 20 | 20 | |
| 21 | 21 | <div class="form-row row align-items-center"> |
| 22 | 22 | |
| 23 | - <?php foreach ( array_keys( $columns ) as $column ) : ?> |
|
| 23 | + <?php foreach (array_keys($columns) as $column) : ?> |
|
| 24 | 24 | |
| 25 | - <div class="<?php echo 'name' === $column ? 'col-12 col-sm-6' : 'col-12 col-sm'; ?> getpaid-invoice-item-<?php echo esc_attr( $column ); ?>"> |
|
| 25 | + <div class="<?php echo 'name' === $column ? 'col-12 col-sm-6' : 'col-12 col-sm'; ?> getpaid-invoice-item-<?php echo esc_attr($column); ?>"> |
|
| 26 | 26 | |
| 27 | 27 | <?php |
| 28 | 28 | |
| 29 | 29 | // Fires before printing a line item column. |
| 30 | - do_action( "getpaid_invoice_line_item_before_$column", $item, $invoice ); |
|
| 30 | + do_action("getpaid_invoice_line_item_before_$column", $item, $invoice); |
|
| 31 | 31 | |
| 32 | 32 | // Item name. |
| 33 | - if ( 'name' === $column ) { |
|
| 33 | + if ('name' === $column) { |
|
| 34 | 34 | |
| 35 | - $has_featured_image = has_post_thumbnail( $item->get_id() ); |
|
| 35 | + $has_featured_image = has_post_thumbnail($item->get_id()); |
|
| 36 | 36 | |
| 37 | - if ( $has_featured_image ) { |
|
| 37 | + if ($has_featured_image) { |
|
| 38 | 38 | echo '<div class="d-flex align-items-center getpaid-form-item-has-featured-image">'; |
| 39 | 39 | echo '<div class="getpaid-form-item-image-container mr-2">'; |
| 40 | - echo get_the_post_thumbnail( $item->get_id(), 'thumbnail', array( 'class' => 'getpaid-form-item-image mb-0' ) ); |
|
| 40 | + echo get_the_post_thumbnail($item->get_id(), 'thumbnail', array('class' => 'getpaid-form-item-image mb-0')); |
|
| 41 | 41 | echo '</div>'; |
| 42 | 42 | echo '<div class="getpaid-form-item-name-container">'; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | // Display the name. |
| 46 | - echo '<div class="mb-1">' . esc_html( $item->get_name() ) . '</div>'; |
|
| 46 | + echo '<div class="mb-1">' . esc_html($item->get_name()) . '</div>'; |
|
| 47 | 47 | |
| 48 | 48 | // And an optional description. |
| 49 | 49 | $description = $item->get_description(); |
| 50 | 50 | |
| 51 | - if ( ! empty( $description ) ) { |
|
| 52 | - echo "<small class='form-text text-muted pr-2 m-0'>" . wp_kses_post( $description ) . '</small>'; |
|
| 51 | + if (!empty($description)) { |
|
| 52 | + echo "<small class='form-text text-muted pr-2 m-0'>" . wp_kses_post($description) . '</small>'; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | // Fires before printing the line item actions. |
| 56 | - do_action( 'getpaid_before_invoice_line_item_actions', $item, $invoice ); |
|
| 56 | + do_action('getpaid_before_invoice_line_item_actions', $item, $invoice); |
|
| 57 | 57 | |
| 58 | - $actions = apply_filters( 'getpaid-invoice-page-line-item-actions', array(), $item, $invoice ); |
|
| 58 | + $actions = apply_filters('getpaid-invoice-page-line-item-actions', array(), $item, $invoice); |
|
| 59 | 59 | |
| 60 | - if ( ! empty( $actions ) ) { |
|
| 60 | + if (!empty($actions)) { |
|
| 61 | 61 | |
| 62 | - $sanitized = array(); |
|
| 63 | - foreach ( $actions as $key => $item_action ) { |
|
| 64 | - $key = sanitize_html_class( $key ); |
|
| 65 | - $item_action = wp_kses_post( $item_action ); |
|
| 62 | + $sanitized = array(); |
|
| 63 | + foreach ($actions as $key => $item_action) { |
|
| 64 | + $key = sanitize_html_class($key); |
|
| 65 | + $item_action = wp_kses_post($item_action); |
|
| 66 | 66 | $sanitized[] = "<span class='$key'>$item_action</span>"; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | echo "<small class='form-text getpaid-line-item-actions'>"; |
| 70 | - echo wp_kses_post( implode( ' | ', $sanitized ) ); |
|
| 70 | + echo wp_kses_post(implode(' | ', $sanitized)); |
|
| 71 | 71 | echo '</small>'; |
| 72 | 72 | |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if ( $has_featured_image ) { |
|
| 75 | + if ($has_featured_image) { |
|
| 76 | 76 | echo '</div>'; |
| 77 | 77 | echo '</div>'; |
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | // Item price. |
| 82 | - if ( 'price' === $column ) { |
|
| 82 | + if ('price' === $column) { |
|
| 83 | 83 | |
| 84 | 84 | // Display the item price (or recurring price if this is a renewal invoice) |
| 85 | 85 | $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
| 86 | - wpinv_the_price( $price, $invoice->get_currency() ); |
|
| 86 | + wpinv_the_price($price, $invoice->get_currency()); |
|
| 87 | 87 | |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | // Tax rate. |
| 91 | - if ( 'tax_rate' === $column ) { |
|
| 92 | - echo floatval( round( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%'; |
|
| 91 | + if ('tax_rate' === $column) { |
|
| 92 | + echo floatval(round(getpaid_get_invoice_tax_rate($invoice, $item), 2)) . '%'; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | // Item quantity. |
| 96 | - if ( 'quantity' === $column ) { |
|
| 96 | + if ('quantity' === $column) { |
|
| 97 | 97 | echo (float) $item->get_quantity(); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // Item sub total. |
| 101 | - if ( 'subtotal' === $column ) { |
|
| 101 | + if ('subtotal' === $column) { |
|
| 102 | 102 | $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total(); |
| 103 | - wpinv_the_price( $subtotal, $invoice->get_currency() ); |
|
| 103 | + wpinv_the_price($subtotal, $invoice->get_currency()); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | // Fires when printing a line item column. |
| 107 | - do_action( "getpaid_invoice_line_item_$column", $item, $invoice ); |
|
| 107 | + do_action("getpaid_invoice_line_item_$column", $item, $invoice); |
|
| 108 | 108 | |
| 109 | 109 | // Fires after printing a line item column. |
| 110 | - do_action( "getpaid_invoice_line_item_after_$column", $item, $invoice ); |
|
| 110 | + do_action("getpaid_invoice_line_item_after_$column", $item, $invoice); |
|
| 111 | 111 | |
| 112 | 112 | ?> |
| 113 | 113 | |
@@ -8,21 +8,21 @@ discard block |
||
| 8 | 8 | * @var WPInv_Invoice $invoice |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | 13 | ?> |
| 14 | 14 | |
| 15 | -<?php do_action( 'getpaid_invoice_before_line_items', $invoice ); ?> |
|
| 15 | +<?php do_action('getpaid_invoice_before_line_items', $invoice); ?> |
|
| 16 | 16 | |
| 17 | - <h2 class="mt-5 mb-1 h4"><?php echo sprintf( esc_html__( '%s Items', 'invoicing' ), esc_html( ucfirst( $invoice->get_invoice_quote_type() ) ) ); ?></h2> |
|
| 17 | + <h2 class="mt-5 mb-1 h4"><?php echo sprintf(esc_html__('%s Items', 'invoicing'), esc_html(ucfirst($invoice->get_invoice_quote_type()))); ?></h2> |
|
| 18 | 18 | <div class="getpaid-invoice-items mb-4 border"> |
| 19 | 19 | |
| 20 | 20 | |
| 21 | - <div class="getpaid-invoice-items-header <?php echo esc_attr( $invoice->get_template() ); ?>"> |
|
| 21 | + <div class="getpaid-invoice-items-header <?php echo esc_attr($invoice->get_template()); ?>"> |
|
| 22 | 22 | <div class="form-row row"> |
| 23 | - <?php foreach ( $columns as $key => $label ) : ?> |
|
| 24 | - <div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm'; ?> getpaid-invoice-line-item-col-<?php echo esc_attr( $key ); ?>"> |
|
| 25 | - <?php echo esc_html( $label ); ?> |
|
| 23 | + <?php foreach ($columns as $key => $label) : ?> |
|
| 24 | + <div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm'; ?> getpaid-invoice-line-item-col-<?php echo esc_attr($key); ?>"> |
|
| 25 | + <?php echo esc_html($label); ?> |
|
| 26 | 26 | </div> |
| 27 | 27 | <?php endforeach; ?> |
| 28 | 28 | </div> |
@@ -32,20 +32,20 @@ discard block |
||
| 32 | 32 | <?php |
| 33 | 33 | |
| 34 | 34 | // Display the item totals. |
| 35 | - foreach ( $invoice->get_items() as $item ) { |
|
| 36 | - wpinv_get_template( 'invoice/line-item.php', compact( 'invoice', 'item', 'columns' ) ); |
|
| 35 | + foreach ($invoice->get_items() as $item) { |
|
| 36 | + wpinv_get_template('invoice/line-item.php', compact('invoice', 'item', 'columns')); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | // Display the fee totals. |
| 40 | - foreach ( $invoice->get_fees() as $fee ) { |
|
| 41 | - wpinv_get_template( 'invoice/fee-item.php', compact( 'invoice', 'fee', 'columns' ) ); |
|
| 40 | + foreach ($invoice->get_fees() as $fee) { |
|
| 41 | + wpinv_get_template('invoice/fee-item.php', compact('invoice', 'fee', 'columns')); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | // Display the cart totals. |
| 45 | - wpinv_get_template( 'invoice/line-totals.php', compact( 'invoice' ) ); |
|
| 45 | + wpinv_get_template('invoice/line-totals.php', compact('invoice')); |
|
| 46 | 46 | |
| 47 | 47 | ?> |
| 48 | 48 | |
| 49 | 49 | </div> |
| 50 | 50 | |
| 51 | -<?php do_action( 'getpaid_invoice_after_line_items', $invoice ); ?> |
|
| 51 | +<?php do_action('getpaid_invoice_after_line_items', $invoice); ?> |
|
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 9 | +if (!defined('ABSPATH')) { |
|
| 10 | 10 | exit; // Exit if accessed directly |
| 11 | 11 | } |
| 12 | 12 | |
@@ -20,13 +20,13 @@ discard block |
||
| 20 | 20 | * |
| 21 | 21 | * @param WP_Post $post |
| 22 | 22 | */ |
| 23 | - public static function output( $post ) { |
|
| 23 | + public static function output($post) { |
|
| 24 | 24 | |
| 25 | 25 | // Retrieve shipping address. |
| 26 | - $shipping_address = get_post_meta( $post->ID, 'shipping_address', true ); |
|
| 26 | + $shipping_address = get_post_meta($post->ID, 'shipping_address', true); |
|
| 27 | 27 | |
| 28 | 28 | // Abort if it is invalid. |
| 29 | - if ( ! is_array( $shipping_address ) ) { |
|
| 29 | + if (!is_array($shipping_address)) { |
|
| 30 | 30 | return; |
| 31 | 31 | } |
| 32 | 32 | |
@@ -34,29 +34,29 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | <div class="bsui"> |
| 36 | 36 | |
| 37 | - <?php if ( ! empty( $shipping_address['method'] ) ) : ?> |
|
| 37 | + <?php if (!empty($shipping_address['method'])) : ?> |
|
| 38 | 38 | |
| 39 | 39 | <div class="form-group mb-3 form-row row" style="color: green;"> |
| 40 | 40 | <div class="col"> |
| 41 | - <span style="font-weight: 600"><?php esc_html_e( 'Shipping Method', 'invoicing' ); ?>:</span> |
|
| 41 | + <span style="font-weight: 600"><?php esc_html_e('Shipping Method', 'invoicing'); ?>:</span> |
|
| 42 | 42 | </div> |
| 43 | 43 | <div class="col"> |
| 44 | - <?php echo wp_kses_post( $shipping_address['method'] ); ?> |
|
| 44 | + <?php echo wp_kses_post($shipping_address['method']); ?> |
|
| 45 | 45 | </div> |
| 46 | 46 | </div> |
| 47 | 47 | |
| 48 | 48 | <?php endif; ?> |
| 49 | 49 | |
| 50 | - <?php foreach ( getpaid_user_address_fields() as $key => $label ) : ?> |
|
| 50 | + <?php foreach (getpaid_user_address_fields() as $key => $label) : ?> |
|
| 51 | 51 | |
| 52 | - <?php if ( ! empty( $shipping_address[ $key ] ) ) : ?> |
|
| 52 | + <?php if (!empty($shipping_address[$key])) : ?> |
|
| 53 | 53 | |
| 54 | 54 | <div class="form-group mb-3 form-row row"> |
| 55 | 55 | <div class="col"> |
| 56 | - <span style="font-weight: 600"><?php echo esc_html( $label ); ?>:</span> |
|
| 56 | + <span style="font-weight: 600"><?php echo esc_html($label); ?>:</span> |
|
| 57 | 57 | </div> |
| 58 | 58 | <div class="col"> |
| 59 | - <?php echo esc_html( self::prepare_for_display( $shipping_address, $key ) ); ?> |
|
| 59 | + <?php echo esc_html(self::prepare_for_display($shipping_address, $key)); ?> |
|
| 60 | 60 | </div> |
| 61 | 61 | </div> |
| 62 | 62 | |
@@ -77,21 +77,21 @@ discard block |
||
| 77 | 77 | * @param string $key |
| 78 | 78 | * @return string |
| 79 | 79 | */ |
| 80 | - public static function prepare_for_display( $address, $key ) { |
|
| 80 | + public static function prepare_for_display($address, $key) { |
|
| 81 | 81 | |
| 82 | 82 | // Prepare the value. |
| 83 | - $value = $address[ $key ]; |
|
| 83 | + $value = $address[$key]; |
|
| 84 | 84 | |
| 85 | - if ( $key == 'country' ) { |
|
| 86 | - $value = wpinv_country_name( $value ); |
|
| 85 | + if ($key == 'country') { |
|
| 86 | + $value = wpinv_country_name($value); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if ( $key == 'state' ) { |
|
| 90 | - $country = isset( $address['country'] ) ? $address['country'] : wpinv_get_default_country(); |
|
| 91 | - $value = wpinv_state_name( $value, $country ); |
|
| 89 | + if ($key == 'state') { |
|
| 90 | + $country = isset($address['country']) ? $address['country'] : wpinv_get_default_country(); |
|
| 91 | + $value = wpinv_state_name($value, $country); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - return esc_html( $value ); |
|
| 94 | + return esc_html($value); |
|
| 95 | 95 | |
| 96 | 96 | } |
| 97 | 97 | |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 10 | +if (!defined('ABSPATH')) { |
|
| 11 | 11 | exit; // Exit if accessed directly |
| 12 | 12 | } |
| 13 | 13 | |
@@ -21,13 +21,13 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @param WP_Post $post |
| 23 | 23 | */ |
| 24 | - public static function output( $post ) { |
|
| 24 | + public static function output($post) { |
|
| 25 | 25 | |
| 26 | 26 | // Prepare the invoice. |
| 27 | - $invoice = new WPInv_Invoice( $post ); |
|
| 27 | + $invoice = new WPInv_Invoice($post); |
|
| 28 | 28 | |
| 29 | 29 | // Nonce field. |
| 30 | - wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ); |
|
| 30 | + wp_nonce_field('wpinv_details', 'wpinv_details_nonce'); |
|
| 31 | 31 | |
| 32 | 32 | ?> |
| 33 | 33 | |
@@ -45,11 +45,11 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | <div class="bsui" style="margin-top: 1.5rem"> |
| 47 | 47 | |
| 48 | - <?php do_action( 'getpaid_invoice_edit_before_viewed_by_customer', $invoice ); ?> |
|
| 49 | - <?php if ( ! $invoice->is_draft() ) : ?> |
|
| 48 | + <?php do_action('getpaid_invoice_edit_before_viewed_by_customer', $invoice); ?> |
|
| 49 | + <?php if (!$invoice->is_draft()) : ?> |
|
| 50 | 50 | <div class="form-group mb-3"> |
| 51 | - <strong><?php esc_html_e( 'Viewed by Customer:', 'invoicing' ); ?></strong> |
|
| 52 | - <?php ( $invoice->get_is_viewed() ) ? esc_html_e( 'Yes', 'invoicing' ) : esc_html_e( 'No', 'invoicing' ); ?> |
|
| 51 | + <strong><?php esc_html_e('Viewed by Customer:', 'invoicing'); ?></strong> |
|
| 52 | + <?php ($invoice->get_is_viewed()) ? esc_html_e('Yes', 'invoicing') : esc_html_e('No', 'invoicing'); ?> |
|
| 53 | 53 | </div> |
| 54 | 54 | <?php endif; ?> |
| 55 | 55 | |
@@ -58,14 +58,14 @@ discard block |
||
| 58 | 58 | // Date created. |
| 59 | 59 | $label = sprintf( |
| 60 | 60 | // translators: %s is the invoice type. |
| 61 | - __( '%s Date:', 'invoicing' ), |
|
| 62 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 61 | + __('%s Date:', 'invoicing'), |
|
| 62 | + ucfirst($invoice->get_invoice_quote_type()) |
|
| 63 | 63 | ); |
| 64 | 64 | |
| 65 | - $info = sprintf( |
|
| 65 | + $info = sprintf( |
|
| 66 | 66 | // translators: %s is the invoice type. |
| 67 | - __( 'The date this %s was created.', 'invoicing' ), |
|
| 68 | - strtolower( $invoice->get_invoice_quote_type() ) |
|
| 67 | + __('The date this %s was created.', 'invoicing'), |
|
| 68 | + strtolower($invoice->get_invoice_quote_type()) |
|
| 69 | 69 | ); |
| 70 | 70 | |
| 71 | 71 | aui()->input( |
@@ -73,11 +73,11 @@ discard block |
||
| 73 | 73 | 'type' => 'datepicker', |
| 74 | 74 | 'id' => 'wpinv_date_created', |
| 75 | 75 | 'name' => 'date_created', |
| 76 | - 'label' => $label . getpaid_get_help_tip( $info ), |
|
| 76 | + 'label' => $label . getpaid_get_help_tip($info), |
|
| 77 | 77 | 'label_type' => 'vertical', |
| 78 | 78 | 'placeholder' => 'YYYY-MM-DD 00:00', |
| 79 | 79 | 'class' => 'form-control-sm', |
| 80 | - 'value' => $invoice->get_date_created( 'edit' ), |
|
| 80 | + 'value' => $invoice->get_date_created('edit'), |
|
| 81 | 81 | 'extra_attributes' => array( |
| 82 | 82 | 'data-enable-time' => 'true', |
| 83 | 83 | 'data-time_24hr' => 'true', |
@@ -94,28 +94,28 @@ discard block |
||
| 94 | 94 | 'type' => 'text', |
| 95 | 95 | 'id' => 'wpinv_date_completed', |
| 96 | 96 | 'name' => 'wpinv_date_completed', |
| 97 | - 'label' => __( 'Date Completed:', 'invoicing' ), |
|
| 97 | + 'label' => __('Date Completed:', 'invoicing'), |
|
| 98 | 98 | 'label_type' => 'vertical', |
| 99 | 99 | 'class' => 'form-control-sm', |
| 100 | - 'value' => $invoice->get_date_completed( 'edit' ), |
|
| 100 | + 'value' => $invoice->get_date_completed('edit'), |
|
| 101 | 101 | 'placeholder' => 'YYYY-MM-DD 00:00', |
| 102 | 102 | ), |
| 103 | 103 | true |
| 104 | 104 | ); |
| 105 | 105 | |
| 106 | 106 | // Due date. |
| 107 | - if ( $invoice->is_type( 'invoice' ) && wpinv_get_option( 'overdue_active' ) && ( ! $invoice->is_paid() || $invoice->is_draft() ) ) { |
|
| 107 | + if ($invoice->is_type('invoice') && wpinv_get_option('overdue_active') && (!$invoice->is_paid() || $invoice->is_draft())) { |
|
| 108 | 108 | |
| 109 | 109 | aui()->input( |
| 110 | 110 | array( |
| 111 | 111 | 'type' => 'datepicker', |
| 112 | 112 | 'id' => 'wpinv_due_date', |
| 113 | 113 | 'name' => 'wpinv_due_date', |
| 114 | - 'label' => __( 'Due Date:', 'invoicing' ) . getpaid_get_help_tip( __( 'Leave blank to disable automated reminder emails for this invoice.', 'invoicing' ) ), |
|
| 114 | + 'label' => __('Due Date:', 'invoicing') . getpaid_get_help_tip(__('Leave blank to disable automated reminder emails for this invoice.', 'invoicing')), |
|
| 115 | 115 | 'label_type' => 'vertical', |
| 116 | - 'placeholder' => __( 'No due date', 'invoicing' ), |
|
| 116 | + 'placeholder' => __('No due date', 'invoicing'), |
|
| 117 | 117 | 'class' => 'form-control-sm', |
| 118 | - 'value' => $invoice->get_due_date( 'edit' ), |
|
| 118 | + 'value' => $invoice->get_due_date('edit'), |
|
| 119 | 119 | 'extra_attributes' => array( |
| 120 | 120 | 'data-enable-time' => 'true', |
| 121 | 121 | 'data-time_24hr' => 'true', |
@@ -128,28 +128,28 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - do_action( 'wpinv_meta_box_details_after_due_date', $invoice->get_id() ); |
|
| 132 | - do_action( 'getpaid_metabox_after_due_date', $invoice ); |
|
| 131 | + do_action('wpinv_meta_box_details_after_due_date', $invoice->get_id()); |
|
| 132 | + do_action('getpaid_metabox_after_due_date', $invoice); |
|
| 133 | 133 | |
| 134 | 134 | // Status. |
| 135 | 135 | $label = sprintf( |
| 136 | 136 | // translators: %s: Invoice type. |
| 137 | - __( '%s Status:', 'invoicing' ), |
|
| 138 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 137 | + __('%s Status:', 'invoicing'), |
|
| 138 | + ucfirst($invoice->get_invoice_quote_type()) |
|
| 139 | 139 | ); |
| 140 | 140 | |
| 141 | - $status = $invoice->get_status( 'edit' ); |
|
| 141 | + $status = $invoice->get_status('edit'); |
|
| 142 | 142 | aui()->select( |
| 143 | 143 | array( |
| 144 | 144 | 'id' => 'wpinv_status', |
| 145 | 145 | 'name' => 'wpinv_status', |
| 146 | 146 | 'label' => $label, |
| 147 | 147 | 'label_type' => 'vertical', |
| 148 | - 'placeholder' => __( 'Select Status', 'invoicing' ), |
|
| 149 | - 'value' => array_key_exists( $status, $invoice->get_all_statuses() ) ? $status : $invoice->get_default_status(), |
|
| 148 | + 'placeholder' => __('Select Status', 'invoicing'), |
|
| 149 | + 'value' => array_key_exists($status, $invoice->get_all_statuses()) ? $status : $invoice->get_default_status(), |
|
| 150 | 150 | 'select2' => true, |
| 151 | 151 | 'data-allow-clear' => 'false', |
| 152 | - 'options' => wpinv_get_invoice_statuses( true, false, $invoice ), |
|
| 152 | + 'options' => wpinv_get_invoice_statuses(true, false, $invoice), |
|
| 153 | 153 | ), |
| 154 | 154 | true |
| 155 | 155 | ); |
@@ -157,14 +157,14 @@ discard block |
||
| 157 | 157 | // Invoice number. |
| 158 | 158 | $label = sprintf( |
| 159 | 159 | // translators: %s: Invoice type. |
| 160 | - __( '%s Number:', 'invoicing' ), |
|
| 161 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 160 | + __('%s Number:', 'invoicing'), |
|
| 161 | + ucfirst($invoice->get_invoice_quote_type()) |
|
| 162 | 162 | ); |
| 163 | 163 | |
| 164 | - $info = sprintf( |
|
| 164 | + $info = sprintf( |
|
| 165 | 165 | // translators: %s: Invoice type. |
| 166 | - __( 'Each %s number must be unique.', 'invoicing' ), |
|
| 167 | - strtolower( $invoice->get_invoice_quote_type() ) |
|
| 166 | + __('Each %s number must be unique.', 'invoicing'), |
|
| 167 | + strtolower($invoice->get_invoice_quote_type()) |
|
| 168 | 168 | ); |
| 169 | 169 | |
| 170 | 170 | aui()->input( |
@@ -172,11 +172,11 @@ discard block |
||
| 172 | 172 | 'type' => 'text', |
| 173 | 173 | 'id' => 'wpinv_number', |
| 174 | 174 | 'name' => 'wpinv_number', |
| 175 | - 'label' => $label . getpaid_get_help_tip( $info ), |
|
| 175 | + 'label' => $label . getpaid_get_help_tip($info), |
|
| 176 | 176 | 'label_type' => 'vertical', |
| 177 | - 'placeholder' => __( 'Autogenerate', 'invoicing' ), |
|
| 177 | + 'placeholder' => __('Autogenerate', 'invoicing'), |
|
| 178 | 178 | 'class' => 'form-control-sm', |
| 179 | - 'value' => $invoice->get_number( 'edit' ), |
|
| 179 | + 'value' => $invoice->get_number('edit'), |
|
| 180 | 180 | ), |
| 181 | 181 | true |
| 182 | 182 | ); |
@@ -187,16 +187,16 @@ discard block |
||
| 187 | 187 | 'type' => 'text', |
| 188 | 188 | 'id' => 'wpinv_cc', |
| 189 | 189 | 'name' => 'wpinv_cc', |
| 190 | - 'label' => __( 'Email CC:', 'invoicing' ) . getpaid_get_help_tip( __( 'Enter a comma separated list of other emails that should be notified about the invoice.', 'invoicing' ) ), |
|
| 190 | + 'label' => __('Email CC:', 'invoicing') . getpaid_get_help_tip(__('Enter a comma separated list of other emails that should be notified about the invoice.', 'invoicing')), |
|
| 191 | 191 | 'label_type' => 'vertical', |
| 192 | - 'placeholder' => __( '[email protected], [email protected]', 'invoicing' ), |
|
| 192 | + 'placeholder' => __('[email protected], [email protected]', 'invoicing'), |
|
| 193 | 193 | 'class' => 'form-control-sm', |
| 194 | - 'value' => $invoice->get_email_cc( 'edit' ), |
|
| 194 | + 'value' => $invoice->get_email_cc('edit'), |
|
| 195 | 195 | ), |
| 196 | 196 | true |
| 197 | 197 | ); |
| 198 | 198 | |
| 199 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
| 199 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
| 200 | 200 | |
| 201 | 201 | // Apply a discount. |
| 202 | 202 | aui()->input( |
@@ -204,26 +204,26 @@ discard block |
||
| 204 | 204 | 'type' => 'text', |
| 205 | 205 | 'id' => 'wpinv_discount_code', |
| 206 | 206 | 'name' => 'wpinv_discount_code', |
| 207 | - 'label' => __( 'Discount Code:', 'invoicing' ), |
|
| 208 | - 'placeholder' => __( 'Apply Discount', 'invoicing' ), |
|
| 207 | + 'label' => __('Discount Code:', 'invoicing'), |
|
| 208 | + 'placeholder' => __('Apply Discount', 'invoicing'), |
|
| 209 | 209 | 'label_type' => 'vertical', |
| 210 | 210 | 'class' => 'form-control-sm getpaid-recalculate-prices-on-change', |
| 211 | - 'value' => $invoice->get_discount_code( 'edit' ), |
|
| 211 | + 'value' => $invoice->get_discount_code('edit'), |
|
| 212 | 212 | ), |
| 213 | 213 | true |
| 214 | 214 | ); |
| 215 | 215 | |
| 216 | - } elseif ( $invoice->get_discount_code( 'edit' ) ) { |
|
| 216 | + } elseif ($invoice->get_discount_code('edit')) { |
|
| 217 | 217 | |
| 218 | 218 | aui()->input( |
| 219 | 219 | array( |
| 220 | 220 | 'type' => 'text', |
| 221 | 221 | 'id' => 'wpinv_discount_code', |
| 222 | 222 | 'name' => 'wpinv_discount_code', |
| 223 | - 'label' => __( 'Discount Code:', 'invoicing' ), |
|
| 223 | + 'label' => __('Discount Code:', 'invoicing'), |
|
| 224 | 224 | 'label_type' => 'vertical', |
| 225 | 225 | 'class' => 'form-control-sm', |
| 226 | - 'value' => $invoice->get_discount_code( 'edit' ), |
|
| 226 | + 'value' => $invoice->get_discount_code('edit'), |
|
| 227 | 227 | 'extra_attributes' => array( |
| 228 | 228 | 'onclick' => 'this.select();', |
| 229 | 229 | 'readonly' => 'true', |
@@ -234,17 +234,17 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - do_action( 'wpinv_meta_box_details_inner', $invoice->get_id() ); |
|
| 237 | + do_action('wpinv_meta_box_details_inner', $invoice->get_id()); |
|
| 238 | 238 | |
| 239 | 239 | // Disable taxes. |
| 240 | - if ( wpinv_use_taxes() && ! ( $invoice->is_paid() || $invoice->is_refunded() ) ) { |
|
| 240 | + if (wpinv_use_taxes() && !($invoice->is_paid() || $invoice->is_refunded())) { |
|
| 241 | 241 | |
| 242 | 242 | aui()->input( |
| 243 | 243 | array( |
| 244 | 244 | 'id' => 'wpinv_taxable', |
| 245 | 245 | 'name' => 'disable_taxes', |
| 246 | 246 | 'type' => 'checkbox', |
| 247 | - 'label' => __( 'Disable taxes', 'invoicing' ), |
|
| 247 | + 'label' => __('Disable taxes', 'invoicing'), |
|
| 248 | 248 | 'value' => '1', |
| 249 | 249 | 'checked' => (bool) $invoice->get_disable_taxes(), |
| 250 | 250 | 'class' => 'getpaid-recalculate-prices-on-change', |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - if ( $invoice->is_type( 'invoice' ) ) { |
|
| 257 | + if ($invoice->is_type('invoice')) { |
|
| 258 | 258 | |
| 259 | 259 | // Send to customer. |
| 260 | 260 | aui()->input( |
@@ -262,16 +262,16 @@ discard block |
||
| 262 | 262 | 'id' => 'wpinv_send_to_customer', |
| 263 | 263 | 'name' => 'send_to_customer', |
| 264 | 264 | 'type' => 'checkbox', |
| 265 | - 'label' => __( 'Send invoice to customer after saving', 'invoicing' ), |
|
| 265 | + 'label' => __('Send invoice to customer after saving', 'invoicing'), |
|
| 266 | 266 | 'value' => '1', |
| 267 | - 'checked' => $invoice->is_draft() && (bool) wpinv_get_option( 'email_user_invoice_active', true ), |
|
| 267 | + 'checked' => $invoice->is_draft() && (bool) wpinv_get_option('email_user_invoice_active', true), |
|
| 268 | 268 | ), |
| 269 | 269 | true |
| 270 | 270 | ); |
| 271 | 271 | |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - do_action( 'getpaid_metabox_after_invoice_details', $invoice ); |
|
| 274 | + do_action('getpaid_metabox_after_invoice_details', $invoice); |
|
| 275 | 275 | |
| 276 | 276 | ?> |
| 277 | 277 | |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 10 | +if (!defined('ABSPATH')) { |
|
| 11 | 11 | exit; // Exit if accessed directly |
| 12 | 12 | } |
| 13 | 13 | |
@@ -21,54 +21,54 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @param WP_Post $post |
| 23 | 23 | */ |
| 24 | - public static function output( $post ) { |
|
| 24 | + public static function output($post) { |
|
| 25 | 25 | |
| 26 | 26 | // Prepare the form. |
| 27 | - $form = new GetPaid_Payment_Form( $post ); |
|
| 27 | + $form = new GetPaid_Payment_Form($post); |
|
| 28 | 28 | |
| 29 | 29 | ?> |
| 30 | 30 | |
| 31 | 31 | <div class='bsui' style='padding-top: 10px;'> |
| 32 | - <?php do_action( 'wpinv_payment_form_before_info_metabox', $form ); ?> |
|
| 32 | + <?php do_action('wpinv_payment_form_before_info_metabox', $form); ?> |
|
| 33 | 33 | |
| 34 | 34 | <div class="wpinv_payment_form_shortcode form-group mb-3 row"> |
| 35 | 35 | <label for="wpinv_payment_form_shortcode" class="col-sm-12 col-form-label"> |
| 36 | - <?php esc_html_e( 'Payment Form Shortcode', 'invoicing' ); ?> |
|
| 37 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a payment form', 'invoicing' ); ?>"></span> |
|
| 36 | + <?php esc_html_e('Payment Form Shortcode', 'invoicing'); ?> |
|
| 37 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a payment form', 'invoicing'); ?>"></span> |
|
| 38 | 38 | </label> |
| 39 | 39 | |
| 40 | 40 | <div class="col-sm-12"> |
| 41 | - <input onClick="this.select()" type="text" id="wpinv_payment_form_shortcode" value="[getpaid form=<?php echo esc_attr( $form->get_id() ); ?>]" style="width: 100%;" /> |
|
| 41 | + <input onClick="this.select()" type="text" id="wpinv_payment_form_shortcode" value="[getpaid form=<?php echo esc_attr($form->get_id()); ?>]" style="width: 100%;" /> |
|
| 42 | 42 | </div> |
| 43 | 43 | </div> |
| 44 | 44 | |
| 45 | 45 | <div class="wpinv_payment_form_buy_shortcode form-group mb-3 row"> |
| 46 | 46 | <label for="wpinv_payment_form_buy_shortcode" class="col-sm-12 col-form-label"> |
| 47 | - <?php esc_html_e( 'Payment Button Shortcode', 'invoicing' ); ?> |
|
| 48 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a buy now button', 'invoicing' ); ?>"></span> |
|
| 47 | + <?php esc_html_e('Payment Button Shortcode', 'invoicing'); ?> |
|
| 48 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a buy now button', 'invoicing'); ?>"></span> |
|
| 49 | 49 | </label> |
| 50 | 50 | |
| 51 | 51 | <div class="col-sm-12"> |
| 52 | - <input onClick="this.select()" type="text" id="wpinv_payment_form_buy_shortcode" value="[getpaid form=<?php echo esc_attr( $form->get_id() ); ?> button='Buy Now']" style="width: 100%;" /> |
|
| 52 | + <input onClick="this.select()" type="text" id="wpinv_payment_form_buy_shortcode" value="[getpaid form=<?php echo esc_attr($form->get_id()); ?> button='Buy Now']" style="width: 100%;" /> |
|
| 53 | 53 | <small class="form-text text-muted"> |
| 54 | - <?php esc_html_e( 'Or use the following URL in a link:', 'invoicing' ); ?> |
|
| 55 | - <code>#getpaid-form-<?php echo intval( $form->get_id() ); ?></code> |
|
| 54 | + <?php esc_html_e('Or use the following URL in a link:', 'invoicing'); ?> |
|
| 55 | + <code>#getpaid-form-<?php echo intval($form->get_id()); ?></code> |
|
| 56 | 56 | </small> |
| 57 | 57 | </div> |
| 58 | 58 | </div> |
| 59 | 59 | |
| 60 | 60 | <div class="wpinv_item_buy_url form-group row mb-3"> |
| 61 | 61 | <label for="wpinv_item_buy_url" class="col-sm-12 col-form-label"> |
| 62 | - <?php esc_html_e( 'Direct Payment URL', 'invoicing' ); ?> |
|
| 63 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'You can use this in an iFrame to embed the payment form on another website', 'invoicing' ); ?>"></span> |
|
| 62 | + <?php esc_html_e('Direct Payment URL', 'invoicing'); ?> |
|
| 63 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('You can use this in an iFrame to embed the payment form on another website', 'invoicing'); ?>"></span> |
|
| 64 | 64 | </label> |
| 65 | 65 | |
| 66 | 66 | <div class="col-sm-12"> |
| 67 | - <input onClick="this.select()" type="text" id="wpinv_item_buy_url" value="<?php echo esc_url( getpaid_embed_url( $form->get_id(), false ) ); ?>" style="width: 100%;" readonly/> |
|
| 67 | + <input onClick="this.select()" type="text" id="wpinv_item_buy_url" value="<?php echo esc_url(getpaid_embed_url($form->get_id(), false)); ?>" style="width: 100%;" readonly/> |
|
| 68 | 68 | </div> |
| 69 | 69 | </div> |
| 70 | 70 | |
| 71 | - <?php do_action( 'wpinv_payment_form_info_metabox', $form ); ?> |
|
| 71 | + <?php do_action('wpinv_payment_form_info_metabox', $form); ?> |
|
| 72 | 72 | </div> |
| 73 | 73 | <?php |
| 74 | 74 | |