Completed
Branch master (2d9dd7)
by Andrey
01:58
created
php/class-core.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@
 block discarded – undo
136 136
 	/**
137 137
 	 * @param string $template
138 138
 	 *
139
-	 * @return string|bool
139
+	 * @return false|string
140 140
 	 */
141 141
 	public function template_include( $template ) {
142 142
 
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
 	/**
12 12
 	 * @param array $values
13 13
 	 */
14
-	public function __construct( $values = array() ) {
14
+	public function __construct($values = array()) {
15 15
 
16 16
 		$defaults['twig.options']     = array();
17 17
 		$defaults['twig.directories'] = array();
18 18
 
19
-		$defaults['twig.loader'] = function ( $meadow ) {
19
+		$defaults['twig.loader'] = function($meadow) {
20 20
 
21 21
 			// this needs to be lazy or theme switchers and alike explode it
22 22
 
@@ -25,12 +25,12 @@  discard block
 block discarded – undo
25 25
 			$calculated_dirs = array(
26 26
 				$stylesheet_dir,
27 27
 				$template_dir,
28
-				plugin_dir_path( __DIR__ ) . 'twig',
28
+				plugin_dir_path(__DIR__) . 'twig',
29 29
 			);
30 30
 
31 31
 			// enables explicit inheritance from parent theme in child
32
-			if ( $stylesheet_dir !== $template_dir ) {
33
-				$calculated_dirs[] = dirname( $template_dir );
32
+			if ($stylesheet_dir !== $template_dir) {
33
+				$calculated_dirs[] = dirname($template_dir);
34 34
 			}
35 35
 
36 36
 			$directories = array_unique(
@@ -40,33 +40,33 @@  discard block
 block discarded – undo
40 40
 				)
41 41
 			);
42 42
 
43
-			return new \Twig_Loader_Filesystem( $directories );
43
+			return new \Twig_Loader_Filesystem($directories);
44 44
 		};
45 45
 
46
-		$defaults['twig.undefined_function'] = array( __CLASS__, 'undefined_function' );
47
-		$defaults['twig.undefined_filter']   = array( __CLASS__, 'undefined_filter' );
46
+		$defaults['twig.undefined_function'] = array(__CLASS__, 'undefined_function');
47
+		$defaults['twig.undefined_filter']   = array(__CLASS__, 'undefined_filter');
48 48
 
49
-		$defaults['twig.environment'] = function ( $meadow ) {
50
-			$environment      = new \Twig_Environment( $meadow['twig.loader'], $meadow['twig.options'] );
49
+		$defaults['twig.environment'] = function($meadow) {
50
+			$environment      = new \Twig_Environment($meadow['twig.loader'], $meadow['twig.options']);
51 51
 			$meadow_extension = new Extension();
52
-			$environment->addExtension( $meadow_extension );
53
-			$environment->registerUndefinedFunctionCallback( $meadow['twig.undefined_function'] );
54
-			$environment->registerUndefinedFilterCallback( $meadow['twig.undefined_filter'] );
52
+			$environment->addExtension($meadow_extension);
53
+			$environment->registerUndefinedFunctionCallback($meadow['twig.undefined_function']);
54
+			$environment->registerUndefinedFilterCallback($meadow['twig.undefined_filter']);
55 55
 
56
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
56
+			if (defined('WP_DEBUG') && WP_DEBUG) {
57 57
 				$debug_extension = new \Twig_Extension_Debug();
58
-				$environment->addExtension( $debug_extension );
58
+				$environment->addExtension($debug_extension);
59 59
 				$environment->enableDebug();
60 60
 			}
61 61
 
62 62
 			return $environment;
63 63
 		};
64 64
 
65
-		$defaults['hierarchy'] = function () {
65
+		$defaults['hierarchy'] = function() {
66 66
 			return new Template_Hierarchy();
67 67
 		};
68 68
 
69
-		parent::__construct( array_merge( $defaults, $values ) );
69
+		parent::__construct(array_merge($defaults, $values));
70 70
 	}
71 71
 
72 72
 	/**
@@ -76,20 +76,20 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @return bool|\Twig_SimpleFunction
78 78
 	 */
79
-	static function undefined_function( $function_name ) {
79
+	static function undefined_function($function_name) {
80 80
 
81
-		if ( function_exists( $function_name ) ) {
81
+		if (function_exists($function_name)) {
82 82
 			return new \Twig_SimpleFunction(
83 83
 				$function_name,
84
-				function () use ( $function_name ) {
84
+				function() use ($function_name) {
85 85
 
86 86
 					ob_start();
87
-					$return = call_user_func_array( $function_name, func_get_args() );
87
+					$return = call_user_func_array($function_name, func_get_args());
88 88
 					$echo   = ob_get_clean();
89 89
 
90
-					return empty( $echo ) ? $return : $echo;
90
+					return empty($echo) ? $return : $echo;
91 91
 				},
92
-				array( 'is_safe' => array( 'all' ) )
92
+				array('is_safe' => array('all'))
93 93
 			);
94 94
 		}
95 95
 
@@ -103,15 +103,15 @@  discard block
 block discarded – undo
103 103
 	 *
104 104
 	 * @return bool|\Twig_SimpleFilter
105 105
 	 */
106
-	static function undefined_filter( $filter_name ) {
106
+	static function undefined_filter($filter_name) {
107 107
 
108 108
 		return new \Twig_SimpleFilter(
109 109
 			$filter_name,
110
-			function () use ( $filter_name ) {
110
+			function() use ($filter_name) {
111 111
 
112
-				return apply_filters( $filter_name, func_get_arg( 0 ) );
112
+				return apply_filters($filter_name, func_get_arg(0));
113 113
 			},
114
-			array( 'is_safe' => array( 'all' ) )
114
+			array('is_safe' => array('all'))
115 115
 		);
116 116
 	}
117 117
 
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
 		/** @var Template_Hierarchy $hierarchy */
121 121
 		$hierarchy = $this['hierarchy'];
122 122
 		$hierarchy->enable();
123
-		add_filter( 'template_include', array( $this, 'template_include' ) );
124
-		add_filter( 'get_search_form', array( $this, 'get_search_form' ), 9 );
123
+		add_filter('template_include', array($this, 'template_include'));
124
+		add_filter('get_search_form', array($this, 'get_search_form'), 9);
125 125
 	}
126 126
 
127 127
 	public function disable() {
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
 		/** @var Template_Hierarchy $hierarchy */
130 130
 		$hierarchy = $this['hierarchy'];
131 131
 		$hierarchy->disable();
132
-		remove_filter( 'template_include', array( $this, 'template_include' ) );
133
-		remove_filter( 'get_search_form', array( $this, 'get_search_form' ), 9 );
132
+		remove_filter('template_include', array($this, 'template_include'));
133
+		remove_filter('get_search_form', array($this, 'get_search_form'), 9);
134 134
 	}
135 135
 
136 136
 	/**
@@ -138,13 +138,13 @@  discard block
 block discarded – undo
138 138
 	 *
139 139
 	 * @return string|bool
140 140
 	 */
141
-	public function template_include( $template ) {
141
+	public function template_include($template) {
142 142
 
143
-		if ( '.twig' === substr( $template, - 5 ) ) {
143
+		if ('.twig' === substr($template, - 5)) {
144 144
 			/** @var \Twig_Environment $twig */
145 145
 			$twig = $this['twig.environment'];
146 146
 
147
-			echo $twig->render( basename( $template ), apply_filters( 'meadow_context', array() ) );
147
+			echo $twig->render(basename($template), apply_filters('meadow_context', array()));
148 148
 
149 149
 			return false;
150 150
 		}
@@ -157,14 +157,14 @@  discard block
 block discarded – undo
157 157
 	 *
158 158
 	 * @return string
159 159
 	 */
160
-	public function get_search_form( $form ) {
160
+	public function get_search_form($form) {
161 161
 
162 162
 		// because first time it's action
163
-		if ( ! empty( $form ) ) {
163
+		if ( ! empty($form)) {
164 164
 			/** @var \Twig_Environment $twig */
165 165
 			$twig = $this['twig.environment'];
166 166
 
167
-			return $twig->render( 'searchform.twig', array() );
167
+			return $twig->render('searchform.twig', array());
168 168
 		}
169 169
 
170 170
 		return $form;
Please login to merge, or discard this patch.
php/class-comments-node.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,13 +11,13 @@
 block discarded – undo
11 11
 	/**
12 12
 	 * @param Twig_Compiler $compiler
13 13
 	 */
14
-	public function compile( Twig_Compiler $compiler ) {
14
+	public function compile(Twig_Compiler $compiler) {
15 15
 
16 16
 		$compiler
17
-			->addDebugInfo( $this )
18
-			->write( '$callback = function() {' )
19
-			->subcompile( $this->getNode( 'callback' ) )
20
-			->write( '};' )
21
-			->write( 'wp_list_comments( array( \'callback\' => $callback ) );' );
17
+			->addDebugInfo($this)
18
+			->write('$callback = function() {')
19
+			->subcompile($this->getNode('callback'))
20
+			->write('};')
21
+			->write('wp_list_comments( array( \'callback\' => $callback ) );');
22 22
 	}
23 23
 } 
24 24
\ No newline at end of file
Please login to merge, or discard this patch.
php/class-loop-node.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -13,23 +13,23 @@
 block discarded – undo
13 13
 	/**
14 14
 	 * @param Twig_Compiler $compiler
15 15
 	 */
16
-	public function compile( Twig_Compiler $compiler ) {
16
+	public function compile(Twig_Compiler $compiler) {
17 17
 
18
-		$compiler->addDebugInfo( $this );
18
+		$compiler->addDebugInfo($this);
19 19
 
20
-		if ( $this->hasNode( 'query' ) ) {
20
+		if ($this->hasNode('query')) {
21 21
 			$compiler
22
-					->write( '$loop = new WP_Query(' )
23
-					->subcompile( $this->getNode( 'query' ) )
24
-					->raw( ");\n" )
25
-					->write( 'while( $loop->have_posts() ) : $loop->the_post();' . "\n" ); // TODO nested loops
22
+					->write('$loop = new WP_Query(')
23
+					->subcompile($this->getNode('query'))
24
+					->raw(");\n")
25
+					->write('while( $loop->have_posts() ) : $loop->the_post();' . "\n"); // TODO nested loops
26 26
 		}
27 27
 		else {
28
-			$compiler->write( 'while( have_posts() ) : the_post();' . "\n" );
28
+			$compiler->write('while( have_posts() ) : the_post();' . "\n");
29 29
 		}
30 30
 
31 31
 		$compiler
32
-				->subcompile( $this->getNode( 'body' ) )
33
-				->write( 'endwhile;' . "\n" );
32
+				->subcompile($this->getNode('body'))
33
+				->write('endwhile;' . "\n");
34 34
 	}
35 35
 }
36 36
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@
 block discarded – undo
23 23
 					->subcompile( $this->getNode( 'query' ) )
24 24
 					->raw( ");\n" )
25 25
 					->write( 'while( $loop->have_posts() ) : $loop->the_post();' . "\n" ); // TODO nested loops
26
-		}
27
-		else {
26
+		} else {
28 27
 			$compiler->write( 'while( have_posts() ) : the_post();' . "\n" );
29 28
 		}
30 29
 
Please login to merge, or discard this patch.
php/class-extension.php 2 patches
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 		return 'meadow';
12 12
 	}
13 13
 
14
-	public function initRuntime( \Twig_Environment $environment ) {
14
+	public function initRuntime(\Twig_Environment $environment) {
15 15
 
16 16
 	}
17 17
 
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
 		$options = array(
21 21
 			'needs_environment' => true,
22 22
 			'needs_context'     => true,
23
-			'is_safe'           => array( 'all' )
23
+			'is_safe'           => array('all')
24 24
 		);
25 25
 
26 26
 		$functions = array();
27 27
 
28
-		foreach ( array( 'get_header', 'get_footer', 'get_sidebar', 'get_template_part', 'get_search_form', 'comments_template' ) as $function ) {
29
-			$functions[] = new \Twig_SimpleFunction( $function, array( $this, $function ), $options );
28
+		foreach (array('get_header', 'get_footer', 'get_sidebar', 'get_template_part', 'get_search_form', 'comments_template') as $function) {
29
+			$functions[] = new \Twig_SimpleFunction($function, array($this, $function), $options);
30 30
 		}
31 31
 
32 32
 		return $functions;
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
 		global $wp_query;
38 38
 
39
-		return compact( 'wp_query' );
39
+		return compact('wp_query');
40 40
 	}
41 41
 
42 42
 	public function getTokenParsers(  ) {
@@ -47,16 +47,16 @@  discard block
 block discarded – undo
47 47
 		);
48 48
 	}
49 49
 
50
-	public function get_header( \Twig_Environment $env, $context, $name = null ) {
50
+	public function get_header(\Twig_Environment $env, $context, $name = null) {
51 51
 
52
-		return $this->get_template( $env, $context, 'header', $name );
52
+		return $this->get_template($env, $context, 'header', $name);
53 53
 	}
54 54
 
55
-	public function get_templates( $slug, $name = null ) {
55
+	public function get_templates($slug, $name = null) {
56 56
 
57 57
 		$templates = array();
58 58
 
59
-		if ( ! empty( $name ) )
59
+		if ( ! empty($name))
60 60
 			$templates[] = "{$slug}-{$name}.twig";
61 61
 
62 62
 		$templates[] = "{$slug}.twig";
@@ -64,24 +64,24 @@  discard block
 block discarded – undo
64 64
 		return $templates;
65 65
 	}
66 66
 
67
-	public function get_footer( \Twig_Environment $env, $context, $name = null ) {
67
+	public function get_footer(\Twig_Environment $env, $context, $name = null) {
68 68
 
69
-		return $this->get_template( $env, $context, 'footer', $name );
69
+		return $this->get_template($env, $context, 'footer', $name);
70 70
 	}
71 71
 
72
-	public function get_sidebar( \Twig_Environment $env, $context, $name = null ) {
72
+	public function get_sidebar(\Twig_Environment $env, $context, $name = null) {
73 73
 
74
-		return $this->get_template( $env, $context, 'sidebar', $name );
74
+		return $this->get_template($env, $context, 'sidebar', $name);
75 75
 	}
76 76
 
77
-	public function get_template_part( \Twig_Environment $env, $context, $slug, $name = null ) {
77
+	public function get_template_part(\Twig_Environment $env, $context, $slug, $name = null) {
78 78
 
79 79
 		try {
80
-			$return = twig_include( $env, $context, $this->get_templates( $slug, $name ) );
81
-			do_action( "get_template_part_{$slug}", $slug, $name );
82
-		} catch ( \Twig_Error_Loader $e ) {
80
+			$return = twig_include($env, $context, $this->get_templates($slug, $name));
81
+			do_action("get_template_part_{$slug}", $slug, $name);
82
+		} catch (\Twig_Error_Loader $e) {
83 83
 			ob_start();
84
-			get_template_part( $slug, $name );
84
+			get_template_part($slug, $name);
85 85
 			$return = ob_get_clean();
86 86
 		}
87 87
 
@@ -95,39 +95,39 @@  discard block
 block discarded – undo
95 95
 	 */
96 96
 	public function get_search_form() {
97 97
 
98
-		return apply_filters( 'get_search_form', true );
98
+		return apply_filters('get_search_form', true);
99 99
 	}
100 100
 
101
-	protected function get_template( \Twig_Environment $env, $context, $type, $name = null ) {
101
+	protected function get_template(\Twig_Environment $env, $context, $type, $name = null) {
102 102
 
103 103
 		try {
104
-			$return = twig_include( $env, $context, $this->get_templates( $type, $name ) );
105
-			do_action( 'get_' . $type, $name );
106
-		} catch ( \Twig_Error_Loader $e ) {
104
+			$return = twig_include($env, $context, $this->get_templates($type, $name));
105
+			do_action('get_' . $type, $name);
106
+		} catch (\Twig_Error_Loader $e) {
107 107
 			ob_start();
108
-			call_user_func( 'get_' . $type, $name );
108
+			call_user_func('get_' . $type, $name);
109 109
 			$return = ob_get_clean();
110 110
 		}
111 111
 
112 112
 		return $return;
113 113
 	}
114 114
 
115
-	public function comments_template( \Twig_Environment $env, $context, $file = 'comments.twig', $separate_comments = false ) {
115
+	public function comments_template(\Twig_Environment $env, $context, $file = 'comments.twig', $separate_comments = false) {
116 116
 
117 117
 		try {
118
-			$env->loadTemplate( $file );
119
-		} catch ( \Twig_Error_Loader $e ) {
118
+			$env->loadTemplate($file);
119
+		} catch (\Twig_Error_Loader $e) {
120 120
 			ob_start();
121
-			comments_template( '/comments.php', $separate_comments );
121
+			comments_template('/comments.php', $separate_comments);
122 122
 
123 123
 			return ob_get_clean();
124 124
 		}
125 125
 
126
-		add_filter( 'comments_template', array( $this, 'return_blank_template' ) );
127
-		comments_template( '/comments.php', $separate_comments );
128
-		remove_filter( 'comments_template', array( $this, 'return_blank_template' ) );
126
+		add_filter('comments_template', array($this, 'return_blank_template'));
127
+		comments_template('/comments.php', $separate_comments);
128
+		remove_filter('comments_template', array($this, 'return_blank_template'));
129 129
 
130
-		return twig_include( $env, $context, $file );
130
+		return twig_include($env, $context, $file);
131 131
 	}
132 132
 
133 133
 	public function return_blank_template() {
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -56,8 +56,9 @@
 block discarded – undo
56 56
 
57 57
 		$templates = array();
58 58
 
59
-		if ( ! empty( $name ) )
60
-			$templates[] = "{$slug}-{$name}.twig";
59
+		if ( ! empty( $name ) ) {
60
+					$templates[] = "{$slug}-{$name}.twig";
61
+		}
61 62
 
62 63
 		$templates[] = "{$slug}.twig";
63 64
 
Please login to merge, or discard this patch.
php/class-comments-token-parser.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,17 +12,17 @@  discard block
 block discarded – undo
12 12
 	 *
13 13
 	 * @return Loop_Node
14 14
 	 */
15
-	public function parse( Twig_Token $token ) {
15
+	public function parse(Twig_Token $token) {
16 16
 
17 17
 		$nodes  = array();
18 18
 		$parser = $this->parser;
19 19
 		$stream = $parser->getStream();
20 20
 
21
-		$stream->expect( Twig_Token::BLOCK_END_TYPE );
22
-		$nodes['callback'] = $parser->subparse( array( $this, 'decide_comments_end' ), true );
23
-		$stream->expect( Twig_Token::BLOCK_END_TYPE );
21
+		$stream->expect(Twig_Token::BLOCK_END_TYPE);
22
+		$nodes['callback'] = $parser->subparse(array($this, 'decide_comments_end'), true);
23
+		$stream->expect(Twig_Token::BLOCK_END_TYPE);
24 24
 
25
-		return new Comments_Node( $nodes, array(), $token->getLine(), $this->getTag() );
25
+		return new Comments_Node($nodes, array(), $token->getLine(), $this->getTag());
26 26
 	}
27 27
 
28 28
 	/**
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @return bool
40 40
 	 */
41
-	public function decide_comments_end( Twig_Token $token ) {
42
-		return $token->test( 'endcomments' );
41
+	public function decide_comments_end(Twig_Token $token) {
42
+		return $token->test('endcomments');
43 43
 	}
44 44
 } 
45 45
\ No newline at end of file
Please login to merge, or discard this patch.
php/class-loop-token-parser.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -13,20 +13,20 @@  discard block
 block discarded – undo
13 13
 	 *
14 14
 	 * @return Loop_Node
15 15
 	 */
16
-	public function parse( Twig_Token $token ) {
16
+	public function parse(Twig_Token $token) {
17 17
 
18 18
 		$nodes  = array();
19 19
 		$parser = $this->parser;
20 20
 		$stream = $parser->getStream();
21 21
 
22
-		if ( ! $stream->getCurrent()->test( Twig_Token::BLOCK_END_TYPE ) )
22
+		if ( ! $stream->getCurrent()->test(Twig_Token::BLOCK_END_TYPE))
23 23
 			$nodes['query'] = $parser->getExpressionParser()->parseExpression();
24 24
 
25
-		$stream->expect( Twig_Token::BLOCK_END_TYPE );
26
-		$nodes['body'] = $parser->subparse( array( $this, 'decide_loop_end' ), true );
27
-		$stream->expect( Twig_Token::BLOCK_END_TYPE );
25
+		$stream->expect(Twig_Token::BLOCK_END_TYPE);
26
+		$nodes['body'] = $parser->subparse(array($this, 'decide_loop_end'), true);
27
+		$stream->expect(Twig_Token::BLOCK_END_TYPE);
28 28
 
29
-		return new Loop_Node( $nodes, array(), $token->getLine(), $this->getTag() );
29
+		return new Loop_Node($nodes, array(), $token->getLine(), $this->getTag());
30 30
 	}
31 31
 
32 32
 	/**
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @return bool
44 44
 	 */
45
-	public function decide_loop_end( Twig_Token $token ) {
46
-		return $token->test( 'endloop' );
45
+	public function decide_loop_end(Twig_Token $token) {
46
+		return $token->test('endloop');
47 47
 	}
48 48
 }
49 49
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,8 +19,9 @@
 block discarded – undo
19 19
 		$parser = $this->parser;
20 20
 		$stream = $parser->getStream();
21 21
 
22
-		if ( ! $stream->getCurrent()->test( Twig_Token::BLOCK_END_TYPE ) )
23
-			$nodes['query'] = $parser->getExpressionParser()->parseExpression();
22
+		if ( ! $stream->getCurrent()->test( Twig_Token::BLOCK_END_TYPE ) ) {
23
+					$nodes['query'] = $parser->getExpressionParser()->parseExpression();
24
+		}
24 25
 
25 26
 		$stream->expect( Twig_Token::BLOCK_END_TYPE );
26 27
 		$nodes['body'] = $parser->subparse( array( $this, 'decide_loop_end' ), true );
Please login to merge, or discard this patch.
php/class-template-hierarchy.php 2 patches
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -29,39 +29,39 @@  discard block
 block discarded – undo
29 29
 
30 30
 	public function enable() {
31 31
 
32
-		add_action( 'template_redirect', array( $this, 'template_redirect' ) );
32
+		add_action('template_redirect', array($this, 'template_redirect'));
33 33
 
34
-		foreach ( $this->template_types as $type ) {
35
-			add_filter( "{$type}_template", array( $this, 'query_template' ) );
34
+		foreach ($this->template_types as $type) {
35
+			add_filter("{$type}_template", array($this, 'query_template'));
36 36
 		}
37 37
 	}
38 38
 
39 39
 	public function disable() {
40 40
 
41
-		remove_action( 'template_redirect', array( $this, 'template_redirect' ) );
41
+		remove_action('template_redirect', array($this, 'template_redirect'));
42 42
 
43
-		foreach ( $this->template_types as $type ) {
44
-			remove_filter( "{$type}_template", array( $this, 'query_template' ) );
43
+		foreach ($this->template_types as $type) {
44
+			remove_filter("{$type}_template", array($this, 'query_template'));
45 45
 		}
46 46
 
47
-		if ( ! empty($this->mime_type) ) {
48
-			remove_filter( "{$this->mime_type[0]}_template", array( $this, 'query_template' ) );
49
-			remove_filter( "{$this->mime_type[1]}_template", array( $this, 'query_template' ) );
50
-			remove_filter( "{$this->mime_type[0]}{$this->mime_type[1]}_template", array( $this, 'query_template' ) );
47
+		if ( ! empty($this->mime_type)) {
48
+			remove_filter("{$this->mime_type[0]}_template", array($this, 'query_template'));
49
+			remove_filter("{$this->mime_type[1]}_template", array($this, 'query_template'));
50
+			remove_filter("{$this->mime_type[0]}{$this->mime_type[1]}_template", array($this, 'query_template'));
51 51
 		}
52 52
 	}
53 53
 
54 54
 	public function template_redirect() {
55 55
 
56
-		if ( is_attachment() ) {
56
+		if (is_attachment()) {
57 57
 			global $posts;
58 58
 
59
-			if ( ! empty( $posts ) && isset( $posts[0]->post_mime_type ) )
60
-				$this->mime_type = explode( '/', $posts[0]->post_mime_type );
59
+			if ( ! empty($posts) && isset($posts[0]->post_mime_type))
60
+				$this->mime_type = explode('/', $posts[0]->post_mime_type);
61 61
 
62
-			add_filter( "{$this->mime_type[0]}_template", array( $this, 'query_template' ) );
63
-			add_filter( "{$this->mime_type[1]}_template", array( $this, 'query_template' ) );
64
-			add_filter( "{$this->mime_type[0]}{$this->mime_type[1]}_template", array( $this, 'query_template' ) );
62
+			add_filter("{$this->mime_type[0]}_template", array($this, 'query_template'));
63
+			add_filter("{$this->mime_type[1]}_template", array($this, 'query_template'));
64
+			add_filter("{$this->mime_type[0]}{$this->mime_type[1]}_template", array($this, 'query_template'));
65 65
 		}
66 66
 	}
67 67
 
@@ -70,16 +70,16 @@  discard block
 block discarded – undo
70 70
 	 *
71 71
 	 * @return string
72 72
 	 */
73
-	public function query_template( $fallback ) {
73
+	public function query_template($fallback) {
74 74
 
75
-		$type      = substr( current_filter(), 0, - 9 ); // trim '_template' from end
75
+		$type      = substr(current_filter(), 0, - 9); // trim '_template' from end
76 76
 		$templates = array();
77 77
 
78
-		switch ( $type ) {
78
+		switch ($type) {
79 79
 			case 'taxonomy':
80 80
 				$term = get_queried_object();
81 81
 
82
-				if ( $term ) {
82
+				if ($term) {
83 83
 					$taxonomy    = $term->taxonomy;
84 84
 					$templates[] = "taxonomy-{$taxonomy}-{$term->slug}.twig";
85 85
 					$templates[] = "taxonomy-{$taxonomy}.twig";
@@ -89,17 +89,17 @@  discard block
 block discarded – undo
89 89
 				break;
90 90
 
91 91
 			case 'frontpage':
92
-				$templates = array( 'front-page.twig' );
92
+				$templates = array('front-page.twig');
93 93
 				break;
94 94
 
95 95
 			case 'home':
96
-				$templates = array( 'home.twig', 'index.twig' );
96
+				$templates = array('home.twig', 'index.twig');
97 97
 				break;
98 98
 
99 99
 			case 'single':
100 100
 				$object = get_queried_object();
101 101
 
102
-				if ( $object )
102
+				if ($object)
103 103
 					$templates[] = "single-{$object->post_type}.twig";
104 104
 
105 105
 				$templates[] = 'single.twig';
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
 			case 'page':
109 109
 				$page_id  = get_queried_object_id();
110 110
 				$template = get_page_template_slug();
111
-				$pagename = get_query_var( 'pagename' );
111
+				$pagename = get_query_var('pagename');
112 112
 
113
-				if ( ! $pagename && $page_id ) {
113
+				if ( ! $pagename && $page_id) {
114 114
 					// If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object
115 115
 					$post     = get_queried_object();
116 116
 					$pagename = $post->post_name;
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
 //				if ( $template && 0 === validate_file( $template ) )
121 121
 //					$templates[] = $template;
122 122
 
123
-				if ( $pagename )
123
+				if ($pagename)
124 124
 					$templates[] = "page-{$pagename}.twig";
125 125
 
126
-				if ( $page_id )
126
+				if ($page_id)
127 127
 					$templates[] = "page-{$page_id}.twig";
128 128
 
129 129
 				$templates[] = 'page.twig';
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 			case 'tag':
134 134
 				$term = get_queried_object();
135 135
 
136
-				if ( $term ) {
136
+				if ($term) {
137 137
 					$templates[] = "{$type}-{$term->slug}.twig";
138 138
 					$templates[] = "{$type}-{$term->term_id}.twig";
139 139
 				}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 			case 'author':
145 145
 				$author = get_queried_object();
146 146
 
147
-				if ( $author ) {
147
+				if ($author) {
148 148
 					$templates[] = "author-{$author->user_nicename}.twig";
149 149
 					$templates[] = "author-{$author->ID}.twig";
150 150
 				}
@@ -153,10 +153,10 @@  discard block
 block discarded – undo
153 153
 				break;
154 154
 
155 155
 			case 'archive':
156
-				$post_types = array_filter( (array) get_query_var( 'post_type' ) );
156
+				$post_types = array_filter((array) get_query_var('post_type'));
157 157
 
158
-				if ( count( $post_types ) == 1 ) {
159
-					$post_type   = reset( $post_types );
158
+				if (count($post_types) == 1) {
159
+					$post_type   = reset($post_types);
160 160
 					$templates[] = "archive-{$post_type}.twig";
161 161
 				}
162 162
 
@@ -164,16 +164,16 @@  discard block
 block discarded – undo
164 164
 				break;
165 165
 
166 166
 			default:
167
-				$templates = array( "{$type}.twig" );
167
+				$templates = array("{$type}.twig");
168 168
 		}
169 169
 
170
-		$template = $this->locate_template( $templates );
170
+		$template = $this->locate_template($templates);
171 171
 
172
-		if ( empty( $template ) ) {
172
+		if (empty($template)) {
173 173
 			$template = $fallback;
174 174
 		}
175 175
 
176
-		return apply_filters( 'meadow_query_template', $template, $type );
176
+		return apply_filters('meadow_query_template', $template, $type);
177 177
 	}
178 178
 
179 179
 	/**
@@ -183,8 +183,8 @@  discard block
 block discarded – undo
183 183
 	 *
184 184
 	 * @return string
185 185
 	 */
186
-	public function locate_template( $templates ) {
186
+	public function locate_template($templates) {
187 187
 
188
-		return locate_template( $templates );
188
+		return locate_template($templates);
189 189
 	}
190 190
 }
191 191
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -56,8 +56,9 @@  discard block
 block discarded – undo
56 56
 		if ( is_attachment() ) {
57 57
 			global $posts;
58 58
 
59
-			if ( ! empty( $posts ) && isset( $posts[0]->post_mime_type ) )
60
-				$this->mime_type = explode( '/', $posts[0]->post_mime_type );
59
+			if ( ! empty( $posts ) && isset( $posts[0]->post_mime_type ) ) {
60
+							$this->mime_type = explode( '/', $posts[0]->post_mime_type );
61
+			}
61 62
 
62 63
 			add_filter( "{$this->mime_type[0]}_template", array( $this, 'query_template' ) );
63 64
 			add_filter( "{$this->mime_type[1]}_template", array( $this, 'query_template' ) );
@@ -99,8 +100,9 @@  discard block
 block discarded – undo
99 100
 			case 'single':
100 101
 				$object = get_queried_object();
101 102
 
102
-				if ( $object )
103
-					$templates[] = "single-{$object->post_type}.twig";
103
+				if ( $object ) {
104
+									$templates[] = "single-{$object->post_type}.twig";
105
+				}
104 106
 
105 107
 				$templates[] = 'single.twig';
106 108
 				break;
@@ -120,11 +122,13 @@  discard block
 block discarded – undo
120 122
 //				if ( $template && 0 === validate_file( $template ) )
121 123
 //					$templates[] = $template;
122 124
 
123
-				if ( $pagename )
124
-					$templates[] = "page-{$pagename}.twig";
125
+				if ( $pagename ) {
126
+									$templates[] = "page-{$pagename}.twig";
127
+				}
125 128
 
126
-				if ( $page_id )
127
-					$templates[] = "page-{$page_id}.twig";
129
+				if ( $page_id ) {
130
+									$templates[] = "page-{$page_id}.twig";
131
+				}
128 132
 
129 133
 				$templates[] = 'page.twig';
130 134
 				break;
Please login to merge, or discard this patch.