Bitsy_Wrapping   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 3
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A wrap() 0 17 3
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 bitsy
10
 */
11
12
function bitsy_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 Bitsy_Wrapping::$main_template;
14
}
15
16
function bitsy_template_base() {
17
	return Bitsy_Wrapping::$base;
18
}
19
20
21
class Bitsy_Wrapping {
0 ignored issues
show
Coding Style introduced by
The class Bitsy_Wrapping is not named in CamelCase.

This check marks class names that have not been written in CamelCase.

In CamelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well.

Thus the name database connector becomes DatabaseConnector.

Loading history...
Coding Style introduced by
The property $main_template is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
22
23
	/**
24
	 * Stores the full path to the main template file
25
	 */
26
	static $main_template;
27
28
	/**
29
	 * Stores the base name of the template file; e.g. 'page' for 'page.php' etc.
30
	 */
31
	static $base;
32
33
	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...
Coding Style Naming introduced by
The variable $main_template is not named in camelCase.

This check marks variable names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

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