@@ -126,25 +126,25 @@ |
||
| 126 | 126 | |
| 127 | 127 | if ( ! empty( $invoice_actions ) ) { |
| 128 | 128 | |
| 129 | - echo '<div class="wpinv-receipt-actions text-right mt-1 mb-4">'; |
|
| 129 | + echo '<div class="wpinv-receipt-actions text-right mt-1 mb-4">'; |
|
| 130 | 130 | |
| 131 | - foreach ( $invoice_actions as $key => $invoice_action ) { |
|
| 131 | + foreach ( $invoice_actions as $key => $invoice_action ) { |
|
| 132 | 132 | |
| 133 | - $key = sanitize_html_class( $key ); |
|
| 134 | - $class = empty( $invoice_action['class'] ) ? 'btn-dark' : sanitize_html_class( $invoice_action['class'] ); |
|
| 135 | - $url = empty( $invoice_action['url'] ) ? '#' : esc_url( $invoice_action['url'] ); |
|
| 136 | - $attrs = empty( $invoice_action['attrs'] ) ? '' : $invoice_action['attrs']; |
|
| 137 | - $anchor = esc_html( $invoice_action['name'] ); |
|
| 133 | + $key = sanitize_html_class( $key ); |
|
| 134 | + $class = empty( $invoice_action['class'] ) ? 'btn-dark' : sanitize_html_class( $invoice_action['class'] ); |
|
| 135 | + $url = empty( $invoice_action['url'] ) ? '#' : esc_url( $invoice_action['url'] ); |
|
| 136 | + $attrs = empty( $invoice_action['attrs'] ) ? '' : $invoice_action['attrs']; |
|
| 137 | + $anchor = esc_html( $invoice_action['name'] ); |
|
| 138 | 138 | |
| 139 | - echo wp_kses_post( "<a href='$url' class='btn btn-sm ml-1 $class $key' $attrs>$anchor</a>" ); |
|
| 139 | + echo wp_kses_post( "<a href='$url' class='btn btn-sm ml-1 $class $key' $attrs>$anchor</a>" ); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - echo '</div>'; |
|
| 142 | + echo '</div>'; |
|
| 143 | 143 | |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | if ( ! empty( $alert ) ) { |
| 147 | - echo wp_kses_post( $alert ); |
|
| 147 | + echo wp_kses_post( $alert ); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | ?> |
@@ -7,64 +7,64 @@ 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 | -} elseif ( $invoice->is_refunded() ) { |
|
| 31 | +} elseif ($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 | -} elseif ( $invoice->is_held() ) { |
|
| 40 | +} elseif ($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 | -} elseif ( $invoice->needs_payment() ) { |
|
| 49 | +} elseif ($invoice->needs_payment()) { |
|
| 50 | 50 | |
| 51 | - if ( ! empty( $_GET['token'] ) ) { |
|
| 51 | + if (!empty($_GET['token'])) { |
|
| 52 | 52 | |
| 53 | 53 | $alert = aui()->alert( |
| 54 | 54 | array( |
| 55 | 55 | 'type' => 'info', |
| 56 | - 'content' => __( "Sometimes it takes a few minutes for us to verify your payment. We'll notify you as soon as we've verified the payment.", 'invoicing' ), |
|
| 56 | + 'content' => __("Sometimes it takes a few minutes for us to verify your payment. We'll notify you as soon as we've verified the payment.", 'invoicing'), |
|
| 57 | 57 | ) |
| 58 | 58 | ); |
| 59 | 59 | |
| 60 | - } elseif ( $invoice->is_due() ) { |
|
| 60 | + } elseif ($invoice->is_due()) { |
|
| 61 | 61 | |
| 62 | 62 | $alert = aui()->alert( |
| 63 | 63 | array( |
| 64 | 64 | 'type' => 'danger', |
| 65 | 65 | 'content' => sprintf( |
| 66 | - __( 'This invoice was due on %.', 'invoicing' ), |
|
| 67 | - getpaid_format_date_value( $invoice->get_due_date() ) |
|
| 66 | + __('This invoice was due on %.', 'invoicing'), |
|
| 67 | + getpaid_format_date_value($invoice->get_due_date()) |
|
| 68 | 68 | ), |
| 69 | 69 | ) |
| 70 | 70 | ); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $alert = aui()->alert( |
| 75 | 75 | array( |
| 76 | 76 | 'type' => 'warning', |
| 77 | - 'content' => __( 'This invoice needs payment.', 'invoicing' ), |
|
| 77 | + 'content' => __('This invoice needs payment.', 'invoicing'), |
|
| 78 | 78 | ) |
| 79 | 79 | ); |
| 80 | 80 | |
@@ -88,19 +88,19 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | 'pay' => array( |
| 90 | 90 | 'url' => $invoice->get_checkout_payment_url(), |
| 91 | - 'name' => __( 'Pay For Invoice', 'invoicing' ), |
|
| 91 | + 'name' => __('Pay For Invoice', 'invoicing'), |
|
| 92 | 92 | 'class' => 'btn-success', |
| 93 | 93 | ), |
| 94 | 94 | |
| 95 | 95 | 'view' => array( |
| 96 | 96 | 'url' => $invoice->get_view_url(), |
| 97 | - 'name' => __( 'View Invoice', 'invoicing' ), |
|
| 97 | + 'name' => __('View Invoice', 'invoicing'), |
|
| 98 | 98 | 'class' => 'btn-primary', |
| 99 | 99 | ), |
| 100 | 100 | |
| 101 | 101 | 'history' => array( |
| 102 | 102 | 'url' => wpinv_get_history_page_uri(), |
| 103 | - 'name' => __( 'Invoice History', 'invoicing' ), |
|
| 103 | + 'name' => __('Invoice History', 'invoicing'), |
|
| 104 | 104 | 'class' => 'btn-warning', |
| 105 | 105 | ), |
| 106 | 106 | |
@@ -108,12 +108,12 @@ discard block |
||
| 108 | 108 | $invoice |
| 109 | 109 | ); |
| 110 | 110 | |
| 111 | -if ( ( ! $invoice->needs_payment() || $invoice->is_held() ) && isset( $invoice_actions['pay'] ) ) { |
|
| 112 | - unset( $invoice_actions['pay'] ); |
|
| 111 | +if ((!$invoice->needs_payment() || $invoice->is_held()) && isset($invoice_actions['pay'])) { |
|
| 112 | + unset($invoice_actions['pay']); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | -if ( ! is_user_logged_in() && isset( $invoice_actions['history'] ) ) { |
|
| 116 | - unset( $invoice_actions['history'] ); |
|
| 115 | +if (!is_user_logged_in() && isset($invoice_actions['history'])) { |
|
| 116 | + unset($invoice_actions['history']); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | ?> |
@@ -122,29 +122,29 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | <?php |
| 124 | 124 | |
| 125 | - do_action( 'wpinv_receipt_start', $invoice ); |
|
| 125 | + do_action('wpinv_receipt_start', $invoice); |
|
| 126 | 126 | |
| 127 | - if ( ! empty( $invoice_actions ) ) { |
|
| 127 | + if (!empty($invoice_actions)) { |
|
| 128 | 128 | |
| 129 | 129 | echo '<div class="wpinv-receipt-actions text-right mt-1 mb-4">'; |
| 130 | 130 | |
| 131 | - foreach ( $invoice_actions as $key => $invoice_action ) { |
|
| 131 | + foreach ($invoice_actions as $key => $invoice_action) { |
|
| 132 | 132 | |
| 133 | - $key = sanitize_html_class( $key ); |
|
| 134 | - $class = empty( $invoice_action['class'] ) ? 'btn-dark' : sanitize_html_class( $invoice_action['class'] ); |
|
| 135 | - $url = empty( $invoice_action['url'] ) ? '#' : esc_url( $invoice_action['url'] ); |
|
| 136 | - $attrs = empty( $invoice_action['attrs'] ) ? '' : $invoice_action['attrs']; |
|
| 137 | - $anchor = esc_html( $invoice_action['name'] ); |
|
| 133 | + $key = sanitize_html_class($key); |
|
| 134 | + $class = empty($invoice_action['class']) ? 'btn-dark' : sanitize_html_class($invoice_action['class']); |
|
| 135 | + $url = empty($invoice_action['url']) ? '#' : esc_url($invoice_action['url']); |
|
| 136 | + $attrs = empty($invoice_action['attrs']) ? '' : $invoice_action['attrs']; |
|
| 137 | + $anchor = esc_html($invoice_action['name']); |
|
| 138 | 138 | |
| 139 | - echo wp_kses_post( "<a href='$url' class='btn btn-sm ml-1 $class $key' $attrs>$anchor</a>" ); |
|
| 139 | + echo wp_kses_post("<a href='$url' class='btn btn-sm ml-1 $class $key' $attrs>$anchor</a>"); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | echo '</div>'; |
| 143 | 143 | |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - if ( ! empty( $alert ) ) { |
|
| 147 | - echo wp_kses_post( $alert ); |
|
| 146 | + if (!empty($alert)) { |
|
| 147 | + echo wp_kses_post($alert); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | ?> |
@@ -152,19 +152,19 @@ discard block |
||
| 152 | 152 | <div class="wpinv-receipt-details"> |
| 153 | 153 | |
| 154 | 154 | <h4 class="wpinv-details-t mb-3 mt-3"> |
| 155 | - <?php echo esc_html( apply_filters( 'wpinv_receipt_details_title', __( 'Invoice Details', 'invoicing' ), $invoice ) ); ?> |
|
| 155 | + <?php echo esc_html(apply_filters('wpinv_receipt_details_title', __('Invoice Details', 'invoicing'), $invoice)); ?> |
|
| 156 | 156 | </h4> |
| 157 | 157 | |
| 158 | - <?php getpaid_invoice_meta( $invoice ); ?> |
|
| 158 | + <?php getpaid_invoice_meta($invoice); ?> |
|
| 159 | 159 | |
| 160 | 160 | </div> |
| 161 | 161 | |
| 162 | - <?php do_action( 'wpinv_receipt_end', $invoice ); ?> |
|
| 162 | + <?php do_action('wpinv_receipt_end', $invoice); ?> |
|
| 163 | 163 | |
| 164 | 164 | </div> |
| 165 | 165 | |
| 166 | 166 | <?php |
| 167 | 167 | |
| 168 | 168 | // @deprecated |
| 169 | -do_action( 'wpinv_success_content_after', $invoice ); |
|
| 170 | -do_action( 'wpinv_after_receipt', $invoice ); |
|
| 169 | +do_action('wpinv_success_content_after', $invoice); |
|
| 170 | +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 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | private static $instance; |
| 16 | 16 | |
| 17 | 17 | public static function run() { |
| 18 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WPInv_Admin_Users ) ) { |
|
| 18 | + if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Admin_Users)) { |
|
| 19 | 19 | self::$instance = new WPInv_Admin_Users(); |
| 20 | 20 | } |
| 21 | 21 | |
@@ -23,8 +23,8 @@ discard block |
||
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function __construct() { |
| 26 | - add_filter( 'manage_users_columns', array( $this, 'wpinv_add_user_column' ) ); |
|
| 27 | - add_filter( 'manage_users_custom_column', array( $this, 'wpinv_user_column_content' ), 10, 3 ); |
|
| 26 | + add_filter('manage_users_columns', array($this, 'wpinv_add_user_column')); |
|
| 27 | + add_filter('manage_users_custom_column', array($this, 'wpinv_user_column_content'), 10, 3); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @return mixed |
| 36 | 36 | */ |
| 37 | - public function wpinv_add_user_column( $column ) { |
|
| 38 | - $column['wpinvoicing'] = __( 'Invoicing', 'invoicing' ); |
|
| 37 | + public function wpinv_add_user_column($column) { |
|
| 38 | + $column['wpinvoicing'] = __('Invoicing', 'invoicing'); |
|
| 39 | 39 | return $column; |
| 40 | 40 | } |
| 41 | 41 | |
@@ -48,10 +48,10 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @return string |
| 50 | 50 | */ |
| 51 | - public function wpinv_user_column_content( $val, $column_name, $user_id ) { |
|
| 52 | - switch ( $column_name ) { |
|
| 51 | + public function wpinv_user_column_content($val, $column_name, $user_id) { |
|
| 52 | + switch ($column_name) { |
|
| 53 | 53 | case 'wpinvoicing': |
| 54 | - return $this->get_user_invoices( $user_id ); |
|
| 54 | + return $this->get_user_invoices($user_id); |
|
| 55 | 55 | break; |
| 56 | 56 | default: |
| 57 | 57 | } |
@@ -65,30 +65,30 @@ discard block |
||
| 65 | 65 | * |
| 66 | 66 | * @return string |
| 67 | 67 | */ |
| 68 | - public function get_user_invoices( $user_id ) { |
|
| 68 | + public function get_user_invoices($user_id) { |
|
| 69 | 69 | $output = ''; |
| 70 | 70 | $wp_query_args = array( |
| 71 | 71 | 'post_type' => 'wpi_invoice', |
| 72 | - 'post_status' => array( 'wpi-pending', 'publish', 'wpi-processing', 'wpi-onhold', 'wpi-refunded', 'wpi-cancelled', 'wpi-failed', 'wpi-renewal' ), |
|
| 72 | + 'post_status' => array('wpi-pending', 'publish', 'wpi-processing', 'wpi-onhold', 'wpi-refunded', 'wpi-cancelled', 'wpi-failed', 'wpi-renewal'), |
|
| 73 | 73 | 'posts_per_page' => -1, |
| 74 | 74 | 'fields' => 'ids', |
| 75 | 75 | 'author' => $user_id, |
| 76 | 76 | ); |
| 77 | 77 | |
| 78 | - $wp_query_args = apply_filters( 'wpinv_get_user_invoices_args', $wp_query_args, $user_id ); |
|
| 78 | + $wp_query_args = apply_filters('wpinv_get_user_invoices_args', $wp_query_args, $user_id); |
|
| 79 | 79 | |
| 80 | - $invoices = new WP_Query( $wp_query_args ); |
|
| 81 | - $count = absint( $invoices->found_posts ); |
|
| 80 | + $invoices = new WP_Query($wp_query_args); |
|
| 81 | + $count = absint($invoices->found_posts); |
|
| 82 | 82 | |
| 83 | - if ( empty( $count ) ) { |
|
| 84 | - $output .= __( 'No Invoice(s)', 'invoicing' ); |
|
| 83 | + if (empty($count)) { |
|
| 84 | + $output .= __('No Invoice(s)', 'invoicing'); |
|
| 85 | 85 | } else { |
| 86 | - $link_url = admin_url( 'edit.php?post_type=wpi_invoice&author=' . absint( $user_id ) ); |
|
| 87 | - $link_text = sprintf( __( 'Invoices ( %d )', 'invoicing' ), $count ); |
|
| 86 | + $link_url = admin_url('edit.php?post_type=wpi_invoice&author=' . absint($user_id)); |
|
| 87 | + $link_text = sprintf(__('Invoices ( %d )', 'invoicing'), $count); |
|
| 88 | 88 | $output .= "<a href='$link_url' >$link_text</a>"; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - return apply_filters( 'wpinv_user_invoice_content', $output, $user_id ); |
|
| 91 | + return apply_filters('wpinv_user_invoice_content', $output, $user_id); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
| 141 | 141 | */ |
| 142 | 142 | function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
| 143 | - return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
| 143 | + return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @return string |
| 159 | 159 | */ |
| 160 | 160 | function wpinv_get_theme_template_dir_name() { |
| 161 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
| 161 | + return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -175,125 +175,125 @@ discard block |
||
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
| 178 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
| 178 | + do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
| 179 | 179 | |
| 180 | - // Setup possible parts |
|
| 181 | - $templates = array(); |
|
| 182 | - if ( isset( $name ) ) { |
|
| 183 | - $templates[] = $slug . '-' . $name . '.php'; |
|
| 180 | + // Setup possible parts |
|
| 181 | + $templates = array(); |
|
| 182 | + if ( isset( $name ) ) { |
|
| 183 | + $templates[] = $slug . '-' . $name . '.php'; |
|
| 184 | 184 | } |
| 185 | - $templates[] = $slug . '.php'; |
|
| 185 | + $templates[] = $slug . '.php'; |
|
| 186 | 186 | |
| 187 | - // Allow template parts to be filtered |
|
| 188 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
| 187 | + // Allow template parts to be filtered |
|
| 188 | + $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
| 189 | 189 | |
| 190 | - // Return the part that is found |
|
| 191 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
| 190 | + // Return the part that is found |
|
| 191 | + return wpinv_locate_tmpl( $templates, $load, false ); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
| 195 | - // No file found yet |
|
| 196 | - $located = false; |
|
| 195 | + // No file found yet |
|
| 196 | + $located = false; |
|
| 197 | 197 | |
| 198 | - // Try to find a template file |
|
| 199 | - foreach ( (array)$template_names as $template_name ) { |
|
| 198 | + // Try to find a template file |
|
| 199 | + foreach ( (array)$template_names as $template_name ) { |
|
| 200 | 200 | |
| 201 | - // Continue if template is empty |
|
| 202 | - if ( empty( $template_name ) ) { |
|
| 203 | - continue; |
|
| 201 | + // Continue if template is empty |
|
| 202 | + if ( empty( $template_name ) ) { |
|
| 203 | + continue; |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - // Trim off any slashes from the template name |
|
| 207 | - $template_name = ltrim( $template_name, '/' ); |
|
| 206 | + // Trim off any slashes from the template name |
|
| 207 | + $template_name = ltrim( $template_name, '/' ); |
|
| 208 | 208 | |
| 209 | - // try locating this template file by looping through the template paths |
|
| 210 | - foreach ( wpinv_get_theme_template_paths() as $template_path ) { |
|
| 209 | + // try locating this template file by looping through the template paths |
|
| 210 | + foreach ( wpinv_get_theme_template_paths() as $template_path ) { |
|
| 211 | 211 | |
| 212 | - if ( file_exists( $template_path . $template_name ) ) { |
|
| 213 | - $located = $template_path . $template_name; |
|
| 214 | - break; |
|
| 215 | - } |
|
| 216 | - } |
|
| 212 | + if ( file_exists( $template_path . $template_name ) ) { |
|
| 213 | + $located = $template_path . $template_name; |
|
| 214 | + break; |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - if ( ! empty( $located ) ) { |
|
| 219 | - break; |
|
| 220 | - } |
|
| 221 | - } |
|
| 218 | + if ( ! empty( $located ) ) { |
|
| 219 | + break; |
|
| 220 | + } |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | - if ( ( true == $load ) && ! empty( $located ) ) { |
|
| 224 | - load_template( $located, $require_once ); |
|
| 223 | + if ( ( true == $load ) && ! empty( $located ) ) { |
|
| 224 | + load_template( $located, $require_once ); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - return $located; |
|
| 227 | + return $located; |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | function wpinv_get_theme_template_paths() { |
| 231 | - $template_dir = wpinv_get_theme_template_dir_name(); |
|
| 231 | + $template_dir = wpinv_get_theme_template_dir_name(); |
|
| 232 | 232 | |
| 233 | - $file_paths = array( |
|
| 234 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 235 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 236 | - 100 => wpinv_get_templates_dir(), |
|
| 237 | - ); |
|
| 233 | + $file_paths = array( |
|
| 234 | + 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 235 | + 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 236 | + 100 => wpinv_get_templates_dir(), |
|
| 237 | + ); |
|
| 238 | 238 | |
| 239 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
| 239 | + $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
| 240 | 240 | |
| 241 | - // sort the file paths based on priority |
|
| 242 | - ksort( $file_paths, SORT_NUMERIC ); |
|
| 241 | + // sort the file paths based on priority |
|
| 242 | + ksort( $file_paths, SORT_NUMERIC ); |
|
| 243 | 243 | |
| 244 | - return array_map( 'trailingslashit', $file_paths ); |
|
| 244 | + return array_map( 'trailingslashit', $file_paths ); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | function wpinv_checkout_meta_tags() { |
| 248 | 248 | |
| 249 | - $pages = array(); |
|
| 250 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
| 251 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
| 252 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
| 253 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
| 249 | + $pages = array(); |
|
| 250 | + $pages[] = wpinv_get_option( 'success_page' ); |
|
| 251 | + $pages[] = wpinv_get_option( 'failure_page' ); |
|
| 252 | + $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
| 253 | + $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
| 254 | 254 | |
| 255 | - if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) { |
|
| 256 | - return; |
|
| 257 | - } |
|
| 255 | + if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) { |
|
| 256 | + return; |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
| 259 | + echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
| 260 | 260 | } |
| 261 | 261 | add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
| 262 | 262 | |
| 263 | 263 | function wpinv_add_body_classes( $class ) { |
| 264 | - $classes = (array)$class; |
|
| 264 | + $classes = (array)$class; |
|
| 265 | 265 | |
| 266 | - if ( wpinv_is_checkout() ) { |
|
| 267 | - $classes[] = 'wpinv-checkout'; |
|
| 268 | - $classes[] = 'wpinv-page'; |
|
| 269 | - } |
|
| 266 | + if ( wpinv_is_checkout() ) { |
|
| 267 | + $classes[] = 'wpinv-checkout'; |
|
| 268 | + $classes[] = 'wpinv-page'; |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | - if ( wpinv_is_success_page() ) { |
|
| 272 | - $classes[] = 'wpinv-success'; |
|
| 273 | - $classes[] = 'wpinv-page'; |
|
| 274 | - } |
|
| 271 | + if ( wpinv_is_success_page() ) { |
|
| 272 | + $classes[] = 'wpinv-success'; |
|
| 273 | + $classes[] = 'wpinv-page'; |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - if ( wpinv_is_failed_transaction_page() ) { |
|
| 277 | - $classes[] = 'wpinv-failed-transaction'; |
|
| 278 | - $classes[] = 'wpinv-page'; |
|
| 279 | - } |
|
| 276 | + if ( wpinv_is_failed_transaction_page() ) { |
|
| 277 | + $classes[] = 'wpinv-failed-transaction'; |
|
| 278 | + $classes[] = 'wpinv-page'; |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | - if ( wpinv_is_invoice_history_page() ) { |
|
| 282 | - $classes[] = 'wpinv-history'; |
|
| 283 | - $classes[] = 'wpinv-page'; |
|
| 284 | - } |
|
| 281 | + if ( wpinv_is_invoice_history_page() ) { |
|
| 282 | + $classes[] = 'wpinv-history'; |
|
| 283 | + $classes[] = 'wpinv-page'; |
|
| 284 | + } |
|
| 285 | 285 | |
| 286 | - if ( wpinv_is_subscriptions_history_page() ) { |
|
| 287 | - $classes[] = 'wpinv-subscription'; |
|
| 288 | - $classes[] = 'wpinv-page'; |
|
| 289 | - } |
|
| 286 | + if ( wpinv_is_subscriptions_history_page() ) { |
|
| 287 | + $classes[] = 'wpinv-subscription'; |
|
| 288 | + $classes[] = 'wpinv-page'; |
|
| 289 | + } |
|
| 290 | 290 | |
| 291 | - if ( wpinv_is_test_mode() ) { |
|
| 292 | - $classes[] = 'wpinv-test-mode'; |
|
| 293 | - $classes[] = 'wpinv-page'; |
|
| 294 | - } |
|
| 291 | + if ( wpinv_is_test_mode() ) { |
|
| 292 | + $classes[] = 'wpinv-test-mode'; |
|
| 293 | + $classes[] = 'wpinv-page'; |
|
| 294 | + } |
|
| 295 | 295 | |
| 296 | - return array_unique( $classes ); |
|
| 296 | + return array_unique( $classes ); |
|
| 297 | 297 | } |
| 298 | 298 | add_filter( 'body_class', 'wpinv_add_body_classes' ); |
| 299 | 299 | |
@@ -458,16 +458,16 @@ discard block |
||
| 458 | 458 | |
| 459 | 459 | wpinv_html_select( |
| 460 | 460 | array( |
| 461 | - 'name' => $args['name'], |
|
| 462 | - 'selected' => $args['selected'], |
|
| 463 | - 'id' => $args['id'], |
|
| 464 | - 'class' => $args['class'], |
|
| 465 | - 'options' => $options, |
|
| 466 | - 'multiple' => $args['multiple'], |
|
| 467 | - 'placeholder' => $args['placeholder'], |
|
| 468 | - 'show_option_all' => $args['show_option_all'], |
|
| 469 | - 'show_option_none' => $args['show_option_none'], |
|
| 470 | - 'data' => $args['data'], |
|
| 461 | + 'name' => $args['name'], |
|
| 462 | + 'selected' => $args['selected'], |
|
| 463 | + 'id' => $args['id'], |
|
| 464 | + 'class' => $args['class'], |
|
| 465 | + 'options' => $options, |
|
| 466 | + 'multiple' => $args['multiple'], |
|
| 467 | + 'placeholder' => $args['placeholder'], |
|
| 468 | + 'show_option_all' => $args['show_option_all'], |
|
| 469 | + 'show_option_none' => $args['show_option_none'], |
|
| 470 | + 'data' => $args['data'], |
|
| 471 | 471 | ) |
| 472 | 472 | ); |
| 473 | 473 | |
@@ -767,21 +767,21 @@ discard block |
||
| 767 | 767 | |
| 768 | 768 | $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
| 769 | 769 | |
| 770 | - // Remove unavailable tags. |
|
| 770 | + // Remove unavailable tags. |
|
| 771 | 771 | $formatted_address = preg_replace( '/\{\{\w+\}\}/', '', $formatted_address ); |
| 772 | 772 | |
| 773 | 773 | // Clean up white space. |
| 774 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
| 774 | + $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
| 775 | 775 | $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
| 776 | 776 | |
| 777 | 777 | // Break newlines apart and remove empty lines/trim commas and white space. |
| 778 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
| 778 | + $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
| 779 | 779 | |
| 780 | 780 | // Add html breaks. |
| 781 | - $formatted_address = implode( $separator, $formatted_address ); |
|
| 781 | + $formatted_address = implode( $separator, $formatted_address ); |
|
| 782 | 782 | |
| 783 | - // We're done! |
|
| 784 | - return $formatted_address; |
|
| 783 | + // We're done! |
|
| 784 | + return $formatted_address; |
|
| 785 | 785 | |
| 786 | 786 | } |
| 787 | 787 | |
@@ -827,7 +827,7 @@ discard block |
||
| 827 | 827 | function getpaid_display_invoice_subscriptions( $invoice ) { |
| 828 | 828 | |
| 829 | 829 | // Subscriptions. |
| 830 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
| 830 | + $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
| 831 | 831 | |
| 832 | 832 | if ( empty( $subscriptions ) || ! $invoice->is_recurring() ) { |
| 833 | 833 | return; |
@@ -1039,7 +1039,7 @@ discard block |
||
| 1039 | 1039 | } |
| 1040 | 1040 | |
| 1041 | 1041 | function wpinv_empty_cart_message() { |
| 1042 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
| 1042 | + return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
| 1043 | 1043 | } |
| 1044 | 1044 | |
| 1045 | 1045 | /** |
@@ -1237,9 +1237,9 @@ discard block |
||
| 1237 | 1237 | |
| 1238 | 1238 | if ( 0 == count( $form->get_items() ) ) { |
| 1239 | 1239 | aui()->alert( |
| 1240 | - array( |
|
| 1241 | - 'type' => 'warning', |
|
| 1242 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
| 1240 | + array( |
|
| 1241 | + 'type' => 'warning', |
|
| 1242 | + 'content' => __( 'No published items found', 'invoicing' ), |
|
| 1243 | 1243 | ), |
| 1244 | 1244 | true |
| 1245 | 1245 | ); |
@@ -1262,10 +1262,10 @@ discard block |
||
| 1262 | 1262 | $invoice = wpinv_get_invoice( $invoice_id ); |
| 1263 | 1263 | |
| 1264 | 1264 | if ( empty( $invoice ) ) { |
| 1265 | - aui()->alert( |
|
| 1266 | - array( |
|
| 1267 | - 'type' => 'warning', |
|
| 1268 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
| 1265 | + aui()->alert( |
|
| 1266 | + array( |
|
| 1267 | + 'type' => 'warning', |
|
| 1268 | + 'content' => __( 'Invoice not found', 'invoicing' ), |
|
| 1269 | 1269 | ), |
| 1270 | 1270 | true |
| 1271 | 1271 | ); |
@@ -1273,10 +1273,10 @@ discard block |
||
| 1273 | 1273 | } |
| 1274 | 1274 | |
| 1275 | 1275 | if ( $invoice->is_paid() ) { |
| 1276 | - aui()->alert( |
|
| 1277 | - array( |
|
| 1278 | - 'type' => 'warning', |
|
| 1279 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
| 1276 | + aui()->alert( |
|
| 1277 | + array( |
|
| 1278 | + 'type' => 'warning', |
|
| 1279 | + 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
| 1280 | 1280 | ), |
| 1281 | 1281 | true |
| 1282 | 1282 | ); |
@@ -1340,7 +1340,7 @@ discard block |
||
| 1340 | 1340 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>"; |
| 1341 | 1341 | } |
| 1342 | 1342 | |
| 1343 | - if ( ! empty( $items ) ) { |
|
| 1343 | + if ( ! empty( $items ) ) { |
|
| 1344 | 1344 | $items = esc_attr( $items ); |
| 1345 | 1345 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>"; |
| 1346 | 1346 | } |
@@ -1526,21 +1526,21 @@ discard block |
||
| 1526 | 1526 | |
| 1527 | 1527 | return aui()->select( |
| 1528 | 1528 | array( |
| 1529 | - 'options' => $states, |
|
| 1530 | - 'name' => esc_attr( $field_name ), |
|
| 1531 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
| 1532 | - 'value' => sanitize_text_field( $state ), |
|
| 1533 | - 'placeholder' => $placeholder, |
|
| 1534 | - 'required' => $required, |
|
| 1535 | - 'label' => wp_kses_post( $label ), |
|
| 1536 | - 'label_type' => 'vertical', |
|
| 1537 | - 'help_text' => $help_text, |
|
| 1538 | - 'class' => 'getpaid-address-field wpinv_state', |
|
| 1539 | - 'wrap_class' => "$wrapper_class getpaid-address-field-wrapper__state", |
|
| 1540 | - 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state', |
|
| 1541 | - 'extra_attributes' => array( |
|
| 1542 | - 'autocomplete' => 'address-level1', |
|
| 1543 | - ), |
|
| 1529 | + 'options' => $states, |
|
| 1530 | + 'name' => esc_attr( $field_name ), |
|
| 1531 | + 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
| 1532 | + 'value' => sanitize_text_field( $state ), |
|
| 1533 | + 'placeholder' => $placeholder, |
|
| 1534 | + 'required' => $required, |
|
| 1535 | + 'label' => wp_kses_post( $label ), |
|
| 1536 | + 'label_type' => 'vertical', |
|
| 1537 | + 'help_text' => $help_text, |
|
| 1538 | + 'class' => 'getpaid-address-field wpinv_state', |
|
| 1539 | + 'wrap_class' => "$wrapper_class getpaid-address-field-wrapper__state", |
|
| 1540 | + 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state', |
|
| 1541 | + 'extra_attributes' => array( |
|
| 1542 | + 'autocomplete' => 'address-level1', |
|
| 1543 | + ), |
|
| 1544 | 1544 | ), |
| 1545 | 1545 | $echo |
| 1546 | 1546 | ); |
@@ -4,99 +4,99 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Displays an invoice. |
| 11 | 11 | * |
| 12 | 12 | * @param WPInv_Invoice $invoice. |
| 13 | 13 | */ |
| 14 | -function getpaid_invoice( $invoice ) { |
|
| 15 | - if ( ! empty( $invoice ) ) { |
|
| 16 | - wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) ); |
|
| 14 | +function getpaid_invoice($invoice) { |
|
| 15 | + if (!empty($invoice)) { |
|
| 16 | + wpinv_get_template('invoice/invoice.php', compact('invoice')); |
|
| 17 | 17 | } |
| 18 | 18 | } |
| 19 | -add_action( 'getpaid_invoice', 'getpaid_invoice', 10 ); |
|
| 19 | +add_action('getpaid_invoice', 'getpaid_invoice', 10); |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * Displays the invoice footer. |
| 23 | 23 | */ |
| 24 | -function getpaid_invoice_footer( $invoice ) { |
|
| 25 | - if ( ! empty( $invoice ) ) { |
|
| 26 | - wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) ); |
|
| 24 | +function getpaid_invoice_footer($invoice) { |
|
| 25 | + if (!empty($invoice)) { |
|
| 26 | + wpinv_get_template('invoice/footer.php', compact('invoice')); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | -add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 ); |
|
| 29 | +add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10); |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * Displays the invoice top bar. |
| 33 | 33 | */ |
| 34 | -function getpaid_invoice_header( $invoice ) { |
|
| 35 | - if ( ! empty( $invoice ) ) { |
|
| 36 | - wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) ); |
|
| 34 | +function getpaid_invoice_header($invoice) { |
|
| 35 | + if (!empty($invoice)) { |
|
| 36 | + wpinv_get_template('invoice/header.php', compact('invoice')); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | -add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 ); |
|
| 39 | +add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10); |
|
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * Displays actions on the left side of the header. |
| 43 | 43 | */ |
| 44 | -function getpaid_invoice_header_left_actions( $invoice ) { |
|
| 45 | - if ( ! empty( $invoice ) ) { |
|
| 46 | - wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) ); |
|
| 44 | +function getpaid_invoice_header_left_actions($invoice) { |
|
| 45 | + if (!empty($invoice)) { |
|
| 46 | + wpinv_get_template('invoice/header-left-actions.php', compact('invoice')); |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | -add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 ); |
|
| 49 | +add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10); |
|
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * Displays actions on the right side of the invoice top bar. |
| 53 | 53 | */ |
| 54 | -function getpaid_invoice_header_right_actions( $invoice ) { |
|
| 55 | - if ( ! empty( $invoice ) ) { |
|
| 56 | - wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) ); |
|
| 54 | +function getpaid_invoice_header_right_actions($invoice) { |
|
| 55 | + if (!empty($invoice)) { |
|
| 56 | + wpinv_get_template('invoice/header-right-actions.php', compact('invoice')); |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | -add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 ); |
|
| 59 | +add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10); |
|
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | 62 | * Displays the invoice title, logo etc. |
| 63 | 63 | */ |
| 64 | -function getpaid_invoice_details_top( $invoice ) { |
|
| 65 | - if ( ! empty( $invoice ) ) { |
|
| 66 | - wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) ); |
|
| 64 | +function getpaid_invoice_details_top($invoice) { |
|
| 65 | + if (!empty($invoice)) { |
|
| 66 | + wpinv_get_template('invoice/details-top.php', compact('invoice')); |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 ); |
|
| 69 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10); |
|
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | 72 | * Displays the company logo. |
| 73 | 73 | */ |
| 74 | -function getpaid_invoice_logo( $invoice ) { |
|
| 75 | - if ( ! empty( $invoice ) ) { |
|
| 76 | - wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) ); |
|
| 74 | +function getpaid_invoice_logo($invoice) { |
|
| 75 | + if (!empty($invoice)) { |
|
| 76 | + wpinv_get_template('invoice/invoice-logo.php', compact('invoice')); |
|
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | -add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' ); |
|
| 79 | +add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo'); |
|
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * Displays the type of invoice. |
| 83 | 83 | */ |
| 84 | -function getpaid_invoice_type( $invoice ) { |
|
| 85 | - if ( ! empty( $invoice ) ) { |
|
| 86 | - wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) ); |
|
| 84 | +function getpaid_invoice_type($invoice) { |
|
| 85 | + if (!empty($invoice)) { |
|
| 86 | + wpinv_get_template('invoice/invoice-type.php', compact('invoice')); |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | -add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' ); |
|
| 89 | +add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type'); |
|
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | 92 | * Displays the invoice details. |
| 93 | 93 | */ |
| 94 | -function getpaid_invoice_details_main( $invoice ) { |
|
| 95 | - if ( ! empty( $invoice ) ) { |
|
| 96 | - wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) ); |
|
| 94 | +function getpaid_invoice_details_main($invoice) { |
|
| 95 | + if (!empty($invoice)) { |
|
| 96 | + wpinv_get_template('invoice/details.php', compact('invoice')); |
|
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 ); |
|
| 99 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50); |
|
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * Returns a path to the templates directory. |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
| 126 | 126 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
| 127 | 127 | */ |
| 128 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 129 | - getpaid_template()->display_template( $template_name, $args, $template_path, $default_path ); |
|
| 128 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 129 | + getpaid_template()->display_template($template_name, $args, $template_path, $default_path); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
| 140 | 140 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
| 141 | 141 | */ |
| 142 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 143 | - return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
| 142 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 143 | + return getpaid_template()->get_template($template_name, $args, $template_path, $default_path); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @return string |
| 150 | 150 | */ |
| 151 | 151 | function wpinv_template_path() { |
| 152 | - return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() ); |
|
| 152 | + return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name()); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @return string |
| 159 | 159 | */ |
| 160 | 160 | function wpinv_get_theme_template_dir_name() { |
| 161 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
| 161 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing')); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -170,58 +170,58 @@ discard block |
||
| 170 | 170 | * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'. |
| 171 | 171 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
| 172 | 172 | */ |
| 173 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
| 174 | - return getpaid_template()->locate_template( $template_name, $template_path, $default_path ); |
|
| 173 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
| 174 | + return getpaid_template()->locate_template($template_name, $template_path, $default_path); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
| 178 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
| 177 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
| 178 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
| 179 | 179 | |
| 180 | 180 | // Setup possible parts |
| 181 | 181 | $templates = array(); |
| 182 | - if ( isset( $name ) ) { |
|
| 182 | + if (isset($name)) { |
|
| 183 | 183 | $templates[] = $slug . '-' . $name . '.php'; |
| 184 | 184 | } |
| 185 | 185 | $templates[] = $slug . '.php'; |
| 186 | 186 | |
| 187 | 187 | // Allow template parts to be filtered |
| 188 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
| 188 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
| 189 | 189 | |
| 190 | 190 | // Return the part that is found |
| 191 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
| 191 | + return wpinv_locate_tmpl($templates, $load, false); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
| 194 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
| 195 | 195 | // No file found yet |
| 196 | 196 | $located = false; |
| 197 | 197 | |
| 198 | 198 | // Try to find a template file |
| 199 | - foreach ( (array)$template_names as $template_name ) { |
|
| 199 | + foreach ((array) $template_names as $template_name) { |
|
| 200 | 200 | |
| 201 | 201 | // Continue if template is empty |
| 202 | - if ( empty( $template_name ) ) { |
|
| 202 | + if (empty($template_name)) { |
|
| 203 | 203 | continue; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | // Trim off any slashes from the template name |
| 207 | - $template_name = ltrim( $template_name, '/' ); |
|
| 207 | + $template_name = ltrim($template_name, '/'); |
|
| 208 | 208 | |
| 209 | 209 | // try locating this template file by looping through the template paths |
| 210 | - foreach ( wpinv_get_theme_template_paths() as $template_path ) { |
|
| 210 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
| 211 | 211 | |
| 212 | - if ( file_exists( $template_path . $template_name ) ) { |
|
| 212 | + if (file_exists($template_path . $template_name)) { |
|
| 213 | 213 | $located = $template_path . $template_name; |
| 214 | 214 | break; |
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - if ( ! empty( $located ) ) { |
|
| 218 | + if (!empty($located)) { |
|
| 219 | 219 | break; |
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - if ( ( true == $load ) && ! empty( $located ) ) { |
|
| 224 | - load_template( $located, $require_once ); |
|
| 223 | + if ((true == $load) && !empty($located)) { |
|
| 224 | + load_template($located, $require_once); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | return $located; |
@@ -231,73 +231,73 @@ discard block |
||
| 231 | 231 | $template_dir = wpinv_get_theme_template_dir_name(); |
| 232 | 232 | |
| 233 | 233 | $file_paths = array( |
| 234 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 235 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 234 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
| 235 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
| 236 | 236 | 100 => wpinv_get_templates_dir(), |
| 237 | 237 | ); |
| 238 | 238 | |
| 239 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
| 239 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
| 240 | 240 | |
| 241 | 241 | // sort the file paths based on priority |
| 242 | - ksort( $file_paths, SORT_NUMERIC ); |
|
| 242 | + ksort($file_paths, SORT_NUMERIC); |
|
| 243 | 243 | |
| 244 | - return array_map( 'trailingslashit', $file_paths ); |
|
| 244 | + return array_map('trailingslashit', $file_paths); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | function wpinv_checkout_meta_tags() { |
| 248 | 248 | |
| 249 | 249 | $pages = array(); |
| 250 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
| 251 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
| 252 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
| 253 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
| 250 | + $pages[] = wpinv_get_option('success_page'); |
|
| 251 | + $pages[] = wpinv_get_option('failure_page'); |
|
| 252 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
| 253 | + $pages[] = wpinv_get_option('invoice_subscription_page'); |
|
| 254 | 254 | |
| 255 | - if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) { |
|
| 255 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
| 256 | 256 | return; |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
| 260 | 260 | } |
| 261 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
| 261 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
| 262 | 262 | |
| 263 | -function wpinv_add_body_classes( $class ) { |
|
| 264 | - $classes = (array)$class; |
|
| 263 | +function wpinv_add_body_classes($class) { |
|
| 264 | + $classes = (array) $class; |
|
| 265 | 265 | |
| 266 | - if ( wpinv_is_checkout() ) { |
|
| 266 | + if (wpinv_is_checkout()) { |
|
| 267 | 267 | $classes[] = 'wpinv-checkout'; |
| 268 | 268 | $classes[] = 'wpinv-page'; |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - if ( wpinv_is_success_page() ) { |
|
| 271 | + if (wpinv_is_success_page()) { |
|
| 272 | 272 | $classes[] = 'wpinv-success'; |
| 273 | 273 | $classes[] = 'wpinv-page'; |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - if ( wpinv_is_failed_transaction_page() ) { |
|
| 276 | + if (wpinv_is_failed_transaction_page()) { |
|
| 277 | 277 | $classes[] = 'wpinv-failed-transaction'; |
| 278 | 278 | $classes[] = 'wpinv-page'; |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - if ( wpinv_is_invoice_history_page() ) { |
|
| 281 | + if (wpinv_is_invoice_history_page()) { |
|
| 282 | 282 | $classes[] = 'wpinv-history'; |
| 283 | 283 | $classes[] = 'wpinv-page'; |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - if ( wpinv_is_subscriptions_history_page() ) { |
|
| 286 | + if (wpinv_is_subscriptions_history_page()) { |
|
| 287 | 287 | $classes[] = 'wpinv-subscription'; |
| 288 | 288 | $classes[] = 'wpinv-page'; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - if ( wpinv_is_test_mode() ) { |
|
| 291 | + if (wpinv_is_test_mode()) { |
|
| 292 | 292 | $classes[] = 'wpinv-test-mode'; |
| 293 | 293 | $classes[] = 'wpinv-page'; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - return array_unique( $classes ); |
|
| 296 | + return array_unique($classes); |
|
| 297 | 297 | } |
| 298 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
| 298 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
| 299 | 299 | |
| 300 | -function wpinv_html_select( $args = array() ) { |
|
| 300 | +function wpinv_html_select($args = array()) { |
|
| 301 | 301 | $defaults = array( |
| 302 | 302 | 'options' => array(), |
| 303 | 303 | 'name' => null, |
@@ -306,8 +306,8 @@ discard block |
||
| 306 | 306 | 'selected' => 0, |
| 307 | 307 | 'placeholder' => null, |
| 308 | 308 | 'multiple' => false, |
| 309 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
| 310 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
| 309 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
| 310 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
| 311 | 311 | 'data' => array(), |
| 312 | 312 | 'onchange' => null, |
| 313 | 313 | 'required' => false, |
@@ -315,79 +315,79 @@ discard block |
||
| 315 | 315 | 'readonly' => false, |
| 316 | 316 | ); |
| 317 | 317 | |
| 318 | - $args = wp_parse_args( $args, $defaults ); |
|
| 318 | + $args = wp_parse_args($args, $defaults); |
|
| 319 | 319 | |
| 320 | 320 | $attrs = array( |
| 321 | 321 | 'name' => $args['name'], |
| 322 | 322 | 'id' => $args['id'], |
| 323 | - 'class' => 'wpinv-select ' . implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ), |
|
| 324 | - 'multiple' => ! empty( $args['multiple'] ), |
|
| 325 | - 'readonly' => ! empty( $args['readonly'] ), |
|
| 326 | - 'disabled' => ! empty( $args['disabled'] ), |
|
| 327 | - 'required' => ! empty( $args['required'] ), |
|
| 328 | - 'onchange' => ! empty( $args['onchange'] ), |
|
| 323 | + 'class' => 'wpinv-select ' . implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))), |
|
| 324 | + 'multiple' => !empty($args['multiple']), |
|
| 325 | + 'readonly' => !empty($args['readonly']), |
|
| 326 | + 'disabled' => !empty($args['disabled']), |
|
| 327 | + 'required' => !empty($args['required']), |
|
| 328 | + 'onchange' => !empty($args['onchange']), |
|
| 329 | 329 | ); |
| 330 | 330 | |
| 331 | - if ( $args['placeholder'] ) { |
|
| 331 | + if ($args['placeholder']) { |
|
| 332 | 332 | $attrs['data-placeholder'] = $args['placeholder']; |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - if ( $args['onchange'] ) { |
|
| 335 | + if ($args['onchange']) { |
|
| 336 | 336 | $attrs['onchange'] = $args['onchange']; |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | - foreach ( $args['data'] as $key => $value ) { |
|
| 339 | + foreach ($args['data'] as $key => $value) { |
|
| 340 | 340 | $attrs["data-$key"] = $value; |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | echo '<select '; |
| 344 | 344 | |
| 345 | - foreach ( $attrs as $attr => $value ) { |
|
| 345 | + foreach ($attrs as $attr => $value) { |
|
| 346 | 346 | |
| 347 | - if ( false === $value ) { |
|
| 347 | + if (false === $value) { |
|
| 348 | 348 | continue; |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | - if ( true === $value ) { |
|
| 352 | - echo ' ' . esc_attr( $attr ); |
|
| 351 | + if (true === $value) { |
|
| 352 | + echo ' ' . esc_attr($attr); |
|
| 353 | 353 | } else { |
| 354 | - echo ' ' . esc_attr( $attr ) . '="' . esc_attr( $value ) . '"'; |
|
| 354 | + echo ' ' . esc_attr($attr) . '="' . esc_attr($value) . '"'; |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | echo '>'; |
| 360 | 360 | |
| 361 | - if ( $args['show_option_all'] ) { |
|
| 362 | - if ( $args['multiple'] ) { |
|
| 363 | - $selected = in_array( 0, $args['selected'] ); |
|
| 361 | + if ($args['show_option_all']) { |
|
| 362 | + if ($args['multiple']) { |
|
| 363 | + $selected = in_array(0, $args['selected']); |
|
| 364 | 364 | } else { |
| 365 | - $selected = empty( $args['selected'] ); |
|
| 365 | + $selected = empty($args['selected']); |
|
| 366 | 366 | } |
| 367 | - echo '<option value="all"' . selected( $selected, true, false ) . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
| 367 | + echo '<option value="all"' . selected($selected, true, false) . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | - if ( ! empty( $args['options'] ) ) { |
|
| 370 | + if (!empty($args['options'])) { |
|
| 371 | 371 | |
| 372 | - if ( $args['show_option_none'] ) { |
|
| 373 | - if ( $args['multiple'] ) { |
|
| 374 | - $selected = in_array( '', $args['selected'], true ); |
|
| 372 | + if ($args['show_option_none']) { |
|
| 373 | + if ($args['multiple']) { |
|
| 374 | + $selected = in_array('', $args['selected'], true); |
|
| 375 | 375 | } else { |
| 376 | 376 | $selected = $args['selected'] === ''; |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - echo '<option value=""' . selected( $selected, true, false ) . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
| 379 | + echo '<option value=""' . selected($selected, true, false) . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | - foreach ( $args['options'] as $key => $option ) { |
|
| 382 | + foreach ($args['options'] as $key => $option) { |
|
| 383 | 383 | |
| 384 | - if ( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
| 385 | - $selected = in_array( $key, $args['selected'], true ); |
|
| 384 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
| 385 | + $selected = in_array($key, $args['selected'], true); |
|
| 386 | 386 | } else { |
| 387 | 387 | $selected = $args['selected'] === $key; |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - echo '<option value="' . esc_attr( $key ) . '"' . selected( $selected, true, false ) . '>' . esc_html( $option ) . '</option>'; |
|
| 390 | + echo '<option value="' . esc_attr($key) . '"' . selected($selected, true, false) . '>' . esc_html($option) . '</option>'; |
|
| 391 | 391 | } |
| 392 | 392 | } |
| 393 | 393 | |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | -function wpinv_item_dropdown( $args = array() ) { |
|
| 398 | +function wpinv_item_dropdown($args = array()) { |
|
| 399 | 399 | $defaults = array( |
| 400 | 400 | 'name' => 'wpi_item', |
| 401 | 401 | 'id' => 'wpi_item', |
@@ -403,14 +403,14 @@ discard block |
||
| 403 | 403 | 'multiple' => false, |
| 404 | 404 | 'selected' => 0, |
| 405 | 405 | 'number' => -1, |
| 406 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
| 407 | - 'data' => array( 'search-type' => 'item' ), |
|
| 406 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
| 407 | + 'data' => array('search-type' => 'item'), |
|
| 408 | 408 | 'show_option_all' => false, |
| 409 | 409 | 'show_option_none' => false, |
| 410 | 410 | 'show_recurring' => false, |
| 411 | 411 | ); |
| 412 | 412 | |
| 413 | - $args = wp_parse_args( $args, $defaults ); |
|
| 413 | + $args = wp_parse_args($args, $defaults); |
|
| 414 | 414 | |
| 415 | 415 | $item_args = array( |
| 416 | 416 | 'post_type' => 'wpi_item', |
@@ -428,40 +428,40 @@ discard block |
||
| 428 | 428 | ), |
| 429 | 429 | ); |
| 430 | 430 | |
| 431 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
| 431 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
| 432 | 432 | |
| 433 | - $items = get_posts( $item_args ); |
|
| 433 | + $items = get_posts($item_args); |
|
| 434 | 434 | $options = array(); |
| 435 | - if ( $items ) { |
|
| 436 | - foreach ( $items as $item ) { |
|
| 437 | - $title = esc_html( $item->post_title ); |
|
| 435 | + if ($items) { |
|
| 436 | + foreach ($items as $item) { |
|
| 437 | + $title = esc_html($item->post_title); |
|
| 438 | 438 | |
| 439 | - if ( ! empty( $args['show_recurring'] ) ) { |
|
| 440 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
| 439 | + if (!empty($args['show_recurring'])) { |
|
| 440 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
| 441 | 441 | } |
| 442 | 442 | |
| 443 | - $options[ absint( $item->ID ) ] = $title; |
|
| 443 | + $options[absint($item->ID)] = $title; |
|
| 444 | 444 | } |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | // This ensures that any selected items are included in the drop down |
| 448 | - if ( is_array( $args['selected'] ) ) { |
|
| 449 | - foreach ( $args['selected'] as $item ) { |
|
| 450 | - if ( ! in_array( $item, $options ) ) { |
|
| 451 | - $title = get_the_title( $item ); |
|
| 452 | - if ( ! empty( $args['show_recurring'] ) ) { |
|
| 453 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
| 448 | + if (is_array($args['selected'])) { |
|
| 449 | + foreach ($args['selected'] as $item) { |
|
| 450 | + if (!in_array($item, $options)) { |
|
| 451 | + $title = get_the_title($item); |
|
| 452 | + if (!empty($args['show_recurring'])) { |
|
| 453 | + $title .= wpinv_get_item_suffix($item, false); |
|
| 454 | 454 | } |
| 455 | - $options[ $item ] = $title; |
|
| 455 | + $options[$item] = $title; |
|
| 456 | 456 | } |
| 457 | 457 | } |
| 458 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
| 459 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
| 460 | - $title = get_the_title( $args['selected'] ); |
|
| 461 | - if ( ! empty( $args['show_recurring'] ) ) { |
|
| 462 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
| 458 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
| 459 | + if (!in_array($args['selected'], $options)) { |
|
| 460 | + $title = get_the_title($args['selected']); |
|
| 461 | + if (!empty($args['show_recurring'])) { |
|
| 462 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
| 463 | 463 | } |
| 464 | - $options[ $args['selected'] ] = get_the_title( $args['selected'] ); |
|
| 464 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | 467 | |
@@ -497,16 +497,16 @@ discard block |
||
| 497 | 497 | ); |
| 498 | 498 | |
| 499 | 499 | $options = array(); |
| 500 | - if ( $items ) { |
|
| 501 | - foreach ( $items as $item ) { |
|
| 502 | - $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false ); |
|
| 500 | + if ($items) { |
|
| 501 | + foreach ($items as $item) { |
|
| 502 | + $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false); |
|
| 503 | 503 | } |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | return $options; |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | -function wpinv_html_checkbox( $args = array() ) { |
|
| 509 | +function wpinv_html_checkbox($args = array()) { |
|
| 510 | 510 | $defaults = array( |
| 511 | 511 | 'name' => null, |
| 512 | 512 | 'current' => null, |
@@ -517,17 +517,17 @@ discard block |
||
| 517 | 517 | ), |
| 518 | 518 | ); |
| 519 | 519 | |
| 520 | - $args = wp_parse_args( $args, $defaults ); |
|
| 520 | + $args = wp_parse_args($args, $defaults); |
|
| 521 | 521 | |
| 522 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 522 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 523 | 523 | $attr = ''; |
| 524 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
| 524 | + if (!empty($args['options']['disabled'])) { |
|
| 525 | 525 | $attr .= ' disabled="disabled"'; |
| 526 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
| 526 | + } elseif (!empty($args['options']['readonly'])) { |
|
| 527 | 527 | $attr .= ' readonly'; |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | - $output = '<input type="checkbox"' . $attr . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . esc_attr( $class ) . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
| 530 | + $output = '<input type="checkbox"' . $attr . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . esc_attr($class) . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
| 531 | 531 | |
| 532 | 532 | return $output; |
| 533 | 533 | } |
@@ -535,34 +535,34 @@ discard block |
||
| 535 | 535 | /** |
| 536 | 536 | * Displays a hidden field. |
| 537 | 537 | */ |
| 538 | -function getpaid_hidden_field( $name, $value ) { |
|
| 539 | - echo "<input type='hidden' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "' />"; |
|
| 538 | +function getpaid_hidden_field($name, $value) { |
|
| 539 | + echo "<input type='hidden' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' />"; |
|
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | /** |
| 543 | 543 | * Displays a submit field. |
| 544 | 544 | */ |
| 545 | -function getpaid_submit_field( $value, $name = 'submit', $class = 'btn-primary' ) { |
|
| 546 | - echo "<input type='submit' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "' class='btn " . esc_attr( $class ) . "' />"; |
|
| 545 | +function getpaid_submit_field($value, $name = 'submit', $class = 'btn-primary') { |
|
| 546 | + echo "<input type='submit' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' class='btn " . esc_attr($class) . "' />"; |
|
| 547 | 547 | } |
| 548 | 548 | |
| 549 | -function wpinv_html_text( $args = array() ) { |
|
| 549 | +function wpinv_html_text($args = array()) { |
|
| 550 | 550 | // Backwards compatibility |
| 551 | - if ( func_num_args() > 1 ) { |
|
| 551 | + if (func_num_args() > 1) { |
|
| 552 | 552 | $args = func_get_args(); |
| 553 | 553 | |
| 554 | 554 | $name = $args[0]; |
| 555 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
| 556 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
| 557 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
| 555 | + $value = isset($args[1]) ? $args[1] : ''; |
|
| 556 | + $label = isset($args[2]) ? $args[2] : ''; |
|
| 557 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | $defaults = array( |
| 561 | 561 | 'id' => '', |
| 562 | - 'name' => isset( $name ) ? $name : 'text', |
|
| 563 | - 'value' => isset( $value ) ? $value : null, |
|
| 564 | - 'label' => isset( $label ) ? $label : null, |
|
| 565 | - 'desc' => isset( $desc ) ? $desc : null, |
|
| 562 | + 'name' => isset($name) ? $name : 'text', |
|
| 563 | + 'value' => isset($value) ? $value : null, |
|
| 564 | + 'label' => isset($label) ? $label : null, |
|
| 565 | + 'desc' => isset($desc) ? $desc : null, |
|
| 566 | 566 | 'placeholder' => '', |
| 567 | 567 | 'class' => 'regular-text', |
| 568 | 568 | 'disabled' => false, |
@@ -572,41 +572,41 @@ discard block |
||
| 572 | 572 | 'data' => false, |
| 573 | 573 | ); |
| 574 | 574 | |
| 575 | - $args = wp_parse_args( $args, $defaults ); |
|
| 575 | + $args = wp_parse_args($args, $defaults); |
|
| 576 | 576 | |
| 577 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 577 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 578 | 578 | $options = ''; |
| 579 | - if ( $args['required'] ) { |
|
| 579 | + if ($args['required']) { |
|
| 580 | 580 | $options .= ' required="required"'; |
| 581 | 581 | } |
| 582 | - if ( $args['readonly'] ) { |
|
| 582 | + if ($args['readonly']) { |
|
| 583 | 583 | $options .= ' readonly'; |
| 584 | 584 | } |
| 585 | - if ( $args['readonly'] ) { |
|
| 585 | + if ($args['readonly']) { |
|
| 586 | 586 | $options .= ' readonly'; |
| 587 | 587 | } |
| 588 | 588 | |
| 589 | 589 | $data = ''; |
| 590 | - if ( ! empty( $args['data'] ) ) { |
|
| 591 | - foreach ( $args['data'] as $key => $value ) { |
|
| 592 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
| 590 | + if (!empty($args['data'])) { |
|
| 591 | + foreach ($args['data'] as $key => $value) { |
|
| 592 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
| 593 | 593 | } |
| 594 | 594 | } |
| 595 | 595 | |
| 596 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 597 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 598 | - if ( ! empty( $args['desc'] ) ) { |
|
| 599 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 596 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
| 597 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
| 598 | + if (!empty($args['desc'])) { |
|
| 599 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
| 602 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
| 603 | 603 | |
| 604 | 604 | $output .= '</span>'; |
| 605 | 605 | |
| 606 | 606 | return $output; |
| 607 | 607 | } |
| 608 | 608 | |
| 609 | -function wpinv_html_textarea( $args = array() ) { |
|
| 609 | +function wpinv_html_textarea($args = array()) { |
|
| 610 | 610 | $defaults = array( |
| 611 | 611 | 'name' => 'textarea', |
| 612 | 612 | 'value' => null, |
@@ -617,31 +617,31 @@ discard block |
||
| 617 | 617 | 'placeholder' => '', |
| 618 | 618 | ); |
| 619 | 619 | |
| 620 | - $args = wp_parse_args( $args, $defaults ); |
|
| 620 | + $args = wp_parse_args($args, $defaults); |
|
| 621 | 621 | |
| 622 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 622 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 623 | 623 | $disabled = ''; |
| 624 | - if ( $args['disabled'] ) { |
|
| 624 | + if ($args['disabled']) { |
|
| 625 | 625 | $disabled = ' disabled="disabled"'; |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 629 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 630 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
| 628 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
| 629 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
| 630 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
| 631 | 631 | |
| 632 | - if ( ! empty( $args['desc'] ) ) { |
|
| 633 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 632 | + if (!empty($args['desc'])) { |
|
| 633 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
| 634 | 634 | } |
| 635 | 635 | $output .= '</span>'; |
| 636 | 636 | |
| 637 | 637 | return $output; |
| 638 | 638 | } |
| 639 | 639 | |
| 640 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
| 640 | +function wpinv_html_ajax_user_search($args = array()) { |
|
| 641 | 641 | $defaults = array( |
| 642 | 642 | 'name' => 'user_id', |
| 643 | 643 | 'value' => null, |
| 644 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
| 644 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
| 645 | 645 | 'label' => null, |
| 646 | 646 | 'desc' => null, |
| 647 | 647 | 'class' => '', |
@@ -650,13 +650,13 @@ discard block |
||
| 650 | 650 | 'data' => false, |
| 651 | 651 | ); |
| 652 | 652 | |
| 653 | - $args = wp_parse_args( $args, $defaults ); |
|
| 653 | + $args = wp_parse_args($args, $defaults); |
|
| 654 | 654 | |
| 655 | 655 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
| 656 | 656 | |
| 657 | 657 | $output = '<span class="wpinv_user_search_wrap">'; |
| 658 | - $output .= wpinv_html_text( $args ); |
|
| 659 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
| 658 | + $output .= wpinv_html_text($args); |
|
| 659 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
| 660 | 660 | $output .= '</span>'; |
| 661 | 661 | |
| 662 | 662 | return $output; |
@@ -667,44 +667,44 @@ discard block |
||
| 667 | 667 | * |
| 668 | 668 | * @param string $template the template that is currently being used. |
| 669 | 669 | */ |
| 670 | -function wpinv_template( $template ) { |
|
| 670 | +function wpinv_template($template) { |
|
| 671 | 671 | global $post; |
| 672 | 672 | |
| 673 | - if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) { |
|
| 673 | + if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) { |
|
| 674 | 674 | |
| 675 | 675 | // If the user can view this invoice, display it. |
| 676 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
| 676 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
| 677 | 677 | |
| 678 | - return wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
| 678 | + return wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
| 679 | 679 | |
| 680 | 680 | // Else display an error message. |
| 681 | 681 | } else { |
| 682 | 682 | |
| 683 | - return wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
| 683 | + return wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
| 684 | 684 | |
| 685 | 685 | } |
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | return $template; |
| 689 | 689 | } |
| 690 | -add_filter( 'template_include', 'wpinv_template', 1000, 1 ); |
|
| 690 | +add_filter('template_include', 'wpinv_template', 1000, 1); |
|
| 691 | 691 | |
| 692 | 692 | function wpinv_get_business_address() { |
| 693 | 693 | $business_address = wpinv_store_address(); |
| 694 | - $business_address = ! empty( $business_address ) ? wp_kses_post( wpautop( $business_address ) ) : ''; |
|
| 694 | + $business_address = !empty($business_address) ? wp_kses_post(wpautop($business_address)) : ''; |
|
| 695 | 695 | |
| 696 | 696 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
| 697 | 697 | |
| 698 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
| 698 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | /** |
| 702 | 702 | * Displays the company address. |
| 703 | 703 | */ |
| 704 | 704 | function wpinv_display_from_address() { |
| 705 | - wpinv_get_template( 'invoice/company-address.php' ); |
|
| 705 | + wpinv_get_template('invoice/company-address.php'); |
|
| 706 | 706 | } |
| 707 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 ); |
|
| 707 | +add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10); |
|
| 708 | 708 | |
| 709 | 709 | /** |
| 710 | 710 | * Generates a watermark text for an invoice. |
@@ -712,9 +712,9 @@ discard block |
||
| 712 | 712 | * @param WPInv_Invoice $invoice |
| 713 | 713 | * @return string |
| 714 | 714 | */ |
| 715 | -function wpinv_watermark( $invoice ) { |
|
| 716 | - $watermark = wpinv_get_watermark( $invoice ); |
|
| 717 | - return apply_filters( 'wpinv_get_watermark', $watermark, $invoice ); |
|
| 715 | +function wpinv_watermark($invoice) { |
|
| 716 | + $watermark = wpinv_get_watermark($invoice); |
|
| 717 | + return apply_filters('wpinv_get_watermark', $watermark, $invoice); |
|
| 718 | 718 | } |
| 719 | 719 | |
| 720 | 720 | /** |
@@ -723,37 +723,37 @@ discard block |
||
| 723 | 723 | * @param WPInv_Invoice $invoice |
| 724 | 724 | * @return string |
| 725 | 725 | */ |
| 726 | -function wpinv_get_watermark( $invoice ) { |
|
| 726 | +function wpinv_get_watermark($invoice) { |
|
| 727 | 727 | return $invoice->get_status_nicename(); |
| 728 | 728 | } |
| 729 | 729 | |
| 730 | 730 | /** |
| 731 | 731 | * @deprecated |
| 732 | 732 | */ |
| 733 | -function wpinv_display_invoice_details( $invoice ) { |
|
| 734 | - return getpaid_invoice_meta( $invoice ); |
|
| 733 | +function wpinv_display_invoice_details($invoice) { |
|
| 734 | + return getpaid_invoice_meta($invoice); |
|
| 735 | 735 | } |
| 736 | 736 | |
| 737 | 737 | /** |
| 738 | 738 | * Displays invoice meta. |
| 739 | 739 | */ |
| 740 | -function getpaid_invoice_meta( $invoice ) { |
|
| 740 | +function getpaid_invoice_meta($invoice) { |
|
| 741 | 741 | |
| 742 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 742 | + $invoice = new WPInv_Invoice($invoice); |
|
| 743 | 743 | |
| 744 | 744 | // Ensure that we have an invoice. |
| 745 | - if ( 0 == $invoice->get_id() ) { |
|
| 745 | + if (0 == $invoice->get_id()) { |
|
| 746 | 746 | return; |
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | // Get the invoice meta. |
| 750 | - $meta = getpaid_get_invoice_meta( $invoice ); |
|
| 750 | + $meta = getpaid_get_invoice_meta($invoice); |
|
| 751 | 751 | |
| 752 | 752 | // Display the meta. |
| 753 | - wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) ); |
|
| 753 | + wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta')); |
|
| 754 | 754 | |
| 755 | 755 | } |
| 756 | -add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 ); |
|
| 756 | +add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10); |
|
| 757 | 757 | |
| 758 | 758 | /** |
| 759 | 759 | * Retrieves the address markup to use on Invoices. |
@@ -765,29 +765,29 @@ discard block |
||
| 765 | 765 | * @param string $separator How to separate address lines. |
| 766 | 766 | * @return string |
| 767 | 767 | */ |
| 768 | -function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) { |
|
| 768 | +function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') { |
|
| 769 | 769 | |
| 770 | 770 | // Retrieve the address markup... |
| 771 | - $country = empty( $billing_details['country'] ) ? '' : $billing_details['country']; |
|
| 772 | - $format = wpinv_get_full_address_format( $country ); |
|
| 771 | + $country = empty($billing_details['country']) ? '' : $billing_details['country']; |
|
| 772 | + $format = wpinv_get_full_address_format($country); |
|
| 773 | 773 | |
| 774 | 774 | // ... and the replacements. |
| 775 | - $replacements = wpinv_get_invoice_address_replacements( $billing_details ); |
|
| 775 | + $replacements = wpinv_get_invoice_address_replacements($billing_details); |
|
| 776 | 776 | |
| 777 | - $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
|
| 777 | + $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format); |
|
| 778 | 778 | |
| 779 | 779 | // Remove unavailable tags. |
| 780 | - $formatted_address = preg_replace( '/\{\{\w+\}\}/', '', $formatted_address ); |
|
| 780 | + $formatted_address = preg_replace('/\{\{\w+\}\}/', '', $formatted_address); |
|
| 781 | 781 | |
| 782 | 782 | // Clean up white space. |
| 783 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
| 784 | - $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
|
| 783 | + $formatted_address = preg_replace('/ +/', ' ', trim($formatted_address)); |
|
| 784 | + $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address); |
|
| 785 | 785 | |
| 786 | 786 | // Break newlines apart and remove empty lines/trim commas and white space. |
| 787 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
| 787 | + $formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address))); |
|
| 788 | 788 | |
| 789 | 789 | // Add html breaks. |
| 790 | - $formatted_address = implode( $separator, $formatted_address ); |
|
| 790 | + $formatted_address = implode($separator, $formatted_address); |
|
| 791 | 791 | |
| 792 | 792 | // We're done! |
| 793 | 793 | return $formatted_address; |
@@ -799,118 +799,118 @@ discard block |
||
| 799 | 799 | * |
| 800 | 800 | * @param WPInv_Invoice $invoice |
| 801 | 801 | */ |
| 802 | -function wpinv_display_to_address( $invoice = 0 ) { |
|
| 803 | - if ( ! empty( $invoice ) ) { |
|
| 804 | - wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) ); |
|
| 802 | +function wpinv_display_to_address($invoice = 0) { |
|
| 803 | + if (!empty($invoice)) { |
|
| 804 | + wpinv_get_template('invoice/billing-address.php', compact('invoice')); |
|
| 805 | 805 | } |
| 806 | 806 | } |
| 807 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 ); |
|
| 807 | +add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40); |
|
| 808 | 808 | |
| 809 | 809 | |
| 810 | 810 | /** |
| 811 | 811 | * Displays invoice line items. |
| 812 | 812 | */ |
| 813 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
| 813 | +function wpinv_display_line_items($invoice_id = 0) { |
|
| 814 | 814 | |
| 815 | 815 | // Prepare the invoice. |
| 816 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 816 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 817 | 817 | |
| 818 | 818 | // Abort if there is no invoice. |
| 819 | - if ( 0 == $invoice->get_id() ) { |
|
| 819 | + if (0 == $invoice->get_id()) { |
|
| 820 | 820 | return; |
| 821 | 821 | } |
| 822 | 822 | |
| 823 | 823 | // Line item columns. |
| 824 | - $columns = getpaid_invoice_item_columns( $invoice ); |
|
| 825 | - $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice ); |
|
| 824 | + $columns = getpaid_invoice_item_columns($invoice); |
|
| 825 | + $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice); |
|
| 826 | 826 | |
| 827 | - wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) ); |
|
| 827 | + wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns')); |
|
| 828 | 828 | } |
| 829 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 ); |
|
| 829 | +add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10); |
|
| 830 | 830 | |
| 831 | 831 | /** |
| 832 | 832 | * Displays invoice subscriptions. |
| 833 | 833 | * |
| 834 | 834 | * @param WPInv_Invoice $invoice |
| 835 | 835 | */ |
| 836 | -function getpaid_display_invoice_subscriptions( $invoice ) { |
|
| 836 | +function getpaid_display_invoice_subscriptions($invoice) { |
|
| 837 | 837 | |
| 838 | 838 | // Subscriptions. |
| 839 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
| 839 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
| 840 | 840 | |
| 841 | - if ( empty( $subscriptions ) || ! $invoice->is_recurring() ) { |
|
| 841 | + if (empty($subscriptions) || !$invoice->is_recurring()) { |
|
| 842 | 842 | return; |
| 843 | 843 | } |
| 844 | 844 | |
| 845 | - $main_subscription = getpaid_get_invoice_subscription( $invoice ); |
|
| 845 | + $main_subscription = getpaid_get_invoice_subscription($invoice); |
|
| 846 | 846 | |
| 847 | 847 | // Display related subscriptions. |
| 848 | - if ( is_array( $subscriptions ) ) { |
|
| 849 | - printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Subscriptions', 'invoicing' ) ); |
|
| 850 | - getpaid_admin_subscription_related_subscriptions_metabox( $main_subscription, false ); |
|
| 848 | + if (is_array($subscriptions)) { |
|
| 849 | + printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Subscriptions', 'invoicing')); |
|
| 850 | + getpaid_admin_subscription_related_subscriptions_metabox($main_subscription, false); |
|
| 851 | 851 | } |
| 852 | 852 | |
| 853 | - if ( $main_subscription->get_total_payments() > 1 ) { |
|
| 854 | - printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Invoices', 'invoicing' ) ); |
|
| 855 | - getpaid_admin_subscription_invoice_details_metabox( $main_subscription, false ); |
|
| 853 | + if ($main_subscription->get_total_payments() > 1) { |
|
| 854 | + printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Invoices', 'invoicing')); |
|
| 855 | + getpaid_admin_subscription_invoice_details_metabox($main_subscription, false); |
|
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | } |
| 859 | -add_action( 'getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55 ); |
|
| 860 | -add_action( 'wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11 ); |
|
| 859 | +add_action('getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55); |
|
| 860 | +add_action('wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11); |
|
| 861 | 861 | |
| 862 | 862 | /** |
| 863 | 863 | * Displays invoice notices on invoices. |
| 864 | 864 | */ |
| 865 | 865 | function wpinv_display_invoice_notice() { |
| 866 | 866 | |
| 867 | - $label = wpinv_get_option( 'vat_invoice_notice_label' ); |
|
| 868 | - $notice = wpinv_get_option( 'vat_invoice_notice' ); |
|
| 867 | + $label = wpinv_get_option('vat_invoice_notice_label'); |
|
| 868 | + $notice = wpinv_get_option('vat_invoice_notice'); |
|
| 869 | 869 | |
| 870 | - if ( empty( $label ) && empty( $notice ) ) { |
|
| 870 | + if (empty($label) && empty($notice)) { |
|
| 871 | 871 | return; |
| 872 | 872 | } |
| 873 | 873 | |
| 874 | 874 | echo '<div class="mt-4 mb-4 wpinv-vat-notice">'; |
| 875 | 875 | |
| 876 | - if ( ! empty( $label ) ) { |
|
| 877 | - echo "<h5>" . esc_html( $label ) . "</h5>"; |
|
| 876 | + if (!empty($label)) { |
|
| 877 | + echo "<h5>" . esc_html($label) . "</h5>"; |
|
| 878 | 878 | } |
| 879 | 879 | |
| 880 | - if ( ! empty( $notice ) ) { |
|
| 881 | - echo '<small class="form-text text-muted">' . wp_kses_post( wpautop( wptexturize( $notice ) ) ) . '</small>'; |
|
| 880 | + if (!empty($notice)) { |
|
| 881 | + echo '<small class="form-text text-muted">' . wp_kses_post(wpautop(wptexturize($notice))) . '</small>'; |
|
| 882 | 882 | } |
| 883 | 883 | |
| 884 | 884 | echo '</div>'; |
| 885 | 885 | } |
| 886 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 ); |
|
| 886 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100); |
|
| 887 | 887 | |
| 888 | 888 | /** |
| 889 | 889 | * @param WPInv_Invoice $invoice |
| 890 | 890 | */ |
| 891 | -function wpinv_display_invoice_notes( $invoice ) { |
|
| 891 | +function wpinv_display_invoice_notes($invoice) { |
|
| 892 | 892 | |
| 893 | 893 | // Retrieve the notes. |
| 894 | - $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' ); |
|
| 894 | + $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer'); |
|
| 895 | 895 | |
| 896 | 896 | // Abort if we have non. |
| 897 | - if ( empty( $notes ) ) { |
|
| 897 | + if (empty($notes)) { |
|
| 898 | 898 | return; |
| 899 | 899 | } |
| 900 | 900 | |
| 901 | 901 | // Echo the note. |
| 902 | 902 | echo '<div class="getpaid-invoice-notes-wrapper position-relative my-4">'; |
| 903 | - echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . esc_html__( 'Notes', 'invoicing' ) . '</h2>'; |
|
| 903 | + echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . esc_html__('Notes', 'invoicing') . '</h2>'; |
|
| 904 | 904 | echo '<ul class="getpaid-invoice-notes text-break overflow-auto list-unstyled p-0 m-0">'; |
| 905 | 905 | |
| 906 | - foreach ( $notes as $note ) { |
|
| 907 | - wpinv_get_invoice_note_line_item( $note ); |
|
| 906 | + foreach ($notes as $note) { |
|
| 907 | + wpinv_get_invoice_note_line_item($note); |
|
| 908 | 908 | } |
| 909 | 909 | |
| 910 | 910 | echo '</ul>'; |
| 911 | 911 | echo '</div>'; |
| 912 | 912 | } |
| 913 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 ); |
|
| 913 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60); |
|
| 914 | 914 | |
| 915 | 915 | /** |
| 916 | 916 | * Loads scripts on our invoice templates. |
@@ -918,32 +918,32 @@ discard block |
||
| 918 | 918 | function wpinv_display_style() { |
| 919 | 919 | |
| 920 | 920 | // Make sure that all scripts have been loaded. |
| 921 | - if ( ! did_action( 'wp_enqueue_scripts' ) ) { |
|
| 922 | - do_action( 'wp_enqueue_scripts' ); |
|
| 921 | + if (!did_action('wp_enqueue_scripts')) { |
|
| 922 | + do_action('wp_enqueue_scripts'); |
|
| 923 | 923 | } |
| 924 | 924 | |
| 925 | 925 | // Register the invoices style. |
| 926 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) ); |
|
| 926 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css')); |
|
| 927 | 927 | |
| 928 | 928 | // Load required styles |
| 929 | - wp_print_styles( 'wpinv-single-style' ); |
|
| 930 | - wp_print_styles( 'ayecode-ui' ); |
|
| 929 | + wp_print_styles('wpinv-single-style'); |
|
| 930 | + wp_print_styles('ayecode-ui'); |
|
| 931 | 931 | |
| 932 | 932 | // Maybe load custom css. |
| 933 | - $custom_css = wpinv_get_option( 'template_custom_css' ); |
|
| 933 | + $custom_css = wpinv_get_option('template_custom_css'); |
|
| 934 | 934 | |
| 935 | - if ( isset( $custom_css ) && ! empty( $custom_css ) ) { |
|
| 936 | - $custom_css = wp_kses( $custom_css, array( '\'', '\"' ) ); |
|
| 937 | - $custom_css = str_replace( '>', '>', $custom_css ); |
|
| 935 | + if (isset($custom_css) && !empty($custom_css)) { |
|
| 936 | + $custom_css = wp_kses($custom_css, array('\'', '\"')); |
|
| 937 | + $custom_css = str_replace('>', '>', $custom_css); |
|
| 938 | 938 | echo '<style type="text/css">'; |
| 939 | - echo wp_kses_post( $custom_css ); |
|
| 939 | + echo wp_kses_post($custom_css); |
|
| 940 | 940 | echo '</style>'; |
| 941 | 941 | } |
| 942 | 942 | |
| 943 | 943 | wp_site_icon(); |
| 944 | 944 | } |
| 945 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
| 946 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
| 945 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
| 946 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
| 947 | 947 | |
| 948 | 948 | |
| 949 | 949 | /** |
@@ -955,41 +955,41 @@ discard block |
||
| 955 | 955 | // Retrieve the current invoice. |
| 956 | 956 | $invoice_id = getpaid_get_current_invoice_id(); |
| 957 | 957 | |
| 958 | - if ( empty( $invoice_id ) ) { |
|
| 958 | + if (empty($invoice_id)) { |
|
| 959 | 959 | |
| 960 | 960 | return aui()->alert( |
| 961 | 961 | array( |
| 962 | 962 | 'type' => 'warning', |
| 963 | - 'content' => __( 'Invalid invoice', 'invoicing' ), |
|
| 963 | + 'content' => __('Invalid invoice', 'invoicing'), |
|
| 964 | 964 | ) |
| 965 | 965 | ); |
| 966 | 966 | |
| 967 | 967 | } |
| 968 | 968 | |
| 969 | 969 | // Can the user view this invoice? |
| 970 | - if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) { |
|
| 970 | + if (!wpinv_user_can_view_invoice($invoice_id)) { |
|
| 971 | 971 | |
| 972 | 972 | return aui()->alert( |
| 973 | 973 | array( |
| 974 | 974 | 'type' => 'warning', |
| 975 | - 'content' => __( 'You are not allowed to view this invoice', 'invoicing' ), |
|
| 975 | + 'content' => __('You are not allowed to view this invoice', 'invoicing'), |
|
| 976 | 976 | ) |
| 977 | 977 | ); |
| 978 | 978 | |
| 979 | 979 | } |
| 980 | 980 | |
| 981 | 981 | // Ensure that it is not yet paid for. |
| 982 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 982 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 983 | 983 | |
| 984 | 984 | // Maybe mark it as viewed. |
| 985 | - getpaid_maybe_mark_invoice_as_viewed( $invoice ); |
|
| 985 | + getpaid_maybe_mark_invoice_as_viewed($invoice); |
|
| 986 | 986 | |
| 987 | - if ( $invoice->is_paid() ) { |
|
| 987 | + if ($invoice->is_paid()) { |
|
| 988 | 988 | |
| 989 | 989 | return aui()->alert( |
| 990 | 990 | array( |
| 991 | 991 | 'type' => 'success', |
| 992 | - 'content' => __( 'This invoice has already been paid.', 'invoicing' ), |
|
| 992 | + 'content' => __('This invoice has already been paid.', 'invoicing'), |
|
| 993 | 993 | ) |
| 994 | 994 | ); |
| 995 | 995 | |
@@ -999,15 +999,15 @@ discard block |
||
| 999 | 999 | $wpi_checkout_id = $invoice_id; |
| 1000 | 1000 | |
| 1001 | 1001 | // Retrieve appropriate payment form. |
| 1002 | - $payment_form = new GetPaid_Payment_Form( wpinv_translate_post_id( $invoice->get_meta( 'force_payment_form' ) ) ); |
|
| 1003 | - $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
| 1002 | + $payment_form = new GetPaid_Payment_Form(wpinv_translate_post_id($invoice->get_meta('force_payment_form'))); |
|
| 1003 | + $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
| 1004 | 1004 | |
| 1005 | - if ( ! $payment_form->exists() ) { |
|
| 1005 | + if (!$payment_form->exists()) { |
|
| 1006 | 1006 | |
| 1007 | 1007 | return aui()->alert( |
| 1008 | 1008 | array( |
| 1009 | 1009 | 'type' => 'warning', |
| 1010 | - 'content' => __( 'Error loading the payment form', 'invoicing' ), |
|
| 1010 | + 'content' => __('Error loading the payment form', 'invoicing'), |
|
| 1011 | 1011 | ) |
| 1012 | 1012 | ); |
| 1013 | 1013 | |
@@ -1016,29 +1016,29 @@ discard block |
||
| 1016 | 1016 | // Set the invoice. |
| 1017 | 1017 | $payment_form->invoice = $invoice; |
| 1018 | 1018 | |
| 1019 | - if ( ! $payment_form->is_default() ) { |
|
| 1019 | + if (!$payment_form->is_default()) { |
|
| 1020 | 1020 | |
| 1021 | 1021 | $items = array(); |
| 1022 | 1022 | $item_ids = array(); |
| 1023 | 1023 | |
| 1024 | - foreach ( $invoice->get_items() as $item ) { |
|
| 1025 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
| 1024 | + foreach ($invoice->get_items() as $item) { |
|
| 1025 | + if (!in_array($item->get_id(), $item_ids)) { |
|
| 1026 | 1026 | $item_ids[] = $item->get_id(); |
| 1027 | 1027 | $items[] = $item; |
| 1028 | 1028 | } |
| 1029 | 1029 | } |
| 1030 | 1030 | |
| 1031 | - foreach ( $payment_form->get_items() as $item ) { |
|
| 1032 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
| 1031 | + foreach ($payment_form->get_items() as $item) { |
|
| 1032 | + if (!in_array($item->get_id(), $item_ids)) { |
|
| 1033 | 1033 | $item_ids[] = $item->get_id(); |
| 1034 | 1034 | $items[] = $item; |
| 1035 | 1035 | } |
| 1036 | 1036 | } |
| 1037 | 1037 | |
| 1038 | - $payment_form->set_items( $items ); |
|
| 1038 | + $payment_form->set_items($items); |
|
| 1039 | 1039 | |
| 1040 | 1040 | } else { |
| 1041 | - $payment_form->set_items( $invoice->get_items() ); |
|
| 1041 | + $payment_form->set_items($invoice->get_items()); |
|
| 1042 | 1042 | } |
| 1043 | 1043 | |
| 1044 | 1044 | // Generate the html. |
@@ -1047,7 +1047,7 @@ discard block |
||
| 1047 | 1047 | } |
| 1048 | 1048 | |
| 1049 | 1049 | function wpinv_empty_cart_message() { |
| 1050 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
| 1050 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
| 1051 | 1051 | } |
| 1052 | 1052 | |
| 1053 | 1053 | /** |
@@ -1065,76 +1065,76 @@ discard block |
||
| 1065 | 1065 | true |
| 1066 | 1066 | ); |
| 1067 | 1067 | } |
| 1068 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
| 1068 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
| 1069 | 1069 | |
| 1070 | 1070 | /** |
| 1071 | 1071 | * Filters the receipt page. |
| 1072 | 1072 | */ |
| 1073 | -function wpinv_filter_success_page_content( $content ) { |
|
| 1073 | +function wpinv_filter_success_page_content($content) { |
|
| 1074 | 1074 | |
| 1075 | 1075 | // Maybe abort early. |
| 1076 | - if ( is_admin() || ! is_singular() || ! in_the_loop() || ! is_main_query() || is_preview() ) { |
|
| 1076 | + if (is_admin() || !is_singular() || !in_the_loop() || !is_main_query() || is_preview()) { |
|
| 1077 | 1077 | return $content; |
| 1078 | 1078 | } |
| 1079 | 1079 | |
| 1080 | 1080 | // Ensure this is our page. |
| 1081 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
| 1081 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
| 1082 | 1082 | |
| 1083 | - $gateway = sanitize_text_field( $_GET['payment-confirm'] ); |
|
| 1084 | - return apply_filters( "wpinv_payment_confirm_$gateway", $content ); |
|
| 1083 | + $gateway = sanitize_text_field($_GET['payment-confirm']); |
|
| 1084 | + return apply_filters("wpinv_payment_confirm_$gateway", $content); |
|
| 1085 | 1085 | |
| 1086 | 1086 | } |
| 1087 | 1087 | |
| 1088 | 1088 | return $content; |
| 1089 | 1089 | } |
| 1090 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
| 1090 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
| 1091 | 1091 | |
| 1092 | -function wpinv_invoice_link( $invoice_id ) { |
|
| 1093 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1092 | +function wpinv_invoice_link($invoice_id) { |
|
| 1093 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1094 | 1094 | |
| 1095 | - if ( empty( $invoice ) ) { |
|
| 1095 | + if (empty($invoice)) { |
|
| 1096 | 1096 | return null; |
| 1097 | 1097 | } |
| 1098 | 1098 | |
| 1099 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
| 1099 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
| 1100 | 1100 | |
| 1101 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
| 1101 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
| 1102 | 1102 | } |
| 1103 | 1103 | |
| 1104 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
| 1105 | - if ( empty( $note ) ) { |
|
| 1104 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
| 1105 | + if (empty($note)) { |
|
| 1106 | 1106 | return null; |
| 1107 | 1107 | } |
| 1108 | 1108 | |
| 1109 | - if ( is_int( $note ) ) { |
|
| 1110 | - $note = get_comment( $note ); |
|
| 1109 | + if (is_int($note)) { |
|
| 1110 | + $note = get_comment($note); |
|
| 1111 | 1111 | } |
| 1112 | 1112 | |
| 1113 | - if ( ! ( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
| 1113 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
| 1114 | 1114 | return null; |
| 1115 | 1115 | } |
| 1116 | 1116 | |
| 1117 | - $note_classes = array( 'note' ); |
|
| 1118 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
| 1117 | + $note_classes = array('note'); |
|
| 1118 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
| 1119 | 1119 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
| 1120 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
| 1121 | - $note_classes = ! empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
| 1120 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
| 1121 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
| 1122 | 1122 | |
| 1123 | 1123 | ob_start(); |
| 1124 | 1124 | ?> |
| 1125 | - <li rel="<?php echo absint( $note->comment_ID ); ?>" class="<?php echo esc_attr( $note_classes ); ?> mb-2"> |
|
| 1125 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mb-2"> |
|
| 1126 | 1126 | <div class="note_content"> |
| 1127 | 1127 | |
| 1128 | - <?php echo wp_kses_post( wptexturize( $note->comment_content ) ); ?> |
|
| 1128 | + <?php echo wp_kses_post(wptexturize($note->comment_content)); ?> |
|
| 1129 | 1129 | |
| 1130 | - <?php if ( ! is_admin() ) : ?> |
|
| 1130 | + <?php if (!is_admin()) : ?> |
|
| 1131 | 1131 | <em class="small form-text text-muted mt-0"> |
| 1132 | 1132 | <?php |
| 1133 | 1133 | printf( |
| 1134 | - esc_html__( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
| 1135 | - esc_html( $note->comment_author ), |
|
| 1136 | - esc_html( getpaid_format_date_value( $note->comment_date ) ), |
|
| 1137 | - esc_html( date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ) |
|
| 1134 | + esc_html__('%1$s - %2$s at %3$s', 'invoicing'), |
|
| 1135 | + esc_html($note->comment_author), |
|
| 1136 | + esc_html(getpaid_format_date_value($note->comment_date)), |
|
| 1137 | + esc_html(date_i18n(get_option('time_format'), strtotime($note->comment_date))) |
|
| 1138 | 1138 | ); |
| 1139 | 1139 | ?> |
| 1140 | 1140 | </em> |
@@ -1142,21 +1142,21 @@ discard block |
||
| 1142 | 1142 | |
| 1143 | 1143 | </div> |
| 1144 | 1144 | |
| 1145 | - <?php if ( is_admin() ) : ?> |
|
| 1145 | + <?php if (is_admin()) : ?> |
|
| 1146 | 1146 | |
| 1147 | 1147 | <p class="meta px-4 py-2"> |
| 1148 | - <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>"> |
|
| 1148 | + <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>"> |
|
| 1149 | 1149 | <?php |
| 1150 | 1150 | printf( |
| 1151 | - esc_html__( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
| 1152 | - esc_html( $note->comment_author ), |
|
| 1153 | - esc_html( getpaid_format_date_value( $note->comment_date ) ), |
|
| 1154 | - esc_html( date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ) |
|
| 1151 | + esc_html__('%1$s - %2$s at %3$s', 'invoicing'), |
|
| 1152 | + esc_html($note->comment_author), |
|
| 1153 | + esc_html(getpaid_format_date_value($note->comment_date)), |
|
| 1154 | + esc_html(date_i18n(get_option('time_format'), strtotime($note->comment_date))) |
|
| 1155 | 1155 | ); |
| 1156 | 1156 | ?> |
| 1157 | 1157 | </abbr> |
| 1158 | - <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?> |
|
| 1159 | - <a href="#" class="delete_note" data-id="<?php echo esc_attr( $note->comment_ID ); ?>"><?php esc_html_e( 'Delete note', 'invoicing' ); ?></a> |
|
| 1158 | + <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?> |
|
| 1159 | + <a href="#" class="delete_note" data-id="<?php echo esc_attr($note->comment_ID); ?>"><?php esc_html_e('Delete note', 'invoicing'); ?></a> |
|
| 1160 | 1160 | <?php } ?> |
| 1161 | 1161 | </p> |
| 1162 | 1162 | |
@@ -1165,10 +1165,10 @@ discard block |
||
| 1165 | 1165 | </li> |
| 1166 | 1166 | <?php |
| 1167 | 1167 | $note_content = ob_get_clean(); |
| 1168 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
| 1168 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
| 1169 | 1169 | |
| 1170 | - if ( $echo ) { |
|
| 1171 | - echo wp_kses_post( $note_content ); |
|
| 1170 | + if ($echo) { |
|
| 1171 | + echo wp_kses_post($note_content); |
|
| 1172 | 1172 | } else { |
| 1173 | 1173 | return $note_content; |
| 1174 | 1174 | } |
@@ -1181,43 +1181,43 @@ discard block |
||
| 1181 | 1181 | * @return string |
| 1182 | 1182 | */ |
| 1183 | 1183 | function wpinv_get_policy_text() { |
| 1184 | - $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 ); |
|
| 1184 | + $privacy_page_id = get_option('wp_page_for_privacy_policy', 0); |
|
| 1185 | 1185 | |
| 1186 | - $text = wpinv_get_option( 'invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' ) ); |
|
| 1186 | + $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]')); |
|
| 1187 | 1187 | |
| 1188 | - if ( ! $privacy_page_id ) { |
|
| 1189 | - $privacy_page_id = wpinv_get_option( 'privacy_page', 0 ); |
|
| 1188 | + if (!$privacy_page_id) { |
|
| 1189 | + $privacy_page_id = wpinv_get_option('privacy_page', 0); |
|
| 1190 | 1190 | } |
| 1191 | 1191 | |
| 1192 | - $privacy_link = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' ); |
|
| 1192 | + $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing'); |
|
| 1193 | 1193 | |
| 1194 | 1194 | $find_replace = array( |
| 1195 | 1195 | '[wpinv_privacy_policy]' => $privacy_link, |
| 1196 | 1196 | ); |
| 1197 | 1197 | |
| 1198 | - $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); |
|
| 1198 | + $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text); |
|
| 1199 | 1199 | |
| 1200 | - return wp_kses_post( wpautop( $privacy_text ) ); |
|
| 1200 | + return wp_kses_post(wpautop($privacy_text)); |
|
| 1201 | 1201 | } |
| 1202 | 1202 | |
| 1203 | 1203 | function wpinv_oxygen_fix_conflict() { |
| 1204 | 1204 | global $ct_ignore_post_types; |
| 1205 | 1205 | |
| 1206 | - if ( ! is_array( $ct_ignore_post_types ) ) { |
|
| 1206 | + if (!is_array($ct_ignore_post_types)) { |
|
| 1207 | 1207 | $ct_ignore_post_types = array(); |
| 1208 | 1208 | } |
| 1209 | 1209 | |
| 1210 | - $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form' ); |
|
| 1210 | + $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form'); |
|
| 1211 | 1211 | |
| 1212 | - foreach ( $post_types as $post_type ) { |
|
| 1212 | + foreach ($post_types as $post_type) { |
|
| 1213 | 1213 | $ct_ignore_post_types[] = $post_type; |
| 1214 | 1214 | |
| 1215 | 1215 | // Ignore post type |
| 1216 | - add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 ); |
|
| 1216 | + add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999); |
|
| 1217 | 1217 | } |
| 1218 | 1218 | |
| 1219 | - remove_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
| 1220 | - add_filter( 'template_include', 'wpinv_template', 999, 1 ); |
|
| 1219 | + remove_filter('template_include', 'wpinv_template', 10, 1); |
|
| 1220 | + add_filter('template_include', 'wpinv_template', 999, 1); |
|
| 1221 | 1221 | } |
| 1222 | 1222 | |
| 1223 | 1223 | /** |
@@ -1225,10 +1225,10 @@ discard block |
||
| 1225 | 1225 | * |
| 1226 | 1226 | * @param GetPaid_Payment_Form $form |
| 1227 | 1227 | */ |
| 1228 | -function getpaid_display_payment_form( $form ) { |
|
| 1228 | +function getpaid_display_payment_form($form) { |
|
| 1229 | 1229 | |
| 1230 | - if ( is_numeric( $form ) ) { |
|
| 1231 | - $form = new GetPaid_Payment_Form( wpinv_translate_post_id( $form ) ); |
|
| 1230 | + if (is_numeric($form)) { |
|
| 1231 | + $form = new GetPaid_Payment_Form(wpinv_translate_post_id($form)); |
|
| 1232 | 1232 | } |
| 1233 | 1233 | |
| 1234 | 1234 | $form->display(); |
@@ -1238,61 +1238,61 @@ discard block |
||
| 1238 | 1238 | /** |
| 1239 | 1239 | * Helper function to display a item payment form on the frontend. |
| 1240 | 1240 | */ |
| 1241 | -function getpaid_display_item_payment_form( $items ) { |
|
| 1241 | +function getpaid_display_item_payment_form($items) { |
|
| 1242 | 1242 | |
| 1243 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
| 1244 | - $form->set_items( $items ); |
|
| 1243 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
| 1244 | + $form->set_items($items); |
|
| 1245 | 1245 | |
| 1246 | - if ( 0 == count( $form->get_items() ) ) { |
|
| 1246 | + if (0 == count($form->get_items())) { |
|
| 1247 | 1247 | aui()->alert( |
| 1248 | 1248 | array( |
| 1249 | 1249 | 'type' => 'warning', |
| 1250 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
| 1250 | + 'content' => __('No published items found', 'invoicing'), |
|
| 1251 | 1251 | ), |
| 1252 | 1252 | true |
| 1253 | 1253 | ); |
| 1254 | 1254 | return; |
| 1255 | 1255 | } |
| 1256 | 1256 | |
| 1257 | - $extra_items = esc_attr( getpaid_convert_items_to_string( $items ) ); |
|
| 1258 | - $extra_items_key = md5( NONCE_KEY . AUTH_KEY . $extra_items ); |
|
| 1257 | + $extra_items = esc_attr(getpaid_convert_items_to_string($items)); |
|
| 1258 | + $extra_items_key = md5(NONCE_KEY . AUTH_KEY . $extra_items); |
|
| 1259 | 1259 | $extra_items = "<input type='hidden' name='getpaid-form-items' value='$extra_items' />"; |
| 1260 | 1260 | $extra_items .= "<input type='hidden' name='getpaid-form-items-key' value='$extra_items_key' />"; |
| 1261 | 1261 | |
| 1262 | - $form->display( $extra_items ); |
|
| 1262 | + $form->display($extra_items); |
|
| 1263 | 1263 | } |
| 1264 | 1264 | |
| 1265 | 1265 | /** |
| 1266 | 1266 | * Helper function to display an invoice payment form on the frontend. |
| 1267 | 1267 | */ |
| 1268 | -function getpaid_display_invoice_payment_form( $invoice_id ) { |
|
| 1268 | +function getpaid_display_invoice_payment_form($invoice_id) { |
|
| 1269 | 1269 | |
| 1270 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1270 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1271 | 1271 | |
| 1272 | - if ( empty( $invoice ) ) { |
|
| 1272 | + if (empty($invoice)) { |
|
| 1273 | 1273 | aui()->alert( |
| 1274 | 1274 | array( |
| 1275 | 1275 | 'type' => 'warning', |
| 1276 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
| 1276 | + 'content' => __('Invoice not found', 'invoicing'), |
|
| 1277 | 1277 | ), |
| 1278 | 1278 | true |
| 1279 | 1279 | ); |
| 1280 | 1280 | return; |
| 1281 | 1281 | } |
| 1282 | 1282 | |
| 1283 | - if ( $invoice->is_paid() ) { |
|
| 1283 | + if ($invoice->is_paid()) { |
|
| 1284 | 1284 | aui()->alert( |
| 1285 | 1285 | array( |
| 1286 | 1286 | 'type' => 'warning', |
| 1287 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
| 1287 | + 'content' => __('Invoice has already been paid', 'invoicing'), |
|
| 1288 | 1288 | ), |
| 1289 | 1289 | true |
| 1290 | 1290 | ); |
| 1291 | 1291 | return; |
| 1292 | 1292 | } |
| 1293 | 1293 | |
| 1294 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
| 1295 | - $form->set_items( $invoice->get_items() ); |
|
| 1294 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
| 1295 | + $form->set_items($invoice->get_items()); |
|
| 1296 | 1296 | |
| 1297 | 1297 | $form->display(); |
| 1298 | 1298 | } |
@@ -1300,24 +1300,24 @@ discard block |
||
| 1300 | 1300 | /** |
| 1301 | 1301 | * Helper function to convert item string to array. |
| 1302 | 1302 | */ |
| 1303 | -function getpaid_convert_items_to_array( $items ) { |
|
| 1304 | - $items = array_filter( array_map( 'trim', explode( ',', $items ) ) ); |
|
| 1303 | +function getpaid_convert_items_to_array($items) { |
|
| 1304 | + $items = array_filter(array_map('trim', explode(',', $items))); |
|
| 1305 | 1305 | $prepared = array(); |
| 1306 | 1306 | |
| 1307 | - foreach ( $items as $item ) { |
|
| 1308 | - $data = array_map( 'trim', explode( '|', $item ) ); |
|
| 1307 | + foreach ($items as $item) { |
|
| 1308 | + $data = array_map('trim', explode('|', $item)); |
|
| 1309 | 1309 | |
| 1310 | - if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) { |
|
| 1310 | + if (empty($data[0]) || !is_numeric($data[0])) { |
|
| 1311 | 1311 | continue; |
| 1312 | 1312 | } |
| 1313 | 1313 | |
| 1314 | 1314 | $quantity = 1; |
| 1315 | - if ( isset( $data[1] ) && is_numeric( $data[1] ) ) { |
|
| 1315 | + if (isset($data[1]) && is_numeric($data[1])) { |
|
| 1316 | 1316 | $quantity = (float) $data[1]; |
| 1317 | 1317 | } |
| 1318 | 1318 | |
| 1319 | 1319 | // WPML support. |
| 1320 | - $prepared[ wpinv_translate_post_id( $data[0] ) ] = $quantity; |
|
| 1320 | + $prepared[wpinv_translate_post_id($data[0])] = $quantity; |
|
| 1321 | 1321 | |
| 1322 | 1322 | } |
| 1323 | 1323 | |
@@ -1327,13 +1327,13 @@ discard block |
||
| 1327 | 1327 | /** |
| 1328 | 1328 | * Helper function to convert item array to string. |
| 1329 | 1329 | */ |
| 1330 | -function getpaid_convert_items_to_string( $items ) { |
|
| 1330 | +function getpaid_convert_items_to_string($items) { |
|
| 1331 | 1331 | $prepared = array(); |
| 1332 | 1332 | |
| 1333 | - foreach ( $items as $item => $quantity ) { |
|
| 1333 | + foreach ($items as $item => $quantity) { |
|
| 1334 | 1334 | $prepared[] = "$item|$quantity"; |
| 1335 | 1335 | } |
| 1336 | - return implode( ',', $prepared ); |
|
| 1336 | + return implode(',', $prepared); |
|
| 1337 | 1337 | } |
| 1338 | 1338 | |
| 1339 | 1339 | /** |
@@ -1341,21 +1341,21 @@ discard block |
||
| 1341 | 1341 | * |
| 1342 | 1342 | * Provide a label and one of $form, $items or $invoice. |
| 1343 | 1343 | */ |
| 1344 | -function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) { |
|
| 1345 | - $label = sanitize_text_field( $label ); |
|
| 1344 | +function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) { |
|
| 1345 | + $label = sanitize_text_field($label); |
|
| 1346 | 1346 | |
| 1347 | - if ( ! empty( $form ) ) { |
|
| 1348 | - $form = esc_attr( $form ); |
|
| 1347 | + if (!empty($form)) { |
|
| 1348 | + $form = esc_attr($form); |
|
| 1349 | 1349 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>"; |
| 1350 | 1350 | } |
| 1351 | 1351 | |
| 1352 | - if ( ! empty( $items ) ) { |
|
| 1353 | - $items = esc_attr( $items ); |
|
| 1352 | + if (!empty($items)) { |
|
| 1353 | + $items = esc_attr($items); |
|
| 1354 | 1354 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>"; |
| 1355 | 1355 | } |
| 1356 | 1356 | |
| 1357 | - if ( ! empty( $invoice ) ) { |
|
| 1358 | - $invoice = esc_attr( $invoice ); |
|
| 1357 | + if (!empty($invoice)) { |
|
| 1358 | + $invoice = esc_attr($invoice); |
|
| 1359 | 1359 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-invoice='$invoice'>$label</button>"; |
| 1360 | 1360 | } |
| 1361 | 1361 | |
@@ -1366,17 +1366,17 @@ discard block |
||
| 1366 | 1366 | * |
| 1367 | 1367 | * @param WPInv_Invoice $invoice |
| 1368 | 1368 | */ |
| 1369 | -function getpaid_the_invoice_description( $invoice ) { |
|
| 1369 | +function getpaid_the_invoice_description($invoice) { |
|
| 1370 | 1370 | $description = $invoice->get_description(); |
| 1371 | 1371 | |
| 1372 | - if ( empty( $description ) ) { |
|
| 1372 | + if (empty($description)) { |
|
| 1373 | 1373 | return; |
| 1374 | 1374 | } |
| 1375 | 1375 | |
| 1376 | - echo "<small class='getpaid-invoice-description text-dark p-2 form-text' style='margin-bottom: 20px; border-left: 2px solid #2196F3;'><em>" . wp_kses_post( wpautop( $description ) ) . "</em></small>"; |
|
| 1376 | + echo "<small class='getpaid-invoice-description text-dark p-2 form-text' style='margin-bottom: 20px; border-left: 2px solid #2196F3;'><em>" . wp_kses_post(wpautop($description)) . "</em></small>"; |
|
| 1377 | 1377 | } |
| 1378 | -add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 ); |
|
| 1379 | -add_action( 'wpinv_email_billing_details', 'getpaid_the_invoice_description', 100 ); |
|
| 1378 | +add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100); |
|
| 1379 | +add_action('wpinv_email_billing_details', 'getpaid_the_invoice_description', 100); |
|
| 1380 | 1380 | |
| 1381 | 1381 | /** |
| 1382 | 1382 | * Render element on a form. |
@@ -1384,79 +1384,79 @@ discard block |
||
| 1384 | 1384 | * @param array $element |
| 1385 | 1385 | * @param GetPaid_Payment_Form $form |
| 1386 | 1386 | */ |
| 1387 | -function getpaid_payment_form_element( $element, $form ) { |
|
| 1387 | +function getpaid_payment_form_element($element, $form) { |
|
| 1388 | 1388 | |
| 1389 | 1389 | // Set up the args. |
| 1390 | - $element_type = trim( $element['type'] ); |
|
| 1390 | + $element_type = trim($element['type']); |
|
| 1391 | 1391 | $element['form'] = $form; |
| 1392 | - extract( $element ); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract |
|
| 1392 | + extract($element); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract |
|
| 1393 | 1393 | |
| 1394 | 1394 | // Try to locate the appropriate template. |
| 1395 | - $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" ); |
|
| 1395 | + $located = wpinv_locate_template("payment-forms/elements/$element_type.php"); |
|
| 1396 | 1396 | |
| 1397 | 1397 | // Abort if this is not our element. |
| 1398 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
| 1398 | + if (empty($located) || !file_exists($located)) { |
|
| 1399 | 1399 | return; |
| 1400 | 1400 | } |
| 1401 | 1401 | |
| 1402 | 1402 | // Generate the class and id of the element. |
| 1403 | - $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) ); |
|
| 1404 | - $id = isset( $id ) ? $id : uniqid( 'gp' ); |
|
| 1403 | + $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type)); |
|
| 1404 | + $id = isset($id) ? $id : uniqid('gp'); |
|
| 1405 | 1405 | |
| 1406 | - $element_id = ! empty( $element['label'] ) ? sanitize_title( $element['label'] ) : $id; |
|
| 1407 | - $query_value = isset( $_GET[ $element_id ] ) ? wpinv_clean( urldecode_deep( $_GET[ $element_id ] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 1406 | + $element_id = !empty($element['label']) ? sanitize_title($element['label']) : $id; |
|
| 1407 | + $query_value = isset($_GET[$element_id]) ? wpinv_clean(urldecode_deep($_GET[$element_id])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 1408 | 1408 | |
| 1409 | 1409 | $element_id = 'getpaid-' . $element_id; |
| 1410 | - if ( ! empty( $GLOBALS['rendered_getpaid_forms'][ $form->get_id() ] ) ) { |
|
| 1411 | - $element_id = $element_id . '-' . $GLOBALS['rendered_getpaid_forms'][ $form->get_id() ]; |
|
| 1410 | + if (!empty($GLOBALS['rendered_getpaid_forms'][$form->get_id()])) { |
|
| 1411 | + $element_id = $element_id . '-' . $GLOBALS['rendered_getpaid_forms'][$form->get_id()]; |
|
| 1412 | 1412 | } |
| 1413 | 1413 | |
| 1414 | 1414 | // Echo the opening wrapper. |
| 1415 | - echo "<div class='getpaid-payment-form-element " . esc_attr( $wrapper_class ) . "'>"; |
|
| 1415 | + echo "<div class='getpaid-payment-form-element " . esc_attr($wrapper_class) . "'>"; |
|
| 1416 | 1416 | |
| 1417 | 1417 | // Fires before displaying a given element type's content. |
| 1418 | - do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form ); |
|
| 1418 | + do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form); |
|
| 1419 | 1419 | |
| 1420 | 1420 | // Include the template for the element. |
| 1421 | 1421 | include $located; |
| 1422 | 1422 | |
| 1423 | 1423 | // Fires after displaying a given element type's content. |
| 1424 | - do_action( "getpaid_payment_form_{$element_type}_element", $element, $form ); |
|
| 1424 | + do_action("getpaid_payment_form_{$element_type}_element", $element, $form); |
|
| 1425 | 1425 | |
| 1426 | 1426 | // Echo the closing wrapper. |
| 1427 | 1427 | echo '</div>'; |
| 1428 | 1428 | } |
| 1429 | -add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 ); |
|
| 1429 | +add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2); |
|
| 1430 | 1430 | |
| 1431 | 1431 | /** |
| 1432 | 1432 | * Render an element's edit page. |
| 1433 | 1433 | * |
| 1434 | 1434 | * @param WP_Post $post |
| 1435 | 1435 | */ |
| 1436 | -function getpaid_payment_form_edit_element_template( $post ) { |
|
| 1436 | +function getpaid_payment_form_edit_element_template($post) { |
|
| 1437 | 1437 | |
| 1438 | 1438 | // Retrieve all elements. |
| 1439 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
| 1439 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
| 1440 | 1440 | |
| 1441 | - foreach ( $all_elements as $element ) { |
|
| 1441 | + foreach ($all_elements as $element) { |
|
| 1442 | 1442 | |
| 1443 | 1443 | // Try to locate the appropriate template. |
| 1444 | - $element = esc_attr( sanitize_key( $element ) ); |
|
| 1445 | - $located = wpinv_locate_template( "payment-forms-admin/edit/$element.php" ); |
|
| 1444 | + $element = esc_attr(sanitize_key($element)); |
|
| 1445 | + $located = wpinv_locate_template("payment-forms-admin/edit/$element.php"); |
|
| 1446 | 1446 | |
| 1447 | 1447 | // Continue if this is not our element. |
| 1448 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
| 1448 | + if (empty($located) || !file_exists($located)) { |
|
| 1449 | 1449 | continue; |
| 1450 | 1450 | } |
| 1451 | 1451 | |
| 1452 | 1452 | // Include the template for the element. |
| 1453 | - echo "<div v-if=\"active_form_element.type=='" . esc_attr( $element ) . "'\">"; |
|
| 1453 | + echo "<div v-if=\"active_form_element.type=='" . esc_attr($element) . "'\">"; |
|
| 1454 | 1454 | include $located; |
| 1455 | 1455 | echo '</div>'; |
| 1456 | 1456 | } |
| 1457 | 1457 | |
| 1458 | 1458 | } |
| 1459 | -add_action( 'getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template' ); |
|
| 1459 | +add_action('getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template'); |
|
| 1460 | 1460 | |
| 1461 | 1461 | /** |
| 1462 | 1462 | * Render an element's preview. |
@@ -1465,27 +1465,27 @@ discard block |
||
| 1465 | 1465 | function getpaid_payment_form_render_element_preview_template() { |
| 1466 | 1466 | |
| 1467 | 1467 | // Retrieve all elements. |
| 1468 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
| 1468 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
| 1469 | 1469 | |
| 1470 | - foreach ( $all_elements as $element ) { |
|
| 1470 | + foreach ($all_elements as $element) { |
|
| 1471 | 1471 | |
| 1472 | 1472 | // Try to locate the appropriate template. |
| 1473 | - $element = sanitize_key( $element ); |
|
| 1474 | - $located = wpinv_locate_template( "payment-forms-admin/previews/$element.php" ); |
|
| 1473 | + $element = sanitize_key($element); |
|
| 1474 | + $located = wpinv_locate_template("payment-forms-admin/previews/$element.php"); |
|
| 1475 | 1475 | |
| 1476 | 1476 | // Continue if this is not our element. |
| 1477 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
| 1477 | + if (empty($located) || !file_exists($located)) { |
|
| 1478 | 1478 | continue; |
| 1479 | 1479 | } |
| 1480 | 1480 | |
| 1481 | 1481 | // Include the template for the element. |
| 1482 | - echo "<div v-if=\"form_element.type=='" . esc_html( $element ) . "'\">"; |
|
| 1482 | + echo "<div v-if=\"form_element.type=='" . esc_html($element) . "'\">"; |
|
| 1483 | 1483 | include $located; |
| 1484 | 1484 | echo '</div>'; |
| 1485 | 1485 | } |
| 1486 | 1486 | |
| 1487 | 1487 | } |
| 1488 | -add_action( 'wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template' ); |
|
| 1488 | +add_action('wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template'); |
|
| 1489 | 1489 | |
| 1490 | 1490 | /** |
| 1491 | 1491 | * Shows a list of gateways that support recurring payments. |
@@ -1493,17 +1493,17 @@ discard block |
||
| 1493 | 1493 | function wpinv_get_recurring_gateways_text() { |
| 1494 | 1494 | $gateways = array(); |
| 1495 | 1495 | |
| 1496 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
| 1497 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
| 1498 | - $gateways[] = sanitize_text_field( $gateway['admin_label'] ); |
|
| 1496 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
| 1497 | + if (wpinv_gateway_support_subscription($key)) { |
|
| 1498 | + $gateways[] = sanitize_text_field($gateway['admin_label']); |
|
| 1499 | 1499 | } |
| 1500 | 1500 | } |
| 1501 | 1501 | |
| 1502 | - if ( empty( $gateways ) ) { |
|
| 1503 | - return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) . '</span>'; |
|
| 1502 | + if (empty($gateways)) { |
|
| 1503 | + return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . '</span>'; |
|
| 1504 | 1504 | } |
| 1505 | 1505 | |
| 1506 | - return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) . '</span>'; |
|
| 1506 | + return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . '</span>'; |
|
| 1507 | 1507 | |
| 1508 | 1508 | } |
| 1509 | 1509 | |
@@ -1513,7 +1513,7 @@ discard block |
||
| 1513 | 1513 | * @return GetPaid_Template |
| 1514 | 1514 | */ |
| 1515 | 1515 | function getpaid_template() { |
| 1516 | - return getpaid()->get( 'template' ); |
|
| 1516 | + return getpaid()->get('template'); |
|
| 1517 | 1517 | } |
| 1518 | 1518 | |
| 1519 | 1519 | /** |
@@ -1522,8 +1522,8 @@ discard block |
||
| 1522 | 1522 | * @param array args |
| 1523 | 1523 | * @return string |
| 1524 | 1524 | */ |
| 1525 | -function getpaid_paginate_links( $args ) { |
|
| 1526 | - return str_replace( 'page-link dots', 'page-link text-dark', aui()->pagination( $args ) ); |
|
| 1525 | +function getpaid_paginate_links($args) { |
|
| 1526 | + return str_replace('page-link dots', 'page-link text-dark', aui()->pagination($args)); |
|
| 1527 | 1527 | } |
| 1528 | 1528 | |
| 1529 | 1529 | /** |
@@ -1533,22 +1533,22 @@ discard block |
||
| 1533 | 1533 | * @param string state |
| 1534 | 1534 | * @return string |
| 1535 | 1535 | */ |
| 1536 | -function getpaid_get_states_select_markup( $country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state', $echo = false ) { |
|
| 1536 | +function getpaid_get_states_select_markup($country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state', $echo = false) { |
|
| 1537 | 1537 | |
| 1538 | - $states = wpinv_get_country_states( $country ); |
|
| 1539 | - $uniqid = uniqid( '_' ); |
|
| 1538 | + $states = wpinv_get_country_states($country); |
|
| 1539 | + $uniqid = uniqid('_'); |
|
| 1540 | 1540 | |
| 1541 | - if ( ! empty( $states ) ) { |
|
| 1541 | + if (!empty($states)) { |
|
| 1542 | 1542 | |
| 1543 | 1543 | return aui()->select( |
| 1544 | 1544 | array( |
| 1545 | 1545 | 'options' => $states, |
| 1546 | - 'name' => esc_attr( $field_name ), |
|
| 1547 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
| 1548 | - 'value' => sanitize_text_field( $state ), |
|
| 1546 | + 'name' => esc_attr($field_name), |
|
| 1547 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
| 1548 | + 'value' => sanitize_text_field($state), |
|
| 1549 | 1549 | 'placeholder' => $placeholder, |
| 1550 | 1550 | 'required' => $required, |
| 1551 | - 'label' => wp_kses_post( $label ), |
|
| 1551 | + 'label' => wp_kses_post($label), |
|
| 1552 | 1552 | 'label_type' => 'vertical', |
| 1553 | 1553 | 'help_text' => $help_text, |
| 1554 | 1554 | 'class' => 'getpaid-address-field wpinv_state', |
@@ -1565,14 +1565,14 @@ discard block |
||
| 1565 | 1565 | |
| 1566 | 1566 | return aui()->input( |
| 1567 | 1567 | array( |
| 1568 | - 'name' => esc_attr( $field_name ), |
|
| 1569 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
| 1568 | + 'name' => esc_attr($field_name), |
|
| 1569 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
| 1570 | 1570 | 'placeholder' => $placeholder, |
| 1571 | 1571 | 'required' => $required, |
| 1572 | - 'label' => wp_kses_post( $label ), |
|
| 1572 | + 'label' => wp_kses_post($label), |
|
| 1573 | 1573 | 'label_type' => 'vertical', |
| 1574 | 1574 | 'help_text' => $help_text, |
| 1575 | - 'value' => sanitize_text_field( $state ), |
|
| 1575 | + 'value' => sanitize_text_field($state), |
|
| 1576 | 1576 | 'class' => 'getpaid-address-field wpinv_state', |
| 1577 | 1577 | 'wrap_class' => "$wrapper_class getpaid-address-field-wrapper__state", |
| 1578 | 1578 | 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state', |
@@ -1591,16 +1591,16 @@ discard block |
||
| 1591 | 1591 | * @param array $element |
| 1592 | 1592 | * @return string |
| 1593 | 1593 | */ |
| 1594 | -function getpaid_get_form_element_grid_class( $element ) { |
|
| 1594 | +function getpaid_get_form_element_grid_class($element) { |
|
| 1595 | 1595 | |
| 1596 | 1596 | $class = 'col-12'; |
| 1597 | - $width = empty( $element['grid_width'] ) ? 'full' : $element['grid_width']; |
|
| 1597 | + $width = empty($element['grid_width']) ? 'full' : $element['grid_width']; |
|
| 1598 | 1598 | |
| 1599 | - if ( $width == 'half' ) { |
|
| 1599 | + if ($width == 'half') { |
|
| 1600 | 1600 | $class .= ' col-md-6'; |
| 1601 | 1601 | } |
| 1602 | 1602 | |
| 1603 | - if ( $width == 'third' ) { |
|
| 1603 | + if ($width == 'third') { |
|
| 1604 | 1604 | $class .= ' col-md-4'; |
| 1605 | 1605 | } |
| 1606 | 1606 | |
@@ -1615,15 +1615,15 @@ discard block |
||
| 1615 | 1615 | * |
| 1616 | 1616 | * @return string |
| 1617 | 1617 | */ |
| 1618 | -function getpaid_embed_url( $payment_form = false, $items = false ) { |
|
| 1618 | +function getpaid_embed_url($payment_form = false, $items = false) { |
|
| 1619 | 1619 | |
| 1620 | 1620 | return add_query_arg( |
| 1621 | 1621 | array( |
| 1622 | 1622 | 'getpaid_embed' => 1, |
| 1623 | - 'form' => $payment_form ? absint( $payment_form ) : false, |
|
| 1624 | - 'item' => $items ? urlencode( $items ) : false, |
|
| 1623 | + 'form' => $payment_form ? absint($payment_form) : false, |
|
| 1624 | + 'item' => $items ? urlencode($items) : false, |
|
| 1625 | 1625 | ), |
| 1626 | - home_url( 'index.php' ) |
|
| 1626 | + home_url('index.php') |
|
| 1627 | 1627 | ); |
| 1628 | 1628 | |
| 1629 | 1629 | } |
@@ -1633,13 +1633,13 @@ discard block |
||
| 1633 | 1633 | * |
| 1634 | 1634 | * @return string |
| 1635 | 1635 | */ |
| 1636 | -function getpaid_filter_embed_template( $template ) { |
|
| 1636 | +function getpaid_filter_embed_template($template) { |
|
| 1637 | 1637 | |
| 1638 | - if ( isset( $_GET['getpaid_embed'] ) ) { |
|
| 1639 | - wpinv_get_template( 'payment-forms/embed.php' ); |
|
| 1638 | + if (isset($_GET['getpaid_embed'])) { |
|
| 1639 | + wpinv_get_template('payment-forms/embed.php'); |
|
| 1640 | 1640 | exit; |
| 1641 | 1641 | } |
| 1642 | 1642 | |
| 1643 | 1643 | return $template; |
| 1644 | 1644 | } |
| 1645 | -add_filter( 'template_include', 'getpaid_filter_embed_template' ); |
|
| 1645 | +add_filter('template_include', 'getpaid_filter_embed_template'); |
|
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | $tax_rates = GetPaid_Tax::get_all_tax_rates(); |
| 10 | 10 | $dummy_rate = array( |
@@ -13,11 +13,11 @@ discard block |
||
| 13 | 13 | 'global' => true, |
| 14 | 14 | 'rate' => wpinv_get_default_tax_rate(), |
| 15 | 15 | 'reduced_rate' => 5, |
| 16 | - 'name' => __( 'VAT', 'invoicing' ), |
|
| 16 | + 'name' => __('VAT', 'invoicing'), |
|
| 17 | 17 | ); |
| 18 | 18 | |
| 19 | 19 | $reset_url = wp_nonce_url( |
| 20 | - add_query_arg( 'getpaid-admin-action', 'reset_tax_rates' ), |
|
| 20 | + add_query_arg('getpaid-admin-action', 'reset_tax_rates'), |
|
| 21 | 21 | 'getpaid-nonce', |
| 22 | 22 | 'getpaid-nonce' |
| 23 | 23 | ); |
@@ -25,34 +25,34 @@ discard block |
||
| 25 | 25 | ?> |
| 26 | 26 | <div class="table-responsive"> |
| 27 | 27 | <table id="wpinv_tax_rates" class="widefat fixed table"> |
| 28 | - <caption><?php echo esc_html_e( 'Enter tax rates for specific regions.', 'invoicing' ); ?></caption> |
|
| 28 | + <caption><?php echo esc_html_e('Enter tax rates for specific regions.', 'invoicing'); ?></caption> |
|
| 29 | 29 | |
| 30 | 30 | <thead> |
| 31 | 31 | <tr class="table-light"> |
| 32 | 32 | |
| 33 | 33 | <th scope="col" class="border-bottom border-top"> |
| 34 | - <?php esc_html_e( 'Country', 'invoicing' ); ?> |
|
| 35 | - <?php getpaid_get_help_tip( __( 'Optionally limit this tax rate to a specific country.', 'invoicing' ), 'position-static', true ); ?> |
|
| 34 | + <?php esc_html_e('Country', 'invoicing'); ?> |
|
| 35 | + <?php getpaid_get_help_tip(__('Optionally limit this tax rate to a specific country.', 'invoicing'), 'position-static', true); ?> |
|
| 36 | 36 | </th> |
| 37 | 37 | |
| 38 | 38 | <th scope="col" class="border-bottom border-top"> |
| 39 | - <?php esc_html_e( 'State', 'invoicing' ); ?> |
|
| 40 | - <?php getpaid_get_help_tip( __( 'Separate state codes using a comma or leave blank to apply country wide.', 'invoicing' ), 'position-static', true ); ?> |
|
| 39 | + <?php esc_html_e('State', 'invoicing'); ?> |
|
| 40 | + <?php getpaid_get_help_tip(__('Separate state codes using a comma or leave blank to apply country wide.', 'invoicing'), 'position-static', true); ?> |
|
| 41 | 41 | </th> |
| 42 | 42 | |
| 43 | 43 | <th scope="col" class="border-bottom border-top"> |
| 44 | - <?php esc_html_e( 'Standard Rate %', 'invoicing' ); ?> |
|
| 45 | - <?php getpaid_get_help_tip( __( 'The tax rate (percentage) to charge on items that use the "Standard rate" tax class.', 'invoicing' ), 'position-static', true ); ?> |
|
| 44 | + <?php esc_html_e('Standard Rate %', 'invoicing'); ?> |
|
| 45 | + <?php getpaid_get_help_tip(__('The tax rate (percentage) to charge on items that use the "Standard rate" tax class.', 'invoicing'), 'position-static', true); ?> |
|
| 46 | 46 | </th> |
| 47 | 47 | |
| 48 | 48 | <th scope="col" class="border-bottom border-top"> |
| 49 | - <?php esc_html_e( 'Reduced Rate %', 'invoicing' ); ?> |
|
| 50 | - <?php getpaid_get_help_tip( __( 'The tax rate (percentage) to charge on items that use the "Reduced rate" tax class.', 'invoicing' ), 'position-static', true ); ?> |
|
| 49 | + <?php esc_html_e('Reduced Rate %', 'invoicing'); ?> |
|
| 50 | + <?php getpaid_get_help_tip(__('The tax rate (percentage) to charge on items that use the "Reduced rate" tax class.', 'invoicing'), 'position-static', true); ?> |
|
| 51 | 51 | </th> |
| 52 | 52 | |
| 53 | 53 | <th scope="col" class="border-bottom border-top"> |
| 54 | - <?php esc_html_e( 'Tax Name', 'invoicing' ); ?> |
|
| 55 | - <?php getpaid_get_help_tip( __( 'The name of this tax, e.g VAT.', 'invoicing' ), 'position-static', true ); ?> |
|
| 54 | + <?php esc_html_e('Tax Name', 'invoicing'); ?> |
|
| 55 | + <?php getpaid_get_help_tip(__('The name of this tax, e.g VAT.', 'invoicing'), 'position-static', true); ?> |
|
| 56 | 56 | </th> |
| 57 | 57 | |
| 58 | 58 | <th scope="col" class="border-bottom border-top" style="width:32px"> </th> |
@@ -61,19 +61,19 @@ discard block |
||
| 61 | 61 | </thead> |
| 62 | 62 | |
| 63 | 63 | <tbody> |
| 64 | - <?php array_walk( $tax_rates, 'wpinv_tax_rate_callback' ); ?> |
|
| 64 | + <?php array_walk($tax_rates, 'wpinv_tax_rate_callback'); ?> |
|
| 65 | 65 | </tbody> |
| 66 | 66 | |
| 67 | 67 | <tfoot> |
| 68 | 68 | <tr class="table-light"> |
| 69 | 69 | <td colspan="6" class="border-top"> |
| 70 | 70 | |
| 71 | - <button type="button" class="button button-secondary wpinv_add_tax_rate" aria-label="<?php esc_attr_e( 'Add Tax Rate', 'invoicing' ); ?>"> |
|
| 72 | - <span><?php esc_html_e( 'Add Tax Rate', 'invoicing' ); ?></span> |
|
| 71 | + <button type="button" class="button button-secondary wpinv_add_tax_rate" aria-label="<?php esc_attr_e('Add Tax Rate', 'invoicing'); ?>"> |
|
| 72 | + <span><?php esc_html_e('Add Tax Rate', 'invoicing'); ?></span> |
|
| 73 | 73 | </button> |
| 74 | 74 | |
| 75 | - <a href="<?php echo esc_url( $reset_url ); ?>" class="button button-secondary wpinv_reset_tax_rates" aria-label="<?php esc_attr_e( 'Reset Tax Rates', 'invoicing' ); ?>"> |
|
| 76 | - <span><?php esc_html_e( 'Reset Tax Rates', 'invoicing' ); ?></span> |
|
| 75 | + <a href="<?php echo esc_url($reset_url); ?>" class="button button-secondary wpinv_reset_tax_rates" aria-label="<?php esc_attr_e('Reset Tax Rates', 'invoicing'); ?>"> |
|
| 76 | + <span><?php esc_html_e('Reset Tax Rates', 'invoicing'); ?></span> |
|
| 77 | 77 | </a> |
| 78 | 78 | </td> |
| 79 | 79 | </tr> |
@@ -82,6 +82,6 @@ discard block |
||
| 82 | 82 | </div> |
| 83 | 83 | |
| 84 | 84 | <script type="text/html" id="tmpl-wpinv-tax-rate-row"> |
| 85 | - <?php wpinv_tax_rate_callback( $dummy_rate, 0, true ); ?> |
|
| 85 | + <?php wpinv_tax_rate_callback($dummy_rate, 0, true); ?> |
|
| 86 | 86 | </script> |
| 87 | 87 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; // Exit if accessed directly |
| 4 | 4 | } |
| 5 | 5 | |
@@ -14,18 +14,18 @@ discard block |
||
| 14 | 14 | * Hook in methods. |
| 15 | 15 | */ |
| 16 | 16 | public static function init() { |
| 17 | - add_action( 'init', array( __CLASS__, 'init_hooks' ), 0 ); |
|
| 18 | - add_action( 'admin_notices', array( __CLASS__, 'notices' ) ); |
|
| 17 | + add_action('init', array(__CLASS__, 'init_hooks'), 0); |
|
| 18 | + add_action('admin_notices', array(__CLASS__, 'notices')); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | public static function init_hooks() { |
| 22 | - if ( false === ( $page_uris = get_transient( 'wpinv_cache_excluded_uris' ) ) ) { |
|
| 23 | - $checkout_page = wpinv_get_option( 'checkout_page', '' ); |
|
| 24 | - $success_page = wpinv_get_option( 'success_page', '' ); |
|
| 25 | - $failure_page = wpinv_get_option( 'failure_page', '' ); |
|
| 26 | - $history_page = wpinv_get_option( 'invoice_history_page', '' ); |
|
| 27 | - $subscr_page = wpinv_get_option( 'invoice_subscription_page', '' ); |
|
| 28 | - if ( empty( $checkout_page ) || empty( $success_page ) || empty( $failure_page ) || empty( $history_page ) || empty( $subscr_page ) ) { |
|
| 22 | + if (false === ($page_uris = get_transient('wpinv_cache_excluded_uris'))) { |
|
| 23 | + $checkout_page = wpinv_get_option('checkout_page', ''); |
|
| 24 | + $success_page = wpinv_get_option('success_page', ''); |
|
| 25 | + $failure_page = wpinv_get_option('failure_page', ''); |
|
| 26 | + $history_page = wpinv_get_option('invoice_history_page', ''); |
|
| 27 | + $subscr_page = wpinv_get_option('invoice_subscription_page', ''); |
|
| 28 | + if (empty($checkout_page) || empty($success_page) || empty($failure_page) || empty($history_page) || empty($subscr_page)) { |
|
| 29 | 29 | return; |
| 30 | 30 | } |
| 31 | 31 | |
@@ -39,34 +39,34 @@ discard block |
||
| 39 | 39 | $page_uris[] = 'p=' . $subscr_page; |
| 40 | 40 | |
| 41 | 41 | // Exclude permalinks |
| 42 | - $checkout_page = get_post( $checkout_page ); |
|
| 43 | - $success_page = get_post( $success_page ); |
|
| 44 | - $failure_page = get_post( $failure_page ); |
|
| 45 | - $history_page = get_post( $history_page ); |
|
| 46 | - $subscr_page = get_post( $subscr_page ); |
|
| 42 | + $checkout_page = get_post($checkout_page); |
|
| 43 | + $success_page = get_post($success_page); |
|
| 44 | + $failure_page = get_post($failure_page); |
|
| 45 | + $history_page = get_post($history_page); |
|
| 46 | + $subscr_page = get_post($subscr_page); |
|
| 47 | 47 | |
| 48 | - if ( ! is_null( $checkout_page ) ) { |
|
| 48 | + if (!is_null($checkout_page)) { |
|
| 49 | 49 | $page_uris[] = '/' . $checkout_page->post_name; |
| 50 | 50 | } |
| 51 | - if ( ! is_null( $success_page ) ) { |
|
| 51 | + if (!is_null($success_page)) { |
|
| 52 | 52 | $page_uris[] = '/' . $success_page->post_name; |
| 53 | 53 | } |
| 54 | - if ( ! is_null( $failure_page ) ) { |
|
| 54 | + if (!is_null($failure_page)) { |
|
| 55 | 55 | $page_uris[] = '/' . $failure_page->post_name; |
| 56 | 56 | } |
| 57 | - if ( ! is_null( $history_page ) ) { |
|
| 57 | + if (!is_null($history_page)) { |
|
| 58 | 58 | $page_uris[] = '/' . $history_page->post_name; |
| 59 | 59 | } |
| 60 | - if ( ! is_null( $subscr_page ) ) { |
|
| 60 | + if (!is_null($subscr_page)) { |
|
| 61 | 61 | $page_uris[] = '/' . $subscr_page->post_name; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - set_transient( 'wpinv_cache_excluded_uris', $page_uris ); |
|
| 64 | + set_transient('wpinv_cache_excluded_uris', $page_uris); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - if ( is_array( $page_uris ) ) { |
|
| 68 | - foreach ( $page_uris as $uri ) { |
|
| 69 | - if ( strstr( $_SERVER['REQUEST_URI'], $uri ) ) { |
|
| 67 | + if (is_array($page_uris)) { |
|
| 68 | + foreach ($page_uris as $uri) { |
|
| 69 | + if (strstr($_SERVER['REQUEST_URI'], $uri)) { |
|
| 70 | 70 | self::nocache(); |
| 71 | 71 | break; |
| 72 | 72 | } |
@@ -79,14 +79,14 @@ discard block |
||
| 79 | 79 | * @access private |
| 80 | 80 | */ |
| 81 | 81 | private static function nocache() { |
| 82 | - if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
|
| 83 | - define( 'DONOTCACHEPAGE', true ); |
|
| 82 | + if (!defined('DONOTCACHEPAGE')) { |
|
| 83 | + define('DONOTCACHEPAGE', true); |
|
| 84 | 84 | } |
| 85 | - if ( ! defined( 'DONOTCACHEOBJECT' ) ) { |
|
| 86 | - define( 'DONOTCACHEOBJECT', true ); |
|
| 85 | + if (!defined('DONOTCACHEOBJECT')) { |
|
| 86 | + define('DONOTCACHEOBJECT', true); |
|
| 87 | 87 | } |
| 88 | - if ( ! defined( 'DONOTCACHEDB' ) ) { |
|
| 89 | - define( 'DONOTCACHEDB', true ); |
|
| 88 | + if (!defined('DONOTCACHEDB')) { |
|
| 89 | + define('DONOTCACHEDB', true); |
|
| 90 | 90 | } |
| 91 | 91 | nocache_headers(); |
| 92 | 92 | } |
@@ -95,18 +95,18 @@ discard block |
||
| 95 | 95 | * notices function. |
| 96 | 96 | */ |
| 97 | 97 | public static function notices() { |
| 98 | - if ( ! function_exists( 'w3tc_pgcache_flush' ) || ! function_exists( 'w3_instance' ) ) { |
|
| 98 | + if (!function_exists('w3tc_pgcache_flush') || !function_exists('w3_instance')) { |
|
| 99 | 99 | return; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - $config = w3_instance( 'W3_Config' ); |
|
| 103 | - $enabled = $config->get_integer( 'dbcache.enabled' ); |
|
| 104 | - $settings = array_map( 'trim', $config->get_array( 'dbcache.reject.sql' ) ); |
|
| 102 | + $config = w3_instance('W3_Config'); |
|
| 103 | + $enabled = $config->get_integer('dbcache.enabled'); |
|
| 104 | + $settings = array_map('trim', $config->get_array('dbcache.reject.sql')); |
|
| 105 | 105 | |
| 106 | - if ( $enabled && ! in_array( '_wp_session_', $settings ) ) { |
|
| 106 | + if ($enabled && !in_array('_wp_session_', $settings)) { |
|
| 107 | 107 | ?> |
| 108 | 108 | <div class="error"> |
| 109 | - <p><?php printf( wp_kses_post( __( 'In order for <strong>database caching</strong> to work with Invoicing you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'invoicing' ) ), '<code>_wp_session_</code>', esc_url( admin_url( 'admin.php?page=w3tc_dbcache' ) ) ); ?></p> |
|
| 109 | + <p><?php printf(wp_kses_post(__('In order for <strong>database caching</strong> to work with Invoicing you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'invoicing')), '<code>_wp_session_</code>', esc_url(admin_url('admin.php?page=w3tc_dbcache'))); ?></p> |
|
| 110 | 110 | </div> |
| 111 | 111 | <?php |
| 112 | 112 | } |
@@ -508,39 +508,39 @@ discard block |
||
| 508 | 508 | |
| 509 | 509 | switch ( $key ) { |
| 510 | 510 | |
| 511 | - case 'total': |
|
| 512 | - echo '<strong>'; |
|
| 513 | - wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
| 514 | - echo '</strong>'; |
|
| 515 | - break; |
|
| 516 | - |
|
| 517 | - case 'relationship': |
|
| 518 | - echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
| 519 | - break; |
|
| 520 | - |
|
| 521 | - case 'date': |
|
| 522 | - echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
| 523 | - break; |
|
| 524 | - |
|
| 525 | - case 'status': |
|
| 526 | - $status = $payment->get_status_nicename(); |
|
| 527 | - if ( is_admin() ) { |
|
| 528 | - $status = $payment->get_status_label_html(); |
|
| 529 | - } |
|
| 530 | - |
|
| 531 | - echo wp_kses_post( $status ); |
|
| 532 | - break; |
|
| 533 | - |
|
| 534 | - case 'invoice': |
|
| 535 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
| 536 | - |
|
| 537 | - if ( ! is_admin() ) { |
|
| 538 | - $link = esc_url( $payment->get_view_url() ); |
|
| 539 | - } |
|
| 540 | - |
|
| 541 | - $invoice = esc_html( $payment->get_number() ); |
|
| 542 | - echo wp_kses_post( "<a href='$link'>$invoice</a>" ); |
|
| 543 | - break; |
|
| 511 | + case 'total': |
|
| 512 | + echo '<strong>'; |
|
| 513 | + wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
| 514 | + echo '</strong>'; |
|
| 515 | + break; |
|
| 516 | + |
|
| 517 | + case 'relationship': |
|
| 518 | + echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
| 519 | + break; |
|
| 520 | + |
|
| 521 | + case 'date': |
|
| 522 | + echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
| 523 | + break; |
|
| 524 | + |
|
| 525 | + case 'status': |
|
| 526 | + $status = $payment->get_status_nicename(); |
|
| 527 | + if ( is_admin() ) { |
|
| 528 | + $status = $payment->get_status_label_html(); |
|
| 529 | + } |
|
| 530 | + |
|
| 531 | + echo wp_kses_post( $status ); |
|
| 532 | + break; |
|
| 533 | + |
|
| 534 | + case 'invoice': |
|
| 535 | + $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
| 536 | + |
|
| 537 | + if ( ! is_admin() ) { |
|
| 538 | + $link = esc_url( $payment->get_view_url() ); |
|
| 539 | + } |
|
| 540 | + |
|
| 541 | + $invoice = esc_html( $payment->get_number() ); |
|
| 542 | + echo wp_kses_post( "<a href='$link'>$invoice</a>" ); |
|
| 543 | + break; |
|
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | echo '</td>'; |
@@ -635,37 +635,37 @@ discard block |
||
| 635 | 635 | |
| 636 | 636 | switch ( $key ) { |
| 637 | 637 | |
| 638 | - case 'item_name': |
|
| 639 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
| 640 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
| 638 | + case 'item_name': |
|
| 639 | + $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
| 640 | + $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
| 641 | 641 | |
| 642 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
| 643 | - echo esc_html( $item_name ); |
|
| 644 | - } else { |
|
| 645 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
| 646 | - } |
|
| 642 | + if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
| 643 | + echo esc_html( $item_name ); |
|
| 644 | + } else { |
|
| 645 | + printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
| 646 | + } |
|
| 647 | 647 | |
| 648 | - break; |
|
| 648 | + break; |
|
| 649 | 649 | |
| 650 | - case 'price': |
|
| 651 | - wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
| 652 | - break; |
|
| 650 | + case 'price': |
|
| 651 | + wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
| 652 | + break; |
|
| 653 | 653 | |
| 654 | - case 'tax': |
|
| 655 | - wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
| 656 | - break; |
|
| 654 | + case 'tax': |
|
| 655 | + wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
| 656 | + break; |
|
| 657 | 657 | |
| 658 | - case 'discount': |
|
| 659 | - wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
| 660 | - break; |
|
| 658 | + case 'discount': |
|
| 659 | + wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
| 660 | + break; |
|
| 661 | 661 | |
| 662 | - case 'initial': |
|
| 663 | - wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
| 664 | - break; |
|
| 662 | + case 'initial': |
|
| 663 | + wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
| 664 | + break; |
|
| 665 | 665 | |
| 666 | - case 'recurring': |
|
| 667 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
| 668 | - break; |
|
| 666 | + case 'recurring': |
|
| 667 | + echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
| 668 | + break; |
|
| 669 | 669 | |
| 670 | 670 | } |
| 671 | 671 | |
@@ -689,29 +689,29 @@ discard block |
||
| 689 | 689 | |
| 690 | 690 | switch ( $key ) { |
| 691 | 691 | |
| 692 | - case 'item_name': |
|
| 693 | - echo esc_html( $subscription_group_fee['name'] ); |
|
| 694 | - break; |
|
| 692 | + case 'item_name': |
|
| 693 | + echo esc_html( $subscription_group_fee['name'] ); |
|
| 694 | + break; |
|
| 695 | 695 | |
| 696 | - case 'price': |
|
| 697 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 698 | - break; |
|
| 696 | + case 'price': |
|
| 697 | + wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 698 | + break; |
|
| 699 | 699 | |
| 700 | - case 'tax': |
|
| 701 | - echo '—'; |
|
| 702 | - break; |
|
| 700 | + case 'tax': |
|
| 701 | + echo '—'; |
|
| 702 | + break; |
|
| 703 | 703 | |
| 704 | - case 'discount': |
|
| 705 | - echo '—'; |
|
| 706 | - break; |
|
| 704 | + case 'discount': |
|
| 705 | + echo '—'; |
|
| 706 | + break; |
|
| 707 | 707 | |
| 708 | - case 'initial': |
|
| 709 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 710 | - break; |
|
| 708 | + case 'initial': |
|
| 709 | + wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 710 | + break; |
|
| 711 | 711 | |
| 712 | - case 'recurring': |
|
| 713 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
| 714 | - break; |
|
| 712 | + case 'recurring': |
|
| 713 | + echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
| 714 | + break; |
|
| 715 | 715 | |
| 716 | 716 | } |
| 717 | 717 | |
@@ -816,39 +816,39 @@ discard block |
||
| 816 | 816 | |
| 817 | 817 | switch ( $key ) { |
| 818 | 818 | |
| 819 | - case 'status': |
|
| 820 | - echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
| 821 | - break; |
|
| 822 | - |
|
| 823 | - case 'item': |
|
| 824 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 825 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
| 826 | - break; |
|
| 827 | - |
|
| 828 | - case 'renewals': |
|
| 829 | - $max_bills = $_suscription->get_bill_times(); |
|
| 830 | - echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
| 831 | - break; |
|
| 832 | - |
|
| 833 | - case 'renewal_date': |
|
| 834 | - echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '—'; |
|
| 835 | - break; |
|
| 836 | - |
|
| 837 | - case 'start_date': |
|
| 838 | - echo 'pending' == $_suscription->get_status() ? '—' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) ); |
|
| 839 | - break; |
|
| 840 | - |
|
| 841 | - case 'subscription': |
|
| 842 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
| 843 | - printf( |
|
| 844 | - '%1$s#%2$s%3$s', |
|
| 845 | - '<a href="' . esc_url( $url ) . '">', |
|
| 846 | - '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
| 847 | - '</a>' |
|
| 848 | - ); |
|
| 849 | - |
|
| 850 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
| 851 | - break; |
|
| 819 | + case 'status': |
|
| 820 | + echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
| 821 | + break; |
|
| 822 | + |
|
| 823 | + case 'item': |
|
| 824 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 825 | + echo wp_kses_post( implode( ' | ', $markup ) ); |
|
| 826 | + break; |
|
| 827 | + |
|
| 828 | + case 'renewals': |
|
| 829 | + $max_bills = $_suscription->get_bill_times(); |
|
| 830 | + echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
| 831 | + break; |
|
| 832 | + |
|
| 833 | + case 'renewal_date': |
|
| 834 | + echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '—'; |
|
| 835 | + break; |
|
| 836 | + |
|
| 837 | + case 'start_date': |
|
| 838 | + echo 'pending' == $_suscription->get_status() ? '—' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) ); |
|
| 839 | + break; |
|
| 840 | + |
|
| 841 | + case 'subscription': |
|
| 842 | + $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
| 843 | + printf( |
|
| 844 | + '%1$s#%2$s%3$s', |
|
| 845 | + '<a href="' . esc_url( $url ) . '">', |
|
| 846 | + '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
| 847 | + '</a>' |
|
| 848 | + ); |
|
| 849 | + |
|
| 850 | + echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
| 851 | + break; |
|
| 852 | 852 | |
| 853 | 853 | } |
| 854 | 854 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | function wpinv_subscriptions_page() { |
| 16 | 16 | |
| 17 | - ?> |
|
| 17 | + ?> |
|
| 18 | 18 | |
| 19 | 19 | <div class="wrap"> |
| 20 | 20 | <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
@@ -22,28 +22,28 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | <?php |
| 24 | 24 | |
| 25 | - // Verify user permissions. |
|
| 26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 25 | + // Verify user permissions. |
|
| 26 | + if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 27 | 27 | |
| 28 | - aui()->alert( |
|
| 28 | + aui()->alert( |
|
| 29 | 29 | array( |
| 30 | - 'type' => 'danger', |
|
| 31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
| 32 | - ), |
|
| 33 | - true |
|
| 30 | + 'type' => 'danger', |
|
| 31 | + 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
| 32 | + ), |
|
| 33 | + true |
|
| 34 | 34 | ); |
| 35 | 35 | |
| 36 | - } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
| 36 | + } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
| 37 | 37 | |
| 38 | - // Display a single subscription. |
|
| 39 | - wpinv_recurring_subscription_details(); |
|
| 40 | - } else { |
|
| 38 | + // Display a single subscription. |
|
| 39 | + wpinv_recurring_subscription_details(); |
|
| 40 | + } else { |
|
| 41 | 41 | |
| 42 | - // Display a list of available subscriptions. |
|
| 43 | - getpaid_print_subscriptions_list(); |
|
| 44 | - } |
|
| 42 | + // Display a list of available subscriptions. |
|
| 43 | + getpaid_print_subscriptions_list(); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - ?> |
|
| 46 | + ?> |
|
| 47 | 47 | |
| 48 | 48 | </div> |
| 49 | 49 | </div> |
@@ -60,10 +60,10 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | function getpaid_print_subscriptions_list() { |
| 62 | 62 | |
| 63 | - $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
| 64 | - $subscribers_table->prepare_items(); |
|
| 63 | + $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
| 64 | + $subscribers_table->prepare_items(); |
|
| 65 | 65 | |
| 66 | - ?> |
|
| 66 | + ?> |
|
| 67 | 67 | <?php $subscribers_table->views(); ?> |
| 68 | 68 | <form id="subscribers-filter" class="bsui" method="get"> |
| 69 | 69 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
@@ -82,42 +82,42 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | function wpinv_recurring_subscription_details() { |
| 84 | 84 | |
| 85 | - // Fetch the subscription. |
|
| 86 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
| 87 | - if ( ! $sub->exists() ) { |
|
| 85 | + // Fetch the subscription. |
|
| 86 | + $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
| 87 | + if ( ! $sub->exists() ) { |
|
| 88 | 88 | |
| 89 | - aui()->alert( |
|
| 90 | - array( |
|
| 91 | - 'type' => 'danger', |
|
| 92 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
| 93 | - ), |
|
| 94 | - true |
|
| 95 | - ); |
|
| 89 | + aui()->alert( |
|
| 90 | + array( |
|
| 91 | + 'type' => 'danger', |
|
| 92 | + 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
| 93 | + ), |
|
| 94 | + true |
|
| 95 | + ); |
|
| 96 | 96 | |
| 97 | - return; |
|
| 98 | - } |
|
| 97 | + return; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - // Use metaboxes to display the subscription details. |
|
| 101 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
| 102 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
| 100 | + // Use metaboxes to display the subscription details. |
|
| 101 | + add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
| 102 | + add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
| 103 | 103 | |
| 104 | - $subscription_id = $sub->get_id(); |
|
| 105 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
| 106 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
| 104 | + $subscription_id = $sub->get_id(); |
|
| 105 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
| 106 | + $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
| 107 | 107 | |
| 108 | - if ( 1 < count( $subscription_groups ) ) { |
|
| 109 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
| 110 | - } |
|
| 108 | + if ( 1 < count( $subscription_groups ) ) { |
|
| 109 | + add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - if ( ! empty( $subscription_group ) ) { |
|
| 113 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
| 114 | - } |
|
| 112 | + if ( ! empty( $subscription_group ) ) { |
|
| 113 | + add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
| 116 | + add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
| 117 | 117 | |
| 118 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
| 118 | + do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
| 119 | 119 | |
| 120 | - ?> |
|
| 120 | + ?> |
|
| 121 | 121 | |
| 122 | 122 | <form method="post" action="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ) ); ?>"> |
| 123 | 123 | |
@@ -157,49 +157,49 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | function getpaid_admin_subscription_details_metabox( $sub ) { |
| 159 | 159 | |
| 160 | - // Subscription items. |
|
| 161 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
| 162 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
| 163 | - |
|
| 164 | - // Prepare subscription detail columns. |
|
| 165 | - $fields = apply_filters( |
|
| 166 | - 'getpaid_subscription_admin_page_fields', |
|
| 167 | - array( |
|
| 168 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 169 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
| 170 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 171 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 172 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
| 173 | - 'renewals' => __( 'Collected Payments', 'invoicing' ), |
|
| 174 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
| 175 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
| 176 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
| 177 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 178 | - ) |
|
| 179 | - ); |
|
| 180 | - |
|
| 181 | - if ( ! $sub->is_active() ) { |
|
| 182 | - |
|
| 183 | - if ( isset( $fields['renews_on'] ) ) { |
|
| 184 | - unset( $fields['renews_on'] ); |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - if ( isset( $fields['gateway'] ) ) { |
|
| 188 | - unset( $fields['gateway'] ); |
|
| 189 | - } |
|
| 190 | - } elseif ( $sub->is_last_renewal() ) { |
|
| 191 | - |
|
| 192 | - if ( isset( $fields['renews_on'] ) ) { |
|
| 193 | - $fields['renews_on'] = __( 'End Date', 'invoicing' ); |
|
| 194 | - } |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - $profile_id = $sub->get_profile_id(); |
|
| 198 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
| 199 | - unset( $fields['profile_id'] ); |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - ?> |
|
| 160 | + // Subscription items. |
|
| 161 | + $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
| 162 | + $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
| 163 | + |
|
| 164 | + // Prepare subscription detail columns. |
|
| 165 | + $fields = apply_filters( |
|
| 166 | + 'getpaid_subscription_admin_page_fields', |
|
| 167 | + array( |
|
| 168 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 169 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
| 170 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
| 171 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 172 | + 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
| 173 | + 'renewals' => __( 'Collected Payments', 'invoicing' ), |
|
| 174 | + 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
| 175 | + 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
| 176 | + 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
| 177 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 178 | + ) |
|
| 179 | + ); |
|
| 180 | + |
|
| 181 | + if ( ! $sub->is_active() ) { |
|
| 182 | + |
|
| 183 | + if ( isset( $fields['renews_on'] ) ) { |
|
| 184 | + unset( $fields['renews_on'] ); |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + if ( isset( $fields['gateway'] ) ) { |
|
| 188 | + unset( $fields['gateway'] ); |
|
| 189 | + } |
|
| 190 | + } elseif ( $sub->is_last_renewal() ) { |
|
| 191 | + |
|
| 192 | + if ( isset( $fields['renews_on'] ) ) { |
|
| 193 | + $fields['renews_on'] = __( 'End Date', 'invoicing' ); |
|
| 194 | + } |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + $profile_id = $sub->get_profile_id(); |
|
| 198 | + if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
| 199 | + unset( $fields['profile_id'] ); |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + ?> |
|
| 203 | 203 | |
| 204 | 204 | <table class="table table-borderless" style="font-size: 14px;"> |
| 205 | 205 | <tbody> |
@@ -233,20 +233,20 @@ discard block |
||
| 233 | 233 | */ |
| 234 | 234 | function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
| 235 | 235 | |
| 236 | - $username = __( '(Missing User)', 'invoicing' ); |
|
| 236 | + $username = __( '(Missing User)', 'invoicing' ); |
|
| 237 | 237 | |
| 238 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
| 239 | - if ( $user ) { |
|
| 238 | + $user = get_userdata( $subscription->get_customer_id() ); |
|
| 239 | + if ( $user ) { |
|
| 240 | 240 | |
| 241 | - $username = sprintf( |
|
| 242 | - '<a href="user-edit.php?user_id=%s">%s</a>', |
|
| 243 | - absint( $user->ID ), |
|
| 244 | - ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
| 245 | - ); |
|
| 241 | + $username = sprintf( |
|
| 242 | + '<a href="user-edit.php?user_id=%s">%s</a>', |
|
| 243 | + absint( $user->ID ), |
|
| 244 | + ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
| 245 | + ); |
|
| 246 | 246 | |
| 247 | - } |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | - echo wp_kses_post( $username ); |
|
| 249 | + echo wp_kses_post( $username ); |
|
| 250 | 250 | } |
| 251 | 251 | add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
| 252 | 252 | |
@@ -256,8 +256,8 @@ discard block |
||
| 256 | 256 | * @param WPInv_Subscription $subscription |
| 257 | 257 | */ |
| 258 | 258 | function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
| 259 | - $amount = getpaid_get_formatted_subscription_amount( $subscription ); |
|
| 260 | - echo wp_kses_post( "<span>$amount</span>" ); |
|
| 259 | + $amount = getpaid_get_formatted_subscription_amount( $subscription ); |
|
| 260 | + echo wp_kses_post( "<span>$amount</span>" ); |
|
| 261 | 261 | } |
| 262 | 262 | add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
| 263 | 263 | |
@@ -268,11 +268,11 @@ discard block |
||
| 268 | 268 | */ |
| 269 | 269 | function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
| 270 | 270 | |
| 271 | - printf( |
|
| 272 | - '<a href="%s">#%s</a>', |
|
| 273 | - esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
| 274 | - absint( $subscription->get_id() ) |
|
| 275 | - ); |
|
| 271 | + printf( |
|
| 272 | + '<a href="%s">#%s</a>', |
|
| 273 | + esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
| 274 | + absint( $subscription->get_id() ) |
|
| 275 | + ); |
|
| 276 | 276 | |
| 277 | 277 | } |
| 278 | 278 | add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
@@ -284,24 +284,24 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
| 286 | 286 | |
| 287 | - if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) { |
|
| 288 | - aui()->input( |
|
| 289 | - array( |
|
| 290 | - 'type' => 'text', |
|
| 291 | - 'id' => 'wpinv_subscription_date_created', |
|
| 292 | - 'name' => 'wpinv_subscription_date_created', |
|
| 293 | - 'label' => __( 'Start Date', 'invoicing' ), |
|
| 294 | - 'label_type' => 'hidden', |
|
| 295 | - 'placeholder' => 'YYYY-MM-DD', |
|
| 296 | - 'value' => esc_attr( $subscription->get_date_created( 'edit' ) ), |
|
| 297 | - 'no_wrap' => true, |
|
| 298 | - 'size' => 'sm', |
|
| 299 | - ), |
|
| 300 | - true |
|
| 301 | - ); |
|
| 302 | - } else { |
|
| 303 | - echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
| 304 | - } |
|
| 287 | + if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) { |
|
| 288 | + aui()->input( |
|
| 289 | + array( |
|
| 290 | + 'type' => 'text', |
|
| 291 | + 'id' => 'wpinv_subscription_date_created', |
|
| 292 | + 'name' => 'wpinv_subscription_date_created', |
|
| 293 | + 'label' => __( 'Start Date', 'invoicing' ), |
|
| 294 | + 'label_type' => 'hidden', |
|
| 295 | + 'placeholder' => 'YYYY-MM-DD', |
|
| 296 | + 'value' => esc_attr( $subscription->get_date_created( 'edit' ) ), |
|
| 297 | + 'no_wrap' => true, |
|
| 298 | + 'size' => 'sm', |
|
| 299 | + ), |
|
| 300 | + true |
|
| 301 | + ); |
|
| 302 | + } else { |
|
| 303 | + echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
| 304 | + } |
|
| 305 | 305 | |
| 306 | 306 | } |
| 307 | 307 | add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
@@ -313,24 +313,24 @@ discard block |
||
| 313 | 313 | */ |
| 314 | 314 | function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
| 315 | 315 | |
| 316 | - if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) { |
|
| 317 | - aui()->input( |
|
| 318 | - array( |
|
| 319 | - 'type' => 'text', |
|
| 320 | - 'id' => 'wpinv_subscription_expiration', |
|
| 321 | - 'name' => 'wpinv_subscription_expiration', |
|
| 322 | - 'label' => __( 'Renews On', 'invoicing' ), |
|
| 323 | - 'label_type' => 'hidden', |
|
| 324 | - 'placeholder' => 'YYYY-MM-DD', |
|
| 325 | - 'value' => esc_attr( $subscription->get_expiration( 'edit' ) ), |
|
| 326 | - 'no_wrap' => true, |
|
| 327 | - 'size' => 'sm', |
|
| 328 | - ), |
|
| 329 | - true |
|
| 330 | - ); |
|
| 331 | - } else { |
|
| 332 | - echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) ); |
|
| 333 | - } |
|
| 316 | + if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) { |
|
| 317 | + aui()->input( |
|
| 318 | + array( |
|
| 319 | + 'type' => 'text', |
|
| 320 | + 'id' => 'wpinv_subscription_expiration', |
|
| 321 | + 'name' => 'wpinv_subscription_expiration', |
|
| 322 | + 'label' => __( 'Renews On', 'invoicing' ), |
|
| 323 | + 'label_type' => 'hidden', |
|
| 324 | + 'placeholder' => 'YYYY-MM-DD', |
|
| 325 | + 'value' => esc_attr( $subscription->get_expiration( 'edit' ) ), |
|
| 326 | + 'no_wrap' => true, |
|
| 327 | + 'size' => 'sm', |
|
| 328 | + ), |
|
| 329 | + true |
|
| 330 | + ); |
|
| 331 | + } else { |
|
| 332 | + echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) ); |
|
| 333 | + } |
|
| 334 | 334 | } |
| 335 | 335 | add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
| 336 | 336 | |
@@ -341,32 +341,32 @@ discard block |
||
| 341 | 341 | */ |
| 342 | 342 | function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
| 343 | 343 | |
| 344 | - $max_bills = $subscription->get_bill_times(); |
|
| 345 | - $times_billed = (int) $subscription->get_times_billed(); |
|
| 346 | - |
|
| 347 | - if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_bill_times_change' ) ) { |
|
| 348 | - aui()->input( |
|
| 349 | - array( |
|
| 350 | - 'type' => 'number', |
|
| 351 | - 'id' => 'wpinv_subscription_max_bill_times', |
|
| 352 | - 'name' => 'wpinv_subscription_max_bill_times', |
|
| 353 | - 'label' => __( 'Maximum bill times', 'invoicing' ), |
|
| 354 | - 'label_type' => 'hidden', |
|
| 355 | - 'placeholder' => __( 'Unlimited', 'invoicing' ), |
|
| 356 | - 'value' => empty( $max_bills ) ? '' : (int) $max_bills, |
|
| 357 | - 'no_wrap' => true, |
|
| 358 | - 'size' => 'sm', |
|
| 359 | - 'input_group_left' => sprintf( |
|
| 360 | - // translators: %d: Number of times billed |
|
| 361 | - __( '%d of', 'invoicing' ), |
|
| 362 | - $times_billed |
|
| 363 | - ), |
|
| 364 | - ), |
|
| 365 | - true |
|
| 366 | - ); |
|
| 367 | - } else { |
|
| 368 | - echo esc_html( $times_billed ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
| 369 | - } |
|
| 344 | + $max_bills = $subscription->get_bill_times(); |
|
| 345 | + $times_billed = (int) $subscription->get_times_billed(); |
|
| 346 | + |
|
| 347 | + if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_bill_times_change' ) ) { |
|
| 348 | + aui()->input( |
|
| 349 | + array( |
|
| 350 | + 'type' => 'number', |
|
| 351 | + 'id' => 'wpinv_subscription_max_bill_times', |
|
| 352 | + 'name' => 'wpinv_subscription_max_bill_times', |
|
| 353 | + 'label' => __( 'Maximum bill times', 'invoicing' ), |
|
| 354 | + 'label_type' => 'hidden', |
|
| 355 | + 'placeholder' => __( 'Unlimited', 'invoicing' ), |
|
| 356 | + 'value' => empty( $max_bills ) ? '' : (int) $max_bills, |
|
| 357 | + 'no_wrap' => true, |
|
| 358 | + 'size' => 'sm', |
|
| 359 | + 'input_group_left' => sprintf( |
|
| 360 | + // translators: %d: Number of times billed |
|
| 361 | + __( '%d of', 'invoicing' ), |
|
| 362 | + $times_billed |
|
| 363 | + ), |
|
| 364 | + ), |
|
| 365 | + true |
|
| 366 | + ); |
|
| 367 | + } else { |
|
| 368 | + echo esc_html( $times_billed ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
| 369 | + } |
|
| 370 | 370 | } |
| 371 | 371 | add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
| 372 | 372 | |
@@ -378,13 +378,13 @@ discard block |
||
| 378 | 378 | */ |
| 379 | 379 | function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
| 380 | 380 | |
| 381 | - if ( empty( $subscription_group ) ) { |
|
| 382 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) ); |
|
| 383 | - return; |
|
| 384 | - } |
|
| 381 | + if ( empty( $subscription_group ) ) { |
|
| 382 | + echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) ); |
|
| 383 | + return; |
|
| 384 | + } |
|
| 385 | 385 | |
| 386 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 387 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
| 386 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 387 | + echo wp_kses_post( implode( ' | ', $markup ) ); |
|
| 388 | 388 | |
| 389 | 389 | } |
| 390 | 390 | add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
@@ -396,13 +396,13 @@ discard block |
||
| 396 | 396 | */ |
| 397 | 397 | function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
| 398 | 398 | |
| 399 | - $gateway = $subscription->get_gateway(); |
|
| 399 | + $gateway = $subscription->get_gateway(); |
|
| 400 | 400 | |
| 401 | - if ( ! empty( $gateway ) ) { |
|
| 402 | - echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
| 403 | - } else { |
|
| 404 | - echo '—'; |
|
| 405 | - } |
|
| 401 | + if ( ! empty( $gateway ) ) { |
|
| 402 | + echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
| 403 | + } else { |
|
| 404 | + echo '—'; |
|
| 405 | + } |
|
| 406 | 406 | |
| 407 | 407 | } |
| 408 | 408 | add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | * @param WPInv_Subscription $subscription |
| 414 | 414 | */ |
| 415 | 415 | function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
| 416 | - echo wp_kses_post( $subscription->get_status_label_html() ); |
|
| 416 | + echo wp_kses_post( $subscription->get_status_label_html() ); |
|
| 417 | 417 | } |
| 418 | 418 | add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
| 419 | 419 | |
@@ -424,28 +424,28 @@ discard block |
||
| 424 | 424 | */ |
| 425 | 425 | function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
| 426 | 426 | |
| 427 | - $profile_id = $subscription->get_profile_id(); |
|
| 428 | - |
|
| 429 | - aui()->input( |
|
| 430 | - array( |
|
| 431 | - 'type' => 'text', |
|
| 432 | - 'id' => 'wpinv_subscription_profile_id', |
|
| 433 | - 'name' => 'wpinv_subscription_profile_id', |
|
| 434 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
| 435 | - 'label_type' => 'hidden', |
|
| 436 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
| 437 | - 'value' => esc_attr( $profile_id ), |
|
| 438 | - 'input_group_right' => '', |
|
| 439 | - 'no_wrap' => true, |
|
| 440 | - 'size' => 'sm', |
|
| 441 | - ), |
|
| 442 | - true |
|
| 443 | - ); |
|
| 444 | - |
|
| 445 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
| 446 | - if ( ! empty( $url ) ) { |
|
| 447 | - echo ' <a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
| 448 | - } |
|
| 427 | + $profile_id = $subscription->get_profile_id(); |
|
| 428 | + |
|
| 429 | + aui()->input( |
|
| 430 | + array( |
|
| 431 | + 'type' => 'text', |
|
| 432 | + 'id' => 'wpinv_subscription_profile_id', |
|
| 433 | + 'name' => 'wpinv_subscription_profile_id', |
|
| 434 | + 'label' => __( 'Profile Id', 'invoicing' ), |
|
| 435 | + 'label_type' => 'hidden', |
|
| 436 | + 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
| 437 | + 'value' => esc_attr( $profile_id ), |
|
| 438 | + 'input_group_right' => '', |
|
| 439 | + 'no_wrap' => true, |
|
| 440 | + 'size' => 'sm', |
|
| 441 | + ), |
|
| 442 | + true |
|
| 443 | + ); |
|
| 444 | + |
|
| 445 | + $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
| 446 | + if ( ! empty( $url ) ) { |
|
| 447 | + echo ' <a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
| 448 | + } |
|
| 449 | 449 | |
| 450 | 450 | } |
| 451 | 451 | add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
@@ -457,40 +457,40 @@ discard block |
||
| 457 | 457 | */ |
| 458 | 458 | function getpaid_admin_subscription_update_metabox( $subscription ) { |
| 459 | 459 | |
| 460 | - ?> |
|
| 460 | + ?> |
|
| 461 | 461 | <div class="mt-3"> |
| 462 | 462 | |
| 463 | 463 | <?php |
| 464 | - aui()->select( |
|
| 465 | - array( |
|
| 466 | - 'options' => getpaid_get_subscription_statuses(), |
|
| 467 | - 'name' => 'subscription_status', |
|
| 468 | - 'id' => 'subscription_status_update_select', |
|
| 469 | - 'required' => true, |
|
| 470 | - 'no_wrap' => false, |
|
| 471 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
| 472 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
| 473 | - 'select2' => true, |
|
| 474 | - 'value' => $subscription->get_status( 'edit' ), |
|
| 475 | - ), |
|
| 476 | - true |
|
| 477 | - ); |
|
| 478 | - ?> |
|
| 464 | + aui()->select( |
|
| 465 | + array( |
|
| 466 | + 'options' => getpaid_get_subscription_statuses(), |
|
| 467 | + 'name' => 'subscription_status', |
|
| 468 | + 'id' => 'subscription_status_update_select', |
|
| 469 | + 'required' => true, |
|
| 470 | + 'no_wrap' => false, |
|
| 471 | + 'label' => __( 'Subscription Status', 'invoicing' ), |
|
| 472 | + 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
| 473 | + 'select2' => true, |
|
| 474 | + 'value' => $subscription->get_status( 'edit' ), |
|
| 475 | + ), |
|
| 476 | + true |
|
| 477 | + ); |
|
| 478 | + ?> |
|
| 479 | 479 | |
| 480 | 480 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
| 481 | 481 | |
| 482 | 482 | <?php |
| 483 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
| 483 | + submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
| 484 | 484 | |
| 485 | - $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
| 486 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
| 487 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
| 485 | + $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
| 486 | + $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
| 487 | + $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
| 488 | 488 | |
| 489 | - if ( $subscription->is_active() ) { |
|
| 490 | - echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>"; |
|
| 491 | - } |
|
| 489 | + if ( $subscription->is_active() ) { |
|
| 490 | + echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>"; |
|
| 491 | + } |
|
| 492 | 492 | |
| 493 | - echo '</div></div>'; |
|
| 493 | + echo '</div></div>'; |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | /** |
@@ -501,33 +501,33 @@ discard block |
||
| 501 | 501 | */ |
| 502 | 502 | function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
| 503 | 503 | |
| 504 | - $columns = apply_filters( |
|
| 505 | - 'getpaid_subscription_related_invoices_columns', |
|
| 506 | - array( |
|
| 507 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
| 508 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
| 509 | - 'date' => __( 'Date', 'invoicing' ), |
|
| 510 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 511 | - 'total' => __( 'Total', 'invoicing' ), |
|
| 512 | - ), |
|
| 513 | - $subscription |
|
| 514 | - ); |
|
| 515 | - |
|
| 516 | - // Prepare the invoices. |
|
| 517 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
| 518 | - $parent = $subscription->get_parent_invoice(); |
|
| 519 | - |
|
| 520 | - if ( $parent->exists() ) { |
|
| 521 | - $payments = array_merge( array( $parent ), $payments ); |
|
| 522 | - } |
|
| 523 | - |
|
| 524 | - $table_class = 'w-100 bg-white'; |
|
| 525 | - |
|
| 526 | - if ( ! is_admin() ) { |
|
| 527 | - $table_class = 'table table-bordered'; |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - ?> |
|
| 504 | + $columns = apply_filters( |
|
| 505 | + 'getpaid_subscription_related_invoices_columns', |
|
| 506 | + array( |
|
| 507 | + 'invoice' => __( 'Invoice', 'invoicing' ), |
|
| 508 | + 'relationship' => __( 'Relationship', 'invoicing' ), |
|
| 509 | + 'date' => __( 'Date', 'invoicing' ), |
|
| 510 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 511 | + 'total' => __( 'Total', 'invoicing' ), |
|
| 512 | + ), |
|
| 513 | + $subscription |
|
| 514 | + ); |
|
| 515 | + |
|
| 516 | + // Prepare the invoices. |
|
| 517 | + $payments = $subscription->get_child_payments( ! is_admin() ); |
|
| 518 | + $parent = $subscription->get_parent_invoice(); |
|
| 519 | + |
|
| 520 | + if ( $parent->exists() ) { |
|
| 521 | + $payments = array_merge( array( $parent ), $payments ); |
|
| 522 | + } |
|
| 523 | + |
|
| 524 | + $table_class = 'w-100 bg-white'; |
|
| 525 | + |
|
| 526 | + if ( ! is_admin() ) { |
|
| 527 | + $table_class = 'table table-bordered'; |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + ?> |
|
| 531 | 531 | <div class="m-0" style="overflow: auto;"> |
| 532 | 532 | |
| 533 | 533 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -535,10 +535,10 @@ discard block |
||
| 535 | 535 | <thead> |
| 536 | 536 | <tr> |
| 537 | 537 | <?php |
| 538 | - foreach ( $columns as $key => $label ) { |
|
| 539 | - echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 540 | - } |
|
| 541 | - ?> |
|
| 538 | + foreach ( $columns as $key => $label ) { |
|
| 539 | + echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 540 | + } |
|
| 541 | + ?> |
|
| 542 | 542 | </tr> |
| 543 | 543 | </thead> |
| 544 | 544 | |
@@ -554,72 +554,72 @@ discard block |
||
| 554 | 554 | |
| 555 | 555 | <?php |
| 556 | 556 | |
| 557 | - foreach ( $payments as $payment ) : |
|
| 557 | + foreach ( $payments as $payment ) : |
|
| 558 | 558 | |
| 559 | - // Ensure that we have an invoice. |
|
| 560 | - $payment = new WPInv_Invoice( $payment ); |
|
| 559 | + // Ensure that we have an invoice. |
|
| 560 | + $payment = new WPInv_Invoice( $payment ); |
|
| 561 | 561 | |
| 562 | - // Abort if the invoice is invalid... |
|
| 563 | - if ( ! $payment->exists() ) { |
|
| 564 | - continue; |
|
| 565 | - } |
|
| 562 | + // Abort if the invoice is invalid... |
|
| 563 | + if ( ! $payment->exists() ) { |
|
| 564 | + continue; |
|
| 565 | + } |
|
| 566 | 566 | |
| 567 | - // ... or belongs to a different subscription. |
|
| 568 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
| 569 | - continue; |
|
| 570 | - } |
|
| 567 | + // ... or belongs to a different subscription. |
|
| 568 | + if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
| 569 | + continue; |
|
| 570 | + } |
|
| 571 | 571 | |
| 572 | - echo '<tr>'; |
|
| 572 | + echo '<tr>'; |
|
| 573 | 573 | |
| 574 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 574 | + foreach ( array_keys( $columns ) as $key ) { |
|
| 575 | 575 | |
| 576 | - echo "<td class='p-2 text-left'>"; |
|
| 576 | + echo "<td class='p-2 text-left'>"; |
|
| 577 | 577 | |
| 578 | - switch ( $key ) { |
|
| 578 | + switch ( $key ) { |
|
| 579 | 579 | |
| 580 | - case 'total': |
|
| 581 | - echo '<strong>'; |
|
| 582 | - wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
| 583 | - echo '</strong>'; |
|
| 584 | - break; |
|
| 580 | + case 'total': |
|
| 581 | + echo '<strong>'; |
|
| 582 | + wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
| 583 | + echo '</strong>'; |
|
| 584 | + break; |
|
| 585 | 585 | |
| 586 | - case 'relationship': |
|
| 587 | - echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
| 588 | - break; |
|
| 586 | + case 'relationship': |
|
| 587 | + echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
| 588 | + break; |
|
| 589 | 589 | |
| 590 | - case 'date': |
|
| 591 | - echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
| 592 | - break; |
|
| 590 | + case 'date': |
|
| 591 | + echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
| 592 | + break; |
|
| 593 | 593 | |
| 594 | - case 'status': |
|
| 595 | - $status = $payment->get_status_nicename(); |
|
| 596 | - if ( is_admin() ) { |
|
| 597 | - $status = $payment->get_status_label_html(); |
|
| 598 | - } |
|
| 594 | + case 'status': |
|
| 595 | + $status = $payment->get_status_nicename(); |
|
| 596 | + if ( is_admin() ) { |
|
| 597 | + $status = $payment->get_status_label_html(); |
|
| 598 | + } |
|
| 599 | 599 | |
| 600 | - echo wp_kses_post( $status ); |
|
| 601 | - break; |
|
| 600 | + echo wp_kses_post( $status ); |
|
| 601 | + break; |
|
| 602 | 602 | |
| 603 | - case 'invoice': |
|
| 604 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
| 603 | + case 'invoice': |
|
| 604 | + $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
| 605 | 605 | |
| 606 | - if ( ! is_admin() ) { |
|
| 607 | - $link = esc_url( $payment->get_view_url() ); |
|
| 608 | - } |
|
| 606 | + if ( ! is_admin() ) { |
|
| 607 | + $link = esc_url( $payment->get_view_url() ); |
|
| 608 | + } |
|
| 609 | 609 | |
| 610 | - $invoice = esc_html( $payment->get_number() ); |
|
| 611 | - echo wp_kses_post( "<a href='$link'>$invoice</a>" ); |
|
| 612 | - break; |
|
| 613 | - } |
|
| 610 | + $invoice = esc_html( $payment->get_number() ); |
|
| 611 | + echo wp_kses_post( "<a href='$link'>$invoice</a>" ); |
|
| 612 | + break; |
|
| 613 | + } |
|
| 614 | 614 | |
| 615 | - echo '</td>'; |
|
| 615 | + echo '</td>'; |
|
| 616 | 616 | |
| 617 | - } |
|
| 617 | + } |
|
| 618 | 618 | |
| 619 | - echo '</tr>'; |
|
| 619 | + echo '</tr>'; |
|
| 620 | 620 | |
| 621 | - endforeach; |
|
| 622 | - ?> |
|
| 621 | + endforeach; |
|
| 622 | + ?> |
|
| 623 | 623 | |
| 624 | 624 | </tbody> |
| 625 | 625 | |
@@ -637,42 +637,42 @@ discard block |
||
| 637 | 637 | */ |
| 638 | 638 | function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
| 639 | 639 | |
| 640 | - // Fetch the subscription group. |
|
| 641 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
| 640 | + // Fetch the subscription group. |
|
| 641 | + $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
| 642 | 642 | |
| 643 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
| 644 | - return; |
|
| 645 | - } |
|
| 643 | + if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
| 644 | + return; |
|
| 645 | + } |
|
| 646 | 646 | |
| 647 | - // Prepare table columns. |
|
| 648 | - $columns = apply_filters( |
|
| 649 | - 'getpaid_subscription_item_details_columns', |
|
| 650 | - array( |
|
| 651 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
| 652 | - 'price' => __( 'Price', 'invoicing' ), |
|
| 653 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
| 654 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
| 655 | - //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
| 656 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
| 657 | - ), |
|
| 658 | - $subscription |
|
| 659 | - ); |
|
| 647 | + // Prepare table columns. |
|
| 648 | + $columns = apply_filters( |
|
| 649 | + 'getpaid_subscription_item_details_columns', |
|
| 650 | + array( |
|
| 651 | + 'item_name' => __( 'Item', 'invoicing' ), |
|
| 652 | + 'price' => __( 'Price', 'invoicing' ), |
|
| 653 | + 'tax' => __( 'Tax', 'invoicing' ), |
|
| 654 | + 'discount' => __( 'Discount', 'invoicing' ), |
|
| 655 | + //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
| 656 | + 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
| 657 | + ), |
|
| 658 | + $subscription |
|
| 659 | + ); |
|
| 660 | 660 | |
| 661 | - // Prepare the invoices. |
|
| 661 | + // Prepare the invoices. |
|
| 662 | 662 | |
| 663 | - $invoice = $subscription->get_parent_invoice(); |
|
| 663 | + $invoice = $subscription->get_parent_invoice(); |
|
| 664 | 664 | |
| 665 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
| 666 | - unset( $columns['tax'] ); |
|
| 667 | - } |
|
| 665 | + if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
| 666 | + unset( $columns['tax'] ); |
|
| 667 | + } |
|
| 668 | 668 | |
| 669 | - $table_class = 'w-100 bg-white'; |
|
| 669 | + $table_class = 'w-100 bg-white'; |
|
| 670 | 670 | |
| 671 | - if ( ! is_admin() ) { |
|
| 672 | - $table_class = 'table table-bordered'; |
|
| 673 | - } |
|
| 671 | + if ( ! is_admin() ) { |
|
| 672 | + $table_class = 'table table-bordered'; |
|
| 673 | + } |
|
| 674 | 674 | |
| 675 | - ?> |
|
| 675 | + ?> |
|
| 676 | 676 | <div class="m-0" style="overflow: auto;"> |
| 677 | 677 | |
| 678 | 678 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -681,10 +681,10 @@ discard block |
||
| 681 | 681 | <tr> |
| 682 | 682 | <?php |
| 683 | 683 | |
| 684 | - foreach ( $columns as $key => $label ) { |
|
| 685 | - echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 686 | - } |
|
| 687 | - ?> |
|
| 684 | + foreach ( $columns as $key => $label ) { |
|
| 685 | + echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 686 | + } |
|
| 687 | + ?> |
|
| 688 | 688 | </tr> |
| 689 | 689 | </thead> |
| 690 | 690 | |
@@ -692,106 +692,106 @@ discard block |
||
| 692 | 692 | |
| 693 | 693 | <?php |
| 694 | 694 | |
| 695 | - foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
| 695 | + foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
| 696 | 696 | |
| 697 | - echo '<tr>'; |
|
| 697 | + echo '<tr>'; |
|
| 698 | 698 | |
| 699 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 699 | + foreach ( array_keys( $columns ) as $key ) { |
|
| 700 | 700 | |
| 701 | - $class = 'text-left'; |
|
| 701 | + $class = 'text-left'; |
|
| 702 | 702 | |
| 703 | - echo "<td class='p-2 text-left'>"; |
|
| 703 | + echo "<td class='p-2 text-left'>"; |
|
| 704 | 704 | |
| 705 | - switch ( $key ) { |
|
| 705 | + switch ( $key ) { |
|
| 706 | 706 | |
| 707 | - case 'item_name': |
|
| 708 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
| 709 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
| 707 | + case 'item_name': |
|
| 708 | + $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
| 709 | + $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
| 710 | 710 | |
| 711 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
| 712 | - echo esc_html( $item_name ); |
|
| 713 | - } else { |
|
| 714 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
| 715 | - } |
|
| 711 | + if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
| 712 | + echo esc_html( $item_name ); |
|
| 713 | + } else { |
|
| 714 | + printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
| 715 | + } |
|
| 716 | 716 | |
| 717 | - break; |
|
| 717 | + break; |
|
| 718 | 718 | |
| 719 | - case 'price': |
|
| 720 | - wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
| 721 | - break; |
|
| 719 | + case 'price': |
|
| 720 | + wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
| 721 | + break; |
|
| 722 | 722 | |
| 723 | - case 'tax': |
|
| 724 | - wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
| 725 | - break; |
|
| 723 | + case 'tax': |
|
| 724 | + wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
| 725 | + break; |
|
| 726 | 726 | |
| 727 | - case 'discount': |
|
| 728 | - wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
| 729 | - break; |
|
| 727 | + case 'discount': |
|
| 728 | + wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
| 729 | + break; |
|
| 730 | 730 | |
| 731 | - case 'initial': |
|
| 732 | - wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
| 733 | - break; |
|
| 731 | + case 'initial': |
|
| 732 | + wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
| 733 | + break; |
|
| 734 | 734 | |
| 735 | - case 'recurring': |
|
| 736 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
| 737 | - break; |
|
| 735 | + case 'recurring': |
|
| 736 | + echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
| 737 | + break; |
|
| 738 | 738 | |
| 739 | - } |
|
| 739 | + } |
|
| 740 | 740 | |
| 741 | - echo '</td>'; |
|
| 741 | + echo '</td>'; |
|
| 742 | 742 | |
| 743 | - } |
|
| 743 | + } |
|
| 744 | 744 | |
| 745 | - echo '</tr>'; |
|
| 745 | + echo '</tr>'; |
|
| 746 | 746 | |
| 747 | - endforeach; |
|
| 747 | + endforeach; |
|
| 748 | 748 | |
| 749 | - foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
| 749 | + foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
| 750 | 750 | |
| 751 | - echo '<tr>'; |
|
| 751 | + echo '<tr>'; |
|
| 752 | 752 | |
| 753 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 753 | + foreach ( array_keys( $columns ) as $key ) { |
|
| 754 | 754 | |
| 755 | - $class = 'text-left'; |
|
| 755 | + $class = 'text-left'; |
|
| 756 | 756 | |
| 757 | - echo "<td class='p-2 text-left'>"; |
|
| 757 | + echo "<td class='p-2 text-left'>"; |
|
| 758 | 758 | |
| 759 | - switch ( $key ) { |
|
| 759 | + switch ( $key ) { |
|
| 760 | 760 | |
| 761 | - case 'item_name': |
|
| 762 | - echo esc_html( $subscription_group_fee['name'] ); |
|
| 763 | - break; |
|
| 761 | + case 'item_name': |
|
| 762 | + echo esc_html( $subscription_group_fee['name'] ); |
|
| 763 | + break; |
|
| 764 | 764 | |
| 765 | - case 'price': |
|
| 766 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 767 | - break; |
|
| 765 | + case 'price': |
|
| 766 | + wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 767 | + break; |
|
| 768 | 768 | |
| 769 | - case 'tax': |
|
| 770 | - echo '—'; |
|
| 771 | - break; |
|
| 769 | + case 'tax': |
|
| 770 | + echo '—'; |
|
| 771 | + break; |
|
| 772 | 772 | |
| 773 | - case 'discount': |
|
| 774 | - echo '—'; |
|
| 775 | - break; |
|
| 773 | + case 'discount': |
|
| 774 | + echo '—'; |
|
| 775 | + break; |
|
| 776 | 776 | |
| 777 | - case 'initial': |
|
| 778 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 779 | - break; |
|
| 777 | + case 'initial': |
|
| 778 | + wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 779 | + break; |
|
| 780 | 780 | |
| 781 | - case 'recurring': |
|
| 782 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
| 783 | - break; |
|
| 781 | + case 'recurring': |
|
| 782 | + echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
| 783 | + break; |
|
| 784 | 784 | |
| 785 | - } |
|
| 785 | + } |
|
| 786 | 786 | |
| 787 | - echo '</td>'; |
|
| 787 | + echo '</td>'; |
|
| 788 | 788 | |
| 789 | - } |
|
| 789 | + } |
|
| 790 | 790 | |
| 791 | - echo '</tr>'; |
|
| 791 | + echo '</tr>'; |
|
| 792 | 792 | |
| 793 | - endforeach; |
|
| 794 | - ?> |
|
| 793 | + endforeach; |
|
| 794 | + ?> |
|
| 795 | 795 | |
| 796 | 796 | </tbody> |
| 797 | 797 | |
@@ -810,38 +810,38 @@ discard block |
||
| 810 | 810 | */ |
| 811 | 811 | function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
| 812 | 812 | |
| 813 | - // Fetch the subscription groups. |
|
| 814 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
| 815 | - |
|
| 816 | - if ( empty( $subscription_groups ) ) { |
|
| 817 | - return; |
|
| 818 | - } |
|
| 819 | - |
|
| 820 | - // Prepare table columns. |
|
| 821 | - $columns = apply_filters( |
|
| 822 | - 'getpaid_subscription_related_subscriptions_columns', |
|
| 823 | - array( |
|
| 824 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 825 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 826 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
| 827 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
| 828 | - 'item' => __( 'Items', 'invoicing' ), |
|
| 829 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 830 | - ), |
|
| 831 | - $subscription |
|
| 832 | - ); |
|
| 833 | - |
|
| 834 | - if ( $subscription->get_status() == 'pending' ) { |
|
| 835 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
| 836 | - } |
|
| 837 | - |
|
| 838 | - $table_class = 'w-100 bg-white'; |
|
| 839 | - |
|
| 840 | - if ( ! is_admin() ) { |
|
| 841 | - $table_class = 'table table-bordered'; |
|
| 842 | - } |
|
| 843 | - |
|
| 844 | - ?> |
|
| 813 | + // Fetch the subscription groups. |
|
| 814 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
| 815 | + |
|
| 816 | + if ( empty( $subscription_groups ) ) { |
|
| 817 | + return; |
|
| 818 | + } |
|
| 819 | + |
|
| 820 | + // Prepare table columns. |
|
| 821 | + $columns = apply_filters( |
|
| 822 | + 'getpaid_subscription_related_subscriptions_columns', |
|
| 823 | + array( |
|
| 824 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 825 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 826 | + 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
| 827 | + 'renewals' => __( 'Payments', 'invoicing' ), |
|
| 828 | + 'item' => __( 'Items', 'invoicing' ), |
|
| 829 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 830 | + ), |
|
| 831 | + $subscription |
|
| 832 | + ); |
|
| 833 | + |
|
| 834 | + if ( $subscription->get_status() == 'pending' ) { |
|
| 835 | + unset( $columns['start_date'], $columns['renewal_date'] ); |
|
| 836 | + } |
|
| 837 | + |
|
| 838 | + $table_class = 'w-100 bg-white'; |
|
| 839 | + |
|
| 840 | + if ( ! is_admin() ) { |
|
| 841 | + $table_class = 'table table-bordered'; |
|
| 842 | + } |
|
| 843 | + |
|
| 844 | + ?> |
|
| 845 | 845 | <div class="m-0" style="overflow: auto;"> |
| 846 | 846 | |
| 847 | 847 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -850,10 +850,10 @@ discard block |
||
| 850 | 850 | <tr> |
| 851 | 851 | <?php |
| 852 | 852 | |
| 853 | - foreach ( $columns as $key => $label ) { |
|
| 854 | - echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 855 | - } |
|
| 856 | - ?> |
|
| 853 | + foreach ( $columns as $key => $label ) { |
|
| 854 | + echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 855 | + } |
|
| 856 | + ?> |
|
| 857 | 857 | </tr> |
| 858 | 858 | </thead> |
| 859 | 859 | |
@@ -861,74 +861,74 @@ discard block |
||
| 861 | 861 | |
| 862 | 862 | <?php |
| 863 | 863 | |
| 864 | - foreach ( $subscription_groups as $subscription_group ) : |
|
| 864 | + foreach ( $subscription_groups as $subscription_group ) : |
|
| 865 | 865 | |
| 866 | - // Do not list current subscription. |
|
| 867 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
| 868 | - continue; |
|
| 869 | - } |
|
| 866 | + // Do not list current subscription. |
|
| 867 | + if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
| 868 | + continue; |
|
| 869 | + } |
|
| 870 | 870 | |
| 871 | - // Ensure the subscription exists. |
|
| 872 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
| 871 | + // Ensure the subscription exists. |
|
| 872 | + $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
| 873 | 873 | |
| 874 | - if ( ! $_suscription->exists() ) { |
|
| 875 | - continue; |
|
| 876 | - } |
|
| 874 | + if ( ! $_suscription->exists() ) { |
|
| 875 | + continue; |
|
| 876 | + } |
|
| 877 | 877 | |
| 878 | - echo '<tr>'; |
|
| 878 | + echo '<tr>'; |
|
| 879 | 879 | |
| 880 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 880 | + foreach ( array_keys( $columns ) as $key ) { |
|
| 881 | 881 | |
| 882 | - $class = 'text-left'; |
|
| 882 | + $class = 'text-left'; |
|
| 883 | 883 | |
| 884 | - echo "<td class='p-2 text-left'>"; |
|
| 884 | + echo "<td class='p-2 text-left'>"; |
|
| 885 | 885 | |
| 886 | - switch ( $key ) { |
|
| 886 | + switch ( $key ) { |
|
| 887 | 887 | |
| 888 | - case 'status': |
|
| 889 | - echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
| 890 | - break; |
|
| 888 | + case 'status': |
|
| 889 | + echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
| 890 | + break; |
|
| 891 | 891 | |
| 892 | - case 'item': |
|
| 893 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 894 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
| 895 | - break; |
|
| 892 | + case 'item': |
|
| 893 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 894 | + echo wp_kses_post( implode( ' | ', $markup ) ); |
|
| 895 | + break; |
|
| 896 | 896 | |
| 897 | - case 'renewals': |
|
| 898 | - $max_bills = $_suscription->get_bill_times(); |
|
| 899 | - echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
| 900 | - break; |
|
| 897 | + case 'renewals': |
|
| 898 | + $max_bills = $_suscription->get_bill_times(); |
|
| 899 | + echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
| 900 | + break; |
|
| 901 | 901 | |
| 902 | - case 'renewal_date': |
|
| 903 | - echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '—'; |
|
| 904 | - break; |
|
| 902 | + case 'renewal_date': |
|
| 903 | + echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '—'; |
|
| 904 | + break; |
|
| 905 | 905 | |
| 906 | - case 'start_date': |
|
| 907 | - echo 'pending' == $_suscription->get_status() ? '—' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) ); |
|
| 908 | - break; |
|
| 906 | + case 'start_date': |
|
| 907 | + echo 'pending' == $_suscription->get_status() ? '—' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) ); |
|
| 908 | + break; |
|
| 909 | 909 | |
| 910 | - case 'subscription': |
|
| 911 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
| 912 | - printf( |
|
| 910 | + case 'subscription': |
|
| 911 | + $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
| 912 | + printf( |
|
| 913 | 913 | '%1$s#%2$s%3$s', |
| 914 | 914 | '<a href="' . esc_url( $url ) . '">', |
| 915 | 915 | '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
| 916 | - '</a>' |
|
| 916 | + '</a>' |
|
| 917 | 917 | ); |
| 918 | 918 | |
| 919 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
| 920 | - break; |
|
| 919 | + echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
| 920 | + break; |
|
| 921 | 921 | |
| 922 | - } |
|
| 922 | + } |
|
| 923 | 923 | |
| 924 | - echo '</td>'; |
|
| 924 | + echo '</td>'; |
|
| 925 | 925 | |
| 926 | - } |
|
| 926 | + } |
|
| 927 | 927 | |
| 928 | - echo '</tr>'; |
|
| 928 | + echo '</tr>'; |
|
| 929 | 929 | |
| 930 | - endforeach; |
|
| 931 | - ?> |
|
| 930 | + endforeach; |
|
| 931 | + ?> |
|
| 932 | 932 | |
| 933 | 933 | </tbody> |
| 934 | 934 | |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | * Contains functions that display the subscriptions admin page. |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | -defined( 'ABSPATH' ) || exit; |
|
| 6 | +defined('ABSPATH') || exit; |
|
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * Render the Subscriptions page |
@@ -17,23 +17,23 @@ discard block |
||
| 17 | 17 | ?> |
| 18 | 18 | |
| 19 | 19 | <div class="wrap"> |
| 20 | - <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
|
| 20 | + <h1><?php echo esc_html(get_admin_page_title()); ?></h1> |
|
| 21 | 21 | <div class="bsui"> |
| 22 | 22 | |
| 23 | 23 | <?php |
| 24 | 24 | |
| 25 | 25 | // Verify user permissions. |
| 26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 26 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 27 | 27 | |
| 28 | 28 | aui()->alert( |
| 29 | 29 | array( |
| 30 | 30 | 'type' => 'danger', |
| 31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
| 31 | + 'content' => __('You are not permitted to view this page.', 'invoicing'), |
|
| 32 | 32 | ), |
| 33 | 33 | true |
| 34 | 34 | ); |
| 35 | 35 | |
| 36 | - } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
| 36 | + } elseif (!empty($_GET['id']) && is_numeric($_GET['id'])) { |
|
| 37 | 37 | |
| 38 | 38 | // Display a single subscription. |
| 39 | 39 | wpinv_recurring_subscription_details(); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | <?php $subscribers_table->views(); ?> |
| 68 | 68 | <form id="subscribers-filter" class="bsui" method="get"> |
| 69 | 69 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
| 70 | - <?php $subscribers_table->search_box( __( 'Search Subscriptions', 'invoicing' ), 'getpaid-search-subscriptions' ); ?> |
|
| 70 | + <?php $subscribers_table->search_box(__('Search Subscriptions', 'invoicing'), 'getpaid-search-subscriptions'); ?> |
|
| 71 | 71 | <?php $subscribers_table->display(); ?> |
| 72 | 72 | </form> |
| 73 | 73 | <?php |
@@ -83,13 +83,13 @@ discard block |
||
| 83 | 83 | function wpinv_recurring_subscription_details() { |
| 84 | 84 | |
| 85 | 85 | // Fetch the subscription. |
| 86 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
| 87 | - if ( ! $sub->exists() ) { |
|
| 86 | + $sub = new WPInv_Subscription((int) $_GET['id']); |
|
| 87 | + if (!$sub->exists()) { |
|
| 88 | 88 | |
| 89 | 89 | aui()->alert( |
| 90 | 90 | array( |
| 91 | 91 | 'type' => 'danger', |
| 92 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
| 92 | + 'content' => __('Subscription not found.', 'invoicing'), |
|
| 93 | 93 | ), |
| 94 | 94 | true |
| 95 | 95 | ); |
@@ -98,32 +98,32 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // Use metaboxes to display the subscription details. |
| 101 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
| 102 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
| 101 | + add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high'); |
|
| 102 | + add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side'); |
|
| 103 | 103 | |
| 104 | 104 | $subscription_id = $sub->get_id(); |
| 105 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
| 106 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
| 105 | + $subscription_groups = getpaid_get_invoice_subscription_groups($sub->get_parent_invoice_id()); |
|
| 106 | + $subscription_group = wp_list_filter($subscription_groups, compact('subscription_id')); |
|
| 107 | 107 | |
| 108 | - if ( 1 < count( $subscription_groups ) ) { |
|
| 109 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
| 108 | + if (1 < count($subscription_groups)) { |
|
| 109 | + add_meta_box('getpaid_admin_subscription_related_subscriptions_metabox', __('Related Subscriptions', 'invoicing'), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced'); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if ( ! empty( $subscription_group ) ) { |
|
| 113 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
| 112 | + if (!empty($subscription_group)) { |
|
| 113 | + add_meta_box('getpaid_admin_subscription_item_details_metabox', __('Subscription Items', 'invoicing'), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low'); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
| 116 | + add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Related Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced'); |
|
| 117 | 117 | |
| 118 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
| 118 | + do_action('getpaid_admin_single_subscription_register_metabox', $sub); |
|
| 119 | 119 | |
| 120 | 120 | ?> |
| 121 | 121 | |
| 122 | - <form method="post" action="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ) ); ?>"> |
|
| 122 | + <form method="post" action="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id()))); ?>"> |
|
| 123 | 123 | |
| 124 | - <?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?> |
|
| 125 | - <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
| 126 | - <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
|
| 124 | + <?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?> |
|
| 125 | + <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
| 126 | + <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> |
|
| 127 | 127 | <input type="hidden" name="getpaid-admin-action" value="update_single_subscription" /> |
| 128 | 128 | <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" /> |
| 129 | 129 | |
@@ -131,12 +131,12 @@ discard block |
||
| 131 | 131 | <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
| 132 | 132 | |
| 133 | 133 | <div id="postbox-container-1" class="postbox-container"> |
| 134 | - <?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?> |
|
| 134 | + <?php do_meta_boxes(get_current_screen(), 'side', $sub); ?> |
|
| 135 | 135 | </div> |
| 136 | 136 | |
| 137 | 137 | <div id="postbox-container-2" class="postbox-container"> |
| 138 | - <?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?> |
|
| 139 | - <?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?> |
|
| 138 | + <?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?> |
|
| 139 | + <?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?> |
|
| 140 | 140 | </div> |
| 141 | 141 | |
| 142 | 142 | </div> |
@@ -155,48 +155,48 @@ discard block |
||
| 155 | 155 | * |
| 156 | 156 | * @param WPInv_Subscription $sub |
| 157 | 157 | */ |
| 158 | -function getpaid_admin_subscription_details_metabox( $sub ) { |
|
| 158 | +function getpaid_admin_subscription_details_metabox($sub) { |
|
| 159 | 159 | |
| 160 | 160 | // Subscription items. |
| 161 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
| 162 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
| 161 | + $subscription_group = getpaid_get_invoice_subscription_group($sub->get_parent_invoice_id(), $sub->get_id()); |
|
| 162 | + $items_count = empty($subscription_group) ? 1 : count($subscription_group['items']); |
|
| 163 | 163 | |
| 164 | 164 | // Prepare subscription detail columns. |
| 165 | 165 | $fields = apply_filters( |
| 166 | 166 | 'getpaid_subscription_admin_page_fields', |
| 167 | 167 | array( |
| 168 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 169 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
| 170 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 171 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 172 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
| 173 | - 'renewals' => __( 'Collected Payments', 'invoicing' ), |
|
| 174 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
| 175 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
| 176 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
| 177 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 168 | + 'subscription' => __('Subscription', 'invoicing'), |
|
| 169 | + 'customer' => __('Customer', 'invoicing'), |
|
| 170 | + 'amount' => __('Amount', 'invoicing'), |
|
| 171 | + 'start_date' => __('Start Date', 'invoicing'), |
|
| 172 | + 'renews_on' => __('Next Payment', 'invoicing'), |
|
| 173 | + 'renewals' => __('Collected Payments', 'invoicing'), |
|
| 174 | + 'item' => _n('Item', 'Items', $items_count, 'invoicing'), |
|
| 175 | + 'gateway' => __('Payment Method', 'invoicing'), |
|
| 176 | + 'profile_id' => __('Profile ID', 'invoicing'), |
|
| 177 | + 'status' => __('Status', 'invoicing'), |
|
| 178 | 178 | ) |
| 179 | 179 | ); |
| 180 | 180 | |
| 181 | - if ( ! $sub->is_active() ) { |
|
| 181 | + if (!$sub->is_active()) { |
|
| 182 | 182 | |
| 183 | - if ( isset( $fields['renews_on'] ) ) { |
|
| 184 | - unset( $fields['renews_on'] ); |
|
| 183 | + if (isset($fields['renews_on'])) { |
|
| 184 | + unset($fields['renews_on']); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - if ( isset( $fields['gateway'] ) ) { |
|
| 188 | - unset( $fields['gateway'] ); |
|
| 187 | + if (isset($fields['gateway'])) { |
|
| 188 | + unset($fields['gateway']); |
|
| 189 | 189 | } |
| 190 | - } elseif ( $sub->is_last_renewal() ) { |
|
| 190 | + } elseif ($sub->is_last_renewal()) { |
|
| 191 | 191 | |
| 192 | - if ( isset( $fields['renews_on'] ) ) { |
|
| 193 | - $fields['renews_on'] = __( 'End Date', 'invoicing' ); |
|
| 192 | + if (isset($fields['renews_on'])) { |
|
| 193 | + $fields['renews_on'] = __('End Date', 'invoicing'); |
|
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | $profile_id = $sub->get_profile_id(); |
| 198 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
| 199 | - unset( $fields['profile_id'] ); |
|
| 198 | + if (empty($profile_id) && isset($fields['profile_id'])) { |
|
| 199 | + unset($fields['profile_id']); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | ?> |
@@ -204,16 +204,16 @@ discard block |
||
| 204 | 204 | <table class="table table-borderless" style="font-size: 14px;"> |
| 205 | 205 | <tbody> |
| 206 | 206 | |
| 207 | - <?php foreach ( $fields as $key => $label ) : ?> |
|
| 207 | + <?php foreach ($fields as $key => $label) : ?> |
|
| 208 | 208 | |
| 209 | - <tr class="getpaid-subscription-meta-<?php echo esc_attr( $key ); ?>"> |
|
| 209 | + <tr class="getpaid-subscription-meta-<?php echo esc_attr($key); ?>"> |
|
| 210 | 210 | |
| 211 | 211 | <th class="w-25" style="font-weight: 500;"> |
| 212 | - <?php echo esc_html( $label ); ?> |
|
| 212 | + <?php echo esc_html($label); ?> |
|
| 213 | 213 | </th> |
| 214 | 214 | |
| 215 | 215 | <td class="w-75 text-muted"> |
| 216 | - <?php do_action( 'getpaid_subscription_admin_display_' . sanitize_key( $key ), $sub, $subscription_group ); ?> |
|
| 216 | + <?php do_action('getpaid_subscription_admin_display_' . sanitize_key($key), $sub, $subscription_group); ?> |
|
| 217 | 217 | </td> |
| 218 | 218 | |
| 219 | 219 | </tr> |
@@ -231,144 +231,144 @@ discard block |
||
| 231 | 231 | * |
| 232 | 232 | * @param WPInv_Subscription $subscription |
| 233 | 233 | */ |
| 234 | -function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
|
| 234 | +function getpaid_admin_subscription_metabox_display_customer($subscription) { |
|
| 235 | 235 | |
| 236 | - $username = __( '(Missing User)', 'invoicing' ); |
|
| 236 | + $username = __('(Missing User)', 'invoicing'); |
|
| 237 | 237 | |
| 238 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
| 239 | - if ( $user ) { |
|
| 238 | + $user = get_userdata($subscription->get_customer_id()); |
|
| 239 | + if ($user) { |
|
| 240 | 240 | |
| 241 | 241 | $username = sprintf( |
| 242 | 242 | '<a href="user-edit.php?user_id=%s">%s</a>', |
| 243 | - absint( $user->ID ), |
|
| 244 | - ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
| 243 | + absint($user->ID), |
|
| 244 | + !empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email) |
|
| 245 | 245 | ); |
| 246 | 246 | |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - echo wp_kses_post( $username ); |
|
| 249 | + echo wp_kses_post($username); |
|
| 250 | 250 | } |
| 251 | -add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
|
| 251 | +add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer'); |
|
| 252 | 252 | |
| 253 | 253 | /** |
| 254 | 254 | * Displays the subscription amount. |
| 255 | 255 | * |
| 256 | 256 | * @param WPInv_Subscription $subscription |
| 257 | 257 | */ |
| 258 | -function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
|
| 259 | - $amount = getpaid_get_formatted_subscription_amount( $subscription ); |
|
| 260 | - echo wp_kses_post( "<span>$amount</span>" ); |
|
| 258 | +function getpaid_admin_subscription_metabox_display_amount($subscription) { |
|
| 259 | + $amount = getpaid_get_formatted_subscription_amount($subscription); |
|
| 260 | + echo wp_kses_post("<span>$amount</span>"); |
|
| 261 | 261 | } |
| 262 | -add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
|
| 262 | +add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount'); |
|
| 263 | 263 | |
| 264 | 264 | /** |
| 265 | 265 | * Displays the subscription id. |
| 266 | 266 | * |
| 267 | 267 | * @param WPInv_Subscription $subscription |
| 268 | 268 | */ |
| 269 | -function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
|
| 269 | +function getpaid_admin_subscription_metabox_display_id($subscription) { |
|
| 270 | 270 | |
| 271 | 271 | printf( |
| 272 | 272 | '<a href="%s">#%s</a>', |
| 273 | - esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
| 274 | - absint( $subscription->get_id() ) |
|
| 273 | + esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($subscription->get_id()))), |
|
| 274 | + absint($subscription->get_id()) |
|
| 275 | 275 | ); |
| 276 | 276 | |
| 277 | 277 | } |
| 278 | -add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
|
| 278 | +add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id'); |
|
| 279 | 279 | |
| 280 | 280 | /** |
| 281 | 281 | * Displays the subscription renewal date. |
| 282 | 282 | * |
| 283 | 283 | * @param WPInv_Subscription $subscription |
| 284 | 284 | */ |
| 285 | -function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
|
| 285 | +function getpaid_admin_subscription_metabox_display_start_date($subscription) { |
|
| 286 | 286 | |
| 287 | - if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) { |
|
| 287 | + if ($subscription->has_status('active trialling') && getpaid_payment_gateway_supports($subscription->get_gateway(), 'subscription_date_change')) { |
|
| 288 | 288 | aui()->input( |
| 289 | 289 | array( |
| 290 | 290 | 'type' => 'text', |
| 291 | 291 | 'id' => 'wpinv_subscription_date_created', |
| 292 | 292 | 'name' => 'wpinv_subscription_date_created', |
| 293 | - 'label' => __( 'Start Date', 'invoicing' ), |
|
| 293 | + 'label' => __('Start Date', 'invoicing'), |
|
| 294 | 294 | 'label_type' => 'hidden', |
| 295 | 295 | 'placeholder' => 'YYYY-MM-DD', |
| 296 | - 'value' => esc_attr( $subscription->get_date_created( 'edit' ) ), |
|
| 296 | + 'value' => esc_attr($subscription->get_date_created('edit')), |
|
| 297 | 297 | 'no_wrap' => true, |
| 298 | 298 | 'size' => 'sm', |
| 299 | 299 | ), |
| 300 | 300 | true |
| 301 | 301 | ); |
| 302 | 302 | } else { |
| 303 | - echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
| 303 | + echo esc_html(getpaid_format_date_value($subscription->get_date_created())); |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | } |
| 307 | -add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
|
| 307 | +add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date'); |
|
| 308 | 308 | |
| 309 | 309 | /** |
| 310 | 310 | * Displays the subscription renewal date. |
| 311 | 311 | * |
| 312 | 312 | * @param WPInv_Subscription $subscription |
| 313 | 313 | */ |
| 314 | -function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
|
| 314 | +function getpaid_admin_subscription_metabox_display_renews_on($subscription) { |
|
| 315 | 315 | |
| 316 | - if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) { |
|
| 316 | + if ($subscription->has_status('active trialling') && getpaid_payment_gateway_supports($subscription->get_gateway(), 'subscription_date_change')) { |
|
| 317 | 317 | aui()->input( |
| 318 | 318 | array( |
| 319 | 319 | 'type' => 'text', |
| 320 | 320 | 'id' => 'wpinv_subscription_expiration', |
| 321 | 321 | 'name' => 'wpinv_subscription_expiration', |
| 322 | - 'label' => __( 'Renews On', 'invoicing' ), |
|
| 322 | + 'label' => __('Renews On', 'invoicing'), |
|
| 323 | 323 | 'label_type' => 'hidden', |
| 324 | 324 | 'placeholder' => 'YYYY-MM-DD', |
| 325 | - 'value' => esc_attr( $subscription->get_expiration( 'edit' ) ), |
|
| 325 | + 'value' => esc_attr($subscription->get_expiration('edit')), |
|
| 326 | 326 | 'no_wrap' => true, |
| 327 | 327 | 'size' => 'sm', |
| 328 | 328 | ), |
| 329 | 329 | true |
| 330 | 330 | ); |
| 331 | 331 | } else { |
| 332 | - echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) ); |
|
| 332 | + echo esc_html(getpaid_format_date_value($subscription->get_expiration())); |
|
| 333 | 333 | } |
| 334 | 334 | } |
| 335 | -add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
|
| 335 | +add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on'); |
|
| 336 | 336 | |
| 337 | 337 | /** |
| 338 | 338 | * Displays the subscription renewal count. |
| 339 | 339 | * |
| 340 | 340 | * @param WPInv_Subscription $subscription |
| 341 | 341 | */ |
| 342 | -function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
|
| 342 | +function getpaid_admin_subscription_metabox_display_renewals($subscription) { |
|
| 343 | 343 | |
| 344 | 344 | $max_bills = $subscription->get_bill_times(); |
| 345 | 345 | $times_billed = (int) $subscription->get_times_billed(); |
| 346 | 346 | |
| 347 | - if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_bill_times_change' ) ) { |
|
| 347 | + if ($subscription->has_status('active trialling') && getpaid_payment_gateway_supports($subscription->get_gateway(), 'subscription_bill_times_change')) { |
|
| 348 | 348 | aui()->input( |
| 349 | 349 | array( |
| 350 | 350 | 'type' => 'number', |
| 351 | 351 | 'id' => 'wpinv_subscription_max_bill_times', |
| 352 | 352 | 'name' => 'wpinv_subscription_max_bill_times', |
| 353 | - 'label' => __( 'Maximum bill times', 'invoicing' ), |
|
| 353 | + 'label' => __('Maximum bill times', 'invoicing'), |
|
| 354 | 354 | 'label_type' => 'hidden', |
| 355 | - 'placeholder' => __( 'Unlimited', 'invoicing' ), |
|
| 356 | - 'value' => empty( $max_bills ) ? '' : (int) $max_bills, |
|
| 355 | + 'placeholder' => __('Unlimited', 'invoicing'), |
|
| 356 | + 'value' => empty($max_bills) ? '' : (int) $max_bills, |
|
| 357 | 357 | 'no_wrap' => true, |
| 358 | 358 | 'size' => 'sm', |
| 359 | 359 | 'input_group_left' => sprintf( |
| 360 | 360 | // translators: %d: Number of times billed |
| 361 | - __( '%d of', 'invoicing' ), |
|
| 361 | + __('%d of', 'invoicing'), |
|
| 362 | 362 | $times_billed |
| 363 | 363 | ), |
| 364 | 364 | ), |
| 365 | 365 | true |
| 366 | 366 | ); |
| 367 | 367 | } else { |
| 368 | - echo esc_html( $times_billed ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
| 368 | + echo esc_html($times_billed) . ' / ' . (empty($max_bills) ? '∞' : (int) $max_bills); |
|
| 369 | 369 | } |
| 370 | 370 | } |
| 371 | -add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
|
| 371 | +add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals'); |
|
| 372 | 372 | |
| 373 | 373 | /** |
| 374 | 374 | * Displays the subscription item. |
@@ -376,53 +376,53 @@ discard block |
||
| 376 | 376 | * @param WPInv_Subscription $subscription |
| 377 | 377 | * @param false|array $subscription_group |
| 378 | 378 | */ |
| 379 | -function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
|
| 379 | +function getpaid_admin_subscription_metabox_display_item($subscription, $subscription_group = false) { |
|
| 380 | 380 | |
| 381 | - if ( empty( $subscription_group ) ) { |
|
| 382 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) ); |
|
| 381 | + if (empty($subscription_group)) { |
|
| 382 | + echo wp_kses_post(WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id())); |
|
| 383 | 383 | return; |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 387 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
| 386 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
| 387 | + echo wp_kses_post(implode(' | ', $markup)); |
|
| 388 | 388 | |
| 389 | 389 | } |
| 390 | -add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
|
| 390 | +add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2); |
|
| 391 | 391 | |
| 392 | 392 | /** |
| 393 | 393 | * Displays the subscription gateway. |
| 394 | 394 | * |
| 395 | 395 | * @param WPInv_Subscription $subscription |
| 396 | 396 | */ |
| 397 | -function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
|
| 397 | +function getpaid_admin_subscription_metabox_display_gateway($subscription) { |
|
| 398 | 398 | |
| 399 | 399 | $gateway = $subscription->get_gateway(); |
| 400 | 400 | |
| 401 | - if ( ! empty( $gateway ) ) { |
|
| 402 | - echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
| 401 | + if (!empty($gateway)) { |
|
| 402 | + echo esc_html(wpinv_get_gateway_admin_label($gateway)); |
|
| 403 | 403 | } else { |
| 404 | 404 | echo '—'; |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | } |
| 408 | -add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
|
| 408 | +add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway'); |
|
| 409 | 409 | |
| 410 | 410 | /** |
| 411 | 411 | * Displays the subscription status. |
| 412 | 412 | * |
| 413 | 413 | * @param WPInv_Subscription $subscription |
| 414 | 414 | */ |
| 415 | -function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
|
| 416 | - echo wp_kses_post( $subscription->get_status_label_html() ); |
|
| 415 | +function getpaid_admin_subscription_metabox_display_status($subscription) { |
|
| 416 | + echo wp_kses_post($subscription->get_status_label_html()); |
|
| 417 | 417 | } |
| 418 | -add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
|
| 418 | +add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status'); |
|
| 419 | 419 | |
| 420 | 420 | /** |
| 421 | 421 | * Displays the subscription profile id. |
| 422 | 422 | * |
| 423 | 423 | * @param WPInv_Subscription $subscription |
| 424 | 424 | */ |
| 425 | -function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
|
| 425 | +function getpaid_admin_subscription_metabox_display_profile_id($subscription) { |
|
| 426 | 426 | |
| 427 | 427 | $profile_id = $subscription->get_profile_id(); |
| 428 | 428 | |
@@ -431,10 +431,10 @@ discard block |
||
| 431 | 431 | 'type' => 'text', |
| 432 | 432 | 'id' => 'wpinv_subscription_profile_id', |
| 433 | 433 | 'name' => 'wpinv_subscription_profile_id', |
| 434 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
| 434 | + 'label' => __('Profile Id', 'invoicing'), |
|
| 435 | 435 | 'label_type' => 'hidden', |
| 436 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
| 437 | - 'value' => esc_attr( $profile_id ), |
|
| 436 | + 'placeholder' => __('Profile Id', 'invoicing'), |
|
| 437 | + 'value' => esc_attr($profile_id), |
|
| 438 | 438 | 'input_group_right' => '', |
| 439 | 439 | 'no_wrap' => true, |
| 440 | 440 | 'size' => 'sm', |
@@ -442,20 +442,20 @@ discard block |
||
| 442 | 442 | true |
| 443 | 443 | ); |
| 444 | 444 | |
| 445 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
| 446 | - if ( ! empty( $url ) ) { |
|
| 447 | - echo ' <a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
| 445 | + $url = apply_filters('getpaid_remote_subscription_profile_url', '', $subscription); |
|
| 446 | + if (!empty($url)) { |
|
| 447 | + echo ' <a href="' . esc_url_raw($url) . '" title="' . esc_attr__('View in Gateway', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | } |
| 451 | -add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
|
| 451 | +add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id'); |
|
| 452 | 452 | |
| 453 | 453 | /** |
| 454 | 454 | * Displays the subscriptions update metabox. |
| 455 | 455 | * |
| 456 | 456 | * @param WPInv_Subscription $subscription |
| 457 | 457 | */ |
| 458 | -function getpaid_admin_subscription_update_metabox( $subscription ) { |
|
| 458 | +function getpaid_admin_subscription_update_metabox($subscription) { |
|
| 459 | 459 | |
| 460 | 460 | ?> |
| 461 | 461 | <div class="mt-3"> |
@@ -468,10 +468,10 @@ discard block |
||
| 468 | 468 | 'id' => 'subscription_status_update_select', |
| 469 | 469 | 'required' => true, |
| 470 | 470 | 'no_wrap' => false, |
| 471 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
| 472 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
| 471 | + 'label' => __('Subscription Status', 'invoicing'), |
|
| 472 | + 'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'), |
|
| 473 | 473 | 'select2' => true, |
| 474 | - 'value' => $subscription->get_status( 'edit' ), |
|
| 474 | + 'value' => $subscription->get_status('edit'), |
|
| 475 | 475 | ), |
| 476 | 476 | true |
| 477 | 477 | ); |
@@ -480,14 +480,14 @@ discard block |
||
| 480 | 480 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
| 481 | 481 | |
| 482 | 482 | <?php |
| 483 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
| 483 | + submit_button(__('Update', 'invoicing'), 'primary', 'submit', false); |
|
| 484 | 484 | |
| 485 | - $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
| 486 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
| 487 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
| 485 | + $url = wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce'); |
|
| 486 | + $anchor = __('Renew Subscription', 'invoicing'); |
|
| 487 | + $title = esc_attr__('Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing'); |
|
| 488 | 488 | |
| 489 | - if ( $subscription->is_active() ) { |
|
| 490 | - echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>"; |
|
| 489 | + if ($subscription->is_active()) { |
|
| 490 | + echo "<a href='" . esc_url($url) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr($title) . "\")'>" . esc_html($anchor) . "</a>"; |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | echo '</div></div>'; |
@@ -499,44 +499,44 @@ discard block |
||
| 499 | 499 | * @param WPInv_Subscription $subscription |
| 500 | 500 | * @param bool $strict Whether or not to skip invoices of sibling subscriptions |
| 501 | 501 | */ |
| 502 | -function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
|
| 502 | +function getpaid_admin_subscription_invoice_details_metabox($subscription, $strict = true) { |
|
| 503 | 503 | |
| 504 | 504 | $columns = apply_filters( |
| 505 | 505 | 'getpaid_subscription_related_invoices_columns', |
| 506 | 506 | array( |
| 507 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
| 508 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
| 509 | - 'date' => __( 'Date', 'invoicing' ), |
|
| 510 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 511 | - 'total' => __( 'Total', 'invoicing' ), |
|
| 507 | + 'invoice' => __('Invoice', 'invoicing'), |
|
| 508 | + 'relationship' => __('Relationship', 'invoicing'), |
|
| 509 | + 'date' => __('Date', 'invoicing'), |
|
| 510 | + 'status' => __('Status', 'invoicing'), |
|
| 511 | + 'total' => __('Total', 'invoicing'), |
|
| 512 | 512 | ), |
| 513 | 513 | $subscription |
| 514 | 514 | ); |
| 515 | 515 | |
| 516 | 516 | // Prepare the invoices. |
| 517 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
| 517 | + $payments = $subscription->get_child_payments(!is_admin()); |
|
| 518 | 518 | $parent = $subscription->get_parent_invoice(); |
| 519 | 519 | |
| 520 | - if ( $parent->exists() ) { |
|
| 521 | - $payments = array_merge( array( $parent ), $payments ); |
|
| 520 | + if ($parent->exists()) { |
|
| 521 | + $payments = array_merge(array($parent), $payments); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | $table_class = 'w-100 bg-white'; |
| 525 | 525 | |
| 526 | - if ( ! is_admin() ) { |
|
| 526 | + if (!is_admin()) { |
|
| 527 | 527 | $table_class = 'table table-bordered'; |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | ?> |
| 531 | 531 | <div class="m-0" style="overflow: auto;"> |
| 532 | 532 | |
| 533 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
| 533 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
| 534 | 534 | |
| 535 | 535 | <thead> |
| 536 | 536 | <tr> |
| 537 | 537 | <?php |
| 538 | - foreach ( $columns as $key => $label ) { |
|
| 539 | - echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 538 | + foreach ($columns as $key => $label) { |
|
| 539 | + echo "<th class='subscription-invoice-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>"; |
|
| 540 | 540 | } |
| 541 | 541 | ?> |
| 542 | 542 | </tr> |
@@ -544,71 +544,71 @@ discard block |
||
| 544 | 544 | |
| 545 | 545 | <tbody> |
| 546 | 546 | |
| 547 | - <?php if ( empty( $payments ) ) : ?> |
|
| 547 | + <?php if (empty($payments)) : ?> |
|
| 548 | 548 | <tr> |
| 549 | - <td colspan="<?php echo count( $columns ); ?>" class="p-2 text-left text-muted"> |
|
| 550 | - <?php esc_html_e( 'This subscription has no invoices.', 'invoicing' ); ?> |
|
| 549 | + <td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted"> |
|
| 550 | + <?php esc_html_e('This subscription has no invoices.', 'invoicing'); ?> |
|
| 551 | 551 | </td> |
| 552 | 552 | </tr> |
| 553 | 553 | <?php endif; ?> |
| 554 | 554 | |
| 555 | 555 | <?php |
| 556 | 556 | |
| 557 | - foreach ( $payments as $payment ) : |
|
| 557 | + foreach ($payments as $payment) : |
|
| 558 | 558 | |
| 559 | 559 | // Ensure that we have an invoice. |
| 560 | - $payment = new WPInv_Invoice( $payment ); |
|
| 560 | + $payment = new WPInv_Invoice($payment); |
|
| 561 | 561 | |
| 562 | 562 | // Abort if the invoice is invalid... |
| 563 | - if ( ! $payment->exists() ) { |
|
| 563 | + if (!$payment->exists()) { |
|
| 564 | 564 | continue; |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | // ... or belongs to a different subscription. |
| 568 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
| 568 | + if ($strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id()) { |
|
| 569 | 569 | continue; |
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | echo '<tr>'; |
| 573 | 573 | |
| 574 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 574 | + foreach (array_keys($columns) as $key) { |
|
| 575 | 575 | |
| 576 | 576 | echo "<td class='p-2 text-left'>"; |
| 577 | 577 | |
| 578 | - switch ( $key ) { |
|
| 578 | + switch ($key) { |
|
| 579 | 579 | |
| 580 | 580 | case 'total': |
| 581 | 581 | echo '<strong>'; |
| 582 | - wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
| 582 | + wpinv_the_price($payment->get_total(), $payment->get_currency()); |
|
| 583 | 583 | echo '</strong>'; |
| 584 | 584 | break; |
| 585 | 585 | |
| 586 | 586 | case 'relationship': |
| 587 | - echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
| 587 | + echo $payment->is_renewal() ? esc_html__('Renewal Invoice', 'invoicing') : esc_html__('Initial Invoice', 'invoicing'); |
|
| 588 | 588 | break; |
| 589 | 589 | |
| 590 | 590 | case 'date': |
| 591 | - echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
| 591 | + echo esc_html(getpaid_format_date_value($payment->get_date_created())); |
|
| 592 | 592 | break; |
| 593 | 593 | |
| 594 | 594 | case 'status': |
| 595 | 595 | $status = $payment->get_status_nicename(); |
| 596 | - if ( is_admin() ) { |
|
| 596 | + if (is_admin()) { |
|
| 597 | 597 | $status = $payment->get_status_label_html(); |
| 598 | 598 | } |
| 599 | 599 | |
| 600 | - echo wp_kses_post( $status ); |
|
| 600 | + echo wp_kses_post($status); |
|
| 601 | 601 | break; |
| 602 | 602 | |
| 603 | 603 | case 'invoice': |
| 604 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
| 604 | + $link = esc_url(get_edit_post_link($payment->get_id())); |
|
| 605 | 605 | |
| 606 | - if ( ! is_admin() ) { |
|
| 607 | - $link = esc_url( $payment->get_view_url() ); |
|
| 606 | + if (!is_admin()) { |
|
| 607 | + $link = esc_url($payment->get_view_url()); |
|
| 608 | 608 | } |
| 609 | 609 | |
| 610 | - $invoice = esc_html( $payment->get_number() ); |
|
| 611 | - echo wp_kses_post( "<a href='$link'>$invoice</a>" ); |
|
| 610 | + $invoice = esc_html($payment->get_number()); |
|
| 611 | + echo wp_kses_post("<a href='$link'>$invoice</a>"); |
|
| 612 | 612 | break; |
| 613 | 613 | } |
| 614 | 614 | |
@@ -635,12 +635,12 @@ discard block |
||
| 635 | 635 | * |
| 636 | 636 | * @param WPInv_Subscription $subscription |
| 637 | 637 | */ |
| 638 | -function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
|
| 638 | +function getpaid_admin_subscription_item_details_metabox($subscription) { |
|
| 639 | 639 | |
| 640 | 640 | // Fetch the subscription group. |
| 641 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
| 641 | + $subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_payment_id(), $subscription->get_id()); |
|
| 642 | 642 | |
| 643 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
| 643 | + if (empty($subscription_group) || empty($subscription_group['items'])) { |
|
| 644 | 644 | return; |
| 645 | 645 | } |
| 646 | 646 | |
@@ -648,12 +648,12 @@ discard block |
||
| 648 | 648 | $columns = apply_filters( |
| 649 | 649 | 'getpaid_subscription_item_details_columns', |
| 650 | 650 | array( |
| 651 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
| 652 | - 'price' => __( 'Price', 'invoicing' ), |
|
| 653 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
| 654 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
| 651 | + 'item_name' => __('Item', 'invoicing'), |
|
| 652 | + 'price' => __('Price', 'invoicing'), |
|
| 653 | + 'tax' => __('Tax', 'invoicing'), |
|
| 654 | + 'discount' => __('Discount', 'invoicing'), |
|
| 655 | 655 | //'initial' => __( 'Initial Amount', 'invoicing' ), |
| 656 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
| 656 | + 'recurring' => __('Subtotal', 'invoicing'), |
|
| 657 | 657 | ), |
| 658 | 658 | $subscription |
| 659 | 659 | ); |
@@ -662,27 +662,27 @@ discard block |
||
| 662 | 662 | |
| 663 | 663 | $invoice = $subscription->get_parent_invoice(); |
| 664 | 664 | |
| 665 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
| 666 | - unset( $columns['tax'] ); |
|
| 665 | + if ((!wpinv_use_taxes() || !$invoice->is_taxable()) && isset($columns['tax'])) { |
|
| 666 | + unset($columns['tax']); |
|
| 667 | 667 | } |
| 668 | 668 | |
| 669 | 669 | $table_class = 'w-100 bg-white'; |
| 670 | 670 | |
| 671 | - if ( ! is_admin() ) { |
|
| 671 | + if (!is_admin()) { |
|
| 672 | 672 | $table_class = 'table table-bordered'; |
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | ?> |
| 676 | 676 | <div class="m-0" style="overflow: auto;"> |
| 677 | 677 | |
| 678 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
| 678 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
| 679 | 679 | |
| 680 | 680 | <thead> |
| 681 | 681 | <tr> |
| 682 | 682 | <?php |
| 683 | 683 | |
| 684 | - foreach ( $columns as $key => $label ) { |
|
| 685 | - echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 684 | + foreach ($columns as $key => $label) { |
|
| 685 | + echo "<th class='subscription-item-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>"; |
|
| 686 | 686 | } |
| 687 | 687 | ?> |
| 688 | 688 | </tr> |
@@ -692,48 +692,48 @@ discard block |
||
| 692 | 692 | |
| 693 | 693 | <?php |
| 694 | 694 | |
| 695 | - foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
| 695 | + foreach ($subscription_group['items'] as $subscription_group_item) : |
|
| 696 | 696 | |
| 697 | 697 | echo '<tr>'; |
| 698 | 698 | |
| 699 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 699 | + foreach (array_keys($columns) as $key) { |
|
| 700 | 700 | |
| 701 | 701 | $class = 'text-left'; |
| 702 | 702 | |
| 703 | 703 | echo "<td class='p-2 text-left'>"; |
| 704 | 704 | |
| 705 | - switch ( $key ) { |
|
| 705 | + switch ($key) { |
|
| 706 | 706 | |
| 707 | 707 | case 'item_name': |
| 708 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
| 709 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
| 708 | + $item_name = get_the_title($subscription_group_item['item_id']); |
|
| 709 | + $item_name = empty($item_name) ? $subscription_group_item['item_name'] : $item_name; |
|
| 710 | 710 | |
| 711 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
| 712 | - echo esc_html( $item_name ); |
|
| 711 | + if ($invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity']) { |
|
| 712 | + echo esc_html($item_name); |
|
| 713 | 713 | } else { |
| 714 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
| 714 | + printf('%1$s x %2$d', esc_html($item_name), (float) $subscription_group_item['quantity']); |
|
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | break; |
| 718 | 718 | |
| 719 | 719 | case 'price': |
| 720 | - wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
| 720 | + wpinv_the_price($subscription_group_item['item_price'], $invoice->get_currency()); |
|
| 721 | 721 | break; |
| 722 | 722 | |
| 723 | 723 | case 'tax': |
| 724 | - wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
| 724 | + wpinv_the_price($subscription_group_item['tax'], $invoice->get_currency()); |
|
| 725 | 725 | break; |
| 726 | 726 | |
| 727 | 727 | case 'discount': |
| 728 | - wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
| 728 | + wpinv_the_price($subscription_group_item['discount'], $invoice->get_currency()); |
|
| 729 | 729 | break; |
| 730 | 730 | |
| 731 | 731 | case 'initial': |
| 732 | - wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
| 732 | + wpinv_the_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()); |
|
| 733 | 733 | break; |
| 734 | 734 | |
| 735 | 735 | case 'recurring': |
| 736 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
| 736 | + echo wp_kses_post('<strong>' . wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()) . '</strong>'); |
|
| 737 | 737 | break; |
| 738 | 738 | |
| 739 | 739 | } |
@@ -746,24 +746,24 @@ discard block |
||
| 746 | 746 | |
| 747 | 747 | endforeach; |
| 748 | 748 | |
| 749 | - foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
| 749 | + foreach ($subscription_group['fees'] as $subscription_group_fee) : |
|
| 750 | 750 | |
| 751 | 751 | echo '<tr>'; |
| 752 | 752 | |
| 753 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 753 | + foreach (array_keys($columns) as $key) { |
|
| 754 | 754 | |
| 755 | 755 | $class = 'text-left'; |
| 756 | 756 | |
| 757 | 757 | echo "<td class='p-2 text-left'>"; |
| 758 | 758 | |
| 759 | - switch ( $key ) { |
|
| 759 | + switch ($key) { |
|
| 760 | 760 | |
| 761 | 761 | case 'item_name': |
| 762 | - echo esc_html( $subscription_group_fee['name'] ); |
|
| 762 | + echo esc_html($subscription_group_fee['name']); |
|
| 763 | 763 | break; |
| 764 | 764 | |
| 765 | 765 | case 'price': |
| 766 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 766 | + wpinv_the_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
| 767 | 767 | break; |
| 768 | 768 | |
| 769 | 769 | case 'tax': |
@@ -775,11 +775,11 @@ discard block |
||
| 775 | 775 | break; |
| 776 | 776 | |
| 777 | 777 | case 'initial': |
| 778 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 778 | + wpinv_the_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
| 779 | 779 | break; |
| 780 | 780 | |
| 781 | 781 | case 'recurring': |
| 782 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
| 782 | + echo wp_kses_post('<strong>' . wpinv_price($subscription_group_fee['recurring_fee'], $invoice->get_currency()) . '</strong>'); |
|
| 783 | 783 | break; |
| 784 | 784 | |
| 785 | 785 | } |
@@ -808,12 +808,12 @@ discard block |
||
| 808 | 808 | * @param WPInv_Subscription $subscription |
| 809 | 809 | * @param bool $skip_current |
| 810 | 810 | */ |
| 811 | -function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
|
| 811 | +function getpaid_admin_subscription_related_subscriptions_metabox($subscription, $skip_current = true) { |
|
| 812 | 812 | |
| 813 | 813 | // Fetch the subscription groups. |
| 814 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
| 814 | + $subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_payment_id()); |
|
| 815 | 815 | |
| 816 | - if ( empty( $subscription_groups ) ) { |
|
| 816 | + if (empty($subscription_groups)) { |
|
| 817 | 817 | return; |
| 818 | 818 | } |
| 819 | 819 | |
@@ -821,37 +821,37 @@ discard block |
||
| 821 | 821 | $columns = apply_filters( |
| 822 | 822 | 'getpaid_subscription_related_subscriptions_columns', |
| 823 | 823 | array( |
| 824 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 825 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 826 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
| 827 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
| 828 | - 'item' => __( 'Items', 'invoicing' ), |
|
| 829 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 824 | + 'subscription' => __('Subscription', 'invoicing'), |
|
| 825 | + 'start_date' => __('Start Date', 'invoicing'), |
|
| 826 | + 'renewal_date' => __('Next Payment', 'invoicing'), |
|
| 827 | + 'renewals' => __('Payments', 'invoicing'), |
|
| 828 | + 'item' => __('Items', 'invoicing'), |
|
| 829 | + 'status' => __('Status', 'invoicing'), |
|
| 830 | 830 | ), |
| 831 | 831 | $subscription |
| 832 | 832 | ); |
| 833 | 833 | |
| 834 | - if ( $subscription->get_status() == 'pending' ) { |
|
| 835 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
| 834 | + if ($subscription->get_status() == 'pending') { |
|
| 835 | + unset($columns['start_date'], $columns['renewal_date']); |
|
| 836 | 836 | } |
| 837 | 837 | |
| 838 | 838 | $table_class = 'w-100 bg-white'; |
| 839 | 839 | |
| 840 | - if ( ! is_admin() ) { |
|
| 840 | + if (!is_admin()) { |
|
| 841 | 841 | $table_class = 'table table-bordered'; |
| 842 | 842 | } |
| 843 | 843 | |
| 844 | 844 | ?> |
| 845 | 845 | <div class="m-0" style="overflow: auto;"> |
| 846 | 846 | |
| 847 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
| 847 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
| 848 | 848 | |
| 849 | 849 | <thead> |
| 850 | 850 | <tr> |
| 851 | 851 | <?php |
| 852 | 852 | |
| 853 | - foreach ( $columns as $key => $label ) { |
|
| 854 | - echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 853 | + foreach ($columns as $key => $label) { |
|
| 854 | + echo "<th class='related-subscription-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>"; |
|
| 855 | 855 | } |
| 856 | 856 | ?> |
| 857 | 857 | </tr> |
@@ -861,62 +861,62 @@ discard block |
||
| 861 | 861 | |
| 862 | 862 | <?php |
| 863 | 863 | |
| 864 | - foreach ( $subscription_groups as $subscription_group ) : |
|
| 864 | + foreach ($subscription_groups as $subscription_group) : |
|
| 865 | 865 | |
| 866 | 866 | // Do not list current subscription. |
| 867 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
| 867 | + if ($skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id()) { |
|
| 868 | 868 | continue; |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | 871 | // Ensure the subscription exists. |
| 872 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
| 872 | + $_suscription = new WPInv_Subscription($subscription_group['subscription_id']); |
|
| 873 | 873 | |
| 874 | - if ( ! $_suscription->exists() ) { |
|
| 874 | + if (!$_suscription->exists()) { |
|
| 875 | 875 | continue; |
| 876 | 876 | } |
| 877 | 877 | |
| 878 | 878 | echo '<tr>'; |
| 879 | 879 | |
| 880 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 880 | + foreach (array_keys($columns) as $key) { |
|
| 881 | 881 | |
| 882 | 882 | $class = 'text-left'; |
| 883 | 883 | |
| 884 | 884 | echo "<td class='p-2 text-left'>"; |
| 885 | 885 | |
| 886 | - switch ( $key ) { |
|
| 886 | + switch ($key) { |
|
| 887 | 887 | |
| 888 | 888 | case 'status': |
| 889 | - echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
| 889 | + echo wp_kses_post($_suscription->get_status_label_html()); |
|
| 890 | 890 | break; |
| 891 | 891 | |
| 892 | 892 | case 'item': |
| 893 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 894 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
| 893 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
| 894 | + echo wp_kses_post(implode(' | ', $markup)); |
|
| 895 | 895 | break; |
| 896 | 896 | |
| 897 | 897 | case 'renewals': |
| 898 | 898 | $max_bills = $_suscription->get_bill_times(); |
| 899 | - echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
| 899 | + echo ((int) $_suscription->get_times_billed()) . ' / ' . (empty($max_bills) ? '∞' : (int) $max_bills); |
|
| 900 | 900 | break; |
| 901 | 901 | |
| 902 | 902 | case 'renewal_date': |
| 903 | - echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '—'; |
|
| 903 | + echo $_suscription->is_active() ? esc_html(getpaid_format_date_value($_suscription->get_expiration())) : '—'; |
|
| 904 | 904 | break; |
| 905 | 905 | |
| 906 | 906 | case 'start_date': |
| 907 | - echo 'pending' == $_suscription->get_status() ? '—' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) ); |
|
| 907 | + echo 'pending' == $_suscription->get_status() ? '—' : esc_html(getpaid_format_date_value($_suscription->get_date_created())); |
|
| 908 | 908 | break; |
| 909 | 909 | |
| 910 | 910 | case 'subscription': |
| 911 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
| 911 | + $url = is_admin() ? admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($_suscription->get_id())) : $_suscription->get_view_url(); |
|
| 912 | 912 | printf( |
| 913 | 913 | '%1$s#%2$s%3$s', |
| 914 | - '<a href="' . esc_url( $url ) . '">', |
|
| 915 | - '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
| 914 | + '<a href="' . esc_url($url) . '">', |
|
| 915 | + '<strong>' . intval($_suscription->get_id()) . '</strong>', |
|
| 916 | 916 | '</a>' |
| 917 | 917 | ); |
| 918 | 918 | |
| 919 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
| 919 | + echo wp_kses_post(WPInv_Subscriptions_List_Table::column_amount($_suscription)); |
|
| 920 | 920 | break; |
| 921 | 921 | |
| 922 | 922 | } |
@@ -1,38 +1,38 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // MUST have WordPress. |
| 3 | -if ( ! defined( 'WPINC' ) ) { |
|
| 3 | +if (!defined('WPINC')) { |
|
| 4 | 4 | exit; |
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | class WPInv_Meta_Box_Notes { |
| 8 | - public static function output( $post ) { |
|
| 8 | + public static function output($post) { |
|
| 9 | 9 | global $post; |
| 10 | 10 | |
| 11 | - $notes = wpinv_get_invoice_notes( $post->ID ); |
|
| 11 | + $notes = wpinv_get_invoice_notes($post->ID); |
|
| 12 | 12 | |
| 13 | 13 | echo '<ul class="invoice_notes">'; |
| 14 | 14 | |
| 15 | - if ( $notes ) { |
|
| 16 | - foreach ( $notes as $note ) { |
|
| 17 | - wpinv_get_invoice_note_line_item( $note ); |
|
| 15 | + if ($notes) { |
|
| 16 | + foreach ($notes as $note) { |
|
| 17 | + wpinv_get_invoice_note_line_item($note); |
|
| 18 | 18 | } |
| 19 | 19 | } else { |
| 20 | - echo '<li>' . esc_html__( 'There are no notes yet.', 'invoicing' ) . '</li>'; |
|
| 20 | + echo '<li>' . esc_html__('There are no notes yet.', 'invoicing') . '</li>'; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | echo '</ul>'; |
| 24 | 24 | ?> |
| 25 | 25 | <div class="add_note"> |
| 26 | - <h4><?php esc_html_e( 'Add note', 'invoicing' ); ?></h4> |
|
| 26 | + <h4><?php esc_html_e('Add note', 'invoicing'); ?></h4> |
|
| 27 | 27 | <p> |
| 28 | 28 | <textarea type="text" name="invoice_note" id="add_invoice_note" class="input-text" cols="20" rows="5"></textarea> |
| 29 | 29 | </p> |
| 30 | 30 | <p> |
| 31 | 31 | <select name="invoice_note_type" id="invoice_note_type" class="regular-text"> |
| 32 | - <option value=""><?php esc_html_e( 'Private note', 'invoicing' ); ?></option> |
|
| 33 | - <option value="customer"><?php esc_html_e( 'Note to customer', 'invoicing' ); ?></option> |
|
| 32 | + <option value=""><?php esc_html_e('Private note', 'invoicing'); ?></option> |
|
| 33 | + <option value="customer"><?php esc_html_e('Note to customer', 'invoicing'); ?></option> |
|
| 34 | 34 | </select> |
| 35 | - <a href="#" class="add_note button"><?php esc_html_e( 'Add', 'invoicing' ); ?></a> <span class="description"><?php esc_html_e( 'Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing' ); ?></span> |
|
| 35 | + <a href="#" class="add_note button"><?php esc_html_e('Add', 'invoicing'); ?></a> <span class="description"><?php esc_html_e('Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing'); ?></span> |
|
| 36 | 36 | </p> |
| 37 | 37 | </div> |
| 38 | 38 | <?php |
@@ -126,14 +126,14 @@ |
||
| 126 | 126 | */ |
| 127 | 127 | function getpaid_doing_it_wrong( $function, $message, $version ) { |
| 128 | 128 | |
| 129 | - $message .= ' Backtrace: ' . wp_debug_backtrace_summary(); |
|
| 130 | - |
|
| 131 | - if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) { |
|
| 132 | - do_action( 'doing_it_wrong_run', $function, $message, $version ); |
|
| 133 | - error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." ); |
|
| 134 | - } else { |
|
| 135 | - _doing_it_wrong( esc_html( $function ), wp_kses_post( $message ), esc_html( $version ) ); |
|
| 136 | - } |
|
| 129 | + $message .= ' Backtrace: ' . wp_debug_backtrace_summary(); |
|
| 130 | + |
|
| 131 | + if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) { |
|
| 132 | + do_action( 'doing_it_wrong_run', $function, $message, $version ); |
|
| 133 | + error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." ); |
|
| 134 | + } else { |
|
| 135 | + _doing_it_wrong( esc_html( $function ), wp_kses_post( $message ), esc_html( $version ) ); |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | 138 | } |
| 139 | 139 | |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @package Invoicing |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -defined( 'ABSPATH' ) || exit; |
|
| 9 | +defined('ABSPATH') || exit; |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * Returns the errors as html |
@@ -15,35 +15,35 @@ discard block |
||
| 15 | 15 | * @param bool $wrap whether or not to wrap the errors. |
| 16 | 16 | * @since 1.0.19 |
| 17 | 17 | */ |
| 18 | -function getpaid_get_errors_html( $clear = true, $wrap = true ) { |
|
| 18 | +function getpaid_get_errors_html($clear = true, $wrap = true) { |
|
| 19 | 19 | |
| 20 | 20 | $errors = ''; |
| 21 | - foreach ( wpinv_get_errors() as $id => $error ) { |
|
| 22 | - $type = 'error'; |
|
| 21 | + foreach (wpinv_get_errors() as $id => $error) { |
|
| 22 | + $type = 'error'; |
|
| 23 | 23 | |
| 24 | - if ( is_array( $error ) ) { |
|
| 24 | + if (is_array($error)) { |
|
| 25 | 25 | $type = $error['type']; |
| 26 | 26 | $error = $error['text']; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - if ( $wrap ) { |
|
| 29 | + if ($wrap) { |
|
| 30 | 30 | |
| 31 | 31 | $errors .= aui()->alert( |
| 32 | 32 | array( |
| 33 | - 'content' => wp_kses_post( $error ), |
|
| 33 | + 'content' => wp_kses_post($error), |
|
| 34 | 34 | 'type' => $type, |
| 35 | 35 | ) |
| 36 | 36 | ); |
| 37 | 37 | |
| 38 | 38 | } else { |
| 39 | 39 | |
| 40 | - $id = esc_attr( $id ); |
|
| 41 | - $error = wp_kses_post( $error ); |
|
| 40 | + $id = esc_attr($id); |
|
| 41 | + $error = wp_kses_post($error); |
|
| 42 | 42 | $errors .= "<div data-code='$id'>$error</div>"; |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - if ( $clear ) { |
|
| 46 | + if ($clear) { |
|
| 47 | 47 | wpinv_clear_errors(); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * Prints (then clears) all available errors. |
| 56 | 56 | */ |
| 57 | 57 | function wpinv_print_errors() { |
| 58 | - echo wp_kses_post( getpaid_get_errors_html() ); |
|
| 58 | + echo wp_kses_post(getpaid_get_errors_html()); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -69,54 +69,54 @@ discard block |
||
| 69 | 69 | $all_errors = array( |
| 70 | 70 | 'perm_cancel_subscription' => array( |
| 71 | 71 | 'type' => 'error', |
| 72 | - 'text' => __( 'You do not have permission to cancel this subscription', 'invoicing' ), |
|
| 72 | + 'text' => __('You do not have permission to cancel this subscription', 'invoicing'), |
|
| 73 | 73 | ), |
| 74 | 74 | 'cannot_cancel_subscription' => array( |
| 75 | 75 | 'type' => 'error', |
| 76 | - 'text' => __( 'This subscription cannot be cancelled as it is not active.', 'invoicing' ), |
|
| 76 | + 'text' => __('This subscription cannot be cancelled as it is not active.', 'invoicing'), |
|
| 77 | 77 | ), |
| 78 | 78 | 'cancelled_subscription' => array( |
| 79 | 79 | 'type' => 'success', |
| 80 | - 'text' => __( 'Subscription cancelled successfully.', 'invoicing' ), |
|
| 80 | + 'text' => __('Subscription cancelled successfully.', 'invoicing'), |
|
| 81 | 81 | ), |
| 82 | 82 | 'address_updated' => array( |
| 83 | 83 | 'type' => 'success', |
| 84 | - 'text' => __( 'Address updated successfully.', 'invoicing' ), |
|
| 84 | + 'text' => __('Address updated successfully.', 'invoicing'), |
|
| 85 | 85 | ), |
| 86 | 86 | 'perm_delete_invoice' => array( |
| 87 | 87 | 'type' => 'error', |
| 88 | - 'text' => __( 'You do not have permission to delete this invoice', 'invoicing' ), |
|
| 88 | + 'text' => __('You do not have permission to delete this invoice', 'invoicing'), |
|
| 89 | 89 | ), |
| 90 | 90 | 'cannot_delete_invoice' => array( |
| 91 | 91 | 'type' => 'error', |
| 92 | - 'text' => __( 'This invoice cannot be deleted as it has already been paid.', 'invoicing' ), |
|
| 92 | + 'text' => __('This invoice cannot be deleted as it has already been paid.', 'invoicing'), |
|
| 93 | 93 | ), |
| 94 | 94 | 'deleted_invoice' => array( |
| 95 | 95 | 'type' => 'success', |
| 96 | - 'text' => __( 'Invoice deleted successfully.', 'invoicing' ), |
|
| 96 | + 'text' => __('Invoice deleted successfully.', 'invoicing'), |
|
| 97 | 97 | ), |
| 98 | 98 | 'card_declined' => array( |
| 99 | 99 | 'type' => 'error', |
| 100 | - 'text' => __( 'Your card was declined.', 'invoicing' ), |
|
| 100 | + 'text' => __('Your card was declined.', 'invoicing'), |
|
| 101 | 101 | ), |
| 102 | 102 | 'invalid_currency' => array( |
| 103 | 103 | 'type' => 'error', |
| 104 | - 'text' => __( 'The chosen payment gateway does not support this currency.', 'invoicing' ), |
|
| 104 | + 'text' => __('The chosen payment gateway does not support this currency.', 'invoicing'), |
|
| 105 | 105 | ), |
| 106 | 106 | ); |
| 107 | 107 | |
| 108 | - $errors = apply_filters( 'wpinv_errors', array() ); |
|
| 108 | + $errors = apply_filters('wpinv_errors', array()); |
|
| 109 | 109 | |
| 110 | - if ( isset( $_GET['wpinv-notice'] ) && isset( $all_errors[ $_GET['wpinv-notice'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 111 | - $errors[ $_GET['wpinv-notice'] ] = $all_errors[ $_GET['wpinv-notice'] ]; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 110 | + if (isset($_GET['wpinv-notice']) && isset($all_errors[$_GET['wpinv-notice']])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 111 | + $errors[$_GET['wpinv-notice']] = $all_errors[$_GET['wpinv-notice']]; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - if ( isset( $GLOBALS['wpinv_notice'] ) && isset( $all_errors[ $GLOBALS['wpinv_notice'] ] ) ) { |
|
| 115 | - $errors[ $GLOBALS['wpinv_notice'] ] = $all_errors[ $GLOBALS['wpinv_notice'] ]; |
|
| 114 | + if (isset($GLOBALS['wpinv_notice']) && isset($all_errors[$GLOBALS['wpinv_notice']])) { |
|
| 115 | + $errors[$GLOBALS['wpinv_notice']] = $all_errors[$GLOBALS['wpinv_notice']]; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - if ( isset( $GLOBALS['wpinv_custom_notice'] ) ) { |
|
| 119 | - $errors[ $GLOBALS['wpinv_custom_notice']['code'] ] = $GLOBALS['wpinv_custom_notice']; |
|
| 118 | + if (isset($GLOBALS['wpinv_custom_notice'])) { |
|
| 119 | + $errors[$GLOBALS['wpinv_custom_notice']['code']] = $GLOBALS['wpinv_custom_notice']; |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | return $errors; |
@@ -129,9 +129,9 @@ discard block |
||
| 129 | 129 | * @param string $error The error message. |
| 130 | 130 | * @param string $type The error type. |
| 131 | 131 | */ |
| 132 | -function wpinv_set_error( $error_id, $message = '', $type = 'error' ) { |
|
| 132 | +function wpinv_set_error($error_id, $message = '', $type = 'error') { |
|
| 133 | 133 | |
| 134 | - if ( ! empty( $message ) ) { |
|
| 134 | + if (!empty($message)) { |
|
| 135 | 135 | $GLOBALS['wpinv_custom_notice'] = array( |
| 136 | 136 | 'code' => $error_id, |
| 137 | 137 | 'type' => $type, |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * |
| 148 | 148 | */ |
| 149 | 149 | function wpinv_has_errors() { |
| 150 | - return count( wpinv_get_errors() ) > 0; |
|
| 150 | + return count(wpinv_get_errors()) > 0; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | /** |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * |
| 156 | 156 | */ |
| 157 | 157 | function wpinv_clear_errors() { |
| 158 | - unset( $GLOBALS['wpinv_notice'] ); |
|
| 158 | + unset($GLOBALS['wpinv_notice']); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /** |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | * |
| 164 | 164 | */ |
| 165 | 165 | function wpinv_unset_error() { |
| 166 | - unset( $GLOBALS['wpinv_notice'] ); |
|
| 166 | + unset($GLOBALS['wpinv_notice']); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -174,15 +174,15 @@ discard block |
||
| 174 | 174 | * @param string $message Message to log. |
| 175 | 175 | * @param string $version Version the message was added in. |
| 176 | 176 | */ |
| 177 | -function getpaid_doing_it_wrong( $function, $message, $version ) { |
|
| 177 | +function getpaid_doing_it_wrong($function, $message, $version) { |
|
| 178 | 178 | |
| 179 | 179 | $message .= ' Backtrace: ' . wp_debug_backtrace_summary(); |
| 180 | 180 | |
| 181 | - if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) { |
|
| 182 | - do_action( 'doing_it_wrong_run', $function, $message, $version ); |
|
| 183 | - error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." ); |
|
| 181 | + if (wp_doing_ajax() || defined('REST_REQUEST')) { |
|
| 182 | + do_action('doing_it_wrong_run', $function, $message, $version); |
|
| 183 | + error_log("{$function} was called incorrectly. {$message}. This message was added in version {$version}."); |
|
| 184 | 184 | } else { |
| 185 | - _doing_it_wrong( esc_html( $function ), wp_kses_post( $message ), esc_html( $version ) ); |
|
| 185 | + _doing_it_wrong(esc_html($function), wp_kses_post($message), esc_html($version)); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | } |
@@ -196,41 +196,41 @@ discard block |
||
| 196 | 196 | * @param string $line The line that contains the error. |
| 197 | 197 | * @param bool $exit Whether or not to exit function execution. |
| 198 | 198 | */ |
| 199 | -function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) { |
|
| 199 | +function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) { |
|
| 200 | 200 | |
| 201 | - if ( true === apply_filters( 'wpinv_log_errors', true ) ) { |
|
| 201 | + if (true === apply_filters('wpinv_log_errors', true)) { |
|
| 202 | 202 | |
| 203 | 203 | // Ensure the log is a scalar. |
| 204 | - if ( ! is_scalar( $log ) ) { |
|
| 205 | - $log = print_r( $log, true ); |
|
| 204 | + if (!is_scalar($log)) { |
|
| 205 | + $log = print_r($log, true); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | // Add title. |
| 209 | - if ( ! empty( $title ) ) { |
|
| 210 | - $log = $title . ' ' . trim( $log ); |
|
| 209 | + if (!empty($title)) { |
|
| 210 | + $log = $title . ' ' . trim($log); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | // Add the file to the label. |
| 214 | - if ( ! empty( $file ) ) { |
|
| 214 | + if (!empty($file)) { |
|
| 215 | 215 | $log .= ' in ' . $file; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | // Add the line number to the label. |
| 219 | - if ( ! empty( $line ) ) { |
|
| 219 | + if (!empty($line)) { |
|
| 220 | 220 | $log .= ' on line ' . $line; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | // Log the message. |
| 224 | - error_log( trim( $log ) ); |
|
| 224 | + error_log(trim($log)); |
|
| 225 | 225 | |
| 226 | 226 | // ... and a backtrace. |
| 227 | - if ( false !== $title && false !== $file ) { |
|
| 228 | - error_log( 'Backtrace ' . wp_debug_backtrace_summary() ); |
|
| 227 | + if (false !== $title && false !== $file) { |
|
| 228 | + error_log('Backtrace ' . wp_debug_backtrace_summary()); |
|
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | // Maybe exit. |
| 233 | - if ( $exit ) { |
|
| 233 | + if ($exit) { |
|
| 234 | 234 | exit; |
| 235 | 235 | } |
| 236 | 236 | |
@@ -12,49 +12,49 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | class GetPaid_Reports { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Class constructor. |
|
| 17 | - * |
|
| 18 | - */ |
|
| 19 | - public function __construct() { |
|
| 20 | - add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 ); |
|
| 21 | - add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) ); |
|
| 22 | - add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) ); |
|
| 23 | - add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) ); |
|
| 24 | - add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) ); |
|
| 25 | - |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Registers the reports page. |
|
| 30 | - * |
|
| 31 | - */ |
|
| 32 | - public function register_reports_page() { |
|
| 33 | - |
|
| 34 | - add_submenu_page( |
|
| 15 | + /** |
|
| 16 | + * Class constructor. |
|
| 17 | + * |
|
| 18 | + */ |
|
| 19 | + public function __construct() { |
|
| 20 | + add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 ); |
|
| 21 | + add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) ); |
|
| 22 | + add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) ); |
|
| 23 | + add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) ); |
|
| 24 | + add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) ); |
|
| 25 | + |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Registers the reports page. |
|
| 30 | + * |
|
| 31 | + */ |
|
| 32 | + public function register_reports_page() { |
|
| 33 | + |
|
| 34 | + add_submenu_page( |
|
| 35 | 35 | 'wpinv', |
| 36 | 36 | __( 'Reports', 'invoicing' ), |
| 37 | 37 | __( 'Reports', 'invoicing' ), |
| 38 | 38 | wpinv_get_capability(), |
| 39 | 39 | 'wpinv-reports', |
| 40 | 40 | array( $this, 'display_reports_page' ) |
| 41 | - ); |
|
| 41 | + ); |
|
| 42 | 42 | |
| 43 | - } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Displays the reports page. |
|
| 47 | - * |
|
| 48 | - */ |
|
| 49 | - public function display_reports_page() { |
|
| 45 | + /** |
|
| 46 | + * Displays the reports page. |
|
| 47 | + * |
|
| 48 | + */ |
|
| 49 | + public function display_reports_page() { |
|
| 50 | 50 | |
| 51 | - // Prepare variables. |
|
| 52 | - $tabs = $this->get_tabs(); |
|
| 53 | - $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports'; |
|
| 54 | - $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports'; |
|
| 51 | + // Prepare variables. |
|
| 52 | + $tabs = $this->get_tabs(); |
|
| 53 | + $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports'; |
|
| 54 | + $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports'; |
|
| 55 | 55 | |
| 56 | - // Display the current tab. |
|
| 57 | - ?> |
|
| 56 | + // Display the current tab. |
|
| 57 | + ?> |
|
| 58 | 58 | |
| 59 | 59 | <div class="wrap"> |
| 60 | 60 | |
@@ -63,19 +63,19 @@ discard block |
||
| 63 | 63 | <nav class="nav-tab-wrapper"> |
| 64 | 64 | |
| 65 | 65 | <?php |
| 66 | - foreach ( $tabs as $key => $label ) { |
|
| 66 | + foreach ( $tabs as $key => $label ) { |
|
| 67 | 67 | |
| 68 | - $key = sanitize_key( $key ); |
|
| 69 | - $label = esc_html( $label ); |
|
| 70 | - $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab'; |
|
| 71 | - $url = esc_url( |
|
| 68 | + $key = sanitize_key( $key ); |
|
| 69 | + $label = esc_html( $label ); |
|
| 70 | + $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab'; |
|
| 71 | + $url = esc_url( |
|
| 72 | 72 | add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) ) |
| 73 | 73 | ); |
| 74 | 74 | |
| 75 | - echo wp_kses_post( "\n\t\t\t<a href='$url' class='" . $class . "'>$label</a>" ); |
|
| 75 | + echo wp_kses_post( "\n\t\t\t<a href='$url' class='" . $class . "'>$label</a>" ); |
|
| 76 | 76 | |
| 77 | - } |
|
| 78 | - ?> |
|
| 77 | + } |
|
| 78 | + ?> |
|
| 79 | 79 | |
| 80 | 80 | </nav> |
| 81 | 81 | |
@@ -86,82 +86,82 @@ discard block |
||
| 86 | 86 | </div> |
| 87 | 87 | <?php |
| 88 | 88 | |
| 89 | - // Wordfence loads an unsupported version of chart js on our page. |
|
| 90 | - wp_deregister_style( 'chart-js' ); |
|
| 91 | - wp_deregister_script( 'chart-js' ); |
|
| 92 | - wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true ); |
|
| 89 | + // Wordfence loads an unsupported version of chart js on our page. |
|
| 90 | + wp_deregister_style( 'chart-js' ); |
|
| 91 | + wp_deregister_script( 'chart-js' ); |
|
| 92 | + wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true ); |
|
| 93 | 93 | |
| 94 | - } |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Retrieves reports page tabs. |
|
| 98 | - * |
|
| 99 | - * @return array |
|
| 100 | - */ |
|
| 101 | - public function get_tabs() { |
|
| 96 | + /** |
|
| 97 | + * Retrieves reports page tabs. |
|
| 98 | + * |
|
| 99 | + * @return array |
|
| 100 | + */ |
|
| 101 | + public function get_tabs() { |
|
| 102 | 102 | |
| 103 | - $tabs = array( |
|
| 104 | - 'reports' => __( 'Reports', 'invoicing' ), |
|
| 105 | - 'export' => __( 'Export', 'invoicing' ), |
|
| 106 | - ); |
|
| 103 | + $tabs = array( |
|
| 104 | + 'reports' => __( 'Reports', 'invoicing' ), |
|
| 105 | + 'export' => __( 'Export', 'invoicing' ), |
|
| 106 | + ); |
|
| 107 | 107 | |
| 108 | - return apply_filters( 'getpaid_report_tabs', $tabs ); |
|
| 109 | - } |
|
| 108 | + return apply_filters( 'getpaid_report_tabs', $tabs ); |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * Displays the reports tab. |
|
| 113 | - * |
|
| 114 | - */ |
|
| 115 | - public function display_reports_tab() { |
|
| 111 | + /** |
|
| 112 | + * Displays the reports tab. |
|
| 113 | + * |
|
| 114 | + */ |
|
| 115 | + public function display_reports_tab() { |
|
| 116 | 116 | |
| 117 | - $reports = new GetPaid_Reports_Report(); |
|
| 118 | - $reports->display(); |
|
| 117 | + $reports = new GetPaid_Reports_Report(); |
|
| 118 | + $reports->display(); |
|
| 119 | 119 | |
| 120 | - } |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - /** |
|
| 123 | - * Displays the exports tab. |
|
| 124 | - * |
|
| 125 | - */ |
|
| 126 | - public function display_exports_tab() { |
|
| 122 | + /** |
|
| 123 | + * Displays the exports tab. |
|
| 124 | + * |
|
| 125 | + */ |
|
| 126 | + public function display_exports_tab() { |
|
| 127 | 127 | |
| 128 | - $exports = new GetPaid_Reports_Export(); |
|
| 129 | - $exports->display(); |
|
| 128 | + $exports = new GetPaid_Reports_Export(); |
|
| 129 | + $exports->display(); |
|
| 130 | 130 | |
| 131 | - } |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - /** |
|
| 134 | - * Donwnloads a graph. |
|
| 135 | - * |
|
| 136 | - * @param array $args |
|
| 137 | - */ |
|
| 138 | - public function download_graph( $args ) { |
|
| 133 | + /** |
|
| 134 | + * Donwnloads a graph. |
|
| 135 | + * |
|
| 136 | + * @param array $args |
|
| 137 | + */ |
|
| 138 | + public function download_graph( $args ) { |
|
| 139 | 139 | |
| 140 | - if ( ! empty( $args['graph'] ) ) { |
|
| 141 | - $downloader = new GetPaid_Graph_Downloader(); |
|
| 142 | - $downloader->download( $args['graph'] ); |
|
| 143 | - } |
|
| 140 | + if ( ! empty( $args['graph'] ) ) { |
|
| 141 | + $downloader = new GetPaid_Graph_Downloader(); |
|
| 142 | + $downloader->download( $args['graph'] ); |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - } |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - /** |
|
| 148 | - * Exports invoices. |
|
| 149 | - * |
|
| 150 | - * @param array $args |
|
| 151 | - */ |
|
| 152 | - public function export_invoices( $args ) { |
|
| 147 | + /** |
|
| 148 | + * Exports invoices. |
|
| 149 | + * |
|
| 150 | + * @param array $args |
|
| 151 | + */ |
|
| 152 | + public function export_invoices( $args ) { |
|
| 153 | 153 | |
| 154 | - if ( ! empty( $args['post_type'] ) ) { |
|
| 154 | + if ( ! empty( $args['post_type'] ) ) { |
|
| 155 | 155 | |
| 156 | - if ( 'subscriptions' === $args['post_type'] ) { |
|
| 157 | - $downloader = new GetPaid_Subscription_Exporter(); |
|
| 158 | - } else { |
|
| 159 | - $downloader = new GetPaid_Invoice_Exporter(); |
|
| 160 | - } |
|
| 156 | + if ( 'subscriptions' === $args['post_type'] ) { |
|
| 157 | + $downloader = new GetPaid_Subscription_Exporter(); |
|
| 158 | + } else { |
|
| 159 | + $downloader = new GetPaid_Invoice_Exporter(); |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - $downloader->export( $args['post_type'], $args ); |
|
| 163 | - } |
|
| 162 | + $downloader->export( $args['post_type'], $args ); |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - } |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | 167 | } |
@@ -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 Class. |
@@ -17,11 +17,11 @@ discard block |
||
| 17 | 17 | * |
| 18 | 18 | */ |
| 19 | 19 | public function __construct() { |
| 20 | - add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 ); |
|
| 21 | - add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) ); |
|
| 22 | - add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) ); |
|
| 23 | - add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) ); |
|
| 24 | - add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) ); |
|
| 20 | + add_action('admin_menu', array($this, 'register_reports_page'), 20); |
|
| 21 | + add_action('wpinv_reports_tab_reports', array($this, 'display_reports_tab')); |
|
| 22 | + add_action('wpinv_reports_tab_export', array($this, 'display_exports_tab')); |
|
| 23 | + add_action('getpaid_authenticated_admin_action_download_graph', array($this, 'download_graph')); |
|
| 24 | + add_action('getpaid_authenticated_admin_action_export_invoices', array($this, 'export_invoices')); |
|
| 25 | 25 | |
| 26 | 26 | } |
| 27 | 27 | |
@@ -33,11 +33,11 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | add_submenu_page( |
| 35 | 35 | 'wpinv', |
| 36 | - __( 'Reports', 'invoicing' ), |
|
| 37 | - __( 'Reports', 'invoicing' ), |
|
| 36 | + __('Reports', 'invoicing'), |
|
| 37 | + __('Reports', 'invoicing'), |
|
| 38 | 38 | wpinv_get_capability(), |
| 39 | 39 | 'wpinv-reports', |
| 40 | - array( $this, 'display_reports_page' ) |
|
| 40 | + array($this, 'display_reports_page') |
|
| 41 | 41 | ); |
| 42 | 42 | |
| 43 | 43 | } |
@@ -50,46 +50,46 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | // Prepare variables. |
| 52 | 52 | $tabs = $this->get_tabs(); |
| 53 | - $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports'; |
|
| 54 | - $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports'; |
|
| 53 | + $current_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'reports'; |
|
| 54 | + $current_tab = array_key_exists($current_tab, $tabs) ? $current_tab : 'reports'; |
|
| 55 | 55 | |
| 56 | 56 | // Display the current tab. |
| 57 | 57 | ?> |
| 58 | 58 | |
| 59 | 59 | <div class="wrap"> |
| 60 | 60 | |
| 61 | - <h1><?php echo esc_html( $tabs[ $current_tab ] ); ?></h1> |
|
| 61 | + <h1><?php echo esc_html($tabs[$current_tab]); ?></h1> |
|
| 62 | 62 | |
| 63 | 63 | <nav class="nav-tab-wrapper"> |
| 64 | 64 | |
| 65 | 65 | <?php |
| 66 | - foreach ( $tabs as $key => $label ) { |
|
| 66 | + foreach ($tabs as $key => $label) { |
|
| 67 | 67 | |
| 68 | - $key = sanitize_key( $key ); |
|
| 69 | - $label = esc_html( $label ); |
|
| 68 | + $key = sanitize_key($key); |
|
| 69 | + $label = esc_html($label); |
|
| 70 | 70 | $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab'; |
| 71 | 71 | $url = esc_url( |
| 72 | - add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) ) |
|
| 72 | + add_query_arg('tab', $key, admin_url('admin.php?page=wpinv-reports')) |
|
| 73 | 73 | ); |
| 74 | 74 | |
| 75 | - echo wp_kses_post( "\n\t\t\t<a href='$url' class='" . $class . "'>$label</a>" ); |
|
| 75 | + echo wp_kses_post("\n\t\t\t<a href='$url' class='" . $class . "'>$label</a>"); |
|
| 76 | 76 | |
| 77 | 77 | } |
| 78 | 78 | ?> |
| 79 | 79 | |
| 80 | 80 | </nav> |
| 81 | 81 | |
| 82 | - <div class="bsui <?php echo esc_attr( $current_tab ); ?>"> |
|
| 83 | - <?php do_action( "wpinv_reports_tab_{$current_tab}" ); ?> |
|
| 82 | + <div class="bsui <?php echo esc_attr($current_tab); ?>"> |
|
| 83 | + <?php do_action("wpinv_reports_tab_{$current_tab}"); ?> |
|
| 84 | 84 | </div> |
| 85 | 85 | |
| 86 | 86 | </div> |
| 87 | 87 | <?php |
| 88 | 88 | |
| 89 | 89 | // Wordfence loads an unsupported version of chart js on our page. |
| 90 | - wp_deregister_style( 'chart-js' ); |
|
| 91 | - wp_deregister_script( 'chart-js' ); |
|
| 92 | - wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true ); |
|
| 90 | + wp_deregister_style('chart-js'); |
|
| 91 | + wp_deregister_script('chart-js'); |
|
| 92 | + wp_enqueue_script('chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array('jquery'), '3.7.1', true); |
|
| 93 | 93 | |
| 94 | 94 | } |
| 95 | 95 | |
@@ -101,11 +101,11 @@ discard block |
||
| 101 | 101 | public function get_tabs() { |
| 102 | 102 | |
| 103 | 103 | $tabs = array( |
| 104 | - 'reports' => __( 'Reports', 'invoicing' ), |
|
| 105 | - 'export' => __( 'Export', 'invoicing' ), |
|
| 104 | + 'reports' => __('Reports', 'invoicing'), |
|
| 105 | + 'export' => __('Export', 'invoicing'), |
|
| 106 | 106 | ); |
| 107 | 107 | |
| 108 | - return apply_filters( 'getpaid_report_tabs', $tabs ); |
|
| 108 | + return apply_filters('getpaid_report_tabs', $tabs); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -135,11 +135,11 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @param array $args |
| 137 | 137 | */ |
| 138 | - public function download_graph( $args ) { |
|
| 138 | + public function download_graph($args) { |
|
| 139 | 139 | |
| 140 | - if ( ! empty( $args['graph'] ) ) { |
|
| 140 | + if (!empty($args['graph'])) { |
|
| 141 | 141 | $downloader = new GetPaid_Graph_Downloader(); |
| 142 | - $downloader->download( $args['graph'] ); |
|
| 142 | + $downloader->download($args['graph']); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | } |
@@ -149,17 +149,17 @@ discard block |
||
| 149 | 149 | * |
| 150 | 150 | * @param array $args |
| 151 | 151 | */ |
| 152 | - public function export_invoices( $args ) { |
|
| 152 | + public function export_invoices($args) { |
|
| 153 | 153 | |
| 154 | - if ( ! empty( $args['post_type'] ) ) { |
|
| 154 | + if (!empty($args['post_type'])) { |
|
| 155 | 155 | |
| 156 | - if ( 'subscriptions' === $args['post_type'] ) { |
|
| 156 | + if ('subscriptions' === $args['post_type']) { |
|
| 157 | 157 | $downloader = new GetPaid_Subscription_Exporter(); |
| 158 | 158 | } else { |
| 159 | 159 | $downloader = new GetPaid_Invoice_Exporter(); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - $downloader->export( $args['post_type'], $args ); |
|
| 162 | + $downloader->export($args['post_type'], $args); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | } |