@@ -103,29 +103,29 @@ discard block |
||
103 | 103 | |
104 | 104 | function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
105 | 105 | if ( ! empty( $args ) && is_array( $args ) ) { |
106 | - extract( $args ); |
|
107 | - } |
|
106 | + extract( $args ); |
|
107 | + } |
|
108 | 108 | |
109 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
110 | - // Allow 3rd party plugin filter template file from their plugin. |
|
111 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
109 | + $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
110 | + // Allow 3rd party plugin filter template file from their plugin. |
|
111 | + $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
112 | 112 | |
113 | - if ( ! file_exists( $located ) ) { |
|
113 | + if ( ! file_exists( $located ) ) { |
|
114 | 114 | _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
115 | - return; |
|
116 | - } |
|
115 | + return; |
|
116 | + } |
|
117 | 117 | |
118 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
118 | + do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
119 | 119 | |
120 | - include( $located ); |
|
120 | + include( $located ); |
|
121 | 121 | |
122 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
122 | + do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
126 | - ob_start(); |
|
127 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
128 | - return ob_get_clean(); |
|
126 | + ob_start(); |
|
127 | + wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
128 | + return ob_get_clean(); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
@@ -155,120 +155,120 @@ discard block |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
158 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
158 | + do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
159 | 159 | |
160 | - // Setup possible parts |
|
161 | - $templates = array(); |
|
162 | - if ( isset( $name ) ) |
|
163 | - $templates[] = $slug . '-' . $name . '.php'; |
|
164 | - $templates[] = $slug . '.php'; |
|
160 | + // Setup possible parts |
|
161 | + $templates = array(); |
|
162 | + if ( isset( $name ) ) |
|
163 | + $templates[] = $slug . '-' . $name . '.php'; |
|
164 | + $templates[] = $slug . '.php'; |
|
165 | 165 | |
166 | - // Allow template parts to be filtered |
|
167 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
166 | + // Allow template parts to be filtered |
|
167 | + $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
168 | 168 | |
169 | - // Return the part that is found |
|
170 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
169 | + // Return the part that is found |
|
170 | + return wpinv_locate_tmpl( $templates, $load, false ); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
174 | - // No file found yet |
|
175 | - $located = false; |
|
174 | + // No file found yet |
|
175 | + $located = false; |
|
176 | 176 | |
177 | - // Try to find a template file |
|
178 | - foreach ( (array)$template_names as $template_name ) { |
|
177 | + // Try to find a template file |
|
178 | + foreach ( (array)$template_names as $template_name ) { |
|
179 | 179 | |
180 | - // Continue if template is empty |
|
181 | - if ( empty( $template_name ) ) |
|
182 | - continue; |
|
180 | + // Continue if template is empty |
|
181 | + if ( empty( $template_name ) ) |
|
182 | + continue; |
|
183 | 183 | |
184 | - // Trim off any slashes from the template name |
|
185 | - $template_name = ltrim( $template_name, '/' ); |
|
184 | + // Trim off any slashes from the template name |
|
185 | + $template_name = ltrim( $template_name, '/' ); |
|
186 | 186 | |
187 | - // try locating this template file by looping through the template paths |
|
188 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
187 | + // try locating this template file by looping through the template paths |
|
188 | + foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
189 | 189 | |
190 | - if( file_exists( $template_path . $template_name ) ) { |
|
191 | - $located = $template_path . $template_name; |
|
192 | - break; |
|
193 | - } |
|
194 | - } |
|
190 | + if( file_exists( $template_path . $template_name ) ) { |
|
191 | + $located = $template_path . $template_name; |
|
192 | + break; |
|
193 | + } |
|
194 | + } |
|
195 | 195 | |
196 | - if( !empty( $located ) ) { |
|
197 | - break; |
|
198 | - } |
|
199 | - } |
|
196 | + if( !empty( $located ) ) { |
|
197 | + break; |
|
198 | + } |
|
199 | + } |
|
200 | 200 | |
201 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
202 | - load_template( $located, $require_once ); |
|
201 | + if ( ( true == $load ) && ! empty( $located ) ) |
|
202 | + load_template( $located, $require_once ); |
|
203 | 203 | |
204 | - return $located; |
|
204 | + return $located; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | function wpinv_get_theme_template_paths() { |
208 | - $template_dir = wpinv_get_theme_template_dir_name(); |
|
208 | + $template_dir = wpinv_get_theme_template_dir_name(); |
|
209 | 209 | |
210 | - $file_paths = array( |
|
211 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
212 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
213 | - 100 => wpinv_get_templates_dir() |
|
214 | - ); |
|
210 | + $file_paths = array( |
|
211 | + 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
212 | + 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
213 | + 100 => wpinv_get_templates_dir() |
|
214 | + ); |
|
215 | 215 | |
216 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
216 | + $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
217 | 217 | |
218 | - // sort the file paths based on priority |
|
219 | - ksort( $file_paths, SORT_NUMERIC ); |
|
218 | + // sort the file paths based on priority |
|
219 | + ksort( $file_paths, SORT_NUMERIC ); |
|
220 | 220 | |
221 | - return array_map( 'trailingslashit', $file_paths ); |
|
221 | + return array_map( 'trailingslashit', $file_paths ); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | function wpinv_get_theme_template_dir_name() { |
225 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
225 | + return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | function wpinv_checkout_meta_tags() { |
229 | 229 | |
230 | - $pages = array(); |
|
231 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
232 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
233 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
230 | + $pages = array(); |
|
231 | + $pages[] = wpinv_get_option( 'success_page' ); |
|
232 | + $pages[] = wpinv_get_option( 'failure_page' ); |
|
233 | + $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
234 | 234 | |
235 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
236 | - return; |
|
237 | - } |
|
235 | + if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
236 | + return; |
|
237 | + } |
|
238 | 238 | |
239 | - echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
239 | + echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
240 | 240 | } |
241 | 241 | add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
242 | 242 | |
243 | 243 | function wpinv_add_body_classes( $class ) { |
244 | - $classes = (array)$class; |
|
244 | + $classes = (array)$class; |
|
245 | 245 | |
246 | - if( wpinv_is_checkout() ) { |
|
247 | - $classes[] = 'wpinv-checkout'; |
|
248 | - $classes[] = 'wpinv-page'; |
|
249 | - } |
|
246 | + if( wpinv_is_checkout() ) { |
|
247 | + $classes[] = 'wpinv-checkout'; |
|
248 | + $classes[] = 'wpinv-page'; |
|
249 | + } |
|
250 | 250 | |
251 | - if( wpinv_is_success_page() ) { |
|
252 | - $classes[] = 'wpinv-success'; |
|
253 | - $classes[] = 'wpinv-page'; |
|
254 | - } |
|
251 | + if( wpinv_is_success_page() ) { |
|
252 | + $classes[] = 'wpinv-success'; |
|
253 | + $classes[] = 'wpinv-page'; |
|
254 | + } |
|
255 | 255 | |
256 | - if( wpinv_is_failed_transaction_page() ) { |
|
257 | - $classes[] = 'wpinv-failed-transaction'; |
|
258 | - $classes[] = 'wpinv-page'; |
|
259 | - } |
|
256 | + if( wpinv_is_failed_transaction_page() ) { |
|
257 | + $classes[] = 'wpinv-failed-transaction'; |
|
258 | + $classes[] = 'wpinv-page'; |
|
259 | + } |
|
260 | 260 | |
261 | - if( wpinv_is_invoice_history_page() ) { |
|
262 | - $classes[] = 'wpinv-history'; |
|
263 | - $classes[] = 'wpinv-page'; |
|
264 | - } |
|
261 | + if( wpinv_is_invoice_history_page() ) { |
|
262 | + $classes[] = 'wpinv-history'; |
|
263 | + $classes[] = 'wpinv-page'; |
|
264 | + } |
|
265 | 265 | |
266 | - if( wpinv_is_test_mode() ) { |
|
267 | - $classes[] = 'wpinv-test-mode'; |
|
268 | - $classes[] = 'wpinv-page'; |
|
269 | - } |
|
266 | + if( wpinv_is_test_mode() ) { |
|
267 | + $classes[] = 'wpinv-test-mode'; |
|
268 | + $classes[] = 'wpinv-page'; |
|
269 | + } |
|
270 | 270 | |
271 | - return array_unique( $classes ); |
|
271 | + return array_unique( $classes ); |
|
272 | 272 | } |
273 | 273 | add_filter( 'body_class', 'wpinv_add_body_classes' ); |
274 | 274 | |
@@ -1404,7 +1404,7 @@ discard block |
||
1404 | 1404 | add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
1405 | 1405 | |
1406 | 1406 | function wpinv_empty_cart_message() { |
1407 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1407 | + return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1408 | 1408 | } |
1409 | 1409 | |
1410 | 1410 | /** |
@@ -1414,7 +1414,7 @@ discard block |
||
1414 | 1414 | * @return void |
1415 | 1415 | */ |
1416 | 1416 | function wpinv_empty_checkout_cart() { |
1417 | - echo wpinv_empty_cart_message(); |
|
1417 | + echo wpinv_empty_cart_message(); |
|
1418 | 1418 | } |
1419 | 1419 | add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
1420 | 1420 | |
@@ -1552,11 +1552,11 @@ discard block |
||
1552 | 1552 | do_action( 'wpinv_payment_mode_before_gateways' ); |
1553 | 1553 | |
1554 | 1554 | if(!empty($gateways)){ |
1555 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
1556 | - $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
1557 | - $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
1558 | - $description = wpinv_get_gateway_description( $gateway_id ); |
|
1559 | - ?> |
|
1555 | + foreach ( $gateways as $gateway_id => $gateway ) { |
|
1556 | + $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
1557 | + $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
1558 | + $description = wpinv_get_gateway_description( $gateway_id ); |
|
1559 | + ?> |
|
1560 | 1560 | <div class="list-group-item"> |
1561 | 1561 | <div class="radio"> |
1562 | 1562 | <label><input type="radio" data-button-text="<?php echo esc_attr( $button_label );?>" value="<?php echo esc_attr( $gateway_id ) ;?>" <?php echo $checked ;?> id="wpi_gateway_<?php echo esc_attr( $gateway_id );?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html( $gateway['checkout_label'] ); ?></label> |
@@ -1569,9 +1569,9 @@ discard block |
||
1569 | 1569 | </div> |
1570 | 1570 | </div> |
1571 | 1571 | <?php |
1572 | - } |
|
1572 | + } |
|
1573 | 1573 | }else{ |
1574 | - echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
|
1574 | + echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
|
1575 | 1575 | } |
1576 | 1576 | |
1577 | 1577 | do_action( 'wpinv_payment_mode_after_gateways' ); |