@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * |
7 | 7 | */ |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if (!defined('ABSPATH')) { |
|
10 | 10 | exit; // Exit if accessed directly |
11 | 11 | } |
12 | 12 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @param WP_Post $post |
22 | 22 | */ |
23 | - public static function output( $post ) { |
|
23 | + public static function output($post) { |
|
24 | 24 | ?> |
25 | 25 | <style> |
26 | 26 | .wpinv-form-builder-edit-field-wrapper label.d-block > span:first-child{ |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | <div class="col-sm-4"> |
34 | 34 | |
35 | 35 | <!-- Builder tabs --> |
36 | - <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php esc_html_e( 'Go Back', 'invoicing' ); ?></button> |
|
36 | + <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php esc_html_e('Go Back', 'invoicing'); ?></button> |
|
37 | 37 | |
38 | 38 | <!-- Builder tab content --> |
39 | 39 | <div class="mt-4"> |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | <!-- Available builder elements --> |
42 | 42 | <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='new_item'"> |
43 | 43 | <div class="wpinv-form-builder-add-field-types"> |
44 | - <small class='form-text text-muted'><?php esc_html_e( 'Add an element by dragging it to the payment form.', 'invoicing' ); ?></small> |
|
44 | + <small class='form-text text-muted'><?php esc_html_e('Add an element by dragging it to the payment form.', 'invoicing'); ?></small> |
|
45 | 45 | <draggable class="section mt-2" style="display: flex; flex-flow: wrap; justify-content: space-between;" v-model="elements" :group="{ name: 'fields', pull: 'clone', put: false }" :sort="false" :clone="addDraggedField" tag="ul" filter=".wpinv-undraggable"> |
46 | 46 | <li v-for="element in elements" class= "wpinv-payment-form-left-fields-field" @click.prevent="addField(element)" :class="{ 'd-none': element.defaults.premade }"> |
47 | 47 | <button class="button btn text-dark"> |
@@ -56,18 +56,18 @@ discard block |
||
56 | 56 | <!-- Edit an element --> |
57 | 57 | <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='edit_item'" style="font-size: 14px;"> |
58 | 58 | <div class="wpinv-form-builder-edit-field-wrapper"> |
59 | - <?php do_action( 'wpinv_payment_form_edit_element_template', 'active_form_element', $post ); ?> |
|
60 | - <?php do_action( 'getpaid_payment_form_edit_element_template', $post ); ?> |
|
59 | + <?php do_action('wpinv_payment_form_edit_element_template', 'active_form_element', $post); ?> |
|
60 | + <?php do_action('getpaid_payment_form_edit_element_template', $post); ?> |
|
61 | 61 | <div class='form-group'> |
62 | - <label :for="active_form_element.id + '_grid_width'"><?php esc_html_e( 'Width', 'invoicing' ); ?></label> |
|
62 | + <label :for="active_form_element.id + '_grid_width'"><?php esc_html_e('Width', 'invoicing'); ?></label> |
|
63 | 63 | <select class='form-control custom-select' :id="active_form_element.id + '_grid_width'" v-model='gridWidth'> |
64 | - <option value='full'><?php esc_html_e( 'Full Width', 'invoicing' ); ?></option> |
|
65 | - <option value='half'><?php esc_html_e( 'Half Width', 'invoicing' ); ?></option> |
|
66 | - <option value='third'><?php esc_html_e( '1/3 Width', 'invoicing' ); ?></option> |
|
64 | + <option value='full'><?php esc_html_e('Full Width', 'invoicing'); ?></option> |
|
65 | + <option value='half'><?php esc_html_e('Half Width', 'invoicing'); ?></option> |
|
66 | + <option value='third'><?php esc_html_e('1/3 Width', 'invoicing'); ?></option> |
|
67 | 67 | </select> |
68 | 68 | </div> |
69 | 69 | <div> |
70 | - <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php esc_html_e( 'Delete Element', 'invoicing' ); ?></button> |
|
70 | + <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php esc_html_e('Delete Element', 'invoicing'); ?></button> |
|
71 | 71 | </div> |
72 | 72 | </div> |
73 | 73 | </div> |
@@ -76,15 +76,15 @@ discard block |
||
76 | 76 | |
77 | 77 | </div> |
78 | 78 | <div class="col-sm-8 border-left"> |
79 | - <small class='form-text text-muted' v-if='form_elements.length'><?php esc_html_e( 'Click on any element to edit or delete it.', 'invoicing' ); ?></small> |
|
80 | - <p class='form-text text-muted' v-if='! form_elements.length'><?php esc_html_e( 'This form is empty. Add new elements by dragging them from the right.', 'invoicing' ); ?></p> |
|
79 | + <small class='form-text text-muted' v-if='form_elements.length'><?php esc_html_e('Click on any element to edit or delete it.', 'invoicing'); ?></small> |
|
80 | + <p class='form-text text-muted' v-if='! form_elements.length'><?php esc_html_e('This form is empty. Add new elements by dragging them from the right.', 'invoicing'); ?></p> |
|
81 | 81 | |
82 | 82 | <div class="container-fluid"> |
83 | 83 | <draggable class="section row" v-model="form_elements" @add="highlightLastDroppedField" group="fields" tag="div" style="min-height: 100%; font-size: 14px;"> |
84 | 84 | <div v-for="form_element in form_elements" class="wpinv-form-builder-element-preview" :class="[{ active: active_form_element==form_element && active_tab=='edit_item' }, form_element.type, grid_class( form_element ) ]" @click="active_tab = 'edit_item'; active_form_element = form_element"> |
85 | 85 | <div class="wpinv-form-builder-element-preview-inner"> |
86 | 86 | <div class="wpinv-payment-form-field-preview-overlay"></div> |
87 | - <?php do_action( 'wpinv_payment_form_render_element_template', 'form_element', $post ); ?> |
|
87 | + <?php do_action('wpinv_payment_form_render_element_template', 'form_element', $post); ?> |
|
88 | 88 | </div> |
89 | 89 | </div> |
90 | 90 | </draggable> |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | </script> |
104 | 104 | <?php |
105 | 105 | |
106 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
106 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -111,33 +111,33 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @param int $post_id |
113 | 113 | */ |
114 | - public static function save( $post_id ) { |
|
114 | + public static function save($post_id) { |
|
115 | 115 | |
116 | 116 | // Prepare the form. |
117 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
117 | + $form = new GetPaid_Payment_Form($post_id); |
|
118 | 118 | |
119 | 119 | // Fetch form items. |
120 | - $form_items = json_decode( wp_unslash( $_POST['wpinv_form_items'] ), true ); |
|
120 | + $form_items = json_decode(wp_unslash($_POST['wpinv_form_items']), true); |
|
121 | 121 | |
122 | 122 | // Ensure that we have an array... |
123 | - if ( empty( $form_items ) ) { |
|
123 | + if (empty($form_items)) { |
|
124 | 124 | $form_items = array(); |
125 | 125 | } |
126 | 126 | |
127 | 127 | // Add it to the form. |
128 | - $form->set_items( self::item_to_objects( wp_kses_post_deep( $form_items ) ) ); |
|
128 | + $form->set_items(self::item_to_objects(wp_kses_post_deep($form_items))); |
|
129 | 129 | |
130 | 130 | // Save form elements. |
131 | - $form_elements = json_decode( wp_unslash( $_POST['wpinv_form_elements'] ), true ); |
|
132 | - if ( empty( $form_elements ) ) { |
|
131 | + $form_elements = json_decode(wp_unslash($_POST['wpinv_form_elements']), true); |
|
132 | + if (empty($form_elements)) { |
|
133 | 133 | $form_elements = array(); |
134 | 134 | } |
135 | 135 | |
136 | - $form->set_elements( wp_kses_post_deep( $form_elements ) ); |
|
136 | + $form->set_elements(wp_kses_post_deep($form_elements)); |
|
137 | 137 | |
138 | 138 | // Persist data to the datastore. |
139 | 139 | $form->save(); |
140 | - do_action( 'getpaid_payment_form_metabox_save', $post_id, $form ); |
|
140 | + do_action('getpaid_payment_form_metabox_save', $post_id, $form); |
|
141 | 141 | |
142 | 142 | } |
143 | 143 | |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @param array $items |
148 | 148 | */ |
149 | - public static function item_to_objects( $items ) { |
|
149 | + public static function item_to_objects($items) { |
|
150 | 150 | |
151 | 151 | $objects = array(); |
152 | 152 | |
153 | - foreach ( $items as $item ) { |
|
154 | - $_item = new GetPaid_Form_Item( $item['id'] ); |
|
155 | - $_item->set_allow_quantities( (bool) $item['allow_quantities'] ); |
|
156 | - $_item->set_is_required( (bool) $item['required'] ); |
|
153 | + foreach ($items as $item) { |
|
154 | + $_item = new GetPaid_Form_Item($item['id']); |
|
155 | + $_item->set_allow_quantities((bool) $item['allow_quantities']); |
|
156 | + $_item->set_is_required((bool) $item['required']); |
|
157 | 157 | $objects[] = $_item; |
158 | 158 | } |
159 | 159 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the invoice. |
27 | - $invoice = new WPInv_Invoice( $post ); |
|
28 | - $customer = $invoice->exists() ? $invoice->get_user_id( 'edit' ) : get_current_user_id(); |
|
29 | - $customer = new WP_User( $customer ); |
|
30 | - $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email ); |
|
31 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
27 | + $invoice = new WPInv_Invoice($post); |
|
28 | + $customer = $invoice->exists() ? $invoice->get_user_id('edit') : get_current_user_id(); |
|
29 | + $customer = new WP_User($customer); |
|
30 | + $display = sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email); |
|
31 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
32 | 32 | |
33 | 33 | ?> |
34 | 34 | |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | <div class="col-12 col-sm-6"> |
44 | 44 | <div id="getpaid-invoice-user-id-wrapper" class="form-group"> |
45 | 45 | <div> |
46 | - <label for="post_author_override"><?php esc_html_e( 'Customer', 'invoicing' );?></label> |
|
46 | + <label for="post_author_override"><?php esc_html_e('Customer', 'invoicing'); ?></label> |
|
47 | 47 | </div> |
48 | 48 | <div> |
49 | - <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e( 'Search for a customer by email or name', 'invoicing' ); ?>"> |
|
50 | - <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo esc_html( $display ); ?> </option>) |
|
49 | + <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e('Search for a customer by email or name', 'invoicing'); ?>"> |
|
50 | + <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo esc_html($display); ?> </option>) |
|
51 | 51 | </select> |
52 | 52 | </div> |
53 | 53 | </div> |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | 'type' => 'text', |
61 | 61 | 'id' => 'getpaid-invoice-new-user-email', |
62 | 62 | 'name' => 'wpinv_email', |
63 | - 'label' => __( 'Email', 'invoicing' ) . '<span class="required">*</span>', |
|
63 | + 'label' => __('Email', 'invoicing') . '<span class="required">*</span>', |
|
64 | 64 | 'label_type' => 'vertical', |
65 | 65 | 'placeholder' => '[email protected]', |
66 | 66 | 'class' => 'form-control-sm', |
@@ -70,18 +70,18 @@ discard block |
||
70 | 70 | </div> |
71 | 71 | </div> |
72 | 72 | <div class="col-12 col-sm-6 form-group mt-sm-4"> |
73 | - <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?> |
|
73 | + <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?> |
|
74 | 74 | <a id="getpaid-invoice-fill-user-details" class="button button-small button-secondary" href="javascript:void(0)"> |
75 | 75 | <i aria-hidden="true" class="fa fa-refresh"></i> |
76 | - <?php esc_html_e( 'Fill User Details', 'invoicing' );?> |
|
76 | + <?php esc_html_e('Fill User Details', 'invoicing'); ?> |
|
77 | 77 | </a> |
78 | 78 | <a id="getpaid-invoice-create-new-user-button" class="button button-small button-secondary" href="javascript:void(0)"> |
79 | 79 | <i aria-hidden="true" class="fa fa-plus"></i> |
80 | - <?php esc_html_e( 'Add New User', 'invoicing' );?> |
|
80 | + <?php esc_html_e('Add New User', 'invoicing'); ?> |
|
81 | 81 | </a> |
82 | 82 | <a id="getpaid-invoice-cancel-create-new-user" class="button button-small button-secondary d-none" href="javascript:void(0)"> |
83 | 83 | <i aria-hidden="true" class="fa fa-close"></i> |
84 | - <?php esc_html_e( 'Cancel', 'invoicing' );?> |
|
84 | + <?php esc_html_e('Cancel', 'invoicing'); ?> |
|
85 | 85 | </a> |
86 | 86 | <?php endif; ?> |
87 | 87 | </div> |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | 'type' => 'text', |
95 | 95 | 'id' => 'wpinv_first_name', |
96 | 96 | 'name' => 'wpinv_first_name', |
97 | - 'label' => __( 'First Name', 'invoicing' ), |
|
97 | + 'label' => __('First Name', 'invoicing'), |
|
98 | 98 | 'label_type' => 'vertical', |
99 | 99 | 'placeholder' => '', |
100 | 100 | 'class' => 'form-control-sm', |
101 | - 'value' => $invoice->get_first_name( 'edit' ), |
|
101 | + 'value' => $invoice->get_first_name('edit'), |
|
102 | 102 | ) |
103 | 103 | ); |
104 | 104 | ?> |
@@ -110,11 +110,11 @@ discard block |
||
110 | 110 | 'type' => 'text', |
111 | 111 | 'id' => 'wpinv_last_name', |
112 | 112 | 'name' => 'wpinv_last_name', |
113 | - 'label' => __( 'Last Name', 'invoicing' ), |
|
113 | + 'label' => __('Last Name', 'invoicing'), |
|
114 | 114 | 'label_type' => 'vertical', |
115 | 115 | 'placeholder' => '', |
116 | 116 | 'class' => 'form-control-sm', |
117 | - 'value' => $invoice->get_last_name( 'edit' ), |
|
117 | + 'value' => $invoice->get_last_name('edit'), |
|
118 | 118 | ) |
119 | 119 | ); |
120 | 120 | ?> |
@@ -129,11 +129,11 @@ discard block |
||
129 | 129 | 'type' => 'text', |
130 | 130 | 'id' => 'wpinv_company', |
131 | 131 | 'name' => 'wpinv_company', |
132 | - 'label' => __( 'Company', 'invoicing' ), |
|
132 | + 'label' => __('Company', 'invoicing'), |
|
133 | 133 | 'label_type' => 'vertical', |
134 | 134 | 'placeholder' => '', |
135 | 135 | 'class' => 'form-control-sm', |
136 | - 'value' => $invoice->get_company( 'edit' ), |
|
136 | + 'value' => $invoice->get_company('edit'), |
|
137 | 137 | ) |
138 | 138 | ); |
139 | 139 | ?> |
@@ -145,11 +145,11 @@ discard block |
||
145 | 145 | 'type' => 'text', |
146 | 146 | 'id' => 'wpinv_vat_number', |
147 | 147 | 'name' => 'wpinv_vat_number', |
148 | - 'label' => __( 'Vat Number', 'invoicing' ), |
|
148 | + 'label' => __('Vat Number', 'invoicing'), |
|
149 | 149 | 'label_type' => 'vertical', |
150 | 150 | 'placeholder' => '', |
151 | 151 | 'class' => 'form-control-sm getpaid-recalculate-prices-on-change', |
152 | - 'value' => $invoice->get_vat_number( 'edit' ), |
|
152 | + 'value' => $invoice->get_vat_number('edit'), |
|
153 | 153 | ) |
154 | 154 | ); |
155 | 155 | ?> |
@@ -164,11 +164,11 @@ discard block |
||
164 | 164 | 'type' => 'text', |
165 | 165 | 'id' => 'wpinv_address', |
166 | 166 | 'name' => 'wpinv_address', |
167 | - 'label' => __( 'Address', 'invoicing' ), |
|
167 | + 'label' => __('Address', 'invoicing'), |
|
168 | 168 | 'label_type' => 'vertical', |
169 | 169 | 'placeholder' => '', |
170 | 170 | 'class' => 'form-control-sm', |
171 | - 'value' => $invoice->get_address( 'edit' ), |
|
171 | + 'value' => $invoice->get_address('edit'), |
|
172 | 172 | ) |
173 | 173 | ); |
174 | 174 | ?> |
@@ -180,11 +180,11 @@ discard block |
||
180 | 180 | 'type' => 'text', |
181 | 181 | 'id' => 'wpinv_city', |
182 | 182 | 'name' => 'wpinv_city', |
183 | - 'label' => __( 'City', 'invoicing' ), |
|
183 | + 'label' => __('City', 'invoicing'), |
|
184 | 184 | 'label_type' => 'vertical', |
185 | 185 | 'placeholder' => '', |
186 | 186 | 'class' => 'form-control-sm', |
187 | - 'value' => $invoice->get_city( 'edit' ), |
|
187 | + 'value' => $invoice->get_city('edit'), |
|
188 | 188 | ) |
189 | 189 | ); |
190 | 190 | ?> |
@@ -198,11 +198,11 @@ discard block |
||
198 | 198 | array( |
199 | 199 | 'id' => 'wpinv_country', |
200 | 200 | 'name' => 'wpinv_country', |
201 | - 'label' => __( 'Country', 'invoicing' ), |
|
201 | + 'label' => __('Country', 'invoicing'), |
|
202 | 202 | 'label_type' => 'vertical', |
203 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
203 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
204 | 204 | 'class' => 'form-control-sm getpaid-recalculate-prices-on-change', |
205 | - 'value' => $invoice->get_country( 'edit' ), |
|
205 | + 'value' => $invoice->get_country('edit'), |
|
206 | 206 | 'options' => wpinv_get_country_list(), |
207 | 207 | 'data-allow-clear' => 'false', |
208 | 208 | 'select2' => true, |
@@ -213,20 +213,20 @@ discard block |
||
213 | 213 | <div class="col-12 col-sm-6"> |
214 | 214 | <?php |
215 | 215 | |
216 | - $states = wpinv_get_country_states( $invoice->get_country( 'edit' ) ); |
|
216 | + $states = wpinv_get_country_states($invoice->get_country('edit')); |
|
217 | 217 | |
218 | - if ( empty( $states ) ) { |
|
218 | + if (empty($states)) { |
|
219 | 219 | |
220 | 220 | echo aui()->input( |
221 | 221 | array( |
222 | 222 | 'type' => 'text', |
223 | 223 | 'id' => 'wpinv_state', |
224 | 224 | 'name' => 'wpinv_state', |
225 | - 'label' => __( 'State', 'invoicing' ), |
|
225 | + 'label' => __('State', 'invoicing'), |
|
226 | 226 | 'label_type' => 'vertical', |
227 | 227 | 'placeholder' => '', |
228 | 228 | 'class' => 'form-control-sm', |
229 | - 'value' => $invoice->get_state( 'edit' ), |
|
229 | + 'value' => $invoice->get_state('edit'), |
|
230 | 230 | ) |
231 | 231 | ); |
232 | 232 | |
@@ -236,11 +236,11 @@ discard block |
||
236 | 236 | array( |
237 | 237 | 'id' => 'wpinv_state', |
238 | 238 | 'name' => 'wpinv_state', |
239 | - 'label' => __( 'State', 'invoicing' ), |
|
239 | + 'label' => __('State', 'invoicing'), |
|
240 | 240 | 'label_type' => 'vertical', |
241 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
241 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
242 | 242 | 'class' => 'form-control-sm', |
243 | - 'value' => $invoice->get_state( 'edit' ), |
|
243 | + 'value' => $invoice->get_state('edit'), |
|
244 | 244 | 'options' => $states, |
245 | 245 | 'data-allow-clear' => 'false', |
246 | 246 | 'select2' => true, |
@@ -261,11 +261,11 @@ discard block |
||
261 | 261 | 'type' => 'text', |
262 | 262 | 'id' => 'wpinv_zip', |
263 | 263 | 'name' => 'wpinv_zip', |
264 | - 'label' => __( 'Zip / Postal Code', 'invoicing' ), |
|
264 | + 'label' => __('Zip / Postal Code', 'invoicing'), |
|
265 | 265 | 'label_type' => 'vertical', |
266 | 266 | 'placeholder' => '', |
267 | 267 | 'class' => 'form-control-sm', |
268 | - 'value' => $invoice->get_zip( 'edit' ), |
|
268 | + 'value' => $invoice->get_zip('edit'), |
|
269 | 269 | ) |
270 | 270 | ); |
271 | 271 | ?> |
@@ -277,19 +277,19 @@ discard block |
||
277 | 277 | 'type' => 'text', |
278 | 278 | 'id' => 'wpinv_phone', |
279 | 279 | 'name' => 'wpinv_phone', |
280 | - 'label' => __( 'Phone', 'invoicing' ), |
|
280 | + 'label' => __('Phone', 'invoicing'), |
|
281 | 281 | 'label_type' => 'vertical', |
282 | 282 | 'placeholder' => '', |
283 | 283 | 'class' => 'form-control-sm', |
284 | - 'value' => $invoice->get_phone( 'edit' ), |
|
284 | + 'value' => $invoice->get_phone('edit'), |
|
285 | 285 | ) |
286 | 286 | ); |
287 | 287 | ?> |
288 | 288 | </div> |
289 | 289 | </div> |
290 | 290 | |
291 | - <?php if ( ! apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) : ?> |
|
292 | - <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?> |
|
291 | + <?php if (!apply_filters('getpaid_use_new_invoice_items_metabox', false)) : ?> |
|
292 | + <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?> |
|
293 | 293 | |
294 | 294 | <div class="row"> |
295 | 295 | <div class="col-12 col-sm-6"> |
@@ -298,14 +298,14 @@ discard block |
||
298 | 298 | array( |
299 | 299 | 'id' => 'wpinv_template', |
300 | 300 | 'name' => 'wpinv_template', |
301 | - 'label' => __( 'Template', 'invoicing' ), |
|
301 | + 'label' => __('Template', 'invoicing'), |
|
302 | 302 | 'label_type' => 'vertical', |
303 | - 'placeholder' => __( 'Choose a template', 'invoicing' ), |
|
303 | + 'placeholder' => __('Choose a template', 'invoicing'), |
|
304 | 304 | 'class' => 'form-control-sm', |
305 | - 'value' => $invoice->get_template( 'edit' ), |
|
305 | + 'value' => $invoice->get_template('edit'), |
|
306 | 306 | 'options' => array( |
307 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
308 | - 'hours' => __( 'Hours', 'invoicing' ), |
|
307 | + 'quantity' => __('Quantity', 'invoicing'), |
|
308 | + 'hours' => __('Hours', 'invoicing'), |
|
309 | 309 | //'amount' => __( 'Amount Only', 'invoicing' ), |
310 | 310 | ), |
311 | 311 | 'data-allow-clear' => 'false', |
@@ -322,11 +322,11 @@ discard block |
||
322 | 322 | array( |
323 | 323 | 'id' => 'wpinv_currency', |
324 | 324 | 'name' => 'wpinv_currency', |
325 | - 'label' => __( 'Currency', 'invoicing' ), |
|
325 | + 'label' => __('Currency', 'invoicing'), |
|
326 | 326 | 'label_type' => 'vertical', |
327 | - 'placeholder' => __( 'Select Invoice Currency', 'invoicing' ), |
|
327 | + 'placeholder' => __('Select Invoice Currency', 'invoicing'), |
|
328 | 328 | 'class' => 'form-control-sm getpaid-recalculate-prices-on-change', |
329 | - 'value' => $invoice->get_currency( 'edit' ), |
|
329 | + 'value' => $invoice->get_currency('edit'), |
|
330 | 330 | 'required' => false, |
331 | 331 | 'data-allow-clear' => 'false', |
332 | 332 | 'select2' => true, |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | </div> |
339 | 339 | </div> |
340 | 340 | |
341 | - <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?> |
|
341 | + <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?> |
|
342 | 342 | <?php endif; ?> |
343 | 343 | |
344 | 344 | <div class="row"> |
@@ -349,18 +349,18 @@ discard block |
||
349 | 349 | 'type' => 'text', |
350 | 350 | 'id' => 'wpinv_company_id', |
351 | 351 | 'name' => 'wpinv_company_id', |
352 | - 'label' => __( 'Company ID', 'invoicing' ), |
|
352 | + 'label' => __('Company ID', 'invoicing'), |
|
353 | 353 | 'label_type' => 'vertical', |
354 | 354 | 'placeholder' => '', |
355 | 355 | 'class' => 'form-control-sm', |
356 | - 'value' => $invoice->get_company_id( 'edit' ), |
|
356 | + 'value' => $invoice->get_company_id('edit'), |
|
357 | 357 | ) |
358 | 358 | ); |
359 | 359 | ?> |
360 | 360 | </div> |
361 | 361 | </div> |
362 | 362 | |
363 | - <?php do_action( 'getpaid_after_metabox_invoice_address', $invoice ); ?> |
|
363 | + <?php do_action('getpaid_after_metabox_invoice_address', $invoice); ?> |
|
364 | 364 | </div> |
365 | 365 | <?php |
366 | 366 | } |
@@ -370,51 +370,51 @@ discard block |
||
370 | 370 | * |
371 | 371 | * @param int $post_id |
372 | 372 | */ |
373 | - public static function save( $post_id ) { |
|
373 | + public static function save($post_id) { |
|
374 | 374 | |
375 | 375 | // Prepare the invoice. |
376 | - $invoice = new WPInv_Invoice( $post_id ); |
|
376 | + $invoice = new WPInv_Invoice($post_id); |
|
377 | 377 | |
378 | 378 | // Load new data. |
379 | 379 | $invoice->set_props( |
380 | 380 | array( |
381 | - 'template' => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null, |
|
382 | - 'email_cc' => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null, |
|
383 | - 'disable_taxes' => ! empty( $_POST['disable_taxes'] ), |
|
384 | - 'currency' => isset( $_POST['wpinv_currency'] ) ? wpinv_clean( $_POST['wpinv_currency'] ) : null, |
|
385 | - 'gateway' => ( $invoice->needs_payment() && isset( $_POST['wpinv_gateway'] ) ) ? wpinv_clean( $_POST['wpinv_gateway'] ) : null, |
|
386 | - 'address' => isset( $_POST['wpinv_address'] ) ? wpinv_clean( $_POST['wpinv_address'] ) : null, |
|
387 | - 'vat_number' => isset( $_POST['wpinv_vat_number'] ) ? wpinv_clean( $_POST['wpinv_vat_number'] ) : null, |
|
388 | - 'company' => isset( $_POST['wpinv_company'] ) ? wpinv_clean( $_POST['wpinv_company'] ) : null, |
|
389 | - 'company_id' => isset( $_POST['wpinv_company_id'] ) ? wpinv_clean( $_POST['wpinv_company_id'] ) : null, |
|
390 | - 'zip' => isset( $_POST['wpinv_zip'] ) ? wpinv_clean( $_POST['wpinv_zip'] ) : null, |
|
391 | - 'state' => isset( $_POST['wpinv_state'] ) ? wpinv_clean( $_POST['wpinv_state'] ) : null, |
|
392 | - 'city' => isset( $_POST['wpinv_city'] ) ? wpinv_clean( $_POST['wpinv_city'] ) : null, |
|
393 | - 'country' => isset( $_POST['wpinv_country'] ) ? wpinv_clean( $_POST['wpinv_country'] ) : null, |
|
394 | - 'phone' => isset( $_POST['wpinv_phone'] ) ? wpinv_clean( $_POST['wpinv_phone'] ) : null, |
|
395 | - 'first_name' => isset( $_POST['wpinv_first_name'] ) ? wpinv_clean( $_POST['wpinv_first_name'] ) : null, |
|
396 | - 'last_name' => isset( $_POST['wpinv_last_name'] ) ? wpinv_clean( $_POST['wpinv_last_name'] ) : null, |
|
397 | - 'author' => isset( $_POST['post_author_override'] ) ? wpinv_clean( $_POST['post_author_override'] ) : null, |
|
398 | - 'date_created' => isset( $_POST['date_created'] ) ? wpinv_clean( $_POST['date_created'] ) : null, |
|
399 | - 'date_completed' => isset( $_POST['wpinv_date_completed'] ) ? wpinv_clean( $_POST['wpinv_date_completed'] ) : null, |
|
400 | - 'due_date' => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null, |
|
401 | - 'number' => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null, |
|
402 | - 'status' => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null, |
|
381 | + 'template' => isset($_POST['wpinv_template']) ? wpinv_clean($_POST['wpinv_template']) : null, |
|
382 | + 'email_cc' => isset($_POST['wpinv_cc']) ? wpinv_clean($_POST['wpinv_cc']) : null, |
|
383 | + 'disable_taxes' => !empty($_POST['disable_taxes']), |
|
384 | + 'currency' => isset($_POST['wpinv_currency']) ? wpinv_clean($_POST['wpinv_currency']) : null, |
|
385 | + 'gateway' => ($invoice->needs_payment() && isset($_POST['wpinv_gateway'])) ? wpinv_clean($_POST['wpinv_gateway']) : null, |
|
386 | + 'address' => isset($_POST['wpinv_address']) ? wpinv_clean($_POST['wpinv_address']) : null, |
|
387 | + 'vat_number' => isset($_POST['wpinv_vat_number']) ? wpinv_clean($_POST['wpinv_vat_number']) : null, |
|
388 | + 'company' => isset($_POST['wpinv_company']) ? wpinv_clean($_POST['wpinv_company']) : null, |
|
389 | + 'company_id' => isset($_POST['wpinv_company_id']) ? wpinv_clean($_POST['wpinv_company_id']) : null, |
|
390 | + 'zip' => isset($_POST['wpinv_zip']) ? wpinv_clean($_POST['wpinv_zip']) : null, |
|
391 | + 'state' => isset($_POST['wpinv_state']) ? wpinv_clean($_POST['wpinv_state']) : null, |
|
392 | + 'city' => isset($_POST['wpinv_city']) ? wpinv_clean($_POST['wpinv_city']) : null, |
|
393 | + 'country' => isset($_POST['wpinv_country']) ? wpinv_clean($_POST['wpinv_country']) : null, |
|
394 | + 'phone' => isset($_POST['wpinv_phone']) ? wpinv_clean($_POST['wpinv_phone']) : null, |
|
395 | + 'first_name' => isset($_POST['wpinv_first_name']) ? wpinv_clean($_POST['wpinv_first_name']) : null, |
|
396 | + 'last_name' => isset($_POST['wpinv_last_name']) ? wpinv_clean($_POST['wpinv_last_name']) : null, |
|
397 | + 'author' => isset($_POST['post_author_override']) ? wpinv_clean($_POST['post_author_override']) : null, |
|
398 | + 'date_created' => isset($_POST['date_created']) ? wpinv_clean($_POST['date_created']) : null, |
|
399 | + 'date_completed' => isset($_POST['wpinv_date_completed']) ? wpinv_clean($_POST['wpinv_date_completed']) : null, |
|
400 | + 'due_date' => isset($_POST['wpinv_due_date']) ? wpinv_clean($_POST['wpinv_due_date']) : null, |
|
401 | + 'number' => isset($_POST['wpinv_number']) ? wpinv_clean($_POST['wpinv_number']) : null, |
|
402 | + 'status' => isset($_POST['wpinv_status']) ? wpinv_clean($_POST['wpinv_status']) : null, |
|
403 | 403 | ) |
404 | 404 | ); |
405 | 405 | |
406 | 406 | // Discount code. |
407 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
407 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
408 | 408 | |
409 | - if ( isset( $_POST['wpinv_discount_code'] ) ) { |
|
410 | - $invoice->set_discount_code( wpinv_clean( $_POST['wpinv_discount_code'] ) ); |
|
409 | + if (isset($_POST['wpinv_discount_code'])) { |
|
410 | + $invoice->set_discount_code(wpinv_clean($_POST['wpinv_discount_code'])); |
|
411 | 411 | } |
412 | 412 | |
413 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
414 | - if ( $discount->exists() ) { |
|
415 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
413 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
414 | + if ($discount->exists()) { |
|
415 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
416 | 416 | } else { |
417 | - $invoice->remove_discount( 'discount_code' ); |
|
417 | + $invoice->remove_discount('discount_code'); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | // Recalculate totals. |
@@ -423,17 +423,17 @@ discard block |
||
423 | 423 | } |
424 | 424 | |
425 | 425 | // If we're creating a new user... |
426 | - if ( ! empty( $_POST['wpinv_new_user'] ) && is_email( stripslashes( $_POST['wpinv_email'] ) ) ) { |
|
426 | + if (!empty($_POST['wpinv_new_user']) && is_email(stripslashes($_POST['wpinv_email']))) { |
|
427 | 427 | |
428 | 428 | // Attempt to create the user. |
429 | - $user = wpinv_create_user( sanitize_email( stripslashes( $_POST['wpinv_email'] ) ) ); |
|
429 | + $user = wpinv_create_user(sanitize_email(stripslashes($_POST['wpinv_email']))); |
|
430 | 430 | |
431 | 431 | |
432 | 432 | // If successful, update the invoice author. |
433 | - if ( is_numeric( $user ) ) { |
|
434 | - $invoice->set_author( $user ); |
|
433 | + if (is_numeric($user)) { |
|
434 | + $invoice->set_author($user); |
|
435 | 435 | } else { |
436 | - wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ ); |
|
436 | + wpinv_error_log($user->get_error_message(), __('Invoice add new user', 'invoicing'), __FILE__, __LINE__); |
|
437 | 437 | } |
438 | 438 | } |
439 | 439 | |
@@ -447,16 +447,16 @@ discard block |
||
447 | 447 | $GLOBALS['wpinv_skip_invoice_notification'] = false; |
448 | 448 | |
449 | 449 | // (Maybe) send new user notification. |
450 | - $should_send_notification = wpinv_get_option( 'disable_new_user_emails' ); |
|
451 | - if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) { |
|
452 | - wp_send_new_user_notifications( $user, 'user' ); |
|
450 | + $should_send_notification = wpinv_get_option('disable_new_user_emails'); |
|
451 | + if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', empty($should_send_notification))) { |
|
452 | + wp_send_new_user_notifications($user, 'user'); |
|
453 | 453 | } |
454 | 454 | |
455 | - if ( ! empty( $_POST['send_to_customer'] ) && ! $invoice->is_draft() ) { |
|
456 | - getpaid()->get( 'invoice_emails' )->user_invoice( $invoice, true ); |
|
455 | + if (!empty($_POST['send_to_customer']) && !$invoice->is_draft()) { |
|
456 | + getpaid()->get('invoice_emails')->user_invoice($invoice, true); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | // Fires after an invoice is saved. |
460 | - do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
460 | + do_action('wpinv_invoice_metabox_saved', $invoice); |
|
461 | 461 | } |
462 | 462 | } |
@@ -192,13 +192,13 @@ discard block |
||
192 | 192 | $name = isset( $option['name'] ) ? $option['name'] : ''; |
193 | 193 | $cb = "wpinv_{$option['type']}_callback"; |
194 | 194 | $section = "wpinv_settings_{$tab}_$section"; |
195 | - $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page']; |
|
195 | + $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page']; |
|
196 | 196 | |
197 | - if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) { |
|
198 | - $tip = wpinv_clean( $option['desc'] ); |
|
199 | - $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
|
200 | - unset( $option['desc'] ); |
|
201 | - } |
|
197 | + if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) { |
|
198 | + $tip = wpinv_clean( $option['desc'] ); |
|
199 | + $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
|
200 | + unset( $option['desc'] ); |
|
201 | + } |
|
202 | 202 | |
203 | 203 | // Loop through all tabs. |
204 | 204 | add_settings_field( |
@@ -225,9 +225,9 @@ discard block |
||
225 | 225 | 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
226 | 226 | 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
227 | 227 | 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
228 | - 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
229 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
230 | - 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
228 | + 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
229 | + 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
230 | + 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
231 | 231 | 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
232 | 232 | 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
233 | 233 | ) |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @return array |
242 | 242 | */ |
243 | 243 | function wpinv_get_registered_settings() { |
244 | - return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
244 | + return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -260,18 +260,18 @@ discard block |
||
260 | 260 | */ |
261 | 261 | function wpinv_settings_sanitize( $input = array() ) { |
262 | 262 | |
263 | - $wpinv_options = wpinv_get_options(); |
|
264 | - $raw_referrer = wp_get_raw_referer(); |
|
263 | + $wpinv_options = wpinv_get_options(); |
|
264 | + $raw_referrer = wp_get_raw_referer(); |
|
265 | 265 | |
266 | 266 | if ( empty( $raw_referrer ) ) { |
267 | - return array_merge( $wpinv_options, $input ); |
|
267 | + return array_merge( $wpinv_options, $input ); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | wp_parse_str( $raw_referrer, $referrer ); |
271 | 271 | |
272 | - if ( in_array( 'gp-setup', $referrer ) ) { |
|
273 | - return array_merge( $wpinv_options, $input ); |
|
274 | - } |
|
272 | + if ( in_array( 'gp-setup', $referrer ) ) { |
|
273 | + return array_merge( $wpinv_options, $input ); |
|
274 | + } |
|
275 | 275 | |
276 | 276 | $settings = wpinv_get_registered_settings(); |
277 | 277 | $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
@@ -293,10 +293,10 @@ discard block |
||
293 | 293 | } |
294 | 294 | |
295 | 295 | // General filter |
296 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
296 | + $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
297 | 297 | |
298 | - // Key specific filter. |
|
299 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
298 | + // Key specific filter. |
|
299 | + $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | // Loop through the whitelist and unset any that are empty for the tab being saved |
@@ -339,14 +339,14 @@ discard block |
||
339 | 339 | |
340 | 340 | foreach ( $new_rates as $rate ) { |
341 | 341 | |
342 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
343 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
344 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
345 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
346 | - $rate['global'] = empty( $rate['state'] ); |
|
347 | - $tax_rates[] = $rate; |
|
342 | + $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
343 | + $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
344 | + $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
345 | + $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
346 | + $rate['global'] = empty( $rate['state'] ); |
|
347 | + $tax_rates[] = $rate; |
|
348 | 348 | |
349 | - } |
|
349 | + } |
|
350 | 350 | |
351 | 351 | update_option( 'wpinv_tax_rates', $tax_rates ); |
352 | 352 | |
@@ -359,11 +359,11 @@ discard block |
||
359 | 359 | $tabs['general'] = __( 'General', 'invoicing' ); |
360 | 360 | $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
361 | 361 | $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
362 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
362 | + $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
363 | 363 | |
364 | - if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
365 | - $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
366 | - } |
|
364 | + if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
365 | + $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
366 | + } |
|
367 | 367 | |
368 | 368 | $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
369 | 369 | $tabs['misc'] = __( 'Misc', 'invoicing' ); |
@@ -394,52 +394,52 @@ discard block |
||
394 | 394 | 'general' => apply_filters( |
395 | 395 | 'wpinv_settings_sections_general', |
396 | 396 | array( |
397 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
398 | - 'page_section' => __( 'Page Settings', 'invoicing' ), |
|
399 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
400 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
397 | + 'main' => __( 'General Settings', 'invoicing' ), |
|
398 | + 'page_section' => __( 'Page Settings', 'invoicing' ), |
|
399 | + 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
400 | + 'labels' => __( 'Label Texts', 'invoicing' ), |
|
401 | 401 | ) |
402 | 402 | ), |
403 | 403 | 'gateways' => apply_filters( |
404 | 404 | 'wpinv_settings_sections_gateways', |
405 | 405 | array( |
406 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
406 | + 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
407 | 407 | ) |
408 | 408 | ), |
409 | 409 | 'taxes' => apply_filters( |
410 | 410 | 'wpinv_settings_sections_taxes', |
411 | 411 | array( |
412 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
413 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
414 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ), |
|
412 | + 'main' => __( 'Tax Settings', 'invoicing' ), |
|
413 | + 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
414 | + 'vat' => __( 'EU VAT Settings', 'invoicing' ), |
|
415 | 415 | ) |
416 | 416 | ), |
417 | 417 | 'emails' => apply_filters( |
418 | 418 | 'wpinv_settings_sections_emails', |
419 | 419 | array( |
420 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
420 | + 'main' => __( 'Email Settings', 'invoicing' ), |
|
421 | 421 | ) |
422 | 422 | ), |
423 | 423 | |
424 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
424 | + 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
425 | 425 | |
426 | 426 | 'privacy' => apply_filters( |
427 | 427 | 'wpinv_settings_sections_privacy', |
428 | 428 | array( |
429 | - 'main' => __( 'Privacy policy', 'invoicing' ), |
|
429 | + 'main' => __( 'Privacy policy', 'invoicing' ), |
|
430 | 430 | ) |
431 | 431 | ), |
432 | 432 | 'misc' => apply_filters( |
433 | 433 | 'wpinv_settings_sections_misc', |
434 | 434 | array( |
435 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
436 | - 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
435 | + 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
436 | + 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
437 | 437 | ) |
438 | 438 | ), |
439 | 439 | 'tools' => apply_filters( |
440 | 440 | 'wpinv_settings_sections_tools', |
441 | 441 | array( |
442 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
442 | + 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
443 | 443 | ) |
444 | 444 | ), |
445 | 445 | ); |
@@ -450,46 +450,46 @@ discard block |
||
450 | 450 | } |
451 | 451 | |
452 | 452 | function wpinv_get_pages( $with_slug = false, $default_label = null ) { |
453 | - $pages_options = array(); |
|
453 | + $pages_options = array(); |
|
454 | 454 | |
455 | - if ( $default_label !== null && $default_label !== false ) { |
|
456 | - $pages_options = array( '' => $default_label ); // Blank option |
|
457 | - } |
|
455 | + if ( $default_label !== null && $default_label !== false ) { |
|
456 | + $pages_options = array( '' => $default_label ); // Blank option |
|
457 | + } |
|
458 | 458 | |
459 | - $pages = get_pages(); |
|
460 | - if ( $pages ) { |
|
461 | - foreach ( $pages as $page ) { |
|
462 | - $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
459 | + $pages = get_pages(); |
|
460 | + if ( $pages ) { |
|
461 | + foreach ( $pages as $page ) { |
|
462 | + $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
463 | 463 | $pages_options[ $page->ID ] = $title; |
464 | - } |
|
465 | - } |
|
464 | + } |
|
465 | + } |
|
466 | 466 | |
467 | - return $pages_options; |
|
467 | + return $pages_options; |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | function wpinv_header_callback( $args ) { |
471 | - if ( ! empty( $args['desc'] ) ) { |
|
471 | + if ( ! empty( $args['desc'] ) ) { |
|
472 | 472 | echo wp_kses_post( $args['desc'] ); |
473 | 473 | } |
474 | 474 | } |
475 | 475 | |
476 | 476 | function wpinv_hidden_callback( $args ) { |
477 | 477 | |
478 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
479 | - $value = wpinv_get_option( $args['id'], $std ); |
|
478 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
479 | + $value = wpinv_get_option( $args['id'], $std ); |
|
480 | 480 | |
481 | - if ( isset( $args['set_value'] ) ) { |
|
482 | - $value = $args['set_value']; |
|
483 | - } |
|
481 | + if ( isset( $args['set_value'] ) ) { |
|
482 | + $value = $args['set_value']; |
|
483 | + } |
|
484 | 484 | |
485 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
486 | - $args['readonly'] = true; |
|
487 | - $name = ''; |
|
488 | - } else { |
|
489 | - $name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']'; |
|
490 | - } |
|
485 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
486 | + $args['readonly'] = true; |
|
487 | + $name = ''; |
|
488 | + } else { |
|
489 | + $name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']'; |
|
490 | + } |
|
491 | 491 | |
492 | - echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
492 | + echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
493 | 493 | |
494 | 494 | } |
495 | 495 | |
@@ -498,12 +498,12 @@ discard block |
||
498 | 498 | */ |
499 | 499 | function wpinv_checkbox_callback( $args ) { |
500 | 500 | |
501 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
502 | - $std = wpinv_get_option( $args['id'], $std ); |
|
503 | - $id = esc_attr( $args['id'] ); |
|
501 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
502 | + $std = wpinv_get_option( $args['id'], $std ); |
|
503 | + $id = esc_attr( $args['id'] ); |
|
504 | 504 | |
505 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
506 | - ?> |
|
505 | + getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
506 | + ?> |
|
507 | 507 | <fieldset> |
508 | 508 | <label> |
509 | 509 | <input id="wpinv-settings-<?php echo esc_attr( $id ); ?>" name="wpinv_settings[<?php echo esc_attr( $id ); ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox"> |
@@ -515,75 +515,75 @@ discard block |
||
515 | 515 | |
516 | 516 | function wpinv_multicheck_callback( $args ) { |
517 | 517 | |
518 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
519 | - $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
518 | + $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
519 | + $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
520 | 520 | |
521 | - if ( ! empty( $args['options'] ) ) { |
|
521 | + if ( ! empty( $args['options'] ) ) { |
|
522 | 522 | |
523 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
524 | - $value = wpinv_get_option( $args['id'], $std ); |
|
523 | + $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
524 | + $value = wpinv_get_option( $args['id'], $std ); |
|
525 | 525 | |
526 | - echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">'; |
|
526 | + echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">'; |
|
527 | 527 | foreach ( $args['options'] as $key => $option ) : |
528 | - $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) ); |
|
529 | - if ( in_array( $sanitize_key, $value ) ) { |
|
530 | - $enabled = $sanitize_key; |
|
531 | - } else { |
|
532 | - $enabled = null; |
|
533 | - } |
|
534 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
535 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
536 | - endforeach; |
|
537 | - echo '</div>'; |
|
538 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
539 | - } |
|
528 | + $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) ); |
|
529 | + if ( in_array( $sanitize_key, $value ) ) { |
|
530 | + $enabled = $sanitize_key; |
|
531 | + } else { |
|
532 | + $enabled = null; |
|
533 | + } |
|
534 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
535 | + echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
536 | + endforeach; |
|
537 | + echo '</div>'; |
|
538 | + echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
539 | + } |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | function wpinv_payment_icons_callback( $args ) { |
543 | 543 | |
544 | 544 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
545 | - $value = wpinv_get_option( $args['id'], false ); |
|
545 | + $value = wpinv_get_option( $args['id'], false ); |
|
546 | 546 | |
547 | - if ( ! empty( $args['options'] ) ) { |
|
548 | - foreach ( $args['options'] as $key => $option ) { |
|
547 | + if ( ! empty( $args['options'] ) ) { |
|
548 | + foreach ( $args['options'] as $key => $option ) { |
|
549 | 549 | $sanitize_key = wpinv_sanitize_key( $key ); |
550 | 550 | |
551 | - if ( empty( $value ) ) { |
|
552 | - $enabled = $option; |
|
553 | - } else { |
|
554 | - $enabled = null; |
|
555 | - } |
|
556 | - |
|
557 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
558 | - |
|
559 | - echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
560 | - |
|
561 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
562 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
563 | - } else { |
|
564 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
565 | - |
|
566 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
567 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
568 | - } else { |
|
569 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
570 | - $content_dir = WP_CONTENT_DIR; |
|
571 | - |
|
572 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
573 | - // Replaces backslashes with forward slashes for Windows systems |
|
574 | - $image = wp_normalize_path( $image ); |
|
575 | - $content_dir = wp_normalize_path( $content_dir ); |
|
576 | - } |
|
577 | - |
|
578 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
579 | - } |
|
580 | - |
|
581 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
582 | - } |
|
583 | - echo wp_kses_post( $option ) . '</label>'; |
|
584 | - } |
|
585 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
586 | - } |
|
551 | + if ( empty( $value ) ) { |
|
552 | + $enabled = $option; |
|
553 | + } else { |
|
554 | + $enabled = null; |
|
555 | + } |
|
556 | + |
|
557 | + echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
558 | + |
|
559 | + echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
560 | + |
|
561 | + if ( wpinv_string_is_image_url( $key ) ) { |
|
562 | + echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
563 | + } else { |
|
564 | + $card = strtolower( str_replace( ' ', '', $option ) ); |
|
565 | + |
|
566 | + if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
567 | + $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
568 | + } else { |
|
569 | + $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
570 | + $content_dir = WP_CONTENT_DIR; |
|
571 | + |
|
572 | + if ( function_exists( 'wp_normalize_path' ) ) { |
|
573 | + // Replaces backslashes with forward slashes for Windows systems |
|
574 | + $image = wp_normalize_path( $image ); |
|
575 | + $content_dir = wp_normalize_path( $content_dir ); |
|
576 | + } |
|
577 | + |
|
578 | + $image = str_replace( $content_dir, content_url(), $image ); |
|
579 | + } |
|
580 | + |
|
581 | + echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
582 | + } |
|
583 | + echo wp_kses_post( $option ) . '</label>'; |
|
584 | + } |
|
585 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
586 | + } |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | /** |
@@ -591,9 +591,9 @@ discard block |
||
591 | 591 | */ |
592 | 592 | function wpinv_radio_callback( $args ) { |
593 | 593 | |
594 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
595 | - $std = wpinv_get_option( $args['id'], $std ); |
|
596 | - ?> |
|
594 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
595 | + $std = wpinv_get_option( $args['id'], $std ); |
|
596 | + ?> |
|
597 | 597 | <fieldset> |
598 | 598 | <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
599 | 599 | <?php foreach ( $args['options'] as $key => $option ) : ?> |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | </ul> |
608 | 608 | </fieldset> |
609 | 609 | <?php |
610 | - getpaid_settings_description_callback( $args ); |
|
610 | + getpaid_settings_description_callback( $args ); |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | /** |
@@ -615,10 +615,10 @@ discard block |
||
615 | 615 | */ |
616 | 616 | function getpaid_settings_description_callback( $args ) { |
617 | 617 | |
618 | - if ( ! empty( $args['desc'] ) ) { |
|
619 | - $description = $args['desc']; |
|
620 | - echo wp_kses_post( "<p class='description'>$description</p>" ); |
|
621 | - } |
|
618 | + if ( ! empty( $args['desc'] ) ) { |
|
619 | + $description = $args['desc']; |
|
620 | + echo wp_kses_post( "<p class='description'>$description</p>" ); |
|
621 | + } |
|
622 | 622 | |
623 | 623 | } |
624 | 624 | |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | */ |
628 | 628 | function wpinv_gateways_callback() { |
629 | 629 | |
630 | - ?> |
|
630 | + ?> |
|
631 | 631 | </td> |
632 | 632 | </tr> |
633 | 633 | <tr class="bsui"> |
@@ -641,26 +641,26 @@ discard block |
||
641 | 641 | |
642 | 642 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
643 | 643 | $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
644 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
645 | - $value = wpinv_get_option( $args['id'], $std ); |
|
644 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
645 | + $value = wpinv_get_option( $args['id'], $std ); |
|
646 | 646 | |
647 | - echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >'; |
|
647 | + echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >'; |
|
648 | 648 | |
649 | - foreach ( $args['options'] as $key => $option ) : |
|
649 | + foreach ( $args['options'] as $key => $option ) : |
|
650 | 650 | |
651 | - echo '<option value="' . esc_attr( $key ) . '" '; |
|
651 | + echo '<option value="' . esc_attr( $key ) . '" '; |
|
652 | 652 | |
653 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
653 | + if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
654 | 654 | selected( $key, $args['selected'] ); |
655 | 655 | } else { |
656 | 656 | selected( $key, $value ); |
657 | 657 | } |
658 | 658 | |
659 | - echo '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
660 | - endforeach; |
|
659 | + echo '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
660 | + endforeach; |
|
661 | 661 | |
662 | - echo '</select>'; |
|
663 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
662 | + echo '</select>'; |
|
663 | + echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | /** |
@@ -671,29 +671,29 @@ discard block |
||
671 | 671 | */ |
672 | 672 | function wpinv_settings_attrs_helper( $args ) { |
673 | 673 | |
674 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
675 | - $id = esc_attr( $args['id'] ); |
|
676 | - $placeholder = esc_attr( $args['placeholder'] ); |
|
674 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
675 | + $id = esc_attr( $args['id'] ); |
|
676 | + $placeholder = esc_attr( $args['placeholder'] ); |
|
677 | 677 | |
678 | - if ( ! empty( $args['faux'] ) ) { |
|
679 | - $args['readonly'] = true; |
|
680 | - $name = ''; |
|
681 | - } else { |
|
682 | - $value = wpinv_get_option( $args['id'], $value ); |
|
683 | - $name = "wpinv_settings[$id]"; |
|
684 | - } |
|
678 | + if ( ! empty( $args['faux'] ) ) { |
|
679 | + $args['readonly'] = true; |
|
680 | + $name = ''; |
|
681 | + } else { |
|
682 | + $value = wpinv_get_option( $args['id'], $value ); |
|
683 | + $name = "wpinv_settings[$id]"; |
|
684 | + } |
|
685 | 685 | |
686 | - $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
687 | - $class = esc_attr( $args['class'] ); |
|
688 | - $style = esc_attr( $args['style'] ); |
|
689 | - $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
686 | + $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
687 | + $class = esc_attr( $args['class'] ); |
|
688 | + $style = esc_attr( $args['style'] ); |
|
689 | + $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
690 | 690 | |
691 | - $onchange = ''; |
|
691 | + $onchange = ''; |
|
692 | 692 | if ( ! empty( $args['onchange'] ) ) { |
693 | 693 | $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
694 | - } |
|
694 | + } |
|
695 | 695 | |
696 | - return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
|
696 | + return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
|
697 | 697 | } |
698 | 698 | |
699 | 699 | /** |
@@ -701,9 +701,9 @@ discard block |
||
701 | 701 | */ |
702 | 702 | function wpinv_text_callback( $args ) { |
703 | 703 | |
704 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
704 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
705 | 705 | |
706 | - ?> |
|
706 | + ?> |
|
707 | 707 | <label style="width: 100%;"> |
708 | 708 | <input type="text" <?php echo wpinv_settings_attrs_helper( $args ); ?>> |
709 | 709 | <?php echo wp_kses_post( $desc ); ?> |
@@ -717,10 +717,10 @@ discard block |
||
717 | 717 | */ |
718 | 718 | function wpinv_number_callback( $args ) { |
719 | 719 | |
720 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
721 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
720 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
721 | + $attr = wpinv_settings_attrs_helper( $args ); |
|
722 | 722 | |
723 | - ?> |
|
723 | + ?> |
|
724 | 724 | <label style="width: 100%;"> |
725 | 725 | <input type="number" step="<?php echo floatval( $args['step'] ); ?>" max="<?php echo intval( $args['max'] ); ?>" min="<?php echo intval( $args['min'] ); ?>" <?php echo $attr; ?>> |
726 | 726 | <?php echo wp_kses_post( $desc ); ?> |
@@ -732,34 +732,34 @@ discard block |
||
732 | 732 | function wpinv_textarea_callback( $args ) { |
733 | 733 | |
734 | 734 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
735 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
736 | - $value = wpinv_get_option( $args['id'], $std ); |
|
735 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
736 | + $value = wpinv_get_option( $args['id'], $std ); |
|
737 | 737 | |
738 | 738 | $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
739 | 739 | $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
740 | 740 | |
741 | - echo '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
742 | - echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
741 | + echo '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
742 | + echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
743 | 743 | |
744 | 744 | } |
745 | 745 | |
746 | 746 | function wpinv_password_callback( $args ) { |
747 | 747 | |
748 | 748 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
749 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
750 | - $value = wpinv_get_option( $args['id'], $std ); |
|
749 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
750 | + $value = wpinv_get_option( $args['id'], $std ); |
|
751 | 751 | |
752 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
753 | - echo '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
754 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
752 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
753 | + echo '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
754 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
755 | 755 | |
756 | 756 | } |
757 | 757 | |
758 | 758 | function wpinv_missing_callback( $args ) { |
759 | - printf( |
|
760 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
761 | - '<strong>' . $args['id'] . '</strong>' |
|
762 | - ); |
|
759 | + printf( |
|
760 | + __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
761 | + '<strong>' . $args['id'] . '</strong>' |
|
762 | + ); |
|
763 | 763 | } |
764 | 764 | |
765 | 765 | /** |
@@ -767,14 +767,14 @@ discard block |
||
767 | 767 | */ |
768 | 768 | function wpinv_select_callback( $args ) { |
769 | 769 | |
770 | - $desc = wp_kses_post( $args['desc'] ); |
|
771 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
772 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
773 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
774 | - $value = wpinv_get_option( $args['id'], $value ); |
|
775 | - $rand = uniqid( 'random_id' ); |
|
770 | + $desc = wp_kses_post( $args['desc'] ); |
|
771 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
772 | + $attr = wpinv_settings_attrs_helper( $args ); |
|
773 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
774 | + $value = wpinv_get_option( $args['id'], $value ); |
|
775 | + $rand = uniqid( 'random_id' ); |
|
776 | 776 | |
777 | - ?> |
|
777 | + ?> |
|
778 | 778 | <label style="width: 100%;"> |
779 | 779 | <select <?php echo $attr; ?> data-allow-clear="true"> |
780 | 780 | <?php foreach ( $args['options'] as $option => $name ) : ?> |
@@ -807,50 +807,50 @@ discard block |
||
807 | 807 | function wpinv_color_select_callback( $args ) { |
808 | 808 | |
809 | 809 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
810 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
811 | - $value = wpinv_get_option( $args['id'], $std ); |
|
810 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
811 | + $value = wpinv_get_option( $args['id'], $std ); |
|
812 | 812 | |
813 | - echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
813 | + echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
814 | 814 | |
815 | - foreach ( $args['options'] as $option => $color ) { |
|
816 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>'; |
|
817 | - } |
|
815 | + foreach ( $args['options'] as $option => $color ) { |
|
816 | + echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>'; |
|
817 | + } |
|
818 | 818 | |
819 | - echo '</select>'; |
|
820 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
819 | + echo '</select>'; |
|
820 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
821 | 821 | |
822 | 822 | } |
823 | 823 | |
824 | 824 | function wpinv_rich_editor_callback( $args ) { |
825 | - global $wp_version; |
|
825 | + global $wp_version; |
|
826 | 826 | |
827 | 827 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
828 | 828 | |
829 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
830 | - $value = wpinv_get_option( $args['id'], $std ); |
|
829 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
830 | + $value = wpinv_get_option( $args['id'], $std ); |
|
831 | 831 | |
832 | - if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
833 | - $value = $std; |
|
834 | - } |
|
832 | + if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
833 | + $value = $std; |
|
834 | + } |
|
835 | 835 | |
836 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
836 | + $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
837 | 837 | |
838 | - echo '<div class="getpaid-settings-editor-input">'; |
|
839 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
840 | - wp_editor( |
|
838 | + echo '<div class="getpaid-settings-editor-input">'; |
|
839 | + if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
840 | + wp_editor( |
|
841 | 841 | stripslashes( $value ), |
842 | 842 | 'wpinv_settings_' . esc_attr( $args['id'] ), |
843 | 843 | array( |
844 | - 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', |
|
845 | - 'textarea_rows' => absint( $rows ), |
|
846 | - 'media_buttons' => false, |
|
844 | + 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', |
|
845 | + 'textarea_rows' => absint( $rows ), |
|
846 | + 'media_buttons' => false, |
|
847 | 847 | ) |
848 | 848 | ); |
849 | - } else { |
|
850 | - echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
851 | - } |
|
849 | + } else { |
|
850 | + echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
851 | + } |
|
852 | 852 | |
853 | - echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
853 | + echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
854 | 854 | |
855 | 855 | } |
856 | 856 | |
@@ -858,51 +858,51 @@ discard block |
||
858 | 858 | |
859 | 859 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
860 | 860 | |
861 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
862 | - $value = wpinv_get_option( $args['id'], $std ); |
|
861 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
862 | + $value = wpinv_get_option( $args['id'], $std ); |
|
863 | 863 | |
864 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
865 | - echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
866 | - echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
867 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
864 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
865 | + echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
866 | + echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
867 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
868 | 868 | |
869 | 869 | } |
870 | 870 | |
871 | 871 | function wpinv_color_callback( $args ) { |
872 | 872 | |
873 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
874 | - $value = wpinv_get_option( $args['id'], $std ); |
|
873 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
874 | + $value = wpinv_get_option( $args['id'], $std ); |
|
875 | 875 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
876 | 876 | |
877 | - echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />'; |
|
878 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
877 | + echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />'; |
|
878 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
879 | 879 | |
880 | 880 | } |
881 | 881 | |
882 | 882 | function wpinv_country_states_callback( $args ) { |
883 | 883 | |
884 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
885 | - $value = wpinv_get_option( $args['id'], $std ); |
|
884 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
885 | + $value = wpinv_get_option( $args['id'], $std ); |
|
886 | 886 | |
887 | 887 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
888 | 888 | |
889 | - if ( isset( $args['placeholder'] ) ) { |
|
890 | - $placeholder = $args['placeholder']; |
|
891 | - } else { |
|
892 | - $placeholder = ''; |
|
893 | - } |
|
889 | + if ( isset( $args['placeholder'] ) ) { |
|
890 | + $placeholder = $args['placeholder']; |
|
891 | + } else { |
|
892 | + $placeholder = ''; |
|
893 | + } |
|
894 | 894 | |
895 | - $states = wpinv_get_country_states(); |
|
895 | + $states = wpinv_get_country_states(); |
|
896 | 896 | |
897 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
898 | - echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
897 | + $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
898 | + echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
899 | 899 | |
900 | - foreach ( $states as $option => $name ) { |
|
901 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>'; |
|
902 | - } |
|
900 | + foreach ( $states as $option => $name ) { |
|
901 | + echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>'; |
|
902 | + } |
|
903 | 903 | |
904 | - echo '</select>'; |
|
905 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
904 | + echo '</select>'; |
|
905 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
906 | 906 | |
907 | 907 | } |
908 | 908 | |
@@ -911,7 +911,7 @@ discard block |
||
911 | 911 | */ |
912 | 912 | function wpinv_tax_rates_callback() { |
913 | 913 | |
914 | - ?> |
|
914 | + ?> |
|
915 | 915 | </td> |
916 | 916 | </tr> |
917 | 917 | <tr class="bsui"> |
@@ -926,17 +926,17 @@ discard block |
||
926 | 926 | * Displays a tax rate' edit row. |
927 | 927 | */ |
928 | 928 | function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) { |
929 | - ob_start(); |
|
929 | + ob_start(); |
|
930 | 930 | |
931 | - $key = sanitize_key( $key ); |
|
932 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
933 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
931 | + $key = sanitize_key( $key ); |
|
932 | + $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
933 | + include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
934 | 934 | |
935 | - if ( $echo ) { |
|
936 | - echo ob_get_clean(); |
|
937 | - } else { |
|
938 | - return ob_get_clean(); |
|
939 | - } |
|
935 | + if ( $echo ) { |
|
936 | + echo ob_get_clean(); |
|
937 | + } else { |
|
938 | + return ob_get_clean(); |
|
939 | + } |
|
940 | 940 | |
941 | 941 | } |
942 | 942 | |
@@ -968,14 +968,14 @@ discard block |
||
968 | 968 | <td> |
969 | 969 | <a href=" |
970 | 970 | <?php |
971 | - echo esc_url( |
|
972 | - wp_nonce_url( |
|
973 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
974 | - 'getpaid-nonce', |
|
975 | - 'getpaid-nonce' |
|
976 | - ) |
|
977 | - ); |
|
978 | - ?> |
|
971 | + echo esc_url( |
|
972 | + wp_nonce_url( |
|
973 | + add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
974 | + 'getpaid-nonce', |
|
975 | + 'getpaid-nonce' |
|
976 | + ) |
|
977 | + ); |
|
978 | + ?> |
|
979 | 979 | " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
980 | 980 | </td> |
981 | 981 | </tr> |
@@ -987,14 +987,14 @@ discard block |
||
987 | 987 | <td> |
988 | 988 | <a href=" |
989 | 989 | <?php |
990 | - echo esc_url( |
|
991 | - wp_nonce_url( |
|
992 | - add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
993 | - 'getpaid-nonce', |
|
994 | - 'getpaid-nonce' |
|
995 | - ) |
|
996 | - ); |
|
997 | - ?> |
|
990 | + echo esc_url( |
|
991 | + wp_nonce_url( |
|
992 | + add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
993 | + 'getpaid-nonce', |
|
994 | + 'getpaid-nonce' |
|
995 | + ) |
|
996 | + ); |
|
997 | + ?> |
|
998 | 998 | " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
999 | 999 | </td> |
1000 | 1000 | </tr> |
@@ -1006,14 +1006,14 @@ discard block |
||
1006 | 1006 | <td> |
1007 | 1007 | <a href=" |
1008 | 1008 | <?php |
1009 | - echo esc_url( |
|
1010 | - wp_nonce_url( |
|
1011 | - add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
1012 | - 'getpaid-nonce', |
|
1013 | - 'getpaid-nonce' |
|
1014 | - ) |
|
1015 | - ); |
|
1016 | - ?> |
|
1009 | + echo esc_url( |
|
1010 | + wp_nonce_url( |
|
1011 | + add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
1012 | + 'getpaid-nonce', |
|
1013 | + 'getpaid-nonce' |
|
1014 | + ) |
|
1015 | + ); |
|
1016 | + ?> |
|
1017 | 1017 | " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
1018 | 1018 | </td> |
1019 | 1019 | </tr> |
@@ -1026,14 +1026,14 @@ discard block |
||
1026 | 1026 | <td> |
1027 | 1027 | <a href=" |
1028 | 1028 | <?php |
1029 | - echo esc_url( |
|
1030 | - wp_nonce_url( |
|
1031 | - add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
1032 | - 'getpaid-nonce', |
|
1033 | - 'getpaid-nonce' |
|
1034 | - ) |
|
1035 | - ); |
|
1036 | - ?> |
|
1029 | + echo esc_url( |
|
1030 | + wp_nonce_url( |
|
1031 | + add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
1032 | + 'getpaid-nonce', |
|
1033 | + 'getpaid-nonce' |
|
1034 | + ) |
|
1035 | + ); |
|
1036 | + ?> |
|
1037 | 1037 | " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
1038 | 1038 | </td> |
1039 | 1039 | </tr> |
@@ -1046,8 +1046,8 @@ discard block |
||
1046 | 1046 | <td> |
1047 | 1047 | <a href=" |
1048 | 1048 | <?php |
1049 | - echo esc_url( admin_url( 'index.php?page=gp-setup' ) ); |
|
1050 | - ?> |
|
1049 | + echo esc_url( admin_url( 'index.php?page=gp-setup' ) ); |
|
1050 | + ?> |
|
1051 | 1051 | " class="button button-primary"><?php esc_html_e( 'Launch', 'invoicing' ); ?></a> |
1052 | 1052 | </td> |
1053 | 1053 | </tr> |
@@ -1061,19 +1061,19 @@ discard block |
||
1061 | 1061 | |
1062 | 1062 | |
1063 | 1063 | function wpinv_descriptive_text_callback( $args ) { |
1064 | - echo wp_kses_post( $args['desc'] ); |
|
1064 | + echo wp_kses_post( $args['desc'] ); |
|
1065 | 1065 | } |
1066 | 1066 | |
1067 | 1067 | function wpinv_raw_html_callback( $args ) { |
1068 | - echo wp_kses_post( $args['desc'] ); |
|
1068 | + echo wp_kses_post( $args['desc'] ); |
|
1069 | 1069 | } |
1070 | 1070 | |
1071 | 1071 | function wpinv_hook_callback( $args ) { |
1072 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1072 | + do_action( 'wpinv_' . $args['id'], $args ); |
|
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | function wpinv_set_settings_cap() { |
1076 | - return wpinv_get_capability(); |
|
1076 | + return wpinv_get_capability(); |
|
1077 | 1077 | } |
1078 | 1078 | add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
1079 | 1079 | |
@@ -1097,15 +1097,15 @@ discard block |
||
1097 | 1097 | */ |
1098 | 1098 | function wpinv_get_merge_tags_help_text( $subscription = false ) { |
1099 | 1099 | |
1100 | - $url = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f'; |
|
1101 | - $link = sprintf( |
|
1102 | - '<strong><a href="%s" target="_blank">%s</a></strong>', |
|
1103 | - $url, |
|
1104 | - esc_html__( 'View available merge tags.', 'wpinv-quotes' ) |
|
1105 | - ); |
|
1100 | + $url = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f'; |
|
1101 | + $link = sprintf( |
|
1102 | + '<strong><a href="%s" target="_blank">%s</a></strong>', |
|
1103 | + $url, |
|
1104 | + esc_html__( 'View available merge tags.', 'wpinv-quotes' ) |
|
1105 | + ); |
|
1106 | 1106 | |
1107 | - $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
1107 | + $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
1108 | 1108 | |
1109 | - return "$description $link"; |
|
1109 | + return "$description $link"; |
|
1110 | 1110 | |
1111 | 1111 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @since 1.0.0 |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Retrieves all default settings. |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | function wpinv_get_settings() { |
17 | 17 | $defaults = array(); |
18 | 18 | |
19 | - foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) { |
|
19 | + foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) { |
|
20 | 20 | |
21 | - foreach ( array_values( $tab_settings ) as $section_settings ) { |
|
21 | + foreach (array_values($tab_settings) as $section_settings) { |
|
22 | 22 | |
23 | - foreach ( $section_settings as $key => $setting ) { |
|
24 | - if ( isset( $setting['std'] ) ) { |
|
25 | - $defaults[ $key ] = $setting['std']; |
|
23 | + foreach ($section_settings as $key => $setting) { |
|
24 | + if (isset($setting['std'])) { |
|
25 | + $defaults[$key] = $setting['std']; |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | } |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | global $wpinv_options; |
42 | 42 | |
43 | 43 | // Try fetching the saved options. |
44 | - if ( empty( $wpinv_options ) ) { |
|
45 | - $wpinv_options = get_option( 'wpinv_settings' ); |
|
44 | + if (empty($wpinv_options)) { |
|
45 | + $wpinv_options = get_option('wpinv_settings'); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | // If that fails, don't fetch the default settings to prevent a loop. |
49 | - if ( ! is_array( $wpinv_options ) ) { |
|
49 | + if (!is_array($wpinv_options)) { |
|
50 | 50 | $wpinv_options = array(); |
51 | 51 | } |
52 | 52 | |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | * @param mixed $default The default value to use if the setting has not been set. |
61 | 61 | * @return mixed |
62 | 62 | */ |
63 | -function wpinv_get_option( $key = '', $default = false ) { |
|
63 | +function wpinv_get_option($key = '', $default = false) { |
|
64 | 64 | |
65 | 65 | $options = wpinv_get_options(); |
66 | - $value = isset( $options[ $key ] ) ? $options[ $key ] : $default; |
|
67 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
66 | + $value = isset($options[$key]) ? $options[$key] : $default; |
|
67 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
68 | 68 | |
69 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
69 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | * @param array $options the new options. |
76 | 76 | * @return bool |
77 | 77 | */ |
78 | -function wpinv_update_options( $options ) { |
|
78 | +function wpinv_update_options($options) { |
|
79 | 79 | global $wpinv_options; |
80 | 80 | |
81 | 81 | // update the option. |
82 | - if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) { |
|
82 | + if (is_array($options) && update_option('wpinv_settings', $options)) { |
|
83 | 83 | $wpinv_options = $options; |
84 | 84 | return true; |
85 | 85 | } |
@@ -94,24 +94,24 @@ discard block |
||
94 | 94 | * @param mixed $value The setting value. |
95 | 95 | * @return bool |
96 | 96 | */ |
97 | -function wpinv_update_option( $key = '', $value = false ) { |
|
97 | +function wpinv_update_option($key = '', $value = false) { |
|
98 | 98 | |
99 | 99 | // If no key, exit. |
100 | - if ( empty( $key ) ) { |
|
100 | + if (empty($key)) { |
|
101 | 101 | return false; |
102 | 102 | } |
103 | 103 | |
104 | 104 | // Maybe delete the option instead. |
105 | - if ( is_null( $value ) ) { |
|
106 | - return wpinv_delete_option( $key ); |
|
105 | + if (is_null($value)) { |
|
106 | + return wpinv_delete_option($key); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | // Prepare the new options. |
110 | 110 | $options = wpinv_get_options(); |
111 | - $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key ); |
|
111 | + $options[$key] = apply_filters('wpinv_update_option', $value, $key); |
|
112 | 112 | |
113 | 113 | // Save the new options. |
114 | - return wpinv_update_options( $options ); |
|
114 | + return wpinv_update_options($options); |
|
115 | 115 | |
116 | 116 | } |
117 | 117 | |
@@ -121,18 +121,18 @@ discard block |
||
121 | 121 | * @param string $key the setting key. |
122 | 122 | * @return bool |
123 | 123 | */ |
124 | -function wpinv_delete_option( $key = '' ) { |
|
124 | +function wpinv_delete_option($key = '') { |
|
125 | 125 | |
126 | 126 | // If no key, exit |
127 | - if ( empty( $key ) ) { |
|
127 | + if (empty($key)) { |
|
128 | 128 | return false; |
129 | 129 | } |
130 | 130 | |
131 | 131 | $options = wpinv_get_options(); |
132 | 132 | |
133 | - if ( isset( $options[ $key ] ) ) { |
|
134 | - unset( $options[ $key ] ); |
|
135 | - return wpinv_update_options( $options ); |
|
133 | + if (isset($options[$key])) { |
|
134 | + unset($options[$key]); |
|
135 | + return wpinv_update_options($options); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | return true; |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | function wpinv_register_settings() { |
147 | 147 | |
148 | 148 | // Loop through all tabs. |
149 | - foreach ( wpinv_get_registered_settings() as $tab => $sections ) { |
|
149 | + foreach (wpinv_get_registered_settings() as $tab => $sections) { |
|
150 | 150 | |
151 | 151 | // In each tab, loop through sections. |
152 | - foreach ( $sections as $section => $settings ) { |
|
152 | + foreach ($sections as $section => $settings) { |
|
153 | 153 | |
154 | 154 | // Check for backwards compatibility |
155 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
156 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
155 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
156 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
157 | 157 | $section = 'main'; |
158 | 158 | $settings = $sections; |
159 | 159 | } |
@@ -166,18 +166,18 @@ discard block |
||
166 | 166 | 'wpinv_settings_' . $tab . '_' . $section |
167 | 167 | ); |
168 | 168 | |
169 | - foreach ( $settings as $option ) { |
|
170 | - if ( ! empty( $option['id'] ) ) { |
|
171 | - wpinv_register_settings_option( $tab, $section, $option ); |
|
169 | + foreach ($settings as $option) { |
|
170 | + if (!empty($option['id'])) { |
|
171 | + wpinv_register_settings_option($tab, $section, $option); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | 177 | // Creates our settings in the options table. |
178 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
178 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
179 | 179 | } |
180 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
180 | +add_action('admin_init', 'wpinv_register_settings'); |
|
181 | 181 | |
182 | 182 | /** |
183 | 183 | * Register a single settings option. |
@@ -187,49 +187,49 @@ discard block |
||
187 | 187 | * @param string $option |
188 | 188 | * |
189 | 189 | */ |
190 | -function wpinv_register_settings_option( $tab, $section, $option ) { |
|
190 | +function wpinv_register_settings_option($tab, $section, $option) { |
|
191 | 191 | |
192 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
192 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
193 | 193 | $cb = "wpinv_{$option['type']}_callback"; |
194 | 194 | $section = "wpinv_settings_{$tab}_$section"; |
195 | - $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page']; |
|
195 | + $is_wizzard = is_admin() && isset($_GET['page']) && 'gp-setup' == $_GET['page']; |
|
196 | 196 | |
197 | - if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) { |
|
198 | - $tip = wpinv_clean( $option['desc'] ); |
|
197 | + if (isset($option['desc']) && (!$is_wizzard && !empty($option['help-tip']))) { |
|
198 | + $tip = wpinv_clean($option['desc']); |
|
199 | 199 | $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
200 | - unset( $option['desc'] ); |
|
200 | + unset($option['desc']); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | // Loop through all tabs. |
204 | 204 | add_settings_field( |
205 | 205 | 'wpinv_settings[' . $option['id'] . ']', |
206 | 206 | $name, |
207 | - function_exists( $cb ) ? $cb : 'wpinv_missing_callback', |
|
207 | + function_exists($cb) ? $cb : 'wpinv_missing_callback', |
|
208 | 208 | $section, |
209 | 209 | $section, |
210 | 210 | array( |
211 | 211 | 'section' => $section, |
212 | - 'id' => isset( $option['id'] ) ? $option['id'] : uniqid( 'wpinv-' ), |
|
213 | - 'desc' => isset( $option['desc'] ) ? $option['desc'] : '', |
|
212 | + 'id' => isset($option['id']) ? $option['id'] : uniqid('wpinv-'), |
|
213 | + 'desc' => isset($option['desc']) ? $option['desc'] : '', |
|
214 | 214 | 'name' => $name, |
215 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
216 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
217 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
218 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
219 | - 'min' => isset( $option['min'] ) ? $option['min'] : 0, |
|
220 | - 'max' => isset( $option['max'] ) ? $option['max'] : 999999, |
|
221 | - 'step' => isset( $option['step'] ) ? $option['step'] : 1, |
|
222 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
223 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
224 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
225 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
226 | - 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
|
227 | - 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
|
228 | - 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
229 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
230 | - 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
231 | - 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
232 | - 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
215 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
216 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
217 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
218 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
219 | + 'min' => isset($option['min']) ? $option['min'] : 0, |
|
220 | + 'max' => isset($option['max']) ? $option['max'] : 999999, |
|
221 | + 'step' => isset($option['step']) ? $option['step'] : 1, |
|
222 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
223 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
224 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
225 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
226 | + 'onchange' => isset($option['onchange']) ? $option['onchange'] : '', |
|
227 | + 'custom' => isset($option['custom']) ? $option['custom'] : '', |
|
228 | + 'default_content' => isset($option['default_content']) ? $option['default_content'] : '', |
|
229 | + 'class' => isset($option['class']) ? $option['class'] : '', |
|
230 | + 'style' => isset($option['style']) ? $option['style'] : '', |
|
231 | + 'cols' => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
232 | + 'rows' => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
233 | 233 | ) |
234 | 234 | ); |
235 | 235 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @return array |
242 | 242 | */ |
243 | 243 | function wpinv_get_registered_settings() { |
244 | - return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
244 | + return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings'))); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @return array |
251 | 251 | */ |
252 | 252 | function getpaid_get_integration_settings() { |
253 | - return apply_filters( 'getpaid_integration_settings', array() ); |
|
253 | + return apply_filters('getpaid_integration_settings', array()); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -258,126 +258,126 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @return array |
260 | 260 | */ |
261 | -function wpinv_settings_sanitize( $input = array() ) { |
|
261 | +function wpinv_settings_sanitize($input = array()) { |
|
262 | 262 | |
263 | 263 | $wpinv_options = wpinv_get_options(); |
264 | 264 | $raw_referrer = wp_get_raw_referer(); |
265 | 265 | |
266 | - if ( empty( $raw_referrer ) ) { |
|
267 | - return array_merge( $wpinv_options, $input ); |
|
266 | + if (empty($raw_referrer)) { |
|
267 | + return array_merge($wpinv_options, $input); |
|
268 | 268 | } |
269 | 269 | |
270 | - wp_parse_str( $raw_referrer, $referrer ); |
|
270 | + wp_parse_str($raw_referrer, $referrer); |
|
271 | 271 | |
272 | - if ( in_array( 'gp-setup', $referrer ) ) { |
|
273 | - return array_merge( $wpinv_options, $input ); |
|
272 | + if (in_array('gp-setup', $referrer)) { |
|
273 | + return array_merge($wpinv_options, $input); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | $settings = wpinv_get_registered_settings(); |
277 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
278 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
277 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
278 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
279 | 279 | |
280 | 280 | $input = $input ? $input : array(); |
281 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
282 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
281 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
282 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
283 | 283 | |
284 | 284 | // Loop through each setting being saved and pass it through a sanitization filter |
285 | - foreach ( $input as $key => $value ) { |
|
285 | + foreach ($input as $key => $value) { |
|
286 | 286 | |
287 | 287 | // Get the setting type (checkbox, select, etc) |
288 | - $type = isset( $settings[ $tab ][ $section ][ $key ]['type'] ) ? $settings[ $tab ][ $section ][ $key ]['type'] : false; |
|
288 | + $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false; |
|
289 | 289 | |
290 | - if ( $type ) { |
|
290 | + if ($type) { |
|
291 | 291 | // Field type specific filter |
292 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$type", $value, $key ); |
|
292 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$type", $value, $key); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | // General filter |
296 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
296 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
297 | 297 | |
298 | 298 | // Key specific filter. |
299 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
299 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | // Loop through the whitelist and unset any that are empty for the tab being saved |
303 | - $main_settings = isset( $settings[ $tab ] ) ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
304 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
303 | + $main_settings = isset($settings[$tab]) ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
304 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
305 | 305 | |
306 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
306 | + $found_settings = array_merge($main_settings, $section_settings); |
|
307 | 307 | |
308 | - if ( ! empty( $found_settings ) ) { |
|
309 | - foreach ( $found_settings as $key => $value ) { |
|
308 | + if (!empty($found_settings)) { |
|
309 | + foreach ($found_settings as $key => $value) { |
|
310 | 310 | |
311 | 311 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
312 | - if ( is_numeric( $key ) ) { |
|
312 | + if (is_numeric($key)) { |
|
313 | 313 | $key = $value['id']; |
314 | 314 | } |
315 | 315 | |
316 | - if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) { |
|
317 | - unset( $wpinv_options[ $key ] ); |
|
316 | + if (!isset($input[$key]) && isset($wpinv_options[$key])) { |
|
317 | + unset($wpinv_options[$key]); |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
322 | 322 | // Merge our new settings with the existing |
323 | - $output = array_merge( $wpinv_options, $input ); |
|
323 | + $output = array_merge($wpinv_options, $input); |
|
324 | 324 | |
325 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
325 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
326 | 326 | |
327 | 327 | return $output; |
328 | 328 | } |
329 | -add_filter( 'wpinv_settings_sanitize_text', 'trim', 10, 1 ); |
|
330 | -add_filter( 'wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount' ); |
|
329 | +add_filter('wpinv_settings_sanitize_text', 'trim', 10, 1); |
|
330 | +add_filter('wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount'); |
|
331 | 331 | |
332 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
333 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
332 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
333 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
334 | 334 | return $input; |
335 | 335 | } |
336 | 336 | |
337 | - $new_rates = ! empty( $_POST['tax_rates'] ) ? wp_kses_post_deep( array_values( $_POST['tax_rates'] ) ) : array(); |
|
337 | + $new_rates = !empty($_POST['tax_rates']) ? wp_kses_post_deep(array_values($_POST['tax_rates'])) : array(); |
|
338 | 338 | $tax_rates = array(); |
339 | 339 | |
340 | - foreach ( $new_rates as $rate ) { |
|
340 | + foreach ($new_rates as $rate) { |
|
341 | 341 | |
342 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
343 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
344 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
345 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
346 | - $rate['global'] = empty( $rate['state'] ); |
|
342 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate']); |
|
343 | + $rate['name'] = sanitize_text_field($rate['name']); |
|
344 | + $rate['state'] = sanitize_text_field($rate['state']); |
|
345 | + $rate['country'] = sanitize_text_field($rate['country']); |
|
346 | + $rate['global'] = empty($rate['state']); |
|
347 | 347 | $tax_rates[] = $rate; |
348 | 348 | |
349 | 349 | } |
350 | 350 | |
351 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
351 | + update_option('wpinv_tax_rates', $tax_rates); |
|
352 | 352 | |
353 | 353 | return $input; |
354 | 354 | } |
355 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
355 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
356 | 356 | |
357 | 357 | function wpinv_get_settings_tabs() { |
358 | 358 | $tabs = array(); |
359 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
360 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
361 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
362 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
359 | + $tabs['general'] = __('General', 'invoicing'); |
|
360 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
361 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
362 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
363 | 363 | |
364 | - if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
365 | - $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
364 | + if (count(getpaid_get_integration_settings()) > 0) { |
|
365 | + $tabs['integrations'] = __('Integrations', 'invoicing'); |
|
366 | 366 | } |
367 | 367 | |
368 | - $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
|
369 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
370 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
368 | + $tabs['privacy'] = __('Privacy', 'invoicing'); |
|
369 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
370 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
371 | 371 | |
372 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
372 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
373 | 373 | } |
374 | 374 | |
375 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
375 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
376 | 376 | $tabs = false; |
377 | 377 | $sections = wpinv_get_registered_settings_sections(); |
378 | 378 | |
379 | - if ( $tab && ! empty( $sections[ $tab ] ) ) { |
|
380 | - $tabs = $sections[ $tab ]; |
|
379 | + if ($tab && !empty($sections[$tab])) { |
|
380 | + $tabs = $sections[$tab]; |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | return $tabs; |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | function wpinv_get_registered_settings_sections() { |
387 | 387 | static $sections = false; |
388 | 388 | |
389 | - if ( false !== $sections ) { |
|
389 | + if (false !== $sections) { |
|
390 | 390 | return $sections; |
391 | 391 | } |
392 | 392 | |
@@ -394,230 +394,230 @@ discard block |
||
394 | 394 | 'general' => apply_filters( |
395 | 395 | 'wpinv_settings_sections_general', |
396 | 396 | array( |
397 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
398 | - 'page_section' => __( 'Page Settings', 'invoicing' ), |
|
399 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
400 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
397 | + 'main' => __('General Settings', 'invoicing'), |
|
398 | + 'page_section' => __('Page Settings', 'invoicing'), |
|
399 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
400 | + 'labels' => __('Label Texts', 'invoicing'), |
|
401 | 401 | ) |
402 | 402 | ), |
403 | 403 | 'gateways' => apply_filters( |
404 | 404 | 'wpinv_settings_sections_gateways', |
405 | 405 | array( |
406 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
406 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
407 | 407 | ) |
408 | 408 | ), |
409 | 409 | 'taxes' => apply_filters( |
410 | 410 | 'wpinv_settings_sections_taxes', |
411 | 411 | array( |
412 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
413 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
414 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ), |
|
412 | + 'main' => __('Tax Settings', 'invoicing'), |
|
413 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
414 | + 'vat' => __('EU VAT Settings', 'invoicing'), |
|
415 | 415 | ) |
416 | 416 | ), |
417 | 417 | 'emails' => apply_filters( |
418 | 418 | 'wpinv_settings_sections_emails', |
419 | 419 | array( |
420 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
420 | + 'main' => __('Email Settings', 'invoicing'), |
|
421 | 421 | ) |
422 | 422 | ), |
423 | 423 | |
424 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
424 | + 'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'), |
|
425 | 425 | |
426 | 426 | 'privacy' => apply_filters( |
427 | 427 | 'wpinv_settings_sections_privacy', |
428 | 428 | array( |
429 | - 'main' => __( 'Privacy policy', 'invoicing' ), |
|
429 | + 'main' => __('Privacy policy', 'invoicing'), |
|
430 | 430 | ) |
431 | 431 | ), |
432 | 432 | 'misc' => apply_filters( |
433 | 433 | 'wpinv_settings_sections_misc', |
434 | 434 | array( |
435 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
436 | - 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
435 | + 'main' => __('Miscellaneous', 'invoicing'), |
|
436 | + 'custom-css' => __('Custom CSS', 'invoicing'), |
|
437 | 437 | ) |
438 | 438 | ), |
439 | 439 | 'tools' => apply_filters( |
440 | 440 | 'wpinv_settings_sections_tools', |
441 | 441 | array( |
442 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
442 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
443 | 443 | ) |
444 | 444 | ), |
445 | 445 | ); |
446 | 446 | |
447 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
447 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
448 | 448 | |
449 | 449 | return $sections; |
450 | 450 | } |
451 | 451 | |
452 | -function wpinv_get_pages( $with_slug = false, $default_label = null ) { |
|
452 | +function wpinv_get_pages($with_slug = false, $default_label = null) { |
|
453 | 453 | $pages_options = array(); |
454 | 454 | |
455 | - if ( $default_label !== null && $default_label !== false ) { |
|
456 | - $pages_options = array( '' => $default_label ); // Blank option |
|
455 | + if ($default_label !== null && $default_label !== false) { |
|
456 | + $pages_options = array('' => $default_label); // Blank option |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | $pages = get_pages(); |
460 | - if ( $pages ) { |
|
461 | - foreach ( $pages as $page ) { |
|
460 | + if ($pages) { |
|
461 | + foreach ($pages as $page) { |
|
462 | 462 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
463 | - $pages_options[ $page->ID ] = $title; |
|
463 | + $pages_options[$page->ID] = $title; |
|
464 | 464 | } |
465 | 465 | } |
466 | 466 | |
467 | 467 | return $pages_options; |
468 | 468 | } |
469 | 469 | |
470 | -function wpinv_header_callback( $args ) { |
|
471 | - if ( ! empty( $args['desc'] ) ) { |
|
472 | - echo wp_kses_post( $args['desc'] ); |
|
470 | +function wpinv_header_callback($args) { |
|
471 | + if (!empty($args['desc'])) { |
|
472 | + echo wp_kses_post($args['desc']); |
|
473 | 473 | } |
474 | 474 | } |
475 | 475 | |
476 | -function wpinv_hidden_callback( $args ) { |
|
476 | +function wpinv_hidden_callback($args) { |
|
477 | 477 | |
478 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
479 | - $value = wpinv_get_option( $args['id'], $std ); |
|
478 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
479 | + $value = wpinv_get_option($args['id'], $std); |
|
480 | 480 | |
481 | - if ( isset( $args['set_value'] ) ) { |
|
481 | + if (isset($args['set_value'])) { |
|
482 | 482 | $value = $args['set_value']; |
483 | 483 | } |
484 | 484 | |
485 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
485 | + if (isset($args['faux']) && true === $args['faux']) { |
|
486 | 486 | $args['readonly'] = true; |
487 | - $name = ''; |
|
487 | + $name = ''; |
|
488 | 488 | } else { |
489 | - $name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']'; |
|
489 | + $name = 'wpinv_settings[' . esc_attr($args['id']) . ']'; |
|
490 | 490 | } |
491 | 491 | |
492 | - echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
492 | + echo '<input type="hidden" id="wpinv_settings[' . esc_attr($args['id']) . ']" name="' . esc_attr($name) . '" value="' . esc_attr(stripslashes($value)) . '" />'; |
|
493 | 493 | |
494 | 494 | } |
495 | 495 | |
496 | 496 | /** |
497 | 497 | * Displays a checkbox settings callback. |
498 | 498 | */ |
499 | -function wpinv_checkbox_callback( $args ) { |
|
499 | +function wpinv_checkbox_callback($args) { |
|
500 | 500 | |
501 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
502 | - $std = wpinv_get_option( $args['id'], $std ); |
|
503 | - $id = esc_attr( $args['id'] ); |
|
501 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
502 | + $std = wpinv_get_option($args['id'], $std); |
|
503 | + $id = esc_attr($args['id']); |
|
504 | 504 | |
505 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
505 | + getpaid_hidden_field("wpinv_settings[$id]", '0'); |
|
506 | 506 | ?> |
507 | 507 | <fieldset> |
508 | 508 | <label> |
509 | - <input id="wpinv-settings-<?php echo esc_attr( $id ); ?>" name="wpinv_settings[<?php echo esc_attr( $id ); ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox"> |
|
510 | - <?php echo wp_kses_post( $args['desc'] ); ?> |
|
509 | + <input id="wpinv-settings-<?php echo esc_attr($id); ?>" name="wpinv_settings[<?php echo esc_attr($id); ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox"> |
|
510 | + <?php echo wp_kses_post($args['desc']); ?> |
|
511 | 511 | </label> |
512 | 512 | </fieldset> |
513 | 513 | <?php |
514 | 514 | } |
515 | 515 | |
516 | -function wpinv_multicheck_callback( $args ) { |
|
516 | +function wpinv_multicheck_callback($args) { |
|
517 | 517 | |
518 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
519 | - $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
518 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
519 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
520 | 520 | |
521 | - if ( ! empty( $args['options'] ) ) { |
|
521 | + if (!empty($args['options'])) { |
|
522 | 522 | |
523 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
524 | - $value = wpinv_get_option( $args['id'], $std ); |
|
523 | + $std = isset($args['std']) ? $args['std'] : array(); |
|
524 | + $value = wpinv_get_option($args['id'], $std); |
|
525 | 525 | |
526 | - echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">'; |
|
527 | - foreach ( $args['options'] as $key => $option ) : |
|
528 | - $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) ); |
|
529 | - if ( in_array( $sanitize_key, $value ) ) { |
|
526 | + echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr($sanitize_id . $class) . '">'; |
|
527 | + foreach ($args['options'] as $key => $option) : |
|
528 | + $sanitize_key = esc_attr(wpinv_sanitize_key($key)); |
|
529 | + if (in_array($sanitize_key, $value)) { |
|
530 | 530 | $enabled = $sanitize_key; |
531 | 531 | } else { |
532 | 532 | $enabled = null; |
533 | 533 | } |
534 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
535 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
534 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" id="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/> '; |
|
535 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']">' . wp_kses_post($option) . '</label></div>'; |
|
536 | 536 | endforeach; |
537 | 537 | echo '</div>'; |
538 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
538 | + echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>'; |
|
539 | 539 | } |
540 | 540 | } |
541 | 541 | |
542 | -function wpinv_payment_icons_callback( $args ) { |
|
542 | +function wpinv_payment_icons_callback($args) { |
|
543 | 543 | |
544 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
545 | - $value = wpinv_get_option( $args['id'], false ); |
|
544 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
545 | + $value = wpinv_get_option($args['id'], false); |
|
546 | 546 | |
547 | - if ( ! empty( $args['options'] ) ) { |
|
548 | - foreach ( $args['options'] as $key => $option ) { |
|
549 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
547 | + if (!empty($args['options'])) { |
|
548 | + foreach ($args['options'] as $key => $option) { |
|
549 | + $sanitize_key = wpinv_sanitize_key($key); |
|
550 | 550 | |
551 | - if ( empty( $value ) ) { |
|
551 | + if (empty($value)) { |
|
552 | 552 | $enabled = $option; |
553 | 553 | } else { |
554 | 554 | $enabled = null; |
555 | 555 | } |
556 | 556 | |
557 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
557 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
558 | 558 | |
559 | - echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
559 | + echo '<input name="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" id="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/> '; |
|
560 | 560 | |
561 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
562 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
561 | + if (wpinv_string_is_image_url($key)) { |
|
562 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
563 | 563 | } else { |
564 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
564 | + $card = strtolower(str_replace(' ', '', $option)); |
|
565 | 565 | |
566 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
567 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
566 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
567 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
568 | 568 | } else { |
569 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
569 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
570 | 570 | $content_dir = WP_CONTENT_DIR; |
571 | 571 | |
572 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
572 | + if (function_exists('wp_normalize_path')) { |
|
573 | 573 | // Replaces backslashes with forward slashes for Windows systems |
574 | - $image = wp_normalize_path( $image ); |
|
575 | - $content_dir = wp_normalize_path( $content_dir ); |
|
574 | + $image = wp_normalize_path($image); |
|
575 | + $content_dir = wp_normalize_path($content_dir); |
|
576 | 576 | } |
577 | 577 | |
578 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
578 | + $image = str_replace($content_dir, content_url(), $image); |
|
579 | 579 | } |
580 | 580 | |
581 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
581 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
582 | 582 | } |
583 | - echo wp_kses_post( $option ) . '</label>'; |
|
583 | + echo wp_kses_post($option) . '</label>'; |
|
584 | 584 | } |
585 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
585 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
586 | 586 | } |
587 | 587 | } |
588 | 588 | |
589 | 589 | /** |
590 | 590 | * Displays a radio settings field. |
591 | 591 | */ |
592 | -function wpinv_radio_callback( $args ) { |
|
592 | +function wpinv_radio_callback($args) { |
|
593 | 593 | |
594 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
595 | - $std = wpinv_get_option( $args['id'], $std ); |
|
594 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
595 | + $std = wpinv_get_option($args['id'], $std); |
|
596 | 596 | ?> |
597 | 597 | <fieldset> |
598 | - <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
|
599 | - <?php foreach ( $args['options'] as $key => $option ) : ?> |
|
598 | + <ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;"> |
|
599 | + <?php foreach ($args['options'] as $key => $option) : ?> |
|
600 | 600 | <li> |
601 | 601 | <label> |
602 | - <input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio"> |
|
603 | - <?php echo wp_kses_post( $option ); ?> |
|
602 | + <input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio"> |
|
603 | + <?php echo wp_kses_post($option); ?> |
|
604 | 604 | </label> |
605 | 605 | </li> |
606 | 606 | <?php endforeach; ?> |
607 | 607 | </ul> |
608 | 608 | </fieldset> |
609 | 609 | <?php |
610 | - getpaid_settings_description_callback( $args ); |
|
610 | + getpaid_settings_description_callback($args); |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | /** |
614 | 614 | * Displays a description if available. |
615 | 615 | */ |
616 | -function getpaid_settings_description_callback( $args ) { |
|
616 | +function getpaid_settings_description_callback($args) { |
|
617 | 617 | |
618 | - if ( ! empty( $args['desc'] ) ) { |
|
618 | + if (!empty($args['desc'])) { |
|
619 | 619 | $description = $args['desc']; |
620 | - echo wp_kses_post( "<p class='description'>$description</p>" ); |
|
620 | + echo wp_kses_post("<p class='description'>$description</p>"); |
|
621 | 621 | } |
622 | 622 | |
623 | 623 | } |
@@ -632,35 +632,35 @@ discard block |
||
632 | 632 | </tr> |
633 | 633 | <tr class="bsui"> |
634 | 634 | <td colspan="2" class="p-0"> |
635 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-gateways-edit.php'; ?> |
|
635 | + <?php include plugin_dir_path(__FILE__) . 'views/html-gateways-edit.php'; ?> |
|
636 | 636 | |
637 | 637 | <?php |
638 | 638 | } |
639 | 639 | |
640 | -function wpinv_gateway_select_callback( $args ) { |
|
640 | +function wpinv_gateway_select_callback($args) { |
|
641 | 641 | |
642 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
643 | - $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
644 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
645 | - $value = wpinv_get_option( $args['id'], $std ); |
|
642 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
643 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
644 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
645 | + $value = wpinv_get_option($args['id'], $std); |
|
646 | 646 | |
647 | - echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >'; |
|
647 | + echo '<select name="wpinv_settings[' . esc_attr($sanitize_id) . ']"" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" class="' . esc_attr($class) . '" >'; |
|
648 | 648 | |
649 | - foreach ( $args['options'] as $key => $option ) : |
|
649 | + foreach ($args['options'] as $key => $option) : |
|
650 | 650 | |
651 | - echo '<option value="' . esc_attr( $key ) . '" '; |
|
651 | + echo '<option value="' . esc_attr($key) . '" '; |
|
652 | 652 | |
653 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
654 | - selected( $key, $args['selected'] ); |
|
653 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
654 | + selected($key, $args['selected']); |
|
655 | 655 | } else { |
656 | - selected( $key, $value ); |
|
656 | + selected($key, $value); |
|
657 | 657 | } |
658 | 658 | |
659 | - echo '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
659 | + echo '>' . esc_html($option['admin_label']) . '</option>'; |
|
660 | 660 | endforeach; |
661 | 661 | |
662 | 662 | echo '</select>'; |
663 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
663 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | /** |
@@ -669,28 +669,28 @@ discard block |
||
669 | 669 | * @param array $args |
670 | 670 | * @return string |
671 | 671 | */ |
672 | -function wpinv_settings_attrs_helper( $args ) { |
|
672 | +function wpinv_settings_attrs_helper($args) { |
|
673 | 673 | |
674 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
675 | - $id = esc_attr( $args['id'] ); |
|
676 | - $placeholder = esc_attr( $args['placeholder'] ); |
|
674 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
675 | + $id = esc_attr($args['id']); |
|
676 | + $placeholder = esc_attr($args['placeholder']); |
|
677 | 677 | |
678 | - if ( ! empty( $args['faux'] ) ) { |
|
678 | + if (!empty($args['faux'])) { |
|
679 | 679 | $args['readonly'] = true; |
680 | 680 | $name = ''; |
681 | 681 | } else { |
682 | - $value = wpinv_get_option( $args['id'], $value ); |
|
682 | + $value = wpinv_get_option($args['id'], $value); |
|
683 | 683 | $name = "wpinv_settings[$id]"; |
684 | 684 | } |
685 | 685 | |
686 | - $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
687 | - $class = esc_attr( $args['class'] ); |
|
688 | - $style = esc_attr( $args['style'] ); |
|
689 | - $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
686 | + $value = is_scalar($value) ? esc_attr($value) : ''; |
|
687 | + $class = esc_attr($args['class']); |
|
688 | + $style = esc_attr($args['style']); |
|
689 | + $readonly = empty($args['readonly']) ? '' : 'readonly onclick="this.select()"'; |
|
690 | 690 | |
691 | 691 | $onchange = ''; |
692 | - if ( ! empty( $args['onchange'] ) ) { |
|
693 | - $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
692 | + if (!empty($args['onchange'])) { |
|
693 | + $onchange = ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
694 | 694 | } |
695 | 695 | |
696 | 696 | return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
@@ -699,14 +699,14 @@ discard block |
||
699 | 699 | /** |
700 | 700 | * Displays a text input settings callback. |
701 | 701 | */ |
702 | -function wpinv_text_callback( $args ) { |
|
702 | +function wpinv_text_callback($args) { |
|
703 | 703 | |
704 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
704 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
705 | 705 | |
706 | 706 | ?> |
707 | 707 | <label style="width: 100%;"> |
708 | - <input type="text" <?php echo wpinv_settings_attrs_helper( $args ); ?>> |
|
709 | - <?php echo wp_kses_post( $desc ); ?> |
|
708 | + <input type="text" <?php echo wpinv_settings_attrs_helper($args); ?>> |
|
709 | + <?php echo wp_kses_post($desc); ?> |
|
710 | 710 | </label> |
711 | 711 | <?php |
712 | 712 | |
@@ -715,49 +715,49 @@ discard block |
||
715 | 715 | /** |
716 | 716 | * Displays a number input settings callback. |
717 | 717 | */ |
718 | -function wpinv_number_callback( $args ) { |
|
718 | +function wpinv_number_callback($args) { |
|
719 | 719 | |
720 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
721 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
720 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
721 | + $attr = wpinv_settings_attrs_helper($args); |
|
722 | 722 | |
723 | 723 | ?> |
724 | 724 | <label style="width: 100%;"> |
725 | - <input type="number" step="<?php echo floatval( $args['step'] ); ?>" max="<?php echo intval( $args['max'] ); ?>" min="<?php echo intval( $args['min'] ); ?>" <?php echo $attr; ?>> |
|
726 | - <?php echo wp_kses_post( $desc ); ?> |
|
725 | + <input type="number" step="<?php echo floatval($args['step']); ?>" max="<?php echo intval($args['max']); ?>" min="<?php echo intval($args['min']); ?>" <?php echo $attr; ?>> |
|
726 | + <?php echo wp_kses_post($desc); ?> |
|
727 | 727 | </label> |
728 | 728 | <?php |
729 | 729 | |
730 | 730 | } |
731 | 731 | |
732 | -function wpinv_textarea_callback( $args ) { |
|
732 | +function wpinv_textarea_callback($args) { |
|
733 | 733 | |
734 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
735 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
736 | - $value = wpinv_get_option( $args['id'], $std ); |
|
734 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
735 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
736 | + $value = wpinv_get_option($args['id'], $std); |
|
737 | 737 | |
738 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
739 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
738 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
739 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
740 | 740 | |
741 | - echo '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
742 | - echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
741 | + echo '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
742 | + echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
743 | 743 | |
744 | 744 | } |
745 | 745 | |
746 | -function wpinv_password_callback( $args ) { |
|
746 | +function wpinv_password_callback($args) { |
|
747 | 747 | |
748 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
749 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
750 | - $value = wpinv_get_option( $args['id'], $std ); |
|
748 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
749 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
750 | + $value = wpinv_get_option($args['id'], $std); |
|
751 | 751 | |
752 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
753 | - echo '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
754 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
752 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
753 | + echo '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>'; |
|
754 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
755 | 755 | |
756 | 756 | } |
757 | 757 | |
758 | -function wpinv_missing_callback( $args ) { |
|
758 | +function wpinv_missing_callback($args) { |
|
759 | 759 | printf( |
760 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
760 | + __('The callback function used for the %s setting is missing.', 'invoicing'), |
|
761 | 761 | '<strong>' . $args['id'] . '</strong>' |
762 | 762 | ); |
763 | 763 | } |
@@ -765,35 +765,35 @@ discard block |
||
765 | 765 | /** |
766 | 766 | * Displays a number input settings callback. |
767 | 767 | */ |
768 | -function wpinv_select_callback( $args ) { |
|
768 | +function wpinv_select_callback($args) { |
|
769 | 769 | |
770 | - $desc = wp_kses_post( $args['desc'] ); |
|
771 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
772 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
773 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
774 | - $value = wpinv_get_option( $args['id'], $value ); |
|
775 | - $rand = uniqid( 'random_id' ); |
|
770 | + $desc = wp_kses_post($args['desc']); |
|
771 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
772 | + $attr = wpinv_settings_attrs_helper($args); |
|
773 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
774 | + $value = wpinv_get_option($args['id'], $value); |
|
775 | + $rand = uniqid('random_id'); |
|
776 | 776 | |
777 | 777 | ?> |
778 | 778 | <label style="width: 100%;"> |
779 | 779 | <select <?php echo $attr; ?> data-allow-clear="true"> |
780 | - <?php foreach ( $args['options'] as $option => $name ) : ?> |
|
781 | - <option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( $option, $value ); ?>><?php echo wpinv_clean( $name ); ?></option> |
|
780 | + <?php foreach ($args['options'] as $option => $name) : ?> |
|
781 | + <option value="<?php echo esc_attr($option); ?>" <?php echo selected($option, $value); ?>><?php echo wpinv_clean($name); ?></option> |
|
782 | 782 | <?php endforeach; ?> |
783 | 783 | </select> |
784 | 784 | |
785 | - <?php if ( substr( $args['id'], -5 ) === '_page' && is_numeric( $value ) ) : ?> |
|
786 | - <a href="<?php echo get_edit_post_link( $value ); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php esc_html_e( 'Edit Page', 'invoicing' ); ?></a> |
|
785 | + <?php if (substr($args['id'], -5) === '_page' && is_numeric($value)) : ?> |
|
786 | + <a href="<?php echo get_edit_post_link($value); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php esc_html_e('Edit Page', 'invoicing'); ?></a> |
|
787 | 787 | <?php endif; ?> |
788 | 788 | |
789 | - <?php if ( substr( $args['id'], -5 ) === '_page' && ! empty( $args['default_content'] ) ) : ?> |
|
790 | - <a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php esc_html_e( 'View Default Content', 'invoicing' ); ?></a> |
|
789 | + <?php if (substr($args['id'], -5) === '_page' && !empty($args['default_content'])) : ?> |
|
790 | + <a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php esc_html_e('View Default Content', 'invoicing'); ?></a> |
|
791 | 791 | <div id='<?php echo $rand; ?>' style='display:none;'> |
792 | 792 | <div> |
793 | - <h3><?php esc_html_e( 'Original Content', 'invoicing' ); ?></h3> |
|
794 | - <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines( wp_kses_post( $args['default_content'] ) ); ?></textarea> |
|
795 | - <h3><?php esc_html_e( 'Current Content', 'invoicing' ); ?></h3> |
|
796 | - <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post( $value ); echo empty( $_post ) ? '' : gepaid_trim_lines( wp_kses_post( $_post->post_content ) ); ?></textarea> |
|
793 | + <h3><?php esc_html_e('Original Content', 'invoicing'); ?></h3> |
|
794 | + <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines(wp_kses_post($args['default_content'])); ?></textarea> |
|
795 | + <h3><?php esc_html_e('Current Content', 'invoicing'); ?></h3> |
|
796 | + <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post($value); echo empty($_post) ? '' : gepaid_trim_lines(wp_kses_post($_post->post_content)); ?></textarea> |
|
797 | 797 | </div> |
798 | 798 | </div> |
799 | 799 | <?php endif; ?> |
@@ -804,89 +804,89 @@ discard block |
||
804 | 804 | |
805 | 805 | } |
806 | 806 | |
807 | -function wpinv_color_select_callback( $args ) { |
|
807 | +function wpinv_color_select_callback($args) { |
|
808 | 808 | |
809 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
810 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
811 | - $value = wpinv_get_option( $args['id'], $std ); |
|
809 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
810 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
811 | + $value = wpinv_get_option($args['id'], $std); |
|
812 | 812 | |
813 | - echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
813 | + echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
814 | 814 | |
815 | - foreach ( $args['options'] as $option => $color ) { |
|
816 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>'; |
|
815 | + foreach ($args['options'] as $option => $color) { |
|
816 | + echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($color['label']) . '</option>'; |
|
817 | 817 | } |
818 | 818 | |
819 | 819 | echo '</select>'; |
820 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
820 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
821 | 821 | |
822 | 822 | } |
823 | 823 | |
824 | -function wpinv_rich_editor_callback( $args ) { |
|
824 | +function wpinv_rich_editor_callback($args) { |
|
825 | 825 | global $wp_version; |
826 | 826 | |
827 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
827 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
828 | 828 | |
829 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
830 | - $value = wpinv_get_option( $args['id'], $std ); |
|
829 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
830 | + $value = wpinv_get_option($args['id'], $std); |
|
831 | 831 | |
832 | - if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
832 | + if (!empty($args['allow_blank']) && empty($value)) { |
|
833 | 833 | $value = $std; |
834 | 834 | } |
835 | 835 | |
836 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
836 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
837 | 837 | |
838 | 838 | echo '<div class="getpaid-settings-editor-input">'; |
839 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
839 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
840 | 840 | wp_editor( |
841 | - stripslashes( $value ), |
|
842 | - 'wpinv_settings_' . esc_attr( $args['id'] ), |
|
841 | + stripslashes($value), |
|
842 | + 'wpinv_settings_' . esc_attr($args['id']), |
|
843 | 843 | array( |
844 | - 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', |
|
845 | - 'textarea_rows' => absint( $rows ), |
|
844 | + 'textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', |
|
845 | + 'textarea_rows' => absint($rows), |
|
846 | 846 | 'media_buttons' => false, |
847 | 847 | ) |
848 | 848 | ); |
849 | 849 | } else { |
850 | - echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
850 | + echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
851 | 851 | } |
852 | 852 | |
853 | - echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
853 | + echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
854 | 854 | |
855 | 855 | } |
856 | 856 | |
857 | -function wpinv_upload_callback( $args ) { |
|
857 | +function wpinv_upload_callback($args) { |
|
858 | 858 | |
859 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
859 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
860 | 860 | |
861 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
862 | - $value = wpinv_get_option( $args['id'], $std ); |
|
861 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
862 | + $value = wpinv_get_option($args['id'], $std); |
|
863 | 863 | |
864 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
865 | - echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
866 | - echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
867 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
864 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
865 | + echo '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
866 | + echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>'; |
|
867 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
868 | 868 | |
869 | 869 | } |
870 | 870 | |
871 | -function wpinv_color_callback( $args ) { |
|
871 | +function wpinv_color_callback($args) { |
|
872 | 872 | |
873 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
874 | - $value = wpinv_get_option( $args['id'], $std ); |
|
875 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
873 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
874 | + $value = wpinv_get_option($args['id'], $std); |
|
875 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
876 | 876 | |
877 | - echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />'; |
|
878 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
877 | + echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($std) . '" />'; |
|
878 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
879 | 879 | |
880 | 880 | } |
881 | 881 | |
882 | -function wpinv_country_states_callback( $args ) { |
|
882 | +function wpinv_country_states_callback($args) { |
|
883 | 883 | |
884 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
885 | - $value = wpinv_get_option( $args['id'], $std ); |
|
884 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
885 | + $value = wpinv_get_option($args['id'], $std); |
|
886 | 886 | |
887 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
887 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
888 | 888 | |
889 | - if ( isset( $args['placeholder'] ) ) { |
|
889 | + if (isset($args['placeholder'])) { |
|
890 | 890 | $placeholder = $args['placeholder']; |
891 | 891 | } else { |
892 | 892 | $placeholder = ''; |
@@ -894,15 +894,15 @@ discard block |
||
894 | 894 | |
895 | 895 | $states = wpinv_get_country_states(); |
896 | 896 | |
897 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
898 | - echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
897 | + $class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
898 | + echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
899 | 899 | |
900 | - foreach ( $states as $option => $name ) { |
|
901 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>'; |
|
900 | + foreach ($states as $option => $name) { |
|
901 | + echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($name) . '</option>'; |
|
902 | 902 | } |
903 | 903 | |
904 | 904 | echo '</select>'; |
905 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
905 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
906 | 906 | |
907 | 907 | } |
908 | 908 | |
@@ -916,7 +916,7 @@ discard block |
||
916 | 916 | </tr> |
917 | 917 | <tr class="bsui"> |
918 | 918 | <td colspan="2" class="p-0"> |
919 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?> |
|
919 | + <?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?> |
|
920 | 920 | |
921 | 921 | <?php |
922 | 922 | |
@@ -925,14 +925,14 @@ discard block |
||
925 | 925 | /** |
926 | 926 | * Displays a tax rate' edit row. |
927 | 927 | */ |
928 | -function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) { |
|
928 | +function wpinv_tax_rate_callback($tax_rate, $key, $echo = true) { |
|
929 | 929 | ob_start(); |
930 | 930 | |
931 | - $key = sanitize_key( $key ); |
|
932 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
933 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
931 | + $key = sanitize_key($key); |
|
932 | + $tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate']; |
|
933 | + include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php'; |
|
934 | 934 | |
935 | - if ( $echo ) { |
|
935 | + if ($echo) { |
|
936 | 936 | echo ob_get_clean(); |
937 | 937 | } else { |
938 | 938 | return ob_get_clean(); |
@@ -941,152 +941,152 @@ discard block |
||
941 | 941 | } |
942 | 942 | |
943 | 943 | |
944 | -function wpinv_tools_callback( $args ) { |
|
944 | +function wpinv_tools_callback($args) { |
|
945 | 945 | ?> |
946 | 946 | </td><tr> |
947 | 947 | <td colspan="2" class="wpinv_tools_tdbox"> |
948 | 948 | <?php |
949 | - if ( $args['desc'] ) { |
|
949 | + if ($args['desc']) { |
|
950 | 950 | ?> |
951 | 951 | <p><?php echo $args['desc']; ?></p><?php } ?> |
952 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
952 | + <?php do_action('wpinv_tools_before'); ?> |
|
953 | 953 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
954 | 954 | <thead> |
955 | 955 | <tr> |
956 | - <th scope="col" class="wpinv-th-tool"><?php esc_html_e( 'Tool', 'invoicing' ); ?></th> |
|
957 | - <th scope="col" class="wpinv-th-desc"><?php esc_html_e( 'Description', 'invoicing' ); ?></th> |
|
958 | - <th scope="col" class="wpinv-th-action"><?php esc_html_e( 'Action', 'invoicing' ); ?></th> |
|
956 | + <th scope="col" class="wpinv-th-tool"><?php esc_html_e('Tool', 'invoicing'); ?></th> |
|
957 | + <th scope="col" class="wpinv-th-desc"><?php esc_html_e('Description', 'invoicing'); ?></th> |
|
958 | + <th scope="col" class="wpinv-th-action"><?php esc_html_e('Action', 'invoicing'); ?></th> |
|
959 | 959 | </tr> |
960 | 960 | </thead> |
961 | 961 | |
962 | 962 | <tbody> |
963 | 963 | <tr> |
964 | - <td><?php esc_html_e( 'Check Pages', 'invoicing' ); ?></td> |
|
964 | + <td><?php esc_html_e('Check Pages', 'invoicing'); ?></td> |
|
965 | 965 | <td> |
966 | - <small><?php esc_html_e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small> |
|
966 | + <small><?php esc_html_e('Creates any missing GetPaid pages.', 'invoicing'); ?></small> |
|
967 | 967 | </td> |
968 | 968 | <td> |
969 | 969 | <a href=" |
970 | 970 | <?php |
971 | 971 | echo esc_url( |
972 | 972 | wp_nonce_url( |
973 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
973 | + add_query_arg('getpaid-admin-action', 'create_missing_pages'), |
|
974 | 974 | 'getpaid-nonce', |
975 | 975 | 'getpaid-nonce' |
976 | 976 | ) |
977 | 977 | ); |
978 | 978 | ?> |
979 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
979 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
980 | 980 | </td> |
981 | 981 | </tr> |
982 | 982 | <tr> |
983 | - <td><?php esc_html_e( 'Create Database Tables', 'invoicing' ); ?></td> |
|
983 | + <td><?php esc_html_e('Create Database Tables', 'invoicing'); ?></td> |
|
984 | 984 | <td> |
985 | - <small><?php esc_html_e( 'Run this tool to create any missing database tables.', 'invoicing' ); ?></small> |
|
985 | + <small><?php esc_html_e('Run this tool to create any missing database tables.', 'invoicing'); ?></small> |
|
986 | 986 | </td> |
987 | 987 | <td> |
988 | 988 | <a href=" |
989 | 989 | <?php |
990 | 990 | echo esc_url( |
991 | 991 | wp_nonce_url( |
992 | - add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
992 | + add_query_arg('getpaid-admin-action', 'create_missing_tables'), |
|
993 | 993 | 'getpaid-nonce', |
994 | 994 | 'getpaid-nonce' |
995 | 995 | ) |
996 | 996 | ); |
997 | 997 | ?> |
998 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
998 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
999 | 999 | </td> |
1000 | 1000 | </tr> |
1001 | 1001 | <tr> |
1002 | - <td><?php esc_html_e( 'Migrate old invoices', 'invoicing' ); ?></td> |
|
1002 | + <td><?php esc_html_e('Migrate old invoices', 'invoicing'); ?></td> |
|
1003 | 1003 | <td> |
1004 | - <small><?php esc_html_e( 'If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing' ); ?></small> |
|
1004 | + <small><?php esc_html_e('If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing'); ?></small> |
|
1005 | 1005 | </td> |
1006 | 1006 | <td> |
1007 | 1007 | <a href=" |
1008 | 1008 | <?php |
1009 | 1009 | echo esc_url( |
1010 | 1010 | wp_nonce_url( |
1011 | - add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
1011 | + add_query_arg('getpaid-admin-action', 'migrate_old_invoices'), |
|
1012 | 1012 | 'getpaid-nonce', |
1013 | 1013 | 'getpaid-nonce' |
1014 | 1014 | ) |
1015 | 1015 | ); |
1016 | 1016 | ?> |
1017 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1017 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1018 | 1018 | </td> |
1019 | 1019 | </tr> |
1020 | 1020 | |
1021 | 1021 | <tr> |
1022 | - <td><?php esc_html_e( 'Recalculate Discounts', 'invoicing' ); ?></td> |
|
1022 | + <td><?php esc_html_e('Recalculate Discounts', 'invoicing'); ?></td> |
|
1023 | 1023 | <td> |
1024 | - <small><?php esc_html_e( 'Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing' ); ?></small> |
|
1024 | + <small><?php esc_html_e('Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing'); ?></small> |
|
1025 | 1025 | </td> |
1026 | 1026 | <td> |
1027 | 1027 | <a href=" |
1028 | 1028 | <?php |
1029 | 1029 | echo esc_url( |
1030 | 1030 | wp_nonce_url( |
1031 | - add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
1031 | + add_query_arg('getpaid-admin-action', 'recalculate_discounts'), |
|
1032 | 1032 | 'getpaid-nonce', |
1033 | 1033 | 'getpaid-nonce' |
1034 | 1034 | ) |
1035 | 1035 | ); |
1036 | 1036 | ?> |
1037 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1037 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1038 | 1038 | </td> |
1039 | 1039 | </tr> |
1040 | 1040 | |
1041 | 1041 | <tr> |
1042 | - <td><?php esc_html_e( 'Set-up Wizard', 'invoicing' ); ?></td> |
|
1042 | + <td><?php esc_html_e('Set-up Wizard', 'invoicing'); ?></td> |
|
1043 | 1043 | <td> |
1044 | - <small><?php esc_html_e( 'Launch the quick set-up wizard.', 'invoicing' ); ?></small> |
|
1044 | + <small><?php esc_html_e('Launch the quick set-up wizard.', 'invoicing'); ?></small> |
|
1045 | 1045 | </td> |
1046 | 1046 | <td> |
1047 | 1047 | <a href=" |
1048 | 1048 | <?php |
1049 | - echo esc_url( admin_url( 'index.php?page=gp-setup' ) ); |
|
1049 | + echo esc_url(admin_url('index.php?page=gp-setup')); |
|
1050 | 1050 | ?> |
1051 | - " class="button button-primary"><?php esc_html_e( 'Launch', 'invoicing' ); ?></a> |
|
1051 | + " class="button button-primary"><?php esc_html_e('Launch', 'invoicing'); ?></a> |
|
1052 | 1052 | </td> |
1053 | 1053 | </tr> |
1054 | 1054 | |
1055 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
1055 | + <?php do_action('wpinv_tools_row'); ?> |
|
1056 | 1056 | </tbody> |
1057 | 1057 | </table> |
1058 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
1058 | + <?php do_action('wpinv_tools_after'); ?> |
|
1059 | 1059 | <?php |
1060 | 1060 | } |
1061 | 1061 | |
1062 | 1062 | |
1063 | -function wpinv_descriptive_text_callback( $args ) { |
|
1064 | - echo wp_kses_post( $args['desc'] ); |
|
1063 | +function wpinv_descriptive_text_callback($args) { |
|
1064 | + echo wp_kses_post($args['desc']); |
|
1065 | 1065 | } |
1066 | 1066 | |
1067 | -function wpinv_raw_html_callback( $args ) { |
|
1068 | - echo wp_kses_post( $args['desc'] ); |
|
1067 | +function wpinv_raw_html_callback($args) { |
|
1068 | + echo wp_kses_post($args['desc']); |
|
1069 | 1069 | } |
1070 | 1070 | |
1071 | -function wpinv_hook_callback( $args ) { |
|
1072 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1071 | +function wpinv_hook_callback($args) { |
|
1072 | + do_action('wpinv_' . $args['id'], $args); |
|
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | function wpinv_set_settings_cap() { |
1076 | 1076 | return wpinv_get_capability(); |
1077 | 1077 | } |
1078 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
1078 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
1079 | 1079 | |
1080 | 1080 | |
1081 | -function wpinv_on_update_settings( $old_value, $value, $option ) { |
|
1082 | - $old = ! empty( $old_value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1083 | - $new = ! empty( $value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1081 | +function wpinv_on_update_settings($old_value, $value, $option) { |
|
1082 | + $old = !empty($old_value['remove_data_on_unistall']) ? 1 : ''; |
|
1083 | + $new = !empty($value['remove_data_on_unistall']) ? 1 : ''; |
|
1084 | 1084 | |
1085 | - if ( $old != $new ) { |
|
1086 | - update_option( 'wpinv_remove_data_on_invoice_unistall', $new ); |
|
1085 | + if ($old != $new) { |
|
1086 | + update_option('wpinv_remove_data_on_invoice_unistall', $new); |
|
1087 | 1087 | } |
1088 | 1088 | } |
1089 | -add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 ); |
|
1089 | +add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3); |
|
1090 | 1090 | |
1091 | 1091 | /** |
1092 | 1092 | * Returns the merge tags help text. |
@@ -1095,16 +1095,16 @@ discard block |
||
1095 | 1095 | * |
1096 | 1096 | * @return string |
1097 | 1097 | */ |
1098 | -function wpinv_get_merge_tags_help_text( $subscription = false ) { |
|
1098 | +function wpinv_get_merge_tags_help_text($subscription = false) { |
|
1099 | 1099 | |
1100 | 1100 | $url = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f'; |
1101 | 1101 | $link = sprintf( |
1102 | 1102 | '<strong><a href="%s" target="_blank">%s</a></strong>', |
1103 | 1103 | $url, |
1104 | - esc_html__( 'View available merge tags.', 'wpinv-quotes' ) |
|
1104 | + esc_html__('View available merge tags.', 'wpinv-quotes') |
|
1105 | 1105 | ); |
1106 | 1106 | |
1107 | - $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
1107 | + $description = esc_html__('The content of the email (Merge Tags and HTML are allowed).', 'invoicing'); |
|
1108 | 1108 | |
1109 | 1109 | return "$description $link"; |
1110 | 1110 |
@@ -1,51 +1,51 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( ! defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | -add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' ); |
|
8 | -function wpinv_discount_custom_column( $column ) { |
|
7 | +add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column'); |
|
8 | +function wpinv_discount_custom_column($column) { |
|
9 | 9 | global $post; |
10 | 10 | |
11 | - $discount = new WPInv_Discount( $post ); |
|
11 | + $discount = new WPInv_Discount($post); |
|
12 | 12 | |
13 | - switch ( $column ) { |
|
13 | + switch ($column) { |
|
14 | 14 | case 'code': |
15 | - echo esc_html( $discount->get_code() ); |
|
15 | + echo esc_html($discount->get_code()); |
|
16 | 16 | break; |
17 | 17 | case 'amount': |
18 | - echo wp_kses_post( $discount->get_formatted_amount() ); |
|
18 | + echo wp_kses_post($discount->get_formatted_amount()); |
|
19 | 19 | break; |
20 | 20 | case 'usage': |
21 | - echo wp_kses_post( $discount->get_usage() ); |
|
21 | + echo wp_kses_post($discount->get_usage()); |
|
22 | 22 | break; |
23 | 23 | case 'start_date': |
24 | - echo wp_kses_post( getpaid_format_date_value( $discount->get_start_date() ) ); |
|
24 | + echo wp_kses_post(getpaid_format_date_value($discount->get_start_date())); |
|
25 | 25 | break; |
26 | 26 | case 'expiry_date': |
27 | - echo wp_kses_post( getpaid_format_date_value( $discount->get_expiration_date(), __( 'Never', 'invoicing' ) ) ); |
|
27 | + echo wp_kses_post(getpaid_format_date_value($discount->get_expiration_date(), __('Never', 'invoicing'))); |
|
28 | 28 | break; |
29 | 29 | } |
30 | 30 | } |
31 | 31 | |
32 | -add_filter( 'post_row_actions', 'wpinv_post_row_actions', 90, 2 ); |
|
33 | -function wpinv_post_row_actions( $actions, $post ) { |
|
34 | - $post_type = ! empty( $post->post_type ) ? $post->post_type : ''; |
|
32 | +add_filter('post_row_actions', 'wpinv_post_row_actions', 90, 2); |
|
33 | +function wpinv_post_row_actions($actions, $post) { |
|
34 | + $post_type = !empty($post->post_type) ? $post->post_type : ''; |
|
35 | 35 | |
36 | - if ( $post_type == 'wpi_discount' ) { |
|
37 | - $actions = wpinv_discount_row_actions( $post, $actions ); |
|
36 | + if ($post_type == 'wpi_discount') { |
|
37 | + $actions = wpinv_discount_row_actions($post, $actions); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | return $actions; |
41 | 41 | } |
42 | 42 | |
43 | -function wpinv_discount_row_actions( $discount, $row_actions ) { |
|
44 | - $row_actions = array(); |
|
45 | - $edit_link = get_edit_post_link( $discount->ID ); |
|
46 | - $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>'; |
|
43 | +function wpinv_discount_row_actions($discount, $row_actions) { |
|
44 | + $row_actions = array(); |
|
45 | + $edit_link = get_edit_post_link($discount->ID); |
|
46 | + $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>'; |
|
47 | 47 | |
48 | - if ( in_array( strtolower( $discount->post_status ), array( 'publish' ) ) ) { |
|
48 | + if (in_array(strtolower($discount->post_status), array('publish'))) { |
|
49 | 49 | |
50 | 50 | $url = wp_nonce_url( |
51 | 51 | add_query_arg( |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | 'getpaid-nonce', |
58 | 58 | 'getpaid-nonce' |
59 | 59 | ); |
60 | - $anchor = __( 'Deactivate', 'invoicing' ); |
|
61 | - $title = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' ); |
|
60 | + $anchor = __('Deactivate', 'invoicing'); |
|
61 | + $title = esc_attr__('Are you sure you want to deactivate this discount?', 'invoicing'); |
|
62 | 62 | $row_actions['deactivate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
63 | 63 | |
64 | - } elseif ( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) ) { |
|
64 | + } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) { |
|
65 | 65 | |
66 | - $url = wp_nonce_url( |
|
66 | + $url = wp_nonce_url( |
|
67 | 67 | add_query_arg( |
68 | 68 | array( |
69 | 69 | 'getpaid-admin-action' => 'activate_discount', |
@@ -73,13 +73,13 @@ discard block |
||
73 | 73 | 'getpaid-nonce', |
74 | 74 | 'getpaid-nonce' |
75 | 75 | ); |
76 | - $anchor = __( 'Activate', 'invoicing' ); |
|
77 | - $title = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' ); |
|
76 | + $anchor = __('Activate', 'invoicing'); |
|
77 | + $title = esc_attr__('Are you sure you want to activate this discount?', 'invoicing'); |
|
78 | 78 | $row_actions['activate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
79 | 79 | |
80 | 80 | } |
81 | 81 | |
82 | - $url = esc_url( |
|
82 | + $url = esc_url( |
|
83 | 83 | wp_nonce_url( |
84 | 84 | add_query_arg( |
85 | 85 | array( |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | 'getpaid-nonce' |
92 | 92 | ) |
93 | 93 | ); |
94 | - $anchor = __( 'Delete', 'invoicing' ); |
|
95 | - $title = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' ); |
|
94 | + $anchor = __('Delete', 'invoicing'); |
|
95 | + $title = esc_attr__('Are you sure you want to delete this discount?', 'invoicing'); |
|
96 | 96 | $row_actions['delete'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
97 | 97 | |
98 | - $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount ); |
|
98 | + $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount); |
|
99 | 99 | |
100 | 100 | return $row_actions; |
101 | 101 | } |
@@ -103,68 +103,68 @@ discard block |
||
103 | 103 | function wpinv_restrict_manage_posts() { |
104 | 104 | global $typenow; |
105 | 105 | |
106 | - if ( 'wpi_discount' == $typenow ) { |
|
106 | + if ('wpi_discount' == $typenow) { |
|
107 | 107 | wpinv_discount_filters(); |
108 | 108 | } |
109 | 109 | } |
110 | -add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 ); |
|
110 | +add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10); |
|
111 | 111 | |
112 | 112 | function wpinv_discount_filters() { |
113 | 113 | |
114 | 114 | ?> |
115 | 115 | <select name="discount_type" id="dropdown_wpinv_discount_type"> |
116 | - <option value=""><?php esc_html_e( 'Show all types', 'invoicing' ); ?></option> |
|
116 | + <option value=""><?php esc_html_e('Show all types', 'invoicing'); ?></option> |
|
117 | 117 | <?php |
118 | 118 | $types = wpinv_get_discount_types(); |
119 | 119 | |
120 | - foreach ( $types as $name => $type ) { |
|
121 | - echo '<option value="' . esc_attr( $name ) . '"'; |
|
120 | + foreach ($types as $name => $type) { |
|
121 | + echo '<option value="' . esc_attr($name) . '"'; |
|
122 | 122 | |
123 | - if ( isset( $_GET['discount_type'] ) ) { |
|
124 | - selected( $name, sanitize_text_field( $_GET['discount_type'] ) ); |
|
123 | + if (isset($_GET['discount_type'])) { |
|
124 | + selected($name, sanitize_text_field($_GET['discount_type'])); |
|
125 | 125 | } |
126 | 126 | |
127 | - echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
|
127 | + echo '>' . esc_html__($type, 'invoicing') . '</option>'; |
|
128 | 128 | } |
129 | 129 | ?> |
130 | 130 | </select> |
131 | 131 | <?php |
132 | 132 | } |
133 | 133 | |
134 | -function wpinv_request( $vars ) { |
|
134 | +function wpinv_request($vars) { |
|
135 | 135 | global $typenow, $wp_post_statuses; |
136 | 136 | |
137 | - if ( getpaid_is_invoice_post_type( $typenow ) ) { |
|
138 | - if ( ! isset( $vars['post_status'] ) ) { |
|
139 | - $post_statuses = wpinv_get_invoice_statuses( false, false, $typenow ); |
|
137 | + if (getpaid_is_invoice_post_type($typenow)) { |
|
138 | + if (!isset($vars['post_status'])) { |
|
139 | + $post_statuses = wpinv_get_invoice_statuses(false, false, $typenow); |
|
140 | 140 | |
141 | - foreach ( $post_statuses as $status => $value ) { |
|
142 | - if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) { |
|
143 | - unset( $post_statuses[ $status ] ); |
|
141 | + foreach ($post_statuses as $status => $value) { |
|
142 | + if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) { |
|
143 | + unset($post_statuses[$status]); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | - $vars['post_status'] = array_keys( $post_statuses ); |
|
147 | + $vars['post_status'] = array_keys($post_statuses); |
|
148 | 148 | } |
149 | -} elseif ( 'wpi_discount' == $typenow ) { |
|
150 | - $meta_query = ! empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
149 | +} elseif ('wpi_discount' == $typenow) { |
|
150 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
151 | 151 | // Filter vat rule type |
152 | - if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) { |
|
152 | + if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') { |
|
153 | 153 | $meta_query[] = array( |
154 | 154 | 'key' => '_wpi_discount_type', |
155 | - 'value' => sanitize_key( urldecode( $_GET['discount_type'] ) ), |
|
155 | + 'value' => sanitize_key(urldecode($_GET['discount_type'])), |
|
156 | 156 | 'compare' => '=', |
157 | 157 | ); |
158 | 158 | } |
159 | 159 | |
160 | - if ( ! empty( $meta_query ) ) { |
|
160 | + if (!empty($meta_query)) { |
|
161 | 161 | $vars['meta_query'] = $meta_query; |
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | 165 | return $vars; |
166 | 166 | } |
167 | -add_filter( 'request', 'wpinv_request' ); |
|
167 | +add_filter('request', 'wpinv_request'); |
|
168 | 168 | |
169 | 169 | /** |
170 | 170 | * Create a page and store the ID in an option. |
@@ -176,61 +176,61 @@ discard block |
||
176 | 176 | * @param int $post_parent (default: 0) Parent for the new page |
177 | 177 | * @return int page ID |
178 | 178 | */ |
179 | -function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) { |
|
179 | +function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) { |
|
180 | 180 | global $wpdb; |
181 | 181 | |
182 | - $option_value = wpinv_get_option( $option ); |
|
182 | + $option_value = wpinv_get_option($option); |
|
183 | 183 | |
184 | - if ( ! empty( $option_value ) && ( $page_object = get_post( $option_value ) ) ) { |
|
185 | - if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) { |
|
184 | + if (!empty($option_value) && ($page_object = get_post($option_value))) { |
|
185 | + if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) { |
|
186 | 186 | // Valid page is already in place |
187 | 187 | return $page_object->ID; |
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
191 | - if ( ! empty( $post_parent ) ) { |
|
192 | - $page = get_page_by_path( $post_parent ); |
|
193 | - if ( $page ) { |
|
191 | + if (!empty($post_parent)) { |
|
192 | + $page = get_page_by_path($post_parent); |
|
193 | + if ($page) { |
|
194 | 194 | $post_parent = $page->ID; |
195 | 195 | } else { |
196 | 196 | $post_parent = ''; |
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
200 | - if ( strlen( $page_content ) > 0 ) { |
|
200 | + if (strlen($page_content) > 0) { |
|
201 | 201 | // Search for an existing page with the specified page content (typically a shortcode) |
202 | - $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); |
|
202 | + $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%")); |
|
203 | 203 | } else { |
204 | 204 | // Search for an existing page with the specified page slug |
205 | - $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug ) ); |
|
205 | + $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug)); |
|
206 | 206 | } |
207 | 207 | |
208 | - $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content ); |
|
208 | + $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content); |
|
209 | 209 | |
210 | - if ( $valid_page_found ) { |
|
211 | - if ( $option ) { |
|
212 | - wpinv_update_option( $option, $valid_page_found ); |
|
210 | + if ($valid_page_found) { |
|
211 | + if ($option) { |
|
212 | + wpinv_update_option($option, $valid_page_found); |
|
213 | 213 | } |
214 | 214 | return $valid_page_found; |
215 | 215 | } |
216 | 216 | |
217 | 217 | // Search for a matching valid trashed page |
218 | - if ( strlen( $page_content ) > 0 ) { |
|
218 | + if (strlen($page_content) > 0) { |
|
219 | 219 | // Search for an existing page with the specified page content (typically a shortcode) |
220 | - $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); |
|
220 | + $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%")); |
|
221 | 221 | } else { |
222 | 222 | // Search for an existing page with the specified page slug |
223 | - $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) ); |
|
223 | + $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug)); |
|
224 | 224 | } |
225 | 225 | |
226 | - if ( $trashed_page_found ) { |
|
226 | + if ($trashed_page_found) { |
|
227 | 227 | $page_id = $trashed_page_found; |
228 | 228 | $page_data = array( |
229 | 229 | 'ID' => $page_id, |
230 | 230 | 'post_status' => 'publish', |
231 | 231 | 'post_parent' => $post_parent, |
232 | 232 | ); |
233 | - wp_update_post( $page_data ); |
|
233 | + wp_update_post($page_data); |
|
234 | 234 | } else { |
235 | 235 | $page_data = array( |
236 | 236 | 'post_status' => 'publish', |
@@ -242,11 +242,11 @@ discard block |
||
242 | 242 | 'post_parent' => $post_parent, |
243 | 243 | 'comment_status' => 'closed', |
244 | 244 | ); |
245 | - $page_id = wp_insert_post( $page_data ); |
|
245 | + $page_id = wp_insert_post($page_data); |
|
246 | 246 | } |
247 | 247 | |
248 | - if ( $option ) { |
|
249 | - wpinv_update_option( $option, (int) $page_id ); |
|
248 | + if ($option) { |
|
249 | + wpinv_update_option($option, (int) $page_id); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | return $page_id; |
@@ -259,11 +259,11 @@ discard block |
||
259 | 259 | * |
260 | 260 | * @return array |
261 | 261 | */ |
262 | -function wpinv_add_aui_screens( $screen_ids ) { |
|
262 | +function wpinv_add_aui_screens($screen_ids) { |
|
263 | 263 | |
264 | 264 | // load on these pages if set |
265 | - $screen_ids = array_merge( $screen_ids, wpinv_get_screen_ids() ); |
|
265 | + $screen_ids = array_merge($screen_ids, wpinv_get_screen_ids()); |
|
266 | 266 | |
267 | 267 | return $screen_ids; |
268 | 268 | } |
269 | -add_filter( 'aui_screen_ids', 'wpinv_add_aui_screens' ); |
|
269 | +add_filter('aui_screen_ids', 'wpinv_add_aui_screens'); |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Contains functions that display the subscriptions admin page. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Render the Subscriptions page |
@@ -17,22 +17,22 @@ discard block |
||
17 | 17 | ?> |
18 | 18 | |
19 | 19 | <div class="wrap"> |
20 | - <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
|
20 | + <h1><?php echo esc_html(get_admin_page_title()); ?></h1> |
|
21 | 21 | <div class="bsui"> |
22 | 22 | |
23 | 23 | <?php |
24 | 24 | |
25 | 25 | // Verify user permissions. |
26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
26 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
27 | 27 | |
28 | 28 | echo aui()->alert( |
29 | 29 | array( |
30 | 30 | 'type' => 'danger', |
31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
31 | + 'content' => __('You are not permitted to view this page.', 'invoicing'), |
|
32 | 32 | ) |
33 | 33 | ); |
34 | 34 | |
35 | - } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
35 | + } elseif (!empty($_GET['id']) && is_numeric($_GET['id'])) { |
|
36 | 36 | |
37 | 37 | // Display a single subscription. |
38 | 38 | wpinv_recurring_subscription_details(); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | <?php $subscribers_table->views(); ?> |
67 | 67 | <form id="subscribers-filter" class="bsui" method="get"> |
68 | 68 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
69 | - <?php $subscribers_table->search_box( __( 'Search Subscriptions', 'invoicing' ), 'getpaid-search-subscriptions' ); ?> |
|
69 | + <?php $subscribers_table->search_box(__('Search Subscriptions', 'invoicing'), 'getpaid-search-subscriptions'); ?> |
|
70 | 70 | <?php $subscribers_table->display(); ?> |
71 | 71 | </form> |
72 | 72 | <?php |
@@ -82,13 +82,13 @@ discard block |
||
82 | 82 | function wpinv_recurring_subscription_details() { |
83 | 83 | |
84 | 84 | // Fetch the subscription. |
85 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
86 | - if ( ! $sub->exists() ) { |
|
85 | + $sub = new WPInv_Subscription((int) $_GET['id']); |
|
86 | + if (!$sub->exists()) { |
|
87 | 87 | |
88 | 88 | echo aui()->alert( |
89 | 89 | array( |
90 | 90 | 'type' => 'danger', |
91 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
91 | + 'content' => __('Subscription not found.', 'invoicing'), |
|
92 | 92 | ) |
93 | 93 | ); |
94 | 94 | |
@@ -96,32 +96,32 @@ discard block |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | // Use metaboxes to display the subscription details. |
99 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
100 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
99 | + add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high'); |
|
100 | + add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side'); |
|
101 | 101 | |
102 | 102 | $subscription_id = $sub->get_id(); |
103 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
104 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
103 | + $subscription_groups = getpaid_get_invoice_subscription_groups($sub->get_parent_invoice_id()); |
|
104 | + $subscription_group = wp_list_filter($subscription_groups, compact('subscription_id')); |
|
105 | 105 | |
106 | - if ( 1 < count( $subscription_groups ) ) { |
|
107 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
106 | + if (1 < count($subscription_groups)) { |
|
107 | + add_meta_box('getpaid_admin_subscription_related_subscriptions_metabox', __('Related Subscriptions', 'invoicing'), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced'); |
|
108 | 108 | } |
109 | 109 | |
110 | - if ( ! empty( $subscription_group ) ) { |
|
111 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
110 | + if (!empty($subscription_group)) { |
|
111 | + add_meta_box('getpaid_admin_subscription_item_details_metabox', __('Subscription Items', 'invoicing'), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low'); |
|
112 | 112 | } |
113 | 113 | |
114 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
114 | + add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Related Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced'); |
|
115 | 115 | |
116 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
116 | + do_action('getpaid_admin_single_subscription_register_metabox', $sub); |
|
117 | 117 | |
118 | 118 | ?> |
119 | 119 | |
120 | - <form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>"> |
|
120 | + <form method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id())); ?>"> |
|
121 | 121 | |
122 | - <?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?> |
|
123 | - <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
124 | - <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
|
122 | + <?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?> |
|
123 | + <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
124 | + <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> |
|
125 | 125 | <input type="hidden" name="getpaid-admin-action" value="update_single_subscription" /> |
126 | 126 | <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" /> |
127 | 127 | |
@@ -129,12 +129,12 @@ discard block |
||
129 | 129 | <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
130 | 130 | |
131 | 131 | <div id="postbox-container-1" class="postbox-container"> |
132 | - <?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?> |
|
132 | + <?php do_meta_boxes(get_current_screen(), 'side', $sub); ?> |
|
133 | 133 | </div> |
134 | 134 | |
135 | 135 | <div id="postbox-container-2" class="postbox-container"> |
136 | - <?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?> |
|
137 | - <?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?> |
|
136 | + <?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?> |
|
137 | + <?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?> |
|
138 | 138 | </div> |
139 | 139 | |
140 | 140 | </div> |
@@ -153,43 +153,43 @@ discard block |
||
153 | 153 | * |
154 | 154 | * @param WPInv_Subscription $sub |
155 | 155 | */ |
156 | -function getpaid_admin_subscription_details_metabox( $sub ) { |
|
156 | +function getpaid_admin_subscription_details_metabox($sub) { |
|
157 | 157 | |
158 | 158 | // Subscription items. |
159 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
160 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
159 | + $subscription_group = getpaid_get_invoice_subscription_group($sub->get_parent_invoice_id(), $sub->get_id()); |
|
160 | + $items_count = empty($subscription_group) ? 1 : count($subscription_group['items']); |
|
161 | 161 | |
162 | 162 | // Prepare subscription detail columns. |
163 | 163 | $fields = apply_filters( |
164 | 164 | 'getpaid_subscription_admin_page_fields', |
165 | 165 | array( |
166 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
167 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
168 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
169 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
170 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
171 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
172 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
173 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
174 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
175 | - 'status' => __( 'Status', 'invoicing' ), |
|
166 | + 'subscription' => __('Subscription', 'invoicing'), |
|
167 | + 'customer' => __('Customer', 'invoicing'), |
|
168 | + 'amount' => __('Amount', 'invoicing'), |
|
169 | + 'start_date' => __('Start Date', 'invoicing'), |
|
170 | + 'renews_on' => __('Next Payment', 'invoicing'), |
|
171 | + 'renewals' => __('Payments', 'invoicing'), |
|
172 | + 'item' => _n('Item', 'Items', $items_count, 'invoicing'), |
|
173 | + 'gateway' => __('Payment Method', 'invoicing'), |
|
174 | + 'profile_id' => __('Profile ID', 'invoicing'), |
|
175 | + 'status' => __('Status', 'invoicing'), |
|
176 | 176 | ) |
177 | 177 | ); |
178 | 178 | |
179 | - if ( ! $sub->is_active() ) { |
|
179 | + if (!$sub->is_active()) { |
|
180 | 180 | |
181 | - if ( isset( $fields['renews_on'] ) ) { |
|
182 | - unset( $fields['renews_on'] ); |
|
181 | + if (isset($fields['renews_on'])) { |
|
182 | + unset($fields['renews_on']); |
|
183 | 183 | } |
184 | 184 | |
185 | - if ( isset( $fields['gateway'] ) ) { |
|
186 | - unset( $fields['gateway'] ); |
|
185 | + if (isset($fields['gateway'])) { |
|
186 | + unset($fields['gateway']); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | 190 | $profile_id = $sub->get_profile_id(); |
191 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
192 | - unset( $fields['profile_id'] ); |
|
191 | + if (empty($profile_id) && isset($fields['profile_id'])) { |
|
192 | + unset($fields['profile_id']); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | ?> |
@@ -197,16 +197,16 @@ discard block |
||
197 | 197 | <table class="table table-borderless" style="font-size: 14px;"> |
198 | 198 | <tbody> |
199 | 199 | |
200 | - <?php foreach ( $fields as $key => $label ) : ?> |
|
200 | + <?php foreach ($fields as $key => $label) : ?> |
|
201 | 201 | |
202 | - <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
202 | + <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>"> |
|
203 | 203 | |
204 | 204 | <th class="w-25" style="font-weight: 500;"> |
205 | - <?php echo esc_html( $label ); ?> |
|
205 | + <?php echo esc_html($label); ?> |
|
206 | 206 | </th> |
207 | 207 | |
208 | 208 | <td class="w-75 text-muted"> |
209 | - <?php do_action( 'getpaid_subscription_admin_display_' . sanitize_key( $key ), $sub, $subscription_group ); ?> |
|
209 | + <?php do_action('getpaid_subscription_admin_display_' . sanitize_key($key), $sub, $subscription_group); ?> |
|
210 | 210 | </td> |
211 | 211 | |
212 | 212 | </tr> |
@@ -224,135 +224,135 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @param WPInv_Subscription $subscription |
226 | 226 | */ |
227 | -function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
|
227 | +function getpaid_admin_subscription_metabox_display_customer($subscription) { |
|
228 | 228 | |
229 | - $username = __( '(Missing User)', 'invoicing' ); |
|
229 | + $username = __('(Missing User)', 'invoicing'); |
|
230 | 230 | |
231 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
232 | - if ( $user ) { |
|
231 | + $user = get_userdata($subscription->get_customer_id()); |
|
232 | + if ($user) { |
|
233 | 233 | |
234 | 234 | $username = sprintf( |
235 | 235 | '<a href="user-edit.php?user_id=%s">%s</a>', |
236 | - absint( $user->ID ), |
|
237 | - ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
236 | + absint($user->ID), |
|
237 | + !empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email) |
|
238 | 238 | ); |
239 | 239 | |
240 | 240 | } |
241 | 241 | |
242 | - echo wp_kses_post( $username ); |
|
242 | + echo wp_kses_post($username); |
|
243 | 243 | } |
244 | -add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
|
244 | +add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer'); |
|
245 | 245 | |
246 | 246 | /** |
247 | 247 | * Displays the subscription amount. |
248 | 248 | * |
249 | 249 | * @param WPInv_Subscription $subscription |
250 | 250 | */ |
251 | -function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
|
252 | - $amount = wp_kses_post( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
251 | +function getpaid_admin_subscription_metabox_display_amount($subscription) { |
|
252 | + $amount = wp_kses_post(getpaid_get_formatted_subscription_amount($subscription)); |
|
253 | 253 | echo "<span>$amount</span>"; |
254 | 254 | } |
255 | -add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
|
255 | +add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount'); |
|
256 | 256 | |
257 | 257 | /** |
258 | 258 | * Displays the subscription id. |
259 | 259 | * |
260 | 260 | * @param WPInv_Subscription $subscription |
261 | 261 | */ |
262 | -function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
|
262 | +function getpaid_admin_subscription_metabox_display_id($subscription) { |
|
263 | 263 | |
264 | 264 | printf( |
265 | 265 | '<a href="%s">#%s</a>', |
266 | - esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
267 | - absint( $subscription->get_id() ) |
|
266 | + esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($subscription->get_id()))), |
|
267 | + absint($subscription->get_id()) |
|
268 | 268 | ); |
269 | 269 | |
270 | 270 | } |
271 | -add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
|
271 | +add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id'); |
|
272 | 272 | |
273 | 273 | /** |
274 | 274 | * Displays the subscription renewal date. |
275 | 275 | * |
276 | 276 | * @param WPInv_Subscription $subscription |
277 | 277 | */ |
278 | -function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
|
279 | - echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
278 | +function getpaid_admin_subscription_metabox_display_start_date($subscription) { |
|
279 | + echo getpaid_format_date_value($subscription->get_date_created()); |
|
280 | 280 | } |
281 | -add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
|
281 | +add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date'); |
|
282 | 282 | |
283 | 283 | /** |
284 | 284 | * Displays the subscription renewal date. |
285 | 285 | * |
286 | 286 | * @param WPInv_Subscription $subscription |
287 | 287 | */ |
288 | -function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
|
289 | - echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
288 | +function getpaid_admin_subscription_metabox_display_renews_on($subscription) { |
|
289 | + echo getpaid_format_date_value($subscription->get_expiration()); |
|
290 | 290 | } |
291 | -add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
|
291 | +add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on'); |
|
292 | 292 | |
293 | 293 | /** |
294 | 294 | * Displays the subscription renewal count. |
295 | 295 | * |
296 | 296 | * @param WPInv_Subscription $subscription |
297 | 297 | */ |
298 | -function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
|
298 | +function getpaid_admin_subscription_metabox_display_renewals($subscription) { |
|
299 | 299 | $max_bills = $subscription->get_bill_times(); |
300 | - echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
300 | + echo ((int) $subscription->get_times_billed()) . ' / ' . (empty($max_bills) ? '∞' : (int) $max_bills); |
|
301 | 301 | } |
302 | -add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
|
302 | +add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals'); |
|
303 | 303 | /** |
304 | 304 | * Displays the subscription item. |
305 | 305 | * |
306 | 306 | * @param WPInv_Subscription $subscription |
307 | 307 | * @param false|array $subscription_group |
308 | 308 | */ |
309 | -function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
|
309 | +function getpaid_admin_subscription_metabox_display_item($subscription, $subscription_group = false) { |
|
310 | 310 | |
311 | - if ( empty( $subscription_group ) ) { |
|
312 | - echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
311 | + if (empty($subscription_group)) { |
|
312 | + echo WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id()); |
|
313 | 313 | return; |
314 | 314 | } |
315 | 315 | |
316 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
317 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
316 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
317 | + echo wp_kses_post(implode(' | ', $markup)); |
|
318 | 318 | |
319 | 319 | } |
320 | -add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
|
320 | +add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2); |
|
321 | 321 | |
322 | 322 | /** |
323 | 323 | * Displays the subscription gateway. |
324 | 324 | * |
325 | 325 | * @param WPInv_Subscription $subscription |
326 | 326 | */ |
327 | -function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
|
327 | +function getpaid_admin_subscription_metabox_display_gateway($subscription) { |
|
328 | 328 | |
329 | 329 | $gateway = $subscription->get_gateway(); |
330 | 330 | |
331 | - if ( ! empty( $gateway ) ) { |
|
332 | - echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
331 | + if (!empty($gateway)) { |
|
332 | + echo esc_html(wpinv_get_gateway_admin_label($gateway)); |
|
333 | 333 | } else { |
334 | 334 | echo '—'; |
335 | 335 | } |
336 | 336 | |
337 | 337 | } |
338 | -add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
|
338 | +add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway'); |
|
339 | 339 | |
340 | 340 | /** |
341 | 341 | * Displays the subscription status. |
342 | 342 | * |
343 | 343 | * @param WPInv_Subscription $subscription |
344 | 344 | */ |
345 | -function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
|
346 | - echo wp_kses_post( $subscription->get_status_label_html() ); |
|
345 | +function getpaid_admin_subscription_metabox_display_status($subscription) { |
|
346 | + echo wp_kses_post($subscription->get_status_label_html()); |
|
347 | 347 | } |
348 | -add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
|
348 | +add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status'); |
|
349 | 349 | |
350 | 350 | /** |
351 | 351 | * Displays the subscription profile id. |
352 | 352 | * |
353 | 353 | * @param WPInv_Subscription $subscription |
354 | 354 | */ |
355 | -function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
|
355 | +function getpaid_admin_subscription_metabox_display_profile_id($subscription) { |
|
356 | 356 | |
357 | 357 | $profile_id = $subscription->get_profile_id(); |
358 | 358 | |
@@ -361,31 +361,31 @@ discard block |
||
361 | 361 | 'type' => 'text', |
362 | 362 | 'id' => 'wpinv_subscription_profile_id', |
363 | 363 | 'name' => 'wpinv_subscription_profile_id', |
364 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
364 | + 'label' => __('Profile Id', 'invoicing'), |
|
365 | 365 | 'label_type' => 'hidden', |
366 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
367 | - 'value' => esc_attr( $profile_id ), |
|
366 | + 'placeholder' => __('Profile Id', 'invoicing'), |
|
367 | + 'value' => esc_attr($profile_id), |
|
368 | 368 | 'input_group_right' => '', |
369 | 369 | 'no_wrap' => true, |
370 | 370 | ) |
371 | 371 | ); |
372 | 372 | |
373 | - echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
373 | + echo str_ireplace('form-control', 'regular-text', $input); |
|
374 | 374 | |
375 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
376 | - if ( ! empty( $url ) ) { |
|
377 | - echo ' <a href="' . esc_url_raw( $url ) . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
375 | + $url = apply_filters('getpaid_remote_subscription_profile_url', '', $subscription); |
|
376 | + if (!empty($url)) { |
|
377 | + echo ' <a href="' . esc_url_raw($url) . '" title="' . __('View in Gateway', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | } |
381 | -add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
|
381 | +add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id'); |
|
382 | 382 | |
383 | 383 | /** |
384 | 384 | * Displays the subscriptions update metabox. |
385 | 385 | * |
386 | 386 | * @param WPInv_Subscription $subscription |
387 | 387 | */ |
388 | -function getpaid_admin_subscription_update_metabox( $subscription ) { |
|
388 | +function getpaid_admin_subscription_update_metabox($subscription) { |
|
389 | 389 | |
390 | 390 | ?> |
391 | 391 | <div class="mt-3"> |
@@ -398,10 +398,10 @@ discard block |
||
398 | 398 | 'id' => 'subscription_status_update_select', |
399 | 399 | 'required' => true, |
400 | 400 | 'no_wrap' => false, |
401 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
402 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
401 | + 'label' => __('Subscription Status', 'invoicing'), |
|
402 | + 'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'), |
|
403 | 403 | 'select2' => true, |
404 | - 'value' => $subscription->get_status( 'edit' ), |
|
404 | + 'value' => $subscription->get_status('edit'), |
|
405 | 405 | ) |
406 | 406 | ); |
407 | 407 | ?> |
@@ -409,13 +409,13 @@ discard block |
||
409 | 409 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
410 | 410 | |
411 | 411 | <?php |
412 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
412 | + submit_button(__('Update', 'invoicing'), 'primary', 'submit', false); |
|
413 | 413 | |
414 | - $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
415 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
416 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
414 | + $url = wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce'); |
|
415 | + $anchor = __('Renew Subscription', 'invoicing'); |
|
416 | + $title = esc_attr__('Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing'); |
|
417 | 417 | |
418 | - if ( $subscription->is_active() ) { |
|
418 | + if ($subscription->is_active()) { |
|
419 | 419 | echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
420 | 420 | } |
421 | 421 | |
@@ -428,45 +428,45 @@ discard block |
||
428 | 428 | * @param WPInv_Subscription $subscription |
429 | 429 | * @param bool $strict Whether or not to skip invoices of sibling subscriptions |
430 | 430 | */ |
431 | -function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
|
431 | +function getpaid_admin_subscription_invoice_details_metabox($subscription, $strict = true) { |
|
432 | 432 | |
433 | 433 | $columns = apply_filters( |
434 | 434 | 'getpaid_subscription_related_invoices_columns', |
435 | 435 | array( |
436 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
437 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
438 | - 'date' => __( 'Date', 'invoicing' ), |
|
439 | - 'status' => __( 'Status', 'invoicing' ), |
|
440 | - 'total' => __( 'Total', 'invoicing' ), |
|
436 | + 'invoice' => __('Invoice', 'invoicing'), |
|
437 | + 'relationship' => __('Relationship', 'invoicing'), |
|
438 | + 'date' => __('Date', 'invoicing'), |
|
439 | + 'status' => __('Status', 'invoicing'), |
|
440 | + 'total' => __('Total', 'invoicing'), |
|
441 | 441 | ), |
442 | 442 | $subscription |
443 | 443 | ); |
444 | 444 | |
445 | 445 | // Prepare the invoices. |
446 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
446 | + $payments = $subscription->get_child_payments(!is_admin()); |
|
447 | 447 | $parent = $subscription->get_parent_invoice(); |
448 | 448 | |
449 | - if ( $parent->exists() ) { |
|
450 | - $payments = array_merge( array( $parent ), $payments ); |
|
449 | + if ($parent->exists()) { |
|
450 | + $payments = array_merge(array($parent), $payments); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | $table_class = 'w-100 bg-white'; |
454 | 454 | |
455 | - if ( ! is_admin() ) { |
|
455 | + if (!is_admin()) { |
|
456 | 456 | $table_class = 'table table-bordered'; |
457 | 457 | } |
458 | 458 | |
459 | 459 | ?> |
460 | 460 | <div class="m-0" style="overflow: auto;"> |
461 | 461 | |
462 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
462 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
463 | 463 | |
464 | 464 | <thead> |
465 | 465 | <tr> |
466 | 466 | <?php |
467 | - foreach ( $columns as $key => $label ) { |
|
468 | - $key = esc_attr( $key ); |
|
469 | - $label = esc_html( $label ); |
|
467 | + foreach ($columns as $key => $label) { |
|
468 | + $key = esc_attr($key); |
|
469 | + $label = esc_html($label); |
|
470 | 470 | $class = 'text-left'; |
471 | 471 | |
472 | 472 | echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
@@ -477,70 +477,70 @@ discard block |
||
477 | 477 | |
478 | 478 | <tbody> |
479 | 479 | |
480 | - <?php if ( empty( $payments ) ) : ?> |
|
480 | + <?php if (empty($payments)) : ?> |
|
481 | 481 | <tr> |
482 | - <td colspan="<?php echo count( $columns ); ?>" class="p-2 text-left text-muted"> |
|
483 | - <?php esc_html_e( 'This subscription has no invoices.', 'invoicing' ); ?> |
|
482 | + <td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted"> |
|
483 | + <?php esc_html_e('This subscription has no invoices.', 'invoicing'); ?> |
|
484 | 484 | </td> |
485 | 485 | </tr> |
486 | 486 | <?php endif; ?> |
487 | 487 | |
488 | 488 | <?php |
489 | 489 | |
490 | - foreach ( $payments as $payment ) : |
|
490 | + foreach ($payments as $payment) : |
|
491 | 491 | |
492 | 492 | // Ensure that we have an invoice. |
493 | - $payment = new WPInv_Invoice( $payment ); |
|
493 | + $payment = new WPInv_Invoice($payment); |
|
494 | 494 | |
495 | 495 | // Abort if the invoice is invalid... |
496 | - if ( ! $payment->exists() ) { |
|
496 | + if (!$payment->exists()) { |
|
497 | 497 | continue; |
498 | 498 | } |
499 | 499 | |
500 | 500 | // ... or belongs to a different subscription. |
501 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
501 | + if ($strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id()) { |
|
502 | 502 | continue; |
503 | 503 | } |
504 | 504 | |
505 | 505 | echo '<tr>'; |
506 | 506 | |
507 | - foreach ( array_keys( $columns ) as $key ) { |
|
507 | + foreach (array_keys($columns) as $key) { |
|
508 | 508 | |
509 | 509 | $class = 'text-left'; |
510 | 510 | |
511 | 511 | echo "<td class='p-2 text-left'>"; |
512 | 512 | |
513 | - switch ( $key ) { |
|
513 | + switch ($key) { |
|
514 | 514 | |
515 | 515 | case 'total': |
516 | - echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
516 | + echo '<strong>' . wpinv_price($payment->get_total(), $payment->get_currency()) . '</strong>'; |
|
517 | 517 | break; |
518 | 518 | |
519 | 519 | case 'relationship': |
520 | - echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
520 | + echo $payment->is_renewal() ? __('Renewal Invoice', 'invoicing') : __('Initial Invoice', 'invoicing'); |
|
521 | 521 | break; |
522 | 522 | |
523 | 523 | case 'date': |
524 | - echo getpaid_format_date_value( $payment->get_date_created() ); |
|
524 | + echo getpaid_format_date_value($payment->get_date_created()); |
|
525 | 525 | break; |
526 | 526 | |
527 | 527 | case 'status': |
528 | 528 | $status = $payment->get_status_nicename(); |
529 | - if ( is_admin() ) { |
|
529 | + if (is_admin()) { |
|
530 | 530 | $status = $payment->get_status_label_html(); |
531 | 531 | } |
532 | 532 | |
533 | - echo wp_kses_post( $status ); |
|
533 | + echo wp_kses_post($status); |
|
534 | 534 | break; |
535 | 535 | |
536 | 536 | case 'invoice': |
537 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
537 | + $link = esc_url(get_edit_post_link($payment->get_id())); |
|
538 | 538 | |
539 | - if ( ! is_admin() ) { |
|
540 | - $link = esc_url( $payment->get_view_url() ); |
|
539 | + if (!is_admin()) { |
|
540 | + $link = esc_url($payment->get_view_url()); |
|
541 | 541 | } |
542 | 542 | |
543 | - $invoice = esc_html( $payment->get_number() ); |
|
543 | + $invoice = esc_html($payment->get_number()); |
|
544 | 544 | echo "<a href='$link'>$invoice</a>"; |
545 | 545 | break; |
546 | 546 | } |
@@ -568,12 +568,12 @@ discard block |
||
568 | 568 | * |
569 | 569 | * @param WPInv_Subscription $subscription |
570 | 570 | */ |
571 | -function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
|
571 | +function getpaid_admin_subscription_item_details_metabox($subscription) { |
|
572 | 572 | |
573 | 573 | // Fetch the subscription group. |
574 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
574 | + $subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_payment_id(), $subscription->get_id()); |
|
575 | 575 | |
576 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
576 | + if (empty($subscription_group) || empty($subscription_group['items'])) { |
|
577 | 577 | return; |
578 | 578 | } |
579 | 579 | |
@@ -581,12 +581,12 @@ discard block |
||
581 | 581 | $columns = apply_filters( |
582 | 582 | 'getpaid_subscription_item_details_columns', |
583 | 583 | array( |
584 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
585 | - 'price' => __( 'Price', 'invoicing' ), |
|
586 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
587 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
584 | + 'item_name' => __('Item', 'invoicing'), |
|
585 | + 'price' => __('Price', 'invoicing'), |
|
586 | + 'tax' => __('Tax', 'invoicing'), |
|
587 | + 'discount' => __('Discount', 'invoicing'), |
|
588 | 588 | //'initial' => __( 'Initial Amount', 'invoicing' ), |
589 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
589 | + 'recurring' => __('Subtotal', 'invoicing'), |
|
590 | 590 | ), |
591 | 591 | $subscription |
592 | 592 | ); |
@@ -595,28 +595,28 @@ discard block |
||
595 | 595 | |
596 | 596 | $invoice = $subscription->get_parent_invoice(); |
597 | 597 | |
598 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
599 | - unset( $columns['tax'] ); |
|
598 | + if ((!wpinv_use_taxes() || !$invoice->is_taxable()) && isset($columns['tax'])) { |
|
599 | + unset($columns['tax']); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | $table_class = 'w-100 bg-white'; |
603 | 603 | |
604 | - if ( ! is_admin() ) { |
|
604 | + if (!is_admin()) { |
|
605 | 605 | $table_class = 'table table-bordered'; |
606 | 606 | } |
607 | 607 | |
608 | 608 | ?> |
609 | 609 | <div class="m-0" style="overflow: auto;"> |
610 | 610 | |
611 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
611 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
612 | 612 | |
613 | 613 | <thead> |
614 | 614 | <tr> |
615 | 615 | <?php |
616 | 616 | |
617 | - foreach ( $columns as $key => $label ) { |
|
618 | - $key = esc_attr( $key ); |
|
619 | - $label = esc_html( $label ); |
|
617 | + foreach ($columns as $key => $label) { |
|
618 | + $key = esc_attr($key); |
|
619 | + $label = esc_html($label); |
|
620 | 620 | $class = 'text-left'; |
621 | 621 | |
622 | 622 | echo "<th class='subscription-item-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
@@ -629,48 +629,48 @@ discard block |
||
629 | 629 | |
630 | 630 | <?php |
631 | 631 | |
632 | - foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
632 | + foreach ($subscription_group['items'] as $subscription_group_item) : |
|
633 | 633 | |
634 | 634 | echo '<tr>'; |
635 | 635 | |
636 | - foreach ( array_keys( $columns ) as $key ) { |
|
636 | + foreach (array_keys($columns) as $key) { |
|
637 | 637 | |
638 | 638 | $class = 'text-left'; |
639 | 639 | |
640 | 640 | echo "<td class='p-2 text-left'>"; |
641 | 641 | |
642 | - switch ( $key ) { |
|
642 | + switch ($key) { |
|
643 | 643 | |
644 | 644 | case 'item_name': |
645 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
646 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
645 | + $item_name = get_the_title($subscription_group_item['item_id']); |
|
646 | + $item_name = empty($item_name) ? $subscription_group_item['item_name'] : $item_name; |
|
647 | 647 | |
648 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
649 | - echo esc_html( $item_name ); |
|
648 | + if ($invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity']) { |
|
649 | + echo esc_html($item_name); |
|
650 | 650 | } else { |
651 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
651 | + printf('%1$s x %2$d', esc_html($item_name), (float) $subscription_group_item['quantity']); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | break; |
655 | 655 | |
656 | 656 | case 'price': |
657 | - echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
657 | + echo wpinv_price($subscription_group_item['item_price'], $invoice->get_currency()); |
|
658 | 658 | break; |
659 | 659 | |
660 | 660 | case 'tax': |
661 | - echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
661 | + echo wpinv_price($subscription_group_item['tax'], $invoice->get_currency()); |
|
662 | 662 | break; |
663 | 663 | |
664 | 664 | case 'discount': |
665 | - echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
665 | + echo wpinv_price($subscription_group_item['discount'], $invoice->get_currency()); |
|
666 | 666 | break; |
667 | 667 | |
668 | 668 | case 'initial': |
669 | - echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
669 | + echo wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()); |
|
670 | 670 | break; |
671 | 671 | |
672 | 672 | case 'recurring': |
673 | - echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
673 | + echo '<strong>' . wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()) . '</strong>'; |
|
674 | 674 | break; |
675 | 675 | |
676 | 676 | } |
@@ -683,24 +683,24 @@ discard block |
||
683 | 683 | |
684 | 684 | endforeach; |
685 | 685 | |
686 | - foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
686 | + foreach ($subscription_group['fees'] as $subscription_group_fee) : |
|
687 | 687 | |
688 | 688 | echo '<tr>'; |
689 | 689 | |
690 | - foreach ( array_keys( $columns ) as $key ) { |
|
690 | + foreach (array_keys($columns) as $key) { |
|
691 | 691 | |
692 | 692 | $class = 'text-left'; |
693 | 693 | |
694 | 694 | echo "<td class='p-2 text-left'>"; |
695 | 695 | |
696 | - switch ( $key ) { |
|
696 | + switch ($key) { |
|
697 | 697 | |
698 | 698 | case 'item_name': |
699 | - echo esc_html( $subscription_group_fee['name'] ); |
|
699 | + echo esc_html($subscription_group_fee['name']); |
|
700 | 700 | break; |
701 | 701 | |
702 | 702 | case 'price': |
703 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
703 | + echo wpinv_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
704 | 704 | break; |
705 | 705 | |
706 | 706 | case 'tax': |
@@ -712,11 +712,11 @@ discard block |
||
712 | 712 | break; |
713 | 713 | |
714 | 714 | case 'initial': |
715 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
715 | + echo wpinv_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
716 | 716 | break; |
717 | 717 | |
718 | 718 | case 'recurring': |
719 | - echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
719 | + echo '<strong>' . wpinv_price($subscription_group_fee['recurring_fee'], $invoice->get_currency()) . '</strong>'; |
|
720 | 720 | break; |
721 | 721 | |
722 | 722 | } |
@@ -745,12 +745,12 @@ discard block |
||
745 | 745 | * @param WPInv_Subscription $subscription |
746 | 746 | * @param bool $skip_current |
747 | 747 | */ |
748 | -function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
|
748 | +function getpaid_admin_subscription_related_subscriptions_metabox($subscription, $skip_current = true) { |
|
749 | 749 | |
750 | 750 | // Fetch the subscription groups. |
751 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
751 | + $subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_payment_id()); |
|
752 | 752 | |
753 | - if ( empty( $subscription_groups ) ) { |
|
753 | + if (empty($subscription_groups)) { |
|
754 | 754 | return; |
755 | 755 | } |
756 | 756 | |
@@ -758,38 +758,38 @@ discard block |
||
758 | 758 | $columns = apply_filters( |
759 | 759 | 'getpaid_subscription_related_subscriptions_columns', |
760 | 760 | array( |
761 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
762 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
763 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
764 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
765 | - 'item' => __( 'Items', 'invoicing' ), |
|
766 | - 'status' => __( 'Status', 'invoicing' ), |
|
761 | + 'subscription' => __('Subscription', 'invoicing'), |
|
762 | + 'start_date' => __('Start Date', 'invoicing'), |
|
763 | + 'renewal_date' => __('Next Payment', 'invoicing'), |
|
764 | + 'renewals' => __('Payments', 'invoicing'), |
|
765 | + 'item' => __('Items', 'invoicing'), |
|
766 | + 'status' => __('Status', 'invoicing'), |
|
767 | 767 | ), |
768 | 768 | $subscription |
769 | 769 | ); |
770 | 770 | |
771 | - if ( $subscription->get_status() == 'pending' ) { |
|
772 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
771 | + if ($subscription->get_status() == 'pending') { |
|
772 | + unset($columns['start_date'], $columns['renewal_date']); |
|
773 | 773 | } |
774 | 774 | |
775 | 775 | $table_class = 'w-100 bg-white'; |
776 | 776 | |
777 | - if ( ! is_admin() ) { |
|
777 | + if (!is_admin()) { |
|
778 | 778 | $table_class = 'table table-bordered'; |
779 | 779 | } |
780 | 780 | |
781 | 781 | ?> |
782 | 782 | <div class="m-0" style="overflow: auto;"> |
783 | 783 | |
784 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
784 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
785 | 785 | |
786 | 786 | <thead> |
787 | 787 | <tr> |
788 | 788 | <?php |
789 | 789 | |
790 | - foreach ( $columns as $key => $label ) { |
|
791 | - $key = esc_attr( $key ); |
|
792 | - $label = esc_html( $label ); |
|
790 | + foreach ($columns as $key => $label) { |
|
791 | + $key = esc_attr($key); |
|
792 | + $label = esc_html($label); |
|
793 | 793 | $class = 'text-left'; |
794 | 794 | |
795 | 795 | echo "<th class='related-subscription-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
@@ -802,62 +802,62 @@ discard block |
||
802 | 802 | |
803 | 803 | <?php |
804 | 804 | |
805 | - foreach ( $subscription_groups as $subscription_group ) : |
|
805 | + foreach ($subscription_groups as $subscription_group) : |
|
806 | 806 | |
807 | 807 | // Do not list current subscription. |
808 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
808 | + if ($skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id()) { |
|
809 | 809 | continue; |
810 | 810 | } |
811 | 811 | |
812 | 812 | // Ensure the subscription exists. |
813 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
813 | + $_suscription = new WPInv_Subscription($subscription_group['subscription_id']); |
|
814 | 814 | |
815 | - if ( ! $_suscription->exists() ) { |
|
815 | + if (!$_suscription->exists()) { |
|
816 | 816 | continue; |
817 | 817 | } |
818 | 818 | |
819 | 819 | echo '<tr>'; |
820 | 820 | |
821 | - foreach ( array_keys( $columns ) as $key ) { |
|
821 | + foreach (array_keys($columns) as $key) { |
|
822 | 822 | |
823 | 823 | $class = 'text-left'; |
824 | 824 | |
825 | 825 | echo "<td class='p-2 text-left'>"; |
826 | 826 | |
827 | - switch ( $key ) { |
|
827 | + switch ($key) { |
|
828 | 828 | |
829 | 829 | case 'status': |
830 | - echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
830 | + echo wp_kses_post($_suscription->get_status_label_html()); |
|
831 | 831 | break; |
832 | 832 | |
833 | 833 | case 'item': |
834 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
835 | - echo implode( ' | ', $markup ); |
|
834 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
835 | + echo implode(' | ', $markup); |
|
836 | 836 | break; |
837 | 837 | |
838 | 838 | case 'renewals': |
839 | 839 | $max_bills = $_suscription->get_bill_times(); |
840 | - echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
840 | + echo ((int) $_suscription->get_times_billed()) . ' / ' . (empty($max_bills) ? '∞' : (int) $max_bills); |
|
841 | 841 | break; |
842 | 842 | |
843 | 843 | case 'renewal_date': |
844 | - echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : '—'; |
|
844 | + echo $_suscription->is_active() ? getpaid_format_date_value($_suscription->get_expiration()) : '—'; |
|
845 | 845 | break; |
846 | 846 | |
847 | 847 | case 'start_date': |
848 | - echo 'pending' == $_suscription->get_status() ? '—' : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
848 | + echo 'pending' == $_suscription->get_status() ? '—' : getpaid_format_date_value($_suscription->get_date_created()); |
|
849 | 849 | break; |
850 | 850 | |
851 | 851 | case 'subscription': |
852 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
852 | + $url = is_admin() ? admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($_suscription->get_id())) : $_suscription->get_view_url(); |
|
853 | 853 | printf( |
854 | 854 | '%1$s#%2$s%3$s', |
855 | - '<a href="' . esc_url( $url ) . '">', |
|
856 | - '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
855 | + '<a href="' . esc_url($url) . '">', |
|
856 | + '<strong>' . intval($_suscription->get_id()) . '</strong>', |
|
857 | 857 | '</a>' |
858 | 858 | ); |
859 | 859 | |
860 | - echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
860 | + echo WPInv_Subscriptions_List_Table::column_amount($_suscription); |
|
861 | 861 | break; |
862 | 862 | |
863 | 863 | } |
@@ -7,81 +7,81 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( ! defined( 'WPINC' ) ) { |
|
10 | +if (!defined('WPINC')) { |
|
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | |
14 | -function wpinv_bulk_actions( $actions ) { |
|
15 | - if ( isset( $actions['edit'] ) ) { |
|
16 | - unset( $actions['edit'] ); |
|
14 | +function wpinv_bulk_actions($actions) { |
|
15 | + if (isset($actions['edit'])) { |
|
16 | + unset($actions['edit']); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | return $actions; |
20 | 20 | } |
21 | -add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' ); |
|
22 | -add_filter( 'bulk_actions-edit-wpi_item', 'wpinv_bulk_actions' ); |
|
21 | +add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions'); |
|
22 | +add_filter('bulk_actions-edit-wpi_item', 'wpinv_bulk_actions'); |
|
23 | 23 | |
24 | -function wpinv_admin_post_id( $id = 0 ) { |
|
24 | +function wpinv_admin_post_id($id = 0) { |
|
25 | 25 | global $post; |
26 | 26 | |
27 | - if ( isset( $id ) && ! empty( $id ) ) { |
|
28 | - return (int)$id; |
|
29 | - } elseif ( get_the_ID() ) { |
|
27 | + if (isset($id) && !empty($id)) { |
|
28 | + return (int) $id; |
|
29 | + } elseif (get_the_ID()) { |
|
30 | 30 | return (int) get_the_ID(); |
31 | - } elseif ( isset( $post->ID ) && ! empty( $post->ID ) ) { |
|
31 | + } elseif (isset($post->ID) && !empty($post->ID)) { |
|
32 | 32 | return (int) $post->ID; |
33 | - } elseif ( isset( $_GET['post'] ) && ! empty( $_GET['post'] ) ) { |
|
33 | + } elseif (isset($_GET['post']) && !empty($_GET['post'])) { |
|
34 | 34 | return (int) $_GET['post']; |
35 | - } elseif ( isset( $_GET['id'] ) && ! empty( $_GET['id'] ) ) { |
|
35 | + } elseif (isset($_GET['id']) && !empty($_GET['id'])) { |
|
36 | 36 | return (int) $_GET['id']; |
37 | - } elseif ( isset( $_POST['id'] ) && ! empty( $_POST['id'] ) ) { |
|
37 | + } elseif (isset($_POST['id']) && !empty($_POST['id'])) { |
|
38 | 38 | return (int) $_POST['id']; |
39 | 39 | } |
40 | 40 | |
41 | 41 | return null; |
42 | 42 | } |
43 | 43 | |
44 | -function wpinv_admin_post_type( $id = 0 ) { |
|
45 | - if ( ! $id ) { |
|
44 | +function wpinv_admin_post_type($id = 0) { |
|
45 | + if (!$id) { |
|
46 | 46 | $id = wpinv_admin_post_id(); |
47 | 47 | } |
48 | 48 | |
49 | - $type = get_post_type( $id ); |
|
49 | + $type = get_post_type($id); |
|
50 | 50 | |
51 | - if ( ! $type ) { |
|
52 | - $type = isset( $_GET['post_type'] ) && ! empty( $_GET['post_type'] ) ? sanitize_text_field( $_GET['post_type'] ) : null; |
|
51 | + if (!$type) { |
|
52 | + $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : null; |
|
53 | 53 | } |
54 | 54 | |
55 | - return apply_filters( 'wpinv_admin_post_type', $type, $id ); |
|
55 | + return apply_filters('wpinv_admin_post_type', $type, $id); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | function wpinv_admin_messages() { |
59 | - settings_errors( 'wpinv-notices' ); |
|
59 | + settings_errors('wpinv-notices'); |
|
60 | 60 | } |
61 | -add_action( 'admin_notices', 'wpinv_admin_messages' ); |
|
61 | +add_action('admin_notices', 'wpinv_admin_messages'); |
|
62 | 62 | |
63 | -add_action( 'admin_init', 'wpinv_show_test_payment_gateway_notice' ); |
|
63 | +add_action('admin_init', 'wpinv_show_test_payment_gateway_notice'); |
|
64 | 64 | function wpinv_show_test_payment_gateway_notice() { |
65 | - add_action( 'admin_notices', 'wpinv_test_payment_gateway_messages' ); |
|
65 | + add_action('admin_notices', 'wpinv_test_payment_gateway_messages'); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | function wpinv_test_payment_gateway_messages() { |
69 | 69 | $gateways = wpinv_get_enabled_payment_gateways(); |
70 | 70 | $name = array(); $test_gateways = ''; |
71 | - if ( $gateways ) { |
|
72 | - foreach ( $gateways as $id => $gateway ) { |
|
73 | - if ( wpinv_is_test_mode( $id ) ) { |
|
71 | + if ($gateways) { |
|
72 | + foreach ($gateways as $id => $gateway) { |
|
73 | + if (wpinv_is_test_mode($id)) { |
|
74 | 74 | $name[] = $gateway['checkout_label']; |
75 | 75 | } |
76 | 76 | } |
77 | - $test_gateways = implode( ', ', $name ); |
|
77 | + $test_gateways = implode(', ', $name); |
|
78 | 78 | } |
79 | - if ( isset( $test_gateways ) && ! empty( $test_gateways ) && wpinv_current_user_can_manage_invoicing() ) { |
|
80 | - $link = admin_url( 'admin.php?page=wpinv-settings&tab=gateways' ); |
|
81 | - $notice = wp_sprintf( __( '<strong>Important:</strong> Payment Gateway(s) %1$s are in testing mode and will not receive real payments. Go to <a href="%2$s"> Gateway Settings</a>.', 'invoicing' ), $test_gateways, $link ); |
|
79 | + if (isset($test_gateways) && !empty($test_gateways) && wpinv_current_user_can_manage_invoicing()) { |
|
80 | + $link = admin_url('admin.php?page=wpinv-settings&tab=gateways'); |
|
81 | + $notice = wp_sprintf(__('<strong>Important:</strong> Payment Gateway(s) %1$s are in testing mode and will not receive real payments. Go to <a href="%2$s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link); |
|
82 | 82 | ?> |
83 | 83 | <div class="notice notice-warning is-dismissible"> |
84 | - <p><?php echo wp_kses_post( $notice ); ?></p> |
|
84 | + <p><?php echo wp_kses_post($notice); ?></p> |
|
85 | 85 | </div> |
86 | 86 | <?php |
87 | 87 | } |
@@ -95,37 +95,37 @@ discard block |
||
95 | 95 | global $wpdb; |
96 | 96 | |
97 | 97 | // Only do this on our settings page. |
98 | - if ( empty( $_GET['page'] ) || 'wpinv-settings' !== $_GET['page'] ) { |
|
98 | + if (empty($_GET['page']) || 'wpinv-settings' !== $_GET['page']) { |
|
99 | 99 | return; |
100 | 100 | } |
101 | 101 | |
102 | 102 | // Check tables. |
103 | - $tables = array( |
|
103 | + $tables = array( |
|
104 | 104 | "{$wpdb->prefix}wpinv_subscriptions", |
105 | 105 | "{$wpdb->prefix}getpaid_invoices", |
106 | 106 | "{$wpdb->prefix}getpaid_invoice_items", |
107 | 107 | ); |
108 | 108 | |
109 | - foreach ( $tables as $table ) { |
|
110 | - if ( $table != $wpdb->get_var( "SHOW TABLES LIKE '$table'" ) ) { |
|
109 | + foreach ($tables as $table) { |
|
110 | + if ($table != $wpdb->get_var("SHOW TABLES LIKE '$table'")) { |
|
111 | 111 | |
112 | - $url = wp_nonce_url( |
|
113 | - add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
112 | + $url = wp_nonce_url( |
|
113 | + add_query_arg('getpaid-admin-action', 'create_missing_tables'), |
|
114 | 114 | 'getpaid-nonce', |
115 | 115 | 'getpaid-nonce' |
116 | 116 | ); |
117 | - $message = __( 'Some GetPaid database tables are missing. To use GetPaid without any issues, click on the button below to create the missing tables.', 'invoicing' ); |
|
118 | - $message2 = __( 'Create Tables', 'invoicing' ); |
|
119 | - echo wp_kses_post( "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>" ); |
|
117 | + $message = __('Some GetPaid database tables are missing. To use GetPaid without any issues, click on the button below to create the missing tables.', 'invoicing'); |
|
118 | + $message2 = __('Create Tables', 'invoicing'); |
|
119 | + echo wp_kses_post("<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>"); |
|
120 | 120 | break; |
121 | 121 | |
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
125 | 125 | } |
126 | -add_action( 'admin_notices', 'wpinv_check_for_missing_tables' ); |
|
126 | +add_action('admin_notices', 'wpinv_check_for_missing_tables'); |
|
127 | 127 | |
128 | -add_action( 'admin_init', 'wpinv_admin_search_by_invoice' ); |
|
128 | +add_action('admin_init', 'wpinv_admin_search_by_invoice'); |
|
129 | 129 | |
130 | 130 | /** |
131 | 131 | * hook the posts search if we're on the admin page for our type |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | function wpinv_admin_search_by_invoice() { |
134 | 134 | global $typenow; |
135 | 135 | |
136 | - if ( $typenow === 'wpi_invoice' || $typenow === 'wpi_quote' ) { |
|
137 | - add_filter( 'posts_search', 'wpinv_posts_search_example_type', 10, 2 ); |
|
136 | + if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote') { |
|
137 | + add_filter('posts_search', 'wpinv_posts_search_example_type', 10, 2); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | * @param WP_Query $query |
145 | 145 | * @return string |
146 | 146 | */ |
147 | -function wpinv_posts_search_example_type( $search, $query ) { |
|
147 | +function wpinv_posts_search_example_type($search, $query) { |
|
148 | 148 | global $wpdb; |
149 | 149 | |
150 | - if ( $query->is_main_query() && ! empty( $query->query['s'] ) ) { |
|
151 | - $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql( $query->query['s'] ) . "%' )"; |
|
152 | - if ( ! empty( $search ) ) { |
|
153 | - $search = preg_replace( '/^ AND /', '', $search ); |
|
150 | + if ($query->is_main_query() && !empty($query->query['s'])) { |
|
151 | + $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql($query->query['s']) . "%' )"; |
|
152 | + if (!empty($search)) { |
|
153 | + $search = preg_replace('/^ AND /', '', $search); |
|
154 | 154 | $search = " AND ( {$search} OR ( {$conditions_str} ) )"; |
155 | 155 | } else { |
156 | 156 | $search = " AND ( {$conditions_str} )"; |
@@ -164,16 +164,16 @@ discard block |
||
164 | 164 | * Resets invoice counts. |
165 | 165 | */ |
166 | 166 | function wpinv_reset_invoice_count() { |
167 | - if ( ! empty( $_GET['reset_invoice_count'] ) && isset( $_GET['_nonce'] ) && wp_verify_nonce( sanitize_text_field( $_GET['_nonce'] ), 'reset_invoice_count' ) ) { |
|
168 | - wpinv_update_option( 'invoice_sequence_start', 1 ); |
|
169 | - delete_option( 'wpinv_last_invoice_number' ); |
|
170 | - getpaid_admin()->show_success( __( 'Invoice number sequence reset successfully.', 'invoicing' ) ); |
|
171 | - $url = remove_query_arg( array( 'reset_invoice_count', '_nonce' ) ); |
|
172 | - wp_redirect( $url ); |
|
167 | + if (!empty($_GET['reset_invoice_count']) && isset($_GET['_nonce']) && wp_verify_nonce(sanitize_text_field($_GET['_nonce']), 'reset_invoice_count')) { |
|
168 | + wpinv_update_option('invoice_sequence_start', 1); |
|
169 | + delete_option('wpinv_last_invoice_number'); |
|
170 | + getpaid_admin()->show_success(__('Invoice number sequence reset successfully.', 'invoicing')); |
|
171 | + $url = remove_query_arg(array('reset_invoice_count', '_nonce')); |
|
172 | + wp_redirect($url); |
|
173 | 173 | exit(); |
174 | 174 | } |
175 | 175 | } |
176 | -add_action( 'admin_init', 'wpinv_reset_invoice_count' ); |
|
176 | +add_action('admin_init', 'wpinv_reset_invoice_count'); |
|
177 | 177 | |
178 | 178 | /** |
179 | 179 | * Displays line items on the invoice edit page. |
@@ -182,29 +182,29 @@ discard block |
||
182 | 182 | * @param array $columns |
183 | 183 | * @return string |
184 | 184 | */ |
185 | -function wpinv_admin_get_line_items( $invoice, $columns ) { |
|
185 | +function wpinv_admin_get_line_items($invoice, $columns) { |
|
186 | 186 | |
187 | 187 | ob_start(); |
188 | 188 | |
189 | - do_action( 'getpaid_admin_before_line_items', $invoice ); |
|
189 | + do_action('getpaid_admin_before_line_items', $invoice); |
|
190 | 190 | |
191 | 191 | $count = 0; |
192 | - foreach ( $invoice->get_items() as $item ) { |
|
192 | + foreach ($invoice->get_items() as $item) { |
|
193 | 193 | |
194 | - $item_price = wpinv_price( $item->get_price(), $invoice->get_currency() ); |
|
194 | + $item_price = wpinv_price($item->get_price(), $invoice->get_currency()); |
|
195 | 195 | $quantity = (int) $item->get_quantity(); |
196 | - $item_subtotal = wpinv_price( $item->get_sub_total(), $invoice->get_currency() ); |
|
197 | - $summary = apply_filters( 'getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice ); |
|
196 | + $item_subtotal = wpinv_price($item->get_sub_total(), $invoice->get_currency()); |
|
197 | + $summary = apply_filters('getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice); |
|
198 | 198 | $item_tax = $item->item_tax; |
199 | - $tax_rate = wpinv_round_amount( getpaid_get_invoice_tax_rate( $invoice, $item ), 2, true ) . '%'; |
|
200 | - $tax_rate = empty( $tax_rate ) ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : ''; |
|
199 | + $tax_rate = wpinv_round_amount(getpaid_get_invoice_tax_rate($invoice, $item), 2, true) . '%'; |
|
200 | + $tax_rate = empty($tax_rate) ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : ''; |
|
201 | 201 | $line_item_tax = $item_tax . $tax_rate; |
202 | - $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . esc_attr( $item->get_id() ) . '">'; |
|
202 | + $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . esc_attr($item->get_id()) . '">'; |
|
203 | 203 | $line_item .= '<td class="id">' . (int) $item->get_id() . '</td>'; |
204 | - $line_item .= '<td class="title"><a href="' . get_edit_post_link( $item->get_id() ) . '" target="_blank">' . $item->get_name() . '</a>'; |
|
204 | + $line_item .= '<td class="title"><a href="' . get_edit_post_link($item->get_id()) . '" target="_blank">' . $item->get_name() . '</a>'; |
|
205 | 205 | |
206 | - if ( $summary !== '' ) { |
|
207 | - $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>'; |
|
206 | + if ($summary !== '') { |
|
207 | + $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>'; |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | $line_item .= '</td>'; |
@@ -212,23 +212,23 @@ discard block |
||
212 | 212 | $line_item .= '<td class="qty" data-quantity="' . $quantity . '"> × ' . $quantity . '</td>'; |
213 | 213 | $line_item .= '<td class="total">' . $item_subtotal . '</td>'; |
214 | 214 | |
215 | - if ( wpinv_use_taxes() && $invoice->is_taxable() ) { |
|
215 | + if (wpinv_use_taxes() && $invoice->is_taxable()) { |
|
216 | 216 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
217 | 217 | } |
218 | 218 | |
219 | 219 | $line_item .= '<td class="action">'; |
220 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
220 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
221 | 221 | $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>'; |
222 | 222 | } |
223 | 223 | $line_item .= '</td>'; |
224 | 224 | $line_item .= '</tr>'; |
225 | 225 | |
226 | - echo wp_kses_post( apply_filters( 'getpaid_admin_line_item', $line_item, $item, $invoice ) ); |
|
226 | + echo wp_kses_post(apply_filters('getpaid_admin_line_item', $line_item, $item, $invoice)); |
|
227 | 227 | |
228 | 228 | $count++; |
229 | 229 | } |
230 | 230 | |
231 | - do_action( 'getpaid_admin_after_line_items', $invoice ); |
|
231 | + do_action('getpaid_admin_after_line_items', $invoice); |
|
232 | 232 | |
233 | 233 | return ob_get_clean(); |
234 | 234 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | if ( ! defined( 'ABSPATH' ) ) { |
7 | - exit; |
|
7 | + exit; |
|
8 | 8 | } |
9 | 9 | add_ThickBox(); |
10 | 10 | ?> |
@@ -14,18 +14,18 @@ discard block |
||
14 | 14 | <?php if ( $tabs ) { ?> |
15 | 15 | <nav class="nav-tab-wrapper wpi-nav-tab-wrapper"> |
16 | 16 | <?php |
17 | - foreach ( $tabs as $name => $label ) { |
|
18 | - echo '<a href="' . esc_url( admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>'; |
|
19 | - } |
|
20 | - do_action( 'wpi_addons_tabs' ); |
|
21 | - ?> |
|
17 | + foreach ( $tabs as $name => $label ) { |
|
18 | + echo '<a href="' . esc_url( admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>'; |
|
19 | + } |
|
20 | + do_action( 'wpi_addons_tabs' ); |
|
21 | + ?> |
|
22 | 22 | </nav> |
23 | 23 | |
24 | 24 | <?php |
25 | 25 | |
26 | - if ( $current_tab == 'membership' ) { |
|
26 | + if ( $current_tab == 'membership' ) { |
|
27 | 27 | |
28 | - ?> |
|
28 | + ?> |
|
29 | 29 | |
30 | 30 | <div class="wpi-membership-tab-conatiner"> |
31 | 31 | <div class="membership-content"> |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | <h2><?php esc_html_e( 'Have a membership key?', 'invoicing' ); ?></h2> |
37 | 37 | <p> |
38 | 38 | <?php |
39 | - $wpeu_admin = new External_Updates_Admin( 'wpinvoicing.com', '1' ); |
|
40 | - echo $wpeu_admin->render_licence_actions( 'wpinvoicing.com', 'membership', array( 95, 106, 108, 12351 ) ); |
|
41 | - ?> |
|
39 | + $wpeu_admin = new External_Updates_Admin( 'wpinvoicing.com', '1' ); |
|
40 | + echo $wpeu_admin->render_licence_actions( 'wpinvoicing.com', 'membership', array( 95, 106, 108, 12351 ) ); |
|
41 | + ?> |
|
42 | 42 | </p> |
43 | 43 | <?php } ?> |
44 | 44 | |
@@ -48,13 +48,13 @@ discard block |
||
48 | 48 | <div class="feature-list"> |
49 | 49 | <ul> |
50 | 50 | <?php |
51 | - $addon_obj = new WPInv_Admin_Addons(); |
|
52 | - if ( $addons = $addon_obj->get_section_data( 'addons' ) ) { |
|
53 | - foreach ( $addons as $addon ) { |
|
54 | - echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>'; |
|
55 | - } |
|
56 | - } |
|
57 | - ?> |
|
51 | + $addon_obj = new WPInv_Admin_Addons(); |
|
52 | + if ( $addons = $addon_obj->get_section_data( 'addons' ) ) { |
|
53 | + foreach ( $addons as $addon ) { |
|
54 | + echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>'; |
|
55 | + } |
|
56 | + } |
|
57 | + ?> |
|
58 | 58 | </ul> |
59 | 59 | |
60 | 60 | <div class="feature-cta"> |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | <h3><?php esc_html_e( 'Included Gateways:', 'invoicing' ); ?></h3> |
66 | 66 | <ul> |
67 | 67 | <?php |
68 | - if ( $addons = $addon_obj->get_section_data( 'gateways' ) ) { |
|
69 | - foreach ( $addons as $addon ) { |
|
70 | - echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>'; |
|
71 | - } |
|
72 | - } |
|
73 | - ?> |
|
68 | + if ( $addons = $addon_obj->get_section_data( 'gateways' ) ) { |
|
69 | + foreach ( $addons as $addon ) { |
|
70 | + echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>'; |
|
71 | + } |
|
72 | + } |
|
73 | + ?> |
|
74 | 74 | </ul> |
75 | 75 | </div> |
76 | 76 | |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | <div class="testimonial-content"> |
82 | 82 | <div class="t-image"> |
83 | 83 | <?php |
84 | - echo '<img src="' . plugins_url( 'images/t-image2.png', dirname( __FILE__ ) ) . '" > '; |
|
85 | - ?> |
|
84 | + echo '<img src="' . plugins_url( 'images/t-image2.png', dirname( __FILE__ ) ) . '" > '; |
|
85 | + ?> |
|
86 | 86 | </div> |
87 | 87 | <div class="t-content"> |
88 | 88 | <p> |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | <div class="testimonial-content"> |
102 | 102 | <div class="t-image"> |
103 | 103 | <?php |
104 | - echo '<img src="' . plugins_url( 'images/t-image1.png', dirname( __FILE__ ) ) . '" > '; |
|
105 | - ?> |
|
104 | + echo '<img src="' . plugins_url( 'images/t-image1.png', dirname( __FILE__ ) ) . '" > '; |
|
105 | + ?> |
|
106 | 106 | </div> |
107 | 107 | <div class="t-content"> |
108 | 108 | <p> |
@@ -126,26 +126,26 @@ discard block |
||
126 | 126 | </div> |
127 | 127 | </div> |
128 | 128 | <?php |
129 | - } else { |
|
130 | - $installed_plugins = get_plugins(); |
|
129 | + } else { |
|
130 | + $installed_plugins = get_plugins(); |
|
131 | 131 | $addon_obj = new WPInv_Admin_Addons(); |
132 | - if ( $addons = $addon_obj->get_section_data( $current_tab ) ) : |
|
133 | - //print_r($addons); |
|
134 | - ?> |
|
132 | + if ( $addons = $addon_obj->get_section_data( $current_tab ) ) : |
|
133 | + //print_r($addons); |
|
134 | + ?> |
|
135 | 135 | <ul class="wpi-products"> |
136 | 136 | <?php |
137 | 137 | foreach ( $addons as $addon ) : |
138 | 138 | if ( 965 == $addon->info->id ) { |
139 | 139 | continue;}// don't show quote add on |
140 | - ?> |
|
140 | + ?> |
|
141 | 141 | <li class="wpi-product"> |
142 | 142 | <div class="wpi-product-title"> |
143 | 143 | <h3> |
144 | 144 | <?php |
145 | - if ( ! empty( $addon->info->excerpt ) ) { |
|
146 | - echo wpi_help_tip( $addon->info->excerpt ); |
|
147 | - } |
|
148 | - echo esc_html( $addon->info->title ); |
|
145 | + if ( ! empty( $addon->info->excerpt ) ) { |
|
146 | + echo wpi_help_tip( $addon->info->excerpt ); |
|
147 | + } |
|
148 | + echo esc_html( $addon->info->title ); |
|
149 | 149 | ?> |
150 | 150 | </h3> |
151 | 151 | </div> |
@@ -156,32 +156,32 @@ discard block |
||
156 | 156 | <?php |
157 | 157 | endif; |
158 | 158 | |
159 | - if ( 'stripe-payment-gateway' == $addon->info->slug ) { |
|
160 | - $addon->info->slug = 'getpaid-stripe-payments'; |
|
161 | - $addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/'; |
|
162 | - } |
|
163 | - |
|
164 | - if ( isset( $addon->info->link ) && substr( $addon->info->link, 0, 21 ) === 'https://wordpress.org' ) { |
|
165 | - echo '<a href="' . esc_url( admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug ) ) . '&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
|
166 | - echo '<span class="wpi-product-info">' . __( 'More info', 'invoicing' ) . '</span>'; |
|
167 | - echo '</a>'; |
|
168 | - } elseif ( isset( $addon->info->link ) && ( substr( $addon->info->link, 0, 23 ) === 'https://wpinvoicing.com' || substr( $addon->info->link, 0, 21 ) === 'https://wpgetpaid.com' ) ) { |
|
169 | - if ( defined( 'WP_EASY_UPDATES_ACTIVE' ) ) { |
|
170 | - $url = admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpgetpaid.com&TB_iframe=true' ); |
|
171 | - } else { |
|
172 | - // if installed show activation link |
|
173 | - if ( isset( $installed_plugins['wp-easy-updates/external-updates.php'] ) ) { |
|
174 | - $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation'; |
|
175 | - } else { |
|
176 | - $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external'; |
|
177 | - } |
|
178 | - } |
|
179 | - echo '<a href="' . esc_url( $url ) . '" class="thickbox">'; |
|
180 | - echo '<span class="wpi-product-info">' . __( 'More info', 'invoicing' ) . '</span>'; |
|
181 | - echo '</a>'; |
|
182 | - } |
|
183 | - |
|
184 | - ?> |
|
159 | + if ( 'stripe-payment-gateway' == $addon->info->slug ) { |
|
160 | + $addon->info->slug = 'getpaid-stripe-payments'; |
|
161 | + $addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/'; |
|
162 | + } |
|
163 | + |
|
164 | + if ( isset( $addon->info->link ) && substr( $addon->info->link, 0, 21 ) === 'https://wordpress.org' ) { |
|
165 | + echo '<a href="' . esc_url( admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug ) ) . '&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
|
166 | + echo '<span class="wpi-product-info">' . __( 'More info', 'invoicing' ) . '</span>'; |
|
167 | + echo '</a>'; |
|
168 | + } elseif ( isset( $addon->info->link ) && ( substr( $addon->info->link, 0, 23 ) === 'https://wpinvoicing.com' || substr( $addon->info->link, 0, 21 ) === 'https://wpgetpaid.com' ) ) { |
|
169 | + if ( defined( 'WP_EASY_UPDATES_ACTIVE' ) ) { |
|
170 | + $url = admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpgetpaid.com&TB_iframe=true' ); |
|
171 | + } else { |
|
172 | + // if installed show activation link |
|
173 | + if ( isset( $installed_plugins['wp-easy-updates/external-updates.php'] ) ) { |
|
174 | + $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation'; |
|
175 | + } else { |
|
176 | + $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external'; |
|
177 | + } |
|
178 | + } |
|
179 | + echo '<a href="' . esc_url( $url ) . '" class="thickbox">'; |
|
180 | + echo '<span class="wpi-product-info">' . __( 'More info', 'invoicing' ) . '</span>'; |
|
181 | + echo '</a>'; |
|
182 | + } |
|
183 | + |
|
184 | + ?> |
|
185 | 185 | |
186 | 186 | </span> |
187 | 187 | |
@@ -189,15 +189,15 @@ discard block |
||
189 | 189 | <span class="wpi-product-button"> |
190 | 190 | <?php |
191 | 191 | $addon_obj->output_button( $addon ); |
192 | - ?> |
|
192 | + ?> |
|
193 | 193 | </span> |
194 | 194 | |
195 | 195 | <span class="wpi-price"><?php //print_r($addon); //echo wp_kses_post( $addon->price ); ?></span></li><?php endforeach; ?></ul> |
196 | 196 | <?php |
197 | 197 | endif; |
198 | - } |
|
198 | + } |
|
199 | 199 | } |
200 | - ?> |
|
200 | + ?> |
|
201 | 201 | |
202 | 202 | |
203 | 203 | <div class="clearfix" ></div> |
@@ -216,8 +216,8 @@ discard block |
||
216 | 216 | <input class="wpeu-licence-key" type="text" placeholder="<?php esc_attr_e( 'Enter your licence key', 'invoicing' ); ?>"> <button class="button-primary wpeu-licence-popup-button" ><?php esc_html_e( 'Install', 'invoicing' ); ?></button> |
217 | 217 | <br> |
218 | 218 | <?php |
219 | - echo sprintf( __( '%1$sFind your licence key here%2$s OR %3$sBuy one here%4$s', 'invoicing' ), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>' ); |
|
220 | - ?> |
|
219 | + echo sprintf( __( '%1$sFind your licence key here%2$s OR %3$sBuy one here%4$s', 'invoicing' ), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>' ); |
|
220 | + ?> |
|
221 | 221 | </span> |
222 | 222 | </div> |
223 | 223 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Admin View: Page - Addons |
4 | 4 | * |
5 | 5 | */ |
6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
6 | +if (!defined('ABSPATH')) { |
|
7 | 7 | exit; |
8 | 8 | } |
9 | 9 | add_ThickBox(); |
@@ -11,19 +11,19 @@ discard block |
||
11 | 11 | <div class="wrap wpi_addons_wrap"> |
12 | 12 | <h1><?php echo get_admin_page_title(); ?></h1> |
13 | 13 | |
14 | - <?php if ( $tabs ) { ?> |
|
14 | + <?php if ($tabs) { ?> |
|
15 | 15 | <nav class="nav-tab-wrapper wpi-nav-tab-wrapper"> |
16 | 16 | <?php |
17 | - foreach ( $tabs as $name => $label ) { |
|
18 | - echo '<a href="' . esc_url( admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>'; |
|
17 | + foreach ($tabs as $name => $label) { |
|
18 | + echo '<a href="' . esc_url(admin_url('admin.php?page=wpi-addons&tab=' . $name)) . '" class="nav-tab ' . ($current_tab == $name ? 'nav-tab-active' : '') . '">' . esc_html($label) . '</a>'; |
|
19 | 19 | } |
20 | - do_action( 'wpi_addons_tabs' ); |
|
20 | + do_action('wpi_addons_tabs'); |
|
21 | 21 | ?> |
22 | 22 | </nav> |
23 | 23 | |
24 | 24 | <?php |
25 | 25 | |
26 | - if ( $current_tab == 'membership' ) { |
|
26 | + if ($current_tab == 'membership') { |
|
27 | 27 | |
28 | 28 | ?> |
29 | 29 | |
@@ -32,42 +32,42 @@ discard block |
||
32 | 32 | <!-- |
33 | 33 | <h2>With our WPInvoicing Membership you get access to all our products!</h2> |
34 | 34 | <p><a class="button button-primary" href="https://wpinvoicing.com/downloads/membership/">View Memberships</a></p>--> |
35 | - <?php if ( defined( 'WP_EASY_UPDATES_ACTIVE' ) ) { ?> |
|
36 | - <h2><?php esc_html_e( 'Have a membership key?', 'invoicing' ); ?></h2> |
|
35 | + <?php if (defined('WP_EASY_UPDATES_ACTIVE')) { ?> |
|
36 | + <h2><?php esc_html_e('Have a membership key?', 'invoicing'); ?></h2> |
|
37 | 37 | <p> |
38 | 38 | <?php |
39 | - $wpeu_admin = new External_Updates_Admin( 'wpinvoicing.com', '1' ); |
|
40 | - echo $wpeu_admin->render_licence_actions( 'wpinvoicing.com', 'membership', array( 95, 106, 108, 12351 ) ); |
|
39 | + $wpeu_admin = new External_Updates_Admin('wpinvoicing.com', '1'); |
|
40 | + echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership', array(95, 106, 108, 12351)); |
|
41 | 41 | ?> |
42 | 42 | </p> |
43 | 43 | <?php } ?> |
44 | 44 | |
45 | 45 | <div class="membership-cta-contet"> |
46 | 46 | <div class="main-cta"> |
47 | - <h2><?php esc_html_e( 'Membership benefits Include:', 'invoicing' ); ?></h2> |
|
47 | + <h2><?php esc_html_e('Membership benefits Include:', 'invoicing'); ?></h2> |
|
48 | 48 | <div class="feature-list"> |
49 | 49 | <ul> |
50 | 50 | <?php |
51 | 51 | $addon_obj = new WPInv_Admin_Addons(); |
52 | - if ( $addons = $addon_obj->get_section_data( 'addons' ) ) { |
|
53 | - foreach ( $addons as $addon ) { |
|
54 | - echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>'; |
|
52 | + if ($addons = $addon_obj->get_section_data('addons')) { |
|
53 | + foreach ($addons as $addon) { |
|
54 | + echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html($addon->info->title) . '</li>'; |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | ?> |
58 | 58 | </ul> |
59 | 59 | |
60 | 60 | <div class="feature-cta"> |
61 | - <h3><?php esc_html_e( 'Membership Starts from', 'invoicing' ); ?></h3> |
|
61 | + <h3><?php esc_html_e('Membership Starts from', 'invoicing'); ?></h3> |
|
62 | 62 | <h4>$99</h4> |
63 | - <a href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php esc_attr_e( 'Buy Membership', 'invoicing' ); ?></a> |
|
63 | + <a href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php esc_attr_e('Buy Membership', 'invoicing'); ?></a> |
|
64 | 64 | </div> |
65 | - <h3><?php esc_html_e( 'Included Gateways:', 'invoicing' ); ?></h3> |
|
65 | + <h3><?php esc_html_e('Included Gateways:', 'invoicing'); ?></h3> |
|
66 | 66 | <ul> |
67 | 67 | <?php |
68 | - if ( $addons = $addon_obj->get_section_data( 'gateways' ) ) { |
|
69 | - foreach ( $addons as $addon ) { |
|
70 | - echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>'; |
|
68 | + if ($addons = $addon_obj->get_section_data('gateways')) { |
|
69 | + foreach ($addons as $addon) { |
|
70 | + echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html($addon->info->title) . '</li>'; |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | ?> |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | <div class="testimonial-content"> |
82 | 82 | <div class="t-image"> |
83 | 83 | <?php |
84 | - echo '<img src="' . plugins_url( 'images/t-image2.png', dirname( __FILE__ ) ) . '" > '; |
|
84 | + echo '<img src="' . plugins_url('images/t-image2.png', dirname(__FILE__)) . '" > '; |
|
85 | 85 | ?> |
86 | 86 | </div> |
87 | 87 | <div class="t-content"> |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | <div class="testimonial-content"> |
102 | 102 | <div class="t-image"> |
103 | 103 | <?php |
104 | - echo '<img src="' . plugins_url( 'images/t-image1.png', dirname( __FILE__ ) ) . '" > '; |
|
104 | + echo '<img src="' . plugins_url('images/t-image1.png', dirname(__FILE__)) . '" > '; |
|
105 | 105 | ?> |
106 | 106 | </div> |
107 | 107 | <div class="t-content"> |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | </div> |
118 | 118 | </div> |
119 | 119 | <div class="member-footer"> |
120 | - <a class="footer-btn" href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php esc_html_e( 'Buy Membership', 'invoicing' ); ?></a> |
|
121 | - <a class="footer-link" href="post-new.php?post_type=wpi_invoice"><?php esc_html_e( 'Create Invoice', 'invoicing' ); ?></a> |
|
120 | + <a class="footer-btn" href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php esc_html_e('Buy Membership', 'invoicing'); ?></a> |
|
121 | + <a class="footer-link" href="post-new.php?post_type=wpi_invoice"><?php esc_html_e('Create Invoice', 'invoicing'); ?></a> |
|
122 | 122 | </div> |
123 | 123 | </div> |
124 | 124 | |
@@ -129,55 +129,55 @@ discard block |
||
129 | 129 | } else { |
130 | 130 | $installed_plugins = get_plugins(); |
131 | 131 | $addon_obj = new WPInv_Admin_Addons(); |
132 | - if ( $addons = $addon_obj->get_section_data( $current_tab ) ) : |
|
132 | + if ($addons = $addon_obj->get_section_data($current_tab)) : |
|
133 | 133 | //print_r($addons); |
134 | 134 | ?> |
135 | 135 | <ul class="wpi-products"> |
136 | 136 | <?php |
137 | - foreach ( $addons as $addon ) : |
|
138 | - if ( 965 == $addon->info->id ) { |
|
139 | -continue;}// don't show quote add on |
|
137 | + foreach ($addons as $addon) : |
|
138 | + if (965 == $addon->info->id) { |
|
139 | +continue; }// don't show quote add on |
|
140 | 140 | ?> |
141 | 141 | <li class="wpi-product"> |
142 | 142 | <div class="wpi-product-title"> |
143 | 143 | <h3> |
144 | 144 | <?php |
145 | - if ( ! empty( $addon->info->excerpt ) ) { |
|
146 | - echo wpi_help_tip( $addon->info->excerpt ); |
|
145 | + if (!empty($addon->info->excerpt)) { |
|
146 | + echo wpi_help_tip($addon->info->excerpt); |
|
147 | 147 | } |
148 | - echo esc_html( $addon->info->title ); |
|
148 | + echo esc_html($addon->info->title); |
|
149 | 149 | ?> |
150 | 150 | </h3> |
151 | 151 | </div> |
152 | 152 | |
153 | 153 | <span class="wpi-product-image"> |
154 | - <?php if ( ! empty( $addon->info->thumbnail ) ) : ?> |
|
155 | - <img src="<?php echo esc_attr( $addon->info->thumbnail ); ?>"/> |
|
154 | + <?php if (!empty($addon->info->thumbnail)) : ?> |
|
155 | + <img src="<?php echo esc_attr($addon->info->thumbnail); ?>"/> |
|
156 | 156 | <?php |
157 | 157 | endif; |
158 | 158 | |
159 | - if ( 'stripe-payment-gateway' == $addon->info->slug ) { |
|
159 | + if ('stripe-payment-gateway' == $addon->info->slug) { |
|
160 | 160 | $addon->info->slug = 'getpaid-stripe-payments'; |
161 | 161 | $addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/'; |
162 | 162 | } |
163 | 163 | |
164 | - if ( isset( $addon->info->link ) && substr( $addon->info->link, 0, 21 ) === 'https://wordpress.org' ) { |
|
165 | - echo '<a href="' . esc_url( admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug ) ) . '&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
|
166 | - echo '<span class="wpi-product-info">' . __( 'More info', 'invoicing' ) . '</span>'; |
|
164 | + if (isset($addon->info->link) && substr($addon->info->link, 0, 21) === 'https://wordpress.org') { |
|
165 | + echo '<a href="' . esc_url(admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug)) . '&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
|
166 | + echo '<span class="wpi-product-info">' . __('More info', 'invoicing') . '</span>'; |
|
167 | 167 | echo '</a>'; |
168 | - } elseif ( isset( $addon->info->link ) && ( substr( $addon->info->link, 0, 23 ) === 'https://wpinvoicing.com' || substr( $addon->info->link, 0, 21 ) === 'https://wpgetpaid.com' ) ) { |
|
169 | - if ( defined( 'WP_EASY_UPDATES_ACTIVE' ) ) { |
|
170 | - $url = admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpgetpaid.com&TB_iframe=true' ); |
|
168 | + } elseif (isset($addon->info->link) && (substr($addon->info->link, 0, 23) === 'https://wpinvoicing.com' || substr($addon->info->link, 0, 21) === 'https://wpgetpaid.com')) { |
|
169 | + if (defined('WP_EASY_UPDATES_ACTIVE')) { |
|
170 | + $url = admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpgetpaid.com&TB_iframe=true'); |
|
171 | 171 | } else { |
172 | 172 | // if installed show activation link |
173 | - if ( isset( $installed_plugins['wp-easy-updates/external-updates.php'] ) ) { |
|
173 | + if (isset($installed_plugins['wp-easy-updates/external-updates.php'])) { |
|
174 | 174 | $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation'; |
175 | 175 | } else { |
176 | 176 | $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external'; |
177 | 177 | } |
178 | 178 | } |
179 | - echo '<a href="' . esc_url( $url ) . '" class="thickbox">'; |
|
180 | - echo '<span class="wpi-product-info">' . __( 'More info', 'invoicing' ) . '</span>'; |
|
179 | + echo '<a href="' . esc_url($url) . '" class="thickbox">'; |
|
180 | + echo '<span class="wpi-product-info">' . __('More info', 'invoicing') . '</span>'; |
|
181 | 181 | echo '</a>'; |
182 | 182 | } |
183 | 183 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | |
189 | 189 | <span class="wpi-product-button"> |
190 | 190 | <?php |
191 | - $addon_obj->output_button( $addon ); |
|
191 | + $addon_obj->output_button($addon); |
|
192 | 192 | ?> |
193 | 193 | </span> |
194 | 194 | |
@@ -202,21 +202,21 @@ discard block |
||
202 | 202 | |
203 | 203 | <div class="clearfix" ></div> |
204 | 204 | |
205 | - <?php if ( $current_tab == 'addons' ) { ?> |
|
206 | - <p><?php printf( __( 'All of our Invoicing Addons can be found on WPInvoicing.com here: <a href="%s">Invoicing Addons</a>', 'invoicing' ), 'https://wpinvoicing.com/downloads/category/addons/' ); ?></p> |
|
207 | - <?php } if ( $current_tab == 'gateways' ) { ?> |
|
208 | - <p><?php printf( __( 'All of our Invoicing Payment Gateways can be found on WPInvoicing.com here: <a href="%s">Invoicing Payment Gateways</a>', 'invoicing' ), 'https://wpinvoicing.com/downloads/category/gateways/' ); ?></p> |
|
205 | + <?php if ($current_tab == 'addons') { ?> |
|
206 | + <p><?php printf(__('All of our Invoicing Addons can be found on WPInvoicing.com here: <a href="%s">Invoicing Addons</a>', 'invoicing'), 'https://wpinvoicing.com/downloads/category/addons/'); ?></p> |
|
207 | + <?php } if ($current_tab == 'gateways') { ?> |
|
208 | + <p><?php printf(__('All of our Invoicing Payment Gateways can be found on WPInvoicing.com here: <a href="%s">Invoicing Payment Gateways</a>', 'invoicing'), 'https://wpinvoicing.com/downloads/category/gateways/'); ?></p> |
|
209 | 209 | <?php } ?> |
210 | 210 | |
211 | - <div id="wpi-wpeu-required-activation" style="display:none;"><span class="wpi-notification "><?php printf( __( "The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s'>activate</a> it now.", 'invoicing' ), wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=wp-easy-updates/external-updates.php' ), 'activate-plugin_wp-easy-updates/external-updates.php' ) ); ?></span></div> |
|
212 | - <div id="wpi-wpeu-required-for-external" style="display:none;"><span class="wpi-notification "><?php printf( __( "The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s' onclick='window.open(\"https://wpeasyupdates.com/wp-easy-updates.zip\", \"_blank\");' >download</a> and install it now.", 'invoicing' ), admin_url( 'plugin-install.php?tab=upload&wpeu-install=true' ) ); ?></span></div> |
|
211 | + <div id="wpi-wpeu-required-activation" style="display:none;"><span class="wpi-notification "><?php printf(__("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s'>activate</a> it now.", 'invoicing'), wp_nonce_url(admin_url('plugins.php?action=activate&plugin=wp-easy-updates/external-updates.php'), 'activate-plugin_wp-easy-updates/external-updates.php')); ?></span></div> |
|
212 | + <div id="wpi-wpeu-required-for-external" style="display:none;"><span class="wpi-notification "><?php printf(__("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s' onclick='window.open(\"https://wpeasyupdates.com/wp-easy-updates.zip\", \"_blank\");' >download</a> and install it now.", 'invoicing'), admin_url('plugin-install.php?tab=upload&wpeu-install=true')); ?></span></div> |
|
213 | 213 | <div id="wpeu-licence-popup" style="display:none;"> |
214 | 214 | <span class="wpi-notification noti-white"> |
215 | - <h3 class="wpeu-licence-title"><?php esc_html_e( 'Licence key', 'invoicing' ); ?></h3> |
|
216 | - <input class="wpeu-licence-key" type="text" placeholder="<?php esc_attr_e( 'Enter your licence key', 'invoicing' ); ?>"> <button class="button-primary wpeu-licence-popup-button" ><?php esc_html_e( 'Install', 'invoicing' ); ?></button> |
|
215 | + <h3 class="wpeu-licence-title"><?php esc_html_e('Licence key', 'invoicing'); ?></h3> |
|
216 | + <input class="wpeu-licence-key" type="text" placeholder="<?php esc_attr_e('Enter your licence key', 'invoicing'); ?>"> <button class="button-primary wpeu-licence-popup-button" ><?php esc_html_e('Install', 'invoicing'); ?></button> |
|
217 | 217 | <br> |
218 | 218 | <?php |
219 | - echo sprintf( __( '%1$sFind your licence key here%2$s OR %3$sBuy one here%4$s', 'invoicing' ), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>' ); |
|
219 | + echo sprintf(__('%1$sFind your licence key here%2$s OR %3$sBuy one here%4$s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>'); |
|
220 | 220 | ?> |
221 | 221 | </span> |
222 | 222 | </div> |
@@ -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 | * Are we supporting item quantities? |
@@ -20,35 +20,35 @@ discard block |
||
20 | 20 | */ |
21 | 21 | function wpinv_get_ip() { |
22 | 22 | |
23 | - if ( isset( $_SERVER['HTTP_X_REAL_IP'] ) ) { |
|
24 | - return sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REAL_IP'] ) ); |
|
23 | + if (isset($_SERVER['HTTP_X_REAL_IP'])) { |
|
24 | + return sanitize_text_field(wp_unslash($_SERVER['HTTP_X_REAL_IP'])); |
|
25 | 25 | } |
26 | 26 | |
27 | - if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
27 | + if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
28 | 28 | // Proxy servers can send through this header like this: X-Forwarded-For: client1, proxy1, proxy2 |
29 | 29 | // Make sure we always only send through the first IP in the list which should always be the client IP. |
30 | - return (string) rest_is_ip_address( trim( current( preg_split( '/,/', sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) ) ) ); |
|
30 | + return (string) rest_is_ip_address(trim(current(preg_split('/,/', sanitize_text_field(wp_unslash($_SERVER['HTTP_X_FORWARDED_FOR'])))))); |
|
31 | 31 | } |
32 | 32 | |
33 | - if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
34 | - return sanitize_text_field( wp_unslash( $_SERVER['HTTP_CLIENT_IP'] ) ); |
|
33 | + if (isset($_SERVER['HTTP_CLIENT_IP'])) { |
|
34 | + return sanitize_text_field(wp_unslash($_SERVER['HTTP_CLIENT_IP'])); |
|
35 | 35 | } |
36 | 36 | |
37 | - if ( isset( $_SERVER['REMOTE_ADDR'] ) ) { |
|
38 | - return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ); |
|
37 | + if (isset($_SERVER['REMOTE_ADDR'])) { |
|
38 | + return sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR'])); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | return ''; |
42 | 42 | } |
43 | 43 | |
44 | 44 | function wpinv_get_user_agent() { |
45 | - if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
46 | - $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ); |
|
45 | + if (!empty($_SERVER['HTTP_USER_AGENT'])) { |
|
46 | + $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']); |
|
47 | 47 | } else { |
48 | 48 | $user_agent = ''; |
49 | 49 | } |
50 | 50 | |
51 | - return apply_filters( 'wpinv_get_user_agent', $user_agent ); |
|
51 | + return apply_filters('wpinv_get_user_agent', $user_agent); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -57,16 +57,16 @@ discard block |
||
57 | 57 | * @param string $amount The amount to sanitize. |
58 | 58 | * @return float |
59 | 59 | */ |
60 | -function getpaid_standardize_amount( $amount ) { |
|
60 | +function getpaid_standardize_amount($amount) { |
|
61 | 61 | |
62 | - $amount = str_replace( wpinv_thousands_separator(), '', $amount ); |
|
63 | - $amount = str_replace( wpinv_decimal_separator(), '.', $amount ); |
|
64 | - if ( is_numeric( $amount ) ) { |
|
65 | - return floatval( $amount ); |
|
62 | + $amount = str_replace(wpinv_thousands_separator(), '', $amount); |
|
63 | + $amount = str_replace(wpinv_decimal_separator(), '.', $amount); |
|
64 | + if (is_numeric($amount)) { |
|
65 | + return floatval($amount); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | // Cast the remaining to a float. |
69 | - return wpinv_round_amount( preg_replace( '/[^0-9\.\-]/', '', $amount ) ); |
|
69 | + return wpinv_round_amount(preg_replace('/[^0-9\.\-]/', '', $amount)); |
|
70 | 70 | |
71 | 71 | } |
72 | 72 | |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @param string $amount The amount to sanitize. |
77 | 77 | */ |
78 | -function getpaid_unstandardize_amount( $amount ) { |
|
79 | - return str_replace( '.', wpinv_decimal_separator(), $amount ); |
|
78 | +function getpaid_unstandardize_amount($amount) { |
|
79 | + return str_replace('.', wpinv_decimal_separator(), $amount); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,23 +84,23 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @param string $amount The amount to sanitize. |
86 | 86 | */ |
87 | -function wpinv_sanitize_amount( $amount ) { |
|
87 | +function wpinv_sanitize_amount($amount) { |
|
88 | 88 | |
89 | - if ( is_numeric( $amount ) ) { |
|
90 | - return floatval( $amount ); |
|
89 | + if (is_numeric($amount)) { |
|
90 | + return floatval($amount); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | // Separate the decimals and thousands. |
94 | - $amount = explode( wpinv_decimal_separator(), $amount ); |
|
94 | + $amount = explode(wpinv_decimal_separator(), $amount); |
|
95 | 95 | |
96 | 96 | // Remove thousands. |
97 | - $amount[0] = str_replace( wpinv_thousands_separator(), '', $amount[0] ); |
|
97 | + $amount[0] = str_replace(wpinv_thousands_separator(), '', $amount[0]); |
|
98 | 98 | |
99 | 99 | // Convert back to string. |
100 | - $amount = count( $amount ) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0]; |
|
100 | + $amount = count($amount) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0]; |
|
101 | 101 | |
102 | 102 | // Cast the remaining to a float. |
103 | - return (float) preg_replace( '/[^0-9\.\-]/', '', $amount ); |
|
103 | + return (float) preg_replace('/[^0-9\.\-]/', '', $amount); |
|
104 | 104 | |
105 | 105 | } |
106 | 106 | |
@@ -110,19 +110,19 @@ discard block |
||
110 | 110 | * @param float $amount |
111 | 111 | * @param float|string|int|null $decimals |
112 | 112 | */ |
113 | -function wpinv_round_amount( $amount, $decimals = null, $use_sprintf = false ) { |
|
113 | +function wpinv_round_amount($amount, $decimals = null, $use_sprintf = false) { |
|
114 | 114 | |
115 | - if ( $decimals === null ) { |
|
115 | + if ($decimals === null) { |
|
116 | 116 | $decimals = wpinv_decimals(); |
117 | 117 | } |
118 | 118 | |
119 | - if ( $use_sprintf ) { |
|
120 | - $amount = sprintf( "%.{$decimals}f", (float) $amount ); |
|
119 | + if ($use_sprintf) { |
|
120 | + $amount = sprintf("%.{$decimals}f", (float) $amount); |
|
121 | 121 | } else { |
122 | - $amount = round( (float) $amount, absint( $decimals ) ); |
|
122 | + $amount = round((float) $amount, absint($decimals)); |
|
123 | 123 | } |
124 | 124 | |
125 | - return apply_filters( 'wpinv_round_amount', $amount, $decimals ); |
|
125 | + return apply_filters('wpinv_round_amount', $amount, $decimals); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -134,32 +134,32 @@ discard block |
||
134 | 134 | * @param string|WPInv_Invoice $invoice The invoice object|post type|type |
135 | 135 | * @return array |
136 | 136 | */ |
137 | -function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
|
137 | +function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) { |
|
138 | 138 | |
139 | 139 | $invoice_statuses = array( |
140 | - 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
141 | - 'publish' => _x( 'Paid', 'Invoice status', 'invoicing' ), |
|
142 | - 'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
143 | - 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
144 | - 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
145 | - 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
146 | - 'wpi-failed' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
147 | - 'wpi-renewal' => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ), |
|
140 | + 'wpi-pending' => _x('Pending payment', 'Invoice status', 'invoicing'), |
|
141 | + 'publish' => _x('Paid', 'Invoice status', 'invoicing'), |
|
142 | + 'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'), |
|
143 | + 'wpi-onhold' => _x('On hold', 'Invoice status', 'invoicing'), |
|
144 | + 'wpi-cancelled' => _x('Cancelled', 'Invoice status', 'invoicing'), |
|
145 | + 'wpi-refunded' => _x('Refunded', 'Invoice status', 'invoicing'), |
|
146 | + 'wpi-failed' => _x('Failed', 'Invoice status', 'invoicing'), |
|
147 | + 'wpi-renewal' => _x('Renewal Payment', 'Invoice status', 'invoicing'), |
|
148 | 148 | ); |
149 | 149 | |
150 | - if ( $draft ) { |
|
151 | - $invoice_statuses['draft'] = __( 'Draft', 'invoicing' ); |
|
150 | + if ($draft) { |
|
151 | + $invoice_statuses['draft'] = __('Draft', 'invoicing'); |
|
152 | 152 | } |
153 | 153 | |
154 | - if ( $trashed ) { |
|
155 | - $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
|
154 | + if ($trashed) { |
|
155 | + $invoice_statuses['trash'] = __('Trash', 'invoicing'); |
|
156 | 156 | } |
157 | 157 | |
158 | - if ( $invoice instanceof WPInv_Invoice ) { |
|
158 | + if ($invoice instanceof WPInv_Invoice) { |
|
159 | 159 | $invoice = $invoice->get_post_type(); |
160 | 160 | } |
161 | 161 | |
162 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
162 | + return apply_filters('wpinv_statuses', $invoice_statuses, $invoice); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -168,11 +168,11 @@ discard block |
||
168 | 168 | * @param string $status The raw status |
169 | 169 | * @param string|WPInv_Invoice $invoice The invoice object|post type|type |
170 | 170 | */ |
171 | -function wpinv_status_nicename( $status, $invoice = false ) { |
|
172 | - $statuses = wpinv_get_invoice_statuses( true, true, $invoice ); |
|
173 | - $status = isset( $statuses[ $status ] ) ? $statuses[ $status ] : $status; |
|
171 | +function wpinv_status_nicename($status, $invoice = false) { |
|
172 | + $statuses = wpinv_get_invoice_statuses(true, true, $invoice); |
|
173 | + $status = isset($statuses[$status]) ? $statuses[$status] : $status; |
|
174 | 174 | |
175 | - return sanitize_text_field( $status ); |
|
175 | + return sanitize_text_field($status); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @param string $current |
182 | 182 | */ |
183 | -function wpinv_get_currency( $current = '' ) { |
|
183 | +function wpinv_get_currency($current = '') { |
|
184 | 184 | |
185 | - if ( empty( $current ) ) { |
|
186 | - $current = apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) ); |
|
185 | + if (empty($current)) { |
|
186 | + $current = apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD')); |
|
187 | 187 | } |
188 | 188 | |
189 | - return trim( strtoupper( $current ) ); |
|
189 | + return trim(strtoupper($current)); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -194,25 +194,25 @@ discard block |
||
194 | 194 | * |
195 | 195 | * @param string|null $currency The currency code. Defaults to the default currency. |
196 | 196 | */ |
197 | -function wpinv_currency_symbol( $currency = null ) { |
|
197 | +function wpinv_currency_symbol($currency = null) { |
|
198 | 198 | |
199 | 199 | // Prepare the currency. |
200 | - $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency ); |
|
200 | + $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency); |
|
201 | 201 | |
202 | 202 | // Fetch all symbols. |
203 | 203 | $symbols = wpinv_get_currency_symbols(); |
204 | 204 | |
205 | 205 | // Fetch this currencies symbol. |
206 | - $currency_symbol = isset( $symbols[ $currency ] ) ? $symbols[ $currency ] : $currency; |
|
206 | + $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency; |
|
207 | 207 | |
208 | 208 | // Filter the symbol. |
209 | - return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency ); |
|
209 | + return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | function wpinv_currency_position() { |
213 | - $position = wpinv_get_option( 'currency_position', 'left' ); |
|
213 | + $position = wpinv_get_option('currency_position', 'left'); |
|
214 | 214 | |
215 | - return apply_filters( 'wpinv_currency_position', $position ); |
|
215 | + return apply_filters('wpinv_currency_position', $position); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -220,13 +220,13 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @param $string|null $current |
222 | 222 | */ |
223 | -function wpinv_thousands_separator( $current = null ) { |
|
223 | +function wpinv_thousands_separator($current = null) { |
|
224 | 224 | |
225 | - if ( null == $current ) { |
|
226 | - $current = wpinv_get_option( 'thousands_separator', ',' ); |
|
225 | + if (null == $current) { |
|
226 | + $current = wpinv_get_option('thousands_separator', ','); |
|
227 | 227 | } |
228 | 228 | |
229 | - return trim( $current ); |
|
229 | + return trim($current); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -234,13 +234,13 @@ discard block |
||
234 | 234 | * |
235 | 235 | * @param $string|null $current |
236 | 236 | */ |
237 | -function wpinv_decimal_separator( $current = null ) { |
|
237 | +function wpinv_decimal_separator($current = null) { |
|
238 | 238 | |
239 | - if ( null == $current ) { |
|
240 | - $current = wpinv_get_option( 'decimal_separator', '.' ); |
|
239 | + if (null == $current) { |
|
240 | + $current = wpinv_get_option('decimal_separator', '.'); |
|
241 | 241 | } |
242 | 242 | |
243 | - return trim( $current ); |
|
243 | + return trim($current); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -248,27 +248,27 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @param $string|null $current |
250 | 250 | */ |
251 | -function wpinv_decimals( $current = null ) { |
|
251 | +function wpinv_decimals($current = null) { |
|
252 | 252 | |
253 | - if ( null == $current ) { |
|
254 | - $current = wpinv_get_option( 'decimals', 2 ); |
|
253 | + if (null == $current) { |
|
254 | + $current = wpinv_get_option('decimals', 2); |
|
255 | 255 | } |
256 | 256 | |
257 | - return absint( $current ); |
|
257 | + return absint($current); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
261 | 261 | * Retrieves a list of all supported currencies. |
262 | 262 | */ |
263 | 263 | function wpinv_get_currencies() { |
264 | - return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) ); |
|
264 | + return apply_filters('wpinv_currencies', wpinv_get_data('currencies')); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | /** |
268 | 268 | * Retrieves a list of all currency symbols. |
269 | 269 | */ |
270 | 270 | function wpinv_get_currency_symbols() { |
271 | - return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) ); |
|
271 | + return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols')); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | $currency_pos = wpinv_currency_position(); |
281 | 281 | $format = '%1$s%2$s'; |
282 | 282 | |
283 | - switch ( $currency_pos ) { |
|
283 | + switch ($currency_pos) { |
|
284 | 284 | case 'left': |
285 | 285 | $format = '%1$s%2$s'; |
286 | 286 | break; |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | break; |
296 | 296 | } |
297 | 297 | |
298 | - return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
298 | + return apply_filters('getpaid_price_format', $format, $currency_pos); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
@@ -305,25 +305,25 @@ discard block |
||
305 | 305 | * @param string $currency Currency. |
306 | 306 | * @return string |
307 | 307 | */ |
308 | -function wpinv_price( $amount = 0, $currency = '' ) { |
|
308 | +function wpinv_price($amount = 0, $currency = '') { |
|
309 | 309 | |
310 | 310 | // Backwards compatibility. |
311 | - $amount = wpinv_sanitize_amount( $amount ); |
|
311 | + $amount = wpinv_sanitize_amount($amount); |
|
312 | 312 | |
313 | 313 | // Prepare variables. |
314 | - $currency = wpinv_get_currency( $currency ); |
|
314 | + $currency = wpinv_get_currency($currency); |
|
315 | 315 | $amount = (float) $amount; |
316 | 316 | $unformatted_amount = $amount; |
317 | 317 | $negative = $amount < 0; |
318 | - $amount = apply_filters( 'getpaid_raw_amount', floatval( $negative ? $amount * -1 : $amount ) ); |
|
319 | - $amount = wpinv_format_amount( $amount ); |
|
318 | + $amount = apply_filters('getpaid_raw_amount', floatval($negative ? $amount * -1 : $amount)); |
|
319 | + $amount = wpinv_format_amount($amount); |
|
320 | 320 | |
321 | 321 | // Format the amount. |
322 | 322 | $format = getpaid_get_price_format(); |
323 | - $formatted_amount = ( $negative ? '-' : '' ) . sprintf( $format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol( $currency ) . '</span>', $amount ); |
|
323 | + $formatted_amount = ($negative ? '-' : '') . sprintf($format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol($currency) . '</span>', $amount); |
|
324 | 324 | |
325 | 325 | // Filter the formatting. |
326 | - return apply_filters( 'wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount ); |
|
326 | + return apply_filters('wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
@@ -334,25 +334,25 @@ discard block |
||
334 | 334 | * @param bool $calculate Whether or not to apply separators. |
335 | 335 | * @return string |
336 | 336 | */ |
337 | -function wpinv_format_amount( $amount, $decimals = null, $calculate = false ) { |
|
337 | +function wpinv_format_amount($amount, $decimals = null, $calculate = false) { |
|
338 | 338 | $thousands_sep = wpinv_thousands_separator(); |
339 | 339 | $decimal_sep = wpinv_decimal_separator(); |
340 | - $decimals = wpinv_decimals( $decimals ); |
|
341 | - $amount = wpinv_sanitize_amount( $amount ); |
|
340 | + $decimals = wpinv_decimals($decimals); |
|
341 | + $amount = wpinv_sanitize_amount($amount); |
|
342 | 342 | |
343 | - if ( $calculate ) { |
|
343 | + if ($calculate) { |
|
344 | 344 | return $amount; |
345 | 345 | } |
346 | 346 | |
347 | 347 | // Fomart the amount. |
348 | - return number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
348 | + return number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
349 | 349 | } |
350 | 350 | |
351 | -function wpinv_sanitize_key( $key ) { |
|
351 | +function wpinv_sanitize_key($key) { |
|
352 | 352 | $raw_key = $key; |
353 | - $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key ); |
|
353 | + $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key); |
|
354 | 354 | |
355 | - return apply_filters( 'wpinv_sanitize_key', $key, $raw_key ); |
|
355 | + return apply_filters('wpinv_sanitize_key', $key, $raw_key); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
@@ -360,8 +360,8 @@ discard block |
||
360 | 360 | * |
361 | 361 | * @param $str the file whose extension should be retrieved. |
362 | 362 | */ |
363 | -function wpinv_get_file_extension( $str ) { |
|
364 | - $filetype = wp_check_filetype( $str ); |
|
363 | +function wpinv_get_file_extension($str) { |
|
364 | + $filetype = wp_check_filetype($str); |
|
365 | 365 | return $filetype['ext']; |
366 | 366 | } |
367 | 367 | |
@@ -370,16 +370,16 @@ discard block |
||
370 | 370 | * |
371 | 371 | * @param string $string |
372 | 372 | */ |
373 | -function wpinv_string_is_image_url( $string ) { |
|
374 | - $extension = strtolower( wpinv_get_file_extension( $string ) ); |
|
375 | - return in_array( $extension, array( 'jpeg', 'jpg', 'png', 'gif', 'ico' ), true ); |
|
373 | +function wpinv_string_is_image_url($string) { |
|
374 | + $extension = strtolower(wpinv_get_file_extension($string)); |
|
375 | + return in_array($extension, array('jpeg', 'jpg', 'png', 'gif', 'ico'), true); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | /** |
379 | 379 | * Returns the current URL. |
380 | 380 | */ |
381 | 381 | function wpinv_get_current_page_url() { |
382 | - return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
382 | + return (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
@@ -389,46 +389,46 @@ discard block |
||
389 | 389 | * @param string $name Constant name. |
390 | 390 | * @param mixed $value Value. |
391 | 391 | */ |
392 | -function getpaid_maybe_define_constant( $name, $value ) { |
|
393 | - if ( ! defined( $name ) ) { |
|
394 | - define( $name, $value ); |
|
392 | +function getpaid_maybe_define_constant($name, $value) { |
|
393 | + if (!defined($name)) { |
|
394 | + define($name, $value); |
|
395 | 395 | } |
396 | 396 | } |
397 | 397 | |
398 | 398 | function wpinv_get_php_arg_separator_output() { |
399 | - return ini_get( 'arg_separator.output' ); |
|
399 | + return ini_get('arg_separator.output'); |
|
400 | 400 | } |
401 | 401 | |
402 | -function wpinv_rgb_from_hex( $color ) { |
|
403 | - $color = str_replace( '#', '', $color ); |
|
402 | +function wpinv_rgb_from_hex($color) { |
|
403 | + $color = str_replace('#', '', $color); |
|
404 | 404 | |
405 | 405 | // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" |
406 | - $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); |
|
407 | - if ( empty( $color ) ) { |
|
406 | + $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color); |
|
407 | + if (empty($color)) { |
|
408 | 408 | return null; |
409 | 409 | } |
410 | 410 | |
411 | - $color = str_split( $color ); |
|
411 | + $color = str_split($color); |
|
412 | 412 | |
413 | 413 | $rgb = array(); |
414 | - $rgb['R'] = hexdec( $color[0] . $color[1] ); |
|
415 | - $rgb['G'] = hexdec( $color[2] . $color[3] ); |
|
416 | - $rgb['B'] = hexdec( $color[4] . $color[5] ); |
|
414 | + $rgb['R'] = hexdec($color[0] . $color[1]); |
|
415 | + $rgb['G'] = hexdec($color[2] . $color[3]); |
|
416 | + $rgb['B'] = hexdec($color[4] . $color[5]); |
|
417 | 417 | |
418 | 418 | return $rgb; |
419 | 419 | } |
420 | 420 | |
421 | -function wpinv_hex_darker( $color, $factor = 30 ) { |
|
422 | - $base = wpinv_rgb_from_hex( $color ); |
|
421 | +function wpinv_hex_darker($color, $factor = 30) { |
|
422 | + $base = wpinv_rgb_from_hex($color); |
|
423 | 423 | $color = '#'; |
424 | 424 | |
425 | - foreach ( $base as $k => $v ) { |
|
425 | + foreach ($base as $k => $v) { |
|
426 | 426 | $amount = $v / 100; |
427 | - $amount = round( $amount * $factor ); |
|
427 | + $amount = round($amount * $factor); |
|
428 | 428 | $new_decimal = $v - $amount; |
429 | 429 | |
430 | - $new_hex_component = dechex( $new_decimal ); |
|
431 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
430 | + $new_hex_component = dechex($new_decimal); |
|
431 | + if (strlen($new_hex_component) < 2) { |
|
432 | 432 | $new_hex_component = '0' . $new_hex_component; |
433 | 433 | } |
434 | 434 | $color .= $new_hex_component; |
@@ -437,18 +437,18 @@ discard block |
||
437 | 437 | return $color; |
438 | 438 | } |
439 | 439 | |
440 | -function wpinv_hex_lighter( $color, $factor = 30 ) { |
|
441 | - $base = wpinv_rgb_from_hex( $color ); |
|
440 | +function wpinv_hex_lighter($color, $factor = 30) { |
|
441 | + $base = wpinv_rgb_from_hex($color); |
|
442 | 442 | $color = '#'; |
443 | 443 | |
444 | - foreach ( $base as $k => $v ) { |
|
444 | + foreach ($base as $k => $v) { |
|
445 | 445 | $amount = 255 - $v; |
446 | 446 | $amount = $amount / 100; |
447 | - $amount = round( $amount * $factor ); |
|
447 | + $amount = round($amount * $factor); |
|
448 | 448 | $new_decimal = $v + $amount; |
449 | 449 | |
450 | - $new_hex_component = dechex( $new_decimal ); |
|
451 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
450 | + $new_hex_component = dechex($new_decimal); |
|
451 | + if (strlen($new_hex_component) < 2) { |
|
452 | 452 | $new_hex_component = '0' . $new_hex_component; |
453 | 453 | } |
454 | 454 | $color .= $new_hex_component; |
@@ -457,22 +457,22 @@ discard block |
||
457 | 457 | return $color; |
458 | 458 | } |
459 | 459 | |
460 | -function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
|
461 | - $hex = str_replace( '#', '', $color ); |
|
460 | +function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') { |
|
461 | + $hex = str_replace('#', '', $color); |
|
462 | 462 | |
463 | - $c_r = hexdec( substr( $hex, 0, 2 ) ); |
|
464 | - $c_g = hexdec( substr( $hex, 2, 2 ) ); |
|
465 | - $c_b = hexdec( substr( $hex, 4, 2 ) ); |
|
463 | + $c_r = hexdec(substr($hex, 0, 2)); |
|
464 | + $c_g = hexdec(substr($hex, 2, 2)); |
|
465 | + $c_b = hexdec(substr($hex, 4, 2)); |
|
466 | 466 | |
467 | - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; |
|
467 | + $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; |
|
468 | 468 | |
469 | 469 | return $brightness > 155 ? $dark : $light; |
470 | 470 | } |
471 | 471 | |
472 | -function wpinv_format_hex( $hex ) { |
|
473 | - $hex = trim( str_replace( '#', '', $hex ) ); |
|
472 | +function wpinv_format_hex($hex) { |
|
473 | + $hex = trim(str_replace('#', '', $hex)); |
|
474 | 474 | |
475 | - if ( strlen( $hex ) == 3 ) { |
|
475 | + if (strlen($hex) == 3) { |
|
476 | 476 | $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
477 | 477 | } |
478 | 478 | |
@@ -492,12 +492,12 @@ discard block |
||
492 | 492 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
493 | 493 | * @return string |
494 | 494 | */ |
495 | -function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
|
496 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
497 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
495 | +function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') { |
|
496 | + if (function_exists('mb_strimwidth')) { |
|
497 | + return mb_strimwidth($str, $start, $width, $trimmaker, $encoding); |
|
498 | 498 | } |
499 | 499 | |
500 | - return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
500 | + return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker; |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | /** |
@@ -509,28 +509,28 @@ discard block |
||
509 | 509 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
510 | 510 | * @return int Returns the number of characters in string. |
511 | 511 | */ |
512 | -function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
|
513 | - if ( function_exists( 'mb_strlen' ) ) { |
|
514 | - return mb_strlen( $str, $encoding ); |
|
512 | +function wpinv_utf8_strlen($str, $encoding = 'UTF-8') { |
|
513 | + if (function_exists('mb_strlen')) { |
|
514 | + return mb_strlen($str, $encoding); |
|
515 | 515 | } |
516 | 516 | |
517 | - return strlen( $str ); |
|
517 | + return strlen($str); |
|
518 | 518 | } |
519 | 519 | |
520 | -function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) { |
|
521 | - if ( function_exists( 'mb_strtolower' ) ) { |
|
522 | - return mb_strtolower( $str, $encoding ); |
|
520 | +function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') { |
|
521 | + if (function_exists('mb_strtolower')) { |
|
522 | + return mb_strtolower($str, $encoding); |
|
523 | 523 | } |
524 | 524 | |
525 | - return strtolower( $str ); |
|
525 | + return strtolower($str); |
|
526 | 526 | } |
527 | 527 | |
528 | -function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) { |
|
529 | - if ( function_exists( 'mb_strtoupper' ) ) { |
|
530 | - return mb_strtoupper( $str, $encoding ); |
|
528 | +function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') { |
|
529 | + if (function_exists('mb_strtoupper')) { |
|
530 | + return mb_strtoupper($str, $encoding); |
|
531 | 531 | } |
532 | 532 | |
533 | - return strtoupper( $str ); |
|
533 | + return strtoupper($str); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | /** |
@@ -544,12 +544,12 @@ discard block |
||
544 | 544 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
545 | 545 | * @return int Returns the position of the first occurrence of search in the string. |
546 | 546 | */ |
547 | -function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
548 | - if ( function_exists( 'mb_strpos' ) ) { |
|
549 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
547 | +function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
548 | + if (function_exists('mb_strpos')) { |
|
549 | + return mb_strpos($str, $find, $offset, $encoding); |
|
550 | 550 | } |
551 | 551 | |
552 | - return strpos( $str, $find, $offset ); |
|
552 | + return strpos($str, $find, $offset); |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | /** |
@@ -563,12 +563,12 @@ discard block |
||
563 | 563 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
564 | 564 | * @return int Returns the position of the last occurrence of search. |
565 | 565 | */ |
566 | -function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
567 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
568 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
566 | +function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
567 | + if (function_exists('mb_strrpos')) { |
|
568 | + return mb_strrpos($str, $find, $offset, $encoding); |
|
569 | 569 | } |
570 | 570 | |
571 | - return strrpos( $str, $find, $offset ); |
|
571 | + return strrpos($str, $find, $offset); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | /** |
@@ -583,16 +583,16 @@ discard block |
||
583 | 583 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
584 | 584 | * @return string |
585 | 585 | */ |
586 | -function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
|
587 | - if ( function_exists( 'mb_substr' ) ) { |
|
588 | - if ( $length === null ) { |
|
589 | - return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
586 | +function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') { |
|
587 | + if (function_exists('mb_substr')) { |
|
588 | + if ($length === null) { |
|
589 | + return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
590 | 590 | } else { |
591 | - return mb_substr( $str, $start, $length, $encoding ); |
|
591 | + return mb_substr($str, $start, $length, $encoding); |
|
592 | 592 | } |
593 | 593 | } |
594 | 594 | |
595 | - return substr( $str, $start, $length ); |
|
595 | + return substr($str, $start, $length); |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | /** |
@@ -604,48 +604,48 @@ discard block |
||
604 | 604 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
605 | 605 | * @return string The width of string. |
606 | 606 | */ |
607 | -function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
|
608 | - if ( function_exists( 'mb_strwidth' ) ) { |
|
609 | - return mb_strwidth( $str, $encoding ); |
|
607 | +function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') { |
|
608 | + if (function_exists('mb_strwidth')) { |
|
609 | + return mb_strwidth($str, $encoding); |
|
610 | 610 | } |
611 | 611 | |
612 | - return wpinv_utf8_strlen( $str, $encoding ); |
|
612 | + return wpinv_utf8_strlen($str, $encoding); |
|
613 | 613 | } |
614 | 614 | |
615 | -function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
|
616 | - if ( function_exists( 'mb_strlen' ) ) { |
|
617 | - $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
615 | +function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') { |
|
616 | + if (function_exists('mb_strlen')) { |
|
617 | + $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding); |
|
618 | 618 | $str_end = ''; |
619 | 619 | |
620 | - if ( $lower_str_end ) { |
|
621 | - $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
620 | + if ($lower_str_end) { |
|
621 | + $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding); |
|
622 | 622 | } else { |
623 | - $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
623 | + $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | return $first_letter . $str_end; |
627 | 627 | } |
628 | 628 | |
629 | - return ucfirst( $str ); |
|
629 | + return ucfirst($str); |
|
630 | 630 | } |
631 | 631 | |
632 | -function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) { |
|
633 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
634 | - return mb_convert_case( $str, MB_CASE_TITLE, $encoding ); |
|
632 | +function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') { |
|
633 | + if (function_exists('mb_convert_case')) { |
|
634 | + return mb_convert_case($str, MB_CASE_TITLE, $encoding); |
|
635 | 635 | } |
636 | 636 | |
637 | - return ucwords( $str ); |
|
637 | + return ucwords($str); |
|
638 | 638 | } |
639 | 639 | |
640 | -function wpinv_period_in_days( $period, $unit ) { |
|
641 | - $period = absint( $period ); |
|
640 | +function wpinv_period_in_days($period, $unit) { |
|
641 | + $period = absint($period); |
|
642 | 642 | |
643 | - if ( $period > 0 ) { |
|
644 | - if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) { |
|
643 | + if ($period > 0) { |
|
644 | + if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) { |
|
645 | 645 | $period = $period * 7; |
646 | - } elseif ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) { |
|
646 | + } elseif (in_array(strtolower($unit), array('m', 'month', 'months'))) { |
|
647 | 647 | $period = $period * 30; |
648 | - } elseif ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) { |
|
648 | + } elseif (in_array(strtolower($unit), array('y', 'year', 'years'))) { |
|
649 | 649 | $period = $period * 365; |
650 | 650 | } |
651 | 651 | } |
@@ -653,14 +653,14 @@ discard block |
||
653 | 653 | return $period; |
654 | 654 | } |
655 | 655 | |
656 | -function wpinv_cal_days_in_month( $calendar, $month, $year ) { |
|
657 | - if ( function_exists( 'cal_days_in_month' ) ) { |
|
658 | - return cal_days_in_month( $calendar, $month, $year ); |
|
656 | +function wpinv_cal_days_in_month($calendar, $month, $year) { |
|
657 | + if (function_exists('cal_days_in_month')) { |
|
658 | + return cal_days_in_month($calendar, $month, $year); |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | // Fallback in case the calendar extension is not loaded in PHP |
662 | 662 | // Only supports Gregorian calendar |
663 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
663 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | /** |
@@ -671,28 +671,28 @@ discard block |
||
671 | 671 | * |
672 | 672 | * @return string |
673 | 673 | */ |
674 | -function wpi_help_tip( $tip, $allow_html = false, $is_vue = false, $echo = false ) { |
|
674 | +function wpi_help_tip($tip, $allow_html = false, $is_vue = false, $echo = false) { |
|
675 | 675 | |
676 | - if ( $allow_html ) { |
|
677 | - $tip = wpi_sanitize_tooltip( $tip ); |
|
676 | + if ($allow_html) { |
|
677 | + $tip = wpi_sanitize_tooltip($tip); |
|
678 | 678 | } else { |
679 | - $tip = strip_tags( $tip ); |
|
679 | + $tip = strip_tags($tip); |
|
680 | 680 | } |
681 | 681 | |
682 | - if ( $is_vue ) { |
|
682 | + if ($is_vue) { |
|
683 | 683 | |
684 | - if ( $echo ) { |
|
685 | - echo '<span class="dashicons dashicons-editor-help" title="' . esc_attr( $tip ) . '"></span>'; |
|
684 | + if ($echo) { |
|
685 | + echo '<span class="dashicons dashicons-editor-help" title="' . esc_attr($tip) . '"></span>'; |
|
686 | 686 | } else { |
687 | - return '<span class="dashicons dashicons-editor-help" title="' . esc_attr( $tip ) . '"></span>'; |
|
687 | + return '<span class="dashicons dashicons-editor-help" title="' . esc_attr($tip) . '"></span>'; |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | } |
691 | 691 | |
692 | - if ( $echo ) { |
|
693 | - echo '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . esc_attr( $tip ) . '"></span>'; |
|
692 | + if ($echo) { |
|
693 | + echo '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . esc_attr($tip) . '"></span>'; |
|
694 | 694 | } else { |
695 | - return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . esc_attr( $tip ) . '"></span>'; |
|
695 | + return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . esc_attr($tip) . '"></span>'; |
|
696 | 696 | } |
697 | 697 | } |
698 | 698 | |
@@ -704,9 +704,9 @@ discard block |
||
704 | 704 | * @param string $var |
705 | 705 | * @return string |
706 | 706 | */ |
707 | -function wpi_sanitize_tooltip( $var ) { |
|
707 | +function wpi_sanitize_tooltip($var) { |
|
708 | 708 | return wp_kses( |
709 | - html_entity_decode( $var ), |
|
709 | + html_entity_decode($var), |
|
710 | 710 | array( |
711 | 711 | 'br' => array(), |
712 | 712 | 'em' => array(), |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | */ |
730 | 730 | function wpinv_get_screen_ids() { |
731 | 731 | |
732 | - $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) ); |
|
732 | + $screen_id = sanitize_title(__('Invoicing', 'invoicing')); |
|
733 | 733 | |
734 | 734 | $screen_ids = array( |
735 | 735 | 'toplevel_page_' . $screen_id, |
@@ -751,7 +751,7 @@ discard block |
||
751 | 751 | 'gp-setup', // setup wizard |
752 | 752 | ); |
753 | 753 | |
754 | - return apply_filters( 'wpinv_screen_ids', $screen_ids ); |
|
754 | + return apply_filters('wpinv_screen_ids', $screen_ids); |
|
755 | 755 | } |
756 | 756 | |
757 | 757 | /** |
@@ -762,14 +762,14 @@ discard block |
||
762 | 762 | * @param array|string $list List of values. |
763 | 763 | * @return array Sanitized array of values. |
764 | 764 | */ |
765 | -function wpinv_parse_list( $list ) { |
|
765 | +function wpinv_parse_list($list) { |
|
766 | 766 | |
767 | - if ( empty( $list ) ) { |
|
767 | + if (empty($list)) { |
|
768 | 768 | $list = array(); |
769 | 769 | } |
770 | 770 | |
771 | - if ( ! is_array( $list ) ) { |
|
772 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
771 | + if (!is_array($list)) { |
|
772 | + return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY); |
|
773 | 773 | } |
774 | 774 | |
775 | 775 | return $list; |
@@ -783,16 +783,16 @@ discard block |
||
783 | 783 | * @param string $key Type of data to fetch. |
784 | 784 | * @return mixed Fetched data. |
785 | 785 | */ |
786 | -function wpinv_get_data( $key ) { |
|
786 | +function wpinv_get_data($key) { |
|
787 | 787 | |
788 | 788 | // Try fetching it from the cache. |
789 | - $data = wp_cache_get( "wpinv-data-$key", 'wpinv' ); |
|
790 | - if ( $data ) { |
|
789 | + $data = wp_cache_get("wpinv-data-$key", 'wpinv'); |
|
790 | + if ($data) { |
|
791 | 791 | return $data; |
792 | 792 | } |
793 | 793 | |
794 | - $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
|
795 | - wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
794 | + $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php"); |
|
795 | + wp_cache_set("wpinv-data-$key", $data, 'wpinv'); |
|
796 | 796 | |
797 | 797 | return $data; |
798 | 798 | } |
@@ -806,10 +806,10 @@ discard block |
||
806 | 806 | * @param bool $first_empty Whether or not the first item in the list should be empty |
807 | 807 | * @return mixed Fetched data. |
808 | 808 | */ |
809 | -function wpinv_maybe_add_empty_option( $options, $first_empty ) { |
|
809 | +function wpinv_maybe_add_empty_option($options, $first_empty) { |
|
810 | 810 | |
811 | - if ( ! empty( $options ) && $first_empty ) { |
|
812 | - return array_merge( array( '' => '' ), $options ); |
|
811 | + if (!empty($options) && $first_empty) { |
|
812 | + return array_merge(array('' => ''), $options); |
|
813 | 813 | } |
814 | 814 | return $options; |
815 | 815 | |
@@ -821,21 +821,21 @@ discard block |
||
821 | 821 | * @param mixed $var Data to sanitize. |
822 | 822 | * @return string|array |
823 | 823 | */ |
824 | -function wpinv_clean( $var ) { |
|
824 | +function wpinv_clean($var) { |
|
825 | 825 | |
826 | - if ( is_array( $var ) ) { |
|
827 | - return array_map( 'wpinv_clean', $var ); |
|
826 | + if (is_array($var)) { |
|
827 | + return array_map('wpinv_clean', $var); |
|
828 | 828 | } |
829 | 829 | |
830 | - if ( is_object( $var ) ) { |
|
831 | - $object_vars = get_object_vars( $var ); |
|
832 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
833 | - $var->$property_name = wpinv_clean( $property_value ); |
|
830 | + if (is_object($var)) { |
|
831 | + $object_vars = get_object_vars($var); |
|
832 | + foreach ($object_vars as $property_name => $property_value) { |
|
833 | + $var->$property_name = wpinv_clean($property_value); |
|
834 | 834 | } |
835 | 835 | return $var; |
836 | 836 | } |
837 | 837 | |
838 | - return is_string( $var ) ? sanitize_text_field( stripslashes( $var ) ) : $var; |
|
838 | + return is_string($var) ? sanitize_text_field(stripslashes($var)) : $var; |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | /** |
@@ -844,43 +844,43 @@ discard block |
||
844 | 844 | * @param string $str Data to convert. |
845 | 845 | * @return string|array |
846 | 846 | */ |
847 | -function getpaid_convert_price_string_to_options( $str ) { |
|
847 | +function getpaid_convert_price_string_to_options($str) { |
|
848 | 848 | |
849 | - $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
850 | - $options = array(); |
|
849 | + $raw_options = array_map('trim', explode(',', $str)); |
|
850 | + $options = array(); |
|
851 | 851 | |
852 | - foreach ( $raw_options as $option ) { |
|
852 | + foreach ($raw_options as $option) { |
|
853 | 853 | |
854 | - if ( '' == $option ) { |
|
854 | + if ('' == $option) { |
|
855 | 855 | continue; |
856 | 856 | } |
857 | 857 | |
858 | - $option = array_map( 'trim', explode( '|', $option ) ); |
|
858 | + $option = array_map('trim', explode('|', $option)); |
|
859 | 859 | |
860 | 860 | $price = null; |
861 | 861 | $label = null; |
862 | 862 | |
863 | - if ( isset( $option[0] ) && '' != $option[0] ) { |
|
864 | - $label = $option[0]; |
|
863 | + if (isset($option[0]) && '' != $option[0]) { |
|
864 | + $label = $option[0]; |
|
865 | 865 | } |
866 | 866 | |
867 | - if ( isset( $option[1] ) && '' != $option[1] ) { |
|
867 | + if (isset($option[1]) && '' != $option[1]) { |
|
868 | 868 | $price = $option[1]; |
869 | 869 | } |
870 | 870 | |
871 | - if ( ! isset( $price ) ) { |
|
871 | + if (!isset($price)) { |
|
872 | 872 | $price = $label; |
873 | 873 | } |
874 | 874 | |
875 | - if ( ! isset( $price ) || ! is_numeric( $price ) ) { |
|
875 | + if (!isset($price) || !is_numeric($price)) { |
|
876 | 876 | continue; |
877 | 877 | } |
878 | 878 | |
879 | - if ( ! isset( $label ) ) { |
|
879 | + if (!isset($label)) { |
|
880 | 880 | $label = $price; |
881 | 881 | } |
882 | 882 | |
883 | - $options[ "$label|$price" ] = $label; |
|
883 | + $options["$label|$price"] = $label; |
|
884 | 884 | } |
885 | 885 | |
886 | 886 | return $options; |
@@ -889,27 +889,27 @@ discard block |
||
889 | 889 | /** |
890 | 890 | * Returns the help tip. |
891 | 891 | */ |
892 | -function getpaid_get_help_tip( $tip, $additional_classes = '' ) { |
|
893 | - $additional_classes = sanitize_html_class( $additional_classes ); |
|
894 | - $tip = esc_attr__( $tip ); |
|
892 | +function getpaid_get_help_tip($tip, $additional_classes = '') { |
|
893 | + $additional_classes = sanitize_html_class($additional_classes); |
|
894 | + $tip = esc_attr__($tip); |
|
895 | 895 | return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>"; |
896 | 896 | } |
897 | 897 | |
898 | 898 | /** |
899 | 899 | * Formats a date |
900 | 900 | */ |
901 | -function getpaid_format_date( $date, $with_time = false ) { |
|
901 | +function getpaid_format_date($date, $with_time = false) { |
|
902 | 902 | |
903 | - if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) { |
|
903 | + if (empty($date) || $date == '0000-00-00 00:00:00') { |
|
904 | 904 | return ''; |
905 | 905 | } |
906 | 906 | |
907 | 907 | $format = getpaid_date_format(); |
908 | 908 | |
909 | - if ( $with_time ) { |
|
909 | + if ($with_time) { |
|
910 | 910 | $format .= ' ' . getpaid_time_format(); |
911 | 911 | } |
912 | - return date_i18n( $format, strtotime( $date ) ); |
|
912 | + return date_i18n($format, strtotime($date)); |
|
913 | 913 | |
914 | 914 | } |
915 | 915 | |
@@ -918,9 +918,9 @@ discard block |
||
918 | 918 | * |
919 | 919 | * @return string |
920 | 920 | */ |
921 | -function getpaid_format_date_value( $date, $default = '—', $with_time = false ) { |
|
922 | - $date = getpaid_format_date( $date, $with_time ); |
|
923 | - return empty( $date ) ? $default : $date; |
|
921 | +function getpaid_format_date_value($date, $default = '—', $with_time = false) { |
|
922 | + $date = getpaid_format_date($date, $with_time); |
|
923 | + return empty($date) ? $default : $date; |
|
924 | 924 | } |
925 | 925 | |
926 | 926 | /** |
@@ -929,7 +929,7 @@ discard block |
||
929 | 929 | * @return string |
930 | 930 | */ |
931 | 931 | function getpaid_date_format() { |
932 | - return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
932 | + return apply_filters('getpaid_date_format', get_option('date_format')); |
|
933 | 933 | } |
934 | 934 | |
935 | 935 | /** |
@@ -938,7 +938,7 @@ discard block |
||
938 | 938 | * @return string |
939 | 939 | */ |
940 | 940 | function getpaid_time_format() { |
941 | - return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
941 | + return apply_filters('getpaid_time_format', get_option('time_format')); |
|
942 | 942 | } |
943 | 943 | |
944 | 944 | /** |
@@ -948,16 +948,16 @@ discard block |
||
948 | 948 | * @param integer $limit Limit size in characters. |
949 | 949 | * @return string |
950 | 950 | */ |
951 | -function getpaid_limit_length( $string, $limit ) { |
|
951 | +function getpaid_limit_length($string, $limit) { |
|
952 | 952 | $str_limit = $limit - 3; |
953 | 953 | |
954 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
955 | - if ( mb_strlen( $string ) > $limit ) { |
|
956 | - $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
954 | + if (function_exists('mb_strimwidth')) { |
|
955 | + if (mb_strlen($string) > $limit) { |
|
956 | + $string = mb_strimwidth($string, 0, $str_limit) . '...'; |
|
957 | 957 | } |
958 | 958 | } else { |
959 | - if ( strlen( $string ) > $limit ) { |
|
960 | - $string = substr( $string, 0, $str_limit ) . '...'; |
|
959 | + if (strlen($string) > $limit) { |
|
960 | + $string = substr($string, 0, $str_limit) . '...'; |
|
961 | 961 | } |
962 | 962 | } |
963 | 963 | return $string; |
@@ -971,7 +971,7 @@ discard block |
||
971 | 971 | * @since 1.0.19 |
972 | 972 | */ |
973 | 973 | function getpaid_api() { |
974 | - return getpaid()->get( 'api' ); |
|
974 | + return getpaid()->get('api'); |
|
975 | 975 | } |
976 | 976 | |
977 | 977 | /** |
@@ -981,7 +981,7 @@ discard block |
||
981 | 981 | * @since 1.0.19 |
982 | 982 | */ |
983 | 983 | function getpaid_post_types() { |
984 | - return getpaid()->get( 'post_types' ); |
|
984 | + return getpaid()->get('post_types'); |
|
985 | 985 | } |
986 | 986 | |
987 | 987 | /** |
@@ -991,7 +991,7 @@ discard block |
||
991 | 991 | * @since 1.0.19 |
992 | 992 | */ |
993 | 993 | function getpaid_session() { |
994 | - return getpaid()->get( 'session' ); |
|
994 | + return getpaid()->get('session'); |
|
995 | 995 | } |
996 | 996 | |
997 | 997 | /** |
@@ -1001,7 +1001,7 @@ discard block |
||
1001 | 1001 | * @since 1.0.19 |
1002 | 1002 | */ |
1003 | 1003 | function getpaid_notes() { |
1004 | - return getpaid()->get( 'notes' ); |
|
1004 | + return getpaid()->get('notes'); |
|
1005 | 1005 | } |
1006 | 1006 | |
1007 | 1007 | /** |
@@ -1010,7 +1010,7 @@ discard block |
||
1010 | 1010 | * @return GetPaid_Admin |
1011 | 1011 | */ |
1012 | 1012 | function getpaid_admin() { |
1013 | - return getpaid()->get( 'admin' ); |
|
1013 | + return getpaid()->get('admin'); |
|
1014 | 1014 | } |
1015 | 1015 | |
1016 | 1016 | /** |
@@ -1020,8 +1020,8 @@ discard block |
||
1020 | 1020 | * @param string $base the base url |
1021 | 1021 | * @return string |
1022 | 1022 | */ |
1023 | -function getpaid_get_authenticated_action_url( $action, $base = false ) { |
|
1024 | - return wp_nonce_url( add_query_arg( 'getpaid-action', $action, $base ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
1023 | +function getpaid_get_authenticated_action_url($action, $base = false) { |
|
1024 | + return wp_nonce_url(add_query_arg('getpaid-action', $action, $base), 'getpaid-nonce', 'getpaid-nonce'); |
|
1025 | 1025 | } |
1026 | 1026 | |
1027 | 1027 | /** |
@@ -1029,11 +1029,11 @@ discard block |
||
1029 | 1029 | * |
1030 | 1030 | * @return string |
1031 | 1031 | */ |
1032 | -function getpaid_get_post_type_label( $post_type, $plural = true ) { |
|
1032 | +function getpaid_get_post_type_label($post_type, $plural = true) { |
|
1033 | 1033 | |
1034 | - $post_type = get_post_type_object( $post_type ); |
|
1034 | + $post_type = get_post_type_object($post_type); |
|
1035 | 1035 | |
1036 | - if ( ! is_object( $post_type ) ) { |
|
1036 | + if (!is_object($post_type)) { |
|
1037 | 1037 | return null; |
1038 | 1038 | } |
1039 | 1039 | |
@@ -1046,18 +1046,18 @@ discard block |
||
1046 | 1046 | * |
1047 | 1047 | * @return mixed|null |
1048 | 1048 | */ |
1049 | -function getpaid_get_array_field( $array, $key, $secondary_key = null ) { |
|
1049 | +function getpaid_get_array_field($array, $key, $secondary_key = null) { |
|
1050 | 1050 | |
1051 | - if ( ! is_array( $array ) ) { |
|
1051 | + if (!is_array($array)) { |
|
1052 | 1052 | return null; |
1053 | 1053 | } |
1054 | 1054 | |
1055 | - if ( ! empty( $secondary_key ) ) { |
|
1056 | - $array = isset( $array[ $secondary_key ] ) ? $array[ $secondary_key ] : array(); |
|
1057 | - return getpaid_get_array_field( $array, $key ); |
|
1055 | + if (!empty($secondary_key)) { |
|
1056 | + $array = isset($array[$secondary_key]) ? $array[$secondary_key] : array(); |
|
1057 | + return getpaid_get_array_field($array, $key); |
|
1058 | 1058 | } |
1059 | 1059 | |
1060 | - return isset( $array[ $key ] ) ? $array[ $key ] : null; |
|
1060 | + return isset($array[$key]) ? $array[$key] : null; |
|
1061 | 1061 | |
1062 | 1062 | } |
1063 | 1063 | |
@@ -1066,12 +1066,12 @@ discard block |
||
1066 | 1066 | * |
1067 | 1067 | * @return array |
1068 | 1068 | */ |
1069 | -function getpaid_array_merge_if_empty( $args, $defaults ) { |
|
1069 | +function getpaid_array_merge_if_empty($args, $defaults) { |
|
1070 | 1070 | |
1071 | - foreach ( $defaults as $key => $value ) { |
|
1071 | + foreach ($defaults as $key => $value) { |
|
1072 | 1072 | |
1073 | - if ( array_key_exists( $key, $args ) && empty( $args[ $key ] ) ) { |
|
1074 | - $args[ $key ] = $value; |
|
1073 | + if (array_key_exists($key, $args) && empty($args[$key])) { |
|
1074 | + $args[$key] = $value; |
|
1075 | 1075 | } |
1076 | 1076 | } |
1077 | 1077 | |
@@ -1088,12 +1088,12 @@ discard block |
||
1088 | 1088 | |
1089 | 1089 | $types = get_allowed_mime_types(); |
1090 | 1090 | |
1091 | - if ( isset( $types['htm|html'] ) ) { |
|
1092 | - unset( $types['htm|html'] ); |
|
1091 | + if (isset($types['htm|html'])) { |
|
1092 | + unset($types['htm|html']); |
|
1093 | 1093 | } |
1094 | 1094 | |
1095 | - if ( isset( $types['js'] ) ) { |
|
1096 | - unset( $types['js'] ); |
|
1095 | + if (isset($types['js'])) { |
|
1096 | + unset($types['js']); |
|
1097 | 1097 | } |
1098 | 1098 | |
1099 | 1099 | return $types; |
@@ -1101,34 +1101,34 @@ discard block |
||
1101 | 1101 | } |
1102 | 1102 | |
1103 | 1103 | |
1104 | -function getpaid_user_delete_invoice( $data ) { |
|
1104 | +function getpaid_user_delete_invoice($data) { |
|
1105 | 1105 | |
1106 | 1106 | // Ensure there is an invoice to delete. |
1107 | - if ( empty( $data['invoice_id'] ) ) { |
|
1107 | + if (empty($data['invoice_id'])) { |
|
1108 | 1108 | return; |
1109 | 1109 | } |
1110 | 1110 | |
1111 | - $invoice = new WPInv_Invoice( (int) $data['invoice_id'] ); |
|
1111 | + $invoice = new WPInv_Invoice((int) $data['invoice_id']); |
|
1112 | 1112 | |
1113 | 1113 | // Ensure that it exists and that it belongs to the current user. |
1114 | - if ( ! $invoice->exists() || $invoice->get_customer_id() != get_current_user_id() ) { |
|
1115 | - wpinv_set_error( 'invalid_invoice', __( 'You do not have permission to delete this invoice', 'invoicing' ) ); |
|
1114 | + if (!$invoice->exists() || $invoice->get_customer_id() != get_current_user_id()) { |
|
1115 | + wpinv_set_error('invalid_invoice', __('You do not have permission to delete this invoice', 'invoicing')); |
|
1116 | 1116 | |
1117 | 1117 | // Can it be deleted? |
1118 | - } elseif ( ! $invoice->needs_payment() ) { |
|
1119 | - wpinv_set_error( 'cannot_delete', __( 'This invoice cannot be deleted as it has already been paid.', 'invoicing' ) ); |
|
1118 | + } elseif (!$invoice->needs_payment()) { |
|
1119 | + wpinv_set_error('cannot_delete', __('This invoice cannot be deleted as it has already been paid.', 'invoicing')); |
|
1120 | 1120 | |
1121 | 1121 | // Delete it. |
1122 | 1122 | } else { |
1123 | 1123 | |
1124 | 1124 | $invoice->delete(); |
1125 | - wpinv_set_error( 'delete', __( 'The invoice has been deleted.', 'invoicing' ), 'info' ); |
|
1125 | + wpinv_set_error('delete', __('The invoice has been deleted.', 'invoicing'), 'info'); |
|
1126 | 1126 | } |
1127 | 1127 | |
1128 | - $redirect = remove_query_arg( array( 'getpaid-action', 'getpaid-nonce', 'invoice_id' ) ); |
|
1128 | + $redirect = remove_query_arg(array('getpaid-action', 'getpaid-nonce', 'invoice_id')); |
|
1129 | 1129 | |
1130 | - wp_safe_redirect( $redirect ); |
|
1130 | + wp_safe_redirect($redirect); |
|
1131 | 1131 | exit; |
1132 | 1132 | |
1133 | 1133 | } |
1134 | -add_action( 'getpaid_authenticated_action_delete_invoice', 'getpaid_user_delete_invoice' ); |
|
1134 | +add_action('getpaid_authenticated_action_delete_invoice', 'getpaid_user_delete_invoice'); |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Abstaract Payment Gateway class. |
@@ -139,50 +139,50 @@ discard block |
||
139 | 139 | public function __construct() { |
140 | 140 | |
141 | 141 | // Register gateway. |
142 | - add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
142 | + add_filter('wpinv_payment_gateways', array($this, 'register_gateway')); |
|
143 | 143 | |
144 | - $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
144 | + $this->enabled = wpinv_is_gateway_active($this->id); |
|
145 | 145 | |
146 | 146 | // Add support for various features. |
147 | - foreach ( $this->supports as $feature ) { |
|
148 | - add_filter( "wpinv_{$this->id}_support_{$feature}", '__return_true' ); |
|
149 | - add_filter( "getpaid_{$this->id}_support_{$feature}", '__return_true' ); |
|
150 | - add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' ); |
|
147 | + foreach ($this->supports as $feature) { |
|
148 | + add_filter("wpinv_{$this->id}_support_{$feature}", '__return_true'); |
|
149 | + add_filter("getpaid_{$this->id}_support_{$feature}", '__return_true'); |
|
150 | + add_filter("getpaid_{$this->id}_supports_{$feature}", '__return_true'); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // Invoice addons. |
154 | - if ( $this->supports( 'addons' ) ) { |
|
155 | - add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 ); |
|
154 | + if ($this->supports('addons')) { |
|
155 | + add_action("getpaid_process_{$this->id}_invoice_addons", array($this, 'process_addons'), 10, 2); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | // Gateway settings. |
159 | - add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
159 | + add_filter("wpinv_gateway_settings_{$this->id}", array($this, 'admin_settings')); |
|
160 | 160 | |
161 | 161 | // Gateway checkout fiellds. |
162 | - add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
162 | + add_action("wpinv_{$this->id}_cc_form", array($this, 'payment_fields'), 10, 2); |
|
163 | 163 | |
164 | 164 | // Process payment. |
165 | - add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
165 | + add_action("getpaid_gateway_{$this->id}", array($this, 'process_payment'), 10, 3); |
|
166 | 166 | |
167 | 167 | // Change the checkout button text. |
168 | - if ( ! empty( $this->checkout_button_text ) ) { |
|
169 | - add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
168 | + if (!empty($this->checkout_button_text)) { |
|
169 | + add_filter("getpaid_gateway_{$this->id}_checkout_button_label", array($this, 'rename_checkout_button')); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | // Check if a gateway is valid for a given currency. |
173 | - add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
173 | + add_filter("getpaid_gateway_{$this->id}_is_valid_for_currency", array($this, 'validate_currency'), 10, 2); |
|
174 | 174 | |
175 | 175 | // Generate the transaction url. |
176 | - add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
176 | + add_filter("getpaid_gateway_{$this->id}_transaction_url", array($this, 'filter_transaction_url'), 10, 2); |
|
177 | 177 | |
178 | 178 | // Generate the subscription url. |
179 | - add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 ); |
|
179 | + add_filter('getpaid_remote_subscription_profile_url', array($this, 'generate_subscription_url'), 10, 2); |
|
180 | 180 | |
181 | 181 | // Confirm payments. |
182 | - add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
182 | + add_filter("wpinv_payment_confirm_{$this->id}", array($this, 'confirm_payment'), 10, 2); |
|
183 | 183 | |
184 | 184 | // Verify IPNs. |
185 | - add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
185 | + add_action("wpinv_verify_{$this->id}_ipn", array($this, 'verify_ipn')); |
|
186 | 186 | |
187 | 187 | } |
188 | 188 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @since 1.0.19 |
193 | 193 | * @return bool |
194 | 194 | */ |
195 | - public function is( $gateway ) { |
|
195 | + public function is($gateway) { |
|
196 | 196 | return $gateway == $this->id; |
197 | 197 | } |
198 | 198 | |
@@ -202,23 +202,23 @@ discard block |
||
202 | 202 | * @since 1.0.19 |
203 | 203 | * @return array |
204 | 204 | */ |
205 | - public function get_tokens( $sandbox = null ) { |
|
205 | + public function get_tokens($sandbox = null) { |
|
206 | 206 | |
207 | - if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
208 | - $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
207 | + if (is_user_logged_in() && $this->supports('tokens') && 0 == count($this->tokens)) { |
|
208 | + $tokens = get_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", true); |
|
209 | 209 | |
210 | - if ( is_array( $tokens ) ) { |
|
210 | + if (is_array($tokens)) { |
|
211 | 211 | $this->tokens = $tokens; |
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | - if ( ! is_bool( $sandbox ) ) { |
|
215 | + if (!is_bool($sandbox)) { |
|
216 | 216 | return $this->tokens; |
217 | 217 | } |
218 | 218 | |
219 | 219 | // Filter tokens. |
220 | - $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
221 | - return wp_list_filter( $this->tokens, $args ); |
|
220 | + $args = array('type' => $sandbox ? 'sandbox' : 'live'); |
|
221 | + return wp_list_filter($this->tokens, $args); |
|
222 | 222 | |
223 | 223 | } |
224 | 224 | |
@@ -227,12 +227,12 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @since 1.0.19 |
229 | 229 | */ |
230 | - public function save_token( $token ) { |
|
230 | + public function save_token($token) { |
|
231 | 231 | |
232 | 232 | $tokens = $this->get_tokens(); |
233 | 233 | $tokens[] = $token; |
234 | 234 | |
235 | - update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
235 | + update_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens); |
|
236 | 236 | |
237 | 237 | $this->tokens = $tokens; |
238 | 238 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * @return string |
245 | 245 | */ |
246 | 246 | public function get_method_title() { |
247 | - return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
247 | + return apply_filters('getpaid_gateway_method_title', $this->method_title, $this); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * @return string |
254 | 254 | */ |
255 | 255 | public function get_method_description() { |
256 | - return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
256 | + return apply_filters('getpaid_gateway_method_description', $this->method_description, $this); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @param WPInv_Invoice $invoice Invoice object. |
263 | 263 | * @return string |
264 | 264 | */ |
265 | - public function get_return_url( $invoice ) { |
|
265 | + public function get_return_url($invoice) { |
|
266 | 266 | |
267 | 267 | // Payment success url |
268 | 268 | $return_url = add_query_arg( |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | wpinv_get_success_page_uri() |
275 | 275 | ); |
276 | 276 | |
277 | - return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
277 | + return apply_filters('getpaid_gateway_success_url', $return_url, $invoice, $this); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -283,24 +283,24 @@ discard block |
||
283 | 283 | * @param string $content Success page content. |
284 | 284 | * @return string |
285 | 285 | */ |
286 | - public function confirm_payment( $content ) { |
|
286 | + public function confirm_payment($content) { |
|
287 | 287 | |
288 | 288 | // Retrieve the invoice. |
289 | 289 | $invoice_id = getpaid_get_current_invoice_id(); |
290 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
290 | + $invoice = wpinv_get_invoice($invoice_id); |
|
291 | 291 | |
292 | 292 | // Ensure that it exists and that it is pending payment. |
293 | - if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
293 | + if (empty($invoice_id) || !$invoice->needs_payment()) { |
|
294 | 294 | return $content; |
295 | 295 | } |
296 | 296 | |
297 | 297 | // Can the user view this invoice?? |
298 | - if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
298 | + if (!wpinv_user_can_view_invoice($invoice)) { |
|
299 | 299 | return $content; |
300 | 300 | } |
301 | 301 | |
302 | 302 | // Show payment processing indicator. |
303 | - return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
303 | + return wpinv_get_template_html('wpinv-payment-processing.php', compact('invoice')); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | /** |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | * @param GetPaid_Form_Item[] $items |
318 | 318 | * @return WPInv_Invoice |
319 | 319 | */ |
320 | - public function process_addons( $invoice, $items ) { |
|
320 | + public function process_addons($invoice, $items) { |
|
321 | 321 | |
322 | 322 | } |
323 | 323 | |
@@ -328,14 +328,14 @@ discard block |
||
328 | 328 | * @param WPInv_Invoice $invoice Invoice object. |
329 | 329 | * @return string transaction URL, or empty string. |
330 | 330 | */ |
331 | - public function filter_transaction_url( $transaction_url, $invoice ) { |
|
331 | + public function filter_transaction_url($transaction_url, $invoice) { |
|
332 | 332 | |
333 | - $transaction_id = $invoice->get_transaction_id(); |
|
333 | + $transaction_id = $invoice->get_transaction_id(); |
|
334 | 334 | |
335 | - if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
336 | - $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
337 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
338 | - $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
335 | + if (!empty($this->view_transaction_url) && !empty($transaction_id)) { |
|
336 | + $transaction_url = sprintf($this->view_transaction_url, $transaction_id); |
|
337 | + $replace = $this->is_sandbox($invoice) ? 'sandbox' : ''; |
|
338 | + $transaction_url = str_replace('{sandbox}', $replace, $transaction_url); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | return $transaction_url; |
@@ -348,15 +348,15 @@ discard block |
||
348 | 348 | * @param WPInv_Subscription $subscription Subscription objectt. |
349 | 349 | * @return string subscription URL, or empty string. |
350 | 350 | */ |
351 | - public function generate_subscription_url( $subscription_url, $subscription ) { |
|
351 | + public function generate_subscription_url($subscription_url, $subscription) { |
|
352 | 352 | |
353 | - $profile_id = $subscription->get_profile_id(); |
|
353 | + $profile_id = $subscription->get_profile_id(); |
|
354 | 354 | |
355 | - if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
355 | + if ($this->id == $subscription->get_gateway() && !empty($this->view_subscription_url) && !empty($profile_id)) { |
|
356 | 356 | |
357 | - $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
358 | - $replace = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : ''; |
|
359 | - $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
357 | + $subscription_url = sprintf($this->view_subscription_url, $profile_id); |
|
358 | + $replace = $this->is_sandbox($subscription->get_parent_invoice()) ? 'sandbox' : ''; |
|
359 | + $subscription_url = str_replace('{sandbox}', $replace, $subscription_url); |
|
360 | 360 | |
361 | 361 | } |
362 | 362 | |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | * @return bool |
370 | 370 | */ |
371 | 371 | public function is_available() { |
372 | - return ! empty( $this->enabled ); |
|
372 | + return !empty($this->enabled); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | /** |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * @return string |
379 | 379 | */ |
380 | 380 | public function get_title() { |
381 | - return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
381 | + return apply_filters('getpaid_gateway_title', $this->title, $this); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | /** |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | * @return string |
388 | 388 | */ |
389 | 389 | public function get_description() { |
390 | - return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
390 | + return apply_filters('getpaid_gateway_description', $this->description, $this); |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | /** |
@@ -399,9 +399,9 @@ discard block |
||
399 | 399 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
400 | 400 | * @return void |
401 | 401 | */ |
402 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
402 | + public function process_payment($invoice, $submission_data, $submission) { |
|
403 | 403 | // Process the payment then either redirect to the success page or the gateway. |
404 | - do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
404 | + do_action('getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
@@ -415,8 +415,8 @@ discard block |
||
415 | 415 | * @param string $reason Refund reason. |
416 | 416 | * @return WP_Error|bool True or false based on success, or a WP_Error object. |
417 | 417 | */ |
418 | - public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
419 | - return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
418 | + public function process_refund($invoice, $amount = null, $reason = '') { |
|
419 | + return apply_filters('getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | /** |
@@ -425,8 +425,8 @@ discard block |
||
425 | 425 | * @param int $invoice_id 0 or invoice id. |
426 | 426 | * @param GetPaid_Payment_Form $form Current payment form. |
427 | 427 | */ |
428 | - public function payment_fields( $invoice_id, $form ) { |
|
429 | - do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
428 | + public function payment_fields($invoice_id, $form) { |
|
429 | + do_action('getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | /** |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | * |
435 | 435 | * @param array $admin_settings |
436 | 436 | */ |
437 | - public function admin_settings( $admin_settings ) { |
|
437 | + public function admin_settings($admin_settings) { |
|
438 | 438 | return $admin_settings; |
439 | 439 | } |
440 | 440 | |
@@ -443,8 +443,8 @@ discard block |
||
443 | 443 | * |
444 | 444 | * @param string $option |
445 | 445 | */ |
446 | - public function get_option( $option, $default = false ) { |
|
447 | - return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
446 | + public function get_option($option, $default = false) { |
|
447 | + return wpinv_get_option($this->id . '_' . $option, $default); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | /** |
@@ -457,8 +457,8 @@ discard block |
||
457 | 457 | * @return bool True if the gateway supports the feature, false otherwise. |
458 | 458 | * @since 1.0.19 |
459 | 459 | */ |
460 | - public function supports( $feature ) { |
|
461 | - return getpaid_payment_gateway_supports( $this->id, $feature ); |
|
460 | + public function supports($feature) { |
|
461 | + return getpaid_payment_gateway_supports($this->id, $feature); |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | /** |
@@ -466,36 +466,36 @@ discard block |
||
466 | 466 | * |
467 | 467 | * @param bool $save whether or not to display the save button. |
468 | 468 | */ |
469 | - public function get_cc_form( $save = false ) { |
|
469 | + public function get_cc_form($save = false) { |
|
470 | 470 | |
471 | 471 | ob_start(); |
472 | 472 | |
473 | - $id_prefix = esc_attr( uniqid( $this->id ) ); |
|
473 | + $id_prefix = esc_attr(uniqid($this->id)); |
|
474 | 474 | |
475 | 475 | $months = array( |
476 | - '01' => __( 'January', 'invoicing' ), |
|
477 | - '02' => __( 'February', 'invoicing' ), |
|
478 | - '03' => __( 'March', 'invoicing' ), |
|
479 | - '04' => __( 'April', 'invoicing' ), |
|
480 | - '05' => __( 'May', 'invoicing' ), |
|
481 | - '06' => __( 'June', 'invoicing' ), |
|
482 | - '07' => __( 'July', 'invoicing' ), |
|
483 | - '08' => __( 'August', 'invoicing' ), |
|
484 | - '09' => __( 'September', 'invoicing' ), |
|
485 | - '10' => __( 'October', 'invoicing' ), |
|
486 | - '11' => __( 'November', 'invoicing' ), |
|
487 | - '12' => __( 'December', 'invoicing' ), |
|
476 | + '01' => __('January', 'invoicing'), |
|
477 | + '02' => __('February', 'invoicing'), |
|
478 | + '03' => __('March', 'invoicing'), |
|
479 | + '04' => __('April', 'invoicing'), |
|
480 | + '05' => __('May', 'invoicing'), |
|
481 | + '06' => __('June', 'invoicing'), |
|
482 | + '07' => __('July', 'invoicing'), |
|
483 | + '08' => __('August', 'invoicing'), |
|
484 | + '09' => __('September', 'invoicing'), |
|
485 | + '10' => __('October', 'invoicing'), |
|
486 | + '11' => __('November', 'invoicing'), |
|
487 | + '12' => __('December', 'invoicing'), |
|
488 | 488 | ); |
489 | 489 | |
490 | - $year = (int) date( 'Y', current_time( 'timestamp' ) ); |
|
490 | + $year = (int) date('Y', current_time('timestamp')); |
|
491 | 491 | $years = array(); |
492 | 492 | |
493 | - for ( $i = 0; $i <= 10; $i++ ) { |
|
494 | - $years[ $year + $i ] = $year + $i; |
|
493 | + for ($i = 0; $i <= 10; $i++) { |
|
494 | + $years[$year + $i] = $year + $i; |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | ?> |
498 | - <div class="<?php echo esc_attr( $this->id ); ?>-cc-form getpaid-cc-form mt-1"> |
|
498 | + <div class="<?php echo esc_attr($this->id); ?>-cc-form getpaid-cc-form mt-1"> |
|
499 | 499 | |
500 | 500 | |
501 | 501 | <div class="getpaid-cc-card-inner"> |
@@ -504,14 +504,14 @@ discard block |
||
504 | 504 | <div class="col-12"> |
505 | 505 | |
506 | 506 | <div class="form-group"> |
507 | - <label for="<?php echo esc_attr( "$id_prefix-cc-number" ); ?>"><?php esc_html_e( 'Card number', 'invoicing' ); ?></label> |
|
507 | + <label for="<?php echo esc_attr("$id_prefix-cc-number"); ?>"><?php esc_html_e('Card number', 'invoicing'); ?></label> |
|
508 | 508 | <div class="input-group input-group-sm"> |
509 | 509 | <div class="input-group-prepend "> |
510 | 510 | <span class="input-group-text"> |
511 | 511 | <i class="fa fa-credit-card"></i> |
512 | 512 | </span> |
513 | 513 | </div> |
514 | - <input type="text" name="<?php echo esc_attr( $this->id . '[cc_number]' ); ?>" id="<?php echo esc_attr( "$id_prefix-cc-number" ); ?>" class="form-control form-control-sm" autocomplete="cc-number"> |
|
514 | + <input type="text" name="<?php echo esc_attr($this->id . '[cc_number]'); ?>" id="<?php echo esc_attr("$id_prefix-cc-number"); ?>" class="form-control form-control-sm" autocomplete="cc-number"> |
|
515 | 515 | </div> |
516 | 516 | </div> |
517 | 517 | |
@@ -519,17 +519,17 @@ discard block |
||
519 | 519 | |
520 | 520 | <div class="col-12"> |
521 | 521 | <div class="form-group"> |
522 | - <label><?php esc_html_e( 'Expiration', 'invoicing' ); ?></label> |
|
522 | + <label><?php esc_html_e('Expiration', 'invoicing'); ?></label> |
|
523 | 523 | <div class="form-row"> |
524 | 524 | |
525 | 525 | <div class="col"> |
526 | - <select class="form-control form-control-sm" autocomplete="cc-exp-month" name="<?php echo esc_attr( $this->id ); ?>[cc_expire_month]"> |
|
527 | - <option disabled selected="selected"><?php esc_html_e( 'MM', 'invoicing' ); ?></option> |
|
526 | + <select class="form-control form-control-sm" autocomplete="cc-exp-month" name="<?php echo esc_attr($this->id); ?>[cc_expire_month]"> |
|
527 | + <option disabled selected="selected"><?php esc_html_e('MM', 'invoicing'); ?></option> |
|
528 | 528 | |
529 | 529 | <?php |
530 | - foreach ( $months as $key => $month ) { |
|
531 | - $key = esc_attr( $key ); |
|
532 | - $month = esc_html( $month ); |
|
530 | + foreach ($months as $key => $month) { |
|
531 | + $key = esc_attr($key); |
|
532 | + $month = esc_html($month); |
|
533 | 533 | echo "<option value='$key'>$month</option>" . PHP_EOL; |
534 | 534 | } |
535 | 535 | ?> |
@@ -538,13 +538,13 @@ discard block |
||
538 | 538 | </div> |
539 | 539 | |
540 | 540 | <div class="col"> |
541 | - <select class="form-control form-control-sm" autocomplete="cc-exp-year" name="<?php echo esc_attr( $this->id ); ?>[cc_expire_year]"> |
|
542 | - <option disabled selected="selected"><?php esc_html_e( 'YY', 'invoicing' ); ?></option> |
|
541 | + <select class="form-control form-control-sm" autocomplete="cc-exp-year" name="<?php echo esc_attr($this->id); ?>[cc_expire_year]"> |
|
542 | + <option disabled selected="selected"><?php esc_html_e('YY', 'invoicing'); ?></option> |
|
543 | 543 | |
544 | 544 | <?php |
545 | - foreach ( $years as $key => $year ) { |
|
546 | - $key = esc_attr( $key ); |
|
547 | - $year = esc_html( $year ); |
|
545 | + foreach ($years as $key => $year) { |
|
546 | + $key = esc_attr($key); |
|
547 | + $year = esc_html($year); |
|
548 | 548 | echo "<option value='$key'>$year</option>" . PHP_EOL; |
549 | 549 | } |
550 | 550 | ?> |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | array( |
563 | 563 | 'name' => $this->id . '[cc_cvv2]', |
564 | 564 | 'id' => "$id_prefix-cc-cvv2", |
565 | - 'label' => __( 'CCV', 'invoicing' ), |
|
565 | + 'label' => __('CCV', 'invoicing'), |
|
566 | 566 | 'label_type' => 'vertical', |
567 | 567 | 'class' => 'form-control-sm', |
568 | 568 | 'extra_attributes' => array( |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | |
578 | 578 | <?php |
579 | 579 | |
580 | - if ( $save ) { |
|
580 | + if ($save) { |
|
581 | 581 | echo $this->save_payment_method_checkbox(); |
582 | 582 | } |
583 | 583 | |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | * |
597 | 597 | * @since 1.0.19 |
598 | 598 | */ |
599 | - public function new_payment_method_entry( $form ) { |
|
599 | + public function new_payment_method_entry($form) { |
|
600 | 600 | echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>"; |
601 | 601 | } |
602 | 602 | |
@@ -606,16 +606,16 @@ discard block |
||
606 | 606 | * @since 1.0.19 |
607 | 607 | */ |
608 | 608 | public function saved_payment_methods() { |
609 | - $html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
609 | + $html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr(count($this->get_tokens($this->is_sandbox()))) . '">'; |
|
610 | 610 | |
611 | - foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
612 | - $html .= $this->get_saved_payment_method_option_html( $token ); |
|
611 | + foreach ($this->get_tokens($this->is_sandbox()) as $token) { |
|
612 | + $html .= $this->get_saved_payment_method_option_html($token); |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | $html .= $this->get_new_payment_method_option_html(); |
616 | 616 | $html .= '</ul>'; |
617 | 617 | |
618 | - echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
618 | + echo apply_filters('getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | /** |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | * @param array $token Payment Token. |
626 | 626 | * @return string Generated payment method HTML |
627 | 627 | */ |
628 | - public function get_saved_payment_method_option_html( $token ) { |
|
628 | + public function get_saved_payment_method_option_html($token) { |
|
629 | 629 | |
630 | 630 | return sprintf( |
631 | 631 | '<li class="getpaid-payment-method form-group"> |
@@ -634,11 +634,11 @@ discard block |
||
634 | 634 | <span>%3$s</span> |
635 | 635 | </label> |
636 | 636 | </li>', |
637 | - esc_attr( $this->id ), |
|
638 | - esc_attr( $token['id'] ), |
|
639 | - esc_html( $token['name'] ), |
|
640 | - checked( empty( $token['default'] ), false, false ), |
|
641 | - empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] ) |
|
637 | + esc_attr($this->id), |
|
638 | + esc_attr($token['id']), |
|
639 | + esc_html($token['name']), |
|
640 | + checked(empty($token['default']), false, false), |
|
641 | + empty($token['currency']) ? 'none' : esc_attr($token['currency']) |
|
642 | 642 | ); |
643 | 643 | |
644 | 644 | } |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | */ |
651 | 651 | public function get_new_payment_method_option_html() { |
652 | 652 | |
653 | - $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
653 | + $label = apply_filters('getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __('Use a new payment method', 'invoicing'), $this); |
|
654 | 654 | |
655 | 655 | return sprintf( |
656 | 656 | '<li class="getpaid-new-payment-method"> |
@@ -659,8 +659,8 @@ discard block |
||
659 | 659 | <span>%2$s</span> |
660 | 660 | </label> |
661 | 661 | </li>', |
662 | - esc_attr( $this->id ), |
|
663 | - esc_html( $label ) |
|
662 | + esc_attr($this->id), |
|
663 | + esc_html($label) |
|
664 | 664 | ); |
665 | 665 | |
666 | 666 | } |
@@ -675,10 +675,10 @@ discard block |
||
675 | 675 | return aui()->input( |
676 | 676 | array( |
677 | 677 | 'type' => 'checkbox', |
678 | - 'name' => esc_attr( "getpaid-$this->id-new-payment-method" ), |
|
679 | - 'id' => esc_attr( uniqid( $this->id ) ), |
|
678 | + 'name' => esc_attr("getpaid-$this->id-new-payment-method"), |
|
679 | + 'id' => esc_attr(uniqid($this->id)), |
|
680 | 680 | 'required' => false, |
681 | - 'label' => esc_html__( 'Save payment method', 'invoicing' ), |
|
681 | + 'label' => esc_html__('Save payment method', 'invoicing'), |
|
682 | 682 | 'value' => 'true', |
683 | 683 | 'checked' => true, |
684 | 684 | 'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1', |
@@ -692,9 +692,9 @@ discard block |
||
692 | 692 | * |
693 | 693 | * @return array |
694 | 694 | */ |
695 | - public function register_gateway( $gateways ) { |
|
695 | + public function register_gateway($gateways) { |
|
696 | 696 | |
697 | - $gateways[ $this->id ] = array( |
|
697 | + $gateways[$this->id] = array( |
|
698 | 698 | |
699 | 699 | 'admin_label' => $this->method_title, |
700 | 700 | 'checkout_label' => $this->title, |
@@ -712,13 +712,13 @@ discard block |
||
712 | 712 | * @param WPInv_Invoice|null $invoice Invoice object or null. |
713 | 713 | * @return bool |
714 | 714 | */ |
715 | - public function is_sandbox( $invoice = null ) { |
|
715 | + public function is_sandbox($invoice = null) { |
|
716 | 716 | |
717 | - if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
717 | + if (!empty($invoice) && !$invoice->needs_payment()) { |
|
718 | 718 | return $invoice->get_mode() == 'test'; |
719 | 719 | } |
720 | 720 | |
721 | - return wpinv_is_test_mode( $this->id ); |
|
721 | + return wpinv_is_test_mode($this->id); |
|
722 | 722 | |
723 | 723 | } |
724 | 724 | |
@@ -736,15 +736,15 @@ discard block |
||
736 | 736 | * |
737 | 737 | * @return bool |
738 | 738 | */ |
739 | - public function validate_currency( $validation, $currency ) { |
|
739 | + public function validate_currency($validation, $currency) { |
|
740 | 740 | |
741 | 741 | // Required currencies. |
742 | - if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
742 | + if (!empty($this->currencies) && !in_array($currency, $this->currencies)) { |
|
743 | 743 | return false; |
744 | 744 | } |
745 | 745 | |
746 | 746 | // Excluded currencies. |
747 | - if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
747 | + if (!empty($this->exclude_currencies) && in_array($currency, $this->exclude_currencies)) { |
|
748 | 748 | return false; |
749 | 749 | } |
750 | 750 | |
@@ -755,13 +755,13 @@ discard block |
||
755 | 755 | * Displays an error |
756 | 756 | * |
757 | 757 | */ |
758 | - public function show_error( $code, $message, $type ) { |
|
758 | + public function show_error($code, $message, $type) { |
|
759 | 759 | |
760 | - if ( is_admin() ) { |
|
761 | - getpaid_admin()->{"show_$type"}( $message ); |
|
760 | + if (is_admin()) { |
|
761 | + getpaid_admin()->{"show_$type"}($message); |
|
762 | 762 | } |
763 | 763 | |
764 | - wpinv_set_error( $code, $message, $type ); |
|
764 | + wpinv_set_error($code, $message, $type); |
|
765 | 765 | |
766 | 766 | } |
767 | 767 |