@@ -7,24 +7,24 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | -$logo_width = wpinv_get_option( 'logo_width' ); |
|
| 13 | -$logo_height = wpinv_get_option( 'logo_height' ); |
|
| 12 | +$logo_width = wpinv_get_option('logo_width'); |
|
| 13 | +$logo_height = wpinv_get_option('logo_height'); |
|
| 14 | 14 | |
| 15 | 15 | ?> |
| 16 | -<a target="_blank" class="logo-link text-dark" href="<?php echo esc_url( wpinv_get_business_website() ); ?>"> |
|
| 16 | +<a target="_blank" class="logo-link text-dark" href="<?php echo esc_url(wpinv_get_business_website()); ?>"> |
|
| 17 | 17 | |
| 18 | - <?php if ( $logo = wpinv_get_business_logo() ) : ?> |
|
| 18 | + <?php if ($logo = wpinv_get_business_logo()) : ?> |
|
| 19 | 19 | |
| 20 | - <?php if ( ! empty( $logo_width ) && ! empty( $logo_height ) ) : ?> |
|
| 21 | - <img class="logo" style="max-width:100%; width:<?php echo absint( $logo_width ); ?>px; height:<?php echo absint( $logo_height ); ?>px;" src="<?php echo esc_url( $logo ); ?>"> |
|
| 20 | + <?php if (!empty($logo_width) && !empty($logo_height)) : ?> |
|
| 21 | + <img class="logo" style="max-width:100%; width:<?php echo absint($logo_width); ?>px; height:<?php echo absint($logo_height); ?>px;" src="<?php echo esc_url($logo); ?>"> |
|
| 22 | 22 | <?php else : ?> |
| 23 | - <img class="logo" style="max-width:100%;" src="<?php echo esc_url( $logo ); ?>"> |
|
| 23 | + <img class="logo" style="max-width:100%;" src="<?php echo esc_url($logo); ?>"> |
|
| 24 | 24 | <?php endif; ?> |
| 25 | 25 | |
| 26 | 26 | <?php else : ?> |
| 27 | - <h1 class="h3"><?php echo esc_html( wpinv_get_business_name() ); ?></h1> |
|
| 27 | + <h1 class="h3"><?php echo esc_html(wpinv_get_business_name()); ?></h1> |
|
| 28 | 28 | <?php endif; ?> |
| 29 | 29 | |
| 30 | 30 | </a> |
@@ -19,12 +19,18 @@ |
||
| 19 | 19 | |
| 20 | 20 | <?php if ( ! empty( $logo_width ) && ! empty( $logo_height ) ) : ?> |
| 21 | 21 | <img class="logo" style="max-width:100%; width:<?php echo absint( $logo_width ); ?>px; height:<?php echo absint( $logo_height ); ?>px;" src="<?php echo esc_url( $logo ); ?>"> |
| 22 | - <?php else : ?> |
|
| 23 | - <img class="logo" style="max-width:100%;" src="<?php echo esc_url( $logo ); ?>"> |
|
| 22 | + <?php else { |
|
| 23 | + : ?> |
|
| 24 | + <img class="logo" style="max-width:100%;" src="<?php echo esc_url( $logo ); |
|
| 25 | +} |
|
| 26 | +?>"> |
|
| 24 | 27 | <?php endif; ?> |
| 25 | 28 | |
| 26 | - <?php else : ?> |
|
| 27 | - <h1 class="h3"><?php echo esc_html( wpinv_get_business_name() ); ?></h1> |
|
| 29 | + <?php else { |
|
| 30 | + : ?> |
|
| 31 | + <h1 class="h3"><?php echo esc_html( wpinv_get_business_name() ); |
|
| 32 | +} |
|
| 33 | +?></h1> |
|
| 28 | 34 | <?php endif; ?> |
| 29 | 35 | |
| 30 | 36 | </a> |
@@ -40,19 +40,19 @@ |
||
| 40 | 40 | <?php |
| 41 | 41 | |
| 42 | 42 | if ( ! $invoice->exists() || $invoice->is_draft() ) { |
| 43 | - $error = __( 'This invoice was deleted or is not visible.', 'invoicing' ); |
|
| 43 | + $error = __( 'This invoice was deleted or is not visible.', 'invoicing' ); |
|
| 44 | 44 | } else { |
| 45 | 45 | |
| 46 | - $user_id = get_current_user_id(); |
|
| 47 | - if ( wpinv_require_login_to_checkout() && empty( $user_id ) ) { |
|
| 48 | - $error = __( 'You must be logged in to view this invoice.', 'invoicing' ); |
|
| 49 | - $error .= sprintf( |
|
| 50 | - ' <a href="%s">%s</a>', |
|
| 51 | - wp_login_url( $invoice->get_view_url() ), |
|
| 52 | - __( 'Login.', 'invoicing' ) |
|
| 53 | - ); |
|
| 54 | - } else { |
|
| 55 | - $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' ); |
|
| 46 | + $user_id = get_current_user_id(); |
|
| 47 | + if ( wpinv_require_login_to_checkout() && empty( $user_id ) ) { |
|
| 48 | + $error = __( 'You must be logged in to view this invoice.', 'invoicing' ); |
|
| 49 | + $error .= sprintf( |
|
| 50 | + ' <a href="%s">%s</a>', |
|
| 51 | + wp_login_url( $invoice->get_view_url() ), |
|
| 52 | + __( 'Login.', 'invoicing' ) |
|
| 53 | + ); |
|
| 54 | + } else { |
|
| 55 | + $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' ); |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
@@ -7,11 +7,11 @@ 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 | -if ( empty( $invoice ) ) { |
|
| 14 | - $invoice = new WPInv_Invoice( $GLOBALS['post'] ); |
|
| 13 | +if (empty($invoice)) { |
|
| 14 | + $invoice = new WPInv_Invoice($GLOBALS['post']); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | ?><!DOCTYPE html> |
@@ -21,16 +21,16 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | <head> |
| 23 | 23 | |
| 24 | - <meta charset="<?php bloginfo( 'charset' ); ?>"> |
|
| 24 | + <meta charset="<?php bloginfo('charset'); ?>"> |
|
| 25 | 25 | <meta name="viewport" content="width=device-width, initial-scale=1.0" > |
| 26 | 26 | |
| 27 | 27 | <meta name="robots" content="noindex,nofollow"> |
| 28 | 28 | |
| 29 | 29 | <link rel="profile" href="https://gmpg.org/xfn/11"> |
| 30 | 30 | |
| 31 | - <title><?php esc_html_e( 'Invalid Access', 'invoicing' ); ?></title> |
|
| 31 | + <title><?php esc_html_e('Invalid Access', 'invoicing'); ?></title> |
|
| 32 | 32 | |
| 33 | - <?php do_action( 'wpinv_invoice_print_head', $invoice ); ?> |
|
| 33 | + <?php do_action('wpinv_invoice_print_head', $invoice); ?> |
|
| 34 | 34 | |
| 35 | 35 | </head> |
| 36 | 36 | |
@@ -39,20 +39,20 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | <?php |
| 41 | 41 | |
| 42 | - if ( ! $invoice->exists() || $invoice->is_draft() ) { |
|
| 43 | - $error = __( 'This invoice was deleted or is not visible.', 'invoicing' ); |
|
| 42 | + if (!$invoice->exists() || $invoice->is_draft()) { |
|
| 43 | + $error = __('This invoice was deleted or is not visible.', 'invoicing'); |
|
| 44 | 44 | } else { |
| 45 | 45 | |
| 46 | 46 | $user_id = get_current_user_id(); |
| 47 | - if ( wpinv_require_login_to_checkout() && empty( $user_id ) ) { |
|
| 48 | - $error = __( 'You must be logged in to view this invoice.', 'invoicing' ); |
|
| 47 | + if (wpinv_require_login_to_checkout() && empty($user_id)) { |
|
| 48 | + $error = __('You must be logged in to view this invoice.', 'invoicing'); |
|
| 49 | 49 | $error .= sprintf( |
| 50 | 50 | ' <a href="%s">%s</a>', |
| 51 | - wp_login_url( $invoice->get_view_url() ), |
|
| 52 | - __( 'Login.', 'invoicing' ) |
|
| 51 | + wp_login_url($invoice->get_view_url()), |
|
| 52 | + __('Login.', 'invoicing') |
|
| 53 | 53 | ); |
| 54 | 54 | } else { |
| 55 | - $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' ); |
|
| 55 | + $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing'); |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | <div class="container"> |
| 62 | 62 | <div class="alert alert-danger m-5" role="alert"> |
| 63 | - <h4 class="alert-heading"><?php esc_html_e( 'Access Denied', 'invoicing' ); ?></h4> |
|
| 64 | - <p><?php echo wp_kses_post( $error ); ?></p> |
|
| 63 | + <h4 class="alert-heading"><?php esc_html_e('Access Denied', 'invoicing'); ?></h4> |
|
| 64 | + <p><?php echo wp_kses_post($error); ?></p> |
|
| 65 | 65 | </div> |
| 66 | 66 | </div> |
| 67 | 67 | |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | ?> |
| 12 | 12 | |
| 13 | 13 | <hr class="featurette-divider" /> |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | 13 | ?> |
| 14 | 14 | <component :is='form_element.level' v-html='form_element.text'></component> |
@@ -7,44 +7,44 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | -if ( empty( $form->get_items() ) ) { |
|
| 12 | +if (empty($form->get_items())) { |
|
| 13 | 13 | return; |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -if ( ! empty( $GLOBALS['getpaid_force_checkbox'] ) ) { |
|
| 16 | +if (!empty($GLOBALS['getpaid_force_checkbox'])) { |
|
| 17 | 17 | $items_type = 'checkbox'; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | -if ( empty( $items_type ) ) { |
|
| 20 | +if (empty($items_type)) { |
|
| 21 | 21 | $items_type = 'total'; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | -do_action( 'getpaid_before_payment_form_items', $form ); |
|
| 24 | +do_action('getpaid_before_payment_form_items', $form); |
|
| 25 | 25 | |
| 26 | -switch ( $items_type ) { |
|
| 26 | +switch ($items_type) { |
|
| 27 | 27 | case 'radio': |
| 28 | - wpinv_get_template( 'payment-forms/variations/radio.php', compact( 'form', 'items_type' ) ); |
|
| 28 | + wpinv_get_template('payment-forms/variations/radio.php', compact('form', 'items_type')); |
|
| 29 | 29 | break; |
| 30 | 30 | case 'checkbox': |
| 31 | - wpinv_get_template( 'payment-forms/variations/checkbox.php', compact( 'form', 'items_type' ) ); |
|
| 31 | + wpinv_get_template('payment-forms/variations/checkbox.php', compact('form', 'items_type')); |
|
| 32 | 32 | break; |
| 33 | 33 | case 'select': |
| 34 | - wpinv_get_template( 'payment-forms/variations/select.php', compact( 'form', 'items_type' ) ); |
|
| 34 | + wpinv_get_template('payment-forms/variations/select.php', compact('form', 'items_type')); |
|
| 35 | 35 | break; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | -do_action( 'getpaid_before_payment_form_cart', $form ); |
|
| 38 | +do_action('getpaid_before_payment_form_cart', $form); |
|
| 39 | 39 | |
| 40 | 40 | // Display the cart totals. |
| 41 | -if ( ! empty( $hide_cart ) ) { |
|
| 41 | +if (!empty($hide_cart)) { |
|
| 42 | 42 | echo '<div class="d-none">'; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | // Display the cart totals. |
| 46 | -wpinv_get_template( 'payment-forms/cart.php', compact( 'form', 'items_type' ) ); |
|
| 46 | +wpinv_get_template('payment-forms/cart.php', compact('form', 'items_type')); |
|
| 47 | 47 | |
| 48 | -if ( ! empty( $hide_cart ) ) { |
|
| 48 | +if (!empty($hide_cart)) { |
|
| 49 | 49 | echo '</div>'; |
| 50 | 50 | } |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | |
| 45 | 45 | // Display the item totals. |
| 46 | 46 | foreach ( $form->get_items() as $item ) { |
| 47 | - wpinv_get_template( 'payment-forms/cart-item.php', compact( 'form', 'item', 'columns' ) ); |
|
| 47 | + wpinv_get_template( 'payment-forms/cart-item.php', compact( 'form', 'item', 'columns' ) ); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | // Display the cart totals. |
@@ -7,34 +7,34 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | // Cart table columns. |
| 13 | 13 | $columns = array( |
| 14 | - 'name' => __( 'Item', 'invoicing' ), |
|
| 15 | - 'price' => __( 'Price', 'invoicing' ), |
|
| 16 | - 'quantity' => __( 'Qty', 'invoicing' ), |
|
| 17 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
| 14 | + 'name' => __('Item', 'invoicing'), |
|
| 15 | + 'price' => __('Price', 'invoicing'), |
|
| 16 | + 'quantity' => __('Qty', 'invoicing'), |
|
| 17 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
| 18 | 18 | ); |
| 19 | 19 | |
| 20 | -if ( ! empty( $form->invoice ) ) { |
|
| 21 | - $columns = getpaid_invoice_item_columns( $form->invoice ); |
|
| 20 | +if (!empty($form->invoice)) { |
|
| 21 | + $columns = getpaid_invoice_item_columns($form->invoice); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | -if ( isset( $columns['tax_rate'] ) ) { |
|
| 25 | - unset( $columns['tax_rate'] ); |
|
| 24 | +if (isset($columns['tax_rate'])) { |
|
| 25 | + unset($columns['tax_rate']); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | -$columns = apply_filters( 'getpaid_payment_form_cart_table_columns', $columns, $form ); |
|
| 28 | +$columns = apply_filters('getpaid_payment_form_cart_table_columns', $columns, $form); |
|
| 29 | 29 | |
| 30 | 30 | ?> |
| 31 | 31 | <div class="getpaid-payment-form-items-cart border form-group mb-3"> |
| 32 | 32 | |
| 33 | 33 | <div class="getpaid-payment-form-items-cart-header font-weight-bold bg-light border-bottom py-2 px-3"> |
| 34 | 34 | <div class="form-row row"> |
| 35 | - <?php foreach ( $columns as $key => $label ) : ?> |
|
| 36 | - <div class="<?php echo 'name' == $key ? 'col-6' : 'col'; ?> <?php echo ( in_array( $key, array( 'subtotal', 'quantity', 'tax_rate' ) ) ) ? 'd-none d-sm-block' : ''; ?> getpaid-form-cart-item-<?php echo esc_attr( $key ); ?>"> |
|
| 37 | - <span><?php echo esc_html( $label ); ?></span> |
|
| 35 | + <?php foreach ($columns as $key => $label) : ?> |
|
| 36 | + <div class="<?php echo 'name' == $key ? 'col-6' : 'col'; ?> <?php echo (in_array($key, array('subtotal', 'quantity', 'tax_rate'))) ? 'd-none d-sm-block' : ''; ?> getpaid-form-cart-item-<?php echo esc_attr($key); ?>"> |
|
| 37 | + <span><?php echo esc_html($label); ?></span> |
|
| 38 | 38 | </div> |
| 39 | 39 | <?php endforeach; ?> |
| 40 | 40 | </div> |
@@ -43,16 +43,16 @@ discard block |
||
| 43 | 43 | <?php |
| 44 | 44 | |
| 45 | 45 | // Display the item totals. |
| 46 | - foreach ( $form->get_items() as $item ) { |
|
| 47 | - wpinv_get_template( 'payment-forms/cart-item.php', compact( 'form', 'item', 'columns' ) ); |
|
| 46 | + foreach ($form->get_items() as $item) { |
|
| 47 | + wpinv_get_template('payment-forms/cart-item.php', compact('form', 'item', 'columns')); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | // Display the cart totals. |
| 51 | - wpinv_get_template( 'payment-forms/cart-totals.php', compact( 'form' ) ); |
|
| 51 | + wpinv_get_template('payment-forms/cart-totals.php', compact('form')); |
|
| 52 | 52 | |
| 53 | 53 | ?> |
| 54 | 54 | </div> |
| 55 | 55 | |
| 56 | 56 | <?php |
| 57 | 57 | |
| 58 | -do_action( 'getpaid_after_payment_form_cart', $form ); |
|
| 58 | +do_action('getpaid_after_payment_form_cart', $form); |
|
@@ -44,12 +44,12 @@ |
||
| 44 | 44 | |
| 45 | 45 | // Display the item totals. |
| 46 | 46 | foreach ( $invoice->get_items() as $item ) { |
| 47 | - wpinv_get_template( 'emails/invoice-item.php', compact( 'invoice', 'item', 'columns' ) ); |
|
| 47 | + wpinv_get_template( 'emails/invoice-item.php', compact( 'invoice', 'item', 'columns' ) ); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | // Display the fee totals. |
| 51 | 51 | foreach ( $invoice->get_fees() as $fee ) { |
| 52 | - wpinv_get_template( 'emails/fee-item.php', compact( 'invoice', 'fee', 'columns' ) ); |
|
| 52 | + wpinv_get_template( 'emails/fee-item.php', compact( 'invoice', 'fee', 'columns' ) ); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | ?> |
@@ -8,18 +8,18 @@ discard block |
||
| 8 | 8 | * @var WPInv_Invoice $invoice |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | -$column_count = count( $columns ); |
|
| 13 | +$column_count = count($columns); |
|
| 14 | 14 | ?> |
| 15 | 15 | |
| 16 | -<?php do_action( 'wpinv_before_email_items', $invoice ); ?> |
|
| 16 | +<?php do_action('wpinv_before_email_items', $invoice); ?> |
|
| 17 | 17 | |
| 18 | 18 | |
| 19 | 19 | <div id="wpinv-email-items"> |
| 20 | 20 | |
| 21 | 21 | <h3 class="invoice-items-title"> |
| 22 | - <?php echo sprintf( esc_html__( '%s Items', 'invoicing' ), esc_html( ucfirst( $invoice->get_invoice_quote_type() ) ) ); ?> |
|
| 22 | + <?php echo sprintf(esc_html__('%s Items', 'invoicing'), esc_html(ucfirst($invoice->get_invoice_quote_type()))); ?> |
|
| 23 | 23 | </h3> |
| 24 | 24 | |
| 25 | 25 | <table class="table table-bordered table-hover"> |
@@ -28,9 +28,9 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | <tr class="wpinv_cart_header_row"> |
| 30 | 30 | |
| 31 | - <?php foreach ( $columns as $key => $label ) : ?> |
|
| 32 | - <th class="<?php echo 'name' == $key ? 'text-left' : 'text-right'; ?> wpinv_cart_item_<?php echo esc_attr( $key ); ?>"> |
|
| 33 | - <?php echo esc_html( $label ); ?> |
|
| 31 | + <?php foreach ($columns as $key => $label) : ?> |
|
| 32 | + <th class="<?php echo 'name' == $key ? 'text-left' : 'text-right'; ?> wpinv_cart_item_<?php echo esc_attr($key); ?>"> |
|
| 33 | + <?php echo esc_html($label); ?> |
|
| 34 | 34 | </th> |
| 35 | 35 | <?php endforeach; ?> |
| 36 | 36 | |
@@ -43,13 +43,13 @@ discard block |
||
| 43 | 43 | <?php |
| 44 | 44 | |
| 45 | 45 | // Display the item totals. |
| 46 | - foreach ( $invoice->get_items() as $item ) { |
|
| 47 | - wpinv_get_template( 'emails/invoice-item.php', compact( 'invoice', 'item', 'columns' ) ); |
|
| 46 | + foreach ($invoice->get_items() as $item) { |
|
| 47 | + wpinv_get_template('emails/invoice-item.php', compact('invoice', 'item', 'columns')); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | // Display the fee totals. |
| 51 | - foreach ( $invoice->get_fees() as $fee ) { |
|
| 52 | - wpinv_get_template( 'emails/fee-item.php', compact( 'invoice', 'fee', 'columns' ) ); |
|
| 51 | + foreach ($invoice->get_fees() as $fee) { |
|
| 52 | + wpinv_get_template('emails/fee-item.php', compact('invoice', 'fee', 'columns')); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | ?> |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | </tbody> |
| 58 | 58 | |
| 59 | 59 | <tfoot> |
| 60 | - <?php wpinv_get_template( 'emails/invoice-totals.php', compact( 'invoice', 'column_count' ) ); ?> |
|
| 60 | + <?php wpinv_get_template('emails/invoice-totals.php', compact('invoice', 'column_count')); ?> |
|
| 61 | 61 | </tfoot> |
| 62 | 62 | |
| 63 | 63 | </table> |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | <a href="<?php echo esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), self_admin_url( 'user-edit.php' ) ) ); ?>"><?php echo esc_html( $invoice->get_user_full_name() ); ?></a> |
| 21 | 21 | <?php |
| 22 | 22 | } else { |
| 23 | - echo esc_html( $invoice->get_user_full_name() ); } |
|
| 23 | + echo esc_html( $invoice->get_user_full_name() ); } |
|
| 24 | 24 | ?> |
| 25 | 25 | </td> |
| 26 | 26 | </tr> |
@@ -1,51 +1,51 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 4 | - die( '-1' ); |
|
| 3 | +if (!defined('ABSPATH')) { |
|
| 4 | + die('-1'); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | -do_action( 'wpinv_email_before_billing_details', $invoice ); ?> |
|
| 7 | +do_action('wpinv_email_before_billing_details', $invoice); ?> |
|
| 8 | 8 | <div id="wpinv-email-billing"> |
| 9 | - <h3 class="wpinv-address-t"><?php echo esc_html( apply_filters( 'wpinv_email_billing_title', __( 'Billing Details', 'invoicing' ) ) ); ?></h3> |
|
| 9 | + <h3 class="wpinv-address-t"><?php echo esc_html(apply_filters('wpinv_email_billing_title', __('Billing Details', 'invoicing'))); ?></h3> |
|
| 10 | 10 | |
| 11 | 11 | <table class="table table-bordered table-sm wpi-billing-details"> |
| 12 | 12 | <tbody> |
| 13 | - <?php do_action( 'wpinv_email_billing_fields_first', $invoice ); ?> |
|
| 13 | + <?php do_action('wpinv_email_billing_fields_first', $invoice); ?> |
|
| 14 | 14 | <tr class="wpi-receipt-name"> |
| 15 | - <th class="text-left"><?php esc_html_e( 'Name', 'invoicing' ); ?></th> |
|
| 15 | + <th class="text-left"><?php esc_html_e('Name', 'invoicing'); ?></th> |
|
| 16 | 16 | <td> |
| 17 | 17 | <?php |
| 18 | - if ( $sent_to_admin && $invoice->get_user_id() ) { |
|
| 18 | + if ($sent_to_admin && $invoice->get_user_id()) { |
|
| 19 | 19 | ?> |
| 20 | -<a href="<?php echo esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), self_admin_url( 'user-edit.php' ) ) ); ?>"><?php echo esc_html( $invoice->get_user_full_name() ); ?></a> |
|
| 20 | +<a href="<?php echo esc_url(add_query_arg('user_id', $invoice->get_user_id(), self_admin_url('user-edit.php'))); ?>"><?php echo esc_html($invoice->get_user_full_name()); ?></a> |
|
| 21 | 21 | <?php |
| 22 | 22 | } else { |
| 23 | - echo esc_html( $invoice->get_user_full_name() ); } |
|
| 23 | + echo esc_html($invoice->get_user_full_name()); } |
|
| 24 | 24 | ?> |
| 25 | 25 | </td> |
| 26 | 26 | </tr> |
| 27 | 27 | <tr class="wpi-receipt-email"> |
| 28 | - <th class="text-left"><?php esc_html_e( 'Email', 'invoicing' ); ?></th> |
|
| 29 | - <td><?php echo esc_html( sanitize_email( $invoice->get_email() ) ); ?></td> |
|
| 28 | + <th class="text-left"><?php esc_html_e('Email', 'invoicing'); ?></th> |
|
| 29 | + <td><?php echo esc_html(sanitize_email($invoice->get_email())); ?></td> |
|
| 30 | 30 | </tr> |
| 31 | - <?php if ( $invoice->get_company() ) { ?> |
|
| 31 | + <?php if ($invoice->get_company()) { ?> |
|
| 32 | 32 | <tr class="wpi-receipt-company"> |
| 33 | - <th class="text-left"><?php esc_html_e( 'Company', 'invoicing' ); ?></th> |
|
| 34 | - <td><?php echo esc_html( $invoice->get_company() ); ?></td> |
|
| 33 | + <th class="text-left"><?php esc_html_e('Company', 'invoicing'); ?></th> |
|
| 34 | + <td><?php echo esc_html($invoice->get_company()); ?></td> |
|
| 35 | 35 | </tr> |
| 36 | 36 | <?php } ?> |
| 37 | 37 | <tr class="wpi-receipt-address"> |
| 38 | - <th class="text-left"><?php esc_html_e( 'Address', 'invoicing' ); ?></th> |
|
| 39 | - <td><?php echo wp_kses_post( wpinv_get_invoice_address_markup( $invoice->get_user_info() ) ); ?></td> |
|
| 38 | + <th class="text-left"><?php esc_html_e('Address', 'invoicing'); ?></th> |
|
| 39 | + <td><?php echo wp_kses_post(wpinv_get_invoice_address_markup($invoice->get_user_info())); ?></td> |
|
| 40 | 40 | </tr> |
| 41 | - <?php if ( $invoice->get_phone() ) { ?> |
|
| 41 | + <?php if ($invoice->get_phone()) { ?> |
|
| 42 | 42 | <tr class="wpi-receipt-phone"> |
| 43 | - <th class="text-left"><?php esc_html_e( 'Phone', 'invoicing' ); ?></th> |
|
| 44 | - <td><?php echo esc_html( $invoice->get_phone() ); ?></td> |
|
| 43 | + <th class="text-left"><?php esc_html_e('Phone', 'invoicing'); ?></th> |
|
| 44 | + <td><?php echo esc_html($invoice->get_phone()); ?></td> |
|
| 45 | 45 | </tr> |
| 46 | 46 | <?php } ?> |
| 47 | - <?php do_action( 'wpinv_email_billing_fields_last', $invoice ); ?> |
|
| 47 | + <?php do_action('wpinv_email_billing_fields_last', $invoice); ?> |
|
| 48 | 48 | </tbody> |
| 49 | 49 | </table> |
| 50 | 50 | </div> |
| 51 | -<?php do_action( 'wpinv_email_after_billing_details', $invoice ); ?> |
|
| 51 | +<?php do_action('wpinv_email_after_billing_details', $invoice); ?> |
|
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | if ( ! defined( 'ABSPATH' ) ) { |
| 7 | - exit; |
|
| 7 | + exit; |
|
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | /** |
@@ -14,179 +14,179 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | class GetPaid_Payment_Form_Data_Store extends GetPaid_Data_Store_WP { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Data stored in meta keys, but not considered "meta" for a form. |
|
| 19 | - * |
|
| 20 | - * @since 1.0.19 |
|
| 21 | - * @var array |
|
| 22 | - */ |
|
| 23 | - protected $internal_meta_keys = array( |
|
| 24 | - 'wpinv_form_elements', |
|
| 25 | - 'wpinv_form_items', |
|
| 26 | - 'wpinv_form_earned', |
|
| 27 | - 'wpinv_form_refunded', |
|
| 28 | - 'wpinv_form_cancelled', |
|
| 29 | - 'wpinv_form_failed', |
|
| 30 | - ); |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * A map of meta keys to data props. |
|
| 34 | - * |
|
| 35 | - * @since 1.0.19 |
|
| 36 | - * |
|
| 37 | - * @var array |
|
| 38 | - */ |
|
| 39 | - protected $meta_key_to_props = array( |
|
| 40 | - 'wpinv_form_elements' => 'elements', |
|
| 41 | - 'wpinv_form_items' => 'items', |
|
| 42 | - 'wpinv_form_earned' => 'earned', |
|
| 43 | - 'wpinv_form_refunded' => 'refunded', |
|
| 44 | - 'wpinv_form_cancelled' => 'cancelled', |
|
| 45 | - 'wpinv_form_failed' => 'failed', |
|
| 46 | - ); |
|
| 47 | - |
|
| 48 | - /* |
|
| 17 | + /** |
|
| 18 | + * Data stored in meta keys, but not considered "meta" for a form. |
|
| 19 | + * |
|
| 20 | + * @since 1.0.19 |
|
| 21 | + * @var array |
|
| 22 | + */ |
|
| 23 | + protected $internal_meta_keys = array( |
|
| 24 | + 'wpinv_form_elements', |
|
| 25 | + 'wpinv_form_items', |
|
| 26 | + 'wpinv_form_earned', |
|
| 27 | + 'wpinv_form_refunded', |
|
| 28 | + 'wpinv_form_cancelled', |
|
| 29 | + 'wpinv_form_failed', |
|
| 30 | + ); |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * A map of meta keys to data props. |
|
| 34 | + * |
|
| 35 | + * @since 1.0.19 |
|
| 36 | + * |
|
| 37 | + * @var array |
|
| 38 | + */ |
|
| 39 | + protected $meta_key_to_props = array( |
|
| 40 | + 'wpinv_form_elements' => 'elements', |
|
| 41 | + 'wpinv_form_items' => 'items', |
|
| 42 | + 'wpinv_form_earned' => 'earned', |
|
| 43 | + 'wpinv_form_refunded' => 'refunded', |
|
| 44 | + 'wpinv_form_cancelled' => 'cancelled', |
|
| 45 | + 'wpinv_form_failed' => 'failed', |
|
| 46 | + ); |
|
| 47 | + |
|
| 48 | + /* |
|
| 49 | 49 | |-------------------------------------------------------------------------- |
| 50 | 50 | | CRUD Methods |
| 51 | 51 | |-------------------------------------------------------------------------- |
| 52 | 52 | */ |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Method to create a new form in the database. |
|
| 56 | - * |
|
| 57 | - * @param GetPaid_Payment_Form $form Form object. |
|
| 58 | - */ |
|
| 59 | - public function create( &$form ) { |
|
| 60 | - $form->set_version( WPINV_VERSION ); |
|
| 61 | - $form->set_date_created( current_time( 'mysql' ) ); |
|
| 62 | - |
|
| 63 | - // Create a new post. |
|
| 64 | - $id = wp_insert_post( |
|
| 65 | - apply_filters( |
|
| 66 | - 'getpaid_new_payment_form_data', |
|
| 67 | - array( |
|
| 68 | - 'post_date' => $form->get_date_created( 'edit' ), |
|
| 69 | - 'post_type' => 'wpi_payment_form', |
|
| 70 | - 'post_status' => $this->get_post_status( $form ), |
|
| 71 | - 'ping_status' => 'closed', |
|
| 72 | - 'post_author' => $form->get_author( 'edit' ), |
|
| 73 | - 'post_title' => $form->get_name( 'edit' ), |
|
| 74 | - ) |
|
| 75 | - ), |
|
| 76 | - true |
|
| 77 | - ); |
|
| 78 | - |
|
| 79 | - if ( $id && ! is_wp_error( $id ) ) { |
|
| 80 | - $form->set_id( $id ); |
|
| 81 | - $this->update_post_meta( $form ); |
|
| 82 | - $form->save_meta_data(); |
|
| 83 | - $form->apply_changes(); |
|
| 84 | - $this->clear_caches( $form ); |
|
| 85 | - do_action( 'getpaid_create_payment_form', $form ); |
|
| 86 | - return true; |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - if ( is_wp_error( $id ) ) { |
|
| 90 | - $form->last_error = $id->get_error_message(); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - return false; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * Method to read a form from the database. |
|
| 98 | - * |
|
| 99 | - * @param GetPaid_Payment_Form $form Form object. |
|
| 100 | - * |
|
| 101 | - */ |
|
| 102 | - public function read( &$form ) { |
|
| 103 | - |
|
| 104 | - $form->set_defaults(); |
|
| 105 | - $form_object = get_post( $form->get_id() ); |
|
| 106 | - |
|
| 107 | - if ( ! $form->get_id() || ! $form_object || $form_object->post_type != 'wpi_payment_form' ) { |
|
| 108 | - $form->last_error = __( 'Invalid form.', 'invoicing' ); |
|
| 109 | - $form->set_id( 0 ); |
|
| 110 | - return false; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - $form->set_props( |
|
| 114 | - array( |
|
| 115 | - 'date_created' => 0 < $form_object->post_date ? $form_object->post_date : null, |
|
| 116 | - 'date_modified' => 0 < $form_object->post_modified ? $form_object->post_modified : null, |
|
| 117 | - 'status' => $form_object->post_status, |
|
| 118 | - 'name' => $form_object->post_title, |
|
| 119 | - 'author' => $form_object->post_author, |
|
| 120 | - ) |
|
| 121 | - ); |
|
| 122 | - |
|
| 123 | - $this->read_object_data( $form, $form_object ); |
|
| 124 | - $form->read_meta_data(); |
|
| 125 | - $form->set_object_read( true ); |
|
| 126 | - do_action( 'getpaid_read_payment_form', $form ); |
|
| 127 | - |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * Method to update a form in the database. |
|
| 132 | - * |
|
| 133 | - * @param GetPaid_Payment_Form $form Form object. |
|
| 134 | - */ |
|
| 135 | - public function update( &$form ) { |
|
| 136 | - $form->save_meta_data(); |
|
| 137 | - $form->set_version( WPINV_VERSION ); |
|
| 138 | - |
|
| 139 | - if ( null === $form->get_date_created( 'edit' ) ) { |
|
| 140 | - $form->set_date_created( current_time( 'mysql' ) ); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - // Grab the current status so we can compare. |
|
| 144 | - $previous_status = get_post_status( $form->get_id() ); |
|
| 145 | - |
|
| 146 | - $changes = $form->get_changes(); |
|
| 147 | - |
|
| 148 | - // Only update the post when the post data changes. |
|
| 149 | - if ( array_intersect( array( 'date_created', 'date_modified', 'status', 'name', 'author' ), array_keys( $changes ) ) ) { |
|
| 150 | - $post_data = array( |
|
| 151 | - 'post_date' => $form->get_date_created( 'edit' ), |
|
| 152 | - 'post_status' => $form->get_status( 'edit' ), |
|
| 153 | - 'post_title' => $form->get_name( 'edit' ), |
|
| 154 | - 'post_author' => $form->get_author( 'edit' ), |
|
| 155 | - 'post_modified' => $form->get_date_modified( 'edit' ), |
|
| 156 | - ); |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * When updating this object, to prevent infinite loops, use $wpdb |
|
| 160 | - * to update data, since wp_update_post spawns more calls to the |
|
| 161 | - * save_post action. |
|
| 162 | - * |
|
| 163 | - * This ensures hooks are fired by either WP itself (admin screen save), |
|
| 164 | - * or an update purely from CRUD. |
|
| 165 | - */ |
|
| 166 | - if ( doing_action( 'save_post' ) ) { |
|
| 167 | - $GLOBALS['wpdb']->update( $GLOBALS['wpdb']->posts, $post_data, array( 'ID' => $form->get_id() ) ); |
|
| 168 | - clean_post_cache( $form->get_id() ); |
|
| 169 | - } else { |
|
| 170 | - wp_update_post( array_merge( array( 'ID' => $form->get_id() ), $post_data ) ); |
|
| 171 | - } |
|
| 172 | - $form->read_meta_data( true ); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook. |
|
| 173 | - } |
|
| 174 | - $this->update_post_meta( $form ); |
|
| 175 | - $form->apply_changes(); |
|
| 176 | - $this->clear_caches( $form ); |
|
| 177 | - |
|
| 178 | - // Fire a hook depending on the status - this should be considered a creation if it was previously draft status. |
|
| 179 | - $new_status = $form->get_status( 'edit' ); |
|
| 180 | - |
|
| 181 | - if ( $new_status !== $previous_status && in_array( $previous_status, array( 'new', 'auto-draft', 'draft' ), true ) ) { |
|
| 182 | - do_action( 'getpaid_new_payment_form', $form ); |
|
| 183 | - } else { |
|
| 184 | - do_action( 'getpaid_update_payment_form', $form ); |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - /* |
|
| 54 | + /** |
|
| 55 | + * Method to create a new form in the database. |
|
| 56 | + * |
|
| 57 | + * @param GetPaid_Payment_Form $form Form object. |
|
| 58 | + */ |
|
| 59 | + public function create( &$form ) { |
|
| 60 | + $form->set_version( WPINV_VERSION ); |
|
| 61 | + $form->set_date_created( current_time( 'mysql' ) ); |
|
| 62 | + |
|
| 63 | + // Create a new post. |
|
| 64 | + $id = wp_insert_post( |
|
| 65 | + apply_filters( |
|
| 66 | + 'getpaid_new_payment_form_data', |
|
| 67 | + array( |
|
| 68 | + 'post_date' => $form->get_date_created( 'edit' ), |
|
| 69 | + 'post_type' => 'wpi_payment_form', |
|
| 70 | + 'post_status' => $this->get_post_status( $form ), |
|
| 71 | + 'ping_status' => 'closed', |
|
| 72 | + 'post_author' => $form->get_author( 'edit' ), |
|
| 73 | + 'post_title' => $form->get_name( 'edit' ), |
|
| 74 | + ) |
|
| 75 | + ), |
|
| 76 | + true |
|
| 77 | + ); |
|
| 78 | + |
|
| 79 | + if ( $id && ! is_wp_error( $id ) ) { |
|
| 80 | + $form->set_id( $id ); |
|
| 81 | + $this->update_post_meta( $form ); |
|
| 82 | + $form->save_meta_data(); |
|
| 83 | + $form->apply_changes(); |
|
| 84 | + $this->clear_caches( $form ); |
|
| 85 | + do_action( 'getpaid_create_payment_form', $form ); |
|
| 86 | + return true; |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + if ( is_wp_error( $id ) ) { |
|
| 90 | + $form->last_error = $id->get_error_message(); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + return false; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * Method to read a form from the database. |
|
| 98 | + * |
|
| 99 | + * @param GetPaid_Payment_Form $form Form object. |
|
| 100 | + * |
|
| 101 | + */ |
|
| 102 | + public function read( &$form ) { |
|
| 103 | + |
|
| 104 | + $form->set_defaults(); |
|
| 105 | + $form_object = get_post( $form->get_id() ); |
|
| 106 | + |
|
| 107 | + if ( ! $form->get_id() || ! $form_object || $form_object->post_type != 'wpi_payment_form' ) { |
|
| 108 | + $form->last_error = __( 'Invalid form.', 'invoicing' ); |
|
| 109 | + $form->set_id( 0 ); |
|
| 110 | + return false; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + $form->set_props( |
|
| 114 | + array( |
|
| 115 | + 'date_created' => 0 < $form_object->post_date ? $form_object->post_date : null, |
|
| 116 | + 'date_modified' => 0 < $form_object->post_modified ? $form_object->post_modified : null, |
|
| 117 | + 'status' => $form_object->post_status, |
|
| 118 | + 'name' => $form_object->post_title, |
|
| 119 | + 'author' => $form_object->post_author, |
|
| 120 | + ) |
|
| 121 | + ); |
|
| 122 | + |
|
| 123 | + $this->read_object_data( $form, $form_object ); |
|
| 124 | + $form->read_meta_data(); |
|
| 125 | + $form->set_object_read( true ); |
|
| 126 | + do_action( 'getpaid_read_payment_form', $form ); |
|
| 127 | + |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * Method to update a form in the database. |
|
| 132 | + * |
|
| 133 | + * @param GetPaid_Payment_Form $form Form object. |
|
| 134 | + */ |
|
| 135 | + public function update( &$form ) { |
|
| 136 | + $form->save_meta_data(); |
|
| 137 | + $form->set_version( WPINV_VERSION ); |
|
| 138 | + |
|
| 139 | + if ( null === $form->get_date_created( 'edit' ) ) { |
|
| 140 | + $form->set_date_created( current_time( 'mysql' ) ); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + // Grab the current status so we can compare. |
|
| 144 | + $previous_status = get_post_status( $form->get_id() ); |
|
| 145 | + |
|
| 146 | + $changes = $form->get_changes(); |
|
| 147 | + |
|
| 148 | + // Only update the post when the post data changes. |
|
| 149 | + if ( array_intersect( array( 'date_created', 'date_modified', 'status', 'name', 'author' ), array_keys( $changes ) ) ) { |
|
| 150 | + $post_data = array( |
|
| 151 | + 'post_date' => $form->get_date_created( 'edit' ), |
|
| 152 | + 'post_status' => $form->get_status( 'edit' ), |
|
| 153 | + 'post_title' => $form->get_name( 'edit' ), |
|
| 154 | + 'post_author' => $form->get_author( 'edit' ), |
|
| 155 | + 'post_modified' => $form->get_date_modified( 'edit' ), |
|
| 156 | + ); |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * When updating this object, to prevent infinite loops, use $wpdb |
|
| 160 | + * to update data, since wp_update_post spawns more calls to the |
|
| 161 | + * save_post action. |
|
| 162 | + * |
|
| 163 | + * This ensures hooks are fired by either WP itself (admin screen save), |
|
| 164 | + * or an update purely from CRUD. |
|
| 165 | + */ |
|
| 166 | + if ( doing_action( 'save_post' ) ) { |
|
| 167 | + $GLOBALS['wpdb']->update( $GLOBALS['wpdb']->posts, $post_data, array( 'ID' => $form->get_id() ) ); |
|
| 168 | + clean_post_cache( $form->get_id() ); |
|
| 169 | + } else { |
|
| 170 | + wp_update_post( array_merge( array( 'ID' => $form->get_id() ), $post_data ) ); |
|
| 171 | + } |
|
| 172 | + $form->read_meta_data( true ); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook. |
|
| 173 | + } |
|
| 174 | + $this->update_post_meta( $form ); |
|
| 175 | + $form->apply_changes(); |
|
| 176 | + $this->clear_caches( $form ); |
|
| 177 | + |
|
| 178 | + // Fire a hook depending on the status - this should be considered a creation if it was previously draft status. |
|
| 179 | + $new_status = $form->get_status( 'edit' ); |
|
| 180 | + |
|
| 181 | + if ( $new_status !== $previous_status && in_array( $previous_status, array( 'new', 'auto-draft', 'draft' ), true ) ) { |
|
| 182 | + do_action( 'getpaid_new_payment_form', $form ); |
|
| 183 | + } else { |
|
| 184 | + do_action( 'getpaid_update_payment_form', $form ); |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + /* |
|
| 190 | 190 | |-------------------------------------------------------------------------- |
| 191 | 191 | | Additional Methods |
| 192 | 192 | |-------------------------------------------------------------------------- |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | * GetPaid_Payment_Form_Data_Store class file. |
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 6 | +if (!defined('ABSPATH')) { |
|
| 7 | 7 | exit; |
| 8 | 8 | } |
| 9 | 9 | |
@@ -56,37 +56,37 @@ discard block |
||
| 56 | 56 | * |
| 57 | 57 | * @param GetPaid_Payment_Form $form Form object. |
| 58 | 58 | */ |
| 59 | - public function create( &$form ) { |
|
| 60 | - $form->set_version( WPINV_VERSION ); |
|
| 61 | - $form->set_date_created( current_time( 'mysql' ) ); |
|
| 59 | + public function create(&$form) { |
|
| 60 | + $form->set_version(WPINV_VERSION); |
|
| 61 | + $form->set_date_created(current_time('mysql')); |
|
| 62 | 62 | |
| 63 | 63 | // Create a new post. |
| 64 | 64 | $id = wp_insert_post( |
| 65 | 65 | apply_filters( |
| 66 | 66 | 'getpaid_new_payment_form_data', |
| 67 | 67 | array( |
| 68 | - 'post_date' => $form->get_date_created( 'edit' ), |
|
| 68 | + 'post_date' => $form->get_date_created('edit'), |
|
| 69 | 69 | 'post_type' => 'wpi_payment_form', |
| 70 | - 'post_status' => $this->get_post_status( $form ), |
|
| 70 | + 'post_status' => $this->get_post_status($form), |
|
| 71 | 71 | 'ping_status' => 'closed', |
| 72 | - 'post_author' => $form->get_author( 'edit' ), |
|
| 73 | - 'post_title' => $form->get_name( 'edit' ), |
|
| 72 | + 'post_author' => $form->get_author('edit'), |
|
| 73 | + 'post_title' => $form->get_name('edit'), |
|
| 74 | 74 | ) |
| 75 | 75 | ), |
| 76 | 76 | true |
| 77 | 77 | ); |
| 78 | 78 | |
| 79 | - if ( $id && ! is_wp_error( $id ) ) { |
|
| 80 | - $form->set_id( $id ); |
|
| 81 | - $this->update_post_meta( $form ); |
|
| 79 | + if ($id && !is_wp_error($id)) { |
|
| 80 | + $form->set_id($id); |
|
| 81 | + $this->update_post_meta($form); |
|
| 82 | 82 | $form->save_meta_data(); |
| 83 | 83 | $form->apply_changes(); |
| 84 | - $this->clear_caches( $form ); |
|
| 85 | - do_action( 'getpaid_create_payment_form', $form ); |
|
| 84 | + $this->clear_caches($form); |
|
| 85 | + do_action('getpaid_create_payment_form', $form); |
|
| 86 | 86 | return true; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if ( is_wp_error( $id ) ) { |
|
| 89 | + if (is_wp_error($id)) { |
|
| 90 | 90 | $form->last_error = $id->get_error_message(); |
| 91 | 91 | } |
| 92 | 92 | |
@@ -99,14 +99,14 @@ discard block |
||
| 99 | 99 | * @param GetPaid_Payment_Form $form Form object. |
| 100 | 100 | * |
| 101 | 101 | */ |
| 102 | - public function read( &$form ) { |
|
| 102 | + public function read(&$form) { |
|
| 103 | 103 | |
| 104 | 104 | $form->set_defaults(); |
| 105 | - $form_object = get_post( $form->get_id() ); |
|
| 105 | + $form_object = get_post($form->get_id()); |
|
| 106 | 106 | |
| 107 | - if ( ! $form->get_id() || ! $form_object || $form_object->post_type != 'wpi_payment_form' ) { |
|
| 108 | - $form->last_error = __( 'Invalid form.', 'invoicing' ); |
|
| 109 | - $form->set_id( 0 ); |
|
| 107 | + if (!$form->get_id() || !$form_object || $form_object->post_type != 'wpi_payment_form') { |
|
| 108 | + $form->last_error = __('Invalid form.', 'invoicing'); |
|
| 109 | + $form->set_id(0); |
|
| 110 | 110 | return false; |
| 111 | 111 | } |
| 112 | 112 | |
@@ -120,10 +120,10 @@ discard block |
||
| 120 | 120 | ) |
| 121 | 121 | ); |
| 122 | 122 | |
| 123 | - $this->read_object_data( $form, $form_object ); |
|
| 123 | + $this->read_object_data($form, $form_object); |
|
| 124 | 124 | $form->read_meta_data(); |
| 125 | - $form->set_object_read( true ); |
|
| 126 | - do_action( 'getpaid_read_payment_form', $form ); |
|
| 125 | + $form->set_object_read(true); |
|
| 126 | + do_action('getpaid_read_payment_form', $form); |
|
| 127 | 127 | |
| 128 | 128 | } |
| 129 | 129 | |
@@ -132,27 +132,27 @@ discard block |
||
| 132 | 132 | * |
| 133 | 133 | * @param GetPaid_Payment_Form $form Form object. |
| 134 | 134 | */ |
| 135 | - public function update( &$form ) { |
|
| 135 | + public function update(&$form) { |
|
| 136 | 136 | $form->save_meta_data(); |
| 137 | - $form->set_version( WPINV_VERSION ); |
|
| 137 | + $form->set_version(WPINV_VERSION); |
|
| 138 | 138 | |
| 139 | - if ( null === $form->get_date_created( 'edit' ) ) { |
|
| 140 | - $form->set_date_created( current_time( 'mysql' ) ); |
|
| 139 | + if (null === $form->get_date_created('edit')) { |
|
| 140 | + $form->set_date_created(current_time('mysql')); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | // Grab the current status so we can compare. |
| 144 | - $previous_status = get_post_status( $form->get_id() ); |
|
| 144 | + $previous_status = get_post_status($form->get_id()); |
|
| 145 | 145 | |
| 146 | 146 | $changes = $form->get_changes(); |
| 147 | 147 | |
| 148 | 148 | // Only update the post when the post data changes. |
| 149 | - if ( array_intersect( array( 'date_created', 'date_modified', 'status', 'name', 'author' ), array_keys( $changes ) ) ) { |
|
| 149 | + if (array_intersect(array('date_created', 'date_modified', 'status', 'name', 'author'), array_keys($changes))) { |
|
| 150 | 150 | $post_data = array( |
| 151 | - 'post_date' => $form->get_date_created( 'edit' ), |
|
| 152 | - 'post_status' => $form->get_status( 'edit' ), |
|
| 153 | - 'post_title' => $form->get_name( 'edit' ), |
|
| 154 | - 'post_author' => $form->get_author( 'edit' ), |
|
| 155 | - 'post_modified' => $form->get_date_modified( 'edit' ), |
|
| 151 | + 'post_date' => $form->get_date_created('edit'), |
|
| 152 | + 'post_status' => $form->get_status('edit'), |
|
| 153 | + 'post_title' => $form->get_name('edit'), |
|
| 154 | + 'post_author' => $form->get_author('edit'), |
|
| 155 | + 'post_modified' => $form->get_date_modified('edit'), |
|
| 156 | 156 | ); |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -163,25 +163,25 @@ discard block |
||
| 163 | 163 | * This ensures hooks are fired by either WP itself (admin screen save), |
| 164 | 164 | * or an update purely from CRUD. |
| 165 | 165 | */ |
| 166 | - if ( doing_action( 'save_post' ) ) { |
|
| 167 | - $GLOBALS['wpdb']->update( $GLOBALS['wpdb']->posts, $post_data, array( 'ID' => $form->get_id() ) ); |
|
| 168 | - clean_post_cache( $form->get_id() ); |
|
| 166 | + if (doing_action('save_post')) { |
|
| 167 | + $GLOBALS['wpdb']->update($GLOBALS['wpdb']->posts, $post_data, array('ID' => $form->get_id())); |
|
| 168 | + clean_post_cache($form->get_id()); |
|
| 169 | 169 | } else { |
| 170 | - wp_update_post( array_merge( array( 'ID' => $form->get_id() ), $post_data ) ); |
|
| 170 | + wp_update_post(array_merge(array('ID' => $form->get_id()), $post_data)); |
|
| 171 | 171 | } |
| 172 | - $form->read_meta_data( true ); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook. |
|
| 172 | + $form->read_meta_data(true); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook. |
|
| 173 | 173 | } |
| 174 | - $this->update_post_meta( $form ); |
|
| 174 | + $this->update_post_meta($form); |
|
| 175 | 175 | $form->apply_changes(); |
| 176 | - $this->clear_caches( $form ); |
|
| 176 | + $this->clear_caches($form); |
|
| 177 | 177 | |
| 178 | 178 | // Fire a hook depending on the status - this should be considered a creation if it was previously draft status. |
| 179 | - $new_status = $form->get_status( 'edit' ); |
|
| 179 | + $new_status = $form->get_status('edit'); |
|
| 180 | 180 | |
| 181 | - if ( $new_status !== $previous_status && in_array( $previous_status, array( 'new', 'auto-draft', 'draft' ), true ) ) { |
|
| 182 | - do_action( 'getpaid_new_payment_form', $form ); |
|
| 181 | + if ($new_status !== $previous_status && in_array($previous_status, array('new', 'auto-draft', 'draft'), true)) { |
|
| 182 | + do_action('getpaid_new_payment_form', $form); |
|
| 183 | 183 | } else { |
| 184 | - do_action( 'getpaid_update_payment_form', $form ); |
|
| 184 | + do_action('getpaid_update_payment_form', $form); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | } |