@@ -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>' . __( 'There are no notes yet.', 'invoicing' ) . '</li>'; |
|
20 | + echo '<li>' . __('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 |
@@ -14,70 +14,70 @@ discard block |
||
14 | 14 | class WPInv_Ajax { |
15 | 15 | |
16 | 16 | /** |
17 | - * Hook in ajax handlers. |
|
18 | - */ |
|
19 | - public static function init() { |
|
20 | - add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
21 | - add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
22 | - self::add_ajax_events(); |
|
17 | + * Hook in ajax handlers. |
|
18 | + */ |
|
19 | + public static function init() { |
|
20 | + add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
21 | + add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
22 | + self::add_ajax_events(); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | - * Set GetPaid AJAX constant and headers. |
|
27 | - */ |
|
28 | - public static function define_ajax() { |
|
29 | - |
|
30 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
31 | - getpaid_maybe_define_constant( 'DOING_AJAX', true ); |
|
32 | - getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true ); |
|
33 | - if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
34 | - /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 ); |
|
35 | - } |
|
36 | - $GLOBALS['wpdb']->hide_errors(); |
|
37 | - } |
|
26 | + * Set GetPaid AJAX constant and headers. |
|
27 | + */ |
|
28 | + public static function define_ajax() { |
|
29 | + |
|
30 | + if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
31 | + getpaid_maybe_define_constant( 'DOING_AJAX', true ); |
|
32 | + getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true ); |
|
33 | + if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
34 | + /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 ); |
|
35 | + } |
|
36 | + $GLOBALS['wpdb']->hide_errors(); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | - * Send headers for GetPaid Ajax Requests. |
|
43 | - * |
|
44 | - * @since 1.0.18 |
|
45 | - */ |
|
46 | - private static function wpinv_ajax_headers() { |
|
47 | - if ( ! headers_sent() ) { |
|
48 | - send_origin_headers(); |
|
49 | - send_nosniff_header(); |
|
50 | - nocache_headers(); |
|
51 | - header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
52 | - header( 'X-Robots-Tag: noindex' ); |
|
53 | - status_header( 200 ); |
|
54 | - } |
|
42 | + * Send headers for GetPaid Ajax Requests. |
|
43 | + * |
|
44 | + * @since 1.0.18 |
|
45 | + */ |
|
46 | + private static function wpinv_ajax_headers() { |
|
47 | + if ( ! headers_sent() ) { |
|
48 | + send_origin_headers(); |
|
49 | + send_nosniff_header(); |
|
50 | + nocache_headers(); |
|
51 | + header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
52 | + header( 'X-Robots-Tag: noindex' ); |
|
53 | + status_header( 200 ); |
|
54 | + } |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | - * Check for GetPaid Ajax request and fire action. |
|
59 | - */ |
|
60 | - public static function do_wpinv_ajax() { |
|
61 | - global $wp_query; |
|
58 | + * Check for GetPaid Ajax request and fire action. |
|
59 | + */ |
|
60 | + public static function do_wpinv_ajax() { |
|
61 | + global $wp_query; |
|
62 | 62 | |
63 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
64 | - $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) ); |
|
65 | - } |
|
63 | + if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
64 | + $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) ); |
|
65 | + } |
|
66 | 66 | |
67 | - $action = $wp_query->get( 'wpinv-ajax' ); |
|
67 | + $action = $wp_query->get( 'wpinv-ajax' ); |
|
68 | 68 | |
69 | - if ( $action ) { |
|
70 | - self::wpinv_ajax_headers(); |
|
71 | - $action = sanitize_text_field( $action ); |
|
72 | - do_action( 'wpinv_ajax_' . $action ); |
|
73 | - wp_die(); |
|
74 | - } |
|
69 | + if ( $action ) { |
|
70 | + self::wpinv_ajax_headers(); |
|
71 | + $action = sanitize_text_field( $action ); |
|
72 | + do_action( 'wpinv_ajax_' . $action ); |
|
73 | + wp_die(); |
|
74 | + } |
|
75 | 75 | |
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | - * Hook in ajax methods. |
|
80 | - */ |
|
79 | + * Hook in ajax methods. |
|
80 | + */ |
|
81 | 81 | public static function add_ajax_events() { |
82 | 82 | |
83 | 83 | // array( 'event' => is_frontend ) |
@@ -261,11 +261,11 @@ discard block |
||
261 | 261 | check_ajax_referer( 'getpaid_form_nonce' ); |
262 | 262 | |
263 | 263 | // Is the request set up correctly? |
264 | - if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) && empty( $_GET['invoice'] ) ) { |
|
265 | - aui()->alert( |
|
266 | - array( |
|
267 | - 'type' => 'warning', |
|
268 | - 'content' => __( 'No payment form or item provided', 'invoicing' ), |
|
264 | + if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) && empty( $_GET['invoice'] ) ) { |
|
265 | + aui()->alert( |
|
266 | + array( |
|
267 | + 'type' => 'warning', |
|
268 | + 'content' => __( 'No payment form or item provided', 'invoicing' ), |
|
269 | 269 | ), |
270 | 270 | true |
271 | 271 | ); |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | } |
274 | 274 | |
275 | 275 | // Payment form or button? |
276 | - if ( ! empty( $_GET['form'] ) ) { |
|
276 | + if ( ! empty( $_GET['form'] ) ) { |
|
277 | 277 | $form = sanitize_text_field( urldecode( $_GET['form'] ) ); |
278 | 278 | |
279 | 279 | if ( false !== strpos( $form, '|' ) ) { |
@@ -326,10 +326,10 @@ discard block |
||
326 | 326 | getpaid_display_payment_form( $form ); |
327 | 327 | } |
328 | 328 | } elseif ( ! empty( $_GET['invoice'] ) ) { |
329 | - getpaid_display_invoice_payment_form( (int) urldecode( $_GET['invoice'] ) ); |
|
329 | + getpaid_display_invoice_payment_form( (int) urldecode( $_GET['invoice'] ) ); |
|
330 | 330 | } else { |
331 | - $items = getpaid_convert_items_to_array( sanitize_text_field( urldecode( $_GET['item'] ) ) ); |
|
332 | - getpaid_display_item_payment_form( $items ); |
|
331 | + $items = getpaid_convert_items_to_array( sanitize_text_field( urldecode( $_GET['item'] ) ) ); |
|
332 | + getpaid_display_item_payment_form( $items ); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | exit; |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | if ( is_wp_error( $error ) ) { |
650 | 650 | $alert = $error->get_error_message(); |
651 | 651 | wp_send_json_success( compact( 'alert' ) ); |
652 | - } |
|
652 | + } |
|
653 | 653 | |
654 | 654 | // Update totals. |
655 | 655 | $invoice->recalculate_total(); |
@@ -1084,12 +1084,12 @@ discard block |
||
1084 | 1084 | } |
1085 | 1085 | |
1086 | 1086 | /** |
1087 | - * Handles file uploads. |
|
1088 | - * |
|
1089 | - * @since 1.0.0 |
|
1090 | - * @return void |
|
1091 | - */ |
|
1092 | - public static function file_upload() { |
|
1087 | + * Handles file uploads. |
|
1088 | + * |
|
1089 | + * @since 1.0.0 |
|
1090 | + * @return void |
|
1091 | + */ |
|
1092 | + public static function file_upload() { |
|
1093 | 1093 | |
1094 | 1094 | // Check nonce. |
1095 | 1095 | check_ajax_referer( 'getpaid_form_nonce' ); |
@@ -1150,7 +1150,7 @@ discard block |
||
1150 | 1150 | |
1151 | 1151 | wp_send_json_success( $response ); |
1152 | 1152 | |
1153 | - } |
|
1153 | + } |
|
1154 | 1154 | |
1155 | 1155 | } |
1156 | 1156 |
@@ -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 | * WPInv_Ajax class. |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | * Hook in ajax handlers. |
18 | 18 | */ |
19 | 19 | public static function init() { |
20 | - add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
21 | - add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
20 | + add_action('init', array(__CLASS__, 'define_ajax'), 0); |
|
21 | + add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0); |
|
22 | 22 | self::add_ajax_events(); |
23 | 23 | } |
24 | 24 | |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public static function define_ajax() { |
29 | 29 | |
30 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
31 | - getpaid_maybe_define_constant( 'DOING_AJAX', true ); |
|
32 | - getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true ); |
|
33 | - if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
34 | - /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 ); |
|
30 | + if (!empty($_GET['wpinv-ajax'])) { |
|
31 | + getpaid_maybe_define_constant('DOING_AJAX', true); |
|
32 | + getpaid_maybe_define_constant('WPInv_DOING_AJAX', true); |
|
33 | + if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) { |
|
34 | + /** @scrutinizer ignore-unhandled */ @ini_set('display_errors', 0); |
|
35 | 35 | } |
36 | 36 | $GLOBALS['wpdb']->hide_errors(); |
37 | 37 | } |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | * @since 1.0.18 |
45 | 45 | */ |
46 | 46 | private static function wpinv_ajax_headers() { |
47 | - if ( ! headers_sent() ) { |
|
47 | + if (!headers_sent()) { |
|
48 | 48 | send_origin_headers(); |
49 | 49 | send_nosniff_header(); |
50 | 50 | nocache_headers(); |
51 | - header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
52 | - header( 'X-Robots-Tag: noindex' ); |
|
53 | - status_header( 200 ); |
|
51 | + header('Content-Type: text/html; charset=' . get_option('blog_charset')); |
|
52 | + header('X-Robots-Tag: noindex'); |
|
53 | + status_header(200); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | public static function do_wpinv_ajax() { |
61 | 61 | global $wp_query; |
62 | 62 | |
63 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
64 | - $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) ); |
|
63 | + if (!empty($_GET['wpinv-ajax'])) { |
|
64 | + $wp_query->set('wpinv-ajax', sanitize_text_field(wp_unslash($_GET['wpinv-ajax']))); |
|
65 | 65 | } |
66 | 66 | |
67 | - $action = $wp_query->get( 'wpinv-ajax' ); |
|
67 | + $action = $wp_query->get('wpinv-ajax'); |
|
68 | 68 | |
69 | - if ( $action ) { |
|
69 | + if ($action) { |
|
70 | 70 | self::wpinv_ajax_headers(); |
71 | - $action = sanitize_text_field( $action ); |
|
72 | - do_action( 'wpinv_ajax_' . $action ); |
|
71 | + $action = sanitize_text_field($action); |
|
72 | + do_action('wpinv_ajax_' . $action); |
|
73 | 73 | wp_die(); |
74 | 74 | } |
75 | 75 | |
@@ -106,36 +106,36 @@ discard block |
||
106 | 106 | 'file_upload' => true, |
107 | 107 | ); |
108 | 108 | |
109 | - foreach ( $ajax_events as $ajax_event => $nopriv ) { |
|
110 | - add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
111 | - add_action( 'wp_ajax_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
109 | + foreach ($ajax_events as $ajax_event => $nopriv) { |
|
110 | + add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
111 | + add_action('wp_ajax_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
112 | 112 | |
113 | - if ( $nopriv ) { |
|
114 | - add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
115 | - add_action( 'wp_ajax_nopriv_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
116 | - add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
113 | + if ($nopriv) { |
|
114 | + add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
115 | + add_action('wp_ajax_nopriv_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
116 | + add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
121 | 121 | public static function add_note() { |
122 | - check_ajax_referer( 'add-invoice-note', '_nonce' ); |
|
122 | + check_ajax_referer('add-invoice-note', '_nonce'); |
|
123 | 123 | |
124 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
124 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
125 | 125 | die( -1 ); |
126 | 126 | } |
127 | 127 | |
128 | - $post_id = absint( $_POST['post_id'] ); |
|
129 | - $note = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) ); |
|
130 | - $note_type = sanitize_text_field( $_POST['note_type'] ); |
|
128 | + $post_id = absint($_POST['post_id']); |
|
129 | + $note = wp_kses_post(trim(stripslashes($_POST['note']))); |
|
130 | + $note_type = sanitize_text_field($_POST['note_type']); |
|
131 | 131 | |
132 | 132 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
133 | 133 | |
134 | - if ( $post_id > 0 ) { |
|
135 | - $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note ); |
|
134 | + if ($post_id > 0) { |
|
135 | + $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note); |
|
136 | 136 | |
137 | - if ( $note_id > 0 && ! is_wp_error( $note_id ) ) { |
|
138 | - wpinv_get_invoice_note_line_item( $note_id ); |
|
137 | + if ($note_id > 0 && !is_wp_error($note_id)) { |
|
138 | + wpinv_get_invoice_note_line_item($note_id); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
@@ -143,16 +143,16 @@ discard block |
||
143 | 143 | } |
144 | 144 | |
145 | 145 | public static function delete_note() { |
146 | - check_ajax_referer( 'delete-invoice-note', '_nonce' ); |
|
146 | + check_ajax_referer('delete-invoice-note', '_nonce'); |
|
147 | 147 | |
148 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
148 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
149 | 149 | die( -1 ); |
150 | 150 | } |
151 | 151 | |
152 | - $note_id = (int)$_POST['note_id']; |
|
152 | + $note_id = (int) $_POST['note_id']; |
|
153 | 153 | |
154 | - if ( $note_id > 0 ) { |
|
155 | - wp_delete_comment( $note_id, true ); |
|
154 | + if ($note_id > 0) { |
|
155 | + wp_delete_comment($note_id, true); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | die(); |
@@ -170,34 +170,34 @@ discard block |
||
170 | 170 | public static function get_billing_details() { |
171 | 171 | |
172 | 172 | // Verify nonce. |
173 | - check_ajax_referer( 'wpinv-nonce' ); |
|
173 | + check_ajax_referer('wpinv-nonce'); |
|
174 | 174 | |
175 | 175 | // Can the user manage the plugin? |
176 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
176 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
177 | 177 | die( -1 ); |
178 | 178 | } |
179 | 179 | |
180 | 180 | // Do we have a user id? |
181 | 181 | $user_id = (int) $_GET['user_id']; |
182 | 182 | |
183 | - if ( empty( $user_id ) || ! is_numeric( $user_id ) ) { |
|
183 | + if (empty($user_id) || !is_numeric($user_id)) { |
|
184 | 184 | die( -1 ); |
185 | 185 | } |
186 | 186 | |
187 | 187 | // Fetch the billing details. |
188 | - $billing_details = wpinv_get_user_address( $user_id ); |
|
189 | - $billing_details = apply_filters( 'wpinv_ajax_billing_details', $billing_details, $user_id ); |
|
188 | + $billing_details = wpinv_get_user_address($user_id); |
|
189 | + $billing_details = apply_filters('wpinv_ajax_billing_details', $billing_details, $user_id); |
|
190 | 190 | |
191 | 191 | // unset the user id and email. |
192 | - $to_ignore = array( 'user_id', 'email' ); |
|
192 | + $to_ignore = array('user_id', 'email'); |
|
193 | 193 | |
194 | - foreach ( $to_ignore as $key ) { |
|
195 | - if ( isset( $billing_details[ $key ] ) ) { |
|
196 | - unset( $billing_details[ $key ] ); |
|
194 | + foreach ($to_ignore as $key) { |
|
195 | + if (isset($billing_details[$key])) { |
|
196 | + unset($billing_details[$key]); |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
200 | - wp_send_json_success( $billing_details ); |
|
200 | + wp_send_json_success($billing_details); |
|
201 | 201 | |
202 | 202 | } |
203 | 203 | |
@@ -207,47 +207,47 @@ discard block |
||
207 | 207 | public static function check_new_user_email() { |
208 | 208 | |
209 | 209 | // Verify nonce. |
210 | - check_ajax_referer( 'wpinv-nonce' ); |
|
210 | + check_ajax_referer('wpinv-nonce'); |
|
211 | 211 | |
212 | 212 | // Can the user manage the plugin? |
213 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
213 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
214 | 214 | die( -1 ); |
215 | 215 | } |
216 | 216 | |
217 | 217 | // We need an email address. |
218 | - if ( empty( $_GET['email'] ) ) { |
|
219 | - _e( "Provide the new user's email address", 'invoicing' ); |
|
218 | + if (empty($_GET['email'])) { |
|
219 | + _e("Provide the new user's email address", 'invoicing'); |
|
220 | 220 | exit; |
221 | 221 | } |
222 | 222 | |
223 | 223 | // Ensure the email is valid. |
224 | - $email = sanitize_email( $_GET['email'] ); |
|
225 | - if ( ! is_email( $email ) ) { |
|
226 | - _e( 'Invalid email address', 'invoicing' ); |
|
224 | + $email = sanitize_email($_GET['email']); |
|
225 | + if (!is_email($email)) { |
|
226 | + _e('Invalid email address', 'invoicing'); |
|
227 | 227 | exit; |
228 | 228 | } |
229 | 229 | |
230 | 230 | // And it does not exist. |
231 | - $id = email_exists( $email ); |
|
232 | - if ( $id ) { |
|
233 | - wp_send_json_success( compact( 'id' ) ); |
|
231 | + $id = email_exists($email); |
|
232 | + if ($id) { |
|
233 | + wp_send_json_success(compact('id')); |
|
234 | 234 | } |
235 | 235 | |
236 | - wp_send_json_success( true ); |
|
236 | + wp_send_json_success(true); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | public static function run_tool() { |
240 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
241 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
240 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
241 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
242 | 242 | die( -1 ); |
243 | 243 | } |
244 | 244 | |
245 | - $tool = sanitize_text_field( $_POST['tool'] ); |
|
245 | + $tool = sanitize_text_field($_POST['tool']); |
|
246 | 246 | |
247 | - do_action( 'wpinv_run_tool' ); |
|
247 | + do_action('wpinv_run_tool'); |
|
248 | 248 | |
249 | - if ( ! empty( $tool ) ) { |
|
250 | - do_action( 'wpinv_tool_' . $tool ); |
|
249 | + if (!empty($tool)) { |
|
250 | + do_action('wpinv_tool_' . $tool); |
|
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
@@ -258,14 +258,14 @@ discard block |
||
258 | 258 | global $getpaid_force_checkbox; |
259 | 259 | |
260 | 260 | // Check nonce. |
261 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
261 | + check_ajax_referer('getpaid_form_nonce'); |
|
262 | 262 | |
263 | 263 | // Is the request set up correctly? |
264 | - if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) && empty( $_GET['invoice'] ) ) { |
|
264 | + if (empty($_GET['form']) && empty($_GET['item']) && empty($_GET['invoice'])) { |
|
265 | 265 | aui()->alert( |
266 | 266 | array( |
267 | 267 | 'type' => 'warning', |
268 | - 'content' => __( 'No payment form or item provided', 'invoicing' ), |
|
268 | + 'content' => __('No payment form or item provided', 'invoicing'), |
|
269 | 269 | ), |
270 | 270 | true |
271 | 271 | ); |
@@ -273,29 +273,29 @@ discard block |
||
273 | 273 | } |
274 | 274 | |
275 | 275 | // Payment form or button? |
276 | - if ( ! empty( $_GET['form'] ) ) { |
|
277 | - $form = sanitize_text_field( urldecode( $_GET['form'] ) ); |
|
276 | + if (!empty($_GET['form'])) { |
|
277 | + $form = sanitize_text_field(urldecode($_GET['form'])); |
|
278 | 278 | |
279 | - if ( false !== strpos( $form, '|' ) ) { |
|
280 | - $form_pos = strpos( $form, '|' ); |
|
281 | - $_items = getpaid_convert_items_to_array( substr( $form, $form_pos + 1 ) ); |
|
282 | - $form = substr( $form, 0, $form_pos ); |
|
279 | + if (false !== strpos($form, '|')) { |
|
280 | + $form_pos = strpos($form, '|'); |
|
281 | + $_items = getpaid_convert_items_to_array(substr($form, $form_pos + 1)); |
|
282 | + $form = substr($form, 0, $form_pos); |
|
283 | 283 | |
284 | 284 | // Retrieve appropriate payment form. |
285 | - $payment_form = new GetPaid_Payment_Form( $form ); |
|
286 | - $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
285 | + $payment_form = new GetPaid_Payment_Form($form); |
|
286 | + $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
287 | 287 | |
288 | 288 | $items = array(); |
289 | 289 | $item_ids = array(); |
290 | 290 | |
291 | - foreach ( $_items as $item_id => $qty ) { |
|
292 | - if ( ! in_array( $item_id, $item_ids ) ) { |
|
293 | - $item = new GetPaid_Form_Item( $item_id ); |
|
294 | - $item->set_quantity( $qty ); |
|
291 | + foreach ($_items as $item_id => $qty) { |
|
292 | + if (!in_array($item_id, $item_ids)) { |
|
293 | + $item = new GetPaid_Form_Item($item_id); |
|
294 | + $item->set_quantity($qty); |
|
295 | 295 | |
296 | - if ( 0 == $qty ) { |
|
297 | - $item->set_allow_quantities( true ); |
|
298 | - $item->set_is_required( false ); |
|
296 | + if (0 == $qty) { |
|
297 | + $item->set_allow_quantities(true); |
|
298 | + $item->set_is_required(false); |
|
299 | 299 | $getpaid_force_checkbox = true; |
300 | 300 | } |
301 | 301 | |
@@ -304,32 +304,32 @@ discard block |
||
304 | 304 | } |
305 | 305 | } |
306 | 306 | |
307 | - if ( ! $payment_form->is_default() ) { |
|
307 | + if (!$payment_form->is_default()) { |
|
308 | 308 | |
309 | - foreach ( $payment_form->get_items() as $item ) { |
|
310 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
309 | + foreach ($payment_form->get_items() as $item) { |
|
310 | + if (!in_array($item->get_id(), $item_ids)) { |
|
311 | 311 | $item_ids[] = $item->get_id(); |
312 | 312 | $items[] = $item; |
313 | 313 | } |
314 | 314 | } |
315 | 315 | } |
316 | 316 | |
317 | - $payment_form->set_items( $items ); |
|
318 | - $extra_items = esc_attr( getpaid_convert_items_to_string( $_items ) ); |
|
319 | - $extra_items_key = md5( NONCE_KEY . AUTH_KEY . $extra_items ); |
|
317 | + $payment_form->set_items($items); |
|
318 | + $extra_items = esc_attr(getpaid_convert_items_to_string($_items)); |
|
319 | + $extra_items_key = md5(NONCE_KEY . AUTH_KEY . $extra_items); |
|
320 | 320 | $extra_items = "<input type='hidden' name='getpaid-form-items' value='$extra_items' />"; |
321 | 321 | $extra_items .= "<input type='hidden' name='getpaid-form-items-key' value='$extra_items_key' />"; |
322 | - $payment_form->display( $extra_items ); |
|
322 | + $payment_form->display($extra_items); |
|
323 | 323 | $getpaid_force_checkbox = false; |
324 | 324 | |
325 | 325 | } else { |
326 | - getpaid_display_payment_form( $form ); |
|
326 | + getpaid_display_payment_form($form); |
|
327 | 327 | } |
328 | -} elseif ( ! empty( $_GET['invoice'] ) ) { |
|
329 | - getpaid_display_invoice_payment_form( (int) urldecode( $_GET['invoice'] ) ); |
|
328 | +} elseif (!empty($_GET['invoice'])) { |
|
329 | + getpaid_display_invoice_payment_form((int) urldecode($_GET['invoice'])); |
|
330 | 330 | } else { |
331 | - $items = getpaid_convert_items_to_array( sanitize_text_field( urldecode( $_GET['item'] ) ) ); |
|
332 | - getpaid_display_item_payment_form( $items ); |
|
331 | + $items = getpaid_convert_items_to_array(sanitize_text_field(urldecode($_GET['item']))); |
|
332 | + getpaid_display_item_payment_form($items); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | exit; |
@@ -344,17 +344,17 @@ discard block |
||
344 | 344 | public static function payment_form() { |
345 | 345 | |
346 | 346 | // Check nonce. |
347 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
347 | + check_ajax_referer('getpaid_form_nonce'); |
|
348 | 348 | |
349 | 349 | // ... form fields... |
350 | - if ( empty( $_POST['getpaid_payment_form_submission'] ) ) { |
|
351 | - _e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
350 | + if (empty($_POST['getpaid_payment_form_submission'])) { |
|
351 | + _e('Error: Reload the page and try again.', 'invoicing'); |
|
352 | 352 | exit; |
353 | 353 | } |
354 | 354 | |
355 | 355 | // Process the payment form. |
356 | - $checkout_class = apply_filters( 'getpaid_checkout_class', 'GetPaid_Checkout' ); |
|
357 | - $checkout = new $checkout_class( new GetPaid_Payment_Form_Submission() ); |
|
356 | + $checkout_class = apply_filters('getpaid_checkout_class', 'GetPaid_Checkout'); |
|
357 | + $checkout = new $checkout_class(new GetPaid_Payment_Form_Submission()); |
|
358 | 358 | $checkout->process_checkout(); |
359 | 359 | |
360 | 360 | exit; |
@@ -367,55 +367,55 @@ discard block |
||
367 | 367 | */ |
368 | 368 | public static function get_payment_form_states_field() { |
369 | 369 | |
370 | - if ( empty( $_GET['country'] ) || empty( $_GET['form'] ) ) { |
|
370 | + if (empty($_GET['country']) || empty($_GET['form'])) { |
|
371 | 371 | exit; |
372 | 372 | } |
373 | 373 | |
374 | - $elements = getpaid_get_payment_form_elements( (int) $_GET['form'] ); |
|
374 | + $elements = getpaid_get_payment_form_elements((int) $_GET['form']); |
|
375 | 375 | |
376 | - if ( empty( $elements ) ) { |
|
376 | + if (empty($elements)) { |
|
377 | 377 | exit; |
378 | 378 | } |
379 | 379 | |
380 | 380 | $address_fields = array(); |
381 | - foreach ( $elements as $element ) { |
|
382 | - if ( 'address' === $element['type'] ) { |
|
381 | + foreach ($elements as $element) { |
|
382 | + if ('address' === $element['type']) { |
|
383 | 383 | $address_fields = $element; |
384 | 384 | break; |
385 | 385 | } |
386 | 386 | } |
387 | 387 | |
388 | - if ( empty( $address_fields ) ) { |
|
388 | + if (empty($address_fields)) { |
|
389 | 389 | exit; |
390 | 390 | } |
391 | 391 | |
392 | - foreach ( $address_fields['fields'] as $address_field ) { |
|
392 | + foreach ($address_fields['fields'] as $address_field) { |
|
393 | 393 | |
394 | - if ( 'wpinv_state' == $address_field['name'] ) { |
|
394 | + if ('wpinv_state' == $address_field['name']) { |
|
395 | 395 | |
396 | - $wrap_class = getpaid_get_form_element_grid_class( $address_field ); |
|
397 | - $wrap_class = esc_attr( "$wrap_class getpaid-address-field-wrapper" ); |
|
398 | - $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] ); |
|
399 | - $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] ); |
|
400 | - $value = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_wpinv_state', true ) : ''; |
|
401 | - $label = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] ); |
|
396 | + $wrap_class = getpaid_get_form_element_grid_class($address_field); |
|
397 | + $wrap_class = esc_attr("$wrap_class getpaid-address-field-wrapper"); |
|
398 | + $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']); |
|
399 | + $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']); |
|
400 | + $value = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_wpinv_state', true) : ''; |
|
401 | + $label = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']); |
|
402 | 402 | |
403 | - if ( ! empty( $address_field['required'] ) ) { |
|
403 | + if (!empty($address_field['required'])) { |
|
404 | 404 | $label .= "<span class='text-danger'> *</span>"; |
405 | 405 | } |
406 | 406 | |
407 | 407 | $html = getpaid_get_states_select_markup( |
408 | - sanitize_text_field( $_GET['country'] ), |
|
408 | + sanitize_text_field($_GET['country']), |
|
409 | 409 | $value, |
410 | 410 | $placeholder, |
411 | 411 | $label, |
412 | 412 | $description, |
413 | - ! empty( $address_field['required'] ), |
|
413 | + !empty($address_field['required']), |
|
414 | 414 | $wrap_class, |
415 | - sanitize_text_field( $_GET['name'] ) |
|
415 | + sanitize_text_field($_GET['name']) |
|
416 | 416 | ); |
417 | 417 | |
418 | - wp_send_json_success( $html ); |
|
418 | + wp_send_json_success($html); |
|
419 | 419 | exit; |
420 | 420 | |
421 | 421 | } |
@@ -430,66 +430,66 @@ discard block |
||
430 | 430 | public static function recalculate_invoice_totals() { |
431 | 431 | |
432 | 432 | // Verify nonce. |
433 | - check_ajax_referer( 'wpinv-nonce' ); |
|
433 | + check_ajax_referer('wpinv-nonce'); |
|
434 | 434 | |
435 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
435 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
436 | 436 | exit; |
437 | 437 | } |
438 | 438 | |
439 | 439 | // We need an invoice. |
440 | - if ( empty( $_POST['post_id'] ) ) { |
|
440 | + if (empty($_POST['post_id'])) { |
|
441 | 441 | exit; |
442 | 442 | } |
443 | 443 | |
444 | 444 | // Fetch the invoice. |
445 | - $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) ); |
|
445 | + $invoice = new WPInv_Invoice(intval($_POST['post_id'])); |
|
446 | 446 | |
447 | 447 | // Ensure it exists. |
448 | - if ( ! $invoice->get_id() ) { |
|
448 | + if (!$invoice->get_id()) { |
|
449 | 449 | exit; |
450 | 450 | } |
451 | 451 | |
452 | 452 | // Maybe set the country, state, currency. |
453 | - foreach ( array( 'country', 'state', 'currency', 'vat_number', 'discount_code' ) as $key ) { |
|
454 | - if ( isset( $_POST[ $key ] ) ) { |
|
453 | + foreach (array('country', 'state', 'currency', 'vat_number', 'discount_code') as $key) { |
|
454 | + if (isset($_POST[$key])) { |
|
455 | 455 | $method = "set_$key"; |
456 | - $invoice->$method( sanitize_text_field( $_POST[ $key ] ) ); |
|
456 | + $invoice->$method(sanitize_text_field($_POST[$key])); |
|
457 | 457 | } |
458 | 458 | } |
459 | 459 | |
460 | 460 | // Maybe disable taxes. |
461 | - $invoice->set_disable_taxes( ! empty( $_POST['taxes'] ) ); |
|
461 | + $invoice->set_disable_taxes(!empty($_POST['taxes'])); |
|
462 | 462 | |
463 | 463 | // Discount code. |
464 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
465 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
466 | - if ( $discount->exists() ) { |
|
467 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
464 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
465 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
466 | + if ($discount->exists()) { |
|
467 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
468 | 468 | } else { |
469 | - $invoice->remove_discount( 'discount_code' ); |
|
469 | + $invoice->remove_discount('discount_code'); |
|
470 | 470 | } |
471 | 471 | } |
472 | 472 | |
473 | 473 | // Recalculate totals. |
474 | 474 | $invoice->recalculate_total(); |
475 | 475 | |
476 | - $total = wpinv_price( $invoice->get_total(), $invoice->get_currency() ); |
|
477 | - $suscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
478 | - if ( is_a( $suscriptions, 'WPInv_Subscription' ) && $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total() ) { |
|
479 | - $recurring_total = wpinv_price( $invoice->get_recurring_total(), $invoice->get_currency() ); |
|
480 | - $total .= '<small class="form-text text-muted">' . sprintf( __( 'Recurring Price: %s', 'invoicing' ), $recurring_total ) . '</small>'; |
|
476 | + $total = wpinv_price($invoice->get_total(), $invoice->get_currency()); |
|
477 | + $suscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
478 | + if (is_a($suscriptions, 'WPInv_Subscription') && $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total()) { |
|
479 | + $recurring_total = wpinv_price($invoice->get_recurring_total(), $invoice->get_currency()); |
|
480 | + $total .= '<small class="form-text text-muted">' . sprintf(__('Recurring Price: %s', 'invoicing'), $recurring_total) . '</small>'; |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | $totals = array( |
484 | - 'subtotal' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ), |
|
485 | - 'discount' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ), |
|
486 | - 'tax' => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ), |
|
484 | + 'subtotal' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()), |
|
485 | + 'discount' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()), |
|
486 | + 'tax' => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()), |
|
487 | 487 | 'total' => $total, |
488 | 488 | ); |
489 | 489 | |
490 | - $totals = apply_filters( 'getpaid_invoice_totals', $totals, $invoice ); |
|
490 | + $totals = apply_filters('getpaid_invoice_totals', $totals, $invoice); |
|
491 | 491 | |
492 | - wp_send_json_success( compact( 'totals' ) ); |
|
492 | + wp_send_json_success(compact('totals')); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | /** |
@@ -498,33 +498,33 @@ discard block |
||
498 | 498 | public static function get_invoice_items() { |
499 | 499 | |
500 | 500 | // Verify nonce. |
501 | - check_ajax_referer( 'wpinv-nonce' ); |
|
501 | + check_ajax_referer('wpinv-nonce'); |
|
502 | 502 | |
503 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
503 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
504 | 504 | exit; |
505 | 505 | } |
506 | 506 | |
507 | 507 | // We need an invoice and items. |
508 | - if ( empty( $_POST['post_id'] ) ) { |
|
508 | + if (empty($_POST['post_id'])) { |
|
509 | 509 | exit; |
510 | 510 | } |
511 | 511 | |
512 | 512 | // Fetch the invoice. |
513 | - $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) ); |
|
513 | + $invoice = new WPInv_Invoice(intval($_POST['post_id'])); |
|
514 | 514 | |
515 | 515 | // Ensure it exists. |
516 | - if ( ! $invoice->get_id() ) { |
|
516 | + if (!$invoice->get_id()) { |
|
517 | 517 | exit; |
518 | 518 | } |
519 | 519 | |
520 | 520 | // Return an array of invoice items. |
521 | 521 | $items = array(); |
522 | 522 | |
523 | - foreach ( $invoice->get_items() as $item ) { |
|
524 | - $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency(), $invoice->is_renewal() ); |
|
523 | + foreach ($invoice->get_items() as $item) { |
|
524 | + $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency(), $invoice->is_renewal()); |
|
525 | 525 | } |
526 | 526 | |
527 | - wp_send_json_success( compact( 'items' ) ); |
|
527 | + wp_send_json_success(compact('items')); |
|
528 | 528 | } |
529 | 529 | |
530 | 530 | /** |
@@ -533,50 +533,50 @@ discard block |
||
533 | 533 | public static function edit_invoice_item() { |
534 | 534 | |
535 | 535 | // Verify nonce. |
536 | - check_ajax_referer( 'wpinv-nonce' ); |
|
536 | + check_ajax_referer('wpinv-nonce'); |
|
537 | 537 | |
538 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
538 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
539 | 539 | exit; |
540 | 540 | } |
541 | 541 | |
542 | 542 | // We need an invoice and item details. |
543 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['data'] ) ) { |
|
543 | + if (empty($_POST['post_id']) || empty($_POST['data'])) { |
|
544 | 544 | exit; |
545 | 545 | } |
546 | 546 | |
547 | 547 | // Fetch the invoice. |
548 | - $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) ); |
|
548 | + $invoice = new WPInv_Invoice(intval($_POST['post_id'])); |
|
549 | 549 | |
550 | 550 | // Ensure it exists and its not been paid for. |
551 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
551 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
552 | 552 | exit; |
553 | 553 | } |
554 | 554 | |
555 | 555 | // Format the data. |
556 | - $data = wp_kses_post_deep( wp_unslash( wp_list_pluck( $_POST['data'], 'value', 'field' ) ) ); |
|
556 | + $data = wp_kses_post_deep(wp_unslash(wp_list_pluck($_POST['data'], 'value', 'field'))); |
|
557 | 557 | |
558 | 558 | // Ensure that we have an item id. |
559 | - if ( empty( $data['id'] ) ) { |
|
559 | + if (empty($data['id'])) { |
|
560 | 560 | exit; |
561 | 561 | } |
562 | 562 | |
563 | 563 | // Abort if the invoice does not have the specified item. |
564 | - $item = $invoice->get_item( (int) $data['id'] ); |
|
564 | + $item = $invoice->get_item((int) $data['id']); |
|
565 | 565 | |
566 | - if ( empty( $item ) ) { |
|
566 | + if (empty($item)) { |
|
567 | 567 | exit; |
568 | 568 | } |
569 | 569 | |
570 | 570 | // Update the item. |
571 | - $item->set_price( getpaid_standardize_amount( $data['price'] ) ); |
|
572 | - $item->set_name( sanitize_text_field( $data['name'] ) ); |
|
573 | - $item->set_description( wp_kses_post( $data['description'] ) ); |
|
574 | - $item->set_quantity( floatval( $data['quantity'] ) ); |
|
571 | + $item->set_price(getpaid_standardize_amount($data['price'])); |
|
572 | + $item->set_name(sanitize_text_field($data['name'])); |
|
573 | + $item->set_description(wp_kses_post($data['description'])); |
|
574 | + $item->set_quantity(floatval($data['quantity'])); |
|
575 | 575 | |
576 | 576 | // Add it to the invoice. |
577 | - $error = $invoice->add_item( $item ); |
|
577 | + $error = $invoice->add_item($item); |
|
578 | 578 | $alert = false; |
579 | - if ( is_wp_error( $error ) ) { |
|
579 | + if (is_wp_error($error)) { |
|
580 | 580 | $alert = $error->get_error_message(); |
581 | 581 | } |
582 | 582 | |
@@ -589,11 +589,11 @@ discard block |
||
589 | 589 | // Return an array of invoice items. |
590 | 590 | $items = array(); |
591 | 591 | |
592 | - foreach ( $invoice->get_items() as $item ) { |
|
593 | - $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
592 | + foreach ($invoice->get_items() as $item) { |
|
593 | + $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
594 | 594 | } |
595 | 595 | |
596 | - wp_send_json_success( compact( 'items', 'alert' ) ); |
|
596 | + wp_send_json_success(compact('items', 'alert')); |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | /** |
@@ -602,53 +602,53 @@ discard block |
||
602 | 602 | public static function create_invoice_item() { |
603 | 603 | |
604 | 604 | // Verify nonce. |
605 | - check_ajax_referer( 'wpinv-nonce' ); |
|
605 | + check_ajax_referer('wpinv-nonce'); |
|
606 | 606 | |
607 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
607 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
608 | 608 | exit; |
609 | 609 | } |
610 | 610 | |
611 | 611 | // We need an invoice and item details. |
612 | - if ( empty( $_POST['invoice_id'] ) || empty( $_POST['_wpinv_quick'] ) ) { |
|
612 | + if (empty($_POST['invoice_id']) || empty($_POST['_wpinv_quick'])) { |
|
613 | 613 | exit; |
614 | 614 | } |
615 | 615 | |
616 | 616 | // Fetch the invoice. |
617 | - $invoice = new WPInv_Invoice( intval( $_POST['invoice_id'] ) ); |
|
617 | + $invoice = new WPInv_Invoice(intval($_POST['invoice_id'])); |
|
618 | 618 | |
619 | 619 | // Ensure it exists and its not been paid for. |
620 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
620 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
621 | 621 | exit; |
622 | 622 | } |
623 | 623 | |
624 | 624 | // Format the data. |
625 | - $data = wp_kses_post_deep( wp_unslash( $_POST['_wpinv_quick'] ) ); |
|
625 | + $data = wp_kses_post_deep(wp_unslash($_POST['_wpinv_quick'])); |
|
626 | 626 | |
627 | 627 | $item = new WPInv_Item(); |
628 | - $item->set_price( getpaid_standardize_amount( $data['price'] ) ); |
|
629 | - $item->set_name( sanitize_text_field( $data['name'] ) ); |
|
630 | - $item->set_description( wp_kses_post( $data['description'] ) ); |
|
631 | - $item->set_type( sanitize_text_field( $data['type'] ) ); |
|
632 | - $item->set_vat_rule( sanitize_text_field( $data['vat_rule'] ) ); |
|
633 | - $item->set_vat_class( sanitize_text_field( $data['vat_class'] ) ); |
|
634 | - $item->set_status( 'publish' ); |
|
628 | + $item->set_price(getpaid_standardize_amount($data['price'])); |
|
629 | + $item->set_name(sanitize_text_field($data['name'])); |
|
630 | + $item->set_description(wp_kses_post($data['description'])); |
|
631 | + $item->set_type(sanitize_text_field($data['type'])); |
|
632 | + $item->set_vat_rule(sanitize_text_field($data['vat_rule'])); |
|
633 | + $item->set_vat_class(sanitize_text_field($data['vat_class'])); |
|
634 | + $item->set_status('publish'); |
|
635 | 635 | $item->save(); |
636 | 636 | |
637 | - if ( ! $item->exists() ) { |
|
638 | - $alert = __( 'Could not create invoice item. Please try again.', 'invoicing' ); |
|
639 | - wp_send_json_success( compact( 'alert' ) ); |
|
637 | + if (!$item->exists()) { |
|
638 | + $alert = __('Could not create invoice item. Please try again.', 'invoicing'); |
|
639 | + wp_send_json_success(compact('alert')); |
|
640 | 640 | } |
641 | 641 | |
642 | - $item = new GetPaid_Form_Item( $item->get_id() ); |
|
643 | - $item->set_quantity( floatval( $data['qty'] ) ); |
|
642 | + $item = new GetPaid_Form_Item($item->get_id()); |
|
643 | + $item->set_quantity(floatval($data['qty'])); |
|
644 | 644 | |
645 | 645 | // Add it to the invoice. |
646 | - $error = $invoice->add_item( $item ); |
|
646 | + $error = $invoice->add_item($item); |
|
647 | 647 | $alert = false; |
648 | 648 | |
649 | - if ( is_wp_error( $error ) ) { |
|
649 | + if (is_wp_error($error)) { |
|
650 | 650 | $alert = $error->get_error_message(); |
651 | - wp_send_json_success( compact( 'alert' ) ); |
|
651 | + wp_send_json_success(compact('alert')); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | // Update totals. |
@@ -661,9 +661,9 @@ discard block |
||
661 | 661 | $invoice->recalculate_total(); |
662 | 662 | $invoice->save(); |
663 | 663 | ob_start(); |
664 | - GetPaid_Meta_Box_Invoice_Items::output_row( GetPaid_Meta_Box_Invoice_Items::get_columns( $invoice ), $item, $invoice ); |
|
664 | + GetPaid_Meta_Box_Invoice_Items::output_row(GetPaid_Meta_Box_Invoice_Items::get_columns($invoice), $item, $invoice); |
|
665 | 665 | $row = ob_get_clean(); |
666 | - wp_send_json_success( compact( 'row' ) ); |
|
666 | + wp_send_json_success(compact('row')); |
|
667 | 667 | } |
668 | 668 | |
669 | 669 | /** |
@@ -672,33 +672,33 @@ discard block |
||
672 | 672 | public static function remove_invoice_item() { |
673 | 673 | |
674 | 674 | // Verify nonce. |
675 | - check_ajax_referer( 'wpinv-nonce' ); |
|
675 | + check_ajax_referer('wpinv-nonce'); |
|
676 | 676 | |
677 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
677 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
678 | 678 | exit; |
679 | 679 | } |
680 | 680 | |
681 | 681 | // We need an invoice and an item. |
682 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) { |
|
682 | + if (empty($_POST['post_id']) || empty($_POST['item_id'])) { |
|
683 | 683 | exit; |
684 | 684 | } |
685 | 685 | |
686 | 686 | // Fetch the invoice. |
687 | - $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) ); |
|
687 | + $invoice = new WPInv_Invoice(intval($_POST['post_id'])); |
|
688 | 688 | |
689 | 689 | // Ensure it exists and its not been paid for. |
690 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
690 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
691 | 691 | exit; |
692 | 692 | } |
693 | 693 | |
694 | 694 | // Abort if the invoice does not have the specified item. |
695 | - $item = $invoice->get_item( (int) $_POST['item_id'] ); |
|
695 | + $item = $invoice->get_item((int) $_POST['item_id']); |
|
696 | 696 | |
697 | - if ( empty( $item ) ) { |
|
697 | + if (empty($item)) { |
|
698 | 698 | exit; |
699 | 699 | } |
700 | 700 | |
701 | - $invoice->remove_item( (int) $_POST['item_id'] ); |
|
701 | + $invoice->remove_item((int) $_POST['item_id']); |
|
702 | 702 | |
703 | 703 | // Update totals. |
704 | 704 | $invoice->recalculate_total(); |
@@ -709,11 +709,11 @@ discard block |
||
709 | 709 | // Return an array of invoice items. |
710 | 710 | $items = array(); |
711 | 711 | |
712 | - foreach ( $invoice->get_items() as $item ) { |
|
713 | - $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
712 | + foreach ($invoice->get_items() as $item) { |
|
713 | + $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
714 | 714 | } |
715 | 715 | |
716 | - wp_send_json_success( compact( 'items' ) ); |
|
716 | + wp_send_json_success(compact('items')); |
|
717 | 717 | } |
718 | 718 | |
719 | 719 | /** |
@@ -722,68 +722,68 @@ discard block |
||
722 | 722 | public static function recalculate_full_prices() { |
723 | 723 | |
724 | 724 | // Verify nonce. |
725 | - check_ajax_referer( 'wpinv-nonce' ); |
|
725 | + check_ajax_referer('wpinv-nonce'); |
|
726 | 726 | |
727 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
727 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
728 | 728 | exit; |
729 | 729 | } |
730 | 730 | |
731 | 731 | // We need an invoice and item. |
732 | - if ( empty( $_POST['post_id'] ) ) { |
|
732 | + if (empty($_POST['post_id'])) { |
|
733 | 733 | exit; |
734 | 734 | } |
735 | 735 | |
736 | 736 | // Fetch the invoice. |
737 | - $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) ); |
|
737 | + $invoice = new WPInv_Invoice(intval($_POST['post_id'])); |
|
738 | 738 | $alert = false; |
739 | 739 | |
740 | 740 | // Ensure it exists and its not been paid for. |
741 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
741 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
742 | 742 | exit; |
743 | 743 | } |
744 | 744 | |
745 | - $invoice->set_items( array() ); |
|
745 | + $invoice->set_items(array()); |
|
746 | 746 | |
747 | - if ( ! empty( $_POST['getpaid_items'] ) ) { |
|
747 | + if (!empty($_POST['getpaid_items'])) { |
|
748 | 748 | |
749 | - foreach ( wp_kses_post_deep( $_POST['getpaid_items'] ) as $item_id => $args ) { |
|
750 | - $item = new GetPaid_Form_Item( $item_id ); |
|
749 | + foreach (wp_kses_post_deep($_POST['getpaid_items']) as $item_id => $args) { |
|
750 | + $item = new GetPaid_Form_Item($item_id); |
|
751 | 751 | |
752 | - if ( $item->exists() ) { |
|
753 | - $item->set_price( getpaid_standardize_amount( $args['price'] ) ); |
|
754 | - $item->set_quantity( floatval( $args['quantity'] ) ); |
|
755 | - $item->set_name( sanitize_text_field( $args['name'] ) ); |
|
756 | - $item->set_description( wp_kses_post( $args['description'] ) ); |
|
757 | - $invoice->add_item( $item ); |
|
752 | + if ($item->exists()) { |
|
753 | + $item->set_price(getpaid_standardize_amount($args['price'])); |
|
754 | + $item->set_quantity(floatval($args['quantity'])); |
|
755 | + $item->set_name(sanitize_text_field($args['name'])); |
|
756 | + $item->set_description(wp_kses_post($args['description'])); |
|
757 | + $invoice->add_item($item); |
|
758 | 758 | } |
759 | 759 | } |
760 | 760 | } |
761 | 761 | |
762 | - $invoice->set_disable_taxes( ! empty( $_POST['disable_taxes'] ) ); |
|
762 | + $invoice->set_disable_taxes(!empty($_POST['disable_taxes'])); |
|
763 | 763 | |
764 | 764 | // Maybe set the country, state, currency. |
765 | - foreach ( array( 'wpinv_country', 'wpinv_state', 'wpinv_currency', 'wpinv_vat_number', 'wpinv_discount_code' ) as $key ) { |
|
766 | - if ( isset( $_POST[ $key ] ) ) { |
|
767 | - $_key = str_replace( 'wpinv_', '', $key ); |
|
765 | + foreach (array('wpinv_country', 'wpinv_state', 'wpinv_currency', 'wpinv_vat_number', 'wpinv_discount_code') as $key) { |
|
766 | + if (isset($_POST[$key])) { |
|
767 | + $_key = str_replace('wpinv_', '', $key); |
|
768 | 768 | $method = "set_$_key"; |
769 | - $invoice->$method( sanitize_text_field( $_POST[ $key ] ) ); |
|
769 | + $invoice->$method(sanitize_text_field($_POST[$key])); |
|
770 | 770 | } |
771 | 771 | } |
772 | 772 | |
773 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
774 | - if ( $discount->exists() ) { |
|
775 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
773 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
774 | + if ($discount->exists()) { |
|
775 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
776 | 776 | } else { |
777 | - $invoice->remove_discount( 'discount_code' ); |
|
777 | + $invoice->remove_discount('discount_code'); |
|
778 | 778 | } |
779 | 779 | |
780 | 780 | // Save the invoice. |
781 | 781 | $invoice->recalculate_total(); |
782 | 782 | $invoice->save(); |
783 | 783 | ob_start(); |
784 | - GetPaid_Meta_Box_Invoice_Items::output( get_post( $invoice->get_id() ), $invoice ); |
|
784 | + GetPaid_Meta_Box_Invoice_Items::output(get_post($invoice->get_id()), $invoice); |
|
785 | 785 | $table = ob_get_clean(); |
786 | - wp_send_json_success( compact( 'table' ) ); |
|
786 | + wp_send_json_success(compact('table')); |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | /** |
@@ -792,42 +792,42 @@ discard block |
||
792 | 792 | public static function admin_add_invoice_item() { |
793 | 793 | |
794 | 794 | // Verify nonce. |
795 | - check_ajax_referer( 'wpinv-nonce' ); |
|
795 | + check_ajax_referer('wpinv-nonce'); |
|
796 | 796 | |
797 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
797 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
798 | 798 | exit; |
799 | 799 | } |
800 | 800 | |
801 | 801 | // We need an invoice and item. |
802 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) { |
|
802 | + if (empty($_POST['post_id']) || empty($_POST['item_id'])) { |
|
803 | 803 | exit; |
804 | 804 | } |
805 | 805 | |
806 | 806 | // Fetch the invoice. |
807 | - $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) ); |
|
807 | + $invoice = new WPInv_Invoice(intval($_POST['post_id'])); |
|
808 | 808 | $alert = false; |
809 | 809 | |
810 | 810 | // Ensure it exists and its not been paid for. |
811 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
811 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
812 | 812 | exit; |
813 | 813 | } |
814 | 814 | |
815 | 815 | // Add the item. |
816 | - $item = new GetPaid_Form_Item( (int) $_POST['item_id'] ); |
|
817 | - $error = $invoice->add_item( $item ); |
|
816 | + $item = new GetPaid_Form_Item((int) $_POST['item_id']); |
|
817 | + $error = $invoice->add_item($item); |
|
818 | 818 | |
819 | - if ( is_wp_error( $error ) ) { |
|
819 | + if (is_wp_error($error)) { |
|
820 | 820 | $alert = $error->get_error_message(); |
821 | - wp_send_json_success( compact( 'alert' ) ); |
|
821 | + wp_send_json_success(compact('alert')); |
|
822 | 822 | } |
823 | 823 | |
824 | 824 | // Save the invoice. |
825 | 825 | $invoice->recalculate_total(); |
826 | 826 | $invoice->save(); |
827 | 827 | ob_start(); |
828 | - GetPaid_Meta_Box_Invoice_Items::output_row( GetPaid_Meta_Box_Invoice_Items::get_columns( $invoice ), $item, $invoice ); |
|
828 | + GetPaid_Meta_Box_Invoice_Items::output_row(GetPaid_Meta_Box_Invoice_Items::get_columns($invoice), $item, $invoice); |
|
829 | 829 | $row = ob_get_clean(); |
830 | - wp_send_json_success( compact( 'row' ) ); |
|
830 | + wp_send_json_success(compact('row')); |
|
831 | 831 | } |
832 | 832 | |
833 | 833 | /** |
@@ -836,39 +836,39 @@ discard block |
||
836 | 836 | public static function add_invoice_items() { |
837 | 837 | |
838 | 838 | // Verify nonce. |
839 | - check_ajax_referer( 'wpinv-nonce' ); |
|
839 | + check_ajax_referer('wpinv-nonce'); |
|
840 | 840 | |
841 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
841 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
842 | 842 | exit; |
843 | 843 | } |
844 | 844 | |
845 | 845 | // We need an invoice and items. |
846 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['items'] ) ) { |
|
846 | + if (empty($_POST['post_id']) || empty($_POST['items'])) { |
|
847 | 847 | exit; |
848 | 848 | } |
849 | 849 | |
850 | 850 | // Fetch the invoice. |
851 | - $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) ); |
|
851 | + $invoice = new WPInv_Invoice(intval($_POST['post_id'])); |
|
852 | 852 | $alert = false; |
853 | 853 | |
854 | 854 | // Ensure it exists and its not been paid for. |
855 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
855 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
856 | 856 | exit; |
857 | 857 | } |
858 | 858 | |
859 | 859 | // Add the items. |
860 | - foreach ( wp_kses_post_deep( wp_unslash( $_POST['items'] ) ) as $data ) { |
|
860 | + foreach (wp_kses_post_deep(wp_unslash($_POST['items'])) as $data) { |
|
861 | 861 | |
862 | - $item = new GetPaid_Form_Item( (int) $data['id'] ); |
|
862 | + $item = new GetPaid_Form_Item((int) $data['id']); |
|
863 | 863 | |
864 | - if ( is_numeric( $data['qty'] ) && (float) $data['qty'] > 0 ) { |
|
865 | - $item->set_quantity( floatval( $data['qty'] ) ); |
|
864 | + if (is_numeric($data['qty']) && (float) $data['qty'] > 0) { |
|
865 | + $item->set_quantity(floatval($data['qty'])); |
|
866 | 866 | } |
867 | 867 | |
868 | - if ( $item->get_id() > 0 ) { |
|
869 | - $error = $invoice->add_item( $item ); |
|
868 | + if ($item->get_id() > 0) { |
|
869 | + $error = $invoice->add_item($item); |
|
870 | 870 | |
871 | - if ( is_wp_error( $error ) ) { |
|
871 | + if (is_wp_error($error)) { |
|
872 | 872 | $alert = $error->get_error_message(); |
873 | 873 | } |
874 | 874 | } |
@@ -881,11 +881,11 @@ discard block |
||
881 | 881 | // Return an array of invoice items. |
882 | 882 | $items = array(); |
883 | 883 | |
884 | - foreach ( $invoice->get_items() as $item ) { |
|
885 | - $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
884 | + foreach ($invoice->get_items() as $item) { |
|
885 | + $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
886 | 886 | } |
887 | 887 | |
888 | - wp_send_json_success( compact( 'items', 'alert' ) ); |
|
888 | + wp_send_json_success(compact('items', 'alert')); |
|
889 | 889 | } |
890 | 890 | |
891 | 891 | /** |
@@ -894,15 +894,15 @@ discard block |
||
894 | 894 | public static function get_invoicing_items() { |
895 | 895 | |
896 | 896 | // Verify nonce. |
897 | - check_ajax_referer( 'wpinv-nonce' ); |
|
897 | + check_ajax_referer('wpinv-nonce'); |
|
898 | 898 | |
899 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
899 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
900 | 900 | exit; |
901 | 901 | } |
902 | 902 | |
903 | 903 | // We need a search term. |
904 | - if ( empty( $_GET['search'] ) ) { |
|
905 | - wp_send_json_success( array() ); |
|
904 | + if (empty($_GET['search'])) { |
|
905 | + wp_send_json_success(array()); |
|
906 | 906 | } |
907 | 907 | |
908 | 908 | // Retrieve items. |
@@ -911,8 +911,8 @@ discard block |
||
911 | 911 | 'orderby' => 'title', |
912 | 912 | 'order' => 'ASC', |
913 | 913 | 'posts_per_page' => -1, |
914 | - 'post_status' => array( 'publish' ), |
|
915 | - 's' => sanitize_text_field( urldecode( $_GET['search'] ) ), |
|
914 | + 'post_status' => array('publish'), |
|
915 | + 's' => sanitize_text_field(urldecode($_GET['search'])), |
|
916 | 916 | 'meta_query' => array( |
917 | 917 | array( |
918 | 918 | 'key' => '_wpinv_type', |
@@ -922,25 +922,25 @@ discard block |
||
922 | 922 | ), |
923 | 923 | ); |
924 | 924 | |
925 | - if ( ! empty( $_GET['ignore'] ) ) { |
|
926 | - $item_args['exclude'] = wp_parse_id_list( sanitize_text_field( $_GET['ignore'] ) ); |
|
925 | + if (!empty($_GET['ignore'])) { |
|
926 | + $item_args['exclude'] = wp_parse_id_list(sanitize_text_field($_GET['ignore'])); |
|
927 | 927 | } |
928 | 928 | |
929 | - $items = get_posts( apply_filters( 'getpaid_ajax_invoice_items_query_args', $item_args ) ); |
|
929 | + $items = get_posts(apply_filters('getpaid_ajax_invoice_items_query_args', $item_args)); |
|
930 | 930 | $data = array(); |
931 | 931 | |
932 | - $is_payment_form = ( ! empty( $_GET['post_id'] ) && 'wpi_payment_form' == get_post_type( (int) $_GET['post_id'] ) ); |
|
932 | + $is_payment_form = (!empty($_GET['post_id']) && 'wpi_payment_form' == get_post_type((int) $_GET['post_id'])); |
|
933 | 933 | |
934 | - foreach ( $items as $item ) { |
|
935 | - $item = new GetPaid_Form_Item( $item ); |
|
934 | + foreach ($items as $item) { |
|
935 | + $item = new GetPaid_Form_Item($item); |
|
936 | 936 | $data[] = array( |
937 | 937 | 'id' => (int) $item->get_id(), |
938 | - 'text' => strip_tags( $item->get_name() ), |
|
939 | - 'form_data' => $is_payment_form ? $item->prepare_data_for_use( false ) : '', |
|
938 | + 'text' => strip_tags($item->get_name()), |
|
939 | + 'form_data' => $is_payment_form ? $item->prepare_data_for_use(false) : '', |
|
940 | 940 | ); |
941 | 941 | } |
942 | 942 | |
943 | - wp_send_json_success( $data ); |
|
943 | + wp_send_json_success($data); |
|
944 | 944 | |
945 | 945 | } |
946 | 946 | |
@@ -950,37 +950,37 @@ discard block |
||
950 | 950 | public static function get_customers() { |
951 | 951 | |
952 | 952 | // Verify nonce. |
953 | - check_ajax_referer( 'wpinv-nonce' ); |
|
953 | + check_ajax_referer('wpinv-nonce'); |
|
954 | 954 | |
955 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
955 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
956 | 956 | exit; |
957 | 957 | } |
958 | 958 | |
959 | 959 | // We need a search term. |
960 | - if ( empty( $_GET['search'] ) ) { |
|
961 | - wp_send_json_success( array() ); |
|
960 | + if (empty($_GET['search'])) { |
|
961 | + wp_send_json_success(array()); |
|
962 | 962 | } |
963 | 963 | |
964 | 964 | // Retrieve customers. |
965 | 965 | |
966 | 966 | $customer_args = array( |
967 | - 'fields' => array( 'ID', 'user_email', 'display_name' ), |
|
967 | + 'fields' => array('ID', 'user_email', 'display_name'), |
|
968 | 968 | 'orderby' => 'display_name', |
969 | - 'search' => '*' . sanitize_text_field( $_GET['search'] ) . '*', |
|
970 | - 'search_columns' => array( 'user_login', 'user_email', 'display_name' ), |
|
969 | + 'search' => '*' . sanitize_text_field($_GET['search']) . '*', |
|
970 | + 'search_columns' => array('user_login', 'user_email', 'display_name'), |
|
971 | 971 | ); |
972 | 972 | |
973 | - $customers = get_users( apply_filters( 'getpaid_ajax_invoice_customers_query_args', $customer_args ) ); |
|
973 | + $customers = get_users(apply_filters('getpaid_ajax_invoice_customers_query_args', $customer_args)); |
|
974 | 974 | $data = array(); |
975 | 975 | |
976 | - foreach ( $customers as $customer ) { |
|
976 | + foreach ($customers as $customer) { |
|
977 | 977 | $data[] = array( |
978 | 978 | 'id' => (int) $customer->ID, |
979 | - 'text' => strip_tags( sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email ) ), |
|
979 | + 'text' => strip_tags(sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email)), |
|
980 | 980 | ); |
981 | 981 | } |
982 | 982 | |
983 | - wp_send_json_success( $data ); |
|
983 | + wp_send_json_success($data); |
|
984 | 984 | |
985 | 985 | } |
986 | 986 | |
@@ -990,28 +990,28 @@ discard block |
||
990 | 990 | public static function get_aui_states_field() { |
991 | 991 | |
992 | 992 | // Verify nonce. |
993 | - check_ajax_referer( 'wpinv-nonce' ); |
|
993 | + check_ajax_referer('wpinv-nonce'); |
|
994 | 994 | |
995 | 995 | // We need a country. |
996 | - if ( empty( $_GET['country'] ) ) { |
|
996 | + if (empty($_GET['country'])) { |
|
997 | 997 | exit; |
998 | 998 | } |
999 | 999 | |
1000 | - $states = wpinv_get_country_states( sanitize_text_field( $_GET['country'] ) ); |
|
1001 | - $state = isset( $_GET['state'] ) ? sanitize_text_field( $_GET['state'] ) : wpinv_get_default_state(); |
|
1002 | - $name = isset( $_GET['name'] ) ? sanitize_text_field( $_GET['name'] ) : 'wpinv_state'; |
|
1003 | - $class = isset( $_GET['class'] ) ? sanitize_text_field( $_GET['class'] ) : 'form-control-sm'; |
|
1000 | + $states = wpinv_get_country_states(sanitize_text_field($_GET['country'])); |
|
1001 | + $state = isset($_GET['state']) ? sanitize_text_field($_GET['state']) : wpinv_get_default_state(); |
|
1002 | + $name = isset($_GET['name']) ? sanitize_text_field($_GET['name']) : 'wpinv_state'; |
|
1003 | + $class = isset($_GET['class']) ? sanitize_text_field($_GET['class']) : 'form-control-sm'; |
|
1004 | 1004 | |
1005 | - if ( empty( $states ) ) { |
|
1005 | + if (empty($states)) { |
|
1006 | 1006 | |
1007 | 1007 | $html = aui()->input( |
1008 | 1008 | array( |
1009 | 1009 | 'type' => 'text', |
1010 | 1010 | 'id' => 'wpinv_state', |
1011 | 1011 | 'name' => $name, |
1012 | - 'label' => __( 'State', 'invoicing' ), |
|
1012 | + 'label' => __('State', 'invoicing'), |
|
1013 | 1013 | 'label_type' => 'vertical', |
1014 | - 'placeholder' => __( 'State', 'invoicing' ), |
|
1014 | + 'placeholder' => __('State', 'invoicing'), |
|
1015 | 1015 | 'class' => $class, |
1016 | 1016 | 'value' => $state, |
1017 | 1017 | ) |
@@ -1023,9 +1023,9 @@ discard block |
||
1023 | 1023 | array( |
1024 | 1024 | 'id' => 'wpinv_state', |
1025 | 1025 | 'name' => $name, |
1026 | - 'label' => __( 'State', 'invoicing' ), |
|
1026 | + 'label' => __('State', 'invoicing'), |
|
1027 | 1027 | 'label_type' => 'vertical', |
1028 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
1028 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
1029 | 1029 | 'class' => $class, |
1030 | 1030 | 'value' => $state, |
1031 | 1031 | 'options' => $states, |
@@ -1039,7 +1039,7 @@ discard block |
||
1039 | 1039 | wp_send_json_success( |
1040 | 1040 | array( |
1041 | 1041 | 'html' => $html, |
1042 | - 'select' => ! empty( $states ), |
|
1042 | + 'select' => !empty($states), |
|
1043 | 1043 | ) |
1044 | 1044 | ); |
1045 | 1045 | |
@@ -1053,11 +1053,11 @@ discard block |
||
1053 | 1053 | public static function payment_form_refresh_prices() { |
1054 | 1054 | |
1055 | 1055 | // Check nonce. |
1056 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
1056 | + check_ajax_referer('getpaid_form_nonce'); |
|
1057 | 1057 | |
1058 | 1058 | // ... form fields... |
1059 | - if ( empty( $_POST['getpaid_payment_form_submission'] ) ) { |
|
1060 | - _e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
1059 | + if (empty($_POST['getpaid_payment_form_submission'])) { |
|
1060 | + _e('Error: Reload the page and try again.', 'invoicing'); |
|
1061 | 1061 | exit; |
1062 | 1062 | } |
1063 | 1063 | |
@@ -1065,7 +1065,7 @@ discard block |
||
1065 | 1065 | $submission = new GetPaid_Payment_Form_Submission(); |
1066 | 1066 | |
1067 | 1067 | // Do we have an error? |
1068 | - if ( ! empty( $submission->last_error ) ) { |
|
1068 | + if (!empty($submission->last_error)) { |
|
1069 | 1069 | wp_send_json_error( |
1070 | 1070 | array( |
1071 | 1071 | 'code' => $submission->last_error_code, |
@@ -1075,12 +1075,12 @@ discard block |
||
1075 | 1075 | } |
1076 | 1076 | |
1077 | 1077 | // Prepare the response. |
1078 | - $response = new GetPaid_Payment_Form_Submission_Refresh_Prices( $submission ); |
|
1078 | + $response = new GetPaid_Payment_Form_Submission_Refresh_Prices($submission); |
|
1079 | 1079 | |
1080 | 1080 | // Filter the response. |
1081 | - $response = apply_filters( 'getpaid_payment_form_ajax_refresh_prices', $response->response, $submission ); |
|
1081 | + $response = apply_filters('getpaid_payment_form_ajax_refresh_prices', $response->response, $submission); |
|
1082 | 1082 | |
1083 | - wp_send_json_success( $response ); |
|
1083 | + wp_send_json_success($response); |
|
1084 | 1084 | } |
1085 | 1085 | |
1086 | 1086 | /** |
@@ -1092,63 +1092,63 @@ discard block |
||
1092 | 1092 | public static function file_upload() { |
1093 | 1093 | |
1094 | 1094 | // Check nonce. |
1095 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
1095 | + check_ajax_referer('getpaid_form_nonce'); |
|
1096 | 1096 | |
1097 | - if ( empty( $_POST['form_id'] ) || empty( $_POST['field_name'] ) || empty( $_FILES['file'] ) ) { |
|
1098 | - wp_die( __( 'Bad Request', 'invoicing' ), 400 ); |
|
1097 | + if (empty($_POST['form_id']) || empty($_POST['field_name']) || empty($_FILES['file'])) { |
|
1098 | + wp_die(__('Bad Request', 'invoicing'), 400); |
|
1099 | 1099 | } |
1100 | 1100 | |
1101 | 1101 | // Fetch form. |
1102 | - $form = new GetPaid_Payment_Form( intval( $_POST['form_id'] ) ); |
|
1102 | + $form = new GetPaid_Payment_Form(intval($_POST['form_id'])); |
|
1103 | 1103 | |
1104 | - if ( ! $form->is_active() ) { |
|
1105 | - wp_send_json_error( __( 'Payment form not active', 'invoicing' ) ); |
|
1104 | + if (!$form->is_active()) { |
|
1105 | + wp_send_json_error(__('Payment form not active', 'invoicing')); |
|
1106 | 1106 | } |
1107 | 1107 | |
1108 | 1108 | // Fetch appropriate field. |
1109 | - $upload_field = current( wp_list_filter( $form->get_elements(), array( 'id' => sanitize_text_field( $_POST['field_name'] ) ) ) ); |
|
1110 | - if ( empty( $upload_field ) ) { |
|
1111 | - wp_send_json_error( __( 'Invalid upload field.', 'invoicing' ) ); |
|
1109 | + $upload_field = current(wp_list_filter($form->get_elements(), array('id' => sanitize_text_field($_POST['field_name'])))); |
|
1110 | + if (empty($upload_field)) { |
|
1111 | + wp_send_json_error(__('Invalid upload field.', 'invoicing')); |
|
1112 | 1112 | } |
1113 | 1113 | |
1114 | 1114 | // Prepare allowed file types. |
1115 | - $file_types = isset( $upload_field['file_types'] ) ? $upload_field['file_types'] : array( 'jpg|jpeg|jpe', 'gif', 'png' ); |
|
1115 | + $file_types = isset($upload_field['file_types']) ? $upload_field['file_types'] : array('jpg|jpeg|jpe', 'gif', 'png'); |
|
1116 | 1116 | $all_types = getpaid_get_allowed_mime_types(); |
1117 | 1117 | $mime_types = array(); |
1118 | 1118 | |
1119 | - foreach ( $file_types as $file_type ) { |
|
1120 | - if ( isset( $all_types[ $file_type ] ) ) { |
|
1121 | - $mime_types[] = $all_types[ $file_type ]; |
|
1119 | + foreach ($file_types as $file_type) { |
|
1120 | + if (isset($all_types[$file_type])) { |
|
1121 | + $mime_types[] = $all_types[$file_type]; |
|
1122 | 1122 | } |
1123 | 1123 | } |
1124 | 1124 | |
1125 | - if ( ! in_array( $_FILES['file']['type'], $mime_types ) ) { |
|
1126 | - wp_send_json_error( __( 'Unsupported file type.', 'invoicing' ) ); |
|
1125 | + if (!in_array($_FILES['file']['type'], $mime_types)) { |
|
1126 | + wp_send_json_error(__('Unsupported file type.', 'invoicing')); |
|
1127 | 1127 | } |
1128 | 1128 | |
1129 | 1129 | // Upload file. |
1130 | - $file_name = explode( '.', strtolower( $_FILES['file']['name'] ) ); |
|
1131 | - $file_name = uniqid( 'getpaid-' ) . '.' . array_pop( $file_name ); |
|
1130 | + $file_name = explode('.', strtolower($_FILES['file']['name'])); |
|
1131 | + $file_name = uniqid('getpaid-') . '.' . array_pop($file_name); |
|
1132 | 1132 | |
1133 | 1133 | $uploaded = wp_upload_bits( |
1134 | 1134 | $file_name, |
1135 | 1135 | null, |
1136 | - file_get_contents( $_FILES['file']['tmp_name'] ) |
|
1136 | + file_get_contents($_FILES['file']['tmp_name']) |
|
1137 | 1137 | ); |
1138 | 1138 | |
1139 | - if ( ! empty( $uploaded['error'] ) ) { |
|
1140 | - wp_send_json_error( $uploaded['error'] ); |
|
1139 | + if (!empty($uploaded['error'])) { |
|
1140 | + wp_send_json_error($uploaded['error']); |
|
1141 | 1141 | } |
1142 | 1142 | |
1143 | 1143 | // Retrieve response. |
1144 | 1144 | $response = sprintf( |
1145 | 1145 | '<input type="hidden" name="%s[%s]" value="%s" />', |
1146 | - esc_attr( sanitize_text_field( $_POST['field_name'] ) ), |
|
1147 | - esc_url( $uploaded['url'] ), |
|
1148 | - esc_attr( sanitize_text_field( strtolower( $_FILES['file']['name'] ) ) ) |
|
1146 | + esc_attr(sanitize_text_field($_POST['field_name'])), |
|
1147 | + esc_url($uploaded['url']), |
|
1148 | + esc_attr(sanitize_text_field(strtolower($_FILES['file']['name']))) |
|
1149 | 1149 | ); |
1150 | 1150 | |
1151 | - wp_send_json_success( $response ); |
|
1151 | + wp_send_json_success($response); |
|
1152 | 1152 | |
1153 | 1153 | } |
1154 | 1154 |
@@ -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 | |
@@ -311,11 +311,11 @@ discard block |
||
311 | 311 | |
312 | 312 | $output = wpinv_html_select( |
313 | 313 | array( |
314 | - 'name' => $name, |
|
315 | - 'selected' => $selected, |
|
316 | - 'options' => $options, |
|
317 | - 'show_option_all' => false, |
|
318 | - 'show_option_none' => false, |
|
314 | + 'name' => $name, |
|
315 | + 'selected' => $selected, |
|
316 | + 'options' => $options, |
|
317 | + 'show_option_all' => false, |
|
318 | + 'show_option_none' => false, |
|
319 | 319 | ) |
320 | 320 | ); |
321 | 321 | |
@@ -344,11 +344,11 @@ discard block |
||
344 | 344 | |
345 | 345 | $output = wpinv_html_select( |
346 | 346 | array( |
347 | - 'name' => $name, |
|
348 | - 'selected' => $selected, |
|
349 | - 'options' => $options, |
|
350 | - 'show_option_all' => false, |
|
351 | - 'show_option_none' => false, |
|
347 | + 'name' => $name, |
|
348 | + 'selected' => $selected, |
|
349 | + 'options' => $options, |
|
350 | + 'show_option_all' => false, |
|
351 | + 'show_option_none' => false, |
|
352 | 352 | ) |
353 | 353 | ); |
354 | 354 | |
@@ -512,16 +512,16 @@ discard block |
||
512 | 512 | |
513 | 513 | $output = wpinv_html_select( |
514 | 514 | array( |
515 | - 'name' => $args['name'], |
|
516 | - 'selected' => $args['selected'], |
|
517 | - 'id' => $args['id'], |
|
518 | - 'class' => $args['class'], |
|
519 | - 'options' => $options, |
|
520 | - 'multiple' => $args['multiple'], |
|
521 | - 'placeholder' => $args['placeholder'], |
|
522 | - 'show_option_all' => $args['show_option_all'], |
|
523 | - 'show_option_none' => $args['show_option_none'], |
|
524 | - 'data' => $args['data'], |
|
515 | + 'name' => $args['name'], |
|
516 | + 'selected' => $args['selected'], |
|
517 | + 'id' => $args['id'], |
|
518 | + 'class' => $args['class'], |
|
519 | + 'options' => $options, |
|
520 | + 'multiple' => $args['multiple'], |
|
521 | + 'placeholder' => $args['placeholder'], |
|
522 | + 'show_option_all' => $args['show_option_all'], |
|
523 | + 'show_option_none' => $args['show_option_none'], |
|
524 | + 'data' => $args['data'], |
|
525 | 525 | ) |
526 | 526 | ); |
527 | 527 | |
@@ -822,21 +822,21 @@ discard block |
||
822 | 822 | |
823 | 823 | $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
824 | 824 | |
825 | - // Remove unavailable tags. |
|
825 | + // Remove unavailable tags. |
|
826 | 826 | $formatted_address = preg_replace( '/\{\{\w+\}\}/', '', $formatted_address ); |
827 | 827 | |
828 | 828 | // Clean up white space. |
829 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
829 | + $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
830 | 830 | $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
831 | 831 | |
832 | 832 | // Break newlines apart and remove empty lines/trim commas and white space. |
833 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
833 | + $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
834 | 834 | |
835 | 835 | // Add html breaks. |
836 | - $formatted_address = implode( $separator, $formatted_address ); |
|
836 | + $formatted_address = implode( $separator, $formatted_address ); |
|
837 | 837 | |
838 | - // We're done! |
|
839 | - return $formatted_address; |
|
838 | + // We're done! |
|
839 | + return $formatted_address; |
|
840 | 840 | |
841 | 841 | } |
842 | 842 | |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | function getpaid_display_invoice_subscriptions( $invoice ) { |
883 | 883 | |
884 | 884 | // Subscriptions. |
885 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
885 | + $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
886 | 886 | |
887 | 887 | if ( empty( $subscriptions ) || ! $invoice->is_recurring() ) { |
888 | 888 | return; |
@@ -1094,7 +1094,7 @@ discard block |
||
1094 | 1094 | } |
1095 | 1095 | |
1096 | 1096 | function wpinv_empty_cart_message() { |
1097 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1097 | + return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1098 | 1098 | } |
1099 | 1099 | |
1100 | 1100 | /** |
@@ -1292,9 +1292,9 @@ discard block |
||
1292 | 1292 | |
1293 | 1293 | if ( 0 == count( $form->get_items() ) ) { |
1294 | 1294 | aui()->alert( |
1295 | - array( |
|
1296 | - 'type' => 'warning', |
|
1297 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
1295 | + array( |
|
1296 | + 'type' => 'warning', |
|
1297 | + 'content' => __( 'No published items found', 'invoicing' ), |
|
1298 | 1298 | ), |
1299 | 1299 | true |
1300 | 1300 | ); |
@@ -1317,10 +1317,10 @@ discard block |
||
1317 | 1317 | $invoice = wpinv_get_invoice( $invoice_id ); |
1318 | 1318 | |
1319 | 1319 | if ( empty( $invoice ) ) { |
1320 | - aui()->alert( |
|
1321 | - array( |
|
1322 | - 'type' => 'warning', |
|
1323 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
1320 | + aui()->alert( |
|
1321 | + array( |
|
1322 | + 'type' => 'warning', |
|
1323 | + 'content' => __( 'Invoice not found', 'invoicing' ), |
|
1324 | 1324 | ), |
1325 | 1325 | true |
1326 | 1326 | ); |
@@ -1328,10 +1328,10 @@ discard block |
||
1328 | 1328 | } |
1329 | 1329 | |
1330 | 1330 | if ( $invoice->is_paid() ) { |
1331 | - aui()->alert( |
|
1332 | - array( |
|
1333 | - 'type' => 'warning', |
|
1334 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
1331 | + aui()->alert( |
|
1332 | + array( |
|
1333 | + 'type' => 'warning', |
|
1334 | + 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
1335 | 1335 | ), |
1336 | 1336 | true |
1337 | 1337 | ); |
@@ -1395,7 +1395,7 @@ discard block |
||
1395 | 1395 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>"; |
1396 | 1396 | } |
1397 | 1397 | |
1398 | - if ( ! empty( $items ) ) { |
|
1398 | + if ( ! empty( $items ) ) { |
|
1399 | 1399 | $items = esc_attr( $items ); |
1400 | 1400 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>"; |
1401 | 1401 | } |
@@ -1581,21 +1581,21 @@ discard block |
||
1581 | 1581 | |
1582 | 1582 | return aui()->select( |
1583 | 1583 | array( |
1584 | - 'options' => $states, |
|
1585 | - 'name' => esc_attr( $field_name ), |
|
1586 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
1587 | - 'value' => sanitize_text_field( $state ), |
|
1588 | - 'placeholder' => $placeholder, |
|
1589 | - 'required' => $required, |
|
1590 | - 'label' => wp_kses_post( $label ), |
|
1591 | - 'label_type' => 'vertical', |
|
1592 | - 'help_text' => $help_text, |
|
1593 | - 'class' => 'getpaid-address-field wpinv_state', |
|
1594 | - 'wrap_class' => "$wrapper_class getpaid-address-field-wrapper__state", |
|
1595 | - 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state', |
|
1596 | - 'extra_attributes' => array( |
|
1597 | - 'autocomplete' => 'address-level1', |
|
1598 | - ), |
|
1584 | + 'options' => $states, |
|
1585 | + 'name' => esc_attr( $field_name ), |
|
1586 | + 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
1587 | + 'value' => sanitize_text_field( $state ), |
|
1588 | + 'placeholder' => $placeholder, |
|
1589 | + 'required' => $required, |
|
1590 | + 'label' => wp_kses_post( $label ), |
|
1591 | + 'label_type' => 'vertical', |
|
1592 | + 'help_text' => $help_text, |
|
1593 | + 'class' => 'getpaid-address-field wpinv_state', |
|
1594 | + 'wrap_class' => "$wrapper_class getpaid-address-field-wrapper__state", |
|
1595 | + 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state', |
|
1596 | + 'extra_attributes' => array( |
|
1597 | + 'autocomplete' => 'address-level1', |
|
1598 | + ), |
|
1599 | 1599 | ) |
1600 | 1600 | ); |
1601 | 1601 |
@@ -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,81 +231,81 @@ 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_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
301 | - $current = date( 'Y' ); |
|
302 | - $start_year = $current - absint( $years_before ); |
|
303 | - $end_year = $current + absint( $years_after ); |
|
304 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
300 | +function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
301 | + $current = date('Y'); |
|
302 | + $start_year = $current - absint($years_before); |
|
303 | + $end_year = $current + absint($years_after); |
|
304 | + $selected = empty($selected) ? date('Y') : $selected; |
|
305 | 305 | $options = array(); |
306 | 306 | |
307 | - while ( $start_year <= $end_year ) { |
|
308 | - $options[ absint( $start_year ) ] = $start_year; |
|
307 | + while ($start_year <= $end_year) { |
|
308 | + $options[absint($start_year)] = $start_year; |
|
309 | 309 | $start_year++; |
310 | 310 | } |
311 | 311 | |
@@ -322,25 +322,25 @@ discard block |
||
322 | 322 | return $output; |
323 | 323 | } |
324 | 324 | |
325 | -function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) { |
|
325 | +function wpinv_html_month_dropdown($name = 'month', $selected = 0) { |
|
326 | 326 | |
327 | 327 | $options = array( |
328 | - '1' => __( 'January', 'invoicing' ), |
|
329 | - '2' => __( 'February', 'invoicing' ), |
|
330 | - '3' => __( 'March', 'invoicing' ), |
|
331 | - '4' => __( 'April', 'invoicing' ), |
|
332 | - '5' => __( 'May', 'invoicing' ), |
|
333 | - '6' => __( 'June', 'invoicing' ), |
|
334 | - '7' => __( 'July', 'invoicing' ), |
|
335 | - '8' => __( 'August', 'invoicing' ), |
|
336 | - '9' => __( 'September', 'invoicing' ), |
|
337 | - '10' => __( 'October', 'invoicing' ), |
|
338 | - '11' => __( 'November', 'invoicing' ), |
|
339 | - '12' => __( 'December', 'invoicing' ), |
|
328 | + '1' => __('January', 'invoicing'), |
|
329 | + '2' => __('February', 'invoicing'), |
|
330 | + '3' => __('March', 'invoicing'), |
|
331 | + '4' => __('April', 'invoicing'), |
|
332 | + '5' => __('May', 'invoicing'), |
|
333 | + '6' => __('June', 'invoicing'), |
|
334 | + '7' => __('July', 'invoicing'), |
|
335 | + '8' => __('August', 'invoicing'), |
|
336 | + '9' => __('September', 'invoicing'), |
|
337 | + '10' => __('October', 'invoicing'), |
|
338 | + '11' => __('November', 'invoicing'), |
|
339 | + '12' => __('December', 'invoicing'), |
|
340 | 340 | ); |
341 | 341 | |
342 | 342 | // If no month is selected, default to the current month |
343 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
343 | + $selected = empty($selected) ? date('n') : $selected; |
|
344 | 344 | |
345 | 345 | $output = wpinv_html_select( |
346 | 346 | array( |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | return $output; |
356 | 356 | } |
357 | 357 | |
358 | -function wpinv_html_select( $args = array() ) { |
|
358 | +function wpinv_html_select($args = array()) { |
|
359 | 359 | $defaults = array( |
360 | 360 | 'options' => array(), |
361 | 361 | 'name' => null, |
@@ -364,8 +364,8 @@ discard block |
||
364 | 364 | 'selected' => 0, |
365 | 365 | 'placeholder' => null, |
366 | 366 | 'multiple' => false, |
367 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
368 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
367 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
368 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
369 | 369 | 'data' => array(), |
370 | 370 | 'onchange' => null, |
371 | 371 | 'required' => false, |
@@ -373,74 +373,74 @@ discard block |
||
373 | 373 | 'readonly' => false, |
374 | 374 | ); |
375 | 375 | |
376 | - $args = wp_parse_args( $args, $defaults ); |
|
376 | + $args = wp_parse_args($args, $defaults); |
|
377 | 377 | |
378 | 378 | $data_elements = ''; |
379 | - foreach ( $args['data'] as $key => $value ) { |
|
380 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
379 | + foreach ($args['data'] as $key => $value) { |
|
380 | + $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
381 | 381 | } |
382 | 382 | |
383 | - if ( $args['multiple'] ) { |
|
383 | + if ($args['multiple']) { |
|
384 | 384 | $multiple = ' MULTIPLE'; |
385 | 385 | } else { |
386 | 386 | $multiple = ''; |
387 | 387 | } |
388 | 388 | |
389 | - if ( $args['placeholder'] ) { |
|
389 | + if ($args['placeholder']) { |
|
390 | 390 | $placeholder = $args['placeholder']; |
391 | 391 | } else { |
392 | 392 | $placeholder = ''; |
393 | 393 | } |
394 | 394 | |
395 | 395 | $options = ''; |
396 | - if ( ! empty( $args['onchange'] ) ) { |
|
397 | - $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
396 | + if (!empty($args['onchange'])) { |
|
397 | + $options .= ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
398 | 398 | } |
399 | 399 | |
400 | - if ( ! empty( $args['required'] ) ) { |
|
400 | + if (!empty($args['required'])) { |
|
401 | 401 | $options .= ' required="required"'; |
402 | 402 | } |
403 | 403 | |
404 | - if ( ! empty( $args['disabled'] ) ) { |
|
404 | + if (!empty($args['disabled'])) { |
|
405 | 405 | $options .= ' disabled'; |
406 | 406 | } |
407 | 407 | |
408 | - if ( ! empty( $args['readonly'] ) ) { |
|
408 | + if (!empty($args['readonly'])) { |
|
409 | 409 | $options .= ' readonly'; |
410 | 410 | } |
411 | 411 | |
412 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
413 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>'; |
|
412 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
413 | + $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>'; |
|
414 | 414 | |
415 | - if ( $args['show_option_all'] ) { |
|
416 | - if ( $args['multiple'] ) { |
|
417 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
415 | + if ($args['show_option_all']) { |
|
416 | + if ($args['multiple']) { |
|
417 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
418 | 418 | } else { |
419 | - $selected = selected( $args['selected'], 0, false ); |
|
419 | + $selected = selected($args['selected'], 0, false); |
|
420 | 420 | } |
421 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
421 | + $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
422 | 422 | } |
423 | 423 | |
424 | - if ( ! empty( $args['options'] ) ) { |
|
424 | + if (!empty($args['options'])) { |
|
425 | 425 | |
426 | - if ( $args['show_option_none'] ) { |
|
427 | - if ( $args['multiple'] ) { |
|
428 | - $selected = selected( true, in_array( '', $args['selected'] ), false ); |
|
426 | + if ($args['show_option_none']) { |
|
427 | + if ($args['multiple']) { |
|
428 | + $selected = selected(true, in_array('', $args['selected']), false); |
|
429 | 429 | } else { |
430 | - $selected = selected( $args['selected'] === '', true, false ); |
|
430 | + $selected = selected($args['selected'] === '', true, false); |
|
431 | 431 | } |
432 | - $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
432 | + $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
433 | 433 | } |
434 | 434 | |
435 | - foreach ( $args['options'] as $key => $option ) { |
|
435 | + foreach ($args['options'] as $key => $option) { |
|
436 | 436 | |
437 | - if ( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
438 | - $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false ); |
|
437 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
438 | + $selected = selected(true, (bool) in_array($key, $args['selected']), false); |
|
439 | 439 | } else { |
440 | - $selected = selected( $args['selected'], $key, false ); |
|
440 | + $selected = selected($args['selected'], $key, false); |
|
441 | 441 | } |
442 | 442 | |
443 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
443 | + $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>'; |
|
444 | 444 | } |
445 | 445 | } |
446 | 446 | |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | return $output; |
450 | 450 | } |
451 | 451 | |
452 | -function wpinv_item_dropdown( $args = array() ) { |
|
452 | +function wpinv_item_dropdown($args = array()) { |
|
453 | 453 | $defaults = array( |
454 | 454 | 'name' => 'wpi_item', |
455 | 455 | 'id' => 'wpi_item', |
@@ -457,14 +457,14 @@ discard block |
||
457 | 457 | 'multiple' => false, |
458 | 458 | 'selected' => 0, |
459 | 459 | 'number' => -1, |
460 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
461 | - 'data' => array( 'search-type' => 'item' ), |
|
460 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
461 | + 'data' => array('search-type' => 'item'), |
|
462 | 462 | 'show_option_all' => false, |
463 | 463 | 'show_option_none' => false, |
464 | 464 | 'show_recurring' => false, |
465 | 465 | ); |
466 | 466 | |
467 | - $args = wp_parse_args( $args, $defaults ); |
|
467 | + $args = wp_parse_args($args, $defaults); |
|
468 | 468 | |
469 | 469 | $item_args = array( |
470 | 470 | 'post_type' => 'wpi_item', |
@@ -473,40 +473,40 @@ discard block |
||
473 | 473 | 'posts_per_page' => $args['number'], |
474 | 474 | ); |
475 | 475 | |
476 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
476 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
477 | 477 | |
478 | - $items = get_posts( $item_args ); |
|
478 | + $items = get_posts($item_args); |
|
479 | 479 | $options = array(); |
480 | - if ( $items ) { |
|
481 | - foreach ( $items as $item ) { |
|
482 | - $title = esc_html( $item->post_title ); |
|
480 | + if ($items) { |
|
481 | + foreach ($items as $item) { |
|
482 | + $title = esc_html($item->post_title); |
|
483 | 483 | |
484 | - if ( ! empty( $args['show_recurring'] ) ) { |
|
485 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
484 | + if (!empty($args['show_recurring'])) { |
|
485 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
486 | 486 | } |
487 | 487 | |
488 | - $options[ absint( $item->ID ) ] = $title; |
|
488 | + $options[absint($item->ID)] = $title; |
|
489 | 489 | } |
490 | 490 | } |
491 | 491 | |
492 | 492 | // This ensures that any selected items are included in the drop down |
493 | - if ( is_array( $args['selected'] ) ) { |
|
494 | - foreach ( $args['selected'] as $item ) { |
|
495 | - if ( ! in_array( $item, $options ) ) { |
|
496 | - $title = get_the_title( $item ); |
|
497 | - if ( ! empty( $args['show_recurring'] ) ) { |
|
498 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
493 | + if (is_array($args['selected'])) { |
|
494 | + foreach ($args['selected'] as $item) { |
|
495 | + if (!in_array($item, $options)) { |
|
496 | + $title = get_the_title($item); |
|
497 | + if (!empty($args['show_recurring'])) { |
|
498 | + $title .= wpinv_get_item_suffix($item, false); |
|
499 | 499 | } |
500 | - $options[ $item ] = $title; |
|
500 | + $options[$item] = $title; |
|
501 | 501 | } |
502 | 502 | } |
503 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
504 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
505 | - $title = get_the_title( $args['selected'] ); |
|
506 | - if ( ! empty( $args['show_recurring'] ) ) { |
|
507 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
503 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
504 | + if (!in_array($args['selected'], $options)) { |
|
505 | + $title = get_the_title($args['selected']); |
|
506 | + if (!empty($args['show_recurring'])) { |
|
507 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
508 | 508 | } |
509 | - $options[ $args['selected'] ] = get_the_title( $args['selected'] ); |
|
509 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
510 | 510 | } |
511 | 511 | } |
512 | 512 | |
@@ -543,16 +543,16 @@ discard block |
||
543 | 543 | ); |
544 | 544 | |
545 | 545 | $options = array(); |
546 | - if ( $items ) { |
|
547 | - foreach ( $items as $item ) { |
|
548 | - $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false ); |
|
546 | + if ($items) { |
|
547 | + foreach ($items as $item) { |
|
548 | + $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false); |
|
549 | 549 | } |
550 | 550 | } |
551 | 551 | |
552 | 552 | return $options; |
553 | 553 | } |
554 | 554 | |
555 | -function wpinv_html_checkbox( $args = array() ) { |
|
555 | +function wpinv_html_checkbox($args = array()) { |
|
556 | 556 | $defaults = array( |
557 | 557 | 'name' => null, |
558 | 558 | 'current' => null, |
@@ -563,17 +563,17 @@ discard block |
||
563 | 563 | ), |
564 | 564 | ); |
565 | 565 | |
566 | - $args = wp_parse_args( $args, $defaults ); |
|
566 | + $args = wp_parse_args($args, $defaults); |
|
567 | 567 | |
568 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
568 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
569 | 569 | $attr = ''; |
570 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
570 | + if (!empty($args['options']['disabled'])) { |
|
571 | 571 | $attr .= ' disabled="disabled"'; |
572 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
572 | + } elseif (!empty($args['options']['readonly'])) { |
|
573 | 573 | $attr .= ' readonly'; |
574 | 574 | } |
575 | 575 | |
576 | - $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 ) . ' />'; |
|
576 | + $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) . ' />'; |
|
577 | 577 | |
578 | 578 | return $output; |
579 | 579 | } |
@@ -581,34 +581,34 @@ discard block |
||
581 | 581 | /** |
582 | 582 | * Displays a hidden field. |
583 | 583 | */ |
584 | -function getpaid_hidden_field( $name, $value ) { |
|
585 | - echo "<input type='hidden' name='" . esc_attr( $name ) . "' value=' " . esc_attr( $value ) . "' />"; |
|
584 | +function getpaid_hidden_field($name, $value) { |
|
585 | + echo "<input type='hidden' name='" . esc_attr($name) . "' value=' " . esc_attr($value) . "' />"; |
|
586 | 586 | } |
587 | 587 | |
588 | 588 | /** |
589 | 589 | * Displays a submit field. |
590 | 590 | */ |
591 | -function getpaid_submit_field( $value, $name = 'submit', $class = 'btn-primary' ) { |
|
592 | - echo "<input type='submit' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "' class='btn " . esc_attr( $class ) . "' />"; |
|
591 | +function getpaid_submit_field($value, $name = 'submit', $class = 'btn-primary') { |
|
592 | + echo "<input type='submit' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' class='btn " . esc_attr($class) . "' />"; |
|
593 | 593 | } |
594 | 594 | |
595 | -function wpinv_html_text( $args = array() ) { |
|
595 | +function wpinv_html_text($args = array()) { |
|
596 | 596 | // Backwards compatibility |
597 | - if ( func_num_args() > 1 ) { |
|
597 | + if (func_num_args() > 1) { |
|
598 | 598 | $args = func_get_args(); |
599 | 599 | |
600 | 600 | $name = $args[0]; |
601 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
602 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
603 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
601 | + $value = isset($args[1]) ? $args[1] : ''; |
|
602 | + $label = isset($args[2]) ? $args[2] : ''; |
|
603 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
604 | 604 | } |
605 | 605 | |
606 | 606 | $defaults = array( |
607 | 607 | 'id' => '', |
608 | - 'name' => isset( $name ) ? $name : 'text', |
|
609 | - 'value' => isset( $value ) ? $value : null, |
|
610 | - 'label' => isset( $label ) ? $label : null, |
|
611 | - 'desc' => isset( $desc ) ? $desc : null, |
|
608 | + 'name' => isset($name) ? $name : 'text', |
|
609 | + 'value' => isset($value) ? $value : null, |
|
610 | + 'label' => isset($label) ? $label : null, |
|
611 | + 'desc' => isset($desc) ? $desc : null, |
|
612 | 612 | 'placeholder' => '', |
613 | 613 | 'class' => 'regular-text', |
614 | 614 | 'disabled' => false, |
@@ -618,41 +618,41 @@ discard block |
||
618 | 618 | 'data' => false, |
619 | 619 | ); |
620 | 620 | |
621 | - $args = wp_parse_args( $args, $defaults ); |
|
621 | + $args = wp_parse_args($args, $defaults); |
|
622 | 622 | |
623 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
623 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
624 | 624 | $options = ''; |
625 | - if ( $args['required'] ) { |
|
625 | + if ($args['required']) { |
|
626 | 626 | $options .= ' required="required"'; |
627 | 627 | } |
628 | - if ( $args['readonly'] ) { |
|
628 | + if ($args['readonly']) { |
|
629 | 629 | $options .= ' readonly'; |
630 | 630 | } |
631 | - if ( $args['readonly'] ) { |
|
631 | + if ($args['readonly']) { |
|
632 | 632 | $options .= ' readonly'; |
633 | 633 | } |
634 | 634 | |
635 | 635 | $data = ''; |
636 | - if ( ! empty( $args['data'] ) ) { |
|
637 | - foreach ( $args['data'] as $key => $value ) { |
|
638 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
636 | + if (!empty($args['data'])) { |
|
637 | + foreach ($args['data'] as $key => $value) { |
|
638 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
639 | 639 | } |
640 | 640 | } |
641 | 641 | |
642 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
643 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
644 | - if ( ! empty( $args['desc'] ) ) { |
|
645 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
642 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
643 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
644 | + if (!empty($args['desc'])) { |
|
645 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
646 | 646 | } |
647 | 647 | |
648 | - $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 ) . '/>'; |
|
648 | + $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) . '/>'; |
|
649 | 649 | |
650 | 650 | $output .= '</span>'; |
651 | 651 | |
652 | 652 | return $output; |
653 | 653 | } |
654 | 654 | |
655 | -function wpinv_html_textarea( $args = array() ) { |
|
655 | +function wpinv_html_textarea($args = array()) { |
|
656 | 656 | $defaults = array( |
657 | 657 | 'name' => 'textarea', |
658 | 658 | 'value' => null, |
@@ -663,31 +663,31 @@ discard block |
||
663 | 663 | 'placeholder' => '', |
664 | 664 | ); |
665 | 665 | |
666 | - $args = wp_parse_args( $args, $defaults ); |
|
666 | + $args = wp_parse_args($args, $defaults); |
|
667 | 667 | |
668 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
668 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
669 | 669 | $disabled = ''; |
670 | - if ( $args['disabled'] ) { |
|
670 | + if ($args['disabled']) { |
|
671 | 671 | $disabled = ' disabled="disabled"'; |
672 | 672 | } |
673 | 673 | |
674 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
675 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
676 | - $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>'; |
|
674 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
675 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
676 | + $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>'; |
|
677 | 677 | |
678 | - if ( ! empty( $args['desc'] ) ) { |
|
679 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
678 | + if (!empty($args['desc'])) { |
|
679 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
680 | 680 | } |
681 | 681 | $output .= '</span>'; |
682 | 682 | |
683 | 683 | return $output; |
684 | 684 | } |
685 | 685 | |
686 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
686 | +function wpinv_html_ajax_user_search($args = array()) { |
|
687 | 687 | $defaults = array( |
688 | 688 | 'name' => 'user_id', |
689 | 689 | 'value' => null, |
690 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
690 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
691 | 691 | 'label' => null, |
692 | 692 | 'desc' => null, |
693 | 693 | 'class' => '', |
@@ -696,13 +696,13 @@ discard block |
||
696 | 696 | 'data' => false, |
697 | 697 | ); |
698 | 698 | |
699 | - $args = wp_parse_args( $args, $defaults ); |
|
699 | + $args = wp_parse_args($args, $defaults); |
|
700 | 700 | |
701 | 701 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
702 | 702 | |
703 | 703 | $output = '<span class="wpinv_user_search_wrap">'; |
704 | - $output .= wpinv_html_text( $args ); |
|
705 | - $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>'; |
|
704 | + $output .= wpinv_html_text($args); |
|
705 | + $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>'; |
|
706 | 706 | $output .= '</span>'; |
707 | 707 | |
708 | 708 | return $output; |
@@ -713,44 +713,44 @@ discard block |
||
713 | 713 | * |
714 | 714 | * @param string $template the template that is currently being used. |
715 | 715 | */ |
716 | -function wpinv_template( $template ) { |
|
716 | +function wpinv_template($template) { |
|
717 | 717 | global $post; |
718 | 718 | |
719 | - if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) { |
|
719 | + if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) { |
|
720 | 720 | |
721 | 721 | // If the user can view this invoice, display it. |
722 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
722 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
723 | 723 | |
724 | - return wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
724 | + return wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
725 | 725 | |
726 | 726 | // Else display an error message. |
727 | 727 | } else { |
728 | 728 | |
729 | - return wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
729 | + return wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
730 | 730 | |
731 | 731 | } |
732 | 732 | } |
733 | 733 | |
734 | 734 | return $template; |
735 | 735 | } |
736 | -add_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
736 | +add_filter('template_include', 'wpinv_template', 10, 1); |
|
737 | 737 | |
738 | 738 | function wpinv_get_business_address() { |
739 | 739 | $business_address = wpinv_store_address(); |
740 | - $business_address = ! empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
740 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
741 | 741 | |
742 | 742 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
743 | 743 | |
744 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
744 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | /** |
748 | 748 | * Displays the company address. |
749 | 749 | */ |
750 | 750 | function wpinv_display_from_address() { |
751 | - wpinv_get_template( 'invoice/company-address.php' ); |
|
751 | + wpinv_get_template('invoice/company-address.php'); |
|
752 | 752 | } |
753 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 ); |
|
753 | +add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10); |
|
754 | 754 | |
755 | 755 | /** |
756 | 756 | * Generates a watermark text for an invoice. |
@@ -758,9 +758,9 @@ discard block |
||
758 | 758 | * @param WPInv_Invoice $invoice |
759 | 759 | * @return string |
760 | 760 | */ |
761 | -function wpinv_watermark( $invoice ) { |
|
762 | - $watermark = wpinv_get_watermark( $invoice ); |
|
763 | - return apply_filters( 'wpinv_get_watermark', $watermark, $invoice ); |
|
761 | +function wpinv_watermark($invoice) { |
|
762 | + $watermark = wpinv_get_watermark($invoice); |
|
763 | + return apply_filters('wpinv_get_watermark', $watermark, $invoice); |
|
764 | 764 | } |
765 | 765 | |
766 | 766 | /** |
@@ -769,37 +769,37 @@ discard block |
||
769 | 769 | * @param WPInv_Invoice $invoice |
770 | 770 | * @return string |
771 | 771 | */ |
772 | -function wpinv_get_watermark( $invoice ) { |
|
772 | +function wpinv_get_watermark($invoice) { |
|
773 | 773 | return $invoice->get_status_nicename(); |
774 | 774 | } |
775 | 775 | |
776 | 776 | /** |
777 | 777 | * @deprecated |
778 | 778 | */ |
779 | -function wpinv_display_invoice_details( $invoice ) { |
|
780 | - return getpaid_invoice_meta( $invoice ); |
|
779 | +function wpinv_display_invoice_details($invoice) { |
|
780 | + return getpaid_invoice_meta($invoice); |
|
781 | 781 | } |
782 | 782 | |
783 | 783 | /** |
784 | 784 | * Displays invoice meta. |
785 | 785 | */ |
786 | -function getpaid_invoice_meta( $invoice ) { |
|
786 | +function getpaid_invoice_meta($invoice) { |
|
787 | 787 | |
788 | - $invoice = new WPInv_Invoice( $invoice ); |
|
788 | + $invoice = new WPInv_Invoice($invoice); |
|
789 | 789 | |
790 | 790 | // Ensure that we have an invoice. |
791 | - if ( 0 == $invoice->get_id() ) { |
|
791 | + if (0 == $invoice->get_id()) { |
|
792 | 792 | return; |
793 | 793 | } |
794 | 794 | |
795 | 795 | // Get the invoice meta. |
796 | - $meta = getpaid_get_invoice_meta( $invoice ); |
|
796 | + $meta = getpaid_get_invoice_meta($invoice); |
|
797 | 797 | |
798 | 798 | // Display the meta. |
799 | - wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) ); |
|
799 | + wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta')); |
|
800 | 800 | |
801 | 801 | } |
802 | -add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 ); |
|
802 | +add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10); |
|
803 | 803 | |
804 | 804 | /** |
805 | 805 | * Retrieves the address markup to use on Invoices. |
@@ -811,29 +811,29 @@ discard block |
||
811 | 811 | * @param string $separator How to separate address lines. |
812 | 812 | * @return string |
813 | 813 | */ |
814 | -function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) { |
|
814 | +function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') { |
|
815 | 815 | |
816 | 816 | // Retrieve the address markup... |
817 | - $country = empty( $billing_details['country'] ) ? '' : $billing_details['country']; |
|
818 | - $format = wpinv_get_full_address_format( $country ); |
|
817 | + $country = empty($billing_details['country']) ? '' : $billing_details['country']; |
|
818 | + $format = wpinv_get_full_address_format($country); |
|
819 | 819 | |
820 | 820 | // ... and the replacements. |
821 | - $replacements = wpinv_get_invoice_address_replacements( $billing_details ); |
|
821 | + $replacements = wpinv_get_invoice_address_replacements($billing_details); |
|
822 | 822 | |
823 | - $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
|
823 | + $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format); |
|
824 | 824 | |
825 | 825 | // Remove unavailable tags. |
826 | - $formatted_address = preg_replace( '/\{\{\w+\}\}/', '', $formatted_address ); |
|
826 | + $formatted_address = preg_replace('/\{\{\w+\}\}/', '', $formatted_address); |
|
827 | 827 | |
828 | 828 | // Clean up white space. |
829 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
830 | - $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
|
829 | + $formatted_address = preg_replace('/ +/', ' ', trim($formatted_address)); |
|
830 | + $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address); |
|
831 | 831 | |
832 | 832 | // Break newlines apart and remove empty lines/trim commas and white space. |
833 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
833 | + $formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address))); |
|
834 | 834 | |
835 | 835 | // Add html breaks. |
836 | - $formatted_address = implode( $separator, $formatted_address ); |
|
836 | + $formatted_address = implode($separator, $formatted_address); |
|
837 | 837 | |
838 | 838 | // We're done! |
839 | 839 | return $formatted_address; |
@@ -845,119 +845,119 @@ discard block |
||
845 | 845 | * |
846 | 846 | * @param WPInv_Invoice $invoice |
847 | 847 | */ |
848 | -function wpinv_display_to_address( $invoice = 0 ) { |
|
849 | - if ( ! empty( $invoice ) ) { |
|
850 | - wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) ); |
|
848 | +function wpinv_display_to_address($invoice = 0) { |
|
849 | + if (!empty($invoice)) { |
|
850 | + wpinv_get_template('invoice/billing-address.php', compact('invoice')); |
|
851 | 851 | } |
852 | 852 | } |
853 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 ); |
|
853 | +add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40); |
|
854 | 854 | |
855 | 855 | |
856 | 856 | /** |
857 | 857 | * Displays invoice line items. |
858 | 858 | */ |
859 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
859 | +function wpinv_display_line_items($invoice_id = 0) { |
|
860 | 860 | |
861 | 861 | // Prepare the invoice. |
862 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
862 | + $invoice = new WPInv_Invoice($invoice_id); |
|
863 | 863 | |
864 | 864 | // Abort if there is no invoice. |
865 | - if ( 0 == $invoice->get_id() ) { |
|
865 | + if (0 == $invoice->get_id()) { |
|
866 | 866 | return; |
867 | 867 | } |
868 | 868 | |
869 | 869 | // Line item columns. |
870 | - $columns = getpaid_invoice_item_columns( $invoice ); |
|
871 | - $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice ); |
|
870 | + $columns = getpaid_invoice_item_columns($invoice); |
|
871 | + $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice); |
|
872 | 872 | |
873 | - wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) ); |
|
873 | + wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns')); |
|
874 | 874 | } |
875 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 ); |
|
875 | +add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10); |
|
876 | 876 | |
877 | 877 | /** |
878 | 878 | * Displays invoice subscriptions. |
879 | 879 | * |
880 | 880 | * @param WPInv_Invoice $invoice |
881 | 881 | */ |
882 | -function getpaid_display_invoice_subscriptions( $invoice ) { |
|
882 | +function getpaid_display_invoice_subscriptions($invoice) { |
|
883 | 883 | |
884 | 884 | // Subscriptions. |
885 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
885 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
886 | 886 | |
887 | - if ( empty( $subscriptions ) || ! $invoice->is_recurring() ) { |
|
887 | + if (empty($subscriptions) || !$invoice->is_recurring()) { |
|
888 | 888 | return; |
889 | 889 | } |
890 | 890 | |
891 | - $main_subscription = getpaid_get_invoice_subscription( $invoice ); |
|
891 | + $main_subscription = getpaid_get_invoice_subscription($invoice); |
|
892 | 892 | |
893 | 893 | // Display related subscriptions. |
894 | - if ( is_array( $subscriptions ) ) { |
|
895 | - printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Subscriptions', 'invoicing' ) ); |
|
896 | - getpaid_admin_subscription_related_subscriptions_metabox( $main_subscription, false ); |
|
894 | + if (is_array($subscriptions)) { |
|
895 | + printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Subscriptions', 'invoicing')); |
|
896 | + getpaid_admin_subscription_related_subscriptions_metabox($main_subscription, false); |
|
897 | 897 | } |
898 | 898 | |
899 | - if ( $main_subscription->get_total_payments() > 1 ) { |
|
900 | - printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Invoices', 'invoicing' ) ); |
|
901 | - getpaid_admin_subscription_invoice_details_metabox( $main_subscription, false ); |
|
899 | + if ($main_subscription->get_total_payments() > 1) { |
|
900 | + printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Invoices', 'invoicing')); |
|
901 | + getpaid_admin_subscription_invoice_details_metabox($main_subscription, false); |
|
902 | 902 | } |
903 | 903 | |
904 | 904 | } |
905 | -add_action( 'getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55 ); |
|
906 | -add_action( 'wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11 ); |
|
905 | +add_action('getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55); |
|
906 | +add_action('wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11); |
|
907 | 907 | |
908 | 908 | /** |
909 | 909 | * Displays invoice notices on invoices. |
910 | 910 | */ |
911 | 911 | function wpinv_display_invoice_notice() { |
912 | 912 | |
913 | - $label = wpinv_get_option( 'vat_invoice_notice_label' ); |
|
914 | - $notice = wpinv_get_option( 'vat_invoice_notice' ); |
|
913 | + $label = wpinv_get_option('vat_invoice_notice_label'); |
|
914 | + $notice = wpinv_get_option('vat_invoice_notice'); |
|
915 | 915 | |
916 | - if ( empty( $label ) && empty( $notice ) ) { |
|
916 | + if (empty($label) && empty($notice)) { |
|
917 | 917 | return; |
918 | 918 | } |
919 | 919 | |
920 | 920 | echo '<div class="mt-4 mb-4 wpinv-vat-notice">'; |
921 | 921 | |
922 | - if ( ! empty( $label ) ) { |
|
923 | - $label = esc_html( $label ); |
|
922 | + if (!empty($label)) { |
|
923 | + $label = esc_html($label); |
|
924 | 924 | echo "<h5>$label</h5>"; |
925 | 925 | } |
926 | 926 | |
927 | - if ( ! empty( $notice ) ) { |
|
928 | - echo '<small class="form-text text-muted">' . wp_kses_post( wpautop( wptexturize( $notice ) ) ) . '</small>'; |
|
927 | + if (!empty($notice)) { |
|
928 | + echo '<small class="form-text text-muted">' . wp_kses_post(wpautop(wptexturize($notice))) . '</small>'; |
|
929 | 929 | } |
930 | 930 | |
931 | 931 | echo '</div>'; |
932 | 932 | } |
933 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 ); |
|
933 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100); |
|
934 | 934 | |
935 | 935 | /** |
936 | 936 | * @param WPInv_Invoice $invoice |
937 | 937 | */ |
938 | -function wpinv_display_invoice_notes( $invoice ) { |
|
938 | +function wpinv_display_invoice_notes($invoice) { |
|
939 | 939 | |
940 | 940 | // Retrieve the notes. |
941 | - $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' ); |
|
941 | + $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer'); |
|
942 | 942 | |
943 | 943 | // Abort if we have non. |
944 | - if ( empty( $notes ) ) { |
|
944 | + if (empty($notes)) { |
|
945 | 945 | return; |
946 | 946 | } |
947 | 947 | |
948 | 948 | // Echo the note. |
949 | 949 | echo '<div class="getpaid-invoice-notes-wrapper position-relative my-4">'; |
950 | - echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . __( 'Notes', 'invoicing' ) . '</h2>'; |
|
950 | + echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . __('Notes', 'invoicing') . '</h2>'; |
|
951 | 951 | echo '<ul class="getpaid-invoice-notes text-break overflow-auto list-unstyled p-0 m-0">'; |
952 | 952 | |
953 | - foreach ( $notes as $note ) { |
|
954 | - wpinv_get_invoice_note_line_item( $note ); |
|
953 | + foreach ($notes as $note) { |
|
954 | + wpinv_get_invoice_note_line_item($note); |
|
955 | 955 | } |
956 | 956 | |
957 | 957 | echo '</ul>'; |
958 | 958 | echo '</div>'; |
959 | 959 | } |
960 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 ); |
|
960 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60); |
|
961 | 961 | |
962 | 962 | /** |
963 | 963 | * Loads scripts on our invoice templates. |
@@ -965,32 +965,32 @@ discard block |
||
965 | 965 | function wpinv_display_style() { |
966 | 966 | |
967 | 967 | // Make sure that all scripts have been loaded. |
968 | - if ( ! did_action( 'wp_enqueue_scripts' ) ) { |
|
969 | - do_action( 'wp_enqueue_scripts' ); |
|
968 | + if (!did_action('wp_enqueue_scripts')) { |
|
969 | + do_action('wp_enqueue_scripts'); |
|
970 | 970 | } |
971 | 971 | |
972 | 972 | // Register the invoices style. |
973 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) ); |
|
973 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css')); |
|
974 | 974 | |
975 | 975 | // Load required styles |
976 | - wp_print_styles( 'wpinv-single-style' ); |
|
977 | - wp_print_styles( 'ayecode-ui' ); |
|
976 | + wp_print_styles('wpinv-single-style'); |
|
977 | + wp_print_styles('ayecode-ui'); |
|
978 | 978 | |
979 | 979 | // Maybe load custom css. |
980 | - $custom_css = wpinv_get_option( 'template_custom_css' ); |
|
980 | + $custom_css = wpinv_get_option('template_custom_css'); |
|
981 | 981 | |
982 | - if ( isset( $custom_css ) && ! empty( $custom_css ) ) { |
|
983 | - $custom_css = wp_kses( $custom_css, array( '\'', '\"' ) ); |
|
984 | - $custom_css = str_replace( '>', '>', $custom_css ); |
|
982 | + if (isset($custom_css) && !empty($custom_css)) { |
|
983 | + $custom_css = wp_kses($custom_css, array('\'', '\"')); |
|
984 | + $custom_css = str_replace('>', '>', $custom_css); |
|
985 | 985 | echo '<style type="text/css">'; |
986 | - echo wp_kses_post( $custom_css ); |
|
986 | + echo wp_kses_post($custom_css); |
|
987 | 987 | echo '</style>'; |
988 | 988 | } |
989 | 989 | |
990 | 990 | wp_site_icon(); |
991 | 991 | } |
992 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
993 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
992 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
993 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
994 | 994 | |
995 | 995 | |
996 | 996 | /** |
@@ -1002,41 +1002,41 @@ discard block |
||
1002 | 1002 | // Retrieve the current invoice. |
1003 | 1003 | $invoice_id = getpaid_get_current_invoice_id(); |
1004 | 1004 | |
1005 | - if ( empty( $invoice_id ) ) { |
|
1005 | + if (empty($invoice_id)) { |
|
1006 | 1006 | |
1007 | 1007 | return aui()->alert( |
1008 | 1008 | array( |
1009 | 1009 | 'type' => 'warning', |
1010 | - 'content' => __( 'Invalid invoice', 'invoicing' ), |
|
1010 | + 'content' => __('Invalid invoice', 'invoicing'), |
|
1011 | 1011 | ) |
1012 | 1012 | ); |
1013 | 1013 | |
1014 | 1014 | } |
1015 | 1015 | |
1016 | 1016 | // Can the user view this invoice? |
1017 | - if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) { |
|
1017 | + if (!wpinv_user_can_view_invoice($invoice_id)) { |
|
1018 | 1018 | |
1019 | 1019 | return aui()->alert( |
1020 | 1020 | array( |
1021 | 1021 | 'type' => 'warning', |
1022 | - 'content' => __( 'You are not allowed to view this invoice', 'invoicing' ), |
|
1022 | + 'content' => __('You are not allowed to view this invoice', 'invoicing'), |
|
1023 | 1023 | ) |
1024 | 1024 | ); |
1025 | 1025 | |
1026 | 1026 | } |
1027 | 1027 | |
1028 | 1028 | // Ensure that it is not yet paid for. |
1029 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
1029 | + $invoice = new WPInv_Invoice($invoice_id); |
|
1030 | 1030 | |
1031 | 1031 | // Maybe mark it as viewed. |
1032 | - getpaid_maybe_mark_invoice_as_viewed( $invoice ); |
|
1032 | + getpaid_maybe_mark_invoice_as_viewed($invoice); |
|
1033 | 1033 | |
1034 | - if ( $invoice->is_paid() ) { |
|
1034 | + if ($invoice->is_paid()) { |
|
1035 | 1035 | |
1036 | 1036 | return aui()->alert( |
1037 | 1037 | array( |
1038 | 1038 | 'type' => 'success', |
1039 | - 'content' => __( 'This invoice has already been paid.', 'invoicing' ), |
|
1039 | + 'content' => __('This invoice has already been paid.', 'invoicing'), |
|
1040 | 1040 | ) |
1041 | 1041 | ); |
1042 | 1042 | |
@@ -1046,15 +1046,15 @@ discard block |
||
1046 | 1046 | $wpi_checkout_id = $invoice_id; |
1047 | 1047 | |
1048 | 1048 | // Retrieve appropriate payment form. |
1049 | - $payment_form = new GetPaid_Payment_Form( $invoice->get_meta( 'force_payment_form' ) ); |
|
1050 | - $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1049 | + $payment_form = new GetPaid_Payment_Form($invoice->get_meta('force_payment_form')); |
|
1050 | + $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1051 | 1051 | |
1052 | - if ( ! $payment_form->exists() ) { |
|
1052 | + if (!$payment_form->exists()) { |
|
1053 | 1053 | |
1054 | 1054 | return aui()->alert( |
1055 | 1055 | array( |
1056 | 1056 | 'type' => 'warning', |
1057 | - 'content' => __( 'Error loading the payment form', 'invoicing' ), |
|
1057 | + 'content' => __('Error loading the payment form', 'invoicing'), |
|
1058 | 1058 | ) |
1059 | 1059 | ); |
1060 | 1060 | |
@@ -1063,29 +1063,29 @@ discard block |
||
1063 | 1063 | // Set the invoice. |
1064 | 1064 | $payment_form->invoice = $invoice; |
1065 | 1065 | |
1066 | - if ( ! $payment_form->is_default() ) { |
|
1066 | + if (!$payment_form->is_default()) { |
|
1067 | 1067 | |
1068 | 1068 | $items = array(); |
1069 | 1069 | $item_ids = array(); |
1070 | 1070 | |
1071 | - foreach ( $invoice->get_items() as $item ) { |
|
1072 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
1071 | + foreach ($invoice->get_items() as $item) { |
|
1072 | + if (!in_array($item->get_id(), $item_ids)) { |
|
1073 | 1073 | $item_ids[] = $item->get_id(); |
1074 | 1074 | $items[] = $item; |
1075 | 1075 | } |
1076 | 1076 | } |
1077 | 1077 | |
1078 | - foreach ( $payment_form->get_items() as $item ) { |
|
1079 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
1078 | + foreach ($payment_form->get_items() as $item) { |
|
1079 | + if (!in_array($item->get_id(), $item_ids)) { |
|
1080 | 1080 | $item_ids[] = $item->get_id(); |
1081 | 1081 | $items[] = $item; |
1082 | 1082 | } |
1083 | 1083 | } |
1084 | 1084 | |
1085 | - $payment_form->set_items( $items ); |
|
1085 | + $payment_form->set_items($items); |
|
1086 | 1086 | |
1087 | 1087 | } else { |
1088 | - $payment_form->set_items( $invoice->get_items() ); |
|
1088 | + $payment_form->set_items($invoice->get_items()); |
|
1089 | 1089 | } |
1090 | 1090 | |
1091 | 1091 | // Generate the html. |
@@ -1094,7 +1094,7 @@ discard block |
||
1094 | 1094 | } |
1095 | 1095 | |
1096 | 1096 | function wpinv_empty_cart_message() { |
1097 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1097 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
1098 | 1098 | } |
1099 | 1099 | |
1100 | 1100 | /** |
@@ -1112,76 +1112,76 @@ discard block |
||
1112 | 1112 | true |
1113 | 1113 | ); |
1114 | 1114 | } |
1115 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
1115 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
1116 | 1116 | |
1117 | 1117 | /** |
1118 | 1118 | * Filters the receipt page. |
1119 | 1119 | */ |
1120 | -function wpinv_filter_success_page_content( $content ) { |
|
1120 | +function wpinv_filter_success_page_content($content) { |
|
1121 | 1121 | |
1122 | 1122 | // Maybe abort early. |
1123 | - if ( is_admin() || ! is_singular() || ! in_the_loop() || ! is_main_query() || is_preview() ) { |
|
1123 | + if (is_admin() || !is_singular() || !in_the_loop() || !is_main_query() || is_preview()) { |
|
1124 | 1124 | return $content; |
1125 | 1125 | } |
1126 | 1126 | |
1127 | 1127 | // Ensure this is our page. |
1128 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
1128 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
1129 | 1129 | |
1130 | - $gateway = sanitize_text_field( $_GET['payment-confirm'] ); |
|
1131 | - return apply_filters( "wpinv_payment_confirm_$gateway", $content ); |
|
1130 | + $gateway = sanitize_text_field($_GET['payment-confirm']); |
|
1131 | + return apply_filters("wpinv_payment_confirm_$gateway", $content); |
|
1132 | 1132 | |
1133 | 1133 | } |
1134 | 1134 | |
1135 | 1135 | return $content; |
1136 | 1136 | } |
1137 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
1137 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
1138 | 1138 | |
1139 | -function wpinv_invoice_link( $invoice_id ) { |
|
1140 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1139 | +function wpinv_invoice_link($invoice_id) { |
|
1140 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1141 | 1141 | |
1142 | - if ( empty( $invoice ) ) { |
|
1142 | + if (empty($invoice)) { |
|
1143 | 1143 | return null; |
1144 | 1144 | } |
1145 | 1145 | |
1146 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
1146 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
1147 | 1147 | |
1148 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
1148 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
1149 | 1149 | } |
1150 | 1150 | |
1151 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
1152 | - if ( empty( $note ) ) { |
|
1151 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
1152 | + if (empty($note)) { |
|
1153 | 1153 | return null; |
1154 | 1154 | } |
1155 | 1155 | |
1156 | - if ( is_int( $note ) ) { |
|
1157 | - $note = get_comment( $note ); |
|
1156 | + if (is_int($note)) { |
|
1157 | + $note = get_comment($note); |
|
1158 | 1158 | } |
1159 | 1159 | |
1160 | - if ( ! ( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
1160 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
1161 | 1161 | return null; |
1162 | 1162 | } |
1163 | 1163 | |
1164 | - $note_classes = array( 'note' ); |
|
1165 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
1164 | + $note_classes = array('note'); |
|
1165 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
1166 | 1166 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
1167 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
1168 | - $note_classes = ! empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
1167 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
1168 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
1169 | 1169 | |
1170 | 1170 | ob_start(); |
1171 | 1171 | ?> |
1172 | - <li rel="<?php echo absint( $note->comment_ID ); ?>" class="<?php echo esc_attr( $note_classes ); ?> mb-2"> |
|
1172 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mb-2"> |
|
1173 | 1173 | <div class="note_content"> |
1174 | 1174 | |
1175 | - <?php echo wptexturize( wp_kses_post( $note->comment_content ) ); ?> |
|
1175 | + <?php echo wptexturize(wp_kses_post($note->comment_content)); ?> |
|
1176 | 1176 | |
1177 | - <?php if ( ! is_admin() ) : ?> |
|
1177 | + <?php if (!is_admin()) : ?> |
|
1178 | 1178 | <em class="small form-text text-muted mt-0"> |
1179 | 1179 | <?php |
1180 | 1180 | printf( |
1181 | - __( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
1181 | + __('%1$s - %2$s at %3$s', 'invoicing'), |
|
1182 | 1182 | $note->comment_author, |
1183 | - getpaid_format_date_value( $note->comment_date ), |
|
1184 | - date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) |
|
1183 | + getpaid_format_date_value($note->comment_date), |
|
1184 | + date_i18n(get_option('time_format'), strtotime($note->comment_date)) |
|
1185 | 1185 | ); |
1186 | 1186 | ?> |
1187 | 1187 | </em> |
@@ -1189,21 +1189,21 @@ discard block |
||
1189 | 1189 | |
1190 | 1190 | </div> |
1191 | 1191 | |
1192 | - <?php if ( is_admin() ) : ?> |
|
1192 | + <?php if (is_admin()) : ?> |
|
1193 | 1193 | |
1194 | 1194 | <p class="meta px-4 py-2"> |
1195 | - <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>"> |
|
1195 | + <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>"> |
|
1196 | 1196 | <?php |
1197 | 1197 | printf( |
1198 | - __( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
1198 | + __('%1$s - %2$s at %3$s', 'invoicing'), |
|
1199 | 1199 | $note->comment_author, |
1200 | - getpaid_format_date_value( $note->comment_date ), |
|
1201 | - date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) |
|
1200 | + getpaid_format_date_value($note->comment_date), |
|
1201 | + date_i18n(get_option('time_format'), strtotime($note->comment_date)) |
|
1202 | 1202 | ); |
1203 | 1203 | ?> |
1204 | 1204 | </abbr> |
1205 | - <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?> |
|
1206 | - <a href="#" class="delete_note"><?php esc_html_e( 'Delete note', 'invoicing' ); ?></a> |
|
1205 | + <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?> |
|
1206 | + <a href="#" class="delete_note"><?php esc_html_e('Delete note', 'invoicing'); ?></a> |
|
1207 | 1207 | <?php } ?> |
1208 | 1208 | </p> |
1209 | 1209 | |
@@ -1212,10 +1212,10 @@ discard block |
||
1212 | 1212 | </li> |
1213 | 1213 | <?php |
1214 | 1214 | $note_content = ob_get_clean(); |
1215 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
1215 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
1216 | 1216 | |
1217 | - if ( $echo ) { |
|
1218 | - echo wp_kses_post( $note_content ); |
|
1217 | + if ($echo) { |
|
1218 | + echo wp_kses_post($note_content); |
|
1219 | 1219 | } else { |
1220 | 1220 | return $note_content; |
1221 | 1221 | } |
@@ -1228,43 +1228,43 @@ discard block |
||
1228 | 1228 | * @return string |
1229 | 1229 | */ |
1230 | 1230 | function wpinv_get_policy_text() { |
1231 | - $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 ); |
|
1231 | + $privacy_page_id = get_option('wp_page_for_privacy_policy', 0); |
|
1232 | 1232 | |
1233 | - $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]' ) ); |
|
1233 | + $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]')); |
|
1234 | 1234 | |
1235 | - if ( ! $privacy_page_id ) { |
|
1236 | - $privacy_page_id = wpinv_get_option( 'privacy_page', 0 ); |
|
1235 | + if (!$privacy_page_id) { |
|
1236 | + $privacy_page_id = wpinv_get_option('privacy_page', 0); |
|
1237 | 1237 | } |
1238 | 1238 | |
1239 | - $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' ); |
|
1239 | + $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'); |
|
1240 | 1240 | |
1241 | 1241 | $find_replace = array( |
1242 | 1242 | '[wpinv_privacy_policy]' => $privacy_link, |
1243 | 1243 | ); |
1244 | 1244 | |
1245 | - $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); |
|
1245 | + $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text); |
|
1246 | 1246 | |
1247 | - return wp_kses_post( wpautop( $privacy_text ) ); |
|
1247 | + return wp_kses_post(wpautop($privacy_text)); |
|
1248 | 1248 | } |
1249 | 1249 | |
1250 | 1250 | function wpinv_oxygen_fix_conflict() { |
1251 | 1251 | global $ct_ignore_post_types; |
1252 | 1252 | |
1253 | - if ( ! is_array( $ct_ignore_post_types ) ) { |
|
1253 | + if (!is_array($ct_ignore_post_types)) { |
|
1254 | 1254 | $ct_ignore_post_types = array(); |
1255 | 1255 | } |
1256 | 1256 | |
1257 | - $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form' ); |
|
1257 | + $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form'); |
|
1258 | 1258 | |
1259 | - foreach ( $post_types as $post_type ) { |
|
1259 | + foreach ($post_types as $post_type) { |
|
1260 | 1260 | $ct_ignore_post_types[] = $post_type; |
1261 | 1261 | |
1262 | 1262 | // Ignore post type |
1263 | - add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 ); |
|
1263 | + add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999); |
|
1264 | 1264 | } |
1265 | 1265 | |
1266 | - remove_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
1267 | - add_filter( 'template_include', 'wpinv_template', 999, 1 ); |
|
1266 | + remove_filter('template_include', 'wpinv_template', 10, 1); |
|
1267 | + add_filter('template_include', 'wpinv_template', 999, 1); |
|
1268 | 1268 | } |
1269 | 1269 | |
1270 | 1270 | /** |
@@ -1272,10 +1272,10 @@ discard block |
||
1272 | 1272 | * |
1273 | 1273 | * @param GetPaid_Payment_Form $form |
1274 | 1274 | */ |
1275 | -function getpaid_display_payment_form( $form ) { |
|
1275 | +function getpaid_display_payment_form($form) { |
|
1276 | 1276 | |
1277 | - if ( is_numeric( $form ) ) { |
|
1278 | - $form = new GetPaid_Payment_Form( $form ); |
|
1277 | + if (is_numeric($form)) { |
|
1278 | + $form = new GetPaid_Payment_Form($form); |
|
1279 | 1279 | } |
1280 | 1280 | |
1281 | 1281 | $form->display(); |
@@ -1285,61 +1285,61 @@ discard block |
||
1285 | 1285 | /** |
1286 | 1286 | * Helper function to display a item payment form on the frontend. |
1287 | 1287 | */ |
1288 | -function getpaid_display_item_payment_form( $items ) { |
|
1288 | +function getpaid_display_item_payment_form($items) { |
|
1289 | 1289 | |
1290 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1291 | - $form->set_items( $items ); |
|
1290 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1291 | + $form->set_items($items); |
|
1292 | 1292 | |
1293 | - if ( 0 == count( $form->get_items() ) ) { |
|
1293 | + if (0 == count($form->get_items())) { |
|
1294 | 1294 | aui()->alert( |
1295 | 1295 | array( |
1296 | 1296 | 'type' => 'warning', |
1297 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
1297 | + 'content' => __('No published items found', 'invoicing'), |
|
1298 | 1298 | ), |
1299 | 1299 | true |
1300 | 1300 | ); |
1301 | 1301 | return; |
1302 | 1302 | } |
1303 | 1303 | |
1304 | - $extra_items = esc_attr( getpaid_convert_items_to_string( $items ) ); |
|
1305 | - $extra_items_key = md5( NONCE_KEY . AUTH_KEY . $extra_items ); |
|
1304 | + $extra_items = esc_attr(getpaid_convert_items_to_string($items)); |
|
1305 | + $extra_items_key = md5(NONCE_KEY . AUTH_KEY . $extra_items); |
|
1306 | 1306 | $extra_items = "<input type='hidden' name='getpaid-form-items' value='$extra_items' />"; |
1307 | 1307 | $extra_items .= "<input type='hidden' name='getpaid-form-items-key' value='$extra_items_key' />"; |
1308 | 1308 | |
1309 | - $form->display( $extra_items ); |
|
1309 | + $form->display($extra_items); |
|
1310 | 1310 | } |
1311 | 1311 | |
1312 | 1312 | /** |
1313 | 1313 | * Helper function to display an invoice payment form on the frontend. |
1314 | 1314 | */ |
1315 | -function getpaid_display_invoice_payment_form( $invoice_id ) { |
|
1315 | +function getpaid_display_invoice_payment_form($invoice_id) { |
|
1316 | 1316 | |
1317 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1317 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1318 | 1318 | |
1319 | - if ( empty( $invoice ) ) { |
|
1319 | + if (empty($invoice)) { |
|
1320 | 1320 | aui()->alert( |
1321 | 1321 | array( |
1322 | 1322 | 'type' => 'warning', |
1323 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
1323 | + 'content' => __('Invoice not found', 'invoicing'), |
|
1324 | 1324 | ), |
1325 | 1325 | true |
1326 | 1326 | ); |
1327 | 1327 | return; |
1328 | 1328 | } |
1329 | 1329 | |
1330 | - if ( $invoice->is_paid() ) { |
|
1330 | + if ($invoice->is_paid()) { |
|
1331 | 1331 | aui()->alert( |
1332 | 1332 | array( |
1333 | 1333 | 'type' => 'warning', |
1334 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
1334 | + 'content' => __('Invoice has already been paid', 'invoicing'), |
|
1335 | 1335 | ), |
1336 | 1336 | true |
1337 | 1337 | ); |
1338 | 1338 | return; |
1339 | 1339 | } |
1340 | 1340 | |
1341 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1342 | - $form->set_items( $invoice->get_items() ); |
|
1341 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1342 | + $form->set_items($invoice->get_items()); |
|
1343 | 1343 | |
1344 | 1344 | $form->display(); |
1345 | 1345 | } |
@@ -1347,23 +1347,23 @@ discard block |
||
1347 | 1347 | /** |
1348 | 1348 | * Helper function to convert item string to array. |
1349 | 1349 | */ |
1350 | -function getpaid_convert_items_to_array( $items ) { |
|
1351 | - $items = array_filter( array_map( 'trim', explode( ',', $items ) ) ); |
|
1350 | +function getpaid_convert_items_to_array($items) { |
|
1351 | + $items = array_filter(array_map('trim', explode(',', $items))); |
|
1352 | 1352 | $prepared = array(); |
1353 | 1353 | |
1354 | - foreach ( $items as $item ) { |
|
1355 | - $data = array_map( 'trim', explode( '|', $item ) ); |
|
1354 | + foreach ($items as $item) { |
|
1355 | + $data = array_map('trim', explode('|', $item)); |
|
1356 | 1356 | |
1357 | - if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) { |
|
1357 | + if (empty($data[0]) || !is_numeric($data[0])) { |
|
1358 | 1358 | continue; |
1359 | 1359 | } |
1360 | 1360 | |
1361 | 1361 | $quantity = 1; |
1362 | - if ( isset( $data[1] ) && is_numeric( $data[1] ) ) { |
|
1362 | + if (isset($data[1]) && is_numeric($data[1])) { |
|
1363 | 1363 | $quantity = (float) $data[1]; |
1364 | 1364 | } |
1365 | 1365 | |
1366 | - $prepared[ $data[0] ] = $quantity; |
|
1366 | + $prepared[$data[0]] = $quantity; |
|
1367 | 1367 | |
1368 | 1368 | } |
1369 | 1369 | |
@@ -1373,13 +1373,13 @@ discard block |
||
1373 | 1373 | /** |
1374 | 1374 | * Helper function to convert item array to string. |
1375 | 1375 | */ |
1376 | -function getpaid_convert_items_to_string( $items ) { |
|
1376 | +function getpaid_convert_items_to_string($items) { |
|
1377 | 1377 | $prepared = array(); |
1378 | 1378 | |
1379 | - foreach ( $items as $item => $quantity ) { |
|
1379 | + foreach ($items as $item => $quantity) { |
|
1380 | 1380 | $prepared[] = "$item|$quantity"; |
1381 | 1381 | } |
1382 | - return implode( ',', $prepared ); |
|
1382 | + return implode(',', $prepared); |
|
1383 | 1383 | } |
1384 | 1384 | |
1385 | 1385 | /** |
@@ -1387,21 +1387,21 @@ discard block |
||
1387 | 1387 | * |
1388 | 1388 | * Provide a label and one of $form, $items or $invoice. |
1389 | 1389 | */ |
1390 | -function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) { |
|
1391 | - $label = sanitize_text_field( $label ); |
|
1390 | +function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) { |
|
1391 | + $label = sanitize_text_field($label); |
|
1392 | 1392 | |
1393 | - if ( ! empty( $form ) ) { |
|
1394 | - $form = esc_attr( $form ); |
|
1393 | + if (!empty($form)) { |
|
1394 | + $form = esc_attr($form); |
|
1395 | 1395 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>"; |
1396 | 1396 | } |
1397 | 1397 | |
1398 | - if ( ! empty( $items ) ) { |
|
1399 | - $items = esc_attr( $items ); |
|
1398 | + if (!empty($items)) { |
|
1399 | + $items = esc_attr($items); |
|
1400 | 1400 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>"; |
1401 | 1401 | } |
1402 | 1402 | |
1403 | - if ( ! empty( $invoice ) ) { |
|
1404 | - $invoice = esc_attr( $invoice ); |
|
1403 | + if (!empty($invoice)) { |
|
1404 | + $invoice = esc_attr($invoice); |
|
1405 | 1405 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-invoice='$invoice'>$label</button>"; |
1406 | 1406 | } |
1407 | 1407 | |
@@ -1412,18 +1412,18 @@ discard block |
||
1412 | 1412 | * |
1413 | 1413 | * @param WPInv_Invoice $invoice |
1414 | 1414 | */ |
1415 | -function getpaid_the_invoice_description( $invoice ) { |
|
1415 | +function getpaid_the_invoice_description($invoice) { |
|
1416 | 1416 | $description = $invoice->get_description(); |
1417 | 1417 | |
1418 | - if ( empty( $description ) ) { |
|
1418 | + if (empty($description)) { |
|
1419 | 1419 | return; |
1420 | 1420 | } |
1421 | 1421 | |
1422 | - $description = wp_kses_post( wpautop( $description ) ); |
|
1422 | + $description = wp_kses_post(wpautop($description)); |
|
1423 | 1423 | echo "<small class='getpaid-invoice-description text-dark p-2 form-text' style='margin-bottom: 20px; border-left: 2px solid #2196F3;'><em>$description</em></small>"; |
1424 | 1424 | } |
1425 | -add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 ); |
|
1426 | -add_action( 'wpinv_email_billing_details', 'getpaid_the_invoice_description', 100 ); |
|
1425 | +add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100); |
|
1426 | +add_action('wpinv_email_billing_details', 'getpaid_the_invoice_description', 100); |
|
1427 | 1427 | |
1428 | 1428 | /** |
1429 | 1429 | * Render element on a form. |
@@ -1431,60 +1431,60 @@ discard block |
||
1431 | 1431 | * @param array $element |
1432 | 1432 | * @param GetPaid_Payment_Form $form |
1433 | 1433 | */ |
1434 | -function getpaid_payment_form_element( $element, $form ) { |
|
1434 | +function getpaid_payment_form_element($element, $form) { |
|
1435 | 1435 | |
1436 | 1436 | // Set up the args. |
1437 | - $element_type = trim( $element['type'] ); |
|
1437 | + $element_type = trim($element['type']); |
|
1438 | 1438 | $element['form'] = $form; |
1439 | - extract( $element ); |
|
1439 | + extract($element); |
|
1440 | 1440 | |
1441 | 1441 | // Try to locate the appropriate template. |
1442 | - $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" ); |
|
1442 | + $located = wpinv_locate_template("payment-forms/elements/$element_type.php"); |
|
1443 | 1443 | |
1444 | 1444 | // Abort if this is not our element. |
1445 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1445 | + if (empty($located) || !file_exists($located)) { |
|
1446 | 1446 | return; |
1447 | 1447 | } |
1448 | 1448 | |
1449 | 1449 | // Generate the class and id of the element. |
1450 | - $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) ); |
|
1451 | - $id = isset( $id ) ? $id : uniqid( 'gp' ); |
|
1450 | + $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type)); |
|
1451 | + $id = isset($id) ? $id : uniqid('gp'); |
|
1452 | 1452 | |
1453 | 1453 | // Echo the opening wrapper. |
1454 | 1454 | echo "<div class='getpaid-payment-form-element $wrapper_class'>"; |
1455 | 1455 | |
1456 | 1456 | // Fires before displaying a given element type's content. |
1457 | - do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form ); |
|
1457 | + do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form); |
|
1458 | 1458 | |
1459 | 1459 | // Include the template for the element. |
1460 | 1460 | include $located; |
1461 | 1461 | |
1462 | 1462 | // Fires after displaying a given element type's content. |
1463 | - do_action( "getpaid_payment_form_{$element_type}_element", $element, $form ); |
|
1463 | + do_action("getpaid_payment_form_{$element_type}_element", $element, $form); |
|
1464 | 1464 | |
1465 | 1465 | // Echo the closing wrapper. |
1466 | 1466 | echo '</div>'; |
1467 | 1467 | } |
1468 | -add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 ); |
|
1468 | +add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2); |
|
1469 | 1469 | |
1470 | 1470 | /** |
1471 | 1471 | * Render an element's edit page. |
1472 | 1472 | * |
1473 | 1473 | * @param WP_Post $post |
1474 | 1474 | */ |
1475 | -function getpaid_payment_form_edit_element_template( $post ) { |
|
1475 | +function getpaid_payment_form_edit_element_template($post) { |
|
1476 | 1476 | |
1477 | 1477 | // Retrieve all elements. |
1478 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
1478 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
1479 | 1479 | |
1480 | - foreach ( $all_elements as $element ) { |
|
1480 | + foreach ($all_elements as $element) { |
|
1481 | 1481 | |
1482 | 1482 | // Try to locate the appropriate template. |
1483 | - $element = esc_attr( sanitize_key( $element ) ); |
|
1484 | - $located = wpinv_locate_template( "payment-forms-admin/edit/$element.php" ); |
|
1483 | + $element = esc_attr(sanitize_key($element)); |
|
1484 | + $located = wpinv_locate_template("payment-forms-admin/edit/$element.php"); |
|
1485 | 1485 | |
1486 | 1486 | // Continue if this is not our element. |
1487 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1487 | + if (empty($located) || !file_exists($located)) { |
|
1488 | 1488 | continue; |
1489 | 1489 | } |
1490 | 1490 | |
@@ -1495,7 +1495,7 @@ discard block |
||
1495 | 1495 | } |
1496 | 1496 | |
1497 | 1497 | } |
1498 | -add_action( 'getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template' ); |
|
1498 | +add_action('getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template'); |
|
1499 | 1499 | |
1500 | 1500 | /** |
1501 | 1501 | * Render an element's preview. |
@@ -1504,16 +1504,16 @@ discard block |
||
1504 | 1504 | function getpaid_payment_form_render_element_preview_template() { |
1505 | 1505 | |
1506 | 1506 | // Retrieve all elements. |
1507 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
1507 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
1508 | 1508 | |
1509 | - foreach ( $all_elements as $element ) { |
|
1509 | + foreach ($all_elements as $element) { |
|
1510 | 1510 | |
1511 | 1511 | // Try to locate the appropriate template. |
1512 | - $element = sanitize_key( $element ); |
|
1513 | - $located = wpinv_locate_template( "payment-forms-admin/previews/$element.php" ); |
|
1512 | + $element = sanitize_key($element); |
|
1513 | + $located = wpinv_locate_template("payment-forms-admin/previews/$element.php"); |
|
1514 | 1514 | |
1515 | 1515 | // Continue if this is not our element. |
1516 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1516 | + if (empty($located) || !file_exists($located)) { |
|
1517 | 1517 | continue; |
1518 | 1518 | } |
1519 | 1519 | |
@@ -1524,7 +1524,7 @@ discard block |
||
1524 | 1524 | } |
1525 | 1525 | |
1526 | 1526 | } |
1527 | -add_action( 'wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template' ); |
|
1527 | +add_action('wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template'); |
|
1528 | 1528 | |
1529 | 1529 | /** |
1530 | 1530 | * Shows a list of gateways that support recurring payments. |
@@ -1532,17 +1532,17 @@ discard block |
||
1532 | 1532 | function wpinv_get_recurring_gateways_text() { |
1533 | 1533 | $gateways = array(); |
1534 | 1534 | |
1535 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
1536 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
1537 | - $gateways[] = sanitize_text_field( $gateway['admin_label'] ); |
|
1535 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
1536 | + if (wpinv_gateway_support_subscription($key)) { |
|
1537 | + $gateways[] = sanitize_text_field($gateway['admin_label']); |
|
1538 | 1538 | } |
1539 | 1539 | } |
1540 | 1540 | |
1541 | - if ( empty( $gateways ) ) { |
|
1542 | - return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) . '</span>'; |
|
1541 | + if (empty($gateways)) { |
|
1542 | + return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . '</span>'; |
|
1543 | 1543 | } |
1544 | 1544 | |
1545 | - return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) . '</span>'; |
|
1545 | + return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . '</span>'; |
|
1546 | 1546 | |
1547 | 1547 | } |
1548 | 1548 | |
@@ -1552,7 +1552,7 @@ discard block |
||
1552 | 1552 | * @return GetPaid_Template |
1553 | 1553 | */ |
1554 | 1554 | function getpaid_template() { |
1555 | - return getpaid()->get( 'template' ); |
|
1555 | + return getpaid()->get('template'); |
|
1556 | 1556 | } |
1557 | 1557 | |
1558 | 1558 | /** |
@@ -1561,8 +1561,8 @@ discard block |
||
1561 | 1561 | * @param array args |
1562 | 1562 | * @return string |
1563 | 1563 | */ |
1564 | -function getpaid_paginate_links( $args ) { |
|
1565 | - return str_replace( 'page-link dots', 'page-link text-dark', aui()->pagination( $args ) ); |
|
1564 | +function getpaid_paginate_links($args) { |
|
1565 | + return str_replace('page-link dots', 'page-link text-dark', aui()->pagination($args)); |
|
1566 | 1566 | } |
1567 | 1567 | |
1568 | 1568 | /** |
@@ -1572,22 +1572,22 @@ discard block |
||
1572 | 1572 | * @param string state |
1573 | 1573 | * @return string |
1574 | 1574 | */ |
1575 | -function getpaid_get_states_select_markup( $country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state' ) { |
|
1575 | +function getpaid_get_states_select_markup($country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state') { |
|
1576 | 1576 | |
1577 | - $states = wpinv_get_country_states( $country ); |
|
1578 | - $uniqid = uniqid( '_' ); |
|
1577 | + $states = wpinv_get_country_states($country); |
|
1578 | + $uniqid = uniqid('_'); |
|
1579 | 1579 | |
1580 | - if ( ! empty( $states ) ) { |
|
1580 | + if (!empty($states)) { |
|
1581 | 1581 | |
1582 | 1582 | return aui()->select( |
1583 | 1583 | array( |
1584 | 1584 | 'options' => $states, |
1585 | - 'name' => esc_attr( $field_name ), |
|
1586 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
1587 | - 'value' => sanitize_text_field( $state ), |
|
1585 | + 'name' => esc_attr($field_name), |
|
1586 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
1587 | + 'value' => sanitize_text_field($state), |
|
1588 | 1588 | 'placeholder' => $placeholder, |
1589 | 1589 | 'required' => $required, |
1590 | - 'label' => wp_kses_post( $label ), |
|
1590 | + 'label' => wp_kses_post($label), |
|
1591 | 1591 | 'label_type' => 'vertical', |
1592 | 1592 | 'help_text' => $help_text, |
1593 | 1593 | 'class' => 'getpaid-address-field wpinv_state', |
@@ -1603,14 +1603,14 @@ discard block |
||
1603 | 1603 | |
1604 | 1604 | return aui()->input( |
1605 | 1605 | array( |
1606 | - 'name' => esc_attr( $field_name ), |
|
1607 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
1606 | + 'name' => esc_attr($field_name), |
|
1607 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
1608 | 1608 | 'placeholder' => $placeholder, |
1609 | 1609 | 'required' => $required, |
1610 | - 'label' => wp_kses_post( $label ), |
|
1610 | + 'label' => wp_kses_post($label), |
|
1611 | 1611 | 'label_type' => 'vertical', |
1612 | 1612 | 'help_text' => $help_text, |
1613 | - 'value' => sanitize_text_field( $state ), |
|
1613 | + 'value' => sanitize_text_field($state), |
|
1614 | 1614 | 'class' => 'getpaid-address-field wpinv_state', |
1615 | 1615 | 'wrap_class' => "$wrapper_class getpaid-address-field-wrapper__state", |
1616 | 1616 | 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state', |
@@ -1628,16 +1628,16 @@ discard block |
||
1628 | 1628 | * @param array $element |
1629 | 1629 | * @return string |
1630 | 1630 | */ |
1631 | -function getpaid_get_form_element_grid_class( $element ) { |
|
1631 | +function getpaid_get_form_element_grid_class($element) { |
|
1632 | 1632 | |
1633 | 1633 | $class = 'col-12'; |
1634 | - $width = empty( $element['grid_width'] ) ? 'full' : $element['grid_width']; |
|
1634 | + $width = empty($element['grid_width']) ? 'full' : $element['grid_width']; |
|
1635 | 1635 | |
1636 | - if ( $width == 'half' ) { |
|
1636 | + if ($width == 'half') { |
|
1637 | 1637 | $class .= ' col-md-6'; |
1638 | 1638 | } |
1639 | 1639 | |
1640 | - if ( $width == 'third' ) { |
|
1640 | + if ($width == 'third') { |
|
1641 | 1641 | $class .= ' col-md-4'; |
1642 | 1642 | } |
1643 | 1643 | |
@@ -1652,15 +1652,15 @@ discard block |
||
1652 | 1652 | * |
1653 | 1653 | * @return string |
1654 | 1654 | */ |
1655 | -function getpaid_embed_url( $payment_form = false, $items = false ) { |
|
1655 | +function getpaid_embed_url($payment_form = false, $items = false) { |
|
1656 | 1656 | |
1657 | 1657 | return add_query_arg( |
1658 | 1658 | array( |
1659 | 1659 | 'getpaid_embed' => 1, |
1660 | - 'form' => $payment_form ? absint( $payment_form ) : false, |
|
1661 | - 'item' => $items ? urlencode( $items ) : false, |
|
1660 | + 'form' => $payment_form ? absint($payment_form) : false, |
|
1661 | + 'item' => $items ? urlencode($items) : false, |
|
1662 | 1662 | ), |
1663 | - home_url( 'index.php' ) |
|
1663 | + home_url('index.php') |
|
1664 | 1664 | ); |
1665 | 1665 | |
1666 | 1666 | } |
@@ -1670,13 +1670,13 @@ discard block |
||
1670 | 1670 | * |
1671 | 1671 | * @return string |
1672 | 1672 | */ |
1673 | -function getpaid_filter_embed_template( $template ) { |
|
1673 | +function getpaid_filter_embed_template($template) { |
|
1674 | 1674 | |
1675 | - if ( isset( $_GET['getpaid_embed'] ) ) { |
|
1676 | - wpinv_get_template( 'payment-forms/embed.php' ); |
|
1675 | + if (isset($_GET['getpaid_embed'])) { |
|
1676 | + wpinv_get_template('payment-forms/embed.php'); |
|
1677 | 1677 | exit; |
1678 | 1678 | } |
1679 | 1679 | |
1680 | 1680 | return $template; |
1681 | 1681 | } |
1682 | -add_filter( 'template_include', 'getpaid_filter_embed_template' ); |
|
1682 | +add_filter('template_include', 'getpaid_filter_embed_template'); |