Completed
Branch master (55ca36)
by Andrey
01:42
created
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.
php/class-core.php 1 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.