Passed
Push — master ( d48fb4...90f5a7 )
by Stiofan
26s
created
includes/wpinv-template-functions.php 1 patch
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -117,29 +117,29 @@  discard block
 block discarded – undo
117 117
 
118 118
 function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
119 119
     if ( ! empty( $args ) && is_array( $args ) ) {
120
-		extract( $args );
121
-	}
120
+        extract( $args );
121
+    }
122 122
 
123
-	$located = wpinv_locate_template( $template_name, $template_path, $default_path );
124
-	if ( ! file_exists( $located ) ) {
123
+    $located = wpinv_locate_template( $template_name, $template_path, $default_path );
124
+    if ( ! file_exists( $located ) ) {
125 125
         _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' );
126
-		return;
127
-	}
126
+        return;
127
+    }
128 128
 
129
-	// Allow 3rd party plugin filter template file from their plugin.
130
-	$located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path );
129
+    // Allow 3rd party plugin filter template file from their plugin.
130
+    $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path );
131 131
 
132
-	do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args );
132
+    do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args );
133 133
 
134
-	include( $located );
134
+    include( $located );
135 135
 
136
-	do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args );
136
+    do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args );
137 137
 }
138 138
 
139 139
 function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
140
-	ob_start();
141
-	wpinv_get_template( $template_name, $args, $template_path, $default_path );
142
-	return ob_get_clean();
140
+    ob_start();
141
+    wpinv_get_template( $template_name, $args, $template_path, $default_path );
142
+    return ob_get_clean();
143 143
 }
144 144
 
145 145
 function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) {
@@ -169,120 +169,120 @@  discard block
 block discarded – undo
169 169
 }
170 170
 
171 171
 function wpinv_get_template_part( $slug, $name = null, $load = true ) {
172
-	do_action( 'get_template_part_' . $slug, $slug, $name );
172
+    do_action( 'get_template_part_' . $slug, $slug, $name );
173 173
 
174
-	// Setup possible parts
175
-	$templates = array();
176
-	if ( isset( $name ) )
177
-		$templates[] = $slug . '-' . $name . '.php';
178
-	$templates[] = $slug . '.php';
174
+    // Setup possible parts
175
+    $templates = array();
176
+    if ( isset( $name ) )
177
+        $templates[] = $slug . '-' . $name . '.php';
178
+    $templates[] = $slug . '.php';
179 179
 
180
-	// Allow template parts to be filtered
181
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
180
+    // Allow template parts to be filtered
181
+    $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
182 182
 
183
-	// Return the part that is found
184
-	return wpinv_locate_tmpl( $templates, $load, false );
183
+    // Return the part that is found
184
+    return wpinv_locate_tmpl( $templates, $load, false );
185 185
 }
186 186
 
187 187
 function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
188
-	// No file found yet
189
-	$located = false;
188
+    // No file found yet
189
+    $located = false;
190 190
 
191
-	// Try to find a template file
192
-	foreach ( (array)$template_names as $template_name ) {
191
+    // Try to find a template file
192
+    foreach ( (array)$template_names as $template_name ) {
193 193
 
194
-		// Continue if template is empty
195
-		if ( empty( $template_name ) )
196
-			continue;
194
+        // Continue if template is empty
195
+        if ( empty( $template_name ) )
196
+            continue;
197 197
 
198
-		// Trim off any slashes from the template name
199
-		$template_name = ltrim( $template_name, '/' );
198
+        // Trim off any slashes from the template name
199
+        $template_name = ltrim( $template_name, '/' );
200 200
 
201
-		// try locating this template file by looping through the template paths
202
-		foreach( wpinv_get_theme_template_paths() as $template_path ) {
201
+        // try locating this template file by looping through the template paths
202
+        foreach( wpinv_get_theme_template_paths() as $template_path ) {
203 203
 
204
-			if( file_exists( $template_path . $template_name ) ) {
205
-				$located = $template_path . $template_name;
206
-				break;
207
-			}
208
-		}
204
+            if( file_exists( $template_path . $template_name ) ) {
205
+                $located = $template_path . $template_name;
206
+                break;
207
+            }
208
+        }
209 209
 
210
-		if( !empty( $located ) ) {
211
-			break;
212
-		}
213
-	}
210
+        if( !empty( $located ) ) {
211
+            break;
212
+        }
213
+    }
214 214
 
215
-	if ( ( true == $load ) && ! empty( $located ) )
216
-		load_template( $located, $require_once );
215
+    if ( ( true == $load ) && ! empty( $located ) )
216
+        load_template( $located, $require_once );
217 217
 
218
-	return $located;
218
+    return $located;
219 219
 }
220 220
 
221 221
 function wpinv_get_theme_template_paths() {
222
-	$template_dir = wpinv_get_theme_template_dir_name();
222
+    $template_dir = wpinv_get_theme_template_dir_name();
223 223
 
224
-	$file_paths = array(
225
-		1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
226
-		10 => trailingslashit( get_template_directory() ) . $template_dir,
227
-		100 => wpinv_get_templates_dir()
228
-	);
224
+    $file_paths = array(
225
+        1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
226
+        10 => trailingslashit( get_template_directory() ) . $template_dir,
227
+        100 => wpinv_get_templates_dir()
228
+    );
229 229
 
230
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
230
+    $file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
231 231
 
232
-	// sort the file paths based on priority
233
-	ksort( $file_paths, SORT_NUMERIC );
232
+    // sort the file paths based on priority
233
+    ksort( $file_paths, SORT_NUMERIC );
234 234
 
235
-	return array_map( 'trailingslashit', $file_paths );
235
+    return array_map( 'trailingslashit', $file_paths );
236 236
 }
