theme-wrapper.php ➔ spurs_template_base()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Enable the theme wrapper.
4
 *
5
 * Thanks to:
6
 * Scribu http://scribu.net/wordpress/theme-wrappers.html
7
 * Ben Word and the team at roots.io
8
 *
9
 * @package spurs
10
 */
11
12
function spurs_template_path() {
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
13
	return SpursWrapping::$mainTemplate;
14
}
15
16
function spurs_template_base() {
17
	return SpursWrapping::$base;
18
}
19
20
21
class SpursWrapping {
22
23
	/**
24
	 * Stores the full path to the main template file
25
	 * @return string
26
	 */
27
	static $mainTemplate;
28
29
	/**
30
	 * Stores the base name of the template file; e.g. 'page' for 'page.php' etc.
31
	 * @return string
32
	 */
33
	static $base;
34
35
	static function wrap( $template ) {
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
36
		self::$mainTemplate = $template;
37
38
		self::$base = substr( basename( self::$mainTemplate ), 0, - 4 );
39
40
		if ( 'index' == self::$base ) {
41
			self::$base = false;
42
		}
43
44
		$templates = array( 'wrapper.php' );
45
46
		if ( false !== self::$base ) {
47
			array_unshift( $templates, sprintf( 'wrapper-%s.php', self::$base ) );
48
		}
49
50
		return locate_template( $templates );
51
	}
52
}
53
54
add_filter( 'template_include', array( 'SpursWrapping', 'wrap' ), 99 );