Completed
Push — master ( 83b84d...55ca36 )
by Andrey
01:41
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   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -11,14 +11,14 @@  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
 		global $wp_version;
17 17
 
18 18
 		$defaults['twig.options']     = array();
19 19
 		$defaults['twig.directories'] = array();
20 20
 
21
-		$defaults['twig.loader'] = function ( $meadow ) {
21
+		$defaults['twig.loader'] = function($meadow) {
22 22
 
23 23
 			// this needs to be lazy or theme switchers and alike explode it
24 24
 
@@ -27,12 +27,12 @@  discard block
 block discarded – undo
27 27
 			$calculated_dirs = array(
28 28
 				$stylesheet_dir,
29 29
 				$template_dir,
30
-				plugin_dir_path( __DIR__ ) . 'twig',
30
+				plugin_dir_path(__DIR__) . 'twig',
31 31
 			);
32 32
 
33 33
 			// enables explicit inheritance from parent theme in child
34
-			if ( $stylesheet_dir !== $template_dir ) {
35
-				$calculated_dirs[] = dirname( $template_dir );
34
+			if ($stylesheet_dir !== $template_dir) {
35
+				$calculated_dirs[] = dirname($template_dir);
36 36
 			}
37 37
 
38 38
 			$directories = array_unique(
@@ -42,44 +42,44 @@  discard block
 block discarded – undo
42 42
 				)
43 43
 			);
44 44
 
45
-			return new \Twig_Loader_Filesystem( $directories );
45
+			return new \Twig_Loader_Filesystem($directories);
46 46
 		};
47 47
 
48
-		$defaults['twig.undefined_function'] = array( __CLASS__, 'undefined_function' );
49
-		$defaults['twig.undefined_filter']   = array( __CLASS__, 'undefined_filter' );
48
+		$defaults['twig.undefined_function'] = array(__CLASS__, 'undefined_function');
49
+		$defaults['twig.undefined_filter']   = array(__CLASS__, 'undefined_filter');
50 50
 
51
-		$defaults['twig.environment'] = function ( $meadow ) {
52
-			$environment      = new \Twig_Environment( $meadow['twig.loader'], $meadow['twig.options'] );
51
+		$defaults['twig.environment'] = function($meadow) {
52
+			$environment      = new \Twig_Environment($meadow['twig.loader'], $meadow['twig.options']);
53 53
 			$meadow_extension = new Extension();
54
-			$environment->addExtension( $meadow_extension );
55
-			$environment->registerUndefinedFunctionCallback( $meadow['twig.undefined_function'] );
56
-			$environment->registerUndefinedFilterCallback( $meadow['twig.undefined_filter'] );
54
+			$environment->addExtension($meadow_extension);
55
+			$environment->registerUndefinedFunctionCallback($meadow['twig.undefined_function']);
56
+			$environment->registerUndefinedFilterCallback($meadow['twig.undefined_filter']);
57 57
 
58
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
58
+			if (defined('WP_DEBUG') && WP_DEBUG) {
59 59
 				$debug_extension = new \Twig_Extension_Debug();
60
-				$environment->addExtension( $debug_extension );
60
+				$environment->addExtension($debug_extension);
61 61
 				$environment->enableDebug();
62 62
 			}
63 63
 
64 64
 			return $environment;
65 65
 		};
66 66
 
67
-		if ( version_compare( rtrim( $wp_version, '-src' ), '4.7', '>=' ) ) {
67
+		if (version_compare(rtrim($wp_version, '-src'), '4.7', '>=')) {
68 68
 
69
-			$defaults['hierarchy'] = function () {
69
+			$defaults['hierarchy'] = function() {
70 70
 				return new Type_Template_Hierarchy();
71 71
 			};
72 72
 		} else {
73 73
 
74
-			trigger_error( 'Pre–WP 4.7 implementation of Meadow hierarchy is deprecated and will be removed in 1.0.', E_USER_DEPRECATED );
74
+			trigger_error('Pre–WP 4.7 implementation of Meadow hierarchy is deprecated and will be removed in 1.0.', E_USER_DEPRECATED);
75 75
 
76
-			$defaults['hierarchy'] = function () {
76
+			$defaults['hierarchy'] = function() {
77 77
 				return new Template_Hierarchy();
78 78
 			};
79 79
 		}
80 80
 
81 81
 
82
-		parent::__construct( array_merge( $defaults, $values ) );
82
+		parent::__construct(array_merge($defaults, $values));
83 83
 	}
84 84
 
85 85
 	/**
@@ -89,20 +89,20 @@  discard block
 block discarded – undo
89 89
 	 *
90 90
 	 * @return bool|\Twig_SimpleFunction
91 91
 	 */
92
-	static function undefined_function( $function_name ) {
92
+	static function undefined_function($function_name) {
93 93
 
94
-		if ( function_exists( $function_name ) ) {
94
+		if (function_exists($function_name)) {
95 95
 			return new \Twig_SimpleFunction(
96 96
 				$function_name,
97
-				function () use ( $function_name ) {
97
+				function() use ($function_name) {
98 98
 
99 99
 					ob_start();
100
-					$return = call_user_func_array( $function_name, func_get_args() );
100
+					$return = call_user_func_array($function_name, func_get_args());
101 101
 					$echo   = ob_get_clean();
102 102
 
103
-					return empty( $echo ) ? $return : $echo;
103
+					return empty($echo) ? $return : $echo;
104 104
 				},
105
-				array( 'is_safe' => array( 'all' ) )
105
+				array('is_safe' => array('all'))
106 106
 			);
107 107
 		}
108 108
 
@@ -116,15 +116,15 @@  discard block
 block discarded – undo
116 116
 	 *
117 117
 	 * @return bool|\Twig_SimpleFilter
118 118
 	 */
119
-	static function undefined_filter( $filter_name ) {
119
+	static function undefined_filter($filter_name) {
120 120
 
121 121
 		return new \Twig_SimpleFilter(
122 122
 			$filter_name,
123
-			function () use ( $filter_name ) {
123
+			function() use ($filter_name) {
124 124
 
125
-				return apply_filters( $filter_name, func_get_arg( 0 ) );
125
+				return apply_filters($filter_name, func_get_arg(0));
126 126
 			},
127
-			array( 'is_safe' => array( 'all' ) )
127
+			array('is_safe' => array('all'))
128 128
 		);
129 129
 	}
130 130
 
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 		/** @var Template_Hierarchy $hierarchy */
134 134
 		$hierarchy = $this['hierarchy'];
135 135
 		$hierarchy->enable();
136
-		add_filter( 'template_include', array( $this, 'template_include' ) );
137
-		add_filter( 'get_search_form', array( $this, 'get_search_form' ), 9 );
136
+		add_filter('template_include', array($this, 'template_include'));
137
+		add_filter('get_search_form', array($this, 'get_search_form'), 9);
138 138
 	}
139 139
 
140 140
 	public function disable() {
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
 		/** @var Template_Hierarchy $hierarchy */
143 143
 		$hierarchy = $this['hierarchy'];
144 144
 		$hierarchy->disable();
145
-		remove_filter( 'template_include', array( $this, 'template_include' ) );
146
-		remove_filter( 'get_search_form', array( $this, 'get_search_form' ), 9 );
145
+		remove_filter('template_include', array($this, 'template_include'));
146
+		remove_filter('get_search_form', array($this, 'get_search_form'), 9);
147 147
 	}
148 148
 
149 149
 	/**
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
 	 *
152 152
 	 * @return string|bool
153 153
 	 */
154
-	public function template_include( $template ) {
154
+	public function template_include($template) {
155 155
 
156
-		if ( '.twig' === substr( $template, - 5 ) ) {
156
+		if ('.twig' === substr($template, - 5)) {
157 157
 			/** @var \Twig_Environment $twig */
158 158
 			$twig = $this['twig.environment'];
159 159
 
160
-			echo $twig->render( basename( $template ), apply_filters( 'meadow_context', array() ) );
160
+			echo $twig->render(basename($template), apply_filters('meadow_context', array()));
161 161
 
162 162
 			return false;
163 163
 		}
@@ -170,14 +170,14 @@  discard block
 block discarded – undo
170 170
 	 *
171 171
 	 * @return string
172 172
 	 */
173
-	public function get_search_form( $form ) {
173
+	public function get_search_form($form) {
174 174
 
175 175
 		// because first time it's action
176
-		if ( ! empty( $form ) ) {
176
+		if ( ! empty($form)) {
177 177
 			/** @var \Twig_Environment $twig */
178 178
 			$twig = $this['twig.environment'];
179 179
 
180
-			return $twig->render( 'searchform.twig', array() );
180
+			return $twig->render('searchform.twig', array());
181 181
 		}
182 182
 
183 183
 		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
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.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
 		$options = array(
17 17
 			'needs_environment' => true,
18 18
 			'needs_context'     => true,
19
-			'is_safe'           => array( 'all' )
19
+			'is_safe'           => array('all')
20 20
 		);
21 21
 
22 22
 		$functions = array();
23 23
 
24
-		foreach ( array( 'get_header', 'get_footer', 'get_sidebar', 'get_template_part', 'get_search_form', 'comments_template' ) as $function ) {
25
-			$functions[] = new \Twig_SimpleFunction( $function, array( $this, $function ), $options );
24
+		foreach (array('get_header', 'get_footer', 'get_sidebar', 'get_template_part', 'get_search_form', 'comments_template') as $function) {
25
+			$functions[] = new \Twig_SimpleFunction($function, array($this, $function), $options);
26 26
 		}
27 27
 
28 28
 		return $functions;
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 
33 33
 		global $wp_query;
34 34
 
35
-		return compact( 'wp_query' );
35
+		return compact('wp_query');
36 36
 	}
37 37
 
38 38
 	public function getTokenParsers(  ) {
@@ -43,16 +43,16 @@  discard block
 block discarded – undo
43 43
 		);
44 44
 	}
45 45
 
46
-	public function get_header( \Twig_Environment $env, $context, $name = null ) {
46
+	public function get_header(\Twig_Environment $env, $context, $name = null) {
47 47
 
48
-		return $this->get_template( $env, $context, 'header', $name );
48
+		return $this->get_template($env, $context, 'header', $name);
49 49
 	}
50 50
 
51
-	public function get_templates( $slug, $name = null ) {
51
+	public function get_templates($slug, $name = null) {
52 52
 
53 53
 		$templates = array();
54 54
 
55
-		if ( ! empty( $name ) )
55
+		if ( ! empty($name))
56 56
 			$templates[] = "{$slug}-{$name}.twig";
57 57
 
58 58
 		$templates[] = "{$slug}.twig";
@@ -60,24 +60,24 @@  discard block
 block discarded – undo
60 60
 		return $templates;
61 61
 	}
62 62
 
63
-	public function get_footer( \Twig_Environment $env, $context, $name = null ) {
63
+	public function get_footer(\Twig_Environment $env, $context, $name = null) {
64 64
 
65
-		return $this->get_template( $env, $context, 'footer', $name );
65
+		return $this->get_template($env, $context, 'footer', $name);
66 66
 	}
67 67
 
68
-	public function get_sidebar( \Twig_Environment $env, $context, $name = null ) {
68
+	public function get_sidebar(\Twig_Environment $env, $context, $name = null) {
69 69
 
70
-		return $this->get_template( $env, $context, 'sidebar', $name );
70
+		return $this->get_template($env, $context, 'sidebar', $name);
71 71
 	}
72 72
 
73
-	public function get_template_part( \Twig_Environment $env, $context, $slug, $name = null ) {
73
+	public function get_template_part(\Twig_Environment $env, $context, $slug, $name = null) {
74 74
 
75 75
 		try {
76
-			$return = twig_include( $env, $context, $this->get_templates( $slug, $name ) );
77
-			do_action( "get_template_part_{$slug}", $slug, $name );
78
-		} catch ( \Twig_Error_Loader $e ) {
76
+			$return = twig_include($env, $context, $this->get_templates($slug, $name));
77
+			do_action("get_template_part_{$slug}", $slug, $name);
78
+		} catch (\Twig_Error_Loader $e) {
79 79
 			ob_start();
80
-			get_template_part( $slug, $name );
80
+			get_template_part($slug, $name);
81 81
 			$return = ob_get_clean();
82 82
 		}
83 83
 
@@ -91,39 +91,39 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public function get_search_form() {
93 93
 
94
-		return apply_filters( 'get_search_form', true );
94
+		return apply_filters('get_search_form', true);
95 95
 	}
96 96
 
97
-	protected function get_template( \Twig_Environment $env, $context, $type, $name = null ) {
97
+	protected function get_template(\Twig_Environment $env, $context, $type, $name = null) {
98 98
 
99 99
 		try {
100
-			$return = twig_include( $env, $context, $this->get_templates( $type, $name ) );
101
-			do_action( 'get_' . $type, $name );
102
-		} catch ( \Twig_Error_Loader $e ) {
100
+			$return = twig_include($env, $context, $this->get_templates($type, $name));
101
+			do_action('get_' . $type, $name);
102
+		} catch (\Twig_Error_Loader $e) {
103 103
 			ob_start();
104
-			call_user_func( 'get_' . $type, $name );
104
+			call_user_func('get_' . $type, $name);
105 105
 			$return = ob_get_clean();
106 106
 		}
107 107
 
108 108
 		return $return;
109 109
 	}
110 110
 
111
-	public function comments_template( \Twig_Environment $env, $context, $file = 'comments.twig', $separate_comments = false ) {
111
+	public function comments_template(\Twig_Environment $env, $context, $file = 'comments.twig', $separate_comments = false) {
112 112
 
113 113
 		try {
114
-			$env->loadTemplate( $file );
115
-		} catch ( \Twig_Error_Loader $e ) {
114
+			$env->loadTemplate($file);
115
+		} catch (\Twig_Error_Loader $e) {
116 116
 			ob_start();
117
-			comments_template( '/comments.php', $separate_comments );
117
+			comments_template('/comments.php', $separate_comments);
118 118
 
119 119
 			return ob_get_clean();
120 120
 		}
121 121
 
122
-		add_filter( 'comments_template', array( $this, 'return_blank_template' ) );
123
-		comments_template( '/comments.php', $separate_comments );
124
-		remove_filter( 'comments_template', array( $this, 'return_blank_template' ) );
122
+		add_filter('comments_template', array($this, 'return_blank_template'));
123
+		comments_template('/comments.php', $separate_comments);
124
+		remove_filter('comments_template', array($this, 'return_blank_template'));
125 125
 
126
-		return twig_include( $env, $context, $file );
126
+		return twig_include($env, $context, $file);
127 127
 	}
128 128
 
129 129
 	public function return_blank_template() {
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
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.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -34,39 +34,39 @@  discard block
 block discarded – undo
34 34
 
35 35
 	public function enable() {
36 36
 
37
-		add_action( 'template_redirect', array( $this, 'template_redirect' ) );
37
+		add_action('template_redirect', array($this, 'template_redirect'));
38 38
 
39
-		foreach ( $this->template_types as $type ) {
40
-			add_filter( "{$type}_template", array( $this, 'query_template' ) );
39
+		foreach ($this->template_types as $type) {
40
+			add_filter("{$type}_template", array($this, 'query_template'));
41 41
 		}
42 42
 	}
43 43
 
44 44
 	public function disable() {
45 45
 
46
-		remove_action( 'template_redirect', array( $this, 'template_redirect' ) );
46
+		remove_action('template_redirect', array($this, 'template_redirect'));
47 47
 
48
-		foreach ( $this->template_types as $type ) {
49
-			remove_filter( "{$type}_template", array( $this, 'query_template' ) );
48
+		foreach ($this->template_types as $type) {
49
+			remove_filter("{$type}_template", array($this, 'query_template'));
50 50
 		}
51 51
 
52
-		if ( ! empty($this->mime_type) ) {
53
-			remove_filter( "{$this->mime_type[0]}_template", array( $this, 'query_template' ) );
54
-			remove_filter( "{$this->mime_type[1]}_template", array( $this, 'query_template' ) );
55
-			remove_filter( "{$this->mime_type[0]}{$this->mime_type[1]}_template", array( $this, 'query_template' ) );
52
+		if ( ! empty($this->mime_type)) {
53
+			remove_filter("{$this->mime_type[0]}_template", array($this, 'query_template'));
54
+			remove_filter("{$this->mime_type[1]}_template", array($this, 'query_template'));
55
+			remove_filter("{$this->mime_type[0]}{$this->mime_type[1]}_template", array($this, 'query_template'));
56 56
 		}
57 57
 	}
58 58
 
59 59
 	public function template_redirect() {
60 60
 
61
-		if ( is_attachment() ) {
61
+		if (is_attachment()) {
62 62
 			global $posts;
63 63
 
64
-			if ( ! empty( $posts ) && isset( $posts[0]->post_mime_type ) )
65
-				$this->mime_type = explode( '/', $posts[0]->post_mime_type );
64
+			if ( ! empty($posts) && isset($posts[0]->post_mime_type))
65
+				$this->mime_type = explode('/', $posts[0]->post_mime_type);
66 66
 
67
-			add_filter( "{$this->mime_type[0]}_template", array( $this, 'query_template' ) );
68
-			add_filter( "{$this->mime_type[1]}_template", array( $this, 'query_template' ) );
69
-			add_filter( "{$this->mime_type[0]}{$this->mime_type[1]}_template", array( $this, 'query_template' ) );
67
+			add_filter("{$this->mime_type[0]}_template", array($this, 'query_template'));
68
+			add_filter("{$this->mime_type[1]}_template", array($this, 'query_template'));
69
+			add_filter("{$this->mime_type[0]}{$this->mime_type[1]}_template", array($this, 'query_template'));
70 70
 		}
71 71
 	}
72 72
 
@@ -75,21 +75,21 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @return string
77 77
 	 */
78
-	public function query_template( $fallback ) {
78
+	public function query_template($fallback) {
79 79
 
80
-		$type      = substr( current_filter(), 0, - 9 ); // trim '_template' from end
80
+		$type      = substr(current_filter(), 0, - 9); // trim '_template' from end
81 81
 		$templates = array();
82 82
 
83
-		switch ( $type ) {
83
+		switch ($type) {
84 84
 			case 'embed':
85 85
 
86 86
 				$object = get_queried_object();
87 87
 
88
-				if ( ! empty( $object->post_type ) ) {
88
+				if ( ! empty($object->post_type)) {
89 89
 
90
-					$post_format = get_post_format( $object );
90
+					$post_format = get_post_format($object);
91 91
 
92
-					if ( $post_format ) {
92
+					if ($post_format) {
93 93
 						$templates[] = "embed-{$object->post_type}-{$post_format}.twig";
94 94
 					}
95 95
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 			case 'taxonomy':
104 104
 				$term = get_queried_object();
105 105
 
106
-				if ( $term ) {
106
+				if ($term) {
107 107
 					$taxonomy    = $term->taxonomy;
108 108
 					$templates[] = "taxonomy-{$taxonomy}-{$term->slug}.twig";
109 109
 					$templates[] = "taxonomy-{$taxonomy}.twig";
@@ -113,17 +113,17 @@  discard block
 block discarded – undo
113 113
 				break;
114 114
 
115 115
 			case 'frontpage':
116
-				$templates = array( 'front-page.twig' );
116
+				$templates = array('front-page.twig');
117 117
 				break;
118 118
 
119 119
 			case 'home':
120
-				$templates = array( 'home.twig', 'index.twig' );
120
+				$templates = array('home.twig', 'index.twig');
121 121
 				break;
122 122
 
123 123
 			case 'single':
124 124
 				$object = get_queried_object();
125 125
 
126
-				if ( $object )
126
+				if ($object)
127 127
 					$templates[] = "single-{$object->post_type}.twig";
128 128
 
129 129
 				$templates[] = 'single.twig';
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
 			case 'page':
133 133
 				$page_id  = get_queried_object_id();
134 134
 //				$template = get_page_template_slug();
135
-				$pagename = get_query_var( 'pagename' );
135
+				$pagename = get_query_var('pagename');
136 136
 
137
-				if ( ! $pagename && $page_id ) {
137
+				if ( ! $pagename && $page_id) {
138 138
 					// If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object
139 139
 					$post     = get_queried_object();
140 140
 					$pagename = $post->post_name;
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
 //				if ( $template && 0 === validate_file( $template ) )
145 145
 //					$templates[] = $template;
146 146
 
147
-				if ( $pagename )
147
+				if ($pagename)
148 148
 					$templates[] = "page-{$pagename}.twig";
149 149
 
150
-				if ( $page_id )
150
+				if ($page_id)
151 151
 					$templates[] = "page-{$page_id}.twig";
152 152
 
153 153
 				$templates[] = 'page.twig';
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 			case 'tag':
158 158
 				$term = get_queried_object();
159 159
 
160
-				if ( $term ) {
160
+				if ($term) {
161 161
 					$templates[] = "{$type}-{$term->slug}.twig";
162 162
 					$templates[] = "{$type}-{$term->term_id}.twig";
163 163
 				}
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 			case 'author':
169 169
 				$author = get_queried_object();
170 170
 
171
-				if ( $author ) {
171
+				if ($author) {
172 172
 					$templates[] = "author-{$author->user_nicename}.twig";
173 173
 					$templates[] = "author-{$author->ID}.twig";
174 174
 				}
@@ -177,10 +177,10 @@  discard block
 block discarded – undo
177 177
 				break;
178 178
 
179 179
 			case 'archive':
180
-				$post_types = array_filter( (array) get_query_var( 'post_type' ) );
180
+				$post_types = array_filter((array) get_query_var('post_type'));
181 181
 
182
-				if ( count( $post_types ) == 1 ) {
183
-					$post_type   = reset( $post_types );
182
+				if (count($post_types) == 1) {
183
+					$post_type   = reset($post_types);
184 184
 					$templates[] = "archive-{$post_type}.twig";
185 185
 				}
186 186
 
@@ -188,16 +188,16 @@  discard block
 block discarded – undo
188 188
 				break;
189 189
 
190 190
 			default:
191
-				$templates = array( "{$type}.twig" );
191
+				$templates = array("{$type}.twig");
192 192
 		}
193 193
 
194
-		$template = $this->locate_template( $templates );
194
+		$template = $this->locate_template($templates);
195 195
 
196
-		if ( empty( $template ) ) {
196
+		if (empty($template)) {
197 197
 			$template = $fallback;
198 198
 		}
199 199
 
200
-		return apply_filters( 'meadow_query_template', $template, $type );
200
+		return apply_filters('meadow_query_template', $template, $type);
201 201
 	}
202 202
 
203 203
 	/**
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
 	 *
208 208
 	 * @return string
209 209
 	 */
210
-	public function locate_template( $templates ) {
210
+	public function locate_template($templates) {
211 211
 
212
-		return locate_template( $templates );
212
+		return locate_template($templates);
213 213
 	}
214 214
 }
Please login to merge, or discard this patch.
php/class-type-template-hierarchy.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -33,19 +33,19 @@  discard block
 block discarded – undo
33 33
 
34 34
 	public function enable() {
35 35
 
36
-		add_filter( 'template_include', array( $this, 'template_include' ), 9 );
36
+		add_filter('template_include', array($this, 'template_include'), 9);
37 37
 
38
-		foreach ( $this->template_types as $type ) {
39
-			add_filter( "{$type}_template_hierarchy", array( $this, 'template_hierarchy' ) );
38
+		foreach ($this->template_types as $type) {
39
+			add_filter("{$type}_template_hierarchy", array($this, 'template_hierarchy'));
40 40
 		}
41 41
 	}
42 42
 
43 43
 	public function disable() {
44 44
 
45
-		remove_filter( 'template_include', array( $this, 'template_include' ), 9 );
45
+		remove_filter('template_include', array($this, 'template_include'), 9);
46 46
 
47
-		foreach ( $this->template_types as $type ) {
48
-			remove_filter( "{$type}_template_hierarchy", array( $this, 'template_hierarchy' ) );
47
+		foreach ($this->template_types as $type) {
48
+			remove_filter("{$type}_template_hierarchy", array($this, 'template_hierarchy'));
49 49
 		}
50 50
 	}
51 51
 
@@ -54,21 +54,21 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @return string[] Array of templates, prepended with Twig versions.
56 56
 	 */
57
-	public function template_hierarchy( $templates ) {
57
+	public function template_hierarchy($templates) {
58 58
 
59
-		$this->type = substr( current_filter(), 0, - 19 ); // Trim '_template_hierarchy' from end.
59
+		$this->type = substr(current_filter(), 0, - 19); // Trim '_template_hierarchy' from end.
60 60
 
61 61
 		$twig_templates = [];
62 62
 
63
-		foreach ( $templates as $php_template ) {
63
+		foreach ($templates as $php_template) {
64 64
 
65
-			if ( '.php' === substr( $php_template, strlen( $php_template ) - 4 ) ) {
65
+			if ('.php' === substr($php_template, strlen($php_template) - 4)) {
66 66
 
67
-				$twig_templates[] = substr( $php_template, 0, - 4 ) . '.twig';
67
+				$twig_templates[] = substr($php_template, 0, - 4) . '.twig';
68 68
 			}
69 69
 		}
70 70
 
71
-		return array_merge( $twig_templates, $templates );
71
+		return array_merge($twig_templates, $templates);
72 72
 	}
73 73
 
74 74
 	/**
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @return string
78 78
 	 */
79
-	public function template_include( $template ) {
79
+	public function template_include($template) {
80 80
 
81
-		return apply_filters( 'meadow_query_template', $template, $this->type );
81
+		return apply_filters('meadow_query_template', $template, $this->type);
82 82
 	}
83 83
 }
Please login to merge, or discard this patch.