237 237
 
238 238
 function wpinv_get_theme_template_dir_name() {
239
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'wpinv_templates' ) );
239
+    return trailingslashit( apply_filters( 'wpinv_templates_dir', 'wpinv_templates' ) );
240 240
 }
241 241
 
242 242
 function wpinv_checkout_meta_tags() {
243 243
 
244
-	$pages   = array();
245
-	$pages[] = wpinv_get_option( 'success_page' );
246
-	$pages[] = wpinv_get_option( 'failure_page' );
247
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
244
+    $pages   = array();
245
+    $pages[] = wpinv_get_option( 'success_page' );
246
+    $pages[] = wpinv_get_option( 'failure_page' );
247
+    $pages[] = wpinv_get_option( 'invoice_history_page' );
248 248
 
249
-	if( !wpinv_is_checkout() && !is_page( $pages ) ) {
250
-		return;
251
-	}
249
+    if( !wpinv_is_checkout() && !is_page( $pages ) ) {
250
+        return;
251
+    }
252 252
 
253
-	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
253
+    echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
254 254
 }
255 255
 add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
256 256
 
257 257
 function wpinv_add_body_classes( $class ) {
258
-	$classes = (array)$class;
258
+    $classes = (array)$class;
259 259
 
260
-	if( wpinv_is_checkout() ) {
261
-		$classes[] = 'wpinv-checkout';
262
-		$classes[] = 'wpinv-page';
263
-	}
260
+    if( wpinv_is_checkout() ) {
261
+        $classes[] = 'wpinv-checkout';
262
+        $classes[] = 'wpinv-page';
263
+    }
264 264
 
265
-	if( wpinv_is_success_page() ) {
266
-		$classes[] = 'wpinv-success';
267
-		$classes[] = 'wpinv-page';
268
-	}
265
+    if( wpinv_is_success_page() ) {
266
+        $classes[] = 'wpinv-success';
267
+        $classes[] = 'wpinv-page';
268
+    }
269 269
 
270
-	if( wpinv_is_failed_transaction_page() ) {
271
-		$classes[] = 'wpinv-failed-transaction';
272
-		$classes[] = 'wpinv-page';
273
-	}
270
+    if( wpinv_is_failed_transaction_page() ) {
271
+        $classes[] = 'wpinv-failed-transaction';
272
+        $classes[] = 'wpinv-page';
273
+    }
274 274
 
275
-	if( wpinv_is_invoice_history_page() ) {
276
-		$classes[] = 'wpinv-history';
277
-		$classes[] = 'wpinv-page';
278
-	}
275
+    if( wpinv_is_invoice_history_page() ) {
276
+        $classes[] = 'wpinv-history';
277
+        $classes[] = 'wpinv-page';
278
+    }
279 279
 
280
-	if( wpinv_is_test_mode() ) {
281
-		$classes[] = 'wpinv-test-mode';
282
-		$classes[] = 'wpinv-page';
283
-	}
280
+    if( wpinv_is_test_mode() ) {
281
+        $classes[] = 'wpinv-test-mode';
282
+        $classes[] = 'wpinv-page';
283
+    }
284 284
 
285
-	return array_unique( $classes );
285
+    return array_unique( $classes );
286 286
 }
287 287
 add_filter( 'body_class', 'wpinv_add_body_classes' );
288 288
 
@@ -1443,7 +1443,7 @@  discard block
 block discarded – undo
1443 1443
 add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 );
1444 1444
 
1445 1445
 function wpinv_empty_cart_message() {
1446
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1446
+    return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1447 1447
 }
1448 1448
 
1449 1449
 /**
@@ -1453,7 +1453,7 @@  discard block
 block discarded – undo
1453 1453
  * @return void
1454 1454
  */
1455 1455
 function wpinv_empty_checkout_cart() {
1456
-	echo wpinv_empty_cart_message();
1456
+    echo wpinv_empty_cart_message();
1457 1457
 }
1458 1458
 add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' );
1459 1459
 
@@ -1589,11 +1589,11 @@  discard block
 block discarded – undo
1589 1589
                     $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id );
1590 1590
                     
1591 1591
                     if(!empty($gateways)){
1592
-	                    foreach ( $gateways as $gateway_id => $gateway ) {
1593
-		                    $checked = checked( $gateway_id, $chosen_gateway, false );
1594
-		                    $button_label = wpinv_get_gateway_button_label( $gateway_id );
1595
-		                    $description = wpinv_get_gateway_description( $gateway_id );
1596
-		                    ?>
1592
+                        foreach ( $gateways as $gateway_id => $gateway ) {
1593
+                            $checked = checked( $gateway_id, $chosen_gateway, false );
1594
+                            $button_label = wpinv_get_gateway_button_label( $gateway_id );
1595
+                            $description = wpinv_get_gateway_description( $gateway_id );
1596
+                            ?>
1597 1597
 		                    <div class="list-group-item">
1598 1598
 			                    <div class="radio">
1599 1599
 				                    <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>
@@ -1606,9 +1606,9 @@  discard block
 block discarded – undo
1606 1606
 			                    </div>
1607 1607
 		                    </div>
1608 1608
 		                    <?php
1609
-	                    }
1609
+                        }
1610 1610
                     }else{
1611
-	                    echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>';
1611
+                        echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>';
1612 1612
                     }
1613 1613
 
1614 1614
                     do_action( 'wpinv_payment_mode_after_gateways' );
Please login to merge, or discard this patch.